comparison lab4/target.mli @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 (* lab4/target.mli *)
2 (* Copyright (c) 2017 J. M. Spivey *)
3
4 open Optree
5
6 (* |reg| -- type of Risc86 registers *)
7 type reg = R of int | R_fp | R_sp | R_pc | R_ip | R_any | R_temp | R_none
8
9 (* |fReg| -- format register for printing *)
10 val fReg : reg -> Print.arg
11
12 (* |volatile| -- list of caller-save registers *)
13 val volatile : reg list
14
15 (* |stable| -- list of callee-save registers *)
16 val stable : reg list
17
18 (* |operand| -- type of operands for assembly instructions *)
19 type operand = (* VALUE ASM SYNTAX *)
20 Const of int (* val #val *)
21 | Register of reg (* [reg] reg *)
22 | Index of reg * int (* [reg]+val [reg, #val] *)
23 | Index2 of reg * reg * int (* [r1]+[r2]<<n [r1, r2, LSL #n] *)
24 | Global of symbol (* lab lab *)
25 | Label of codelab (* lab lab *)
26
27 (* |fRand| -- format operand for printing *)
28 val fRand : operand -> Print.arg
29
30 (* |reg_of| -- extract register (or R_none) from operand *)
31 val reg_of : operand -> reg
32
33 (* |emit| -- emit an assembly language instruction *)
34 val emit : string -> operand list -> unit
35
36 (* |move_reg| -- emit a register-to-register move *)
37 val move_reg : reg -> reg -> unit
38
39 (* |emit_lab| -- place a label *)
40 val emit_lab : codelab -> unit
41
42 (* |emit_comment| -- insert a comment *)
43 val emit_comment : string -> unit
44
45 (* |emit_tree| -- Print an optree as a comment *)
46 val emit_tree : optree -> unit
47
48 (* |need_stack| -- ensure stack space *)
49 val need_stack : int -> unit
50
51 (* |preamble| -- emit first part of assembly language output *)
52 val preamble : unit -> unit
53
54 (* |postamble| -- emit last part of assembly language output *)
55 val postamble : unit -> unit
56
57 (* |start_proc| -- emit beginning of procedure *)
58 val start_proc : symbol -> int -> int -> unit
59
60 (* |end_proc| -- emit end of procedure *)
61 val end_proc : unit -> unit
62
63 (* |flush_proc| -- dump out code after failure *)
64 val flush_proc : unit -> unit
65
66 (* |emit_string| -- emit assembler code for string constant *)
67 val emit_string : symbol -> string -> unit
68
69 (* |emit_global| -- emit assembler code to define global variable *)
70 val emit_global : symbol -> int -> unit