2016-09-25 20:17:14 +00:00
|
|
|
REGISTERS
|
|
|
|
|
2016-10-01 10:17:14 +00:00
|
|
|
r0 any int ret;
|
|
|
|
r1 any int;
|
|
|
|
r2 any int;
|
|
|
|
r3 any int;
|
|
|
|
r4 any int;
|
|
|
|
r5 any int;
|
|
|
|
r6 any int;
|
|
|
|
r7 any int;
|
|
|
|
r8 any int;
|
|
|
|
r9 any int;
|
|
|
|
r10 any int;
|
|
|
|
r11 any int;
|
|
|
|
|
|
|
|
s0 any float;
|
|
|
|
s1 any float;
|
|
|
|
s2 any float;
|
|
|
|
s3 any float;
|
|
|
|
s4 any float;
|
|
|
|
s5 any float;
|
|
|
|
s6 any float;
|
|
|
|
s7 any float;
|
|
|
|
s8 any float;
|
|
|
|
s9 any float;
|
|
|
|
|
|
|
|
cc cc;
|
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
|
|
|
|
DECLARATIONS
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg;
|
|
|
|
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 */
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg;
|
2016-09-25 20:17:14 +00:00
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
PAIR(BLOCK4, BLOCK4);
|
|
|
|
|
|
|
|
|
|
|
|
/* Miscellaneous special things */
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
PUSH4(in:reg)
|
2016-09-24 20:46:08 +00:00
|
|
|
emit "push %in"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = POP4
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "pop %reg"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
RET
|
|
|
|
emit "ret"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
SETRET4(in:reg)
|
|
|
|
with 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-10-03 18:52:36 +00:00
|
|
|
reg = in:REG
|
2016-10-01 11:56:52 +00:00
|
|
|
cost 1;
|
2016-10-01 10:17:14 +00:00
|
|
|
|
2016-10-03 18:52:36 +00:00
|
|
|
reg = NOP(in:reg)
|
2016-10-02 15:50:34 +00:00
|
|
|
cost 1;
|
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
/* Memory operations */
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
STORE4(addr:address, value:reg)
|
|
|
|
with int value
|
2016-09-24 15:20:40 +00:00
|
|
|
emit "str %value, %addr"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
STORE1(addr:address, value:reg)
|
|
|
|
with int value
|
2016-10-01 21:41:45 +00:00
|
|
|
emit "strb %value, %addr"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = LOAD4(addr:address)
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "ldr %reg, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = LOAD1(addr:address)
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "ldrb %reg, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = CIU14(LOAD1(addr:address))
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "ldrb %reg, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
2016-09-25 15:14:54 +00:00
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = CII14(CIU41(CIU14(LOAD1(addr:address))))
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "ldrsb %reg, %addr"
|
2016-09-25 15:14:54 +00:00
|
|
|
cost 4;
|
2016-09-24 20:46:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Locals */
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = in:LOCAL4
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "add %reg, 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-02 19:51:25 +00:00
|
|
|
address = ADD4(addr:reg, offset:CONST4)
|
|
|
|
with int addr
|
2016-09-25 20:17:14 +00:00
|
|
|
emit "[%addr, #$offset]";
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
address = ADD4(addr1:reg, addr2:reg)
|
|
|
|
with int addr1, int addr2
|
2016-10-01 21:41:45 +00:00
|
|
|
emit "[%addr1, %addr2]";
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
address = addr:reg
|
|
|
|
with int addr
|
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-01 10:17:14 +00:00
|
|
|
CJUMPEQ(value:cc, PAIR(true:BLOCK4, false:BLOCK4))
|
2016-09-27 21:38:47 +00:00
|
|
|
emit "beq $true"
|
|
|
|
emit "b $false"
|
|
|
|
cost 8;
|
|
|
|
|
2016-10-01 21:41:45 +00:00
|
|
|
CJUMPLE(value:cc, PAIR(true:BLOCK4, false:BLOCK4))
|
|
|
|
emit "ble $true"
|
|
|
|
emit "b $false"
|
|
|
|
cost 8;
|
|
|
|
|
2016-10-02 15:50:34 +00:00
|
|
|
CJUMPLT(value:cc, PAIR(true:BLOCK4, false:BLOCK4))
|
|
|
|
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-02 19:51:25 +00:00
|
|
|
cc = COMPARES4(left:reg, right:aluparam)
|
2016-10-03 22:16:06 +00:00
|
|
|
with cc cc
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "cmp %left, %right"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
cc = COMPARES4(COMPARES4(left:reg, right:aluparam), CONST4)
|
2016-10-03 22:16:06 +00:00
|
|
|
with cc cc
|
2016-09-27 21:38:47 +00:00
|
|
|
emit "cmp %left, %right"
|
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = cc
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "mov %reg, #0"
|
|
|
|
emit "movlt %reg, #-1"
|
|
|
|
emit "movgt %reg, #1"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 12;
|
|
|
|
|
|
|
|
|
|
|
|
/* Conversions */
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = CII14(CIU41(value:reg))
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "sxtb %reg, %value"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = CIU41(in:reg)
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "and %reg, %in, #0xff"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
|
|
|
|
/* ALU operations */
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = ADD4(left:reg, right:aluparam)
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "add %reg, %left, %right"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = ADD4(left:aluparam, right:reg)
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "add %reg, %right, %left"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = MOD4(left:reg, right:reg)
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "udiv %reg, %left, %right"
|
|
|
|
emit "mls %reg, %reg, %right, %left"
|
2016-10-01 21:41:45 +00:00
|
|
|
cost 8;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = DIV4(left:reg, right:aluparam)
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "div %reg, %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-02 19:51:25 +00:00
|
|
|
aluparam = value:reg
|
2016-09-29 20:06:04 +00:00
|
|
|
emit "%value";
|
2016-09-24 15:20:40 +00:00
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = value:aluparam
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "mov %reg, %value"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = value:LABEL4
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "adr %reg, $value"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = value:BLOCK4
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "adr %reg, $value"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = value:CONST4
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "ldr %reg, address-containing-$value"
|
2016-10-01 11:56:52 +00:00
|
|
|
cost 8;
|
|
|
|
|
2016-10-02 19:51:25 +00:00
|
|
|
reg = value:CONSTF4
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "vldr %reg, 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-02 19:51:25 +00:00
|
|
|
reg = ADDF4(left:reg, right:reg)
|
2016-10-03 22:16:06 +00:00
|
|
|
with int reg
|
2016-10-02 19:51:25 +00:00
|
|
|
emit "fadds %reg, %left, %right"
|
2016-09-29 20:06:04 +00:00
|
|
|
cost 4;
|
|
|
|
|