diff mbox

[ARM] attribute target (thumb,arm) [2.1/6] respin (5th)

Message ID 55531022.20801@st.com
State New
Headers show

Commit Message

Christian Bruel May 13, 2015, 8:49 a.m. UTC
2 parts for maintainers

  - c-family: machine descriptions export macro definitions into c 
implementation : need to export 'builtin_define_with_int_value' and ' 
builtin_define_type_sizeof'

    Could a global reviewer check this ?

  - ARM: Move the CPP builtins from arm.h to arm-c.c

many thanks

Christian

Comments

Kyrylo Tkachov May 13, 2015, 9:05 a.m. UTC | #1
On 13/05/15 09:49, Christian Bruel wrote:
>    2 parts for maintainers
>
>    - c-family: machine descriptions export macro definitions into c
> implementation : need to export 'builtin_define_with_int_value' and '
> builtin_define_type_sizeof'

+1 on this. It would help me a lot in implementing
target attributes and pragmas in aarch64 as well.

Kyrill

>
>      Could a global reviewer check this ?
>
>    - ARM: Move the CPP builtins from arm.h to arm-c.c
>
> many thanks
>
> Christian
>
>
>
Christian Bruel May 20, 2015, 7:19 a.m. UTC | #2
Hi,

Could a global reviewer have a look at the c-family part ?, this is 
blocking for the TARGET_CPU_CPP_BUILTINS macro redefinition in C (arm 
but probably others)

https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01185.html

many thanks

Christian

On 05/13/2015 10:49 AM, Christian Bruel wrote:
>   2 parts for maintainers
>
>   - c-family: machine descriptions export macro definitions into c
> implementation : need to export 'builtin_define_with_int_value' and '
> builtin_define_type_sizeof'
>
>     Could a global reviewer check this ?
>
>   - ARM: Move the CPP builtins from arm.h to arm-c.c
>
> many thanks
>
> Christian
>
>
Jeff Law May 20, 2015, 1:13 p.m. UTC | #3
On 05/20/2015 01:19 AM, Christian Bruel wrote:
> Hi,
>
> Could a global reviewer have a look at the c-family part ?, this is
> blocking for the TARGET_CPU_CPP_BUILTINS macro redefinition in C (arm
> but probably others)
>
> https://gcc.gnu.org/ml/gcc-patches/2015-05/msg01185.html
The c-family bits are OK.  Sorry I totally ignored this thread not 
realizing there were things outside the ARM port that needed review.

Thanks,
Jeff
Ramana Radhakrishnan May 26, 2015, 1:44 p.m. UTC | #4
On Wed, May 13, 2015 at 9:49 AM, Christian Bruel <christian.bruel@st.com> wrote:
>  2 parts for maintainers
>
>  - c-family: machine descriptions export macro definitions into c
> implementation : need to export 'builtin_define_with_int_value' and '
> builtin_define_type_sizeof'
>
>    Could a global reviewer check this ?
>
>  - ARM: Move the CPP builtins from arm.h to arm-c.c

The ARM bits are OK, please apply. Sorry to have missed that there was
an ARM part of this too.

Ramana

>
> many thanks
>
> Christian
>
>
>
diff mbox

Patch

2015-05-12  Christian Bruel  <christian.bruel@st.com>

	* c-common.h (builtin_define_with_int_value)
	(builtin_define_type_sizeof): Declare.
	* c-cppbuiltin.c (builtin_define_with_int_value)
	(builtin_define_type_sizeof): Externalize.
	(builtin_define_std): Cleanup declaration.

2015-05-13  Christian Bruel  <christian.bruel@st.com>

	* config/arm/arm-protos.h (arm_cpu_cpp_builtins): Declare.
	* config/arm/arm.h (TARGET_CPU_CPP_BUILTINS): Move macro defines into...
	* config/arm/arm-c.c (arm_cpu_cpp_builtins): New function.
	(builtin_define, builtin_assert): New macros.

