Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-23 Thread Andre Vieira (lists)
On 23/09/16 11:04, Jakub Jelinek wrote:
> On Thu, Sep 22, 2016 at 10:37:21PM +0200, Uros Bizjak wrote:
>> diff --git a/gcc/hooks.c b/gcc/hooks.c
>> index 
>> 99ec4014adb6fcbb073bf538dd00fe8695ee6cb2..1e925645c3173f8d97e104b9b2f480fca2ede438
>> 100644
>> --- a/gcc/hooks.c
>> +++ b/gcc/hooks.c
>> @@ -481,3 +481,13 @@ void
>>   hook_void_gcc_optionsp (struct gcc_options *opts ATTRIBUTE_UNUSED)
>>   {
>>   }
>> +
>> +/* Generic hook that takes an unsigned int, an unsigned int pointer and
>> +   returns false.  */
>> +
>> +bool
>> +hook_uint_uintp_false (unsigned int, unsigned int *)
>> +{
>> +  return false;
>> +}
>>
>>
>> The name of this hook doesn't adhere to the convention. It should be named:
>>
>> hook_bool_uint_uintp_false
> 
> You're right, I've committed this as obvious:
> 
> 2016-09-23  Uros Bizjak  
>   Jakub Jelinek  
> 
>   * hooks.h (hook_uint_uintp_false): Rename to...
>   (hook_bool_uint_uintp_false): ... this.
>   * hooks.c (hook_uint_uintp_false): Rename to...
>   (hook_bool_uint_uintp_false): ... this.
>   * target.def (elf_flags_numeric): Use hook_bool_uint_uintp_false
>   instead of hook_uint_uintp_false.
> 
> --- gcc/hooks.h.jj2016-09-23 09:32:13.0 +0200
> +++ gcc/hooks.h   2016-09-23 11:57:28.116738504 +0200
> @@ -76,7 +76,7 @@ extern void hook_void_tree (tree);
>  extern void hook_void_tree_treeptr (tree, tree *);
>  extern void hook_void_int_int (int, int);
>  extern void hook_void_gcc_optionsp (struct gcc_options *);
> -extern bool hook_uint_uintp_false (unsigned int, unsigned int *);
> +extern bool hook_bool_uint_uintp_false (unsigned int, unsigned int *);
>  
>  extern int hook_int_uint_mode_1 (unsigned int, machine_mode);
>  extern int hook_int_const_tree_0 (const_tree);
> --- gcc/hooks.c.jj2016-09-23 09:32:13.0 +0200
> +++ gcc/hooks.c   2016-09-23 11:57:39.938588268 +0200
> @@ -486,8 +486,7 @@ hook_void_gcc_optionsp (struct gcc_optio
> returns false.  */
>  
>  bool
> -hook_uint_uintp_false (unsigned int, unsigned int *)
> +hook_bool_uint_uintp_false (unsigned int, unsigned int *)
>  {
>return false;
>  }
> -
> --- gcc/target.def.jj 2016-09-23 09:32:13.0 +0200
> +++ gcc/target.def2016-09-23 11:59:03.581525303 +0200
> @@ -446,7 +446,7 @@ instead of the normal sequence of letter
>  defined, or if it returns false, then @var{num} will be ignored and the\n\
>  traditional letter sequence will be emitted.",
>   bool, (unsigned int flags, unsigned int *num),
> - hook_uint_uintp_false)
> + hook_bool_uint_uintp_false)
>  
>  /* Return preferred text (sub)section for function DECL.
> Main purpose of this function is to separate cold, normal and hot
> 
> 
>   Jakub
> 

The hook that keeps on giving. Thanks! And one more time, sorry!

Cheers,
Andre


Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-23 Thread Jakub Jelinek
On Thu, Sep 22, 2016 at 10:37:21PM +0200, Uros Bizjak wrote:
> diff --git a/gcc/hooks.c b/gcc/hooks.c
> index 
> 99ec4014adb6fcbb073bf538dd00fe8695ee6cb2..1e925645c3173f8d97e104b9b2f480fca2ede438
> 100644
> --- a/gcc/hooks.c
> +++ b/gcc/hooks.c
> @@ -481,3 +481,13 @@ void
>   hook_void_gcc_optionsp (struct gcc_options *opts ATTRIBUTE_UNUSED)
>   {
>   }
> +
> +/* Generic hook that takes an unsigned int, an unsigned int pointer and
> +   returns false.  */
> +
> +bool
> +hook_uint_uintp_false (unsigned int, unsigned int *)
> +{
> +  return false;
> +}
> 
> 
> The name of this hook doesn't adhere to the convention. It should be named:
> 
> hook_bool_uint_uintp_false

