* postreload problem using reload_inm and SECONDARY_RELOAD macros
@ 2011-09-14 13:09 BELBACHIR Selim
2011-09-14 13:41 ` Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: BELBACHIR Selim @ 2011-09-14 13:09 UTC (permalink / raw)
To: gcc
Hi,
I'm writing a backend for gcc3.4.6 and I'm a bit confused about reload passes.
-> my constraints :
'b' = arithmetic/logical unit register ($R, class R_REGS)
'c' = counter register ($C, class C_REGS)
'v' = memory with several special constraint (also described in predicate my_mem_or_reg_operand)
-> movsi expand/insn :
(define_insn "movsi_internal"
[(set
(match_operand:SI 0 "my_mem_or_reg_operand" "=v,v,c,b,b ")
(match_operand: SI 1 "general_operand" "c,b,v,v,i "))]
""
"@
mov %1,%0
[.]
loadi %1,%0"
)
(define_expand "movsi"
[(set
(match_operand:SI 0 "general_operand" "")
(match_operand:SI 1 "general_operand" ""))]
""
{
/* Handle Memory to Memory and immediate to memory movs */
if (((GET_CODE (operands[1]) == MEM) || immediate_operand (operands[1], SImode))
&& (GET_CODE(operands[0])== MEM) )
{
operands[1] = force_reg(SImode,operands[1]);
}
}
)
Note there is no instruction to move immediate to $R regs ('b' constraint) but there is one to move immediate to $C regs ('c' constraint).
I have no mean to express this limitation inside predicates (because pseudo register don't known in which hard register they will be allocated), reload pass create some moves from immediate to $R. :
arithmetic.c:197: error: insn does not satisfy its constraints:
(insn 1505 903 1506 0 (set (reg:SI 25 $R9)
(const_int 8 [0x8])) 0 {movsi_internal} (nil)
(nil))
arithmetic.c:197: internal compiler error: in reload_cse_simplify_operands, at postreload.c:391
So, I read the doc :) and figured out how to control the reload pass. I added 2 MACROs and the reload_insi expand :
#define PREFERRED_RELOAD_CLASS(X,CLASS) my_preferred_reload_class(X,CLASS)
#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) my_secondary_input_reload_class (CLASS, MODE, X)
enum reg_class my_preferred_reload_class(rtx x, enum reg_class rclass)
{
if (GET_CODE(x) == CONST_INT || GET_CODE(x) == CONST_DOUBLE) {
if (rclass == GENERAL_REGS) {
return C_REGS;
}
else if (rclass == R_REGS) {
return NO_REGS; /* put the constant in memory */
}
}
return rclass;
}
enum reg_class my_secondary_input_reload_class(enum reg_class rclass, enum machine_mode mode, rtx x)
{
if ((GET_CODE(x) == CONST_INT || GET_CODE(x) == CONST_DOUBLE) && rclass == R_REGS) {
return C_REGS; /* use C_REGS for clobber in reload_insi */
}
return NO_REGS;
}
(define_expand "reload_insi"
[(set
(match_operand:SI 0 "register_operand" "=b")
(match_operand:SI 1 "immediate_operand" "i"))
(clobber (match_operand:SI 2 "register_operand" "=c"))]
"
{
emit_insn(gen_rtx_SET(SImode, operands[2], operands[1]));
emit_insn(gen_rtx_SET(SImode, operands[0], operands[2]));
DONE;
}
)
Theses MACROs and insn do not solve my problem and the forbidden move keeps on being emitted.
Did I misunderstood something ? A my doing something illegal ? Should I do things differently?
(A printf in my reload_insi shows that this expand is never called.)
Thank you for your help.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: postreload problem using reload_inm and SECONDARY_RELOAD macros
2011-09-14 13:09 postreload problem using reload_inm and SECONDARY_RELOAD macros BELBACHIR Selim
@ 2011-09-14 13:41 ` Ian Lance Taylor
2011-09-14 16:14 ` BELBACHIR Selim
[not found] ` <13001_1316008937_4E70B3E9_13001_13069_1_9C88BF562A27AA41B242B2780441926E207712005C@THSONEA01CMS05P.one.grp>
0 siblings, 2 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2011-09-14 13:41 UTC (permalink / raw)
To: BELBACHIR Selim; +Cc: gcc
BELBACHIR Selim <selim.belbachir@fr.thalesgroup.com> writes:
> I'm writing a backend for gcc3.4.6 and I'm a bit confused about reload passes.
You know gcc 3.4.6 is really old, right?
> I have no mean to express this limitation inside predicates (because
> pseudo register don't known in which hard register they will be
> allocated), reload pass create some moves from immediate to $R. :
First guess would be REGISTER_MOVE_COST.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: postreload problem using reload_inm and SECONDARY_RELOAD macros
2011-09-14 13:41 ` Ian Lance Taylor
@ 2011-09-14 16:14 ` BELBACHIR Selim
[not found] ` <13001_1316008937_4E70B3E9_13001_13069_1_9C88BF562A27AA41B242B2780441926E207712005C@THSONEA01CMS05P.one.grp>
1 sibling, 0 replies; 4+ messages in thread
From: BELBACHIR Selim @ 2011-09-14 16:14 UTC (permalink / raw)
To: gcc
Yes I know gcc 3.4.6 is quite old :) but the backend work has started on this version for bad reasons and now we plan to make something work (pass a few test cases) before migrating to last gcc 4 version.
Concerning REGISTER_MOVE_COST, I don't know what can be fixed with it.
The 3 params of REGISTER_MOVE_COST are (machine_mode mode, regclass from, reg_class to).
So I can only write cost for register to register moves.
I don't see any suitable macro to specify immediate to register moves. (in gcc3.4.6 internals ....)
Nevertheless, the REGISTER_MOVE_COST is defined with costs 3 for all valid moves (C_REGS <-> R_REGS).
Is there a way to prevent totally the allocation of a hard register in specific context using 'costs'?
-----Message d'origine-----
De : Ian Lance Taylor [mailto:iant@google.com]
Envoyé : mercredi 14 septembre 2011 15:40
À : BELBACHIR Selim
Cc : gcc@gcc.gnu.org
Objet : Re: postreload problem using reload_inm and SECONDARY_RELOAD macros
BELBACHIR Selim <selim.belbachir@fr.thalesgroup.com> writes:
> I'm writing a backend for gcc3.4.6 and I'm a bit confused about reload passes.
You know gcc 3.4.6 is really old, right?
> I have no mean to express this limitation inside predicates (because
> pseudo register don't known in which hard register they will be
> allocated), reload pass create some moves from immediate to $R. :
First guess would be REGISTER_MOVE_COST.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: postreload problem using reload_inm and SECONDARY_RELOAD macros
[not found] ` <mcrty8fb3qn.fsf@coign.corp.google.com>
@ 2011-09-15 7:51 ` BELBACHIR Selim
0 siblings, 0 replies; 4+ messages in thread
From: BELBACHIR Selim @ 2011-09-15 7:51 UTC (permalink / raw)
To: gcc
further hints :
The immediate which gcc wants to move in R_REGS is a (const_int 8) as described in the error message below :
arithmetic.c:197: error: insn does not satisfy its constraints:
(insn 1505 903 1506 0 (set (reg:SI 25 $R9)
(const_int 8 [0x8])) 0 {movsi_internal} (nil)
(nil))
arithmetic.c:197: internal compiler error: in reload_cse_simplify_operands, at postreload.c:391
So I added some debug trace in function 'my_secondary_input_reload_class' to understand why (const_int 8) is not reloaded to C_REGS.
'my_secondary_input_reload_class' is called several times but never with rtl expression (const_int 8).
I also checked 'my_preferred_reload_class' function and I don't see expression (const_int 8).
Selim
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-09-15 7:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-14 13:09 postreload problem using reload_inm and SECONDARY_RELOAD macros BELBACHIR Selim
2011-09-14 13:41 ` Ian Lance Taylor
2011-09-14 16:14 ` BELBACHIR Selim
[not found] ` <13001_1316008937_4E70B3E9_13001_13069_1_9C88BF562A27AA41B242B2780441926E207712005C@THSONEA01CMS05P.one.grp>
[not found] ` <mcrty8fb3qn.fsf@coign.corp.google.com>
2011-09-15 7:51 ` BELBACHIR Selim
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).