Stop fighting the terrible code and remove the regvar support --- it didn't help much and was a pain.

--HG--
branch : dtrg-videocore
This commit is contained in:
David Given 2013-05-25 23:58:35 +01:00
parent 6a672d5e96
commit 8c21a2ef9b
2 changed files with 130 additions and 321 deletions

View file

@ -84,108 +84,3 @@ char *segname[] = {
".sect .bss" ".sect .bss"
}; };
#ifdef REGVARS
static int savedregsi[32];
static int numsaved;
/* Initialise regvar system for one function. */
void i_regsave(void)
{
int i;
fprintf(codefile, "! i_regsave()\n");
for (i=0; i<32; i++)
savedregsi[i] = INT_MAX;
numsaved = 0;
}
/* Mark a register as being saved. */
void regsave(const char* regname, full offset, int size)
{
int regnum = atoi(regname+1);
savedregsi[regnum] = offset;
numsaved++;
fprintf(codefile, "! %d is saved in %s\n", offset, regname);
#if 0
fprintf(codefile, "stwu %s, -4(sp)\n", regname);
if (offset >= 0)
fprintf(codefile, "lwz %s, %d(fp)\n", regname, offset);
#endif
}
/* Finish saving ragisters. */
static void saveloadregs(const char* op)
{
int minreg = 32;
int maxreg = -1;
int i;
for (i=0; i<32; i++)
{
if (savedregsi[i] != INT_MAX)
{
if (i < minreg)
minreg = i;
if (i > maxreg)
maxreg = i;
}
}
if (minreg != 32)
{
fprintf(codefile, "! saving registers %d to %d\n", minreg, maxreg);
assert((minreg == 6) || (minreg == 16));
fprintf(codefile, "%s r6-r%d\n", op, maxreg);
}
}
f_regsave()
{
int i;
fprintf(codefile, "! f_regsave()\n");
saveloadregs("push");
for (i=0; i<32; i++)
{
int o = savedregsi[i];
if ((o != INT_MAX) && (o > 0))
fprintf(codefile, "ld r%d, %d (fp)\n", i, savedregsi[i]);
}
}
/* Restore all saved registers. */
regreturn()
{
fprintf(codefile, "! regreturn()\n");
saveloadregs("pop");
}
/* Calculate the score of a given register. */
int regscore(full offset, int size, int type, int frequency, int totype)
{
int score;
fprintf(codefile, "! regscore(%ld, %d, %d, %d, %d)\n", offset, size, type, frequency, totype);
if (size != 4)
return -1;
/* Per use: 6 bytes (on average)
* Overhead in prologue: 4 bytes, plus 4 if a parameter
* Overhead in epilogue: 0 bytes
*/
score = frequency*6 - 4 - ((offset>=0) ? 4 : 0);
fprintf(codefile, "! local at offset %d has regvar score %d\n", offset, score);
return score;
}
#endif

View file

