summaryrefslogtreecommitdiff
path: root/rust/src/high_level_il
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2026-06-04 16:36:52 -0700
committerMark Rowe <mark@vector35.com>2026-06-05 13:01:46 -0700
commitfde1241ce928d38c2031c827ae0ddee5c6f5af0f (patch)
tree6711a47863332712eb5324e2c3ef1dffb843bb5d /rust/src/high_level_il
parentfa09f36b5f47ed690dc029fe9f1ed9ad4ebce7c8 (diff)
Add abs, min, and max instructions
Diffstat (limited to 'rust/src/high_level_il')
-rw-r--r--rust/src/high_level_il/instruction.rs29
-rw-r--r--rust/src/high_level_il/lift.rs15
2 files changed, 42 insertions, 2 deletions
diff --git a/rust/src/high_level_il/instruction.rs b/rust/src/high_level_il/instruction.rs
index 0fbbb297..8b675657 100644
--- a/rust/src/high_level_il/instruction.rs
+++ b/rust/src/high_level_il/instruction.rs
@@ -227,6 +227,22 @@ impl HighLevelILInstruction {
left: HighLevelExpressionIndex::from(op.operands[0]),
right: HighLevelExpressionIndex::from(op.operands[1]),
}),
+ HLIL_MINS => Op::MinSigned(BinaryOp {
+ left: HighLevelExpressionIndex::from(op.operands[0]),
+ right: HighLevelExpressionIndex::from(op.operands[1]),
+ }),
+ HLIL_MAXS => Op::MaxSigned(BinaryOp {
+ left: HighLevelExpressionIndex::from(op.operands[0]),
+ right: HighLevelExpressionIndex::from(op.operands[1]),
+ }),
+ HLIL_MINU => Op::MinUnsigned(BinaryOp {
+ left: HighLevelExpressionIndex::from(op.operands[0]),
+ right: HighLevelExpressionIndex::from(op.operands[1]),
+ }),
+ HLIL_MAXU => Op::MaxUnsigned(BinaryOp {
+ left: HighLevelExpressionIndex::from(op.operands[0]),
+ right: HighLevelExpressionIndex::from(op.operands[1]),
+ }),
HLIL_CMP_E => Op::CmpE(BinaryOp {
left: HighLevelExpressionIndex::from(op.operands[0]),
right: HighLevelExpressionIndex::from(op.operands[1]),
@@ -430,6 +446,9 @@ impl HighLevelILInstruction {
HLIL_CLS => Op::Cls(UnaryOp {
src: HighLevelExpressionIndex::from(op.operands[0]),
}),
+ HLIL_ABS => Op::Abs(UnaryOp {
+ src: HighLevelExpressionIndex::from(op.operands[0]),
+ }),
HLIL_SX => Op::Sx(UnaryOp {
src: HighLevelExpressionIndex::from(op.operands[0]),
}),
@@ -695,6 +714,10 @@ impl HighLevelILInstruction {
ModuDp(op) => Lifted::ModuDp(self.lift_binary_op(op)),
Mods(op) => Lifted::Mods(self.lift_binary_op(op)),
ModsDp(op) => Lifted::ModsDp(self.lift_binary_op(op)),
+ MinSigned(op) => Lifted::MinSigned(self.lift_binary_op(op)),
+ MaxSigned(op) => Lifted::MaxSigned(self.lift_binary_op(op)),
+ MinUnsigned(op) => Lifted::MinUnsigned(self.lift_binary_op(op)),
+ MaxUnsigned(op) => Lifted::MaxUnsigned(self.lift_binary_op(op)),
CmpE(op) => Lifted::CmpE(self.lift_binary_op(op)),
CmpNe(op) => Lifted::CmpNe(self.lift_binary_op(op)),
CmpSlt(op) => Lifted::CmpSlt(self.lift_binary_op(op)),
@@ -818,6 +841,7 @@ impl HighLevelILInstruction {
Ctz(op) => Lifted::Ctz(self.lift_unary_op(op)),
Rbit(op) => Lifted::Rbit(self.lift_unary_op(op)),
Cls(op) => Lifted::Cls(self.lift_unary_op(op)),
+ Abs(op) => Lifted::Abs(self.lift_unary_op(op)),
Sx(op) => Lifted::Sx(self.lift_unary_op(op)),
Zx(op) => Lifted::Zx(self.lift_unary_op(op)),
LowPart(op) => Lifted::LowPart(self.lift_unary_op(op)),
@@ -1152,6 +1176,10 @@ pub enum HighLevelILInstructionKind {
ModuDp(BinaryOp),
Mods(BinaryOp),
ModsDp(BinaryOp),
+ MinSigned(BinaryOp),
+ MaxSigned(BinaryOp),
+ MinUnsigned(BinaryOp),
+ MaxUnsigned(BinaryOp),
CmpE(BinaryOp),
CmpNe(BinaryOp),
CmpSlt(BinaryOp),
@@ -1203,6 +1231,7 @@ pub enum HighLevelILInstructionKind {
Ctz(UnaryOp),
Rbit(UnaryOp),
Cls(UnaryOp),
+ Abs(UnaryOp),
Sx(UnaryOp),
Zx(UnaryOp),
LowPart(UnaryOp),
diff --git a/rust/src/high_level_il/lift.rs b/rust/src/high_level_il/lift.rs
index 3d32b369..1de6248a 100644
--- a/rust/src/high_level_il/lift.rs
+++ b/rust/src/high_level_il/lift.rs
@@ -71,6 +71,10 @@ pub enum HighLevelILLiftedInstructionKind {
ModuDp(LiftedBinaryOp),
Mods(LiftedBinaryOp),
ModsDp(LiftedBinaryOp),
+ MinSigned(LiftedBinaryOp),
+ MaxSigned(LiftedBinaryOp),
+ MinUnsigned(LiftedBinaryOp),
+ MaxUnsigned(LiftedBinaryOp),
CmpE(LiftedBinaryOp),
CmpNe(LiftedBinaryOp),
CmpSlt(LiftedBinaryOp),
@@ -122,6 +126,7 @@ pub enum HighLevelILLiftedInstructionKind {
Ctz(LiftedUnaryOp),
Rbit(LiftedUnaryOp),
Cls(LiftedUnaryOp),
+ Abs(LiftedUnaryOp),
Sx(LiftedUnaryOp),
Zx(LiftedUnaryOp),
LowPart(LiftedUnaryOp),
@@ -207,6 +212,10 @@ impl HighLevelILLiftedInstruction {
ModuDp(_) => "ModuDp",
Mods(_) => "Mods",
ModsDp(_) => "ModsDp",
+ MinSigned(_) => "MinSigned",
+ MaxSigned(_) => "MaxSigned",
+ MinUnsigned(_) => "MinUnsigned",
+ MaxUnsigned(_) => "MaxUnsigned",
CmpE(_) => "CmpE",
CmpNe(_) => "CmpNe",
CmpSlt(_) => "CmpSlt",
@@ -258,6 +267,7 @@ impl HighLevelILLiftedInstruction {
Ctz(_) => "Ctz",
Rbit(_) => "Rbit",
Cls(_) => "Cls",
+ Abs(_) => "Abs",
Sx(_) => "Sx",
Zx(_) => "Zx",
LowPart(_) => "LowPart",
@@ -319,7 +329,8 @@ impl HighLevelILLiftedInstruction {
],
Add(op) | Sub(op) | And(op) | Or(op) | Xor(op) | Lsl(op) | Lsr(op) | Asr(op)
| Rol(op) | Ror(op) | Mul(op) | MuluDp(op) | MulsDp(op) | Divu(op) | DivuDp(op)
- | Divs(op) | DivsDp(op) | Modu(op) | ModuDp(op) | Mods(op) | ModsDp(op) | CmpE(op)
+ | Divs(op) | DivsDp(op) | Modu(op) | ModuDp(op) | Mods(op) | ModsDp(op)
+ | MinSigned(op) | MaxSigned(op) | MinUnsigned(op) | MaxUnsigned(op) | CmpE(op)
| CmpNe(op) | CmpSlt(op) | CmpUlt(op) | CmpSle(op) | CmpUle(op) | CmpSge(op)
| CmpUge(op) | CmpSgt(op) | CmpUgt(op) | TestBit(op) | AddOverflow(op) | Fadd(op)
| Fsub(op) | Fmul(op) | Fdiv(op) | FcmpE(op) | FcmpNe(op) | FcmpLt(op) | FcmpLe(op)
@@ -377,7 +388,7 @@ impl HighLevelILLiftedInstruction {
Operand::ConstantData(op.constant_data.clone()),
)],
Deref(op) | AddressOf(op) | PassByRef(op) | ReturnByRef(op) | Neg(op) | Not(op)
- | Bswap(op) | Popcnt(op) | Clz(op) | Ctz(op) | Rbit(op) | Cls(op)
+ | Bswap(op) | Popcnt(op) | Clz(op) | Ctz(op) | Rbit(op) | Cls(op) | Abs(op)
| Sx(op) | Zx(op) | LowPart(op) | BoolToInt(op) | UnimplMem(op) | Fsqrt(op)
| Fneg(op) | Fabs(op) | FloatToInt(op) | IntToFloat(op) | FloatConv(op)
| RoundToInt(op) | Floor(op) | Ceil(op) | Ftrunc(op) => {