public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Split insn-attr.h
@ 2011-06-28  2:00 Joseph S. Myers
  2011-06-28  2:46 ` Bernd Schmidt
  2011-07-25  2:10 ` Hans-Peter Nilsson
  0 siblings, 2 replies; 3+ messages in thread
From: Joseph S. Myers @ 2011-06-28  2:00 UTC (permalink / raw)
  To: gcc-patches

opts.c includes insn-attr.h to get the definitions of INSN_SCHEDULING
and DELAY_SLOTS, used to determine whether to enable certain options
by default at certain -O levels.  insn-attr.h in turn requires rtl.h
to have been included first (and rtl.h requires tm.h, although there
are other tm.h dependencies in opts.c as well).

Apart from being a modularity issue - option handling shouldn't care
about RTL - this is also a problem for linking opts.o into the driver,
because these headers, and others they include, contain various inline
functions that in turn call other out-of-line functions not available
in the driver (and the stage1 compiler is built with
-fkeep-inline-functions so this issue gets detected reliably then).

This patch splits the two required macros into a new generated header
insn-attr-common.h.  It follows the minimal approach of including this
header in insn-attr.h so that files including insn-attr.h don't need
to change, but it might make sense to clean things up in future with
explicit includes of insn-attr-common.h in those files testing either
of the affected macros, removing the insn-attr.h includes if no other
definitions from that header are used.  (In checking for such files -
there aren't that many - I also noticed that the target macro
DELAY_SLOTS_FOR_EPILOGUE is used and documented but not defined by any
target, so the code relating to that macro is ripe for removal and
poisoning of the macro.)

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  OK to
commit?

2011-06-27  Joseph Myers  <joseph@codesourcery.com>

	* genattr-common.c: New.  Based on genattr.c.
	* Makefile.in (INSN_ATTR_H): Include insn-attr-common.h.
	(MOSTLYCLEANFILES): Add insn-attr-common.h.
	(opts.o): Update dependencies.
	(.PRECIOUS): Add insn-attr-common.h.
	(simple_rtl_generated_h): Add insn-attr-common.h.
	(build/genattr-common.o): New.
	(genprogrtl): Add attr-common.
	* genattr.c (main): Include insn-attr-common.h.  Don't generate
	definitions of DELAY_SLOTS or INSN_SCHEDULING.
	* opts.c: Include insn-attr-common.h instead of rtl.h and
	insn-attr.h.

Index: gcc/genattr-common.c
===================================================================
--- gcc/genattr-common.c	(revision 0)
+++ gcc/genattr-common.c	(revision 0)
@@ -0,0 +1,83 @@
+/* Generate attribute information shared between driver and core
+   compilers (insn-attr-common.h) from machine description.  Split out
+   of genattr.c.
+   Copyright (C) 1991, 1994, 1996, 1998, 1999, 2000, 2003, 2004, 2007, 2008,
+   2010, 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/>.  */
+
+
+#include "bconfig.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rtl.h"
+#include "errors.h"
+#include "read-md.h"
+#include "gensupport.h"
+
+int
+main (int argc, char **argv)
+{
+  rtx desc;
+  bool have_delay = false;
+  bool have_sched = false;
+
+  progname = "genattr-common";
+
+  if (!init_rtx_reader_args (argc, argv))
+    return (FATAL_EXIT_CODE);
+
+  puts ("/* Generated automatically by the program `genattr-common'");
+  puts ("   from the machine description file `md'.  */\n");
+  puts ("#ifndef GCC_INSN_ATTR_COMMON_H");
+  puts ("#define GCC_INSN_ATTR_COMMON_H\n");
+
+  /* Read the machine description.  */
+
+  while (1)
+    {
+      int line_no, insn_code_number;
+
+      desc = read_md_rtx (&line_no, &insn_code_number);
+      if (desc == NULL)
+	break;
+
+      if (GET_CODE (desc) == DEFINE_DELAY)
+        {
+	  if (!have_delay)
+	    {
+	      printf ("#define DELAY_SLOTS\n");
+	      have_delay = true;
+	    }
+	}
+      else if (GET_CODE (desc) == DEFINE_INSN_RESERVATION)
+	{
+	  if (!have_sched)
+	    {
+	      printf ("#define INSN_SCHEDULING\n");
+	      have_sched = true;
+	    }
+	}
+    }
+  puts ("\n#endif /* GCC_INSN_ATTR_COMMON_H */");
+
+  if (ferror (stdout) || fflush (stdout) || fclose (stdout))
+    return FATAL_EXIT_CODE;
+
+  return SUCCESS_EXIT_CODE;
+}
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 175330)
+++ gcc/opts.c	(working copy)
@@ -23,17 +23,16 @@ along with GCC; see the file COPYING3.  
 #include "system.h"
 #include "intl.h"
 #include "coretypes.h"
