-
Notifications
You must be signed in to change notification settings - Fork 0
/
optMips.h
77 lines (63 loc) · 2.72 KB
/
optMips.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef COMPILER_OPTMIPS_H
#define COMPILER_OPTMIPS_H
#include "stdafx.h"
#include "midCode.h"
#include "tempVarTable.h"
#include "output.h"
#include "optimize.h"
class OptMips {
public:
OptMips(Output *output, MidCode *midCode);
~OptMips();
void geneMips();
TempVar& getVar(std::string &var, bool needLoad=false, SyntaxType syntaxType=INT);
void geneLoadVar(const std::string ®, const std::string &addr, bool isGlobal, SyntaxType syntaxType);
void geneLoadArray(const std::string ®, const std::string &addrReg, bool isGlobal, SyntaxType syntaxType);
void geneStoreVar(const std::string ®, const std::string &addr, bool isGlobal, SyntaxType syntaxType);
void geneStoreArray(const std::string ®, const std::string &addrReg, bool isGlobal, SyntaxType syntaxType);
void geneStoreFunc(const std::string ®, const std::string &addr,
const std::string &addrReg, SyntaxType syntaxType);
void geneExpr(const std::string &resReg, const std::string ®,
const std::string ®OrVal, const std::string &op);
void geneLi(const std::string ®, const std::string &val);
void geneJ(const std::string &label);
void geneJar(std::string &func);
void geneJr();
void geneJump(std::string &label, const std::string ®1, const std::string ®2, std::string &op);
void geneLabel(std::string &label);
void geneRead(SyntaxType syntaxType);
void printString(std::string &s);
void printVar(SyntaxType syntaxType);
void geneMove(const std::string ®1, const std::string ®2);
void printEnter();
void geneSignalVarAssignMips(MdCode &mdCode);
void geneConAssignMips(MdCode &mdCode);
void geneArrayRefMips(MdCode &mdCode);
void geneArrayAssignMips(MdCode &mdCode);
void geneArrayDefMips(MdCode &mdCode);
void geneDirJumpMips(MdCode &mdCode);
void geneExprMips(MdCode &mdCode);
void geneJumpMips(MdCode &mdCode);
void geneConDefMips(MdCode &mdCode);
void geneVarDefMips(MdCode &mdCode);
void geneCallFuncMips(MdCode &mdCode);
void geneFuncDefMips(MdCode &mdCode);
void geneLabelMips(MdCode &mdCode);
void geneReturnMips(MdCode &mdCode);
void geneScanfMips(MdCode &mdCode);
void genePrintfMips(MdCode &mdCode);
void geneEndFuncMips();
void geneExitMips();
void geneInitRegsMips();
int stringToInt(const std::string &val, SyntaxType syntaxType);
bool varIsConst(SyntaxType syntaxType);
void initRegAllVars();
void initRegGlobalVars();
private:
MidCode *midCode;
Output *output;
TempVarTable *tempVarTable;
Optimize *optimize;
bool firstFunc = true;
};
#endif //COMPILER_OPTMIPS_H