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/alpha/emit/alphaAsm.sml
ViewVC logotype

Diff of /sml/branches/SMLNJ/src/MLRISC/alpha/emit/alphaAsm.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 19  Line 19 
19    
20     fun error msg = MLRiscErrorMsg.error("AlphaAsm",msg)     fun error msg = MLRiscErrorMsg.error("AlphaAsm",msg)
21    
22     fun makeStream() =     fun makeStream formatAnnotations =
23     let val stream = !AsmStream.asmOutStream     let val stream = !AsmStream.asmOutStream
24         fun emit s = TextIO.output(stream,s)         fun emit' s = TextIO.output(stream,s)
25         fun nl() = emit "\n"         val newline = ref true
26           val tabs = ref 0
27           fun tabbing 0 = ()
28             | tabbing n = (emit' "\t"; tabbing(n-1))
29           fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s)
30           fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n"))
31         fun comma() = emit ","         fun comma() = emit ","
32         fun tab() = emit "\t"         fun tab() = tabs := !tabs + 1
33         fun ms n = if n<0 then "-"^Int.toString(~n)         fun ms n = let val s = Int.toString n
34                    else Int.toString n                    in  if n<0 then "-"^String.substring(s,1,size s-1)
35                          else s
36                      end
37         fun emit_label lab = emit(Label.nameOf lab)         fun emit_label lab = emit(Label.nameOf lab)
38         fun emit_labexp le = emit(LabelExp.toString le)         fun emit_labexp le = emit(LabelExp.toString le)
39         fun emit_const c = emit(Constant.toString c)         fun emit_const c = emit(Constant.toString c)
# Line 41  Line 48 
48         fun pseudoOp pOp = emit(P.toString pOp)         fun pseudoOp pOp = emit(P.toString pOp)
49         fun init size = (comment("Code Size = " ^ ms size); nl())         fun init size = (comment("Code Size = " ^ ms size); nl())
50         fun doNothing _ = ()         fun doNothing _ = ()
51           val emitRegInfo = AsmFormatUtil.reginfo(emit,formatAnnotations)
52         fun emitter regmap =         fun emitter regmap =
53         let         let
54    
55     fun emit_CC r = (emit (C.showCC (regmap r)))     fun emit_CC r =
56     and emit_GP r = (emit (C.showGP (regmap r)))         ((emit (C.showCC (regmap r)));
57     and emit_FP r = (emit (C.showFP (regmap r)))         (emitRegInfo r))
58       and emit_FP r =
59           ((emit (C.showFP (regmap r)));
60           (emitRegInfo r))
61       and emit_GP r =
62           ((emit (C.showGP (regmap r)));
63           (emitRegInfo r))
64    
65     fun asm_osf_user_palcode (I.BPT) = "bpt"     fun asm_pseudo_op (I.DIVL) = "divl"
66         | asm_pseudo_op (I.DIVLU) = "divlu"
67         | asm_pseudo_op (I.DIVQ) = "divq"
68         | asm_pseudo_op (I.DIVQU) = "divqu"
69         | asm_pseudo_op (I.REML) = "reml"
70         | asm_pseudo_op (I.REMLU) = "remlu"
71         | asm_pseudo_op (I.REMQ) = "remq"
72         | asm_pseudo_op (I.REMQU) = "remqu"
73       and emit_pseudo_op x = (emit (asm_pseudo_op x))
74       and asm_store (I.STL) = "stl"
75         | asm_store (I.STQ) = "stq"
76         | asm_store (I.STQ_U) = "stq_u"
77       and emit_store x = (emit (asm_store x))
78       and asm_osf_user_palcode (I.BPT) = "bpt"
79       | asm_osf_user_palcode (I.BUGCHK) = "bugchk"       | asm_osf_user_palcode (I.BUGCHK) = "bugchk"
80       | asm_osf_user_palcode (I.CALLSYS) = "callsys"       | asm_osf_user_palcode (I.CALLSYS) = "callsys"
81       | asm_osf_user_palcode (I.GENTRAP) = "gentrap"       | asm_osf_user_palcode (I.GENTRAP) = "gentrap"
# Line 56  Line 83 
83       | asm_osf_user_palcode (I.RDUNIQUE) = "rdunique"       | asm_osf_user_palcode (I.RDUNIQUE) = "rdunique"
84       | asm_osf_user_palcode (I.WRUNIQUE) = "wrunique"       | asm_osf_user_palcode (I.WRUNIQUE) = "wrunique"
85     and emit_osf_user_palcode x = (emit (asm_osf_user_palcode x))     and emit_osf_user_palcode x = (emit (asm_osf_user_palcode x))
86     and asm_store (I.STL) = "stl"     and asm_foperateV (I.ADDSSUD) = "addssud"
87       | asm_store (I.STQ) = "stq"       | asm_foperateV (I.ADDSSU) = "addssu"
88       | asm_store (I.STQ_U) = "stq_u"       | asm_foperateV (I.ADDTSUD) = "addtsud"
89     and emit_store x = (emit (asm_store x))       | asm_foperateV (I.ADDTSU) = "addtsu"
90     and asm_fcmove (I.FCMOVEQ) = "fcmoveq"       | asm_foperateV (I.DIVSSUD) = "divssud"
91       | asm_fcmove (I.FCMOVEGE) = "fcmovege"       | asm_foperateV (I.DIVSSU) = "divssu"
92       | asm_fcmove (I.FCMOVEGT) = "fcmovegt"       | asm_foperateV (I.DIVTSUD) = "divtsud"
93       | asm_fcmove (I.FCMOVLE) = "fcmovle"       | asm_foperateV (I.DIVTSU) = "divtsu"
94       | asm_fcmove (I.FCMOVELT) = "fcmovelt"       | asm_foperateV (I.MULSSUD) = "mulssud"
95       | asm_fcmove (I.FCMOVENE) = "fcmovene"       | asm_foperateV (I.MULSSU) = "mulssu"
96     and emit_fcmove x = (emit (asm_fcmove x))       | asm_foperateV (I.MULTSUD) = "multsud"
97         | asm_foperateV (I.MULTSU) = "multsu"
98         | asm_foperateV (I.SUBSSUD) = "subssud"
99         | asm_foperateV (I.SUBSSU) = "subssu"
100         | asm_foperateV (I.SUBTSUD) = "subtsud"
101         | asm_foperateV (I.SUBTSU) = "subtsu"
102       and emit_foperateV x = (emit (asm_foperateV x))
103       and emit_operand (I.REGop GP) = (emit_GP GP)
104         | emit_operand (I.IMMop int) = (emit_int int)
105         | emit_operand (I.HILABop labexp) =
106           ((emit "hi(");
107           (emit_labexp labexp);
108           (emit ")"))
109         | emit_operand (I.LOLABop labexp) =
110           ((emit "lo(");
111           (emit_labexp labexp);
112           (emit ")"))
113         | emit_operand (I.LABop labexp) = (emit_labexp labexp)
114         | emit_operand (I.CONSTop const) = (emit_const const)
115       and asm_fload (I.LDF) = "ldf"
116         | asm_fload (I.LDG) = "ldg"
117         | asm_fload (I.LDS) = "lds"
118         | asm_fload (I.LDT) = "ldt"
119       and emit_fload x = (emit (asm_fload x))
120     and asm_foperate (I.CPYS) = "cpys"     and asm_foperate (I.CPYS) = "cpys"
121       | asm_foperate (I.CPYSE) = "cpyse"       | asm_foperate (I.CPYSE) = "cpyse"
122       | asm_foperate (I.CPYSN) = "cpysn"       | asm_foperate (I.CPYSN) = "cpysn"
# Line 81  Line 131 
131       | asm_foperate (I.CMPTLESU) = "cmptlesu"       | asm_foperate (I.CMPTLESU) = "cmptlesu"
132       | asm_foperate (I.CMPTUNSU) = "cmptunsu"       | asm_foperate (I.CMPTUNSU) = "cmptunsu"
133     and emit_foperate x = (emit (asm_foperate x))     and emit_foperate x = (emit (asm_foperate x))
134     and asm_pseudo_op (I.DIVL) = "divl"     and asm_funary (I.CVTLQ) = "cvtlq"
135       | asm_pseudo_op (I.DIVLU) = "divlu"       | asm_funary (I.CVTQL) = "cvtql"
136     and emit_pseudo_op x = (emit (asm_pseudo_op x))       | asm_funary (I.CVTQLSV) = "cvtqlsv"
137         | asm_funary (I.CVTQLV) = "cvtqlv"
138         | asm_funary (I.CVTQS) = "cvtqs"
139         | asm_funary (I.CVTQSC) = "cvtqsc"
140         | asm_funary (I.CVTQT) = "cvtqt"
141         | asm_funary (I.CVTQTC) = "cvtqtc"
142         | asm_funary (I.CVTTS) = "cvtts"
143         | asm_funary (I.CVTTSC) = "cvttsc"
144         | asm_funary (I.CVTST) = "cvtst"
145         | asm_funary (I.CVTSTS) = "cvtsts"
146         | asm_funary (I.CVTTQ) = "cvttq"
147         | asm_funary (I.CVTTQC) = "cvttqc"
148       and emit_funary x = (emit (asm_funary x))
149       and asm_fstore (I.STF) = "stf"
150         | asm_fstore (I.STG) = "stg"
151         | asm_fstore (I.STS) = "sts"
152         | asm_fstore (I.STT) = "stt"
153       and emit_fstore x = (emit (asm_fstore x))
154       and asm_branch (I.BR) = "br"
155         | asm_branch (I.BSR) = "bsr"
156         | asm_branch (I.BLBC) = "blbc"
157         | asm_branch (I.BEQ) = "beq"
158         | asm_branch (I.BLT) = "blt"
159         | asm_branch (I.BLE) = "ble"
160         | asm_branch (I.BLBS) = "blbs"
161         | asm_branch (I.BNE) = "bne"
162         | asm_branch (I.BGE) = "bge"
163         | asm_branch (I.BGT) = "bgt"
164       and emit_branch x = (emit (asm_branch x))
165     and asm_cmove (I.CMOVEQ) = "cmoveq"     and asm_cmove (I.CMOVEQ) = "cmoveq"
166       | asm_cmove (I.CMOVLBC) = "cmovlbc"       | asm_cmove (I.CMOVLBC) = "cmovlbc"
167       | asm_cmove (I.CMOVLBS) = "cmovlbs"       | asm_cmove (I.CMOVLBS) = "cmovlbs"
# Line 100  Line 178 
178       | asm_operateV (I.MULLV) = "mullv"       | asm_operateV (I.MULLV) = "mullv"
179       | asm_operateV (I.MULQV) = "mulqv"       | asm_operateV (I.MULQV) = "mulqv"
180     and emit_operateV x = (emit (asm_operateV x))     and emit_operateV x = (emit (asm_operateV x))
181     and asm_fload (I.LDF) = "ldf"     and asm_fbranch (I.FBEQ) = "fbeq"
182       | asm_fload (I.LDG) = "ldg"       | asm_fbranch (I.FBLT) = "fblt"
183       | asm_fload (I.LDS) = "lds"       | asm_fbranch (I.FBLE) = "fble"
184       | asm_fload (I.LDT) = "ldt"       | asm_fbranch (I.FBNE) = "fbne"
185     and emit_fload x = (emit (asm_fload x))       | asm_fbranch (I.FBGE) = "fbge"
186     and asm_branch (I.BR) = "br"       | asm_fbranch (I.FBGT) = "fbgt"
187       | asm_branch (I.BSR) = "bsr"     and emit_fbranch x = (emit (asm_fbranch x))
188       | asm_branch (I.BLBC) = "blbc"     and asm_load (I.LDL) = "ldl"
189       | asm_branch (I.BEQ) = "beq"       | asm_load (I.LDL_L) = "ldl_l"
190       | asm_branch (I.BLT) = "blt"       | asm_load (I.LDQ) = "ldq"
191       | asm_branch (I.BLE) = "ble"       | asm_load (I.LDQ_L) = "ldq_l"
192       | asm_branch (I.BLBS) = "blbs"       | asm_load (I.LDQ_U) = "ldq_u"
193       | asm_branch (I.BNE) = "bne"     and emit_load x = (emit (asm_load x))
      | asm_branch (I.BGE) = "bge"  
      | asm_branch (I.BGT) = "bgt"  
    and emit_branch x = (emit (asm_branch x))  
    and asm_foperateV (I.ADDSSUD) = "addssud"  
      | asm_foperateV (I.ADDSSU) = "addssu"  
      | asm_foperateV (I.ADDTSUD) = "addtsud"  
      | asm_foperateV (I.ADDTSU) = "addtsu"  
      | asm_foperateV (I.DIVSSUD) = "divssud"  
      | asm_foperateV (I.DIVSSU) = "divssu"  
      | asm_foperateV (I.DIVTSUD) = "divtsud"  
      | asm_foperateV (I.DIVTSU) = "divtsu"  
      | asm_foperateV (I.MULSSUD) = "mulssud"  
      | asm_foperateV (I.MULSSU) = "mulssu"  
      | asm_foperateV (I.MULTSUD) = "multsud"  
      | asm_foperateV (I.MULTSU) = "multsu"  
      | asm_foperateV (I.SUBSSUD) = "subssud"  
      | asm_foperateV (I.SUBSSU) = "subssu"  
      | asm_foperateV (I.SUBTSUD) = "subtsud"  
      | asm_foperateV (I.SUBTSU) = "subtsu"  
    and emit_foperateV x = (emit (asm_foperateV x))  
