This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] define-constraints rewrite for s390 back end


%% > As discussed, the patch appended below is a rewrite for the s390 back
%% > end to exploit the new define-constraints framework.

%% Thanks!  The patch looks good, except for some minor coding style
%% issues, see below.  Also, please provide a ChangeLog entry.

Here are the modified patch and the Changelog entry:

2006-10-10  Wolfgang Gellerich  <gellerich@de.ibm.com>

	* config/s390/contraints.md: new file
        * config/s390/s390-protos.h: added protos for new functions 
	s390_mem_constraint, s390_O_constraint_str,
	s390_N_constraint_str, s390_float_const_zero_p
	* config/s390/s390.c (s390_extra_constraint_str): removed.
        (s390_mem_constraint): new.
	(s390_const_double_ok_for_constraint_p): removed.
	(s390_O_constraint_str): new.
	(s390_const_ok_for_constraint_p): removed.
	(s390_N_constraint_str): new.
	(s390_float_const_zero_p): new.
	* config/s390/s390.h (REG_CLASS_FROM_LETTER): removed.
	(CONST_OK_FOR_CONSTRAINT_P): removed.
	(s390_const_ok_for_constraint_p): removed.
	(CONST_DOUBLE_OK_FOR_CONSTRAINT_P): removed.
	(s390_const_double_ok_for_constraint_p): removed.
	(EXTRA_CONSTRAINT_STR): removed.
	(s390_extra_constraint_str): removed.
	(EXTRA_MEMORY_CONSTRAINT): removed.
	(EXTRA_ADDRESS_CONSTRAINT): removed.
	(CONSTRAINT_LEN): removed.


Regards, Wolfgang


-------------------------------------------------




