-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtigertree.sml
More file actions
44 lines (35 loc) · 900 Bytes
/
Copy pathtigertree.sml
File metadata and controls
44 lines (35 loc) · 900 Bytes
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
structure tigertree =
struct
open tigertemp
open tigerutils
datatype exp = CONST of int
| NAME of tigertemp.label
| TEMP of tigertemp.temp
| BINOP of binop * exp * exp
| MEM of exp
| CALL of exp * exp list
| ESEQ of stm * exp
and stm = MOVE of exp * exp
| EXP of exp
| JUMP of exp * tigertemp.label list
| CJUMP of relop * exp * exp * tigertemp.label * tigertemp.label
| SEQ of stm * stm
| LABEL of tigertemp.label
and binop = PLUS | MINUS | MUL | DIV
| AND | OR | LSHIFT | RSHIFT
| ARSHIFT | XOR
and relop = EQ | NE | LT | GT | LE | GE
| ULT | ULE | UGT | UGE
fun seq l = List.foldr (fn (x,y) => SEQ(x,y)) (List.last l) (init l)
fun notRel r = case r of
EQ => NE
| NE => EQ
| LT => GE
| GT => LE
| LE => GT
| GE => LT
| ULT => UGE
| ULE => UGT
| UGT => ULE
| UGE => ULT
end