-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeObject.hpp
65 lines (49 loc) · 1.12 KB
/
CodeObject.hpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef CODE_OBJECT_HPP
#define CODE_OBJECT_HPP
#include<vector>
#include<string>
#include<set>
#include "AST.hpp"
using namespace std;
using namespace ast;
namespace tac {
class CodeLine {
public:
string arg1;
string arg2;
string arg3;
string arg4;
set<CodeLine *> predecessors;
set<CodeLine *> successors;
set<string> genSet;
set<string> killSet;
set<string> inSet;
set<string> outSet;
CodeLine(string arg1, string arg2, string arg3, string arg4);
string stringify() {
return arg1 + " " + arg2 + " " + arg3 + " " + arg4;
}
};
class CodeObject {
public:
vector<CodeLine *> codeList;
vector<bool> reset;
set<string> tempReg;
int temporary;
ast::Type type; // more specifically for value type (int, float, str)
void addLine(CodeLine * line);
void addRegister(string reg);
void print();
void optimizeTiny();
string getType();
private:
void configureCFG();
void createGenKillSet();
void createInOutSet();
void allocateRegisters();
void createReset();
};
CodeObject * merge(CodeObject * left, CodeObject * right);
CodeObject * buildTAC(ASTNode * node);
}
#endif