retdec
optimizer.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_OPTIMIZER_OPTIMIZER_H
8 #define RETDEC_LLVMIR2HLL_OPTIMIZER_OPTIMIZER_H
9 
10 #include <string>
11 
15 
16 namespace retdec {
17 namespace llvmir2hll {
18 
44 public:
46 
50  virtual std::string getId() const = 0;
51 
53 
65  template<class OptimizerType, typename... Args>
66  static ShPtr<Module> optimize(ShPtr<Module> module, Args &&... args) {
67  auto optimizer = std::make_shared<OptimizerType>(module,
68  std::forward<Args>(args)...);
69  return optimizer->optimize();
70  }
71 
72 protected:
73  virtual void doInitialization();
74  virtual void doOptimization();
75  virtual void doFinalization();
76 
77 protected:
80 };
81 
82 } // namespace llvmir2hll
83 } // namespace retdec
84 
85 #endif
A base class of all optimizers.
Definition: optimizer.h:43
virtual std::string getId() const =0
Returns the ID of the optimizer.
ShPtr< Module > optimize()
Performs all the optimizations of the specific optimizer.
Definition: optimizer.cpp:39
virtual void doInitialization()
Performs pre-optimization matters.
Definition: optimizer.cpp:53
static ShPtr< Module > optimize(ShPtr< Module > module, Args &&... args)
Creates an instance of OptimizerType with the given arguments and optimizes the given module by it.
Definition: optimizer.h:66
ShPtr< Module > module
The module that is being optimized.
Definition: optimizer.h:79
virtual void doOptimization()
Performs the optimization.
Definition: optimizer.cpp:64
virtual void doFinalization()
Performs post-optimization matters.
Definition: optimizer.cpp:73
Optimizer(ShPtr< Module > module)
Constructs a new optimizer.
Definition: optimizer.cpp:22
A visitor that visits everything in an ordered way.
Definition: ordered_all_visitor.h:44
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.
Declarations, aliases, macros, etc. for the use of smart pointers.