194     and asm_operate (I.ADDL) = "addl"     and asm_operate (I.ADDL) = "addl"
195       | asm_operate (I.ADDQ) = "addq"       | asm_operate (I.ADDQ) = "addq"
196       | asm_operate (I.CMPBGE) = "cmpbge"       | asm_operate (I.CMPBGE) = "cmpbge"
# Line 188  Line 246 
246       | asm_operate (I.UMULH) = "umulh"       | asm_operate (I.UMULH) = "umulh"
247       | asm_operate (I.SGNXL) = "addl"       | asm_operate (I.SGNXL) = "addl"
248     and emit_operate x = (emit (asm_operate x))     and emit_operate x = (emit (asm_operate x))
249     and asm_load (I.LDL) = "ldl"     and asm_fcmove (I.FCMOVEQ) = "fcmoveq"
250       | asm_load (I.LDL_L) = "ldl_l"       | asm_fcmove (I.FCMOVEGE) = "fcmovege"
251       | asm_load (I.LDQ) = "ldq"       | asm_fcmove (I.FCMOVEGT) = "fcmovegt"
252       | asm_load (I.LDQ_L) = "ldq_l"       | asm_fcmove (I.FCMOVLE) = "fcmovle"
253       | asm_load (I.LDQ_U) = "ldq_u"       | asm_fcmove (I.FCMOVELT) = "fcmovelt"
254     and emit_load x = (emit (asm_load x))       | asm_fcmove (I.FCMOVENE) = "fcmovene"
255     and asm_funary (I.CVTLQ) = "cvtlq"     and emit_fcmove x = (emit (asm_fcmove x))
      | asm_funary (I.CVTQL) = "cvtql"  
      | asm_funary (I.CVTQLSV) = "cvtqlsv"  
      | asm_funary (I.CVTQLV) = "cvtqlv"  
      | asm_funary (I.CVTQS) = "cvtqs"  
      | asm_funary (I.CVTQSC) = "cvtqsc"  
      | asm_funary (I.CVTQT) = "cvtqt"  
      | asm_funary (I.CVTQTC) = "cvtqtc"  
      | asm_funary (I.CVTTS) = "cvtts"  
      | asm_funary (I.CVTTSC) = "cvttsc"  
      | asm_funary (I.CVTTQ) = "cvttq"  
      | asm_funary (I.CVTTQC) = "cvttqc"  
    and emit_funary x = (emit (asm_funary x))  
    and asm_fbranch (I.FBEQ) = "fbeq"  
      | asm_fbranch (I.FBLT) = "fblt"  
      | asm_fbranch (I.FBLE) = "fble"  
      | asm_fbranch (I.FBNE) = "fbne"  
      | asm_fbranch (I.FBGE) = "fbge"  
      | asm_fbranch (I.FBGT) = "fbgt"  
    and emit_fbranch x = (emit (asm_fbranch x))  
    and emit_operand (I.REGop GP) = (emit_GP GP)  
      | emit_operand (I.IMMop int) = (emit_int int)  
      | emit_operand (I.HILABop labexp) =  
        ((emit "hi(");  
        (emit_labexp labexp);  
        (emit ")"))  
      | emit_operand (I.LOLABop labexp) =  
        ((emit "lo(");  
        (emit_labexp labexp);  
        (emit ")"))  
      | emit_operand (I.LABop labexp) = (emit_labexp labexp)  
      | emit_operand (I.CONSTop const) = (emit_const const)  
    and asm_fstore (I.STF) = "stf"  
      | asm_fstore (I.STG) = "stg"  
      | asm_fstore (I.STS) = "sts"  
      | asm_fstore (I.STT) = "stt"  
    and emit_fstore x = (emit (asm_fstore x))  
