retdec
while_true_to_ufor_loop_optimizer.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_OPTIMIZER_OPTIMIZERS_WHILE_TRUE_TO_UFOR_LOOP_OPTIMIZER_H
8 #define RETDEC_LLVMIR2HLL_OPTIMIZER_OPTIMIZERS_WHILE_TRUE_TO_UFOR_LOOP_OPTIMIZER_H
9 
13 
14 namespace retdec {
15 namespace llvmir2hll {
16 
17 class ValueAnalysis;
18 
27 public:
29 
30  virtual std::string getId() const override { return "WhileTrueToUForLoop"; }
31 
32 private:
33  virtual void doOptimization() override;
34 
43 
47  virtual void visit(ShPtr<WhileLoopStmt> stmt) override;
49 
50 private:
53 
56 
59 
62 
65 };
66 
67 } // namespace llvmir2hll
68 } // namespace retdec
69 
70 #endif
A base class of all function optimizers.
Definition: func_optimizer.h:44
ShPtr< Module > module
The module that is being optimized.
Definition: optimizer.h:79
virtual void visit(ShPtr< GlobalVarDef > varDef) override
Definition: ordered_all_visitor.cpp:95
Optimizes while loops into universal for loops.
Definition: while_true_to_ufor_loop_optimizer.h:26
ShPtr< UForLoopStmt > tryConversionToUForLoop()
Tries to convert the "while true" loop into a universal for loop.
Definition: while_true_to_ufor_loop_optimizer.cpp:112
void initializeReplacement(ShPtr< WhileLoopStmt > stmt)
Initialize a new replacement.
Definition: while_true_to_ufor_loop_optimizer.cpp:82
ShPtr< WhileLoopStmt > whileLoop
While loop that is being optimized.
Definition: while_true_to_ufor_loop_optimizer.h:55
ShPtr< ValueAnalysis > va
Analysis of values.
Definition: while_true_to_ufor_loop_optimizer.h:52
void removeUselessSucessors(ShPtr< UForLoopStmt > forLoop)
Removes useless successors (if any) of the given universal for loop.
Definition: while_true_to_ufor_loop_optimizer.cpp:128
ShPtr< EmptyStmt > getLastEmptyStatement(ShPtr< Statement > stmts) const
Returns the last empty statement in the given statements.
Definition: while_true_to_ufor_loop_optimizer.cpp:120
void performReplacement(ShPtr< UForLoopStmt > forLoop)
Performs the replacement.
Definition: while_true_to_ufor_loop_optimizer.cpp:147
void removeStatementsToBeRemoved()
Removes statements that are to be removed after a successful optimization.
Definition: while_true_to_ufor_loop_optimizer.cpp:156
bool canBeOptimized
Can the loop be optimized?
Definition: while_true_to_ufor_loop_optimizer.h:61
ShPtr< SplittedWhileTrueLoop > splittedLoop
Splitted loop that is being optimized.
Definition: while_true_to_ufor_loop_optimizer.h:58
virtual void visit(ShPtr< GlobalVarDef > varDef) override
Definition: ordered_all_visitor.cpp:95
void tryReplacementWithUForLoop(ShPtr< WhileLoopStmt > whileLoop)
Tries to replace the given while loop with a universal for loop.
Definition: while_true_to_ufor_loop_optimizer.cpp:50
virtual std::string getId() const override
Returns the ID of the optimizer.
Definition: while_true_to_ufor_loop_optimizer.h:30
bool gatherInfoAboutOptimizedWhileLoop()
Gathers information about the loop.
Definition: while_true_to_ufor_loop_optimizer.cpp:94
StmtSet toRemoveStmts
Statements to be removed when the optimization is successful.
Definition: while_true_to_ufor_loop_optimizer.h:64
virtual void doOptimization() override
Performs the optimization on all functions in the module.
Definition: while_true_to_ufor_loop_optimizer.cpp:35
WhileTrueToUForLoopOptimizer(ShPtr< Module > module, ShPtr< ValueAnalysis > va)
Constructs a new optimizer.
Definition: while_true_to_ufor_loop_optimizer.cpp:28
A base class of all function optimizers.
Utilities for optimizers.
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
std::set< ShPtr< Statement > > StmtSet
Set of statements.
Definition: types.h:69
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.