Rename SCRATCH to RSCRATCH. Never stack RSCRATCH nor FSCRATCH.

Rename the scratch gpr (currently r11) from SCRATCH to RSCRATCH so I
can search for RSCRATCH without finding FSCRATCH.  I also want to
avoid confusion with the SCRATCH keyword of the old code generator (cg
which came before ncg).

Change the stacking rules to prevent stacking of RSCRATCH or FSCRATCH
or any other GPR or FPR that isn't an allocatable REG or FREG.  Then
ncgg rejects any rule that tries to stack a GPR or FPR, so change such
rules to stack a REG or FREG.
This commit is contained in:
George Koehler 2016-10-06 20:47:42 -04:00
parent 9017ba9dea
commit 7cccd88b71

View file

@ -167,7 +167,7 @@ REGISTERS
CTR("ctr") : SPR. CTR("ctr") : SPR.
C0("cr0") : CR, CR0. C0("cr0") : CR, CR0.
#define SCRATCH R11 #define RSCRATCH R11
#define FSCRATCH F0 #define FSCRATCH F0
@ -430,8 +430,8 @@ MOVES
from IND_RC_B to GPR from IND_RC_B to GPR
gen gen
COMMENT("move IND_RC_B->GPR large") COMMENT("move IND_RC_B->GPR large")
addis SCRATCH, %1.reg, {CONST, his(%1.off)} addis RSCRATCH, %1.reg, {CONST, his(%1.off)}
lbz %2, {GPRINDIRECT, SCRATCH, los(%1.off)} lbz %2, {GPRINDIRECT, RSCRATCH, los(%1.off)}
from GPR to IND_RC_B smalls(%off) from GPR to IND_RC_B smalls(%off)
gen gen
@ -441,8 +441,8 @@ MOVES
from GPR to IND_RC_B from GPR to IND_RC_B
gen gen
COMMENT("move GPR->IND_RC_B large") COMMENT("move GPR->IND_RC_B large")
addis SCRATCH, %2.reg, {CONST, his(%2.off)} addis RSCRATCH, %2.reg, {CONST, his(%2.off)}
stb %1, {GPRINDIRECT, SCRATCH, los(%2.off)} stb %1, {GPRINDIRECT, RSCRATCH, los(%2.off)}
/* Read/write short */ /* Read/write short */
@ -454,8 +454,8 @@ MOVES
from IND_RC_H to GPR from IND_RC_H to GPR
gen gen
COMMENT("move IND_RC_H->GPR large") COMMENT("move IND_RC_H->GPR large")
addis SCRATCH, %1.reg, {CONST, his(%1.off)} addis RSCRATCH, %1.reg, {CONST, his(%1.off)}
lhz %2, {GPRINDIRECT, SCRATCH, los(%1.off)} lhz %2, {GPRINDIRECT, RSCRATCH, los(%1.off)}
from IND_RC_H_S smalls(%off) to GPR from IND_RC_H_S smalls(%off) to GPR
gen gen
@ -465,8 +465,8 @@ MOVES
from IND_RC_H_S to GPR from IND_RC_H_S to GPR
gen gen
COMMENT("move IND_RC_H_S->GPR large") COMMENT("move IND_RC_H_S->GPR large")
addis SCRATCH, %1.reg, {CONST, his(%1.off)} addis RSCRATCH, %1.reg, {CONST, his(%1.off)}
lha %2, {GPRINDIRECT, SCRATCH, los(%1.off)} lha %2, {GPRINDIRECT, RSCRATCH, los(%1.off)}
from GPR to IND_RC_H smalls(%off) from GPR to IND_RC_H smalls(%off)
gen gen
@ -476,8 +476,8 @@ MOVES
from GPR to IND_RC_H from GPR to IND_RC_H
gen gen
COMMENT("move GPR->IND_RC_H large") COMMENT("move GPR->IND_RC_H large")
addis SCRATCH, %2.reg, {CONST, his(%2.off)} addis RSCRATCH, %2.reg, {CONST, his(%2.off)}
sth %1, {GPRINDIRECT, SCRATCH, los(%2.off)} sth %1, {GPRINDIRECT, RSCRATCH, los(%2.off)}
/* Read word */ /* Read word */
@ -500,8 +500,8 @@ MOVES
from IND_LABEL_W to GPR from IND_LABEL_W to GPR
gen gen
COMMENT("move IND_LABEL_W->GPR") COMMENT("move IND_LABEL_W->GPR")
move {LABEL, %1.adr}, SCRATCH move {LABEL, %1.adr}, RSCRATCH
lwz %2, {GPRINDIRECT, SCRATCH, 0} lwz %2, {GPRINDIRECT, RSCRATCH, 0}
from IND_RC_W smalls(%off) to FSREG from IND_RC_W smalls(%off) to FSREG
gen gen
@ -511,8 +511,8 @@ MOVES
from IND_RC_W to FSREG from IND_RC_W to FSREG
gen gen
COMMENT("move IND_RC_W->FSREG large") COMMENT("move IND_RC_W->FSREG large")
addis SCRATCH, %1.reg, {CONST, his(%1.off)} addis RSCRATCH, %1.reg, {CONST, his(%1.off)}
lfs %2, {GPRINDIRECT, SCRATCH, los(%1.off)} lfs %2, {GPRINDIRECT, RSCRATCH, los(%1.off)}
from IND_RR_W to FSREG from IND_RR_W to FSREG
gen gen
@ -522,8 +522,8 @@ MOVES
from IND_LABEL_W to FSREG from IND_LABEL_W to FSREG
gen gen
COMMENT("move IND_LABEL_W->FSREG") COMMENT("move IND_LABEL_W->FSREG")
move {LABEL, %1.adr}, SCRATCH move {LABEL, %1.adr}, RSCRATCH
lfs %2, {GPRINDIRECT, SCRATCH, 0} lfs %2, {GPRINDIRECT, RSCRATCH, 0}
/* Write word */ /* Write word */
@ -535,8 +535,8 @@ MOVES
from GPR to IND_RC_W from GPR to IND_RC_W
gen gen
COMMENT("move GPR->IND_RC_W large") COMMENT("move GPR->IND_RC_W large")
addis SCRATCH, %2.reg, {CONST, his(%2.off)} addis RSCRATCH, %2.reg, {CONST, his(%2.off)}
stw %1, {GPRINDIRECT, SCRATCH, los(%2.off)} stw %1, {GPRINDIRECT, RSCRATCH, los(%2.off)}
from GPR to IND_RR_W from GPR to IND_RR_W
gen gen
@ -546,8 +546,8 @@ MOVES
from GPR to IND_LABEL_W from GPR to IND_LABEL_W
gen gen
COMMENT("move GPR->IND_LABEL_D") COMMENT("move GPR->IND_LABEL_D")
move {LABEL, %2.adr}, SCRATCH move {LABEL, %2.adr}, RSCRATCH
stw %1, {GPRINDIRECT, SCRATCH, 0} stw %1, {GPRINDIRECT, RSCRATCH, 0}
from FSREG to IND_RC_W smalls(%off) from FSREG to IND_RC_W smalls(%off)
gen gen
@ -557,8 +557,8 @@ MOVES
from FSREG to IND_RC_W from FSREG to IND_RC_W
gen gen
COMMENT("move FSREG->IND_RC_W large") COMMENT("move FSREG->IND_RC_W large")
addis SCRATCH, %2.reg, {CONST, his(%2.off)} addis RSCRATCH, %2.reg, {CONST, his(%2.off)}
stfs %1, {GPRINDIRECT, SCRATCH, los(%2.off)} stfs %1, {GPRINDIRECT, RSCRATCH, los(%2.off)}
from FSREG to IND_RR_W from FSREG to IND_RR_W
gen gen
@ -568,8 +568,8 @@ MOVES
from FSREG to IND_LABEL_W from FSREG to IND_LABEL_W
gen gen
COMMENT("move FSREG->IND_LABEL_D") COMMENT("move FSREG->IND_LABEL_D")
move {LABEL, %2.adr}, SCRATCH move {LABEL, %2.adr}, RSCRATCH
stfs %1, {GPRINDIRECT, SCRATCH, 0} stfs %1, {GPRINDIRECT, RSCRATCH, 0}
/* Read double */ /* Read double */
@ -581,8 +581,8 @@ MOVES
from IND_RC_D to FPR from IND_RC_D to FPR
gen gen
COMMENT("move IND_RC_D->FPR large") COMMENT("move IND_RC_D->FPR large")
addis SCRATCH, %1.reg, {CONST, his(%1.off)} addis RSCRATCH, %1.reg, {CONST, his(%1.off)}
lfd %2, {GPRINDIRECT, SCRATCH, los(%1.off)} lfd %2, {GPRINDIRECT, RSCRATCH, los(%1.off)}
from IND_RR_D to FPR from IND_RR_D to FPR
gen gen
@ -592,8 +592,8 @@ MOVES
from IND_LABEL_D to FPR from IND_LABEL_D to FPR
gen gen
COMMENT("move IND_LABEL_D->FPR") COMMENT("move IND_LABEL_D->FPR")
move {LABEL, %1.adr}, SCRATCH move {LABEL, %1.adr}, RSCRATCH
lfd %2, {GPRINDIRECT, SCRATCH, 0} lfd %2, {GPRINDIRECT, RSCRATCH, 0}
/* Write double */ /* Write double */
@ -605,8 +605,8 @@ MOVES
from FPR to IND_RC_D from FPR to IND_RC_D
gen gen
COMMENT("move FPR->IND_RC_D large") COMMENT("move FPR->IND_RC_D large")
addis SCRATCH, %2.reg, {CONST, his(%2.off)} addis RSCRATCH, %2.reg, {CONST, his(%2.off)}
stfd %1, {GPRINDIRECT, SCRATCH, los(%2.off)} stfd %1, {GPRINDIRECT, RSCRATCH, los(%2.off)}
from FPR to IND_RR_D from FPR to IND_RR_D
gen gen
@ -616,8 +616,8 @@ MOVES
from FPR to IND_LABEL_D from FPR to IND_LABEL_D
gen gen
COMMENT("move FPR->IND_LABEL_D") COMMENT("move FPR->IND_LABEL_D")
move {LABEL, %2.adr}, SCRATCH move {LABEL, %2.adr}, RSCRATCH
stfd %1, {GPRINDIRECT, SCRATCH, 0} stfd %1, {GPRINDIRECT, RSCRATCH, 0}
/* Extract condition code field (actually produces (CC&3)<<2) */ /* Extract condition code field (actually produces (CC&3)<<2) */
@ -640,8 +640,8 @@ MOVES
from TRISTATE_RC_S to CR0 from TRISTATE_RC_S to CR0
gen gen
COMMENT("move TRISTATE_RC_S->CR0 large") COMMENT("move TRISTATE_RC_S->CR0 large")
move {CONST, %1.val}, SCRATCH move {CONST, %1.val}, RSCRATCH
cmp %2, {CONST, 0}, %1.reg, SCRATCH cmp %2, {CONST, 0}, %1.reg, RSCRATCH
from TRISTATE_RC_U smallu(%val) to CR0 from TRISTATE_RC_U smallu(%val) to CR0
gen gen
@ -651,8 +651,8 @@ MOVES
from TRISTATE_RC_U to CR0 from TRISTATE_RC_U to CR0
gen gen
COMMENT("move TRISTATE_RC_U->CR0") COMMENT("move TRISTATE_RC_U->CR0")
move {CONST, %1.val}, SCRATCH move {CONST, %1.val}, RSCRATCH
cmpl %2, {CONST, 0}, %1.reg, SCRATCH cmpl %2, {CONST, 0}, %1.reg, RSCRATCH
from TRISTATE_FF to CR0 from TRISTATE_FF to CR0
gen gen
@ -662,23 +662,23 @@ MOVES
from GPR to CR0 from GPR to CR0
gen gen
COMMENT("move GPR->CR0") COMMENT("move GPR->CR0")
orX SCRATCH, %1, %1 /* alas, can't call test */ orX RSCRATCH, %1, %1 /* alas, can't call test */
from TRISTATE_RR_S + TRISTATE_RC_S + TRISTATE_FF to GPR from TRISTATE_RR_S + TRISTATE_RC_S + TRISTATE_FF to GPR
gen gen
COMMENT("move TRISTATE_R*_S->GPR") COMMENT("move TRISTATE_R*_S->GPR")
move %1, C0 move %1, C0
move C0, SCRATCH move C0, RSCRATCH
move {LABEL, ".tristate_s_table"}, %2 move {LABEL, ".tristate_s_table"}, %2
lwzx %2, %2, SCRATCH lwzx %2, %2, RSCRATCH
from TRISTATE_RR_U + TRISTATE_RC_U to GPR from TRISTATE_RR_U + TRISTATE_RC_U to GPR
gen gen
COMMENT("move TRISTATE_R*_U->GPR") COMMENT("move TRISTATE_R*_U->GPR")
move %1, C0 move %1, C0
move C0, SCRATCH move C0, RSCRATCH
move {LABEL, ".tristate_u_table"}, %2 move {LABEL, ".tristate_u_table"}, %2
lwzx %2, %2, SCRATCH lwzx %2, %2, RSCRATCH
/* Logicals */ /* Logicals */
@ -700,8 +700,8 @@ MOVES
from AND_RC to GPR from AND_RC to GPR
gen gen
COMMENT("move AND_RC->GPR") COMMENT("move AND_RC->GPR")
move {CONST, %1.val}, SCRATCH move {CONST, %1.val}, RSCRATCH
and %2, %1.reg, SCRATCH and %2, %1.reg, RSCRATCH
from OR_RR to GPR from OR_RR to GPR
gen gen
@ -716,8 +716,8 @@ MOVES
from OR_RC to GPR from OR_RC to GPR
gen gen
COMMENT("move OR_RC->GPR") COMMENT("move OR_RC->GPR")
move {CONST, %1.val}, SCRATCH move {CONST, %1.val}, RSCRATCH
or %2, %1.reg, SCRATCH or %2, %1.reg, RSCRATCH
from XOR_RR to GPR from XOR_RR to GPR
gen gen
@ -732,8 +732,8 @@ MOVES
from XOR_RC to GPR from XOR_RC to GPR
gen gen
COMMENT("move XOR_RC->GPR") COMMENT("move XOR_RC->GPR")
move {CONST, %1.val}, SCRATCH move {CONST, %1.val}, RSCRATCH
xor %2, %1.reg, SCRATCH xor %2, %1.reg, RSCRATCH
/* Miscellaneous */ /* Miscellaneous */
@ -746,7 +746,7 @@ TESTS
to test GPR to test GPR
gen gen
orX SCRATCH, %1, %1 orX RSCRATCH, %1, %1
@ -757,51 +757,51 @@ STACKINGRULES
COMMENT("stack LOCAL") COMMENT("stack LOCAL")
stwu {GPRE, regvar(%1.off)}, {GPRINDIRECT, SP, 0-4} stwu {GPRE, regvar(%1.off)}, {GPRINDIRECT, SP, 0-4}
from GPR to STACK from REG to STACK
gen gen
COMMENT("stack GPR") COMMENT("stack REG")
stwu %1, {GPRINDIRECT, SP, 0-4} stwu %1, {GPRINDIRECT, SP, 0-4}
from CONST to STACK from CONST to STACK
gen gen
COMMENT("stack CONST") COMMENT("stack CONST")
move %1, SCRATCH move %1, RSCRATCH
stwu SCRATCH, {GPRINDIRECT, SP, 0-4} stwu RSCRATCH, {GPRINDIRECT, SP, 0-4}
from LABEL to STACK from LABEL to STACK
gen gen
COMMENT("stack LABEL") COMMENT("stack LABEL")
move %1, SCRATCH move %1, RSCRATCH
stwu SCRATCH, {GPRINDIRECT, SP, 0-4} stwu RSCRATCH, {GPRINDIRECT, SP, 0-4}
from SEX_B to STACK from SEX_B to STACK
gen gen
COMMENT("stack SEX_B") COMMENT("stack SEX_B")
extsb SCRATCH, %1.reg extsb RSCRATCH, %1.reg
stwu SCRATCH, {GPRINDIRECT, SP, 0-4} stwu RSCRATCH, {GPRINDIRECT, SP, 0-4}
from SEX_H to STACK from SEX_H to STACK
gen gen
COMMENT("stack SEX_H") COMMENT("stack SEX_H")
extsh SCRATCH, %1.reg extsh RSCRATCH, %1.reg
stwu SCRATCH, {GPRINDIRECT, SP, 0-4} stwu RSCRATCH, {GPRINDIRECT, SP, 0-4}
from SUM_ALL + TRISTATE_ALL + LOGICAL_ALL to STACK from SUM_ALL + TRISTATE_ALL + LOGICAL_ALL to STACK
gen gen
move %1, {GPRE, SCRATCH} move %1, {GPRE, RSCRATCH}
stwu SCRATCH, {GPRINDIRECT, SP, 0-4} stwu RSCRATCH, {GPRINDIRECT, SP, 0-4}
from IND_ALL_W to STACK from IND_ALL_W to STACK
gen gen
move %1, SCRATCH move %1, RSCRATCH
stwu SCRATCH, {GPRINDIRECT, SP, 0-4} stwu RSCRATCH, {GPRINDIRECT, SP, 0-4}
from IND_ALL_D to STACK from IND_ALL_D to STACK
gen gen
move %1, FSCRATCH move %1, FSCRATCH
stfdu FSCRATCH, {GPRINDIRECT, SP, 0-8} stfdu FSCRATCH, {GPRINDIRECT, SP, 0-8}
from FPR to STACK from FREG to STACK
gen gen
COMMENT("stack FPR") COMMENT("stack FPR")
stfdu %1, {GPRINDIRECT, SP, 0-8} stfdu %1, {GPRINDIRECT, SP, 0-8}
@ -870,8 +870,8 @@ COERCIONS
fmr %a, %1 fmr %a, %1
yields %a yields %a
from FPR from FREG
uses FPR uses FREG
gen gen
fmr %a, %1 fmr %a, %1
yields %a yields %a
@ -921,19 +921,19 @@ PATTERNS
yields {CONST, $1} yields {CONST, $1}
pat dup $1==INT32 /* Duplicate word on top of stack */ pat dup $1==INT32 /* Duplicate word on top of stack */
with GPR with REG
yields %1 %1 yields %1 %1
with FSREG with FSREG
yields %1 %1 yields %1 %1
pat dup $1==INT64 /* Duplicate double-word on top of stack */ pat dup $1==INT64 /* Duplicate double-word on top of stack */
with GPR GPR with REG REG
yields %2 %1 %2 %1 yields %2 %1 %2 %1
with FREG with FREG
yields %1 %1 yields %1 %1
pat exg $1==INT32 /* Exchange top two words on stack */ pat exg $1==INT32 /* Exchange top two words on stack */
with GPR GPR with REG REG
yields %1 %2 yields %1 %2
pat stl lol $1==$2 /* Store then load local */ pat stl lol $1==$2 /* Store then load local */
@ -1635,9 +1635,9 @@ PATTERNS
uses reusing %1, REG uses reusing %1, REG
gen gen
move %1, C0 move %1, C0
move C0, SCRATCH move C0, RSCRATCH
move {LABEL, ".teq_table"}, %a move {LABEL, ".teq_table"}, %a
lwzx %a, %a, SCRATCH lwzx %a, %a, RSCRATCH
yields %a yields %a
pat tne /* top = (top != 0) */ pat tne /* top = (top != 0) */
@ -1645,9 +1645,9 @@ PATTERNS
uses reusing %1, REG uses reusing %1, REG
gen gen
move %1, C0 move %1, C0
move C0, SCRATCH move C0, RSCRATCH
move {LABEL, ".tne_table"}, %a move {LABEL, ".tne_table"}, %a
lwzx %a, %a, SCRATCH lwzx %a, %a, RSCRATCH
yields %a yields %a
pat tlt /* top = (top < 0) */ pat tlt /* top = (top < 0) */
@ -1655,9 +1655,9 @@ PATTERNS
uses reusing %1, REG uses reusing %1, REG
gen gen
move %1, C0 move %1, C0
move C0, SCRATCH move C0, RSCRATCH
move {LABEL, ".tlt_table"}, %a move {LABEL, ".tlt_table"}, %a
lwzx %a, %a, SCRATCH lwzx %a, %a, RSCRATCH
yields %a yields %a
pat tle /* top = (top <= 0) */ pat tle /* top = (top <= 0) */
@ -1665,9 +1665,9 @@ PATTERNS
uses reusing %1, REG uses reusing %1, REG
gen gen
move %1, C0 move %1, C0
move C0, SCRATCH move C0, RSCRATCH
move {LABEL, ".tle_table"}, %a move {LABEL, ".tle_table"}, %a
lwzx %a, %a, SCRATCH lwzx %a, %a, RSCRATCH
yields %a yields %a
pat tgt /* top = (top > 0) */ pat tgt /* top = (top > 0) */
@ -1675,9 +1675,9 @@ PATTERNS
uses reusing %1, REG uses reusing %1, REG
gen gen
move %1, C0 move %1, C0
move C0, SCRATCH move C0, RSCRATCH
move {LABEL, ".tgt_table"}, %a move {LABEL, ".tgt_table"}, %a
lwzx %a, %a, SCRATCH lwzx %a, %a, RSCRATCH
yields %a yields %a
pat tge /* top = (top >= 0) */ pat tge /* top = (top >= 0) */
@ -1685,9 +1685,9 @@ PATTERNS
uses reusing %1, REG uses reusing %1, REG
gen gen
move %1, C0 move %1, C0
move C0, SCRATCH move C0, RSCRATCH
move {LABEL, ".tge_table"}, %a move {LABEL, ".tge_table"}, %a
lwzx %a, %a, SCRATCH lwzx %a, %a, RSCRATCH
yields %a yields %a