256    
257     fun emitInstr instr =     fun emitInstr instr =
258         ((tab ());         ((tab ());
# Line 336  Line 358 
358          (emit_label label))          (emit_label label))
359        | I.OPERATE{oper, ra, rb, rc} => let        | I.OPERATE{oper, ra, rb, rc} => let
360    
361  (*#line 304.1 "alpha/alpha.md"*)  (*#line 306.1 "alpha/alpha.md"*)
362    
363             fun f (oper, ra, rb, rc) =             fun f (oper, ra, rb, rc) =
364                 ((emit oper);                 ((emit oper);
# Line 350  Line 372 
372             (             (
373              case (oper, ra, rb, rc) of              case (oper, ra, rb, rc) of
374              (I.BIS, 27, I.REGop 31, 29) => (emit "ldgp\t$29, 0($27)")              (I.BIS, 27, I.REGop 31, 29) => (emit "ldgp\t$29, 0($27)")
375            | (I.BIS, 26, I.REGop 31, 29) => (emit "ldgp\t$26, 0($27)")            | (I.BIS, 26, I.REGop 31, 29) => (emit "ldgp\t$29, 0($26)")
376            | (I.ADDL, 30, I.CONSTop b, 30) => (if ((Constant.valueOf b) = 0)            | (I.ADDL, 30, I.CONSTop b, 30) => (if ((Constant.valueOf b) = 0)
377                 then ()                 then ()
378                 else (f ("addl", ra, rb, rc)))                 else (f ("addl", ra, rb, rc)))
# Line 438  Line 460 
460             (emitInstr i; app (fn i => (tab(); emitInstr i)) is)             (emitInstr i; app (fn i => (tab(); emitInstr i)) is)
461        in  emitInstr end        in  emitInstr end
462    
463     in  S.STREAM{init=init,     in  S.STREAM{beginCluster=init,
464                  pseudoOp=pseudoOp,                  pseudoOp=pseudoOp,
465                  emit=emitter,                  emit=emitter,
466                  finish=doNothing,                  endCluster=doNothing,
467                  defineLabel=defineLabel,                  defineLabel=defineLabel,
468                  entryLabel=entryLabel,                  entryLabel=entryLabel,
469                  comment=comment,                  comment=comment,
470                  exitBlock=doNothing,                  exitBlock=doNothing,
471                  blockName=blockName,                  blockName=blockName,
472                  annotation=annotation                  annotation=annotation,
473                    phi=doNothing,
474                    alias=doNothing
475                 }                 }
476     end     end
477  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