summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorMichael Krasnitski <michael.krasnitski@gmail.com>2024-02-07 13:15:34 -0500
committerKyle Martin <krm504@nyu.edu>2024-03-18 17:46:37 -0400
commitb6897fab3eddcb94ebae211913253246f0407377 (patch)
treefd8bb3918a505b799a76ada02aa7e227ccdea760 /rust/src
parent5fcf6bc59ebc2110d053360d223e6570cdd2272c (diff)
Instantiate `MediumLevelILInstruction` inline and remove constructors
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/mlil/instruction.rs965
-rw-r--r--rust/src/mlil/operation.rs437
2 files changed, 529 insertions, 873 deletions
diff --git a/rust/src/mlil/instruction.rs b/rust/src/mlil/instruction.rs
index 50154f34..816065a5 100644
--- a/rust/src/mlil/instruction.rs
+++ b/rust/src/mlil/instruction.rs
@@ -171,446 +171,531 @@ impl MediumLevelILInstruction {
MLIL_BP => Op::Bp,
MLIL_UNDEF => Op::Undef,
MLIL_UNIMPL => Op::Unimpl,
- MLIL_IF => Op::If(MediumLevelILOperationIf::new(
- op.operands[0] as usize,
- op.operands[1],
- op.operands[2],
- )),
- MLIL_FLOAT_CONST => Op::FloatConst(FloatConst::new(op.operands[0], op.size)),
- MLIL_CONST => Op::Const(Constant::new(op.operands[0])),
- MLIL_CONST_PTR => Op::ConstPtr(Constant::new(op.operands[0])),
- MLIL_IMPORT => Op::Import(Constant::new(op.operands[0])),
- MLIL_EXTERN_PTR => Op::ExternPtr(ExternPtr::new(op.operands[0], op.operands[1])),
- MLIL_CONST_DATA => Op::ConstData(ConstantData::new(
- op.operands[0] as u32,
- op.operands[1] as i64,
- op.size,
- )),
- MLIL_JUMP => Op::Jump(Jump::new(op.operands[0] as usize)),
- MLIL_RET_HINT => Op::RetHint(Jump::new(op.operands[0] as usize)),
- MLIL_STORE_SSA => Op::StoreSsa(StoreSsa::new(
- op.operands[0] as usize,
- op.operands[1],
- op.operands[2],
- op.operands[3] as usize,
- )),
- MLIL_STORE_STRUCT_SSA => Op::StoreStructSsa(StoreStructSsa::new(
- op.operands[0] as usize,
- op.operands[1],
- op.operands[2],
- op.operands[3],
- op.operands[4] as usize,
- )),
- MLIL_STORE_STRUCT => Op::StoreStruct(StoreStruct::new(
- op.operands[0] as usize,
- op.operands[1],
- op.operands[2] as usize,
- )),
- MLIL_STORE => Op::Store(Store::new(op.operands[0] as usize, op.operands[1] as usize)),
- MLIL_JUMP_TO => Op::JumpTo(JumpTo::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- )),
- MLIL_GOTO => Op::Goto(Goto::new(op.operands[0])),
- MLIL_FREE_VAR_SLOT => Op::FreeVarSlot(FreeVarSlot::new(op.operands[0])),
- MLIL_SET_VAR_FIELD => Op::SetVarField(SetVarField::new(
- op.operands[0],
- op.operands[1],
- op.operands[2] as usize,
- )),
- MLIL_SET_VAR => Op::SetVar(SetVar::new(op.operands[0], op.operands[1] as usize)),
- MLIL_FREE_VAR_SLOT_SSA => Op::FreeVarSlotSsa(FreeVarSlotSsa::new(
- (op.operands[0], op.operands[1] as usize),
- (op.operands[0], op.operands[2] as usize),
- )),
- MLIL_SET_VAR_SSA_FIELD => Op::SetVarSsaField(SetVarSsaField::new(
- (op.operands[0], op.operands[1] as usize),
- (op.operands[0], op.operands[2] as usize),
- op.operands[3],
- op.operands[4] as usize,
- )),
- MLIL_SET_VAR_ALIASED_FIELD => Op::SetVarAliasedField(SetVarSsaField::new(
- (op.operands[0], op.operands[1] as usize),
- (op.operands[0], op.operands[2] as usize),
- op.operands[3],
- op.operands[4] as usize,
- )),
- MLIL_SET_VAR_ALIASED => Op::SetVarAliased(SetVarAliased::new(
- (op.operands[0], op.operands[1] as usize),
- (op.operands[0], op.operands[2] as usize),
- op.operands[3] as usize,
- )),
- MLIL_SET_VAR_SSA => Op::SetVarSsa(SetVarSsa::new(
- (op.operands[0], op.operands[1] as usize),
- op.operands[2] as usize,
- )),
- MLIL_VAR_PHI => Op::VarPhi(VarPhi::new(
- (op.operands[0], op.operands[1] as usize),
- op.operands[2] as usize,
- op.operands[3] as usize,
- )),
- MLIL_MEM_PHI => Op::MemPhi(MemPhi::new(
- op.operands[0],
- op.operands[1] as usize,
- op.operands[2] as usize,
- )),
- MLIL_VAR_SPLIT => Op::VarSplit(VarSplit::new(op.operands[0], op.operands[1])),
- MLIL_SET_VAR_SPLIT => Op::SetVarSplit(SetVarSplit::new(
- op.operands[0],
- op.operands[1],
- op.operands[2] as usize,
- )),
- MLIL_VAR_SPLIT_SSA => Op::VarSplitSsa(VarSplitSsa::new(
- (op.operands[0], op.operands[1] as usize),
- (op.operands[2], op.operands[3] as usize),
- )),
- MLIL_SET_VAR_SPLIT_SSA => Op::SetVarSplitSsa(SetVarSplitSsa::new(
- (op.operands[0], op.operands[1] as usize),
- (op.operands[2], op.operands[3] as usize),
- op.operands[4] as usize,
- )),
- MLIL_ADD => Op::Add(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_SUB => Op::Sub(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_AND => Op::And(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_OR => Op::Or(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_XOR => Op::Xor(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_LSL => Op::Lsl(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_LSR => Op::Lsr(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_ASR => Op::Asr(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_ROL => Op::Rol(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_ROR => Op::Ror(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_MUL => Op::Mul(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_MULU_DP => Op::MuluDp(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_MULS_DP => Op::MulsDp(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_DIVU => Op::Divu(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_DIVU_DP => Op::DivuDp(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_DIVS => Op::Divs(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_DIVS_DP => Op::DivsDp(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_MODU => Op::Modu(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_MODU_DP => Op::ModuDp(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_MODS => Op::Mods(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_MODS_DP => Op::ModsDp(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_E => Op::CmpE(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_NE => Op::CmpNe(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_SLT => Op::CmpSlt(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_ULT => Op::CmpUlt(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_SLE => Op::CmpSle(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_ULE => Op::CmpUle(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_SGE => Op::CmpSge(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_UGE => Op::CmpUge(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_SGT => Op::CmpSgt(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_CMP_UGT => Op::CmpUgt(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_TEST_BIT => Op::TestBit(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_ADD_OVERFLOW => Op::AddOverflow(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FCMP_E => Op::FcmpE(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FCMP_NE => Op::FcmpNe(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FCMP_LT => Op::FcmpLt(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FCMP_LE => Op::FcmpLe(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FCMP_GE => Op::FcmpGe(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FCMP_GT => Op::FcmpGt(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FCMP_O => Op::FcmpO(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FCMP_UO => Op::FcmpUo(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FADD => Op::Fadd(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FSUB => Op::Fsub(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FMUL => Op::Fmul(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_FDIV => Op::Fdiv(BinaryOp::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_ADC => Op::Adc(BinaryOpCarry::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- )),
- MLIL_SBB => Op::Sbb(BinaryOpCarry::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- )),
- MLIL_RLC => Op::Rlc(BinaryOpCarry::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- )),
- MLIL_RRC => Op::Rrc(BinaryOpCarry::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- )),
- MLIL_CALL => Op::Call(Call::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- op.operands[4] as usize,
- )),
- MLIL_TAILCALL => Op::Tailcall(Call::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- op.operands[4] as usize,
- )),
- MLIL_SYSCALL => Op::Syscall(Syscall::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- )),
- MLIL_INTRINSIC => Op::Intrinsic(Intrinsic::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as u32,
- op.operands[3] as usize,
- op.operands[4] as usize,
- )),
- MLIL_INTRINSIC_SSA => Op::IntrinsicSsa(IntrinsicSsa::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as u32,
- op.operands[3] as usize,
- op.operands[4] as usize,
- )),
- MLIL_CALL_SSA => Op::CallSsa(CallSsa::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- op.operands[4],
- )),
- MLIL_TAILCALL_SSA => Op::TailcallSsa(CallSsa::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- op.operands[4],
- )),
- MLIL_CALL_UNTYPED_SSA => Op::CallUntypedSsa(CallUntypedSsa::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- )),
- MLIL_TAILCALL_UNTYPED_SSA => Op::TailcallUntypedSsa(CallUntypedSsa::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- )),
- MLIL_SYSCALL_SSA => Op::SyscallSsa(SyscallSsa::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3],
- )),
- MLIL_SYSCALL_UNTYPED_SSA => Op::SyscallUntypedSsa(SyscallUntypedSsa::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- )),
- MLIL_CALL_UNTYPED => Op::CallUntyped(CallUntyped::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- )),
- MLIL_TAILCALL_UNTYPED => Op::TailcallUntyped(CallUntyped::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- op.operands[3] as usize,
- )),
- MLIL_SYSCALL_UNTYPED => Op::SyscallUntyped(SyscallUntyped::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- op.operands[2] as usize,
- )),
- MLIL_NEG => Op::Neg(UnaryOp::new(op.operands[0] as usize)),
- MLIL_NOT => Op::Not(UnaryOp::new(op.operands[0] as usize)),
- MLIL_SX => Op::Sx(UnaryOp::new(op.operands[0] as usize)),
- MLIL_ZX => Op::Zx(UnaryOp::new(op.operands[0] as usize)),
- MLIL_LOW_PART => Op::LowPart(UnaryOp::new(op.operands[0] as usize)),
- MLIL_BOOL_TO_INT => Op::BoolToInt(UnaryOp::new(op.operands[0] as usize)),
- MLIL_UNIMPL_MEM => Op::UnimplMem(UnaryOp::new(op.operands[0] as usize)),
- MLIL_FSQRT => Op::Fsqrt(UnaryOp::new(op.operands[0] as usize)),
- MLIL_FNEG => Op::Fneg(UnaryOp::new(op.operands[0] as usize)),
- MLIL_FABS => Op::Fabs(UnaryOp::new(op.operands[0] as usize)),
- MLIL_FLOAT_TO_INT => Op::FloatToInt(UnaryOp::new(op.operands[0] as usize)),
- MLIL_INT_TO_FLOAT => Op::IntToFloat(UnaryOp::new(op.operands[0] as usize)),
- MLIL_FLOAT_CONV => Op::FloatConv(UnaryOp::new(op.operands[0] as usize)),
- MLIL_ROUND_TO_INT => Op::RoundToInt(UnaryOp::new(op.operands[0] as usize)),
- MLIL_FLOOR => Op::Floor(UnaryOp::new(op.operands[0] as usize)),
- MLIL_CEIL => Op::Ceil(UnaryOp::new(op.operands[0] as usize)),
- MLIL_FTRUNC => Op::Ftrunc(UnaryOp::new(op.operands[0] as usize)),
- MLIL_LOAD => Op::Load(UnaryOp::new(op.operands[0] as usize)),
- MLIL_LOAD_STRUCT => {
- Op::LoadStruct(LoadStruct::new(op.operands[0] as usize, op.operands[1]))
- }
- MLIL_LOAD_STRUCT_SSA => Op::LoadStructSsa(LoadStructSsa::new(
- op.operands[0] as usize,
- op.operands[1],
- op.operands[2],
- )),
- MLIL_LOAD_SSA => Op::LoadSsa(LoadSsa::new(op.operands[0] as usize, op.operands[1])),
- MLIL_RET => Op::Ret(Ret::new(op.operands[0] as usize, op.operands[1] as usize)),
- MLIL_SEPARATE_PARAM_LIST => Op::SeparateParamList(SeparateParamList::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_SHARED_PARAM_SLOT => Op::SharedParamSlot(SharedParamSlot::new(
- op.operands[0] as usize,
- op.operands[1] as usize,
- )),
- MLIL_VAR => Op::Var(Var::new(op.operands[0])),
- MLIL_ADDRESS_OF => Op::AddressOf(Var::new(op.operands[0])),
- MLIL_VAR_FIELD => Op::VarField(Field::new(op.operands[0], op.operands[1])),
- MLIL_ADDRESS_OF_FIELD => Op::AddressOfField(Field::new(op.operands[0], op.operands[1])),
- MLIL_VAR_SSA => Op::VarSsa(VarSsa::new((op.operands[0], op.operands[1] as usize))),
- MLIL_VAR_ALIASED => {
- Op::VarAliased(VarSsa::new((op.operands[0], op.operands[1] as usize)))
- }
- MLIL_VAR_SSA_FIELD => Op::VarSsaField(VarSsaField::new(
- (op.operands[0], op.operands[1] as usize),
- op.operands[2],
- )),
- MLIL_VAR_ALIASED_FIELD => Op::VarAliasedField(VarSsaField::new(
- (op.operands[0], op.operands[1] as usize),
- op.operands[2],
- )),
- MLIL_TRAP => Op::Trap(Trap::new(op.operands[0])),
+ MLIL_IF => Op::If(MediumLevelILOperationIf {
+ condition: op.operands[0] as usize,
+ dest_true: op.operands[1],
+ dest_false: op.operands[2],
+ }),
+ MLIL_FLOAT_CONST => Op::FloatConst(FloatConst {
+ constant: get_float(op.operands[0], op.size),
+ }),
+ MLIL_CONST => Op::Const(Constant {
+ constant: op.operands[0],
+ }),
+ MLIL_CONST_PTR => Op::ConstPtr(Constant {
+ constant: op.operands[0],
+ }),
+ MLIL_IMPORT => Op::Import(Constant {
+ constant: op.operands[0],
+ }),
+ MLIL_EXTERN_PTR => Op::ExternPtr(ExternPtr {
+ constant: op.operands[0],
+ offset: op.operands[1],
+ }),
+ MLIL_CONST_DATA => Op::ConstData(ConstantData {
+ constant_data_kind: op.operands[0] as u32,
+ constant_data_value: op.operands[1] as i64,
+ size: op.size,
+ }),
+ MLIL_JUMP => Op::Jump(Jump {
+ dest: op.operands[0] as usize,
+ }),
+ MLIL_RET_HINT => Op::RetHint(Jump {
+ dest: op.operands[0] as usize,
+ }),
+ MLIL_STORE_SSA => Op::StoreSsa(StoreSsa {
+ dest: op.operands[0] as usize,
+ dest_memory: op.operands[1],
+ src_memory: op.operands[2],
+ src: op.operands[3] as usize,
+ }),
+ MLIL_STORE_STRUCT_SSA => Op::StoreStructSsa(StoreStructSsa {
+ dest: op.operands[0] as usize,
+ offset: op.operands[1],
+ dest_memory: op.operands[2],
+ src_memory: op.operands[3],
+ src: op.operands[4] as usize,
+ }),
+ MLIL_STORE_STRUCT => Op::StoreStruct(StoreStruct {
+ dest: op.operands[0] as usize,
+ offset: op.operands[1],
+ src: op.operands[2] as usize,
+ }),
+ MLIL_STORE => Op::Store(Store {
+ dest: op.operands[0] as usize,
+ src: op.operands[1] as usize,
+ }),
+ MLIL_JUMP_TO => Op::JumpTo(JumpTo {
+ dest: op.operands[0] as usize,
+ num_operands: op.operands[1] as usize,
+ first_operand: op.operands[2] as usize,
+ }),
+ MLIL_GOTO => Op::Goto(Goto {
+ dest: op.operands[0],
+ }),
+ MLIL_FREE_VAR_SLOT => Op::FreeVarSlot(FreeVarSlot {
+ dest: get_var(op.operands[0]),
+ }),
+ MLIL_SET_VAR_FIELD => Op::SetVarField(SetVarField {
+ dest: get_var(op.operands[0]),
+ offset: op.operands[1],
+ src: op.operands[2] as usize,
+ }),
+ MLIL_SET_VAR => Op::SetVar(SetVar {
+ dest: get_var(op.operands[0]),
+ src: op.operands[1] as usize,
+ }),
+ MLIL_FREE_VAR_SLOT_SSA => Op::FreeVarSlotSsa(FreeVarSlotSsa {
+ dest: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ prev: get_var_ssa(op.operands[0], op.operands[2] as usize),
+ }),
+ MLIL_SET_VAR_SSA_FIELD => Op::SetVarSsaField(SetVarSsaField {
+ dest: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ prev: get_var_ssa(op.operands[0], op.operands[2] as usize),
+ offset: op.operands[3],
+ src: op.operands[4] as usize,
+ }),
+ MLIL_SET_VAR_ALIASED_FIELD => Op::SetVarAliasedField(SetVarSsaField {
+ dest: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ prev: get_var_ssa(op.operands[0], op.operands[2] as usize),
+ offset: op.operands[3],
+ src: op.operands[4] as usize,
+ }),
+ MLIL_SET_VAR_ALIASED => Op::SetVarAliased(SetVarAliased {
+ dest: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ prev: get_var_ssa(op.operands[0], op.operands[2] as usize),
+ src: op.operands[3] as usize,
+ }),
+ MLIL_SET_VAR_SSA => Op::SetVarSsa(SetVarSsa {
+ dest: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ src: op.operands[2] as usize,
+ }),
+ MLIL_VAR_PHI => Op::VarPhi(VarPhi {
+ dest: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ num_operands: op.operands[2] as usize,
+ first_operand: op.operands[3] as usize,
+ }),
+ MLIL_MEM_PHI => Op::MemPhi(MemPhi {
+ dest_memory: op.operands[0],
+ num_operands: op.operands[1] as usize,
+ first_operand: op.operands[2] as usize,
+ }),
+ MLIL_VAR_SPLIT => Op::VarSplit(VarSplit {
+ high: get_var(op.operands[0]),
+ low: get_var(op.operands[1]),
+ }),
+ MLIL_SET_VAR_SPLIT => Op::SetVarSplit(SetVarSplit {
+ high: get_var(op.operands[0]),
+ low: get_var(op.operands[1]),
+ src: op.operands[2] as usize,
+ }),
+ MLIL_VAR_SPLIT_SSA => Op::VarSplitSsa(VarSplitSsa {
+ high: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ low: get_var_ssa(op.operands[2], op.operands[3] as usize),
+ }),
+ MLIL_SET_VAR_SPLIT_SSA => Op::SetVarSplitSsa(SetVarSplitSsa {
+ high: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ low: get_var_ssa(op.operands[2], op.operands[3] as usize),
+ src: op.operands[4] as usize,
+ }),
+ MLIL_ADD => Op::Add(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_SUB => Op::Sub(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_AND => Op::And(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_OR => Op::Or(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_XOR => Op::Xor(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_LSL => Op::Lsl(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_LSR => Op::Lsr(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_ASR => Op::Asr(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_ROL => Op::Rol(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_ROR => Op::Ror(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_MUL => Op::Mul(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_MULU_DP => Op::MuluDp(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_MULS_DP => Op::MulsDp(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_DIVU => Op::Divu(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_DIVU_DP => Op::DivuDp(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_DIVS => Op::Divs(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_DIVS_DP => Op::DivsDp(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_MODU => Op::Modu(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_MODU_DP => Op::ModuDp(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_MODS => Op::Mods(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_MODS_DP => Op::ModsDp(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_E => Op::CmpE(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_NE => Op::CmpNe(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_SLT => Op::CmpSlt(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_ULT => Op::CmpUlt(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_SLE => Op::CmpSle(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_ULE => Op::CmpUle(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_SGE => Op::CmpSge(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_UGE => Op::CmpUge(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_SGT => Op::CmpSgt(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_CMP_UGT => Op::CmpUgt(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_TEST_BIT => Op::TestBit(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_ADD_OVERFLOW => Op::AddOverflow(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FCMP_E => Op::FcmpE(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FCMP_NE => Op::FcmpNe(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FCMP_LT => Op::FcmpLt(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FCMP_LE => Op::FcmpLe(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FCMP_GE => Op::FcmpGe(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FCMP_GT => Op::FcmpGt(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FCMP_O => Op::FcmpO(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FCMP_UO => Op::FcmpUo(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FADD => Op::Fadd(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FSUB => Op::Fsub(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FMUL => Op::Fmul(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_FDIV => Op::Fdiv(BinaryOp {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ }),
+ MLIL_ADC => Op::Adc(BinaryOpCarry {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ carry: op.operands[2] as usize,
+ }),
+ MLIL_SBB => Op::Sbb(BinaryOpCarry {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ carry: op.operands[2] as usize,
+ }),
+ MLIL_RLC => Op::Rlc(BinaryOpCarry {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ carry: op.operands[2] as usize,
+ }),
+ MLIL_RRC => Op::Rrc(BinaryOpCarry {
+ left: op.operands[0] as usize,
+ right: op.operands[1] as usize,
+ carry: op.operands[2] as usize,
+ }),
+ MLIL_CALL => Op::Call(Call {
+ num_outputs: op.operands[0] as usize,
+ first_output: op.operands[1] as usize,
+ dest: op.operands[2] as usize,
+ num_params: op.operands[3] as usize,
+ first_param: op.operands[4] as usize,
+ }),
+ MLIL_TAILCALL => Op::Tailcall(Call {
+ num_outputs: op.operands[0] as usize,
+ first_output: op.operands[1] as usize,
+ dest: op.operands[2] as usize,
+ num_params: op.operands[3] as usize,
+ first_param: op.operands[4] as usize,
+ }),
+ MLIL_SYSCALL => Op::Syscall(Syscall {
+ num_outputs: op.operands[0] as usize,
+ first_output: op.operands[1] as usize,
+ num_params: op.operands[2] as usize,
+ first_param: op.operands[3] as usize,
+ }),
+ MLIL_INTRINSIC => Op::Intrinsic(Intrinsic {
+ num_outputs: op.operands[0] as usize,
+ first_output: op.operands[1] as usize,
+ intrinsic: op.operands[2] as u32,
+ num_params: op.operands[3] as usize,
+ first_param: op.operands[4] as usize,
+ }),
+ MLIL_INTRINSIC_SSA => Op::IntrinsicSsa(IntrinsicSsa {
+ num_outputs: op.operands[0] as usize,
+ first_output: op.operands[1] as usize,
+ intrinsic: op.operands[2] as u32,
+ num_params: op.operands[3] as usize,
+ first_param: op.operands[4] as usize,
+ }),
+ MLIL_CALL_SSA => Op::CallSsa(CallSsa {
+ output: op.operands[0] as usize,
+ dest: op.operands[1] as usize,
+ num_params: op.operands[2] as usize,
+ first_param: op.operands[3] as usize,
+ src_memory: op.operands[4],
+ }),
+ MLIL_TAILCALL_SSA => Op::TailcallSsa(CallSsa {
+ output: op.operands[0] as usize,
+ dest: op.operands[1] as usize,
+ num_params: op.operands[2] as usize,
+ first_param: op.operands[3] as usize,
+ src_memory: op.operands[4],
+ }),
+ MLIL_CALL_UNTYPED_SSA => Op::CallUntypedSsa(CallUntypedSsa {
+ output: op.operands[0] as usize,
+ dest: op.operands[1] as usize,
+ params: op.operands[2] as usize,
+ stack: op.operands[3] as usize,
+ }),
+ MLIL_TAILCALL_UNTYPED_SSA => Op::TailcallUntypedSsa(CallUntypedSsa {
+ output: op.operands[0] as usize,
+ dest: op.operands[1] as usize,
+ params: op.operands[2] as usize,
+ stack: op.operands[3] as usize,
+ }),
+ MLIL_SYSCALL_SSA => Op::SyscallSsa(SyscallSsa {
+ output: op.operands[0] as usize,
+ num_params: op.operands[1] as usize,
+ first_param: op.operands[2] as usize,
+ src_memory: op.operands[3],
+ }),
+ MLIL_SYSCALL_UNTYPED_SSA => Op::SyscallUntypedSsa(SyscallUntypedSsa {
+ output: op.operands[0] as usize,
+ params: op.operands[1] as usize,
+ stack: op.operands[2] as usize,
+ }),
+ MLIL_CALL_UNTYPED => Op::CallUntyped(CallUntyped {
+ output: op.operands[0] as usize,
+ dest: op.operands[1] as usize,
+ params: op.operands[2] as usize,
+ stack: op.operands[3] as usize,
+ }),
+ MLIL_TAILCALL_UNTYPED => Op::TailcallUntyped(CallUntyped {
+ output: op.operands[0] as usize,
+ dest: op.operands[1] as usize,
+ params: op.operands[2] as usize,
+ stack: op.operands[3] as usize,
+ }),
+ MLIL_SYSCALL_UNTYPED => Op::SyscallUntyped(SyscallUntyped {
+ output: op.operands[0] as usize,
+ params: op.operands[1] as usize,
+ stack: op.operands[2] as usize,
+ }),
+ MLIL_NEG => Op::Neg(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_NOT => Op::Not(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_SX => Op::Sx(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_ZX => Op::Zx(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_LOW_PART => Op::LowPart(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_BOOL_TO_INT => Op::BoolToInt(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_UNIMPL_MEM => Op::UnimplMem(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_FSQRT => Op::Fsqrt(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_FNEG => Op::Fneg(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_FABS => Op::Fabs(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_FLOAT_TO_INT => Op::FloatToInt(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_INT_TO_FLOAT => Op::IntToFloat(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_FLOAT_CONV => Op::FloatConv(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_ROUND_TO_INT => Op::RoundToInt(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_FLOOR => Op::Floor(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_CEIL => Op::Ceil(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_FTRUNC => Op::Ftrunc(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_LOAD => Op::Load(UnaryOp {
+ src: op.operands[0] as usize,
+ }),
+ MLIL_LOAD_STRUCT => Op::LoadStruct(LoadStruct {
+ src: op.operands[0] as usize,
+ offset: op.operands[1],
+ }),
+ MLIL_LOAD_STRUCT_SSA => Op::LoadStructSsa(LoadStructSsa {
+ src: op.operands[0] as usize,
+ offset: op.operands[1],
+ src_memory: op.operands[2],
+ }),
+ MLIL_LOAD_SSA => Op::LoadSsa(LoadSsa {
+ src: op.operands[0] as usize,
+ src_memory: op.operands[1],
+ }),
+ MLIL_RET => Op::Ret(Ret {
+ num_operands: op.operands[0] as usize,
+ first_operand: op.operands[1] as usize,
+ }),
+ MLIL_SEPARATE_PARAM_LIST => Op::SeparateParamList(SeparateParamList {
+ num_params: op.operands[0] as usize,
+ first_param: op.operands[1] as usize,
+ }),
+ MLIL_SHARED_PARAM_SLOT => Op::SharedParamSlot(SharedParamSlot {
+ num_params: op.operands[0] as usize,
+ first_param: op.operands[1] as usize,
+ }),
+ MLIL_VAR => Op::Var(Var {
+ src: get_var(op.operands[0]),
+ }),
+ MLIL_ADDRESS_OF => Op::AddressOf(Var {
+ src: get_var(op.operands[0]),
+ }),
+ MLIL_VAR_FIELD => Op::VarField(Field {
+ src: get_var(op.operands[0]),
+ offset: op.operands[1],
+ }),
+ MLIL_ADDRESS_OF_FIELD => Op::AddressOfField(Field {
+ src: get_var(op.operands[0]),
+ offset: op.operands[1],
+ }),
+ MLIL_VAR_SSA => Op::VarSsa(VarSsa {
+ src: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ }),
+ MLIL_VAR_ALIASED => Op::VarAliased(VarSsa {
+ src: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ }),
+ MLIL_VAR_SSA_FIELD => Op::VarSsaField(VarSsaField {
+ src: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ offset: op.operands[2],
+ }),
+ MLIL_VAR_ALIASED_FIELD => Op::VarAliasedField(VarSsaField {
+ src: get_var_ssa(op.operands[0], op.operands[1] as usize),
+ offset: op.operands[2],
+ }),
+ MLIL_TRAP => Op::Trap(Trap {
+ vector: op.operands[0],
+ }),
// translated directly into a list for Expression or Variables
// TODO MLIL_MEMORY_INTRINSIC_SSA needs to be handled properly
MLIL_CALL_OUTPUT | MLIL_CALL_PARAM | MLIL_CALL_PARAM_SSA | MLIL_CALL_OUTPUT_SSA | MLIL_MEMORY_INTRINSIC_OUTPUT_SSA | MLIL_MEMORY_INTRINSIC_SSA => {
diff --git a/rust/src/mlil/operation.rs b/rust/src/mlil/operation.rs
index 544fe275..9b3a4a70 100644
--- a/rust/src/mlil/operation.rs
+++ b/rust/src/mlil/operation.rs
@@ -58,7 +58,7 @@ impl Iterator for OperandIter {
} else {
// Will short-circuit and return `None` once iter is exhausted
let iter_idx = self.next_iter_idx?;
- let node = unsafe { BNGetMediumLevelILByIndex(self.function.handle, iter_idx) };
+ let node = get_raw_operation(&self.function, iter_idx);
assert_eq!(node.operation, BNMediumLevelILOperation::MLIL_UNDEF);
let next = if self.remaining > 4 {
@@ -183,7 +183,7 @@ impl ExactSizeIterator for OperandSSAVarIter {
}
}
-fn get_float(value: u64, size: usize) -> f64 {
+pub(super) fn get_float(value: u64, size: usize) -> f64 {
match size {
4 => f32::from_bits(value as u32) as f64,
8 => f64::from_bits(value),
@@ -213,11 +213,11 @@ fn get_raw_operation(function: &MediumLevelILFunction, idx: usize) -> BNMediumLe
unsafe { BNGetMediumLevelILByIndex(function.handle, idx) }
}
-fn get_var(id: u64) -> Variable {
+pub(super) fn get_var(id: u64) -> Variable {
unsafe { Variable::from_raw(BNFromVariableIdentifier(id)) }
}
-fn get_var_ssa(id: u64, version: usize) -> SSAVariable {
+pub(super) fn get_var_ssa(id: u64, version: usize) -> SSAVariable {
SSAVariable::new(get_var(id), version)
}
@@ -261,39 +261,18 @@ pub struct LiftedIf {
pub dest_true: u64,
pub dest_false: u64,
}
-impl MediumLevelILOperationIf {
- pub(crate) fn new(condition: usize, dest_true: u64, dest_false: u64) -> Self {
- Self {
- condition,
- dest_true,
- dest_false,
- }
- }
-}
// FLOAT_CONST
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct FloatConst {
pub constant: f64,
}
-impl FloatConst {
- pub(crate) fn new(constant: u64, size: usize) -> Self {
- Self {
- constant: get_float(constant, size),
- }
- }
-}
// CONST, CONST_PTR, IMPORT
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct Constant {
pub constant: u64,
}
-impl Constant {
- pub(crate) fn new(constant: u64) -> Self {
- Self { constant }
- }
-}
// EXTERN_PTR
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
@@ -301,11 +280,6 @@ pub struct ExternPtr {
pub constant: u64,
pub offset: u64,
}
-impl ExternPtr {
- pub(crate) fn new(constant: u64, offset: u64) -> Self {
- Self { constant, offset }
- }
-}
// CONST_DATA
#[derive(Copy, Clone)]
@@ -318,15 +292,6 @@ pub struct ConstantData {
pub struct LiftedConstantData {
pub constant_data: types::ConstantData,
}
-impl ConstantData {
- pub(crate) fn new(constant_data_kind: u32, constant_data_value: i64, size: usize) -> Self {
- Self {
- constant_data_kind,
- constant_data_value,
- size,
- }
- }
-}
// JUMP, RET_HINT
#[derive(Copy, Clone)]
@@ -337,11 +302,6 @@ pub struct Jump {
pub struct LiftedJump {
pub dest: Box<MediumLevelILLiftedInstruction>,
}
-impl Jump {
- pub(crate) fn new(dest: usize) -> Self {
- Self { dest }
- }
-}
// STORE_SSA
#[derive(Copy, Clone)]
@@ -358,16 +318,6 @@ pub struct LiftedStoreSsa {
pub src_memory: u64,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl StoreSsa {
- pub(crate) fn new(dest: usize, dest_memory: u64, src_memory: u64, src: usize) -> Self {
- Self {
- dest,
- dest_memory,
- src_memory,
- src,
- }
- }
-}
// STORE_STRUCT_SSA
#[derive(Copy, Clone)]
@@ -386,23 +336,6 @@ pub struct LiftedStoreStructSsa {
pub src_memory: u64,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl StoreStructSsa {
- pub(crate) fn new(
- dest: usize,
- offset: u64,
- dest_memory: u64,
- src_memory: u64,
- src: usize,
- ) -> Self {
- Self {
- dest,
- offset,
- dest_memory,
- src_memory,
- src,
- }
- }
-}
// STORE_STRUCT
#[derive(Copy, Clone)]
@@ -417,11 +350,6 @@ pub struct LiftedStoreStruct {
pub offset: u64,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl StoreStruct {
- pub(crate) fn new(dest: usize, offset: u64, src: usize) -> Self {
- Self { dest, offset, src }
- }
-}
// STORE
#[derive(Copy, Clone)]
@@ -434,11 +362,6 @@ pub struct LiftedStore {
pub dest: Box<MediumLevelILLiftedInstruction>,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl Store {
- pub(crate) fn new(dest: usize, src: usize) -> Self {
- Self { dest, src }
- }
-}
// JUMP_TO
#[derive(Copy, Clone)]
@@ -452,39 +375,18 @@ pub struct LiftedJumpTo {
pub dest: Box<MediumLevelILLiftedInstruction>,
pub targets: HashMap<u64, u64>,
}
-impl JumpTo {
- pub(crate) fn new(dest: usize, num_operands: usize, first_operand: usize) -> Self {
- Self {
- dest,
- first_operand,
- num_operands,
- }
- }
-}
// GOTO
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct Goto {
pub dest: u64,
}
-impl Goto {
- pub(crate) fn new(dest: u64) -> Self {
- Self { dest }
- }
-}
// FREE_VAR_SLOT
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct FreeVarSlot {
pub dest: Variable,
}
-impl FreeVarSlot {
- pub(crate) fn new(dest: u64) -> Self {
- Self {
- dest: get_var(dest),
- }
- }
-}
// SET_VAR_FIELD
#[derive(Copy, Clone)]
@@ -499,15 +401,6 @@ pub struct LiftedSetVarField {
pub offset: u64,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl SetVarField {
- pub(crate) fn new(dest: u64, offset: u64, src: usize) -> Self {
- Self {
- dest: get_var(dest),
- offset,
- src,
- }
- }
-}
// SET_VAR
#[derive(Copy, Clone)]
@@ -520,14 +413,6 @@ pub struct LiftedSetVar {
pub dest: Variable,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl SetVar {
- pub(crate) fn new(dest: u64, src: usize) -> Self {
- Self {
- dest: get_var(dest),
- src,
- }
- }
-}
// FREE_VAR_SLOT_SSA
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
@@ -535,14 +420,6 @@ pub struct FreeVarSlotSsa {
pub dest: SSAVariable,
pub prev: SSAVariable,
}
-impl FreeVarSlotSsa {
- pub(crate) fn new(dest: (u64, usize), prev: (u64, usize)) -> Self {
- Self {
- dest: get_var_ssa(dest.0, dest.1),
- prev: get_var_ssa(prev.0, prev.1),
- }
- }
-}
// SET_VAR_SSA_FIELD, SET_VAR_ALIASED_FIELD
#[derive(Copy, Clone)]
@@ -559,16 +436,6 @@ pub struct LiftedSetVarSsaField {
pub offset: u64,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl SetVarSsaField {
- pub(crate) fn new(dest: (u64, usize), prev: (u64, usize), offset: u64, src: usize) -> Self {
- Self {
- dest: get_var_ssa(dest.0, dest.1),
- prev: get_var_ssa(prev.0, prev.1),
- offset,
- src,
- }
- }
-}
// SET_VAR_ALIASED
#[derive(Copy, Clone)]
@@ -583,15 +450,6 @@ pub struct LiftedSetVarAliased {
pub prev: SSAVariable,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl SetVarAliased {
- pub(crate) fn new(dest: (u64, usize), prev: (u64, usize), src: usize) -> Self {
- Self {
- dest: get_var_ssa(dest.0, dest.1),
- prev: get_var_ssa(prev.0, prev.1),
- src,
- }
- }
-}
// SET_VAR_SSA
#[derive(Copy, Clone)]
@@ -604,14 +462,6 @@ pub struct LiftedSetVarSsa {
pub dest: SSAVariable,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl SetVarSsa {
- pub(crate) fn new(dest: (u64, usize), src: usize) -> Self {
- Self {
- dest: get_var_ssa(dest.0, dest.1),
- src,
- }
- }
-}
// VAR_PHI
#[derive(Copy, Clone)]
@@ -625,15 +475,6 @@ pub struct LiftedVarPhi {
pub dest: SSAVariable,
pub src: Vec<SSAVariable>,
}
-impl VarPhi {
- pub(crate) fn new(dest: (u64, usize), num_operands: usize, first_operand: usize) -> Self {
- Self {
- dest: get_var_ssa(dest.0, dest.1),
- first_operand,
- num_operands,
- }
- }
-}
// MEM_PHI
#[derive(Copy, Clone)]
@@ -647,15 +488,6 @@ pub struct LiftedMemPhi {
pub dest_memory: u64,
pub src_memory: Vec<u64>,
}
-impl MemPhi {
- pub(crate) fn new(dest_memory: u64, num_operands: usize, first_operand: usize) -> Self {
- Self {
- dest_memory,
- first_operand,
- num_operands,
- }
- }
-}
// VAR_SPLIT
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
@@ -663,14 +495,6 @@ pub struct VarSplit {
pub high: Variable,
pub low: Variable,
}
-impl VarSplit {
- pub(crate) fn new(high: u64, low: u64) -> Self {
- Self {
- high: get_var(high),
- low: get_var(low),
- }
- }
-}
// SET_VAR_SPLIT
#[derive(Copy, Clone)]
@@ -685,15 +509,6 @@ pub struct LiftedSetVarSplit {
pub low: Variable,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl SetVarSplit {
- pub(crate) fn new(high: u64, low: u64, src: usize) -> Self {
- Self {
- high: get_var(high),
- low: get_var(low),
- src,
- }
- }
-}
// VAR_SPLIT_SSA
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
@@ -701,14 +516,6 @@ pub struct VarSplitSsa {
pub high: SSAVariable,
pub low: SSAVariable,
}
-impl VarSplitSsa {
- pub(crate) fn new(high: (u64, usize), low: (u64, usize)) -> Self {
- Self {
- high: get_var_ssa(high.0, high.1),
- low: get_var_ssa(low.0, low.1),
- }
- }
-}
// SET_VAR_SPLIT_SSA
#[derive(Copy, Clone)]
@@ -723,15 +530,6 @@ pub struct LiftedSetVarSplitSsa {
pub low: SSAVariable,
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl SetVarSplitSsa {
- pub(crate) fn new(high: (u64, usize), low: (u64, usize), src: usize) -> Self {
- Self {
- high: get_var_ssa(high.0, high.1),
- low: get_var_ssa(low.0, low.1),
- src,
- }
- }
-}
// ADD, SUB, AND, OR, XOR, LSL, LSR, ASR, ROL, ROR, MUL, MULU_DP, MULS_DP, DIVU, DIVU_DP, DIVS, DIVS_DP, MODU, MODU_DP, MODS, MODS_DP, CMP_E, CMP_NE, CMP_SLT, CMP_ULT, CMP_SLE, CMP_ULE, CMP_SGE, CMP_UGE, CMP_SGT, CMP_UGT, TEST_BIT, ADD_OVERFLOW, FCMP_E, FCMP_NE, FCMP_LT, FCMP_LE, FCMP_GE, FCMP_GT, FCMP_O, FCMP_UO, FADD, FSUB, FMUL, FDIV
#[derive(Copy, Clone)]
@@ -744,11 +542,6 @@ pub struct LiftedBinaryOp {
pub left: Box<MediumLevelILLiftedInstruction>,
pub right: Box<MediumLevelILLiftedInstruction>,
}
-impl BinaryOp {
- pub(crate) fn new(left: usize, right: usize) -> Self {
- Self { left, right }
- }
-}
// ADC, SBB, RLC, RRC
#[derive(Copy, Clone)]
@@ -763,11 +556,6 @@ pub struct LiftedBinaryOpCarry {
pub right: Box<MediumLevelILLiftedInstruction>,
pub carry: Box<MediumLevelILLiftedInstruction>,
}
-impl BinaryOpCarry {
- pub(crate) fn new(left: usize, right: usize, carry: usize) -> Self {
- Self { left, right, carry }
- }
-}
// CALL, TAILCALL
#[derive(Copy, Clone)]
@@ -784,23 +572,6 @@ pub struct LiftedCall {
pub dest: Box<MediumLevelILLiftedInstruction>,
pub params: Vec<MediumLevelILLiftedInstruction>,
}
-impl Call {
- pub(crate) fn new(
- num_outputs: usize,
- first_output: usize,
- dest: usize,
- num_params: usize,
- first_param: usize,
- ) -> Self {
- Self {
- num_outputs,
- first_output,
- dest,
- num_params,
- first_param,
- }
- }
-}
// SYSCALL
#[derive(Copy, Clone)]
@@ -815,21 +586,6 @@ pub struct LiftedSyscallCall {
pub output: Vec<Variable>,
pub params: Vec<MediumLevelILLiftedInstruction>,
}
-impl Syscall {
- pub(crate) fn new(
- num_outputs: usize,
- first_output: usize,
- num_params: usize,
- first_param: usize,
- ) -> Self {
- Self {
- num_outputs,
- first_output,
- num_params,
- first_param,
- }
- }
-}
// INTRINSIC
#[derive(Copy, Clone)]
@@ -846,23 +602,6 @@ pub struct LiftedIntrinsic {
pub intrinsic: ILIntrinsic,
pub params: Vec<MediumLevelILLiftedInstruction>,
}
-impl Intrinsic {
- pub(crate) fn new(
- num_outputs: usize,
- first_output: usize,
- intrinsic: u32,
- num_params: usize,
- first_param: usize,
- ) -> Self {
- Self {
- num_outputs,
- first_output,
- intrinsic,
- num_params,
- first_param,
- }
- }
-}
// INTRINSIC_SSA
#[derive(Copy, Clone)]
@@ -879,23 +618,6 @@ pub struct LiftedIntrinsicSsa {
pub intrinsic: ILIntrinsic,
pub params: Vec<MediumLevelILLiftedInstruction>,
}
-impl IntrinsicSsa {
- pub(crate) fn new(
- num_outputs: usize,
- first_output: usize,
- intrinsic: u32,
- num_params: usize,
- first_param: usize,
- ) -> Self {
- Self {
- num_outputs,
- first_output,
- intrinsic,
- num_params,
- first_param,
- }
- }
-}
// CALL_SSA, TAILCALL_SSA
#[derive(Copy, Clone)]
@@ -913,23 +635,6 @@ pub struct LiftedCallSsa {
pub params: Vec<MediumLevelILLiftedInstruction>,
pub src_memory: u64,
}
-impl CallSsa {
- pub(crate) fn new(
- output: usize,
- dest: usize,
- num_params: usize,
- first_param: usize,
- src_memory: u64,
- ) -> Self {
- Self {
- output,
- dest,
- first_param,
- num_params,
- src_memory,
- }
- }
-}
// CALL_UNTYPED_SSA, TAILCALL_UNTYPED_SSA
#[derive(Copy, Clone)]
@@ -946,16 +651,6 @@ pub struct LiftedCallUntypedSsa {
pub params: Vec<MediumLevelILLiftedInstruction>,
pub stack: Box<MediumLevelILLiftedInstruction>,
}
-impl CallUntypedSsa {
- pub(crate) fn new(output: usize, dest: usize, params: usize, stack: usize) -> Self {
- Self {
- output,
- dest,
- params,
- stack,
- }
- }
-}
// SYSCALL_SSA
#[derive(Copy, Clone)]
@@ -971,21 +666,6 @@ pub struct LiftedSyscallSsa {
pub params: Vec<MediumLevelILLiftedInstruction>,
pub src_memory: u64,
}
-impl SyscallSsa {
- pub(crate) fn new(
- output: usize,
- num_params: usize,
- first_param: usize,
- src_memory: u64,
- ) -> Self {
- Self {
- output,
- first_param,
- num_params,
- src_memory,
- }
- }
-}
// SYSCALL_UNTYPED_SSA
#[derive(Copy, Clone)]
@@ -1000,15 +680,6 @@ pub struct LiftedSyscallUntypedSsa {
pub params: Vec<MediumLevelILLiftedInstruction>,
pub stack: Box<MediumLevelILLiftedInstruction>,
}
-impl SyscallUntypedSsa {
- pub(crate) fn new(output: usize, params: usize, stack: usize) -> Self {
- Self {
- output,
- params,
- stack,
- }
- }
-}
// CALL_UNTYPED, TAILCALL_UNTYPED
#[derive(Copy, Clone)]
@@ -1025,16 +696,6 @@ pub struct LiftedCallUntyped {
pub params: Vec<MediumLevelILLiftedInstruction>,
pub stack: Box<MediumLevelILLiftedInstruction>,
}
-impl CallUntyped {
- pub(crate) fn new(output: usize, dest: usize, params: usize, stack: usize) -> Self {
- Self {
- output,
- dest,
- params,
- stack,
- }
- }
-}
// SYSCALL_UNTYPED
#[derive(Copy, Clone)]
@@ -1049,15 +710,6 @@ pub struct LiftedSyscallUntyped {
pub params: Vec<MediumLevelILLiftedInstruction>,
pub stack: Box<MediumLevelILLiftedInstruction>,
}
-impl SyscallUntyped {
- pub(crate) fn new(output: usize, params: usize, stack: usize) -> Self {
- Self {
- output,
- params,
- stack,
- }
- }
-}
// NEG, NOT, SX, ZX, LOW_PART, BOOL_TO_INT, UNIMPL_MEM, FSQRT, FNEG, FABS, FLOAT_TO_INT, INT_TO_FLOAT, FLOAT_CONV, ROUND_TO_INT, FLOOR, CEIL, FTRUNC, LOAD
#[derive(Copy, Clone)]
@@ -1068,11 +720,6 @@ pub struct UnaryOp {
pub struct LiftedUnaryOp {
pub src: Box<MediumLevelILLiftedInstruction>,
}
-impl UnaryOp {
- pub(crate) fn new(src: usize) -> Self {
- Self { src }
- }
-}
// LOAD_STRUCT
#[derive(Copy, Clone)]
@@ -1085,11 +732,6 @@ pub struct LiftedLoadStruct {
pub src: Box<MediumLevelILLiftedInstruction>,
pub offset: u64,
}
-impl LoadStruct {
- pub(crate) fn new(src: usize, offset: u64) -> Self {
- Self { src, offset }
- }
-}
// LOAD_STRUCT_SSA
#[derive(Copy, Clone)]
@@ -1104,15 +746,6 @@ pub struct LiftedLoadStructSsa {
pub offset: u64,
pub src_memory: u64,
}
-impl LoadStructSsa {
- pub(crate) fn new(src: usize, offset: u64, src_memory: u64) -> Self {
- Self {
- src,
- offset,
- src_memory,
- }
- }
-}
// LOAD_SSA
#[derive(Copy, Clone)]
@@ -1125,11 +758,6 @@ pub struct LiftedLoadSsa {
pub src: Box<MediumLevelILLiftedInstruction>,
pub src_memory: u64,
}
-impl LoadSsa {
- pub(crate) fn new(src: usize, src_memory: u64) -> Self {
- Self { src, src_memory }
- }
-}
// RET
#[derive(Copy, Clone)]
@@ -1141,14 +769,6 @@ pub struct Ret {
pub struct LiftedRet {
pub src: Vec<MediumLevelILLiftedInstruction>,
}
-impl Ret {
- pub(crate) fn new(num_operands: usize, first_operand: usize) -> Self {
- Self {
- first_operand,
- num_operands,
- }
- }
-}
// SEPARATE_PARAM_LIST
#[derive(Copy, Clone)]
@@ -1160,14 +780,6 @@ pub struct SeparateParamList {
pub struct LiftedSeparateParamList {
pub params: Vec<MediumLevelILLiftedInstruction>,
}
-impl SeparateParamList {
- pub fn new(num_params: usize, first_param: usize) -> Self {
- Self {
- num_params,
- first_param,
- }
- }
-}
// SHARED_PARAM_SLOT
#[derive(Copy, Clone)]
@@ -1179,25 +791,12 @@ pub struct SharedParamSlot {
pub struct LiftedSharedParamSlot {
pub params: Vec<MediumLevelILLiftedInstruction>,
}
-impl SharedParamSlot {
- pub fn new(num_params: usize, first_param: usize) -> Self {
- Self {
- num_params,
- first_param,
- }
- }
-}
// VAR, ADDRESS_OF
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct Var {
pub src: Variable,
}
-impl Var {
- pub(crate) fn new(src: u64) -> Self {
- Self { src: get_var(src) }
- }
-}
// VAR_FIELD, ADDRESS_OF_FIELD
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
@@ -1205,27 +804,12 @@ pub struct Field {
pub src: Variable,
pub offset: u64,
}
-impl Field {
- pub(crate) fn new(src: u64, offset: u64) -> Self {
- Self {
- src: get_var(src),
- offset,
- }
- }
-}
// VAR_SSA, VAR_ALIASED
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct VarSsa {
pub src: SSAVariable,
}
-impl VarSsa {
- pub(crate) fn new(src: (u64, usize)) -> Self {
- Self {
- src: get_var_ssa(src.0, src.1),
- }
- }
-}
// VAR_SSA_FIELD, VAR_ALIASED_FIELD
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
@@ -1233,22 +817,9 @@ pub struct VarSsaField {
pub src: SSAVariable,
pub offset: u64,
}
-impl VarSsaField {
- pub(crate) fn new(src: (u64, usize), offset: u64) -> Self {
- Self {
- src: get_var_ssa(src.0, src.1),
- offset,
- }
- }
-}
// TRAP
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct Trap {
pub vector: u64,
}
-impl Trap {
- pub(crate) fn new(vector: u64) -> Self {
- Self { vector }
- }
-}