Common subdirectories: s390-ORI/.svn and s390/.svn
diff -p -c -N s390-ORI/constraints.md s390/constraints.md
*** s390-ORI/constraints.md	Thu Jan  1 01:00:00 1970
--- s390/constraints.md	Mon Oct  9 16:19:09 2006
***************
*** 0 ****
--- 1,438 ----
+ ;; Constraints definitions belonging to the gcc backend for IBM S/390.
+ ;; Copyright (C) 2006 Free Software Foundation, Inc.
+ ;; Written by Wolfgang Gellerich, using code and information found in
+ ;; files s390.md, s390.h, and s390.c.
+ ;;
+ ;; 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 2, 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 COPYING.  If not, write to the Free
+ ;; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ ;; 02110-1301, USA.
+ 
+ 
+ ;;
+ ;; Special constraints for s/390 machine description:
+ ;;
+ ;;    a -- Any address register from 1 to 15.
+ ;;    c -- Condition code register 33.
+ ;;    d -- Any register from 0 to 15.
+ ;;    f -- Floating point registers.
+ ;;    t -- Access registers 36 and 37.
+ ;;    G -- Const double zero operand
+ ;;    I -- An 8-bit constant (0..255).
+ ;;    J -- A 12-bit constant (0..4095).
+ ;;    K -- A 16-bit constant (-32768..32767).
+ ;;    L -- Value appropriate as displacement.
+ ;;         (0..4095) for short displacement
+ ;;         (-524288..524287) for long displacement
+ ;;    M -- Constant integer with a value of 0x7fffffff.
+ ;;    N -- Multiple letter constraint followed by 4 parameter letters.
+ ;;         0..9,x:  number of the part counting from most to least significant
+ ;;         H,Q:     mode of the part
+ ;;         D,S,H:   mode of the containing operand
+ ;;         0,F:     value of the other parts (F - all bits set)
+ ;;
+ ;;         The constraint matches if the specified part of a constant
+ ;;         has a value different from its other parts.  If the letter x
+ ;;         is specified instead of a part number, the constraint matches
+ ;;         if there is any single part with non-default value.
+ ;;    O -- Multiple letter constraint followed by 1 parameter.
+ ;;         s:  Signed extended immediate value (-2G .. 2G-1).
+ ;;         p:  Positive extended immediate value (0 .. 4G-1).
+ ;;         n:  Negative extended immediate value (-4G .. -1).
+ ;;         These constraints do not accept any operand if the machine does
+ ;;         not provide the extended-immediate facility.
+ ;;    P -- Any integer constant that can be loaded without literal pool.
+ ;;    Q -- Memory reference without index register and with short displacement.
+ ;;    R -- Memory reference with index register and short displacement.
+ ;;    S -- Memory reference without index register but with long displacement.
+ ;;    T -- Memory reference with index register and long displacement.
+ ;;    A -- Multiple letter constraint followed by Q, R, S, or T:
+ ;;         Offsettable memory reference of type specified by second letter.
+ ;;    B -- Multiple letter constraint followed by Q, R, S, or T:
+ ;;         Memory reference of the type specified by second letter that
+ ;;         does *not* refer to a literal pool entry.
+ ;;    U -- Pointer with short displacement.
+ ;;    W -- Pointer with long displacement.
+ ;;    Y -- Shift count operand.
+ ;;
+ 
+ 
+ ;;
+ ;;  Register constraints.
+ ;;
+ 
+ (define_register_constraint "a" 
+   "ADDR_REGS"
+   "Any address register from 1 to 15.")
+ 
+ 
+ (define_register_constraint "c" 
+   "CC_REGS"
+   "Condition code register 33")
+ 
+ 
+ (define_register_constraint "d" 
+   "GENERAL_REGS"
+   "Any register from 0 to 15")
+ 
+ 
+ (define_register_constraint "f" 
+   "FP_REGS"
+   "Floating point registers")
+ 
+ 
+ (define_register_constraint "t" 
+   "ACCESS_REGS"
+   "@internal
+    Access registers 36 and 37")
+ 
+ 
+ ;;
+ ;;  General constraints for constants.
+ ;;
+ 
+ (define_constraint "G"
+   "@internal
+    Const double zero operand"
+    (and (match_code "const_double")
+         (match_test "s390_float_const_zero_p (op)")))
+ 
+ 
+ (define_constraint "I"
+   "An 8-bit constant (0..255)"
+   (and (match_code "const_int")
+        (match_test "(unsigned int) ival <= 255")))
+ 
+ 
+ (define_constraint "J"
+   "A 12-bit constant (0..4095)"
+   (and (match_code "const_int")
+        (match_test "(unsigned int) ival <= 4095")))
+ 
+ 
+ (define_constraint "K"
+   "A 16-bit constant (-32768..32767)"
+   (and (match_code "const_int")
+        (match_test "ival >= -32768 && ival <= 32767")))
+ 
+ 
+ 
+ (define_constraint "L"
+   "Value appropriate as displacement.
+       (0..4095) for short displacement
+       (-524288..524287) for long displacement"
+   (and (match_code "const_int")
+        (match_test "TARGET_LONG_DISPLACEMENT ?
+               (ival >= -524288 && ival <= 524287)
+             : (ival >= 0 && ival <= 4095)")))
+ 
+ 
+ (define_constraint "M"
+   "Constant integer with a value of 0x7fffffff"
+   (and (match_code "const_int")
+        (match_test "ival == 2147483647")))
+ 
+ 
+ (define_constraint "P"
+   "@internal
+    Any integer constant that can be loaded without literal pool"
+    (and (match_code "const_int")
+         (match_test "legitimate_reload_constant_p (GEN_INT (ival))")))
+ 
+ 
+ (define_address_constraint "Y"
+   "Shift count operand"
+ 
+ ;; Simply check for the basic form of a shift count.  Reload will
+ ;; take care of making sure we have a proper base register.
+ 
+   (match_test "s390_decompose_shift_count (op, NULL, NULL)"  ))
+ 
+ 
+ ;;    N -- Multiple letter constraint followed by 4 parameter letters.
+ ;;         0..9,x:  number of the part counting from most to least significant
+ ;;         H,Q:     mode of the part
+ ;;         D,S,H:   mode of the containing operand
+ ;;         0,F:     value of the other parts (F = all bits set)
+ ;;
+ ;;         The constraint matches if the specified part of a constant
+ ;;         has a value different from its other parts.  If the letter x
+ ;;         is specified instead of a part number, the constraint matches
+ ;;         if there is any single part with non-default value.
+ ;;
+ ;; The following patterns define only those constraints that are actually 
+ ;; used in s390.md.  If you need an additional one, simply add it in the 
+ ;; obvious way.  Function s390_N_constraint_str is ready to handle all 
+ ;; combinations.
+ ;;
+ 
+ 
+ (define_constraint "NxQS0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"xQS0\", ival)")))
+ 
+ 
+ (define_constraint "NxQD0"
+   "@internal"
+    (and (match_code "const_int")
+         (match_test "s390_N_constraint_str (\"xQD0\", ival)")))
+ 
+ 
+ (define_constraint "N3HD0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"3HD0\", ival)")))
+ 
+ 
+ (define_constraint "N2HD0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"2HD0\", ival)")))
+ 
+ 
+ (define_constraint "N1SD0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"1SD0\", ival)")))
+ 
+ 
+ (define_constraint "N1HS0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"1HS0\", ival)")))
+ 
+ 
+ (define_constraint "N1HD0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"1HD0\", ival)")))
+ 
+ 
+ (define_constraint "N0SD0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"0SD0\", ival)")))
+ 
+ 
+ (define_constraint "N0HS0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"0HS0\", ival)")))
+ 
+ 
+ (define_constraint "N0HD0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"0HD0\", ival)")))
+ 
+ 
+ (define_constraint "NxQDF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"xQDF\", ival)")))
+ 
+ 
+ (define_constraint "N1SDF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"1SDF\", ival)")))
+ 
+ 
+ (define_constraint "N0SDF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"0SDF\", ival)")))
+ 
+ 
+ (define_constraint "N3HDF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"3HDF\", ival)")))
+ 
+ 
+ (define_constraint "N2HDF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"2HDF\", ival)")))
+ 
+ 
+ (define_constraint "N1HDF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"1HDF\", ival)")))
+ 
+ 
+ (define_constraint "N0HDF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"0HDF\", ival)")))
+ 
+ 
+ (define_constraint "N0HSF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"0HSF\", ival)")))
+ 
+ 
+ (define_constraint "N1HSF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"1HSF\", ival)")))
+ 
+ 
+ (define_constraint "NxQSF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"xQSF\", ival)")))
+ 
+ 
+ (define_constraint "NxQHF"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"xQHF\", ival)")))
+ 
+ 
+ (define_constraint "NxQH0"
+   "@internal"
+   (and (match_code "const_int")
+        (match_test "s390_N_constraint_str (\"xQH0\", ival)")))
+ 
+ 
+ 
+ 
+ ;;
+ ;; Double-letter constraints starting with O follow.
+ ;;
+ 
+ 
+ (define_constraint "Os"
+   "@internal
+    Signed extended immediate value (-2G .. 2G-1).
+    This constraint will only match if the machine provides
+    the extended-immediate facility."
+   (and (match_code "const_int")
+        (match_test "s390_O_constraint_str ('s', ival)")))
+ 
+ 
+ (define_constraint "Op"
+   "@internal
+    Positive extended immediate value (0 .. 4G-1).
+    This constraint will only match if the machine provides
+    the extended-immediate facility."
+   (and (match_code "const_int")
+        (match_test "s390_O_constraint_str ('p', ival)")))
+ 
+ 
+ (define_constraint "On"
+   "@internal
+    Negative extended immediate value (-4G .. -1).
+    This constraint will only match if the machine provides
+    the extended-immediate facility."
+   (and (match_code "const_int")
+        (match_test "s390_O_constraint_str ('n', ival)")))
+ 
+ 
+ 
+ 
+ ;;
+ ;; Memory constraints follow.
+ ;;
+ 
+ (define_memory_constraint "Q"
+   "Memory reference without index register and with short displacement"
+   (match_test "s390_mem_constraint (\"Q\", op)"))
+ 
+ 
+ 
+ (define_memory_constraint "R"
+   "Memory reference with index register and short displacement"
+   (match_test "s390_mem_constraint (\"R\", op)"))
+ 
+ 
+ (define_memory_constraint "S"
+   "Memory reference without index register but with long displacement"
+   (match_test "s390_mem_constraint (\"S\", op)"))
+ 
+ 
+ (define_memory_constraint "T"
+   "Memory reference with index register and long displacement"
+   (match_test "s390_mem_constraint (\"T\", op)"))
+ 
+ 
+ 
+ (define_memory_constraint "AQ"
+   "@internal 
+    Offsettable memory reference without index register and with short displacement"
+   (match_test "s390_mem_constraint (\"AQ\", op)"))
+ 
+ 
+ (define_memory_constraint "AR"
+   "@internal 
+    Offsettable memory reference with index register and short displacement"
+   (match_test "s390_mem_constraint (\"AR\", op)"))
+ 
+ 
+ (define_memory_constraint "AS"
+   "@internal 
+    Offsettable memory reference without index register but with long displacement"
+   (match_test "s390_mem_constraint (\"AS\", op)"))
+ 
+ 
+ (define_memory_constraint "AT"
+   "@internal 
+    Offsettable memory reference with index register and long displacement"
+   (match_test "s390_mem_constraint (\"AT\", op)"))
+ 
+ 
+ 
+ (define_constraint "BQ"
+   "@internal 
+    Memory reference without index register and with short 
+    displacement that does *not* refer to a literal pool entry."
+   (match_test "s390_mem_constraint (\"BQ\", op)"))
+ 
+ 
+ (define_constraint "BR"
+   "@internal 
+    Memory reference with index register and short displacement that
+    does *not* refer to a literal pool entry. "
+   (match_test "s390_mem_constraint (\"BR\", op)"))
+ 
+ 
+ (define_constraint "BS"
+   "@internal 
+    Memory reference without index register but with long displacement
+    that does *not* refer to a literal pool entry. "
+   (match_test "s390_mem_constraint (\"BS\", op)"))
+ 
+ 
+ (define_constraint "BT"
+   "@internal 
+    Memory reference with index register and long displacement that
+    does *not* refer to a literal pool entry. "
+   (match_test "s390_mem_constraint (\"BT\", op)"))
+ 
+ 
+ 
+ (define_address_constraint "U"
+   "Pointer with short displacement"
+   (match_test "s390_mem_constraint (\"U\", op)"))
+ 
+ 
+ 
+ (define_address_constraint "W"
+   "Pointer with long displacement"
+   (match_test "s390_mem_constraint (\"W\", op)"))
diff -p -c -N s390-ORI/s390-protos.h s390/s390-protos.h
*** s390-ORI/s390-protos.h	Thu Sep 28 09:58:58 2006
--- s390/s390-protos.h	Mon Oct  9 16:19:09 2006
*************** along with GCC; see the file COPYING.  I
*** 19,24 ****
--- 19,36 ----
  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
  02110-1301, USA.  */
  