diff '--exclude=.svn' -ruN gnu_trunk.p1/gcc/gcc/c-family/c-common.h gnu_trunk.ref/gcc/gcc/c-family/c-common.h
--- gnu_trunk.p1/gcc/gcc/c-family/c-common.h	2015-05-13 09:27:08.049196052 +0200
+++ gnu_trunk.ref/gcc/gcc/c-family/c-common.h	2015-05-13 09:07:31.355106264 +0200
@@ -1085,6 +1085,8 @@ 
 /* In c-cppbuiltin.c  */
 extern void builtin_define_std (const char *macro);
 extern void builtin_define_with_value (const char *, const char *, int);
+extern void builtin_define_with_int_value (const char *, HOST_WIDE_INT);
+extern void builtin_define_type_sizeof (const char *, tree);
 extern void c_stddef_cpp_builtins (void);
 extern void fe_file_change (const struct line_map *);
 extern void c_parse_error (const char *, enum cpp_ttype, tree, unsigned char);
diff '--exclude=.svn' -ruN gnu_trunk.p1/gcc/gcc/c-family/c-cppbuiltin.c gnu_trunk.ref/gcc/gcc/c-family/c-cppbuiltin.c
--- gnu_trunk.p1/gcc/gcc/c-family/c-cppbuiltin.c	2015-03-25 15:14:13.132366687 +0100
+++ gnu_trunk.ref/gcc/gcc/c-family/c-cppbuiltin.c	2015-05-11 18:05:41.009176614 +0200
@@ -58,8 +58,6 @@ 
 #endif
 
 /* Non-static as some targets don't use it.  */
-void builtin_define_std (const char *) ATTRIBUTE_UNUSED;
-static void builtin_define_with_int_value (const char *, HOST_WIDE_INT);
 static void builtin_define_with_hex_fp_value (const char *, tree,
 					      int, const char *,
 					      const char *,
@@ -68,7 +66,6 @@ 
 static void builtin_define_constants (const char *, tree);
 static void builtin_define_type_max (const char *, tree);
 static void builtin_define_type_minmax (const char *, const char *, tree);
-static void builtin_define_type_sizeof (const char *, tree);
 static void builtin_define_float_constants (const char *,
 					    const char *,
 					    const char *,
@@ -113,7 +110,7 @@ 
 }
 
 /* Define NAME with value TYPE size_unit.  */
-static void
+void
 builtin_define_type_sizeof (const char *name, tree type)
 {
   builtin_define_with_int_value (name,
@@ -1372,7 +1369,7 @@ 
 
 
 /* Pass an object-like macro and an integer value to define it to.  */
-static void
+void
 builtin_define_with_int_value (const char *macro, HOST_WIDE_INT value)
 {
   char *buf;
diff '--exclude=.svn' -ruN gnu_trunk.p1/gcc/gcc/config/arm/arm-c.c gnu_trunk.ref/gcc/gcc/config/arm/arm-c.c
--- gnu_trunk.p1/gcc/gcc/config/arm/arm-c.c	2015-05-06 14:06:27.508142998 +0200
+++ gnu_trunk.ref/gcc/gcc/config/arm/arm-c.c	2015-05-13 10:29:41.160088869 +0200
@@ -51,3 +51,126 @@ 
 {
   arm_lang_output_object_attributes_hook = arm_output_c_attributes;
 }
+
+#define builtin_define(TXT) cpp_define (pfile, TXT)
+#define builtin_assert(TXT) cpp_assert (pfile, TXT)
+
+void
+arm_cpu_cpp_builtins (struct cpp_reader * pfile)
+{
+  if (TARGET_DSP_MULTIPLY)
+    builtin_define ("__ARM_FEATURE_DSP");
+  if (TARGET_ARM_QBIT)
+    builtin_define ("__ARM_FEATURE_QBIT");
+  if (TARGET_ARM_SAT)
+    builtin_define ("__ARM_FEATURE_SAT");
+  if (TARGET_CRYPTO)
+    builtin_define ("__ARM_FEATURE_CRYPTO");
+  if (unaligned_access)
+    builtin_define ("__ARM_FEATURE_UNALIGNED");
+  if (TARGET_CRC32)
+    builtin_define ("__ARM_FEATURE_CRC32");
+  if (TARGET_32BIT)
+    builtin_define ("__ARM_32BIT_STATE");
+  if (TARGET_ARM_FEATURE_LDREX)
+    builtin_define_with_int_value ("__ARM_FEATURE_LDREX", 
+				   TARGET_ARM_FEATURE_LDREX);
+  if ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB)
+      || TARGET_ARM_ARCH_ISA_THUMB >=2)
+    builtin_define ("__ARM_FEATURE_CLZ");
+  if (TARGET_INT_SIMD)
+    builtin_define ("__ARM_FEATURE_SIMD32");
+
+  builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM",
+				 flag_short_enums ? 1 : 4);
+  builtin_define_type_sizeof ("__ARM_SIZEOF_WCHAR_T", wchar_type_node);
+  if (TARGET_ARM_ARCH_PROFILE)
+    builtin_define_with_int_value ("__ARM_ARCH_PROFILE",
+				   TARGET_ARM_ARCH_PROFILE);
+
+  /* Define __arm__ even when in thumb mode, for
+     consistency with armcc.  */
+  builtin_define ("__arm__");
+  if (TARGET_ARM_ARCH)
+    builtin_define_with_int_value ("__ARM_ARCH", TARGET_ARM_ARCH);
+  if (arm_arch_notm)
+    builtin_define ("__ARM_ARCH_ISA_ARM");
+  builtin_define ("__APCS_32__");
+  if (TARGET_THUMB)
+    builtin_define ("__thumb__");
+  if (TARGET_THUMB2)
+    builtin_define ("__thumb2__");
+  if (TARGET_ARM_ARCH_ISA_THUMB)
+    builtin_define_with_int_value ("__ARM_ARCH_ISA_THUMB",
+				   TARGET_ARM_ARCH_ISA_THUMB);
+
+  if (TARGET_BIG_END)
+    {
+      builtin_define ("__ARMEB__");
+      builtin_define ("__ARM_BIG_ENDIAN");
+      if (TARGET_THUMB)
+	builtin_define ("__THUMBEB__");
+    }
+  else
+    {
+      builtin_define ("__ARMEL__");
+      if (TARGET_THUMB)
+	builtin_define ("__THUMBEL__");
+    }
+
+  if (TARGET_SOFT_FLOAT)
+    builtin_define ("__SOFTFP__");
+
+  if (TARGET_VFP)
+    builtin_define ("__VFP_FP__");
+	
+  if (TARGET_ARM_FP)
+    builtin_define_with_int_value ("__ARM_FP", TARGET_ARM_FP);
+  if (arm_fp16_format == ARM_FP16_FORMAT_IEEE)
+    builtin_define ("__ARM_FP16_FORMAT_IEEE");
+  if (arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE)
+    builtin_define ("__ARM_FP16_FORMAT_ALTERNATIVE");
+  if (TARGET_FMA)
+    builtin_define ("__ARM_FEATURE_FMA");
+
+  if (TARGET_NEON)
+    {
+      builtin_define ("__ARM_NEON__");
+      builtin_define ("__ARM_NEON");
+    }
+  if (TARGET_NEON_FP)
+    builtin_define_with_int_value ("__ARM_NEON_FP", TARGET_NEON_FP);
+  
+  /* Add a define for interworking. Needed when building libgcc.a.  */
+  if (arm_cpp_interwork)
+    builtin_define ("__THUMB_INTERWORK__");
+
+  builtin_assert ("cpu=arm");
+  builtin_assert ("machine=arm");
+
+  builtin_define (arm_arch_name);
+  if (arm_arch_xscale)
+    builtin_define ("__XSCALE__");
+  if (arm_arch_iwmmxt)
+    {
+      builtin_define ("__IWMMXT__");
+      builtin_define ("__ARM_WMMX");
+    }
+  if (arm_arch_iwmmxt2)
+    builtin_define ("__IWMMXT2__");
+  if (TARGET_AAPCS_BASED)
+    {
+      if (arm_pcs_default == ARM_PCS_AAPCS_VFP)
+	builtin_define ("__ARM_PCS_VFP");
+      else if (arm_pcs_default == ARM_PCS_AAPCS)
+	builtin_define ("__ARM_PCS");
+      builtin_define ("__ARM_EABI__");
+    }
+  if (TARGET_IDIV)
+    {
+      builtin_define ("__ARM_ARCH_EXT_IDIV__");
+      builtin_define ("__ARM_FEATURE_IDIV");
+    }
+  if (inline_asm_unified)
+    builtin_define ("__ARM_ASM_SYNTAX_UNIFIED__");
+}
diff '--exclude=.svn' -ruN gnu_trunk.p1/gcc/gcc/config/arm/arm.h gnu_trunk.ref/gcc/gcc/config/arm/arm.h
--- gnu_trunk.p1/gcc/gcc/config/arm/arm.h	2015-05-13 09:27:10.761200864 +0200
+++ gnu_trunk.ref/gcc/gcc/config/arm/arm.h	2015-05-13 10:29:33.460074402 +0200
@@ -45,132 +45,7 @@ 
 extern char arm_arch_name[];
 
 /* Target CPU builtins.  */
-#define TARGET_CPU_CPP_BUILTINS()			\
-  do							\
-    {							\
-	if (TARGET_DSP_MULTIPLY)			\
-	   builtin_define ("__ARM_FEATURE_DSP");	\
-        if (TARGET_ARM_QBIT)				\
-           builtin_define ("__ARM_FEATURE_QBIT");	\
-        if (TARGET_ARM_SAT)				\
-           builtin_define ("__ARM_FEATURE_SAT");	\
-        if (TARGET_CRYPTO)				\
-	   builtin_define ("__ARM_FEATURE_CRYPTO");	\
-	if (unaligned_access)				\
-	  builtin_define ("__ARM_FEATURE_UNALIGNED");	\
-	if (TARGET_CRC32)				\
-	  builtin_define ("__ARM_FEATURE_CRC32");	\
-	if (TARGET_32BIT)				\
-	  builtin_define ("__ARM_32BIT_STATE");		\
-	if (TARGET_ARM_FEATURE_LDREX)				\
-	  builtin_define_with_int_value (			\
-	    "__ARM_FEATURE_LDREX", TARGET_ARM_FEATURE_LDREX);	\
-	if ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB)		\
-	     || TARGET_ARM_ARCH_ISA_THUMB >=2)			\
-	  builtin_define ("__ARM_FEATURE_CLZ");			\
-	if (TARGET_INT_SIMD)					\
-	  builtin_define ("__ARM_FEATURE_SIMD32");		\
-								\
-	builtin_define_with_int_value (				\
-	  "__ARM_SIZEOF_MINIMAL_ENUM",				\
-	  flag_short_enums ? 1 : 4);				\
-	builtin_define_type_sizeof ("__ARM_SIZEOF_WCHAR_T",	\
-				    wchar_type_node);		\
-	if (TARGET_ARM_ARCH_PROFILE)				\
-	  builtin_define_with_int_value (			\
-	    "__ARM_ARCH_PROFILE", TARGET_ARM_ARCH_PROFILE);	\
-								\
-	/* Define __arm__ even when in thumb mode, for	\
-	   consistency with armcc.  */			\
-	builtin_define ("__arm__");			\
-	if (TARGET_ARM_ARCH)				\
-	  builtin_define_with_int_value (		\
-	    "__ARM_ARCH", TARGET_ARM_ARCH);		\
-	if (arm_arch_notm)				\
-	  builtin_define ("__ARM_ARCH_ISA_ARM");	\
-	builtin_define ("__APCS_32__");			\
-	if (TARGET_THUMB)				\
-	  builtin_define ("__thumb__");			\
-	if (TARGET_THUMB2)				\
-	  builtin_define ("__thumb2__");		\
-	if (TARGET_ARM_ARCH_ISA_THUMB)			\
-	  builtin_define_with_int_value (		\
-	    "__ARM_ARCH_ISA_THUMB",			\
-	    TARGET_ARM_ARCH_ISA_THUMB);			\
-							\
-	if (TARGET_BIG_END)				\
-	  {						\
-	    builtin_define ("__ARMEB__");		\
-	    builtin_define ("__ARM_BIG_ENDIAN");	\
-	    if (TARGET_THUMB)				\
-	      builtin_define ("__THUMBEB__");		\
-	  }						\
-        else						\
-	  {						\
-	    builtin_define ("__ARMEL__");		\
-	    if (TARGET_THUMB)				\
-	      builtin_define ("__THUMBEL__");		\
-	  }						\
-							\
-	if (TARGET_SOFT_FLOAT)				\
-	  builtin_define ("__SOFTFP__");		\
-							\
-	if (TARGET_VFP)					\
-	  builtin_define ("__VFP_FP__");		\
-							\
-	if (TARGET_ARM_FP)				\
-	  builtin_define_with_int_value (		\
-	    "__ARM_FP", TARGET_ARM_FP);			\
-	if (arm_fp16_format == ARM_FP16_FORMAT_IEEE)		\
-	  builtin_define ("__ARM_FP16_FORMAT_IEEE");		\
-	if (arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE)	\
-	  builtin_define ("__ARM_FP16_FORMAT_ALTERNATIVE");	\
-        if (TARGET_FMA)					\
-          builtin_define ("__ARM_FEATURE_FMA");		\
-							\
-	if (TARGET_NEON)				\
-	  {						\
-	    builtin_define ("__ARM_NEON__");		\
-	    builtin_define ("__ARM_NEON");		\
-	  }						\
-	if (TARGET_NEON_FP)				\
-	  builtin_define_with_int_value (		\
-	    "__ARM_NEON_FP", TARGET_NEON_FP);		\
-							\
-	/* Add a define for interworking.		\
-	   Needed when building libgcc.a.  */		\
-	if (arm_cpp_interwork)				\
-	  builtin_define ("__THUMB_INTERWORK__");	\
-							\
-	builtin_assert ("cpu=arm");			\
-	builtin_assert ("machine=arm");			\
-							\
-	builtin_define (arm_arch_name);			\
-	if (arm_arch_xscale)				\
-	  builtin_define ("__XSCALE__");		\
-	if (arm_arch_iwmmxt)				\
-          {						\
-	    builtin_define ("__IWMMXT__");		\
-	    builtin_define ("__ARM_WMMX");		\
-	  }						\
-	if (arm_arch_iwmmxt2)				\
-	  builtin_define ("__IWMMXT2__");		\
-	if (TARGET_AAPCS_BASED)				\
-	  {						\
-	    if (arm_pcs_default == ARM_PCS_AAPCS_VFP)	\
-	      builtin_define ("__ARM_PCS_VFP");		\
-	    else if (arm_pcs_default == ARM_PCS_AAPCS)	\
-	      builtin_define ("__ARM_PCS");		\
-	    builtin_define ("__ARM_EABI__");		\
-	  }						\
-	if (TARGET_IDIV)				\
-         {						\
-            builtin_define ("__ARM_ARCH_EXT_IDIV__");	\
-            builtin_define ("__ARM_FEATURE_IDIV");	\
-         }						\
-	if (inline_asm_unified)				\
-	  builtin_define ("__ARM_ASM_SYNTAX_UNIFIED__");\
-    } while (0)
+#define TARGET_CPU_CPP_BUILTINS() arm_cpu_cpp_builtins (pfile)
 
 #include "config/arm/arm-opts.h"
 
diff '--exclude=.svn' -ruN gnu_trunk.p1/gcc/gcc/config/arm/arm-protos.h gnu_trunk.ref/gcc/gcc/config/arm/arm-protos.h
--- gnu_trunk.p1/gcc/gcc/config/arm/arm-protos.h	2015-05-13 09:27:10.761200864 +0200
+++ gnu_trunk.ref/gcc/gcc/config/arm/arm-protos.h	2015-05-13 10:29:45.956097880 +0200
@@ -216,8 +216,6 @@ 
 extern void arm_pr_no_long_calls (struct cpp_reader *);
 extern void arm_pr_long_calls_off (struct cpp_reader *);
 
-extern void arm_lang_object_attributes_init(void);
-
 extern const char *arm_mangle_type (const_tree);
 extern const char *arm_mangle_builtin_type (const_tree);
 
@@ -331,6 +329,10 @@ 
 /* Defined in gcc/common/config/arm-common.c.  */
 extern const char *arm_rewrite_selected_cpu (const char *name);
 
+/* Defined in gcc/common/config/arm-c.c.  */
+extern void arm_lang_object_attributes_init (void);
+extern void arm_cpu_cpp_builtins (struct cpp_reader *);
+
 extern bool arm_is_constant_pool_ref (rtx);
 
 /* Flags used to identify the presence of processor capabilities.  */