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/Doc/mltree.html
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 498 - (view) (download) (as text)
Original Path: sml/branches/SMLNJ/src/MLRISC/Doc/mltree.html

1 : monnier 409 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 :     <HTML>
3 :     <HEAD>
4 :     <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
5 :     <META NAME="GENERATOR" CONTENT="Mozilla/4.07 [en] (X11; I; Linux 2.2.7 i686) [Netscape]">
6 :     </HEAD>
7 :     <BODY bgcolor="#FFFFFF">
8 :    
9 :     <CENTER>
10 :     <H1>
11 :     <FONT COLOR="#aa0000">The MLTREE Language</FONT></H1></CENTER>
12 :    
13 :     <h2> Introduction </h2>
14 :     <font color="#ff0000"> MLTree </font>
15 :     is the RTL-like intermediate language used to communicate
16 :     between the MLRISC system and the compiler front-end.
17 :     <p>
18 :     In order to allow the client to specify operations that operate on operands
19 :     of various widths, all integer and floating point operators in MLTREE now
20 : monnier 498 take an additional width paramater.
21 : monnier 409 <p>
22 :     For example,
23 :     <small>
24 :     <pre>
25 :     MV(32,t,
26 :     ADDT(32,MULT(32,REG(32,b),REG(32,b)),
27 :     MULT(32,MULT(32,LI(4),REG(32,a)),REG(32,c))))
28 :     </pre>
29 :     </small>
30 :     <pre>
31 :     computes <tt>t := b*b + 4*a*c</tt>, all in 32-bit precision; while
32 :     <small>
33 :     <pre>
34 :     MV(32,t,
35 :     ADD(32,CVTI2I(32,SIGN_EXTEND,
36 :     LOAD(8,ADD(32,REG(32,a),REG(32,i))))))
37 :     </pre>
38 :     </small>
39 :     loads the byte in address <tt>a+i</tt> and sign extend it to a 32-bit
40 :     value.
41 :    
42 :     <h3> The Details </h3>
43 : monnier 498 The signature
44 : monnier 409 <a href="../mltree/mltree-basis.sig" target=code> MLTREE_BASIS </a>
45 : monnier 498 defines the basic types used in the MLTREE signature.
46 : monnier 409 <small>
47 :     <pre>
48 :     signature MLTREE_BASIS =
49 :     sig
50 :    
51 :     datatype cond = LT | LTU | LE | LEU | EQ | NE | GE | GEU | GT | GTU
52 :    
53 :     datatype fcond = ? | !<=> | == | ?= | !<> | !?>= | < | ?< | !>= | !?> |
54 :     <= | ?<= | !> | !?<= | > | ?> | !<= | !?< | >= | ?>= |
55 :     !< | !?= | <> | != | !? | <=> | ?<>
56 :    
57 :     datatype ext = SIGN_EXTEND | ZERO_EXTEND
58 :    
59 :     datatype rounding_mode = TO_NEAREST | TO_NEGINF | TO_POSINF | TO_ZERO
60 :    
61 :     type attribs = word
62 :    
63 :     type misc_op = {ty:int,name:string,attribs:attribs,hash:word}
64 :    
65 :     (* Should be datatypes, but FLINT does not optimize them well *)
66 :     type ty = int
67 :     type fty = int
68 :    
69 :     end
70 :     </pre>
71 :     </small>
72 :    
73 :    
74 : monnier 498 The signature
75 :     <a href="../mltree/mltree.sig" target=code> MLTREE </a> is parameterized
76 :     with respect to the client defined constant, pseudo ops, aliasing regions
77 :     and instruction stream types.
78 : monnier 409 <small>
79 :     <pre>
80 :     signature MLTREE = sig
81 :     structure Constant : <a href="constants.html">CONSTANT</a>
82 :     structure PseudoOp : <a href="pseudo-ops.html">PSEUDO_OPS</a>
83 :     structure Region : <a href="region.html">REGION</a>
84 : monnier 498 structure Stream : <a href="stream.html">INSTRUCTION_STREAM</a>
85 :     sharing Stream.P = PseudoOp
86 : monnier 409
87 :     include MLTREE_BASIS
88 :    
89 :     type rextension
90 :     type fextension
91 :    
92 :     type var = int (* variable *)
93 :     type src = var (* source variable *)
94 :     type dst = var (* destination variable *)
95 :     type reg = var (* physical register *)
96 :    
97 : monnier 498
98 : monnier 409 (* phi-functions for SSA form *)
99 :     datatype phi =
100 :     PHI of ty * dst * src list
101 :     | FPHI of fty * dst * src list
102 :     | CCPHI of dst * src list
103 :    
104 :     (* aliasing declarations
105 :     * These are used to define physical register bindings for SSA names
106 :     *)
107 : monnier 498 type alias = var * reg (* var is aliased to register *)
108 : monnier 409
109 :     (* statements *)
110 :     datatype stm =
111 :     MV of ty * dst * rexp
112 :     | CCMV of dst * ccexp
113 :     | FMV of fty * dst * fexp
114 :     | COPY of ty * dst list * src list
115 :     | FCOPY of fty * dst list * src list
116 :     | JMP of rexp * Label.label list
117 :     | CALL of rexp * mlrisc list * mlrisc list * Region.region
118 :     | RET
119 :    
120 :     | STORE of ty * rexp * rexp * Region.region (* address, data *)
121 :     | STORE_UNALIGNED of ty * rexp * rexp * Region.region
122 :     | FSTORE of fty * rexp * fexp * Region.region (* address, data *)
123 :     | FSTORE_UNALIGNED of fty * rexp * fexp * Region.region
124 :     | BCC of cond * ccexp * Label.label
125 :     | FBCC of fcond * ccexp * Label.label
126 :     | ANNOTATION of stm * Annotations.annotation
127 :    
128 :     (* The following are used internally by SSA optimizations;
129 :     * The frontend should not generate these.
130 :     *)
131 :     | RTL of word ref * word * stm (* a RTL that has been cached *)
132 :     | RTLPHI of int (* a phi-function at block id *)
133 :     | RTLPINNED of stm (* pinned statement *)
134 :     | RTLPAR of stm list (* parallel execution *)
135 :    
136 :     and rexp =
137 :     REG of ty * src
138 :    
139 :     (* sizes of constants are inferred by context *)
140 :     | LI of int
141 :     | LI32 of Word32.word
142 :     | LI64 of Word64.word
143 :     | LABEL of LabelExp.labexp
144 :     | CONST of Constant.const
145 :    
146 :     | ADD of ty * rexp * rexp
147 :     | SUB of ty * rexp * rexp
148 :    
149 :     (* signed multiplication etc. *)
150 :     | MULS of ty * rexp * rexp
151 :     | DIVS of ty * rexp * rexp
152 :     | REMS of ty * rexp * rexp
153 :    
154 :     (* unsigned multiplication etc. *)
155 :     | MULU of ty * rexp * rexp
156 :     | DIVU of ty * rexp * rexp
157 :     | REMU of ty * rexp * rexp
158 :    
159 :     (* trapping versions of above. These are all signed *)
160 :     | ADDT of ty * rexp * rexp
161 :     | SUBT of ty * rexp * rexp
162 :     | MULT of ty * rexp * rexp
163 :     | DIVT of ty * rexp * rexp
164 :     | REMT of ty * rexp * rexp
165 :    
166 :     | ANDB of ty * rexp * rexp
167 :     | ORB of ty * rexp * rexp
168 :     | XORB of ty * rexp * rexp
169 :     | NOTB of ty * rexp
170 :    
171 :     | SRA of ty * rexp * rexp (* value, shift *)
172 :     | SRL of ty * rexp * rexp
173 :     | SLL of ty * rexp * rexp
174 :    
175 :     (* type promotion *)
176 :     | CVTI2I of ty * ext * rexp
177 :     | CVTF2I of ty * rounding_mode * fexp
178 :    
179 :     (*
180 :     * COND(ty,cc,e1,e2):
181 :     * Evaluate into either e1 or e2, depending on cc.
182 :     * Both e1 and e2 can be evaluated eagerly.
183 :     *)
184 :     | COND of ty * ccexp * rexp * rexp
185 :    
186 :     (* integer load *)
187 :     | LOAD of ty * rexp * Region.region
188 :     | LOAD_UNALIGNED of ty * rexp * Region.region
189 :    
190 :     | SEQ of stm * rexp
191 :    
192 : monnier 498 | EXTENSION of ty * rextension * rexp list
193 : monnier 409
194 :     | MARK of rexp * Annotations.annotation
195 :    
196 :     (* Used in RTL *)
197 :     | RTLPC (* the program counter; used for describing relative addressing *)
198 :     | RTLMISC of misc_op ref * rexp list
199 :    
200 :     and fexp =
201 :     FREG of fty * src
202 :     | FLOAD of fty * rexp * Region.region
203 :     | FLOAD_UNALIGNED of fty * rexp * Region.region
204 :    
205 :     | FADD of fty * fexp * fexp
206 :     | FMUL of fty * fexp * fexp
207 :     | FSUB of fty * fexp * fexp
208 :     | FDIV of fty * fexp * fexp
209 :     | FABS of fty * fexp
210 :     | FNEG of fty * fexp
211 :     | FSQRT of fty * fexp
212 :    
213 :     | CVTI2F of fty * ext * rexp
214 :     | CVTF2F of fty * rounding_mode * fexp
215 :     | FSEQ of stm * fexp
216 :    
217 : monnier 498 | FEXTENSION of fty * fextension * fexp list
218 : monnier 409
219 :     | FMARK of fexp * Annotations.annotation
220 :    
221 :     (* used in RTL *)
222 :     | RTLFMISC of misc_op ref * fexp list
223 :    
224 :     and ccexp =
225 :     CC of src
226 :     | CMP of ty * cond * rexp * rexp
227 :     | FCMP of fty * fcond * fexp * fexp
228 :     | CCMARK of ccexp * Annotations.annotation
229 :     | RTLCCMISC of misc_op ref * ccexp list
230 :    
231 :     and mlrisc = CCR of ccexp | GPR of rexp | FPR of fexp
232 :    
233 :     exception Unsupported of string * rexp
234 :    
235 : monnier 498 type ('i,'regmap) stream =
236 :     ('i -> unit,'regmap,Annotations.annotations,
237 :     mlrisc list, alias, phi) Stream.stream
238 :    
239 : monnier 409 end (* MLTREE *)
240 :     </pre>
241 :     </small>
242 :    
243 :     <HR>
244 :    
245 :     </BODY>
246 :     </HTML>

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