2016-09-25 20:17:14 +00:00
|
|
|
REGISTERS
|
|
|
|
|
2016-10-05 19:00:28 +00:00
|
|
|
r0 bytes4 int ret;
|
|
|
|
r1 bytes4 int;
|
|
|
|
r2 bytes4 int;
|
|
|
|
r3 bytes4 int;
|
|
|
|
r4 bytes4 int;
|
|
|
|
r5 bytes4 int;
|
|
|
|
r6 bytes4 int;
|
|
|
|
r7 bytes4 int;
|
|
|
|
r8 bytes4 int;
|
|
|
|
r9 bytes4 int;
|
|
|
|
r10 bytes4 int;
|
|
|
|
r11 bytes4 int;
|
|
|
|
|
|
|
|
s0 bytes4 float;
|
|
|
|
s1 bytes4 float;
|
|
|
|
s2 bytes4 float;
|
|
|
|
s3 bytes4 float;
|
|
|
|
s4 bytes4 float;
|
|
|
|
s5 bytes4 float;
|
|
|
|
s6 bytes4 float;
|
|
|
|
s7 bytes4 float;
|
|
|
|
s8 bytes4 float;
|
|
|
|
s9 bytes4 float;
|
2016-10-01 10:17:14 +00:00
|
|
|
|
|
|
|
cc cc;
|
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
|
|
|
|
DECLARATIONS
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
cc;
|
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
address fragment;
|
|
|
|
aluparam fragment;
|
2016-10-01 10:17:14 +00:00
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
|
2016-09-24 17:03:55 +00:00
|
|
|
PATTERNS
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
/* Special */
|
|
|
|
|
|
|
|
PAIR(BLOCK4, BLOCK4);
|
|
|
|
|
|
|
|
|
|
|
|
/* Miscellaneous special things */
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
PUSH4(in:(int)reg)
|
2016-09-24 20:46:08 +00:00
|
|
|
emit "push %in"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = POP4
|
|
|
|
emit "pop %out"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
RET
|
|
|
|
emit "ret"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
SETRET4(in:(ret)reg)
|
2016-10-04 19:58:31 +00:00
|
|
|
emit "mov r0, %in"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-01 21:41:45 +00:00
|
|
|
STACKADJUST4(delta:aluparam)
|
|
|
|
emit "add sp, sp, %delta"
|
|
|
|
cost 4;
|
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
/* Memory operations */
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
STORE4(addr:address, value:(int)reg)
|
2016-09-24 15:20:40 +00:00
|
|
|
emit "str %value, %addr"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
STORE1(addr:address, value:(int)reg)
|
2016-10-01 21:41:45 +00:00
|
|
|
emit "strb %value, %addr"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = LOAD4(addr:address)
|
|
|
|
emit "ldr %out, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = LOAD1(addr:address)
|
|
|
|
emit "ldrb %out, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = CIU14(LOAD1(addr:address))
|
|
|
|
emit "ldrb %out, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
2016-09-25 15:14:54 +00:00
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = CII14(CIU41(CIU14(LOAD1(addr:address))))
|
|
|
|
emit "ldrsb %out, %addr"
|
2016-09-25 15:14:54 +00:00
|
|
|
cost 4;
|
2016-09-24 20:46:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Locals */
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = in:LOCAL4
|
|
|
|
emit "add %out, fp, #$in"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
address = in:LOCAL4
|
2016-09-25 20:17:14 +00:00
|
|
|
emit "[fp, #$in]";
|
2016-09-24 20:46:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Memory addressing modes */
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
address = ADD4(addr:(int)reg, offset:CONST4)
|
2016-09-25 20:17:14 +00:00
|
|
|
emit "[%addr, #$offset]";
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
address = ADD4(addr1:(int)reg, addr2:(int)reg)
|
2016-10-01 21:41:45 +00:00
|
|
|
emit "[%addr1, %addr2]";
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
address = addr:(int)reg
|
2016-09-25 20:17:14 +00:00
|
|
|
emit "[%addr]";
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
|
2016-10-01 21:41:45 +00:00
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
/* Branches */
|
|
|
|
|
|
|
|
JUMP(addr:BLOCK4)
|
2016-09-25 15:14:54 +00:00
|
|
|
emit "b $addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
CJUMPEQ(value:(cc)cc, PAIR(true:BLOCK4, false:BLOCK4))
|
2016-09-27 21:38:47 +00:00
|
|
|
emit "beq $true"
|
|
|
|
emit "b $false"
|
|
|
|
cost 8;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
CJUMPLE(value:(cc)cc, PAIR(true:BLOCK4, false:BLOCK4))
|
2016-10-01 21:41:45 +00:00
|
|
|
emit "ble $true"
|
|
|
|
emit "b $false"
|
|
|
|
cost 8;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
CJUMPLT(value:(cc)cc, PAIR(true:BLOCK4, false:BLOCK4))
|
2016-10-02 15:50:34 +00:00
|
|
|
emit "blt $true"
|
|
|
|
emit "b $false"
|
|
|
|
cost 8;
|
|
|
|
|
2016-10-01 21:41:45 +00:00
|
|
|
CALL(dest:LABEL4)
|
|
|
|
emit "bl $dest"
|
|
|
|
cost 4;
|
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
|
|
|
|
/* Comparisons */
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
(cc)cc = COMPARES4(left:(int)reg, right:aluparam)
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "cmp %left, %right"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
(cc)cc = COMPARES4(COMPARES4(left:(int)reg, right:aluparam), CONST4)
|
2016-09-27 21:38:47 +00:00
|
|
|
emit "cmp %left, %right"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = (cc)cc
|
|
|
|
emit "mov %out, #0"
|
|
|
|
emit "movlt %out, #-1"
|
|
|
|
emit "movgt %out, #1"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 12;
|
|
|
|
|
|
|
|
|
|
|
|
/* Conversions */
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = CII14(CIU41(value:(int)reg))
|
|
|
|
emit "sxtb %out, %value"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = CIU41(in:(int)reg)
|
|
|
|
emit "and %out, %in, #0xff"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
|
|
|
|
/* ALU operations */
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = ADD4(left:(int)reg, right:aluparam)
|
|
|
|
emit "add %out, %left, %right"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = ADD4(left:aluparam, right:(int)reg)
|
|
|
|
emit "add %out, %right, %left"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = MOD4(left:(int)reg, right:(int)reg)
|
|
|
|
emit "udiv %out, %left, %right"
|
|
|
|
emit "mls %out, %out, %right, %left"
|
2016-10-01 21:41:45 +00:00
|
|
|
cost 8;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = DIV4(left:(int)reg, right:aluparam)
|
|
|
|
emit "div %out, %left, %right"
|
2016-10-01 21:41:45 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-09-24 16:31:35 +00:00
|
|
|
aluparam = value:CONST4
|
2016-09-25 20:17:14 +00:00
|
|
|
emit "#$value";
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
aluparam = value:(int)reg
|
2016-09-29 20:06:04 +00:00
|
|
|
emit "%value";
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = value:aluparam
|
|
|
|
emit "mov %out, %value"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = value:LABEL4
|
|
|
|
emit "adr %out, $value"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = value:BLOCK4
|
|
|
|
emit "adr %out, $value"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = value:CONST4
|
|
|
|
emit "ldr %out, address-containing-$value"
|
2016-10-01 11:56:52 +00:00
|
|
|
cost 8;
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(int)reg = value:CONSTF4
|
|
|
|
emit "vldr %out, address-containing-$value"
|
2016-09-29 17:58:02 +00:00
|
|
|
cost 8;
|
2016-09-29 20:06:04 +00:00
|
|
|
|
|
|
|
/* FPU operations */
|
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
out:(float)reg = ADDF4(left:(float)reg, right:(float)reg)
|
|
|
|
emit "fadds %out, %left, %right"
|
2016-09-29 20:06:04 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-05 19:07:29 +00:00
|
|
|
/* vim: set sw=4 ts=4 expandtab : */
|
|
|
|
|