-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbril_core_constants.py
100 lines (65 loc) · 1.14 KB
/
bril_core_constants.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
ARGS = "args"
DEST = "dest"
LABELS = "labels"
TYPE = "type"
OP = "op"
VALUE = "value"
LABEL = "label"
FUNCS = "funcs"
NAME = "name"
INT = "int"
BOOL = "bool"
CONST = "const"
ADD = "add"
SUB = "sub"
MUL = "mul"
DIV = "div"
EQ = "eq"
LT = "lt"
GT = "gt"
LE = "le"
GE = "ge"
NOT = "not"
AND = "and"
OR = "or"
JMP = "jmp"
BR = "br"
CALL = "call"
RET = "ret"
ID = "id"
PRINT = "print"
NOP = "nop"
PHI = "phi"
BRIL_BINOPS = [
ADD, SUB, MUL, DIV,
EQ, LT, GT, LE, GE,
AND, OR,
]
COMP_OPS = [LT, GT, LE, GE, EQ]
LOGIC_OPS = [NOT, AND, OR]
BOOL_OPS = [NOT, AND, OR, LT, GT, LE, GE, EQ]
INT_OPS = [ADD, SUB, MUL, DIV]
BRIL_UNOPS = [NOT]
BRIL_CORE_OPS = [*BRIL_BINOPS, *BRIL_UNOPS]
BRIL_CORE_INSTRS = [
*BRIL_BINOPS, *BRIL_UNOPS,
JMP, BR, CALL, RET,
ID, PRINT, NOP, PHI, CONST,
]
BRIL_COMMUTE_BINOPS = [
ADD, MUL, AND, OR, EQ
]
BRIL_CORE_TYPES = [
INT, BOOL
]
TERMINATORS = [JMP, BR, RET]
OP_TO_TYPE = {**{b: BOOL for b in BOOL_OPS}, **{i: INT for i in INT_OPS}}
SIDE_EFFECT_OPS = [
PRINT, DIV
]
NUM_BINARY_ARGS = 2
NUM_UNARY_ARGS = 1
ARGUMENT = "argument"
INSTRS = "instrs"
FUNCTIONS = "functions"
MAIN = "main"