From ffafa54703d239414e616d88633736ced71b63a5 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 13 Dec 2022 22:46:39 -0500 Subject: Add instruction attributes to IL instructions --- highlevelilinstruction.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'highlevelilinstruction.cpp') diff --git a/highlevelilinstruction.cpp b/highlevelilinstruction.cpp index 0b106d8b..e9c2676d 100644 --- a/highlevelilinstruction.cpp +++ b/highlevelilinstruction.cpp @@ -639,6 +639,7 @@ HighLevelILOperandList::operator vector() const HighLevelILInstruction::HighLevelILInstruction() { operation = HLIL_UNDEF; + attributes = 0; sourceOperand = BN_INVALID_OPERAND; size = 0; address = 0; @@ -652,6 +653,7 @@ HighLevelILInstruction::HighLevelILInstruction( HighLevelILFunction* func, const BNHighLevelILInstruction& instr, size_t expr, bool asFullAst, size_t instrIdx) { operation = instr.operation; + attributes = instr.attributes; sourceOperand = instr.sourceOperand; size = instr.size; operands[0] = instr.operands[0]; @@ -671,6 +673,7 @@ HighLevelILInstruction::HighLevelILInstruction( HighLevelILInstruction::HighLevelILInstruction(const HighLevelILInstructionBase& instr) { operation = instr.operation; + attributes = instr.attributes; sourceOperand = instr.sourceOperand; size = instr.size; operands[0] = instr.operands[0]; @@ -933,6 +936,44 @@ void HighLevelILInstructionBase::Replace(ExprId expr) } +void HighLevelILInstructionBase::SetAttributes(uint32_t attributes) +{ + function->SetExprAttributes(exprIndex, attributes); +} + + +void HighLevelILInstructionBase::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 HighLevelILInstructionBase::ClearAttribute(BNILInstructionAttribute attribute) +{ + SetAttribute(attribute, false); +} + + size_t HighLevelILInstructionBase::GetInstructionIndex() const { return function->GetInstructionForExpr(exprIndex); -- cgit v1.3.1