summaryrefslogtreecommitdiff
path: root/rust/src/high_level_il
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2026-06-03 21:25:55 -0700
committerMark Rowe <mark@vector35.com>2026-06-04 14:31:09 -0700
commitd592ed6dafbb134553bf3a0b8ee70ff7f2049aba (patch)
tree1bfe7e335e5b4e21371cde4bf8858c6439bc3f18 /rust/src/high_level_il
parent9987102015875991813200116558306851763009 (diff)
Add bswap, popcnt, clz, ctz, cls, and rbit instructions
Diffstat (limited to 'rust/src/high_level_il')
-rw-r--r--rust/src/high_level_il/instruction.rs30
-rw-r--r--rust/src/high_level_il/lift.rs13
2 files changed, 43 insertions, 0 deletions
diff --git a/rust/src/high_level_il/instruction.rs b/rust/src/high_level_il/instruction.rs
index 98839cae..0fbbb297 100644
--- a/rust/src/high_level_il/instruction.rs
+++ b/rust/src/high_level_il/instruction.rs
@@ -412,6 +412,24 @@ impl HighLevelILInstruction {
HLIL_NOT => Op::Not(UnaryOp {
src: HighLevelExpressionIndex::from(op.operands[0]),
}),
+ HLIL_BSWAP => Op::Bswap(UnaryOp {
+ src: HighLevelExpressionIndex::from(op.operands[0]),
+ }),
+ HLIL_POPCNT => Op::Popcnt(UnaryOp {
+ src: HighLevelExpressionIndex::from(op.operands[0]),
+ }),
+ HLIL_CLZ => Op::Clz(UnaryOp {
+ src: HighLevelExpressionIndex::from(op.operands[0]),
+ }),
+ HLIL_CTZ => Op::Ctz(UnaryOp {
+ src: HighLevelExpressionIndex::from(op.operands[0]),
+ }),
+ HLIL_RBIT => Op::Rbit(UnaryOp {
+ src: HighLevelExpressionIndex::from(op.operands[0]),
+ }),
+ HLIL_CLS => Op::Cls(UnaryOp {
+ src: HighLevelExpressionIndex::from(op.operands[0]),
+ }),
HLIL_SX => Op::Sx(UnaryOp {
src: HighLevelExpressionIndex::from(op.operands[0]),
}),
@@ -794,6 +812,12 @@ impl HighLevelILInstruction {
ReturnByRef(op) => Lifted::ReturnByRef(self.lift_unary_op(op)),
Neg(op) => Lifted::Neg(self.lift_unary_op(op)),
Not(op) => Lifted::Not(self.lift_unary_op(op)),
+ Bswap(op) => Lifted::Bswap(self.lift_unary_op(op)),
+ Popcnt(op) => Lifted::Popcnt(self.lift_unary_op(op)),
+ Clz(op) => Lifted::Clz(self.lift_unary_op(op)),
+ 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)),
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)),
@@ -1173,6 +1197,12 @@ pub enum HighLevelILInstructionKind {
ReturnByRef(UnaryOp),
Neg(UnaryOp),
Not(UnaryOp),
+ Bswap(UnaryOp),
+ Popcnt(UnaryOp),
+ Clz(UnaryOp),
+ Ctz(UnaryOp),
+ Rbit(UnaryOp),
+ Cls(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 e2ce3686..3d32b369 100644
--- a/rust/src/high_level_il/lift.rs
+++ b/rust/src/high_level_il/lift.rs
@@ -116,6 +116,12 @@ pub enum HighLevelILLiftedInstructionKind {
ReturnByRef(LiftedUnaryOp),
Neg(LiftedUnaryOp),
Not(LiftedUnaryOp),
+ Bswap(LiftedUnaryOp),
+ Popcnt(LiftedUnaryOp),
+ Clz(LiftedUnaryOp),
+ Ctz(LiftedUnaryOp),
+ Rbit(LiftedUnaryOp),
+ Cls(LiftedUnaryOp),
Sx(LiftedUnaryOp),
Zx(LiftedUnaryOp),
LowPart(LiftedUnaryOp),
@@ -246,6 +252,12 @@ impl HighLevelILLiftedInstruction {
ReturnByRef(_) => "ReturnByRef",
Neg(_) => "Neg",
Not(_) => "Not",
+ Bswap(_) => "Bswap",
+ Popcnt(_) => "Popcnt",
+ Clz(_) => "Clz",
+ Ctz(_) => "Ctz",
+ Rbit(_) => "Rbit",
+ Cls(_) => "Cls",
Sx(_) => "Sx",
Zx(_) => "Zx",
LowPart(_) => "LowPart",
@@ -365,6 +377,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)
| 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) => {