summaryrefslogtreecommitdiff
path: root/lowlevelilinstruction.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2023-11-09 18:39:55 -0500
committerRusty Wagner <rusty.wagner@gmail.com>2023-12-06 13:48:37 -0500
commite9604c37df479a991d131d9540fafe78c7a0f7d4 (patch)
treed1ac45fbc0da8dbfd3d09fec0625d11a5cfbc69e /lowlevelilinstruction.cpp
parent6e1a863a4b20d73610e88cb7d9adf676c1053fce (diff)
Add LLIL/MLIL instructions to describe integer vs. floating point argument usage
Diffstat (limited to 'lowlevelilinstruction.cpp')
-rw-r--r--lowlevelilinstruction.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/lowlevelilinstruction.cpp b/lowlevelilinstruction.cpp
index a1ec2f92..e85c58b0 100644
--- a/lowlevelilinstruction.cpp
+++ b/lowlevelilinstruction.cpp
@@ -149,6 +149,8 @@ unordered_map<BNLowLevelILOperation, vector<LowLevelILOperandUsage>> LowLevelILI
{LLIL_TAILCALL_SSA, {OutputSSARegistersLowLevelOperandUsage, OutputMemoryVersionLowLevelOperandUsage,
DestExprLowLevelOperandUsage, StackSSARegisterLowLevelOperandUsage,
StackMemoryVersionLowLevelOperandUsage, ParameterExprsLowLevelOperandUsage}},
+ {LLIL_SEPARATE_PARAM_LIST_SSA, {ParameterExprsLowLevelOperandUsage}},
+ {LLIL_SHARED_PARAM_SLOT_SSA, {ParameterExprsLowLevelOperandUsage}},
{LLIL_REG_PHI, {DestSSARegisterLowLevelOperandUsage, SourceSSARegistersLowLevelOperandUsage}},
{LLIL_REG_STACK_PHI, {DestSSARegisterStackLowLevelOperandUsage, SourceSSARegisterStacksLowLevelOperandUsage}},
{LLIL_FLAG_PHI, {DestSSAFlagLowLevelOperandUsage, SourceSSAFlagsLowLevelOperandUsage}},
@@ -245,8 +247,16 @@ static unordered_map<BNLowLevelILOperation, unordered_map<LowLevelILOperandUsage
operand++;
break;
case ParameterExprsLowLevelOperandUsage:
- // Represented as subexpression, so only takes one slot even though it is a list
- operand++;
+ if (operand == 0)
+ {
+ // Represented as a counted list
+ operand += 2;
+ }
+ else
+ {
+ // Represented as subexpression, so only takes one slot even though it is a list
+ operand++;
+ }
break;
case OutputSSARegistersLowLevelOperandUsage:
// OutputMemoryVersionLowLevelOperandUsage follows at same operand
@@ -2010,6 +2020,14 @@ void LowLevelILInstruction::VisitExprs(const std::function<bool(const LowLevelIL
for (auto i : GetParameterExprs<LLIL_INTRINSIC_SSA>())
i.VisitExprs(func);
break;
+ case LLIL_SEPARATE_PARAM_LIST_SSA:
+ for (auto i : GetParameterExprs<LLIL_SEPARATE_PARAM_LIST_SSA>())
+ i.VisitExprs(func);
+ break;
+ case LLIL_SHARED_PARAM_SLOT_SSA:
+ for (auto i : GetParameterExprs<LLIL_SHARED_PARAM_SLOT_SSA>())
+ i.VisitExprs(func);
+ break;
default:
break;
}
@@ -2304,6 +2322,14 @@ ExprId LowLevelILInstruction::CopyTo(
params.push_back(subExprHandler(i));
return dest->IntrinsicSSA(
GetOutputSSARegisterOrFlagList<LLIL_INTRINSIC_SSA>(), GetIntrinsic<LLIL_INTRINSIC_SSA>(), params, *this);
+ case LLIL_SEPARATE_PARAM_LIST_SSA:
+ for (auto i : GetParameterExprs<LLIL_SEPARATE_PARAM_LIST_SSA>())
+ params.push_back(subExprHandler(i));
+ return dest->SeparateParamListSSA(params, *this);
+ case LLIL_SHARED_PARAM_SLOT_SSA:
+ for (auto i : GetParameterExprs<LLIL_SHARED_PARAM_SLOT_SSA>())
+ params.push_back(subExprHandler(i));
+ return dest->SharedParamSlotSSA(params, *this);
default:
throw LowLevelILInstructionAccessException();
}
@@ -2693,7 +2719,11 @@ LowLevelILInstructionList LowLevelILInstruction::GetParameterExprs() const
{
size_t operandIndex;
if (GetOperandIndexForUsage(ParameterExprsLowLevelOperandUsage, operandIndex))
+ {
+ if (operandIndex == 0)
+ return GetRawOperandAsExprList(0);
return GetRawOperandAsExpr(operandIndex).GetRawOperandAsExprList(0);
+ }
throw LowLevelILInstructionAccessException();
}
@@ -3315,6 +3345,18 @@ ExprId LowLevelILFunction::TailCallSSA(const vector<SSARegister>& output, ExprId
}
+ExprId LowLevelILFunction::SeparateParamListSSA(const vector<ExprId>& params, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(LLIL_SEPARATE_PARAM_LIST_SSA, loc, 0, 0, params.size(), AddOperandList(params));
+}
+
+
+ExprId LowLevelILFunction::SharedParamSlotSSA(const vector<ExprId>& params, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(LLIL_SHARED_PARAM_SLOT_SSA, loc, 0, 0, params.size(), AddOperandList(params));
+}
+
+
ExprId LowLevelILFunction::Return(size_t dest, const ILSourceLocation& loc)
{
return AddExprWithLocation(LLIL_RET, loc, 0, 0, dest);