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]

Making rtxes use less memory (sometimes!)


After:

2002-05-12  Zack Weinberg  <zack@codesourcery.com>

	[...]
	* output.h: Delete prototype for clear_const_double_mem.
	* real.h: Make REAL_VALUE_TYPE a macro again.  Remove leading
	'0' slot from all CONST_DOUBLE_FORMAT definitions.  Prototype
	const_double_from_real_value, not immed_real_const_1, and use
	it to define CONST_DOUBLE_FROM_REAL_VALUE.  Define new macro
	CONST_DOUBLE_ATOF.
	* rtl.h (CONST_DOUBLE_CHAIN): Kill.
	(CONST_DOUBLE_LOW, CONST_DOUBLE_HIGH): Adjust.
	(gen_rtx_CONST_DOUBLE, immed_real_const): Delete prototypes.
	(gen_rtx_REG): Second arg is unsigned.

we seem to have a clean split between rtxes.  CONST_INT and
CONST_DOUBLE have just HOST_WIDE_INT fields while all the rest
have non-HOST_WIDE_INT fields.

At the moment, all the different types of rtx field (pointer, integer
and HOST_WIDE_INT) are wrapped up in an rtunion.  So if you have a host
where integers and pointers are 32 bits wide, and a target which needs
64-bit HOST_WIDE_INTs, every rtx field will be 64 bits wide.  Examples
include x86-to-mips crosses and n32 mips natives.

It seems like it should be more efficient to distinguish between
HOST_WIDE_INT and non-HOST_WIDE_INT fields on a per-rtx rather
than per-field basis.

That's what this patch is supposed to do.  It removes the rtwint field
from rtunion and changes:

     struct rtx_def {
       [...]
       rtunion [...] fld[1];
     };
to:
     struct rtx_def {
       [...]
       union u {
	 rtunion fld[1];
	 HOST_WIDE_INT hwint[1];
       } [...] u;
     };

Since rtxes are (almost!) always accessed through macros, this proved
to be quite an easy change to make.  In detail:

  - Several places used the equivalent of:

	sizeof (struct rtx_def) - sizeof (rtunion)

    to work out the size of the rtx header.  The patch makes them
    use a new macro constant, RTX_HDR_SIZE, instead.

  - Several places also used:

	sizeof (struct rtx_def) - (nfields - 1) * sizeof (rtunion)

    to calculate the size of an rtx.  That's no longer possible
    since the size of a field depends on the rtx_code.  The patch
    introduces a new macro, RTX_SIZE (CODE), which returns the
    size in bytes of a particular type of rtx.

  - Related: ggc_alloc_rtx() takes the number of fields as an argument,
    which it uses to work out the byte size.  The patch makes it take
    the rtx_code as argument instead.

  - XWINT and XCWINT must now access the rtx structure directly.
    They need separate checking and non-checking forms.

  - Some places use X0WINT to copy '0'-type fields, on the basis
    that HOST_WIDE_INT should be at least as big as a pointer or
    an integer.  Nothing actually seems to store HOST_WIDE_INTs
    in '0' fields though.

    The patch removes X0WINT and introduces a new macro, X0ANY,
    for copying 0 fields.

    [ I thought about generalising this to XANY(), for copying any
      non-'w' field.  We could them collect together all the various
      cases in copy functions:

	  case 's':
	  case 'i':
	  ...
	    XANY (dest, i) = XANY (src, i);

      But this would introduce more assumptions about the underlying
      representation, exactly the sort of thing I'd like to avoid. ]

  - The "rtx_def" GTY marker now applies to the new "u" field.
    Since hwints don't need to be marked, the behaviour is the
    same as before, the code just needs to use '.fld[%d]' rather
    than '[%d]' to get at a particular field.

Here's the sort of speed-up I get when compiling mips.i
using a mips64-linux-gnu native:

     -O0
	     before         after
     real    0m31.478s      0m29.830s
     user    0m31.270s      0m29.670s
     sys     0m0.200s       0m0.130s

     -O1
	     before         after
     real    0m16.364s      0m15.465s
     user    0m16.220s      0m15.270s
     sys     0m0.140s       0m0.190s

     -O2
	     before         after
     real    0m7.804s       0m7.104s
     user    0m7.690s       0m7.030s
     sys     0m0.100s       0m0.070s

(these are reproducable to within ~0.1s).

GC output and -fmem-report shows that memory consumption is much
lower and that collections are needed less often.  I'm not sure how
to measure this accurately though.

The patch was bootstrapped & regression tested on mips-sgi-irix6.5
and mips64{,el}-linux-gnu.  Also bootstrapped & regression tested
on i686-pc-linux-gnu, both with and without rtl checking.

I realise I've missed the boat for stage2, sorry.  Is it non-invasive
enough to be applied early in stage3?  Please? ;)

