-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (42 loc) · 1.21 KB
/
main.cpp
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
#include "compiler.h"
FILE *testfile = fopen("testfile.txt", "r");/* NOLINT */
ofstream out("output.txt");/* NOLINT */
ofstream err("error.txt");/* NOLINT */
ofstream midGross("18373647_xpy_before_optimize.txt");/* NOLINT */
ofstream midOptimize("18373647_xpy_after_optimize.txt");/* NOLINT */
ofstream mips("mips.txt");/* NOLINT */
ofstream mipsTest("mips.asm");/* NOLINT */
int main() {
synAnalysis();
if (outputErr.empty()) {
copyPropagation();
copyPropagation();
multiSimplifier();
copyPropagation();
changeSameName();
counterTempVar();
allocateRegisterForGlobalVar();
outputIntermediateCode();
for (auto &outputAn : intermediateCode) {
midGross << outputAn << endl;
}
generateMIPSAssembly();
for (auto &outputAn : mipsCode) {
mips << outputAn << endl;
}
for (auto &outputAn : mipsCode) {
mipsTest << outputAn << endl;
}
} else {
for (auto &outputAn : outputErr) {
err << outputAn << endl;
}
}
fclose(testfile);
out.close();
err.close();
midGross.close();
midOptimize.close();
mips.close();
return 0;
}