Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/sparc/emit/sparcAsm.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/sparc/emit/sparcAsm.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

sml/branches/SMLNJ/src/MLRISC/sparc/emit/sparcAsm.sml revision 498, Tue Dec 7 15:44:50 1999 UTC sml/trunk/src/MLRISC/sparc/emit/sparcAsm.sml revision 909, Fri Aug 24 17:48:53 2001 UTC
# Line 1  Line 1 
1  (*  (*
2   * This file was automatically generated by MDGen   * WARNING: This file was automatically generated by MDLGen (v3.0)
3   * from the machine description file "sparc/sparc.md".   * from the machine description file "sparc/sparc.mdl".
4     * DO NOT EDIT this file directly
5   *)   *)
6    
7    
8  functor SparcAsmEmitter(structure Instr : SPARCINSTR  functor SparcAsmEmitter(structure Instr : SPARCINSTR
                         structure Stream : INSTRUCTION_STREAM  
9                          structure Shuffle : SPARCSHUFFLE                          structure Shuffle : SPARCSHUFFLE
10                             where I = Instr                             where I = Instr
11    
12  (*#line 251.1 "sparc/sparc.md"*)  (*#line 466.21 "sparc/sparc.mdl"*)
13                          val V9 : bool                          val V9 : bool
14                         ) : INSTRUCTION_EMITTER =                         ) : INSTRUCTION_EMITTER =
15  struct  struct
16     structure I  = Instr     structure I  = Instr
17     structure C  = I.C     structure C  = I.C
18     structure S  = Stream     structure T  = I.T
19       structure S  = T.Stream
20     structure P  = S.P     structure P  = S.P
21     structure LE = LabelExp     structure LabelExp = I.LabelExp
22     structure Constant = I.Constant     structure Constant = I.Constant
23    
24     val show_cellset = MLRiscControl.getFlag "asm-show-cellset"     val show_cellset = MLRiscControl.getFlag "asm-show-cellset"
25       val show_region  = MLRiscControl.getFlag "asm-show-region"
26       val show_cutsTo = MLRiscControl.getFlag "asm-show-cutsto"
27       val indent_copies = MLRiscControl.getFlag "asm-indent-copies"
28    
29     fun error msg = MLRiscErrorMsg.error("SparcAsm",msg)     fun error msg = MLRiscErrorMsg.error("SparcAsmEmitter",msg)
30    
31     fun makeStream formatAnnotations =     fun makeStream formatAnnotations =
32     let val stream = !AsmStream.asmOutStream     let val stream = !AsmStream.asmOutStream
# Line 34  Line 38 
38         fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s)         fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s)
39         fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n"))         fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n"))
40         fun comma() = emit ","         fun comma() = emit ","
41         fun tab() = tabs := !tabs + 1         fun tab() = tabs := 1
42           fun indent() = tabs := 2
43         fun ms n = let val s = Int.toString n         fun ms n = let val s = Int.toString n
44                    in  if n<0 then "-"^String.substring(s,1,size s-1)                    in  if n<0 then "-"^String.substring(s,1,size s-1)
45                        else s                        else s
46                    end                    end
47         fun emit_label lab = emit(Label.nameOf lab)         fun emit_label lab = emit(Label.toString lab)
48         fun emit_labexp le = emit(LabelExp.toString le)         fun emit_labexp le = emit(LabelExp.toString le)
49         fun emit_const c = emit(Constant.toString c)         fun emit_const c = emit(Constant.toString c)
50         fun emit_int i = emit(ms i)         fun emit_int i = emit(ms i)
51         fun paren f = (emit "("; f(); emit ")")         fun paren f = (emit "("; f(); emit ")")
52         fun defineLabel lab = emit(Label.nameOf lab^":\n")         fun defineLabel lab = emit(Label.toString lab^":\n")
53         fun entryLabel lab = defineLabel lab         fun entryLabel lab = defineLabel lab
54         fun comment msg = emit("\t/* " ^ msg ^ " */")         fun comment msg = (tab(); emit("/* " ^ msg ^ " */\n"))
55         fun annotation a = (comment(Annotations.toString a); nl())         fun annotation a = (comment(Annotations.toString a); nl())
56           fun getAnnotations() = error "getAnnotations"
57           fun doNothing _ = ()
58           fun fail _ = raise Fail "AsmEmitter"
59         fun emit_region mem = comment(I.Region.toString mem)         fun emit_region mem = comment(I.Region.toString mem)
60           val emit_region =
61              if !show_region then emit_region else doNothing
62         fun pseudoOp pOp = emit(P.toString pOp)         fun pseudoOp pOp = emit(P.toString pOp)
63         fun init size = (comment("Code Size = " ^ ms size); nl())         fun init size = (comment("Code Size = " ^ ms size); nl())
64         fun doNothing _ = ()         val emitCellInfo = AsmFormatUtil.reginfo
65         val emitRegInfo = AsmFormatUtil.reginfo(emit,formatAnnotations)                                  (emit,formatAnnotations)
66         fun emitter regmap =         fun emitCell r = (emit(CellsBasis.toString r); emitCellInfo r)
        let  
   
    fun emit_PSR r =  
        ((emit (C.showPSR (regmap r)));  
        (emitRegInfo r))  
    and emit_CC r =  
        ((emit (C.showCC (regmap r)));  
        (emitRegInfo r))  
    and emit_Y r =  
        ((emit (C.showY (regmap r)));  
        (emitRegInfo r))  
    and emit_FP r =  
        ((emit (C.showFP (regmap r)));  
        (emitRegInfo r))  
    and emit_GP r =  
        ((emit (C.showGP (regmap r)));  
        (emitRegInfo r))  
    and emit_FSR r =  
        ((emit (C.showFSR (regmap r)));  
        (emitRegInfo r))  
   