Richard


	* rtl.h (rtl_size): Declare.
	(rtunion): Remove rtwint.
	(rtx_def): Replace 'fld' with a union of an rtunion or a HOST_WIDE_INT.
	(RTX_HDR_SIZE, RTX_SIZE): New macros.
	(RTL_CHECK1): Adjust for new rtx_def layout.
	(RTL_CHECK2, RTL_CHECKC1, RTL_CHECKC2): Likewise.
	(XWINT, XCWINT): Likewise.  Access the rtx structure directly.
	(X0WINT): Remove.
	(X0ANY): New macro.
	* rtl.def: Adjust comments for new rtx_def layout.
	* ggc.h (ggc_alloc_rtx): Take the rtx code as argument, not the
	number of slots.
	* rtl.c (rtx_size): New array.
	(rtx_alloc): Adjust call to ggc_alloc_rtx.  Use RTX_HDR_SIZE.
	(copy_rtx): Use RTX_HDR_SIZE.  Adjust for new rtx_def layout.
	(shallow_copy_rtx): Adjust call to ggc_alloc_rtx.  Use RTX_SIZE.
	* integrate.c (copy_rtx_and_substitute): Use X0ANY to copy '0' fields.
	* emit-rtl.c (copy_most_rtx): Likewise.
	(copy_rtx_if_shared): Use RTX_SIZE.
	(copy_insn_1): Use RTX_HDR_SIZE.  Adjust for new rtx_def layout.
	* gengenrtl.c (gendef): Adjust ggc_alloc_rtx call.  Use RTX_HDR_SIZE.
	* gengtype.c (write_rtx_next): Use RTX_HDR_SIZE.
	(adjust_field_rtx_def): Expect "rtx_def" to be a union rather than
	an array.  Adjust output for new rtx_def layout.
	* ggc-page.c (RTL_SIZE): Use RTX_HDR_SIZE.
	* reload1.c (eliminate_regs): Use RTX_SIZE.
	* rtlanal.c (loc_mentioned_in_p): Adjust for new rtx_def layout.
	* gdbinit.in (pi): Likewise.

Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.436
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.436 rtl.h
--- rtl.h	11 Oct 2003 22:57:46 -0000	1.436
+++ rtl.h	16 Oct 2003 18:56:14 -0000
@@ -64,6 +64,7 @@ #define GET_RTX_FORMAT(CODE)		(rtx_forma
 extern const char rtx_class[NUM_RTX_CODE];
 #define GET_RTX_CLASS(CODE)		(rtx_class[(int) (CODE)])
 
+extern const unsigned char rtx_size[NUM_RTX_CODE];
 extern const unsigned char rtx_next[NUM_RTX_CODE];
 
 /* The flags and bitfields of an ADDR_DIFF_VEC.  BASE is the base label
@@ -117,7 +118,6 @@ typedef struct reg_attrs GTY(())
 
 union rtunion_def
 {
-  HOST_WIDE_INT rtwint;
   int rtint;
   unsigned int rtuint;
   const char *rtstr;
@@ -215,10 +215,18 @@ struct rtx_def GTY((chain_next ("RTX_NEX
   /* The first element of the operands of this rtx.
      The number of operands and their types are controlled
      by the `code' field, according to rtl.def.  */
-  rtunion GTY ((special ("rtx_def"),
-		desc ("GET_CODE (&%0)"))) fld[1];
+  union u {
+    rtunion fld[1];
+    HOST_WIDE_INT hwint[1];
+  } GTY ((special ("rtx_def"), desc ("GET_CODE (&%0)"))) u;
 };
 