+ 
+ 
+ /* Prototypes of functions used for constraint evaluation in 
+    constraints.c.  */
+ 
+ extern int s390_mem_constraint (const char *str, rtx op);
+ extern int s390_O_constraint_str (const char c, HOST_WIDE_INT value);
+ extern int s390_N_constraint_str (const char *str, HOST_WIDE_INT value);
+ extern int s390_float_const_zero_p (rtx value);
+ 
+ 
+ 
  /* Declare functions in s390.c.  */
  
  extern void optimization_options (int, int);
diff -p -c -N s390-ORI/s390.c s390/s390.c
*** s390-ORI/s390.c	Thu Sep 28 09:58:58 2006
--- s390/s390.c	Mon Oct  9 16:19:09 2006
*************** s390_legitimate_address_without_index_p 
*** 1843,1856 ****
    return true;
  }
  
! /* Return 1 if OP is a valid operand for a C constraint, 0 else.  */
  
  int
! s390_extra_constraint_str (rtx op, int c, const char * str)
  {
    struct s390_address addr;
! 
!   gcc_assert (c == str[0]);
  
    /* Check for offsettable variants of memory constraints.  */
    if (c == 'A')
--- 1843,1858 ----
    return true;
  }
  
! 
! /* Evaluates constraint strings described by the regular expression
!    ([A|B](Q|R|S|T))|U|W and returns 1 if OP is a valid operand for the
!    constraint given in STR, or 0 else.  */
  
  int
