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]

Pmode in md patterns


The following preserves Pmode as a separate entity during the genfoo
programs.  The only special changes appear to be to genrecog, which
must realize that Pmode is may not be a compile-time constant.

I've visually examined the correctness of several md file fragments
using this feature and (to see that nothing silly happened) bootstrapped
alphaev6-linux.


r~


        * machmode.def (Pmode): Redefine if GENERATOR_FILE.
        * genrecog.c (maybe_both_true_mode): New.
        (maybe_both_true_2): Use it.
        (write_switch): Don't put Pmode in a switch.
        * rtl.c (mode arrays): Don't explicitly size them.

Index: genrecog.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genrecog.c,v
retrieving revision 1.101
diff -c -p -d -r1.101 genrecog.c
*** genrecog.c	2001/07/06 20:39:56	1.101
--- genrecog.c	2001/07/15 23:47:02
*************** static void validate_pattern
*** 238,243 ****
--- 238,245 ----
  static struct decision *add_to_sequence
    PARAMS ((rtx, struct decision_head *, const char *, enum routine_type, int));
  
+ static int maybe_both_true_mode
+   PARAMS ((enum machine_mode, enum machine_mode));
  static int maybe_both_true_2
    PARAMS ((struct decision_test *, struct decision_test *));
  static int maybe_both_true_1
*************** add_to_sequence (pattern, last, position
*** 1054,1059 ****
--- 1056,1084 ----
    return sub;
  }
  
+ /* A subroutine of maybe_both_true; compares two modes.
+    Returns > 0 for "definitely both true" and < 0 for "maybe both true".  */
+ 
+ static int
+ maybe_both_true_mode (m1, m2)
+      enum machine_mode m1, m2;
+ {
+   enum mode_class other_mode_class;
+ 
+   /* Pmode is not a distinct mode.  We do know that it is
+      either MODE_INT or MODE_PARTIAL_INT though.  */
+   if (m1 == Pmode)
+     other_mode_class = GET_MODE_CLASS (m2);
+   else if (m2 == Pmode)
+     other_mode_class = GET_MODE_CLASS (m1);
+   else
+     return m1 == m2;
+ 
+   return (other_mode_class == MODE_INT
+ 	  || other_mode_class == MODE_PARTIAL_INT
+ 	  ? -1 : 0);
+ }
+ 
  /* A subroutine of maybe_both_true; examines only one test.
     Returns > 0 for "definitely both true" and < 0 for "maybe both true".  */
  
