ack/mach/proto/mcg/table

339 lines
6.6 KiB
Plaintext
Raw Normal View History

REGISTERS
2016-10-08 09:35:33 +00:00
/* Reverse order because registers are assigned from top down. */
r31 bytes4 int;
r30 bytes4 int;
r29 bytes4 int;
r28 bytes4 int;
r27 bytes4 int;
r26 bytes4 int;
r25 bytes4 int;
r24 bytes4 int;
r23 bytes4 int;
r22 bytes4 int;
r21 bytes4 int;
r20 bytes4 int;
r19 bytes4 int;
r18 bytes4 int;
r17 bytes4 int;
r16 bytes4 int;
r15 bytes4 int;
r14 bytes4 int;
r13 bytes4 int;
r12 bytes4 int;
r11 bytes4 int;
r10 bytes4 int;
r9 bytes4 int;
r8 bytes4 int;
r7 bytes4 int;
r6 bytes4 int;
r5 bytes4 int;
r4 bytes4 int;
r3 bytes4 int ret;
f31 bytes4 bytes8 float;
f30 bytes4 bytes8 float;
f29 bytes4 bytes8 float;
f28 bytes4 bytes8 float;
f27 bytes4 bytes8 float;
f26 bytes4 bytes8 float;
f25 bytes4 bytes8 float;
f24 bytes4 bytes8 float;
f23 bytes4 bytes8 float;
f22 bytes4 bytes8 float;
f21 bytes4 bytes8 float;
f20 bytes4 bytes8 float;
f19 bytes4 bytes8 float;
f18 bytes4 bytes8 float;
f17 bytes4 bytes8 float;
f16 bytes4 bytes8 float;
f15 bytes4 bytes8 float;
f14 bytes4 bytes8 float;
f13 bytes4 bytes8 float;
f12 bytes4 bytes8 float;
f11 bytes4 bytes8 float;
f10 bytes4 bytes8 float;
f9 bytes4 bytes8 float;
f8 bytes4 bytes8 float;
f7 bytes4 bytes8 float;
f6 bytes4 bytes8 float;
f5 bytes4 bytes8 float;
f4 bytes4 bytes8 float;
f3 bytes4 bytes8 float;
f2 bytes4 bytes8 float;
f1 bytes4 bytes8 float;
f0 bytes4 bytes8 float;
cr0 cr;
DECLARATIONS
2016-10-08 09:35:33 +00:00
cr;
address fragment;
2016-09-24 17:03:55 +00:00
PATTERNS
2016-09-24 15:20:40 +00:00
/* Special */
PAIR(BLOCK4, BLOCK4);
2016-10-08 09:35:33 +00:00
/* Miscellaneous special things */
PUSH4(in:(int)reg)
2016-10-08 09:35:33 +00:00
emit "stwu %in, -4(sp)"
cost 4;
out:(int)reg = POP4
2016-10-08 09:35:33 +00:00
emit "lwz %out, 0(sp)"
emit "addi sp, sp, 4"
cost 8;
2016-10-08 09:35:33 +00:00
out:(float)reg = POPF4
emit "lfs %out, 0(sp)"
emit "addi sp, sp, 4"
cost 8;
RET
emit "ret"
cost 4;
SETRET4(in:(ret)reg)
emit "mov r0, %in"
cost 4;
2016-10-08 09:35:33 +00:00
(ret)reg = GETRET4
cost 1;
STACKADJUST4(delta:CONST4)
when constant_signed_16_bit(delta)
emit "addi sp, sp, $delta"
2016-10-01 21:41:45 +00:00
cost 4;
2016-10-08 09:35:33 +00:00
/* Memory operations */
STORE4(addr:address, value:(int)reg)
2016-10-08 09:35:33 +00:00
emit "stw %value, %addr"
cost 4;
STORE2(addr:address, value:(int)reg)
emit "sth %value, %addr"
2016-09-24 15:20:40 +00:00
cost 4;
STORE1(addr:address, value:(int)reg)
2016-10-08 09:35:33 +00:00
emit "stb %value, %addr"
2016-10-01 21:41:45 +00:00
cost 4;
out:(int)reg = LOAD4(addr:address)
2016-10-08 09:35:33 +00:00
emit "lwz %out, %addr"
cost 4;
out:(int)reg = LOAD2(addr:address)
emit "lhz %out, %addr"
cost 4;
out:(int)reg = LOAD1(addr:address)
2016-10-08 09:35:33 +00:00
emit "lbz %out, %addr"
cost 4;
out:(int)reg = CIU14(LOAD1(addr:address))
2016-10-08 09:35:33 +00:00
emit "lbz %out, %addr"
cost 4;
2016-10-08 09:35:33 +00:00
out:(int)reg = CIU24(LOAD2(addr:address))
emit "lhz %out, %addr"
cost 4;
2016-10-08 09:35:33 +00:00
/* Locals */
out:(int)reg = in:LOCAL4
2016-10-08 09:35:33 +00:00
emit "addi %out, fp, #$in"
2016-09-24 15:20:40 +00:00
cost 4;
address = in:LOCAL4
2016-10-08 09:35:33 +00:00
emit "$in(fp)";
/* Memory addressing modes */
address = ADD4(addr:(int)reg, offset:CONST4)
2016-10-08 09:35:33 +00:00
when constant_signed_16_bit(offset)
emit "$offset(%addr)";
2016-10-01 21:41:45 +00:00
address = addr:(int)reg
2016-10-08 09:35:33 +00:00
emit "0(%addr)";
2016-09-24 15:20:40 +00:00
2016-10-01 21:41:45 +00:00
/* Branches */
JUMP(addr:BLOCK4)
emit "b $addr"
cost 4;
2016-10-08 09:35:33 +00:00
CJUMPEQ(value:(cr)cr, PAIR(true:BLOCK4, false:BLOCK4))
emit "bc IFTRUE, EQ, $true"
emit "b $false"
cost 8;
2016-10-08 09:35:33 +00:00
CJUMPLE(value:(cr)cr, PAIR(true:BLOCK4, false:BLOCK4))
emit "bc IFTRUE, LE, $true"
emit "b $false"
2016-10-01 21:41:45 +00:00
cost 8;
2016-10-08 09:35:33 +00:00
CJUMPLT(value:(cr)cr, PAIR(true:BLOCK4, false:BLOCK4))
emit "bc IFTRUE, LT, $true"
emit "b $false"
cost 8;
2016-10-01 21:41:45 +00:00
CALL(dest:LABEL4)
emit "bl $dest"
cost 4;
2016-10-08 09:35:33 +00:00
CALL(dest:(int)reg)
emit "mtspr ctr, %dest"
emit "bcctrl ALWAYS, 0, 0"
cost 8;
JUMP(dest:LABEL4)
emit "b $dest"
cost 4;
/* Comparisons */
2016-10-08 09:35:33 +00:00
cr:(cr)cr = COMPARES4(left:(int)reg, right:(int)reg)
emit "cmp %cr, 0, %left, %right"
cost 4;
2016-10-08 09:35:33 +00:00
cr:(cr)cr = COMPARES4(left:(int)reg, right:CONST4)
when constant_signed_16_bit(right)
emit "cmpi %cr, 0, %left, $right"
cost 4;
2016-10-08 09:35:33 +00:00
cr:(cr)cr = COMPAREU4(left:(int)reg, right:(int)reg)
emit "cmpl %cr, 0, %left, %right"
cost 4;
cr:(cr)cr = COMPAREU4(left:(int)reg, right:CONST4)
when constant_signed_16_bit(right)
emit "cmpli %cr, 0, %left, $right"
cost 4;
cr:(cr)cr = COMPARES4(COMPARES4(left:(int)reg, right:(int)reg), result:CONST4)
when constant_is_zero(result)
emit "cmp %cr, 0, %left, %right"
cost 4;
cr:(cr)cr = COMPARES4(COMPARES4(left:(int)reg, right:CONST4), result:CONST4)
when constant_is_zero(result)
when constant_signed_16_bit(right)
emit "cmpi %cr, 0, %left, $right"
cost 4;
cr:(cr)cr = COMPARES4(COMPAREU4(left:(int)reg, right:(int)reg), result:CONST4)
when constant_is_zero(result)
emit "cmpl %cr, 0, %left, %right"
cost 4;
/* Conversions */
out:(int)reg = CII14(CIU41(value:(int)reg))
2016-10-08 09:35:33 +00:00
emit "extsb %out, %value"
cost 4;
out:(int)reg = CII24(CIU42(value:(int)reg))
emit "extsh %out, %value"
cost 4;
out:(int)reg = CIU41(in:(int)reg)
2016-10-08 09:35:33 +00:00
emit "andi %out, %in, 0xff"
cost 4;
2016-10-08 09:35:33 +00:00
out:(int)reg = CIU42(in:(int)reg)
emit "andi %out, %in, 0xffff"
cost 4;
out:(int)reg = CIU44(in:(int)reg)
emit "mr %out, %in"
cost 4;
/* ALU operations */
2016-09-24 15:20:40 +00:00
2016-10-08 09:35:33 +00:00
out:(int)reg = ADD4(left:(int)reg, right:(int)reg)
emit "add %out, %left, %right"
2016-09-24 15:20:40 +00:00
cost 4;
2016-10-08 09:35:33 +00:00
out:(int)reg = ADD4(left:(int)reg, right:CONST4)
when constant_signed_16_bit(right)
emit "addi %out, %left, $right"
2016-09-24 15:20:40 +00:00
cost 4;
2016-10-08 09:35:33 +00:00
out:(int)reg = SUB4(left:(int)reg, right:(int)reg)
emit "sub %out, %right, %left"
cost 4;
2016-10-01 21:41:45 +00:00
2016-10-08 09:35:33 +00:00
out:(int)reg = MUL4(left:(int)reg, right:(int)reg)
emit "mullw %out, %right, %left"
2016-10-01 21:41:45 +00:00
cost 4;
2016-10-08 09:35:33 +00:00
out:(int)reg = MOD4(left:(int)reg, right:(int)reg)
emit "divw %out, %left, %right"
emit "mullw %out, %out, %right"
emit "subf %out, %out, %left"
cost 12;
out:(int)reg = DIV4(left:(int)reg, right:(int)reg)
emit "divw %out, %left, %right"
cost 4;
2016-09-24 15:20:40 +00:00
2016-10-08 09:35:33 +00:00
out:(int)reg = NEG4(left:(int)reg)
emit "neg %out, %left"
cost 4;
2016-09-24 15:20:40 +00:00
2016-10-08 09:35:33 +00:00
out:(int)reg = EOR4(left:(int)reg, right:(int)reg)
emit "xor %out, %right, %left"
2016-09-24 15:20:40 +00:00
cost 4;
out:(int)reg = value:LABEL4
2016-10-08 09:35:33 +00:00
emit "la %out, $value"
cost 4;
out:(int)reg = value:BLOCK4
2016-10-08 09:35:33 +00:00
emit "la %out, $value"
2016-09-24 15:20:40 +00:00
cost 4;
out:(int)reg = value:CONST4
2016-10-08 09:35:33 +00:00
emit "la %out, $value"
cost 8;
out:(int)reg = value:CONSTF4
2016-10-08 09:35:33 +00:00
emit "lfs %out, address-containing-$value"
cost 8;
2016-10-08 09:35:33 +00:00
/* FPU operations */
out:(float)reg = ADDF4(left:(float)reg, right:(float)reg)
emit "fadds %out, %left, %right"
cost 4;
/* vim: set sw=4 ts=4 expandtab : */