! s390_mem_constraint (const char *str, rtx op)
  {
    struct s390_address addr;
!   char c = str[0];
  
    /* Check for offsettable variants of memory constraints.  */
    if (c == 'A')
*************** s390_extra_constraint_str (rtx op, int c
*** 1860,1867 ****
  	return 0;
  
        if ((reload_completed || reload_in_progress)
! 	  ? !offsettable_memref_p (op)
! 	  : !offsettable_nonstrict_memref_p (op))
  	return 0;
  
        c = str[1];
--- 1862,1868 ----
  	return 0;
  
        if ((reload_completed || reload_in_progress)
! 	  ? !offsettable_memref_p (op) : !offsettable_nonstrict_memref_p (op))
  	return 0;
  
        c = str[1];
*************** s390_extra_constraint_str (rtx op, int c
*** 1929,1935 ****
        if (GET_CODE (op) != MEM)
  	return 0;
        /* Any invalid address here will be fixed up by reload,
! 	 so accept it for the most generic constraint.  */
        if (s390_decompose_address (XEXP (op, 0), &addr)
  	  && s390_short_displacement (addr.disp))
  	return 0;
--- 1930,1936 ----
        if (GET_CODE (op) != MEM)
  	return 0;
        /* Any invalid address here will be fixed up by reload,
!          so accept it for the most generic constraint.  */
        if (s390_decompose_address (XEXP (op, 0), &addr)
  	  && s390_short_displacement (addr.disp))
  	return 0;
*************** s390_extra_constraint_str (rtx op, int c
*** 1949,1955 ****
        if (!TARGET_LONG_DISPLACEMENT)
  	return 0;
        /* Any invalid address here will be fixed up by reload,
! 	 so accept it for the most generic constraint.  */
        if (s390_decompose_address (op, &addr)
  	  && s390_short_displacement (addr.disp))
  	return 0;
--- 1950,1956 ----
        if (!TARGET_LONG_DISPLACEMENT)
  	return 0;
        /* Any invalid address here will be fixed up by reload,
!          so accept it for the most generic constraint.  */
        if (s390_decompose_address (op, &addr)
  	  && s390_short_displacement (addr.disp))
  	return 0;
*************** s390_extra_constraint_str (rtx op, int c
*** 1969,2100 ****
    return 1;
  }
  
! /* Return true if VALUE matches the constraint STR.  */
  
  int
! s390_const_double_ok_for_constraint_p (rtx value,
! 				       int c,
! 				       const char * str)
  {
!   gcc_assert (c == str[0]);
  
!   switch (str[0])
      {
!     case 'G':
!       /* The floating point zero constant.  */
!       return (GET_MODE_CLASS (GET_MODE (value)) == MODE_FLOAT
!               && value == CONST0_RTX (GET_MODE (value)));
!       
      default:
!       return 0;
      }
  }
  
! /* Return true if VALUE matches the constraint STR.  */
  
  int
! s390_const_ok_for_constraint_p (HOST_WIDE_INT value,
! 				int c,
! 				const char * str)
  {
    enum machine_mode mode, part_mode;
    int def;
    int part, part_goal;
  
-   gcc_assert (c == str[0]);
- 
-   switch (str[0])
-     {
-     case 'I':
-       return (unsigned int)value < 256;
- 
-     case 'J':
-       return (unsigned int)value < 4096;
- 
-     case 'K':
-       return value >= -32768 && value < 32768;
- 
-     case 'L':
-       return (TARGET_LONG_DISPLACEMENT ?
- 	      (value >= -524288 && value <= 524287)
- 	      : (value >= 0 && value <= 4095));
-     case 'M':
-       return value == 2147483647;
- 
-     case 'N':
-       if (str[1] == 'x')
- 	part_goal = -1;
-       else
- 	part_goal = str[1] - '0';
- 
-       switch (str[2])
- 	{
-   	case 'Q': part_mode = QImode; break;
-  	case 'H': part_mode = HImode; break;
-  	case 'S': part_mode = SImode; break;
- 	default:  return 0;
- 	}
- 
-       switch (str[3])
- 	{
- 	case 'H': mode = HImode; break;
- 	case 'S': mode = SImode; break;
- 	case 'D': mode = DImode; break;
- 	default: return 0;
- 	}
- 
-       switch (str[4])
- 	{
- 	case '0': def = 0;  break;
- 	case 'F': def = -1; break;
- 	default: return 0;
- 	}
  
!       if (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (part_mode))
! 	return 0;
! 
!       part = s390_single_part (GEN_INT (value), mode, part_mode, def);
!       if (part < 0)
! 	return 0;
!       if (part_goal != -1 && part_goal != part)
! 	return 0;
  
        break;
! 
!     case 'O':
!       if (!TARGET_EXTIMM)
! 	return 0;
!       
!       switch (str[1])
! 	{
! 	case 's':
! 	  return trunc_int_for_mode (value, SImode) == value;
! 	  
! 	case 'p':
! 	  return value == 0
! 	    || s390_single_part (GEN_INT (value), DImode, SImode, 0) == 1;
! 	  
! 	case 'n':
! 	  return 
! 	    (value == -1
! 	     || s390_single_part (GEN_INT (value), DImode, SImode, -1) == 1)
! 	    && value != -((HOST_WIDE_INT)1 << 32);
! 	  
! 	default:
! 	  gcc_unreachable ();
! 	}
        break;
  
!     case 'P':
!       return legitimate_reload_constant_p (GEN_INT (value));
  
      default:
        return 0;
      }
  
    return 1;
  }
  
  /* Compute a (partial) cost for rtx X.  Return true if the complete
     cost has been computed, and false if subexpressions should be
     scanned.  In either case, *TOTAL contains the cost result.  
--- 1970,2089 ----
    return 1;
  }
  
! 
! 
! /* Evaluates constraint strings starting with letter O.  Input
!    parameter C is the second letter following the "O" in the constraint
!    string. Returns 1 if VALUE meets the respective constraint and 0
!    otherwise.  */
  
  int
! s390_O_constraint_str (const char c, HOST_WIDE_INT value)
  {
!   if (!TARGET_EXTIMM)
!     return 0;
  
!   switch (c)
      {
!     case 's':
!       return trunc_int_for_mode (value, SImode) == value;
! 
!     case 'p':
!       return value == 0
! 	|| s390_single_part (GEN_INT (value), DImode, SImode, 0) == 1;
! 
!     case 'n':
!       return value == -1
! 	|| s390_single_part (GEN_INT (value), DImode, SImode, -1) == 1;
! 
      default:
!       gcc_unreachable ();
      }
  }
  
! 
! /* Evaluates constraint strings starting with letter N.  Parameter STR
!    contains the letters following letter "N" in the constraint string.
!    Returns true if VALUE matches the constraint.  */
  
  int
! s390_N_constraint_str (const char *str, HOST_WIDE_INT value)
  {
    enum machine_mode mode, part_mode;
    int def;
    int part, part_goal;
  
  
!   if (str[0] == 'x')
!     part_goal = -1;
!   else
!     part_goal = str[0] - '0';
  
+   switch (str[1])
+     {
+     case 'Q':
+       part_mode = QImode;
        break;
!     case 'H':
!       part_mode = HImode;
        break;
+     case 'S':
+       part_mode = SImode;
+       break;
+     default:
+       return 0;
+     }
  
!   switch (str[2])
!     {
!     case 'H':
!       mode = HImode;
!       break;
!     case 'S':
!       mode = SImode;
!       break;
!     case 'D':
!       mode = DImode;
!       break;
!     default:
!       return 0;
!     }
  
+   switch (str[3])
+     {
+     case '0':
+       def = 0;
+       break;
+     case 'F':
+       def = -1;
+       break;
      default:
        return 0;
      }
  
+   if (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (part_mode))
+     return 0;
+ 
+   part = s390_single_part (GEN_INT (value), mode, part_mode, def);
+   if (part < 0)
+     return 0;
+   if (part_goal != -1 && part_goal != part)
+     return 0;
+ 
    return 1;
  }
  
+ 
+ /* Returns true if the input parameter VALUE is a float zero.  */
+ 
+ int
+ s390_float_const_zero_p (rtx value)
+ {
+   return (GET_MODE_CLASS (GET_MODE (value)) == MODE_FLOAT
+ 	  && value == CONST0_RTX (GET_MODE (value)));
+ }
+ 
+ 
  /* Compute a (partial) cost for rtx X.  Return true if the complete
     cost has been computed, and false if subexpressions should be
     scanned.  In either case, *TOTAL contains the cost result.  
diff -p -c -N s390-ORI/s390.h s390/s390.h
*** s390-ORI/s390.h	Thu Sep 28 09:58:58 2006
--- s390/s390.h	Mon Oct  9 16:19:09 2006
*************** extern const enum reg_class regclass_map
*** 481,514 ****
    : MODE)
  
  
- /* Define various machine-dependent constraint letters.  */
- 
- #define REG_CLASS_FROM_LETTER(C)                                        \
-   ((C) == 'a' ? ADDR_REGS :                                             \
-    (C) == 'd' ? GENERAL_REGS :                                          \
-    (C) == 'f' ? FP_REGS :                                               \
-    (C) == 'c' ? CC_REGS : 						\
-    (C) == 't' ? ACCESS_REGS : NO_REGS)
- 
- #define CONST_OK_FOR_CONSTRAINT_P(VALUE, C, STR)                          \
-   s390_const_ok_for_constraint_p ((VALUE), (C), (STR))
- 
- #define CONST_DOUBLE_OK_FOR_CONSTRAINT_P(VALUE, C, STR)			\
-   s390_const_double_ok_for_constraint_p ((VALUE), (C), (STR))
- 
- #define EXTRA_CONSTRAINT_STR(OP, C, STR)                               	\
-   s390_extra_constraint_str ((OP), (C), (STR))
- #define EXTRA_MEMORY_CONSTRAINT(C, STR)					\
-   ((C) == 'Q' || (C) == 'R' || (C) == 'S' || (C) == 'T' || (C) == 'A')
- #define EXTRA_ADDRESS_CONSTRAINT(C, STR)				\
-   ((C) == 'U' || (C) == 'W' || (C) == 'Y')
- 
- #define CONSTRAINT_LEN(C, STR)                                  	\
-   ((C) == 'N' ? 5 : 	                                                \
-    (C) == 'O' ? 2 :							\
-    (C) == 'A' ? 2 :							\
-    (C) == 'B' ? 2 : DEFAULT_CONSTRAINT_LEN ((C), (STR)))
- 
  /* Stack layout and calling conventions.  */
  
  /* Our stack grows from higher to lower addresses.  However, local variables
--- 481,486 ----
diff -p -c -N s390-ORI/s390.md s390/s390.md
*** s390-ORI/s390.md	Thu Sep 28 09:58:58 2006
--- s390/s390.md	Mon Oct  9 16:19:09 2006
***************
*** 22,72 ****
  ;; 02110-1301, USA.
  
  ;;
! ;; Special constraints for s/390 machine description:
! ;;
! ;;    a -- Any address register from 1 to 15.
! ;;    c -- Condition code register 33.
! ;;    d -- Any register from 0 to 15.
! ;;    f -- Floating point registers.
! ;;    t -- Access registers 36 and 37.
! ;;    G -- Const double zero operand
! ;;    I -- An 8-bit constant (0..255).
! ;;    J -- A 12-bit constant (0..4095).
! ;;    K -- A 16-bit constant (-32768..32767).
! ;;    L -- Value appropriate as displacement.
! ;;         (0..4095) for short displacement
! ;;         (-524288..524287) for long displacement
! ;;    M -- Constant integer with a value of 0x7fffffff.
! ;;    N -- Multiple letter constraint followed by 4 parameter letters.
! ;;         0..9,x:  number of the part counting from most to least significant
! ;;         H,Q:     mode of the part
! ;;         D,S,H:   mode of the containing operand
! ;;         0,F:     value of the other parts (F - all bits set)
! ;;
! ;;         The constraint matches if the specified part of a constant
! ;;         has a value different from its other parts.  If the letter x
! ;;         is specified instead of a part number, the constraint matches
! ;;         if there is any single part with non-default value.
! ;;    O -- Multiple letter constraint followed by 1 parameter.
! ;;         s:  Signed extended immediate value (-2G .. 2G-1).
! ;;         p:  Positive extended immediate value (0 .. 4G-1).
! ;;         n:  Negative extended immediate value (-4G+1 .. -1).
! ;;         These constraints do not accept any operand if the machine does
! ;;         not provide the extended-immediate facility.
! ;;    P -- Any integer constant that can be loaded without literal pool.
! ;;    Q -- Memory reference without index register and with short displacement.
! ;;    R -- Memory reference with index register and short displacement.
! ;;    S -- Memory reference without index register but with long displacement.
! ;;    T -- Memory reference with index register and long displacement.
! ;;    A -- Multiple letter constraint followed by Q, R, S, or T:
! ;;         Offsettable memory reference of type specified by second letter.
! ;;    B -- Multiple letter constraint followed by Q, R, S, or T:
! ;;         Memory reference of the type specified by second letter that
! ;;         does *not* refer to a literal pool entry.
! ;;    U -- Pointer with short displacement.
! ;;    W -- Pointer with long displacement.
! ;;    Y -- Shift count operand.
  ;;
  ;; Special formats used for outputting 390 instructions.
  ;;
  ;;     %C: print opcode suffix for branch condition.
--- 22,30 ----
  ;; 02110-1301, USA.
  
  ;;
! ;; See constraints.md for a description of constraints specific to s390.
  ;;
+ 
  ;; Special formats used for outputting 390 instructions.
  ;;
  ;;     %C: print opcode suffix for branch condition.
***************
*** 243,248 ****
--- 201,209 ----
  ;; Predicates
  (include "predicates.md")
  
+ ;; Constraint definitions
+ (include "constraints.md")
+ 
  ;; Other includes
  (include "tpf.md")
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]