| 1 |
(* |
| 2 |
* WARNING: This file was automatically generated by MDLGen (v3.1) |
| 3 |
* from the machine description file "sparc/sparc.mdl". |
| 4 |
* DO NOT EDIT this file directly |
| 5 |
*) |
| 6 |
|
| 7 |
|
| 8 |
functor SparcAsmEmitter(structure S : INSTRUCTION_STREAM |
| 9 |
structure Instr : SPARCINSTR (* where T = S.P.T *) |
| 10 |
where type T.Basis.cond = S.P.T.Basis.cond |
| 11 |
and type T.Basis.div_rounding_mode = S.P.T.Basis.div_rounding_mode |
| 12 |
and type T.Basis.ext = S.P.T.Basis.ext |
| 13 |
and type T.Basis.fcond = S.P.T.Basis.fcond |
| 14 |
and type T.Basis.rounding_mode = S.P.T.Basis.rounding_mode |
| 15 |
and type T.Constant.const = S.P.T.Constant.const |
| 16 |
and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) S.P.T.Extension.ccx |
| 17 |
and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) S.P.T.Extension.fx |
| 18 |
and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) S.P.T.Extension.rx |
| 19 |
and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) S.P.T.Extension.sx |
| 20 |
and type T.I.div_rounding_mode = S.P.T.I.div_rounding_mode |
| 21 |
and type T.Region.region = S.P.T.Region.region |
| 22 |
and type T.ccexp = S.P.T.ccexp |
| 23 |
and type T.fexp = S.P.T.fexp |
| 24 |
(* and type T.labexp = S.P.T.labexp *) |
| 25 |
and type T.mlrisc = S.P.T.mlrisc |
| 26 |
and type T.oper = S.P.T.oper |
| 27 |
and type T.rep = S.P.T.rep |
| 28 |
and type T.rexp = S.P.T.rexp |
| 29 |
and type T.stm = S.P.T.stm |
| 30 |
structure Shuffle : SPARCSHUFFLE (* where I = Instr *) |
| 31 |
where type I.Constant.const = Instr.Constant.const |
| 32 |
and type I.Region.region = Instr.Region.region |
| 33 |
and type I.T.Basis.cond = Instr.T.Basis.cond |
| 34 |
and type I.T.Basis.div_rounding_mode = Instr.T.Basis.div_rounding_mode |
| 35 |
and type I.T.Basis.ext = Instr.T.Basis.ext |
| 36 |
and type I.T.Basis.fcond = Instr.T.Basis.fcond |
| 37 |
and type I.T.Basis.rounding_mode = Instr.T.Basis.rounding_mode |
| 38 |
and type ('s,'r,'f,'c) I.T.Extension.ccx = ('s,'r,'f,'c) Instr.T.Extension.ccx |
| 39 |
and type ('s,'r,'f,'c) I.T.Extension.fx = ('s,'r,'f,'c) Instr.T.Extension.fx |
| 40 |
and type ('s,'r,'f,'c) I.T.Extension.rx = ('s,'r,'f,'c) Instr.T.Extension.rx |
| 41 |
and type ('s,'r,'f,'c) I.T.Extension.sx = ('s,'r,'f,'c) Instr.T.Extension.sx |
| 42 |
and type I.T.I.div_rounding_mode = Instr.T.I.div_rounding_mode |
| 43 |
and type I.T.ccexp = Instr.T.ccexp |
| 44 |
and type I.T.fexp = Instr.T.fexp |
| 45 |
(* and type I.T.labexp = Instr.T.labexp *) |
| 46 |
and type I.T.mlrisc = Instr.T.mlrisc |
| 47 |
and type I.T.oper = Instr.T.oper |
| 48 |
and type I.T.rep = Instr.T.rep |
| 49 |
and type I.T.rexp = Instr.T.rexp |
| 50 |
and type I.T.stm = Instr.T.stm |
| 51 |
and type I.arith = Instr.arith |
| 52 |
and type I.branch = Instr.branch |
| 53 |
and type I.cc = Instr.cc |
| 54 |
and type I.ea = Instr.ea |
| 55 |
and type I.farith1 = Instr.farith1 |
| 56 |
and type I.farith2 = Instr.farith2 |
| 57 |
and type I.fbranch = Instr.fbranch |
| 58 |
and type I.fcmp = Instr.fcmp |
| 59 |
and type I.fload = Instr.fload |
| 60 |
and type I.fsize = Instr.fsize |
| 61 |
and type I.fstore = Instr.fstore |
| 62 |
and type I.instr = Instr.instr |
| 63 |
and type I.instruction = Instr.instruction |
| 64 |
and type I.load = Instr.load |
| 65 |
and type I.operand = Instr.operand |
| 66 |
and type I.prediction = Instr.prediction |
| 67 |
and type I.rcond = Instr.rcond |
| 68 |
and type I.shift = Instr.shift |
| 69 |
and type I.store = Instr.store |
| 70 |
structure MLTreeEval : MLTREE_EVAL (* where T = Instr.T *) |
| 71 |
where type T.Basis.cond = Instr.T.Basis.cond |
| 72 |
and type T.Basis.div_rounding_mode = Instr.T.Basis.div_rounding_mode |
| 73 |
and type T.Basis.ext = Instr.T.Basis.ext |
| 74 |
and type T.Basis.fcond = Instr.T.Basis.fcond |
| 75 |
and type T.Basis.rounding_mode = Instr.T.Basis.rounding_mode |
| 76 |
and type T.Constant.const = Instr.T.Constant.const |
| 77 |
and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) Instr.T.Extension.ccx |
| 78 |
and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) Instr.T.Extension.fx |
| 79 |
and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) Instr.T.Extension.rx |
| 80 |
and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) Instr.T.Extension.sx |
| 81 |
and type T.I.div_rounding_mode = Instr.T.I.div_rounding_mode |
| 82 |
and type T.Region.region = Instr.T.Region.region |
| 83 |
and type T.ccexp = Instr.T.ccexp |
| 84 |
and type T.fexp = Instr.T.fexp |
| 85 |
(* and type T.labexp = Instr.T.labexp *) |
| 86 |
and type T.mlrisc = Instr.T.mlrisc |
| 87 |
and type T.oper = Instr.T.oper |
| 88 |
and type T.rep = Instr.T.rep |
| 89 |
and type T.rexp = Instr.T.rexp |
| 90 |
and type T.stm = Instr.T.stm |
| 91 |
|
| 92 |
(*#line 466.21 "sparc/sparc.mdl"*) |
| 93 |
val V9 : bool |
| 94 |
) : INSTRUCTION_EMITTER = |
| 95 |
struct |
| 96 |
structure I = Instr |
| 97 |
structure C = I.C |
| 98 |
structure T = I.T |
| 99 |
structure S = S |
| 100 |
structure P = S.P |
| 101 |
structure Constant = I.Constant |
| 102 |
|
| 103 |
open AsmFlags |
| 104 |
|
| 105 |
fun error msg = MLRiscErrorMsg.error("SparcAsmEmitter",msg) |
| 106 |
|
| 107 |
fun makeStream formatAnnotations = |
| 108 |
let val stream = !AsmStream.asmOutStream |
| 109 |
fun emit' s = TextIO.output(stream,s) |
| 110 |
val newline = ref true |
| 111 |
val tabs = ref 0 |
| 112 |
fun tabbing 0 = () |
| 113 |
| tabbing n = (emit' "\t"; tabbing(n-1)) |
| 114 |
fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s) |
| 115 |
fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n")) |
| 116 |
fun comma() = emit "," |
| 117 |
fun tab() = tabs := 1 |
| 118 |
fun indent() = tabs := 2 |
| 119 |
fun ms n = let val s = Int.toString n |
| 120 |
in if n<0 then "-"^String.substring(s,1,size s-1) |
| 121 |
else s |
| 122 |
end |
| 123 |
fun emit_label lab = emit(P.Client.AsmPseudoOps.lexpToString(T.LABEL lab)) |
| 124 |
fun emit_labexp le = emit(P.Client.AsmPseudoOps.lexpToString (T.LABEXP le)) |
| 125 |
fun emit_const c = emit(Constant.toString c) |
| 126 |
fun emit_int i = emit(ms i) |
| 127 |
fun paren f = (emit "("; f(); emit ")") |
| 128 |
fun defineLabel lab = emit(P.Client.AsmPseudoOps.defineLabel lab^"\n") |
| 129 |
fun entryLabel lab = defineLabel lab |
| 130 |
fun comment msg = (tab(); emit("/* " ^ msg ^ " */"); nl()) |
| 131 |
fun annotation a = comment(Annotations.toString a) |
| 132 |
fun getAnnotations() = error "getAnnotations" |
| 133 |
fun doNothing _ = () |
| 134 |
fun fail _ = raise Fail "AsmEmitter" |
| 135 |
fun emit_region mem = comment(I.Region.toString mem) |
| 136 |
val emit_region = |
| 137 |
if !show_region then emit_region else doNothing |
| 138 |
fun pseudoOp pOp = (emit(P.toString pOp); emit "\n") |
| 139 |
fun init size = (comment("Code Size = " ^ ms size); nl()) |
| 140 |
val emitCellInfo = AsmFormatUtil.reginfo |
| 141 |
(emit,formatAnnotations) |
| 142 |
fun emitCell r = (emit(CellsBasis.toString r); emitCellInfo r) |
| 143 |
fun emit_cellset(title,cellset) = |
| 144 |
(nl(); comment(title^CellsBasis.CellSet.toString cellset)) |
| 145 |
val emit_cellset = |
| 146 |
if !show_cellset then emit_cellset else doNothing |
| 147 |
fun emit_defs cellset = emit_cellset("defs: ",cellset) |
| 148 |
fun emit_uses cellset = emit_cellset("uses: ",cellset) |
| 149 |
val emit_cutsTo = |
| 150 |
if !show_cutsTo then AsmFormatUtil.emit_cutsTo emit |
| 151 |
else doNothing |
| 152 |
fun emitter instr = |
| 153 |
let |
| 154 |
fun asm_load (I.LDSB) = "ldsb" |
| 155 |
| asm_load (I.LDSH) = "ldsh" |
| 156 |
| asm_load (I.LDUB) = "ldub" |
| 157 |
| asm_load (I.LDUH) = "lduh" |
| 158 |
| asm_load (I.LD) = "ld" |
| 159 |
| asm_load (I.LDX) = "ldx" |
| 160 |
| asm_load (I.LDD) = "ldd" |
| 161 |
and emit_load x = emit (asm_load x) |
| 162 |
and asm_store (I.STB) = "stb" |
| 163 |
| asm_store (I.STH) = "sth" |
| 164 |
| asm_store (I.ST) = "st" |
| 165 |
| asm_store (I.STX) = "stx" |
| 166 |
| asm_store (I.STD) = "std" |
| 167 |
and emit_store x = emit (asm_store x) |
| 168 |
and asm_fload (I.LDF) = "ldf" |
| 169 |
| asm_fload (I.LDDF) = "lddf" |
| 170 |
| asm_fload (I.LDQF) = "ldqf" |
| 171 |
| asm_fload (I.LDFSR) = "ldfsr" |
| 172 |
| asm_fload (I.LDXFSR) = "ldxfsr" |
| 173 |
and emit_fload x = emit (asm_fload x) |
| 174 |
and asm_fstore (I.STF) = "stf" |
| 175 |
| asm_fstore (I.STDF) = "stdf" |
| 176 |
| asm_fstore (I.STFSR) = "stfsr" |
| 177 |
and emit_fstore x = emit (asm_fstore x) |
| 178 |
and asm_arith (I.AND) = "and" |
| 179 |
| asm_arith (I.ANDCC) = "andcc" |
| 180 |
| asm_arith (I.ANDN) = "andn" |
| 181 |
| asm_arith (I.ANDNCC) = "andncc" |
| 182 |
| asm_arith (I.OR) = "or" |
| 183 |
| asm_arith (I.ORCC) = "orcc" |
| 184 |
| asm_arith (I.ORN) = "orn" |
| 185 |
| asm_arith (I.ORNCC) = "orncc" |
| 186 |
| asm_arith (I.XOR) = "xor" |
| 187 |
| asm_arith (I.XORCC) = "xorcc" |
| 188 |
| asm_arith (I.XNOR) = "xnor" |
| 189 |
| asm_arith (I.XNORCC) = "xnorcc" |
| 190 |
| asm_arith (I.ADD) = "add" |
| 191 |
| asm_arith (I.ADDCC) = "addcc" |
| 192 |
| asm_arith (I.TADD) = "tadd" |
| 193 |
| asm_arith (I.TADDCC) = "taddcc" |
| 194 |
| asm_arith (I.TADDTV) = "taddtv" |
| 195 |
| asm_arith (I.TADDTVCC) = "taddtvcc" |
| 196 |
| asm_arith (I.SUB) = "sub" |
| 197 |
| asm_arith (I.SUBCC) = "subcc" |
| 198 |
| asm_arith (I.TSUB) = "tsub" |
| 199 |
| asm_arith (I.TSUBCC) = "tsubcc" |
| 200 |
| asm_arith (I.TSUBTV) = "tsubtv" |
| 201 |
| asm_arith (I.TSUBTVCC) = "tsubtvcc" |
| 202 |
| asm_arith (I.UMUL) = "umul" |
| 203 |
| asm_arith (I.UMULCC) = "umulcc" |
| 204 |
| asm_arith (I.SMUL) = "smul" |
| 205 |
| asm_arith (I.SMULCC) = "smulcc" |
| 206 |
| asm_arith (I.UDIV) = "udiv" |
| 207 |
| asm_arith (I.UDIVCC) = "udivcc" |
| 208 |
| asm_arith (I.SDIV) = "sdiv" |
| 209 |
| asm_arith (I.SDIVCC) = "sdivcc" |
| 210 |
| asm_arith (I.MULX) = "mulx" |
| 211 |
| asm_arith (I.SDIVX) = "sdivx" |
| 212 |
| asm_arith (I.UDIVX) = "udivx" |
| 213 |
and emit_arith x = emit (asm_arith x) |
| 214 |
and asm_shift (I.SLL) = "sll" |
| 215 |
| asm_shift (I.SRL) = "srl" |
| 216 |
| asm_shift (I.SRA) = "sra" |
| 217 |
| asm_shift (I.SLLX) = "sllx" |
| 218 |
| asm_shift (I.SRLX) = "srlx" |
| 219 |
| asm_shift (I.SRAX) = "srax" |
| 220 |
and emit_shift x = emit (asm_shift x) |
| 221 |
and asm_farith1 (I.FiTOs) = "fitos" |
| 222 |
| asm_farith1 (I.FiTOd) = "fitod" |
| 223 |
| asm_farith1 (I.FiTOq) = "fitoq" |
| 224 |
| asm_farith1 (I.FsTOi) = "fstoi" |
| 225 |
| asm_farith1 (I.FdTOi) = "fdtoi" |
| 226 |
| asm_farith1 (I.FqTOi) = "fqtoi" |
| 227 |
| asm_farith1 (I.FsTOd) = "fstod" |
| 228 |
| asm_farith1 (I.FsTOq) = "fstoq" |
| 229 |
| asm_farith1 (I.FdTOs) = "fdtos" |
| 230 |
| asm_farith1 (I.FdTOq) = "fdtoq" |
| 231 |
| asm_farith1 (I.FqTOs) = "fqtos" |
| 232 |
| asm_farith1 (I.FqTOd) = "fqtod" |
| 233 |
| asm_farith1 (I.FMOVs) = "fmovs" |
| 234 |
| asm_farith1 (I.FNEGs) = "fnegs" |
| 235 |
| asm_farith1 (I.FABSs) = "fabss" |
| 236 |
| asm_farith1 (I.FMOVd) = "fmovd" |
| 237 |
| asm_farith1 (I.FNEGd) = "fnegd" |
| 238 |
| asm_farith1 (I.FABSd) = "fabsd" |
| 239 |
| asm_farith1 (I.FMOVq) = "fmovq" |
| 240 |
| asm_farith1 (I.FNEGq) = "fnegq" |
| 241 |
| asm_farith1 (I.FABSq) = "fabsq" |
| 242 |
| asm_farith1 (I.FSQRTs) = "fsqrts" |
| 243 |
| asm_farith1 (I.FSQRTd) = "fsqrtd" |
| 244 |
| asm_farith1 (I.FSQRTq) = "fsqrtq" |
| 245 |
and emit_farith1 x = emit (asm_farith1 x) |
| 246 |
and asm_farith2 (I.FADDs) = "fadds" |
| 247 |
| asm_farith2 (I.FADDd) = "faddd" |
| 248 |
| asm_farith2 (I.FADDq) = "faddq" |
| 249 |
| asm_farith2 (I.FSUBs) = "fsubs" |
| 250 |
| asm_farith2 (I.FSUBd) = "fsubd" |
| 251 |
| asm_farith2 (I.FSUBq) = "fsubq" |
| 252 |
| asm_farith2 (I.FMULs) = "fmuls" |
| 253 |
| asm_farith2 (I.FMULd) = "fmuld" |
| 254 |
| asm_farith2 (I.FMULq) = "fmulq" |
| 255 |
| asm_farith2 (I.FsMULd) = "fsmuld" |
| 256 |
| asm_farith2 (I.FdMULq) = "fdmulq" |
| 257 |
| asm_farith2 (I.FDIVs) = "fdivs" |
| 258 |
| asm_farith2 (I.FDIVd) = "fdivd" |
| 259 |
| asm_farith2 (I.FDIVq) = "fdivq" |
| 260 |
and emit_farith2 x = emit (asm_farith2 x) |
| 261 |
and asm_fcmp (I.FCMPs) = "fcmps" |
| 262 |
| asm_fcmp (I.FCMPd) = "fcmpd" |
| 263 |
| asm_fcmp (I.FCMPq) = "fcmpq" |
| 264 |
| asm_fcmp (I.FCMPEs) = "fcmpes" |
| 265 |
| asm_fcmp (I.FCMPEd) = "fcmped" |
| 266 |
| asm_fcmp (I.FCMPEq) = "fcmpeq" |
| 267 |
and emit_fcmp x = emit (asm_fcmp x) |
| 268 |
and asm_branch (I.BN) = "n" |
| 269 |
| asm_branch (I.BE) = "e" |
| 270 |
| asm_branch (I.BLE) = "le" |
| 271 |
| asm_branch (I.BL) = "l" |
| 272 |
| asm_branch (I.BLEU) = "leu" |
| 273 |
| asm_branch (I.BCS) = "cs" |
| 274 |
| asm_branch (I.BNEG) = "neg" |
| 275 |
| asm_branch (I.BVS) = "vs" |
| 276 |
| asm_branch (I.BA) = "" |
| 277 |
| asm_branch (I.BNE) = "ne" |
| 278 |
| asm_branch (I.BG) = "g" |
| 279 |
| asm_branch (I.BGE) = "ge" |
| 280 |
| asm_branch (I.BGU) = "gu" |
| 281 |
| asm_branch (I.BCC) = "cc" |
| 282 |
| asm_branch (I.BPOS) = "pos" |
| 283 |
| asm_branch (I.BVC) = "vs" |
| 284 |
and emit_branch x = emit (asm_branch x) |
| 285 |
and asm_rcond (I.RZ) = "rz" |
| 286 |
| asm_rcond (I.RLEZ) = "rlez" |
| 287 |
| asm_rcond (I.RLZ) = "rlz" |
| 288 |
| asm_rcond (I.RNZ) = "rnz" |
| 289 |
| asm_rcond (I.RGZ) = "rgz" |
| 290 |
| asm_rcond (I.RGEZ) = "rgez" |
| 291 |
and emit_rcond x = emit (asm_rcond x) |
| 292 |
and asm_prediction (I.PT) = "pt" |
| 293 |
| asm_prediction (I.PN) = "pn" |
| 294 |
and emit_prediction x = emit (asm_prediction x) |
| 295 |
and asm_fbranch (I.FBN) = "fbn" |
| 296 |
| asm_fbranch (I.FBNE) = "fbne" |
| 297 |
| asm_fbranch (I.FBLG) = "fblg" |
| 298 |
| asm_fbranch (I.FBUL) = "fbul" |
| 299 |
| asm_fbranch (I.FBL) = "fbl" |
| 300 |
| asm_fbranch (I.FBUG) = "fbug" |
| 301 |
| asm_fbranch (I.FBG) = "fbg" |
| 302 |
| asm_fbranch (I.FBU) = "fbu" |
| 303 |
| asm_fbranch (I.FBA) = "fb" |
| 304 |
| asm_fbranch (I.FBE) = "fbe" |
| 305 |
| asm_fbranch (I.FBUE) = "fbue" |
| 306 |
| asm_fbranch (I.FBGE) = "fbge" |
| 307 |
| asm_fbranch (I.FBUGE) = "fbuge" |
| 308 |
| asm_fbranch (I.FBLE) = "fble" |
| 309 |
| asm_fbranch (I.FBULE) = "fbule" |
| 310 |
| asm_fbranch (I.FBO) = "fbo" |
| 311 |
and emit_fbranch x = emit (asm_fbranch x) |
| 312 |
and asm_fsize (I.S) = "s" |
| 313 |
| asm_fsize (I.D) = "d" |
| 314 |
| asm_fsize (I.Q) = "q" |
| 315 |
and emit_fsize x = emit (asm_fsize x) |
| 316 |
and emit_operand (I.REG GP) = emitCell GP |
| 317 |
| emit_operand (I.IMMED int) = emit_int int |
| 318 |
| emit_operand (I.LAB labexp) = emit_labexp labexp |
| 319 |
| emit_operand (I.LO labexp) = |
| 320 |
( emit "%lo("; |
| 321 |
emit_labexp labexp; |
| 322 |
emit ")" ) |
| 323 |
| emit_operand (I.HI labexp) = |
| 324 |
( emit "%hi("; |
| 325 |
emit_labexp labexp; |
| 326 |
emit ")" ) |
| 327 |
|
| 328 |
(*#line 469.7 "sparc/sparc.mdl"*) |
| 329 |
fun emit_leaf false = () |
| 330 |
| emit_leaf true = emit "l" |
| 331 |
|
| 332 |
(*#line 470.7 "sparc/sparc.mdl"*) |
| 333 |
fun emit_nop false = () |
| 334 |
| emit_nop true = emit "\n\tnop" |
| 335 |
|
| 336 |
(*#line 471.7 "sparc/sparc.mdl"*) |
| 337 |
fun emit_a false = () |
| 338 |
| emit_a true = emit ",a" |
| 339 |
|
| 340 |
(*#line 472.7 "sparc/sparc.mdl"*) |
| 341 |
fun emit_cc false = () |
| 342 |
| emit_cc true = emit "cc" |
| 343 |
fun emitInstr' instr = |
| 344 |
(case instr of |
| 345 |
I.LOAD{l, d, r, i, mem} => |
| 346 |
( emit_load l; |
| 347 |
emit "\t["; |
| 348 |
emitCell r; |
| 349 |
emit "+"; |
| 350 |
emit_operand i; |
| 351 |
emit "], "; |
| 352 |
emitCell d; |
| 353 |
emit_region mem ) |
| 354 |
| I.STORE{s, d, r, i, mem} => |
| 355 |
( emit_store s; |
| 356 |
emit "\t"; |
| 357 |
emitCell d; |
| 358 |
emit ", ["; |
| 359 |
emitCell r; |
| 360 |
emit "+"; |
| 361 |
emit_operand i; |
| 362 |
emit "]"; |
| 363 |
emit_region mem ) |
| 364 |
| I.FLOAD{l, r, i, d, mem} => |
| 365 |
( emit_fload l; |
| 366 |
emit "\t["; |
| 367 |
emitCell r; |
| 368 |
emit "+"; |
| 369 |
emit_operand i; |
| 370 |
emit "], "; |
| 371 |
emitCell d; |
| 372 |
emit_region mem ) |
| 373 |
| I.FSTORE{s, d, r, i, mem} => |
| 374 |
( emit_fstore s; |
| 375 |
emit "\t["; |
| 376 |
emitCell r; |
| 377 |
emit "+"; |
| 378 |
emit_operand i; |
| 379 |
emit "], "; |
| 380 |
emitCell d; |
| 381 |
emit_region mem ) |
| 382 |
| I.UNIMP{const22} => |
| 383 |
( emit "unimp "; |
| 384 |
emit_int const22 ) |
| 385 |
| I.SETHI{i, d} => |
| 386 |
let |
| 387 |
(*#line 656.18 "sparc/sparc.mdl"*) |
| 388 |
val i = Word32.toString (Word32.<< (Word32.fromInt i, 0wxA)) |
| 389 |
in |
| 390 |
( emit "sethi\t%hi(0x"; |
| 391 |
emit i; |
| 392 |
emit "), "; |
| 393 |
emitCell d ) |
| 394 |
end |
| 395 |
| I.ARITH{a, r, i, d} => |
| 396 |
(case (a, CellsBasis.registerId r, CellsBasis.registerId d, i) of |
| 397 |
(I.OR, 0, _, I.REG _) => |
| 398 |
( emit "mov\t"; |
| 399 |
emit_operand i; |
| 400 |
emit ", "; |
| 401 |
emitCell d ) |
| 402 |
| (I.OR, 0, _, _) => |
| 403 |
( emit "set\t"; |
| 404 |
emit_operand i; |
| 405 |
emit ", "; |
| 406 |
emitCell d ) |
| 407 |
| (I.SUBCC, _, 0, _) => |
| 408 |
( emit "cmp\t"; |
| 409 |
emitCell r; |
| 410 |
emit ", "; |
| 411 |
emit_operand i ) |
| 412 |
| _ => |
| 413 |
( emit_arith a; |
| 414 |
emit "\t"; |
| 415 |
emitCell r; |
| 416 |
emit ", "; |
| 417 |
emit_operand i; |
| 418 |
emit ", "; |
| 419 |
emitCell d ) |
| 420 |
) |
| 421 |
| I.SHIFT{s, r, i, d} => |
| 422 |
( emit_shift s; |
| 423 |
emit "\t"; |
| 424 |
emitCell r; |
| 425 |
emit ", "; |
| 426 |
emit_operand i; |
| 427 |
emit ", "; |
| 428 |
emitCell d ) |
| 429 |
| I.MOVicc{b, i, d} => |
| 430 |
( emit "mov"; |
| 431 |
emit_branch b; |
| 432 |
emit "\t"; |
| 433 |
emit_operand i; |
| 434 |
emit ", "; |
| 435 |
emitCell d ) |
| 436 |
| I.MOVfcc{b, i, d} => |
| 437 |
( emit "mov"; |
| 438 |
emit_fbranch b; |
| 439 |
emit "\t"; |
| 440 |
emit_operand i; |
| 441 |
emit ", "; |
| 442 |
emitCell d ) |
| 443 |
| I.MOVR{rcond, r, i, d} => |
| 444 |
( emit "movr"; |
| 445 |
emit_rcond rcond; |
| 446 |
emit "\t"; |
| 447 |
emitCell r; |
| 448 |
emit ", "; |
| 449 |
emit_operand i; |
| 450 |
emit ", "; |
| 451 |
emitCell d ) |
| 452 |
| I.FMOVicc{sz, b, r, d} => |
| 453 |
( emit "fmov"; |
| 454 |
emit_fsize sz; |
| 455 |
emit_branch b; |
| 456 |
emit "\t"; |
| 457 |
emitCell r; |
| 458 |
emit ", "; |
| 459 |
emitCell d ) |
| 460 |
| I.FMOVfcc{sz, b, r, d} => |
| 461 |
( emit "fmov"; |
| 462 |
emit_fsize sz; |
| 463 |
emit_fbranch b; |
| 464 |
emit "\t"; |
| 465 |
emitCell r; |
| 466 |
emit ", "; |
| 467 |
emitCell d ) |
| 468 |
| I.Bicc{b, a, label, nop} => |
| 469 |
( emit "b"; |
| 470 |
emit_branch b; |
| 471 |
emit_a a; |
| 472 |
emit "\t"; |
| 473 |
emit_label label; |
| 474 |
emit_nop nop ) |
| 475 |
| I.FBfcc{b, a, label, nop} => |
| 476 |
( emit_fbranch b; |
| 477 |
emit_a a; |
| 478 |
emit "\t"; |
| 479 |
emit_label label; |
| 480 |
emit_nop nop ) |
| 481 |
| I.BR{rcond, p, r, a, label, nop} => |
| 482 |
( emit "b"; |
| 483 |
emit_rcond rcond; |
| 484 |
emit_a a; |
| 485 |
emit_prediction p; |
| 486 |
emit "\t"; |
| 487 |
emitCell r; |
| 488 |
emit ", "; |
| 489 |
emit_label label; |
| 490 |
emit_nop nop ) |
| 491 |
| I.BP{b, p, cc, a, label, nop} => |
| 492 |
( emit "bp"; |
| 493 |
emit_branch b; |
| 494 |
emit_a a; |
| 495 |
emit_prediction p; |
| 496 |
emit "\t%"; |
| 497 |
emit (if (cc = I.ICC) |
| 498 |
then "i" |
| 499 |
else "x"); |
| 500 |
emit "cc, "; |
| 501 |
emit_label label; |
| 502 |
emit_nop nop ) |
| 503 |
| I.JMP{r, i, labs, nop} => |
| 504 |
( emit "jmp\t"; |
| 505 |
emitCell r; |
| 506 |
emit "+"; |
| 507 |
emit_operand i; |
| 508 |
emit_nop nop ) |
| 509 |
| I.JMPL{r, i, d, defs, uses, cutsTo, nop, mem} => |
| 510 |
( emit "jmpl\t"; |
| 511 |
emitCell r; |
| 512 |
emit "+"; |
| 513 |
emit_operand i; |
| 514 |
emit ", "; |
| 515 |
emitCell d; |
| 516 |
emit_region mem; |
| 517 |
emit_defs defs; |
| 518 |
emit_uses uses; |
| 519 |
emit_cutsTo cutsTo; |
| 520 |
emit_nop nop ) |
| 521 |
| I.CALL{defs, uses, label, cutsTo, nop, mem} => |
| 522 |
( emit "call\t"; |
| 523 |
emit_label label; |
| 524 |
emit_region mem; |
| 525 |
emit_defs defs; |
| 526 |
emit_uses uses; |
| 527 |
emit_cutsTo cutsTo; |
| 528 |
emit_nop nop ) |
| 529 |
| I.Ticc{t, cc, r, i} => |
| 530 |
( emit "t"; |
| 531 |
emit_branch t; |
| 532 |
emit "\t"; |
| 533 |
(if (cc = I.ICC) |
| 534 |
then () |
| 535 |
else (emit "%xcc, ")); |
| 536 |
emitCell r; |
| 537 |
emit "+"; |
| 538 |
emit_operand i ) |
| 539 |
| I.FPop1{a, r, d} => |
| 540 |
let |
| 541 |
(*#line 764.18 "sparc/sparc.mdl"*) |
| 542 |
fun f (a, r, d) = |
| 543 |
( emit a; |
| 544 |
emit "\t"; |
| 545 |
emit (C.showFP r); |
| 546 |
emit ", "; |
| 547 |
emit (C.showFP d)) |
| 548 |
|
| 549 |
(*#line 769.18 "sparc/sparc.mdl"*) |
| 550 |
fun g (a, r, d) = |
| 551 |
let |
| 552 |
(*#line 770.22 "sparc/sparc.mdl"*) |
| 553 |
val r = CellsBasis.registerNum r |
| 554 |
and d = CellsBasis.registerNum d |
| 555 |
in f (a, r, d); |
| 556 |
emit "\n\t"; |
| 557 |
f ("fmovs", r + 1, d + 1) |
| 558 |
end |
| 559 |
|
| 560 |
(*#line 774.18 "sparc/sparc.mdl"*) |
| 561 |
fun h (a, r, d) = |
| 562 |
let |
| 563 |
(*#line 775.22 "sparc/sparc.mdl"*) |
| 564 |
val r = CellsBasis.registerNum r |
| 565 |
and d = CellsBasis.registerNum d |
| 566 |
in f (a, r, d); |
| 567 |
emit "\n\t"; |
| 568 |
f ("fmovs", r + 1, d + 1); |
| 569 |
emit "\n\t"; |
| 570 |
f ("fmovs", r + 2, d + 2); |
| 571 |
emit "\n\t"; |
| 572 |
f ("fmovs", r + 3, d + 3) |
| 573 |
end |
| 574 |
in (if V9 |
| 575 |
then |
| 576 |
( emit_farith1 a; |
| 577 |
emit "\t"; |
| 578 |
emitCell r; |
| 579 |
emit ", "; |
| 580 |
emitCell d ) |
| 581 |
else |
| 582 |
(case a of |
| 583 |
I.FMOVd => g ("fmovs", r, d) |
| 584 |
| I.FNEGd => g ("fnegs", r, d) |
| 585 |
| I.FABSd => g ("fabss", r, d) |
| 586 |
| I.FMOVq => h ("fmovs", r, d) |
| 587 |
| I.FNEGq => h ("fnegs", r, d) |
| 588 |
| I.FABSq => h ("fabss", r, d) |
| 589 |
| _ => |
| 590 |
( emit_farith1 a; |
| 591 |
emit "\t"; |
| 592 |
emitCell r; |
| 593 |
emit ", "; |
| 594 |
emitCell d ) |
| 595 |
)) |
| 596 |
end |
| 597 |
| I.FPop2{a, r1, r2, d} => |
| 598 |
( emit_farith2 a; |
| 599 |
emit "\t"; |
| 600 |
emitCell r1; |
| 601 |
emit ", "; |
| 602 |
emitCell r2; |
| 603 |
emit ", "; |
| 604 |
emitCell d ) |
| 605 |
| I.FCMP{cmp, r1, r2, nop} => |
| 606 |
( emit_fcmp cmp; |
| 607 |
emit "\t"; |
| 608 |
emitCell r1; |
| 609 |
emit ", "; |
| 610 |
emitCell r2; |
| 611 |
emit_nop nop ) |
| 612 |
| I.SAVE{r, i, d} => |
| 613 |
( emit "save\t"; |
| 614 |
emitCell r; |
| 615 |
emit ", "; |
| 616 |
emit_operand i; |
| 617 |
emit ", "; |
| 618 |
emitCell d ) |
| 619 |
| I.RESTORE{r, i, d} => |
| 620 |
( emit "restore\t"; |
| 621 |
emitCell r; |
| 622 |
emit ", "; |
| 623 |
emit_operand i; |
| 624 |
emit ", "; |
| 625 |
emitCell d ) |
| 626 |
| I.RDY{d} => |
| 627 |
( emit "rd\t%y, "; |
| 628 |
emitCell d ) |
| 629 |
| I.WRY{r, i} => |
| 630 |
( emit "wr\t"; |
| 631 |
emitCell r; |
| 632 |
emit ", "; |
| 633 |
emit_operand i; |
| 634 |
emit ", %y" ) |
| 635 |
| I.RET{leaf, nop} => |
| 636 |
( emit "ret"; |
| 637 |
emit_leaf leaf; |
| 638 |
emit_nop nop ) |
| 639 |
| I.SOURCE{} => emit "source" |
| 640 |
| I.SINK{} => emit "sink" |
| 641 |
| I.PHI{} => emit "phi" |
| 642 |
) |
| 643 |
in tab(); emitInstr' instr; nl() |
| 644 |
end (* emitter *) |
| 645 |
and emitInstrIndented i = (indent(); emitInstr i; nl()) |
| 646 |
and emitInstrs instrs = |
| 647 |
app (if !indent_copies then emitInstrIndented |
| 648 |
else emitInstr) instrs |
| 649 |
|
| 650 |
and emitInstr(I.ANNOTATION{i,a}) = |
| 651 |
( comment(Annotations.toString a); |
| 652 |
nl(); |
| 653 |
emitInstr i ) |
| 654 |
| emitInstr(I.LIVE{regs, spilled}) = |
| 655 |
comment("live= " ^ CellsBasis.CellSet.toString regs ^ |
| 656 |
"spilled= " ^ CellsBasis.CellSet.toString spilled) |
| 657 |
| emitInstr(I.KILL{regs, spilled}) = |
| 658 |
comment("killed:: " ^ CellsBasis.CellSet.toString regs ^ |
| 659 |
"spilled:: " ^ CellsBasis.CellSet.toString spilled) |
| 660 |
| emitInstr(I.INSTR i) = emitter i |
| 661 |
| emitInstr(I.COPY{k=CellsBasis.GP, sz, src, dst, tmp}) = |
| 662 |
emitInstrs(Shuffle.shuffle{tmp=tmp, src=src, dst=dst}) |
| 663 |
| emitInstr(I.COPY{k=CellsBasis.FP, sz, src, dst, tmp}) = |
| 664 |
emitInstrs(Shuffle.shufflefp{tmp=tmp, src=src, dst=dst}) |
| 665 |
| emitInstr _ = error "emitInstr" |
| 666 |
|
| 667 |
in S.STREAM{beginCluster=init, |
| 668 |
pseudoOp=pseudoOp, |
| 669 |
emit=emitInstr, |
| 670 |
endCluster=fail, |
| 671 |
defineLabel=defineLabel, |
| 672 |
entryLabel=entryLabel, |
| 673 |
comment=comment, |
| 674 |
exitBlock=doNothing, |
| 675 |
annotation=annotation, |
| 676 |
getAnnotations=getAnnotations |
| 677 |
} |
| 678 |
end |
| 679 |
end |
| 680 |
|