On Sunday 04 June 2006 16:26, Wolfgang Mües wrote:
> Paul,
>
> On Sunday 04 June 2006 13:24, Paul Brook wrote:
> > On Sunday 04 June 2006 11:31, Wolfgang Mües wrote:
> > > Splitting the insn
> > >
> > > (define_insn "*arm_movqi_insn"
> > >   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,m")
> > >   (match_operand:QI 1 "general_operand" "rI,K,m,r"))]
> > >
> > > into 4 different insns:
> >
> > No. This is completely the wrong approach.
>
> Why? I am learning.

Because then you have several different patterns for the same operation.
The different variants of movsi should be part of the same pattern so that the 
compiler can change its mind which variant it wants to use.

> > You should just change the valid QImode memory addresses, adding a new
> > constraint if neccessary.
>
> Hmmmm... I have tried this. I have changed the operand constraint from
> "m" to "Q". But these constraints are only used to select the right
> alternative inside the insn, not which insn is invoked. It might be
> possible to modify "nonimmediate_operand"
> into something else, to select this insn only if the address is fitting
> in a single register, without offset or increment.
>
> But this will not give me the freedom to allocate a temporary register.
> According to the manual, mov insns are not supposed to clobber a
> register. I suppose I will have to allocate these registers in
>
> (define_expand "movqi"
>   [(set (match_operand:QI 0 "general_operand" "")
>         (match_operand:QI 1 "general_operand" ""))]
>
> So I have to narrow down the constraint "nonimmediate_operand", so that
> every memory address not fitting in a single register will not invoke
> arm_movqi_insn.

You're confusing constraints and predicates. general_operand is the predicate.
The predicate says under which conditions the insn will match.
The constraints tell regalooc/reload how to make sure the operands of the 
instruction are valid.

To simplify greatly the predicates are used for pattern matching during early 
RTL generation and the constraints are used in the later regalloc/reload 
stages.

Tightening the predicates isn't sufficient (and may not even be neccessary). 
You need to set the constraints so that the compiler knows *how* to fix 
invalid instructions.

The compilcation is that while constraints give sufficient information for the 
compiler to generate correct code they don't help generating good code.  
There are often non-obvious target specific ways of reloading invalid 
addresses. So reload has additional hooks (eg. GO_IF_LEGITIMATE_ADDRESS) to 
provice clever ways of fixing invalid operands. Generally speaking it's up to 
the target backend to make sure the code generated by these satisfies the 
appropriate constraints, and gcc will ICE if they aren't consistent.

I'm afraid I can't really be more specific that this. That would require me 
implementing your changes and figuring out what's going wrong.

Paul

Reply via email to