public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Using SCRATCH Register for a mov op,
       [not found] <20021101010649.GI5029@redhat.com>
@ 2002-11-04  2:03 ` Pierre Mallard
  2002-11-04  4:10   ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Pierre Mallard @ 2002-11-04  2:03 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

Hi and thanks for paying attention to my problem,
I still got a problem around those scratch regs :
Here is how I define a mohi (I 'm gonna define
define_split later):
(define_expand "movhi"
  [(parallel[(set (match_operand:HI 0
"general_operand" "=r,r,m,r,r")
        (match_operand:HI 1 "general_operand"
"r,m,r,I,i"))
   (clobber (match_scratch:QI 2	      ""))])]
  ""
  "{
  rtx temp;
  /* One of the ops has to be in a register */
  if (!register_operand(operand0, HImode)
      && !register_operand(operand1, HImode))
    {
      operands[1] = copy_to_mode_reg(HImode,
operand1);
    }
}")

(define_insn "*movhi"
  [(set	(match_operand:HI 0 "nonimmediate_operand" 
"=r,r,m,r,r")
       	(match_operand:HI 1 "general_operand"       
"r,m,r,I,i"))
   (clobber (match_scratch:QI 2				"=X,&r,X,X,X"))]
  "(register_operand (operands[0],HImode)||
register_operand (operands[1],HImode))"
  "* return output_movhi (insn, operands, NULL);"
  [(set_attr "length" "1,2,2,1,2")
   (set_attr "cc" "none,none,none,none,none")
   (set_attr "type" "none,load,none,none,none")])

But It looks like the reload pass still generate movhi
without using scratch regs : 
../../gcc-3.0.4/gcc/libgcc2.c: In function `__modhi3':
../../gcc-3.0.4/gcc/libgcc2.c:773: Insn does not
satisfy its constraints:
(insn 1064 1061 1055 (parallel[ 
            (set (reg:HI 22 r22)
                (mem:HI (reg:HI 22 r22) 8))
            (clobber (scratch:QI))
        ] ) 1 {*movhi} (nil)
    (nil))
../../gcc-3.0.4/gcc/libgcc2.c:773: Internal compiler
error in reload_cse_simplify_operands, at
reload1.c:8368

--- Richard Henderson <rth@redhat.com> a écrit : > On
Wed, Oct 30, 2002 at 05:45:57PM +0100, Pierre
> Mallard wrote:
> > I'd like to use scratch reg for operation such as 
> > reg X = mem(reg X) generated during the RELOAD
> PASS.
> > with X a number of a hard reg same for both side
> of
> > expression
> 
> You'll have to use a PARALLEL with a (clobber
> (match_scratch)).
> 
> 
> r~ 

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using SCRATCH Register for a mov op,
  2002-11-04  2:03 ` Using SCRATCH Register for a mov op, Pierre Mallard
@ 2002-11-04  4:10   ` Richard Henderson
  2002-11-04  4:30     ` Pierre Mallard
  2002-11-04  7:20     ` David Edelsohn
  0 siblings, 2 replies; 7+ messages in thread
From: Richard Henderson @ 2002-11-04  4:10 UTC (permalink / raw)
  To: Pierre Mallard; +Cc: gcc

