clang: lib/Driver/ToolChains/AMDGPUOpenMP.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

20#include "llvm/ADT/STLExtras.h"

21#include "llvm/Support/FileSystem.h"

22#include "llvm/Support/FormatAdapters.h"

23#include "llvm/Support/FormatVariadic.h"

24#include "llvm/Support/Path.h"

25

29using namespace clang;

31

33 const llvm::Triple &Triple,

35 const ArgList &Args)

37

38

40}

41

43 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,

46

48 "Only OpenMP offloading kinds are supported.");

49

50 if (DriverArgs.hasArg(options::OPT_nogpulib))

51 return;

52

54 CC1Args.push_back(BCFile.ShouldInternalize ? "-mlink-builtin-bitcode"

55 : "-mlink-bitcode-file");

56 CC1Args.push_back(DriverArgs.MakeArgString(BCFile.Path));

57 }

58

59

60 if (getDriver().isUsingOffloadLTO())

61 return;

62}

63

65 const llvm::opt::DerivedArgList &Args, StringRef BoundArch,

67 DerivedArgList *DAL =

69 if (!DAL)

70 DAL = new DerivedArgList(Args.getBaseArgs());

71

73

75 for (Arg *A : Args)

76 if (!llvm::is_contained(*DAL, A))

77 DAL->append(A);

78

79 if (!DAL->hasArg(options::OPT_march_EQ)) {

80 StringRef Arch = BoundArch;

81 if (Arch.empty()) {

83 if (!ArchsOrErr) {

84 std::string ErrMsg =

85 llvm::formatv("{0}", llvm::fmt_consume(ArchsOrErr.takeError()));

86 getDriver().Diag(diag::err_drv_undetermined_gpu_arch)

87 << llvm::Triple::getArchTypeName(getArch()) << ErrMsg << "-march";

89 } else {

90 Arch = Args.MakeArgString(ArchsOrErr->front());

91 }

92 }

93 DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ), Arch);

94 }

95

96 return DAL;

97 }

98

99 for (Arg *A : Args) {

100 DAL->append(A);

101 }

102

103 if (!BoundArch.empty()) {

104 DAL->eraseArg(options::OPT_march_EQ);

105 DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ),

106 BoundArch);

107 }

108

109 return DAL;

110}

111

113 ArgStringList &CC1Args) const {

116}

117

121}

122

124 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1Args) const {

126}

127

129 const ArgList &DriverArgs, ArgStringList &CC1Args) const {

131}

132

134 ArgStringList &CC1Args) const {

136}

137

139

140

141

142

143

144

145

146

147

149}

150

151VersionTuple

153 const ArgList &Args) const {

155}

156

159 if (Args.hasArg(options::OPT_nogpulib))

160 return {};

161

163 getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0;

164 return {};

165 }

166

168 getTriple(), Args.getLastArgValue(options::OPT_march_EQ));

169

172 true))

173 BCLibs.emplace_back(BCLib);

174

175 return BCLibs;

176}

Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...

DiagnosticBuilder Diag(unsigned DiagID) const

const llvm::opt::OptTable & getOpts() const

The JSON file list parser is used to communicate input to InstallAPI.

llvm::StringRef getProcessorFromTargetID(const llvm::Triple &T, llvm::StringRef OffloadArch)

Get processor name from target ID.

const char * OffloadArchToString(OffloadArch A)