Skip to content

Commit 880eb83

Browse files
committed
[SystemZ] Enable -mtune= option in clang.
https://reviews.llvm.org/D128910 enabled handling of attribute "tune-cpu" in LLVM. This PR now enables option `-mtune` in clang, which then generates the new attribute. Reviewed By: uweigand Differential Revision: https://reviews.llvm.org/D129562
1 parent 6589729 commit 880eb83

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

clang/docs/ClangCommandLineReference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,7 @@ Specify bit size of immediate TLS offsets (AArch64 ELF only): 12 (for 4KB) \| 24
33253325
.. option:: -mtune=<arg>
33263326
.. program:: clang
33273327

3328-
Only supported on X86 and RISC-V. Otherwise accepted for compatibility with GCC.
3328+
Only supported on X86, RISC-V and SystemZ. Otherwise accepted for compatibility with GCC.
33293329

33303330
.. option:: -mtvos-version-min=<arg>, -mappletvos-version-min=<arg>
33313331

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3950,7 +3950,7 @@ def module_file_info : Flag<["-"], "module-file-info">, Flags<[NoXarchOption,CC1
39503950
HelpText<"Provide information about a particular module file">;
39513951
def mthumb : Flag<["-"], "mthumb">, Group<m_Group>;
39523952
def mtune_EQ : Joined<["-"], "mtune=">, Group<m_Group>,
3953-
HelpText<"Only supported on X86 and RISC-V. Otherwise accepted for compatibility with GCC.">;
3953+
HelpText<"Only supported on X86, RISC-V and SystemZ. Otherwise accepted for compatibility with GCC.">;
39543954
def multi__module : Flag<["-"], "multi_module">;
39553955
def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
39563956
def multiply__defined : Separate<["-"], "multiply_defined">;

clang/lib/Basic/Targets/SystemZ.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
123123

124124
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
125125

126+
bool isValidTuneCPUName(StringRef Name) const override {
127+
return isValidCPUName(Name);
128+
}
129+
130+
void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const override {
131+
fillValidCPUList(Values);
132+
}
133+
126134
bool setCPU(const std::string &Name) override {
127135
CPU = Name;
128136
ISARevision = getISARevision(CPU);

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,8 +2228,23 @@ void Clang::AddSparcTargetArgs(const ArgList &Args,
22282228

22292229
void Clang::AddSystemZTargetArgs(const ArgList &Args,
22302230
ArgStringList &CmdArgs) const {
2231-
bool HasBackchain = Args.hasFlag(options::OPT_mbackchain,
2232-
options::OPT_mno_backchain, false);
2231+
if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
2232+
StringRef Name = A->getValue();
2233+
2234+
std::string TuneCPU;
2235+
if (Name == "native")
2236+
TuneCPU = std::string(llvm::sys::getHostCPUName());
2237+
else
2238+
TuneCPU = std::string(Name);
2239+
2240+
if (!TuneCPU.empty()) {
2241+
CmdArgs.push_back("-tune-cpu");
2242+
CmdArgs.push_back(Args.MakeArgString(TuneCPU));
2243+
}
2244+
}
2245+
2246+
bool HasBackchain =
2247+
Args.hasFlag(options::OPT_mbackchain, options::OPT_mno_backchain, false);
22332248
bool HasPackedStack = Args.hasFlag(options::OPT_mpacked_stack,
22342249
options::OPT_mno_packed_stack, false);
22352250
systemz::FloatABI FloatABI =

0 commit comments

Comments
 (0)