retdec
sub_optimizer.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_OPTIMIZER_OPTIMIZERS_SIMPLIFY_ARITHM_EXPR_SUB_OPTIMIZER_H
8 #define RETDEC_LLVMIR2HLL_OPTIMIZER_OPTIMIZERS_SIMPLIFY_ARITHM_EXPR_SUB_OPTIMIZER_H
9 
10 #include <string>
11 
17 
18 namespace retdec {
19 namespace llvmir2hll {
20 
25 public:
29  virtual std::string getId() const = 0;
30  virtual bool tryOptimize(ShPtr<Expression> expr);
31 
32 protected:
34 
36  void optimizeExpr(ShPtr<Expression> oldExpr, ShPtr<Expression> newExpr);
38 
39 protected:
42 
43 private:
45 };
46 
47 } // namespace llvmir2hll
48 } // namespace retdec
49 
50 #endif
A base class for all evaluators.
A visitor that visits everything in an ordered way.
Definition: ordered_all_visitor.h:44
A base class for all simplify arithmetical expression optimizations.
Definition: sub_optimizer.h:24
virtual std::string getId() const =0
Returns the ID of the optimizer.
bool tryOptimizeAndReturnIfCodeChanged(ShPtr< Expression > expr)
Start traversal in abstract syntax tree.
Definition: sub_optimizer.cpp:67
ShPtr< ArithmExprEvaluator > arithmExprEvaluator
The used evaluator of arithmetical expressions.
Definition: sub_optimizer.h:41
void optimizeExpr(ShPtr< Expression > oldExpr, ShPtr< Expression > newExpr)
Optimize expression from oldExpr to newExpr.
Definition: sub_optimizer.cpp:49
bool codeChanged
Definition: sub_optimizer.h:44
bool isConstFloatOrConstInt(ShPtr< Expression > expr) const
Check if expression is a ConstInt or ConstFloat.
Definition: sub_optimizer.cpp:81
SubOptimizer(ShPtr< ArithmExprEvaluator > arithmExprEvaluator)
Constructs the SubOptimizer.
Definition: sub_optimizer.cpp:27
virtual bool tryOptimize(ShPtr< Expression > expr)
Run optimization and try to optimize.
Definition: sub_optimizer.cpp:39
A mixin to make classes non-copyable.
Definition: non_copyable.h:27
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.
Factory that creates instances of classes derived from SubOptimizer.
Aliases for several useful types.