This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/4] [ARM] Add attribute/pragma target fpu=


This patch splits the neon_builtins initialization into 2 internals functions. One for NEON and one for CRYPTO, each one guarded by its own predicate. arm_init_neon_builtins is now global to be called from arm_valid_target_attribute_tree if needed.

 2015-09-14  Christian Bruel  <christian.bruel@st.com>
 
	PR target/65837
	* config/arm/arm-protos.h (arm_init_neon_builtins): Declare.
	* config/arm/arm.c (arm_valid_target_attribute_tree): Call
	arm_init_neon_builtins.
	* config/arm/arm-builtins.c (arm_init_neon_builtins): Split into...
	(arm_init_neon_builtins_internal)
	(arm_init_crypto_builtins_internal):
	Test and set neon_set_p, neon_crypto_set_p.
	(neon_set_p, neon_crypto_set_p): New static booleans.

diff -ruN gnu_trunk.p2/gcc/gcc/config/arm/arm-builtins.c gnu_trunk.p3/gcc/gcc/config/arm/arm-builtins.c
--- gnu_trunk.p2/gcc/gcc/config/arm/arm-builtins.c	2015-09-10 14:46:30.994448152 +0200
+++ gnu_trunk.p3/gcc/gcc/config/arm/arm-builtins.c	2015-09-11 16:48:51.420065488 +0200
@@ -901,7 +901,7 @@
 }
 
 static void
-arm_init_neon_builtins (void)
+arm_init_neon_builtins_internal (void)
 {
   unsigned int i, fcode = ARM_BUILTIN_NEON_PATTERN_START;
 
@@ -1022,87 +1022,105 @@
 				     NULL, NULL_TREE);
       arm_builtin_decls[fcode] = fndecl;
     }
+}
 
