summaryrefslogtreecommitdiff
path: root/lowlevelilinstruction.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 /lowlevelilinstruction.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 'lowlevelilinstruction.h')
-rw-r--r--lowlevelilinstruction.h27
1 files changed, 11 insertions, 16 deletions
diff --git a/lowlevelilinstruction.h b/lowlevelilinstruction.h
index 4c3499b8..37d0d30a 100644
--- a/lowlevelilinstruction.h
+++ b/lowlevelilinstruction.h
@@ -162,7 +162,7 @@ namespace BinaryNinja
/*!
\ingroup lowlevelil
*/
- enum LowLevelILOperandType
+ enum LowLevelILOperandType : uint8_t
{
IntegerLowLevelOperand,
IndexLowLevelOperand,
@@ -192,7 +192,7 @@ namespace BinaryNinja
/*!
\ingroup lowlevelil
*/
- enum LowLevelILOperandUsage
+ enum LowLevelILOperandUsage : uint8_t
{
SourceExprLowLevelOperandUsage,
SourceRegisterLowLevelOperandUsage,
@@ -750,11 +750,6 @@ namespace BinaryNinja
#endif
size_t exprIndex, instructionIndex;
- static _STD_UNORDERED_MAP<LowLevelILOperandUsage, LowLevelILOperandType> operandTypeForUsage;
- static _STD_UNORDERED_MAP<BNLowLevelILOperation, _STD_VECTOR<LowLevelILOperandUsage>> operationOperandUsage;
- static _STD_UNORDERED_MAP<BNLowLevelILOperation, _STD_UNORDERED_MAP<LowLevelILOperandUsage, size_t>>
- operationOperandIndex;
-
LowLevelILOperandList GetOperands() const;
uint64_t GetRawOperandAsInteger(size_t operand) const;
@@ -1290,27 +1285,27 @@ namespace BinaryNinja
typedef value_type reference;
const LowLevelILOperandList* owner;
- _STD_VECTOR<LowLevelILOperandUsage>::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 LowLevelILOperand operator*();
};
LowLevelILInstruction m_instr;
- const _STD_VECTOR<LowLevelILOperandUsage>& m_usageList;
- const _STD_UNORDERED_MAP<LowLevelILOperandUsage, size_t>& m_operandIndexMap;
+ const LowLevelILOperandUsage* m_usages;
+ const uint8_t* m_indices;
+ uint8_t m_count;
public:
typedef ListIterator const_iterator;
- LowLevelILOperandList(const LowLevelILInstruction& instr, const _STD_VECTOR<LowLevelILOperandUsage>& usageList,
- const _STD_UNORDERED_MAP<LowLevelILOperandUsage, size_t>& operandIndexMap);
+ LowLevelILOperandList(const LowLevelILInstruction& instr, const LowLevelILOperandUsage* usages,
+ const uint8_t* indices, uint8_t count);
const_iterator begin() const;
const_iterator end() const;