mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 15:41:04 +00:00
c0dd845b39
Signed-off-by: xermicus <cyrill@parity.io>
32 lines
891 B
Rust
32 lines
891 B
Rust
//! Translates the comparison operations.
|
|
|
|
use inkwell::values::BasicValue;
|
|
|
|
use crate::polkavm::context::Context;
|
|
use crate::polkavm::Dependency;
|
|
|
|
/// Translates the comparison operations.
|
|
/// There is not difference between the EVM and LLVM IR behaviors.
|
|
pub fn compare<'ctx, D>(
|
|
context: &mut Context<'ctx, D>,
|
|
operand_1: inkwell::values::IntValue<'ctx>,
|
|
operand_2: inkwell::values::IntValue<'ctx>,
|
|
operation: inkwell::IntPredicate,
|
|
) -> anyhow::Result<inkwell::values::BasicValueEnum<'ctx>>
|
|
where
|
|
D: Dependency + Clone,
|
|
{
|
|
let result = context.builder().build_int_compare(
|
|
operation,
|
|
operand_1,
|
|
operand_2,
|
|
"comparison_result",
|
|
)?;
|
|
let result = context.builder().build_int_z_extend_or_bit_cast(
|
|
result,
|
|
context.word_type(),
|
|
"comparison_result_extended",
|
|
)?;
|
|
Ok(result.as_basic_value_enum())
|
|
}
|