public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [ARM] [3/3] Implement TARGET_BUILTIN_DECL
@ 2010-10-11  7:44 Jie Zhang
  2011-04-18 14:19 ` Richard Earnshaw
  0 siblings, 1 reply; 3+ messages in thread
From: Jie Zhang @ 2010-10-11  7:44 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

This patch implements TARGET_BUILTIN_DECL for ARM. With the changes of 
the previous two patches, this one is straightforward.

Is it OK?

-- 
Jie Zhang
CodeSourcery

[-- Attachment #2: gcc-arm-target-builtin-decl.diff --]
[-- Type: text/x-patch, Size: 3829 bytes --]


	* 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 *

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

end of thread, other threads:[~2011-04-22  4:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-11  7:44 [ARM] [3/3] Implement TARGET_BUILTIN_DECL Jie Zhang
2011-04-18 14:19 ` Richard Earnshaw
2011-04-22  8:52   ` Jie Zhang

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).