Debian Codegraph @

lib/mlrisc-lib/MLRISC/Tools/basis.mdl

raw
1 (*
2 * The standard basis used in our lambda RTL language.
3 *)
4 structure Basis =
5 struct
6 (* Primitive types *)
7 type #n bits (* a value that is n bits wide *)
8 type #n cell (* a cell containing an n-bit value *)
9 type bool (* a boolean *)
10 type effect (* an action *)
11 type (#n, 'a) list (* an n-element list of type 'a *)
12 type string
13
14 type int
15 type word
16
17 type operand
18 type label
19
20 (* We are allowed to use map in the basis.
21 * This is the only higher order function we have.
22 *)
23 val map : ('a -> 'b) -> (#n, 'a) list -> (#n, 'b) list
24
25 val := : #n bits * #n bits -> effect
26 val ??? : #n bits
27 val label : label -> #n bits
28 val operand : operand -> #n bits
29
30 (* Signed/unsigned promotion *)
31 val sx : #n bits -> #m bits
32 val zx : #n bits -> #m bits
33
34 (* Integer operators *)
35 val ~ notb negt : #n bits -> #n bits
36 val + - muls mulu divs divu quots rems remu
37 : #n bits * #n bits -> #n bits
38 val andb orb xorb eqvb << >> ~>> : #n bits * #n bits -> #n bits
39 val addt subt mult divt quott remt : #n bits * #n bits -> #n bits
40
41 (* Boolean operators *)
42 val cond : bool * #n bits * #n bits -> #n bits
43 val not : bool -> bool
44 val andalso : bool * bool -> bool
45 val orelse : bool * bool -> bool
46
47 (* Integer comparisons *)
48 val == <> > < <= >= ltu leu gtu geu : #n bits * #n bits -> bool
49
50 (* Floating point operators *)
51 val fadd fsub fmul fdiv : #n bits * #n bits -> #n bits
52 val fabs fneg : #n bits -> #n bits
53
54 (* Floating point comparisons *)
55 val |?| |!<=>| |==| |?=| |!<>| |!?>=| |<| |?<|
56 |!>=| |!?>| |<=| |?<=| |!>| |!?<=| |>| |?>|
57 |!<=| |!?<| |>=| |?>=| |!<| |!?=| |<>| |!=|
58 |!?| |<=>| |?<>| : #n bits * #n bits -> bool
59
60 (* Effect combinators *)
61 val || : effect * effect -> effect (* parallel effects *)
62 val Nop : effect (* empty effect *)
63 val Jmp : #n bits -> effect (* jump to address *)
64 val Call : #n bits -> effect (* call address *)
65 val Ret : effect (* return *)
66 val If : bool * effect * effect -> effect (* if/then/else *)
67
68 fun Kill x = x := ???
69 fun Use x = ??? := x
70
71 (* Hidden definitions *)
72 val intConst : int -> #n bits
73 val wordConst : word -> #n bits
74 val newOp : string -> 'a
75 end