You're right, I've committed this as obvious:

2016-09-23  Uros Bizjak  
Jakub Jelinek  

* hooks.h (hook_uint_uintp_false): Rename to...
(hook_bool_uint_uintp_false): ... this.
* hooks.c (hook_uint_uintp_false): Rename to...
(hook_bool_uint_uintp_false): ... this.
* target.def (elf_flags_numeric): Use hook_bool_uint_uintp_false
instead of hook_uint_uintp_false.

--- gcc/hooks.h.jj  2016-09-23 09:32:13.0 +0200
+++ gcc/hooks.h 2016-09-23 11:57:28.116738504 +0200
@@ -76,7 +76,7 @@ extern void hook_void_tree (tree);
 extern void hook_void_tree_treeptr (tree, tree *);
 extern void hook_void_int_int (int, int);
 extern void hook_void_gcc_optionsp (struct gcc_options *);
-extern bool hook_uint_uintp_false (unsigned int, unsigned int *);
+extern bool hook_bool_uint_uintp_false (unsigned int, unsigned int *);
 
 extern int hook_int_uint_mode_1 (unsigned int, machine_mode);
 extern int hook_int_const_tree_0 (const_tree);
--- gcc/hooks.c.jj  2016-09-23 09:32:13.0 +0200
+++ gcc/hooks.c 2016-09-23 11:57:39.938588268 +0200
@@ -486,8 +486,7 @@ hook_void_gcc_optionsp (struct gcc_optio
returns false.  */
 
 bool
-hook_uint_uintp_false (unsigned int, unsigned int *)
+hook_bool_uint_uintp_false (unsigned int, unsigned int *)
 {
   return false;
 }
-
--- gcc/target.def.jj   2016-09-23 09:32:13.0 +0200
+++ gcc/target.def  2016-09-23 11:59:03.581525303 +0200
@@ -446,7 +446,7 @@ instead of the normal sequence of letter
 defined, or if it returns false, then @var{num} will be ignored and the\n\
 traditional letter sequence will be emitted.",
  bool, (unsigned int flags, unsigned int *num),
- hook_uint_uintp_false)
+ hook_bool_uint_uintp_false)
 
 /* Return preferred text (sub)section for function DECL.
Main purpose of this function is to separate cold, normal and hot


Jakub


Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread Uros Bizjak
diff --git a/gcc/hooks.c b/gcc/hooks.c
index 
99ec4014adb6fcbb073bf538dd00fe8695ee6cb2..1e925645c3173f8d97e104b9b2f480fca2ede438
100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -481,3 +481,13 @@ void
  hook_void_gcc_optionsp (struct gcc_options *opts ATTRIBUTE_UNUSED)
  {
  }
+
+/* Generic hook that takes an unsigned int, an unsigned int pointer and
+   returns false.  */
+
+bool
+hook_uint_uintp_false (unsigned int, unsigned int *)
+{
+  return false;
+}


The name of this hook doesn't adhere to the convention. It should be named:

hook_bool_uint_uintp_false

Uros.


Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread Martin Sebor

FYI (to help avoid raising duplicate bugs), I opened bug 77695
for the bootstrap failure.

Martin

On 09/22/2016 01:33 PM, Bill Seurer wrote:

This patch breaks compilation on power:

g++ -fno-PIE -c   -g -O2 -DIN_GCC -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common
-DHAVE_CONFIG_H -I. -I. -I/home/seurer/gcc/gcc-test2/gcc
-I/home/seurer/gcc/gcc-test2/gcc/.
-I/home/seurer/gcc/gcc-test2/gcc/../include
-I/home/seurer/gcc/gcc-test2/gcc/../libcpp/include
-I/home/seurer/gcc/gcc-test2/gcc/../libdecnumber
-I/home/seurer/gcc/gcc-test2/gcc/../libdecnumber/dpd -I../libdecnumber
-I/home/seurer/gcc/gcc-test2/gcc/../libbacktrace   -o rs6000.o -MT
rs6000.o -MMD -MP -MF ./.deps/rs6000.TPo
/home/seurer/gcc/gcc-test2/gcc/config/rs6000/rs6000.c
In file included from /home/seurer/gcc/gcc-test2/gcc/target-def.h:106:0,
 from
/home/seurer/gcc/gcc-test2/gcc/config/rs6000/rs6000.c:77:
./target-hooks-def.h:92:38: error: 'hook_uint_uintp_false' was not
declared in this scope
 #define TARGET_ASM_ELF_FLAGS_NUMERIC hook_uint_uintp_false
  ^
