On Tue, Mar 10, 2009 at 05:20:28PM +0000, Dave Korn wrote:

> Stelian Pop wrote:
> 
> > I need to use a scratch register in the "jump" pattern and I can't
> > figure out how to do it properly.
> > 
> > My problem is that the microcontroller I'm porting gcc onto does not
> > permit "far" jumps, those must be done using an indirect adressing.
> 
> > (define_insn "*jump"
> 
> > Any idea ?
> 
>   You should be able to define/use the "indirect_jump" pattern instead?  Take
> a look at the last paragraph of the the docs for the "call" pattern as well.
> 

I already do have an "indirect_jump" pattern in my md file:

(define_insn "indirect_jump"
  [(set (pc)
        (match_operand:QI 0 "register_operand" "r"))]
  ""  
  "ijmp (%0)"
  [(set_attr "cc" "none")]
)

However, I didn't find a way to say to gcc that it cannot use the "direct"
jump in some cases, and force it to use the "indirect_jump" instead.

>   I don't think it'll work to have a jump insn that is sometimes direct,
> sometimes indirect.

>   Looking at how the rs6000 backend handles direct and indirect calls and
> jumps might give you some inspiration too.

Well, I already did look at all the backends, but didn't find the answer
(although the answer probably is hidden somewhere inside those files...).

As for the rs6000 backend I see a simple direct call pattern, not sure what
you want me to look at:

in rs6000.md:

(define_insn "jump"
  [(set (pc)
        (label_ref (match_operand 0 "" "")))]
  ""
  "b %l0"
  [(set_attr "type" "branch")])


Thanks,

Stelian.
-- 
Stelian Pop <stel...@popies.net>

Reply via email to