00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BASICBLOCK_H_
00009 #define BASICBLOCK_H_
00010
00011 #define INVALID_BLOCK_ID -1
00012
00013 #include <vector>
00014 #include <string>
00015 #include <set>
00016 #include "Block.h"
00017 using namespace std;
00018
00019 namespace sail {
00020
00021 class Instruction;
00022 class CfgEdge;
00023 class Symbol;
00024
00028 class BasicBlock: public Block {
00029 friend class boost::serialization::access;
00030
00031 template<class Archive>
00032 void serialize(Archive & ar, const unsigned int version)
00033 {
00034 ar & boost::serialization::base_object<sail::Block>(*this);
00035 ar & statements;
00036 ar & dominators;
00037 ar & post_dominators;
00038 }
00039
00040 private:
00041 vector<Instruction*> statements;
00042 set<BasicBlock*> dominators;
00043 set<BasicBlock*> post_dominators;
00044
00045
00046
00047 public:
00048 BasicBlock();
00049 BasicBlock(const BasicBlock& other);
00050 void add_statement(Instruction* inst);
00051 void add_statements(vector<Instruction*>& stmts);
00052 void set_dominators(set<BasicBlock*>& doms);
00053 void set_post_dominators(set<BasicBlock*>& pdoms);
00054 set<BasicBlock*>& get_dominators();
00055 set<BasicBlock*>& get_post_dominators();
00056 bool is_empty_block();
00057
00062 vector<Instruction*>& get_statements();
00063
00064 string to_string() const;
00065 string to_string(bool pretty_print, bool print_block_id = true) const;
00066 virtual string to_dotty(string prelude, bool pretty_print = true);
00067 virtual bool is_basicblock();
00068 virtual ~BasicBlock();
00069 };
00070
00071 }
00072
00073 #endif