Patchwork [AArch64] Add support for TARGET_BUILTIN_DECL

login
register
mail settings
Submitter James Greenhalgh
Date Nov. 21, 2012, 3:05 p.m.
Message ID <1353510307-28459-1-git-send-email-james.greenhalgh@arm.com>
Download mbox | patch
Permalink /patch/200791/
State New
Headers show

Comments

James Greenhalgh - Nov. 21, 2012, 3:05 p.m.
Hi,

This patch wires up support for TARGET_BUILTIN_DECL in the AArch64
backend.

Is this OK to commit?

Thanks,
James Greenhalgh

---
gcc/

2012-11-21  James Greenhalgh  <james.greenhalgh@arm.com>

	* config/aarch64/aarch64-builtins.c (aarch64_builtin_decls): New.
	(aarch64_init_simd_builtins): Store declaration after builtin
	initialisation.
	(aarch64_builtin_decl): New.
	* config/aarch64/aarch64-protos.h (aarch64_builtin_decl): New.
	* config/aarch64/aarch64.c (TARGET_BUILTIN_DECL): Define.
Marcus Shawcroft - Nov. 26, 2012, 12:31 p.m.
On 21/11/12 15:05, James Greenhalgh wrote:
>
> Hi,
>
> This patch wires up support for TARGET_BUILTIN_DECL in the AArch64
> backend.
>
> Is this OK to commit?
>
> Thanks,
> James Greenhalgh
>
> ---
> gcc/
>
> 2012-11-21  James Greenhalgh  <james.greenhalgh@arm.com>
>
> 	* config/aarch64/aarch64-builtins.c (aarch64_builtin_decls): New.
> 	(aarch64_init_simd_builtins): Store declaration after builtin
> 	initialisation.
> 	(aarch64_builtin_decl): New.
> 	* config/aarch64/aarch64-protos.h (aarch64_builtin_decl): New.
> 	* config/aarch64/aarch64.c (TARGET_BUILTIN_DECL): Define.
>

OK and please back port to ARM/aarch64-4.7-branch

Thanks
/Marcus

Patch

diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index 0ce57d3..2cdda0f 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -304,6 +304,8 @@  enum aarch64_builtins
 #undef VAR10
 #undef VAR11
 
+static GTY(()) tree aarch64_builtin_decls[AARCH64_BUILTIN_MAX];
+
 #define NUM_DREG_TYPES 6
 #define NUM_QREG_TYPES 6
 
@@ -611,6 +613,7 @@  aarch64_init_simd_builtins (void)
       };
       char namebuf[60];
       tree ftype = NULL;
+      tree fndecl = NULL;
       int is_load = 0;
       int is_store = 0;
 
@@ -951,8 +954,9 @@  aarch64_init_simd_builtins (void)
       snprintf (namebuf, sizeof (namebuf), "__builtin_aarch64_%s%s",
 		d->name, modenames[d->mode]);
 
-      add_builtin_function (namebuf, ftype, fcode, BUILT_IN_MD, NULL,
-			    NULL_TREE);
+      fndecl = add_builtin_function (namebuf, ftype, fcode, BUILT_IN_MD,
+				     NULL, NULL_TREE);
+      aarch64_builtin_decls[fcode] = fndecl;
     }
 }
 
@@ -963,6 +967,15 @@  aarch64_init_builtins (void)
     aarch64_init_simd_builtins ();
 }
 
+tree
+aarch64_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
+{
+  if (code >= AARCH64_BUILTIN_MAX)
+    return error_mark_node;
+
+  return aarch64_builtin_decls[code];
+}
+
 typedef enum
 {
   SIMD_ARG_COPY_TO_REG,
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index b5a32b3..ab84257 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -234,5 +234,6 @@  rtx aarch64_expand_builtin (tree exp,
 			    rtx subtarget ATTRIBUTE_UNUSED,
 			    enum machine_mode mode ATTRIBUTE_UNUSED,
 			    int ignore ATTRIBUTE_UNUSED);
+tree aarch64_builtin_decl (unsigned, bool ATTRIBUTE_UNUSED);
 
 #endif /* GCC_AARCH64_PROTOS_H */
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index d4708bf..6241ba5 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -6736,6 +6736,9 @@  aarch64_c_mode_for_suffix (char suffix)
 #undef TARGET_CLASS_MAX_NREGS
 #define TARGET_CLASS_MAX_NREGS aarch64_class_max_nregs
 
+#undef TARGET_BUILTIN_DECL
+#define TARGET_BUILTIN_DECL aarch64_builtin_decl
+
 #undef  TARGET_EXPAND_BUILTIN
 #define TARGET_EXPAND_BUILTIN aarch64_expand_builtin