]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AArch64: Add support for --with-tune
authorWilco Dijkstra <wdijkstr@arm.com>
Thu, 3 Dec 2020 18:40:34 +0000 (18:40 +0000)
committerSebastian Pop <spop@amazon.com>
Mon, 14 Dec 2020 17:57:06 +0000 (17:57 +0000)
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.burduv@arm.com>
Bootstrap OK, regress pass, OK to commit?

2020-09-03  Wilco Dijkstra  <wdijkstr@arm.com>

gcc/
* config.gcc (aarch64*-*-*): Add --with-tune. Support --with-cpu=native.
* config/aarch64/aarch64.h (OPTION_DEFAULT_SPECS): Add --with-tune.

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.

gcc/config.gcc
gcc/config/aarch64/aarch64.h
gcc/testsuite/gcc.target/aarch64/with-tune-config.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/with-tune-march.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/with-tune-mcpu.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/with-tune-mtune.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp

index 5af380a3cf407b5bfb69add8127619da129f72a3..01dde36d80558c43fee095d54ad0b34d0897a534 100644 (file)
@@ -4114,6 +4114,12 @@ case "${target}" in
                                  sed -e 's/,.*$//'`
                          fi
 
+                         # 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.
@@ -4171,8 +4177,13 @@ case "${target}" in
                          fi
                          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
                ;;
index 01512a89ab7de4c92e4bf3337ae9f725dffd9b68..5114884634507e9c14c288a7394fd36bc95ed6f3 100644 (file)
@@ -1184,12 +1184,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 (file)
index 0000000..0940e9e
--- /dev/null
@@ -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 (file)
index 0000000..61039ad
--- /dev/null
@@ -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 (file)
index 0000000..4f8267a
--- /dev/null
@@ -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 (file)
index 0000000..60f795a
--- /dev/null
@@ -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" } } */
index 8ec9f1cf1aaf2c98841d0bb827b3656593f06480..9575c7d8f8cf9db5c373c17c9889d6a3596e63e4 100644 (file)
@@ -10346,3 +10346,8 @@ proc check_effective_target_movdir { } {
        }
     } "-mmovdiri -mmovdir64b" ]
 }
+
+# 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"]
+}