craig.topper created this revision. craig.topper added reviewers: rnk, thakis, hans, echristo, erichkeane. Herald added subscribers: dang, danielkiss. craig.topper requested review of this revision.
We recently added support for -mtune. This patch adds /tune: so we can specify the tune CPU from clang-cl. MSVC doesn't support this but icc does. https://reviews.llvm.org/D86820 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/cl-x86-flags.c Index: clang/test/Driver/cl-x86-flags.c =================================================================== --- clang/test/Driver/cl-x86-flags.c +++ clang/test/Driver/cl-x86-flags.c @@ -128,5 +128,9 @@ // RUN: %clang_cl -m64 -arch:avx512 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx51264 %s // avx51264: argument unused during compilation +// RUN: %clang_cl -m64 -arch:AVX -tune:haswell --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=tune %s +// tune: "-target-cpu" "sandybridge" +// tune-SAME: "-tune-cpu" "haswell" + void f() { } Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2080,8 +2080,9 @@ if (!Args.hasArg(clang::driver::options::OPT_march_EQ)) TuneCPU = "generic"; - // Override based on -mtune. - if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) { + // Override based on -mtune or /tune: + if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ, + clang::driver::options::OPT__SLASH_tune)) { StringRef Name = A->getValue(); if (Name == "native") { Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -4690,6 +4690,8 @@ def _SLASH_arch : CLCompileJoined<"arch:">, HelpText<"Set architecture for code generation">; +def _SLASH_tune : CLCompileJoined<"tune:">, + HelpText<"Set CPU for optimization without affecting instruction set">; def _SLASH_M_Group : OptionGroup<"</M group>">, Group<cl_compile_Group>; def _SLASH_volatile_Group : OptionGroup<"</volatile group>">,
Index: clang/test/Driver/cl-x86-flags.c =================================================================== --- clang/test/Driver/cl-x86-flags.c +++ clang/test/Driver/cl-x86-flags.c @@ -128,5 +128,9 @@ // RUN: %clang_cl -m64 -arch:avx512 --target=i386-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=avx51264 %s // avx51264: argument unused during compilation +// RUN: %clang_cl -m64 -arch:AVX -tune:haswell --target=x86_64-pc-windows -### -- 2>&1 %s | FileCheck -check-prefix=tune %s +// tune: "-target-cpu" "sandybridge" +// tune-SAME: "-tune-cpu" "haswell" + void f() { } Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2080,8 +2080,9 @@ if (!Args.hasArg(clang::driver::options::OPT_march_EQ)) TuneCPU = "generic"; - // Override based on -mtune. - if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) { + // Override based on -mtune or /tune: + if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ, + clang::driver::options::OPT__SLASH_tune)) { StringRef Name = A->getValue(); if (Name == "native") { Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -4690,6 +4690,8 @@ def _SLASH_arch : CLCompileJoined<"arch:">, HelpText<"Set architecture for code generation">; +def _SLASH_tune : CLCompileJoined<"tune:">, + HelpText<"Set CPU for optimization without affecting instruction set">; def _SLASH_M_Group : OptionGroup<"</M group>">, Group<cl_compile_Group>; def _SLASH_volatile_Group : OptionGroup<"</volatile group>">,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits