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