| 1 |
(* |
| 2 |
* This is the machine description file of PowerPC derived from Lal's code. |
| 3 |
* I have no idea what the instructions do so it probably won't work. |
| 4 |
* |
| 5 |
* Note: I've now added lots of instructions for 64-bit and single precision |
| 6 |
* floating point support. |
| 7 |
* |
| 8 |
* I'm using Book E: PowerPC Architecture Enhanced for Embedded Applications |
| 9 |
* as the reference |
| 10 |
* |
| 11 |
* -- Allen |
| 12 |
*) |
| 13 |
|
| 14 |
architecture PPC = |
| 15 |
struct |
| 16 |
|
| 17 |
superscalar |
| 18 |
|
| 19 |
big endian |
| 20 |
|
| 21 |
lowercase assembly |
| 22 |
|
| 23 |
storage |
| 24 |
GP = $r[32] of 64 bits asm: ( |
| 25 |
fn (r,_) => if !PPCAsmSyntax.ibm_syntax |
| 26 |
then Int.toString r |
| 27 |
else "r"^Int.toString r) |
| 28 |
| FP = $f[32] of 64 bits asm: ( |
| 29 |
fn (f,_) => if !PPCAsmSyntax.ibm_syntax |
| 30 |
then Int.toString f |
| 31 |
else "f"^Int.toString r) |
| 32 |
| CC = $cc[8] of 4 bits asm: (fn (cr,_) => "cr"^Int.toString cr) |
| 33 |
| SPR = $spr[32] of 64 bits |
| 34 |
asm: (fn (1,_) => "xer" |
| 35 |
| (8,_) => "lr" |
| 36 |
| (9,_) => "ctr" |
| 37 |
| (r,_) => Int.toString r |
| 38 |
) |
| 39 |
| MEM = $m[] of 8 aggregable bits asm: (fn (r,_) => "m"^Int.toString r) |
| 40 |
| CTRL = $ctrl[] of 8 bits asm: (fn (r,_) => "ctrl"^Int.toString r) |
| 41 |
|
| 42 |
locations |
| 43 |
stackptrR = $r[1] |
| 44 |
and asmTmpR = $r[28] |
| 45 |
and fasmTmp = $f[0] |
| 46 |
and r0 = $r[0] |
| 47 |
|
| 48 |
(* the encoding of these are from page 372 *) |
| 49 |
and xer = $spr[1] (* Integer exception register *) |
| 50 |
and lr = $spr[8] (* Link register *) |
| 51 |
and ctr = $spr[9] (* counter register *) |
| 52 |
|
| 53 |
structure RTL = |
| 54 |
struct |
| 55 |
end |
| 56 |
|
| 57 |
structure Instruction = |
| 58 |
struct |
| 59 |
type gpr = int (* general purpose register *) |
| 60 |
type fpr = int (* floating point register *) |
| 61 |
type ccr = int (* condition code register *) |
| 62 |
type crf = int (* condition register field *) |
| 63 |
|
| 64 |
datatype spr! = XER | LR | CTR |
| 65 |
|
| 66 |
datatype operand = |
| 67 |
RegOp of $GP ``<GP>'' (emit_GP GP) rtl: $r[GP] |
| 68 |
| ImmedOp of int ``<int>'' (itow int) rtl: immed int |
| 69 |
| LabelOp of T.labexp ``<emit_labexp labexp>'' |
| 70 |
(itow(MLTreeEval.valueOf labexp)) |
| 71 |
|
| 72 |
type addressing_mode = CellsBasis.cell * operand |
| 73 |
|
| 74 |
datatype ea = |
| 75 |
Direct of $GP |
| 76 |
| FDirect of $FP |
| 77 |
| Displace of {base: $GP, disp: T.labexp, mem: Region.region} |
| 78 |
|
| 79 |
(* Load/store operators that have the E suffix means that 64-bit |
| 80 |
* addressing is used. Note: the x suffix is implicitly added if rb is a |
| 81 |
* register. |
| 82 |
* |
| 83 |
* -- Allen |
| 84 |
*) |
| 85 |
|
| 86 |
|
| 87 |
datatype load! = LBZ (* load byte and zero *) |
| 88 |
| LBZE |
| 89 |
| LHZ (* load half word and zero *) |
| 90 |
| LHZE |
| 91 |
| LHA (* load half word algebraic *) |
| 92 |
| LHAE |
| 93 |
| LWZ (* load word and zero *) |
| 94 |
| LWZE |
| 95 |
| LDE (* load double word extended |
| 96 |
* Note: there is no LD or LDX!!! |
| 97 |
*) |
| 98 |
|
| 99 |
| LBZU |
| 100 |
| LHZU |
| 101 |
| LHAU |
| 102 |
| LWZU |
| 103 |
| LDZU |
| 104 |
|
| 105 |
datatype store! = STB |
| 106 |
| STBE |
| 107 |
| STH |
| 108 |
| STHE |
| 109 |
| STW |
| 110 |
| STWE |
| 111 |
| STDE |
| 112 |
|
| 113 |
| STBU |
| 114 |
| STHU |
| 115 |
| STWU |
| 116 |
| STDU |
| 117 |
|
| 118 |
datatype fload! = LFS |
| 119 |
| LFSE |
| 120 |
| LFD |
| 121 |
| LFDE |
| 122 |
|
| 123 |
| LFSU |
| 124 |
| LFDU |
| 125 |
|
| 126 |
datatype fstore! = STFS |
| 127 |
| STFSE |
| 128 |
| STFD |
| 129 |
| STFDE |
| 130 |
|
| 131 |
| STFSU |
| 132 |
| STFDU |
| 133 |
|
| 134 |
datatype cmp! = CMP | CMPL |
| 135 |
|
| 136 |
datatype fcmp! = FCMPO 0w32 (* ordered *) |
| 137 |
| FCMPU 0w0 (* unordered *) |
| 138 |
|
| 139 |
(* xo *) |
| 140 |
datatype unary! = NEG 0w104 |
| 141 |
| EXTSB 0w954 (* extend sign byte *) |
| 142 |
| EXTSH 0w922 (* extend sign halfword *) |
| 143 |
| EXTSW 0w986 (* extend sign word *) |
| 144 |
| CNTLZW 0w26 (* count leading zeros word *) |
| 145 |
| CNTLZD 0w58 (* count leading zeros double word *) |
| 146 |
|
| 147 |
|
| 148 |
(* opcd/xo *) |
| 149 |
datatype funary! = FMR (0w63,0w72) |
| 150 |
| FNEG (0w63,0w40) |
| 151 |
| FABS (0w63,0w264) |
| 152 |
| FNABS (0w63,0w136) |
| 153 |
| FSQRT (0w63,0w22) |
| 154 |
| FSQRTS (0w59,0w22) |
| 155 |
| FRSP (0w63,0w12) (* round to single precision *) |
| 156 |
| FCTIW (0w63,0w14) (* convert to integer word *) |
| 157 |
| FCTIWZ (0w63,0w15) (* convert to integer word *) |
| 158 |
| FCTID (0w63,0w814) (* convert to double word *) |
| 159 |
| FCTIDZ (0w63,0w815) (* convert to double word *) |
| 160 |
| FCFID (0w63,0w846) (* convert from double word *) |
| 161 |
|
| 162 |
(* opcd/xo *) |
| 163 |
datatype farith! = FADD (0w63,0w21) |
| 164 |
| FSUB (0w63,0w20) |
| 165 |
| FMUL (0w63,0w25) |
| 166 |
| FDIV (0w63,0w18) |
| 167 |
| FADDS (0w59,0w21) |
| 168 |
| FSUBS (0w59,0w20) |
| 169 |
| FMULS (0w59,0w25) |
| 170 |
| FDIVS (0w59,0w18) |
| 171 |
|
| 172 |
(* opcd, xo *) |
| 173 |
datatype farith3! = FMADD (0w63,0w29) |
| 174 |
| FMADDS (0w59,0w29) |
| 175 |
| FMSUB (0w63,0w28) |
| 176 |
| FMSUBS (0w59,0w28) |
| 177 |
| FNMADD (0w63,0w31) |
| 178 |
| FNMADDS (0w59,0w31) |
| 179 |
| FNMSUB (0w63,0w30) |
| 180 |
| FNMSUBS (0w59,0w30) |
| 181 |
| FSEL (0w63,0w23) (* floating point select *) |
| 182 |
|
| 183 |
datatype bo = |
| 184 |
TRUE 0wb01100 (* 011zy *) |
| 185 |
| FALSE 0wb00100 (* 001zy *) |
| 186 |
| ALWAYS 0wb10100 (* 1z1zz *) |
| 187 |
| COUNTER of {eqZero:bool, cond:bool option} |
| 188 |
(case cond of |
| 189 |
NONE => if eqZero then 0wb10010 (* 1z01y *) |
| 190 |
else 0wb10000 (* 1z00y *) |
| 191 |
| SOME cc => case (eqZero,cc) of |
| 192 |
(false,false) => 0wb00000 (* 0000y *) |
| 193 |
| (false,true) => 0wb01000 (* 0100y *) |
| 194 |
| (true,false) => 0wb00010 (* 0001y *) |
| 195 |
| (true,true) => 0wb01010 (* 0101y *) |
| 196 |
) |
| 197 |
|
| 198 |
(* operation ARITH ARITHI *) |
| 199 |
datatype arith! = (* --------- ----- ------ *) |
| 200 |
(* xo *) |
| 201 |
ADD 0w266 (* add add addi *) |
| 202 |
| SUBF 0w40 (* subtract from subf subfic *) |
| 203 |
| MULLW 0w235 (* multiply mullw mulli *) |
| 204 |
| MULLD 0w233 (* multiply double word mulld - *) |
| 205 |
| MULHW 0w75 (* multiply high word mulhw - *) |
| 206 |
| MULHWU 0w11 (* multiply high word unsigned mulhwu - *) |
| 207 |
| DIVW 0w491 (* divide word divw - *) |
| 208 |
| DIVD 0w489 (* divide doubleword divd - *) |
| 209 |
| DIVWU 0w459 (* divide word unsigned divwu - *) |
| 210 |
| DIVDU 0w457 (* divide doubleword unsigned divdu - *) |
| 211 |
| AND 0w28 (* and and andi *) |
| 212 |
| OR 0w444 (* or or ori *) |
| 213 |
| XOR 0w316 (* xor xor xori *) |
| 214 |
| NAND 0w476 (* nand *) |
| 215 |
| NOR 0w124 (* nor *) |
| 216 |
| EQV 0w284 (* eqv *) |
| 217 |
| ANDC 0w60 (* and with complement andc - *) |
| 218 |
| ORC 0w412 (* or with complement orc - *) |
| 219 |
| SLW 0w24 (* shift left word slw rlwinm *) |
| 220 |
| SLD 0w27 (* shift left double word sld rldinm *) |
| 221 |
| SRW 0w536 (* shift right word srw rlwinm *) |
| 222 |
| SRD 0w539 (* shift right double word srd rldinm *) |
| 223 |
| SRAW 0w792 (* shift right algebraic word sraw srawi *) |
| 224 |
| SRAD 0w794 (* shift right algebraic dword srad sradi *) |
| 225 |
|
| 226 |
datatype arithi! = (* --------- ----- ------ *) |
| 227 |
(* opcd *) |
| 228 |
ADDI 0w14 (* add add addi *) |
| 229 |
| ADDIS 0w15 (* add-shifted - addis *) |
| 230 |
| SUBFIC 0w8 (* subtract from subf subfic *) |
| 231 |
| MULLI 0w7 (* multiply mullw mulli *) |
| 232 |
| ANDI_Rc "andi." 0w28 (* and and andi *) |
| 233 |
| ANDIS_Rc "andis." 0w29(* and-shifted - andis *) |
| 234 |
| ORI 0w24 (* or or ori *) |
| 235 |
| ORIS 0w25 (* or-shifted - ori *) |
| 236 |
| XORI 0w26 (* xor xor xori *) |
| 237 |
| XORIS 0w27 (* xor-shifted - xoris *) |
| 238 |
(* |
| 239 |
| SLWI (* !!! *) (* shift left word slw rlwinm *) |
| 240 |
| SLDI (* !!! *) (* shift left double word sld rldinm *) |
| 241 |
| SRWI (* !!! *) (* shift right word srw rlwinm *) |
| 242 |
| SRDI (* !!! *) (* shift right double word srd rldinm *) |
| 243 |
*) |
| 244 |
| SRAWI (* shift right algebric word sraw srawi *) |
| 245 |
| SRADI (* shift right algebraic dword srad sradi *) |
| 246 |
|
| 247 |
(* !!! means that these are pseudo ops! *) |
| 248 |
|
| 249 |
datatype rotate! = |
| 250 |
(* opcd *) |
| 251 |
RLWNM (* rotate left word AND mask rlwnm rlwinm *) |
| 252 |
| RLDCL |
| 253 |
| RLDCR |
| 254 |
|
| 255 |
datatype rotatei! = |
| 256 |
RLWINM (* rotate left word AND mask rlwnm rlwinm *) |
| 257 |
| RLWIMI |
| 258 |
| RLDICL |
| 259 |
| RLDICR |
| 260 |
| RLDIC |
| 261 |
| RLDIMI |
| 262 |
|
| 263 |
datatype ccarith! = (* page 47-49 *) |
| 264 |
(* xo *) |
| 265 |
CRAND 0w257 (* cond. reg. AND *) |
| 266 |
| CROR 0w449 (* cond. reg. OR *) |
| 267 |
| CRXOR 0w193 (* cond. reg. XOR *) |
| 268 |
| CRNAND 0w225 (* cond. reg. NAND *) |
| 269 |
| CRNOR 0w33 (* cond. reg. NOR *) |
| 270 |
| CREQV 0w289 (* cond. reg. EQV *) |
| 271 |
| CRANDC 0w129 (* cond. reg. AND with complement *) |
| 272 |
| CRORC 0w417 (* cond. reg. OR with complement *) |
| 273 |
|
| 274 |
|
| 275 |
(* bits in condition code *) |
| 276 |
datatype bit! = |
| 277 |
LT "lt" | GT "gt" | EQ "eq" | SO "so" (* cr0 *) |
| 278 |
| FL "lt" | FG "gt" | FE "eq" | FU "un" (* cr1 *) |
| 279 |
(* Lal: as far as I can tell there don't seem to be mnemonics |
| 280 |
* for these, however using lt, gt, eq, so should fool |
| 281 |
* the assembler into looking at the right bits in the |
| 282 |
* cc field. Of course the bf field had better be cr1. |
| 283 |
*) |
| 284 |
| FX "lt" | FEX "gt" | VX "eq" | OX "so" |
| 285 |
|
| 286 |
(* bits in integer exception register *) |
| 287 |
datatype xerbit = SO64 (* summary overflow 64 *) |
| 288 |
| OV64 (* overflow 64 *) |
| 289 |
| CA64 (* carry 64 *) |
| 290 |
| SO32 (* summary overflow 32 bits *) |
| 291 |
| OV32 (* overflow 32 bits *) |
| 292 |
| CA32 (* carry 32 bits *) |
| 293 |
|
| 294 |
type cr_bit = $CC * bit |
| 295 |
end (* Instruction *) |
| 296 |
|
| 297 |
(* |
| 298 |
* The following describes the encoding of the instructions. |
| 299 |
*) |
| 300 |
instruction formats 32 bits |
| 301 |
|
| 302 |
(* primitives *) |
| 303 |
x_form{opcd:6,rt:5,ra:5,rb:5,xo:10,rc:bool 1} |
| 304 |
| xl_form{opcd:6,bt:5,ba:5,bb:5,xo:10,lk:bool 1} |
| 305 |
| m_form{opcd:6,rs:5,ra:5,rb:5,mb:5,me:5,rc:bool 1} |
| 306 |
| a_form{opcd:6,frt:5,fra:5,frb:5,frc:5,xo:5,rc:bool 1} |
| 307 |
|
| 308 |
(* integer loads *) |
| 309 |
| loadx{opcd:6=31,rt:GP 5,ra:GP 5,rb:GP 5,xop:10,rc:1=0} |
| 310 |
| loadd{opcd:6,rt:GP 5,ra:GP 5,d:operand signed 16} |
| 311 |
| loadde{opcd:6,rt:GP 5,ra:GP 5,de:operand signed 12,xop:4} |
| 312 |
|
| 313 |
| load{ld,rt,ra,d} = |
| 314 |
(case (d,ld) of |
| 315 |
(I.RegOp rb,I.LBZ) => loadx{rt,ra,rb,xop=0w87} (* lbzx *) |
| 316 |
| (I.RegOp rb,I.LBZE) => loadx{rt,ra,rb,xop=0w95} (* lbzxe *) |
| 317 |
| (I.RegOp rb,I.LHZ) => loadx{rt,ra,rb,xop=0w279} (* lhzx *) |
| 318 |
| (I.RegOp rb,I.LHZE) => loadx{rt,ra,rb,xop=0w287} (* lhzxe *) |
| 319 |
| (I.RegOp rb,I.LHA) => loadx{rt,ra,rb,xop=0w343} (* lhax *) |
| 320 |
| (I.RegOp rb,I.LHAE) => loadx{rt,ra,rb,xop=0w351} (* lhaxe *) |
| 321 |
| (I.RegOp rb,I.LWZ) => loadx{rt,ra,rb,xop=0w23} (* lwzx *) |
| 322 |
| (I.RegOp rb,I.LWZE) => loadx{rt,ra,rb,xop=0w31} (* lwzxe *) |
| 323 |
| (I.RegOp rb,I.LDE) => loadx{rt,ra,rb,xop=0w799} (* ldxe *) |
| 324 |
|
| 325 |
| (d,I.LBZ) => loadd{opcd=0w34,rt,ra,d} |
| 326 |
| (de,I.LBZE) => loadde{opcd=0w58,rt,ra,de,xop=0w0} |
| 327 |
| (d,I.LHZ) => loadd{opcd=0w40,rt,ra,d} |
| 328 |
| (de,I.LHZE) => loadde{opcd=0w58,rt,ra,de,xop=0w2} |
| 329 |
| (d,I.LHA) => loadd{opcd=0w42,rt,ra,d} |
| 330 |
| (de,I.LHAE) => loadde{opcd=0w58,rt,ra,de,xop=0w4} |
| 331 |
| (d,I.LWZ) => loadd{opcd=0w32,rt,ra,d} |
| 332 |
| (de,I.LWZE) => loadde{opcd=0w58,rt,ra,de,xop=0w6} |
| 333 |
| (de,I.LDE) => loadde{opcd=0w62,rt,ra,de,xop=0w0} |
| 334 |
|
| 335 |
| (I.RegOp rb,I.LHAU) => loadx{rt,ra,rb,xop=0w375} (* lhaux *) |
| 336 |
| (I.RegOp rb,I.LHZU) => loadx{rt,ra,rb,xop=0w311} (* lhzux *) |
| 337 |
| (I.RegOp rb,I.LWZU) => loadx{rt,ra,rb,xop=0w55} (* lwzux *) |
| 338 |
| (d,I.LHZU) => loadd{opcd=0w41,rt,ra,d} |
| 339 |
| (d,I.LWZU) => loadd{opcd=0w33,rt,ra,d} |
| 340 |
) |
| 341 |
|
| 342 |
(* floating point loads *) |
| 343 |
| floadx{opcd:6=31,ft:FP 5,ra:GP 5,rb:GP 5,xop:10,rc:1=0} |
| 344 |
| floadd{opcd:6,ft:FP 5,ra:GP 5,d:operand signed 16} |
| 345 |
| floadde{opcd:6,ft:FP 5,ra:GP 5,de:operand signed 12,xop:4} |
| 346 |
|
| 347 |
| fload{ld,ft,ra,d} = |
| 348 |
(case (d,ld) of |
| 349 |
(I.RegOp rb,I.LFS) => floadx{ft,ra,rb,xop=0w535} |
| 350 |
| (I.RegOp rb,I.LFSE) => floadx{ft,ra,rb,xop=0w543} |
| 351 |
| (I.RegOp rb,I.LFD) => floadx{ft,ra,rb,xop=0w599} |
| 352 |
| (I.RegOp rb,I.LFDE) => floadx{ft,ra,rb,xop=0w607} |
| 353 |
| (I.RegOp rb,I.LFDU) => floadx{ft,ra,rb,xop=0w631} |
| 354 |
| (d,I.LFS) => floadd{ft,ra,d,opcd=0w48} |
| 355 |
| (de,I.LFSE) => floadde{ft,ra,de,opcd=0w62,xop=0w4} |
| 356 |
| (d,I.LFD) => floadd{ft,ra,d,opcd=0w50} |
| 357 |
| (de,I.LFDE) => floadde{ft,ra,de,opcd=0w62,xop=0w6} |
| 358 |
| (d,I.LFDU) => floadd{ft,ra,d,opcd=0w51} |
| 359 |
) |
| 360 |
|
| 361 |
(* integer stores *) |
| 362 |
| storex{opcd:6=31,rs:GP 5,ra:GP 5,rb:GP 5,xop:10,rc:1=0} |
| 363 |
| stored{opcd:6,rs:GP 5,ra:GP 5,d:operand signed 16} |
| 364 |
| storede{opcd:6,rs:GP 5,ra:GP 5,de:operand signed 12,xop:4} |
| 365 |
|
| 366 |
| store{st,rs,ra,d} = |
| 367 |
(case (d,st) of |
| 368 |
(I.RegOp rb,I.STB) => storex{rs,ra,rb,xop=0w215} |
| 369 |
| (I.RegOp rb,I.STBE) => storex{rs,ra,rb,xop=0w223} |
| 370 |
| (I.RegOp rb,I.STH) => storex{rs,ra,rb,xop=0w407} |
| 371 |
| (I.RegOp rb,I.STHE) => storex{rs,ra,rb,xop=0w415} |
| 372 |
| (I.RegOp rb,I.STW) => storex{rs,ra,rb,xop=0w151} |
| 373 |
| (I.RegOp rb,I.STWE) => storex{rs,ra,rb,xop=0w159} |
| 374 |
| (I.RegOp rb,I.STDE) => storex{rs,ra,rb,xop=0w927} |
| 375 |
| (d,I.STB) => stored{rs,ra,d,opcd=0w38} |
| 376 |
| (de,I.STBE) => storede{rs,ra,de,opcd=0w58,xop=0w8} |
| 377 |
| (d,I.STH) => stored{rs,ra,d,opcd=0w44} |
| 378 |
| (de,I.STHE) => storede{rs,ra,de,opcd=0w58,xop=0w10} |
| 379 |
| (d,I.STW) => stored{rs,ra,d,opcd=0w36} |
| 380 |
| (de,I.STWE) => storede{rs,ra,de,opcd=0w58,xop=0w14} |
| 381 |
| (de,I.STDE) => storede{rs,ra,de,opcd=0w62,xop=0w8} |
| 382 |
) |
| 383 |
|
| 384 |
(* floating point stores *) |
| 385 |
| fstorex{opcd:6=31,fs:FP 5,ra:GP 5,rb:GP 5,xop:10,rc:1=0} |
| 386 |
| fstored{opcd:6,fs:FP 5,ra:GP 5,d:operand signed 16} |
| 387 |
| fstorede{opcd:6,fs:FP 5,ra:GP 5,de:operand signed 12,xop:4} |
| 388 |
|
| 389 |
| fstore{st,fs,ra,d} = |
| 390 |
(case (d,st) of |
| 391 |
(I.RegOp rb,I.STFS) => fstorex{fs,ra,rb,xop=0w663} |
| 392 |
| (I.RegOp rb,I.STFSE) => fstorex{fs,ra,rb,xop=0w671} |
| 393 |
| (I.RegOp rb,I.STFD) => fstorex{fs,ra,rb,xop=0w727} |
| 394 |
| (I.RegOp rb,I.STFDE) => fstorex{fs,ra,rb,xop=0w759} |
| 395 |
| (d,I.STFS) => fstored{fs,ra,d,opcd=0w52} |
| 396 |
| (de,I.STFSE) => fstorede{fs,ra,de,opcd=0w62,xop=0w12} |
| 397 |
| (d,I.STFD) => fstored{fs,ra,d,opcd=0w54} |
| 398 |
| (de,I.STFDE) => fstorede{fs,ra,de,opcd=0w62,xop=0w14} |
| 399 |
) |
| 400 |
|
| 401 |
(* integer arithmetic *) |
| 402 |
| unary'{opcd:6=31,ra:GP 5,rt:GP 5,_:5=0,OE:bool 1,oper:unary 9,Rc:bool 1} |
| 403 |
| unary{ra,rt,oper,OE,Rc} = |
| 404 |
(case oper of |
| 405 |
I.NEG => unary'{ra=rt,rt=ra,oper,OE,Rc} (* swapped! *) |
| 406 |
| _ => unary'{ra,rt,oper,OE,Rc} |
| 407 |
) |
| 408 |
| arith'{opcd:6=31,rt:GP 5,ra:GP 5,rb:GP 5,OE:bool 1,oper:arith 9,Rc:bool 1} |
| 409 |
| arithi'{oper:arithi 6,rt:GP 5,ra:GP 5,im:operand signed 16} |
| 410 |
| srawi{opcd:6=31,rs:GP 5,ra:GP 5,sh:operand signed 5,xop:10=824,Rc:1=0} |
| 411 |
| sradi'{opcd:6=31,rs:GP 5,ra:GP 5,sh:5,xop:9=0w413,sh2:1,Rc:1=0} |
| 412 |
| sradi{rs,ra,sh:operand signed 6} = |
| 413 |
sradi'{rs=rs,ra=ra,sh=(sh at [0..4]),sh2=sh at [5]} |
| 414 |
|
| 415 |
| arith{oper,rt,ra,rb,OE,Rc} = |
| 416 |
(case oper of |
| 417 |
(I.ADD | I.SUBF | I.MULLW | I.MULLD | I.MULHW | I.MULHWU | |
| 418 |
I.DIVW | I.DIVD | I.DIVWU | I.DIVDU) => |
| 419 |
arith'{oper,rt,ra,rb,OE,Rc} |
| 420 |
(* For some unknown reasons, the encoding of rt and ra |
| 421 |
* are swapped! |
| 422 |
*) |
| 423 |
| _ => arith'{oper,rt=ra,ra=rt,rb,OE,Rc} |
| 424 |
) |
| 425 |
|
| 426 |
| arithi{oper,rt,ra,im} = |
| 427 |
(case oper of |
| 428 |
(I.ADDI | I.ADDIS | I.SUBFIC | I.MULLI) => arithi'{oper,rt,ra,im} |
| 429 |
| I.SRAWI => srawi{rs=ra,ra=rt,sh=im} |
| 430 |
| I.SRADI => sradi{rs=ra,ra=rt,sh=im} |
| 431 |
(* For some unknown reasons, the encoding of rt and ra |
| 432 |
* are swapped! |
| 433 |
*) |
| 434 |
| _ => arithi'{oper,rt=ra,ra=rt,im} |
| 435 |
) |
| 436 |
|
| 437 |
(* integer compare *) |
| 438 |
| Cmpl{opcd:6=31,bf:CC 3,_:1=0,l:bool 1,ra:GP 5,rb:GP 5,xo:10=32,_:1=0} |
| 439 |
| Cmpli{opcd:6=10,bf:CC 3,_:1=0,l:bool 1,ra:GP 5,ui:operand signed 16} |
| 440 |
| Cmp{opcd:6=31,bf:CC 3,_:1=0,l:bool 1,ra:GP 5,rb:GP 5,xo:10=0,_:1=0} |
| 441 |
| Cmpi{opcd:6=11,bf:CC 3,_:1=0,l:bool 1,ra:GP 5,si:operand signed 16} |
| 442 |
| compare{cmp,bf,l,ra,rb} = |
| 443 |
(case (cmp,rb) of |
| 444 |
(I.CMP,I.RegOp rb) => Cmp{bf,l,ra,rb} |
| 445 |
| (I.CMPL,I.RegOp rb) => Cmpl{bf,l,ra,rb} |
| 446 |
| (I.CMP,si) => Cmpi{bf,l,ra,si} |
| 447 |
| (I.CMPL,ui) => Cmpli{bf,l,ra,ui} |
| 448 |
) |
| 449 |
|
| 450 |
(* floating point compare *) |
| 451 |
| fcmp{opcd:6=63,bf:CC 3,_:2=0,fa:FP 5,fb:FP 5,cmp:fcmp 10,_:1=0} |
| 452 |
|
| 453 |
(* floating point unary *) |
| 454 |
| funary{oper:funary,ft:FP,fb:FP,Rc} = |
| 455 |
let val (opcd,xo) = oper |
| 456 |
in |
| 457 |
case oper |
| 458 |
of (0wx3f, 0wx16) => (* FSQRT *) |
| 459 |
a_form{opcd=opcd,frt=ft,fra=0w0,frb=fb,frc=0w0,xo=xo,rc=Rc} |
| 460 |
| (0wx3b, 0wx16) => (* FSQRTS *) |
| 461 |
a_form{opcd=opcd,frt=ft,fra=0w0,frb=fb,frc=0w0,xo=xo,rc=Rc} |
| 462 |
| _ => |
| 463 |
x_form{opcd=opcd,rt=ft,ra=0w0,rb=fb,xo=xo,rc=Rc} |
| 464 |
end |
| 465 |
|
| 466 |
(* floating point binary *) |
| 467 |
| farith{oper,ft:FP,fa:FP,fb:FP,Rc} = |
| 468 |
let val (opcd,xo) = emit_farith oper |
| 469 |
in case oper of |
| 470 |
(I.FMUL | I.FMULS) => |
| 471 |
a_form{opcd=opcd,frt=ft,fra=fa,frb=0w0,frc=fb,xo=xo,rc=Rc} |
| 472 |
| _ => a_form{opcd=opcd,frt=ft,fra=fa,frb=fb,frc=0w0,xo=xo,rc=Rc} |
| 473 |
end |
| 474 |
|
| 475 |
(* floating point ternary *) |
| 476 |
| farith3{oper:farith3,ft:FP,fa:FP,fc:FP,fb:FP,Rc} = |
| 477 |
let val (opcd,xo) = oper |
| 478 |
in a_form{opcd=opcd,frt=ft,fra=fa,frb=fb,frc=fc,xo=xo,rc=Rc} |
| 479 |
end |
| 480 |
|
| 481 |
| cr_bit{cc} = |
| 482 |
let val (cr,bit) = cc |
| 483 |
in (emit_CC cr << 0w2) + |
| 484 |
itow( |
| 485 |
case bit of |
| 486 |
I.LT => 0 | I.GT => 1 | I.EQ => 2 | I.SO => 3 |
| 487 |
| I.FL => 0 | I.FG => 1 | I.FE => 2 | I.FU => 3 |
| 488 |
| I.FX => 0 | I.FEX => 1 | I.VX => 2 | I.OX => 3 |
| 489 |
) |
| 490 |
end |
| 491 |
|
| 492 |
| ccarith{oper:ccarith,bt,ba,bb} = |
| 493 |
xl_form{opcd=0w19,bt=cr_bit{cc=bt},ba=cr_bit{cc=ba},bb=cr_bit{cc=bb}, |
| 494 |
xo=oper,lk=false} |
| 495 |
|
| 496 |
(* trap on word *) |
| 497 |
| twr{opcd:6=31,to:int 5,ra:GP 5,rb:GP 5,xop:10=4,_:1=0} |
| 498 |
| twi{opcd:6=3,to:int 5,ra:GP 5,si:operand signed 16} |
| 499 |
| tw{to,ra,si} = |
| 500 |
(case si of I.RegOp rb => twr{to,ra,rb} | _ => twi{to,ra,si}) |
| 501 |
|
| 502 |
(* trap on double word *) |
| 503 |
| tdr{opcd:6=31,to:int 5,ra:GP 5,rb:GP 5,xop:10=68,_:1=0} |
| 504 |
| tdi{opcd:6=2,to:int 5,ra:GP 5,si:operand signed 16} |
| 505 |
| td{to,ra,si} = |
| 506 |
(case si of I.RegOp rb => tdr{to,ra,rb} | _ => tdi{to,ra,si}) |
| 507 |
|
| 508 |
(* move condition field p49 *) |
| 509 |
| mcrf{opcd:6=19,bf:CC 3,_:2=0,bfa:CC 3,_:18=0} |
| 510 |
|
| 511 |
(* move from/to special purpose register p131/132 |
| 512 |
* the encoding of spr = spr[0..4] || spr[5..9] |
| 513 |
*) |
| 514 |
| mtspr'{opcd:6=31,rs:GP 5,spr:10,xop:10=467,_:1=0} |
| 515 |
| mtspr{rs,spr:SPR} = |
| 516 |
mtspr'{rs,spr=((spr at [0..4]) << 0w5) + (spr at [5..9])} |
| 517 |
| mfspr'{opcd:6=31,rt:GP 5,spr:10,xop:10=339,_:1=0} |
| 518 |
| mfspr{rt,spr:SPR} = |
| 519 |
mfspr'{rt,spr=((spr at [0..4]) << 0w5) + (spr at [5..9])} |
| 520 |
|
| 521 |
(* Branch p41 *) |
| 522 |
| b{opcd:6=18,li:signed 24,aa:bool 1,lk:bool 1} |
| 523 |
| be{opcd:6=22,li:signed 24,aa:bool 1,lk:bool 1} |
| 524 |
|
| 525 |
(* Branch conditional p42 *) |
| 526 |
| bc{opcd:6=16,bo:bo 5,bi:5,bd:signed 14,aa:bool 1,lk:bool 1} |
| 527 |
| bce{opcd:6=16,bo:bo 5,bi:5,bd:signed 14,aa:bool 1,lk:bool 1} |
| 528 |
|
| 529 |
(* Branch conditional to link register *) |
| 530 |
| bclr{opcd:6=19,bo:bo 5,bi:5,_:5=0,xop:10=16,lk:bool 1} |
| 531 |
| bclre{opcd:6=19,bo:bo 5,bi:5,_:5=0,xop:10=17,lk:bool 1} |
| 532 |
|
| 533 |
(* Branch conditional to count register *) |
| 534 |
| bcctr{opcd:6=19,bo:bo 5,bi:5,_:5=0,xop:10=528,lk:bool 1} |
| 535 |
| bcctre{opcd:6=19,bo:bo 5,bi:5,_:5=0,xop:10=529,lk:bool 1} |
| 536 |
|
| 537 |
(* Rotate *) |
| 538 |
| rlwnm{oper:6=23,rs:GP 5,ra:GP 5,sh:GP 5,mb:int 5,me:int 5,Rc:1=0} |
| 539 |
| rlwinm{oper:6=21,rs:GP 5,ra:GP 5,sh:5,mb:int 5,me:int 5,Rc:1=0} |
| 540 |
| rldcl{oper:6=30,rs:GP 5,ra:GP 5,sh:GP 5,mb:int 5,_:5=8,Rc:1=0} |
| 541 |
| rldicl{oper:6=30,rs:GP 5,ra:GP 5,sh:5,mb:int 5,_:4=0,sh2:1,Rc:1=0} |
| 542 |
| rldcr{oper:6=30,rs:GP 5,ra:GP 5,sh:GP 5,mb:int 5,_:5=9,Rc:1=0} |
| 543 |
| rldicr{oper:6=30,rs:GP 5,ra:GP 5,sh:5,mb:int 5,_:4=1,sh2:1,Rc:1=0} |
| 544 |
| rldic{oper:6=30,rs:GP 5,ra:GP 5,sh:5,mb:int 5,_:4=2,sh2:1,Rc:1=0} |
| 545 |
| rlwimi{oper:6=20,rs:GP 5,ra:GP 5,sh:5,mb:int 5,me:int 5,Rc:1=0} |
| 546 |
| rldimi{oper:6=30,rs:GP 5,ra:GP 5,sh:5,mb:int 5,_:4=3,sh2:1,Rc:1=0} |
| 547 |
|
| 548 |
| rotate{oper,ra,rs,sh,mb,me} = |
| 549 |
(case (oper,me) of |
| 550 |
(I.RLWNM,SOME me) => rlwnm{ra,rs,sh,mb,me} |
| 551 |
| (I.RLDCL,_) => rldcl{ra,rs,sh,mb} |
| 552 |
| (I.RLDCR,_) => rldcr{ra,rs,sh,mb} |
| 553 |
| _ => error "rotate" |
| 554 |
) |
| 555 |
| rotatei{oper,ra,rs,sh:operand,mb,me} = |
| 556 |
(case (oper,me) of |
| 557 |
(I.RLWINM,SOME me) => rlwinm{ra,rs,sh,mb,me} |
| 558 |
| (I.RLWIMI,SOME me) => rlwimi{ra,rs,sh=sh,mb,me} |
| 559 |
| (I.RLDICL,_) => rldicl{ra,rs,sh=sh at [0..4],sh2=sh at [5],mb} |
| 560 |
| (I.RLDICR,_) => rldicr{ra,rs,sh=sh at [0..4],sh2=sh at [5],mb} |
| 561 |
| (I.RLDIC,_) => rldic{ra,rs,sh=sh at [0..4],sh2=sh at [5],mb} |
| 562 |
| (I.RLDIMI,_) => rldimi{ra,rs,sh=sh at [0..4],sh2=sh at [5],mb} |
| 563 |
| _ => error "rotatei" |
| 564 |
) |
| 565 |
|
| 566 |
(* Taken from a googled link: |
| 567 |
http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixassem/alangref/lwarx.htm |
| 568 |
*) |
| 569 |
| lwarx{oper:6=0w31, rt:GP 5, ra:GP 5, rb:GP 5, _:10=0w20, _:1=0} |
| 570 |
| stwcx{oper:6=0w31, rs:GP 5, ra:GP 5, rb:GP 5, _:10=0w150, _:1=1} |
| 571 |
|
| 572 |
(* |
| 573 |
* Some helper functions for generating machine code. |
| 574 |
* These are copied from Lal's code. |
| 575 |
*) |
| 576 |
structure MC = |
| 577 |
struct |
| 578 |
fun relative(I.LabelOp lexp) = itow(MLTreeEval.valueOf lexp - !loc) ~>> 0w2 |
| 579 |
| relative _ = error "relative" |
| 580 |
end |
| 581 |
|
| 582 |
(* |
| 583 |
* Reservation tables and pipeline definitions for scheduling |
| 584 |
*) |
| 585 |
|
| 586 |
(* Function units *) |
| 587 |
resource issue and mem and alu and falu and fmul and fdiv and branch |
| 588 |
|
| 589 |
(* Different implementations of cpus *) |
| 590 |
cpu default 2 [2 issue, 2 mem, 1 alu] (* 2 issue machine *) |
| 591 |
|
| 592 |
(* Definitions of various reservation tables *) |
| 593 |
pipeline NOP _ = [issue] |
| 594 |
and ARITH _ = [issue^^alu] |
| 595 |
and LOAD _ = [issue^^mem] |
| 596 |
and STORE _ = [issue^^mem,mem,mem] |
| 597 |
and FARITH _ = [issue^^falu] |
| 598 |
and FMUL _ = [issue^^fmul,fmul] |
| 599 |
and FDIV _ = [issue^^fdiv,fdiv*50] |
| 600 |
and BRANCH _ = [issue^^branch] |
| 601 |
|
| 602 |
(* |
| 603 |
* Some helper functions for generating assembly code. |
| 604 |
*) |
| 605 |
structure Assembly = |
| 606 |
struct |
| 607 |
(* Add the x suffix if necessary; this is a stupid hack *) |
| 608 |
fun emitx(s,I.RegOp _) = |
| 609 |
if String.sub(s,size s-1) = #"e" then |
| 610 |
(emit(String.substring(s,0,size s-1)); emit "xe") |
| 611 |
else (emit(s); emit "x") |
| 612 |
| emitx(s,_) = emit s |
| 613 |
|
| 614 |
fun eOERc{OE=false,Rc=false} = () |
| 615 |
| eOERc{OE=false,Rc=true} = emit "." |
| 616 |
| eOERc{OE=true,Rc=false} = emit "o" |
| 617 |
| eOERc{OE=true,Rc=true} = emit "o." |
| 618 |
fun eRc false = "" | eRc true = "." |
| 619 |
fun cr_bit(cr,bit) = |
| 620 |
4 * (CellsBasis.physicalRegisterNum cr) + |
| 621 |
(case bit of |
| 622 |
I.LT => 0 | I.GT => 1 | I.EQ => 2 | I.SO => 3 |
| 623 |
| I.FL => 0 | I.FG => 1 | I.FE => 2 | I.FU => 3 |
| 624 |
| I.FX => 0 | I.FEX => 1 | I.VX => 2 | I.OX => 3 |
| 625 |
) |
| 626 |
fun eCRbit x = emit(Int.toString(cr_bit x)) |
| 627 |
fun eLK true = emit "l" | eLK false = () |
| 628 |
fun eI (I.RegOp _) = () | eI _ = emit "i" |
| 629 |
fun eBI(bo, bf, bit) = |
| 630 |
case (bo, CellsBasis.physicalRegisterNum bf) of |
| 631 |
(I.ALWAYS, _) => () |
| 632 |
| (I.COUNTER{cond=NONE, ...}, _) => () |
| 633 |
| (_,0) => emit(asm_bit bit) |
| 634 |
| (_,n) => emit("4*cr" ^ Int.toString n ^ "+" ^ asm_bit bit) |
| 635 |
fun emit_bo bo = |
| 636 |
emit(case bo |
| 637 |
of I.TRUE => "t" |
| 638 |
| I.FALSE => "f" |
| 639 |
| I.ALWAYS => "" |
| 640 |
| I.COUNTER{eqZero, cond=NONE} => if eqZero then "dz" else "dnz" |
| 641 |
| I.COUNTER{eqZero, cond=SOME cc} => |
| 642 |
(if eqZero then "dz" else "dnz") ^ |
| 643 |
(if cc then "t" else "f") |
| 644 |
(*esac*)) |
| 645 |
|
| 646 |
fun eME(SOME me) = (emit ", "; emit_int me) |
| 647 |
| eME(NONE) = () |
| 648 |
|
| 649 |
fun addr(ra,I.RegOp rb) = (emitCell ra; emit ", "; emitCell rb) |
| 650 |
| addr(ra,d) = (emit_operand d; emit "("; emitCell ra; emit ")") |
| 651 |
|
| 652 |
end (* Assembly *) |
| 653 |
|
| 654 |
instruction |
| 655 |
L of {ld:load, rt: $GP, ra: $GP, d:operand, mem:Region.region} |
| 656 |
``<emitx(asm_load ld,d)>\t<rt>, <addr(ra,d)><mem>'' |
| 657 |
load{ld,rt,ra,d} |
| 658 |
|
| 659 |
| LF of {ld:fload, ft: $FP, ra: $GP, d:operand, mem:Region.region} |
| 660 |
``<emitx(asm_fload ld,d)>\t<ft>, <addr(ra,d)><mem>'' |
| 661 |
fload{ld,ft,ra,d} |
| 662 |
|
| 663 |
| ST of {st:store, rs: $GP, ra: $GP, d:operand, mem:Region.region} |
| 664 |
``<emitx(asm_store st,d)>\t<rs>, <addr(ra,d)><mem>'' |
| 665 |
store{st,rs,ra,d} |
| 666 |
|
| 667 |
| STF of {st:fstore, fs: $FP, ra: $GP, d:operand, mem:Region.region} |
| 668 |
``<emitx(asm_fstore st,d)>\t<fs>, <addr(ra,d)><mem>'' |
| 669 |
fstore{st,fs,ra,d} |
| 670 |
|
| 671 |
| UNARY of {oper:unary, rt: $GP, ra: $GP, Rc:bool, OE:bool} |
| 672 |
``<oper><eOERc{Rc,OE}>\t<rt>, <ra>'' |
| 673 |
unary{oper,rt,ra,OE,Rc} |
| 674 |
|
| 675 |
| ARITH of {oper:arith, rt: $GP, ra: $GP, rb: $GP, Rc:bool, OE:bool} |
| 676 |
``<oper><eOERc{Rc,OE}>\t<rt>, <ra>, <rb>'' |
| 677 |
arith{oper,rt,ra,rb,OE,Rc} |
| 678 |
|
| 679 |
| ARITHI of {oper:arithi, rt: $GP, ra: $GP, im:operand} |
| 680 |
``<oper>\t<rt>, <ra>, <im>'' |
| 681 |
arithi{oper,rt,ra,im} |
| 682 |
|
| 683 |
| ROTATE of {oper:rotate, ra: $GP, rs: $GP, sh: $GP, mb:int, me:int option} |
| 684 |
``<oper>\t<ra>, <rs>, <sh>, <mb><eME me>'' |
| 685 |
rotate{oper,ra,rs,sh,mb,me} |
| 686 |
|
| 687 |
| ROTATEI of {oper:rotatei, ra: $GP, rs: $GP, sh:operand, mb:int, me:int option} |
| 688 |
``<oper>\t<ra>, <rs>, <sh>, <mb><eME me>'' |
| 689 |
rotatei{oper,ra,rs,sh,mb,me} |
| 690 |
|
| 691 |
| COMPARE of {cmp:cmp, l:bool, bf: $CC, ra: $GP, rb:operand} |
| 692 |
``<cmp><eI rb>\t<bf>, <emit(if l then "1" else "0")>, <ra>, <rb>'' |
| 693 |
compare{cmp,bf,l,ra,rb} |
| 694 |
|
| 695 |
| FCOMPARE of {cmp:fcmp, bf: $CC, fa: $FP, fb: $FP} |
| 696 |
``<cmp>\t<bf>, <fa>, <fb>'' |
| 697 |
fcmp{cmp,bf,fa,fb} |
| 698 |
|
| 699 |
| FUNARY of {oper:funary, ft: $FP, fb: $FP, Rc:bool} |
| 700 |
``<oper><eRc Rc>\t<ft>, <fb>'' |
| 701 |
funary{oper,ft,fb,Rc} |
| 702 |
|
| 703 |
| FARITH of {oper:farith, ft: $FP, fa: $FP, fb: $FP, Rc:bool} |
| 704 |
``<oper><eRc Rc>\t<ft>, <fa>, <fb>'' |
| 705 |
farith{oper,ft,fa,fb,Rc} |
| 706 |
|
| 707 |
| FARITH3 of {oper:farith3, ft: $FP, fa: $FP, fb: $FP, fc: $FP, Rc:bool} |
| 708 |
``<oper><eRc Rc>\t<ft>, <fa>, <fb>, <fc>'' |
| 709 |
farith3{oper,ft,fa,fb,fc,Rc} |
| 710 |
|
| 711 |
| CCARITH of {oper:ccarith, bt:cr_bit, ba:cr_bit, bb:cr_bit} |
| 712 |
``<oper>\t<eCRbit bt>, <eCRbit ba>, <eCRbit bb>'' |
| 713 |
ccarith{oper,bt,ba,bb} |
| 714 |
|
| 715 |
| MCRF of {bf: $CC, bfa: $CC} (* move condition register field p49 *) |
| 716 |
``mcrf\t<bf>, <bfa>'' |
| 717 |
mcrf{bf,bfa} |
| 718 |
|
| 719 |
(* move to special register p131 *) |
| 720 |
| MTSPR of {rs: $GP, spr: $SPR} |
| 721 |
``mt<spr>\t<rs>'' |
| 722 |
mtspr{rs,spr} |
| 723 |
|
| 724 |
(* move from special register p132 *) |
| 725 |
| MFSPR of {rt: $GP, spr: $SPR} |
| 726 |
``mf<spr>\t<rt>'' |
| 727 |
mfspr{rt,spr} |
| 728 |
|
| 729 |
(* Load word and reserve indexed *) |
| 730 |
| LWARX of {rt: $GP, ra: $GP, rb: $GP} |
| 731 |
``lwarx\t<rt>, <ra>, <rb>'' |
| 732 |
lwarx{rt, ra, rb} |
| 733 |
|
| 734 |
(* Store word conditional indexed *) |
| 735 |
| STWCX of {rs: $GP, ra: $GP, rb: $GP} |
| 736 |
``stwcx.\t<rs>, <ra>, <rb>'' |
| 737 |
stwcx{rs, ra, rb} |
| 738 |
|
| 739 |
(* Trapping word *) |
| 740 |
| TW of {to:int, ra: $GP, si:operand} |
| 741 |
``tw<eI si>\t<to>, <ra>, <si>'' |
| 742 |
tw{to,ra,si} |
| 743 |
|
| 744 |
(* Trapping double word *) |
| 745 |
| TD of {to:int, ra: $GP, si:operand} |
| 746 |
``td<eI si>\t<to>, <ra>, <si>'' |
| 747 |
td{to,ra,si} |
| 748 |
|
| 749 |
(* Control Instructions - AA is always assumed to be 0 *) |
| 750 |
| BC of {bo:bo, bf: $CC, bit:bit, addr:operand, LK:bool, fall:operand} |
| 751 |
``b<bo><eLK LK>\t<eBI(bo,bf,bit)>, <addr>'' |
| 752 |
bc{bo,bi=cr_bit{cc=(bf,bit)},bd=relative addr,aa=false,lk=LK} |
| 753 |
|
| 754 |
| BCLR of {bo:bo, bf: $CC, bit:bit, LK:bool, labels:Label.label list} |
| 755 |
``b<bo>lr<eLK LK>\t<eBI(bo,bf,bit)>'' |
| 756 |
bclr{bo,bi=cr_bit{cc=(bf,bit)},lk=LK} |
| 757 |
|
| 758 |
| B of {addr:operand, LK:bool} |
| 759 |
``b<eLK LK>\t<addr>'' |
| 760 |
b{li=relative addr,aa=false,lk=LK} |
| 761 |
|
| 762 |
(* CALL = BCLR {bo=ALWAYS, bf=0, bit=0, LK=true, labels=[] *) |
| 763 |
| CALL of {def:C.cellset, use:C.cellset, |
| 764 |
cutsTo: Label.label list, mem: Region.region} |
| 765 |
``blrl<mem><emit_defs(def)><emit_uses(use)><emit_cutsTo cutsTo>'' |
| 766 |
bclr{bo=I.ALWAYS,bi=0w0,lk=true} |
| 767 |
|
| 768 |
| SOURCE of {} |
| 769 |
asm: ``source'' |
| 770 |
mc: () |
| 771 |
|
| 772 |
| SINK of {} |
| 773 |
asm: ``sink'' |
| 774 |
mc: () |
| 775 |
|
| 776 |
| PHI of {} |
| 777 |
asm: ``phi'' |
| 778 |
mc: () |
| 779 |
|
| 780 |
structure SSA = |
| 781 |
struct |
| 782 |
|
| 783 |
fun operand(ty, I.RegOp r) = T.REG(32, r) |
| 784 |
| operand(ty, I.ImmedOp i) = T.LI i |
| 785 |
(*| operand(ty, I.LabelOp le) = T.LABEL le*) |
| 786 |
|
| 787 |
end |
| 788 |
|
| 789 |
end |