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 */
|
|
|
|
|
|
|
|
reg;
|
|
|
|
|
|
|
|
PAIR(BLOCK4, BLOCK4);
|
|
|
|
|
|
|
|
|
|
|
|
/* Miscellaneous special things */
|
|
|
|
|
|
|
|
PUSH4(in:reg)
|
|
|
|
emit "push %in"
|
|
|
|
cost 4;
|
|
|
|
|
|
|
|
reg = POP4
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "pop %reg"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
RET
|
|
|
|
emit "ret"
|
|
|
|
cost 4;
|
|
|
|
|
|
|
|
SETRET4(in:reg)
|
|
|
|
emit "mov r0, %in"
|
|
|
|
cost 4;
|
|
|
|
|
|
|
|
/* Memory operations */
|
|
|
|
|
2016-09-24 17:03:55 +00:00
|
|
|
STORE4(addr:address, value:reg)
|
2016-09-24 15:20:40 +00:00
|
|
|
emit "str %value, %addr"
|
|
|
|
cost 4;
|
|
|
|
|
2016-09-24 16:31:35 +00:00
|
|
|
reg = LOAD4(addr:address)
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "ldr %reg, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
reg = LOAD1(addr:address)
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "ldrb %reg, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
reg = CIU14(LOAD1(addr:address))
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "ldrb %reg, %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
|
|
|
|
/* Locals */
|
|
|
|
|
|
|
|
reg = in:LOCAL4
|
2016-09-25 09:49:51 +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-24 22:21:46 +00:00
|
|
|
fragment "[fp, #%in]";
|
2016-09-24 20:46:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Memory addressing modes */
|
|
|
|
|
2016-09-24 16:31:35 +00:00
|
|
|
address = ADD4(addr:reg, offset:CONST)
|
2016-09-24 22:21:46 +00:00
|
|
|
fragment "[%addr, #%offset]";
|
2016-09-24 15:20:40 +00:00
|
|
|
|
|
|
|
address = addr:reg
|
|
|
|
fragment "[%addr]";
|
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
|
|
|
|
/* Branches */
|
|
|
|
|
|
|
|
JUMP(addr:BLOCK4)
|
2016-09-24 22:21:46 +00:00
|
|
|
emit "b %addr"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
CJUMPEQ(value:tristate, PAIR(true:BLOCK4, false:BLOCK4))
|
2016-09-24 22:21:46 +00:00
|
|
|
emit "beq %true"
|
|
|
|
emit "bne %false"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 8;
|
|
|
|
|
|
|
|
|
|
|
|
/* Comparisons */
|
|
|
|
|
2016-09-25 09:49:51 +00:00
|
|
|
tristate = COMPARES4(left:reg, right:aluparam)
|
2016-09-24 20:46:08 +00:00
|
|
|
outs CC
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "cmp %left, %right"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
reg = tristate
|
2016-09-25 09:49:51 +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 */
|
|
|
|
|
|
|
|
reg = CII14(CIU41(value:reg))
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "sxtb %reg, %value"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
reg = CIU41(in:reg)
|
2016-09-25 09:49:51 +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-09-24 16:31:35 +00:00
|
|
|
reg = ADD4(left:reg, right:aluparam)
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "add %reg, %left, %right"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-09-24 16:31:35 +00:00
|
|
|
reg = ADD4(left:aluparam, right:reg)
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "add %reg, %right, %left"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-09-24 16:31:35 +00:00
|
|
|
aluparam = value:CONST4
|
2016-09-24 15:20:40 +00:00
|
|
|
fragment "#%value.ivalue";
|
|
|
|
|
|
|
|
aluparam = reg;
|
|
|
|
|
|
|
|
reg = value:aluparam
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "mov %reg, %value"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-09-24 16:31:35 +00:00
|
|
|
reg = value:LABEL4
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "adr %reg, %value"
|
2016-09-24 20:46:08 +00:00
|
|
|
cost 4;
|
|
|
|
|
|
|
|
reg = value:BLOCK4
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "adr %reg, %value"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|
|
|
|
|
2016-09-24 16:31:35 +00:00
|
|
|
reg = value:CONST4
|
2016-09-25 09:49:51 +00:00
|
|
|
emit "ldr %reg, #value"
|
2016-09-24 15:20:40 +00:00
|
|
|
cost 4;
|