SCM Repository
Annotation of /sml/trunk/src/MLRISC/ppc/emit/ppcAsm.sml
Parent Directory
|
Revision Log
Revision 1017 - (view) (download)
1 : | monnier | 411 | (* |
2 : | leunga | 744 | * WARNING: This file was automatically generated by MDLGen (v3.0) |
3 : | leunga | 815 | * from the machine description file "ppc/ppc.mdl". |
4 : | leunga | 744 | * DO NOT EDIT this file directly |
5 : | monnier | 247 | *) |
6 : | |||
7 : | monnier | 411 | |
8 : | george | 984 | functor PPCAsmEmitter(structure S : INSTRUCTION_STREAM |
9 : | structure Instr : PPCINSTR | ||
10 : | where T = S.P.T | ||
11 : | monnier | 411 | structure Shuffle : PPCSHUFFLE |
12 : | where I = Instr | ||
13 : | george | 984 | structure MLTreeEval : MLTREE_EVAL |
14 : | where T = Instr.T | ||
15 : | monnier | 411 | ) : INSTRUCTION_EMITTER = |
16 : | monnier | 247 | struct |
17 : | monnier | 411 | structure I = Instr |
18 : | structure C = I.C | ||
19 : | leunga | 775 | structure T = I.T |
20 : | george | 984 | structure S = S |
21 : | monnier | 411 | structure P = S.P |
22 : | structure Constant = I.Constant | ||
23 : | |||
24 : | monnier | 498 | val show_cellset = MLRiscControl.getFlag "asm-show-cellset" |
25 : | george | 545 | val show_region = MLRiscControl.getFlag "asm-show-region" |
26 : | leunga | 796 | val show_cutsTo = MLRiscControl.getFlag "asm-show-cutsto" |
27 : | leunga | 594 | val indent_copies = MLRiscControl.getFlag "asm-indent-copies" |
28 : | monnier | 498 | |
29 : | george | 545 | fun error msg = MLRiscErrorMsg.error("PPCAsmEmitter",msg) |
30 : | monnier | 411 | |
31 : | monnier | 429 | fun makeStream formatAnnotations = |
32 : | monnier | 411 | let val stream = !AsmStream.asmOutStream |
33 : | monnier | 429 | fun emit' s = TextIO.output(stream,s) |
34 : | val newline = ref true | ||
35 : | val tabs = ref 0 | ||
36 : | fun tabbing 0 = () | ||
37 : | | tabbing n = (emit' "\t"; tabbing(n-1)) | ||
38 : | fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s) | ||
39 : | fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n")) | ||
40 : | monnier | 411 | fun comma() = emit "," |
41 : | leunga | 594 | fun tab() = tabs := 1 |
42 : | fun indent() = tabs := 2 | ||
43 : | monnier | 429 | fun ms n = let val s = Int.toString n |
44 : | in if n<0 then "-"^String.substring(s,1,size s-1) | ||
45 : | else s | ||
46 : | end | ||
47 : | george | 984 | fun emit_label lab = emit(P.Client.AsmPseudoOps.lexpToString(T.LABEL lab)) |
48 : | fun emit_labexp le = emit(P.Client.AsmPseudoOps.lexpToString (T.LABEXP le)) | ||
49 : | monnier | 411 | fun emit_const c = emit(Constant.toString c) |
50 : | fun emit_int i = emit(ms i) | ||
51 : | fun paren f = (emit "("; f(); emit ")") | ||
52 : | george | 1017 | fun defineLabel lab = emit(P.Client.AsmPseudoOps.defineLabel lab^"\n") |
53 : | monnier | 411 | fun entryLabel lab = defineLabel lab |
54 : | george | 909 | fun comment msg = (tab(); emit("/* " ^ msg ^ " */\n")) |
55 : | monnier | 411 | fun annotation a = (comment(Annotations.toString a); nl()) |
56 : | leunga | 815 | fun getAnnotations() = error "getAnnotations" |
57 : | george | 545 | fun doNothing _ = () |
58 : | george | 909 | fun fail _ = raise Fail "AsmEmitter" |
59 : | monnier | 411 | fun emit_region mem = comment(I.Region.toString mem) |
60 : | george | 545 | val emit_region = |
61 : | if !show_region then emit_region else doNothing | ||
62 : | george | 984 | fun pseudoOp pOp = (emit(P.toString pOp); emit "\n") |
63 : | monnier | 411 | fun init size = (comment("Code Size = " ^ ms size); nl()) |
64 : | leunga | 744 | val emitCellInfo = AsmFormatUtil.reginfo |
65 : | (emit,formatAnnotations) | ||
66 : | george | 889 | fun emitCell r = (emit(CellsBasis.toString r); emitCellInfo r) |
67 : | monnier | 498 | fun emit_cellset(title,cellset) = |
68 : | jhr | 900 | (nl(); comment(title^CellsBasis.CellSet.toString cellset)) |
69 : | george | 545 | val emit_cellset = |
70 : | if !show_cellset then emit_cellset else doNothing | ||
71 : | monnier | 498 | fun emit_defs cellset = emit_cellset("defs: ",cellset) |
72 : | fun emit_uses cellset = emit_cellset("uses: ",cellset) | ||
73 : | leunga | 796 | val emit_cutsTo = |
74 : | if !show_cutsTo then AsmFormatUtil.emit_cutsTo emit | ||
75 : | else doNothing | ||
76 : | leunga | 744 | fun emitter instr = |
77 : | let | ||
78 : | george | 545 | fun asm_spr (I.XER) = "xer" |
79 : | | asm_spr (I.LR) = "lr" | ||
80 : | | asm_spr (I.CTR) = "ctr" | ||
81 : | and emit_spr x = emit (asm_spr x) | ||
82 : | leunga | 744 | and emit_operand (I.RegOp GP) = emitCell GP |
83 : | george | 545 | | emit_operand (I.ImmedOp int) = emit_int int |
84 : | | emit_operand (I.LabelOp labexp) = emit_labexp labexp | ||
85 : | and asm_load (I.LBZ) = "lbz" | ||
86 : | | asm_load (I.LBZE) = "lbze" | ||
87 : | | asm_load (I.LHZ) = "lhz" | ||
88 : | | asm_load (I.LHZE) = "lhze" | ||
89 : | | asm_load (I.LHA) = "lha" | ||
90 : | | asm_load (I.LHAE) = "lhae" | ||
91 : | | asm_load (I.LWZ) = "lwz" | ||
92 : | | asm_load (I.LWZE) = "lwze" | ||
93 : | | asm_load (I.LDE) = "lde" | ||
94 : | and emit_load x = emit (asm_load x) | ||
95 : | monnier | 429 | and asm_store (I.STB) = "stb" |
96 : | monnier | 411 | | asm_store (I.STBE) = "stbe" |
97 : | | asm_store (I.STH) = "sth" | ||
98 : | | asm_store (I.STHE) = "sthe" | ||
99 : | | asm_store (I.STW) = "stw" | ||
100 : | | asm_store (I.STWE) = "stwe" | ||
101 : | | asm_store (I.STDE) = "stde" | ||
102 : | george | 545 | and emit_store x = emit (asm_store x) |
103 : | monnier | 411 | and asm_fload (I.LFS) = "lfs" |
104 : | | asm_fload (I.LFSE) = "lfse" | ||
105 : | | asm_fload (I.LFD) = "lfd" | ||
106 : | | asm_fload (I.LFDE) = "lfde" | ||
107 : | george | 545 | and emit_fload x = emit (asm_fload x) |
108 : | and asm_fstore (I.STFS) = "stfs" | ||
109 : | | asm_fstore (I.STFSE) = "stfse" | ||
110 : | | asm_fstore (I.STFD) = "stfd" | ||
111 : | | asm_fstore (I.STFDE) = "stfde" | ||
112 : | and emit_fstore x = emit (asm_fstore x) | ||
113 : | and asm_cmp (I.CMP) = "cmp" | ||
114 : | | asm_cmp (I.CMPL) = "cmpl" | ||
115 : | and emit_cmp x = emit (asm_cmp x) | ||
116 : | and asm_fcmp (I.FCMPO) = "fcmpo" | ||
117 : | | asm_fcmp (I.FCMPU) = "fcmpu" | ||
118 : | and emit_fcmp x = emit (asm_fcmp x) | ||
119 : | and asm_unary (I.NEG) = "neg" | ||
120 : | | asm_unary (I.EXTSB) = "extsb" | ||
121 : | | asm_unary (I.EXTSH) = "extsh" | ||
122 : | | asm_unary (I.EXTSW) = "extsw" | ||
123 : | | asm_unary (I.CNTLZW) = "cntlzw" | ||
124 : | | asm_unary (I.CNTLZD) = "cntlzd" | ||
125 : | and emit_unary x = emit (asm_unary x) | ||
126 : | monnier | 429 | and asm_funary (I.FMR) = "fmr" |
127 : | | asm_funary (I.FNEG) = "fneg" | ||
128 : | | asm_funary (I.FABS) = "fabs" | ||
129 : | | asm_funary (I.FNABS) = "fnabs" | ||
130 : | | asm_funary (I.FSQRT) = "fsqrt" | ||
131 : | | asm_funary (I.FSQRTS) = "fsqrts" | ||
132 : | | asm_funary (I.FRSP) = "frsp" | ||
133 : | | asm_funary (I.FCTIW) = "fctiw" | ||
134 : | | asm_funary (I.FCTIWZ) = "fctiwz" | ||
135 : | | asm_funary (I.FCTID) = "fctid" | ||
136 : | | asm_funary (I.FCTIDZ) = "fctidz" | ||
137 : | | asm_funary (I.FCFID) = "fcfid" | ||
138 : | george | 545 | and emit_funary x = emit (asm_funary x) |
139 : | and asm_farith (I.FADD) = "fadd" | ||
140 : | | asm_farith (I.FSUB) = "fsub" | ||
141 : | | asm_farith (I.FMUL) = "fmul" | ||
142 : | | asm_farith (I.FDIV) = "fdiv" | ||
143 : | | asm_farith (I.FADDS) = "fadds" | ||
144 : | | asm_farith (I.FSUBS) = "fsubs" | ||
145 : | | asm_farith (I.FMULS) = "fmuls" | ||
146 : | | asm_farith (I.FDIVS) = "fdivs" | ||
147 : | and emit_farith x = emit (asm_farith x) | ||
148 : | and asm_farith3 (I.FMADD) = "fmadd" | ||
149 : | | asm_farith3 (I.FMADDS) = "fmadds" | ||
150 : | | asm_farith3 (I.FMSUB) = "fmsub" | ||
151 : | | asm_farith3 (I.FMSUBS) = "fmsubs" | ||
152 : | | asm_farith3 (I.FNMADD) = "fnmadd" | ||
153 : | | asm_farith3 (I.FNMADDS) = "fnmadds" | ||
154 : | | asm_farith3 (I.FNMSUB) = "fnmsub" | ||
155 : | | asm_farith3 (I.FNMSUBS) = "fnmsubs" | ||
156 : | | asm_farith3 (I.FSEL) = "fsel" | ||
157 : | and emit_farith3 x = emit (asm_farith3 x) | ||
158 : | monnier | 411 | and asm_arith (I.ADD) = "add" |
159 : | | asm_arith (I.SUBF) = "subf" | ||
160 : | | asm_arith (I.MULLW) = "mullw" | ||
161 : | | asm_arith (I.MULLD) = "mulld" | ||
162 : | | asm_arith (I.MULHW) = "mulhw" | ||
163 : | | asm_arith (I.MULHWU) = "mulhwu" | ||
164 : | | asm_arith (I.DIVW) = "divw" | ||
165 : | | asm_arith (I.DIVD) = "divd" | ||
166 : | | asm_arith (I.DIVWU) = "divwu" | ||
167 : | | asm_arith (I.DIVDU) = "divdu" | ||
168 : | | asm_arith (I.AND) = "and" | ||
169 : | | asm_arith (I.OR) = "or" | ||
170 : | | asm_arith (I.XOR) = "xor" | ||
171 : | | asm_arith (I.NAND) = "nand" | ||
172 : | | asm_arith (I.NOR) = "nor" | ||
173 : | | asm_arith (I.EQV) = "eqv" | ||
174 : | | asm_arith (I.ANDC) = "andc" | ||
175 : | | asm_arith (I.ORC) = "orc" | ||
176 : | | asm_arith (I.SLW) = "slw" | ||
177 : | | asm_arith (I.SLD) = "sld" | ||
178 : | | asm_arith (I.SRW) = "srw" | ||
179 : | | asm_arith (I.SRD) = "srd" | ||
180 : | | asm_arith (I.SRAW) = "sraw" | ||
181 : | | asm_arith (I.SRAD) = "srad" | ||
182 : | george | 545 | and emit_arith x = emit (asm_arith x) |
183 : | monnier | 429 | and asm_arithi (I.ADDI) = "addi" |
184 : | | asm_arithi (I.ADDIS) = "addis" | ||
185 : | | asm_arithi (I.SUBFIC) = "subfic" | ||
186 : | | asm_arithi (I.MULLI) = "mulli" | ||
187 : | | asm_arithi (I.ANDI_Rc) = "andi." | ||
188 : | | asm_arithi (I.ANDIS_Rc) = "andis." | ||
189 : | | asm_arithi (I.ORI) = "ori" | ||
190 : | | asm_arithi (I.ORIS) = "oris" | ||
191 : | | asm_arithi (I.XORI) = "xori" | ||
192 : | | asm_arithi (I.XORIS) = "xoris" | ||
193 : | | asm_arithi (I.SRAWI) = "srawi" | ||
194 : | | asm_arithi (I.SRADI) = "sradi" | ||
195 : | george | 545 | and emit_arithi x = emit (asm_arithi x) |
196 : | and asm_rotate (I.RLWNM) = "rlwnm" | ||
197 : | | asm_rotate (I.RLDCL) = "rldcl" | ||
198 : | | asm_rotate (I.RLDCR) = "rldcr" | ||
199 : | and emit_rotate x = emit (asm_rotate x) | ||
200 : | and asm_rotatei (I.RLWINM) = "rlwinm" | ||
201 : | | asm_rotatei (I.RLWIMI) = "rlwimi" | ||
202 : | | asm_rotatei (I.RLDICL) = "rldicl" | ||
203 : | | asm_rotatei (I.RLDICR) = "rldicr" | ||
204 : | | asm_rotatei (I.RLDIC) = "rldic" | ||
205 : | | asm_rotatei (I.RLDIMI) = "rldimi" | ||
206 : | and emit_rotatei x = emit (asm_rotatei x) | ||
207 : | and asm_ccarith (I.CRAND) = "crand" | ||
208 : | | asm_ccarith (I.CROR) = "cror" | ||
209 : | | asm_ccarith (I.CRXOR) = "crxor" | ||
210 : | | asm_ccarith (I.CRNAND) = "crnand" | ||
211 : | | asm_ccarith (I.CRNOR) = "crnor" | ||
212 : | | asm_ccarith (I.CREQV) = "creqv" | ||
213 : | | asm_ccarith (I.CRANDC) = "crandc" | ||
214 : | | asm_ccarith (I.CRORC) = "crorc" | ||
215 : | and emit_ccarith x = emit (asm_ccarith x) | ||
216 : | and asm_bit (I.LT) = "lt" | ||
217 : | | asm_bit (I.GT) = "gt" | ||
218 : | | asm_bit (I.EQ) = "eq" | ||
219 : | | asm_bit (I.SO) = "so" | ||
220 : | | asm_bit (I.FL) = "lt" | ||
221 : | | asm_bit (I.FG) = "gt" | ||
222 : | | asm_bit (I.FE) = "eq" | ||
223 : | | asm_bit (I.FU) = "un" | ||
224 : | | asm_bit (I.FX) = "lt" | ||
225 : | | asm_bit (I.FEX) = "gt" | ||
226 : | | asm_bit (I.VX) = "eq" | ||
227 : | | asm_bit (I.OX) = "so" | ||
228 : | and emit_bit x = emit (asm_bit x) | ||
229 : | monnier | 247 | |
230 : | george | 823 | (*#line 570.7 "ppc/ppc.mdl"*) |
231 : | george | 545 | fun emitx (s, I.RegOp _) = (if ((String.sub (s, (size s) - 1)) = #"e") |
232 : | monnier | 411 | then |
233 : | george | 545 | ( emit (String.substring (s, 0, (size s) - 1)); |
234 : | leunga | 744 | emit "xe" ) |
235 : | monnier | 411 | else |
236 : | george | 545 | ( emit s; |
237 : | leunga | 744 | emit "x" )) |
238 : | george | 545 | | emitx (s, _) = emit s |
239 : | monnier | 247 | |
240 : | george | 823 | (*#line 576.7 "ppc/ppc.mdl"*) |
241 : | monnier | 411 | fun eOERc {OE=false, Rc=false} = () |
242 : | george | 545 | | eOERc {OE=false, Rc=true} = emit "." |
243 : | | eOERc {OE=true, Rc=false} = emit "o" | ||
244 : | | eOERc {OE=true, Rc=true} = emit "o." | ||
245 : | monnier | 247 | |
246 : | george | 823 | (*#line 580.7 "ppc/ppc.mdl"*) |
247 : | monnier | 411 | fun eRc false = "" |
248 : | | eRc true = "." | ||
249 : | monnier | 247 | |
250 : | george | 823 | (*#line 581.7 "ppc/ppc.mdl"*) |
251 : | george | 889 | fun cr_bit (cr, bit) = (4 * (CellsBasis.physicalRegisterNum cr)) + |
252 : | leunga | 744 | (case bit of |
253 : | I.LT => 0 | ||
254 : | | I.GT => 1 | ||
255 : | | I.EQ => 2 | ||
256 : | | I.SO => 3 | ||
257 : | | I.FL => 0 | ||
258 : | | I.FG => 1 | ||
259 : | | I.FE => 2 | ||
260 : | | I.FU => 3 | ||
261 : | | I.FX => 0 | ||
262 : | | I.FEX => 1 | ||
263 : | | I.VX => 2 | ||
264 : | | I.OX => 3 | ||
265 : | george | 545 | ) |
266 : | monnier | 247 | |
267 : | george | 823 | (*#line 588.7 "ppc/ppc.mdl"*) |
268 : | george | 545 | fun eCRbit x = emit (Int.toString (cr_bit x)) |
269 : | monnier | 247 | |
270 : | george | 823 | (*#line 589.7 "ppc/ppc.mdl"*) |
271 : | george | 545 | fun eLK true = emit "l" |
272 : | monnier | 411 | | eLK false = () |
273 : | monnier | 247 | |
274 : | george | 823 | (*#line 590.7 "ppc/ppc.mdl"*) |
275 : | monnier | 411 | fun eI (I.RegOp _) = () |
276 : | george | 545 | | eI _ = emit "i" |
277 : | monnier | 247 | |
278 : | george | 823 | (*#line 591.7 "ppc/ppc.mdl"*) |
279 : | monnier | 411 | fun eBI (bo, bf, bit) = |
280 : | george | 889 | (case (bo, CellsBasis.physicalRegisterNum bf) of |
281 : | leunga | 744 | (I.ALWAYS, _) => () |
282 : | | (I.COUNTER{cond=NONE, ...}, _) => () | ||
283 : | | (_, 0) => emit (asm_bit bit) | ||
284 : | | (_, n) => emit ((("4*cr" ^ (Int.toString n)) ^ "+") ^ (asm_bit bit)) | ||
285 : | monnier | 411 | ) |
286 : | monnier | 247 | |
287 : | george | 823 | (*#line 597.7 "ppc/ppc.mdl"*) |
288 : | george | 545 | fun emit_bo bo = emit |
289 : | leunga | 744 | (case bo of |
290 : | I.TRUE => "t" | ||
291 : | | I.FALSE => "f" | ||
292 : | | I.ALWAYS => "" | ||
293 : | | I.COUNTER{eqZero, cond=NONE} => (if eqZero | ||
294 : | then "dz" | ||
295 : | else "dnz") | ||
296 : | | I.COUNTER{eqZero, cond=SOME cc} => (if eqZero | ||
297 : | then "dz" | ||
298 : | else "dnz") ^ (if cc | ||
299 : | then "t" | ||
300 : | else "f") | ||
301 : | george | 545 | ) |
302 : | monnier | 411 | |
303 : | george | 823 | (*#line 608.7 "ppc/ppc.mdl"*) |
304 : | monnier | 411 | fun eME (SOME me) = |
305 : | george | 545 | ( emit ", "; |
306 : | leunga | 744 | emit_int me ) |
307 : | monnier | 411 | | eME NONE = () |
308 : | |||
309 : | george | 823 | (*#line 611.7 "ppc/ppc.mdl"*) |
310 : | monnier | 411 | fun addr (ra, I.RegOp rb) = |
311 : | leunga | 744 | ( emitCell ra; |
312 : | emit ", "; | ||
313 : | emitCell rb ) | ||
314 : | monnier | 411 | | addr (ra, d) = |
315 : | george | 545 | ( emit_operand d; |
316 : | leunga | 744 | emit "("; |
317 : | emitCell ra; | ||
318 : | emit ")" ) | ||
319 : | leunga | 594 | fun emitInstr' instr = |
320 : | leunga | 744 | (case instr of |
321 : | I.L{ld, rt, ra, d, mem} => | ||
322 : | ( emitx (asm_load ld, d); | ||
323 : | emit "\t"; | ||
324 : | emitCell rt; | ||
325 : | emit ", "; | ||
326 : | addr (ra, d); | ||
327 : | emit_region mem ) | ||
328 : | | I.LF{ld, ft, ra, d, mem} => | ||
329 : | ( emitx (asm_fload ld, d); | ||
330 : | emit "\t"; | ||
331 : | emitCell ft; | ||
332 : | emit ", "; | ||
333 : | addr (ra, d); | ||
334 : | emit_region mem ) | ||
335 : | | I.ST{st, rs, ra, d, mem} => | ||
336 : | ( emitx (asm_store st, d); | ||
337 : | emit "\t"; | ||
338 : | emitCell rs; | ||
339 : | emit ", "; | ||
340 : | addr (ra, d); | ||
341 : | emit_region mem ) | ||
342 : | | I.STF{st, fs, ra, d, mem} => | ||
343 : | ( emitx (asm_fstore st, d); | ||
344 : | emit "\t"; | ||
345 : | emitCell fs; | ||
346 : | emit ", "; | ||
347 : | addr (ra, d); | ||
348 : | emit_region mem ) | ||
349 : | | I.UNARY{oper, rt, ra, Rc, OE} => | ||
350 : | ( emit_unary oper; | ||
351 : | eOERc {Rc=Rc, OE=OE}; | ||
352 : | emit "\t"; | ||
353 : | emitCell rt; | ||
354 : | emit ", "; | ||
355 : | emitCell ra ) | ||
356 : | | I.ARITH{oper, rt, ra, rb, Rc, OE} => | ||
357 : | ( emit_arith oper; | ||
358 : | eOERc {Rc=Rc, OE=OE}; | ||
359 : | emit "\t"; | ||
360 : | emitCell rt; | ||
361 : | emit ", "; | ||
362 : | emitCell ra; | ||
363 : | emit ", "; | ||
364 : | emitCell rb ) | ||
365 : | | I.ARITHI{oper, rt, ra, im} => | ||
366 : | ( emit_arithi oper; | ||
367 : | emit "\t"; | ||
368 : | emitCell rt; | ||
369 : | emit ", "; | ||
370 : | emitCell ra; | ||
371 : | emit ", "; | ||
372 : | emit_operand im ) | ||
373 : | | I.ROTATE{oper, ra, rs, sh, mb, me} => | ||
374 : | ( emit_rotate oper; | ||
375 : | emit "\t"; | ||
376 : | emitCell ra; | ||
377 : | emit ", "; | ||
378 : | emitCell rs; | ||
379 : | emit ", "; | ||
380 : | emitCell sh; | ||
381 : | emit ", "; | ||
382 : | emit_int mb; | ||
383 : | eME me ) | ||
384 : | | I.ROTATEI{oper, ra, rs, sh, mb, me} => | ||
385 : | ( emit_rotatei oper; | ||
386 : | emit "\t"; | ||
387 : | emitCell ra; | ||
388 : | emit ", "; | ||
389 : | emitCell rs; | ||
390 : | emit ", "; | ||
391 : | emit_operand sh; | ||
392 : | emit ", "; | ||
393 : | emit_int mb; | ||
394 : | eME me ) | ||
395 : | | I.COMPARE{cmp, l, bf, ra, rb} => | ||
396 : | ( emit_cmp cmp; | ||
397 : | eI rb; | ||
398 : | emit "\t"; | ||
399 : | emitCell bf; | ||
400 : | emit ", "; | ||
401 : | emit (if l | ||
402 : | then "1" | ||
403 : | else "0"); | ||
404 : | emit ", "; | ||
405 : | emitCell ra; | ||
406 : | emit ", "; | ||
407 : | emit_operand rb ) | ||
408 : | | I.FCOMPARE{cmp, bf, fa, fb} => | ||
409 : | ( emit_fcmp cmp; | ||
410 : | emit "\t"; | ||
411 : | emitCell bf; | ||
412 : | emit ", "; | ||
413 : | emitCell fa; | ||
414 : | emit ", "; | ||
415 : | emitCell fb ) | ||
416 : | | I.FUNARY{oper, ft, fb, Rc} => | ||
417 : | ( emit_funary oper; | ||
418 : | eRc Rc; | ||
419 : | emit "\t"; | ||
420 : | emitCell ft; | ||
421 : | emit ", "; | ||
422 : | emitCell fb ) | ||
423 : | | I.FARITH{oper, ft, fa, fb, Rc} => | ||
424 : | ( emit_farith oper; | ||
425 : | eRc Rc; | ||
426 : | emit "\t"; | ||
427 : | emitCell ft; | ||
428 : | emit ", "; | ||
429 : | emitCell fa; | ||
430 : | emit ", "; | ||
431 : | emitCell fb ) | ||
432 : | | I.FARITH3{oper, ft, fa, fb, fc, Rc} => | ||
433 : | ( emit_farith3 oper; | ||
434 : | eRc Rc; | ||
435 : | emit "\t"; | ||
436 : | emitCell ft; | ||
437 : | emit ", "; | ||
438 : | emitCell fa; | ||
439 : | emit ", "; | ||
440 : | emitCell fb; | ||
441 : | emit ", "; | ||
442 : | emitCell fc ) | ||
443 : | | I.CCARITH{oper, bt, ba, bb} => | ||
444 : | ( emit_ccarith oper; | ||
445 : | emit "\t"; | ||
446 : | eCRbit bt; | ||
447 : | emit ", "; | ||
448 : | eCRbit ba; | ||
449 : | emit ", "; | ||
450 : | eCRbit bb ) | ||
451 : | | I.MCRF{bf, bfa} => | ||
452 : | ( emit "mcrf\t"; | ||
453 : | emitCell bf; | ||
454 : | emit ", "; | ||
455 : | emitCell bfa ) | ||
456 : | | I.MTSPR{rs, spr} => | ||
457 : | ( emit "mt"; | ||
458 : | emitCell spr; | ||
459 : | emit "\t"; | ||
460 : | emitCell rs ) | ||
461 : | | I.MFSPR{rt, spr} => | ||
462 : | ( emit "mf"; | ||
463 : | emitCell spr; | ||
464 : | emit "\t"; | ||
465 : | emitCell rt ) | ||
466 : | | I.TW{to, ra, si} => | ||
467 : | ( emit "tw"; | ||
468 : | eI si; | ||
469 : | emit "\t"; | ||
470 : | emit_int to; | ||
471 : | emit ", "; | ||
472 : | emitCell ra; | ||
473 : | emit ", "; | ||
474 : | emit_operand si ) | ||
475 : | | I.TD{to, ra, si} => | ||
476 : | ( emit "td"; | ||
477 : | eI si; | ||
478 : | emit "\t"; | ||
479 : | emit_int to; | ||
480 : | emit ", "; | ||
481 : | emitCell ra; | ||
482 : | emit ", "; | ||
483 : | emit_operand si ) | ||
484 : | | I.BC{bo, bf, bit, addr, LK, fall} => | ||
485 : | ( emit "b"; | ||
486 : | emit_bo bo; | ||
487 : | eLK LK; | ||
488 : | emit "\t"; | ||
489 : | eBI (bo, bf, bit); | ||
490 : | emit ", "; | ||
491 : | emit_operand addr ) | ||
492 : | | I.BCLR{bo, bf, bit, LK, labels} => | ||
493 : | ( emit "b"; | ||
494 : | emit_bo bo; | ||
495 : | emit "lr"; | ||
496 : | eLK LK; | ||
497 : | emit "\t"; | ||
498 : | eBI (bo, bf, bit)) | ||
499 : | | I.B{addr, LK} => | ||
500 : | ( emit "b"; | ||
501 : | eLK LK; | ||
502 : | emit "\t"; | ||
503 : | emit_operand addr ) | ||
504 : | leunga | 796 | | I.CALL{def, use, cutsTo, mem} => |
505 : | leunga | 744 | ( emit "blrl"; |
506 : | emit_region mem; | ||
507 : | emit_defs def; | ||
508 : | leunga | 796 | emit_uses use; |
509 : | emit_cutsTo cutsTo ) | ||
510 : | leunga | 744 | | I.SOURCE{} => emit "source" |
511 : | | I.SINK{} => emit "sink" | ||
512 : | | I.PHI{} => emit "phi" | ||
513 : | leunga | 594 | ) |
514 : | george | 1003 | in tab(); emitInstr' instr; nl() |
515 : | end (* emitter *) | ||
516 : | and emitInstrIndented i = (indent(); emitInstr i; nl()) | ||
517 : | and emitInstrs instrs = | ||
518 : | leunga | 594 | app (if !indent_copies then emitInstrIndented |
519 : | else emitInstr) instrs | ||
520 : | monnier | 411 | |
521 : | george | 1003 | and emitInstr(I.ANNOTATION{i,a}) = |
522 : | ( comment(Annotations.toString a); | ||
523 : | nl(); | ||
524 : | emitInstr i ) | ||
525 : | | emitInstr(I.LIVE{regs, spilled}) = | ||
526 : | comment("live= " ^ CellsBasis.CellSet.toString regs ^ | ||
527 : | "spilled= " ^ CellsBasis.CellSet.toString spilled) | ||
528 : | | emitInstr(I.KILL{regs, spilled}) = | ||
529 : | comment("killed:: " ^ CellsBasis.CellSet.toString regs ^ | ||
530 : | "spilled:: " ^ CellsBasis.CellSet.toString spilled) | ||
531 : | | emitInstr(I.INSTR i) = emitter i | ||
532 : | george | 1009 | | emitInstr(I.COPY{k=CellsBasis.GP, sz, src, dst, tmp}) = |
533 : | emitInstrs(Shuffle.shuffle{tmp=tmp, src=src, dst=dst}) | ||
534 : | | emitInstr(I.COPY{k=CellsBasis.FP, sz, src, dst, tmp}) = | ||
535 : | emitInstrs(Shuffle.shufflefp{tmp=tmp, src=src, dst=dst}) | ||
536 : | george | 1003 | | emitInstr _ = error "emitInstr" |
537 : | |||
538 : | monnier | 429 | in S.STREAM{beginCluster=init, |
539 : | monnier | 411 | pseudoOp=pseudoOp, |
540 : | george | 1003 | emit=emitInstr, |
541 : | george | 909 | endCluster=fail, |
542 : | monnier | 411 | defineLabel=defineLabel, |
543 : | entryLabel=entryLabel, | ||
544 : | comment=comment, | ||
545 : | exitBlock=doNothing, | ||
546 : | leunga | 815 | annotation=annotation, |
547 : | getAnnotations=getAnnotations | ||
548 : | monnier | 411 | } |
549 : | end | ||
550 : | end | ||
551 : | monnier | 247 |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |