Patchwork Fix Ada bootstrap (PR 54092)

login
register
mail settings
Submitter Richard Henderson
Date July 25, 2012, 3:20 p.m.
Message ID <50100EB1.1020806@redhat.com>
Download mbox | patch
Permalink /patch/173199/
State New
Headers show

Comments

Richard Henderson - July 25, 2012, 3:20 p.m.
That's what I get for assuming front-ends don't touch back-end things
like optabs and libcalls...

I'm reasonably certain that a better solution would be to move the
set_stack_check_libfunc declaration elsewhere and/or totally rearrange
that specific interface: c.f. lang_hooks.eh_protect_cleanup_actions.

That said, there's no practical benefit to using actual enums in this
hash table.  (Indeed, now that I think about it, it might even be better
to use the same sort of packed encoding used for raw_optab_handler; not
done here in this patch.)  Which lets us lose the dependency on optabs.h,
which has an implicit dependency on rtl.h.  Which is where we got into
trouble with the Ada front end.

Tested on x86_64-linux and committed.


r~
PR bootstrap/54092
	* libfuncs.h: Don't include optabs.h.
	(struct libfunc_entry): Use "int" for op, mode1, mode2 members.
	* optabs.c (hash_libfunc): Don't cast members to int.
	* Makefile.in (LIBFUNCS_H): Don't include OPTABS_H.
Steven Bosscher - July 25, 2012, 4:21 p.m.
On Wed, Jul 25, 2012 at 5:20 PM, Richard Henderson <rth@redhat.com> wrote:
> That's what I get for assuming front-ends don't touch back-end things
> like optabs and libcalls...

That is _almost_ the case. In fact, this is one of the last problems...

$ egrep "\"optabs\.h|\"libfuncs\.h|\"expr\.h|\"rtl|\"recog|\"basic-block|\"expmed|\"ira\.h|\"output\.h|"
c/*.{c,h} {c-family,java,fortran}/*.{c,h,def,opt}
{cp,objc,objc}/*.{c,h,def} lto/*.{c,h,opt} go/*.{c,cc,h} ada/*.adb
ada/gcc-interface/*.{c,h,def,opt}
c-family/c-cppbuiltin.c:#include "output.h"             /* For
user_label_prefix.  */
java/builtins.c:#include "rtl.h"
java/builtins.c:#include "expr.h"
java/builtins.c:#include "optabs.h"
java/class.c:#include "output.h" /* for switch_to_section and get_section */
go/go-backend.c:#include "rtl.h"
go/go-backend.c:#include "output.h"     /* for assemble_string */
ada/gcc-interface/trans.c:#include "output.h"
ada/gcc-interface/trans.c:#include "libfuncs.h" /* For
set_stack_check_libfunc.  */
ada/gcc-interface/utils.c:#include "output.h"

Ciao!
Steven

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 40f7c4d..d7b8a76 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -971,7 +971,7 @@  GCC_PLUGIN_H = gcc-plugin.h highlev-plugin-common.h plugin.def \
 		$(CONFIG_H) $(SYSTEM_H) $(HASHTAB_H)
 PLUGIN_H = plugin.h $(GCC_PLUGIN_H)
 PLUGIN_VERSION_H = plugin-version.h configargs.h
-LIBFUNCS_H = libfuncs.h $(HASHTAB_H) $(OPTABS_H)
+LIBFUNCS_H = libfuncs.h $(HASHTAB_H)
 
 #
 # Now figure out from those variables how to compile and link.
diff --git a/gcc/libfuncs.h b/gcc/libfuncs.h
index 75f7a69..262e10f 100644
--- a/gcc/libfuncs.h
+++ b/gcc/libfuncs.h
@@ -1,5 +1,5 @@ 
 /* Definitions for code generation pass of GNU compiler.
-   Copyright (C) 2001, 2004, 2007, 2008, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2001-2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -21,7 +21,6 @@  along with GCC; see the file COPYING3.  If not see
 #define GCC_LIBFUNCS_H
 
 #include "hashtab.h"
-#include "optabs.h"
 
 /* Enumeration of indexes into libfunc_table.  */
 enum libfunc_index
@@ -48,12 +47,16 @@  enum libfunc_index
   LTI_MAX
 };
 
-/* Information about an optab-related libfunc.  We use the same hashtable
-   for normal optabs and conversion optabs.  In the first case mode2
-   is unused.  */
+/* Information about an optab-related libfunc.  The op field is logically
+   an enum optab_d, and the mode fields are logically enum machine_mode.
+   However, in the absence of forward-declared enums, there's no practical
+   benefit of pulling in the defining headers.
+
+   We use the same hashtable for normal optabs and conversion optabs.  In
+   the first case mode2 is forced to VOIDmode.  */
+
 struct GTY(()) libfunc_entry {
-  optab op;
-  enum machine_mode mode1, mode2;
+  int op, mode1, mode2;
   rtx libfunc;
 };
 
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 022adfa..462aa7c 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -75,7 +75,7 @@  static hashval_t
 hash_libfunc (const void *p)
 {
   const struct libfunc_entry *const e = (const struct libfunc_entry *) p;
-  return (((int) e->mode1 + (int) e->mode2 * NUM_MACHINE_MODES) ^ e->op);
+  return ((e->mode1 + e->mode2 * NUM_MACHINE_MODES) ^ e->op);
 }
 
 /* Used for libfunc_hash.  */