Patchwork [committed] Implement TARGET_BUILTIN_DECL for MIPS

login
register
mail settings
Submitter Richard Sandiford
Date Sept. 26, 2010, 7:23 a.m.
Message ID <874oddc6id.fsf@firetop.home>
Download mbox | patch
Permalink /patch/65774/
State New
Headers show

Comments

Richard Sandiford - Sept. 26, 2010, 7:23 a.m.
Recent changes have brought to the fore the lack of TARGET_BUILTIN_DECL
for MIPS.  Tested on mips64octeon-linux-gnu and applied.

Richard


gcc/
	* config/mips/mips.c (mips_builtin_decls): Declare.
	(mips_init_builtins): Store function declarations in
	mips_builtin_decls.
	(mips_builtin_decl): New function.
	(TARGET_BUILTIN_DECL): Define.

Patch

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2010-09-26 08:05:58.000000000 +0100
+++ gcc/config/mips/mips.c	2010-09-26 08:15:01.000000000 +0100
@@ -13025,6 +13025,10 @@  static const struct mips_builtin_descrip
   DIRECT_NO_TARGET_BUILTIN (cache, MIPS_VOID_FTYPE_SI_CVPOINTER, cache)
 };
 
+/* Index I is the function declaration for mips_builtins[I], or null if the
+   function isn't defined on this target.  */
+static GTY(()) tree mips_builtin_decls[ARRAY_SIZE (mips_builtins)];
+
 /* MODE is a vector mode whose elements have type TYPE.  Return the type
    of the vector itself.  */
 
@@ -13141,12 +13145,23 @@  mips_init_builtins (void)
     {
       d = &mips_builtins[i];
       if (d->avail ())
-	add_builtin_function (d->name,
-			      mips_build_function_type (d->function_type),
-			      i, BUILT_IN_MD, NULL, NULL);
+	mips_builtin_decls[i]
+	  = add_builtin_function (d->name,
+				  mips_build_function_type (d->function_type),
+				  i, BUILT_IN_MD, NULL, NULL);
     }
 }
 
+/* Implement TARGET_BUILTIN_DECL.  */
+
+static tree
+mips_builtin_decl (unsigned int code, bool initialize_p ATTRIBUTE_UNUSED)
+{
+  if (code >= ARRAY_SIZE (mips_builtins))
+    return error_mark_node;
+  return mips_builtin_decls[code];
+}
+
 /* Take argument ARGNO from EXP's argument list and convert it into a
    form suitable for input operand OPNO of instruction ICODE.  Return the
    value.  */
@@ -16519,6 +16534,8 @@  #define TARGET_VECTORIZE_UNITS_PER_SIMD_
 
 #undef TARGET_INIT_BUILTINS
 #define TARGET_INIT_BUILTINS mips_init_builtins
+#undef TARGET_BUILTIN_DECL
+#define TARGET_BUILTIN_DECL mips_builtin_decl
 #undef TARGET_EXPAND_BUILTIN
 #define TARGET_EXPAND_BUILTIN mips_expand_builtin