Skip to content

Commit de94ac9

Browse files
committed
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=?. llvm-svn: 364362
1 parent 17c18a9 commit de94ac9

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

clang/docs/ClangCommandLineReference.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,6 +2168,8 @@ Link stack frames through backchain on System Z
21682168

21692169
.. 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)
21702170

2171+
Use -mcpu=? to see a list of supported cpu models.
2172+
21712173
.. option:: -mcrc, -mno-crc
21722174

21732175
Allow use of CRC instructions (ARM/Mips only)
@@ -2302,6 +2304,8 @@ The thread model to use, e.g. posix, single (posix by default)
23022304

23032305
.. option:: -mtune=<arg>
23042306

2307+
Use -mtune=? to see a list of supported cpu models.
2308+
23052309
.. option:: -mtvos-version-min=<arg>, -mappletvos-version-min=<arg>
23062310

23072311
.. option:: -municode<arg>

clang/docs/CommandGuide/clang.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ number of cross compilers, or may only support a native target.
330330
through --target=<architecture> or -arch <architecture>). If no target is
331331
specified, the system default target will be used.
332332

333+
.. option:: -mcpu=?, -mtune=?
334+
335+
Aliases of --print-supported-cpus
336+
333337
.. option:: -march=<cpu>
334338

335339
Specify that Clang should generate code for a specific processor family

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,8 @@ def _print_supported_cpus : Flag<["-", "--"], "print-supported-cpus">,
26482648
Group<CompileOnly_Group>, Flags<[CC1Option, CoreOption]>,
26492649
HelpText<"Print supported cpu models for the given target (if target is not specified,"
26502650
" it will print the supported cpus for the default target)">;
2651+
def mcpu_EQ_QUESTION : Flag<["-"], "mcpu=?">, Alias<_print_supported_cpus>;
2652+
def mtune_EQ_QUESTION : Flag<["-"], "mtune=?">, Alias<_print_supported_cpus>;
26512653
def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[DriverOption]>,
26522654
HelpText<"Use the gcc toolchain at the given directory">;
26532655
def time : Flag<["-"], "time">,

clang/lib/Driver/Driver.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,15 +3377,21 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
33773377
Args.ClaimAllArgs(options::OPT_cl_compile_Group);
33783378
}
33793379

3380-
// If the use specify --print-supported-cpus, clang will only print out
3381-
// supported cpu names without doing compilation.
3380+
// if the user specify --print-supported-cpus, or use -mcpu=?, or use
3381+
// -mtune=? (aliases), clang will only print out supported cpu names
3382+
// without doing compilation.
33823383
if (Arg *A = Args.getLastArg(options::OPT__print_supported_cpus)) {
3383-
Actions.clear();
33843384
// the compilation now has only two phases: Input and Compile
33853385
// use the --prints-supported-cpus flag as the dummy input to cc1
3386+
Actions.clear();
33863387
Action *InputAc = C.MakeAction<InputAction>(*A, types::TY_C);
33873388
Actions.push_back(
33883389
C.MakeAction<PrecompileJobAction>(InputAc, types::TY_Nothing));
3390+
// claim all the input files to prevent argument unused warnings
3391+
for (auto &I : Inputs) {
3392+
const Arg *InputArg = I.second;
3393+
InputArg->claim();
3394+
}
33893395
}
33903396

33913397
// Claim ignored clang-cl options.
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
// Test that the --print-supported-cpus flag works
2+
// Also test its aliases: -mcpu=? and -mtune=?
23

34
// REQUIRES: x86-registered-target
5+
// REQUIRES: arm-registered-target
6+
47
// RUN: %clang --target=x86_64-unknown-linux-gnu \
58
// RUN: --print-supported-cpus 2>&1 \
69
// RUN: | FileCheck %s --check-prefix=CHECK-X86
710
// CHECK-X86: Target: x86_64-unknown-linux-gnu
811
// CHECK-X86: corei7
912
// CHECK-X86: Use -mcpu or -mtune to specify the target's processor.
1013

11-
// REQUIRES: arm-registered-target
14+
// RUN: %clang --target=x86_64-unknown-linux-gnu \
15+
// RUN: -mcpu=? 2>&1 \
16+
// RUN: | FileCheck %s --check-prefix=CHECK-X86-MCPU
17+
// CHECK-X86-MCPU: Target: x86_64-unknown-linux-gnu
18+
// CHECK-X86-MCPU: corei7
19+
// CHECK-X86-MCPU: Use -mcpu or -mtune to specify the target's processor.
20+
1221
// RUN: %clang --target=arm-unknown-linux-android \
1322
// RUN: --print-supported-cpus 2>&1 \
1423
// RUN: | FileCheck %s --check-prefix=CHECK-ARM
1524
// CHECK-ARM: Target: arm-unknown-linux-android
1625
// CHECK-ARM: cortex-a73
1726
// CHECK-ARM: cortex-a75
1827
// CHECK-ARM: Use -mcpu or -mtune to specify the target's processor.
28+
29+
// RUN: %clang --target=arm-unknown-linux-android \
30+
// RUN: -mtune=? 2>&1 \
31+
// RUN: | FileCheck %s --check-prefix=CHECK-ARM-MTUNE
32+
// CHECK-ARM-MTUNE: Target: arm-unknown-linux-android
33+
// CHECK-ARM-MTUNE: cortex-a73
34+
// CHECK-ARM-MTUNE: cortex-a75
35+
// CHECK-ARM-MTUNE: Use -mcpu or -mtune to specify the target's processor.

0 commit comments

Comments
 (0)