diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2022-12-13 22:46:39 -0500 |
|---|---|---|
| committer | Rusty Wagner <rusty.wagner@gmail.com> | 2023-01-03 10:41:46 -0500 |
| commit | ffafa54703d239414e616d88633736ced71b63a5 (patch) | |
| tree | 8158860a69828cdf529872b60084d1ce55ca8834 /mediumlevelilinstruction.cpp | |
| parent | 3681a37debf204cf2416a807a189865a3834f300 (diff) | |
Add instruction attributes to IL instructions
Diffstat (limited to 'mediumlevelilinstruction.cpp')
| -rw-r--r-- | mediumlevelilinstruction.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/mediumlevelilinstruction.cpp b/mediumlevelilinstruction.cpp index 0cdda81e..ee4ed9e4 100644 --- a/mediumlevelilinstruction.cpp +++ b/mediumlevelilinstruction.cpp @@ -887,6 +887,7 @@ MediumLevelILOperandList::operator vector<MediumLevelILOperand>() const MediumLevelILInstruction::MediumLevelILInstruction() { operation = MLIL_UNDEF; + attributes = 0; sourceOperand = BN_INVALID_OPERAND; size = 0; address = 0; @@ -900,6 +901,7 @@ MediumLevelILInstruction::MediumLevelILInstruction( MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t expr, size_t instrIdx) { operation = instr.operation; + attributes = instr.attributes; sourceOperand = instr.sourceOperand; size = instr.size; operands[0] = instr.operands[0]; @@ -917,6 +919,7 @@ MediumLevelILInstruction::MediumLevelILInstruction( MediumLevelILInstruction::MediumLevelILInstruction(const MediumLevelILInstructionBase& instr) { operation = instr.operation; + attributes = instr.attributes; sourceOperand = instr.sourceOperand; size = instr.size; operands[0] = instr.operands[0]; @@ -1328,6 +1331,44 @@ void MediumLevelILInstructionBase::Replace(ExprId expr) } +void MediumLevelILInstructionBase::SetAttributes(uint32_t attributes) +{ + function->SetExprAttributes(exprIndex, attributes); +} + + +void MediumLevelILInstructionBase::SetAttribute(BNILInstructionAttribute attribute, bool state) +{ + uint32_t newAttributes = attributes; + if (state) + { + newAttributes |= attribute; + switch (attribute) + { + case ILAllowDeadStoreElimination: + newAttributes &= ~ILPreventDeadStoreElimination; + break; + case ILPreventDeadStoreElimination: + newAttributes &= ~ILAllowDeadStoreElimination; + break; + default: + break; + } + } + else + { + newAttributes &= ~attribute; + } + SetAttributes(newAttributes); +} + + +void MediumLevelILInstructionBase::ClearAttribute(BNILInstructionAttribute attribute) +{ + SetAttribute(attribute, false); +} + + void MediumLevelILInstruction::VisitExprs(const std::function<bool(const MediumLevelILInstruction& expr)>& func) const { if (!func(*this)) |