+/* The size in bytes of an rtx header (code, mode and flags).  */
+#define RTX_HDR_SIZE offsetof (struct rtx_def, u)
+
+/* The size in bytes of an rtx with code CODE.  */
+#define RTX_SIZE(CODE) rtx_size[CODE]
+
 #define NULL_RTX (rtx) 0
 
 /* The "next" and "previous" RTX, relative to this one.  */
@@ -303,7 +311,7 @@ (*({ rtx const _rtx = (RTX); const int _
      if (GET_RTX_FORMAT(_code)[_n] != C1)				\
        rtl_check_failed_type1 (_rtx, _n, C1, __FILE__, __LINE__,	\
 			       __FUNCTION__);				\
-     &_rtx->fld[_n]; }))
+     &_rtx->u.fld[_n]; }))
 
 #define RTL_CHECK2(RTX, N, C1, C2) __extension__			\
 (*({ rtx const _rtx = (RTX); const int _n = (N);			\
@@ -315,14 +323,14 @@ (*({ rtx const _rtx = (RTX); const int _
 	 && GET_RTX_FORMAT(_code)[_n] != C2)				\
        rtl_check_failed_type2 (_rtx, _n, C1, C2, __FILE__, __LINE__,	\
 			       __FUNCTION__);				\
-     &_rtx->fld[_n]; }))
+     &_rtx->u.fld[_n]; }))
 
 #define RTL_CHECKC1(RTX, N, C) __extension__				\
 (*({ rtx const _rtx = (RTX); const int _n = (N);			\
      if (GET_CODE (_rtx) != (C))					\
        rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__,		\
 			       __FUNCTION__);				\
-     &_rtx->fld[_n]; }))
+     &_rtx->u.fld[_n]; }))
 
 #define RTL_CHECKC2(RTX, N, C1, C2) __extension__			\
 (*({ rtx const _rtx = (RTX); const int _n = (N);			\
@@ -330,7 +338,7 @@ (*({ rtx const _rtx = (RTX); const int _
      if (_code != (C1) && _code != (C2))				\
        rtl_check_failed_code2 (_rtx, (C1), (C2), __FILE__, __LINE__,	\
 			       __FUNCTION__); \
-     &_rtx->fld[_n]; }))
+     &_rtx->u.fld[_n]; }))
 
 #define RTVEC_ELT(RTVEC, I) __extension__				\
 (*({ rtvec const _rtvec = (RTVEC); const int _i = (I);			\
@@ -339,6 +347,24 @@ (*({ rtvec const _rtvec = (RTVEC); const
 				  __FUNCTION__);			\
      &_rtvec->elem[_i]; }))
 
+#define XWINT(RTX, N) __extension__					\
+(*({ rtx const _rtx = (RTX); const int _n = (N);			\
+     const enum rtx_code _code = GET_CODE (_rtx);			\
+     if (_n < 0 || _n >= GET_RTX_LENGTH (_code))			\
+       rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,		\
+				__FUNCTION__);				\
+     if (GET_RTX_FORMAT(_code)[_n] != 'w')				\
+       rtl_check_failed_type1 (_rtx, _n, 'w', __FILE__, __LINE__,	\
+			       __FUNCTION__);				\
+     &_rtx->u.hwint[_n]; }))
+
+#define XCWINT(RTX, N, C) __extension__					\
+(*({ rtx const _rtx = (RTX);						\
+     if (GET_CODE (_rtx) != (C))					\
+       rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__,		\
+			       __FUNCTION__);				\
+     &_rtx->u.hwint[N]; }))
+
 extern void rtl_check_failed_bounds (rtx, int, const char *, int,
 				     const char *)
     ATTRIBUTE_NORETURN;
