This is the mail archive of the
mailing list for the GCC project.
Re: Query with legitimate_constant_p
- From: Dan Towner <dant at picochip dot com>
- To: Geoff Keating <geoffk at geoffk dot org>, gcc at gcc dot gnu dot org
- Date: Tue, 12 Feb 2002 15:50:54 +0000
- Subject: Re: Query with legitimate_constant_p
- Organization: picoChip Designs Ltd.
- References: <003001c1b26b$b3cbd790$1528fdd5@DERWENT> <email@example.com> <3C69153C.8624C4DD@picochip.com>
Geoff Keating wrote:
> > D.Towner wrote:
> > > I am writing a new port of GCC. I want to prevent symbol_refs from being
> > > used as immediate operands, so I am specifically rejecting these in
> > > legitimate_constant_p.
> > You don't want to do this...
> > > However, this also means that the addresses of
> > > symbol_refs can't be computed (e.g, loading the address into a register),
> > because clearly you _do_ use SYMBOL_REF as an immediate operand.
> > > where previously a `mov??3' instruction was used to move the symbol_ref
> > > address into a register. This no longer works, as the mov instruction can't
> > > accept an immediate symbol_ref any more. How do I fix this?
> > Instead of doing that, use `n' constraints, and suitable predicates
> > where appropriate, to prevent GCC generating symbol references as
> > immediate operands where they won't work.
That doesn't work though. Consider the following:
reg0 := symbol_ref("s")
reg1 := mem(reg0 + 2)
Because the symbol_ref is a valid constant, gcc propagates the constant
into the memory load:
reg1 := mem(symbol_ref("s") + 2)
I don't allow this to be generated directly, but the constant
propagation causes it to be generated, without appearing to recheck the
on the instruction. Thus, doesn't this mean that symbol_refs must fail
legitimate_constant_p in order to prevent them being propagated into
picoChip Designs Ltd., Riverside Buildings, 108, Walcot Street, BATH,