-  if (TARGET_CRYPTO && TARGET_HARD_FLOAT)
-    {
-      tree V16UQI_type_node = arm_simd_builtin_type (V16QImode,
-						       true,
-						       false);
-
-      tree V4USI_type_node = arm_simd_builtin_type (V4SImode,
-						      true,
-						      false);
+void
+arm_init_crypto_builtins_internal (void)
+{
+  tree V16UQI_type_node
+    = arm_simd_builtin_type (V16QImode, true, false);
 
-      tree v16uqi_ftype_v16uqi
-	= build_function_type_list (V16UQI_type_node, V16UQI_type_node,
-				    NULL_TREE);
+  tree V4USI_type_node
+    = arm_simd_builtin_type (V4SImode, true, false);
+
+  tree v16uqi_ftype_v16uqi
+    = build_function_type_list (V16UQI_type_node, V16UQI_type_node,
+				NULL_TREE);
 
-      tree v16uqi_ftype_v16uqi_v16uqi
+  tree v16uqi_ftype_v16uqi_v16uqi
 	= build_function_type_list (V16UQI_type_node, V16UQI_type_node,
 				    V16UQI_type_node, NULL_TREE);
 
-      tree v4usi_ftype_v4usi
-	= build_function_type_list (V4USI_type_node, V4USI_type_node,
-				    NULL_TREE);
-
-      tree v4usi_ftype_v4usi_v4usi
-	= build_function_type_list (V4USI_type_node, V4USI_type_node,
-				    V4USI_type_node, NULL_TREE);
-
-      tree v4usi_ftype_v4usi_v4usi_v4usi
-	= build_function_type_list (V4USI_type_node, V4USI_type_node,
-				    V4USI_type_node, V4USI_type_node,
-				    NULL_TREE);
-
-      tree uti_ftype_udi_udi
-	= build_function_type_list (unsigned_intTI_type_node,
-				    unsigned_intDI_type_node,
-				    unsigned_intDI_type_node,
-				    NULL_TREE);
-
-      #undef CRYPTO1
-      #undef CRYPTO2
-      #undef CRYPTO3
-      #undef C
-      #undef N
-      #undef CF
-      #undef FT1
-      #undef FT2
-      #undef FT3
-
-      #define C(U) \
-	ARM_BUILTIN_CRYPTO_##U
-      #define N(L) \
-	"__builtin_arm_crypto_"#L
-      #define FT1(R, A) \
-	R##_ftype_##A
-      #define FT2(R, A1, A2) \
-	R##_ftype_##A1##_##A2
-      #define FT3(R, A1, A2, A3) \
-        R##_ftype_##A1##_##A2##_##A3
-      #define CRYPTO1(L, U, R, A) \
-	arm_builtin_decls[C (U)] \
-	  = add_builtin_function (N (L), FT1 (R, A), \
-				  C (U), BUILT_IN_MD, NULL, NULL_TREE);
-      #define CRYPTO2(L, U, R, A1, A2)  \
-	arm_builtin_decls[C (U)]	\
-	  = add_builtin_function (N (L), FT2 (R, A1, A2), \
+  tree v4usi_ftype_v4usi
+    = build_function_type_list (V4USI_type_node, V4USI_type_node,
+				NULL_TREE);
+
+  tree v4usi_ftype_v4usi_v4usi
+    = build_function_type_list (V4USI_type_node, V4USI_type_node,
+				V4USI_type_node, NULL_TREE);
+
+  tree v4usi_ftype_v4usi_v4usi_v4usi
+    = build_function_type_list (V4USI_type_node, V4USI_type_node,
+				V4USI_type_node, V4USI_type_node,
+				NULL_TREE);
+
+  tree uti_ftype_udi_udi
+    = build_function_type_list (unsigned_intTI_type_node,
+				unsigned_intDI_type_node,
+				unsigned_intDI_type_node,
+				NULL_TREE);
+
+  #undef CRYPTO1
+  #undef CRYPTO2
+  #undef CRYPTO3
+  #undef C
+  #undef N
+  #undef CF
+  #undef FT1
+  #undef FT2
+  #undef FT3
+
+  #define C(U) \
+    ARM_BUILTIN_CRYPTO_##U
+  #define N(L) \
+    "__builtin_arm_crypto_"#L
+  #define FT1(R, A) \
+    R##_ftype_##A
+  #define FT2(R, A1, A2) \
+    R##_ftype_##A1##_##A2
+  #define FT3(R, A1, A2, A3) \
+    R##_ftype_##A1##_##A2##_##A3
+  #define CRYPTO1(L, U, R, A) \
+    arm_builtin_decls[C (U)] \
+      = add_builtin_function (N (L), FT1 (R, A), \
+		  C (U), BUILT_IN_MD, NULL, NULL_TREE);
+  #define CRYPTO2(L, U, R, A1, A2)  \
+    arm_builtin_decls[C (U)]	\
+      = add_builtin_function (N (L), FT2 (R, A1, A2), \
+		  C (U), BUILT_IN_MD, NULL, NULL_TREE);
+
+  #define CRYPTO3(L, U, R, A1, A2, A3) \
+    arm_builtin_decls[C (U)]	   \
+      = add_builtin_function (N (L), FT3 (R, A1, A2, A3), \
 				  C (U), BUILT_IN_MD, NULL, NULL_TREE);
+  #include "crypto.def"
 
-      #define CRYPTO3(L, U, R, A1, A2, A3) \
-	arm_builtin_decls[C (U)]	   \
-	  = add_builtin_function (N (L), FT3 (R, A1, A2, A3), \
-				  C (U), BUILT_IN_MD, NULL, NULL_TREE);
-      #include "crypto.def"
+  #undef CRYPTO1
+  #undef CRYPTO2
+  #undef CRYPTO3
+  #undef C
+  #undef N
+  #undef FT1
+  #undef FT2
+  #undef FT3
+}
+
+static bool neon_set_p = false;
+static bool neon_crypto_set_p = false;
+
+void
+arm_init_neon_builtins (void)
+{
+  if (! neon_set_p)
+    {
+      arm_init_neon_builtins_internal ();
+      neon_set_p = true;
+    }
 
-      #undef CRYPTO1
-      #undef CRYPTO2
-      #undef CRYPTO3
-      #undef C
-      #undef N
-      #undef FT1
-      #undef FT2
-      #undef FT3
+  if (!neon_crypto_set_p && TARGET_CRYPTO && TARGET_HARD_FLOAT)
+    {
+      arm_init_crypto_builtins_internal ();
+      neon_crypto_set_p = true;
     }
 }
 
diff -ruN gnu_trunk.p2/gcc/gcc/config/arm/arm.c gnu_trunk.p3/gcc/gcc/config/arm/arm.c
--- gnu_trunk.p2/gcc/gcc/config/arm/arm.c	2015-09-11 15:28:59.937357745 +0200
+++ gnu_trunk.p3/gcc/gcc/config/arm/arm.c	2015-09-11 16:26:33.869000746 +0200
@@ -29556,6 +29556,9 @@
   /* Do any overrides, such as global options arch=xxx.  */
   arm_option_override_internal (opts, opts_set);
 
+  if (TARGET_NEON)
+    arm_init_neon_builtins ();
+
   return build_target_option_node (opts);
 }
 
diff -ruN gnu_trunk.p2/gcc/gcc/config/arm/arm-protos.h gnu_trunk.p3/gcc/gcc/config/arm/arm-protos.h
--- gnu_trunk.p2/gcc/gcc/config/arm/arm-protos.h	2015-09-11 15:23:51.852687891 +0200
+++ gnu_trunk.p3/gcc/gcc/config/arm/arm-protos.h	2015-09-11 16:30:15.833511559 +0200
@@ -213,7 +213,10 @@
 extern bool arm_change_mode_p (tree);
 #endif
 
-extern tree arm_valid_target_attribute_tree (tree, struct gcc_options *,
+extern void arm_init_neon_builtins (void);
+
+extern tree arm_valid_target_attribute_tree (tree,
+					     struct gcc_options *,
 					     struct gcc_options *);
 extern void arm_pr_long_calls (struct cpp_reader *);
 extern void arm_pr_no_long_calls (struct cpp_reader *);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]