./target-hooks-def.h:2205:5: note: in expansion of macro
'TARGET_ASM_ELF_FLAGS_NUMERIC'
 TARGET_ASM_ELF_FLAGS_NUMERIC, \
 ^~~~
./target-hooks-def.h:1792:5: note: in expansion of macro 'TARGET_ASM_OUT'
 TARGET_ASM_OUT, \
 ^~
/home/seurer/gcc/gcc-test2/gcc/config/rs6000/rs6000.c:40709:29: note: in
expansion of macro 'TARGET_INITIALIZER'
 struct gcc_target targetm = TARGET_INITIALIZER;
 ^~
make[2]: *** [rs6000.o] Error 1


On 09/22/16 12:04, Andre Vieira (lists) wrote:

On 22/09/16 16:28, Richard Earnshaw (lists) wrote:

On 22/09/16 16:04, Andre Vieira (lists) wrote:


I reworked the patch according to the comments above.

Is this OK?

gcc/ChangeLog:
2016-09-22  Andre Vieira  
Terry Guo  

* target.def (elf_flags_numeric): New target hook.
* targhooks.h (default_asm_elf_flags_numeric): New.
* varasm.c (default_asm_elf_flags_numeric): New.
  (default_elf_asm_named_section): Use new target hook.
* config/arm/arm.opt (mpure-code): New.
* config/arm/arm.h (SECTION_ARM_PURECODE): New.
* config/arm/arm.c (arm_asm_init_sections): Add section
  attribute to default text section if -mpure-code.
  (arm_option_check_internal): Diagnose use of option with
  non supported targets and/or options.
  (arm_asm_elf_flags_numeric): New.
  (arm_function_section): New.
  (arm_elf_section_type_flags): New.
* config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Disable
  for -mpure-code.
* gcc/doc/texi (TARGET_ASM_ELF_FLAGS_NUMERIC): New.
* gcc/doc/texi.in (TARGET_ASM_ELF_FLAGS_NUMERIC): Likewise.



gcc/testsuite/ChangeLog:
2016-09-22  Andre Vieira  
Terry Guo  

* gcc.target/arm/pure-code/ffunction-sections.c: New.
* gcc.target/arm/pure-code/no-literal-pool.c: New.
* gcc.target/arm/pure-code/pure-code.exp: New.




I missed this last time around, but please can you wrap references to
SHF_ARM_PURECODE in the documentation with @code{...}.

OK with that change.

R.


Done. Committed as revision r240379.








Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread Paolo Carlini

Hi,

On 22/09/2016 19:04, Andre Vieira (lists) wrote:

diff --git a/gcc/hooks.c b/gcc/hooks.c
index 
99ec4014adb6fcbb073bf538dd00fe8695ee6cb2..1e925645c3173f8d97e104b9b2f480fca2ede438
 100644
--- a/gcc/hooks.c
+++ b/gcc/hooks.c
@@ -481,3 +481,13 @@ void
  hook_void_gcc_optionsp (struct gcc_options *opts ATTRIBUTE_UNUSED)
  {
  }
+
+/* Generic hook that takes an unsigned int, an unsigned int pointer and
+   returns false.  */
+
+bool
+hook_uint_uintp_false (unsigned int, unsigned int *)
+{
+  return false;
+}
+


I don't see this change in the committed ChangeLog and, as is, it 
doesn't have a counterpart in hooks.h. Something as trivial as the below 
fixes the bootstrap error for me on x86_64-linux.


Thanks,
Paolo.


Index: hooks.h
===
--- hooks.h (revision 240379)
+++ hooks.h (working copy)
@@ -76,6 +76,7 @@ extern void hook_void_tree (tree);
 extern void hook_void_tree_treeptr (tree, tree *);
 extern void hook_void_int_int (int, int);
 extern void hook_void_gcc_optionsp (struct gcc_options *);
+extern bool hook_uint_uintp_false (unsigned int, unsigned int *);
 
 extern int hook_int_uint_mode_1 (unsigned int, machine_mode);
 extern int hook_int_const_tree_0 (const_tree);


Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread Bill Seurer

This patch breaks compilation on power:

g++ -fno-PIE -c   -g -O2 -DIN_GCC -fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic 
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common 
-DHAVE_CONFIG_H -I. -I. -I/home/seurer/gcc/gcc-test2/gcc 
-I/home/seurer/gcc/gcc-test2/gcc/. 
-I/home/seurer/gcc/gcc-test2/gcc/../include 
-I/home/seurer/gcc/gcc-test2/gcc/../libcpp/include 
-I/home/seurer/gcc/gcc-test2/gcc/../libdecnumber 
-I/home/seurer/gcc/gcc-test2/gcc/../libdecnumber/dpd -I../libdecnumber 
-I/home/seurer/gcc/gcc-test2/gcc/../libbacktrace   -o rs6000.o -MT 
rs6000.o -MMD -MP -MF ./.deps/rs6000.TPo 
/home/seurer/gcc/gcc-test2/gcc/config/rs6000/rs6000.c

