| 1 |
(* |
| 2 |
* WARNING: This file was automatically generated by MDLGen (v3.1) |
| 3 |
* from the machine description file "hppa/hppa.mdl". |
| 4 |
* DO NOT EDIT this file directly |
| 5 |
*) |
| 6 |
|
| 7 |
|
| 8 |
functor HppaMCEmitter(structure Instr : HPPAINSTR |
| 9 |
structure MLTreeEval : MLTREE_EVAL (* where T = Instr.T *) |
| 10 |
where type T.Basis.cond = Instr.T.Basis.cond |
| 11 |
and type T.Basis.div_rounding_mode = Instr.T.Basis.div_rounding_mode |
| 12 |
and type T.Basis.ext = Instr.T.Basis.ext |
| 13 |
and type T.Basis.fcond = Instr.T.Basis.fcond |
| 14 |
and type T.Basis.rounding_mode = Instr.T.Basis.rounding_mode |
| 15 |
and type T.Constant.const = Instr.T.Constant.const |
| 16 |
and type ('s,'r,'f,'c) T.Extension.ccx = ('s,'r,'f,'c) Instr.T.Extension.ccx |
| 17 |
and type ('s,'r,'f,'c) T.Extension.fx = ('s,'r,'f,'c) Instr.T.Extension.fx |
| 18 |
and type ('s,'r,'f,'c) T.Extension.rx = ('s,'r,'f,'c) Instr.T.Extension.rx |
| 19 |
and type ('s,'r,'f,'c) T.Extension.sx = ('s,'r,'f,'c) Instr.T.Extension.sx |
| 20 |
and type T.I.div_rounding_mode = Instr.T.I.div_rounding_mode |
| 21 |
and type T.Region.region = Instr.T.Region.region |
| 22 |
and type T.ccexp = Instr.T.ccexp |
| 23 |
and type T.fexp = Instr.T.fexp |
| 24 |
(* and type T.labexp = Instr.T.labexp *) |
| 25 |
and type T.mlrisc = Instr.T.mlrisc |
| 26 |
and type T.oper = Instr.T.oper |
| 27 |
and type T.rep = Instr.T.rep |
| 28 |
and type T.rexp = Instr.T.rexp |
| 29 |
and type T.stm = Instr.T.stm |
| 30 |
structure Stream : INSTRUCTION_STREAM |
| 31 |
structure CodeString : CODE_STRING |
| 32 |
) : INSTRUCTION_EMITTER = |
| 33 |
struct |
| 34 |
structure I = Instr |
| 35 |
structure C = I.C |
| 36 |
structure Constant = I.Constant |
| 37 |
structure T = I.T |
| 38 |
structure S = Stream |
| 39 |
structure P = S.P |
| 40 |
structure W = Word32 |
| 41 |
|
| 42 |
(* Hppa is big endian *) |
| 43 |
|
| 44 |
fun error msg = MLRiscErrorMsg.error("HppaMC",msg) |
| 45 |
fun makeStream _ = |
| 46 |
let infix && || << >> ~>> |
| 47 |
val op << = W.<< |
| 48 |
val op >> = W.>> |
| 49 |
val op ~>> = W.~>> |
| 50 |
val op || = W.orb |
| 51 |
val op && = W.andb |
| 52 |
val itow = W.fromInt |
| 53 |
fun emit_bool false = 0w0 : W.word |
| 54 |
| emit_bool true = 0w1 : W.word |
| 55 |
val emit_int = itow |
| 56 |
fun emit_word w = w |
| 57 |
fun emit_label l = itow(Label.addrOf l) |
| 58 |
fun emit_labexp le = itow(MLTreeEval.valueOf le) |
| 59 |
fun emit_const c = itow(Constant.valueOf c) |
| 60 |
val w32ToByte = Word8.fromLarge o Word32.toLarge |
| 61 |
val loc = ref 0 |
| 62 |
|
| 63 |
(* emit a byte *) |
| 64 |
fun eByte b = |
| 65 |
let val i = !loc in loc := i + 1; CodeString.update(i,b) end |
| 66 |
|
| 67 |
(* emit the low order byte of a word *) |
| 68 |
(* note: fromLargeWord strips the high order bits! *) |
| 69 |
fun eByteW w = |
| 70 |
let val i = !loc |
| 71 |
in loc := i + 1; CodeString.update(i, w32ToByte w) end |
| 72 |
|
| 73 |
fun doNothing _ = () |
| 74 |
fun fail _ = raise Fail "MCEmitter" |
| 75 |
fun getAnnotations () = error "getAnnotations" |
| 76 |
|
| 77 |
fun pseudoOp pOp = P.emitValue{pOp=pOp, loc= !loc,emit=eByte} |
| 78 |
|
| 79 |
fun init n = (CodeString.init n; loc := 0) |
| 80 |
|
| 81 |
|
| 82 |
fun eWord32 w = |
| 83 |
let val b8 = w |
| 84 |
val w = w >> 0wx8 |
| 85 |
val b16 = w |
| 86 |
val w = w >> 0wx8 |
| 87 |
val b24 = w |
| 88 |
val w = w >> 0wx8 |
| 89 |
val b32 = w |
| 90 |
in |
| 91 |
( eByteW b32; |
| 92 |
eByteW b24; |
| 93 |
eByteW b16; |
| 94 |
eByteW b8 ) |
| 95 |
end |
| 96 |
fun emit_GP r = itow (CellsBasis.physicalRegisterNum r) |
| 97 |
and emit_FP r = itow (CellsBasis.physicalRegisterNum r) |
| 98 |
and emit_CR r = itow (CellsBasis.physicalRegisterNum r) |
| 99 |
and emit_CC r = itow (CellsBasis.physicalRegisterNum r) |
| 100 |
and emit_MEM r = itow (CellsBasis.physicalRegisterNum r) |
| 101 |
and emit_CTRL r = itow (CellsBasis.physicalRegisterNum r) |
| 102 |
and emit_CELLSET r = itow (CellsBasis.physicalRegisterNum r) |
| 103 |
fun emit_fmt (I.SGL) = (0wx0 : Word32.word) |
| 104 |
| emit_fmt (I.DBL) = (0wx1 : Word32.word) |
| 105 |
| emit_fmt (I.QUAD) = (0wx3 : Word32.word) |
| 106 |
and emit_loadi (I.LDW) = (0wx12 : Word32.word) |
| 107 |
| emit_loadi (I.LDH) = (0wx11 : Word32.word) |
| 108 |
| emit_loadi (I.LDB) = (0wx10 : Word32.word) |
| 109 |
and emit_store (I.STW) = (0wx1A : Word32.word) |
| 110 |
| emit_store (I.STH) = (0wx19 : Word32.word) |
| 111 |
| emit_store (I.STB) = (0wx18 : Word32.word) |
| 112 |
and emit_load (I.LDWX) = (0wx2, 0wx0, 0wx0) |
| 113 |
| emit_load (I.LDWX_S) = (0wx2, 0wx1, 0wx0) |
| 114 |
| emit_load (I.LDWX_M) = (0wx2, 0wx0, 0wx1) |
| 115 |
| emit_load (I.LDWX_SM) = (0wx2, 0wx1, 0wx1) |
| 116 |
| emit_load (I.LDHX) = (0wx1, 0wx0, 0wx0) |
| 117 |
| emit_load (I.LDHX_S) = (0wx1, 0wx1, 0wx0) |
| 118 |
| emit_load (I.LDHX_M) = (0wx1, 0wx0, 0wx1) |
| 119 |
| emit_load (I.LDHX_SM) = (0wx1, 0wx1, 0wx1) |
| 120 |
| emit_load (I.LDBX) = (0wx0, 0wx0, 0wx0) |
| 121 |
| emit_load (I.LDBX_M) = (0wx0, 0wx0, 0wx1) |
| 122 |
and emit_cmp (I.COMBT) = (0wx20 : Word32.word) |
| 123 |
| emit_cmp (I.COMBF) = (0wx22 : Word32.word) |
| 124 |
and emit_cmpi (I.COMIBT) = (0wx21 : Word32.word) |
| 125 |
| emit_cmpi (I.COMIBF) = (0wx23 : Word32.word) |
| 126 |
and emit_arith (I.ADD) = (0wx18 : Word32.word) |
| 127 |
| emit_arith (I.ADDL) = (0wx28 : Word32.word) |
| 128 |
| emit_arith (I.ADDO) = (0wx38 : Word32.word) |
| 129 |
| emit_arith (I.SH1ADD) = (0wx19 : Word32.word) |
| 130 |
| emit_arith (I.SH1ADDL) = (0wx29 : Word32.word) |
| 131 |
| emit_arith (I.SH1ADDO) = (0wx39 : Word32.word) |
| 132 |
| emit_arith (I.SH2ADD) = (0wx1A : Word32.word) |
| 133 |
| emit_arith (I.SH2ADDL) = (0wx2A : Word32.word) |
| 134 |
| emit_arith (I.SH2ADDO) = (0wx3A : Word32.word) |
| 135 |
| emit_arith (I.SH3ADD) = (0wx1B : Word32.word) |
| 136 |
| emit_arith (I.SH3ADDL) = (0wx2B : Word32.word) |
| 137 |
| emit_arith (I.SH3ADDO) = (0wx3B : Word32.word) |
| 138 |
| emit_arith (I.SUB) = (0wx10 : Word32.word) |
| 139 |
| emit_arith (I.SUBO) = (0wx30 : Word32.word) |
| 140 |
| emit_arith (I.OR) = (0wx9 : Word32.word) |
| 141 |
| emit_arith (I.XOR) = (0wxA : Word32.word) |
| 142 |
| emit_arith (I.AND) = (0wx8 : Word32.word) |
| 143 |
| emit_arith (I.ANDCM) = (0wx0 : Word32.word) |
| 144 |
and emit_arithi (I.ADDI) = (0wx2D, 0wx0) |
| 145 |
| emit_arithi (I.ADDIO) = (0wx2D, 0wx1) |
| 146 |
| emit_arithi (I.ADDIL) = error "ADDIL" |
| 147 |
| emit_arithi (I.SUBI) = (0wx25, 0wx0) |
| 148 |
| emit_arithi (I.SUBIO) = (0wx25, 0wx1) |
| 149 |
and emit_farith (I.FADD_S) = (0wx0, 0wx0) |
| 150 |
| emit_farith (I.FADD_D) = (0wx0, 0wx1) |
| 151 |
| emit_farith (I.FADD_Q) = (0wx0, 0wx3) |
| 152 |
| emit_farith (I.FSUB_S) = (0wx1, 0wx0) |
| 153 |
| emit_farith (I.FSUB_D) = (0wx1, 0wx1) |
| 154 |
| emit_farith (I.FSUB_Q) = (0wx1, 0wx3) |
| 155 |
| emit_farith (I.FMPY_S) = (0wx2, 0wx0) |
| 156 |
| emit_farith (I.FMPY_D) = (0wx2, 0wx1) |
| 157 |
| emit_farith (I.FMPY_Q) = (0wx2, 0wx3) |
| 158 |
| emit_farith (I.FDIV_S) = (0wx3, 0wx0) |
| 159 |
| emit_farith (I.FDIV_D) = (0wx3, 0wx1) |
| 160 |
| emit_farith (I.FDIV_Q) = (0wx3, 0wx3) |
| 161 |
| emit_farith (I.XMPYU) = error "XMPYU" |
| 162 |
and emit_funary (I.FCPY_S) = (0wx2, 0wx0) |
| 163 |
| emit_funary (I.FCPY_D) = (0wx2, 0wx1) |
| 164 |
| emit_funary (I.FCPY_Q) = (0wx2, 0wx3) |
| 165 |
| emit_funary (I.FABS_S) = (0wx3, 0wx0) |
| 166 |
| emit_funary (I.FABS_D) = (0wx3, 0wx1) |
| 167 |
| emit_funary (I.FABS_Q) = (0wx3, 0wx3) |
| 168 |
| emit_funary (I.FSQRT_S) = (0wx4, 0wx0) |
| 169 |
| emit_funary (I.FSQRT_D) = (0wx4, 0wx1) |
| 170 |
| emit_funary (I.FSQRT_Q) = (0wx4, 0wx3) |
| 171 |
| emit_funary (I.FRND_S) = (0wx5, 0wx0) |
| 172 |
| emit_funary (I.FRND_D) = (0wx5, 0wx1) |
| 173 |
| emit_funary (I.FRND_Q) = (0wx5, 0wx3) |
| 174 |
and emit_fcnv (I.FCNVFF_SD) = (0wx0, 0wx0, 0wx1) |
| 175 |
| emit_fcnv (I.FCNVFF_SQ) = (0wx0, 0wx0, 0wx3) |
| 176 |
| emit_fcnv (I.FCNVFF_DS) = (0wx0, 0wx1, 0wx0) |
| 177 |
| emit_fcnv (I.FCNVFF_DQ) = (0wx0, 0wx1, 0wx3) |
| 178 |
| emit_fcnv (I.FCNVFF_QS) = (0wx0, 0wx3, 0wx0) |
| 179 |
| emit_fcnv (I.FCNVFF_QD) = (0wx0, 0wx3, 0wx1) |
| 180 |
| emit_fcnv (I.FCNVXF_S) = (0wx1, 0wx0, 0wx0) |
| 181 |
| emit_fcnv (I.FCNVXF_D) = (0wx1, 0wx0, 0wx1) |
| 182 |
| emit_fcnv (I.FCNVXF_Q) = (0wx1, 0wx0, 0wx3) |
| 183 |
| emit_fcnv (I.FCNVFX_S) = (0wx2, 0wx0, 0wx0) |
| 184 |
| emit_fcnv (I.FCNVFX_D) = (0wx2, 0wx1, 0wx0) |
| 185 |
| emit_fcnv (I.FCNVFX_Q) = (0wx2, 0wx3, 0wx0) |
| 186 |
| emit_fcnv (I.FCNVFXT_S) = (0wx3, 0wx0, 0wx0) |
| 187 |
| emit_fcnv (I.FCNVFXT_D) = (0wx3, 0wx1, 0wx0) |
| 188 |
| emit_fcnv (I.FCNVFXT_Q) = (0wx3, 0wx3, 0wx0) |
| 189 |
and emit_fstorex (I.FSTDX) = (0wxB, 0wx0, 0wx0, 0wx0) |
| 190 |
| emit_fstorex (I.FSTDX_S) = (0wxB, 0wx0, 0wx1, 0wx0) |
| 191 |
| emit_fstorex (I.FSTDX_M) = (0wxB, 0wx0, 0wx0, 0wx1) |
| 192 |
| emit_fstorex (I.FSTDX_SM) = (0wxB, 0wx0, 0wx1, 0wx1) |
| 193 |
| emit_fstorex (I.FSTWX) = (0wx9, 0wx1, 0wx0, 0wx0) |
| 194 |
| emit_fstorex (I.FSTWX_S) = (0wx9, 0wx1, 0wx1, 0wx0) |
| 195 |
| emit_fstorex (I.FSTWX_M) = (0wx9, 0wx1, 0wx0, 0wx1) |
| 196 |
| emit_fstorex (I.FSTWX_SM) = (0wx9, 0wx1, 0wx1, 0wx1) |
| 197 |
and emit_floadx (I.FLDDX) = (0wxB, 0wx0, 0wx0, 0wx0) |
| 198 |
| emit_floadx (I.FLDDX_S) = (0wxB, 0wx0, 0wx1, 0wx0) |
| 199 |
| emit_floadx (I.FLDDX_M) = (0wxB, 0wx0, 0wx0, 0wx1) |
| 200 |
| emit_floadx (I.FLDDX_SM) = (0wxB, 0wx0, 0wx1, 0wx1) |
| 201 |
| emit_floadx (I.FLDWX) = (0wx9, 0wx1, 0wx0, 0wx0) |
| 202 |
| emit_floadx (I.FLDWX_S) = (0wx9, 0wx1, 0wx1, 0wx0) |
| 203 |
| emit_floadx (I.FLDWX_M) = (0wx9, 0wx1, 0wx0, 0wx1) |
| 204 |
| emit_floadx (I.FLDWX_SM) = (0wx9, 0wx1, 0wx1, 0wx1) |
| 205 |
and emit_bcond (I.EQ) = (0wx1 : Word32.word) |
| 206 |
| emit_bcond (I.LT) = (0wx2 : Word32.word) |
| 207 |
| emit_bcond (I.LE) = (0wx3 : Word32.word) |
| 208 |
| emit_bcond (I.LTU) = (0wx4 : Word32.word) |
| 209 |
| emit_bcond (I.LEU) = (0wx5 : Word32.word) |
| 210 |
| emit_bcond (I.NE) = error "NE" |
| 211 |
| emit_bcond (I.GE) = error "GE" |
| 212 |
| emit_bcond (I.GT) = error "GT" |
| 213 |
| emit_bcond (I.GTU) = error "GTU" |
| 214 |
| emit_bcond (I.GEU) = error "GEU" |
| 215 |
and emit_bitcond (I.BSET) = (0wx2 : Word32.word) |
| 216 |
| emit_bitcond (I.BCLR) = (0wx6 : Word32.word) |
| 217 |
and emit_fcond (I.False_) = (0wx0 : Word32.word) |
| 218 |
| emit_fcond (I.False) = (0wx1 : Word32.word) |
| 219 |
| emit_fcond (I.?) = (0wx2 : Word32.word) |
| 220 |
| emit_fcond (I.!<=>) = (0wx3 : Word32.word) |
| 221 |
| emit_fcond (I.==) = (0wx4 : Word32.word) |
| 222 |
| emit_fcond (I.EQT) = (0wx5 : Word32.word) |
| 223 |
| emit_fcond (I.?=) = (0wx6 : Word32.word) |
| 224 |
| emit_fcond (I.!<>) = (0wx7 : Word32.word) |
| 225 |
| emit_fcond (I.!?>=) = (0wx8 : Word32.word) |
| 226 |
| emit_fcond (I.<) = (0wx9 : Word32.word) |
| 227 |
| emit_fcond (I.?<) = (0wxA : Word32.word) |
| 228 |
| emit_fcond (I.!>=) = (0wxB : Word32.word) |
| 229 |
| emit_fcond (I.!?>) = (0wxC : Word32.word) |
| 230 |
| emit_fcond (I.<=) = (0wxD : Word32.word) |
| 231 |
| emit_fcond (I.?<=) = (0wxE : Word32.word) |
| 232 |
| emit_fcond (I.!>) = (0wxF : Word32.word) |
| 233 |
| emit_fcond (I.!?<=) = (0wx10 : Word32.word) |
| 234 |
| emit_fcond (I.>) = (0wx11 : Word32.word) |
| 235 |
| emit_fcond (I.?>) = (0wx12 : Word32.word) |
| 236 |
| emit_fcond (I.!<=) = (0wx13 : Word32.word) |
| 237 |
| emit_fcond (I.!?<) = (0wx14 : Word32.word) |
| 238 |
| emit_fcond (I.>=) = (0wx15 : Word32.word) |
| 239 |
| emit_fcond (I.?>=) = (0wx16 : Word32.word) |
| 240 |
| emit_fcond (I.!<) = (0wx17 : Word32.word) |
| 241 |
| emit_fcond (I.!?=) = (0wx18 : Word32.word) |
| 242 |
| emit_fcond (I.<>) = (0wx19 : Word32.word) |
| 243 |
| emit_fcond (I.!=) = (0wx1A : Word32.word) |
| 244 |
| emit_fcond (I.NET) = (0wx1B : Word32.word) |
| 245 |
| emit_fcond (I.!?) = (0wx1C : Word32.word) |
| 246 |
| emit_fcond (I.<=>) = (0wx1D : Word32.word) |
| 247 |
| emit_fcond (I.True_) = (0wx1E : Word32.word) |
| 248 |
| emit_fcond (I.True) = (0wx1F : Word32.word) |
| 249 |
fun Load {Op, b, t, im14} = |
| 250 |
let val b = emit_GP b |
| 251 |
val t = emit_GP t |
| 252 |
in eWord32 ((Op << 0wx1A) + ((b << 0wx15) + ((t << 0wx10) + (im14 && 0wx3FFF)))) |
| 253 |
end |
| 254 |
and Store {st, b, r, im14} = |
| 255 |
let val st = emit_store st |
| 256 |
val b = emit_GP b |
| 257 |
val r = emit_GP r |
| 258 |
in eWord32 ((st << 0wx1A) + ((b << 0wx15) + ((r << 0wx10) + (im14 && 0wx3FFF)))) |
| 259 |
end |
| 260 |
and IndexedLoad {Op, b, x, u, ext4, m, t} = |
| 261 |
let val b = emit_GP b |
| 262 |
val x = emit_GP x |
| 263 |
val t = emit_GP t |
| 264 |
in eWord32 ((Op << 0wx1A) + ((b << 0wx15) + ((x << 0wx10) + ((u << 0wxD) + ((ext4 << 0wx6) + ((m << 0wx5) + (t + 0wxC000))))))) |
| 265 |
end |
| 266 |
and ShortDispLoad {Op, b, im5, s, a, cc, ext4, m, t} = |
| 267 |
let val b = emit_GP b |
| 268 |
val t = emit_GP t |
| 269 |
in eWord32 ((Op << 0wx1A) + ((b << 0wx15) + (((im5 && 0wx1F) << 0wx10) + ((s << 0wxE) + ((a << 0wxD) + ((cc << 0wxA) + ((ext4 << 0wx6) + ((m << 0wx5) + (t + 0wx1000))))))))) |
| 270 |
end |
| 271 |
and ShoftDispShort {Op, b, r, s, a, cc, ext4, m, im5} = eWord32 ((Op << 0wx1A) + ((b << 0wx15) + ((r << 0wx10) + ((s << 0wxE) + ((a << 0wxD) + ((cc << 0wxA) + ((ext4 << 0wx6) + ((m << 0wx5) + ((im5 && 0wx1F) + 0wx1000))))))))) |
| 272 |
and LongImmed {Op, r, im21} = |
| 273 |
let val r = emit_GP r |
| 274 |
in eWord32 ((Op << 0wx1A) + ((r << 0wx15) + (im21 && 0wx1FFFFF))) |
| 275 |
end |
| 276 |
and Arith {r2, r1, a, t} = |
| 277 |
let val r2 = emit_GP r2 |
| 278 |
val r1 = emit_GP r1 |
| 279 |
val a = emit_arith a |
| 280 |
val t = emit_GP t |
| 281 |
in eWord32 ((r2 << 0wx15) + ((r1 << 0wx10) + ((a << 0wx6) + (t + 0wx8000000)))) |
| 282 |
end |
| 283 |
and Arithi {Op, r, t, e, im11} = |
| 284 |
let val r = emit_GP r |
| 285 |
val t = emit_GP t |
| 286 |
in eWord32 ((Op << 0wx1A) + ((r << 0wx15) + ((t << 0wx10) + ((e << 0wxB) + (im11 && 0wx7FF))))) |
| 287 |
end |
| 288 |
and Extract {Op, r, t, ext3, p, clen} = |
| 289 |
let val r = emit_GP r |
| 290 |
val t = emit_GP t |
| 291 |
val p = emit_int p |
| 292 |
val clen = emit_int clen |
| 293 |
in eWord32 ((Op << 0wx1A) + ((r << 0wx15) + ((t << 0wx10) + ((ext3 << 0wxA) + ((p << 0wx5) + clen))))) |
| 294 |
end |
| 295 |
and Deposit {Op, t, r, ext3, cp, clen} = |
| 296 |
let val t = emit_GP t |
| 297 |
val r = emit_GP r |
| 298 |
val cp = emit_int cp |
| 299 |
val clen = emit_int clen |
| 300 |
in eWord32 ((Op << 0wx1A) + ((t << 0wx15) + ((r << 0wx10) + ((ext3 << 0wxA) + ((cp << 0wx5) + clen))))) |
| 301 |
end |
| 302 |
and Shift {Op, r2, r1, ext3, cp, t} = |
| 303 |
let val r2 = emit_GP r2 |
| 304 |
val r1 = emit_GP r1 |
| 305 |
val t = emit_GP t |
| 306 |
in eWord32 ((Op << 0wx1A) + ((r2 << 0wx15) + ((r1 << 0wx10) + ((ext3 << 0wxA) + ((cp << 0wx5) + t))))) |
| 307 |
end |
| 308 |
and ConditionalBranch {Op, r2, r1, c, w1, n, w} = |
| 309 |
let val r2 = emit_GP r2 |
| 310 |
val r1 = emit_GP r1 |
| 311 |
val c = emit_bcond c |
| 312 |
val n = emit_bool n |
| 313 |
in eWord32 ((Op << 0wx1A) + ((r2 << 0wx15) + ((r1 << 0wx10) + ((c << 0wxD) + ((w1 << 0wx2) + ((n << 0wx1) + w)))))) |
| 314 |
end |
| 315 |
and ConditionalBranchi {Op, r2, im5, c, w1, n, w} = |
| 316 |
let val r2 = emit_GP r2 |
| 317 |
val c = emit_bcond c |
| 318 |
val n = emit_bool n |
| 319 |
in eWord32 ((Op << 0wx1A) + ((r2 << 0wx15) + ((im5 << 0wx10) + ((c << 0wxD) + ((w1 << 0wx2) + ((n << 0wx1) + w)))))) |
| 320 |
end |
| 321 |
and BranchExternal {Op, b, w1, s, w2, n, w} = |
| 322 |
let val b = emit_GP b |
| 323 |
val n = emit_bool n |
| 324 |
in eWord32 ((Op << 0wx1A) + ((b << 0wx15) + ((w1 << 0wx10) + ((s << 0wxD) + ((w2 << 0wx2) + ((n << 0wx1) + w)))))) |
| 325 |
end |
| 326 |
and BranchAndLink {Op, t, w1, ext3, w2, n, w} = |
| 327 |
let val t = emit_GP t |
| 328 |
val n = emit_bool n |
| 329 |
in eWord32 ((Op << 0wx1A) + ((t << 0wx15) + ((w1 << 0wx10) + ((ext3 << 0wxD) + ((w2 << 0wx2) + ((n << 0wx1) + w)))))) |
| 330 |
end |
| 331 |
and BranchVectored {Op, t, x, ext3, n} = |
| 332 |
let val t = emit_GP t |
| 333 |
val x = emit_GP x |
| 334 |
val n = emit_bool n |
| 335 |
in eWord32 ((Op << 0wx1A) + ((t << 0wx15) + ((x << 0wx10) + ((ext3 << 0wxD) + (n << 0wx1))))) |
| 336 |
end |
| 337 |
and Break {Op, im13, ext8, im5} = eWord32 ((Op << 0wx1A) + (((im13 && 0wx1FFF) << 0wxD) + ((ext8 << 0wx5) + (im5 && 0wx1F)))) |
| 338 |
and BranchOnBit {p, r, c, w1, n, w} = |
| 339 |
let val p = emit_int p |
| 340 |
val r = emit_GP r |
| 341 |
val n = emit_bool n |
| 342 |
in eWord32 ((p << 0wx15) + ((r << 0wx10) + ((c << 0wxD) + ((w1 << 0wx2) + ((n << 0wx1) + (w + 0wxC4000000)))))) |
| 343 |
end |
| 344 |
and MoveToControlReg {Op, t, r, rv, ext8} = |
| 345 |
let val t = emit_CR t |
| 346 |
val r = emit_GP r |
| 347 |
in eWord32 ((Op << 0wx1A) + ((t << 0wx15) + ((r << 0wx10) + ((rv << 0wxD) + (ext8 << 0wx5))))) |
| 348 |
end |
| 349 |
and CompareClear {r2, r1, c, f, ext, t} = |
| 350 |
let val r2 = emit_GP r2 |
| 351 |
val r1 = emit_GP r1 |
| 352 |
val t = emit_GP t |
| 353 |
in eWord32 ((r2 << 0wx15) + ((r1 << 0wx10) + ((c << 0wxD) + ((f << 0wxC) + ((ext << 0wx6) + (t + 0wx8000000)))))) |
| 354 |
end |
| 355 |
and CompareImmClear {r, t, c, f, im11} = |
| 356 |
let val r = emit_GP r |
| 357 |
val t = emit_GP t |
| 358 |
in eWord32 ((r << 0wx15) + ((t << 0wx10) + ((c << 0wxD) + ((f << 0wxC) + ((im11 && 0wx7FF) + 0wx90000000))))) |
| 359 |
end |
| 360 |
and CoProcShort {Op, b, im5, s, a, ls, uid, rt} = |
| 361 |
let val b = emit_GP b |
| 362 |
val rt = emit_FP rt |
| 363 |
in eWord32 ((Op << 0wx1A) + ((b << 0wx15) + ((im5 << 0wx10) + ((s << 0wxE) + ((a << 0wxD) + ((ls << 0wx9) + ((uid << 0wx6) + (rt + 0wx1000)))))))) |
| 364 |
end |
| 365 |
and CoProcIndexed {Op, b, x, s, u, ls, uid, m, rt} = |
| 366 |
let val b = emit_GP b |
| 367 |
val x = emit_GP x |
| 368 |
val rt = emit_FP rt |
| 369 |
in eWord32 ((Op << 0wx1A) + ((b << 0wx15) + ((x << 0wx10) + ((s << 0wxE) + ((u << 0wxD) + ((ls << 0wx9) + ((uid << 0wx6) + ((m << 0wx5) + rt)))))))) |
| 370 |
end |
| 371 |
and NOP {} = eWord32 0wx8000240 |
| 372 |
and Nop {nop} = (if nop |
| 373 |
then (NOP {}) |
| 374 |
else ()) |
| 375 |
and FloatOp0Maj0C {r, sop, fmt, t} = |
| 376 |
let val r = emit_FP r |
| 377 |
val t = emit_FP t |
| 378 |
in eWord32 ((r << 0wx15) + ((sop << 0wxD) + ((fmt << 0wxB) + (t + 0wx30000000)))) |
| 379 |
end |
| 380 |
and FloatOp1Maj0C {r, sop, df, sf, t} = |
| 381 |
let val r = emit_FP r |
| 382 |
val t = emit_FP t |
| 383 |
in eWord32 ((r << 0wx15) + ((sop << 0wxF) + ((df << 0wxD) + ((sf << 0wxB) + (t + 0wx30000200))))) |
| 384 |
end |
| 385 |
and FloatOp2Maj0C {r1, r2, sop, fmt, n, c} = |
| 386 |
let val r1 = emit_FP r1 |
| 387 |
val r2 = emit_FP r2 |
| 388 |
in eWord32 ((r1 << 0wx15) + ((r2 << 0wx10) + ((sop << 0wxD) + ((fmt << 0wxB) + ((n << 0wx5) + (c + 0wx30000400)))))) |
| 389 |
end |
| 390 |
and FloatOp3Maj0C {r1, r2, sop, fmt, n, t} = |
| 391 |
let val r1 = emit_FP r1 |
| 392 |
val r2 = emit_FP r2 |
| 393 |
val t = emit_FP t |
| 394 |
in eWord32 ((r1 << 0wx15) + ((r2 << 0wx10) + ((sop << 0wxD) + ((fmt << 0wxB) + ((n << 0wx5) + (t + 0wx30000600)))))) |
| 395 |
end |
| 396 |
and FloatOp0Maj0E {r, sop, fmt, r2, t2, t} = |
| 397 |
let val r = emit_FP r |
| 398 |
val t = emit_FP t |
| 399 |
in eWord32 ((r << 0wx15) + ((sop << 0wxD) + ((fmt << 0wxB) + ((r2 << 0wx7) + ((t2 << 0wx6) + (t + 0wx38000000)))))) |
| 400 |
end |
| 401 |
and FloatOp1Maj0E {r, sop, df, sf, r2, t2, t} = |
| 402 |
let val r = emit_FP r |
| 403 |
val t = emit_FP t |
| 404 |
in eWord32 ((r << 0wx15) + ((sop << 0wxF) + ((df << 0wxD) + ((sf << 0wxB) + ((r2 << 0wx7) + ((t2 << 0wx6) + (t + 0wx38000200))))))) |
| 405 |
end |
| 406 |
and FloatOp2Maj0E {r1, r2, sop, r22, f, r11, c} = |
| 407 |
let val r1 = emit_FP r1 |
| 408 |
val r2 = emit_FP r2 |
| 409 |
in eWord32 ((r1 << 0wx15) + ((r2 << 0wx10) + ((sop << 0wxD) + ((r22 << 0wxC) + ((f << 0wxB) + ((r11 << 0wx7) + (c + 0wx38000400))))))) |
| 410 |
end |
| 411 |
and FloatOp3Maj0E {r1, r2, sop, r22, f, r11, t} = |
| 412 |
let val r1 = emit_FP r1 |
| 413 |
val r2 = emit_FP r2 |
| 414 |
val t = emit_FP t |
| 415 |
in eWord32 ((r1 << 0wx15) + ((r2 << 0wx10) + ((sop << 0wxD) + ((r22 << 0wxC) + ((f << 0wxB) + ((r11 << 0wx7) + (t + 0wx38000600))))))) |
| 416 |
end |
| 417 |
and FloatMultiOp {rm1, rm2, ta, ra, f, tm} = eWord32 ((rm1 << 0wx15) + ((rm2 << 0wx10) + ((ta << 0wxB) + ((ra << 0wx6) + ((f << 0wx5) + (tm + 0wx38000000)))))) |
| 418 |
and FTest {} = eWord32 0wx30002420 |
| 419 |
|
| 420 |
(*#line 656.7 "hppa/hppa.mdl"*) |
| 421 |
val zeroR = Option.valOf (C.zeroReg CellsBasis.GP) |
| 422 |
|
| 423 |
(*#line 657.7 "hppa/hppa.mdl"*) |
| 424 |
fun opn opnd = |
| 425 |
let |
| 426 |
(*#line 658.11 "hppa/hppa.mdl"*) |
| 427 |
fun hi21 n = (itow n) >> 0wxB |
| 428 |
|
| 429 |
(*#line 659.11 "hppa/hppa.mdl"*) |
| 430 |
fun hi21X n = (itow n) ~>> 0wxB |
| 431 |
|
| 432 |
(*#line 660.11 "hppa/hppa.mdl"*) |
| 433 |
fun lo11 n = (itow n) && 0wx7FF |
| 434 |
in |
| 435 |
(case opnd of |
| 436 |
I.HILabExp(lexp, _) => hi21X (MLTreeEval.valueOf lexp) |
| 437 |
| I.LOLabExp(lexp, _) => lo11 (MLTreeEval.valueOf lexp) |
| 438 |
| I.LabExp(lexp, _) => itow (MLTreeEval.valueOf lexp) |
| 439 |
| I.IMMED i => itow i |
| 440 |
| I.REG _ => error "REG" |
| 441 |
) |
| 442 |
end |
| 443 |
|
| 444 |
(*#line 671.6 "hppa/hppa.mdl"*) |
| 445 |
fun disp lab = (itow (((Label.addrOf lab) - ( ! loc)) - 8)) ~>> 0wx2 |
| 446 |
|
| 447 |
(*#line 672.6 "hppa/hppa.mdl"*) |
| 448 |
fun low_sign_ext_im14 n = ((n && 0wx1FFF) << 0wx1) || ((n && 0wx2000) >> 0wxD) |
| 449 |
|
| 450 |
(*#line 673.6 "hppa/hppa.mdl"*) |
| 451 |
fun low_sign_ext_im11 n = ((n && 0wx3FF) << 0wx1) || ((n && 0wx400) >> 0wxA) |
| 452 |
|
| 453 |
(*#line 674.6 "hppa/hppa.mdl"*) |
| 454 |
fun low_sign_ext_im5 n = ((n && 0wxF) << 0wx1) || ((n && 0wx10) >> 0wx4) |
| 455 |
|
| 456 |
(*#line 676.6 "hppa/hppa.mdl"*) |
| 457 |
fun assemble_3 n = |
| 458 |
let |
| 459 |
(*#line 677.10 "hppa/hppa.mdl"*) |
| 460 |
val w1 = (n && 0wx4) >> 0wx2 |
| 461 |
|
| 462 |
(*#line 678.10 "hppa/hppa.mdl"*) |
| 463 |
val w2 = (n && 0wx3) << 0wx1 |
| 464 |
in w1 || w2 |
| 465 |
end |
| 466 |
|
| 467 |
(*#line 681.6 "hppa/hppa.mdl"*) |
| 468 |
fun assemble_12 n = |
| 469 |
let |
| 470 |
(*#line 682.10 "hppa/hppa.mdl"*) |
| 471 |
val w = (n && 0wx800) >> 0wxB |
| 472 |
|
| 473 |
(*#line 683.10 "hppa/hppa.mdl"*) |
| 474 |
val w1 = ((n && 0wx3FF) << 0wx1) || ((n && 0wx400) >> 0wxA) |
| 475 |
in (w1, w) |
| 476 |
end |
| 477 |
|
| 478 |
(*#line 686.6 "hppa/hppa.mdl"*) |
| 479 |
fun assemble_17 n = |
| 480 |
let |
| 481 |
(*#line 687.10 "hppa/hppa.mdl"*) |
| 482 |
val w = (n && 0wx10000) >> 0wx10 |
| 483 |
|
| 484 |
(*#line 688.10 "hppa/hppa.mdl"*) |
| 485 |
val w1 = (n && 0wxF800) >> 0wxB |
| 486 |
|
| 487 |
(*#line 689.10 "hppa/hppa.mdl"*) |
| 488 |
val w2 = ((n && 0wx3FF) << 0wx1) || ((n && 0wx400) >> 0wxA) |
| 489 |
in (w, w1, w2) |
| 490 |
end |
| 491 |
|
| 492 |
(*#line 692.6 "hppa/hppa.mdl"*) |
| 493 |
fun assemble_21 disp = |
| 494 |
let |
| 495 |
(*#line 693.10 "hppa/hppa.mdl"*) |
| 496 |
val w = (((((disp && 0wx3) << 0wxC) || ((disp && 0wx7C) << 0wxE)) || ((disp && 0wx180) << 0wx7)) || ((disp && 0wxFFE00) >> 0wx8)) || ((disp && 0wx100000) >> 0wx14) |
| 497 |
in w |
| 498 |
end |
| 499 |
|
| 500 |
(*#line 701.6 "hppa/hppa.mdl"*) |
| 501 |
fun branchLink (Op, t, lab, ext3, n) = |
| 502 |
let |
| 503 |
(*#line 702.10 "hppa/hppa.mdl"*) |
| 504 |
val (w, w1, w2) = assemble_17 (disp lab) |
| 505 |
in BranchAndLink {Op=Op, t=t, w1=w1, w2=w2, w=w, ext3=ext3, n=n} |
| 506 |
end |
| 507 |
|
| 508 |
(*#line 705.6 "hppa/hppa.mdl"*) |
| 509 |
fun bcond (cmp, bc, r1, r2, n, t, nop) = |
| 510 |
let |
| 511 |
(*#line 706.10 "hppa/hppa.mdl"*) |
| 512 |
val (w1, w) = assemble_12 (disp t) |
| 513 |
in ConditionalBranch {Op=emit_cmp cmp, c=bc, r1=r1, r2=r2, n=n, w=w, |
| 514 |
w1=w1}; |
| 515 |
Nop {nop=nop} |
| 516 |
end |
| 517 |
|
| 518 |
(*#line 709.6 "hppa/hppa.mdl"*) |
| 519 |
fun bcondi (cmpi, bc, i, r2, n, t, nop) = |
| 520 |
let |
| 521 |
(*#line 710.10 "hppa/hppa.mdl"*) |
| 522 |
val (w1, w) = assemble_12 (disp t) |
| 523 |
in ConditionalBranchi {Op=emit_cmpi cmpi, c=bc, im5=low_sign_ext_im5 (itow i), |
| 524 |
r2=r2, n=n, w=w, w1=w1}; |
| 525 |
Nop {nop=nop} |
| 526 |
end |
| 527 |
|
| 528 |
(*#line 714.6 "hppa/hppa.mdl"*) |
| 529 |
fun branchOnBit (bc, r, p, n, t, nop) = |
| 530 |
let |
| 531 |
(*#line 715.10 "hppa/hppa.mdl"*) |
| 532 |
val (w1, w) = assemble_12 (disp t) |
| 533 |
in BranchOnBit {p=p, r=r, c=emit_bitcond bc, w1=w1, n=n, w=w}; |
| 534 |
Nop {nop=nop} |
| 535 |
end |
| 536 |
|
| 537 |
(*#line 719.6 "hppa/hppa.mdl"*) |
| 538 |
fun cmpCond cond = |
| 539 |
(case cond of |
| 540 |
I.EQ => (0wx1, 0wx0) |
| 541 |
| I.LT => (0wx2, 0wx0) |
| 542 |
| I.LE => (0wx3, 0wx0) |
| 543 |
| I.LTU => (0wx4, 0wx0) |
| 544 |
| I.LEU => (0wx5, 0wx0) |
| 545 |
| I.NE => (0wx1, 0wx1) |
| 546 |
| I.GE => (0wx2, 0wx1) |
| 547 |
| I.GT => (0wx3, 0wx1) |
| 548 |
| I.GTU => (0wx4, 0wx1) |
| 549 |
| I.GEU => (0wx5, 0wx1) |
| 550 |
) |
| 551 |
fun emitter instr = |
| 552 |
let |
| 553 |
fun emitInstr (I.LOADI{li, r, i, t, mem}) = Load {Op=emit_loadi li, b=r, |
| 554 |
im14=low_sign_ext_im14 (opn i), t=t} |
| 555 |
| emitInstr (I.LOAD{l, r1, r2, t, mem}) = |
| 556 |
let |
| 557 |
(*#line 819.18 "hppa/hppa.mdl"*) |
| 558 |
val (ext4, u, m) = emit_load l |
| 559 |
in IndexedLoad {Op=0wx3, b=r1, x=r2, ext4=ext4, u=u, t=t, m=m} |
| 560 |
end |
| 561 |
| emitInstr (I.STORE{st, b, d, r, mem}) = Store {st=st, b=b, im14=low_sign_ext_im14 (opn d), |
| 562 |
r=r} |
| 563 |
| emitInstr (I.ARITH{a, r1, r2, t}) = Arith {a=a, r1=r1, r2=r2, t=t} |
| 564 |
| emitInstr (I.ARITHI{ai, i, r, t}) = |
| 565 |
(case ai of |
| 566 |
I.ADDIL => LongImmed {Op=0wxA, r=r, im21=assemble_21 (opn i)} |
| 567 |
| _ => |
| 568 |
let |
| 569 |
(*#line 843.26 "hppa/hppa.mdl"*) |
| 570 |
val (Op, e) = emit_arithi ai |
| 571 |
in Arithi {Op=Op, r=r, t=t, im11=low_sign_ext_im11 (opn i), e=e} |
| 572 |
end |
| 573 |
) |
| 574 |
| emitInstr (I.COMCLR_LDO{cc, r1, r2, t1, i, b, t2}) = |
| 575 |
let |
| 576 |
(*#line 862.17 "hppa/hppa.mdl"*) |
| 577 |
val (c, f) = cmpCond cc |
| 578 |
in CompareClear {r1=r1, r2=r2, t=t1, c=c, f=f, ext=0wx22}; |
| 579 |
Load {Op=0wxD, b=b, im14=low_sign_ext_im14 (itow i), t=t2} |
| 580 |
end |
| 581 |
| emitInstr (I.COMICLR_LDO{cc, i1, r2, t1, i2, b, t2}) = |
| 582 |
let |
| 583 |
(*#line 877.17 "hppa/hppa.mdl"*) |
| 584 |
val (c, f) = cmpCond cc |
| 585 |
in CompareImmClear {r=r2, t=t1, c=c, f=f, im11=low_sign_ext_im11 (opn i1)}; |
| 586 |
Load {Op=0wxD, b=b, im14=low_sign_ext_im14 (itow i2), t=t2} |
| 587 |
end |
| 588 |
| emitInstr (I.SHIFTV{sv, r, len, t}) = |
| 589 |
(case sv of |
| 590 |
I.VEXTRU => Extract {Op=0wx34, r=r, t=t, ext3=0wx4, p=0, clen=32 - len} |
| 591 |
| I.VEXTRS => Extract {Op=0wx34, r=r, t=t, ext3=0wx5, p=0, clen=32 - len} |
| 592 |
| I.ZVDEP => Deposit {Op=0wx35, t=t, r=r, ext3=0wx0, cp=0, clen=32 - len} |
| 593 |
) |
| 594 |
| emitInstr (I.SHIFT{s, r, p, len, t}) = |
| 595 |
(case s of |
| 596 |
I.EXTRU => Extract {Op=0wx34, r=r, t=t, ext3=0wx6, p=p, clen=32 - len} |
| 597 |
| I.EXTRS => Extract {Op=0wx34, r=r, t=t, ext3=0wx7, p=p, clen=32 - len} |
| 598 |
| I.ZDEP => Deposit {Op=0wx35, t=t, r=r, ext3=0wx2, cp=31 - p, clen=32 - len} |
| 599 |
) |
| 600 |
| emitInstr (I.BCOND{cmp, bc, r1, r2, n, nop, t, f}) = bcond (cmp, bc, |
| 601 |
r1, r2, n, t, nop) |
| 602 |
| emitInstr (I.BCONDI{cmpi, bc, i, r2, n, nop, t, f}) = bcondi (cmpi, |
| 603 |
bc, i, r2, n, t, nop) |
| 604 |
| emitInstr (I.BB{bc, r, p, n, nop, t, f}) = branchOnBit (bc, r, p, n, |
| 605 |
t, nop) |
| 606 |
| emitInstr (I.B{lab, n}) = branchLink (0wx3A, zeroR, lab, 0wx0, n) |
| 607 |
| emitInstr (I.LONGJUMP{lab, n, tmp, tmpLab}) = |
| 608 |
let |
| 609 |
(*#line 975.18 "hppa/hppa.mdl"*) |
| 610 |
val offset = T.SUB (32, T.LABEL lab, T.ADD (32, T.LABEL tmpLab, |
| 611 |
T.LI (IntInf.fromInt 4))) |
| 612 |
in Label.setAddr (tmpLab, ( ! loc) + 4); |
| 613 |
branchLink (0wx3A, tmp, tmpLab, 0wx0, n); |
| 614 |
LongImmed {Op=0wxA, r=tmp, im21=assemble_21 (itow (MLTreeEval.valueOf offset))}; |
| 615 |
BranchVectored {Op=0wx3A, t=tmp, x=zeroR, ext3=0wx6, n=n} |
| 616 |
end |
| 617 |
| emitInstr (I.BE{b, d, sr, n, labs}) = |
| 618 |
let |
| 619 |
(*#line 992.18 "hppa/hppa.mdl"*) |
| 620 |
val (w, w1, w2) = assemble_17 (opn d) |
| 621 |
in BranchExternal {Op=0wx38, b=b, w1=w1, s=assemble_3 (itow sr), w2=w2, |
| 622 |
n=n, w=w} |
| 623 |
end |
| 624 |
| emitInstr (I.BV{x, b, labs, n}) = BranchVectored {Op=0wx3A, t=b, x=x, |
| 625 |
ext3=0wx6, n=n} |
| 626 |
| emitInstr (I.BLR{x, t, labs, n}) = BranchVectored {Op=0wx3A, t=t, x=x, |
| 627 |
ext3=0wx2, n=n} |
| 628 |
| emitInstr (I.BL{lab, t, defs, uses, cutsTo, mem, n}) = branchLink (0wx3A, |
| 629 |
t, lab, 0wx0, n) |
| 630 |
| emitInstr (I.BLE{d, b, sr, t, defs, uses, cutsTo, mem}) = |
| 631 |
(case (d, CellsBasis.registerId t) of |
| 632 |
(I.IMMED 0, 31) => BranchExternal {Op=0wx39, b=b, w1=0wx0, s=assemble_3 (itow sr), |
| 633 |
w2=0wx0, n=true, w=0wx0} |
| 634 |
| _ => error "BLE: not implemented" |
| 635 |
) |
| 636 |
| emitInstr (I.LDIL{i, t}) = LongImmed {Op=0wx8, r=t, im21=assemble_21 (opn i)} |
| 637 |
| emitInstr (I.LDO{i, b, t}) = Load {Op=0wxD, b=b, im14=low_sign_ext_im14 (opn i), |
| 638 |
t=t} |
| 639 |
| emitInstr (I.MTCTL{r, t}) = MoveToControlReg {Op=0wx0, t=t, r=r, rv=0wx0, |
| 640 |
ext8=0wxC2} |
| 641 |
| emitInstr (I.FSTORE{fst, b, d, r, mem}) = |
| 642 |
(case fst of |
| 643 |
I.FSTDS => CoProcShort {Op=0wxB, b=b, im5=low_sign_ext_im5 (itow d), |
| 644 |
s=0wx0, a=0wx0, ls=0wx1, uid=0wx0, rt=r} |
| 645 |
| I.FSTWS => CoProcShort {Op=0wx9, b=b, im5=low_sign_ext_im5 (itow d), |
| 646 |
s=0wx0, a=0wx0, ls=0wx1, uid=0wx1, rt=r} |
| 647 |
) |
| 648 |
| emitInstr (I.FSTOREX{fstx, b, x, r, mem}) = |
| 649 |
let |
| 650 |
(*#line 1076.18 "hppa/hppa.mdl"*) |
| 651 |
val (Op, uid, u, m) = emit_fstorex fstx |
| 652 |
in CoProcIndexed {Op=Op, b=b, x=x, s=0wx0, u=u, m=m, ls=0wx1, uid=uid, |
| 653 |
rt=r} |
| 654 |
end |
| 655 |
| emitInstr (I.FLOAD{fl, b, d, t, mem}) = |
| 656 |
(case fl of |
| 657 |
I.FLDDS => CoProcShort {Op=0wxB, b=b, im5=low_sign_ext_im5 (itow d), |
| 658 |
s=0wx0, a=0wx0, ls=0wx0, uid=0wx0, rt=t} |
| 659 |
| I.FLDWS => CoProcShort {Op=0wx9, b=b, im5=low_sign_ext_im5 (itow d), |
| 660 |
s=0wx0, a=0wx0, ls=0wx0, uid=0wx1, rt=t} |
| 661 |
) |
| 662 |
| emitInstr (I.FLOADX{flx, b, x, t, mem}) = |
| 663 |
let |
| 664 |
(*#line 1096.18 "hppa/hppa.mdl"*) |
| 665 |
val (Op, uid, u, m) = emit_floadx flx |
| 666 |
in CoProcIndexed {Op=Op, b=b, x=x, s=0wx0, u=u, m=m, ls=0wx0, uid=uid, |
| 667 |
rt=t} |
| 668 |
end |
| 669 |
| emitInstr (I.FARITH{fa, r1, r2, t}) = |
| 670 |
(case fa of |
| 671 |
I.XMPYU => FloatOp3Maj0E {sop=0wx2, f=0wx1, r1=r1, r2=r2, t=t, r11=0wx0, |
| 672 |
r22=0wx0} |
| 673 |
| _ => |
| 674 |
let |
| 675 |
(*#line 1107.25 "hppa/hppa.mdl"*) |
| 676 |
val (sop, fmt) = emit_farith fa |
| 677 |
in FloatOp3Maj0C {sop=sop, r1=r1, r2=r2, t=t, n=0wx0, fmt=fmt} |
| 678 |
end |
| 679 |
) |
| 680 |
| emitInstr (I.FUNARY{fu, f, t}) = |
| 681 |
let |
| 682 |
(*#line 1124.18 "hppa/hppa.mdl"*) |
| 683 |
val (sop, fmt) = emit_funary fu |
| 684 |
in FloatOp0Maj0C {r=f, t=t, sop=sop, fmt=fmt} |
| 685 |
end |
| 686 |
| emitInstr (I.FCNV{fcnv, f, t}) = |
| 687 |
let |
| 688 |
(*#line 1133.18 "hppa/hppa.mdl"*) |
| 689 |
val (sop, sf, df) = emit_fcnv fcnv |
| 690 |
in FloatOp1Maj0E {r=f, t=t, sop=sop, sf=sf, df=df, r2=0wx1, t2=0wx0} |
| 691 |
end |
| 692 |
| emitInstr (I.FBRANCH{cc, fmt, f1, f2, t, f, n, long}) = |
| 693 |
( FloatOp2Maj0C {r1=f1, r2=f2, sop=0wx0, fmt=emit_fmt fmt, n=0wx0, c=emit_fcond cc}; |
| 694 |
FTest {}; |
| 695 |
branchLink (0wx3A, zeroR, t, 0wx0, n)) |
| 696 |
| emitInstr (I.BREAK{code1, code2}) = error "BREAK" |
| 697 |
| emitInstr (I.NOP) = NOP {} |
| 698 |
| emitInstr (I.SOURCE{}) = () |
| 699 |
| emitInstr (I.SINK{}) = () |
| 700 |
| emitInstr (I.PHI{}) = () |
| 701 |
in |
| 702 |
emitInstr instr |
| 703 |
end |
| 704 |
|
| 705 |
fun emitInstruction(I.ANNOTATION{i, ...}) = emitInstruction(i) |
| 706 |
| emitInstruction(I.INSTR(i)) = emitter(i) |
| 707 |
| emitInstruction(I.LIVE _) = () |
| 708 |
| emitInstruction(I.KILL _) = () |
| 709 |
| emitInstruction _ = error "emitInstruction" |
| 710 |
|
| 711 |
in S.STREAM{beginCluster=init, |
| 712 |
pseudoOp=pseudoOp, |
| 713 |
emit=emitInstruction, |
| 714 |
endCluster=fail, |
| 715 |
defineLabel=doNothing, |
| 716 |
entryLabel=doNothing, |
| 717 |
comment=doNothing, |
| 718 |
exitBlock=doNothing, |
| 719 |
annotation=doNothing, |
| 720 |
getAnnotations=getAnnotations |
| 721 |
} |
| 722 |
end |
| 723 |
end |
| 724 |
|