Re: [PATCH, ARM] attribute target (thumb,arm) [5/6] respin (5th)

2015-06-01 Thread Kyrill Tkachov

Hi Christian,

On 18/05/15 09:26, Christian Bruel wrote:

On 05/08/2015 11:18 AM, Ramana Radhakrishnan wrote:



On 06/05/15 15:27, Christian Bruel wrote:

Implements the hooks for #pragma GCC target

A test included to check that macros were correctly defined/undefined on
pragma regions.

Thanks

Christian




Missing the hooks - this only appears to have the test.

Ramana


patch management glitch:-(  here there are (rebased) :


p5.patch


2014-09-23  Christian Bruelchristian.br...@st.com

* config/arm/arm.h (REGISTER_TARGET_PRAGMAS):
 Call arm_register_target_pragmas.
* config/arm/arm-protos.h (arm_register_target_pragmas): Declare.
* config/arm/arm-c.c (arm_register_target_pragmas): New function.
(arm_pragma_target_parse): Likewise.


This is ok for trunk once the previous patches in the series are approved.
Minor nit below.

Thanks,
Kyrill



2014-09-23  Christian Bruelchristian.br...@st.com

* gcc.target/arm/pragma_attribute.c: New test.

diff '--exclude=.svn' -ruN gnu_trunk.p4/gcc/gcc/config/arm/arm-c.c 
gnu_trunk.p5/gcc/gcc/config/arm/arm-c.c
--- gnu_trunk.p4/gcc/gcc/config/arm/arm-c.c 2015-05-13 12:59:14.309087193 
+0200
+++ gnu_trunk.p5/gcc/gcc/config/arm/arm-c.c 2015-05-13 13:21:17.291617848 
+0200
@@ -20,7 +20,6 @@
  #include system.h
  #include coretypes.h
  #include tm.h
-#include tm_p.h
  #include hash-set.h
  #include machmode.h
  #include vec.h
@@ -31,7 +30,11 @@
  #include wide-int.h
  #include inchash.h
  #include tree.h
+#include tm_p.h
  #include c-family/c-common.h
+#include target.h
+#include target-def.h
+#include c-family/c-pragma.h
  
  /* Output C specific EABI object attributes.  These can not be done in

 arm.c because they require information from the C frontend.  */
@@ -192,3 +195,81 @@
  
def_or_undef_macro (pfile, __ARM_ASM_SYNTAX_UNIFIED__, inline_asm_unified);

  }
+
+/* Hook to validate the current #pragma GCC target and set the arch custom
+   mode state.  If ARGS is NULL, then POP_TARGET is used to reset
+   the options.  */
+static bool
+arm_pragma_target_parse (tree args, tree pop_target)


New line after comment and before the static bool.


