Patchwork [C] Always use TRANSLATION_UNIT_DECL as context

login
register
mail settings
Submitter Steve Ellcey
Date Sept. 28, 2010, 8:07 p.m.
Message ID <1285704453.29933.46.camel@hpsje.cup.hp.com>
Download mbox | patch
Permalink /patch/66024/
State New
Headers show

Comments

Steve Ellcey - Sept. 28, 2010, 8:07 p.m.
On Tue, 2010-09-28 at 10:36 +0200, Richard Guenther wrote:
> On Mon, 27 Sep 2010, Steve Ellcey wrote:
> 
> > FYI: I am getting the gimple bytecode messages on my IA64 Linux and
> > HP-UX platforms as well when running the testsuite.
> > 
> > /proj/opensrc_nobackup/nightly2/src/trunk/gcc/testsuite/gcc.c-torture/compile/20000105-1.c:25:1: sorry, unimplemented: gimple bytecode streams do not support machine specific builtin functions on this target
> 
> Yep, that's a known issue now.  Really all targets with builtins
> need to implement targetm.builtin_decl for LTO to work for them.
> 
> Richard.

OK, I am testing the attached patch for IA64 to fix the builtin problem.

Steve Ellcey
sje@cup.hp.com
Richard Guenther - Sept. 29, 2010, 8:51 a.m.
On Tue, 28 Sep 2010, Steve Ellcey wrote:

> On Tue, 2010-09-28 at 10:36 +0200, Richard Guenther wrote:
> > On Mon, 27 Sep 2010, Steve Ellcey wrote:
> > 
> > > FYI: I am getting the gimple bytecode messages on my IA64 Linux and
> > > HP-UX platforms as well when running the testsuite.
> > > 
> > > /proj/opensrc_nobackup/nightly2/src/trunk/gcc/testsuite/gcc.c-torture/compile/20000105-1.c:25:1: sorry, unimplemented: gimple bytecode streams do not support machine specific builtin functions on this target
> > 
> > Yep, that's a known issue now.  Really all targets with builtins
> > need to implement targetm.builtin_decl for LTO to work for them.
> > 
> > Richard.
> 
> OK, I am testing the attached patch for IA64 to fix the builtin problem.

