public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Understanding Predicate and Constrains
@ 2008-04-07 22:00 Omar
  2008-04-08 17:53 ` Jim Wilson
  0 siblings, 1 reply; 5+ messages in thread
From: Omar @ 2008-04-07 22:00 UTC (permalink / raw)
  To: gcc-help

Hi,
 I am trying to understand predicate and constraints. To this end, I
created a simple define_insn :
(define_insn "movqi"
  [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,>,<,r")
	 (match_operand:QI 1 "general_operand" 	          "r,m,r,>,<,r,r,i"))]
  ""
  "@
   move.b %0,%1; <movqi reg := reg>
   move.b %0,%1; <movqi reg := mem>
   move.b %0,%1; <movqi mem := reg>
   move.b %0,%1; <movqi reg := mem with autoincrement>
   move.b %0,%1; <movqi reg := mem with autodecrement>
   move.b %0,%1; <movqi mem with autoincrement := reg>
   move.b %0,%1; <movqi mem with autodecrement := reg>
   move.b %0,%1; <movqi reg := const>")

My questions are:
1) How '>' really work, am i using it correctly or do I need to use it
with another another constraint (like 'm>')?
   1.1) Which file should I load while debugging to understand how
constrains are being use?
2) How I limit the 'i' constraint so that only constants below or
equal to 255 are allowed?

Thanks in advance for your help!
Regards, -Omar

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

* Re: Understanding Predicate and Constrains
  2008-04-07 22:00 Understanding Predicate and Constrains Omar
@ 2008-04-08 17:53 ` Jim Wilson
       [not found]   ` <178adb870804081024n6c055d2boab4bed7750f5b16d@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Wilson @ 2008-04-08 17:53 UTC (permalink / raw)
  To: Omar; +Cc: gcc-help

Omar wrote:
> 1) How '>' really work, am i using it correctly or do I need to use it
> with another another constraint (like 'm>')?

It is usually used in the same alternative as another constraint such as 
'm' or 'o', but I'm not sure if that is required.  Most gcc internals 
stuff like this is not well documented.  You just try it, and if it 
works fine, if it doesn't, then change it.

>    1.1) Which file should I load while debugging to understand how
> constrains are being use?

Constraints are only used by the register allocation passes, primarily 
regclass and reload.

> 2) How I limit the 'i' constraint so that only constants below or
> equal to 255 are allowed?

Depends on the gcc version.  It current sources, you want to define a 
$target/constraints.md file that has a (define_contraint "I" ...) 
pattern.  See any target for an example.

You can't redefine what 'i' means.  That is reserved.  See the 
"Constraints" section of the gcc internals manual.

Jim

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

* Re: Understanding Predicate and Constrains
       [not found]   ` <178adb870804081024n6c055d2boab4bed7750f5b16d@mail.gmail.com>
@ 2008-04-08 19:52     ` Omar
  2008-04-08 22:15       ` Omar
  2008-04-11 19:13       ` Jim Wilson
  0 siblings, 2 replies; 5+ messages in thread
From: Omar @ 2008-04-08 19:52 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gcc-help

Jim,
   First, thanks a lot for your comments.

> It current sources, you want to define a
> $target/constraints.md file that has a (define_contraint "I" ...) pattern.
I have been looking at other targets, and they seem to use the
CONST_OK_FOR_LETTER_P macro for this purpose.
Is the define_constraint equivalent to what the macro CONST_OK_FOR
_LETTER_P used to stand for?
I am trying to understand is define_constraint replaces this macro's
functionality.

Your comment confirms my suspicion:
> Most gcc internals stuff like this is not well documented.
> You just try it, and if it works fine, if
> it doesn't, then change it.

-Omar

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

* Re: Understanding Predicate and Constrains
  2008-04-08 19:52     ` Omar
@ 2008-04-08 22:15       ` Omar
  2008-04-11 19:13       ` Jim Wilson
  1 sibling, 0 replies; 5+ messages in thread
From: Omar @ 2008-04-08 22:15 UTC (permalink / raw)
  To: Jim Wilson; +Cc: gcc-help

Jim,
 After further reading, the Internals document answered my question.
 I realized that CONST_OK_FOR_LETTER_P is under the "Obsolete Macros
for Defining Constraints" section, which states:
 "Machine-specific constraints can be defined with these macros
instead of the machine description
constructs described in Section 14.8.6 [Define Constraints], page 274.
This mechanism is obsolete. New ports should not use it..."

So, to answer myself: Yes, define_constraint definitions are used
instead of the CONST_OK_FOR_LETTER_P macro.

Thanks for your patience!
-Omar

On Tue, Apr 8, 2008 at 1:33 PM, Omar <gcc.omar@gmail.com> wrote:
>
> Jim,
>    First, thanks a lot for your comments.
>
>  > It current sources, you want to define a
>  > $target/constraints.md file that has a (define_contraint "I" ...) pattern.
>  I have been looking at other targets, and they seem to use the
>  CONST_OK_FOR_LETTER_P macro for this purpose.
>  Is the define_constraint equivalent to what the macro CONST_OK_FOR
>  _LETTER_P used to stand for?
>  I am trying to understand is define_constraint replaces this macro's
>  functionality.
>
>  Your comment confirms my suspicion:
>  > Most gcc internals stuff like this is not well documented.
>  > You just try it, and if it works fine, if
>  > it doesn't, then change it.
>
>  -Omar
>

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

* Re: Understanding Predicate and Constrains
  2008-04-08 19:52     ` Omar
  2008-04-08 22:15       ` Omar
@ 2008-04-11 19:13       ` Jim Wilson
  1 sibling, 0 replies; 5+ messages in thread
From: Jim Wilson @ 2008-04-11 19:13 UTC (permalink / raw)
  To: Omar; +Cc: gcc-help

On Tue, 2008-04-08 at 13:33 -0500, Omar wrote:
> I have been looking at other targets, and they seem to use the
> CONST_OK_FOR_LETTER_P macro for this purpose.

Current ports in current sources use the constraints.md file.  Old ports
and/or old sources use CONST_OK_FOR_LETTER_P.  Long term, everything
will be moved to the constraints.md file, but the change is not complete
yet.

Jim

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

end of thread, other threads:[~2008-04-11 15:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-07 22:00 Understanding Predicate and Constrains Omar
2008-04-08 17:53 ` Jim Wilson
     [not found]   ` <178adb870804081024n6c055d2boab4bed7750f5b16d@mail.gmail.com>
2008-04-08 19:52     ` Omar
2008-04-08 22:15       ` Omar
2008-04-11 19:13       ` Jim Wilson

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).