+{
+  tree prev_tree = build_target_option_node (global_options);
+  tree cur_tree;
+  struct cl_target_option *prev_opt;
+  struct cl_target_option *cur_opt;
+  bool cur_mode, prev_mode;
+
+  if (! args)




Re: [PATCH, ARM] attribute target (thumb,arm) [5/6] respin (4th)

2015-05-08 Thread Ramana Radhakrishnan



On 06/05/15 15:27, Christian Bruel wrote:

Implements the hooks for #pragma GCC target

A test included to check that macros were correctly defined/undefined on
pragma regions.

Thanks

Christian




Missing the hooks - this only appears to have the test.

Ramana


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

2015-05-06 Thread Christian Bruel
Implements the hooks for #pragma GCC target

A test included to check that macros were correctly defined/undefined on
pragma regions.

Thanks

Christian
2014-09-23  Christian Bruel  christian.br...@st.com

	* config/arm/arm.h (REGISTER_TARGET_PRAGMAS):
	 Call arm_register_target_pragmas.
	* config/arm/arm-protos.h (arm_register_target_pragmas): Declare.
	* config/arm/arm-c.c (arm_register_target_pragmas): New function.
	(arm_pragma_target_parse): Likewise.

diff '--exclude=.svn' -ruN gnu_trunk.p4/gcc/gcc/testsuite/gcc.target/arm/pragma_attribute.c gnu_trunk.p5/gcc/gcc/testsuite/gcc.target/arm/pragma_attribute.c
--- gnu_trunk.p4/gcc/gcc/testsuite/gcc.target/arm/pragma_attribute.c	1970-01-01 01:00:00.0 +0100
+++ gnu_trunk.p5/gcc/gcc/testsuite/gcc.target/arm/pragma_attribute.c	2015-05-06 14:37:31.215314738 +0200
@@ -0,0 +1,35 @@
+/* Test for #prama target macros.  */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_thumb1_ok } */
+
+#pragma GCC target (thumb)
+
+#ifndef __thumb__
+#error __thumb__ is not defined
+#endif
+
+#ifdef __thumb2__
+#ifndef __ARM_32BIT_STATE
+#error  __ARM_32BIT_STATE is not defined
+#endif
+#else /* thumb1 */
+#ifdef __ARM_32BIT_STATE
+#error  __ARM_32BIT_STATE is defined
+#endif
+#endif /* thumb1 */
+
+#pragma GCC target (arm)
+
+#ifdef __thumb__
+#error __thumb__ is defined
+#endif
+
+#if defined (__thumb2__) || defined (__thumb1__)
+#error thumb is defined
+#endif 
+
+#ifndef __ARM_32BIT_STATE
+#error  __ARM_32BIT_STATE is not defined
+#endif
+
+#pragma GCC reset_options


[PATCH, ARM] attribute target (thumb,arm) [5/6]

2014-11-19 Thread Christian Bruel

Implements the hooks for #pragma GCC target

A test included to check that macros were correctly defined/undefined on 
pragma regions.


Thanks

Christian
2014-09-23  Christian Bruel  christian.br...@st.com

	* config/arm/arm.h (REGISTER_TARGET_PRAGMAS):
	 Call arm_register_target_pragmas.
	* config/arm/arm-protos.h (arm_register_target_pragmas): Declare.
	* config/arm/arm-c.c (arm_register_target_pragmas): New function.
	(arm_pragma_target_parse): Likewise.

diff '--exclude=ChangeLog*' '--exclude=.svn' '--exclude=*~' '--exclude=#*#' -rupN e/gcc/gcc/config/arm/arm-c.c f/gcc/gcc/config/arm/arm-c.c
--- e/gcc/gcc/config/arm/arm-c.c	2014-11-13 13:03:27.0 +0100
+++ f/gcc/gcc/config/arm/arm-c.c	2014-11-13 13:53:45.0 +0100
@@ -20,9 +20,12 @@
 #include system.h
 #include coretypes.h
 #include tm.h
-#include tm_p.h
 #include tree.h
+#include tm_p.h
 #include c-family/c-common.h
+#include target.h
+#include target-def.h
+#include c-family/c-pragma.h
 
 /* Output C specific EABI object attributes.  These can not be done in
arm.c because they require information from the C frontend.  */
@@ -112,3 +115,78 @@ arm_cpp_builtins (struct cpp_reader *in,
  cpp_def_or_undef (in, __ARM_ASM_SYNTAX_UNIFIED__, inline_asm_unified);
 }
 
