summaryrefslogtreecommitdiff
path: root/mediumlevelilinstruction.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2018-02-02 18:02:57 -0500
committerRusty Wagner <rusty@vector35.com>2018-02-02 18:02:57 -0500
commit331bfd4e4a648de8aba4fefd8301703a6a3440c9 (patch)
tree6a2287c7d4731c787918e47161eb944fc225051c /mediumlevelilinstruction.cpp
parentfd51307c7fa5baff29860b1e3be09aafca13c2f0 (diff)
Add rounding instructions
Diffstat (limited to 'mediumlevelilinstruction.cpp')
-rw-r--r--mediumlevelilinstruction.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/mediumlevelilinstruction.cpp b/mediumlevelilinstruction.cpp
index 7e1e663f..c4800837 100644
--- a/mediumlevelilinstruction.cpp
+++ b/mediumlevelilinstruction.cpp
@@ -215,6 +215,10 @@ unordered_map<BNMediumLevelILOperation, vector<MediumLevelILOperandUsage>>
{MLIL_FLOAT_TO_INT, {SourceExprMediumLevelOperandUsage}},
{MLIL_INT_TO_FLOAT, {SourceExprMediumLevelOperandUsage}},
{MLIL_FLOAT_CONV, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_ROUND_TO_INT, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_FLOOR, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_CEIL, {SourceExprMediumLevelOperandUsage}},
+ {MLIL_FTRUNC, {SourceExprMediumLevelOperandUsage}},
{MLIL_FCMP_E, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
{MLIL_FCMP_NE, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
{MLIL_FCMP_LT, {LeftExprMediumLevelOperandUsage, RightExprMediumLevelOperandUsage}},
@@ -1300,6 +1304,10 @@ void MediumLevelILInstruction::VisitExprs(const std::function<bool(const MediumL
case MLIL_FLOAT_TO_INT:
case MLIL_INT_TO_FLOAT:
case MLIL_FLOAT_CONV:
+ case MLIL_ROUND_TO_INT:
+ case MLIL_FLOOR:
+ case MLIL_CEIL:
+ case MLIL_FTRUNC:
AsOneOperand().GetSourceExpr().VisitExprs(func);
break;
case MLIL_ADD:
@@ -1539,6 +1547,10 @@ ExprId MediumLevelILInstruction::CopyTo(MediumLevelILFunction* dest,
case MLIL_FLOAT_TO_INT:
case MLIL_INT_TO_FLOAT:
case MLIL_FLOAT_CONV:
+ case MLIL_ROUND_TO_INT:
+ case MLIL_FLOOR:
+ case MLIL_CEIL:
+ case MLIL_FTRUNC:
return dest->AddExprWithLocation(operation, *this, size,
subExprHandler(AsOneOperand().GetSourceExpr()));
case MLIL_ADD:
@@ -2731,6 +2743,30 @@ ExprId MediumLevelILFunction::FloatConvert(size_t size, ExprId a, const ILSource
}
+ExprId MediumLevelILFunction::RoundToInt(size_t size, ExprId a, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(MLIL_ROUND_TO_INT, loc, size, a);
+}
+
+
+ExprId MediumLevelILFunction::Floor(size_t size, ExprId a, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(MLIL_FLOOR, loc, size, a);
+}
+
+
+ExprId MediumLevelILFunction::Ceil(size_t size, ExprId a, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(MLIL_CEIL, loc, size, a);
+}
+
+
+ExprId MediumLevelILFunction::FloatTrunc(size_t size, ExprId a, const ILSourceLocation& loc)
+{
+ return AddExprWithLocation(MLIL_FTRUNC, loc, size, a);
+}
+
+
ExprId MediumLevelILFunction::FloatCompareEqual(size_t size, ExprId a, ExprId b, const ILSourceLocation& loc)
{
return AddExprWithLocation(MLIL_FCMP_E, loc, size, a, b);