* TARGET_SECONDARY_RELOAD usage
@ 2011-08-28 14:13 Ilya Lesokhin
2011-08-29 12:21 ` Georg-Johann Lay
0 siblings, 1 reply; 2+ messages in thread
From: Ilya Lesokhin @ 2011-08-28 14:13 UTC (permalink / raw)
To: gcc-help
Hi,
The avr backend uses r0 as a temporary register for a couple of
complex instruction, and i would like to remove that usage.
As a start i wanted to remove it from the code to update the stack,
this code need a temporary register to save the flags before disabling
the interrupts so i tried to use secondary reload to get a temporary
register.
i defined the following in avr.c:
[Code]
static reg_class_t
avr_secondary_reload (bool in_p, rtx x, reg_class_t rclass,
enum machine_mode mode,
secondary_reload_info *sri)
{
if (in_p)
{
if (rclass == STACK_REG && register_operand (x, HImode))
{
if (!TARGET_NO_INTERRUPTS && !AVR_HAVE_8BIT_SP)
{
sri->icode = CODE_FOR_movhi_sp_r;
}
}
}
return NO_REGS;
}
#undef TARGET_SECONDARY_RELOAD
#define TARGET_SECONDARY_RELOAD avr_secondary_reload
[\Code]
and in avr.md:
[Code]
(define_insn "movhi_sp_r"
[(set (match_operand:HI 0 "stack_register_operand" "=q")
(match_operand:HI 1 "register_operand" "r"))
(clobber (match_operand:QI 2 "register_operand" "=&r"))]
"(stack_register_operand(operands[0], HImode) && register_operand
(operands[1], HImode))"
"in %2, __SREG__
cli
out __SP_H__, %B1
out,__SREG__, %2
out,__SP_L__, %A1"
[(set_attr "length" "5")
(set_attr "cc" "none")])
[\Code]
but for some reason when i use my changed compiler to compile code
that update the stack pointer i get the following error:
../testgcc.c:24:1: error: invalid insn:
(insn/f 27 26 28 (set (reg/f:HI 28 r28)
(reg/f:HI 32 __SP_L__)) ../testgcc.c:4 7 {*movhi_r_sp}
(expr_list:REG_UNUSED (reg:QI 29 r29)
(nil)))
which to me say's that the compiler didnt use my new pattern.
can anyone explain to me what's wrong with what i did?
Thank in advance,
Ilya.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: TARGET_SECONDARY_RELOAD usage
2011-08-28 14:13 TARGET_SECONDARY_RELOAD usage Ilya Lesokhin
@ 2011-08-29 12:21 ` Georg-Johann Lay
0 siblings, 0 replies; 2+ messages in thread
From: Georg-Johann Lay @ 2011-08-29 12:21 UTC (permalink / raw)
To: Ilya Lesokhin; +Cc: gcc-help
Ilya Lesokhin schrieb:
> Hi,
>
> The avr backend uses r0 as a temporary register for a couple of
> complex instruction, and i would like to remove that usage.
> As a start i wanted to remove it from the code to update the stack,
> this code need a temporary register to save the flags before disabling
> the interrupts so i tried to use secondary reload to get a temporary
> register.
>
> i defined the following in avr.c:
> [Code]
> static reg_class_t
> avr_secondary_reload (bool in_p, rtx x, reg_class_t rclass,
> enum machine_mode mode,
> secondary_reload_info *sri)
> {
> if (in_p)
> {
> if (rclass == STACK_REG && register_operand (x, HImode))
> {
> if (!TARGET_NO_INTERRUPTS && !AVR_HAVE_8BIT_SP)
> {
> sri->icode = CODE_FOR_movhi_sp_r;
> }
> }
> }
> return NO_REGS;
> }
>
> #undef TARGET_SECONDARY_RELOAD
> #define TARGET_SECONDARY_RELOAD avr_secondary_reload
> [\Code]
>
> and in avr.md:
>
> [Code]
> (define_insn "movhi_sp_r"
> [(set (match_operand:HI 0 "stack_register_operand" "=q")
> (match_operand:HI 1 "register_operand" "r"))
> (clobber (match_operand:QI 2 "register_operand" "=&r"))]
> "(stack_register_operand(operands[0], HImode) && register_operand
> (operands[1], HImode))"
> "in %2, __SREG__
> cli
> out __SP_H__, %B1
> out,__SREG__, %2
> out,__SP_L__, %A1"
> [(set_attr "length" "5")
> (set_attr "cc" "none")])
> [\Code]
>
>
> but for some reason when i use my changed compiler to compile code
> that update the stack pointer i get the following error:
>
> ../testgcc.c:24:1: error: invalid insn:
> (insn/f 27 26 28 (set (reg/f:HI 28 r28)
> (reg/f:HI 32 __SP_L__)) ../testgcc.c:4 7 {*movhi_r_sp}
> (expr_list:REG_UNUSED (reg:QI 29 r29)
> (nil)))
>
> which to me say's that the compiler didnt use my new pattern.
>
> can anyone explain to me what's wrong with what i did?
>
> Thank in advance,
> Ilya.
The avr BE has more thon one movhi insn. It's discouraged to have more
than one move insn per mode. Remove the superfluous move insn and
ensure that the remaining mov insn handles that case.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-29 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-28 14:13 TARGET_SECONDARY_RELOAD usage Ilya Lesokhin
2011-08-29 12:21 ` Georg-Johann Lay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).