-#include "tm.h" /* Needed by rtl.h and used for STACK_CHECK_BUILTIN,
+#include "tm.h" /* For STACK_CHECK_BUILTIN,
 		   STACK_CHECK_STATIC_BUILTIN, DEFAULT_GDB_EXTENSIONS,
 		   DWARF2_DEBUGGING_INFO and DBX_DEBUGGING_INFO.  */
-#include "rtl.h" /* Needed by insn-attr.h.  */
 #include "opts.h"
 #include "options.h"
 #include "flags.h"
 #include "params.h"
 #include "diagnostic.h"
 #include "opts-diagnostic.h"
-#include "insn-attr.h"		/* For INSN_SCHEDULING and DELAY_SLOTS.  */
+#include "insn-attr-common.h"
 #include "common/common-target.h"
 
 /* Parse the -femit-struct-debug-detailed option value
Index: gcc/genattr.c
===================================================================
--- gcc/genattr.c	(revision 175330)
+++ gcc/genattr.c	(working copy)
@@ -1,6 +1,6 @@
 /* Generate attribute information (insn-attr.h) from machine description.
    Copyright (C) 1991, 1994, 1996, 1998, 1999, 2000, 2003, 2004, 2007, 2008,
-   2010  Free Software Foundation, Inc.
+   2010, 2011  Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
 This file is part of GCC.
@@ -180,6 +180,8 @@ main (int argc, char **argv)
   puts ("#ifndef GCC_INSN_ATTR_H");
   puts ("#define GCC_INSN_ATTR_H\n");
 
+  puts ("#include \"insn-attr-common.h\"\n");
+
   /* For compatibility, define the attribute `alternative', which is just
      a reference to the variable `which_alternative'.  */
 
