From c7e9bb6b63e96a6cc779f3f1f64556ebe71b9bfb Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Mon, 18 Sep 2017 23:25:08 -0400 Subject: Add basic floating point instructions --- lowlevelilinstruction.h | 61 +++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'lowlevelilinstruction.h') diff --git a/lowlevelilinstruction.h b/lowlevelilinstruction.h index 169c7a60..6ae52798 100644 --- a/lowlevelilinstruction.h +++ b/lowlevelilinstruction.h @@ -49,7 +49,6 @@ namespace BinaryNinja struct LowLevelILOneOperandInstruction; struct LowLevelILTwoOperandInstruction; struct LowLevelILTwoOperandWithCarryInstruction; - struct LowLevelILDoublePrecisionInstruction; struct LowLevelILLabel; struct MediumLevelILInstruction; class LowLevelILOperand; @@ -118,8 +117,6 @@ namespace BinaryNinja LeftExprLowLevelOperandUsage, RightExprLowLevelOperandUsage, CarryExprLowLevelOperandUsage, - HighExprLowLevelOperandUsage, - LowExprLowLevelOperandUsage, ConditionExprLowLevelOperandUsage, HighRegisterLowLevelOperandUsage, HighSSARegisterLowLevelOperandUsage, @@ -428,10 +425,6 @@ namespace BinaryNinja { return *(LowLevelILTwoOperandWithCarryInstruction*)this; } - LowLevelILDoublePrecisionInstruction& AsDoublePrecision() - { - return *(LowLevelILDoublePrecisionInstruction*)this; - } template const LowLevelILInstructionAccessor& As() const @@ -456,10 +449,6 @@ namespace BinaryNinja { return *(const LowLevelILTwoOperandWithCarryInstruction*)this; } - const LowLevelILDoublePrecisionInstruction& AsDoublePrecision() const - { - return *(const LowLevelILDoublePrecisionInstruction*)this; - } }; struct LowLevelILInstruction: public LowLevelILInstructionBase @@ -491,8 +480,6 @@ namespace BinaryNinja template LowLevelILInstruction GetLeftExpr() const { return As().GetLeftExpr(); } template LowLevelILInstruction GetRightExpr() const { return As().GetRightExpr(); } template LowLevelILInstruction GetCarryExpr() const { return As().GetCarryExpr(); } - template LowLevelILInstruction GetHighExpr() const { return As().GetHighExpr(); } - template LowLevelILInstruction GetLowExpr() const { return As().GetLowExpr(); } template LowLevelILInstruction GetConditionExpr() const { return As().GetConditionExpr(); } template uint32_t GetHighRegister() const { return As().GetHighRegister(); } template SSARegister GetHighSSARegister() const { return As().GetHighSSARegister(); } @@ -544,8 +531,6 @@ namespace BinaryNinja LowLevelILInstruction GetLeftExpr() const; LowLevelILInstruction GetRightExpr() const; LowLevelILInstruction GetCarryExpr() const; - LowLevelILInstruction GetHighExpr() const; - LowLevelILInstruction GetLowExpr() const; LowLevelILInstruction GetConditionExpr() const; uint32_t GetHighRegister() const; SSARegister GetHighSSARegister() const; @@ -651,13 +636,6 @@ namespace BinaryNinja LowLevelILInstruction GetCarryExpr() const { return GetRawOperandAsExpr(2); } }; - struct LowLevelILDoublePrecisionInstruction: public LowLevelILInstructionBase - { - LowLevelILInstruction GetHighExpr() const { return GetRawOperandAsExpr(0); } - LowLevelILInstruction GetLowExpr() const { return GetRawOperandAsExpr(1); } - LowLevelILInstruction GetRightExpr() const { return GetRawOperandAsExpr(2); } - }; - // Implementations of each instruction to fetch the correct operand value for the valid operands, these // are derived from LowLevelILInstructionBase so that invalid operand accessor functions will generate // a compiler error. @@ -764,6 +742,19 @@ namespace BinaryNinja void SetSourceSSAVersion(size_t version) { UpdateRawOperand(1, version); } }; + template <> struct LowLevelILInstructionAccessor: public LowLevelILInstructionBase + { + uint32_t GetHighRegister() const { return GetRawOperandAsRegister(0); } + uint32_t GetLowRegister() const { return GetRawOperandAsRegister(1); } + }; + template <> struct LowLevelILInstructionAccessor: public LowLevelILInstructionBase + { + SSARegister GetHighSSARegister() const { return GetRawOperandAsSSARegister(0); } + SSARegister GetLowSSARegister() const { return GetRawOperandAsSSARegister(2); } + void SetHighSSAVersion(size_t version) { UpdateRawOperand(1, version); } + void SetLowSSAVersion(size_t version) { UpdateRawOperand(3, version); } + }; + template <> struct LowLevelILInstructionAccessor: public LowLevelILInstructionBase { LowLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); } @@ -880,6 +871,10 @@ namespace BinaryNinja template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; @@ -892,17 +887,23 @@ namespace BinaryNinja template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandWithCarryInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandWithCarryInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandWithCarryInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILTwoOperandWithCarryInstruction {}; - template <> struct LowLevelILInstructionAccessor: public LowLevelILDoublePrecisionInstruction {}; - template <> struct LowLevelILInstructionAccessor: public LowLevelILDoublePrecisionInstruction {}; - template <> struct LowLevelILInstructionAccessor: public LowLevelILDoublePrecisionInstruction {}; - template <> struct LowLevelILInstructionAccessor: public LowLevelILDoublePrecisionInstruction {}; - template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; @@ -911,4 +912,10 @@ namespace BinaryNinja template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; + template <> struct LowLevelILInstructionAccessor: public LowLevelILOneOperandInstruction {}; } -- cgit v1.3.1