Patchwork [ARM,3/3] Implement TARGET_BUILTIN_DECL

login
register
mail settings
Submitter Jie Zhang
Date Oct. 11, 2010, 7:44 a.m.
Message ID <4CB2C054.5050408@codesourcery.com>
Download mbox | patch
Permalink /patch/67384/
State New
Headers show

Comments

Jie Zhang - Oct. 11, 2010, 7:44 a.m.
This patch implements TARGET_BUILTIN_DECL for ARM. With the changes of 
the previous two patches, this one is straightforward.

Is it OK?

Patch


	* config/arm/arm.c (arm_builtin_decl): Declare.
	(TARGET_BUILTIN_DECL): Define.
	(enum arm_builtins): Correct ARM_BUILTIN_MAX.
	(arm_builtin_decls[]): New.
	(arm_init_neon_builtins): Store builtin declarations in
	arm_builtin_decls[].
	(arm_init_iwmmxt_builtins): Likewise.
	(arm_init_tls_builtins): Likewise.
	(arm_builtin_decl): New.

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 432da46..c9d6a64 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -160,6 +160,7 @@  static rtx safe_vector_operand (rtx, enum machine_mode);
 static rtx arm_expand_binop_builtin (enum insn_code, tree, rtx);
 static rtx arm_expand_unop_builtin (enum insn_code, tree, rtx, int);
 static rtx arm_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
+static tree arm_builtin_decl (unsigned, bool);
 static void emit_constant_insn (rtx cond, rtx pattern);
 static rtx emit_set_insn (rtx, rtx);
 static int arm_arg_partial_bytes (CUMULATIVE_ARGS *, enum machine_mode,
@@ -391,6 +392,8 @@  static const struct attribute_spec arm_attribute_table[] =
 #define TARGET_INIT_BUILTINS  arm_init_builtins
 #undef  TARGET_EXPAND_BUILTIN
 #define TARGET_EXPAND_BUILTIN arm_expand_builtin
+#undef  TARGET_BUILTIN_DECL
+#define TARGET_BUILTIN_DECL arm_builtin_decl
 
 #undef TARGET_INIT_LIBFUNCS
 #define TARGET_INIT_LIBFUNCS arm_init_libfuncs
@@ -18009,14 +18012,16 @@  enum arm_builtins
 
   ARM_BUILTIN_NEON_BASE,
 
-  ARM_BUILTIN_MAX = ARM_BUILTIN_NEON_BASE  /* FIXME: Wrong!  */
+  ARM_BUILTIN_MAX = ARM_BUILTIN_NEON_BASE + ARRAY_SIZE (neon_builtin_data)
 };
 
+static GTY(()) tree arm_builtin_decls[ARM_BUILTIN_MAX];
 
 static void
 arm_init_neon_builtins (void)
 {
-  unsigned int i, fcode = ARM_BUILTIN_NEON_BASE;
+  unsigned int i, fcode;
+  tree decl;
 
   tree neon_intQI_type_node;
   tree neon_intHI_type_node;
@@ -18264,7 +18269,9 @@  arm_init_neon_builtins (void)
         }
     }
 
-  for (i = 0; i < ARRAY_SIZE (neon_builtin_data); i++)
+  for (i = 0, fcode = ARM_BUILTIN_NEON_BASE;
+       i < ARRAY_SIZE (neon_builtin_data);
+       i++, fcode++)
     {
       neon_builtin_datum *d = &neon_builtin_data[i];
       const char* const modenames[] = {
@@ -18496,8 +18503,9 @@  arm_init_neon_builtins (void)
 
       sprintf (namebuf, "__builtin_neon_%s%s", d->name, modenames[d->mode]);
 
-      add_builtin_function (namebuf, ftype, fcode++, BUILT_IN_MD, NULL,
-			    NULL_TREE);
+      decl = add_builtin_function (namebuf, ftype, fcode, BUILT_IN_MD, NULL,
+				   NULL_TREE);
+      arm_builtin_decls[fcode] = decl;
     }
 }
 
@@ -18505,8 +18513,11 @@  arm_init_neon_builtins (void)
   do									\
     {									\
       if ((MASK) & insn_flags)						\
-        add_builtin_function ((NAME), (TYPE), (CODE),			\
-			     BUILT_IN_MD, NULL, NULL_TREE);		\
+	{								\
+	  decl = add_builtin_function ((NAME), (TYPE), (CODE),		\
+				       BUILT_IN_MD, NULL, NULL_TREE);	\
+	  arm_builtin_decls[CODE] = decl;				\
+	}								\
     }									\
   while (0)
 
@@ -18652,6 +18663,7 @@  arm_init_iwmmxt_builtins (void)
 {
   const struct builtin_description * d;
   size_t i;
+  tree decl;
   tree endlink = void_list_node;
 
   tree V2SI_type_node = build_vector_type_for_mode (intSI_type_node, V2SImode);
@@ -18981,6 +18993,7 @@  arm_init_tls_builtins (void)
 			       NULL, NULL_TREE);
   TREE_NOTHROW (decl) = 1;
   TREE_READONLY (decl) = 1;
+  arm_builtin_decls[ARM_BUILTIN_THREAD_POINTER] = decl;
 }
 
 static void
@@ -19007,6 +19020,17 @@  arm_init_builtins (void)
     arm_init_fp16_builtins ();
 }
 
+/* Return the ARM builtin for CODE.  */
+
+static tree
+arm_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
+{
+  if (code >= ARM_BUILTIN_MAX)
+    return error_mark_node;
+
+  return arm_builtin_decls[code];
+}
+
 /* Implement TARGET_INVALID_PARAMETER_TYPE.  */
 
 static const char *