Add support for --with-tune. Like --with-cpu and --with-arch, the argument is validated and transformed into a -mtune option to be processed like any other command-line option. --with-tune has no effect if a -mcpu or -mtune option is used. The validating code didn't allow --with-cpu=native, so explicitly allow that.
Co-authored-by: Delia Burduv <delia.bur...@arm.com> Bootstrap OK, regress pass, OK to commit? ChangeLog 2020-09-03 Wilco Dijkstra <wdijk...@arm.com> * config.gcc (aarch64*-*-*): Add --with-tune. Support --with-cpu=native. * config/aarch64/aarch64.h (OPTION_DEFAULT_SPECS): Add --with-tune. 2020-09-03 Wilco Dijkstra <wdijk...@arm.com> * gcc/testsuite/lib/target-supports.exp: (check_effective_target_tune_cortex_a76): New effective target test. * gcc.target/aarch64/with-tune-config.c: New test. * gcc.target/aarch64/with-tune-march.c: Likewise. * gcc.target/aarch64/with-tune-mcpu.c: Likewise. * gcc.target/aarch64/with-tune-mtune.c: Likewise. --- diff --git a/gcc/config.gcc b/gcc/config.gcc index 918320573ade712ddc252045e0b70fb8b65e0c66..947cebb0960d403a9ce40b65bef948fbbe8916a9 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -4052,8 +4052,8 @@ fi supported_defaults= case "${target}" in aarch64*-*-*) - supported_defaults="abi cpu arch" - for which in cpu arch; do + supported_defaults="abi cpu arch tune" + for which in cpu arch tune; do eval "val=\$with_$which" base_val=`echo $val | sed -e 's/\+.*//'` @@ -4074,6 +4074,12 @@ case "${target}" in ${srcdir}/config/aarch64/$def \ > /dev/null; then + # Disallow extensions in --with-tune=cortex-a53+crc. + if [ $which = tune ] && [ x"$ext_val" != x ]; then + echo "Architecture extensions not supported in --with-$which=$val" 1>&2 + exit 1 + fi + # Use the pre-processor to strip flatten the options. # This makes the format less rigid than if we use # grep and sed directly here. @@ -4109,8 +4115,13 @@ case "${target}" in true else - echo "Unknown $which used in --with-$which=$val" 1>&2 - exit 1 + # Allow --with-$which=native. + if [ "$val" = native ]; then + true + else + echo "Unknown $which used in --with-$which=$val" 1>&2 + exit 1 + fi fi done ;; diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 30b3a28a6d2893cc29bec4aa5b7cfbe1fd51e0b7..09d1f7f8a84e726129f8ec7f59dacae7fe132eaa 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -1200,12 +1200,14 @@ extern enum aarch64_code_model aarch64_cmodel; #define ENDIAN_LANE_N(NUNITS, N) \ (BYTES_BIG_ENDIAN ? NUNITS - 1 - N : N) -/* Support for a configure-time default CPU, etc. We currently support - --with-arch and --with-cpu. Both are ignored if either is specified - explicitly on the command line at run time. */ +/* Support for configure-time --with-arch, --with-cpu and --with-tune. + --with-arch and --with-cpu are ignored if either -mcpu or -march is used. + --with-tune is ignored if either -mtune or -mcpu is used (but is not + affected by -march). */ #define OPTION_DEFAULT_SPECS \ {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \ - {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, + {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ + {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}"}, #define MCPU_TO_MARCH_SPEC \ " %{mcpu=*:-march=%:rewrite_mcpu(%{mcpu=*:%*})}" diff --git a/gcc/testsuite/gcc.target/aarch64/with-tune-config.c b/gcc/testsuite/gcc.target/aarch64/with-tune-config.c new file mode 100644 index 0000000000000000000000000000000000000000..0940e9eea892770fada0b9bc0e05e22bebef1167 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/with-tune-config.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { tune_cortex_a76 } } } */ +/* { dg-additional-options " -dA " } */ + +void foo () +{} + +/* { dg-final { scan-assembler "//.tune cortex-a76" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/with-tune-march.c b/gcc/testsuite/gcc.target/aarch64/with-tune-march.c new file mode 100644 index 0000000000000000000000000000000000000000..61039adea71878222dc27633d0818bac2daefeea --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/with-tune-march.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target { tune_cortex_a76 } } } */ +/* { dg-additional-options " -dA -march=armv8.6-a " } */ + +void foo () +{} + +/* { dg-final { scan-assembler "//.tune cortex-a76" } } */ +/* { dg-final { scan-assembler ".arch armv8.6-a" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/with-tune-mcpu.c b/gcc/testsuite/gcc.target/aarch64/with-tune-mcpu.c new file mode 100644 index 0000000000000000000000000000000000000000..4f8267a5c167cbeda28537811a4f41d51afb05b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/with-tune-mcpu.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target { tune_cortex_a76 } } } */ +/* { dg-additional-options " -dA -mcpu=cortex-a73" } */ + +void foo () +{} + +/* { dg-final { scan-assembler "//.tune cortex-a73" } } */ +/* { dg-final { scan-assembler ".arch armv8-a" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/with-tune-mtune.c b/gcc/testsuite/gcc.target/aarch64/with-tune-mtune.c new file mode 100644 index 0000000000000000000000000000000000000000..60f795a3919968153ba7bf092e22b135d9078294 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/with-tune-mtune.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { tune_cortex_a76 } } } */ +/* { dg-additional-options " -dA -mtune=cortex-a73" } */ + +void foo () +{} + +/* { dg-final { scan-assembler "//.tune cortex-a73" } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index f3fc5b80aea34911536de6535c9ca28c9a3d83a6..bbf03624c0960053cd4a7333d991bae0c67d225b 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -10435,6 +10435,11 @@ proc check_effective_target_msp430_large {} { } ""] } +# Return 1 if GCC was configured with --with-tune=cortex-a76 +proc check_effective_target_tune_cortex_a76 { } { + return [check_configured_with "with-tune=cortex-a76"] +} + # Return 1 if the target has an efficient means to encode large initializers # in the assembly.