In file included from /home/seurer/gcc/gcc-test2/gcc/target-def.h:106:0,
 from 
/home/seurer/gcc/gcc-test2/gcc/config/rs6000/rs6000.c:77:
./target-hooks-def.h:92:38: error: 'hook_uint_uintp_false' was not 
declared in this scope

 #define TARGET_ASM_ELF_FLAGS_NUMERIC hook_uint_uintp_false
  ^
./target-hooks-def.h:2205:5: note: in expansion of macro 
'TARGET_ASM_ELF_FLAGS_NUMERIC'

 TARGET_ASM_ELF_FLAGS_NUMERIC, \
 ^~~~
./target-hooks-def.h:1792:5: note: in expansion of macro 'TARGET_ASM_OUT'
 TARGET_ASM_OUT, \
 ^~
/home/seurer/gcc/gcc-test2/gcc/config/rs6000/rs6000.c:40709:29: note: in 
expansion of macro 'TARGET_INITIALIZER'

 struct gcc_target targetm = TARGET_INITIALIZER;
 ^~
make[2]: *** [rs6000.o] Error 1


On 09/22/16 12:04, Andre Vieira (lists) wrote:

On 22/09/16 16:28, Richard Earnshaw (lists) wrote:

On 22/09/16 16:04, Andre Vieira (lists) wrote:


I reworked the patch according to the comments above.

Is this OK?

gcc/ChangeLog:
2016-09-22  Andre Vieira  
Terry Guo  

* target.def (elf_flags_numeric): New target hook.
* targhooks.h (default_asm_elf_flags_numeric): New.
* varasm.c (default_asm_elf_flags_numeric): New.
  (default_elf_asm_named_section): Use new target hook.
* config/arm/arm.opt (mpure-code): New.
* config/arm/arm.h (SECTION_ARM_PURECODE): New.
* config/arm/arm.c (arm_asm_init_sections): Add section
  attribute to default text section if -mpure-code.
  (arm_option_check_internal): Diagnose use of option with
  non supported targets and/or options.
  (arm_asm_elf_flags_numeric): New.
  (arm_function_section): New.
  (arm_elf_section_type_flags): New.
* config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Disable
  for -mpure-code.
* gcc/doc/texi (TARGET_ASM_ELF_FLAGS_NUMERIC): New.
* gcc/doc/texi.in (TARGET_ASM_ELF_FLAGS_NUMERIC): Likewise.



gcc/testsuite/ChangeLog:
2016-09-22  Andre Vieira  
Terry Guo  

* gcc.target/arm/pure-code/ffunction-sections.c: New.
* gcc.target/arm/pure-code/no-literal-pool.c: New.
* gcc.target/arm/pure-code/pure-code.exp: New.




I missed this last time around, but please can you wrap references to
SHF_ARM_PURECODE in the documentation with @code{...}.

OK with that change.

R.


Done. Committed as revision r240379.




--

-Bill Seurer



Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread Christophe Lyon
Hi Andre,


On 22 September 2016 at 19:04, Andre Vieira (lists)
 wrote:
