7 #ifndef RETDEC_LLVMIR2HLL_EVALUATOR_ARITHM_EXPR_EVALUATOR_H
8 #define RETDEC_LLVMIR2HLL_EVALUATOR_ARITHM_EXPR_EVALUATOR_H
40 using APSIntPair = std::pair<llvm::APSInt, llvm::APSInt>;
67 virtual std::string
getId()
const = 0;
75 template<
typename ConstType>
94 const llvm::APInt &,
bool &)
const;
96 const llvm::APInt &)
const;
98 const llvm::APInt &)
const;
100 const llvm::APFloat &, llvm::APFloat::roundingMode);
105 const llvm::APFloat &);
220 &constFloatPair,
LLVMAPFloatOp op, llvm::APFloat::opStatus &status);
Base class for cast instructions.
A base class for all evaluators.
Definition: arithm_expr_evaluator.h:37
std::stack< ShPtr< Constant > > ConstStack
Stack of constats.
Definition: arithm_expr_evaluator.h:58
ConstPair getOperandsForBinaryOpAndResolveTypes()
Get operands from stackOfResults and call resolve types method that is implemented in sub-evaluators.
Definition: arithm_expr_evaluator.cpp:969
std::pair< ShPtr< ConstFloat >, ShPtr< ConstFloat > > ConstFloatPair
Pair of float constants.
Definition: arithm_expr_evaluator.h:49
virtual void resolveOverflowForAPInt(bool overflow)
Definition: arithm_expr_evaluator.cpp:945
virtual void resolveOverflowForAPFloat(llvm::APFloat::opStatus opStatus)
Definition: arithm_expr_evaluator.cpp:947
llvm::APFloat::opStatus(llvm::APFloat::*)(const llvm::APFloat &) LLVMAPFloatOpNoRounding
Definition: arithm_expr_evaluator.h:105
virtual void resolveCast(ShPtr< BitCastExpr > expr, ShPtr< Constant > &constant)
Definition: arithm_expr_evaluator.cpp:930
ConstStack stackOfResults
Stack of results during the evaluation.
Definition: arithm_expr_evaluator.h:242
virtual void resolveTypesUnaryOp(ShPtr< Constant > &operand)
Definition: arithm_expr_evaluator.cpp:866
std::pair< ShPtr< ConstBool >, ShPtr< ConstBool > > ConstBoolPair
Pair of bool constants.
Definition: arithm_expr_evaluator.h:52
static std::optional< std::pair< ShPtr< ConstType >, ShPtr< ConstType > > > castConstPair(const ConstPair &constPair)
Casts the constants in constPair to the given type.
Definition: arithm_expr_evaluator.cpp:985
ShPtr< Constant > evaluate(ShPtr< Expression > expr)
Evaluate an expr.
Definition: arithm_expr_evaluator.cpp:105
virtual void resolveOpSpecifications(ShPtr< AddOpExpr > expr, ConstPair &constPair)
Definition: arithm_expr_evaluator.cpp:870
virtual void visit(ShPtr< GlobalVarDef > varDef) override
Definition: ordered_all_visitor.cpp:95
void resolveOverflows(bool overflow, llvm::APFloat::opStatus opStatus)
Call resolve methods for overflow.
Definition: arithm_expr_evaluator.cpp:1142
std::map< ShPtr< Variable >, ShPtr< Constant > > VarConstMap
Mapping of variables to constants.
Definition: arithm_expr_evaluator.h:61
virtual void resolveTypesBinaryOp(ConstPair &constPair)
Definition: arithm_expr_evaluator.cpp:868
static APSIntPair getAPSIntsFromConstants(const std::optional< ConstIntPair > &constIntPair)
Create APSIntPair from constIntPair and return it.
Definition: arithm_expr_evaluator.cpp:1117
virtual std::optional< bool > toBool(ShPtr< Expression > expr, VarConstMap varValues=VarConstMap())
Evaluate expr and return if result is bool.
Definition: arithm_expr_evaluator.cpp:139
static APFloatPair getAPFloatsFromConstants(const std::optional< ConstFloatPair > &ConstFloatPair)
Create APFloatPair from constFloatPair and return it.
Definition: arithm_expr_evaluator.cpp:1130
ArithmExprEvaluator()=default
virtual std::string getId() const =0
Returns the ID of the optimizer.
ShPtr< Constant > getOperandForUnaryOpAndResolveTypes()
Get operand from stackOfResults and call resolve types method that is implemented in sub-evaluators.
Definition: arithm_expr_evaluator.cpp:956
bool canBeEvaluated
Signalizes if evaluation can go on.
Definition: arithm_expr_evaluator.h:90
bool(llvm::APInt::*)(const llvm::APInt &) const LLVMBoolAPIntOp
Definition: arithm_expr_evaluator.h:96
llvm::APInt(llvm::APInt::*)(const llvm::APInt &, bool &) const LLVMAPIntAPIntBoolOp
Definition: arithm_expr_evaluator.h:94
llvm::APFloat::opStatus(llvm::APFloat::*)(const llvm::APFloat &, llvm::APFloat::roundingMode) LLVMAPFloatOp
Definition: arithm_expr_evaluator.h:100
std::pair< ShPtr< Constant >, ShPtr< Constant > > ConstPair
Pair of constants.
Definition: arithm_expr_evaluator.h:55
const VarConstMap * varValues
Map of constants that substitute variables in evaluation.
Definition: arithm_expr_evaluator.h:239
ShPtr< ConstFloat > performOperationOverApFloat(const std::optional< ConstFloatPair > &constFloatPair, LLVMAPFloatOp op, llvm::APFloat::opStatus &status)
Perform the operation specified by op on the first and the second operand in constFloatPair.
Definition: arithm_expr_evaluator.cpp:1089
static bool isConstantZero(ShPtr< Constant > constant)
Return if constant is a ConstInt or a ConstFloat zero.
Definition: arithm_expr_evaluator.cpp:1155
llvm::APInt(llvm::APInt::*)(const llvm::APInt &) const LLVMAPIntAPIntOp
Definition: arithm_expr_evaluator.h:98
std::pair< llvm::APFloat, llvm::APFloat > APFloatPair
Pair of llvm::APFloat.
Definition: arithm_expr_evaluator.h:43
std::pair< llvm::APSInt, llvm::APSInt > APSIntPair
Pair of llvm::APSInt.
Definition: arithm_expr_evaluator.h:40
std::pair< ShPtr< ConstInt >, ShPtr< ConstInt > > ConstIntPair
Pair of integer constants.
Definition: arithm_expr_evaluator.h:46
ShPtr< ConstInt > performOperationOverApInt(const std::optional< ConstIntPair > &constIntPair, LLVMAPIntAPIntBoolOp op, bool &overflow)
Perform the operation specified by op on the first and the second operand in constIntPair.
Definition: arithm_expr_evaluator.cpp:1011
A visitor that visits everything in an ordered way.
Definition: ordered_all_visitor.h:44
virtual void visit(ShPtr< GlobalVarDef > varDef) override
Definition: ordered_all_visitor.cpp:95
A mixin to make classes non-copyable.
Definition: non_copyable.h:27
A base class for all constants.
A library providing API for working with back-end IR.
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
Definition: archive_wrapper.h:19
A mixin to make classes non-copyable.
A visitor that visits everything in an ordered way.
Aliases for several useful types.