On Tue, Mar 10, 2009 at 10:18:10PM +0100, Georg-Johann Lay wrote:
> Note that no one is generating an insn that looks like "*jump". Maybe
> insn combine and peep2 would try to build such a pattern, but that is
> not what helpd you out here. Write the expander as parallel of a (set
> (pc) ...) and a (clobber (match_scratch ...)) so that an appropriate
> insn is expanded.
Like this ?
(define_expand "jump"
[(parallel [(set (pc) (label_ref (match_operand 0 "" "")))
(clobber (match_scratch:QI 1 "=&r"))])]
""
""
)
> Also note that "*jump" is an (implicit) parallel. As
> constraint for the "*jump" insn use an "X" in the case you do not need
> the clobber reg and sth. like "=&r" in the case you really need it.
Ok, but the decision on if I need the clobber reg or not is based
on the 'length' attribute. So if I could write the following, but where
I can put the calculation and the test of the 'length' attribute:
(define_insn "*jump_internal"
[(set (pc)
(label_ref (match_operand 0 "" "")))
(clobber (match_scratch:QI 1 "X,=&r"))]
""
"@
rjmp %0
ldih %1,hi(%l0)\n\t\n\tldil %1,lo(%l0)\n\tijmp (%1)"
)
>> Side question regarding the "length" attribute. It seems to work ok, but
>> if I change the default value (first line in my example) to be 'const_int 1',
>> I later get 'operand out of range' from the assembler because the 'rjmp'
>> instruction was used for deplacements bigger than 2048. How can this happen,
>> since my '(set (attr "length")' code explicitly sets the correct value
>> each time ?
>
> You set the length explicitely, so the default does not matter.
Yes, this was exactly my point. It shouldn't matter, but it does, because
it does different things when I change the default value.
Stelian.
--
Stelian Pop <[email protected]>