@@ -204,7 +206,6 @@ main (int argc, char **argv)
         {
 	  if (! have_delay)
 	    {
-	      printf ("#define DELAY_SLOTS\n");
 	      printf ("extern int num_delay_slots (rtx);\n");
 	      printf ("extern int eligible_for_delay (rtx, int, rtx, int);\n\n");
 	      printf ("extern int const_num_delay_slots (rtx);\n\n");
@@ -242,7 +243,6 @@ main (int argc, char **argv)
 	= find_tune_attr (XEXP (VEC_index (rtx, reservations, 0), 2));
       /* Output interface for pipeline hazards recognition based on
 	 DFA (deterministic finite state automata.  */
-      printf ("\n#define INSN_SCHEDULING\n");
       printf ("\n/* DFA based pipeline interface.  */");
       printf ("\n#ifndef AUTOMATON_ALTS\n");
       printf ("#define AUTOMATON_ALTS 0\n");
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 175330)
+++ gcc/Makefile.in	(working copy)
@@ -965,7 +965,7 @@ GCC_H = gcc.h version.h $(DIAGNOSTIC_COR
 GGC_H = ggc.h gtype-desc.h statistics.h
 GGC_INTERNAL_H = ggc-internal.h $(GGC_H)
 TIMEVAR_H = timevar.h timevar.def
-INSN_ATTR_H = insn-attr.h $(INSN_ADDR_H)
+INSN_ATTR_H = insn-attr.h insn-attr-common.h $(INSN_ADDR_H)
 INSN_ADDR_H = $(srcdir)/insn-addr.h vecprim.h
 C_COMMON_H = c-family/c-common.h c-family/c-common.def \
 	$(SPLAY_TREE_H) $(CPPLIB_H) $(GGC_H) $(DIAGNOSTIC_CORE_H)
@@ -1524,7 +1524,8 @@ BACKEND = main.o @TREEBROWSER@ libbacken
 
 MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
  insn-output.c insn-recog.c insn-emit.c insn-extract.c insn-peep.c \
- insn-attr.h insn-attrtab.c insn-opinit.c insn-preds.c insn-constants.h \
+ insn-attr.h insn-attr-common.h insn-attrtab.c insn-opinit.c \
+ insn-preds.c insn-constants.h \
  tm-preds.h tm-constrs.h checksum-options \
  tree-check.h min-insn-modes.c insn-modes.c insn-modes.h \
  genrtl.h gt-*.h gtype-*.h gtype-desc.c gtyp-input.list \
@@ -2848,8 +2849,8 @@ fold-const.o : fold-const.c $(CONFIG_H) 
 diagnostic.o : diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    version.h $(INPUT_H) intl.h $(DIAGNOSTIC_H) diagnostic.def
 opts.o : opts.c $(OPTS_H) $(OPTIONS_H) $(DIAGNOSTIC_CORE_H) $(CONFIG_H) $(SYSTEM_H) \
-   coretypes.h $(TM_H) $(RTL_H) \
-   $(DIAGNOSTIC_H) $(INSN_ATTR_H) intl.h $(COMMON_TARGET_H) \
+   coretypes.h $(TM_H) \
+   $(DIAGNOSTIC_H) insn-attr-common.h intl.h $(COMMON_TARGET_H) \
    $(FLAGS_H) $(PARAMS_H) opts-diagnostic.h
 opts-global.o : opts-global.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(DIAGNOSTIC_H) $(OPTS_H) $(FLAGS_H) $(GGC_H) $(TREE_H) langhooks.h \
@@ -3589,7 +3590,7 @@ mips-tdump.o : mips-tdump.c $(CONFIG_H) 
 
 .PRECIOUS: insn-config.h insn-flags.h insn-codes.h insn-constants.h \
   insn-emit.c insn-recog.c insn-extract.c insn-output.c insn-peep.c \
-  insn-attr.h insn-attrtab.c insn-preds.c
+  insn-attr.h insn-attr-common.h insn-attrtab.c insn-preds.c
 
 # Dependencies for the md file.  The first time through, we just assume
 # the md file itself and the generated dependency file (in order to get
@@ -3646,7 +3647,8 @@ insn-recog.o : insn-recog.c $(CONFIG_H) 
 # The "; @true" construct forces Make to recheck the timestamp on
 # the target file.
 
-simple_rtl_generated_h	= insn-attr.h insn-codes.h insn-config.h insn-flags.h
+simple_rtl_generated_h	= insn-attr.h insn-attr-common.h insn-codes.h \
+			  insn-config.h insn-flags.h
 
 simple_rtl_generated_c	= insn-attrtab.c insn-automata.c insn-emit.c \
 			  insn-extract.c insn-opinit.c insn-output.c \
@@ -3962,6 +3964,8 @@ build/gencondmd.o : \
 # ...these are the programs themselves.
 build/genattr.o : genattr.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
   coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
+build/genattr-common.o : genattr-common.c $(RTL_BASE_H) $(BCONFIG_H)	\
+  $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 build/genattrtab.o : genattrtab.c $(RTL_BASE_H) $(OBSTACK_H)		\
   $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(GGC_H)	\
   $(READ_MD_H) gensupport.h vecprim.h
@@ -4021,7 +4025,7 @@ build/genhooks.o : genhooks.c $(TARGET_D
 # even if GCC is being compiled to run on some other machine.
 
 # All these programs use the RTL reader ($(BUILD_RTL)).
-genprogrtl = attr attrtab automata codes conditions config emit \
+genprogrtl = attr attr-common attrtab automata codes conditions config emit \
 	     extract flags opinit output peep preds recog
 $(genprogrtl:%=build/gen%$(build_exeext)): $(BUILD_RTL)
 

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Split insn-attr.h
  2011-06-28  2:00 Split insn-attr.h Joseph S. Myers
@ 2011-06-28  2:46 ` Bernd Schmidt
  2011-07-25  2:10 ` Hans-Peter Nilsson
  1 sibling, 0 replies; 3+ messages in thread
From: Bernd Schmidt @ 2011-06-28  2:46 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches

On 06/28/11 02:24, Joseph S. Myers wrote:
> 
> 	* genattr-common.c: New.  Based on genattr.c.
> 	* Makefile.in (INSN_ATTR_H): Include insn-attr-common.h.
> 	(MOSTLYCLEANFILES): Add insn-attr-common.h.
> 	(opts.o): Update dependencies.
> 	(.PRECIOUS): Add insn-attr-common.h.
> 	(simple_rtl_generated_h): Add insn-attr-common.h.
> 	(build/genattr-common.o): New.
> 	(genprogrtl): Add attr-common.
> 	* genattr.c (main): Include insn-attr-common.h.  Don't generate
> 	definitions of DELAY_SLOTS or INSN_SCHEDULING.
> 	* opts.c: Include insn-attr-common.h instead of rtl.h and
> 	insn-attr.h.

Ok.


Bernd

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Split insn-attr.h
  2011-06-28  2:00 Split insn-attr.h Joseph S. Myers
  2011-06-28  2:46 ` Bernd Schmidt
@ 2011-07-25  2:10 ` Hans-Peter Nilsson
  1 sibling, 0 replies; 3+ messages in thread
From: Hans-Peter Nilsson @ 2011-07-25  2:10 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches

On Tue, 28 Jun 2011, Joseph S. Myers wrote:
> (In checking for such files -
> there aren't that many - I also noticed that the target macro
> DELAY_SLOTS_FOR_EPILOGUE is used and documented but not defined by any
> target, so the code relating to that macro is ripe for removal and
> poisoning of the macro.)

Now that you mention that, I recall that a patch to do that has
been preapproved by Jeff Law; there be bugs (IIRC) and it'd only
be useful with a text epilogue.  At the moment I blame a slow
and flaky internet connection...

brgds, H-P

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-24 22:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-28  2:00 Split insn-attr.h Joseph S. Myers
2011-06-28  2:46 ` Bernd Schmidt
2011-07-25  2:10 ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).