This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR target/21299 (reload accepting invalid asm)


Richard Sandiford <richard@codesourcery.com> writes:

> Ian Lance Taylor <iant@google.com> writes:
> > Richard Sandiford <richard@codesourcery.com> writes:
> >> I think we need to clarify what it means to have several register
> >> classes in the same alternative.  Which interpretation is right?
> >> constrain_operands(), or find_reloads() and preprocess_constraints()?
> >
> > Thanks for helping to clarify the issue.  As I noted in my earlier
> > reply, I believe that both interpretations are right, because MD file
> > writers are required to follow rules such that both are right.
> 
> Wasn't sure whether to reply to that message or this one, but...
> 
> I think that message missed the point.  At least it misses the point of
> what I was trying to say in my reply.  What happens if you have constraints
> for two register classes C1 and C2, and a union C1+C2?  Must a register
> belong to either C1 or C2, or may it straddle both?  constrain_operands()
> does not allow it to straddle both classes, but find_reloads() and
> preprocess_constraints() do.

I believe that an MD file for which this question arises is buggy.

It can only arise if you use a value which requires multiple
registers, and you put multiple register class constraints in a single
alternative, and it is possible, due to register numbering and the
definition of HARD_REGNO_MODE_OK, for the multiple registers to cross
from one register class to another.

I see no reason that we ever need to support this case.  Therefore,
the MD file is buggy.  You should fix HARD_REGNO_MODE_OK, or you
should separate the constraints into two separate alternatives, or you
should use the union class.  We don't need to answer the question of
which of constrain_operand or find_reloads is correct, because for
correctly written MD files they will always reach the same answer.

> Note that we definitely have cases where .md files are using classes that
> have no direct union.  E.g. ARM has "lh" constraints, but there is no
> class that holds exactly the union of LO_REGS and HI_REGS.  (GENERAL_REGS
> includes the soft frame pointer too, which I still think is very
> suspicious.)  But that is an aside to main point (the one I tried to
> clarify in the paragraph above).

That does seem somewhat suspicious.  I think it's harmless in this
case since the soft frame pointer is a fixed register.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]