]> granicus.if.org Git - clang/commitdiff
print-supported-cpus quality of life patch.
authorZiang Wan <ziangw2@illinois.edu>
Tue, 25 Jun 2019 23:57:14 +0000 (23:57 +0000)
committerZiang Wan <ziangw2@illinois.edu>
Tue, 25 Jun 2019 23:57:14 +0000 (23:57 +0000)
Claim all input files so that clang does not give a warning. Add two
short-cut aliases: -mcpu=? and -mtune=?.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364362 91177308-0d34-0410-b5e6-96231b3b80d8

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

index bad91ff830d21f14ba04cc1db8e87333b7de6b6e..b7f94e98d494607dbfb7241baa07d2b5a4aa259d 100644 (file)
@@ -2168,6 +2168,8 @@ Link stack frames through backchain on System Z
 
 .. 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, single (posix by default)
 
 .. 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>
index f511022dd77ef5aafbd20720f5cee5ab85dce831..7b0873600fc3b1702766c6cd726726ab050ce4d1 100644 (file)
@@ -330,6 +330,10 @@ number of cross compilers, or may only support a native target.
   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
index d766b856b0a36ee81e2c86594d4ec845463e60a6..2cc5cbe819e968a910f31a56aa2fe5f707392641 100644 (file)
@@ -2648,6 +2648,8 @@ def _print_supported_cpus : Flag<["-", "--"], "print-supported-cpus">,
   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">,
index 925ded71e187b28c04c4ddce772bfe24052fc0b1..57ead2d6eb1b11b602991b41a0257b9bb43d5780 100644 (file)
@@ -3377,15 +3377,21 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
     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.
index b368a31dd615f4f8e74074d787ef6ba20a4b7da8..10985fea8a83e41cd68d996012a4afb128d2c500 100644 (file)
@@ -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
 // 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.