[PATCH] R600: Handle -mcpu option
Tom Stellard
tom at stellard.net
Tue Mar 12 13:21:38 PDT 2013
From: Tom Stellard <thomas.stellard at amd.com>
---
lib/Driver/Tools.cpp | 19 +++++++++++++++++++
lib/Driver/Tools.h | 1 +
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 62b1feb..b0de2a8 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -1108,6 +1108,21 @@ void Clang::AddPPCTargetArgs(const ArgList &Args,
}
}
+/// Get the (LLVM) name of the R600 gpu we are targeting.
+static std::string getR600TargetGPU(const ArgList &Args) {
+ if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+ return A->getValue();
+ }
+ return "";
+}
+
+void Clang::AddR600TargetArgs(const ArgList &Args,
+ ArgStringList &CmdArgs) const {
+ std::string TargetGPUName = getR600TargetGPU(Args);
+ CmdArgs.push_back("-target-cpu");
+ CmdArgs.push_back(Args.MakeArgString(TargetGPUName.c_str()));
+}
+
void Clang::AddSparcTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
const Driver &D = getToolChain().getDriver();
@@ -2230,6 +2245,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
AddPPCTargetArgs(Args, CmdArgs);
break;
+ case llvm::Triple::r600:
+ AddR600TargetArgs(Args, CmdArgs);
+ break;
+
case llvm::Triple::sparc:
AddSparcTargetArgs(Args, CmdArgs);
break;
diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h
index 846c834..f002e30 100644
--- a/lib/Driver/Tools.h
+++ b/lib/Driver/Tools.h
@@ -51,6 +51,7 @@ namespace tools {
bool KernelOrKext) const;
void AddMIPSTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddPPCTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
+ void AddR600TargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddSparcTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddX86TargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
void AddHexagonTargetArgs (const ArgList &Args, ArgStringList &CmdArgs) const;
--
1.7.3.4
More information about the cfe-commits
mailing list