Hard registers in RTL templates, -fomit-frame-pointer

law@redhat.com law@redhat.com
Sun Jun 23 11:02:00 GMT 2002


In message <15636.65474.191987.685819@sibyl.beware.dropbear.id.au>, Ian Dall wr
ites:
 > I am trying to track down the cause of incorrect code generation
 > with the -fomit-frame-pointer option for the ns32k.
 > 
 > What happens is 
 > 
 > (insn 20 19 21 (set (reg:SI 1 r1)
 >         (plus:SI (reg/f:SI 24 fp)
 >             (const_int -36 [0xffffffdc]))) 60 {*frame_addr} (nil)
 >     (nil))
 > 
 > after local register allocation gets translated to
 > 
 > (insn 20 18 22 (set (reg:SI 1 r1)
 >         (plus:SI (reg/f:SI 25 sp)
 >             (const_int 40 [0x28]))) 60 {*frame_addr} (nil)
 >     (nil))
 > 
 > after global register allocation. This is wrong because it doesn't
 > match the pattern for "*frame_addr", which is:
 > 
 > (define_insn "*frame_addr"
 >   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm<")
 > 	(plus:SI (reg:SI 24)
 > 		 (match_operand:SI 1 "immediate_operand" "i")))]
 >   "GET_CODE (operands[1]) == CONST_INT"
 >   "addr %c1(fp),%0")
 > 
 > 
 > There is a corresponding "*stack_addr" which would match.  I know one
 > way I can fix this: replace the hard register number with a match_operand
 > which can only match fp or sp, then make the assembly generation conditional
 > on REGNO (operands[...]).
That would certainly work and seems like the best solution without overhauling
your entire port :-)  You might investigate combining the various addsi
patterns into a single pattern -- addsi is somewhat special like movsi in
that regard due to how it's used by register reloading.


 > The question I have is is this the Right Thing To Do (tm). I notice no
 > prohibition against hard register numbers in RTL templates in the
 > documentation and they are quite widely used in most machine
 > descriptions. If it is the right thing to do, how far do I go? Should I
 > eliminate all such hard register numbers? Only references to sp or fp?
In general we recommend trying to avoid explicit hard registers in patterns;
sometimes they're unavoidable, but that should be the exception rather than
the rule.

The compiler 




More information about the Gcc mailing list