> On 22/09/16 16:28, Richard Earnshaw (lists) wrote:
>> On 22/09/16 16:04, Andre Vieira (lists) wrote:
>>>
>>> I reworked the patch according to the comments above.
>>>
>>> Is this OK?
>>>
>>> gcc/ChangeLog:
>>> 2016-09-22  Andre Vieira  
>>> Terry Guo  
>>>
>>> * target.def (elf_flags_numeric): New target hook.
>>> * targhooks.h (default_asm_elf_flags_numeric): New.
>>> * varasm.c (default_asm_elf_flags_numeric): New.
>>>   (default_elf_asm_named_section): Use new target hook.
>>> * config/arm/arm.opt (mpure-code): New.
>>> * config/arm/arm.h (SECTION_ARM_PURECODE): New.
>>> * config/arm/arm.c (arm_asm_init_sections): Add section
>>>   attribute to default text section if -mpure-code.
>>>   (arm_option_check_internal): Diagnose use of option with
>>>   non supported targets and/or options.
>>>   (arm_asm_elf_flags_numeric): New.
>>>   (arm_function_section): New.
>>>   (arm_elf_section_type_flags): New.
>>> * config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Disable
>>>   for -mpure-code.
>>> * gcc/doc/texi (TARGET_ASM_ELF_FLAGS_NUMERIC): New.
>>> * gcc/doc/texi.in (TARGET_ASM_ELF_FLAGS_NUMERIC): Likewise.
>>>
>>>
>>>
>>> gcc/testsuite/ChangeLog:
>>> 2016-09-22  Andre Vieira  
>>> Terry Guo  
>>>
>>> * gcc.target/arm/pure-code/ffunction-sections.c: New.
>>> * gcc.target/arm/pure-code/no-literal-pool.c: New.
>>> * gcc.target/arm/pure-code/pure-code.exp: New.
>>>
>>>
>>
>> I missed this last time around, but please can you wrap references to
>> SHF_ARM_PURECODE in the documentation with @code{...}.
>>
>> OK with that change.
>>
>> R.
>
> Done. Committed as revision r240379.
>
This patch broke the aarch64 builds:
/tmp/9380062_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:14391:
error: ‘hook_uint_uintp_false’ was not declared in this s
cope
/tmp/9380062_6.tmpdir/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/config/aarch64/aarch64.c:14391:
error: too many initializers for ‘gcc_target::asm_out’
make[2]: *** [aarch64.o] Error 1
make[2]: Leaving directory
`/tmp/9380062_6.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc1/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory
`/tmp/9380062_6.tmpdir/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc1'
make: *** [all] Error 2


Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread David Edelsohn
This patch broke bootstrap.

In file included from
/nasfarm/edelsohn/src/src/gcc/target-def.h:106:0, from
/nasfarm/edelsohn/src/src/gcc/config/rs6000/rs6000.c:77:./target-hooks-def.h:92:38:
error: 'hook_uint_uintp_false' was not declared in this scope

 #define TARGET_ASM_ELF_FLAGS_NUMERIC hook_uint_uintp_false
  ^./target-hooks-def.h:2205:5: note: in
expansion of macro 'TARGET_ASM_ELF_FLAGS_NUMERIC'
TARGET_ASM_ELF_FLAGS_NUMERIC, \

 ^

./target-hooks-def.h:1792:5: note: in expansion of macro 'TARGET_ASM_OUT'

 TARGET_ASM_OUT, \

 ^

/nasfarm/edelsohn/src/src/gcc/config/rs6000/rs6000.c:40709:29: note:
in expansion of macro 'TARGET_INITIALIZER'

 struct gcc_target targetm = TARGET_INITIALIZER;


Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread Andre Vieira (lists)
On 22/09/16 16:28, Richard Earnshaw (lists) wrote:
> On 22/09/16 16:04, Andre Vieira (lists) wrote:
>>
>> I reworked the patch according to the comments above.
>>
>> Is this OK?
>>
>> gcc/ChangeLog:
>> 2016-09-22  Andre Vieira  
>> Terry Guo  
>>
>> * target.def (elf_flags_numeric): New target hook.
>> * targhooks.h (default_asm_elf_flags_numeric): New.
>> * varasm.c (default_asm_elf_flags_numeric): New.
>>   (default_elf_asm_named_section): Use new target hook.
>> * config/arm/arm.opt (mpure-code): New.
>> * config/arm/arm.h (SECTION_ARM_PURECODE): New.
>> * config/arm/arm.c (arm_asm_init_sections): Add section
>>   attribute to default text section if -mpure-code.
>>   (arm_option_check_internal): Diagnose use of option with
>>   non supported targets and/or options.
>>   (arm_asm_elf_flags_numeric): New.
>>   (arm_function_section): New.
>>   (arm_elf_section_type_flags): New.
>> * config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Disable
>>   for -mpure-code.
>> * gcc/doc/texi (TARGET_ASM_ELF_FLAGS_NUMERIC): New.
>> * gcc/doc/texi.in (TARGET_ASM_ELF_FLAGS_NUMERIC): Likewise.
>>
>>
>>
>> gcc/testsuite/ChangeLog:
>> 2016-09-22  Andre Vieira  
>> Terry Guo  
>>
>> * gcc.target/arm/pure-code/ffunction-sections.c: New.
>> * gcc.target/arm/pure-code/no-literal-pool.c: New.
>> * gcc.target/arm/pure-code/pure-code.exp: New.
>>
>>
> 
> I missed this last time around, but please can you wrap references to
> SHF_ARM_PURECODE in the documentation with @code{...}.
> 
> OK with that change.
> 
> R.

Done. Committed as revision r240379.

diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index f0cdd669191689bc5dcf3a7c2b60da5a2d201e3f..d10605cee0e6e0e07bbb4e1910d30c91443f8d17 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -2263,4 +2263,8 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
 /* For switching between functions with different target attributes.  */
 #define SWITCHABLE_TARGET 1
 
+/* Define SECTION_ARM_PURECODE as the ARM specific section attribute
+   representation for SHF_ARM_PURECODE in GCC.  */
+#define SECTION_ARM_PURECODE SECTION_MACH_DEP
+
 #endif /* ! GCC_ARM_H */
>From f1d08002e245776ff131fcdf498cc3a9acc87ca3 Mon Sep 17 00:00:00 2001
From: Andre Simoes Dias Vieira 
Date: Tue, 14 Jun 2016 11:17:12 +0100
Subject: [PATCH] mpure-code for ARM

---
 gcc/config/arm/arm.c   | 145 -
 gcc/config/arm/arm.h   |   4 +
 gcc/config/arm/arm.md  |   2 +-
 gcc/config/arm/arm.opt |   4 +
 gcc/config/arm/elf.h   |   3 +-
 gcc/doc/invoke.texi|  11 +-
 gcc/doc/tm.texi|  12 ++
 gcc/doc/tm.texi.in |   2 +
 gcc/hooks.c|  10 ++
 gcc/target.def |  16 +++
 .../gcc.target/arm/pure-code/ffunction-sections.c  |  17 +++
 gcc/testsuite/gcc.target/arm/pure-code/no-casesi.c |  29 +
 .../gcc.target/arm/pure-code/no-literal-pool.c |  68 ++
 .../gcc.target/arm/pure-code/pure-code.exp |  54 
 gcc/varasm.c   |  50 ---
 15 files changed, 397 insertions(+), 30 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/arm/pure-code/ffunction-sections.c
 create mode 100644 gcc/testsuite/gcc.target/arm/pure-code/no-casesi.c
 create mode 100644 gcc/testsuite/gcc.target/arm/pure-code/no-literal-pool.c
 create mode 100644 gcc/testsuite/gcc.target/arm/pure-code/pure-code.exp

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index f60955438d6f1cc5d996e7eacd4b453213044181..4d3f3d5b169dba636276093f1567b248e3035812 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -214,8 +214,8 @@ static bool arm_return_in_memory (const_tree, const_tree);
 static void arm_unwind_emit (FILE *, rtx_insn *);
 static bool arm_output_ttype (rtx);
 static void arm_asm_emit_except_personality (rtx);
-static void arm_asm_init_sections (void);
 #endif
+static void arm_asm_init_sections (void);
 static rtx arm_dwarf_register_span (rtx);
 
 static tree arm_cxx_guard_type (void);
@@ -299,7 +299,10 @@ static unsigned HOST_WIDE_INT arm_asan_shadow_offset (void);
 static void arm_sched_fusion_priority (rtx_insn *, int, int *, int*);
 static bool arm_can_output_mi_thunk (const_tree, HOST_WIDE_INT, HOST_WIDE_INT,
  const_tree);
-
+static section *arm_function_section (tree, enum node_frequency, bool, bool);
+static bool arm_asm_elf_flags_numeric (unsigned int flags, unsigned int *num);
+static unsigned int 

Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread Richard Earnshaw (lists)
On 22/09/16 16:04, Andre Vieira (lists) wrote:
> 
> I reworked the patch according to the comments above.
> 
> Is this OK?
> 
> gcc/ChangeLog:
> 2016-09-22  Andre Vieira  
> Terry Guo  
> 
> * target.def (elf_flags_numeric): New target hook.
> * targhooks.h (default_asm_elf_flags_numeric): New.
> * varasm.c (default_asm_elf_flags_numeric): New.
>   (default_elf_asm_named_section): Use new target hook.
> * config/arm/arm.opt (mpure-code): New.
> * config/arm/arm.h (SECTION_ARM_PURECODE): New.
> * config/arm/arm.c (arm_asm_init_sections): Add section
>   attribute to default text section if -mpure-code.
>   (arm_option_check_internal): Diagnose use of option with
>   non supported targets and/or options.
>   (arm_asm_elf_flags_numeric): New.
>   (arm_function_section): New.
>   (arm_elf_section_type_flags): New.
> * config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Disable
>   for -mpure-code.
> * gcc/doc/texi (TARGET_ASM_ELF_FLAGS_NUMERIC): New.
> * gcc/doc/texi.in (TARGET_ASM_ELF_FLAGS_NUMERIC): Likewise.
> 
> 
> 
> gcc/testsuite/ChangeLog:
> 2016-09-22  Andre Vieira  
> Terry Guo  
> 
> * gcc.target/arm/pure-code/ffunction-sections.c: New.
> * gcc.target/arm/pure-code/no-literal-pool.c: New.
> * gcc.target/arm/pure-code/pure-code.exp: New.
> 
> 

