2018-12-31 22:47:31 -05:00
|
|
|
#ifndef TDL_INCLUDE_IR_BASIC_BLOCK_H
|
|
|
|
#define TDL_INCLUDE_IR_BASIC_BLOCK_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "value.h"
|
|
|
|
|
|
|
|
namespace tdl{
|
|
|
|
namespace ir{
|
|
|
|
|
|
|
|
class context;
|
|
|
|
class function;
|
2019-01-02 01:06:43 -05:00
|
|
|
class instruction;
|
2018-12-31 22:47:31 -05:00
|
|
|
|
|
|
|
/* Basic Block */
|
|
|
|
class basic_block: public value{
|
|
|
|
public:
|
2019-01-02 01:06:43 -05:00
|
|
|
// Accessors
|
2018-12-31 22:47:31 -05:00
|
|
|
function* get_parent();
|
2019-01-02 01:06:43 -05:00
|
|
|
instruction* get_first_non_phi_or_dbg();
|
|
|
|
// Iterators
|
|
|
|
instruction* begin();
|
|
|
|
instruction* end();
|
|
|
|
// CFG
|
|
|
|
const std::vector<basic_block*>& get_predecessors() const;
|
|
|
|
void add_predecessor(basic_block* pred);
|
2018-12-31 22:47:31 -05:00
|
|
|
// Factory functions
|
|
|
|
static basic_block* create(context &ctx, const std::string &name, function *parent);
|
|
|
|
|
|
|
|
private:
|
|
|
|
context &ctx_;
|
|
|
|
std::string name_;
|
|
|
|
function *parent_;
|
2019-01-02 01:06:43 -05:00
|
|
|
std::vector<basic_block*> preds_;
|
2018-12-31 22:47:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|