@@ -360,11 +386,13 @@ extern void rtvec_check_failed_bounds (r
 
 #else   /* not ENABLE_RTL_CHECKING */
 
-#define RTL_CHECK1(RTX, N, C1)      ((RTX)->fld[N])
-#define RTL_CHECK2(RTX, N, C1, C2)  ((RTX)->fld[N])
-#define RTL_CHECKC1(RTX, N, C)	    ((RTX)->fld[N])
-#define RTL_CHECKC2(RTX, N, C1, C2) ((RTX)->fld[N])
+#define RTL_CHECK1(RTX, N, C1)      ((RTX)->u.fld[N])
+#define RTL_CHECK2(RTX, N, C1, C2)  ((RTX)->u.fld[N])
+#define RTL_CHECKC1(RTX, N, C)	    ((RTX)->u.fld[N])
+#define RTL_CHECKC2(RTX, N, C1, C2) ((RTX)->u.fld[N])
 #define RTVEC_ELT(RTVEC, I)	    ((RTVEC)->elem[I])
+#define XWINT(RTX, N)		    ((RTX)->u.hwint[N])
+#define XCWINT(RTX, N, C)	    ((RTX)->u.hwint[N])
 
 #endif
 
@@ -475,7 +503,6 @@ do {				\
   _rtx->volatil = 0;		\
 } while (0)
 
-#define XWINT(RTX, N)	(RTL_CHECK1 (RTX, N, 'w').rtwint)
 #define XINT(RTX, N)	(RTL_CHECK2 (RTX, N, 'i', 'n').rtint)
 #define XSTR(RTX, N)	(RTL_CHECK2 (RTX, N, 's', 'S').rtstr)
 #define XEXP(RTX, N)	(RTL_CHECK2 (RTX, N, 'e', 'u').rtx)
@@ -489,10 +516,9 @@ #define XTMPL(RTX, N)	(RTL_CHECK1 (RTX, 
 #define XVECEXP(RTX, N, M)	RTVEC_ELT (XVEC (RTX, N), M)
 #define XVECLEN(RTX, N)		GET_NUM_ELEM (XVEC (RTX, N))
 
-/* These are like XWINT, etc. except that they expect a '0' field instead
+/* These are like XINT, etc. except that they expect a '0' field instead
    of the normal type code.  */
 
-#define X0WINT(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rtwint)
 #define X0INT(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rtint)
 #define X0UINT(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rtuint)
 #define X0STR(RTX, N)	   (RTL_CHECK1 (RTX, N, '0').rtstr)
@@ -507,7 +533,9 @@ #define X0CSELIB(RTX, N)   (RTL_CHECK1 (
 #define X0MEMATTR(RTX, N)  (RTL_CHECKC1 (RTX, N, MEM).rtmem)
 #define X0REGATTR(RTX, N)  (RTL_CHECKC1 (RTX, N, REG).rtreg)
 
-#define XCWINT(RTX, N, C)     (RTL_CHECKC1 (RTX, N, C).rtwint)
+/* Access a '0' field with any type.  */
+#define X0ANY(RTX, N)	   RTL_CHECK1 (RTX, N, '0')
+
 #define XCINT(RTX, N, C)      (RTL_CHECKC1 (RTX, N, C).rtint)
 #define XCUINT(RTX, N, C)     (RTL_CHECKC1 (RTX, N, C).rtuint)
 #define XCSTR(RTX, N, C)      (RTL_CHECKC1 (RTX, N, C).rtstr)
Index: rtl.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.def,v
retrieving revision 1.72
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.72 rtl.def
--- rtl.def	11 Jul 2003 23:49:43 -0000	1.72
+++ rtl.def	16 Oct 2003 18:56:14 -0000
@@ -39,7 +39,7 @@ 02111-1307, USA.  */
    These names are stored in rtx_name[].
    By convention these are the internal (field 1) names in lower_case.
 
-   3.  The print format, and type of each rtx->fld[] (field) in this rtx.
+   3.  The print format, and type of each rtx->u.fld[] (field) in this rtx.
    These formats are stored in rtx_format[].
    The meaning of the formats is documented in front of this array in rtl.c
    
@@ -598,7 +598,7 @@ DEF_RTL_EXPR (ATTR_FLAG, "attr_flag", "s
    All formats must start with "iuu" to handle the chain.
    Each insn expression holds an rtl instruction and its semantics
    during back-end processing.
-   See macros's in "rtl.h" for the meaning of each rtx->fld[].
+   See macros's in "rtl.h" for the meaning of each rtx->u.fld[].
 
    ---------------------------------------------------------------------- */
 
@@ -606,14 +606,14 @@ DEF_RTL_EXPR (ATTR_FLAG, "attr_flag", "s
 DEF_RTL_EXPR(INSN, "insn", "iuuBieiee", 'i')
 
 /* An instruction that can possibly jump.
-   Fields ( rtx->fld[] ) have exact same meaning as INSN's.  */
+   Fields ( rtx->u.fld[] ) have exact same meaning as INSN's.  */
 DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "iuuBieiee0", 'i')
 
 /* An instruction that can possibly call a subroutine
    but which will not change which instruction comes next
    in the current function.
-   Field ( rtx->fld[9] ) is CALL_INSN_FUNCTION_USAGE.
-   All other fields ( rtx->fld[] ) have exact same meaning as INSN's.  */
+   Field ( rtx->u.fld[9] ) is CALL_INSN_FUNCTION_USAGE.
+   All other fields ( rtx->u.fld[] ) have exact same meaning as INSN's.  */
 DEF_RTL_EXPR(CALL_INSN, "call_insn", "iuuBieieee", 'i')
 
 /* A marker that indicates that control will not flow through.  */
Index: ggc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc.h,v
retrieving revision 1.57
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.57 ggc.h
--- ggc.h	5 Oct 2003 13:09:48 -0000	1.57
+++ ggc.h	16 Oct 2003 18:56:14 -0000
@@ -199,9 +199,7 @@ extern void *ggc_realloc (void *, size_t
 /* Like ggc_alloc_cleared, but performs a multiplication.  */
 extern void *ggc_calloc (size_t, size_t);
 
-#define ggc_alloc_rtx(NSLOTS)						  \
-  ((rtx) ggc_alloc (sizeof (struct rtx_def)				  \
-		    + ((NSLOTS) - 1) * sizeof (rtunion)))
+#define ggc_alloc_rtx(CODE) ((rtx) ggc_alloc (RTX_SIZE (CODE)))
 
 #define ggc_alloc_rtvec(NELT)						  \
   ((rtvec) ggc_alloc (sizeof (struct rtvec_def)				  \
Index: rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.c,v
retrieving revision 1.127
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.127 rtl.c
--- rtl.c	10 Oct 2003 20:33:05 -0000	1.127
+++ rtl.c	16 Oct 2003 18:56:14 -0000
@@ -96,6 +96,18 @@ #define DEF_RTL_EXPR(ENUM, NAME, FORMAT,
 #undef DEF_RTL_EXPR
 };
 
+/* Indexed by rtx code, gives the size of the rtx in bytes.  */
+
+const unsigned char rtx_size[NUM_RTX_CODE] = {
+#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)				\
+  ((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE			\
+   ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT)	\
+   : RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (rtunion)),
+
+#include "rtl.def"
+#undef DEF_RTL_EXPR
+};
+
 /* Names for kinds of NOTEs and REG_NOTEs.  */
 
 const char * const note_insn_name[NOTE_INSN_MAX - NOTE_INSN_BIAS] =
@@ -150,15 +162,14 @@ rtx
 rtx_alloc (RTX_CODE code)
 {
   rtx rt;
-  int n = GET_RTX_LENGTH (code);
 
-  rt = ggc_alloc_rtx (n);
+  rt = ggc_alloc_rtx (code);
 
   /* We want to clear everything up to the FLD array.  Normally, this
      is one int, but we don't want to assume that and it isn't very
      portable anyway; this is.  */
 
-  memset (rt, 0, sizeof (struct rtx_def) - sizeof (rtunion));
+  memset (rt, 0, RTX_HDR_SIZE);
   PUT_CODE (rt, code);
   return rt;
 }
@@ -218,7 +229,7 @@ copy_rtx (rtx orig)
      all fields need copying, and then clear the fields that should
      not be copied.  That is the sensible default behavior, and forces
      us to explicitly document why we are *not* copying a flag.  */
-  memcpy (copy, orig, sizeof (struct rtx_def) - sizeof (rtunion));
+  memcpy (copy, orig, RTX_HDR_SIZE);
 
   /* We do not copy the USED flag, which is used as a mark bit during
      walks over the RTL.  */
@@ -234,7 +245,7 @@ copy_rtx (rtx orig)
 
   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
     {
-      copy->fld[i] = orig->fld[i];
+      copy->u.fld[i] = orig->u.fld[i];
       switch (*format_ptr++)
 	{
 	case 'e':
@@ -276,13 +287,10 @@ copy_rtx (rtx orig)
 rtx
 shallow_copy_rtx (rtx orig)
 {
-  RTX_CODE code = GET_CODE (orig);
-  size_t n = GET_RTX_LENGTH (code);
-  rtx copy = ggc_alloc_rtx (n);
-
-  memcpy (copy, orig,
-	  sizeof (struct rtx_def) + sizeof (rtunion) * (n - 1));
+  rtx copy;
 
+  copy = ggc_alloc_rtx (GET_CODE (orig));
+  memcpy (copy, orig, RTX_SIZE (GET_CODE (orig)));
   return copy;
 }
 
Index: integrate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/integrate.c,v
retrieving revision 1.237
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.237 integrate.c
--- integrate.c	22 Sep 2003 05:09:12 -0000	1.237
+++ integrate.c	16 Oct 2003 18:56:18 -0000
@@ -2338,8 +2338,7 @@ copy_rtx_and_substitute (rtx orig, struc
       switch (*format_ptr++)
 	{
 	case '0':
-	  /* Copy this through the wide int field; that's safest.  */
-	  X0WINT (copy, i) = X0WINT (orig, i);
+	  X0ANY (copy, i) = X0ANY (orig, i);
 	  break;
 
 	case 'e':
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.350
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.350 emit-rtl.c
--- emit-rtl.c	11 Sep 2003 21:40:41 -0000	1.350
+++ emit-rtl.c	16 Oct 2003 18:56:16 -0000
@@ -2629,8 +2629,7 @@ copy_most_rtx (rtx orig, rtx may_share)
 	  break;
 
 	case '0':
-	  /* Copy this through the wide int field; that's safest.  */
-	  X0WINT (copy, i) = X0WINT (orig, i);
+	  X0ANY (copy, i) = X0ANY (orig, i);
 	  break;
 
 	default:
@@ -2717,9 +2716,7 @@ copy_rtx_if_shared (rtx orig)
       rtx copy;
 
       copy = rtx_alloc (code);
-      memcpy (copy, x,
-	     (sizeof (*copy) - sizeof (copy->fld)
-	      + sizeof (copy->fld[0]) * GET_RTX_LENGTH (code)));
+      memcpy (copy, x, RTX_SIZE (code));
       x = copy;
       copied = 1;
     }
@@ -5110,7 +5107,7 @@ copy_insn_1 (rtx orig)
      all fields need copying, and then clear the fields that should
      not be copied.  That is the sensible default behavior, and forces
      us to explicitly document why we are *not* copying a flag.  */
-  memcpy (copy, orig, sizeof (struct rtx_def) - sizeof (rtunion));
+  memcpy (copy, orig, RTX_HDR_SIZE);
 
   /* We do not copy the USED flag, which is used as a mark bit during
      walks over the RTL.  */
@@ -5128,7 +5125,7 @@ copy_insn_1 (rtx orig)
 
   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
     {
-      copy->fld[i] = orig->fld[i];
+      copy->u.fld[i] = orig->u.fld[i];
       switch (*format_ptr++)
 	{
 	case 'e':
Index: gengenrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengenrtl.c,v
retrieving revision 1.65
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.65 gengenrtl.c
--- gengenrtl.c	11 Oct 2003 00:18:02 -0000	1.65
+++ gengenrtl.c	16 Oct 2003 18:56:16 -0000
@@ -268,9 +268,9 @@ gendef (const char *format)
      the memory and initializes it.  */
   puts ("{");
   puts ("  rtx rt;");
-  printf ("  rt = ggc_alloc_rtx (%d);\n", (int) strlen (format));
+  puts ("  rt = ggc_alloc_rtx (code);\n");
 
-  puts ("  memset (rt, 0, sizeof (struct rtx_def) - sizeof (rtunion));\n");
+  puts ("  memset (rt, 0, RTX_HDR_SIZE);\n");
   puts ("  PUT_CODE (rt, code);");
   puts ("  PUT_MODE (rt, mode);");
 
Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.39
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.39 gengtype.c
--- gengtype.c	14 Aug 2003 03:10:49 -0000	1.39
+++ gengtype.c	16 Oct 2003 18:56:16 -0000
@@ -371,7 +371,7 @@ write_rtx_next (void)
       oprintf (f, "  0,\n");
     else
       oprintf (f,
-	       "  offsetof (struct rtx_def, fld) + %d * sizeof (rtunion),\n",
+	       "  RTX_HDR_SIZE + %d * sizeof (rtunion),\n",
 	       rtx_next_new[i]);
   oprintf (f, "};\n");
 }
@@ -395,10 +395,10 @@ #define DEF_RTL_EXPR(ENUM, NAME, FORMAT,
 #undef DEF_RTL_EXPR
   };
 
-  if (t->kind != TYPE_ARRAY)
+  if (t->kind != TYPE_UNION)
     {
       error_at_line (&lexer_line,
-		     "special `rtx_def' must be applied to an array");
+		     "special `rtx_def' must be applied to a union");
       return &string_type;
     }
 
@@ -578,7 +578,7 @@ #define DEF_RTL_EXPR(ENUM, NAME, FORMAT,
 	  subfields = xmalloc (sizeof (*subfields));
 	  subfields->next = old_subf;
 	  subfields->type = t;
-	  subfields->name = xasprintf ("[%lu].%s", (unsigned long)aindex,
+	  subfields->name = xasprintf (".fld[%lu].%s", (unsigned long)aindex,
 				       subname);
 	  subfields->line.file = __FILE__;
 	  subfields->line.line = __LINE__;
Index: ggc-page.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-page.c,v
retrieving revision 1.77
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.77 ggc-page.c
--- ggc-page.c	5 Oct 2003 13:09:48 -0000	1.77
+++ ggc-page.c	16 Oct 2003 18:56:17 -0000
@@ -171,7 +171,7 @@ #define OFFSET_TO_BIT(OFFSET, ORDER) \
 #define NUM_EXTRA_ORDERS ARRAY_SIZE (extra_order_size_table)
 
 #define RTL_SIZE(NSLOTS) \
-  (sizeof (struct rtx_def) + ((NSLOTS) - 1) * sizeof (rtunion))
+  (RTX_HDR_SIZE + (NSLOTS) * sizeof (rtunion))
 
 #define TREE_EXP_SIZE(OPS) \
   (sizeof (struct tree_exp) + ((OPS) - 1) * sizeof (tree))
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.406
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.406 reload1.c
--- reload1.c	19 Jul 2003 14:47:13 -0000	1.406
+++ reload1.c	16 Oct 2003 18:56:20 -0000
@@ -2570,9 +2570,7 @@ eliminate_regs (rtx x, enum machine_mode
 	  if (new != XEXP (x, i) && ! copied)
 	    {
 	      rtx new_x = rtx_alloc (code);
-	      memcpy (new_x, x,
-		      (sizeof (*new_x) - sizeof (new_x->fld)
-		       + sizeof (new_x->fld[0]) * GET_RTX_LENGTH (code)));
+	      memcpy (new_x, x, RTX_SIZE (code));
 	      x = new_x;
 	      copied = 1;
 	    }
@@ -2591,10 +2589,7 @@ eliminate_regs (rtx x, enum machine_mode
 		  if (! copied)
 		    {
 		      rtx new_x = rtx_alloc (code);
-		      memcpy (new_x, x,
-			      (sizeof (*new_x) - sizeof (new_x->fld)
-			       + (sizeof (new_x->fld[0])
-				  * GET_RTX_LENGTH (code))));
+		      memcpy (new_x, x, RTX_SIZE (code));
 		      x = new_x;
 		      copied = 1;
 		    }
Index: rtlanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
retrieving revision 1.168
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.168 rtlanal.c
--- rtlanal.c	24 Aug 2003 09:02:32 -0000	1.168
+++ rtlanal.c	16 Oct 2003 18:56:21 -0000
@@ -3167,7 +3167,7 @@ loc_mentioned_in_p (rtx *loc, rtx in)
 
   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
     {
-      if (loc == &in->fld[i].rtx)
+      if (loc == &in->u.fld[i].rtx)
 	return 1;
       if (fmt[i] == 'e')
 	{
Index: gdbinit.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gdbinit.in,v
retrieving revision 1.4
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.4 gdbinit.in
--- gdbinit.in	28 Apr 2003 21:24:06 -0000	1.4
+++ gdbinit.in	16 Oct 2003 18:56:21 -0000
@@ -79,7 +79,7 @@ Print the rtx-code and machine mode of t
 end
 
 define pi
-print $.fld[0].rtx@7
+print $.u.fld[0].rtx@7
 end
 
 document pi


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