On Fri, Sep 25, 2015 at 02:59:41PM +0100, Dominik Vogt wrote: > The following set of two patches implements the function > __attribute__ ((target("..."))) and the corresponding #pragma GCC > target("...") on S/390. It comes with certain limitations: > > * It is not possible to change any options that affect the ABI or > the definition of target macros by using the attribute (vx, > htm, zarch and others). Some of them are still supported but > unable to change the definition of the corresponding target macros. > In these cases, the pragma has to be used. One reason for this > is that it is not possible to change the definition of the target > macros with the attribute, but the implementation of some features > relies on them. > > * Even with the pragma it is not possible to switch between zarch > and esa architecture because internal data typed would have to be > changed at Gcc run time. > > The second patch contains a long term change in the interface with > the assembler. Currently, the compiler wrapper passes the same > -march= and -mtune= options to the compiler and the assembler. > The patch makes this obsolete by emitting ".machine" and > ".machinemode" dirctives to the top of the assembly language file. > The old way ist still supported but may be removed once the > ".machine" feature is supported by all as versions in the field. > > The second patch depends on the first one, and both require the > (latest) change proposed in this thread: > https://gcc.gnu.org/ml/gcc-patches/2015-09/msg01546.html
Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany
gcc/ChangeLog * config/s390/s390.c (s390_asm_file_start): Implement hook function to emit .machine and .machinemode to the top of the assembler file. (TARGET_ASM_FILE_START): Provide target hook. (s390_asm_output_machine_for_arch): Protect with HAVE_AS_MACHINE_MACHINEMODE instead of S390_USE_TARGET_ATTRIBUTE. gcc/testsuite/ChangeLog * gcc.target/s390/asm-machine-1.c: Updated. * gcc.target/s390/asm-machine-2.c: Updated. * gcc.target/s390/asm-machine-3.c: Updated. * gcc.target/s390/asm-machine-4.c: Updated.
>From 43563dc64dc8574493d5361140dbff2fbd366a27 Mon Sep 17 00:00:00 2001 From: Dominik Vogt <v...@linux.vnet.ibm.com> Date: Fri, 28 Aug 2015 10:39:10 +0100 Subject: [PATCH 2/2] S/390: Emit .machine and .machinemode at start of assembler files. --- gcc/config/s390/s390.c | 16 +++++++++++++++- gcc/testsuite/gcc.target/s390/asm-machine-1.c | 7 +++++-- gcc/testsuite/gcc.target/s390/asm-machine-2.c | 9 ++++++--- gcc/testsuite/gcc.target/s390/asm-machine-3.c | 9 ++++++--- gcc/testsuite/gcc.target/s390/asm-machine-4.c | 9 ++++++--- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index c40f1c5..2711301 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -6723,7 +6723,7 @@ s390_function_num_hotpatch_hw (tree decl, /* Write the current .machine and .machinemode specification to the assembler file. */ -#if S390_USE_TARGET_ATTRIBUTE +#ifdef HAVE_AS_MACHINE_MACHINEMODE static void s390_asm_output_machine_for_arch (FILE *asm_out_file) { @@ -14363,6 +14363,15 @@ s390_vector_alignment (const_tree type) return MIN (64, tree_to_shwi (TYPE_SIZE (type))); } +#ifdef HAVE_AS_MACHINE_MACHINEMODE +/* Implement TARGET_ASM_FILE_START. */ +static void +s390_asm_file_start (void) +{ + s390_asm_output_machine_for_arch (asm_out_file); +} +#endif + /* Implement TARGET_ASM_FILE_END. */ static void s390_asm_file_end (void) @@ -14662,6 +14671,11 @@ s390_invalid_binary_op (int op ATTRIBUTE_UNUSED, const_tree type1, const_tree ty #undef TARGET_INVALID_BINARY_OP #define TARGET_INVALID_BINARY_OP s390_invalid_binary_op +#ifdef HAVE_AS_MACHINE_MACHINEMODE +#undef TARGET_ASM_FILE_START +#define TARGET_ASM_FILE_START s390_asm_file_start +#endif + #undef TARGET_ASM_FILE_END #define TARGET_ASM_FILE_END s390_asm_file_end diff --git a/gcc/testsuite/gcc.target/s390/asm-machine-1.c b/gcc/testsuite/gcc.target/s390/asm-machine-1.c index a5326e1..430d923 100644 --- a/gcc/testsuite/gcc.target/s390/asm-machine-1.c +++ b/gcc/testsuite/gcc.target/s390/asm-machine-1.c @@ -3,7 +3,10 @@ /* { dg-require-effective-target target_attribute } */ /* { dg-options "-march=z13 -mzarch" } */ +/* { dg-final { scan-assembler-times "\t\.machine \"z13\"" 1 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 1 } } */ + void foo(void) { } -/* { dg-final { scan-assembler-not "\t\.machine " } } */ -/* { dg-final { scan-assembler-not "\t\.machinemode " } } */ +/* { dg-final { scan-assembler-times "\t\.machine " 1 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode " 1 } } */ diff --git a/gcc/testsuite/gcc.target/s390/asm-machine-2.c b/gcc/testsuite/gcc.target/s390/asm-machine-2.c index 910438e..6817e2a 100644 --- a/gcc/testsuite/gcc.target/s390/asm-machine-2.c +++ b/gcc/testsuite/gcc.target/s390/asm-machine-2.c @@ -3,6 +3,9 @@ /* { dg-require-effective-target target_attribute } */ /* { dg-options "-march=z13 -mzarch" } */ +/* { dg-final { scan-assembler-times "\t\.machine \"z13\"" 1 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 2 } } */ + void foo(void) { } __attribute__ ((target("arch=z10"))) @@ -12,8 +15,8 @@ void bar(void) { } /* { dg-final { scan-assembler-times "\t\.machine pop" 1 } } */ /* { dg-final { scan-assembler-times "\t\.machine \"z10\"" 1 } } */ /* { dg-final { scan-assembler-times "\t\.machinemode push" 1 } } */ -/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 1 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 2 } } */ /* { dg-final { scan-assembler-times "\t\.machinemode pop" 1 } } */ -/* { dg-final { scan-assembler-times "\t\.machine " 3 } } */ -/* { dg-final { scan-assembler-times "\t\.machinemode " 3 } } */ +/* { dg-final { scan-assembler-times "\t\.machine " 4 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode " 4 } } */ diff --git a/gcc/testsuite/gcc.target/s390/asm-machine-3.c b/gcc/testsuite/gcc.target/s390/asm-machine-3.c index b056b19..3ae57a8 100644 --- a/gcc/testsuite/gcc.target/s390/asm-machine-3.c +++ b/gcc/testsuite/gcc.target/s390/asm-machine-3.c @@ -3,6 +3,9 @@ /* { dg-require-effective-target target_attribute } */ /* { dg-options "-march=z13 -mzarch" } */ +/* { dg-final { scan-assembler-times "\t\.machine \"z13\"" 1 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 2 } } */ + void foo(void) { } #pragma GCC target("arch=z10") @@ -12,8 +15,8 @@ void bar(void) { } /* { dg-final { scan-assembler-times "\t\.machine pop" 1 } } */ /* { dg-final { scan-assembler-times "\t\.machine \"z10\"" 1 } } */ /* { dg-final { scan-assembler-times "\t\.machinemode push" 1 } } */ -/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 1 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 2 } } */ /* { dg-final { scan-assembler-times "\t\.machinemode pop" 1 } } */ -/* { dg-final { scan-assembler-times "\t\.machine " 3 } } */ -/* { dg-final { scan-assembler-times "\t\.machinemode " 3 } } */ +/* { dg-final { scan-assembler-times "\t\.machine " 4 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode " 4 } } */ diff --git a/gcc/testsuite/gcc.target/s390/asm-machine-4.c b/gcc/testsuite/gcc.target/s390/asm-machine-4.c index af9ab1c..932bfe6 100644 --- a/gcc/testsuite/gcc.target/s390/asm-machine-4.c +++ b/gcc/testsuite/gcc.target/s390/asm-machine-4.c @@ -3,6 +3,9 @@ /* { dg-require-effective-target target_attribute } */ /* { dg-options "-march=z13 -mzarch" } */ +/* { dg-final { scan-assembler-times "\t\.machine \"z13\"" 1 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 2 } } */ + void foo(void) { } #pragma GCC target("arch=z196") @@ -13,8 +16,8 @@ void bar(void) { } /* { dg-final { scan-assembler-times "\t\.machine pop" 1 } } */ /* { dg-final { scan-assembler-times "\t\.machine \"z10\"" 1 } } */ /* { dg-final { scan-assembler-times "\t\.machinemode push" 1 } } */ -/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 1 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode zarch" 2 } } */ /* { dg-final { scan-assembler-times "\t\.machinemode pop" 1 } } */ -/* { dg-final { scan-assembler-times "\t\.machine " 3 } } */ -/* { dg-final { scan-assembler-times "\t\.machinemode " 3 } } */ +/* { dg-final { scan-assembler-times "\t\.machine " 4 } } */ +/* { dg-final { scan-assembler-times "\t\.machinemode " 4 } } */ -- 2.3.0