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

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

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