*************** maybe_both_true_2 (d1, d2)
*** 1066,1072 ****
        switch (d1->type)
  	{
  	case DT_mode:
! 	  return d1->u.mode == d2->u.mode;
  
  	case DT_code:
  	  return d1->u.code == d2->u.code;
--- 1091,1097 ----
        switch (d1->type)
  	{
  	case DT_mode:
! 	  return maybe_both_true_mode (d1->u.mode, d2->u.mode);
  
  	case DT_code:
  	  return d1->u.code == d2->u.code;
*************** maybe_both_true_2 (d1, d2)
*** 1102,1108 ****
  	{
  	  if (d2->type == DT_mode)
  	    {
! 	      if (d1->u.pred.mode != d2->u.mode
  		  /* The mode of an address_operand predicate is the
  		     mode of the memory, not the operand.  It can only
  		     be used for testing the predicate, so we must
--- 1127,1133 ----
  	{
  	  if (d2->type == DT_mode)
  	    {
! 	      if (maybe_both_true_mode (d1->u.pred.mode, d2->u.mode) == 0
  		  /* The mode of an address_operand predicate is the
  		     mode of the memory, not the operand.  It can only
  		     be used for testing the predicate, so we must
*************** write_switch (start, depth)
*** 1884,1889 ****
--- 1909,1918 ----
  	   || type == DT_elt_one_int
  	   || type == DT_elt_zero_wide_safe)
      {
+       /* Pmode may not be a compile-time constant.  */
+       if (type == DT_mode && p->tests->u.mode == Pmode)
+ 	return p;
+ 
        printf ("  switch (");
        switch (type)
  	{
*************** write_switch (start, depth)
*** 1918,1923 ****
--- 1947,1956 ----
  	  for (q = start; q != p; q = q->next)
  	    if (nodes_identical_1 (p->tests, q->tests))
  	      goto case_done;
+ 
+ 	  /* Pmode may not be a compile-time constant.  */
+ 	  if (type == DT_mode && p->tests->u.mode == Pmode)
+ 	    goto case_done;
  
  	  if (p != start && p->need_label && needs_label == NULL)
  	    needs_label = p;
Index: machmode.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/machmode.def,v
retrieving revision 1.11
diff -c -p -d -r1.11 machmode.def
*** machmode.def	2000/12/07 01:47:31	1.11
--- machmode.def	2001/07/15 23:47:02
*************** EXTRA_CC_MODES
*** 154,160 ****
  #undef CC
  
  /* The symbol Pmode stands for one of the above machine modes (usually SImode).
!    The tm file specifies which one.  It is not a distinct mode.  */
  
  /*
  Local variables:
--- 154,167 ----
  #undef CC
  
  /* The symbol Pmode stands for one of the above machine modes (usually SImode).
!    The tm file specifies which one.  It is not a distinct mode.  Nevertheless,
!    while processing the md file, we wish to treat as a distinct mode so that 
!    it is preserved intact through to the insn-foo.c files.  This eliminates a
!    lot of redundancy in ports that support both 32-bit and 64-bit targets.  */
! #ifdef GENERATOR_FILE
! #undef Pmode
! DEF_MACHMODE (Pmode, "P", MODE_RANDOM, 0, 0, 0, VOIDmode)
! #endif
  
  /*
  Local variables:
Index: rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.c,v
retrieving revision 1.93
diff -c -p -d -r1.93 rtl.c
*** rtl.c	2001/07/03 19:23:35	1.93
--- rtl.c	2001/07/15 23:47:02
*************** const char * const rtx_name[] = {
*** 117,127 ****
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  NAME,
  
! const char * const mode_name[(int) MAX_MACHINE_MODE + 1] = {
  #include "machmode.def"
-   /* Add an extra field to avoid a core dump if someone tries to convert
-      MAX_MACHINE_MODE to a string.   */
-   ""
  };
  
  #undef DEF_MACHMODE
--- 117,124 ----
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  NAME,
  
! const char * const mode_name[] = {
  #include "machmode.def"
  };
  
  #undef DEF_MACHMODE
*************** const char * const mode_name[(int) MAX_M
*** 130,136 ****
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  CLASS,
  
! const enum mode_class mode_class[(int) MAX_MACHINE_MODE] = {
  #include "machmode.def"
  };
  
--- 127,133 ----
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  CLASS,
  
! const enum mode_class mode_class[] = {
  #include "machmode.def"
  };
  
*************** const enum mode_class mode_class[(int) M
*** 141,147 ****
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  BITSIZE,
  
! const unsigned int mode_bitsize[(int) MAX_MACHINE_MODE] = {
  #include "machmode.def"
  };
  
--- 138,144 ----
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  BITSIZE,
  
! const unsigned int mode_bitsize[] = {
  #include "machmode.def"
  };
  
*************** const unsigned int mode_bitsize[(int) MA
*** 152,158 ****
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  SIZE,
  
! const unsigned int mode_size[(int) MAX_MACHINE_MODE] = {
  #include "machmode.def"
  };
  
--- 149,155 ----
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  SIZE,
  
! const unsigned int mode_size[] = {
  #include "machmode.def"
  };
  
*************** const unsigned int mode_size[(int) MAX_M
*** 163,169 ****
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  UNIT,
  
! const unsigned int mode_unit_size[(int) MAX_MACHINE_MODE] = {
  #include "machmode.def"		/* machine modes are documented here */
  };
  
--- 160,166 ----
  
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  UNIT,
  
! const unsigned int mode_unit_size[] = {
  #include "machmode.def"		/* machine modes are documented here */
  };
  
*************** const unsigned int mode_unit_size[(int) 
*** 176,182 ****
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  \
    (unsigned char) WIDER,
  
! const unsigned char mode_wider_mode[(int) MAX_MACHINE_MODE] = {
  #include "machmode.def"		/* machine modes are documented here */
  };
  
--- 173,179 ----
  #define DEF_MACHMODE(SYM, NAME, CLASS, BITSIZE, SIZE, UNIT, WIDER)  \
    (unsigned char) WIDER,
  
! const unsigned char mode_wider_mode[] = {
  #include "machmode.def"		/* machine modes are documented here */
  };
  
*************** const unsigned char mode_wider_mode[(int
*** 187,193 ****
  
  /* Indexed by machine mode, gives mask of significant bits in mode.  */
  
! const unsigned HOST_WIDE_INT mode_mask_array[(int) MAX_MACHINE_MODE] = {
  #include "machmode.def"
  };
  
--- 184,190 ----
  
  /* Indexed by machine mode, gives mask of significant bits in mode.  */
  
! const unsigned HOST_WIDE_INT mode_mask_array[] = {
  #include "machmode.def"
  };
  


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