+/* Hook to validate the current #pragma GCC target and set the arch custom
+   mode state.  If ARGS is NULL, then POP_TARGET is used to reset
+   the options.  */
+static bool
+arm_pragma_target_parse (tree args, tree pop_target)
+{
+  tree prev_tree = build_target_option_node (global_options);
+  tree cur_tree;
+  struct cl_target_option *prev_opt;
+  struct cl_target_option *cur_opt;
+  bool cur_mode, prev_mode;
+
+  if (! args)
+{
+  cur_tree = ((pop_target) ? pop_target : target_option_default_node);
+  cl_target_option_restore (global_options,
+TREE_TARGET_OPTION (cur_tree));
+}
+  else
+{
+  cur_tree = arm_valid_target_attribute_tree (args,  global_options);
+  if (cur_tree == NULL_TREE)
+	{
+	  cl_target_option_restore (global_options,
+TREE_TARGET_OPTION (prev_tree));
+	  return false;
+	}
+}
+
+  target_option_current_node = cur_tree;
+  arm_reset_previous_fndecl ();
+
+  /* Figure out the previous mode.  */
+  prev_opt  = TREE_TARGET_OPTION (prev_tree);
+  cur_opt   = TREE_TARGET_OPTION (cur_tree);
+
+  gcc_assert (prev_opt);
+  gcc_assert (cur_opt);
+
+  cur_mode = TARGET_THUMB_P (cur_opt-x_target_flags);
+  prev_mode = TARGET_THUMB_P (prev_opt-x_target_flags);
+
+  if (prev_mode != cur_mode)
+{
+  /* For the definitions, ensure all newly defined macros are considered
+	 as used for -Wunused-macros.  There is no point warning about the
+	 compiler predefined macros.  */
+  cpp_options *cpp_opts = cpp_get_options (parse_in);
+  unsigned char saved_warn_unused_macros = cpp_opts-warn_unused_macros;
+  cpp_opts-warn_unused_macros = 0;
+
+  /* Update macros.  */
+  arm_cpp_builtins (parse_in, cur_mode);
+
+  cpp_opts-warn_unused_macros = saved_warn_unused_macros;
+}
+
+  return true;
+}
+
+/* Register target pragmas.  We need to add the hook for parsing #pragma GCC
+   option here rather than in arm.c since it will pull in various preprocessor
+   functions, and those are not present in languages like fortran without a
+   preprocessor.  */
+
+void
+arm_register_target_pragmas (void)
+{
+  /* Update pragma hook to allow parsing #pragma GCC target.  */
+  targetm.target_option.pragma_parse = arm_pragma_target_parse;
+
+#ifdef REGISTER_SUBTARGET_PRAGMAS
+  REGISTER_SUBTARGET_PRAGMAS ();
+#endif
+}
diff '--exclude=ChangeLog*' '--exclude=.svn' '--exclude=*~' '--exclude=#*#' -rupN e/gcc/gcc/config/arm/arm.h f/gcc/gcc/config/arm/arm.h
--- e/gcc/gcc/config/arm/arm.h	2014-11-13 13:48:59.0 +0100
+++ f/gcc/gcc/config/arm/arm.h	2014-11-13 13:48:01.0 +0100
@@ -2097,7 +2097,8 @@ extern int making_const_table;
   c_register_pragma (0, long_calls, arm_pr_long_calls);		\
   c_register_pragma (0, no_long_calls, arm_pr_no_long_calls);		\
   c_register_pragma (0, long_calls_off, arm_pr_long_calls_off);	\
-  arm_lang_object_attributes_init(); \
+  arm_lang_object_attributes_init();	\
+  arm_register_target_pragmas();   \
 } while (0)
 
 /* Condition code information.  */
diff '--exclude=ChangeLog*' '--exclude=.svn' '--exclude=*~' '--exclude=#*#' -rupN e/gcc/gcc/config/arm/arm-protos.h f/gcc/gcc/config/arm/arm-protos.h
--- e/gcc/gcc/config/arm/arm-protos.h	2014-11-13 13:07:47.0 +0100
+++ f/gcc/gcc/config/arm/arm-protos.h	2014-11-13 13:49:50.0 +0100
@@ -306,6 +306,7 @@ extern const char *arm_rewrite_selected_
 
 /* Defined in gcc/common/config/arm-c.c.  */
 extern void arm_lang_object_attributes_init(void);
+extern void arm_register_target_pragmas (void);
 extern void arm_cpp_builtins (struct cpp_reader *, bool);
 
 extern bool arm_is_constant_pool_ref (rtx);
2014-09-23  Christian Bruel  christian.br...@st.com

	*