r364362 - print-supported-cpus quality of life patch.

Ziang Wan via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 16:57:14 PDT 2019


Author: ziangwan725
Date: Tue Jun 25 16:57:14 2019
New Revision: 364362

URL: http://llvm.org/viewvc/llvm-project?rev=364362&view=rev
Log:
print-supported-cpus quality of life patch.

Claim all input files so that clang does not give a warning. Add two
short-cut aliases: -mcpu=? and -mtune=?.

Modified:
    cfe/trunk/docs/ClangCommandLineReference.rst
    cfe/trunk/docs/CommandGuide/clang.rst
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/test/Driver/print-supported-cpus.c

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=364362&r1=364361&r2=364362&view=diff
==============================================================================
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Tue Jun 25 16:57:14 2019
@@ -2168,6 +2168,8 @@ Link stack frames through backchain on S
 
 .. option:: -mcpu=<arg>, -mv5 (equivalent to -mcpu=hexagonv5), -mv55 (equivalent to -mcpu=hexagonv55), -mv60 (equivalent to -mcpu=hexagonv60), -mv62 (equivalent to -mcpu=hexagonv62), -mv65 (equivalent to -mcpu=hexagonv65)
 
+Use -mcpu=? to see a list of supported cpu models.
+
 .. option:: -mcrc, -mno-crc
 
 Allow use of CRC instructions (ARM/Mips only)
@@ -2302,6 +2304,8 @@ The thread model to use, e.g. posix, sin
 
 .. option:: -mtune=<arg>
 
+Use -mtune=? to see a list of supported cpu models.
+
 .. option:: -mtvos-version-min=<arg>, -mappletvos-version-min=<arg>
 
 .. option:: -municode<arg>

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=364362&r1=364361&r2=364362&view=diff
==============================================================================
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Tue Jun 25 16:57:14 2019
@@ -330,6 +330,10 @@ number of cross compilers, or may only s
   through --target=<architecture> or -arch <architecture>). If no target is
   specified, the system default target will be used.
 
+.. option:: -mcpu=?, -mtune=?
+
+  Aliases of --print-supported-cpus
+
 .. option:: -march=<cpu>
 
   Specify that Clang should generate code for a specific processor family

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=364362&r1=364361&r2=364362&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Jun 25 16:57:14 2019
@@ -2648,6 +2648,8 @@ def _print_supported_cpus : Flag<["-", "
   Group<CompileOnly_Group>, Flags<[CC1Option, CoreOption]>,
   HelpText<"Print supported cpu models for the given target (if target is not specified,"
            " it will print the supported cpus for the default target)">;
+def mcpu_EQ_QUESTION : Flag<["-"], "mcpu=?">, Alias<_print_supported_cpus>;
+def mtune_EQ_QUESTION : Flag<["-"], "mtune=?">, Alias<_print_supported_cpus>;
 def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[DriverOption]>,
   HelpText<"Use the gcc toolchain at the given directory">;
 def time : Flag<["-"], "time">,

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=364362&r1=364361&r2=364362&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Jun 25 16:57:14 2019
@@ -3377,15 +3377,21 @@ void Driver::BuildActions(Compilation &C
     Args.ClaimAllArgs(options::OPT_cl_compile_Group);
   }
 
-  // If the use specify --print-supported-cpus, clang will only print out
-  // supported cpu names without doing compilation.
+  // if the user specify --print-supported-cpus, or use -mcpu=?, or use
+  // -mtune=? (aliases), clang will only print out supported cpu names
+  // without doing compilation.
   if (Arg *A = Args.getLastArg(options::OPT__print_supported_cpus)) {
-    Actions.clear();
     // the compilation now has only two phases: Input and Compile
     // use the --prints-supported-cpus flag as the dummy input to cc1
+    Actions.clear();
     Action *InputAc = C.MakeAction<InputAction>(*A, types::TY_C);
     Actions.push_back(
         C.MakeAction<PrecompileJobAction>(InputAc, types::TY_Nothing));
+    // claim all the input files to prevent argument unused warnings
+    for (auto &I : Inputs) {
+      const Arg *InputArg = I.second;
+      InputArg->claim();
+    }
   }
 
   // Claim ignored clang-cl options.

Modified: cfe/trunk/test/Driver/print-supported-cpus.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/print-supported-cpus.c?rev=364362&r1=364361&r2=364362&view=diff
==============================================================================
--- cfe/trunk/test/Driver/print-supported-cpus.c (original)
+++ cfe/trunk/test/Driver/print-supported-cpus.c Tue Jun 25 16:57:14 2019
@@ -1,6 +1,9 @@
 // Test that the --print-supported-cpus flag works
+// Also test its aliases: -mcpu=? and -mtune=?
 
 // REQUIRES: x86-registered-target
+// REQUIRES: arm-registered-target
+
 // RUN: %clang --target=x86_64-unknown-linux-gnu \
 // RUN:   --print-supported-cpus 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-X86
@@ -8,7 +11,13 @@
 // CHECK-X86: corei7
 // CHECK-X86: Use -mcpu or -mtune to specify the target's processor.
 
-// REQUIRES: arm-registered-target
+// RUN: %clang --target=x86_64-unknown-linux-gnu \
+// RUN:   -mcpu=? 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-X86-MCPU
+// CHECK-X86-MCPU: Target: x86_64-unknown-linux-gnu
+// CHECK-X86-MCPU: corei7
+// CHECK-X86-MCPU: Use -mcpu or -mtune to specify the target's processor.
+
 // RUN: %clang --target=arm-unknown-linux-android \
 // RUN:   --print-supported-cpus 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-ARM
@@ -16,3 +25,11 @@
 // CHECK-ARM: cortex-a73
 // CHECK-ARM: cortex-a75
 // CHECK-ARM: Use -mcpu or -mtune to specify the target's processor.
+
+// RUN: %clang --target=arm-unknown-linux-android \
+// RUN:   -mtune=? 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ARM-MTUNE
+// CHECK-ARM-MTUNE: Target: arm-unknown-linux-android
+// CHECK-ARM-MTUNE: cortex-a73
+// CHECK-ARM-MTUNE: cortex-a75
+// CHECK-ARM-MTUNE: Use -mcpu or -mtune to specify the target's processor.




More information about the cfe-commits mailing list