Debian Codegraph @

lib/mlrisc-lib/MLRISC/demo/demo-types.sml

raw
1
2 (*---------------------------------------------------------------------------
3 * First, some front-end dependent stuff. Typically, you only need
4 * one instance of these things for each source language.
5 *---------------------------------------------------------------------------*)
6
7 (*
8 * User defined constant type. Dummy for now.
9 * In practice, you'll want to use this type to implement constants with
10 * values that cannot be determined until final code generation, e.g.
11 * stack frame offset.
12 *)
13 structure UserConst =
14 struct
15 type const = unit
16 fun toString() = ""
17 fun hash() = 0w0
18 fun valueOf _ = 0
19 fun == _ = true
20 end
21
22 (*
23 * Instantiate label expressions with respect to user defined constants.
24 * This type is somewhat misnamed; it is used to represent constant
25 * expressions.
26 *)
27 (* structure LabelExp = LabelExp(UserConst) *)
28
29 (*
30 * User defined datatype for representing aliasing. Dummy for now.
31 * You'll need this to represent aliasing information.
32 *)
33 structure UserRegion =
34 struct
35 type region = unit
36 fun toString () = ""
37 val memory = ()
38 val stack = ()
39 val readonly = ()
40 val spill = ()
41 end
42
43 (*
44 * User defined datatype for representing pseudo assembly operators.
45 * Dummy for now.
46 *
47 * You'll need this to represent assembler directives.
48 *)
49 structure UserPseudoOps =
50 struct
51 type pseudo_op = unit
52 fun toString () = ""
53 fun emitValue _ = ()
54 fun sizeOf _ = 0
55 fun adjustLabels _ = true
56 end
57
58
59 (*
60 * Instruction stream datatype.
61 * This is just a simple record type used by MLRISC to represent
62 * instruction streams.
63 *)
64 (*structure Stream = InstructionStream(UserPseudoOps)*)
65
66 (*
67 * Client defined extensions. None for now.
68 * You'll need this only if you need to extend the set of MLTREE operators
69 *)
70 structure UserExtension =
71 struct
72
73 type ('s,'r,'f,'c) sx = ('s,'r,'f,'c) AMD64InstrExt.sext
74 type ('s,'r,'f,'c) rx = unit
75 type ('s,'r,'f,'c) fx = unit
76 type ('s,'r,'f,'c) ccx = unit
77
78 end
79
80 (*
81 * This module controls how we handle user extensions. Since we don't
82 * have any yet. This is just a bunch of dummy routines.
83 *)
84 functor UserMLTreeExtComp
85 ( structure I : AMD64INSTR where T.Extension = UserExtension
86 structure TS : MLTREE_STREAM where T = I.T
87 structure CFG : CONTROL_FLOW_GRAPH where I = I and P = TS.S.P
88 ) : MLTREE_EXTENSION_COMP =
89 struct
90 structure T = TS.T
91 structure TS = TS
92 structure I = I
93 structure CFG = CFG
94 structure C = I.C
95
96 structure CompInstrExt = AMD64CompInstrExt (
97 structure I = I
98 structure TS = TS
99 structure CFG = CFG)
100
101 type reducer =
102 (I.instruction,C.cellset,I.operand,I.addressing_mode,CFG.cfg) TS.reducer
103
104 val compileSext = CompInstrExt.compileSext
105
106 fun compileRext _ = raise Fail "AMD64CompExtFn.compileRext"
107 fun compileFext _ = raise Fail "AMD64CompExtFn.compileFext"
108 fun compileCCext _ = raise Fail "AMD64CompExtFn.compileCCext"
109 (*
110 structure T = T
111 structure I = I
112 structure C = I.C
113 type reducer =
114 (I.instruction,C.cellset,I.operand,I.addressing_mode) T.reducer
115 fun unimplemented _ = MLRiscErrorMsg.impossible "UserMLTreeExtComp"
116 val compileSext = unimplemented
117 val compileRext = unimplemented
118 val compileFext = unimplemented
119 val compileCCext = unimplemented
120 *)
121 end
122