[clang] 003078b - [Clang][Driver] Add -mcpu=help and -mtune=help to clang

Michael Maitland via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 28 10:46:27 PST 2023


Author: Michael Maitland
Date: 2023-02-28T10:45:35-08:00
New Revision: 003078b62d8d40fc000462a97c3b70e01cbe4458

URL: https://github.com/llvm/llvm-project/commit/003078b62d8d40fc000462a97c3b70e01cbe4458
DIFF: https://github.com/llvm/llvm-project/commit/003078b62d8d40fc000462a97c3b70e01cbe4458.diff

LOG: [Clang][Driver] Add -mcpu=help and -mtune=help to clang

Clang currently uses `-mcpu=?` and `-mtune=?`. The `?` causes errors on some
shells such as zsh since it is a special character. In order for it to work on
shells such as zsh, the option must be passed in quotes or escaped. This patch
adds `-mcpu=help` and `-mtune=help` as another alias for `--print-supported-cpus`.
In llc, `-mcpu=help` is an alias to print supported cpus.

Differential Revision: https://reviews.llvm.org/D144914

Added: 
    

Modified: 
    clang/docs/CommandGuide/clang.rst
    clang/include/clang/Driver/Options.td
    clang/test/Driver/print-supported-cpus.c

Removed: 
    


################################################################################
diff  --git a/clang/docs/CommandGuide/clang.rst b/clang/docs/CommandGuide/clang.rst
index 7277b598f0cad..7fae1b5cec53c 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -373,6 +373,10 @@ number of cross compilers, or may only support a native target.
 
   Acts as an alias for :option:`--print-supported-cpus`.
 
+.. option:: -mcpu=help, -mtune=help
+
+  Acts as an alias for :option:`--print-supported-cpus`.
+
 .. option:: -march=<cpu>
 
   Specify that Clang should generate code for a specific processor family

diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 5b6c0e6e914d0..6bf5fafd6d7cc 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4347,6 +4347,8 @@ def print_supported_cpus : Flag<["-", "--"], "print-supported-cpus">,
   MarshallingInfoFlag<FrontendOpts<"PrintSupportedCPUs">>;
 def mcpu_EQ_QUESTION : Flag<["-"], "mcpu=?">, Alias<print_supported_cpus>;
 def mtune_EQ_QUESTION : Flag<["-"], "mtune=?">, Alias<print_supported_cpus>;
+def mcpu_EQ_help : Flag<["-"], "mcpu=help">, Alias<print_supported_cpus>;
+def mtune_EQ_help : Flag<["-"], "mtune=help">, Alias<print_supported_cpus>;
 def time : Flag<["-"], "time">,
   HelpText<"Time individual commands">;
 def traditional_cpp : Flag<["-", "--"], "traditional-cpp">, Flags<[CC1Option]>,

diff  --git a/clang/test/Driver/print-supported-cpus.c b/clang/test/Driver/print-supported-cpus.c
index 468382cd955fe..8e79a011fbec8 100644
--- a/clang/test/Driver/print-supported-cpus.c
+++ b/clang/test/Driver/print-supported-cpus.c
@@ -13,6 +13,13 @@
 // RUN: %clang --target=x86_64-unknown-linux-gnu -mtune=? -fuse-ld=dummy 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CHECK-X86
 
+// Test -mcpu=help and -mtune=help alises.
+// RUN: %clang --target=x86_64-unknown-linux-gnu -mcpu=help 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-X86
+
+// RUN: %clang --target=x86_64-unknown-linux-gnu -mtune=help -fuse-ld=dummy 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-X86
+
 // CHECK-NOT: warning: argument unused during compilation
 // CHECK-X86: Target: x86_64-unknown-linux-gnu
 // CHECK-X86: corei7


        


More information about the cfe-commits mailing list