@ -21,12 +21,6 @@ PC_OFFSET = 4 /* Offset of saved PC relative to our FP */
#define nicesize(x) ((x)==BYTE || (x)==WORD || (x)==QUAD) #define nicesize(x) ((x)==BYTE || (x)==WORD || (x)==QUAD)
/* #define REGVARS */
#ifndef REGVARS
#define regvar
#define return
#endif
PROPERTIES PROPERTIES
@ -49,19 +43,15 @@ REGISTERS
R3("r3") : GPR, REG, GPR3. R3("r3") : GPR, REG, GPR3.
R4("r4") : GPR, REG, GPR4. R4("r4") : GPR, REG, GPR4.
R5("r5") : GPR, REG, GPR5. R5("r5") : GPR, REG, GPR5.
#if defined REGVARS
R6("r6") : GPR, REG, GPR6, STACKABLE.
#else
R6("r6") : GPR, GPR6. R6("r6") : GPR, GPR6.
#endif R7("r7") : GPR, REG, GPR7.
R7("r7") : GPR, REG, GPR7 regvar. R8("r8") : GPR, REG, GPR8.
R8("r8") : GPR, REG, GPR8 regvar. R9("r9") : GPR, REG, GPR9.
R9("r9") : GPR, REG, GPR9 regvar. R10("r10") : GPR, REG, GPR10.
R10("r10") : GPR, REG, GPR10 regvar. R11("r11") : GPR, REG, GPR11.
R11("r11") : GPR, REG, GPR11 regvar. R12("r12") : GPR, REG, GPR12.
R12("r12") : GPR, REG, GPR12 regvar. R13("r13") : GPR, REG, GPR13.
R13("r13") : GPR, REG, GPR13 regvar. R14("r14") : GPR, REG, GPR14.
R14("r14") : GPR, REG, GPR14 regvar.
GP("r15") : GPR, GPRGP. GP("r15") : GPR, GPRGP.
R16("r16") : GPR, GPR16. R16("r16") : GPR, GPR16.
@ -73,11 +63,7 @@ REGISTERS
PC("pc") : GPR, GPRPC. PC("pc") : GPR, GPRPC.
/* r26 to r31 are special and the code generator doesn't touch them. */ /* r26 to r31 are special and the code generator doesn't touch them. */
#if defined REGVARS
#define SCRATCH R16
#else
#define SCRATCH R6 #define SCRATCH R6
#endif
TOKENS TOKENS
@ -92,10 +78,6 @@ TOKENS
LABEL = { ADDR adr; } 4 adr. LABEL = { ADDR adr; } 4 adr.
CONST = { INT val; } 4 "#" val. CONST = { INT val; } 4 "#" val.
/* Allows us to use regvar() to refer to registers */
GPRE = { GPR reg; } 4 reg.
/* Sign extended values. */ /* Sign extended values. */
/* The size refers to the *source*. */ /* The size refers to the *source*. */
@ -114,65 +96,64 @@ TOKENS
SETS SETS
TOKEN = LABEL + CONST. TOKEN = LABEL + CONST.
GPRI = GPR + GPRE.
OP = TOKEN + SIGNEX8 + SIGNEX16. OP = TOKEN + SIGNEX8 + SIGNEX16.
XREG = GPRI + SIGNEX8 + SIGNEX16. ANY = GPR + OP.
INSTRUCTIONS INSTRUCTIONS
add XREG:wo, XREG:ro, XREG+CONST:ro. add GPR:wo, GPR:ro, GPR+CONST:ro.
add XREG:rw, XREG+CONST:ro. add GPR:rw, GPR+CONST:ro.
adds2 XREG:rw, XREG+CONST:ro. adds2 GPR:rw, GPR+CONST:ro.
adds4 XREG:rw, XREG+CONST:ro. adds4 GPR:rw, GPR+CONST:ro.
adds8 XREG:rw, XREG+CONST:ro. adds8 GPR:rw, GPR+CONST:ro.
adds16 XREG:rw, XREG+CONST:ro. adds16 GPR:rw, GPR+CONST:ro.
adds256 XREG:rw, XREG:rw, XREG:ro. adds256 GPR:rw, GPR:rw, GPR:ro.
and XREG:rw, XREG+CONST:ro. and GPR:rw, GPR+CONST:ro.
asr XREG:rw, XREG+CONST:ro. asr GPR:rw, GPR+CONST:ro.
beq "b.eq" LABEL:ro. beq "b.eq" LABEL:ro.
bne "b.ne" LABEL:ro. bne "b.ne" LABEL:ro.
bgt "b.gt" LABEL:ro. bgt "b.gt" LABEL:ro.
bgt "b.gt" LABEL:ro. bgt "b.gt" LABEL:ro.
bhi "b.hi" LABEL:ro. bhi "b.hi" LABEL:ro.
bset XREG:rw, XREG+CONST:ro. bset GPR:rw, GPR+CONST:ro.
b XREG+LABEL:ro. b GPR+LABEL:ro.
bl XREG+LABEL:ro. bl GPR+LABEL:ro.
cmp XREG:ro, XREG+CONST:ro kills :cc. cmp GPR:ro, GPR+CONST:ro kills :cc.
divs XREG:wo, XREG:ro, XREG+CONST:ro. divs GPR:wo, GPR:ro, GPR+CONST:ro.
divu XREG:wo, XREG:ro, XREG+CONST:ro. divu GPR:wo, GPR:ro, GPR+CONST:ro.
eor XREG:rw, XREG+CONST:ro. eor GPR:rw, GPR+CONST:ro.
exts XREG:wo, XREG:ro, XREG+CONST:ro. exts GPR:wo, GPR:ro, GPR+CONST:ro.
exts XREG:rw, XREG+CONST:ro. exts GPR:rw, GPR+CONST:ro.
fadd XREG:wo, XREG:ro, XREG:ro. fadd GPR:wo, GPR:ro, GPR:ro.
fcmp XREG:wo, XREG:ro, XREG:ro. fcmp GPR:wo, GPR:ro, GPR:ro.
fdiv XREG:wo, XREG:ro, XREG:ro. fdiv GPR:wo, GPR:ro, GPR:ro.
fmul XREG:wo, XREG:ro, XREG:ro. fmul GPR:wo, GPR:ro, GPR:ro.
fsub XREG:wo, XREG:ro, XREG:ro. fsub GPR:wo, GPR:ro, GPR:ro.
ld XREG:wo, GPRINC:rw. ld GPR:wo, GPRINC:rw.
ld XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. ld GPR:wo, GPROFFSET+GPRGPR+LABEL:ro.
ldb XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. ldb GPR:wo, GPROFFSET+GPRGPR+LABEL:ro.
ldh XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. ldh GPR:wo, GPROFFSET+GPRGPR+LABEL:ro.
ldhs XREG:wo, GPROFFSET+GPRGPR+LABEL:ro. ldhs GPR:wo, GPROFFSET+GPRGPR+LABEL:ro.
lea XREG:wo, LABEL:ro. lea GPR:wo, LABEL:ro.
lsl XREG:rw, XREG+CONST:ro. lsl GPR:rw, GPR+CONST:ro.
lsl XREG:wo, XREG:ro, XREG+CONST:ro. lsl GPR:wo, GPR:ro, GPR+CONST:ro.
lsr XREG:rw, XREG+CONST:ro. lsr GPR:rw, GPR+CONST:ro.
mov XREG:wo, XREG+CONST:ro. mov GPR:wo, GPR+CONST:ro.
mul XREG:rw, XREG+CONST:ro. mul GPR:rw, GPR+CONST:ro.
neg XREG:rw, XREG+CONST:ro. neg GPR:rw, GPR+CONST:ro.
or XREG:rw, XREG+CONST:ro. or GPR:rw, GPR+CONST:ro.
pop GPR0+GPR6+GPR16+GPRFP+GPRPC:wo. pop GPR0+GPR6+GPR16+GPRFP+GPRPC:wo.
pop GPR0+GPR6+GPR16+GPRFP:wo, GPRPC:wo. pop GPR0+GPR6+GPR16+GPRFP:wo, GPRPC:wo.
push GPR0+GPR6+GPR16+GPRFP+GPRLR:ro. push GPR0+GPR6+GPR16+GPRFP+GPRLR:ro.
push GPR0+GPR6+GPR16+GPRFP:ro, GPRLR:ro. push GPR0+GPR6+GPR16+GPRFP:ro, GPRLR:ro.
sub XREG:wo, XREG:ro, CONST+XREG:ro. sub GPR:wo, GPR:ro, CONST+GPR:ro.
sub XREG:rw, XREG+CONST:ro. sub GPR:rw, GPR+CONST:ro.
st XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. st GPR:ro, GPROFFSET+GPRGPR+LABEL:ro.
stb XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. stb GPR:ro, GPROFFSET+GPRGPR+LABEL:ro.
sth XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. sth GPR:ro, GPROFFSET+GPRGPR+LABEL:ro.
sths XREG:ro, GPROFFSET+GPRGPR+LABEL:ro. sths GPR:ro, GPROFFSET+GPRGPR+LABEL:ro.
invalid "invalid". invalid "invalid".
comment "!" LABEL:ro. comment "!" LABEL:ro.
@ -186,13 +167,6 @@ MOVES
COMMENT("mov GPR->GPR") COMMENT("mov GPR->GPR")
mov %2, %1 mov %2, %1
/* GPRE exists solely to allow us to use regvar() (which can only be used in
an expression) as a register constant. */
from GPRE to GPR
gen
mov %2, %1
/* Constants */ /* Constants */
from CONST to GPR from CONST to GPR
@ -216,9 +190,9 @@ MOVES
/* Miscellaneous */ /* Miscellaneous */
from CONST+LABEL+GPR+GPRE to GPRE from CONST+LABEL+GPR to GPR
gen gen
move %1, %2.reg move %1, %2
TESTS TESTS
@ -236,7 +210,7 @@ STACKINGRULES
comment {LABEL, "push stackable"} comment {LABEL, "push stackable"}
push %1 push %1
from OP+GPRI to STACK from OP+GPR to STACK
uses GPR0 uses GPR0
gen gen
move %1, %a move %1, %a
@ -248,7 +222,7 @@ STACKINGRULES
move %1, %a move %1, %a
push %a push %a
from OP+GPRI to STACK from OP+GPR to STACK
gen gen
comment {LABEL, "push via scratch"} comment {LABEL, "push via scratch"}
move %1, SCRATCH move %1, SCRATCH
@ -259,19 +233,6 @@ STACKINGRULES
COERCIONS COERCIONS
from GPRI
uses reusing %1, REG=%1
yields %a
from GPR
yields {GPRE, %1}
from OP
uses GPR0
gen
move %1, %a
yields %a
from OP from OP
uses REG uses REG
gen gen
@ -281,8 +242,8 @@ COERCIONS
from STACK from STACK
uses REG uses REG
gen gen
pop R0 pop SCRATCH
move R0, %a move SCRATCH, %a
yields %a yields %a
@ -295,15 +256,15 @@ PATTERNS
yields {CONST, $1} yields {CONST, $1}
pat dup $1<=QUAD /* Duplicate word on top of stack */ pat dup $1<=QUAD /* Duplicate word on top of stack */
with GPRI with ANY
yields %1 %1 yields %1 %1
pat dup $1<=(2*QUAD) /* Duplicate word pair on top of stack */ pat dup $1<=(2*QUAD) /* Duplicate word pair on top of stack */
with GPRI GPRI with ANY ANY
yields %1 %2 %1 %2 yields %1 %2 %1 %2
pat exg $1==QUAD /* Exchange top two words on stack */ pat exg $1==QUAD /* Exchange top two words on stack */
with GPRI GPRI with ANY ANY
yields %1 %2 yields %1 %2
pat stl lol $1==$2 /* Store then load local */ pat stl lol $1==$2 /* Store then load local */
@ -362,8 +323,6 @@ PATTERNS
pat loc loc cii $1==BYTE && $2>BYTE /* signed char -> anything */ pat loc loc cii $1==BYTE && $2>BYTE /* signed char -> anything */
with GPR with GPR
yields {SIGNEX8, %1} yields {SIGNEX8, %1}
with GPRE
yields {SIGNEX8, %1.reg}
with SIGNEX8 with SIGNEX8
yields {SIGNEX8, %1.reg} yields {SIGNEX8, %1.reg}
with SIGNEX16 with SIGNEX16
@ -372,8 +331,6 @@ PATTERNS
pat loc loc cii $1==WORD && $2>WORD /* signed short -> anything */ pat loc loc cii $1==WORD && $2>WORD /* signed short -> anything */
with GPR with GPR
yields {SIGNEX16, %1} yields {SIGNEX16, %1}
with GPRE
yields {SIGNEX16, %1.reg}
with SIGNEX8 with SIGNEX8
yields {SIGNEX16, %1.reg} yields {SIGNEX16, %1.reg}
with SIGNEX16 with SIGNEX16
@ -390,11 +347,6 @@ PATTERNS
add %a, {CONST, $1} add %a, {CONST, $1}
yields %a yields %a
#if defined REGVARS
pat lol inreg($1)>0 /* Load from local */
yields {GPRE, regvar($1)}
#endif
pat lol /* Load quad from local */ pat lol /* Load quad from local */
uses REG uses REG
gen gen
@ -406,16 +358,8 @@ PATTERNS
lol $1 + QUAD*1 lol $1 + QUAD*1
lol $1 + QUAD*0 lol $1 + QUAD*0
#if defined REGVARS
pat stl inreg($1)>0 /* Store to local */
with CONST+GPRI
kills regvar($1)
gen
move %1, {GPRE, regvar($1)}
#endif
pat stl /* Store to local */ pat stl /* Store to local */
with GPRI with GPR
gen gen
st %1, {GPROFFSET, FP, $1} st %1, {GPROFFSET, FP, $1}
@ -424,14 +368,6 @@ PATTERNS
stl $1 + QUAD*0 stl $1 + QUAD*0
stl $1 + QUAD*1 stl $1 + QUAD*1
#if defined REGVARS
pat lil inreg($1)>0 /* Load from indirected local */
uses REG
gen
ld %a, {GPROFFSET, regvar($1), 0}
yields %a
#endif
pat lil /* Load from indirected local */ pat lil /* Load from indirected local */
leaving leaving
lol $1 lol $1
@ -452,31 +388,6 @@ PATTERNS
loc 0 loc 0
stl $1 stl $1
#if defined REGVARS
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 */
leaving
lol $1
loc 1
adi QUAD
stl $1
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 */
leaving
lol $1
loc 1
sbi QUAD
stl $1
#else
pat inl /* Increment local in register */ pat inl /* Increment local in register */
leaving leaving
lol $1 lol $1
@ -490,7 +401,7 @@ PATTERNS
loc 1 loc 1
sbi QUAD sbi QUAD
stl $1 stl $1
#endif
/* Global variables */ /* Global variables */
@ -552,7 +463,7 @@ PATTERNS
loi QUAD loi QUAD
pat ldf /* Load double offsetted */ pat ldf /* Load double offsetted */
with GPRI with GPR
uses reusing %1, REG=%1, REG uses reusing %1, REG=%1, REG
gen gen
add %a, GP add %a, GP
@ -566,7 +477,7 @@ PATTERNS
sti QUAD sti QUAD
pat sdf /* Store double offsetted */ pat sdf /* Store double offsetted */
with GPRI GPRI GPRI with GPR GPR GPR
uses reusing %3, REG=%3 uses reusing %3, REG=%3
gen gen
add %a, GP add %a, GP
@ -589,11 +500,6 @@ PATTERNS
gen gen
ldb %a, {GPRGPR, %1, GP} ldb %a, {GPRGPR, %1, GP}
yields %a yields %a
with GPRE
uses reusing %1.reg, REG
gen
ldb %a, {GPRGPR, %1.reg, GP}
yields %a
pat loi loc loc cii $1==WORD && $2==WORD && $3==QUAD /* Load short indirect and sign extend */ pat loi loc loc cii $1==WORD && $2==WORD && $3==QUAD /* Load short indirect and sign extend */
with LABEL with LABEL
@ -601,7 +507,7 @@ PATTERNS
gen gen
ldhs %a, %1 ldhs %a, %1
yields %a yields %a
with GPRI with GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
add %a, %1, GP add %a, %1, GP
@ -614,7 +520,7 @@ PATTERNS
gen gen
ldh %a, %1 ldh %a, %1
yields %a yields %a
with GPRI with GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
add %a, %1, GP add %a, %1, GP
@ -627,7 +533,7 @@ PATTERNS
gen gen
ld %a, %1 ld %a, %1
yields %a yields %a
with GPRI with GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
add %a, %1, GP add %a, %1, GP
@ -642,7 +548,7 @@ PATTERNS
ld %a, {GPROFFSET, %b, 0} ld %a, {GPROFFSET, %b, 0}
ld %b, {GPROFFSET, %b, 4} ld %b, {GPROFFSET, %b, 4}
yields %b %a yields %b %a
with GPRI with GPR
uses reusing %1, REG, REG uses reusing %1, REG, REG
gen gen
add %b, %1, GP add %b, %1, GP
@ -660,44 +566,55 @@ PATTERNS
cal ".los" cal ".los"
pat sti $1==BYTE /* Store byte indirect */ pat sti $1==BYTE /* Store byte indirect */
with LABEL GPRI+SIGNEX8+SIGNEX16 with LABEL GPR
gen gen
stb %2, %1 stb %2, %1
with GPR GPRI+SIGNEX8+SIGNEX16 with LABEL SIGNEX8+SIGNEX16
gen
stb %2.reg, %1
with GPR GPR
gen gen
stb %2, {GPRGPR, %1, GP} stb %2, {GPRGPR, %1, GP}
with GPRE GPRI+SIGNEX8+SIGNEX16 with GPR SIGNEX8+SIGNEX16
gen gen
stb %2, {GPRGPR, %1.reg, GP} stb %2.reg, {GPRGPR, %1, GP}
pat sti $1==WORD /* Store half-word indirect */ pat sti $1==WORD /* Store half-word indirect */
with LABEL GPRI+SIGNEX16 with LABEL GPR
gen gen
sth %2, %1 sth %2, %1
with GPRI GPRI+SIGNEX16 with LABEL SIGNEX16
gen
sth %2.reg, %1
with GPR GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
add %a, %1, GP add %a, %1, GP
sth %2, {GPROFFSET, %a, 0} sth %2, {GPROFFSET, %a, 0}
with GPR SIGNEX16
uses reusing %1, REG
gen
add %a, %1, GP
sth %2.reg, {GPROFFSET, %a, 0}
pat sti $1==QUAD /* Store quad indirect */ pat sti $1==QUAD /* Store quad indirect */
with LABEL GPRI with LABEL GPR
gen gen
st %2, %1 st %2, %1
with GPRI GPRI with GPR GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
add %a, %1, GP add %a, %1, GP
st %2, {GPROFFSET, %a, 0} st %2, {GPROFFSET, %a, 0}
pat sti $1==2*QUAD /* Load double-quad indirect */ pat sti $1==2*QUAD /* Load double-quad indirect */
with LABEL GPRI GPRI with LABEL GPR GPR
uses REG uses REG
gen gen
lea %a, %1 lea %a, %1
st %2, {GPROFFSET, %a, 0} st %2, {GPROFFSET, %a, 0}
st %3, {GPROFFSET, %a, 4} st %3, {GPROFFSET, %a, 4}
with GPRI GPRI GPRI with GPR GPR GPR
uses reusing %1, REG=%1 uses reusing %1, REG=%1
gen gen
add %a, GP add %a, GP
@ -774,12 +691,12 @@ PATTERNS
/* nop */ /* nop */
pat adi $1==QUAD /* Add word (second + top) */ pat adi $1==QUAD /* Add word (second + top) */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
add %a, %1 add %a, %1
yields %a yields %a
with GPRI GPRI+CONST with GPR GPR+CONST
uses reusing %1, REG=%1 uses reusing %1, REG=%1
gen gen
add %a, %2 add %a, %2
@ -789,19 +706,19 @@ PATTERNS
/* nop */ /* nop */
pat sbi $1==QUAD /* Subtract word (second - top) */ pat sbi $1==QUAD /* Subtract word (second - top) */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
sub %a, %1 sub %a, %1
yields %a yields %a
pat mli $1==QUAD /* Multiply word (second * top) */ pat mli $1==QUAD /* Multiply word (second * top) */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
mul %a, %1 mul %a, %1
yields %a yields %a
with GPRI GPRI+CONST with GPR GPR+CONST
uses reusing %1, REG=%1 uses reusing %1, REG=%1
gen gen
mul %a, %2 mul %a, %2
@ -812,21 +729,21 @@ PATTERNS
mli $1 mli $1
pat dvi $1==QUAD /* Divide word (second / top) */ pat dvi $1==QUAD /* Divide word (second / top) */
with GPRI GPRI with GPR GPR
uses reusing %2, REG uses reusing %2, REG
gen gen
divs %a, %2, %1 divs %a, %2, %1
yields %a yields %a
pat dvu $1==QUAD /* Divide unsigned word (second / top) */ pat dvu $1==QUAD /* Divide unsigned word (second / top) */
with GPRI GPRI with GPR GPR
uses reusing %2, REG uses reusing %2, REG
gen gen
divu %a, %2, %1 divu %a, %2, %1
yields %a yields %a
pat rmu $1==QUAD /* Remainder unsigned word (second % top) */ pat rmu $1==QUAD /* Remainder unsigned word (second % top) */
with GPRI GPRI with GPR GPR
uses REG uses REG
gen gen
divu %a, %2, %1 divu %a, %2, %1
@ -835,7 +752,7 @@ PATTERNS
yields %a yields %a
pat rmi $1==QUAD /* Remainder signed word (second % top) */ pat rmi $1==QUAD /* Remainder signed word (second % top) */
with GPRI GPRI with GPR GPR
uses REG uses REG
gen gen
divs %a, %2, %1 divs %a, %2, %1
@ -844,64 +761,64 @@ PATTERNS
yields %a yields %a
pat ngi $1==QUAD /* Negate word */ pat ngi $1==QUAD /* Negate word */
with GPRI with GPR
uses reusing %1, REG=%1 uses reusing %1, REG=%1
gen gen
neg %a, %a neg %a, %a
yields %a yields %a
pat and $1==QUAD /* AND word */ pat and $1==QUAD /* AND word */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
and %a, %1 and %a, %1
yields %a yields %a
with GPRI GPRI+CONST with GPR GPR+CONST
uses reusing %1, REG=%1 uses reusing %1, REG=%1
gen gen
and %a, %2 and %a, %2
yields %a yields %a
pat ior $1==QUAD /* OR word */ pat ior $1==QUAD /* OR word */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
or %a, %1 or %a, %1
yields %a yields %a
with GPRI GPRI+CONST with GPR GPR+CONST
uses reusing %1, REG=%1 uses reusing %1, REG=%1
gen gen
or %a, %2 or %a, %2
yields %a yields %a
pat xor $1==QUAD /* XOR word */ pat xor $1==QUAD /* XOR word */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
eor %a, %1 eor %a, %1
yields %a yields %a
with GPRI GPRI+CONST with GPR GPR+CONST
uses reusing %1, REG=%1 uses reusing %1, REG=%1
gen gen
eor %a, %2 eor %a, %2
yields %a yields %a
pat dvi $1==QUAD /* Divide word (second / top) */ pat dvi $1==QUAD /* Divide word (second / top) */
with GPRI GPRI with GPR GPR
uses reusing %2, REG uses reusing %2, REG
gen gen
divs %a, %2, %1 divs %a, %2, %1
yields %a yields %a
pat dvu $1==QUAD /* Divide unsigned word (second / top) */ pat dvu $1==QUAD /* Divide unsigned word (second / top) */
with GPRI GPRI with GPR GPR
uses reusing %2, REG uses reusing %2, REG
gen gen
divu %a, %2, %1 divu %a, %2, %1
yields %a yields %a
pat rmu $1==QUAD /* Remainder unsigned word (second % top) */ pat rmu $1==QUAD /* Remainder unsigned word (second % top) */
with GPRI GPRI with GPR GPR
uses REG uses REG
gen gen
divu %a, %2, %1 divu %a, %2, %1
@ -910,7 +827,7 @@ PATTERNS
yields %a yields %a
pat rmi $1==QUAD /* Remainder signed word (second % top) */ pat rmi $1==QUAD /* Remainder signed word (second % top) */
with GPRI GPRI with GPR GPR
uses REG uses REG
gen gen
divs %a, %2, %1 divs %a, %2, %1
@ -966,21 +883,21 @@ PATTERNS
#endif #endif
pat sli $1==4 /* Shift left (second << top) */ pat sli $1==4 /* Shift left (second << top) */
with CONST+GPRI GPRI with CONST+GPR GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
lsl %a, %1 lsl %a, %1
yields %a yields %a
pat sri $1==4 /* Shift right signed (second >> top) */ pat sri $1==4 /* Shift right signed (second >> top) */
with CONST+GPRI GPRI with CONST+GPR GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
asr %2, %1 asr %2, %1
yields %a yields %a
pat sru $1==4 /* Shift right unsigned (second >> top) */ pat sru $1==4 /* Shift right unsigned (second >> top) */
with CONST+GPRI GPRI with CONST+GPR GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
lsr %2, %1 lsr %2, %1
@ -991,35 +908,35 @@ PATTERNS
/* Special arithmetic */ /* Special arithmetic */
pat loc sli adi $1==1 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<1) */ pat loc sli adi $1==1 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<1) */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
adds2 %a, %1 adds2 %a, %1
yields %a yields %a
pat loc sli adi $1==2 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<2) */ pat loc sli adi $1==2 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<2) */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
adds4 %a, %1 adds4 %a, %1
yields %a yields %a
pat loc sli adi $1==3 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<3) */ pat loc sli adi $1==3 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<3) */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
adds8 %a, %1 adds8 %a, %1
yields %a yields %a
pat loc sli adi $1==4 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<4) */ pat loc sli adi $1==4 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<4) */
with GPRI+CONST GPRI with GPR+CONST GPR
uses reusing %2, REG=%2 uses reusing %2, REG=%2
gen gen
adds16 %a, %1 adds16 %a, %1
yields %a yields %a
pat loc sli adi $1==8 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<8) */ pat loc sli adi $1==8 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<8) */
with GPRI GPRI with GPR GPR
uses reusing %2, REG uses reusing %2, REG
gen gen
adds256 %a, %2, %1 adds256 %a, %2, %1
@ -1087,7 +1004,7 @@ PATTERNS
/* Sets */ /* Sets */
pat set $1==QUAD /* Create quad with one bit set */ pat set $1==QUAD /* Create quad with one bit set */
with GPRI with GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
bset %a, %1 bset %a, %1
@ -1133,7 +1050,7 @@ PATTERNS
/* Boolean resolutions */ /* Boolean resolutions */
proc cm_t example teq proc cm_t example teq
with GPRI GPRI with GPR GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
cmp %1, %2 cmp %1, %2
@ -1155,7 +1072,7 @@ PATTERNS
pat cmi tge call cm_t("add.ge") /* top = signed (second >= top) */ pat cmi tge call cm_t("add.ge") /* top = signed (second >= top) */
proc cmf_t example teq proc cmf_t example teq
with GPRI GPRI with GPR GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
fcmp %a, %1, %2 fcmp %a, %1, %2
@ -1171,7 +1088,7 @@ PATTERNS
pat cmf tge call cmf_t("add.hs") /* top = float (second >= top) */ pat cmf tge call cmf_t("add.hs") /* top = float (second >= top) */
proc fallback_t example teq proc fallback_t example teq
with GPRI with GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
cmp %1, {CONST, 0} cmp %1, {CONST, 0}
@ -1191,7 +1108,7 @@ PATTERNS
/* Simple branches */ /* Simple branches */
proc anyz example zeq proc anyz example zeq
with GPRI STACK with GPR STACK
gen gen
cmp %1, {CONST, 0} cmp %1, {CONST, 0}
beq[1] {LABEL, $1} beq[1] {LABEL, $1}
@ -1204,7 +1121,7 @@ PATTERNS
pat zle call anyz("b.le") /* Branch if signed top <= 0 */ pat zle call anyz("b.le") /* Branch if signed top <= 0 */
proc anyb example beq proc anyb example beq
with GPRI+CONST GPRI STACK with GPR+CONST GPR STACK
gen gen
cmp %2, %1 cmp %2, %1
beq[1] {LABEL, $1} beq[1] {LABEL, $1}
@ -1217,7 +1134,7 @@ PATTERNS
pat ble call anyb("b.le") /* Branch if signed second <= top */ pat ble call anyb("b.le") /* Branch if signed second <= top */
proc cmu_z example cmu zeq proc cmu_z example cmu zeq
with GPRI+CONST GPRI STACK with GPR+CONST GPR STACK
gen gen
cmp %2, %1 cmp %2, %1
beq[1] {LABEL, $2} beq[1] {LABEL, $2}
@ -1236,7 +1153,7 @@ PATTERNS
pat cmi zle call cmu_z("b.le") /* Branch if signed second <= top */ pat cmi zle call cmu_z("b.le") /* Branch if signed second <= top */
proc cmf_z example cmu zeq proc cmf_z example cmu zeq
with GPRI GPRI STACK with GPR GPR STACK
gen gen
fcmp %2, %2, %1 fcmp %2, %2, %1
beq[1] {LABEL, $2} beq[1] {LABEL, $2}
@ -1327,23 +1244,20 @@ PATTERNS
pat ret $1==0 /* Return from procedure */ pat ret $1==0 /* Return from procedure */
gen gen
return
mov SP, FP mov SP, FP
pop FP, PC pop FP, PC
pat ret $1==QUAD /* Return from procedure, word */ pat ret $1==QUAD /* Return from procedure, word */
with GPR0 with GPR0
gen gen
return
mov SP, FP mov SP, FP
pop FP, PC pop FP, PC
pat ret $1==QUAD*2 /* Return from procedure, word */ pat ret $1==QUAD*2 /* Return from procedure, word */
with GPRI GPRI with GPR GPR
gen gen
move %1, R0 move %1, R0
move %2, R1 move %2, R1
return
mov SP, FP mov SP, FP
pop FP, PC pop FP, PC
@ -1480,12 +1394,12 @@ PATTERNS
loe ".reghp" loe ".reghp"
pat str $1==0 /* Store FP */ pat str $1==0 /* Store FP */
with GPRI with GPR
gen gen
sub FP, %1, GP sub FP, %1, GP
pat str $1==1 /* Store SP */ pat str $1==1 /* Store SP */
with GPRI with GPR
gen gen
sub SP, %1, GP sub SP, %1, GP
@ -1494,7 +1408,7 @@ PATTERNS
ste ".reghp" ste ".reghp"
pat ass /* Adjust stack by variable amount */ pat ass /* Adjust stack by variable amount */
with CONST+GPRI with CONST+GPR
gen gen
add SP, %1 add SP, %1
@ -1518,7 +1432,7 @@ PATTERNS
sbf QUAD sbf QUAD
proc simple_f example adf proc simple_f example adf
with GPRI GPRI with GPR GPR
uses reusing %1, REG uses reusing %1, REG
gen gen
fadd[1] %a, %2, %1 fadd[1] %a, %2, %1