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/branches/SMLNJ/src/MLRISC/sparc/emit/sparcAsm.sml
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/MLRISC/sparc/emit/sparcAsm.sml

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

revision 428, Wed Sep 8 09:47:00 1999 UTC revision 429, Wed Sep 8 09:47:00 1999 UTC
# Line 22  Line 22 
22    
23     fun error msg = MLRiscErrorMsg.error("SparcAsm",msg)     fun error msg = MLRiscErrorMsg.error("SparcAsm",msg)
24    
25     fun makeStream() =     fun makeStream formatAnnotations =
26     let val stream = !AsmStream.asmOutStream     let val stream = !AsmStream.asmOutStream
27         fun emit s = TextIO.output(stream,s)         fun emit' s = TextIO.output(stream,s)
28         fun nl() = emit "\n"         val newline = ref true
29           val tabs = ref 0
30           fun tabbing 0 = ()
31             | tabbing n = (emit' "\t"; tabbing(n-1))
32           fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s)
33           fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n"))
34         fun comma() = emit ","         fun comma() = emit ","
35         fun tab() = emit "\t"         fun tab() = tabs := !tabs + 1
36         fun ms n = if n<0 then "-"^Int.toString(~n)         fun ms n = let val s = Int.toString n
37                    else Int.toString n                    in  if n<0 then "-"^String.substring(s,1,size s-1)
38                          else s
39                      end
40         fun emit_label lab = emit(Label.nameOf lab)         fun emit_label lab = emit(Label.nameOf lab)
41         fun emit_labexp le = emit(LabelExp.toString le)         fun emit_labexp le = emit(LabelExp.toString le)
42         fun emit_const c = emit(Constant.toString c)         fun emit_const c = emit(Constant.toString c)
# Line 44  Line 51 
51         fun pseudoOp pOp = emit(P.toString pOp)         fun pseudoOp pOp = emit(P.toString pOp)
52         fun init size = (comment("Code Size = " ^ ms size); nl())         fun init size = (comment("Code Size = " ^ ms size); nl())
53         fun doNothing _ = ()         fun doNothing _ = ()
54           val emitRegInfo = AsmFormatUtil.reginfo(emit,formatAnnotations)
55         fun emitter regmap =         fun emitter regmap =
56         let         let
57    
58     fun emit_Y r = (emit (C.showY (regmap r)))     fun emit_PSR r =
59     and emit_CC r = (emit (C.showCC (regmap r)))         ((emit (C.showPSR (regmap r)));
60     and emit_PSR r = (emit (C.showPSR (regmap r)))         (emitRegInfo r))
61     and emit_GP r = (emit (C.showGP (regmap r)))     and emit_CC r =
62     and emit_FSR r = (emit (C.showFSR (regmap r)))         ((emit (C.showCC (regmap r)));
63     and emit_FP r = (emit (C.showFP (regmap r)))         (emitRegInfo r))
64       and emit_Y r =
65           ((emit (C.showY (regmap r)));
66           (emitRegInfo r))
67       and emit_FP r =
68           ((emit (C.showFP (regmap r)));
69           (emitRegInfo r))
70       and emit_GP r =
71           ((emit (C.showGP (regmap r)));
72           (emitRegInfo r))
73       and emit_FSR r =
74           ((emit (C.showFSR (regmap r)));
75           (emitRegInfo r))
76    
77     fun asm_store (I.STB) = "stb"     fun asm_farith1 (I.FiTOs) = "fitos"
      | asm_store (I.STH) = "sth"  
      | asm_store (I.ST) = "st"  
      | asm_store (I.STX) = "stx"  
      | asm_store (I.STD) = "std"  
    and emit_store x = (emit (asm_store 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_rcond (I.RZ) = "rz"  
      | asm_rcond (I.RLEZ) = "rlez"  
      | asm_rcond (I.RLZ) = "rlz"  
      | asm_rcond (I.RNZ) = "rnz"  
      | asm_rcond (I.RGZ) = "rgz"  
      | asm_rcond (I.RGEZ) = "rgez"  
    and emit_rcond x = (emit (asm_rcond x))  
    and asm_fload (I.LDF) = "ldf"  
      | asm_fload (I.LDDF) = "lddf"  
      | asm_fload (I.LDQF) = "ldqf"  
      | asm_fload (I.LDFSR) = "ldfsr"  
      | asm_fload (I.LDXFSR) = "ldxfsr"  
    and emit_fload x = (emit (asm_fload 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))  
    and asm_farith1 (I.FiTOs) = "fitos"  
78       | asm_farith1 (I.FiTOd) = "fitod"       | asm_farith1 (I.FiTOd) = "fitod"
79       | asm_farith1 (I.FiTOq) = "fitoq"       | asm_farith1 (I.FiTOq) = "fitoq"
80       | asm_farith1 (I.FsTOi) = "fstoi"       | asm_farith1 (I.FsTOi) = "fstoi"
# Line 119  Line 99 
99       | asm_farith1 (I.FSQRTd) = "fsqrtd"       | asm_farith1 (I.FSQRTd) = "fsqrtd"
100       | asm_farith1 (I.FSQRTq) = "fsqrtq"       | asm_farith1 (I.FSQRTq) = "fsqrtq"
101     and emit_farith1 x = (emit (asm_farith1 x))     and emit_farith1 x = (emit (asm_farith1 x))
102     and asm_farith2 (I.FADDs) = "fadds"     and asm_store (I.STB) = "stb"
103       | asm_farith2 (I.FADDd) = "faddd"       | asm_store (I.STH) = "sth"
104       | asm_farith2 (I.FADDq) = "faddq"       | asm_store (I.ST) = "st"
105       | asm_farith2 (I.FSUBs) = "fsubs"       | asm_store (I.STX) = "stx"
106       | asm_farith2 (I.FSUBd) = "fsubd"       | asm_store (I.STD) = "std"
107       | asm_farith2 (I.FSUBq) = "fsubq"     and emit_store x = (emit (asm_store x))
108       | asm_farith2 (I.FMULs) = "fmuls"     and emit_operand (I.REG GP) = (emit_GP GP)
109       | asm_farith2 (I.FMULd) = "fmuld"       | emit_operand (I.IMMED int) = (emit_int int)
110       | asm_farith2 (I.FMULq) = "fmulq"       | emit_operand (I.LAB labexp) = (emit_labexp labexp)
111       | asm_farith2 (I.FsMULd) = "fsmuld"       | emit_operand (I.LO labexp) =
112       | asm_farith2 (I.FdMULq) = "fdmulq"         ((emit "%lo(");
113       | asm_farith2 (I.FDIVs) = "fdivs"         (emit_labexp labexp);
114       | asm_farith2 (I.FDIVd) = "fdivd"         (emit ")"))
115       | asm_farith2 (I.FDIVq) = "fdivq"       | emit_operand (I.HI labexp) =
116     and emit_farith2 x = (emit (asm_farith2 x))         ((emit "%hi(");
117           (emit_labexp labexp);
118           (emit ")"))
119         | emit_operand (I.CONST const) = (emit_const const)
120       and asm_fload (I.LDF) = "ldf"
121         | asm_fload (I.LDDF) = "lddf"
122         | asm_fload (I.LDQF) = "ldqf"
123         | asm_fload (I.LDFSR) = "ldfsr"
124         | asm_fload (I.LDXFSR) = "ldxfsr"
125       and emit_fload x = (emit (asm_fload x))
126       and asm_fstore (I.STF) = "stf"
127         | asm_fstore (I.STDF) = "stdf"
128         | asm_fstore (I.STFSR) = "stfsr"
129       and emit_fstore x = (emit (asm_fstore x))
130       and asm_prediction (I.PT) = "pt"
131         | asm_prediction (I.PN) = "pn"
132       and emit_prediction x = (emit (asm_prediction x))
133       and asm_fsize (I.S) = "s"
134         | asm_fsize (I.D) = "d"
135         | asm_fsize (I.Q) = "q"
136       and emit_fsize x = (emit (asm_fsize x))
137     and asm_shift (I.SLL) = "sll"     and asm_shift (I.SLL) = "sll"
138       | asm_shift (I.SRL) = "srl"       | asm_shift (I.SRL) = "srl"
139       | asm_shift (I.SRA) = "sra"       | asm_shift (I.SRA) = "sra"
# Line 141  Line 141 
141       | asm_shift (I.SRLX) = "srlx"       | asm_shift (I.SRLX) = "srlx"
142       | asm_shift (I.SRAX) = "srax"       | asm_shift (I.SRAX) = "srax"
143     and emit_shift x = (emit (asm_shift x))     and emit_shift x = (emit (asm_shift x))
144       and asm_branch (I.BN) = "n"
145         | asm_branch (I.BE) = "e"
146         | asm_branch (I.BLE) = "le"
147         | asm_branch (I.BL) = "l"
148         | asm_branch (I.BLEU) = "leu"
149         | asm_branch (I.BCS) = "cs"
150         | asm_branch (I.BNEG) = "neg"
151         | asm_branch (I.BVS) = "vs"
152         | asm_branch (I.BA) = ""
153         | asm_branch (I.BNE) = "ne"
154         | asm_branch (I.BG) = "g"
155         | asm_branch (I.BGE) = "ge"
156         | asm_branch (I.BGU) = "gu"
157         | asm_branch (I.BCC) = "cc"
158         | asm_branch (I.BPOS) = "pos"
159         | asm_branch (I.BVC) = "vs"
160       and emit_branch x = (emit (asm_branch x))
161     and asm_arith (I.AND) = "and"     and asm_arith (I.AND) = "and"
162       | asm_arith (I.ANDCC) = "andcc"       | asm_arith (I.ANDCC) = "andcc"
163       | asm_arith (I.ANDN) = "andn"       | asm_arith (I.ANDN) = "andn"
# Line 184  Line 201 
201       | asm_fcmp (I.FCMPEd) = "fcmped"       | asm_fcmp (I.FCMPEd) = "fcmped"
202       | asm_fcmp (I.FCMPEq) = "fcmpeq"       | asm_fcmp (I.FCMPEq) = "fcmpeq"
203     and emit_fcmp x = (emit (asm_fcmp x))     and emit_fcmp x = (emit (asm_fcmp x))
204     and asm_load (I.LDSB) = "ldsb"     and asm_rcond (I.RZ) = "rz"
205       | asm_load (I.LDSH) = "ldsh"       | asm_rcond (I.RLEZ) = "rlez"
206       | asm_load (I.LDUB) = "ldub"       | asm_rcond (I.RLZ) = "rlz"
207       | asm_load (I.LDUH) = "lduh"       | asm_rcond (I.RNZ) = "rnz"
208       | asm_load (I.LD) = "ld"       | asm_rcond (I.RGZ) = "rgz"
209       | asm_load (I.LDX) = "ldx"       | asm_rcond (I.RGEZ) = "rgez"
210       | asm_load (I.LDD) = "ldd"     and emit_rcond x = (emit (asm_rcond x))
    and emit_load x = (emit (asm_load x))  
    and asm_prediction (I.PT) = "pt"  
      | asm_prediction (I.PN) = "pn"  
    and emit_prediction x = (emit (asm_prediction x))  
211     and asm_fbranch (I.FBN) = "fbn"     and asm_fbranch (I.FBN) = "fbn"
212       | asm_fbranch (I.FBNE) = "fbne"       | asm_fbranch (I.FBNE) = "fbne"
213       | asm_fbranch (I.FBLG) = "fblg"       | asm_fbranch (I.FBLG) = "fblg"
# Line 212  Line 225 
225       | asm_fbranch (I.FBULE) = "fbule"       | asm_fbranch (I.FBULE) = "fbule"
226       | asm_fbranch (I.FBO) = "fbo"       | asm_fbranch (I.FBO) = "fbo"
227     and emit_fbranch x = (emit (asm_fbranch x))     and emit_fbranch x = (emit (asm_fbranch x))
228     and emit_operand (I.REG GP) = (emit_GP GP)     and asm_load (I.LDSB) = "ldsb"
229       | emit_operand (I.IMMED int) = (emit_int int)       | asm_load (I.LDSH) = "ldsh"
230       | emit_operand (I.LAB labexp) = (emit_labexp labexp)       | asm_load (I.LDUB) = "ldub"
231       | emit_operand (I.LO labexp) =       | asm_load (I.LDUH) = "lduh"
232         ((emit "%lo(");       | asm_load (I.LD) = "ld"
233         (emit_labexp labexp);       | asm_load (I.LDX) = "ldx"
234         (emit ")"))       | asm_load (I.LDD) = "ldd"
235       | emit_operand (I.HI labexp) =     and emit_load x = (emit (asm_load x))
236         ((emit "%hi(");     and asm_farith2 (I.FADDs) = "fadds"
237         (emit_labexp labexp);       | asm_farith2 (I.FADDd) = "faddd"
238         (emit ")"))       | asm_farith2 (I.FADDq) = "faddq"
239       | emit_operand (I.CONST const) = (emit_const const)       | asm_farith2 (I.FSUBs) = "fsubs"
240     and asm_fstore (I.STF) = "stf"       | asm_farith2 (I.FSUBd) = "fsubd"
241       | asm_fstore (I.STDF) = "stdf"       | asm_farith2 (I.FSUBq) = "fsubq"
242       | asm_fstore (I.STFSR) = "stfsr"       | asm_farith2 (I.FMULs) = "fmuls"
243     and emit_fstore x = (emit (asm_fstore x))       | asm_farith2 (I.FMULd) = "fmuld"
244         | asm_farith2 (I.FMULq) = "fmulq"
245         | asm_farith2 (I.FsMULd) = "fsmuld"
246         | asm_farith2 (I.FdMULq) = "fdmulq"
247         | asm_farith2 (I.FDIVs) = "fdivs"
248         | asm_farith2 (I.FDIVd) = "fdivd"
249         | asm_farith2 (I.FDIVq) = "fdivq"
250       and emit_farith2 x = (emit (asm_farith2 x))
251    
252     fun emit_leaf false = ()     fun emit_leaf false = ()
253       | emit_leaf true = (emit "l")       | emit_leaf true = (emit "l")
# Line 519  Line 539 
539             (emitInstr i; app (fn i => (tab(); emitInstr i)) is)             (emitInstr i; app (fn i => (tab(); emitInstr i)) is)
540        in  emitInstr end        in  emitInstr end
541    
542     in  S.STREAM{init=init,     in  S.STREAM{beginCluster=init,
543                  pseudoOp=pseudoOp,                  pseudoOp=pseudoOp,
544                  emit=emitter,                  emit=emitter,
545                  finish=doNothing,                  endCluster=doNothing,
546                  defineLabel=defineLabel,                  defineLabel=defineLabel,
547                  entryLabel=entryLabel,                  entryLabel=entryLabel,
548                  comment=comment,                  comment=comment,
549                  exitBlock=doNothing,                  exitBlock=doNothing,
550                  blockName=blockName,                  blockName=blockName,
551                  annotation=annotation                  annotation=annotation,
552                    phi=doNothing,
553                    alias=doNothing
554                 }                 }
555     end     end
556  end  end

Legend:
Removed from v.428  
changed lines
  Added in v.429

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