-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintercode.cpp
68 lines (61 loc) · 1.1 KB
/
intercode.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// Created by oruret on 2018/6/29.
//
#include "intercode.h"
void InterInst::init() {
op = OP_NOP;
this->result = NULL;
this->target = NULL;
this->arg1 = NULL;
this->fun = NULL;
this->arg2 = NULL;
first = false;
isDead = false;
}
/*
* 一般运算指令
*/
InterInst::InterInst(Operator op,Var*rs,Var*arg1,Var*arg2){
init();
this->op = op;
this->result = rs;
this->arg1 = arg1;
this->arg2 = arg2;
}
/*
* 函数调用指令
*/
InterInst::InterInst(Operator op, Fun *fun, Var *rs) {
init();
this->op = op;
this->result = rs;
this->fun = fun;
this->arg2 = NULL;
}
/*
* 参数进栈指令
*/
InterInst::InterInst(Operator op, Var *arg1) {
init();
this->op = op;
this->result = NULL;
this->arg1 = arg1;
this->arg2 = NULL;
}
/*
* 产生唯一标号
*/
InterInst::InterInst() {
init();
label = GenIR::genLb();
}
/*
* 条件跳转指令
*/
InterInst::InterInst(Operator op, InterInst *tar, Var *arg1, Var *arg2) {
init();
this->op = op;
this->target = tar;
this->arg2 = arg2;
this->arg1 = arg1;
}