67         fun emit_cellset(title,cellset) =         fun emit_cellset(title,cellset) =
68         if !show_cellset then           (nl(); comment(title^CellsBasis.CellSet.toString cellset))
69           (nl(); comment(title^C.cellsetToString' regmap cellset))         val emit_cellset =
70         else ()           if !show_cellset then emit_cellset else doNothing
71         fun emit_defs cellset = emit_cellset("defs: ",cellset)         fun emit_defs cellset = emit_cellset("defs: ",cellset)
72         fun emit_uses cellset = emit_cellset("uses: ",cellset)         fun emit_uses cellset = emit_cellset("uses: ",cellset)
73           val emit_cutsTo =
74     fun asm_farith1 (I.FiTOs) = "fitos"           if !show_cutsTo then AsmFormatUtil.emit_cutsTo emit
75       | asm_farith1 (I.FiTOd) = "fitod"           else doNothing
76       | asm_farith1 (I.FiTOq) = "fitoq"         fun emitter instr =
77       | asm_farith1 (I.FsTOi) = "fstoi"         let
78       | asm_farith1 (I.FdTOi) = "fdtoi"     fun asm_load (I.LDSB) = "ldsb"
79       | asm_farith1 (I.FqTOi) = "fqtoi"       | asm_load (I.LDSH) = "ldsh"
80       | asm_farith1 (I.FsTOd) = "fstod"       | asm_load (I.LDUB) = "ldub"
81       | asm_farith1 (I.FsTOq) = "fstoq"       | asm_load (I.LDUH) = "lduh"
82       | asm_farith1 (I.FdTOs) = "fdtos"       | asm_load (I.LD) = "ld"
83       | asm_farith1 (I.FdTOq) = "fdtoq"       | asm_load (I.LDX) = "ldx"
84       | asm_farith1 (I.FqTOs) = "fqtos"       | asm_load (I.LDD) = "ldd"
85       | asm_farith1 (I.FqTOd) = "fqtod"     and emit_load x = emit (asm_load x)
      | asm_farith1 (I.FMOVs) = "fmovs"  
      | asm_farith1 (I.FNEGs) = "fnegs"  
      | asm_farith1 (I.FABSs) = "fabss"  
      | asm_farith1 (I.FMOVd) = "fmovd"  
      | asm_farith1 (I.FNEGd) = "fnegd"  
      | asm_farith1 (I.FABSd) = "fabsd"  
      | asm_farith1 (I.FMOVq) = "fmovq"  
      | asm_farith1 (I.FNEGq) = "fnegq"  
      | asm_farith1 (I.FABSq) = "fabsq"  
      | asm_farith1 (I.FSQRTs) = "fsqrts"  
      | asm_farith1 (I.FSQRTd) = "fsqrtd"  
      | asm_farith1 (I.FSQRTq) = "fsqrtq"  
    and emit_farith1 x = (emit (asm_farith1 x))  
86     and asm_store (I.STB) = "stb"     and asm_store (I.STB) = "stb"
87       | asm_store (I.STH) = "sth"       | asm_store (I.STH) = "sth"
88       | asm_store (I.ST) = "st"       | asm_store (I.ST) = "st"
89       | asm_store (I.STX) = "stx"       | asm_store (I.STX) = "stx"
90       | asm_store (I.STD) = "std"       | asm_store (I.STD) = "std"
91     and emit_store x = (emit (asm_store x))     and emit_store x = emit (asm_store x)
    and emit_operand (I.REG GP) = (emit_GP GP)  
      | emit_operand (I.IMMED int) = (emit_int int)  
      | emit_operand (I.LAB labexp) = (emit_labexp labexp)  
      | emit_operand (I.LO labexp) =  
        ((emit "%lo(");  
        (emit_labexp labexp);  
        (emit ")"))  
      | emit_operand (I.HI labexp) =  
        ((emit "%hi(");  
        (emit_labexp labexp);  
        (emit ")"))  
      | emit_operand (I.CONST const) = (emit_const const)  
92     and asm_fload (I.LDF) = "ldf"     and asm_fload (I.LDF) = "ldf"
93       | asm_fload (I.LDDF) = "lddf"       | asm_fload (I.LDDF) = "lddf"
94       | asm_fload (I.LDQF) = "ldqf"       | asm_fload (I.LDQF) = "ldqf"
95       | asm_fload (I.LDFSR) = "ldfsr"       | asm_fload (I.LDFSR) = "ldfsr"
96       | asm_fload (I.LDXFSR) = "ldxfsr"       | asm_fload (I.LDXFSR) = "ldxfsr"
97     and emit_fload x = (emit (asm_fload x))     and emit_fload x = emit (asm_fload x)
98     and asm_fstore (I.STF) = "stf"     and asm_fstore (I.STF) = "stf"
99       | asm_fstore (I.STDF) = "stdf"       | asm_fstore (I.STDF) = "stdf"
100       | asm_fstore (I.STFSR) = "stfsr"       | asm_fstore (I.STFSR) = "stfsr"
101     and emit_fstore x = (emit (asm_fstore x))     and emit_fstore x = emit (asm_fstore x)
    and asm_prediction (I.PT) = "pt"  
      | asm_prediction (I.PN) = "pn"  
    and emit_prediction x = (emit (asm_prediction x))  
    and asm_fsize (I.S) = "s"  
      | asm_fsize (I.D) = "d"  
      | asm_fsize (I.Q) = "q"  
    and emit_fsize x = (emit (asm_fsize x))  
    and asm_shift (I.SLL) = "sll"  
      | asm_shift (I.SRL) = "srl"  
      | asm_shift (I.SRA) = "sra"  
      | asm_shift (I.SLLX) = "sllx"  
      | asm_shift (I.SRLX) = "srlx"  
      | asm_shift (I.SRAX) = "srax"  
    and emit_shift x = (emit (asm_shift x))  
    and asm_branch (I.BN) = "n"  
      | asm_branch (I.BE) = "e"  
      | asm_branch (I.BLE) = "le"  
      | asm_branch (I.BL) = "l"  
      | asm_branch (I.BLEU) = "leu"  
      | asm_branch (I.BCS) = "cs"  
      | asm_branch (I.BNEG) = "neg"  
      | asm_branch (I.BVS) = "vs"  
      | asm_branch (I.BA) = ""  
      | asm_branch (I.BNE) = "ne"  
      | asm_branch (I.BG) = "g"  
      | asm_branch (I.BGE) = "ge"  
      | asm_branch (I.BGU) = "gu"  
      | asm_branch (I.BCC) = "cc"  
      | asm_branch (I.BPOS) = "pos"  
      | asm_branch (I.BVC) = "vs"  
    and emit_branch x = (emit (asm_branch x))  
102     and asm_arith (I.AND) = "and"     and asm_arith (I.AND) = "and"
103       | asm_arith (I.ANDCC) = "andcc"       | asm_arith (I.ANDCC) = "andcc"
104       | asm_arith (I.ANDN) = "andn"       | asm_arith (I.ANDN) = "andn"
# Line 201  Line 134 
134       | asm_arith (I.MULX) = "mulx"       | asm_arith (I.MULX) = "mulx"
135       | asm_arith (I.SDIVX) = "sdivx"       | asm_arith (I.SDIVX) = "sdivx"
136       | asm_arith (I.UDIVX) = "udivx"       | asm_arith (I.UDIVX) = "udivx"
137     and emit_arith x = (emit (asm_arith x))     and emit_arith x = emit (asm_arith x)
138       and asm_shift (I.SLL) = "sll"
139         | asm_shift (I.SRL) = "srl"
140         | asm_shift (I.SRA) = "sra"
141         | asm_shift (I.SLLX) = "sllx"
142         | asm_shift (I.SRLX) = "srlx"
143         | asm_shift (I.SRAX) = "srax"
144       and emit_shift x = emit (asm_shift x)
145       and asm_farith1 (I.FiTOs) = "fitos"
146         | asm_farith1 (I.FiTOd) = "fitod"
147         | asm_farith1 (I.FiTOq) = "fitoq"
148         | asm_farith1 (I.FsTOi) = "fstoi"
149         | asm_farith1 (I.FdTOi) = "fdtoi"
150         | asm_farith1 (I.FqTOi) = "fqtoi"
151         | asm_farith1 (I.FsTOd) = "fstod"
152         | asm_farith1 (I.FsTOq) = "fstoq"
153         | asm_farith1 (I.FdTOs) = "fdtos"
154         | asm_farith1 (I.FdTOq) = "fdtoq"
155         | asm_farith1 (I.FqTOs) = "fqtos"
156         | asm_farith1 (I.FqTOd) = "fqtod"
157         | asm_farith1 (I.FMOVs) = "fmovs"
158         | asm_farith1 (I.FNEGs) = "fnegs"
159         | asm_farith1 (I.FABSs) = "fabss"
160         | asm_farith1 (I.FMOVd) = "fmovd"
161         | asm_farith1 (I.FNEGd) = "fnegd"
162         | asm_farith1 (I.FABSd) = "fabsd"
163         | asm_farith1 (I.FMOVq) = "fmovq"
164         | asm_farith1 (I.FNEGq) = "fnegq"
165         | asm_farith1 (I.FABSq) = "fabsq"
166         | asm_farith1 (I.FSQRTs) = "fsqrts"
167         | asm_farith1 (I.FSQRTd) = "fsqrtd"
168         | asm_farith1 (I.FSQRTq) = "fsqrtq"
169       and emit_farith1 x = emit (asm_farith1 x)
170       and asm_farith2 (I.FADDs) = "fadds"
171         | asm_farith2 (I.FADDd) = "faddd"
172         | asm_farith2 (I.FADDq) = "faddq"
173         | asm_farith2 (I.FSUBs) = "fsubs"
174         | asm_farith2 (I.FSUBd) = "fsubd"
175         | asm_farith2 (I.FSUBq) = "fsubq"
176         | asm_farith2 (I.FMULs) = "fmuls"
177         | asm_farith2 (I.FMULd) = "fmuld"
178         | asm_farith2 (I.FMULq) = "fmulq"
179         | asm_farith2 (I.FsMULd) = "fsmuld"
180         | asm_farith2 (I.FdMULq) = "fdmulq"
181         | asm_farith2 (I.FDIVs) = "fdivs"
182         | asm_farith2 (I.FDIVd) = "fdivd"
183         | asm_farith2 (I.FDIVq) = "fdivq"
184       and emit_farith2 x = emit (asm_farith2 x)
185     and asm_fcmp (I.FCMPs) = "fcmps"     and asm_fcmp (I.FCMPs) = "fcmps"
186       | asm_fcmp (I.FCMPd) = "fcmpd"       | asm_fcmp (I.FCMPd) = "fcmpd"
187       | asm_fcmp (I.FCMPq) = "fcmpq"       | asm_fcmp (I.FCMPq) = "fcmpq"
188       | asm_fcmp (I.FCMPEs) = "fcmpes"       | asm_fcmp (I.FCMPEs) = "fcmpes"
189       | asm_fcmp (I.FCMPEd) = "fcmped"       | asm_fcmp (I.FCMPEd) = "fcmped"
190       | asm_fcmp (I.FCMPEq) = "fcmpeq"       | asm_fcmp (I.FCMPEq) = "fcmpeq"
191     and emit_fcmp x = (emit (asm_fcmp x))     and emit_fcmp x = emit (asm_fcmp x)
192       and asm_branch (I.BN) = "n"
193         | asm_branch (I.BE) = "e"
194         | asm_branch (I.BLE) = "le"
195         | asm_branch (I.BL) = "l"
196         | asm_branch (I.BLEU) = "leu"
197         | asm_branch (I.BCS) = "cs"
198         | asm_branch (I.BNEG) = "neg"
199         | asm_branch (I.BVS) = "vs"
200         | asm_branch (I.BA) = ""
201         | asm_branch (I.BNE) = "ne"
202         | asm_branch (I.BG) = "g"
203         | asm_branch (I.BGE) = "ge"
204         | asm_branch (I.BGU) = "gu"
205         | asm_branch (I.BCC) = "cc"
206         | asm_branch (I.BPOS) = "pos"
207         | asm_branch (I.BVC) = "vs"
208       and emit_branch x = emit (asm_branch x)
209     and asm_rcond (I.RZ) = "rz"     and asm_rcond (I.RZ) = "rz"
210       | asm_rcond (I.RLEZ) = "rlez"       | asm_rcond (I.RLEZ) = "rlez"
211       | asm_rcond (I.RLZ) = "rlz"       | asm_rcond (I.RLZ) = "rlz"
212       | asm_rcond (I.RNZ) = "rnz"       | asm_rcond (I.RNZ) = "rnz"
213       | asm_rcond (I.RGZ) = "rgz"       | asm_rcond (I.RGZ) = "rgz"
214       | asm_rcond (I.RGEZ) = "rgez"       | asm_rcond (I.RGEZ) = "rgez"
215     and emit_rcond x = (emit (asm_rcond x))     and emit_rcond x = emit (asm_rcond x)
216       and asm_prediction (I.PT) = "pt"
217         | asm_prediction (I.PN) = "pn"
218       and emit_prediction x = emit (asm_prediction x)
219     and asm_fbranch (I.FBN) = "fbn"     and asm_fbranch (I.FBN) = "fbn"
220       | asm_fbranch (I.FBNE) = "fbne"       | asm_fbranch (I.FBNE) = "fbne"
221       | asm_fbranch (I.FBLG) = "fblg"       | asm_fbranch (I.FBLG) = "fblg"
# Line 232  Line 232 
232       | asm_fbranch (I.FBLE) = "fble"       | asm_fbranch (I.FBLE) = "fble"
233       | asm_fbranch (I.FBULE) = "fbule"       | asm_fbranch (I.FBULE) = "fbule"
234       | asm_fbranch (I.FBO) = "fbo"       | asm_fbranch (I.FBO) = "fbo"
235     and emit_fbranch x = (emit (asm_fbranch x))     and emit_fbranch x = emit (asm_fbranch x)
236     and asm_load (I.LDSB) = "ldsb"     and asm_fsize (I.S) = "s"
237       | asm_load (I.LDSH) = "ldsh"       | asm_fsize (I.D) = "d"
238       | asm_load (I.LDUB) = "ldub"       | asm_fsize (I.Q) = "q"
239       | asm_load (I.LDUH) = "lduh"     and emit_fsize x = emit (asm_fsize x)
240       | asm_load (I.LD) = "ld"     and emit_operand (I.REG GP) = emitCell GP
241       | asm_load (I.LDX) = "ldx"       | emit_operand (I.IMMED int) = emit_int int
242       | asm_load (I.LDD) = "ldd"       | emit_operand (I.LAB labexp) = emit_labexp labexp
243     and emit_load x = (emit (asm_load x))       | emit_operand (I.LO labexp) =
244     and asm_farith2 (I.FADDs) = "fadds"         ( emit "%lo(";
245       | asm_farith2 (I.FADDd) = "faddd"           emit_labexp labexp;
246       | asm_farith2 (I.FADDq) = "faddq"           emit ")" )
247       | asm_farith2 (I.FSUBs) = "fsubs"       | emit_operand (I.HI labexp) =
248       | asm_farith2 (I.FSUBd) = "fsubd"         ( emit "%hi(";
249       | asm_farith2 (I.FSUBq) = "fsubq"           emit_labexp labexp;
250       | asm_farith2 (I.FMULs) = "fmuls"           emit ")" )
      | asm_farith2 (I.FMULd) = "fmuld"  
      | asm_farith2 (I.FMULq) = "fmulq"  
      | asm_farith2 (I.FsMULd) = "fsmuld"  
      | asm_farith2 (I.FdMULq) = "fdmulq"  
      | asm_farith2 (I.FDIVs) = "fdivs"  
      | asm_farith2 (I.FDIVd) = "fdivd"  
      | asm_farith2 (I.FDIVq) = "fdivq"  
    and emit_farith2 x = (emit (asm_farith2 x))  
251    
252    (*#line 469.7 "sparc/sparc.mdl"*)
253     fun emit_leaf false = ()     fun emit_leaf false = ()
254       | emit_leaf true = (emit "l")       | emit_leaf true = emit "l"
255    
256    (*#line 470.7 "sparc/sparc.mdl"*)
257     fun emit_nop false = ()     fun emit_nop false = ()
258       | emit_nop true = (emit "\n\tnop")       | emit_nop true = emit "\n\tnop"
259    
260    (*#line 471.7 "sparc/sparc.mdl"*)
261     fun emit_a false = ()     fun emit_a false = ()
262       | emit_a true = (emit ",a")       | emit_a true = emit ",a"
263    
264    (*#line 472.7 "sparc/sparc.mdl"*)
265     fun emit_cc false = ()     fun emit_cc false = ()
266       | emit_cc true = (emit "cc")       | emit_cc true = emit "cc"
267       fun emitInstr' instr =
268     fun emitInstr instr =         (case instr of
        ((tab ());  
   
        (  
         case instr of  
269          I.LOAD{l, d, r, i, mem} =>          I.LOAD{l, d, r, i, mem} =>
270          ((emit_load l);           ( emit_load l;
271          (emit "\t[");             emit "\t[";
272          (emit_GP r);             emitCell r;
273          (emit "+");             emit "+";
274          (emit_operand i);             emit_operand i;
275          (emit "], ");             emit "], ";
276          (emit_GP d);             emitCell d;
277          (emit_region mem))             emit_region mem )
278        | I.STORE{s, d, r, i, mem} =>        | I.STORE{s, d, r, i, mem} =>
279          ((emit_store s);           ( emit_store s;
280          (emit "\t");             emit "\t";
281          (emit_GP d);             emitCell d;
282          (emit ", [");             emit ", [";
283          (emit_GP r);             emitCell r;
284          (emit "+");             emit "+";
285          (emit_operand i);             emit_operand i;
286          (emit "]");             emit "]";
287          (emit_region mem))             emit_region mem )
288        | I.FLOAD{l, r, i, d, mem} =>        | I.FLOAD{l, r, i, d, mem} =>
289          ((emit_fload l);           ( emit_fload l;
290          (emit "\t[");             emit "\t[";
291          (emit_GP r);             emitCell r;
292          (emit "+");             emit "+";
293          (emit_operand i);             emit_operand i;
294          (emit "], ");             emit "], ";
295          (emit_FP d);             emitCell d;
296          (emit_region mem))             emit_region mem )
297        | I.FSTORE{s, d, r, i, mem} =>        | I.FSTORE{s, d, r, i, mem} =>
298          ((emit_fstore s);           ( emit_fstore s;
299          (emit "\t[");             emit "\t[";
300          (emit_GP r);             emitCell r;
301          (emit "+");             emit "+";
302          (emit_operand i);             emit_operand i;
303          (emit "], ");             emit "], ";
304          (emit_FP d);             emitCell d;
305          (emit_region mem))             emit_region mem )
306           | I.UNIMP{const22} =>
307             ( emit "unimp ";
308               emit_int const22 )
309        | I.SETHI{i, d} =>        | I.SETHI{i, d} =>
310          ((emit "sethi\t%hi(0x");           let
311          (emit (Word32.toString (Word32.<< ((Word32.fromInt i), 0wxa))));  (*#line 656.18 "sparc/sparc.mdl"*)
312          (emit "), ");               val i = Word32.toString (Word32.<< (Word32.fromInt i, 0wxa))
313          (emit_GP d))           in
314                ( emit "sethi\t%hi(0x";
315                  emit i;
316                  emit "), ";
317                  emitCell d )
318             end
319        | I.ARITH{a, r, i, d} =>        | I.ARITH{a, r, i, d} =>
320          ((emit_arith a);           (case (a, CellsBasis.registerId r, CellsBasis.registerId d) of
321          (emit "\t");             (I.OR, 0, _) =>
322          (emit_GP r);             ( emit "mov\t";
323          (emit ", ");               emit_operand i;
324          (emit_operand i);               emit ", ";
325          (emit ", ");               emitCell d )
326          (emit_GP d))           | (I.SUBCC, _, 0) =>
327               ( emit "cmp\t";
328                 emitCell r;
329                 emit ", ";
330                 emit_operand i )
331             | _ =>
332               ( emit_arith a;
333                 emit "\t";
334                 emitCell r;
335                 emit ", ";
336                 emit_operand i;
337                 emit ", ";
338                 emitCell d )
339             )
340        | I.SHIFT{s, r, i, d} =>        | I.SHIFT{s, r, i, d} =>
341          ((emit_shift s);           ( emit_shift s;
342          (emit "\t");             emit "\t";
343          (emit_GP r);             emitCell r;
344          (emit ", ");             emit ", ";
345          (emit_operand i);             emit_operand i;
346          (emit ", ");             emit ", ";
347          (emit_GP d))             emitCell d )
348        | I.MOVicc{b, i, d} =>        | I.MOVicc{b, i, d} =>
349          ((emit "mov");           ( emit "mov";
350          (emit_branch b);             emit_branch b;
351          (emit "\t");             emit "\t";
352          (emit_operand i);             emit_operand i;
353          (emit ", ");             emit ", ";
354          (emit_GP d))             emitCell d )
355        | I.MOVfcc{b, i, d} =>        | I.MOVfcc{b, i, d} =>
356          ((emit "mov");           ( emit "mov";
357          (emit_fbranch b);             emit_fbranch b;
358          (emit "\t");             emit "\t";
359          (emit_operand i);             emit_operand i;
360          (emit ", ");             emit ", ";
361          (emit_GP d))             emitCell d )
362        | I.MOVR{rcond, r, i, d} =>        | I.MOVR{rcond, r, i, d} =>
363          ((emit "movr");           ( emit "movr";
364          (emit_rcond rcond);             emit_rcond rcond;
365          (emit "\t");             emit "\t";
366          (emit_GP r);             emitCell r;
367          (emit ", ");             emit ", ";
368          (emit_operand i);             emit_operand i;
369          (emit ", ");             emit ", ";
370          (emit_GP d))             emitCell d )
371        | I.FMOVicc{sz, b, r, d} =>        | I.FMOVicc{sz, b, r, d} =>
372          ((emit "fmov");           ( emit "fmov";
373          (emit_fsize sz);             emit_fsize sz;
374          (emit_branch b);             emit_branch b;
375          (emit "\t");             emit "\t";
376          (emit_FP r);             emitCell r;
377          (emit ", ");             emit ", ";
378          (emit_FP d))             emitCell d )
379        | I.FMOVfcc{sz, b, r, d} =>        | I.FMOVfcc{sz, b, r, d} =>
380          ((emit "fmov");           ( emit "fmov";
381          (emit_fsize sz);             emit_fsize sz;
382          (emit_fbranch b);             emit_fbranch b;
383          (emit "\t");             emit "\t";
384          (emit_FP r);             emitCell r;
385          (emit ", ");             emit ", ";
386          (emit_FP d))             emitCell d )
387        | I.Bicc{b, a, label, nop} =>        | I.Bicc{b, a, label, nop} =>
388          ((emit "b");           ( emit "b";
389          (emit_branch b);             emit_branch b;
390          (emit_a a);             emit_a a;
391          (emit "\t");             emit "\t";
392          (emit_label label);             emit_label label;
393          (emit_nop nop))             emit_nop nop )
394        | I.FBfcc{b, a, label, nop} =>        | I.FBfcc{b, a, label, nop} =>
395          ((emit_fbranch b);           ( emit_fbranch b;
396          (emit_a a);             emit_a a;
397          (emit "\t");             emit "\t";
398          (emit_label label);             emit_label label;
399          (emit_nop nop))             emit_nop nop )
400        | I.BR{rcond, p, r, a, label, nop} =>        | I.BR{rcond, p, r, a, label, nop} =>
401          ((emit "b");           ( emit "b";
402          (emit_rcond rcond);             emit_rcond rcond;
403          (emit_a a);             emit_a a;
404          (emit_prediction p);             emit_prediction p;
405          (emit "\t");             emit "\t";
406          (emit_GP r);             emitCell r;
407          (emit ", ");             emit ", ";
408          (emit_label label);             emit_label label;
409          (emit_nop nop))             emit_nop nop )
410        | I.BP{b, p, cc, a, label, nop} =>        | I.BP{b, p, cc, a, label, nop} =>
411          ((emit "bp");           ( emit "bp";
412          (emit_branch b);             emit_branch b;
413          (emit_a a);             emit_a a;
414          (emit_prediction p);             emit_prediction p;
415          (emit "\t%");             emit "\t%";
416          (emit (if (cc = I.ICC)             emit (if (cc = I.ICC)
417             then "i"             then "i"
418             else "x"));                else "x");
419          (emit "cc, ");             emit "cc, ";
420          (emit_label label);             emit_label label;
421          (emit_nop nop))             emit_nop nop )
422        | I.JMP{r, i, labs, nop} =>        | I.JMP{r, i, labs, nop} =>
423          ((emit "jmp\t[");           ( emit "jmp\t[";
424          (emit_GP r);             emitCell r;
425          (emit "+");             emit "+";
426          (emit_operand i);             emit_operand i;
427          (emit "]");             emit "]";
428          (emit_nop nop))             emit_nop nop )
429        | I.JMPL{r, i, d, defs, uses, nop, mem} =>         | I.JMPL{r, i, d, defs, uses, cutsTo, nop, mem} =>
430          ((emit "jmpl\t[");           ( emit "jmpl\t[";
431          (emit_GP r);             emitCell r;
432          (emit "+");             emit "+";
433          (emit_operand i);             emit_operand i;
434          (emit "], ");             emit "], ";
435          (emit_GP d);             emitCell d;
436          (emit_region mem);             emit_region mem;
437          (emit_defs defs);             emit_defs defs;
438          (emit_uses uses);             emit_uses uses;
439          (emit_nop nop))             emit_cutsTo cutsTo;
440        | I.CALL{defs, uses, label, nop, mem} =>             emit_nop nop )
441          ((emit "call\t");         | I.CALL{defs, uses, label, cutsTo, nop, mem} =>
442          (emit_label label);           ( emit "call\t";
443          (emit_region mem);             emit_label label;
444          (emit_defs defs);             emit_region mem;
445          (emit_uses uses);             emit_defs defs;
446          (emit_nop nop))             emit_uses uses;
447               emit_cutsTo cutsTo;
448               emit_nop nop )
449        | I.Ticc{t, cc, r, i} =>        | I.Ticc{t, cc, r, i} =>
450          ((emit "t");           ( emit "t";
451          (emit_branch t);             emit_branch t;
452          (emit "\t");             emit "\t";
453          (if (cc = I.ICC)          (if (cc = I.ICC)
454             then ()             then ()
455             else (emit "%xcc, "));             else (emit "%xcc, "));
456          (emit_GP r);             emitCell r;
457          (emit ", ");             emit "+";
458          (emit_operand i))             emit_operand i )
459        | I.FPop1{a, r, d} => let         | I.FPop1{a, r, d} =>
460             let
461  (*#line 508.1 "sparc/sparc.md"*)  (*#line 763.18 "sparc/sparc.mdl"*)
   
462             fun f (a, r, d) =             fun f (a, r, d) =
463                 ((emit a);                   ( emit a;
464                 (emit "\t");                     emit "\t";
465                 (emit_FP r);                     emit (C.showFP r);
466                 (emit ", ");                     emit ", ";
467                 (emit_FP d))                     emit (C.showFP d))
   
 (*#line 510.1 "sparc/sparc.md"*)  
   
            fun g (a, r, d) = let  
   
 (*#line 511.1 "sparc/sparc.md"*)  
                   val r = (regmap r)  
                  and d = (regmap d)  
                in (f (a, r, d));  
                   (emit "\n\t");  
                   (f ("fmovs", (r + 1), (d + 1)))  
                end  
   
   
 (*#line 515.1 "sparc/sparc.md"*)  
468    
469             fun h (a, r, d) = let  (*#line 768.18 "sparc/sparc.mdl"*)
470                 fun g (a, r, d) =
471  (*#line 516.1 "sparc/sparc.md"*)                   let
472                    val r = (regmap r)  (*#line 769.22 "sparc/sparc.mdl"*)
473                   and d = (regmap d)                       val r = CellsBasis.registerNum r
474                 in (f (a, r, d));                       and d = CellsBasis.registerNum d
475                    (emit "\n\t");                   in f (a, r, d);
476                    (f ("fmovs", (r + 1), (d + 1)));                      emit "\n\t";
477                    (emit "\n\t");                      f ("fmovs", r + 1, d + 1)
                   (f ("fmovs", (r + 2), (d + 2)));  
                   (emit "\n\t");  
                   (f ("fmovs", (r + 3), (d + 3)))  
478                 end                 end
479    
480    (*#line 773.18 "sparc/sparc.mdl"*)
481                 fun h (a, r, d) =
482                     let
483    (*#line 774.22 "sparc/sparc.mdl"*)
484                         val r = CellsBasis.registerNum r
485                         and d = CellsBasis.registerNum d
486                     in f (a, r, d);
487                        emit "\n\t";
488                        f ("fmovs", r + 1, d + 1);
489                        emit "\n\t";
490                        f ("fmovs", r + 2, d + 2);
491                        emit "\n\t";
492                        f ("fmovs", r + 3, d + 3)
493                     end
494          in (if V9          in (if V9
495                then (f ((asm_farith1 a), r, d))                 then
496                   ( emit_farith1 a;
497                     emit "\t";
498                     emitCell r;
499                     emit ", ";
500                     emitCell d )
501                else                else
502                (                 (case a of
503                 case a of                   I.FMOVd => g ("fmovs", r, d)
504                 I.FMOVd => (g ("fmovs", r, d))                 | I.FNEGd => g ("fnegs", r, d)
505               | I.FNEGd => (g ("fnegs", r, d))                 | I.FABSd => g ("fabss", r, d)
506               | I.FABSd => (g ("fabss", r, d))                 | I.FMOVq => h ("fmovs", r, d)
507               | I.FMOVq => (h ("fmovs", r, d))                 | I.FNEGq => h ("fnegs", r, d)
508               | I.FNEGq => (h ("fnegs", r, d))                 | I.FABSq => h ("fabss", r, d)
509               | I.FABSq => (h ("fabss", r, d))                 | _ =>
510               | _ => (f ((asm_farith1 a), r, d))                   ( emit_farith1 a;
511                       emit "\t";
512                       emitCell r;
513                       emit ", ";
514                       emitCell d )
515                ))                ))
516          end          end
   
517        | I.FPop2{a, r1, r2, d} =>        | I.FPop2{a, r1, r2, d} =>
518          ((emit_farith2 a);           ( emit_farith2 a;
519          (emit "\t");             emit "\t";
520          (emit_FP r1);             emitCell r1;
521          (emit ", ");             emit ", ";
522          (emit_FP r2);             emitCell r2;
523          (emit ", ");             emit ", ";
524          (emit_FP d))             emitCell d )
525        | I.FCMP{cmp, r1, r2, nop} =>        | I.FCMP{cmp, r1, r2, nop} =>
526          ((emit_fcmp cmp);           ( emit_fcmp cmp;
527          (emit "\t");             emit "\t";
528          (emit_FP r1);             emitCell r1;
529          (emit ", ");             emit ", ";
530          (emit_FP r2);             emitCell r2;
531          (emit_nop nop))             emit_nop nop )
532        | I.COPY{dst, src, impl, tmp} => (emitInstrs (Shuffle.shuffle {regmap=regmap, tmp=tmp, src=src, dst=dst}))         | I.COPY{dst, src, impl, tmp} => emitInstrs (Shuffle.shuffle {tmp=tmp,
533        | I.FCOPY{dst, src, impl, tmp} => (emitInstrs (Shuffle.shufflefp {regmap=regmap, tmp=tmp, src=src, dst=dst}))              src=src, dst=dst})
534           | I.FCOPY{dst, src, impl, tmp} => emitInstrs (Shuffle.shufflefp {tmp=tmp,
535                src=src, dst=dst})
536        | I.SAVE{r, i, d} =>        | I.SAVE{r, i, d} =>
537          ((emit "save\t");           ( emit "save\t";
538          (emit_GP r);             emitCell r;
539          (emit ", ");             emit ", ";
540          (emit_operand i);             emit_operand i;
541          (emit ", ");             emit ", ";
542          (emit_GP d))             emitCell d )
543        | I.RESTORE{r, i, d} =>        | I.RESTORE{r, i, d} =>
544          ((emit "restore\t");           ( emit "restore\t";
545          (emit_GP r);             emitCell r;
546          (emit ", ");             emit ", ";
547          (emit_operand i);             emit_operand i;
548          (emit ", ");             emit ", ";
549          (emit_GP d))             emitCell d )
550        | I.RDY{d} =>        | I.RDY{d} =>
551          ((emit "rd\t%y, ");           ( emit "rd\t%y, ";
552          (emit_GP d))             emitCell d )
553        | I.WRY{r, i} =>        | I.WRY{r, i} =>
554          ((emit "wr\t");           ( emit "wr\t";
555          (emit_GP r);             emitCell r;
556          (emit ", ");             emit ", ";
557          (emit_operand i);             emit_operand i;
558          (emit ", %y"))             emit ", %y" )
559        | I.RET{leaf, nop} =>        | I.RET{leaf, nop} =>
560          ((emit "ret");           ( emit "ret";
561          (emit_leaf leaf);             emit_leaf leaf;
562          (emit_nop nop))             emit_nop nop )
563        | I.ANNOTATION{i, a} =>        | I.ANNOTATION{i, a} =>
564          ((emitInstr i);           ( comment (Annotations.toString a);
565          (comment (Annotations.toString a)))             nl ();
566        | I.GROUP annotation => (comment (Annotations.toString annotation))             emitInstr i )
567         );         | I.SOURCE{} => emit "source"
568         (nl ()))         | I.SINK{} => emit "sink"
569            and emitInstrs [] = ()         | I.PHI{} => emit "phi"
570              | emitInstrs (i::is) =         )
571             (emitInstr i; app (fn i => (tab(); emitInstr i)) is)            and emitInstr i = (tab(); emitInstr' i; nl())
572        in  emitInstr end            and emitInstrIndented i = (indent(); emitInstr' i; nl())
573              and emitInstrs instrs =
574               app (if !indent_copies then emitInstrIndented
575                    else emitInstr) instrs
576          in  emitInstr instr end
577    
578     in  S.STREAM{beginCluster=init,     in  S.STREAM{beginCluster=init,
579                  pseudoOp=pseudoOp,                  pseudoOp=pseudoOp,
580                  emit=emitter,                  emit=emitter,
581                  endCluster=doNothing,                  endCluster=fail,
582                  defineLabel=defineLabel,                  defineLabel=defineLabel,
583                  entryLabel=entryLabel,                  entryLabel=entryLabel,
584                  comment=comment,                  comment=comment,
585                  exitBlock=doNothing,                  exitBlock=doNothing,
586                  annotation=annotation,                  annotation=annotation,
587                  phi=doNothing,                  getAnnotations=getAnnotations
                 alias=doNothing  
588                 }                 }
589     end     end
590  end  end

Legend:
Removed from v.498  
changed lines
  Added in v.909

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