This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Requesting scratch register
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: "Natasha Wilson" <nat_w at operamail dot com>
- Cc: gcc at gcc dot gnu dot org, Richard dot Earnshaw at arm dot com
- Date: Tue, 15 Jul 2003 11:32:43 +0100
- Subject: Re: Requesting scratch register
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> Hi all,
>
> As written in MD Documentation, the pattern (clobber
> (match_scratch)) would request for a scratch register for use in
> particular insn. Is there any way to know if the scratch register
> is available for use. I would clarify on my point. I'm generating
> an insn
>
> (parallel [(.............) (clobber (match_scratch:SI))])
>
> That would give me a little improvement. But I don't want to
> increase the register pressure. I would like to generate the above
> insn in the situation where I could find a free scratch
> register.
>
Add a peephole2 that uses the scratch and generates the more efficient
sequence. Use a pattern without the scratch prior to register allocation.
Alternatively, you might be able to do this with register constraints; if
an alternative doesn't need a scratch register, just use X in the
constraint for that alternative. Something like
(set (match_operand:SI 0 "register_operand" "r,r")
(OP:SI (match_operand:SI 1 "register_operand" "r,r")
(match_operand:SI 2 "some_constraint" "r,I"))) ; I is some magic
constant
; Scratch only needed if op 2 is a constant
(clobber (match_operand:SI 3 "match_scratch" "X,r"))
R.