On Mon, Nov 04, 2002 at 11:03:12AM +0100, Pierre Mallard wrote:
> (define_insn "*movhi"
>   [(set	(match_operand:HI 0 "nonimmediate_operand" 
> "=r,r,m,r,r")
>        	(match_operand:HI 1 "general_operand"       
> "r,m,r,I,i"))
>    (clobber (match_scratch:QI 2				"=X,&r,X,X,X"))]

Looks ok; no idea what's going wrong off the top of my head.


r~

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using SCRATCH Register for a mov op,
  2002-11-04  4:10   ` Richard Henderson
@ 2002-11-04  4:30     ` Pierre Mallard
  2002-11-04  8:13       ` Peter Barada
  2002-11-04  7:20     ` David Edelsohn
  1 sibling, 1 reply; 7+ messages in thread
From: Pierre Mallard @ 2002-11-04  4:30 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

I'm wondering if it has sthg to do with the Macro
defined in .h ...

#define PREFERRED_RELOAD_CLASS(X,CLASS)	CLASS

#define CLASS_LIKELY_SPILLED_P(c) GENERAL_REGS

#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN)				\
{									\
  (X) = legitimize_address (X, OLDX, MODE);				\
  if (memory_address_p (MODE, X))					\
    goto WIN;								\
}

#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL) \
{}

Is there other macro I got to define to help reload
pass generate a SCRATCH register ?
 --- Richard Henderson <rth@redhat.com> a écrit : > On
Mon, Nov 04, 2002 at 11:03:12AM +0100, Pierre
> Mallard wrote:
> > (define_insn "*movhi"
> >   [(set	(match_operand:HI 0 "nonimmediate_operand"
> 
> > "=r,r,m,r,r")
> >        	(match_operand:HI 1 "general_operand"     
>  
> > "r,m,r,I,i"))
> >    (clobber (match_scratch:QI 2			
> "=X,&r,X,X,X"))]
> 
> Looks ok; no idea what's going wrong off the top of
> my head.
> 
> 
> r~ 

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using SCRATCH Register for a mov op,
  2002-11-04  4:10   ` Richard Henderson
  2002-11-04  4:30     ` Pierre Mallard
@ 2002-11-04  7:20     ` David Edelsohn
  1 sibling, 0 replies; 7+ messages in thread
From: David Edelsohn @ 2002-11-04  7:20 UTC (permalink / raw)
  To: Richard Henderson, Pierre Mallard; +Cc: gcc

(define_expand "movhi"
  [(parallel[(set (match_operand:HI 0 "general_operand" "=r,r,m,r,r")
        (match_operand:HI 1 "general_operand" "r,m,r,I,i"))
   (clobber (match_scratch:QI 2 ""))])]
  ""
  "{
  rtx temp;
  /* One of the ops has to be in a register */
  if (!register_operand(operand0, HImode)
      && !register_operand(operand1, HImode))
    {
      operands[1] = copy_to_mode_reg(HImode, operand1);
    }
}")

	Shouldn't the define_expand use

(clobber (scratch:QI))

not

(clobber (match_scratch:QI 2 ""))

	The define_insn needs to match the scratch, but the define_expand
needs to create the scratch register.

David

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using SCRATCH Register for a mov op,
  2002-11-04  4:30     ` Pierre Mallard
@ 2002-11-04  8:13       ` Peter Barada
  2002-11-04  8:24         ` Peter Barada
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Barada @ 2002-11-04  8:13 UTC (permalink / raw)
  To: pierremallard; +Cc: rth, gcc


You could look at SECONDARY_RELOAD_CLASS and its cousins, the
reload_inXX and reload_outXX patterns(section 17.6 of the manual).
I've used them in gcc-3.0.4 (and working on gcc-3.2) with great effect
to generate a scratch address register to hold the address of an
abolute symbol while trying to load/store a float/double (for the
ColdFire v4e architecture).

I lifted my code form the PA architecture(foind in
gcc/config/gcc/pa/pa.{h,c,md}) which has some severe restructicions on
its instructiions and addressing modes so it ends up(for some
cases)loading the resultant operand address into a register and then
dloing the load/store indirect from that(see emite_move_sequence for
the code).  I'll have to take the same approach for some of the
ColdFire load/store pairs since certain addressing modes are
not allowed in conjunction with other addressing modes.  For example:

	   move d8(Ax,Xi),Dy
	   move Dy,d8(Ax,Xi)

Are both allowed, but:

	   move d8(Ax,Xi),d8(Ay,Xj)

is not allowed.  And since GO_IF_LEGITIMATE_ADDRESS/LEGITIMIZE_ADDRESS
have no knowledge of the instruction its trying to validate/fix, nor
which side of the instruction(src/dst) its on, so in this case I will
have to force *everything* through the reload_in/reload_out patterns
and not use the scratch register that is proffered by the pattern if
it is not needed...

I hope this might shed some light on your problem...

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Using SCRATCH Register for a mov op,
  2002-11-04  8:13       ` Peter Barada
@ 2002-11-04  8:24         ` Peter Barada
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Barada @ 2002-11-04  8:24 UTC (permalink / raw)
  To: Peter.Barada; +Cc: pierremallard, rth, gcc


>dloing the load/store indirect from that(see emite_move_sequence for

That should be:

>doing the load/store indirect from that(see emit_move_sequence for

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Using SCRATCH Register for a mov op,
@ 2002-10-30 13:56 Pierre Mallard
  0 siblings, 0 replies; 7+ messages in thread
From: Pierre Mallard @ 2002-10-30 13:56 UTC (permalink / raw)
  To: gcc; +Cc: gcc-patches

Hi,
I'd like to use scratch reg for operation such as 
reg X = mem(reg X) generated during the RELOAD PASS.
with X a number of a hard reg same for both side of
expression

Unfortunately it appears that a good means to obtain
the SCRATCH register from gcc is to use reload_in.
But this doesn't work in my proc cause I have no
different classes of regs (for me they are all
equivalent), I can't be able to define
SECONDARY_RELOAD_CLASS or things like this cause it
will abort if using same CLASS of regs ().
So I have no idea how to have a SCRATCH reg generated
with the op seen above.

Please Help Me
Regards
Pierre Mallard

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-11-04 16:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20021101010649.GI5029@redhat.com>
2002-11-04  2:03 ` Using SCRATCH Register for a mov op, Pierre Mallard
2002-11-04  4:10   ` Richard Henderson
2002-11-04  4:30     ` Pierre Mallard
2002-11-04  8:13       ` Peter Barada
2002-11-04  8:24         ` Peter Barada
2002-11-04  7:20     ` David Edelsohn
2002-10-30 13:56 Pierre Mallard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).