Thanks.  FYI I'm still poking at a solution that would avoid
the situation but I'll let folks some time to update their targets
to implememt that hook (we're in stage1 anyways).

Richard.

Patch

Index: config/ia64/ia64.c
===================================================================
--- config/ia64/ia64.c	(revision 164675)
+++ config/ia64/ia64.c	(working copy)
@@ -319,6 +319,7 @@  static void ia64_trampoline_init (rtx, t
 static void ia64_override_options_after_change (void);
 
 static void ia64_dwarf_handle_frame_unspec (const char *, rtx, int);
+static tree ia64_builtin_decl (unsigned, bool);
 
 /* Table of valid machine attributes.  */
 static const struct attribute_spec ia64_attribute_table[] =
@@ -344,6 +345,9 @@  static const struct attribute_spec ia64_
 #undef TARGET_EXPAND_BUILTIN
 #define TARGET_EXPAND_BUILTIN ia64_expand_builtin
 
+#undef TARGET_BUILTIN_DECL
+#define TARGET_BUILTIN_DECL ia64_builtin_decl
+
 #undef TARGET_ASM_BYTE_OP
 #define TARGET_ASM_BYTE_OP "\tdata1\t"
 #undef TARGET_ASM_ALIGNED_HI_OP
@@ -9999,14 +10003,18 @@  enum ia64_builtins
   IA64_BUILTIN_FABSQ,
   IA64_BUILTIN_FLUSHRS,
   IA64_BUILTIN_INFQ,
-  IA64_BUILTIN_HUGE_VALQ
+  IA64_BUILTIN_HUGE_VALQ,
+  IA64_BUILTIN_max
 };
 
+static GTY(()) tree ia64_builtins[(int) IA64_BUILTIN_max];
+
 void
 ia64_init_builtins (void)
 {
   tree fpreg_type;
   tree float80_type;
+  tree decl;
 
   /* The __fpreg type.  */
   fpreg_type = make_node (REAL_TYPE);
@@ -10023,7 +10031,7 @@  ia64_init_builtins (void)
   /* The __float128 type.  */
   if (!TARGET_HPUX)
     {
-      tree ftype, decl;
+      tree ftype;
       tree float128_type = make_node (REAL_TYPE);
 
       TYPE_PRECISION (float128_type) = 128;
@@ -10032,13 +10040,15 @@  ia64_init_builtins (void)
 
       /* TFmode support builtins.  */
       ftype = build_function_type (float128_type, void_list_node);
-      add_builtin_function ("__builtin_infq", ftype,
-			    IA64_BUILTIN_INFQ, BUILT_IN_MD,
-			    NULL, NULL_TREE);
-
-      add_builtin_function ("__builtin_huge_valq", ftype,
-			    IA64_BUILTIN_HUGE_VALQ, BUILT_IN_MD,
-			    NULL, NULL_TREE);
+      decl = add_builtin_function ("__builtin_infq", ftype,
+				   IA64_BUILTIN_INFQ, BUILT_IN_MD,
+				   NULL, NULL_TREE);
+      ia64_builtins[IA64_BUILTIN_INFQ] = decl;
+
+      decl = add_builtin_function ("__builtin_huge_valq", ftype,
+				   IA64_BUILTIN_HUGE_VALQ, BUILT_IN_MD,
+				   NULL, NULL_TREE);
+      ia64_builtins[IA64_BUILTIN_HUGE_VALQ] = decl;
 
       ftype = build_function_type_list (float128_type,
 					float128_type,
@@ -10047,6 +10057,7 @@  ia64_init_builtins (void)
 				   IA64_BUILTIN_FABSQ, BUILT_IN_MD,
 				   "__fabstf2", NULL_TREE);
       TREE_READONLY (decl) = 1;
+      ia64_builtins[IA64_BUILTIN_FABSQ] = decl;
 
       ftype = build_function_type_list (float128_type,
 					float128_type,
@@ -10056,6 +10067,7 @@  ia64_init_builtins (void)
 				   IA64_BUILTIN_COPYSIGNQ, BUILT_IN_MD,
 				   "__copysigntf3", NULL_TREE);
       TREE_READONLY (decl) = 1;
+      ia64_builtins[IA64_BUILTIN_COPYSIGNQ] = decl;
     }
   else
     /* Under HPUX, this is a synonym for "long double".  */
@@ -10073,13 +10085,15 @@  ia64_init_builtins (void)
   add_builtin_function ((name), (type), (code), BUILT_IN_MD,	\
 		       NULL, NULL_TREE)
 
-  def_builtin ("__builtin_ia64_bsp",
+  decl = def_builtin ("__builtin_ia64_bsp",
 	       build_function_type (ptr_type_node, void_list_node),
 	       IA64_BUILTIN_BSP);
+  ia64_builtins[IA64_BUILTIN_BSP] = decl;
 
-  def_builtin ("__builtin_ia64_flushrs",
+  decl = def_builtin ("__builtin_ia64_flushrs",
 	       build_function_type (void_type_node, void_list_node),
 	       IA64_BUILTIN_FLUSHRS);
+  ia64_builtins[IA64_BUILTIN_FLUSHRS] = decl;
 
 #undef def_builtin
 
@@ -10149,6 +10163,17 @@  ia64_expand_builtin (tree exp, rtx targe
   return NULL_RTX;
 }
 
+/* Return the ia64 builtin for CODE.  */
+
+static tree
+ia64_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
+{
+  if (code >= IA64_BUILTIN_max)
+    return error_mark_node;
+
+  return ia64_builtins[code];
+}
+
 /* For the HP-UX IA64 aggregate parameters are passed stored in the
    most significant bits of the stack slot.  */