Skip to content

Commit b4d4a66

Browse files
committed
[Rust] Fix double precision expression low level IL definition
1 parent 88eba55 commit b4d4a66

File tree

2 files changed

+8
-76
lines changed

2 files changed

+8
-76
lines changed

rust/src/low_level_il/expression.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ where
301301
Divu(Operation<'func, M, F, operation::BinaryOp>),
302302
Divs(Operation<'func, M, F, operation::BinaryOp>),
303303

304-
DivuDp(Operation<'func, M, F, operation::DoublePrecDivOp>),
305-
DivsDp(Operation<'func, M, F, operation::DoublePrecDivOp>),
304+
DivuDp(Operation<'func, M, F, operation::BinaryOp>),
305+
DivsDp(Operation<'func, M, F, operation::BinaryOp>),
306306

307307
Modu(Operation<'func, M, F, operation::BinaryOp>),
308308
Mods(Operation<'func, M, F, operation::BinaryOp>),
309309

310-
ModuDp(Operation<'func, M, F, operation::DoublePrecDivOp>),
311-
ModsDp(Operation<'func, M, F, operation::DoublePrecDivOp>),
310+
ModuDp(Operation<'func, M, F, operation::BinaryOp>),
311+
ModsDp(Operation<'func, M, F, operation::BinaryOp>),
312312

313313
Neg(Operation<'func, M, F, operation::UnaryOp>),
314314
Not(Operation<'func, M, F, operation::UnaryOp>),
@@ -538,7 +538,6 @@ where
538538
LowLevelILExpressionKind::UnimplMem(Operation::new(function, op, index))
539539
}
540540

541-
// TODO: LLIL_REG_STACK_PUSH
542541
_ => {
543542
// #[cfg(debug_assertions)]
544543
log::error!(
@@ -568,7 +567,6 @@ where
568567
}
569568

570569
_ => Some(self.raw_struct().size),
571-
//TestBit(Operation<'func, M, F, operation::TestBit>), // TODO
572570
}
573571
}
574572

@@ -607,7 +605,8 @@ where
607605
Add(ref op) | Sub(ref op) | And(ref op) | Or(ref op) | Xor(ref op) | Lsl(ref op)
608606
| Lsr(ref op) | Asr(ref op) | Rol(ref op) | Ror(ref op) | Mul(ref op)
609607
| MulsDp(ref op) | MuluDp(ref op) | Divu(ref op) | Divs(ref op) | Modu(ref op)
610-
| Mods(ref op) | Fadd(ref op) | Fsub(ref op) | Fmul(ref op) | Fdiv(ref op) => Some(op),
608+
| Mods(ref op) | Fadd(ref op) | Fsub(ref op) | Fmul(ref op) | Fdiv(ref op)
609+
| DivuDp(ref op) | DivsDp(ref op) | ModuDp(ref op) | ModsDp(ref op) => Some(op),
611610
_ => None,
612611
}
613612
}
@@ -621,17 +620,6 @@ where
621620
}
622621
}
623622

624-
pub fn as_double_prec_div_op(
625-
&self,
626-
) -> Option<&Operation<'func, M, F, operation::DoublePrecDivOp>> {
627-
use self::LowLevelILExpressionKind::*;
628-
629-
match *self {
630-
DivuDp(ref op) | DivsDp(ref op) | ModuDp(ref op) | ModsDp(ref op) => Some(op),
631-
_ => None,
632-
}
633-
}
634-
635623
pub fn as_unary_op(&self) -> Option<&Operation<'func, M, F, operation::UnaryOp>> {
636624
use self::LowLevelILExpressionKind::*;
637625

@@ -675,15 +663,11 @@ where
675663
| Xor(ref op) | Lsl(ref op) | Lsr(ref op) | Asr(ref op) | Rol(ref op) | Ror(ref op)
676664
| Mul(ref op) | MulsDp(ref op) | MuluDp(ref op) | Divu(ref op) | Divs(ref op)
677665
| Modu(ref op) | Mods(ref op) | Fadd(ref op) | Fsub(ref op) | Fmul(ref op)
678-
| Fdiv(ref op) | TestBit(ref op) => {
666+
| DivuDp(ref op) | DivsDp(ref op) | ModuDp(ref op) | ModsDp(ref op) | Fdiv(ref op)
667+
| TestBit(ref op) => {
679668
visit!(op.left());
680669
visit!(op.right());
681670
}
682-
DivuDp(ref op) | DivsDp(ref op) | ModuDp(ref op) | ModsDp(ref op) => {
683-
visit!(op.high());
684-
visit!(op.low());
685-
visit!(op.right());
686-
}
687671
Neg(ref op) | Not(ref op) | Sx(ref op) | Zx(ref op) | LowPart(ref op)
688672
| BoolToInt(ref op) | Fsqrt(ref op) | Fneg(ref op) | Fabs(ref op)
689673
| FloatToInt(ref op) | IntToFloat(ref op) | FloatConv(ref op) | RoundToInt(ref op)

rust/src/low_level_il/operation.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,57 +1893,6 @@ where
18931893
}
18941894
}
18951895

1896-
// LLIL_DIVS_DP, LLIL_DIVU_DP, LLIL_MODU_DP, LLIL_MODS_DP
1897-
pub struct DoublePrecDivOp;
1898-
1899-
impl<'func, M, F> Operation<'func, M, F, DoublePrecDivOp>
1900-
where
1901-
M: FunctionMutability,
1902-
F: FunctionForm,
1903-
{
1904-
pub fn size(&self) -> usize {
1905-
self.op.size
1906-
}
1907-
1908-
pub fn high(&self) -> LowLevelILExpression<'func, M, F, ValueExpr> {
1909-
LowLevelILExpression::new(
1910-
self.function,
1911-
LowLevelExpressionIndex(self.op.operands[0] as usize),
1912-
)
1913-
}
1914-
1915-
pub fn low(&self) -> LowLevelILExpression<'func, M, F, ValueExpr> {
1916-
LowLevelILExpression::new(
1917-
self.function,
1918-
LowLevelExpressionIndex(self.op.operands[1] as usize),
1919-
)
1920-
}
1921-
1922-
// TODO: I don't think this actually exists?
1923-
pub fn right(&self) -> LowLevelILExpression<'func, M, F, ValueExpr> {
1924-
LowLevelILExpression::new(
1925-
self.function,
1926-
LowLevelExpressionIndex(self.op.operands[2] as usize),
1927-
)
1928-
}
1929-
}
1930-
1931-
impl<M, F> Debug for Operation<'_, M, F, DoublePrecDivOp>
1932-
where
1933-
M: FunctionMutability,
1934-
F: FunctionForm,
1935-
{
1936-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1937-
f.debug_struct("DoublePrecDivOp")
1938-
.field("size", &self.size())
1939-
.field("high", &self.high())
1940-
.field("low", &self.low())
1941-
// TODO: I don't think this actually is used...
1942-
.field("right", &self.right())
1943-
.finish()
1944-
}
1945-
}
1946-
19471896
// LLIL_PUSH, LLIL_NEG, LLIL_NOT, LLIL_SX,
19481897
// LLIL_ZX, LLIL_LOW_PART, LLIL_BOOL_TO_INT, LLIL_UNIMPL_MEM
19491898
pub struct UnaryOp;
@@ -2281,7 +2230,6 @@ impl OperationArguments for FloatConst {}
22812230
impl OperationArguments for Extern {}
22822231
impl OperationArguments for BinaryOp {}
22832232
impl OperationArguments for BinaryOpCarry {}
2284-
impl OperationArguments for DoublePrecDivOp {}
22852233
impl OperationArguments for UnaryOp {}
22862234
impl OperationArguments for Condition {}
22872235
impl OperationArguments for UnimplMem {}

0 commit comments

Comments
 (0)