]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Give hint for -mcpu options that match -march instead
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Tue, 18 Apr 2023 11:15:35 +0000 (12:15 +0100)
committerKyrylo Tkachov <kyrylo.tkachov@arm.com>
Tue, 18 Apr 2023 11:15:35 +0000 (12:15 +0100)
We should redirect users of the erroneous -mcpu=armv8.2-a to use -march instead.
There is an equivalent hint for -march used with a CPU name.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_validate_mcpu): Add hint to use -march
if the argument matches that.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/spellcheck_11.c: New test.

gcc/config/aarch64/aarch64.cc
gcc/testsuite/gcc.target/aarch64/spellcheck_11.c [new file with mode: 0644]

index 0f04ab9fba025c5f8a76da87c521dc90127a48fd..adbdaaf860308231506590094d017717edc87151 100644 (file)
@@ -18139,6 +18139,12 @@ aarch64_validate_mcpu (const char *str, const struct processor **res,
       case AARCH_PARSE_INVALID_ARG:
        error ("unknown value %qs for %<-mcpu%>", str);
        aarch64_print_hint_for_core (str);
+       /* A common user error is confusing -march and -mcpu.
+          If the -mcpu string matches a known architecture then suggest
+          -march=.  */
+       parse_res = aarch64_parse_arch (str, res, isa_flags, &invalid_extension);
+       if (parse_res == AARCH_PARSE_OK)
+         inform (input_location, "did you mean %<-march=%s%>?", str);
        break;
       case AARCH_PARSE_INVALID_FEATURE:
        error ("invalid feature modifier %qs in %<-mcpu=%s%>",
diff --git a/gcc/testsuite/gcc.target/aarch64/spellcheck_11.c b/gcc/testsuite/gcc.target/aarch64/spellcheck_11.c
new file mode 100644 (file)
index 0000000..a278328
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-march=*" } { "" } } */
+/* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */
+/* { dg-options "-mcpu=armv8.2-a+dotprod" } */
+
+void
+foo ()
+{
+}
+
+/* { dg-error "unknown value .armv8.2-a\\+dotprod. for .-mcpu."  "" { target *-*-* } 0 } */
+/* { dg-message "valid arguments are: \[^\n\r]*"  "" { target *-*-* } 0 } */
+/* { dg-message "did you mean .-march=armv8.2-a\\+dotprod.?"  "" { target *-*-* } 0 } */