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]

MD-only RTL out of compiler (2/2) substantive change


This patch causes all RTX codes that are only used in machine
descriptions to be excluded from rtl.def when building the compiler
proper.  As previously discussed, this is good for a 6-10KB reduction
in the size of the compiler binaries.

There's not much to the change - all I had to do was add an #ifdef
GENERATOR_FILE around the appropriate section of rtl.def.  The only
fallout was in gengtype.c, which needed to examine rtl.def and
insn-notes.def directly rather than rely on rtl.def.  A nice side
effect is that the generated gtype-desc.c now uses the enumeration
constants to refer to insn note code numbers, not integer literals.

Bootstrapped powerpc64-linux.

zw

        * rtl.def: Wrap MD-only codes in #ifdef GENERATOR_FILE.
        * gengtype.c: Don't include rtl.h.  Define enum rtx_code and
        rtx_name, rtx_format arrays by direct reference to rtl.def,
        first undefining GENERATOR_FILE.  Define enum insn_note and
        note_insn_name array by direct reference to insn-notes.def.
        (adjust_field_rtx_def): Remove local definition of rtx_name.
        Use symbolic names for insn notes.
        * Makefile.in (gengtype.o): Update dependencies.

===================================================================
Index: rtl.def
--- rtl.def	24 Aug 2004 16:49:54 -0000	1.92
+++ rtl.def	24 Aug 2004 16:55:04 -0000
@@ -685,6 +685,7 @@ DEF_RTL_EXPR(VAR_LOCATION, "var_location
 
 /* All expressions from this point forward appear only in machine
    descriptions.  */
+#ifdef GENERATOR_FILE
 
 /* Include a secondary machine-description file at this point.  */
 DEF_RTL_EXPR(INCLUDE, "include", "s", RTX_EXTRA)
@@ -1160,6 +1161,7 @@ DEF_RTL_EXPR (ATTR_FLAG, "attr_flag", "s
    true, the second operand will be used as the value of the conditional.  */
 DEF_RTL_EXPR(COND, "cond", "Ee", RTX_EXTRA)
 
+#endif /* GENERATOR_FILE */
 
 /*
 Local variables:
===================================================================
Index: gengtype.c
--- gengtype.c	18 Aug 2004 01:58:13 -0000	1.63
+++ gengtype.c	24 Aug 2004 16:55:04 -0000
@@ -24,7 +24,6 @@ Software Foundation, 59 Temple Place - S
 #include "tm.h"
 #include "gengtype.h"
 #include "gtyp-gen.h"
-#include "rtl.h"
 #undef abort
 
 /* Nonzero iff an error has occurred.  */
@@ -332,9 +331,25 @@ note_variable (const char *s, type_p t, 
   variables = n;
 }
 
-/* We really don't care how long a CONST_DOUBLE is.  */
+/* We don't care how long a CONST_DOUBLE is.  */
 #define CONST_DOUBLE_FORMAT "ww"
-const char * const rtx_format[NUM_RTX_CODE] = {
+/* We don't want to see codes that are only for generator files.  */
+#undef GENERATOR_FILE
+
+enum rtx_code {
+#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) ENUM ,
+#include "rtl.def"
+#undef DEF_RTL_EXPR
+  NUM_RTX_CODE
+};
+
+static const char * const rtx_name[NUM_RTX_CODE] = {
+#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   NAME ,
+#include "rtl.def"
+#undef DEF_RTL_EXPR
+};
+
+static const char * const rtx_format[NUM_RTX_CODE] = {
 #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   FORMAT ,
 #include "rtl.def"
 #undef DEF_RTL_EXPR
@@ -342,6 +357,25 @@ const char * const rtx_format[NUM_RTX_CO
 
 static int rtx_next_new[NUM_RTX_CODE];
 
+/* We also need codes and names for insn notes (not register notes).
+   Note that we do *not* bias the note values here.  */
+enum insn_note {
+#define DEF_INSN_NOTE(NAME) NAME,
+#include "insn-notes.def"
+#undef DEF_INSN_NOTE
+
+  NOTE_INSN_MAX
+};
+
+static const char *const note_insn_name[NOTE_INSN_MAX] = {
+#define DEF_INSN_NOTE(NAME) #NAME,
+#include "insn-notes.def"
+#undef DEF_INSN_NOTE
+};
+
+#undef CONST_DOUBLE_FORMAT
+#define GENERATOR_FILE
+
 /* Generate the contents of the rtx_next array.  This really doesn't belong
    in gengtype at all, but it's needed for adjust_field_rtx_def.  */
 
@@ -397,12 +431,6 @@ adjust_field_rtx_def (type_p t, options_
   type_p rtx_tp, rtvec_tp, tree_tp, mem_attrs_tp, note_union_tp, scalar_tp;
   type_p bitmap_tp, basic_block_tp, reg_attrs_tp;
 
-  static const char * const rtx_name[NUM_RTX_CODE] = {
-#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS)   NAME ,
-#include "rtl.def"
-#undef DEF_RTL_EXPR
-  };
-
   if (t->kind != TYPE_UNION)
     {
       error_at_line (&lexer_line,
@@ -428,7 +456,7 @@ adjust_field_rtx_def (type_p t, options_
     pair_p note_flds = NULL;
     int c;
 
-    for (c = NOTE_INSN_BIAS; c <= NOTE_INSN_MAX; c++)
+    for (c = 0; c <= NOTE_INSN_MAX; c++)
       {
 	pair_p old_note_flds = note_flds;
 
@@ -438,7 +466,7 @@ adjust_field_rtx_def (type_p t, options_
 	note_flds->opt = XNEW (struct options);
 	note_flds->opt->next = nodot;
 	note_flds->opt->name = "tag";
-	note_flds->opt->info = xasprintf ("%d", c);
+	note_flds->opt->info = note_insn_name[c];
 	note_flds->next = old_note_flds;
 
 	switch (c)
===================================================================
Index: Makefile.in
--- Makefile.in	24 Aug 2004 08:52:32 -0000	1.1357
+++ Makefile.in	24 Aug 2004 16:55:04 -0000
@@ -2566,8 +2566,8 @@ gengtype$(build_exeext) : gengtype.o gen
 	$(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \
 	 gengtype.o gengtype-lex.o gengtype-yacc.o $(BUILD_LIBS)
 
-gengtype.o : gengtype.c gengtype.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) \
-  real.h $(RTL_BASE_H) gtyp-gen.h
+gengtype.o : gengtype.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) \
+  gengtype.h gtyp-gen.h rtl.def insn-notes.def
 
 gengtype-lex.o : gengtype-lex.c gengtype.h gengtype-yacc.h \
   $(BCONFIG_H) coretypes.h $(GTM_H) $(SYSTEM_H) vec.h

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