2013-05-16 23:03:38 +00:00
|
|
|
/*
|
|
|
|
* VideoCore IV code generator for the ACK
|
|
|
|
* © 2013 David Given
|
|
|
|
* This file is redistributable under the terms of the 3-clause BSD license.
|
|
|
|
* See the file 'Copying' in the root of the distribution for the full text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
EM_WSIZE = 4
|
|
|
|
EM_PSIZE = 4
|
|
|
|
EM_BSIZE = 8 /* two words saved in call frame */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
BYTE = 1 /* Size of values */
|
|
|
|
WORD = 2
|
|
|
|
QUAD = 4
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
FP_OFFSET = 0 /* Offset of saved FP relative to our FP */
|
|
|
|
PC_OFFSET = 4 /* Offset of saved PC relative to our FP */
|
|
|
|
|
|
|
|
#define COMMENT(n) /* noop */
|
|
|
|
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
#define nicesize(x) ((x)==BYTE || (x)==WORD || (x)==QUAD)
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PROPERTIES
|
|
|
|
|
|
|
|
GPR /* any GPR */
|
|
|
|
REG /* any allocatable GPR */
|
2013-05-19 22:33:42 +00:00
|
|
|
|
|
|
|
GPR0 GPR1 GPR2 GPR3 GPR4 GPR5 GPR6 GPR7
|
2013-05-16 23:03:38 +00:00
|
|
|
GPR8 GPR9 GPR10 GPR11 GPR12 GPR13 GPR14 GPR15
|
|
|
|
GPR16 GPR17 GPR18 GPR19 GPR20 GPR21 GPR22 GPR23
|
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
GPRGP GPRFP GPRSP GPRLR GPRPC
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
REGISTERS
|
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
R0("r0") : GPR, REG, GPR0.
|
2013-05-20 21:35:12 +00:00
|
|
|
R1("r1") : GPR, REG, GPR1.
|
|
|
|
R2("r2") : GPR, REG, GPR2.
|
|
|
|
R3("r3") : GPR, REG, GPR3.
|
|
|
|
R4("r4") : GPR, REG, GPR4.
|
|
|
|
R5("r5") : GPR, REG, GPR5.
|
2013-05-24 16:04:29 +00:00
|
|
|
R6("r6") : GPR, REG, GPR6 regvar.
|
2013-05-20 21:35:12 +00:00
|
|
|
R7("r7") : GPR, REG, GPR7 regvar.
|
|
|
|
R8("r8") : GPR, REG, GPR8 regvar.
|
|
|
|
R9("r9") : GPR, REG, GPR9 regvar.
|
|
|
|
R10("r10") : GPR, REG, GPR10 regvar.
|
|
|
|
R11("r11") : GPR, REG, GPR11 regvar.
|
|
|
|
R12("r12") : GPR, REG, GPR12 regvar.
|
|
|
|
R13("r13") : GPR, REG, GPR13 regvar.
|
|
|
|
R14("r14") : GPR, REG, GPR14 regvar.
|
|
|
|
GP("r15") : GPR, GPRGP.
|
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
R16("r16") : GPR, GPR16.
|
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
R23("r23") : GPR.
|
2013-05-24 16:04:29 +00:00
|
|
|
FP("fp") : GPR, GPRFP.
|
2013-05-16 23:03:38 +00:00
|
|
|
SP("sp") : GPR, GPRSP.
|
2013-05-19 22:33:42 +00:00
|
|
|
LR("lr") : GPR, GPRLR.
|
|
|
|
PC("pc") : GPR, GPRPC.
|
|
|
|
/* r26 to r31 are special and the code generator doesn't touch them. */
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
#define SCRATCH R16
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
TOKENS
|
|
|
|
|
|
|
|
/* Used only in instruction descriptions (to generate the correct syntax). */
|
|
|
|
|
2013-05-19 22:33:42 +00:00
|
|
|
GPROFFSET = { GPR reg; INT off; } 4 off "(" reg ")".
|
|
|
|
GPRGPR = { GPR reg1; GPR reg2; } 4 "(" reg1 "," reg2 ")".
|
2013-05-24 16:04:29 +00:00
|
|
|
GPRINC = { GPR reg; } 4 "(" reg ")++".
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
/* Primitives */
|
|
|
|
|
|
|
|
LABEL = { ADDR adr; } 4 adr.
|
2013-05-19 22:33:42 +00:00
|
|
|
CONST = { INT val; } 4 "#" val.
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
/* Allows us to use regvar() to refer to registers */
|
|
|
|
|
|
|
|
GPRE = { GPR reg; } 4 reg.
|
|
|
|
|
2013-05-22 22:12:48 +00:00
|
|
|
/* Sign extended values. */
|
|
|
|
|
|
|
|
/* The size refers to the *source*. */
|
|
|
|
SIGNEX8 = { GPR reg; } 4 reg.
|
|
|
|
SIGNEX16 = { GPR reg; } 4 reg.
|
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
/* The results of comparisons. */
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
TRISTATE_RC_S = { GPR reg; INT val; } 4.
|
|
|
|
TRISTATE_RC_U = { GPR reg; INT val; } 4.
|
|
|
|
TRISTATE_RR_S = { GPR reg1; GPR reg2; } 4.
|
|
|
|
TRISTATE_RR_U = { GPR reg1; GPR reg2; } 4.
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SETS
|
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
TOKEN = LABEL + CONST.
|
2013-05-16 23:03:38 +00:00
|
|
|
GPRI = GPR + GPRE.
|
2013-05-22 22:12:48 +00:00
|
|
|
OP = TOKEN + SIGNEX8 + SIGNEX16.
|
|
|
|
XREG = GPRI + SIGNEX8 + SIGNEX16.
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSTRUCTIONS
|
|
|
|
|
2013-05-22 22:12:48 +00:00
|
|
|
add XREG:wo, XREG:ro, XREG+CONST:ro.
|
|
|
|
add XREG:rw, XREG+CONST:ro.
|
|
|
|
adds2 XREG:rw, XREG+CONST:ro.
|
|
|
|
adds4 XREG:rw, XREG+CONST:ro.
|
|
|
|
adds8 XREG:rw, XREG+CONST:ro.
|
|
|
|
adds16 XREG:rw, XREG+CONST:ro.
|
|
|
|
adds256 XREG:rw, XREG:rw, XREG:ro.
|
|
|
|
and XREG:rw, XREG+CONST:ro.
|
|
|
|
asr XREG:rw, XREG+CONST:ro.
|
2013-05-19 22:33:42 +00:00
|
|
|
beq "b.eq" LABEL:ro.
|
|
|
|
bne "b.ne" LABEL:ro.
|
2013-05-20 21:35:12 +00:00
|
|
|
bgt "b.gt" LABEL:ro.
|
|
|
|
bgt "b.gt" LABEL:ro.
|
|
|
|
bhi "b.hi" LABEL:ro.
|
2013-05-24 16:04:29 +00:00
|
|
|
bset XREG:rw, XREG+CONST:ro.
|
2013-05-22 22:12:48 +00:00
|
|
|
b XREG+LABEL:ro.
|
|
|
|
bl XREG+LABEL:ro.
|
|
|
|
cmp XREG:ro, XREG+CONST:ro kills :cc.
|
|
|
|
divs XREG:wo, XREG:ro, XREG+CONST:ro.
|
|
|
|
divu XREG:wo, XREG:ro, XREG+CONST:ro.
|
|
|
|
eor XREG:rw, XREG+CONST:ro.
|
|
|
|
exts XREG:wo, XREG:ro, XREG+CONST:ro.
|
|
|
|
exts XREG:rw, XREG+CONST:ro.
|
|
|
|
fadd XREG:wo, XREG:ro, XREG:ro.
|
|
|
|
fcmp XREG:wo, XREG:ro, XREG:ro.
|
|
|
|
fdiv XREG:wo, XREG:ro, XREG:ro.
|
|
|
|
fmul XREG:wo, XREG:ro, XREG:ro.
|
|
|
|
fsub XREG:wo, XREG:ro, XREG:ro.
|
2013-05-24 16:04:29 +00:00
|
|
|
ld XREG:wo, GPRINC:rw.
|
2013-05-22 22:12:48 +00:00
|
|
|
ld XREG:wo, GPROFFSET+GPRGPR+LABEL:ro.
|
|
|
|
ldb XREG:wo, GPROFFSET+GPRGPR+LABEL:ro.
|
|
|
|
ldh XREG:wo, GPROFFSET+GPRGPR+LABEL:ro.
|
|
|
|
ldhs XREG:wo, GPROFFSET+GPRGPR+LABEL:ro.
|
|
|
|
lea XREG:wo, LABEL:ro.
|
|
|
|
lsl XREG:rw, XREG+CONST:ro.
|
|
|
|
lsl XREG:wo, XREG:ro, XREG+CONST:ro.
|
|
|
|
lsr XREG:rw, XREG+CONST:ro.
|
|
|
|
mov XREG:wo, XREG+CONST:ro.
|
|
|
|
mul XREG:rw, XREG+CONST:ro.
|
|
|
|
neg XREG:rw, XREG+CONST:ro.
|
|
|
|
or XREG:rw, XREG+CONST:ro.
|
2013-05-24 16:04:29 +00:00
|
|
|
pop GPR0+GPR6+GPR16+GPRFP+GPRPC:wo.
|
|
|
|
pop GPR0+GPR6+GPR16+GPRFP:wo, GPRPC:wo.
|
|
|
|
push GPR0+GPR6+GPR16+GPRFP+GPRLR:ro.
|
|
|
|
push GPR0+GPR6+GPR16+GPRFP:ro, GPRLR:ro.
|
2013-05-22 22:12:48 +00:00
|
|
|
sub XREG:wo, XREG:ro, CONST+XREG:ro.
|
|
|
|
sub XREG:rw, XREG+CONST:ro.
|
|
|
|
st XREG:ro, GPROFFSET+GPRGPR+LABEL:ro.
|
|
|
|
stb XREG:ro, GPROFFSET+GPRGPR+LABEL:ro.
|
|
|
|
sth XREG:ro, GPROFFSET+GPRGPR+LABEL:ro.
|
|
|
|
sths XREG:ro, GPROFFSET+GPRGPR+LABEL:ro.
|
2013-05-19 22:33:42 +00:00
|
|
|
|
|
|
|
invalid "invalid".
|
2013-05-24 16:04:29 +00:00
|
|
|
comment "!" LABEL:ro.
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MOVES
|
|
|
|
|
|
|
|
from GPR to GPR
|
|
|
|
gen
|
2013-05-19 22:33:42 +00:00
|
|
|
COMMENT("mov GPR->GPR")
|
|
|
|
mov %2, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
/* GPRE exists solely to allow us to use regvar() (which can only be used in
|
|
|
|
an expression) as a register constant. */
|
|
|
|
|
2013-05-19 22:33:42 +00:00
|
|
|
from GPRE to GPR
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-19 22:33:42 +00:00
|
|
|
mov %2, %1
|
|
|
|
|
|
|
|
/* Constants */
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
from CONST to GPR
|
|
|
|
gen
|
2013-05-19 22:33:42 +00:00
|
|
|
mov %2, %1
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
from LABEL to GPR
|
|
|
|
gen
|
2013-05-19 22:33:42 +00:00
|
|
|
lea %2, {LABEL, %1.adr}
|
2013-05-20 21:35:12 +00:00
|
|
|
sub %2, GP
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-22 22:12:48 +00:00
|
|
|
/* Sign extension */
|
|
|
|
|
|
|
|
from SIGNEX8 to GPR
|
|
|
|
gen
|
|
|
|
exts %2, %1.reg, {CONST, 8}
|
|
|
|
|
|
|
|
from SIGNEX16 to GPR
|
|
|
|
gen
|
|
|
|
exts %2, %1.reg, {CONST, 16}
|
|
|
|
|
2013-05-19 22:33:42 +00:00
|
|
|
/* Miscellaneous */
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
from CONST+LABEL+GPR+GPRE to GPRE
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-19 22:33:42 +00:00
|
|
|
move %1, %2.reg
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
2013-05-19 22:33:42 +00:00
|
|
|
TESTS
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-19 22:33:42 +00:00
|
|
|
to test GPR
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
cmp %1, {CONST, 0}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-19 22:33:42 +00:00
|
|
|
STACKINGRULES
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
from GPR0+GPR6+GPR16 to STACK
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-24 16:04:29 +00:00
|
|
|
comment {LABEL, "push stackable"}
|
|
|
|
push %1
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-24 23:33:38 +00:00
|
|
|
from OP+GPRI to STACK
|
|
|
|
uses GPR0
|
|
|
|
gen
|
|
|
|
move %1, %a
|
|
|
|
push %a
|
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
from OP+GPRI to STACK
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-24 16:04:29 +00:00
|
|
|
comment {LABEL, "push via scratch"}
|
2013-05-16 23:03:38 +00:00
|
|
|
move %1, SCRATCH
|
2013-05-24 16:04:29 +00:00
|
|
|
push SCRATCH
|
|
|
|
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
COERCIONS
|
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
from GPRI
|
2013-05-20 21:35:12 +00:00
|
|
|
uses reusing %1, REG=%1
|
2013-05-19 22:33:42 +00:00
|
|
|
yields %a
|
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
from GPR
|
|
|
|
yields {GPRE, %1}
|
|
|
|
|
|
|
|
from OP
|
|
|
|
uses GPR0
|
|
|
|
gen
|
|
|
|
move %1, %a
|
|
|
|
yields %a
|
|
|
|
|
2013-05-22 22:12:48 +00:00
|
|
|
from OP
|
2013-05-16 23:03:38 +00:00
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
move %1, %a
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
from STACK
|
2013-05-24 16:04:29 +00:00
|
|
|
uses REG
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-24 16:04:29 +00:00
|
|
|
pop R0
|
|
|
|
move R0, %a
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
PATTERNS
|
|
|
|
|
|
|
|
/* Intrinsics */
|
|
|
|
|
|
|
|
pat loc /* Load constant */
|
|
|
|
yields {CONST, $1}
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat dup $1<=QUAD /* Duplicate word on top of stack */
|
|
|
|
with GPRI
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %1 %1
|
2013-05-20 21:35:12 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat dup $1<=(2*QUAD) /* Duplicate word pair on top of stack */
|
|
|
|
with GPRI GPRI
|
|
|
|
yields %1 %2 %1 %2
|
|
|
|
|
|
|
|
pat exg $1==QUAD /* Exchange top two words on stack */
|
|
|
|
with GPRI GPRI
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %1 %2
|
2013-05-20 21:35:12 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat stl lol $1==$2 /* Store then load local */
|
|
|
|
leaving
|
2013-05-21 17:16:30 +00:00
|
|
|
dup QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
stl $1
|
|
|
|
|
|
|
|
pat lal sti lal loi $1==$3 && $2==$4 /* Store then load local, of a different size */
|
|
|
|
leaving
|
2013-05-20 21:35:12 +00:00
|
|
|
dup $2
|
2013-05-16 23:03:38 +00:00
|
|
|
lal $1
|
|
|
|
sti $2
|
|
|
|
|
|
|
|
pat ste loe $1==$2 /* Store then load external */
|
|
|
|
leaving
|
|
|
|
dup 4
|
|
|
|
ste $1
|
2013-05-21 19:05:26 +00:00
|
|
|
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
/* Type conversions */
|
|
|
|
|
|
|
|
pat loc loc cii loc loc cii $1==$4 && $2==$5 /* madness, generated by the C compiler */
|
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
loc $2
|
|
|
|
cii
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat loc loc cii loc loc cii $2==QUAD && $5==QUAD && $4<$2 /* madness, generated by the C compiler */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
|
|
|
loc $4
|
|
|
|
loc $5
|
|
|
|
cii
|
|
|
|
|
|
|
|
pat loc loc ciu /* signed X -> unsigned X */
|
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
loc $2
|
|
|
|
cuu
|
|
|
|
|
|
|
|
pat loc loc cuu $1==$2 /* unsigned X -> unsigned X */
|
|
|
|
/* nop */
|
|
|
|
|
|
|
|
pat loc loc cii $1==$2 /* signed X -> signed X */
|
|
|
|
/* nop */
|
|
|
|
|
|
|
|
pat loc loc cui $1==$2 /* unsigned X -> signed X */
|
|
|
|
/* nop */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat loc loc cui $1==BYTE && $2==QUAD /* unsigned char -> signed int */
|
2013-05-16 23:03:38 +00:00
|
|
|
/* nop */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat loc loc cui $1==WORD && $2==QUAD /* unsigned short -> signed int */
|
2013-05-16 23:03:38 +00:00
|
|
|
/* nop */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat loc loc cii $1==BYTE && $2>BYTE /* signed char -> anything */
|
2013-05-22 22:12:48 +00:00
|
|
|
with GPR
|
|
|
|
yields {SIGNEX8, %1}
|
|
|
|
with GPRE
|
|
|
|
yields {SIGNEX8, %1.reg}
|
|
|
|
with SIGNEX8
|
|
|
|
yields {SIGNEX8, %1.reg}
|
|
|
|
with SIGNEX16
|
|
|
|
yields {SIGNEX8, %1.reg}
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat loc loc cii $1==WORD && $2>WORD /* signed short -> anything */
|
2013-05-22 22:12:48 +00:00
|
|
|
with GPR
|
|
|
|
yields {SIGNEX16, %1}
|
|
|
|
with GPRE
|
|
|
|
yields {SIGNEX16, %1.reg}
|
|
|
|
with SIGNEX8
|
|
|
|
yields {SIGNEX16, %1.reg}
|
|
|
|
with SIGNEX16
|
|
|
|
yields {SIGNEX16, %1.reg}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Local variables */
|
|
|
|
|
|
|
|
pat lal /* Load address of local */
|
2013-05-20 21:35:12 +00:00
|
|
|
uses REG
|
|
|
|
gen
|
2013-05-22 09:55:13 +00:00
|
|
|
sub %a, FP, GP
|
|
|
|
add %a, {CONST, $1}
|
2013-05-20 21:35:12 +00:00
|
|
|
yields %a
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat lol inreg($1)>0 /* Load from local */
|
2013-05-20 21:35:12 +00:00
|
|
|
yields {GPRE, regvar($1)}
|
|
|
|
|
|
|
|
pat lol /* Load quad from local */
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
ld %a, {GPROFFSET, FP, $1}
|
|
|
|
yields %a
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat ldl /* Load double-word from local */
|
|
|
|
leaving
|
2013-05-22 09:55:13 +00:00
|
|
|
lol $1 + QUAD*1
|
2013-05-22 22:55:23 +00:00
|
|
|
lol $1 + QUAD*0
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat stl inreg($1)>0 /* Store to local */
|
2013-05-20 21:35:12 +00:00
|
|
|
with CONST+GPRI
|
|
|
|
kills regvar($1)
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
|
|
|
move %1, {GPRE, regvar($1)}
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat stl /* Store to local */
|
2013-05-20 21:35:12 +00:00
|
|
|
with GPRI
|
|
|
|
gen
|
|
|
|
st %1, {GPROFFSET, FP, $1}
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat sdl /* Store double-word to local */
|
|
|
|
leaving
|
2013-05-22 09:55:13 +00:00
|
|
|
stl $1 + QUAD*0
|
2013-05-22 22:55:23 +00:00
|
|
|
stl $1 + QUAD*1
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat lil inreg($1)>0 /* Load from indirected local */
|
|
|
|
uses REG
|
|
|
|
gen
|
2013-05-19 22:33:42 +00:00
|
|
|
ld %a, {GPROFFSET, regvar($1), 0}
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat lil /* Load from indirected local */
|
|
|
|
leaving
|
|
|
|
lol $1
|
2013-05-21 17:16:30 +00:00
|
|
|
loi QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat sil /* Save to indirected local */
|
|
|
|
leaving
|
|
|
|
lol $1
|
2013-05-21 17:16:30 +00:00
|
|
|
sti QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat stl lol $1==$2 /* Save then load (generated by C compiler) */
|
|
|
|
leaving
|
2013-05-22 09:55:13 +00:00
|
|
|
dup QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
stl $1
|
|
|
|
|
2013-05-22 09:55:13 +00:00
|
|
|
pat zrl /* Zero local */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
|
|
|
loc 0
|
|
|
|
stl $1
|
|
|
|
|
2013-05-22 09:55:13 +00:00
|
|
|
pat inl inreg($1)>0 /* Increment local in register */
|
|
|
|
kills regvar($1)
|
|
|
|
gen
|
|
|
|
add {GPRE, regvar($1)}, {CONST, 1}
|
|
|
|
|
|
|
|
pat inl inreg($1)<=0 /* Increment local */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
|
|
|
lol $1
|
|
|
|
loc 1
|
2013-05-22 09:55:13 +00:00
|
|
|
adi QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
stl $1
|
|
|
|
|
2013-05-22 09:55:13 +00:00
|
|
|
pat del inreg($1)>0 /* Decrement local in register */
|
|
|
|
kills regvar($1)
|
|
|
|
gen
|
|
|
|
sub {GPRE, regvar($1)}, {CONST, 1}
|
|
|
|
|
|
|
|
pat del inreg($1)<=0 /* Decrement local */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
|
|
|
lol $1
|
|
|
|
loc 1
|
2013-05-22 09:55:13 +00:00
|
|
|
sbi QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
stl $1
|
|
|
|
|
|
|
|
|
|
|
|
/* Global variables */
|
|
|
|
|
|
|
|
pat lpi /* Load address of external function */
|
|
|
|
leaving
|
|
|
|
lae $1
|
|
|
|
|
|
|
|
pat lae /* Load address of external */
|
|
|
|
yields {LABEL, $1}
|
|
|
|
|
|
|
|
pat loe /* Load word external */
|
|
|
|
leaving
|
|
|
|
lae $1
|
2013-05-21 17:16:30 +00:00
|
|
|
loi QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat ste /* Store word external */
|
|
|
|
leaving
|
|
|
|
lae $1
|
2013-05-21 17:16:30 +00:00
|
|
|
sti QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat zre /* Zero external */
|
|
|
|
leaving
|
|
|
|
loc 0
|
|
|
|
ste $1
|
|
|
|
|
|
|
|
pat ine /* Increment external */
|
2013-05-21 19:05:26 +00:00
|
|
|
leaving
|
|
|
|
lae $1
|
|
|
|
dup QUAD
|
|
|
|
loi QUAD
|
|
|
|
inc
|
|
|
|
sti QUAD
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat dee /* Decrement external */
|
2013-05-21 19:05:26 +00:00
|
|
|
leaving
|
|
|
|
lae $1
|
|
|
|
dup QUAD
|
|
|
|
loi QUAD
|
|
|
|
dec
|
|
|
|
sti QUAD
|
|
|
|
|
2013-05-22 22:55:23 +00:00
|
|
|
pat lde /* Load double external */
|
|
|
|
leaving
|
|
|
|
lae $1
|
|
|
|
loi QUAD*2
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-22 22:55:23 +00:00
|
|
|
pat sde /* Store double external */
|
|
|
|
leaving
|
|
|
|
lae $1
|
|
|
|
sti QUAD*2
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Structures */
|
|
|
|
|
|
|
|
pat lof /* Load word offsetted */
|
|
|
|
leaving
|
|
|
|
adp $1
|
2013-05-21 17:16:30 +00:00
|
|
|
loi QUAD
|
2013-05-21 19:05:26 +00:00
|
|
|
|
|
|
|
pat ldf /* Load double offsetted */
|
|
|
|
with GPRI
|
|
|
|
uses reusing %1, REG=%1, REG
|
|
|
|
gen
|
|
|
|
add %a, GP
|
|
|
|
ld %b, {GPROFFSET, %a, $1+4}
|
|
|
|
ld %a, {GPROFFSET, %a, $1+0}
|
|
|
|
yields %a %b
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat stf /* Store word offsetted */
|
|
|
|
leaving
|
|
|
|
adp $1
|
2013-05-21 17:16:30 +00:00
|
|
|
sti QUAD
|
2013-05-21 19:05:26 +00:00
|
|
|
|
|
|
|
pat sdf /* Store double offsetted */
|
|
|
|
with GPRI GPRI GPRI
|
|
|
|
uses reusing %3, REG=%3
|
|
|
|
gen
|
|
|
|
add %a, GP
|
|
|
|
st %1, {GPROFFSET, %a, $1+0}
|
|
|
|
st %2, {GPROFFSET, %a, $1+4}
|
|
|
|
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Loads and stores */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat loi $1==BYTE /* Load byte indirect */
|
2013-05-22 09:55:13 +00:00
|
|
|
with LABEL
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
ldb %a, %1
|
|
|
|
yields %a
|
2013-05-16 23:03:38 +00:00
|
|
|
with GPR
|
2013-05-20 21:35:12 +00:00
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
|
|
|
ldb %a, {GPRGPR, %1, GP}
|
|
|
|
yields %a
|
|
|
|
with GPRE
|
|
|
|
uses reusing %1.reg, REG
|
|
|
|
gen
|
|
|
|
ldb %a, {GPRGPR, %1.reg, GP}
|
|
|
|
yields %a
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-22 09:55:13 +00:00
|
|
|
pat loi loc loc cii $1==WORD && $2==WORD && $3==QUAD /* Load short indirect and sign extend */
|
|
|
|
with LABEL
|
2013-05-16 23:03:38 +00:00
|
|
|
uses REG
|
|
|
|
gen
|
2013-05-22 09:55:13 +00:00
|
|
|
ldhs %a, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-22 09:55:13 +00:00
|
|
|
with GPRI
|
2013-05-16 23:03:38 +00:00
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
2013-05-22 09:55:13 +00:00
|
|
|
add %a, %1, GP
|
|
|
|
ldhs %a, {GPROFFSET, %a, 0}
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
|
|
|
|
2013-05-22 22:55:23 +00:00
|
|
|
pat loi $1==WORD /* Load short indirect */
|
2013-05-22 09:55:13 +00:00
|
|
|
with LABEL
|
2013-05-16 23:03:38 +00:00
|
|
|
uses REG
|
|
|
|
gen
|
2013-05-22 09:55:13 +00:00
|
|
|
ldh %a, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-22 09:55:13 +00:00
|
|
|
with GPRI
|
2013-05-16 23:03:38 +00:00
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
2013-05-22 09:55:13 +00:00
|
|
|
add %a, %1, GP
|
|
|
|
ldh %a, {GPROFFSET, %a, 0}
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-22 09:55:13 +00:00
|
|
|
|
2013-05-22 22:55:23 +00:00
|
|
|
pat loi $1==QUAD /* Load quad indirect */
|
2013-05-22 09:55:13 +00:00
|
|
|
with LABEL
|
2013-05-16 23:03:38 +00:00
|
|
|
uses REG
|
|
|
|
gen
|
2013-05-22 09:55:13 +00:00
|
|
|
ld %a, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-22 09:55:13 +00:00
|
|
|
with GPRI
|
2013-05-20 21:35:12 +00:00
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
|
|
|
add %a, %1, GP
|
|
|
|
ld %a, {GPROFFSET, %a, 0}
|
|
|
|
yields %a
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-22 22:55:23 +00:00
|
|
|
pat loi $1==2*QUAD /* Load double-quad indirect */
|
|
|
|
with LABEL
|
|
|
|
uses REG, REG
|
|
|
|
gen
|
|
|
|
lea %b, %1
|
|
|
|
ld %a, {GPROFFSET, %b, 0}
|
|
|
|
ld %b, {GPROFFSET, %b, 4}
|
|
|
|
yields %b %a
|
|
|
|
with GPRI
|
|
|
|
uses reusing %1, REG, REG
|
|
|
|
gen
|
|
|
|
add %b, %1, GP
|
|
|
|
ld %a, {GPROFFSET, %b, 0}
|
|
|
|
ld %b, {GPROFFSET, %b, 4}
|
|
|
|
yields %b %a
|
|
|
|
|
2013-05-22 09:55:13 +00:00
|
|
|
pat loi !nicesize($1) /* Load arbitrary size */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
|
|
|
loc $1
|
2013-05-21 17:16:30 +00:00
|
|
|
los QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat los /* Load arbitrary size */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".los"
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat sti $1==BYTE /* Store byte indirect */
|
2013-05-22 22:12:48 +00:00
|
|
|
with LABEL GPRI+SIGNEX8+SIGNEX16
|
2013-05-22 09:55:13 +00:00
|
|
|
gen
|
|
|
|
stb %2, %1
|
2013-05-22 22:12:48 +00:00
|
|
|
with GPR GPRI+SIGNEX8+SIGNEX16
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
stb %2, {GPRGPR, %1, GP}
|
2013-05-22 22:12:48 +00:00
|
|
|
with GPRE GPRI+SIGNEX8+SIGNEX16
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
stb %2, {GPRGPR, %1.reg, GP}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat sti $1==WORD /* Store half-word indirect */
|
2013-05-22 22:12:48 +00:00
|
|
|
with LABEL GPRI+SIGNEX16
|
2013-05-22 09:55:13 +00:00
|
|
|
gen
|
|
|
|
sth %2, %1
|
2013-05-22 22:12:48 +00:00
|
|
|
with GPRI GPRI+SIGNEX16
|
2013-05-22 09:55:13 +00:00
|
|
|
uses reusing %1, REG
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
add %a, %1, GP
|
|
|
|
sth %2, {GPROFFSET, %a, 0}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat sti $1==QUAD /* Store quad indirect */
|
2013-05-22 09:55:13 +00:00
|
|
|
with LABEL GPRI
|
|
|
|
gen
|
|
|
|
st %2, %1
|
|
|
|
with GPRI GPRI
|
|
|
|
uses reusing %1, REG
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
add %a, %1, GP
|
|
|
|
st %2, {GPROFFSET, %a, 0}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-22 22:55:23 +00:00
|
|
|
pat sti $1==2*QUAD /* Load double-quad indirect */
|
|
|
|
with LABEL GPRI GPRI
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
lea %a, %1
|
|
|
|
st %2, {GPROFFSET, %a, 0}
|
|
|
|
st %3, {GPROFFSET, %a, 4}
|
|
|
|
with GPRI GPRI GPRI
|
|
|
|
uses reusing %1, REG=%1
|
|
|
|
gen
|
|
|
|
add %a, GP
|
|
|
|
st %2, {GPROFFSET, %a, 0}
|
|
|
|
st %3, {GPROFFSET, %a, 4}
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat sti /* Store arbitrary size */
|
|
|
|
leaving
|
|
|
|
loc $1
|
2013-05-21 17:16:30 +00:00
|
|
|
sts QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat sts /* Load arbitrary size */
|
2013-05-20 22:27:45 +00:00
|
|
|
with STACK
|
2013-05-16 23:03:38 +00:00
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
bl {LABEL, ".sts"}
|
2013-05-20 22:27:45 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Arithmetic wrappers */
|
|
|
|
|
2013-05-22 20:37:48 +00:00
|
|
|
pat ads /* Add var to pointer */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving adi $1
|
|
|
|
|
2013-05-22 20:37:48 +00:00
|
|
|
pat sbs /* Subtract var from pointer */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving sbi $1
|
|
|
|
|
|
|
|
pat adp /* Add constant to pointer */
|
|
|
|
leaving
|
|
|
|
loc $1
|
2013-05-22 20:37:48 +00:00
|
|
|
adi QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat adu /* Add unsigned */
|
|
|
|
leaving
|
|
|
|
adi $1
|
|
|
|
|
|
|
|
pat sbu /* Subtract unsigned */
|
|
|
|
leaving
|
|
|
|
sbi $1
|
|
|
|
|
|
|
|
pat inc /* Add 1 */
|
|
|
|
leaving
|
|
|
|
loc 1
|
2013-05-22 20:37:48 +00:00
|
|
|
adi QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat dec /* Subtract 1 */
|
|
|
|
leaving
|
|
|
|
loc 1
|
2013-05-22 20:37:48 +00:00
|
|
|
sbi QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-22 20:37:48 +00:00
|
|
|
pat loc mlu /* Unsigned multiply by constant */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
|
|
|
loc $1
|
2013-05-22 20:37:48 +00:00
|
|
|
mli QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat mlu /* Unsigned multiply by var */
|
|
|
|
leaving
|
2013-05-22 20:37:48 +00:00
|
|
|
mli QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat loc slu /* Shift left unsigned by constant amount */
|
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
sli $2
|
|
|
|
|
|
|
|
pat slu /* Shift left unsigned by variable amount */
|
|
|
|
leaving
|
|
|
|
sli $1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Word arithmetic */
|
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
pat loc adi $1==0 /* Add nothing */
|
|
|
|
/* nop */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat adi $1==QUAD /* Add word (second + top) */
|
2013-05-20 21:35:12 +00:00
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
add %a, %1
|
|
|
|
yields %a
|
|
|
|
with GPRI GPRI+CONST
|
|
|
|
uses reusing %1, REG=%1
|
|
|
|
gen
|
|
|
|
add %a, %2
|
|
|
|
yields %a
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
pat loc sbi $1==0 /* Subtract nothing */
|
|
|
|
/* nop */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat sbi $1==QUAD /* Subtract word (second - top) */
|
2013-05-20 21:35:12 +00:00
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
sub %a, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-20 21:35:12 +00:00
|
|
|
|
2013-05-21 19:05:26 +00:00
|
|
|
pat mli $1==QUAD /* Multiply word (second * top) */
|
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
mul %a, %1
|
|
|
|
yields %a
|
|
|
|
with GPRI GPRI+CONST
|
|
|
|
uses reusing %1, REG=%1
|
|
|
|
gen
|
|
|
|
mul %a, %2
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat mlu
|
|
|
|
leaving
|
|
|
|
mli $1
|
|
|
|
|
|
|
|
pat dvi $1==QUAD /* Divide word (second / top) */
|
|
|
|
with GPRI GPRI
|
|
|
|
uses reusing %2, REG
|
|
|
|
gen
|
|
|
|
divs %a, %2, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat dvu $1==QUAD /* Divide unsigned word (second / top) */
|
|
|
|
with GPRI GPRI
|
|
|
|
uses reusing %2, REG
|
|
|
|
gen
|
|
|
|
divu %a, %2, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat rmu $1==QUAD /* Remainder unsigned word (second % top) */
|
|
|
|
with GPRI GPRI
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
divu %a, %2, %1
|
|
|
|
mul %a, %1
|
|
|
|
sub %a, %2
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat rmi $1==QUAD /* Remainder signed word (second % top) */
|
|
|
|
with GPRI GPRI
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
divs %a, %2, %1
|
|
|
|
mul %a, %1
|
|
|
|
sub %a, %2
|
|
|
|
yields %a
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat ngi $1==QUAD /* Negate word */
|
2013-05-20 21:35:12 +00:00
|
|
|
with GPRI
|
|
|
|
uses reusing %1, REG=%1
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
neg %a, %a
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-20 21:35:12 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat and $1==QUAD /* AND word */
|
2013-05-20 22:27:45 +00:00
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
and %a, %1
|
|
|
|
yields %a
|
|
|
|
with GPRI GPRI+CONST
|
|
|
|
uses reusing %1, REG=%1
|
|
|
|
gen
|
|
|
|
and %a, %2
|
|
|
|
yields %a
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat ior $1==QUAD /* OR word */
|
2013-05-20 22:27:45 +00:00
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
or %a, %1
|
|
|
|
yields %a
|
|
|
|
with GPRI GPRI+CONST
|
|
|
|
uses reusing %1, REG=%1
|
|
|
|
gen
|
|
|
|
or %a, %2
|
|
|
|
yields %a
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat xor $1==QUAD /* XOR word */
|
2013-05-20 22:27:45 +00:00
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
eor %a, %1
|
|
|
|
yields %a
|
|
|
|
with GPRI GPRI+CONST
|
|
|
|
uses reusing %1, REG=%1
|
|
|
|
gen
|
|
|
|
eor %a, %2
|
|
|
|
yields %a
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat dvi $1==QUAD /* Divide word (second / top) */
|
2013-05-20 22:27:45 +00:00
|
|
|
with GPRI GPRI
|
2013-05-16 23:03:38 +00:00
|
|
|
uses reusing %2, REG
|
|
|
|
gen
|
2013-05-20 22:27:45 +00:00
|
|
|
divs %a, %2, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-20 22:27:45 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat dvu $1==QUAD /* Divide unsigned word (second / top) */
|
2013-05-20 22:27:45 +00:00
|
|
|
with GPRI GPRI
|
2013-05-16 23:03:38 +00:00
|
|
|
uses reusing %2, REG
|
|
|
|
gen
|
2013-05-20 22:27:45 +00:00
|
|
|
divu %a, %2, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-20 22:27:45 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat rmu $1==QUAD /* Remainder unsigned word (second % top) */
|
2013-05-20 22:27:45 +00:00
|
|
|
with GPRI GPRI
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
divu %a, %2, %1
|
|
|
|
mul %a, %1
|
|
|
|
sub %a, %2
|
|
|
|
yields %a
|
|
|
|
|
2013-05-21 19:05:26 +00:00
|
|
|
pat rmi $1==QUAD /* Remainder signed word (second % top) */
|
|
|
|
with GPRI GPRI
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
divs %a, %2, %1
|
|
|
|
mul %a, %1
|
|
|
|
sub %a, %2
|
|
|
|
yields %a
|
|
|
|
|
2013-05-20 22:27:45 +00:00
|
|
|
#if 0
|
|
|
|
pat mli $1==4 /* Multiply word (second * top) */
|
2013-05-16 23:03:38 +00:00
|
|
|
with REG REG
|
|
|
|
uses reusing %2, REG
|
|
|
|
gen
|
2013-05-20 22:27:45 +00:00
|
|
|
mullw %a, %2, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-20 22:27:45 +00:00
|
|
|
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat xor $1==4 /* XOR word */
|
|
|
|
with GPR GPR
|
|
|
|
yields {XOR_RR, %1, %2}
|
|
|
|
with GPR CONST
|
|
|
|
yields {XOR_RC, %1, %2.val}
|
|
|
|
with CONST GPR
|
|
|
|
yields {XOR_RC, %2, %1.val}
|
|
|
|
|
|
|
|
pat xor !defined($1) /* XOR set */
|
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
bl {LABEL, ".xor"}
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat com $1==QUAD /* NOT word */
|
2013-05-16 23:03:38 +00:00
|
|
|
with AND_RR
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
nand %a, %1.reg1, %1.reg2
|
|
|
|
yields %a
|
|
|
|
with OR_RR
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
nor %a, %1.reg1, %1.reg2
|
|
|
|
yields %a
|
|
|
|
with XOR_RR
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
eqv %a, %1.reg1, %1.reg2
|
|
|
|
yields %a
|
|
|
|
with GPR
|
|
|
|
yields {NOT_R, %1}
|
|
|
|
|
|
|
|
pat com !defined($1) /* NOT set */
|
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
bl {LABEL, ".com"}
|
2013-05-19 22:33:42 +00:00
|
|
|
#endif
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat sli $1==4 /* Shift left (second << top) */
|
2013-05-20 21:35:12 +00:00
|
|
|
with CONST+GPRI GPRI
|
|
|
|
uses reusing %2, REG=%2
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
lsl %a, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat sri $1==4 /* Shift right signed (second >> top) */
|
2013-05-21 17:16:30 +00:00
|
|
|
with CONST+GPRI GPRI
|
|
|
|
uses reusing %2, REG=%2
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-21 17:16:30 +00:00
|
|
|
asr %2, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat sru $1==4 /* Shift right unsigned (second >> top) */
|
2013-05-21 17:16:30 +00:00
|
|
|
with CONST+GPRI GPRI
|
|
|
|
uses reusing %2, REG=%2
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-21 17:16:30 +00:00
|
|
|
lsr %2, %1
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
2013-05-22 20:37:48 +00:00
|
|
|
/* Special arithmetic */
|
|
|
|
|
|
|
|
pat loc sli adi $1==1 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<1) */
|
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
adds2 %a, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat loc sli adi $1==2 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<2) */
|
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
adds4 %a, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat loc sli adi $1==3 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<3) */
|
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
adds8 %a, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat loc sli adi $1==4 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<4) */
|
|
|
|
with GPRI+CONST GPRI
|
|
|
|
uses reusing %2, REG=%2
|
|
|
|
gen
|
|
|
|
adds16 %a, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat loc sli adi $1==8 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<8) */
|
|
|
|
with GPRI GPRI
|
|
|
|
uses reusing %2, REG
|
|
|
|
gen
|
|
|
|
adds256 %a, %2, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat loc sli ads
|
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
sli $2
|
|
|
|
adi $3
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
/* Arrays */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat aar $1==QUAD /* Index array */
|
2013-05-21 19:05:26 +00:00
|
|
|
with STACK
|
|
|
|
uses GPR0
|
|
|
|
gen
|
|
|
|
bl {LABEL, ".aar4stack"}
|
|
|
|
yields R0
|
|
|
|
with GPR0 GPR1 GPR2
|
|
|
|
uses GPR0
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
|
|
|
bl {LABEL, ".aar4"}
|
2013-05-21 19:05:26 +00:00
|
|
|
yields R0
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat lae lar $2==QUAD && nicesize(rom($1, 3)) /* Load array */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
|
|
|
lae $1
|
2013-05-21 17:16:30 +00:00
|
|
|
aar QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
loi rom($1, 3)
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat lar $1==QUAD /* Load array */
|
2013-05-21 19:05:26 +00:00
|
|
|
with STACK
|
|
|
|
uses GPR0
|
|
|
|
gen
|
|
|
|
bl {LABEL, ".lar4stack"}
|
|
|
|
yields R0
|
|
|
|
with GPR0 GPR1 GPR2
|
|
|
|
uses GPR0
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
|
|
|
bl {LABEL, ".lar4"}
|
2013-05-21 19:05:26 +00:00
|
|
|
yields R0
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat lae sar $2==QUAD && nicesize(rom($1, 3)) /* Store array */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
|
|
|
lae $1
|
2013-05-21 17:16:30 +00:00
|
|
|
aar QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
sti rom($1, 3)
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat sar $1==QUAD /* Store array */
|
2013-05-21 19:05:26 +00:00
|
|
|
with STACK
|
|
|
|
uses GPR0
|
|
|
|
gen
|
|
|
|
bl {LABEL, ".sar4stack"}
|
|
|
|
yields R0
|
|
|
|
with GPR0 GPR1 GPR2
|
|
|
|
uses GPR0
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
|
|
|
bl {LABEL, ".sar4"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Sets */
|
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
pat set $1==QUAD /* Create quad with one bit set */
|
|
|
|
with GPRI
|
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
|
|
|
bset %a, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat set defined($1) /* Any other set */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
2013-05-24 16:04:29 +00:00
|
|
|
loc $1
|
|
|
|
cal ".set"
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat set !defined($1) /* Create structure with set bit (variable) */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".set"
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat inn defined($1) /* Test for set bit */
|
|
|
|
leaving
|
2013-05-24 16:04:29 +00:00
|
|
|
set $1
|
|
|
|
and $1
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat inn !defined($1) /* Test for set bit (variable) */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".inn"
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
pat ior !nicesize($1) /* OR set */
|
|
|
|
leaving
|
|
|
|
cal ".ior"
|
|
|
|
|
|
|
|
pat ior !defined($1) /* OR set */
|
|
|
|
leaving
|
|
|
|
cal ".ior"
|
|
|
|
|
|
|
|
pat and !nicesize($1) /* AND set */
|
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
cal ".and"
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
pat and !defined($1) /* AND set */
|
|
|
|
leaving
|
|
|
|
cal ".and"
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Boolean resolutions */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
proc cm_t example teq
|
|
|
|
with GPRI GPRI
|
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
|
|
|
cmp %1, %2
|
|
|
|
mov %a, {CONST, 0}
|
|
|
|
add[1] %a, {CONST, 1}
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat cmu teq call cm_t("add.eq") /* top = (second == top) */
|
|
|
|
pat cmu tne call cm_t("add.ne") /* top = (second != top) */
|
|
|
|
pat cmu tlt call cm_t("add.lo") /* top = unsigned (second < top) */
|
|
|
|
pat cmu tle call cm_t("add.ls") /* top = unsigned (second <= top) */
|
|
|
|
pat cmu tgt call cm_t("add.hi") /* top = unsigned (second < top) */
|
|
|
|
pat cmu tge call cm_t("add.hs") /* top = unsigned (second >= top) */
|
|
|
|
pat cmi teq call cm_t("add.eq") /* top = (second == top) */
|
|
|
|
pat cmi tne call cm_t("add.ne") /* top = (second != top) */
|
|
|
|
pat cmi tlt call cm_t("add.lt") /* top = signed (second < top) */
|
|
|
|
pat cmi tle call cm_t("add.le") /* top = signed (second <= top) */
|
|
|
|
pat cmi tgt call cm_t("add.gt") /* top = signed (second < top) */
|
|
|
|
pat cmi tge call cm_t("add.ge") /* top = signed (second >= top) */
|
|
|
|
|
|
|
|
proc cmf_t example teq
|
|
|
|
with GPRI GPRI
|
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
|
|
|
fcmp %a, %1, %2
|
|
|
|
mov %a, {CONST, 0}
|
|
|
|
add[1] %a, {CONST, 1}
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat cmf teq call cmf_t("add.eq") /* top = float (second == top) */
|
|
|
|
pat cmf tne call cmf_t("add.ne") /* top = float (second != top) */
|
|
|
|
pat cmf tlt call cmf_t("add.lo") /* top = float (second < top) */
|
|
|
|
pat cmf tle call cmf_t("add.ls") /* top = float (second <= top) */
|
|
|
|
pat cmf tgt call cmf_t("add.hi") /* top = float (second < top) */
|
|
|
|
pat cmf tge call cmf_t("add.hs") /* top = float (second >= top) */
|
|
|
|
|
|
|
|
proc fallback_t example teq
|
2013-05-20 22:27:45 +00:00
|
|
|
with GPRI
|
2013-05-21 17:16:30 +00:00
|
|
|
uses reusing %1, REG
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 22:27:45 +00:00
|
|
|
cmp %1, {CONST, 0}
|
2013-05-21 17:16:30 +00:00
|
|
|
mov %a, {CONST, 0}
|
|
|
|
add[1] %a, {CONST, 1}
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat teq call fallback_t("add.eq") /* top = float (top == 0) */
|
|
|
|
pat tne call fallback_t("add.ne") /* top = float (top != 0) */
|
|
|
|
pat tlt call fallback_t("add.lo") /* top = float (top < 0) */
|
|
|
|
pat tle call fallback_t("add.ls") /* top = float (top <= 0) */
|
|
|
|
pat tgt call fallback_t("add.hi") /* top = float (top < 0) */
|
|
|
|
pat tge call fallback_t("add.hs") /* top = float (top >= 0) */
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Simple branches */
|
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
proc anyz example zeq
|
|
|
|
with GPRI STACK
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-19 22:33:42 +00:00
|
|
|
cmp %1, {CONST, 0}
|
2013-05-20 21:35:12 +00:00
|
|
|
beq[1] {LABEL, $1}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
pat zeq call anyz("b.eq") /* Branch if signed top == 0 */
|
|
|
|
pat zne call anyz("b.ne") /* Branch if signed top != 0 */
|
|
|
|
pat zgt call anyz("b.gt") /* Branch if signed top > 0 */
|
2013-05-20 22:27:45 +00:00
|
|
|
pat zlt call anyz("b.lt") /* Branch if signed top < 0 */
|
|
|
|
pat zge call anyz("b.ge") /* Branch if signed top >= 0 */
|
|
|
|
pat zle call anyz("b.le") /* Branch if signed top <= 0 */
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-20 21:35:12 +00:00
|
|
|
proc anyb example beq
|
2013-05-21 23:44:04 +00:00
|
|
|
with GPRI+CONST GPRI STACK
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
cmp %2, %1
|
|
|
|
beq[1] {LABEL, $1}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-21 23:44:04 +00:00
|
|
|
pat beq call anyb("b.eq") /* Branch if signed second == top */
|
|
|
|
pat bne call anyb("b.ne") /* Branch if signed second != top */
|
|
|
|
pat bgt call anyb("b.gt") /* Branch if signed second > top */
|
|
|
|
pat bge call anyb("b.ge") /* Branch if signed second >= top */
|
|
|
|
pat blt call anyb("b.lt") /* Branch if signed second < top */
|
|
|
|
pat ble call anyb("b.le") /* Branch if signed second <= top */
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
proc cmu_z example cmu zeq
|
2013-05-24 16:04:29 +00:00
|
|
|
with GPRI+CONST GPRI STACK
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
cmp %2, %1
|
|
|
|
beq[1] {LABEL, $2}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
pat cmu zeq call cmu_z("b.eq") /* Branch if unsigned second == top */
|
|
|
|
pat cmu zne call cmu_z("b.ne") /* Branch if unsigned second != top */
|
2013-05-21 17:16:30 +00:00
|
|
|
pat cmu zgt call cmu_z("b.hi") /* Branch if unsigned second > top */
|
|
|
|
pat cmu zlt call cmu_z("b.lo") /* Branch if unsigned second < top */
|
|
|
|
pat cmu zge call cmu_z("b.hs") /* Branch if unsigned second >= top */
|
|
|
|
pat cmu zle call cmu_z("b.ls") /* Branch if unsigned second <= top */
|
2013-05-24 16:04:29 +00:00
|
|
|
pat cmi zeq call cmu_z("b.eq") /* Branch if signed second == top */
|
|
|
|
pat cmi zne call cmu_z("b.ne") /* Branch if signed second != top */
|
|
|
|
pat cmi zgt call cmu_z("b.gt") /* Branch if signed second > top */
|
|
|
|
pat cmi zlt call cmu_z("b.lt") /* Branch if signed second < top */
|
|
|
|
pat cmi zge call cmu_z("b.ge") /* Branch if signed second >= top */
|
|
|
|
pat cmi zle call cmu_z("b.le") /* Branch if signed second <= top */
|
2013-05-21 17:16:30 +00:00
|
|
|
|
|
|
|
proc cmf_z example cmu zeq
|
|
|
|
with GPRI GPRI STACK
|
|
|
|
gen
|
|
|
|
fcmp %2, %2, %1
|
|
|
|
beq[1] {LABEL, $2}
|
|
|
|
|
|
|
|
pat cmf zeq call cmf_z("b.eq") /* Branch if float second == top */
|
|
|
|
pat cmf zne call cmf_z("b.ne") /* Branch if float second != top */
|
|
|
|
pat cmf zgt call cmf_z("b.gt") /* Branch if float second > top */
|
|
|
|
pat cmf zlt call cmf_z("b.lt") /* Branch if float second < top */
|
|
|
|
pat cmf zge call cmf_z("b.ge") /* Branch if float second >= top */
|
|
|
|
pat cmf zle call cmf_z("b.le") /* Branch if float second <= top */
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat cmp /* Compare pointers */
|
|
|
|
leaving
|
2013-05-21 17:16:30 +00:00
|
|
|
cmu QUAD
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat cms $1==QUAD /* Compare blocks (word sized) */
|
2013-05-16 23:03:38 +00:00
|
|
|
leaving
|
2013-05-21 17:16:30 +00:00
|
|
|
cmi QUAD
|
2013-05-20 22:27:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Other branching and labelling */
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
#if 0
|
|
|
|
pat lab topeltsize($1)<=4 && !fallthrough($1)
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
|
|
|
labeldef $1
|
2013-05-21 17:16:30 +00:00
|
|
|
yields R0
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat lab topeltsize($1)<=4 && fallthrough($1)
|
|
|
|
with GPR0
|
|
|
|
gen
|
|
|
|
labeldef $1
|
|
|
|
yields %1
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat lab topeltsize($1)>4
|
2013-05-16 23:03:38 +00:00
|
|
|
with STACK
|
2013-05-21 17:16:30 +00:00
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
labeldef $1
|
|
|
|
|
|
|
|
pat bra topeltsize($1)<=4 /* Unconditional jump with TOS register */
|
|
|
|
with GPR0 STACK
|
|
|
|
gen
|
|
|
|
b {LABEL, $1}
|
|
|
|
|
|
|
|
pat bra topeltsize($1)>4 /* Unconditional jump without TOS register */
|
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
b {LABEL, $1}
|
2013-05-19 22:33:42 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat lab
|
2013-05-16 23:03:38 +00:00
|
|
|
with STACK
|
2013-05-21 17:16:30 +00:00
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
labeldef $1
|
|
|
|
|
|
|
|
pat bra
|
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
b {LABEL, $1}
|
|
|
|
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Miscellaneous */
|
|
|
|
|
|
|
|
pat cal /* Call procedure */
|
|
|
|
with STACK
|
|
|
|
kills ALL
|
|
|
|
gen
|
|
|
|
bl {LABEL, $1}
|
|
|
|
|
|
|
|
pat cai /* Call procedure indirect */
|
|
|
|
with GPR STACK
|
|
|
|
kills ALL
|
|
|
|
gen
|
2013-05-19 22:33:42 +00:00
|
|
|
bl %1
|
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat lfr $1==QUAD /* Load function result, word */
|
2013-05-19 22:33:42 +00:00
|
|
|
yields R0
|
2013-05-16 23:03:38 +00:00
|
|
|
|
2013-05-24 16:04:29 +00:00
|
|
|
pat lfr $1==QUAD*2 /* Load function result, word */
|
|
|
|
yields R1 R0
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat ret $1==0 /* Return from procedure */
|
|
|
|
gen
|
|
|
|
return
|
2013-05-21 17:16:30 +00:00
|
|
|
mov SP, FP
|
|
|
|
pop FP, PC
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
pat ret $1<=QUAD /* Return from procedure, word */
|
2013-05-19 22:33:42 +00:00
|
|
|
with GPR0
|
2013-05-21 17:16:30 +00:00
|
|
|
gen
|
|
|
|
return
|
|
|
|
mov SP, FP
|
|
|
|
pop FP, PC
|
2013-05-24 16:04:29 +00:00
|
|
|
|
|
|
|
pat ret $1==QUAD*2 /* Return from procedure, word */
|
|
|
|
with GPRI GPRI
|
2013-05-21 17:16:30 +00:00
|
|
|
gen
|
2013-05-24 16:04:29 +00:00
|
|
|
move %1, R0
|
|
|
|
move %2, R1
|
2013-05-21 17:16:30 +00:00
|
|
|
return
|
|
|
|
mov SP, FP
|
|
|
|
pop FP, PC
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat blm /* Block move constant length */
|
2013-05-21 19:05:26 +00:00
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
bls
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat bls /* Block move variable length */
|
2013-05-21 19:05:26 +00:00
|
|
|
with STACK
|
|
|
|
kills ALL
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
|
|
|
bl {LABEL, "_memmove"}
|
2013-05-21 19:05:26 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat csa /* Array-lookup switch */
|
2013-05-20 22:27:45 +00:00
|
|
|
with STACK
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 22:27:45 +00:00
|
|
|
bl {LABEL, ".csa"}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat csb /* Table-lookup switch */
|
2013-05-20 22:27:45 +00:00
|
|
|
with STACK
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 22:27:45 +00:00
|
|
|
bl {LABEL, ".csb"}
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* EM specials */
|
|
|
|
|
|
|
|
pat fil /* Set current filename */
|
|
|
|
leaving
|
|
|
|
lae $1
|
|
|
|
ste ".filename"
|
|
|
|
|
|
|
|
pat lin /* Set current line number */
|
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
ste ".linenumber"
|
|
|
|
|
|
|
|
pat lni /* Increment line number */
|
|
|
|
leaving
|
|
|
|
ine ".linenumber"
|
|
|
|
|
|
|
|
pat lim /* Load EM trap ignore mask */
|
|
|
|
leaving
|
|
|
|
lde ".ignmask"
|
|
|
|
|
|
|
|
pat sim /* Store EM trap ignore mask */
|
|
|
|
leaving
|
|
|
|
ste ".ignmask"
|
|
|
|
|
|
|
|
pat trp /* Raise EM trap */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".trap"
|
2013-05-16 23:03:38 +00:00
|
|
|
|
|
|
|
pat sig /* Set trap handler */
|
|
|
|
leaving
|
|
|
|
ste ".trppc"
|
|
|
|
|
|
|
|
pat rtt /* Return from trap */
|
|
|
|
leaving
|
|
|
|
ret 0
|
|
|
|
|
|
|
|
pat lxl $1==0 /* Load FP */
|
|
|
|
leaving
|
|
|
|
lor 0
|
|
|
|
|
|
|
|
pat lxl $1==1 /* Load caller's FP */
|
|
|
|
leaving
|
|
|
|
lxl 0
|
|
|
|
dch
|
|
|
|
|
|
|
|
pat dch /* FP -> caller FP */
|
|
|
|
with GPR
|
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
2013-05-20 22:27:45 +00:00
|
|
|
ld %a, {GPROFFSET, %1, FP_OFFSET}
|
|
|
|
sub %a, GP
|
2013-05-16 23:03:38 +00:00
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat lpb /* Convert FP to argument address */
|
|
|
|
leaving
|
|
|
|
adp EM_BSIZE
|
|
|
|
|
|
|
|
pat lxa /* Load caller's SP */
|
|
|
|
leaving
|
|
|
|
lxl $1
|
|
|
|
lpb
|
|
|
|
|
|
|
|
pat gto /* longjmp */
|
2013-05-20 22:27:45 +00:00
|
|
|
uses REG, REG
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
|
|
|
move {LABEL, $1}, %a
|
2013-05-20 22:27:45 +00:00
|
|
|
ld %b, {GPROFFSET, %a, 8}
|
|
|
|
add FP, %b, GP
|
|
|
|
ld %b, {GPROFFSET, %a, 4}
|
|
|
|
add SP, %b, GP
|
|
|
|
ld %b, {GPROFFSET, %a, 0}
|
|
|
|
add %b, GP
|
|
|
|
b %b
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
#if 0
|
|
|
|
|
|
|
|
pat gto /* longjmp */
|
|
|
|
with STACK
|
|
|
|
gen
|
|
|
|
ld {LABEL, $1+2}
|
|
|
|
wspec {CONST, 1}
|
|
|
|
ld {LABEL, $1+4}
|
|
|
|
wspec {CONST, 0}
|
|
|
|
ld {LABEL, $1+0}
|
|
|
|
wspec {CONST, 2}
|
|
|
|
|
|
|
|
pat str $1==1 /* Store special GPRister */
|
|
|
|
with GPR0
|
|
|
|
gen
|
|
|
|
wspec {CONST, $1}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pat lor $1==0 /* Load FP */
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
move FP, %a
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat lor $1==1 /* Load SP */
|
|
|
|
uses REG
|
|
|
|
gen
|
|
|
|
move SP, %a
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat lor $1==2 /* Load HP */
|
|
|
|
leaving
|
|
|
|
loe ".reghp"
|
|
|
|
|
|
|
|
pat str $1==0 /* Store FP */
|
2013-05-20 21:35:12 +00:00
|
|
|
with GPRI
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
sub FP, %1, GP
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat str $1==1 /* Store SP */
|
2013-05-20 21:35:12 +00:00
|
|
|
with GPRI
|
2013-05-16 23:03:38 +00:00
|
|
|
gen
|
2013-05-20 21:35:12 +00:00
|
|
|
sub SP, %1, GP
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat str $1==2 /* Store HP */
|
|
|
|
leaving
|
|
|
|
ste ".reghp"
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat ass /* Adjust stack by variable amount */
|
2013-05-20 21:35:12 +00:00
|
|
|
with CONST+GPRI
|
|
|
|
gen
|
|
|
|
add SP, %1
|
|
|
|
|
2013-05-16 23:03:38 +00:00
|
|
|
pat asp /* Adjust stack by constant amount */
|
|
|
|
leaving
|
|
|
|
loc $1
|
|
|
|
ass
|
2013-05-19 22:33:42 +00:00
|
|
|
|
2013-05-21 17:16:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Floating point */
|
|
|
|
|
|
|
|
pat ngf /* Negate float */
|
|
|
|
leaving
|
|
|
|
loc 0
|
|
|
|
exg QUAD
|
|
|
|
sbf QUAD
|
|
|
|
|
|
|
|
proc simple_f example adf
|
|
|
|
with GPRI GPRI
|
|
|
|
uses reusing %1, REG
|
|
|
|
gen
|
|
|
|
fadd[1] %a, %2, %1
|
|
|
|
yields %a
|
|
|
|
|
|
|
|
pat adf call simple_f("fadd") /* Float subtract (second + top) */
|
|
|
|
pat sbf call simple_f("fsub") /* Float subtract (second - top) */
|
|
|
|
pat mlf call simple_f("fmul") /* Float multiply (second * top) */
|
|
|
|
pat dvf call simple_f("fdiv") /* Float divide (second / top) */
|
|
|
|
|
|
|
|
pat loc loc cff $1==$2 && $1==QUAD /* Convert float to float */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
2013-05-21 17:16:30 +00:00
|
|
|
nop
|
|
|
|
|
|
|
|
pat loc loc cfi $1==$2 && $1==QUAD /* Convert float -> integer */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".cfi"
|
|
|
|
lfr QUAD
|
2013-05-21 17:16:30 +00:00
|
|
|
|
|
|
|
pat loc loc cfu $1==$2 && $1==QUAD /* Convert float -> unsigned */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".cfu"
|
|
|
|
lfr QUAD
|
2013-05-21 17:16:30 +00:00
|
|
|
|
|
|
|
pat loc loc cif $1==$2 && $1==QUAD /* Convert integer -> float */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".cif"
|
|
|
|
lfr QUAD
|
2013-05-21 17:16:30 +00:00
|
|
|
|
|
|
|
pat loc loc cuf $1==$2 && $1==QUAD /* Convert unsigned -> float */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".cuf"
|
|
|
|
lfr QUAD
|
2013-05-21 17:16:30 +00:00
|
|
|
|
|
|
|
pat fef /* Split float */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
cal ".cuf"
|
|
|
|
lfr QUAD*2
|
2013-05-21 17:16:30 +00:00
|
|
|
|
|
|
|
pat fif /* Multiply float and split (?) */
|
2013-05-24 16:04:29 +00:00
|
|
|
leaving
|
|
|
|
mlf QUAD
|
|
|
|
fef
|
2013-05-21 17:16:30 +00:00
|
|
|
|
2013-05-21 19:05:26 +00:00
|
|
|
pat zrf /* Load a floating zero */
|
|
|
|
leaving
|
|
|
|
loc 0
|