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 591 - (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 : george 545 | PHI of int (* a phi-function at some block id *)
89 : george 555 | PINNED of stm (* pinned statement *)
90 :     | RTL of {hash:word ref, attribs:Basis.attribs, e:stm}
91 : monnier 411
92 : george 555 and rexp =
93 : george 545 REG of ty * reg (* rtl *)
94 : monnier 411
95 :     (* sizes of constants are inferred by context *)
96 : george 545 | LI of int (* rtl *)
97 :     | LI32 of Word32.word (* rtl *)
98 :     | LI64 of Word64.word (* rtl *)
99 : monnier 245 | LABEL of LabelExp.labexp
100 :     | CONST of Constant.const
101 :    
102 : george 555 | NEG of ty * rexp
103 :     | ADD of ty * rexp * rexp (* rtl *)
104 :     | SUB of ty * rexp * rexp (* rtl *)
105 : monnier 245
106 : monnier 411 (* signed multiplication etc. *)
107 : george 555 | MULS of ty * rexp * rexp (* rtl *)
108 :     | DIVS of ty * rexp * rexp (* rtl *)
109 :     | QUOTS of ty * rexp * rexp (* rtl *)
110 :     | REMS of ty * rexp * rexp (* rtl *)
111 : monnier 245
112 : monnier 411 (* unsigned multiplication etc. *)
113 : george 555 | MULU of ty * rexp * rexp (* rtl *)
114 :     | DIVU of ty * rexp * rexp (* rtl *)
115 :     | REMU of ty * rexp * rexp (* rtl *)
116 : monnier 245
117 : monnier 411 (* trapping versions of above. These are all signed *)
118 : george 555 | NEGT of ty * rexp
119 :     | ADDT of ty * rexp * rexp (* rtl *)
120 :     | SUBT of ty * rexp * rexp (* rtl *)
121 :     | MULT of ty * rexp * rexp (* rtl *)
122 :     | DIVT of ty * rexp * rexp (* rtl *)
123 :     | QUOTT of ty * rexp * rexp (* rtl *)
124 :     | REMT of ty * rexp * rexp (* rtl *)
125 : monnier 245
126 : george 545 (* bit operations *)
127 : george 555 | ANDB of ty * rexp * rexp (* rtl *)
128 :     | ORB of ty * rexp * rexp (* rtl *)
129 :     | XORB of ty * rexp * rexp (* rtl *)
130 :     | NOTB of ty * rexp (* rtl *)
131 : monnier 245
132 : george 555 | SRA of ty * rexp * rexp (* value, shift *) (* rtl *)
133 :     | SRL of ty * rexp * rexp (* rtl *)
134 :     | SLL of ty * rexp * rexp (* rtl *)
135 : monnier 411
136 : george 545 (* type promotion/conversion *)
137 : george 555 | CVTI2I of ty * ext * ty * rexp (* signed extension *) (* rtl *)
138 :     | CVTF2I of ty * rounding_mode * fty * fexp (* rtl *)
139 : monnier 411
140 : george 545 (*
141 :     * COND(ty,cc,e1,e2):
142 :     * Evaluate into either e1 or e2, depending on cc.
143 :     * Both e1 and e2 are allowed to be evaluated eagerly.
144 :     *)
145 : george 555 | COND of ty * ccexp * rexp * rexp (* rtl *)
146 : monnier 411
147 :     (* integer load *)
148 : george 555 | LOAD of ty * rexp * Region.region (* rtl *)
149 : monnier 411
150 : george 545 (* predication *)
151 : george 555 | PRED of rexp * ctrl
152 : monnier 245
153 : george 555 | LET of stm * rexp
154 : monnier 411
155 : george 555 | REXT of ty * rext
156 : monnier 411
157 : george 555 | MARK of rexp * an
158 : monnier 411
159 : george 555 and fexp =
160 : monnier 411 FREG of fty * src
161 : george 555 | FLOAD of fty * rexp * Region.region
162 : monnier 245
163 : george 555 | FADD of fty * fexp * fexp
164 :     | FMUL of fty * fexp * fexp
165 :     | FSUB of fty * fexp * fexp
166 :     | FDIV of fty * fexp * fexp
167 :     | FABS of fty * fexp
168 :     | FNEG of fty * fexp
169 :     | FSQRT of fty * fexp
170 :     | FCOND of fty * ccexp *
171 :     fexp * fexp
172 :     | FCOPYSIGN of fty * fexp (*sign*) * fexp (*magnitude*)
173 : monnier 245
174 : george 555 | CVTI2F of fty * ty * rexp (* from signed integer *)
175 :     | CVTF2F of fty * fty * fexp (* float to float conversion *)
176 : monnier 245
177 : george 555 | FPRED of fexp * ctrl
178 : george 545
179 : george 555 | FEXT of fty * fext
180 : monnier 411
181 : george 555 | FMARK of fexp * an
182 : monnier 411
183 : george 555 and ccexp =
184 : george 545 CC of Basis.cond * src (* rtl *)
185 :     | FCC of Basis.fcond * src (* rtl *)
186 :     | TRUE (* rtl *)
187 :     | FALSE (* rtl *)
188 : george 555 | NOT of ccexp (* rtl *)
189 :     | AND of ccexp * ccexp (* rtl *)
190 :     | OR of ccexp * ccexp (* rtl *)
191 :     | XOR of ccexp * ccexp (* rtl *)
192 :     | CMP of ty * Basis.cond * rexp * rexp(*rtl*)
193 :     | FCMP of fty * Basis.fcond * fexp * fexp
194 :     | CCMARK of ccexp * an
195 :     | CCEXT of ty * ccext
196 : monnier 411
197 : george 555 and mlrisc =
198 :     CCR of ccexp
199 :     | GPR of rexp
200 :     | FPR of fexp
201 : monnier 245
202 : george 545 withtype controlflow = Label.label list (* control flow info *)
203 : george 555 and ctrl = var (* control dependence info *)
204 :     and ctrls = ctrl list
205 :     and sext = (stm, rexp, fexp, ccexp) Extension.sx
206 :     and rext = (stm, rexp, fexp, ccexp) Extension.rx
207 :     and fext = (stm, rexp, fexp, ccexp) Extension.fx
208 :     and ccext = (stm, rexp, fexp, ccexp) Extension.ccx
209 : monnier 245
210 : george 545 (*
211 :     * Instruction streams
212 :     *)
213 :     type ('i,'regmap,'cellset) stream =
214 :     ('i -> unit,'regmap, an list, 'cellset, alias, phi) Stream.stream
215 : monnier 411
216 : george 555 (*
217 :     * Extension mechanism
218 :     *)
219 : monnier 429
220 : george 555 datatype ('instr,'regmap,'cellset,'operand,'addressing_mode) reducer =
221 : george 545 REDUCER of
222 : george 555 { reduceRexp : rexp -> reg,
223 :     reduceFexp : fexp -> reg,
224 :     reduceCCexp : ccexp -> reg,
225 :     reduceStm : stm * an list -> unit,
226 :     operand : rexp -> 'operand,
227 : george 545 reduceOperand : 'operand -> reg,
228 : george 555 addressOf : rexp -> 'addressing_mode,
229 : george 545 emit : 'instr * an list -> unit,
230 :     instrStream : ('instr,'regmap,'cellset) stream,
231 : george 555 mltreeStream : (stm,'regmap,mlrisc list) stream
232 : george 545 }
233 :    
234 : george 555 (*
235 :     * Useful type abbreviations for working for MLTree.
236 :     *)
237 :     type rewriter = (* rewriting functions *)
238 :     {stm:stm->stm, rexp:rexp->rexp, fexp:fexp->fexp, ccexp:ccexp->ccexp}
239 :     type 'a folder = (* aggregation functions *)
240 :     {stm:stm*'a->'a, rexp:rexp*'a->'a, fexp:fexp*'a->'a, ccexp:ccexp*'a->'a}
241 :     type hasher = (* hashing functions *)
242 :     {stm:stm->word, rexp:rexp->word, fexp:fexp->word, ccexp:ccexp->word}
243 :     type equality = (* comparison functions *)
244 :     {stm:stm * stm->bool, rexp:rexp * rexp->bool,
245 :     fexp:fexp * fexp->bool, ccexp:ccexp * ccexp->bool}
246 :     type printer = (* pretty printing functions *)
247 :     {stm:stm->string, rexp:rexp->string, fexp:fexp->string, ccexp:ccexp->string,
248 :     dstReg : ty * var -> string, srcReg : ty * var -> string}
249 : george 545
250 : monnier 411 end (* MLTREE *)

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