diff options
| author | Mason Reed <mason@vector35.com> | 2025-07-04 16:44:24 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-07-04 16:44:24 -0400 |
| commit | b4d4a66337d4a8220f92710dc3c8895134c73cca (patch) | |
| tree | f404ad7d415092cb084429642c07dc59f5c2fd04 /rust/src/low_level_il | |
| parent | 88eba55a93f4f750ccdfe81575c91c59a73f3a8c (diff) | |
[Rust] Fix double precision expression low level IL definition
Diffstat (limited to 'rust/src/low_level_il')
| -rw-r--r-- | rust/src/low_level_il/expression.rs | 32 | ||||
| -rw-r--r-- | rust/src/low_level_il/operation.rs | 52 |
2 files changed, 8 insertions, 76 deletions
diff --git a/rust/src/low_level_il/expression.rs b/rust/src/low_level_il/expression.rs index d554e8b7..ecd850f9 100644 --- a/rust/src/low_level_il/expression.rs +++ b/rust/src/low_level_il/expression.rs @@ -301,14 +301,14 @@ where Divu(Operation<'func, M, F, operation::BinaryOp>), Divs(Operation<'func, M, F, operation::BinaryOp>), - DivuDp(Operation<'func, M, F, operation::DoublePrecDivOp>), - DivsDp(Operation<'func, M, F, operation::DoublePrecDivOp>), + DivuDp(Operation<'func, M, F, operation::BinaryOp>), + DivsDp(Operation<'func, M, F, operation::BinaryOp>), Modu(Operation<'func, M, F, operation::BinaryOp>), Mods(Operation<'func, M, F, operation::BinaryOp>), - ModuDp(Operation<'func, M, F, operation::DoublePrecDivOp>), - ModsDp(Operation<'func, M, F, operation::DoublePrecDivOp>), + ModuDp(Operation<'func, M, F, operation::BinaryOp>), + ModsDp(Operation<'func, M, F, operation::BinaryOp>), Neg(Operation<'func, M, F, operation::UnaryOp>), Not(Operation<'func, M, F, operation::UnaryOp>), @@ -538,7 +538,6 @@ where LowLevelILExpressionKind::UnimplMem(Operation::new(function, op, index)) } - // TODO: LLIL_REG_STACK_PUSH _ => { // #[cfg(debug_assertions)] log::error!( @@ -568,7 +567,6 @@ where } _ => Some(self.raw_struct().size), - //TestBit(Operation<'func, M, F, operation::TestBit>), // TODO } } @@ -607,7 +605,8 @@ where Add(ref op) | Sub(ref op) | And(ref op) | Or(ref op) | Xor(ref op) | Lsl(ref op) | Lsr(ref op) | Asr(ref op) | Rol(ref op) | Ror(ref op) | Mul(ref op) | MulsDp(ref op) | MuluDp(ref op) | Divu(ref op) | Divs(ref op) | Modu(ref op) - | Mods(ref op) | Fadd(ref op) | Fsub(ref op) | Fmul(ref op) | Fdiv(ref op) => Some(op), + | Mods(ref op) | Fadd(ref op) | Fsub(ref op) | Fmul(ref op) | Fdiv(ref op) + | DivuDp(ref op) | DivsDp(ref op) | ModuDp(ref op) | ModsDp(ref op) => Some(op), _ => None, } } @@ -621,17 +620,6 @@ where } } - pub fn as_double_prec_div_op( - &self, - ) -> Option<&Operation<'func, M, F, operation::DoublePrecDivOp>> { - use self::LowLevelILExpressionKind::*; - - match *self { - DivuDp(ref op) | DivsDp(ref op) | ModuDp(ref op) | ModsDp(ref op) => Some(op), - _ => None, - } - } - pub fn as_unary_op(&self) -> Option<&Operation<'func, M, F, operation::UnaryOp>> { use self::LowLevelILExpressionKind::*; @@ -675,15 +663,11 @@ where | Xor(ref op) | Lsl(ref op) | Lsr(ref op) | Asr(ref op) | Rol(ref op) | Ror(ref op) | Mul(ref op) | MulsDp(ref op) | MuluDp(ref op) | Divu(ref op) | Divs(ref op) | Modu(ref op) | Mods(ref op) | Fadd(ref op) | Fsub(ref op) | Fmul(ref op) - | Fdiv(ref op) | TestBit(ref op) => { + | DivuDp(ref op) | DivsDp(ref op) | ModuDp(ref op) | ModsDp(ref op) | Fdiv(ref op) + | TestBit(ref op) => { visit!(op.left()); visit!(op.right()); } - DivuDp(ref op) | DivsDp(ref op) | ModuDp(ref op) | ModsDp(ref op) => { - visit!(op.high()); - visit!(op.low()); - visit!(op.right()); - } Neg(ref op) | Not(ref op) | Sx(ref op) | Zx(ref op) | LowPart(ref op) | BoolToInt(ref op) | Fsqrt(ref op) | Fneg(ref op) | Fabs(ref op) | FloatToInt(ref op) | IntToFloat(ref op) | FloatConv(ref op) | RoundToInt(ref op) diff --git a/rust/src/low_level_il/operation.rs b/rust/src/low_level_il/operation.rs index e110c385..e74a8240 100644 --- a/rust/src/low_level_il/operation.rs +++ b/rust/src/low_level_il/operation.rs @@ -1893,57 +1893,6 @@ where } } -// LLIL_DIVS_DP, LLIL_DIVU_DP, LLIL_MODU_DP, LLIL_MODS_DP -pub struct DoublePrecDivOp; - -impl<'func, M, F> Operation<'func, M, F, DoublePrecDivOp> -where - M: FunctionMutability, - F: FunctionForm, -{ - pub fn size(&self) -> usize { - self.op.size - } - - pub fn high(&self) -> LowLevelILExpression<'func, M, F, ValueExpr> { - LowLevelILExpression::new( - self.function, - LowLevelExpressionIndex(self.op.operands[0] as usize), - ) - } - - pub fn low(&self) -> LowLevelILExpression<'func, M, F, ValueExpr> { - LowLevelILExpression::new( - self.function, - LowLevelExpressionIndex(self.op.operands[1] as usize), - ) - } - - // TODO: I don't think this actually exists? - pub fn right(&self) -> LowLevelILExpression<'func, M, F, ValueExpr> { - LowLevelILExpression::new( - self.function, - LowLevelExpressionIndex(self.op.operands[2] as usize), - ) - } -} - -impl<M, F> Debug for Operation<'_, M, F, DoublePrecDivOp> -where - M: FunctionMutability, - F: FunctionForm, -{ - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - f.debug_struct("DoublePrecDivOp") - .field("size", &self.size()) - .field("high", &self.high()) - .field("low", &self.low()) - // TODO: I don't think this actually is used... - .field("right", &self.right()) - .finish() - } -} - // LLIL_PUSH, LLIL_NEG, LLIL_NOT, LLIL_SX, // LLIL_ZX, LLIL_LOW_PART, LLIL_BOOL_TO_INT, LLIL_UNIMPL_MEM pub struct UnaryOp; @@ -2281,7 +2230,6 @@ impl OperationArguments for FloatConst {} impl OperationArguments for Extern {} impl OperationArguments for BinaryOp {} impl OperationArguments for BinaryOpCarry {} -impl OperationArguments for DoublePrecDivOp {} impl OperationArguments for UnaryOp {} impl OperationArguments for Condition {} impl OperationArguments for UnimplMem {} |
