00001
00002
00003
00004
00005
00006
00007
00008 #ifndef LOOP_H_
00009 #define LOOP_H_
00010
00011 #include<set>
00012 #include <vector>
00013 #include <string>
00014 #include <vector>
00015 using namespace std;
00016
00017 namespace il
00018 {
00019 class node;
00020 }
00021
00022 namespace sail{
00023
00024 class BasicBlock;
00025 class CfgEdge;
00026 class Loop;
00027 class Instruction;
00028
00029 class Loop {
00030
00031 private:
00032 BasicBlock* header;
00033 BasicBlock* exit_block;
00034 set<CfgEdge*> backedges;
00035 set<BasicBlock*> body;
00036 int loop_id;
00037 set<Loop*> parent_loops;
00038
00039
00040
00041
00042
00043
00044
00045 set<BasicBlock*> exit_blocks;
00046
00047
00048 public:
00049 Loop(CfgEdge* backedge);
00050 void add_backedge(CfgEdge* backedge);
00051 BasicBlock* get_header() const;
00052 BasicBlock* get_exit_block() const;
00053 set<BasicBlock*>& get_body();
00054 set<CfgEdge*>& get_backedges();
00055 set<BasicBlock*>& get_exit_blocks();
00056 virtual ~Loop();
00057 string to_string() const;
00058 void get_edges(set<CfgEdge*> & edges);
00059 void make_unique_exit(set<BasicBlock*> & basic_blocks);
00060 void add_parent_loop(Loop *p);
00061 void insert_recursive_calls(set<BasicBlock*> & basic_blocks);
00062
00063
00064
00065 private:
00066 void construct_body(CfgEdge* backedge);
00067 void update_parents(BasicBlock *b, bool add_to_self);
00068
00069 };
00070
00071 void reset_loop_count();
00072
00073 class LoopCompare:public binary_function<Loop*, Loop*, bool> {
00074
00075 public:
00076 bool operator()(const Loop* b1, const Loop* b2) const;
00077 };
00078
00079 }
00080
00081
00082
00083 #endif