Re: Committed: fix cris.md strict_low_part constraints (was: Re: A doubt about constraint modifiers)

2008-04-13 Thread Hans-Peter Nilsson
> Date: Sun, 13 Apr 2008 16:18:04 +0530
> From: "Mohamed Shafi" <[EMAIL PROTECTED]>

> I am glad that the mistake has been rectified. But it would be of
> great help requirement of the '+' constraint for strict_low_part is
> mentioned somewhere in the gcc internals. Even though the mailing list
> helped me to solve  the problem , i could have saved some time had it
> been documented.

It's not a requirement of strict_low_part per se, but for it
being an operator that keeps the rest of the register
unmodified, therefore an input to the insn.  As Bernd mentioned,
it was when operand 0 was not *otherwise* marked as an input in
the constraints (by use of effectively "%0"), that it had to be
marked with "+".  There's at least one other RTL operator that
is also keeping the rest of the register unmodified:
zero_extract.  Once you understand that (which you have to),
IMHO the existing:

@table @samp
@cindex @samp{=} in constraint
@item =
Means that this operand is write-only for this instruction: the previous
value is discarded and replaced by output data.

@cindex @samp{+} in constraint
@item +
Means that this operand is both read and written by the instruction

should be sufficient.  Maybe a note at the strict_low_part and
zero_extract documentation would help, but I'm not sure what.
Patches are welcome.

brgds, H-P


Re: Committed: fix cris.md strict_low_part constraints (was: Re: A doubt about constraint modifiers)

2008-04-13 Thread Mohamed Shafi
Hello all,

I am glad that the mistake has been rectified. But it would be of
great help requirement of the '+' constraint for strict_low_part is
mentioned somewhere in the gcc internals. Even though the mailing list
helped me to solve  the problem , i could have saved some time had it
been documented.

Regards,
Shafi

