| 1 |
(* |
| 2 |
* WARNING: This file was automatically generated by MDLGen (v3.1) |
| 3 |
* from the machine description file "x86/x86.mdl". |
| 4 |
* DO NOT EDIT this file directly |
| 5 |
*) |
| 6 |
|
| 7 |
|
| 8 |
functor X86AsmEmitter(structure S : INSTRUCTION_STREAM |
| 9 |
structure Instr : X86INSTR (* 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 : X86SHUFFLE (* 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.addressing_mode = Instr.addressing_mode *) |
| 52 |
and type I.binaryOp = Instr.binaryOp |
| 53 |
and type I.bitOp = Instr.bitOp |
| 54 |
and type I.cond = Instr.cond |
| 55 |
and type I.fbinOp = Instr.fbinOp |
| 56 |
and type I.fenvOp = Instr.fenvOp |
| 57 |
and type I.fibinOp = Instr.fibinOp |
| 58 |
and type I.fsize = Instr.fsize |
| 59 |
and type I.funOp = Instr.funOp |
| 60 |
and type I.instr = Instr.instr |
| 61 |
and type I.instruction = Instr.instruction |
| 62 |
and type I.isize = Instr.isize |
| 63 |
and type I.move = Instr.move |
| 64 |
and type I.multDivOp = Instr.multDivOp |
| 65 |
and type I.operand = Instr.operand |
| 66 |
and type I.shiftOp = Instr.shiftOp |
| 67 |
and type I.unaryOp = Instr.unaryOp |
| 68 |
structure MLTreeEval : MLTREE_EVAL (* where T = Instr.T *) |
| 69 |
where type T.Basis.cond = Instr.T.Basis.cond |
| 70 |
and type T.Basis.div_rounding_mode = Instr.T.Basis.div_rounding_mode |
| 71 |
and type T.Basis.ext = Instr.T.Basis.ext |
| 72 |
and type T.Basis.fcond = Instr.T.Basis.fcond |
| 73 |
and type T.Basis.rounding_mode = Instr.T.Basis.rounding_mode |
| 74 |
and type T.Constant.const = Instr.T.Constant.const |
| 75 |
and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) Instr.T.Extension.ccx |
| 76 |
and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) Instr.T.Extension.fx |
| 77 |
and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) Instr.T.Extension.rx |
| 78 |
and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) Instr.T.Extension.sx |
| 79 |
and type T.I.div_rounding_mode = Instr.T.I.div_rounding_mode |
| 80 |
and type T.Region.region = Instr.T.Region.region |
| 81 |
and type T.ccexp = Instr.T.ccexp |
| 82 |
and type T.fexp = Instr.T.fexp |
| 83 |
(* and type T.labexp = Instr.T.labexp *) |
| 84 |
and type T.mlrisc = Instr.T.mlrisc |
| 85 |
and type T.oper = Instr.T.oper |
| 86 |
and type T.rep = Instr.T.rep |
| 87 |
and type T.rexp = Instr.T.rexp |
| 88 |
and type T.stm = Instr.T.stm |
| 89 |
|
| 90 |
(*#line 512.7 "x86/x86.mdl"*) |
| 91 |
structure MemRegs : MEMORY_REGISTERS (* where I = Instr *) |
| 92 |
where type I.Constant.const = Instr.Constant.const |
| 93 |
and type I.Region.region = Instr.Region.region |
| 94 |
and type I.T.Basis.cond = Instr.T.Basis.cond |
| 95 |
and type I.T.Basis.div_rounding_mode = Instr.T.Basis.div_rounding_mode |
| 96 |
and type I.T.Basis.ext = Instr.T.Basis.ext |
| 97 |
and type I.T.Basis.fcond = Instr.T.Basis.fcond |
| 98 |
and type I.T.Basis.rounding_mode = Instr.T.Basis.rounding_mode |
| 99 |
and type ('s,'r,'f,'c) I.T.Extension.ccx = ('s,'r,'f,'c) Instr.T.Extension.ccx |
| 100 |
and type ('s,'r,'f,'c) I.T.Extension.fx = ('s,'r,'f,'c) Instr.T.Extension.fx |
| 101 |
and type ('s,'r,'f,'c) I.T.Extension.rx = ('s,'r,'f,'c) Instr.T.Extension.rx |
| 102 |
and type ('s,'r,'f,'c) I.T.Extension.sx = ('s,'r,'f,'c) Instr.T.Extension.sx |
| 103 |
and type I.T.I.div_rounding_mode = Instr.T.I.div_rounding_mode |
| 104 |
and type I.T.ccexp = Instr.T.ccexp |
| 105 |
and type I.T.fexp = Instr.T.fexp |
| 106 |
(* and type I.T.labexp = Instr.T.labexp *) |
| 107 |
and type I.T.mlrisc = Instr.T.mlrisc |
| 108 |
and type I.T.oper = Instr.T.oper |
| 109 |
and type I.T.rep = Instr.T.rep |
| 110 |
and type I.T.rexp = Instr.T.rexp |
| 111 |
and type I.T.stm = Instr.T.stm |
| 112 |
(* and type I.addressing_mode = Instr.addressing_mode *) |
| 113 |
and type I.binaryOp = Instr.binaryOp |
| 114 |
and type I.bitOp = Instr.bitOp |
| 115 |
and type I.cond = Instr.cond |
| 116 |
and type I.fbinOp = Instr.fbinOp |
| 117 |
and type I.fenvOp = Instr.fenvOp |
| 118 |
and type I.fibinOp = Instr.fibinOp |
| 119 |
and type I.fsize = Instr.fsize |
| 120 |
and type I.funOp = Instr.funOp |
| 121 |
and type I.instr = Instr.instr |
| 122 |
and type I.instruction = Instr.instruction |
| 123 |
and type I.isize = Instr.isize |
| 124 |
and type I.move = Instr.move |
| 125 |
and type I.multDivOp = Instr.multDivOp |
| 126 |
and type I.operand = Instr.operand |
| 127 |
and type I.shiftOp = Instr.shiftOp |
| 128 |
and type I.unaryOp = Instr.unaryOp |
| 129 |
|
| 130 |
(*#line 513.7 "x86/x86.mdl"*) |
| 131 |
val memRegBase : CellsBasis.cell option |
| 132 |
) : INSTRUCTION_EMITTER = |
| 133 |
struct |
| 134 |
structure I = Instr |
| 135 |
structure C = I.C |
| 136 |
structure T = I.T |
| 137 |
structure S = S |
| 138 |
structure P = S.P |
| 139 |
structure Constant = I.Constant |
| 140 |
|
| 141 |
open AsmFlags |
| 142 |
|
| 143 |
fun error msg = MLRiscErrorMsg.error("X86AsmEmitter",msg) |
| 144 |
|
| 145 |
fun makeStream formatAnnotations = |
| 146 |
let val stream = !AsmStream.asmOutStream |
| 147 |
fun emit' s = TextIO.output(stream,s) |
| 148 |
val newline = ref true |
| 149 |
val tabs = ref 0 |
| 150 |
fun tabbing 0 = () |
| 151 |
| tabbing n = (emit' "\t"; tabbing(n-1)) |
| 152 |
fun emit s = (tabbing(!tabs); tabs := 0; newline := false; emit' s) |
| 153 |
fun nl() = (tabs := 0; if !newline then () else (newline := true; emit' "\n")) |
| 154 |
fun comma() = emit "," |
| 155 |
fun tab() = tabs := 1 |
| 156 |
fun indent() = tabs := 2 |
| 157 |
fun ms n = let val s = Int.toString n |
| 158 |
in if n<0 then "-"^String.substring(s,1,size s-1) |
| 159 |
else s |
| 160 |
end |
| 161 |
fun emit_label lab = emit(P.Client.AsmPseudoOps.lexpToString(T.LABEL lab)) |
| 162 |
fun emit_labexp le = emit(P.Client.AsmPseudoOps.lexpToString (T.LABEXP le)) |
| 163 |
fun emit_const c = emit(Constant.toString c) |
| 164 |
fun emit_int i = emit(ms i) |
| 165 |
fun paren f = (emit "("; f(); emit ")") |
| 166 |
fun defineLabel lab = emit(P.Client.AsmPseudoOps.defineLabel lab^"\n") |
| 167 |
fun entryLabel lab = defineLabel lab |
| 168 |
fun comment msg = (tab(); emit("/* " ^ msg ^ " */"); nl()) |
| 169 |
fun annotation a = comment(Annotations.toString a) |
| 170 |
fun getAnnotations() = error "getAnnotations" |
| 171 |
fun doNothing _ = () |
| 172 |
fun fail _ = raise Fail "AsmEmitter" |
| 173 |
fun emit_region mem = comment(I.Region.toString mem) |
| 174 |
val emit_region = |
| 175 |
if !show_region then emit_region else doNothing |
| 176 |
fun pseudoOp pOp = (emit(P.toString pOp); emit "\n") |
| 177 |
fun init size = (comment("Code Size = " ^ ms size); nl()) |
| 178 |
val emitCellInfo = AsmFormatUtil.reginfo |
| 179 |
(emit,formatAnnotations) |
| 180 |
fun emitCell r = (emit(CellsBasis.toString r); emitCellInfo r) |
| 181 |
fun emit_cellset(title,cellset) = |
| 182 |
(nl(); comment(title^CellsBasis.CellSet.toString cellset)) |
| 183 |
val emit_cellset = |
| 184 |
if !show_cellset then emit_cellset else doNothing |
| 185 |
fun emit_defs cellset = emit_cellset("defs: ",cellset) |
| 186 |
fun emit_uses cellset = emit_cellset("uses: ",cellset) |
| 187 |
val emit_cutsTo = |
| 188 |
if !show_cutsTo then AsmFormatUtil.emit_cutsTo emit |
| 189 |
else doNothing |
| 190 |
fun emitter instr = |
| 191 |
let |
| 192 |
fun asm_cond (I.EQ) = "e" |
| 193 |
| asm_cond (I.NE) = "ne" |
| 194 |
| asm_cond (I.LT) = "l" |
| 195 |
| asm_cond (I.LE) = "le" |
| 196 |
| asm_cond (I.GT) = "g" |
| 197 |
| asm_cond (I.GE) = "ge" |
| 198 |
| asm_cond (I.B) = "b" |
| 199 |
| asm_cond (I.BE) = "be" |
| 200 |
| asm_cond (I.A) = "a" |
| 201 |
| asm_cond (I.AE) = "ae" |
| 202 |
| asm_cond (I.C) = "c" |
| 203 |
| asm_cond (I.NC) = "nc" |
| 204 |
| asm_cond (I.P) = "p" |
| 205 |
| asm_cond (I.NP) = "np" |
| 206 |
| asm_cond (I.O) = "o" |
| 207 |
| asm_cond (I.NO) = "no" |
| 208 |
and emit_cond x = emit (asm_cond x) |
| 209 |
and asm_binaryOp (I.ADDL) = "addl" |
| 210 |
| asm_binaryOp (I.SUBL) = "subl" |
| 211 |
| asm_binaryOp (I.ANDL) = "andl" |
| 212 |
| asm_binaryOp (I.ORL) = "orl" |
| 213 |
| asm_binaryOp (I.XORL) = "xorl" |
| 214 |
| asm_binaryOp (I.SHLL) = "shll" |
| 215 |
| asm_binaryOp (I.SARL) = "sarl" |
| 216 |
| asm_binaryOp (I.SHRL) = "shrl" |
| 217 |
| asm_binaryOp (I.IMULL) = "imull" |
| 218 |
| asm_binaryOp (I.ADCL) = "adcl" |
| 219 |
| asm_binaryOp (I.SBBL) = "sbbl" |
| 220 |
| asm_binaryOp (I.ADDW) = "addw" |
| 221 |
| asm_binaryOp (I.SUBW) = "subw" |
| 222 |
| asm_binaryOp (I.ANDW) = "andw" |
| 223 |
| asm_binaryOp (I.ORW) = "orw" |
| 224 |
| asm_binaryOp (I.XORW) = "xorw" |
| 225 |
| asm_binaryOp (I.SHLW) = "shlw" |
| 226 |
| asm_binaryOp (I.SARW) = "sarw" |
| 227 |
| asm_binaryOp (I.SHRW) = "shrw" |
| 228 |
| asm_binaryOp (I.IMULW) = "imulw" |
| 229 |
| asm_binaryOp (I.ADDB) = "addb" |
| 230 |
| asm_binaryOp (I.SUBB) = "subb" |
| 231 |
| asm_binaryOp (I.ANDB) = "andb" |
| 232 |
| asm_binaryOp (I.ORB) = "orb" |
| 233 |
| asm_binaryOp (I.XORB) = "xorb" |
| 234 |
| asm_binaryOp (I.SHLB) = "shlb" |
| 235 |
| asm_binaryOp (I.SARB) = "sarb" |
| 236 |
| asm_binaryOp (I.SHRB) = "shrb" |
| 237 |
| asm_binaryOp (I.IMULB) = "imulb" |
| 238 |
| asm_binaryOp (I.BTSW) = "btsw" |
| 239 |
| asm_binaryOp (I.BTCW) = "btcw" |
| 240 |
| asm_binaryOp (I.BTRW) = "btrw" |
| 241 |
| asm_binaryOp (I.BTSL) = "btsl" |
| 242 |
| asm_binaryOp (I.BTCL) = "btcl" |
| 243 |
| asm_binaryOp (I.BTRL) = "btrl" |
| 244 |
| asm_binaryOp (I.ROLW) = "rolw" |
| 245 |
| asm_binaryOp (I.RORW) = "rorw" |
| 246 |
| asm_binaryOp (I.ROLL) = "roll" |
| 247 |
| asm_binaryOp (I.RORL) = "rorl" |
| 248 |
| asm_binaryOp (I.XCHGB) = "xchgb" |
| 249 |
| asm_binaryOp (I.XCHGW) = "xchgw" |
| 250 |
| asm_binaryOp (I.XCHGL) = "xchgl" |
| 251 |
| asm_binaryOp (I.LOCK_ADCW) = "lock\n\tadcw" |
| 252 |
| asm_binaryOp (I.LOCK_ADCL) = "lock\n\tadcl" |
| 253 |
| asm_binaryOp (I.LOCK_ADDW) = "lock\n\taddw" |
| 254 |
| asm_binaryOp (I.LOCK_ADDL) = "lock\n\taddl" |
| 255 |
| asm_binaryOp (I.LOCK_ANDW) = "lock\n\tandw" |
| 256 |
| asm_binaryOp (I.LOCK_ANDL) = "lock\n\tandl" |
| 257 |
| asm_binaryOp (I.LOCK_BTSW) = "lock\n\tbtsw" |
| 258 |
| asm_binaryOp (I.LOCK_BTSL) = "lock\n\tbtsl" |
| 259 |
| asm_binaryOp (I.LOCK_BTRW) = "lock\n\tbtrw" |
| 260 |
| asm_binaryOp (I.LOCK_BTRL) = "lock\n\tbtrl" |
| 261 |
| asm_binaryOp (I.LOCK_BTCW) = "lock\n\tbtcw" |
| 262 |
| asm_binaryOp (I.LOCK_BTCL) = "lock\n\tbtcl" |
| 263 |
| asm_binaryOp (I.LOCK_ORW) = "lock\n\torw" |
| 264 |
| asm_binaryOp (I.LOCK_ORL) = "lock\n\torl" |
| 265 |
| asm_binaryOp (I.LOCK_SBBW) = "lock\n\tsbbw" |
| 266 |
| asm_binaryOp (I.LOCK_SBBL) = "lock\n\tsbbl" |
| 267 |
| asm_binaryOp (I.LOCK_SUBW) = "lock\n\tsubw" |
| 268 |
| asm_binaryOp (I.LOCK_SUBL) = "lock\n\tsubl" |
| 269 |
| asm_binaryOp (I.LOCK_XORW) = "lock\n\txorw" |
| 270 |
| asm_binaryOp (I.LOCK_XORL) = "lock\n\txorl" |
| 271 |
| asm_binaryOp (I.LOCK_XADDB) = "lock\n\txaddb" |
| 272 |
| asm_binaryOp (I.LOCK_XADDW) = "lock\n\txaddw" |
| 273 |
| asm_binaryOp (I.LOCK_XADDL) = "lock\n\txaddl" |
| 274 |
and emit_binaryOp x = emit (asm_binaryOp x) |
| 275 |
and asm_multDivOp (I.IMULL1) = "imull" |
| 276 |
| asm_multDivOp (I.MULL1) = "mull" |
| 277 |
| asm_multDivOp (I.IDIVL1) = "idivl" |
| 278 |
| asm_multDivOp (I.DIVL1) = "divl" |
| 279 |
and emit_multDivOp x = emit (asm_multDivOp x) |
| 280 |
and asm_unaryOp (I.DECL) = "decl" |
| 281 |
| asm_unaryOp (I.INCL) = "incl" |
| 282 |
| asm_unaryOp (I.NEGL) = "negl" |
| 283 |
| asm_unaryOp (I.NOTL) = "notl" |
| 284 |
| asm_unaryOp (I.DECW) = "decw" |
| 285 |
| asm_unaryOp (I.INCW) = "incw" |
| 286 |
| asm_unaryOp (I.NEGW) = "negw" |
| 287 |
| asm_unaryOp (I.NOTW) = "notw" |
| 288 |
| asm_unaryOp (I.DECB) = "decb" |
| 289 |
| asm_unaryOp (I.INCB) = "incb" |
| 290 |
| asm_unaryOp (I.NEGB) = "negb" |
| 291 |
| asm_unaryOp (I.NOTB) = "notb" |
| 292 |
| asm_unaryOp (I.LOCK_DECL) = "lock\n\tdecl" |
| 293 |
| asm_unaryOp (I.LOCK_INCL) = "lock\n\tincl" |
| 294 |
| asm_unaryOp (I.LOCK_NEGL) = "lock\n\tnegl" |
| 295 |
| asm_unaryOp (I.LOCK_NOTL) = "lock\n\tnotl" |
| 296 |
and emit_unaryOp x = emit (asm_unaryOp x) |
| 297 |
and asm_shiftOp (I.SHLDL) = "shldl" |
| 298 |
| asm_shiftOp (I.SHRDL) = "shrdl" |
| 299 |
and emit_shiftOp x = emit (asm_shiftOp x) |
| 300 |
and asm_bitOp (I.BTW) = "btw" |
| 301 |
| asm_bitOp (I.BTL) = "btl" |
| 302 |
| asm_bitOp (I.LOCK_BTW) = "lock\n\tbtw" |
| 303 |
| asm_bitOp (I.LOCK_BTL) = "lock\n\tbtl" |
| 304 |
and emit_bitOp x = emit (asm_bitOp x) |
| 305 |
and asm_move (I.MOVL) = "movl" |
| 306 |
| asm_move (I.MOVB) = "movb" |
| 307 |
| asm_move (I.MOVW) = "movw" |
| 308 |
| asm_move (I.MOVSWL) = "movswl" |
| 309 |
| asm_move (I.MOVZWL) = "movzwl" |
| 310 |
| asm_move (I.MOVSBL) = "movsbl" |
| 311 |
| asm_move (I.MOVZBL) = "movzbl" |
| 312 |
and emit_move x = emit (asm_move x) |
| 313 |
and asm_fbinOp (I.FADDP) = "faddp" |
| 314 |
| asm_fbinOp (I.FADDS) = "fadds" |
| 315 |
| asm_fbinOp (I.FMULP) = "fmulp" |
| 316 |
| asm_fbinOp (I.FMULS) = "fmuls" |
| 317 |
| asm_fbinOp (I.FCOMS) = "fcoms" |
| 318 |
| asm_fbinOp (I.FCOMPS) = "fcomps" |
| 319 |
| asm_fbinOp (I.FSUBP) = "fsubp" |
| 320 |
| asm_fbinOp (I.FSUBS) = "fsubs" |
| 321 |
| asm_fbinOp (I.FSUBRP) = "fsubrp" |
| 322 |
| asm_fbinOp (I.FSUBRS) = "fsubrs" |
| 323 |
| asm_fbinOp (I.FDIVP) = "fdivp" |
| 324 |
| asm_fbinOp (I.FDIVS) = "fdivs" |
| 325 |
| asm_fbinOp (I.FDIVRP) = "fdivrp" |
| 326 |
| asm_fbinOp (I.FDIVRS) = "fdivrs" |
| 327 |
| asm_fbinOp (I.FADDL) = "faddl" |
| 328 |
| asm_fbinOp (I.FMULL) = "fmull" |
| 329 |
| asm_fbinOp (I.FCOML) = "fcoml" |
| 330 |
| asm_fbinOp (I.FCOMPL) = "fcompl" |
| 331 |
| asm_fbinOp (I.FSUBL) = "fsubl" |
| 332 |
| asm_fbinOp (I.FSUBRL) = "fsubrl" |
| 333 |
| asm_fbinOp (I.FDIVL) = "fdivl" |
| 334 |
| asm_fbinOp (I.FDIVRL) = "fdivrl" |
| 335 |
and emit_fbinOp x = emit (asm_fbinOp x) |
| 336 |
and asm_fibinOp (I.FIADDS) = "fiadds" |
| 337 |
| asm_fibinOp (I.FIMULS) = "fimuls" |
| 338 |
| asm_fibinOp (I.FICOMS) = "ficoms" |
| 339 |
| asm_fibinOp (I.FICOMPS) = "ficomps" |
| 340 |
| asm_fibinOp (I.FISUBS) = "fisubs" |
| 341 |
| asm_fibinOp (I.FISUBRS) = "fisubrs" |
| 342 |
| asm_fibinOp (I.FIDIVS) = "fidivs" |
| 343 |
| asm_fibinOp (I.FIDIVRS) = "fidivrs" |
| 344 |
| asm_fibinOp (I.FIADDL) = "fiaddl" |
| 345 |
| asm_fibinOp (I.FIMULL) = "fimull" |
| 346 |
| asm_fibinOp (I.FICOML) = "ficoml" |
| 347 |
| asm_fibinOp (I.FICOMPL) = "ficompl" |
| 348 |
| asm_fibinOp (I.FISUBL) = "fisubl" |
| 349 |
| asm_fibinOp (I.FISUBRL) = "fisubrl" |
| 350 |
| asm_fibinOp (I.FIDIVL) = "fidivl" |
| 351 |
| asm_fibinOp (I.FIDIVRL) = "fidivrl" |
| 352 |
and emit_fibinOp x = emit (asm_fibinOp x) |
| 353 |
and asm_funOp (I.FCHS) = "fchs" |
| 354 |
| asm_funOp (I.FABS) = "fabs" |
| 355 |
| asm_funOp (I.FTST) = "ftst" |
| 356 |
| asm_funOp (I.FXAM) = "fxam" |
| 357 |
| asm_funOp (I.FPTAN) = "fptan" |
| 358 |
| asm_funOp (I.FPATAN) = "fpatan" |
| 359 |
| asm_funOp (I.FXTRACT) = "fxtract" |
| 360 |
| asm_funOp (I.FPREM1) = "fprem1" |
| 361 |
| asm_funOp (I.FDECSTP) = "fdecstp" |
| 362 |
| asm_funOp (I.FINCSTP) = "fincstp" |
| 363 |
| asm_funOp (I.FPREM) = "fprem" |
| 364 |
| asm_funOp (I.FYL2XP1) = "fyl2xp1" |
| 365 |
| asm_funOp (I.FSQRT) = "fsqrt" |
| 366 |
| asm_funOp (I.FSINCOS) = "fsincos" |
| 367 |
| asm_funOp (I.FRNDINT) = "frndint" |
| 368 |
| asm_funOp (I.FSCALE) = "fscale" |
| 369 |
| asm_funOp (I.FSIN) = "fsin" |
| 370 |
| asm_funOp (I.FCOS) = "fcos" |
| 371 |
and emit_funOp x = emit (asm_funOp x) |
| 372 |
and asm_fenvOp (I.FLDENV) = "fldenv" |
| 373 |
| asm_fenvOp (I.FNLDENV) = "fnldenv" |
| 374 |
| asm_fenvOp (I.FSTENV) = "fstenv" |
| 375 |
| asm_fenvOp (I.FNSTENV) = "fnstenv" |
| 376 |
and emit_fenvOp x = emit (asm_fenvOp x) |
| 377 |
and asm_fsize (I.FP32) = "s" |
| 378 |
| asm_fsize (I.FP64) = "l" |
| 379 |
| asm_fsize (I.FP80) = "t" |
| 380 |
and emit_fsize x = emit (asm_fsize x) |
| 381 |
and asm_isize (I.I8) = "8" |
| 382 |
| asm_isize (I.I16) = "16" |
| 383 |
| asm_isize (I.I32) = "32" |
| 384 |
| asm_isize (I.I64) = "64" |
| 385 |
and emit_isize x = emit (asm_isize x) |
| 386 |
|
| 387 |
(*#line 515.6 "x86/x86.mdl"*) |
| 388 |
fun memReg r = MemRegs.memReg {reg=r, base=Option.valOf memRegBase} |
| 389 |
|
| 390 |
(*#line 516.6 "x86/x86.mdl"*) |
| 391 |
fun emitInt32 i = |
| 392 |
let |
| 393 |
(*#line 517.10 "x86/x86.mdl"*) |
| 394 |
val s = Int32.toString i |
| 395 |
|
| 396 |
(*#line 518.10 "x86/x86.mdl"*) |
| 397 |
val s = (if (i >= 0) |
| 398 |
then s |
| 399 |
else ("-" ^ (String.substring (s, 1, (size s) - 1)))) |
| 400 |
in emit s |
| 401 |
end |
| 402 |
|
| 403 |
(*#line 521.6 "x86/x86.mdl"*) |
| 404 |
val {low=SToffset, ...} = C.cellRange CellsBasis.FP |
| 405 |
|
| 406 |
(*#line 523.6 "x86/x86.mdl"*) |
| 407 |
fun emitScale 0 = emit "1" |
| 408 |
| emitScale 1 = emit "2" |
| 409 |
| emitScale 2 = emit "4" |
| 410 |
| emitScale 3 = emit "8" |
| 411 |
| emitScale _ = error "emitScale" |
| 412 |
and eImmed (I.Immed i) = emitInt32 i |
| 413 |
| eImmed (I.ImmedLabel lexp) = emit_labexp lexp |
| 414 |
| eImmed _ = error "eImmed" |
| 415 |
and emit_operand opn = |
| 416 |
(case opn of |
| 417 |
I.Immed i => |
| 418 |
( emit "$"; |
| 419 |
emitInt32 i ) |
| 420 |
| I.ImmedLabel lexp => |
| 421 |
( emit "$"; |
| 422 |
emit_labexp lexp ) |
| 423 |
| I.LabelEA le => emit_labexp le |
| 424 |
| I.Relative _ => error "emit_operand" |
| 425 |
| I.Direct r => emitCell r |
| 426 |
| I.MemReg r => emit_operand (memReg opn) |
| 427 |
| I.ST f => emitCell f |
| 428 |
| I.FPR f => |
| 429 |
( emit "%f"; |
| 430 |
emit (Int.toString (CellsBasis.registerNum f))) |
| 431 |
| I.FDirect f => emit_operand (memReg opn) |
| 432 |
| I.Displace{base, disp, mem, ...} => |
| 433 |
( emit_disp disp; |
| 434 |
emit "("; |
| 435 |
emitCell base; |
| 436 |
emit ")"; |
| 437 |
emit_region mem ) |
| 438 |
| I.Indexed{base, index, scale, disp, mem, ...} => |
| 439 |
( emit_disp disp; |
| 440 |
emit "("; |
| 441 |
|
| 442 |
(case base of |
| 443 |
NONE => () |
| 444 |
| SOME base => emitCell base |
| 445 |
); |
| 446 |
comma (); |
| 447 |
emitCell index; |
| 448 |
comma (); |
| 449 |
emitScale scale; |
| 450 |
emit ")"; |
| 451 |
emit_region mem ) |
| 452 |
) |
| 453 |
and emit_operand8 (I.Direct r) = emit (CellsBasis.toStringWithSize (r, 8)) |
| 454 |
| emit_operand8 opn = emit_operand opn |
| 455 |
and emit_disp (I.Immed 0) = () |
| 456 |
| emit_disp (I.Immed i) = emitInt32 i |
| 457 |
| emit_disp (I.ImmedLabel lexp) = emit_labexp lexp |
| 458 |
| emit_disp _ = error "emit_disp" |
| 459 |
|
| 460 |
(*#line 568.7 "x86/x86.mdl"*) |
| 461 |
fun stupidGas (I.ImmedLabel lexp) = emit_labexp lexp |
| 462 |
| stupidGas opnd = |
| 463 |
( emit "*"; |
| 464 |
emit_operand opnd ) |
| 465 |
|
| 466 |
(*#line 572.7 "x86/x86.mdl"*) |
| 467 |
fun isMemOpnd (I.MemReg _) = true |
| 468 |
| isMemOpnd (I.FDirect f) = true |
| 469 |
| isMemOpnd (I.LabelEA _) = true |
| 470 |
| isMemOpnd (I.Displace _) = true |
| 471 |
| isMemOpnd (I.Indexed _) = true |
| 472 |
| isMemOpnd _ = false |
| 473 |
|
| 474 |
(*#line 578.7 "x86/x86.mdl"*) |
| 475 |
fun chop fbinOp = |
| 476 |
let |
| 477 |
(*#line 579.15 "x86/x86.mdl"*) |
| 478 |
val n = size fbinOp |
| 479 |
in |
| 480 |
(case Char.toLower (String.sub (fbinOp, n - 1)) of |
| 481 |
(#"s" | #"l") => String.substring (fbinOp, 0, n - 1) |
| 482 |
| _ => fbinOp |
| 483 |
) |
| 484 |
end |
| 485 |
|
| 486 |
(*#line 585.7 "x86/x86.mdl"*) |
| 487 |
fun isST0 (I.ST r) = (CellsBasis.registerNum r) = 0 |
| 488 |
| isST0 _ = false |
| 489 |
|
| 490 |
(*#line 589.7 "x86/x86.mdl"*) |
| 491 |
fun emit_fbinaryOp (binOp, src, dst) = (if (isMemOpnd src) |
| 492 |
then |
| 493 |
( emit_fbinOp binOp; |
| 494 |
emit "\t"; |
| 495 |
emit_operand src ) |
| 496 |
else |
| 497 |
( emit (chop (asm_fbinOp binOp)); |
| 498 |
emit "\t"; |
| 499 |
|
| 500 |
(case (isST0 src, isST0 dst) of |
| 501 |
(_, true) => |
| 502 |
( emit_operand src; |
| 503 |
emit ", %st" ) |
| 504 |
| (true, _) => |
| 505 |
( emit "%st, "; |
| 506 |
emit_operand dst ) |
| 507 |
| _ => error "emit_fbinaryOp" |
| 508 |
))) |
| 509 |
|
| 510 |
(*#line 599.7 "x86/x86.mdl"*) |
| 511 |
val emit_dst = emit_operand |
| 512 |
|
| 513 |
(*#line 600.7 "x86/x86.mdl"*) |
| 514 |
val emit_src = emit_operand |
| 515 |
|
| 516 |
(*#line 601.7 "x86/x86.mdl"*) |
| 517 |
val emit_opnd = emit_operand |
| 518 |
|
| 519 |
(*#line 602.7 "x86/x86.mdl"*) |
| 520 |
val emit_opnd8 = emit_operand8 |
| 521 |
|
| 522 |
(*#line 603.7 "x86/x86.mdl"*) |
| 523 |
val emit_rsrc = emit_operand |
| 524 |
|
| 525 |
(*#line 604.7 "x86/x86.mdl"*) |
| 526 |
val emit_lsrc = emit_operand |
| 527 |
|
| 528 |
(*#line 605.7 "x86/x86.mdl"*) |
| 529 |
val emit_addr = emit_operand |
| 530 |
|
| 531 |
(*#line 606.7 "x86/x86.mdl"*) |
| 532 |
val emit_src1 = emit_operand |
| 533 |
|
| 534 |
(*#line 607.7 "x86/x86.mdl"*) |
| 535 |
val emit_ea = emit_operand |
| 536 |
|
| 537 |
(*#line 608.7 "x86/x86.mdl"*) |
| 538 |
val emit_count = emit_operand |
| 539 |
fun emitInstr' instr = |
| 540 |
(case instr of |
| 541 |
I.NOP => emit "nop" |
| 542 |
| I.JMP(operand, list) => |
| 543 |
( emit "jmp\t"; |
| 544 |
stupidGas operand ) |
| 545 |
| I.JCC{cond, opnd} => |
| 546 |
( emit "j"; |
| 547 |
emit_cond cond; |
| 548 |
emit "\t"; |
| 549 |
stupidGas opnd ) |
| 550 |
| I.CALL{opnd, defs, uses, return, cutsTo, mem, pops} => |
| 551 |
( emit "call\t"; |
| 552 |
stupidGas opnd; |
| 553 |
emit_region mem; |
| 554 |
emit_defs defs; |
| 555 |
emit_uses uses; |
| 556 |
emit_cellset ("return", return); |
| 557 |
emit_cutsTo cutsTo ) |
| 558 |
| I.ENTER{src1, src2} => |
| 559 |
( emit "enter\t"; |
| 560 |
emit_operand src1; |
| 561 |
emit ", "; |
| 562 |
emit_operand src2 ) |
| 563 |
| I.LEAVE => emit "leave" |
| 564 |
| I.RET option => |
| 565 |
( emit "ret"; |
| 566 |
|
| 567 |
(case option of |
| 568 |
NONE => () |
| 569 |
| SOME e => |
| 570 |
( emit "\t"; |
| 571 |
emit_operand e ) |
| 572 |
)) |
| 573 |
| I.MOVE{mvOp, src, dst} => |
| 574 |
( emit_move mvOp; |
| 575 |
emit "\t"; |
| 576 |
emit_src src; |
| 577 |
emit ", "; |
| 578 |
emit_dst dst ) |
| 579 |
| I.LEA{r32, addr} => |
| 580 |
( emit "leal\t"; |
| 581 |
emit_addr addr; |
| 582 |
emit ", "; |
| 583 |
emitCell r32 ) |
| 584 |
| I.CMPL{lsrc, rsrc} => |
| 585 |
( emit "cmpl\t"; |
| 586 |
emit_rsrc rsrc; |
| 587 |
emit ", "; |
| 588 |
emit_lsrc lsrc ) |
| 589 |
| I.CMPW{lsrc, rsrc} => |
| 590 |
( emit "cmpb\t"; |
| 591 |
emit_rsrc rsrc; |
| 592 |
emit ", "; |
| 593 |
emit_lsrc lsrc ) |
| 594 |
| I.CMPB{lsrc, rsrc} => |
| 595 |
( emit "cmpb\t"; |
| 596 |
emit_rsrc rsrc; |
| 597 |
emit ", "; |
| 598 |
emit_lsrc lsrc ) |
| 599 |
| I.TESTL{lsrc, rsrc} => |
| 600 |
( emit "testl\t"; |
| 601 |
emit_rsrc rsrc; |
| 602 |
emit ", "; |
| 603 |
emit_lsrc lsrc ) |
| 604 |
| I.TESTW{lsrc, rsrc} => |
| 605 |
( emit "testw\t"; |
| 606 |
emit_rsrc rsrc; |
| 607 |
emit ", "; |
| 608 |
emit_lsrc lsrc ) |
| 609 |
| I.TESTB{lsrc, rsrc} => |
| 610 |
( emit "testb\t"; |
| 611 |
emit_rsrc rsrc; |
| 612 |
emit ", "; |
| 613 |
emit_lsrc lsrc ) |
| 614 |
| I.BITOP{bitOp, lsrc, rsrc} => |
| 615 |
( emit_bitOp bitOp; |
| 616 |
emit "\t"; |
| 617 |
emit_rsrc rsrc; |
| 618 |
emit ", "; |
| 619 |
emit_lsrc lsrc ) |
| 620 |
| I.BINARY{binOp, src, dst} => |
| 621 |
(case (src, binOp) of |
| 622 |
(I.Direct _, (I.SARL | I.SHRL | I.SHLL | I.SARW | I.SHRW | I.SHLW | I.SARB | I.SHRB | I.SHLB)) => |
| 623 |
|
| 624 |
( emit_binaryOp binOp; |
| 625 |
emit "\t%cl, "; |
| 626 |
emit_dst dst ) |
| 627 |
| _ => |
| 628 |
( emit_binaryOp binOp; |
| 629 |
emit "\t"; |
| 630 |
emit_src src; |
| 631 |
emit ", "; |
| 632 |
emit_dst dst ) |
| 633 |
) |
| 634 |
| I.SHIFT{shiftOp, src, dst, count} => |
| 635 |
(case count of |
| 636 |
I.Direct ecx => |
| 637 |
( emit_shiftOp shiftOp; |
| 638 |
emit "\t"; |
| 639 |
emit_src src; |
| 640 |
emit ", "; |
| 641 |
emit_dst dst ) |
| 642 |
| _ => |
| 643 |
( emit_shiftOp shiftOp; |
| 644 |
emit "\t"; |
| 645 |
emit_src src; |
| 646 |
emit ", "; |
| 647 |
emit_count count; |
| 648 |
emit ", "; |
| 649 |
emit_dst dst ) |
| 650 |
) |
| 651 |
| I.CMPXCHG{lock, sz, src, dst} => |
| 652 |
( (if lock |
| 653 |
then (emit "lock\n\t") |
| 654 |
else ()); |
| 655 |
emit "cmpxchg"; |
| 656 |
|
| 657 |
(case sz of |
| 658 |
I.I8 => emit "b" |
| 659 |
| I.I16 => emit "w" |
| 660 |
| I.I32 => emit "l" |
| 661 |
| I.I64 => error "CMPXCHG: I64" |
| 662 |
); |
| 663 |
|
| 664 |
( emit "\t"; |
| 665 |
emit_src src; |
| 666 |
emit ", "; |
| 667 |
emit_dst dst ) ) |
| 668 |
| I.MULTDIV{multDivOp, src} => |
| 669 |
( emit_multDivOp multDivOp; |
| 670 |
emit "\t"; |
| 671 |
emit_src src ) |
| 672 |
| I.MUL3{dst, src2, src1} => |
| 673 |
( emit "imull\t$"; |
| 674 |
emitInt32 src2; |
| 675 |
emit ", "; |
| 676 |
emit_src1 src1; |
| 677 |
emit ", "; |
| 678 |
emitCell dst ) |
| 679 |
| I.UNARY{unOp, opnd} => |
| 680 |
( emit_unaryOp unOp; |
| 681 |
emit "\t"; |
| 682 |
emit_opnd opnd ) |
| 683 |
| I.SET{cond, opnd} => |
| 684 |
( emit "set"; |
| 685 |
emit_cond cond; |
| 686 |
emit "\t"; |
| 687 |
emit_opnd8 opnd ) |
| 688 |
| I.CMOV{cond, src, dst} => |
| 689 |
( emit "cmov"; |
| 690 |
emit_cond cond; |
| 691 |
emit "\t"; |
| 692 |
emit_src src; |
| 693 |
emit ", "; |
| 694 |
emitCell dst ) |
| 695 |
| I.PUSHL operand => |
| 696 |
( emit "pushl\t"; |
| 697 |
emit_operand operand ) |
| 698 |
| I.PUSHW operand => |
| 699 |
( emit "pushw\t"; |
| 700 |
emit_operand operand ) |
| 701 |
| I.PUSHB operand => |
| 702 |
( emit "pushb\t"; |
| 703 |
emit_operand operand ) |
| 704 |
| I.PUSHFD => emit "pushfd" |
| 705 |
| I.POPFD => emit "popfd" |
| 706 |
| I.POP operand => |
| 707 |
( emit "popl\t"; |
| 708 |
emit_operand operand ) |
| 709 |
| I.CDQ => emit "cdq" |
| 710 |
| I.INTO => emit "into" |
| 711 |
| I.FBINARY{binOp, src, dst} => emit_fbinaryOp (binOp, src, dst) |
| 712 |
| I.FIBINARY{binOp, src} => |
| 713 |
( emit_fibinOp binOp; |
| 714 |
emit "\t"; |
| 715 |
emit_src src ) |
| 716 |
| I.FUNARY funOp => emit_funOp funOp |
| 717 |
| I.FUCOM operand => |
| 718 |
( emit "fucom\t"; |
| 719 |
emit_operand operand ) |
| 720 |
| I.FUCOMP operand => |
| 721 |
( emit "fucomp\t"; |
| 722 |
emit_operand operand ) |
| 723 |
| I.FUCOMPP => emit "fucompp" |
| 724 |
| I.FCOMPP => emit "fcompp" |
| 725 |
| I.FCOMI operand => |
| 726 |
( emit "fcomi\t"; |
| 727 |
emit_operand operand; |
| 728 |
emit ", %st" ) |
| 729 |
| I.FCOMIP operand => |
| 730 |
( emit "fcomip\t"; |
| 731 |
emit_operand operand; |
| 732 |
emit ", %st" ) |
| 733 |
| I.FUCOMI operand => |
| 734 |
( emit "fucomi\t"; |
| 735 |
emit_operand operand; |
| 736 |
emit ", %st" ) |
| 737 |
| I.FUCOMIP operand => |
| 738 |
( emit "fucomip\t"; |
| 739 |
emit_operand operand; |
| 740 |
emit ", %st" ) |
| 741 |
| I.FXCH{opnd} => |
| 742 |
( emit "fxch\t"; |
| 743 |
emitCell opnd ) |
| 744 |
| I.FSTPL operand => |
| 745 |
(case operand of |
| 746 |
I.ST _ => |
| 747 |
( emit "fstp\t"; |
| 748 |
emit_operand operand ) |
| 749 |
| _ => |
| 750 |
( emit "fstpl\t"; |
| 751 |
emit_operand operand ) |
| 752 |
) |
| 753 |
| I.FSTPS operand => |
| 754 |
( emit "fstps\t"; |
| 755 |
emit_operand operand ) |
| 756 |
| I.FSTPT operand => |
| 757 |
( emit "fstps\t"; |
| 758 |
emit_operand operand ) |
| 759 |
| I.FSTL operand => |
| 760 |
(case operand of |
| 761 |
I.ST _ => |
| 762 |
( emit "fst\t"; |
| 763 |
emit_operand operand ) |
| 764 |
| _ => |
| 765 |
( emit "fstl\t"; |
| 766 |
emit_operand operand ) |
| 767 |
) |
| 768 |
| I.FSTS operand => |
| 769 |
( emit "fsts\t"; |
| 770 |
emit_operand operand ) |
| 771 |
| I.FLD1 => emit "fld1" |
| 772 |
| I.FLDL2E => emit "fldl2e" |
| 773 |
| I.FLDL2T => emit "fldl2t" |
| 774 |
| I.FLDLG2 => emit "fldlg2" |
| 775 |
| I.FLDLN2 => emit "fldln2" |
| 776 |
| I.FLDPI => emit "fldpi" |
| 777 |
| I.FLDZ => emit "fldz" |
| 778 |
| I.FLDL operand => |
| 779 |
(case operand of |
| 780 |
I.ST _ => |
| 781 |
( emit "fld\t"; |
| 782 |
emit_operand operand ) |
| 783 |
| _ => |
| 784 |
( emit "fldl\t"; |
| 785 |
emit_operand operand ) |
| 786 |
) |
| 787 |
| I.FLDS operand => |
| 788 |
( emit "flds\t"; |
| 789 |
emit_operand operand ) |
| 790 |
| I.FLDT operand => |
| 791 |
( emit "fldt\t"; |
| 792 |
emit_operand operand ) |
| 793 |
| I.FILD operand => |
| 794 |
( emit "fild\t"; |
| 795 |
emit_operand operand ) |
| 796 |
| I.FILDL operand => |
| 797 |
( emit "fildl\t"; |
| 798 |
emit_operand operand ) |
| 799 |
| I.FILDLL operand => |
| 800 |
( emit "fildll\t"; |
| 801 |
emit_operand operand ) |
| 802 |
| I.FNSTSW => emit "fnstsw" |
| 803 |
| I.FENV{fenvOp, opnd} => |
| 804 |
( emit_fenvOp fenvOp; |
| 805 |
emit "\t"; |
| 806 |
emit_opnd opnd ) |
| 807 |
| I.FMOVE{fsize, src, dst} => |
| 808 |
( emit "fmove"; |
| 809 |
emit_fsize fsize; |
| 810 |
emit "\t"; |
| 811 |
emit_src src; |
| 812 |
emit ", "; |
| 813 |
emit_dst dst ) |
| 814 |
| I.FILOAD{isize, ea, dst} => |
| 815 |
( emit "fiload"; |
| 816 |
emit_isize isize; |
| 817 |
emit "\t"; |
| 818 |
emit_ea ea; |
| 819 |
emit ", "; |
| 820 |
emit_dst dst ) |
| 821 |
| I.FBINOP{fsize, binOp, lsrc, rsrc, dst} => |
| 822 |
( emit_fbinOp binOp; |
| 823 |
emit_fsize fsize; |
| 824 |
emit "\t"; |
| 825 |
emit_lsrc lsrc; |
| 826 |
emit ", "; |
| 827 |
emit_rsrc rsrc; |
| 828 |
emit ", "; |
| 829 |
emit_dst dst ) |
| 830 |
| I.FIBINOP{isize, binOp, lsrc, rsrc, dst} => |
| 831 |
( emit_fibinOp binOp; |
| 832 |
emit_isize isize; |
| 833 |
emit "\t"; |
| 834 |
emit_lsrc lsrc; |
| 835 |
emit ", "; |
| 836 |
emit_rsrc rsrc; |
| 837 |
emit ", "; |
| 838 |
emit_dst dst ) |
| 839 |
| I.FUNOP{fsize, unOp, src, dst} => |
| 840 |
( emit_funOp unOp; |
| 841 |
emit_fsize fsize; |
| 842 |
emit "\t"; |
| 843 |
emit_src src; |
| 844 |
emit ", "; |
| 845 |
emit_dst dst ) |
| 846 |
| I.FCMP{i, fsize, lsrc, rsrc} => |
| 847 |
( (if i |
| 848 |
then (emit "fcmpi") |
| 849 |
else (emit "fcmp")); |
| 850 |
|
| 851 |
( emit_fsize fsize; |
| 852 |
emit "\t"; |
| 853 |
emit_lsrc lsrc; |
| 854 |
emit ", "; |
| 855 |
emit_rsrc rsrc ) ) |
| 856 |
| I.SAHF => emit "sahf" |
| 857 |
| I.LFENCE => emit "lfence" |
| 858 |
| I.MFENCE => emit "mfence" |
| 859 |
| I.SFENCE => emit "sfence" |
| 860 |
| I.PAUSE => emit "pause" |
| 861 |
| I.LAHF => emit "lahf" |
| 862 |
| I.SOURCE{} => emit "source" |
| 863 |
| I.SINK{} => emit "sink" |
| 864 |
| I.PHI{} => emit "phi" |
| 865 |
) |
| 866 |
in tab(); emitInstr' instr; nl() |
| 867 |
end (* emitter *) |
| 868 |
and emitInstrIndented i = (indent(); emitInstr i; nl()) |
| 869 |
and emitInstrs instrs = |
| 870 |
app (if !indent_copies then emitInstrIndented |
| 871 |
else emitInstr) instrs |
| 872 |
|
| 873 |
and emitInstr(I.ANNOTATION{i,a}) = |
| 874 |
( comment(Annotations.toString a); |
| 875 |
nl(); |
| 876 |
emitInstr i ) |
| 877 |
| emitInstr(I.LIVE{regs, spilled}) = |
| 878 |
comment("live= " ^ CellsBasis.CellSet.toString regs ^ |
| 879 |
"spilled= " ^ CellsBasis.CellSet.toString spilled) |
| 880 |
| emitInstr(I.KILL{regs, spilled}) = |
| 881 |
comment("killed:: " ^ CellsBasis.CellSet.toString regs ^ |
| 882 |
"spilled:: " ^ CellsBasis.CellSet.toString spilled) |
| 883 |
| emitInstr(I.INSTR i) = emitter i |
| 884 |
| emitInstr(I.COPY{k=CellsBasis.GP, sz, src, dst, tmp}) = |
| 885 |
emitInstrs(Shuffle.shuffle{tmp=tmp, src=src, dst=dst}) |
| 886 |
| emitInstr(I.COPY{k=CellsBasis.FP, sz, src, dst, tmp}) = |
| 887 |
emitInstrs(Shuffle.shufflefp{tmp=tmp, src=src, dst=dst}) |
| 888 |
| emitInstr _ = error "emitInstr" |
| 889 |
|
| 890 |
in S.STREAM{beginCluster=init, |
| 891 |
pseudoOp=pseudoOp, |
| 892 |
emit=emitInstr, |
| 893 |
endCluster=fail, |
| 894 |
defineLabel=defineLabel, |
| 895 |
entryLabel=entryLabel, |
| 896 |
comment=comment, |
| 897 |
exitBlock=doNothing, |
| 898 |
annotation=annotation, |
| 899 |
getAnnotations=getAnnotations |
| 900 |
} |
| 901 |
end |
| 902 |
end |
| 903 |
|