-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeiko.mli
More file actions
84 lines (63 loc) · 2.65 KB
/
keiko.mli
File metadata and controls
84 lines (63 loc) · 2.65 KB
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
(* ppc/keiko.mli *)
(* |op| -- type of picoPascal operators *)
type op = Plus | Minus | Times | Div | Mod | Eq
| Uminus | Lt | Gt | Leq | Geq | Neq
| And | Or | Not | PlusA | Lsl | Lsr | Asr | BitAnd | BitOr | BitNot
val fOp : op -> Print.arg
(* |symbol| -- global symbols *)
type symbol = string
val nosym : symbol
val gensym : unit -> symbol
(* |codelab| -- type of code labels *)
type codelab = int
val nolab : codelab
(* |label| -- generate a code label *)
val label : unit -> codelab
val fLab : codelab -> Print.arg
(* |inst| -- type of intermediate instructions *)
type inst =
CONST of int (* Constant (value) *)
| GLOBAL of symbol (* Global address (symbol) *)
| LOCAL of int (* Local address (offset) *)
| REGVAR of int (* Register (index) *)
| LOADC (* Load char *)
| LOADW (* Load word *)
| STOREC (* Store char *)
| STOREW (* Store word *)
| ARG of int (* Pass argument (index) *)
| SLINK (* Pass static link *)
| PCALL of int (* Call procedure (nparams) *)
| RESULTW (* Procedure result *)
| MONOP of op (* Perform unary operation (op) *)
| BINOP of op (* Perform binary operation (op) *)
| BOUND (* Array bound check *)
| NCHECK (* Null pointer check *)
| LABEL of codelab (* Set code label *)
| JUMP of codelab (* Unconditional branch (dest) *)
| JUMPC of op * codelab (* Conditional branch (cond, dest) *)
| JCASE of codelab list * codelab (* Jump table *)
(* Extra instructions *)
| LINE of int (* Line number *)
| NOP
| SEQ
| AFTER (* Expression with side effect *)
| DEFTMP of int
| TEMP of int (* Temporary *)
(* |Inst| -- printf format for instructions *)
val fInst : inst -> Print.arg
(* |do_monop| -- evaluate unary operation *)
val do_monop : op -> int -> int
(* |do_binop| -- evaluate binary operation *)
val do_binop : op -> int -> int -> int
(* |negate| -- find opposite for comparison op *)
val negate : op -> op
(* Operator trees *)
(* |optree| -- type of operator trees *)
type optree = inst Util.list_tree
(* |canon| -- eliminate SEQ, NOP, AFTER nodes *)
val canon : optree -> optree list
(* |flatten| -- move args before calls *)
val flatten : optree list -> optree list
val string_of_inst : inst -> string
(* |print_optree| -- output operator tree on stdout with line breaking *)
val print_optree : string -> optree -> unit