summaryrefslogtreecommitdiff
path: root/highlevelilinstruction.cpp
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2026-06-03 21:25:55 -0700
committerMark Rowe <mark@vector35.com>2026-06-04 14:31:09 -0700
commitd592ed6dafbb134553bf3a0b8ee70ff7f2049aba (patch)
tree1bfe7e335e5b4e21371cde4bf8858c6439bc3f18 /highlevelilinstruction.cpp
parent9987102015875991813200116558306851763009 (diff)
Add bswap, popcnt, clz, ctz, cls, and rbit instructions
Diffstat (limited to 'highlevelilinstruction.cpp')
-rw-r--r--highlevelilinstruction.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/highlevelilinstruction.cpp b/highlevelilinstruction.cpp
index 0ce32c27..92312549 100644
--- a/highlevelilinstruction.cpp
+++ b/highlevelilinstruction.cpp
@@ -260,6 +260,12 @@ static constexpr std::array s_instructionOperandUsage = {
OperandUsage{HLIL_INTRINSIC_SSA, {IntrinsicHighLevelOperandUsage, ParameterExprsHighLevelOperandUsage, DestMemoryVersionHighLevelOperandUsage, SourceMemoryVersionHighLevelOperandUsage}},
OperandUsage{HLIL_VAR_PHI, {DestSSAVariableHighLevelOperandUsage, SourceSSAVariablesHighLevelOperandUsage}},
OperandUsage{HLIL_MEM_PHI, {DestMemoryVersionHighLevelOperandUsage, SourceMemoryVersionsHighLevelOperandUsage}},
+ OperandUsage{HLIL_BSWAP, {SourceExprHighLevelOperandUsage}},
+ OperandUsage{HLIL_POPCNT, {SourceExprHighLevelOperandUsage}},
+ OperandUsage{HLIL_CLZ, {SourceExprHighLevelOperandUsage}},
+ OperandUsage{HLIL_CTZ, {SourceExprHighLevelOperandUsage}},
+ OperandUsage{HLIL_RBIT, {SourceExprHighLevelOperandUsage}},
+ OperandUsage{HLIL_CLS, {SourceExprHighLevelOperandUsage}},
};
@@ -1261,6 +1267,12 @@ void HighLevelILInstruction::CollectSubExprs(stack<size_t>& toProcess) const
case HLIL_ADDRESS_OF:
case HLIL_NEG:
case HLIL_NOT:
+ case HLIL_BSWAP:
+ case HLIL_POPCNT:
+ case HLIL_CLZ:
+ case HLIL_CTZ:
+ case HLIL_RBIT:
+ case HLIL_CLS:
case HLIL_SX:
case HLIL_ZX:
case HLIL_LOW_PART:
@@ -1569,6 +1581,12 @@ ExprId HighLevelILInstruction::CopyTo(
return dest->Unreachable(loc);
case HLIL_NEG:
case HLIL_NOT:
+ case HLIL_BSWAP:
+ case HLIL_POPCNT:
+ case HLIL_CLZ:
+ case HLIL_CTZ:
+ case HLIL_RBIT:
+ case HLIL_CLS:
case HLIL_SX:
case HLIL_ZX:
case HLIL_LOW_PART:
@@ -2130,6 +2148,12 @@ bool HighLevelILInstruction::operator<(const HighLevelILInstruction& other) cons
case HLIL_DEREF:
case HLIL_NEG:
case HLIL_NOT:
+ case HLIL_BSWAP:
+ case HLIL_POPCNT:
+ case HLIL_CLZ:
+ case HLIL_CTZ:
+ case HLIL_RBIT:
+ case HLIL_CLS:
case HLIL_SX:
case HLIL_ZX:
case HLIL_LOW_PART:
@@ -3097,6 +3121,42 @@ ExprId HighLevelILFunction::Not(size_t size, ExprId src, const ILSourceLocation&
}
+ExprId HighLevelILFunction::ByteSwap(size_t size, ExprId src, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(HLIL_BSWAP, loc, size, src);
+}
+
+
+ExprId HighLevelILFunction::PopulationCount(size_t size, ExprId src, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(HLIL_POPCNT, loc, size, src);
+}
+
+
+ExprId HighLevelILFunction::CountLeadingZeros(size_t size, ExprId src, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(HLIL_CLZ, loc, size, src);
+}
+
+
+ExprId HighLevelILFunction::CountTrailingZeros(size_t size, ExprId src, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(HLIL_CTZ, loc, size, src);
+}
+
+
+ExprId HighLevelILFunction::ReverseBits(size_t size, ExprId src, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(HLIL_RBIT, loc, size, src);
+}
+
+
+ExprId HighLevelILFunction::CountLeadingSigns(size_t size, ExprId src, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(HLIL_CLS, loc, size, src);
+}
+
+
ExprId HighLevelILFunction::SignExtend(size_t size, ExprId src, const ILSourceLocation& loc)
{
return AddExprWithLocation(HLIL_SX, loc, size, src);