Re[2]: [CRIS] Convert CRIS to constraints.md

2011-11-07 Thread Anatoly Sokolov
Hi.


> From: Hans-Peter.
> Date: 5 Nov 2011 г., 5:24:20:

>> +(define_constraint "S"
>> +  "PIC-constructs for symbols."
>> +  (and (match_test "flag_pic")
>> +   (match_code "const")
>> +   (match_test "cris_valid_pic_const (op, false)")))

> Can you really have other than two operands to the RTL "and"
> these days?  (I guess that's changed to "yes"; if not, the gen*
> programs should have alerted.  Unless there's some bug.)

Yes, it is possible.

de facto - code of satisfies_constraint_S function is math with 
define_constraint "S".

static inline bool
satisfies_constraint_S (rtx op)
{
  return (
#line 155 "../../gcc/gcc/config/cris/constraints.md"
(flag_pic)) && ((GET_CODE (op) == CONST) && (
#line 157 "../../gcc/gcc/config/cris/constraints.md"
(cris_valid_pic_const (op, false;
}

de jure:

16.8.7 Defining Machine-Specific Constraints

define_constraint name docstring exp
... exp is an RTL expression, obeying the same rules as the RTL
expressions in predicate definitions. See Section 16.7.2 [Defining Predicates],
page 302, for details. 

16.7.2 Defining Machine-Specific Predicates

  AND
  IOR
  NOT
  IF_THEN_ELSE
  ... As in Common Lisp, you may give an AND or IOR expression
  an arbitrary number of arguments; this has exactly the same effect as
  writing a chain of two-argument AND or IOR expressions.

Anatoly.



Re: [CRIS] Convert CRIS to constraints.md

2011-11-04 Thread Hans-Peter Nilsson
> From: Anatoly Sokolov 
> Date: Wed, 2 Nov 2011 20:37:12 +0100

>   Comments? OK to install?
> 
> * config/cris/constraints.md: New file.

Whee!

> * config/cris/cris.h (REG_CLASS_FROM_LETTER, CONSTRAINT_LEN,
> CRIS_CONST_OK_FOR_LETTER_P, CONST_OK_FOR_CONSTRAINT_P,
> CONST_DOUBLE_OK_FOR_LETTER_P, EXTRA_MEMORY_CONSTRAINT,
> EXTRA_CONSTRAINT, EXTRA_CONSTRAINT_Q, EXTRA_CONSTRAINT_R,
> EXTRA_CONSTRAINT_T, EXTRA_CONSTRAINT_S, EXTRA_CONSTRAINT_U): Remove.
> * config/cris/cris.c: Incule "tm-constrs.h".
> (cris_print_operand): Use satisfies_constraint_O.
> (cris_normal_notice_update_cc, cris_rtx_costs): Use
> satisfies_constraint_I.
> (cris_address_cost): Use satisfies_constraint_L.
> * config/cris/cris.md: Include "constraints.md".
> (*mov_side, *mov_sidesisf, *mov_side_mem,
> *mov_sidesisf_mem, *clear_side, *ext_sideqihi,
> *ext_sidesi, *op_side, *op_swap_side,
> *extopqihi_side, *extopsi_side, *extopqihi_swap_side,
> *extopsi_swap_side): Use satisfies_constraint_N and
> satisfies_constraint_J.
> (moversideqi movemsideqi mover2side peephole2): Use
> satisfies_constraint_N and satisfies_constraint_J.
> (andu peephole2): Use satisfies_constraint_I and
> satisfies_constraint_O.

Some utter nits:

> +(define_constraint "J"
> +  "ADDQ, SUBQ."
> +  (and (match_code "const_int")
> +   (match_test "IN_RANGE (ival, 0, 63)")))
> +
> +(define_constraint "L"
> +  "A 16-bit signed number."
> +  (and (match_code "const_int")
> +   (match_test "IN_RANGE (ival, -32768, 32767)")))

0. Please move Kc and Kp between J and L.

> +(define_constraint "T"
> +  "Memory three-address operand."
> +;; All are indirect-memory:
> +  (and (match_code "mem")
> +   ;; Double indirect: [[reg]] or [[reg+]]?
> +   (ior (and (match_code "mem" "0")
> +(match_test "cris_base_or_autoincr_p (XEXP (XEXP (op, 0), 0),

1. Match the ";;" with the indentation of context to which the
   comment refers.
   (You have this right in *most* places.)

2. Match indentation for operands.
   (Ditto.)

3. Everywhere in the code you change, use TAB, not eight spaces
   at multiples-of-8 columns: fix modified regions in emacs with
   "M-x tabify".

Like so (except (3) is wrong here because I didn't adjust for
the mail-reply-quote and diff prefixes):

> +(define_constraint "T"
> +  "Memory three-address operand."
> +  ;; All are indirect-memory:
> +  (and (match_code "mem")
> +   ;; Double indirect: [[reg]] or [[reg+]]?
> +   (ior (and (match_code "mem" "0")
> + (match_test "cris_base_or_autoincr_p (XEXP (XEXP (op, 0), 
> 0),

Hmm:

> +(define_constraint "S"
> +  "PIC-constructs for symbols."
> +  (and (match_test "flag_pic")
> +   (match_code "const")
> +   (match_test "cris_valid_pic_const (op, false)")))

Can you really have other than two operands to the RTL "and"
these days?  (I guess that's changed to "yes"; if not, the gen*
programs should have alerted.  Unless there's some bug.)

Ok with these nits fixed and the supposedly quick check with
tm-constrs.h (the latter unless you really know already).

Thanks!

brgds, H-P


Re: [CRIS] Convert CRIS to constraints.md

2011-11-02 Thread Hans-Peter Nilsson
> From: Anatoly Sokolov 
> Date: Wed, 2 Nov 2011 20:37:12 +0100

>   As subject suggests.
> 
>   Regression tested on cris-axis-elf.
> 
>   Comments?

Thanks, I'll review this once the tree returns to single-digit
regression state.

brgds, H-P


[CRIS] Convert CRIS to constraints.md

2011-11-02 Thread Anatoly Sokolov
Hello.

  As subject suggests.

  Regression tested on cris-axis-elf.

  Comments? OK to install?

* config/cris/constraints.md: New file.
* config/cris/cris.h (REG_CLASS_FROM_LETTER, CONSTRAINT_LEN,
CRIS_CONST_OK_FOR_LETTER_P, CONST_OK_FOR_CONSTRAINT_P,
CONST_DOUBLE_OK_FOR_LETTER_P, EXTRA_MEMORY_CONSTRAINT,
EXTRA_CONSTRAINT, EXTRA_CONSTRAINT_Q, EXTRA_CONSTRAINT_R,
EXTRA_CONSTRAINT_T, EXTRA_CONSTRAINT_S, EXTRA_CONSTRAINT_U): Remove.
* config/cris/cris.c: Incule "tm-constrs.h".
(cris_print_operand): Use satisfies_constraint_O.
(cris_normal_notice_update_cc, cris_rtx_costs): Use
satisfies_constraint_I.
(cris_address_cost): Use satisfies_constraint_L.
* config/cris/cris.md: Include "constraints.md".
(*mov_side, *mov_sidesisf, *mov_side_mem,
*mov_sidesisf_mem, *clear_side, *ext_sideqihi,
*ext_sidesi, *op_side, *op_swap_side,
*extopqihi_side, *extopsi_side, *extopqihi_swap_side,
*extopsi_swap_side): Use satisfies_constraint_N and
satisfies_constraint_J.
(moversideqi movemsideqi mover2side peephole2): Use
satisfies_constraint_N and satisfies_constraint_J.
(andu peephole2): Use satisfies_constraint_I and
satisfies_constraint_O.

Index: gcc/config/cris/cris.md
===
--- gcc/config/cris/cris.md (revision 180776)
+++ gcc/config/cris/cris.md (working copy)
@@ -242,6 +242,7 @@ (define_code_attr roCC [(lt "pl") (ge "m
 ;; Operand and operator predicates.
 
 (include "predicates.md")
+(include "constraints.md")
 
 ;; Test insns.
 
@@ -650,8 +651,8 @@ (define_insn "*mov_side"
   && (!CONST_INT_P (operands[2])
  || INTVAL (operands[2]) > 127
  || INTVAL (operands[2]) < -128
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
+ || satisfies_constraint_N (operands[2])
+ || satisfies_constraint_J (operands[2])))
 return "#";
   if (which_alternative == 4)
 return "move [%3=%2%S1],%0";
@@ -677,8 +678,8 @@ (define_insn "*mov_sidesisf"
   && (!CONST_INT_P (operands[2])
  || INTVAL (operands[2]) > 127
  || INTVAL (operands[2]) < -128
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
+ || satisfies_constraint_N (operands[2])
+ || satisfies_constraint_J (operands[2])))
 return "#";
   if (which_alternative < 3)
 return "move.%s0 [%3=%1%S2],%0";
@@ -796,8 +797,8 @@ (define_insn "*mov_side_mem"
   && (!CONST_INT_P (operands[1])
  || INTVAL (operands[1]) > 127
  || INTVAL (operands[1]) < -128
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
+ || satisfies_constraint_N (operands[1])
+ || satisfies_constraint_J (operands[1])))
 return "#";
   if (which_alternative == 1 || which_alternative == 5)
 return "#";
@@ -830,8 +831,8 @@ (define_insn "*mov_sidesisf_mem"
   && (!CONST_INT_P (operands[1])
  || INTVAL (operands[1]) > 127
  || INTVAL (operands[1]) < -128
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
+ || satisfies_constraint_N (operands[1])
+ || satisfies_constraint_J (operands[1])))
 return "#";
   if (which_alternative == 1
   || which_alternative == 7
@@ -903,8 +904,8 @@ (define_insn "*clear_side"
   && (!CONST_INT_P (operands[1])
  || INTVAL (operands[1]) > 127
  || INTVAL (operands[1]) < -128
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
+ || satisfies_constraint_N (operands[1])
+ || satisfies_constraint_J (operands[1])))
 return "#";
   if (which_alternative == 4)
 return "clear [%2=%1%S0]";
@@ -1246,8 +1247,8 @@ (define_insn "*ext_sideqihi"
   && (!CONST_INT_P (operands[2])
  || INTVAL (operands[2]) > 127
  || INTVAL (operands[2]) < -128
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
+ || satisfies_constraint_N (operands[2])
+ || satisfies_constraint_J (operands[2])))
 return "#";
   if (which_alternative == 4)
 return "mov%e4.%m4 [%3=%2%S1],%0";
@@ -1270,8 +1271,8 @@ (define_insn "*ext_sidesi"
   && (!CONST_INT_P (operands[2])
  || INTVAL (operands[2]) > 127
  || INTVAL (operands[2]) < -128
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
- || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
+ || satisfies_constraint_N (operands[2])
+