summaryrefslogtreecommitdiff
path: root/highlevelilinstruction.h
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2025-07-16 18:42:37 -0700
committerMark Rowe <mark@vector35.com>2025-12-11 21:09:38 -0800
commit62ded0de7b820f6e25be31254158401ce31a1c87 (patch)
tree83ff5d27bc01af2cec331eaf148de80914357420 /highlevelilinstruction.h
parent290bbcf333679ffa057d57d1b540608e3bec8ada (diff)
Use constexpr arrays for metadata about IL instruction operands
This avoids constructing two unordered maps and numerous vectors for each IL level at library load time for each plug-in that uses the C++ API. Additionally, the arrays allow for more efficient look-ups.
Diffstat (limited to 'highlevelilinstruction.h')
-rw-r--r--highlevelilinstruction.h27
1 files changed, 12 insertions, 15 deletions
diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h
index 53a3c567..84afeb98 100644
--- a/highlevelilinstruction.h
+++ b/highlevelilinstruction.h
@@ -62,7 +62,7 @@ namespace BinaryNinja
/*!
\ingroup highlevelil
*/
- enum HighLevelILOperandType
+ enum HighLevelILOperandType : uint8_t
{
IntegerHighLevelOperand,
ConstantDataHighLevelOperand,
@@ -79,7 +79,7 @@ namespace BinaryNinja
/*!
\ingroup highlevelil
*/
- enum HighLevelILOperandUsage
+ enum HighLevelILOperandUsage : uint8_t
{
SourceExprHighLevelOperandUsage,
VariableHighLevelOperandUsage,
@@ -358,10 +358,6 @@ namespace BinaryNinja
size_t exprIndex, instructionIndex;
bool ast;
- static _STD_UNORDERED_MAP<HighLevelILOperandUsage, HighLevelILOperandType> operandTypeForUsage;
- static _STD_UNORDERED_MAP<BNHighLevelILOperation, _STD_VECTOR<HighLevelILOperandUsage>> operationOperandUsage;
- static _STD_UNORDERED_MAP<BNHighLevelILOperation, _STD_UNORDERED_MAP<HighLevelILOperandUsage, size_t>>
- operationOperandIndex;
HighLevelILOperandList GetOperands() const;
@@ -856,28 +852,29 @@ namespace BinaryNinja
typedef value_type reference;
const HighLevelILOperandList* owner;
- _STD_VECTOR<HighLevelILOperandUsage>::const_iterator pos;
- bool operator==(const ListIterator& a) const { return pos == a.pos; }
- bool operator!=(const ListIterator& a) const { return pos != a.pos; }
- bool operator<(const ListIterator& a) const { return pos < a.pos; }
+ size_t index;
+ constexpr bool operator==(const ListIterator& a) const { return index == a.index; }
+ constexpr auto operator<=>(const ListIterator& a) const { return index <=> a.index; }
ListIterator& operator++()
{
- ++pos;
+ ++index;
return *this;
}
const HighLevelILOperand operator*();
};
HighLevelILInstruction m_instr;
- const _STD_VECTOR<HighLevelILOperandUsage>& m_usageList;
- const _STD_UNORDERED_MAP<HighLevelILOperandUsage, size_t>& m_operandIndexMap;
+ const HighLevelILOperandUsage* m_usages;
+ const uint8_t* m_indices;
+ uint8_t m_count;
public:
typedef ListIterator const_iterator;
HighLevelILOperandList(const HighLevelILInstruction& instr,
- const _STD_VECTOR<HighLevelILOperandUsage>& usageList,
- const _STD_UNORDERED_MAP<HighLevelILOperandUsage, size_t>& operandIndexMap);
+ const HighLevelILOperandUsage* usages,
+ const uint8_t* indices,
+ uint8_t count);
const_iterator begin() const;
const_iterator end() const;