On Sun, Apr 13, 2008 at 6:23 AM, Hans-Peter Nilsson
<[EMAIL PROTECTED]> wrote:
> > Date: Fri, 11 Apr 2008 15:32:02 +0200
>  > From: Bernd Schmidt <[EMAIL PROTECTED]>
>
>  > Mohamed Shafi wrote:
>  > > In cris i saw this patten
>  > >
>  > > (define_insn "*andhi_lowpart"
>  > >   [(set (strict_low_part
>  > >  (match_operand:HI 0 "register_operand""=r,r, r,r,r,r"))
>  > > (and:HI (match_operand:HI 1 "register_operand" "%0,0, 0,0,0,r")
>  > > (match_operand:HI 2 "general_operand"   "r,Q>,L,O,g,!To")))]
>  > >
>  > > Here = is used.
>  >
>  > This is incorrect since when the last alternative matches, nothing tells
>  > the compiler that operand 0 is also an input.
>
>  Oops, thanks for noticing.  For consistency, I made all
>  strict_low_part constraints use "+", including those where all
>  alternatives had %0.  Regtested cross to cris-elf and
>  crisv32-elf.
>
>  PS. I'm not a native speaker, but FWIW I agree with Joe Buck
>  regarding usage of the word "doubt", but I see it's quite common
>  with some non-native speakers, indicating the fault is at the
>  teaching level.
>
>  gcc:
> * config/cris/cris.md ("*andhi_lowpart_non_v32", "*andhi_lowpart_v32")
> ("*andqi_lowpart_non_v32", "*andqi_lowpart_v32"): Use "+" for the
> operand 0 constraint, not "=".
>
>  Index: config/cris/cris.md
>  ===
>  --- config/cris/cris.md (revision 134224)
>  +++ config/cris/cris.md (working copy)
>  @@ -2958,7 +2958,7 @@ (define_insn "*expanded_andhi_v32"
>
>   (define_insn "*andhi_lowpart_non_v32"
>[(set (strict_low_part
>  -(match_operand:HI 0 "register_operand""=r,r, r,r,r,r"))
>  +(match_operand:HI 0 "register_operand""+r,r, r,r,r,r"))
> (and:HI (match_operand:HI 1 "register_operand" "%0,0, 0,0,0,r")
> (match_operand:HI 2 "general_operand"   "r,Q>,L,O,g,!To")))]
>"!TARGET_V32"
>  @@ -2974,7 +2974,7 @@ (define_insn "*andhi_lowpart_non_v32"
>
>   (define_insn "*andhi_lowpart_v32"
>[(set (strict_low_part
>  -(match_operand:HI 0 "register_operand" "=r,r,r,r,r"))
>  +(match_operand:HI 0 "register_operand" "+r,r,r,r,r"))
> (and:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
> (match_operand:HI 2 "general_operand" "r,Q>,L,O,g")))]
>"TARGET_V32"
>  @@ -3025,7 +3025,7 @@ (define_insn "*andqi3_v32"
>
>   (define_insn "*andqi_lowpart_non_v32"
>[(set (strict_low_part
>  -(match_operand:QI 0 "register_operand""=r,r, r,r,r"))
>  +(match_operand:QI 0 "register_operand""+r,r, r,r,r"))
> (and:QI (match_operand:QI 1 "register_operand" "%0,0, 0,0,r")
> (match_operand:QI 2 "general_operand"   "r,Q>,O,g,!To")))]
>"!TARGET_V32"
>  @@ -3040,7 +3040,7 @@ (define_insn "*andqi_lowpart_non_v32"
>
>   (define_insn "*andqi_lowpart_v32"
>[(set (strict_low_part
>  -(match_operand:QI 0 "register_operand" "=r,r,r,r"))
>  +(match_operand:QI 0 "register_operand" "+r,r,r,r"))
> (and:QI (match_operand:QI 1 "register_operand" "%0,0,0,0")
> (match_operand:QI 2 "general_operand" "r,Q>,O,g")))]
>"TARGET_V32"
>
>  brgds, H-P
>


Committed: fix cris.md strict_low_part constraints (was: Re: A doubt about constraint modifiers)

2008-04-12 Thread Hans-Peter Nilsson
> Date: Fri, 11 Apr 2008 15:32:02 +0200
> From: Bernd Schmidt <[EMAIL PROTECTED]>

> Mohamed Shafi wrote:
> > In cris i saw this patten
> > 
> > (define_insn "*andhi_lowpart"
> >   [(set (strict_low_part
> >  (match_operand:HI 0 "register_operand""=r,r, r,r,r,r"))
> > (and:HI (match_operand:HI 1 "register_operand" "%0,0, 0,0,0,r")
> > (match_operand:HI 2 "general_operand"   "r,Q>,L,O,g,!To")))]
> > 
> > Here = is used.
> 
> This is incorrect since when the last alternative matches, nothing tells 
> the compiler that operand 0 is also an input.

Oops, thanks for noticing.  For consistency, I made all
strict_low_part constraints use "+", including those where all
alternatives had %0.  Regtested cross to cris-elf and
crisv32-elf.

PS. I'm not a native speaker, but FWIW I agree with Joe Buck
regarding usage of the word "doubt", but I see it's quite common
with some non-native speakers, indicating the fault is at the
teaching level.

gcc:
* config/cris/cris.md ("*andhi_lowpart_non_v32", "*andhi_lowpart_v32")
("*andqi_lowpart_non_v32", "*andqi_lowpart_v32"): Use "+" for the
operand 0 constraint, not "=".

Index: config/cris/cris.md
===
--- config/cris/cris.md (revision 134224)
+++ config/cris/cris.md (working copy)
@@ -2958,7 +2958,7 @@ (define_insn "*expanded_andhi_v32"
 
 (define_insn "*andhi_lowpart_non_v32"
   [(set (strict_low_part
-(match_operand:HI 0 "register_operand""=r,r, r,r,r,r"))
+(match_operand:HI 0 "register_operand""+r,r, r,r,r,r"))
(and:HI (match_operand:HI 1 "register_operand" "%0,0, 0,0,0,r")
(match_operand:HI 2 "general_operand"   "r,Q>,L,O,g,!To")))]
   "!TARGET_V32"
@@ -2974,7 +2974,7 @@ (define_insn "*andhi_lowpart_non_v32"
 
 (define_insn "*andhi_lowpart_v32"
   [(set (strict_low_part
-(match_operand:HI 0 "register_operand" "=r,r,r,r,r"))
+(match_operand:HI 0 "register_operand" "+r,r,r,r,r"))
(and:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
(match_operand:HI 2 "general_operand" "r,Q>,L,O,g")))]
   "TARGET_V32"
@@ -3025,7 +3025,7 @@ (define_insn "*andqi3_v32"
 
 (define_insn "*andqi_lowpart_non_v32"
   [(set (strict_low_part
-(match_operand:QI 0 "register_operand""=r,r, r,r,r"))
+(match_operand:QI 0 "register_operand""+r,r, r,r,r"))
(and:QI (match_operand:QI 1 "register_operand" "%0,0, 0,0,r")
(match_operand:QI 2 "general_operand"   "r,Q>,O,g,!To")))]
   "!TARGET_V32"
@@ -3040,7 +3040,7 @@ (define_insn "*andqi_lowpart_non_v32"
 
 (define_insn "*andqi_lowpart_v32"
   [(set (strict_low_part
-(match_operand:QI 0 "register_operand" "=r,r,r,r"))
+(match_operand:QI 0 "register_operand" "+r,r,r,r"))
(and:QI (match_operand:QI 1 "register_operand" "%0,0,0,0")
(match_operand:QI 2 "general_operand" "r,Q>,O,g")))]
   "TARGET_V32"

brgds, H-P


Re: A doubt about constraint modifiers

2008-04-11 Thread Joe Buck
On Fri, Apr 11, 2008 at 11:28:04AM +0530, Mohamed Shafi wrote:
> [ another "doubt" ]

You seem to be using the word "doubt" a lot whenever you don't completely
understand something, but this is not what the word means.

It means "to consider questionable or unlikely; to hesitate to believe; to
distrust", as in "I doubt that she is telling the truth".  So it makes it
sound, not like you don't understand something, but that you think it is
bad or wrong (not trustworthy).  I know that this isn't your intention.


Re: A doubt about constraint modifiers

2008-04-11 Thread Bernd Schmidt

Mohamed Shafi wrote:

In cris i saw this patten

(define_insn "*andhi_lowpart"
  [(set (strict_low_part
 (match_operand:HI 0 "register_operand"  "=r,r, r,r,r,r"))
(and:HI (match_operand:HI 1 "register_operand" "%0,0, 0,0,0,r")
(match_operand:HI 2 "general_operand"   "r,Q>,L,O,g,!To")))]

Here = is used.


This is incorrect since when the last alternative matches, nothing tells 
the compiler that operand 0 is also an input.



Bernd
--
This footer brought to you by insane German lawmakers.
Analog Devices GmbH  Wilhelm-Wagenfeld-Str. 6  80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif


Re: A doubt about constraint modifiers

2008-04-11 Thread Mohamed Shafi
On Fri, Apr 11, 2008 at 12:41 PM, Ian Lance Taylor <[EMAIL PROTECTED]> wrote:
> "Mohamed Shafi" <[EMAIL PROTECTED]> writes:
>
>  > I have noticed that when strict_low_part is used in a patten we need
>  > to use '+' as the constraint modifier if any constraints are used in
>  > the patterns.
>  > Why is this so?
>
>  Using strict_low_part implies that the register or memory location is
>  neither a pure input nor a pure output.  It is both an input and an
>  output.  Therefore a '+' constraint is appropriate.

Thanks for the reply.

In cris i saw this patten

(define_insn "*andhi_lowpart"
  [(set (strict_low_part
 (match_operand:HI 0 "register_operand""=r,r, r,r,r,r"))
(and:HI (match_operand:HI 1 "register_operand" "%0,0, 0,0,0,r")
(match_operand:HI 2 "general_operand"   "r,Q>,L,O,g,!To")))]

Here = is used.
So when you say appropriate you mean to say that its not mandatory to
use '+' but '=' also suffices?

Regards,
Shafi


Re: A doubt about constraint modifiers

2008-04-11 Thread Ian Lance Taylor
"Mohamed Shafi" <[EMAIL PROTECTED]> writes:

> I have noticed that when strict_low_part is used in a patten we need
> to use '+' as the constraint modifier if any constraints are used in
> the patterns.
> Why is this so?

Using strict_low_part implies that the register or memory location is
neither a pure input nor a pure output.  It is both an input and an
output.  Therefore a '+' constraint is appropriate.

Ian


A doubt about constraint modifiers

2008-04-10 Thread Mohamed Shafi
Hello all,

I have noticed that when strict_low_part is used in a patten we need
to use '+' as the constraint modifier if any constraints are used in
the patterns.
Why is this so?

Regards,
Shafi