summaryrefslogtreecommitdiff
path: root/highlevelilinstruction.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2022-12-13 22:46:39 -0500
committerRusty Wagner <rusty.wagner@gmail.com>2023-01-03 10:41:46 -0500
commitffafa54703d239414e616d88633736ced71b63a5 (patch)
tree8158860a69828cdf529872b60084d1ce55ca8834 /highlevelilinstruction.cpp
parent3681a37debf204cf2416a807a189865a3834f300 (diff)
Add instruction attributes to IL instructions
Diffstat (limited to 'highlevelilinstruction.cpp')
-rw-r--r--highlevelilinstruction.cpp41
1 files changed, 41 insertions, 0 deletions
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<HighLevelILOperand>() 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);