This is the mail archive of the gcc@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]

Long and short jumps


Hi,
I have this architecture which has limited range short jumps. Long range
jumps require a register, and the link register is convenient for this.
However, the link register is also available as an allocatable register,
and it'd be nice to allow its use as such.  Also, it is desirable to not
force its saving in small leaf functions.  The solution I was trying
for is to (1) add a clobber of the link register to unconditional jumps
and (2) the non-fallthrough arc of conditional jumps.  Then have a machine
dependent reorg pass that fixes the long conditional jumps to be
short conditional jumps to unconditional long jump stubs.  If possible
I'd like the opportunity before register allocation to remove the link
clobbers, if the function is small enough that a short jump can always
be used.

Unfortunately I discovered that (1) cannot be implemented as
	(define_insn "jump"
	  [(set (pc) (label_ref))
	   (clobber (reg linkregnum))] ...)
because then a jump instruction does not satisfy simplejump_p, and
try_redirect_by_replacing_jump blows up continually replacing non-simple
jumps with non-simple jumps.  I found that
(define_expand "jump"
  [(clobber (reg linkregnum))
   (set (pc) (label_ref))]
doesn't have this immediate problem, but I've not tested that fully.

The only way to describe (2) I could think of would be to generate an
rtl sequence that looked something like,
	(set (pc) (if_then_else (cond) (true_label) (pc)))
        (set (pc) (false_label))
        (barrier)
        (label true_label)
        (clobber (reg linkregnum))
	(set (pc) (target))
	(barrier)
	(label false_label)
but I'm not convinced horribleness will not happen to this.

Am I being too ambitious? Do I have to treat linkreg as a non-register
allocatable register?

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk



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