Patchwork [CRIS] Convert CRIS to constraints.md

login
register
mail settings
Submitter Anatoly Sokolov
Date Nov. 2, 2011, 7:37 p.m.
Message ID <481938203.20111102233712@post.ru>
Download mbox | patch
Permalink /patch/123322/
State New
Headers show

Comments

Anatoly Sokolov - Nov. 2, 2011, 7:37 p.m.
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<mode>, *mov_sidesisf, *mov_side<mode>_mem,
        *mov_sidesisf_mem, *clear_side<mode>, *ext_sideqihi,
        *ext_side<mode>si, *op_side<mode>, *op_swap_side<mode>,
        *extopqihi_side, *extop<mode>si_side, *extopqihi_swap_side,
        *extop<mode>si_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.



Anatoly.
Anatoly Sokolov - Nov. 7, 2011, 9:20 p.m.
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.

Patch

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<mode>"
       && (!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<m> [%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<mode>_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<mode>"
       && (!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<m> [%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_side<mode>si"
       && (!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<m> [%3=%2%S1],%0";
@@ -1607,8 +1608,8 @@  (define_insn "*op_side<mode>"
       && (!CONST_INT_P (operands[3])
          || INTVAL (operands[3]) > 127
          || INTVAL (operands[3]) < -128
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
+         || satisfies_constraint_N (operands[3])
+         || satisfies_constraint_J (operands[3])))
     return "#";
   if (which_alternative == 4)
     return "%x5.%s0 [%4=%3%S2],%0";
@@ -1665,8 +1666,8 @@  (define_insn "*op_swap_side<mode>"
       && (!CONST_INT_P (operands[3])
          || INTVAL (operands[3]) > 127
          || INTVAL (operands[3]) < -128
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
+         || satisfies_constraint_N (operands[3])
+         || satisfies_constraint_J (operands[3])))
     return "#";
   if (which_alternative == 4)
     return "%x5<m> [%4=%3%S2],%0";
@@ -2097,8 +2098,8 @@  (define_insn "*extopqihi_side"
       && (!CONST_INT_P (operands[3])
          || INTVAL (operands[3]) > 127
          || INTVAL (operands[3]) < -128
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
+         || satisfies_constraint_N (operands[3])
+         || satisfies_constraint_J (operands[3])))
     return "#";
   if (which_alternative == 4)
     return "%x5%E6.%m6 [%4=%3%S2],%0";
@@ -2126,8 +2127,8 @@  (define_insn "*extop<mode>si_side"
       && (!CONST_INT_P (operands[3])
          || INTVAL (operands[3]) > 127
          || INTVAL (operands[3]) < -128
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
+         || satisfies_constraint_N (operands[3])
+         || satisfies_constraint_J (operands[3])))
     return "#";
   if (which_alternative == 4)
     return "%x5%E6<m> [%4=%3%S2],%0";
@@ -2206,8 +2207,8 @@  (define_insn "*extopqihi_swap_side"
       && (!CONST_INT_P (operands[3])
          || INTVAL (operands[3]) > 127
          || INTVAL (operands[3]) < -128
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
+         || satisfies_constraint_N (operands[3])
+         || satisfies_constraint_J (operands[3])))
     return "#";
   if (which_alternative == 4)
     return "add%e5.b [%4=%3%S2],%0";
@@ -2234,8 +2235,8 @@  (define_insn "*extop<mode>si_swap_side"
       && (!CONST_INT_P (operands[3])
          || INTVAL (operands[3]) > 127
          || INTVAL (operands[3]) < -128
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
-         || CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
+         || satisfies_constraint_N (operands[3])
+         || satisfies_constraint_J (operands[3])))
     return "#";
   if (which_alternative == 4)
     return \"%x6%E5.%m5 [%4=%3%S2],%0\";
@@ -4681,8 +4682,8 @@  (define_peephole2 ; moversideqi (peephol
   "GET_MODE_SIZE (GET_MODE (operands[4])) <= UNITS_PER_WORD
    && REGNO (operands[3]) != REGNO (operands[0])
    && (cris_base_p (operands[1], true) || cris_base_p (operands[2], true))
-   && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
-   && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
+   && !satisfies_constraint_J (operands[2])
+   && !satisfies_constraint_N (operands[2])
    && (INTVAL (operands[2]) >= -128 && INTVAL (operands[2]) < 128)
    && TARGET_SIDE_EFFECT_PREFIXES"
   [(parallel
@@ -4717,8 +4718,8 @@  (define_peephole2 ; movemsideqi (peephol
   "GET_MODE_SIZE (GET_MODE (operands[4])) <= UNITS_PER_WORD
    && REGNO (operands[4]) != REGNO (operands[0])
    && (cris_base_p (operands[1], true) || cris_base_p (operands[2], true))
-   && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
-   && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
+   && !satisfies_constraint_J (operands[2])
+   && !satisfies_constraint_N (operands[2])
    && (INTVAL (operands[2]) >= -128 && INTVAL (operands[2]) < 128)
    && TARGET_SIDE_EFFECT_PREFIXES"
   [(parallel
@@ -4755,8 +4756,8 @@  (define_peephole2 ; mover2side (peephole
   ;; Change to GET_MODE_SIZE (GET_MODE (operands[3])) <= UNITS_PER_WORD?
   "GET_MODE (operands[3]) != DImode
    && REGNO (operands[0]) != REGNO (operands[3])
-   && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
-   && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
+   && !satisfies_constraint_J (operands[2])
+   && !satisfies_constraint_N (operands[2])
    && INTVAL (operands[2]) >= -128
    && INTVAL (operands[2]) <= 127
    && TARGET_SIDE_EFFECT_PREFIXES"
@@ -4947,7 +4948,7 @@  (define_peephole2 ; andu (casesi+45)
    ;; don't do this for a mem-volatile access.
   "REGNO (operands[2]) == REGNO (operands[0])
    && INTVAL (operands[3]) <= 65535 && INTVAL (operands[3]) >= 0
-   && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'I')
+   && !satisfies_constraint_I (operands[3])
    && !side_effects_p (operands[1])
    && (!REG_P (operands[1])
        || REGNO (operands[1]) <= CRIS_LAST_GENERAL_REGISTER)"
@@ -4957,7 +4958,7 @@  (define_peephole2 ; andu (casesi+45)
 {
   enum machine_mode zmode = INTVAL (operands[3]) <= 255 ? QImode : HImode;
   enum machine_mode amode
-    = CRIS_CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'O') ? SImode : zmode;
+    = satisfies_constraint_O (operands[3]) ? SImode : zmode;
   rtx op1
     = (REG_S_P (operands[1])
        ? gen_rtx_REG (zmode, REGNO (operands[1]))
Index: gcc/config/cris/cris.c
===================================================================
--- gcc/config/cris/cris.c      (revision 180776)
+++ gcc/config/cris/cris.c      (working copy)
@@ -40,6 +40,7 @@  along with GCC; see the file COPYING3.  
 #include "tm_p.h"
 #include "debug.h"
 #include "output.h"
+#include "tm-constrs.h"
 #include "target.h"
 #include "target-def.h"
 #include "ggc.h"
@@ -703,8 +704,7 @@  cris_print_operand (FILE *file, rtx x, i
     case 'b':
       /* Print the unsigned supplied integer as if it were signed
         and < 0, i.e print 255 or 65535 as -1, 254, 65534 as -2, etc.  */
-      if (!CONST_INT_P (x)
-         || !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (x), 'O'))
+      if (!satisfies_constraint_O (x))
        LOSE_AND_RETURN ("invalid operand for 'b' modifier", x);
       fprintf (file, HOST_WIDE_INT_PRINT_DEC,
               INTVAL (x)| (INTVAL (x) <= 255 ? ~255 : ~65535));
@@ -1692,9 +1692,7 @@  cris_normal_notice_update_cc (rtx exp, r
                       && (REGNO (SET_SRC (exp))
                           > CRIS_LAST_GENERAL_REGISTER))
                   || (TARGET_V32
-                      && GET_CODE (SET_SRC (exp)) == CONST_INT
-                      && CRIS_CONST_OK_FOR_LETTER_P (INTVAL (SET_SRC (exp)),
-                                                     'I')))
+                      && satisfies_constraint_I (SET_SRC (exp))))
            {
              /* There's no CC0 change for this case.  Just check
                 for overlap.  */
@@ -2037,7 +2035,7 @@  cris_rtx_costs (rtx x, int code, int out
       if (CONST_INT_P (XEXP (x, 1))
           /* Two constants may actually happen before optimization.  */
           && !CONST_INT_P (XEXP (x, 0))
-          && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (XEXP (x, 1)), 'I'))
+          && !satisfies_constraint_I (XEXP (x, 1)))
        {
          *total
            = (rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code,
@@ -2118,8 +2116,7 @@  cris_address_cost (rtx x, bool speed ATT
 
       /* A BDAP -32768 .. 32767 is like BDAP quick, but with 2 extra
         bytes.  */
-      if (CONST_INT_P (tem2)
-         && CRIS_CONST_OK_FOR_LETTER_P (INTVAL (tem2), 'L'))
+      if (satisfies_constraint_L (tem2))
        return (2 + 2) / 2;
 
       /* A BDAP with some other constant is 2 bytes extra.  */
Index: gcc/config/cris/cris.h
===================================================================
--- gcc/config/cris/cris.h      (revision 180776)
+++ gcc/config/cris/cris.h      (working copy)
@@ -550,16 +550,6 @@  enum reg_class
 
 #define INDEX_REG_CLASS GENERAL_REGS
 
-#define REG_CLASS_FROM_LETTER(C)               \
-  (                                            \
-   (C) == 'a' ? ACR_REGS :                     \
-   (C) == 'b' ? GENNONACR_REGS :               \
-   (C) == 'h' ? MOF_REGS :                     \
-   (C) == 'x' ? SPECIAL_REGS :                 \
-   (C) == 'c' ? CC0_REGS :                     \
-   NO_REGS                                     \
-  )
-
 /* Since it uses reg_renumber, it is safe only once reg_renumber
    has been allocated, which happens in local-alloc.c.  */
 #define REGNO_OK_FOR_BASE_P(REGNO)                                     \
@@ -609,127 +599,6 @@  enum reg_class
   ? 1 /* + cris_fatal ("CLASS_MAX_NREGS with VOIDmode")        */              \
   : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
 
-/* We are now out of letters; we could use ten more.  This forces us to
-   use C-code in the 'md' file.  FIXME: Use some EXTRA_CONSTRAINTS.  */
-#define CRIS_CONST_OK_FOR_LETTER_P(VALUE, C)           \
- (                                                     \
-  /* MOVEQ, CMPQ, ANDQ, ORQ.  */                       \
-  (C) == 'I' ? (VALUE) >= -32 && (VALUE) <= 31 :       \
-  /* ADDQ, SUBQ.  */                                   \
-  (C) == 'J' ? (VALUE) >= 0 && (VALUE) <= 63 :         \
-  /* ASRQ, BTSTQ, LSRQ, LSLQ.  */                      \
-  (C) == 'K' ? (VALUE) >= 0 && (VALUE) <= 31 :         \
-  /* A 16-bit signed number.  */                       \
-  (C) == 'L' ? (VALUE) >= -32768 && (VALUE) <= 32767 :	\
-  /* The constant 0 for CLEAR.  */                     \
-  (C) == 'M' ? (VALUE) == 0 :                          \
-  /* A negative ADDQ or SUBQ.  */                      \
-  (C) == 'N' ? (VALUE) >= -63 && (VALUE) < 0 :         \
-  /* Quickened ints, QI and HI.  */                    \
-  (C) == 'O' ? (VALUE) >= 0 && (VALUE) <= 65535                \
-               && ((VALUE) >= (65535-31)               \
-                   || ((VALUE) >= (255-31)             \
-                       && (VALUE) <= 255 )) :          \
-  /* A 16-bit number signed *or* unsigned.  */         \
-  (C) == 'P' ? (VALUE) >= -32768 && (VALUE) <= 65535 :	\
-  0)
-
-#define CONST_OK_FOR_CONSTRAINT_P(VALUE, C, S)	\
- (                                             \
-  ((C) != 'K' || (S)[1] == 'c')                        \
-   ? CRIS_CONST_OK_FOR_LETTER_P (VALUE, C) :   \
-  ((C) == 'K' && (S)[1] == 'p')                        \
-   ? exact_log2 (VALUE) >= 0 :                 \
-  0)
-
-#define CONSTRAINT_LEN(C, S) ((C) == 'K' ? 2 : DEFAULT_CONSTRAINT_LEN (C, S))
-
-/* It is really simple to make up a 0.0; it is the same as int-0 in
-   IEEE754.  */
-#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C)                 \
- ((C) == 'G' && ((VALUE) == CONST0_RTX (DFmode)                        \
-                || (VALUE) == CONST0_RTX (SFmode)))
-
-/* We need this on cris to distinguish delay-slottable addressing modes.  */
-#define EXTRA_CONSTRAINT(X, C)                 \
- (                                             \
-  /* Slottable address mode?  */               \
-  (C) == 'Q' ? EXTRA_CONSTRAINT_Q (X) :                \
-  /* Operand to BDAP or BIAP?  */              \
-  (C) == 'R' ? EXTRA_CONSTRAINT_R (X) :                \
-  /* A local PIC symbol?  */                   \
-  (C) == 'S' ? EXTRA_CONSTRAINT_S (X) :                \
-  /* A three-address addressing-mode?  */      \
-  (C) == 'T' ? EXTRA_CONSTRAINT_T (X) :                \
-  /* A PLT symbol?  */                         \
-  (C) == 'U' ? EXTRA_CONSTRAINT_U (X) :                \
-  0)
-
-#define EXTRA_MEMORY_CONSTRAINT(X, STR) ((X) == 'Q')
-
-#define EXTRA_CONSTRAINT_Q(X)                          \
- (                                                     \
-  /* Just an indirect register (happens to also be     \
-     "all" slottable memory addressing modes not       \
-     covered by other constraints, i.e. '>').  */      \
-  MEM_P (X)                                            \
-  && cris_base_p (XEXP (X, 0), reload_in_progress || reload_completed) \
- )
-
-#define EXTRA_CONSTRAINT_R(X)                                  \
- (                                                             \
-  /* An operand to BDAP or BIAP:                               \
-     A BIAP; r.S? */                                           \
-  cris_biap_index_p (X, reload_in_progress || reload_completed)  \
-  /* A [reg] or (int) [reg], maybe with post-increment.  */    \
-  || cris_bdap_index_p (X, reload_in_progress || reload_completed) \
-  || cris_constant_index_p (X)                                 \
- )
-
-#define EXTRA_CONSTRAINT_T(X)                                          \
- (                                                                     \
-  /* Memory three-address operand.  All are indirect-memory:  */       \
-  MEM_P (X)                                                            \
-  && ((MEM_P (XEXP (X, 0))                                             \
-       /* Double indirect: [[reg]] or [[reg+]]?  */                    \
-       && (cris_base_or_autoincr_p (XEXP (XEXP (X, 0), 0),             \
-                             reload_in_progress || reload_completed))) \
-      /* Just an explicit indirect reference: [const]?  */             \
-      || CONSTANT_P (XEXP (X, 0))                                      \
-      /* Something that is indexed; [...+...]?  */                     \
-      || (GET_CODE (XEXP (X, 0)) == PLUS                               \
-         /* A BDAP constant: [reg+(8|16|32)bit offset]?  */            \
-         && ((cris_base_p (XEXP (XEXP (X, 0), 0),                      \
-                              reload_in_progress || reload_completed)  \
-              && cris_constant_index_p (XEXP (XEXP (X, 0), 1)))        \
-             /* A BDAP register: [reg+[reg(+)].S]?  */                 \
-             || (cris_base_p (XEXP (XEXP (X, 0), 0),                   \
-                              reload_in_progress || reload_completed)  \
-                 && cris_bdap_index_p (XEXP(XEXP(X, 0), 1),            \
-                              reload_in_progress || reload_completed)) \
-             /* Same, but with swapped arguments (no canonical         \
-                ordering between e.g. REG and MEM as of LAST_UPDATED   \
-                "Thu May 12 03:59:11 UTC 2005").  */                   \
-             || (cris_base_p (XEXP (XEXP (X, 0), 1),                   \
-               reload_in_progress | reload_completed)                  \
-                 && cris_bdap_index_p (XEXP (XEXP (X, 0), 0),          \
-                              reload_in_progress || reload_completed)) \
-             /* A BIAP: [reg+reg.S] (MULT comes first).  */            \
-             || (cris_base_p (XEXP (XEXP (X, 0), 1),                   \
-                               reload_in_progress || reload_completed) \
-                 && cris_biap_index_p (XEXP (XEXP (X, 0), 0),          \
-                           reload_in_progress || reload_completed))))) \
- )
-
-/* PIC-constructs for symbols.  */
-#define EXTRA_CONSTRAINT_S(X)                                          \
- (flag_pic && GET_CODE (X) == CONST && cris_valid_pic_const (X, false))
-
-#define EXTRA_CONSTRAINT_U(X)                                          \
- (flag_pic                                                             \
-  && CONSTANT_P (X)                                                    \
-  && cris_nonmemory_operand_or_callable_symbol (X, VOIDmode))
-
 
 /* Node: Frame Layout */
 
Index: gcc/config/cris/constraints.md
===================================================================
--- gcc/config/cris/constraints.md      (revision 0)
+++ gcc/config/cris/constraints.md      (revision 0)
@@ -0,0 +1,164 @@ 
+;; Constraint definitions for CRIS.
+;; Copyright (C) 2011 Free Software Foundation, Inc.
+;;
+;; This file is part of GCC.
+;;
+;; GCC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; GCC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; <http://www.gnu.org/licenses/>.
+
+;; Register constraints.
+(define_register_constraint "a" "ACR_REGS"
+  "@internal")
+
+(define_register_constraint "b" "GENNONACR_REGS"
+  "@internal")
+
+(define_register_constraint "h" "MOF_REGS"
+  "@internal")
+
+(define_register_constraint "x" "SPECIAL_REGS"
+  "@internal")
+
+(define_register_constraint "c" "CC0_REGS"
+  "@internal")
+
+;; Integer constraints.
+(define_constraint "I"
+  "MOVEQ, CMPQ, ANDQ, ORQ."
+  (and (match_code "const_int")
+       (match_test "IN_RANGE (ival, -32, 31)")))
+
+(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)")))
+
+(define_constraint "M"
+  "The constant 0 for CLEAR."
+  (and (match_code "const_int")
+       (match_test "ival == 0")))
+
+(define_constraint "N"
+  "A negative ADDQ or SUBQ."
+  (and (match_code "const_int")
+       (match_test "IN_RANGE (ival, -63, -1)")))
+
+(define_constraint "O"
+  "Quickened ints, QI and HI."
+  (and (match_code "const_int")
+       (ior (match_test "IN_RANGE (ival, (65535 - 31), 65535)")
+            (match_test "IN_RANGE (ival, (255 - 31), 255)"))))
+
+(define_constraint "P"
+  "A 16-bit number signed *or* unsigned."
+  (and (match_code "const_int")
+       (match_test "IN_RANGE (ival, -32768, 65535)")))
+
+(define_constraint "Kc"
+  "ASRQ, BTSTQ, LSRQ, LSLQ."
+  (and (match_code "const_int")
+       (match_test "IN_RANGE (ival, 0, 31)")))
+       
+ (define_constraint "Kp"
+  "A power of two."
+  (and (match_code "const_int")
+       (match_test "exact_log2 (ival) >= 0")))
+ 
+;; Floating-point constant constraints.
+(define_constraint "G"
+  "The floating point zero constant"
+  (and (match_code "const_double")
+       (match_test "GET_MODE_CLASS (mode) == MODE_FLOAT")
+       (match_test "op == CONST0_RTX (mode)")))
+
+;; Memory constraints.
+
+;; Just an indirect register (happens to also be "all" slottable
+;; memory addressing modes not covered by other constraints, i.e. '>').
+(define_memory_constraint "Q"
+  "@internal"
+  (and (match_code "mem")
+       (match_test "cris_base_p (XEXP (op, 0), reload_in_progress
+                                              || reload_completed)")))
+
+;; Extra constraints.
+(define_constraint "R"
+  "An operand to BDAP or BIAP."
+       ;; A BIAP; r.S?
+  (ior (match_test "cris_biap_index_p (op, reload_in_progress
+                                          || reload_completed)")
+       ;; A [reg] or (int) [reg], maybe with post-increment. 
+       (match_test "cris_bdap_index_p (op, reload_in_progress
+                                          || reload_completed)")
+       (match_test "cris_constant_index_p (op)")))
+
+(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),
+                                                      reload_in_progress
+                                                      || reload_completed)"))
+           ;; Just an explicit indirect reference: [const]?
+           (match_test "CONSTANT_P (XEXP (op, 0))")
+           ;; Something that is indexed; [...+...]?
+           (and (match_code "plus" "0")
+                     ;; A BDAP constant: [reg+(8|16|32)bit offset]?
+                (ior (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
+                                                    reload_in_progress
+                                                    || reload_completed)")
+                          (match_test "cris_constant_index_p (XEXP (XEXP (op, 0), 1))"))
+                     ;; A BDAP register: [reg+[reg(+)].S]?
+                     (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 0),
+                                                    reload_in_progress
+                                                    || reload_completed)")
+                          (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 1),
+                                                          reload_in_progress
+                                                          || reload_completed)"))
+                     ;; Same, but with swapped arguments (no canonical
+                     ;; ordering between e.g. REG and MEM as of LAST_UPDATED
+                     ;; "Thu May 12 03:59:11 UTC 2005").
+                     (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
+                                                    reload_in_progress
+                                                    || reload_completed)")
+                          (match_test "cris_bdap_index_p (XEXP (XEXP (op, 0), 0),
+                                                          reload_in_progress
+                                                          || reload_completed)"))
+                     ;; A BIAP: [reg+reg.S] (MULT comes first).
+                     (and (match_test "cris_base_p (XEXP (XEXP (op, 0), 1),
+                                                    reload_in_progress
+                                                    || reload_completed)")
+                          (match_test "cris_biap_index_p (XEXP (XEXP (op, 0), 0),
+                                                          reload_in_progress
+                                                          || reload_completed)")))))))
+
+(define_constraint "S"
+  "PIC-constructs for symbols."
+  (and (match_test "flag_pic")
+       (match_code "const")
+       (match_test "cris_valid_pic_const (op, false)")))
+
+(define_constraint "U"
+  "@internal"
+  (and (match_test "flag_pic")
+       (match_test "CONSTANT_P (op)")
+       (match_operand 0 "cris_nonmemory_operand_or_callable_symbol")))
+