-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBasicBlock.h
42 lines (37 loc) · 1003 Bytes
/
BasicBlock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef BASIC_BLOCK_H_INCLUDED
#define BASIC_BLOCK_H_INCLUDED
#include <vector>
#include "Instruction.h"
#include <string>
#include <fstream>
/*
Defines the structure of basic blocks
*/
using namespace std;
class Instruction;
class BasicBlock {
private:
std::vector<Instruction*> instructions;
bool closed;
static bool lastClosedWithBranch;
public:
int referenceCounter;//How many instructions can branch to this basic block
int instructionCounter;//Number of instructions in this basic block
string name;
BasicBlock(string name = "");
BasicBlock(int instructionCounter);
void Add(Instruction* instruction);
std::vector<BasicBlock*> trueSuccessor;//deprecated
std::vector<BasicBlock*> falseSuccessor;//deprecated
void Close();
bool IsClosed();
Instruction* LastInstruction();
void Emit(ofstream &os);
int Length();
void PassForBranch();
bool endWithBranch;
bool isLive();
void Optimize();
void Clean();
};
#endif