I missed this last time around, but please can you wrap references to
SHF_ARM_PURECODE in the documentation with @code{...}.

OK with that change.

R.

> 0001-mpure-code-for-ARM.patch
> 
> 
> diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
> index 
> f0cdd669191689bc5dcf3a7c2b60da5a2d201e3f..d10605cee0e6e0e07bbb4e1910d30c91443f8d17
>  100644
> --- a/gcc/config/arm/arm.h
> +++ b/gcc/config/arm/arm.h
> @@ -2263,4 +2263,8 @@ extern const char *host_detect_local_cpu (int argc, 
> const char **argv);
>  /* For switching between functions with different target attributes.  */
>  #define SWITCHABLE_TARGET 1
>  
> +/* Define SECTION_ARM_PURECODE as the ARM specific section attribute
> +   representation for SHF_ARM_PURECODE in GCC.  */
> +#define SECTION_ARM_PURECODE SECTION_MACH_DEP
> +
>  #endif /* ! GCC_ARM_H */
> From d0e5894dbe59ea87a3dfc9f681d5616f178ce3a7 Mon Sep 17 00:00:00 2001
> From: Andre Simoes Dias Vieira 
> Date: Tue, 14 Jun 2016 11:17:12 +0100
> Subject: [PATCH] mpure-code for ARM
> 
> ---
>  gcc/config/arm/arm.c   | 145 
> -
>  gcc/config/arm/arm.h   |   4 +
>  gcc/config/arm/arm.md  |   2 +-
>  gcc/config/arm/arm.opt |   4 +
>  gcc/config/arm/elf.h   |   3 +-
>  gcc/doc/invoke.texi|  11 +-
>  gcc/doc/tm.texi|  12 ++
>  gcc/doc/tm.texi.in |   2 +
>  gcc/hooks.c|  10 ++
>  gcc/target.def |  16 +++
>  gcc/targhooks.h|   1 -
>  .../gcc.target/arm/pure-code/ffunction-sections.c  |  17 +++
>  gcc/testsuite/gcc.target/arm/pure-code/no-casesi.c |  29 +
>  .../gcc.target/arm/pure-code/no-literal-pool.c |  68 ++
>  .../gcc.target/arm/pure-code/pure-code.exp |  54 
>  gcc/varasm.c   |  50 ---
>  16 files changed, 397 insertions(+), 31 deletions(-)
>  create mode 100644 
> gcc/testsuite/gcc.target/arm/pure-code/ffunction-sections.c
>  create mode 100644 gcc/testsuite/gcc.target/arm/pure-code/no-casesi.c
>  create mode 100644 gcc/testsuite/gcc.target/arm/pure-code/no-literal-pool.c
>  create mode 100644 gcc/testsuite/gcc.target/arm/pure-code/pure-code.exp
> 
> diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
> index 
> f60955438d6f1cc5d996e7eacd4b453213044181..59dc2d3392bf375e26507041309e219215198d62
>  100644
> --- a/gcc/config/arm/arm.c
> +++ b/gcc/config/arm/arm.c
> @@ -214,8 +214,8 @@ static bool arm_return_in_memory (const_tree, const_tree);
>  static void arm_unwind_emit (FILE *, rtx_insn *);
>  static bool arm_output_ttype (rtx);
>  static void arm_asm_emit_except_personality (rtx);
> -static void arm_asm_init_sections (void);
>  #endif
> +static void arm_asm_init_sections (void);
>  static rtx arm_dwarf_register_span (rtx);
>  
>  static tree arm_cxx_guard_type (void);
> @@ -299,7 +299,10 @@ static unsigned HOST_WIDE_INT arm_asan_shadow_offset 
> (void);
>  static void arm_sched_fusion_priority (rtx_insn *, int, int *, int*);
>  static bool arm_can_output_mi_thunk (const_tree, HOST_WIDE_INT, 
> HOST_WIDE_INT,
>const_tree);
> -
> +static section *arm_function_section (tree, 

Re: [PATCHv3][ARM] -mpure-code option for ARM

2016-09-22 Thread Andre Vieira (lists)
On 22/09/16 14:52, Richard Earnshaw (lists) wrote:
> On 11/07/16 17:56, Andre Vieira (lists) wrote:
>> On 07/07/16 13:30, mickael guene wrote:
>>> Hi Andre,
>>>
>>>  Another feedback on your purecode patch.
>>>  You have to disable casesi pattern since then it will
>>> generate wrong code with -mpure-code option.
>>>  Indeed it will generate an 'adr rx, .Lx' (aka
>>> 'subs rx, PC, #offset') which will not work in our
>>> case since 'Lx' label is put in an .rodata section.
>>> So offset value is unknown and can be impossible
>>> to encode correctly.
>>>
>>> Regards
>>> Mickael
>>>
>>> On 06/30/2016 04:32 PM, Andre Vieira (lists) wrote:
 Hello,

 This patch adds the -mpure-code option for ARM. This option ensures
 functions are put into sections that contain only code and no data. To
 ensure this throughout compilation we give these sections the ARM
 processor-specific ELF section attribute "SHF_ARM_PURECODE". This option
 is only supported for non-pic code for armv7-m targets.

 This patch introduces a new target hook 'TARGET_ASM_ELF_FLAGS_NUMERIC'.
 This target hook enables a target to use the numeric value for elf
 section attributes rather than their alphabetical representation. If
 TARGET_ASM_ELF_FLAGS_NUMERIC returns TRUE, the existing
 'default_elf_asm_named_section', will print the numeric value of the
 section attributes for the current section. This target hook has two
 parameters:
 unsigned int FLAGS, the input parameter that tells the function the
 current section's attributes;
 unsigned int *NUM, used to pass down the numerical representation of the
 section's attributes.

 The default implementation for TARGET_ASM_ELF_FLAGS_NUMERIC will return
 false, so existing behavior is not changed.

 Bootstrapped and tested for arm-none-linux-gnueabihf. Further tested for
 arm-none-eabi with a Cortex-M3 target.


 gcc/ChangeLog:
 2016-06-30  Andre Vieira  
 Terry Guo  

 * target.def (elf_flags_numeric): New target hook.
 * targhooks.h (default_asm_elf_flags_numeric): New.
 * varasm.c (default_asm_elf_flags_numeric): New.
   (default_elf_asm_named_section): Use new target hook.
 * config/arm/arm.opt (mpure-code): New.
 * config/arm/arm.h (SECTION_ARM_PURECODE): New.
 * config/arm/arm.c (arm_asm_init_sections): Add section
   attribute to default text section if -mpure-code.
   (arm_option_check_internal): Diagnose use of option with
   non supported targets and/or options.
   (arm_asm_elf_flags_numeric): New.
   (arm_function_section): New.
   (arm_elf_section_type_flags): New.
 * config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Disable
   for -mpure-code.
 * gcc/doc/texi (TARGET_ASM_ELF_FLAGS_NUMERIC): New.
 * gcc/doc/texi.in (TARGET_ASM_ELF_FLAGS_NUMERIC): Likewise.



 gcc/testsuite/ChangeLog:
 2016-06-30  Andre Vieira  
 Terry Guo  

 * gcc.target/arm/pure-code/ffunction-sections.c: New.
 * gcc.target/arm/pure-code/no-literal-pool.c: New.
 * gcc.target/arm/pure-code/pure-code.exp: New.

>>>
>> Hi Sandra, Mickael,
>>
>> Thank you for your comments. I changed the description of -mpure-code in
>> invoke.texi to better reflect the error message you get wrt supported
>> targets.
>>
>> As for the target hook description, I hope the text is clearer now. Let
>> me know if you think it needs further explanation.
>>
>> I also fixed the double '%' in the text string for unnamed text sections
>> and disabled the casesi pattern.
>>
>> I duplicated the original casesi test
>> 'gcc/testsuite/gcc.c-torture/compile/pr46934.c' for pure-code to make
>> sure the casesi was disabled and other patterns were selected instead.
>>
>> Reran regressions for pure-code.exp for Cortex-M3.
>>
>> Cheers,
>> Andre
>>
>>
>> gcc/ChangeLog:
>> 2016-07-11  Andre Vieira  
>> Terry Guo  
>>
>> * target.def (elf_flags_numeric): New target hook.
>> * hooks.c (hook_uint_uintp_false): New generic hook.
>> * varasm.c (default_elf_asm_named_section): Use new target hook.
>> * config/arm/arm.opt (mpure-code): New.
>> * config/arm/arm.h (SECTION_ARM_PURECODE): New.
>> * config/arm/arm.c (arm_asm_init_sections): Add section
>> attribute to default text section if -mpure-code.
>> (arm_option_check_internal): Diagnose use of option with
>> non supported targets and/or options.
>> (arm_asm_elf_flags_numeric): New.
>> (arm_function_section): New.
>> (arm_elf_section_type_flags): New.