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 624 - (view) (download)

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

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