Skip to content

Commit 8914a6d

Browse files
committedNov 10, 2017
AMDGPU/NFC: Move getAMDGPUTargetFeatures to AMDGPU toolchain
Differential Revision: https://reviews.llvm.org/D39877 llvm-svn: 317909
1 parent 5f043ae commit 8914a6d

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed
 

‎clang/lib/Driver/ToolChains/AMDGPU.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "CommonArgs.h"
1212
#include "InputInfo.h"
1313
#include "clang/Driver/Compilation.h"
14+
#include "clang/Driver/DriverDiagnostic.h"
1415
#include "llvm/Option/ArgList.h"
1516

1617
using namespace clang::driver;
@@ -35,6 +36,24 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
3536
CmdArgs, Inputs));
3637
}
3738

39+
void amdgpu::getAMDGPUTargetFeatures(const Driver &D,
40+
const llvm::opt::ArgList &Args,
41+
std::vector<StringRef> &Features) {
42+
if (const Arg *dAbi = Args.getLastArg(options::OPT_mamdgpu_debugger_abi)) {
43+
StringRef value = dAbi->getValue();
44+
if (value == "1.0") {
45+
Features.push_back("+amdgpu-debugger-insert-nops");
46+
Features.push_back("+amdgpu-debugger-reserve-regs");
47+
Features.push_back("+amdgpu-debugger-emit-prologue");
48+
} else {
49+
D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);
50+
}
51+
}
52+
53+
handleTargetFeaturesGroup(
54+
Args, Features, options::OPT_m_amdgpu_Features_Group);
55+
}
56+
3857
/// AMDGPU Toolchain
3958
AMDGPUToolChain::AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
4059
const ArgList &Args)

‎clang/lib/Driver/ToolChains/AMDGPU.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
namespace clang {
2020
namespace driver {
2121
namespace tools {
22-
2322
namespace amdgpu {
2423

2524
class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
@@ -33,6 +32,9 @@ class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
3332
const char *LinkingOutput) const override;
3433
};
3534

35+
void getAMDGPUTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
36+
std::vector<StringRef> &Features);
37+
3638
} // end namespace amdgpu
3739
} // end namespace tools
3840

‎clang/lib/Driver/ToolChains/Clang.cpp

+2-18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Arch/Sparc.h"
1616
#include "Arch/SystemZ.h"
1717
#include "Arch/X86.h"
18+
#include "AMDGPU.h"
1819
#include "CommonArgs.h"
1920
#include "Hexagon.h"
2021
#include "InputInfo.h"
@@ -278,23 +279,6 @@ static void getWebAssemblyTargetFeatures(const ArgList &Args,
278279
handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group);
279280
}
280281

281-
static void getAMDGPUTargetFeatures(const Driver &D, const ArgList &Args,
282-
std::vector<StringRef> &Features) {
283-
if (const Arg *dAbi = Args.getLastArg(options::OPT_mamdgpu_debugger_abi)) {
284-
StringRef value = dAbi->getValue();
285-
if (value == "1.0") {
286-
Features.push_back("+amdgpu-debugger-insert-nops");
287-
Features.push_back("+amdgpu-debugger-reserve-regs");
288-
Features.push_back("+amdgpu-debugger-emit-prologue");
289-
} else {
290-
D.Diag(diag::err_drv_clang_unsupported) << dAbi->getAsString(Args);
291-
}
292-
}
293-
294-
handleTargetFeaturesGroup(
295-
Args, Features, options::OPT_m_amdgpu_Features_Group);
296-
}
297-
298282
static void getTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple,
299283
const ArgList &Args, ArgStringList &CmdArgs,
300284
bool ForAS) {
@@ -347,7 +331,7 @@ static void getTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple,
347331
break;
348332
case llvm::Triple::r600:
349333
case llvm::Triple::amdgcn:
350-
getAMDGPUTargetFeatures(D, Args, Features);
334+
amdgpu::getAMDGPUTargetFeatures(D, Args, Features);
351335
break;
352336
}
353337

0 commit comments

Comments
 (0)
Please sign in to comment.