annotate ppc/keiko.mli @ 1:b5139af1a420 tip basis

Fixed permissions on compile scripts
author Mike Spivey <mike@cs.ox.ac.uk>
date Fri, 13 Oct 2017 17:27:58 +0100
parents bfdcc3820b32
children
rev   line source
mike@0 1 (* ppc/keiko.mli *)
mike@0 2 (* Copyright (c) 2017 J. M. Spivey *)
mike@0 3
mike@0 4 (* |op| -- type of picoPascal operators *)
mike@0 5 type op = Plus | Minus | Times | Div | Mod | Eq
mike@0 6 | Uminus | Lt | Gt | Leq | Geq | Neq
mike@0 7 | And | Or | Not | Lsl | Lsr | Asr
mike@0 8 | BitAnd | BitOr | BitNot
mike@0 9
mike@0 10 val fOp : op -> Print.arg
mike@0 11
mike@0 12 (* |symbol| -- global symbols *)
mike@0 13 type symbol = string
mike@0 14
mike@0 15 val nosym : symbol
mike@0 16
mike@0 17 val gensym : unit -> symbol
mike@0 18
mike@0 19 (* |codelab| -- type of code labels *)
mike@0 20 type codelab
mike@0 21
mike@0 22 val nolab : codelab
mike@0 23
mike@0 24 (* |label| -- generate a code label *)
mike@0 25 val label : unit -> codelab
mike@0 26
mike@0 27 val fLab : codelab -> Print.arg
mike@0 28
mike@0 29 (* |code| -- type of intermediate instructions *)
mike@0 30 type code =
mike@0 31 CONST of int (* Constant (value) *)
mike@0 32 | GLOBAL of symbol (* Constant (symbol) *)
mike@0 33 | LOCAL of int (* Local address (offset) *)
mike@0 34 | LOAD of int (* Load (size) *)
mike@0 35 | STORE of int (* Store (size) *)
mike@0 36 | FIXCOPY (* Copy multiple values (size) *)
mike@0 37 | PCALL of int * int (* Call procedure (nparams, rsize) *)
mike@0 38 | RETURN of int (* Procedure result (rsize) *)
mike@0 39 | MONOP of op (* Perform unary operation (op) *)
mike@0 40 | BINOP of op (* Perform binary operation (op) *)
mike@0 41 | OFFSET (* Add address and offset *)
mike@0 42 | BOUND of int (* Array bound check (line) *)
mike@0 43 | NCHECK of int (* Null pointer check (line) *)
mike@0 44 | ERETURN of int (* Failure to return (line) *)
mike@0 45 | LABEL of codelab (* Set code label *)
mike@0 46 | JUMP of codelab (* Unconditional branch (dest) *)
mike@0 47 | JUMPC of op * codelab (* Conditional branch (cond, dest) *)
mike@0 48 | JCASE of codelab list (* Jump table *)
mike@0 49 | LINE of int (* Line number *)
mike@0 50
mike@0 51 (* Compressed instructions *)
mike@0 52 | LDL of int * int (* LDL (n, s) = LOCAL n / LOAD s *)
mike@0 53 | STL of int * int (* STL (n, s) = LOCAL n / STORE s *)
mike@0 54 | LDG of symbol * int (* LDG (x, s) = GLOBAL x / LOAD s *)
mike@0 55 | STG of symbol * int (* STG (x, s) = GLOBAL x / STORE s *)
mike@0 56 | LDNW of int (* LDNW n = CONST n / OFFSET / LOAD 4 *)
mike@0 57 | STNW of int (* STNW n = CONST n / OFFSET / STORE 4 *)
mike@0 58 | LDI of int (* LDI s = CONST s / TIMES / OFFSET / LOAD s *)
mike@0 59 | STI of int (* STI s = CONST s / TIMES / OFFSET / STORE s *)
mike@0 60 | JUMPCZ of op * codelab (* JUMPCZ (w, a) = CONST 0 / JUMPC (w, a) *)
mike@0 61
mike@0 62 | SEQ of code list (* Sequence of other instructions *)
mike@0 63 | NOP (* Null operation *)
mike@0 64
mike@0 65 (* canon -- eliminate SEQ and NOP nodes and unneeded LINE's *)
mike@0 66 val canon : code -> code
mike@0 67
mike@0 68 (* |fInst| -- printf format for instructions *)
mike@0 69 val fInst : code -> Print.arg
mike@0 70
mike@0 71 (* |output| -- output code sequence *)
mike@0 72 val output : code -> unit
mike@0 73
mike@0 74 (* |do_monop| -- evaluate unary operation *)
mike@0 75 val do_monop : op -> int -> int
mike@0 76
mike@0 77 (* |do_binop| -- evaluate binary operation *)
mike@0 78 val do_binop : op -> int -> int -> int
mike@0 79
mike@0 80 (* |negate| -- find opposite for comparison op *)
mike@0 81 val negate : op -> op