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

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