Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/mltree/mltree.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/mltree/mltree.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 545 - (view) (download)

1 : monnier 245 (* mltree.sml
2 :     *
3 :     * COPYRIGHT (c) 1994 AT&T Bell Laboratories.
4 :     *
5 :     *)
6 :    
7 : george 545 functor MLTreeF(structure LabelExp : LABELEXP
8 : monnier 245 structure R : REGION
9 : monnier 429 structure S : INSTRUCTION_STREAM
10 : monnier 411 ) : MLTREE =
11 : monnier 245 struct
12 : george 545 structure LabelExp = LabelExp
13 :     structure Constant = LabelExp.Constant
14 : monnier 429 structure PseudoOp = S.P
15 :     structure Stream = S
16 : monnier 245 structure Region = R
17 : monnier 475 structure Basis = MLTreeBasis
18 : monnier 245
19 : monnier 475 type ty = Basis.ty
20 :     type fty = Basis.fty
21 : monnier 411 type var = int (* variable *)
22 :     type src = var (* source variable *)
23 :     type dst = var (* destination variable *)
24 :     type reg = var (* physical register *)
25 : george 545 type an = Annotations.annotation
26 : monnier 245
27 : monnier 475 datatype cond = datatype Basis.cond
28 :     datatype fcond = datatype Basis.fcond
29 : george 545 datatype rounding_mode = datatype Basis.rounding_mode
30 : monnier 475 datatype ext = datatype Basis.ext
31 :    
32 : monnier 411 (* phi-functions for SSA form *)
33 :     datatype phi =
34 : george 545 RPHI of ty * dst * src list
35 : monnier 411 | FPHI of fty * dst * src list
36 :     | CCPHI of dst * src list
37 :    
38 :     (* aliasing declarations
39 :     * These are used to define physical register bindings for SSA names
40 :     *)
41 : george 545 type alias = var * reg (* var is aliased to register *)
42 : monnier 411
43 : george 545 (* Statements/effects. These types are parameterized by the statement
44 :     * extension type. Unfortunately, this has to be made polymorphic to make
45 :     * it possible for recursive type definitions to work.
46 :     *
47 :     * Terms marked with rtl are used within the rtl language
48 :     *)
49 :     datatype ('s,'r,'f,'c) stm =
50 :     (* assignment *)
51 :     MV of ty * dst * ('s,'r,'f,'c) rexp (* rtl *)
52 :     | CCMV of dst * ('s,'r,'f,'c) ccexp
53 :     | FMV of fty * dst * ('s,'r,'f,'c) fexp
54 :    
55 :     (* parallel copies *)
56 :     | COPY of ty * dst list * src list (* rtl *)
57 : monnier 411 | FCOPY of fty * dst list * src list
58 : monnier 245
59 : george 545 (* control flow *)
60 :     | JMP of ctrls * ('s,'r,'f,'c) rexp * controlflow (* rtl *)
61 :     | BCC of ctrls * ('s,'r,'f,'c) ccexp * Label.label
62 :     | CALL of ('s,'r,'f,'c) rexp * controlflow * ('s,'r,'f,'c) mlrisc list * ('s,'r,'f,'c) mlrisc list *
63 :     ctrls * ctrls * Region.region (* rtl *)
64 :     | RET of ctrls * controlflow (* rtl *)
65 :     | JOIN of ctrls
66 :     | IF of ctrls * ('s,'r,'f,'c) ccexp *
67 :     ('s,'r,'f,'c) stm * ('s,'r,'f,'c) stm (* rtl *)
68 : monnier 245
69 : george 545 (* memory update: ea, data *)
70 :     | STORE of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp * Region.region
71 :     | FSTORE of fty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) fexp * Region.region
72 :    
73 :     (* control dependence *)
74 :     | REGION of ('s,'r,'f,'c) stm * ctrl
75 :    
76 :     | SEQ of ('s,'r,'f,'c) stm list (* sequencing *)
77 :     | DEFINE of Label.label (* define local label *)
78 :    
79 :     | ANNOTATION of ('s,'r,'f,'c) stm * an
80 :     | EXT of 's (* extension *)
81 :    
82 :     (* RTL operators:
83 :     * The following are used internally for describing instruction semantics.
84 :     * The frontend must not use these.
85 : monnier 411 *)
86 : george 545 | PHI of int (* a phi-function at some block id *)
87 :     | PINNED of ('s,'r,'f,'c) stm (* pinned statement *)
88 :     | RTL of {hash:word ref, attribs:Basis.attribs, e:('s,'r,'f,'c) stm}
89 : monnier 411
90 : george 545 and ('s,'r,'f,'c) rexp =
91 :     REG of ty * reg (* rtl *)
92 : monnier 411
93 :     (* sizes of constants are inferred by context *)
94 : george 545 | LI of int (* rtl *)
95 :     | LI32 of Word32.word (* rtl *)
96 :     | LI64 of Word64.word (* rtl *)
97 : monnier 245 | LABEL of LabelExp.labexp
98 :     | CONST of Constant.const
99 :    
100 : george 545 | NEG of ty * ('s,'r,'f,'c) rexp
101 :     | ADD of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
102 :     | SUB of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
103 : monnier 245
104 : monnier 411 (* signed multiplication etc. *)
105 : george 545 | MULS of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
106 :     | DIVS of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
107 :     | QUOTS of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
108 :     | REMS of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
109 : monnier 245
110 : monnier 411 (* unsigned multiplication etc. *)
111 : george 545 | MULU of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
112 :     | DIVU of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
113 :     | REMU of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
114 : monnier 245
115 : monnier 411 (* trapping versions of above. These are all signed *)
116 : george 545 | NEGT of ty * ('s,'r,'f,'c) rexp
117 :     | ADDT of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
118 :     | SUBT of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
119 :     | MULT of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
120 :     | DIVT of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
121 :     | QUOTT of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
122 :     | REMT of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
123 : monnier 245
124 : george 545 (* bit operations *)
125 :     | ANDB of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
126 :     | ORB of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
127 :     | XORB of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
128 :     | NOTB of ty * ('s,'r,'f,'c) rexp (* rtl *)
129 : monnier 245
130 : george 545 | SRA of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* value, shift *) (* rtl *)
131 :     | SRL of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
132 :     | SLL of ty * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
133 : monnier 411
134 : george 545 (* type promotion/conversion *)
135 :     | CVTI2I of ty * ext * ty * ('s,'r,'f,'c) rexp (* signed extension *) (* rtl *)
136 :     | CVTF2I of ty * rounding_mode * fty * ('s,'r,'f,'c) fexp (* rtl *)
137 : monnier 411
138 : george 545 (*
139 :     * COND(ty,cc,e1,e2):
140 :     * Evaluate into either e1 or e2, depending on cc.
141 :     * Both e1 and e2 are allowed to be evaluated eagerly.
142 :     *)
143 :     | COND of ty * ('s,'r,'f,'c) ccexp * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp (* rtl *)
144 : monnier 411
145 :     (* integer load *)
146 : george 545 | LOAD of ty * ('s,'r,'f,'c) rexp * Region.region (* rtl *)
147 : monnier 411
148 : george 545 (* predication *)
149 :     | PRED of ('s,'r,'f,'c) rexp * ctrl
150 : monnier 245
151 : george 545 | LET of ('s,'r,'f,'c) stm * ('s,'r,'f,'c) rexp
152 : monnier 411
153 : george 545 | REXT of ty * 'r
154 : monnier 411
155 : george 545 | MARK of ('s,'r,'f,'c) rexp * an
156 : monnier 411
157 : george 545 and ('s,'r,'f,'c) fexp =
158 : monnier 411 FREG of fty * src
159 : george 545 | FLOAD of fty * ('s,'r,'f,'c) rexp * Region.region
160 : monnier 245
161 : george 545 | FADD of fty * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp
162 :     | FMUL of fty * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp
163 :     | FSUB of fty * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp
164 :     | FDIV of fty * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp
165 :     | FABS of fty * ('s,'r,'f,'c) fexp
166 :     | FNEG of fty * ('s,'r,'f,'c) fexp
167 :     | FSQRT of fty * ('s,'r,'f,'c) fexp
168 :     | FCOND of fty * ('s,'r,'f,'c) ccexp *
169 :     ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp
170 :     | FCOPYSIGN of fty * ('s,'r,'f,'c) fexp (*sign*) *
171 :     ('s,'r,'f,'c) fexp (*magnitude*)
172 : monnier 245
173 : george 545 | CVTI2F of fty * ty * ('s,'r,'f,'c) rexp (* from signed integer *)
174 :     | CVTF2F of fty * fty * ('s,'r,'f,'c) fexp (* float to float conversion *)
175 : monnier 245
176 : george 545 | FPRED of ('s,'r,'f,'c) fexp * ctrl
177 :    
178 :     | FEXT of fty * 'f
179 : monnier 411
180 : george 545 | FMARK of ('s,'r,'f,'c) fexp * an
181 : monnier 411
182 : george 545 and ('s,'r,'f,'c) ccexp =
183 :     CC of Basis.cond * src (* rtl *)
184 :     | FCC of Basis.fcond * src (* rtl *)
185 :     | TRUE (* rtl *)
186 :     | FALSE (* rtl *)
187 :     | NOT of ('s,'r,'f,'c) ccexp (* rtl *)
188 :     | AND of ('s,'r,'f,'c) ccexp * ('s,'r,'f,'c) ccexp (* rtl *)
189 :     | OR of ('s,'r,'f,'c) ccexp * ('s,'r,'f,'c) ccexp (* rtl *)
190 :     | XOR of ('s,'r,'f,'c) ccexp * ('s,'r,'f,'c) ccexp (* rtl *)
191 :     | CMP of ty * Basis.cond * ('s,'r,'f,'c) rexp * ('s,'r,'f,'c) rexp(*rtl*)
192 :     | FCMP of fty * Basis.fcond * ('s,'r,'f,'c) fexp * ('s,'r,'f,'c) fexp
193 :     | CCMARK of ('s,'r,'f,'c) ccexp * an
194 :     | CCEXT of ty * 'c
195 : monnier 411
196 : george 545 and ('s,'r,'f,'c) mlrisc =
197 :     CCR of ('s,'r,'f,'c) ccexp
198 :     | GPR of ('s,'r,'f,'c) rexp
199 :     | FPR of ('s,'r,'f,'c) fexp
200 : monnier 245
201 : george 545 withtype controlflow = Label.label list (* control flow info *)
202 :     and ctrl = var (* control dependence info *)
203 :     and ctrls = ctrl list
204 : monnier 245
205 : george 545 (*
206 :     * Instruction streams
207 :     *)
208 :     type ('i,'regmap,'cellset) stream =
209 :     ('i -> unit,'regmap, an list, 'cellset, alias, phi) Stream.stream
210 : monnier 411
211 : george 545 (* Extension mechanism *)
212 : monnier 429
213 : george 545 (* These functions are supplied by the instruction selection module *)
214 :     datatype ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)
215 :     reducer =
216 :     REDUCER of
217 :     { reduceRexp : ('s,'r,'f,'c) rexp -> reg,
218 :     reduceFexp : ('s,'r,'f,'c) fexp -> reg,
219 :     reduceCCexp : ('s,'r,'f,'c) ccexp -> reg,
220 :     reduceStm : ('s,'r,'f,'c) stm * an list -> unit,
221 :     operand : ('s,'r,'f,'c) rexp -> 'operand,
222 :     reduceOperand : 'operand -> reg,
223 :     addressOf : ('s,'r,'f,'c) rexp -> 'addressing_mode,
224 :     emit : 'instr * an list -> unit,
225 :     instrStream : ('instr,'regmap,'cellset) stream,
226 :     mltreeStream :
227 :     (('s,'r,'f,'c) stm,'regmap,('s,'r,'f,'c) mlrisc list) stream
228 :     }
229 :    
230 :    
231 :     (* These functions should be provided by the client *)
232 :     datatype ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)
233 :     extender =
234 :     EXTENDER of
235 :     { compileStm :
236 :     ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)
237 :     reducer -> { stm : 's, an : an list} -> unit,
238 :     compileRexp :
239 :     ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)
240 :     reducer -> {e:ty * 'r, an:an list, rd:reg} -> unit,
241 :     compileFexp :
242 :     ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)
243 :     reducer -> {e:fty * 'f, an:an list, fd:reg} -> unit,
244 :     compileCCexp :
245 :     ('instr,'regmap,'cellset,'operand,'addressing_mode,'s,'r,'f,'c)
246 :     reducer -> {e:ty * 'c, an:an list, cd:reg} -> unit
247 :     }
248 :    
249 : monnier 411 end (* MLTREE *)
250 : george 545

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0