Skip to content

Commit af05b3e

Browse files
authored
[Clang] Rework creating offloading toolchains (llvm#3175)
2 parents 35d552a + 00dce9f commit af05b3e

20 files changed

+375
-548
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def err_drv_cuda_host_arch : Error<
119119
"unsupported architecture '%0' for host compilation">;
120120
def err_drv_mix_cuda_hip : Error<
121121
"mixed CUDA and HIP compilation is not supported">;
122+
def err_drv_mix_offload : Error<
123+
"mixed %0 and %1 offloading compilation is not supported">;
122124
def err_drv_bad_target_id : Error<
123125
"invalid target ID '%0'; format is a processor name followed by an optional "
124126
"colon-delimited list of features followed by an enable/disable sign (e.g., "

clang/include/clang/Driver/Driver.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ class Driver {
358358
phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL,
359359
llvm::opt::Arg **FinalPhaseArg = nullptr) const;
360360

361+
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
362+
executeProgram(llvm::ArrayRef<llvm::StringRef> Args) const;
363+
361364
private:
362365
/// Certain options suppress the 'no input files' warning.
363366
LLVM_PREFERRED_TYPE(bool)
@@ -373,10 +376,6 @@ class Driver {
373376
/// Number of parallel jobs.
374377
unsigned NumParallelJobs;
375378

376-
/// The associated offloading architectures with each toolchain.
377-
llvm::DenseMap<const ToolChain *, llvm::SmallVector<llvm::StringRef>>
378-
OffloadArchs;
379-
380379
private:
381380
/// TranslateInputArgs - Create a new derived argument list from the input
382381
/// arguments, after applying the standard argument translations.
@@ -548,8 +547,7 @@ class Driver {
548547
/// empty string.
549548
llvm::SmallVector<StringRef>
550549
getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
551-
Action::OffloadKind Kind, const ToolChain *TC,
552-
bool SpecificToolchain = true) const;
550+
Action::OffloadKind Kind, const ToolChain &TC) const;
553551

554552
/// Check that the file referenced by Value exists. If it doesn't,
555553
/// issue a diagnostic and return false.

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ def offload_arch_EQ : CommaJoined<["--"], "offload-arch=">,
11611161
"If 'native' is used the compiler will detect locally installed architectures. "
11621162
"For HIP offloading, the device architecture can be followed by target ID features "
11631163
"delimited by a colon (e.g. gfx908:xnack+:sramecc-). May be specified more than once.">;
1164-
def no_offload_arch_EQ : Joined<["--"], "no-offload-arch=">,
1164+
def no_offload_arch_EQ : CommaJoined<["--"], "no-offload-arch=">,
11651165
Visibility<[ClangOption, FlangOption]>,
11661166
HelpText<"Remove CUDA/HIP offloading device architecture (e.g. sm_35, gfx906) from the list of devices to compile for. "
11671167
"'all' resets the list to its default value.">;
@@ -1633,7 +1633,7 @@ defm auto_import : BoolFOption<"auto-import",
16331633
// In the future this option will be supported by other offloading
16341634
// languages and accept other values such as CPU/GPU architectures,
16351635
// offload kinds and target aliases.
1636-
def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
1636+
def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>, Alias<offload_targets_EQ>,
16371637
HelpText<"Specify comma-separated list of offloading target triples (CUDA and HIP only)">;
16381638

16391639
// C++ Coroutines

clang/include/clang/Driver/ToolChain.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,6 @@ class ToolChain {
205205
ToolChain(const Driver &D, const llvm::Triple &T,
206206
const llvm::opt::ArgList &Args);
207207

208-
/// Executes the given \p Executable and returns the stdout.
209-
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
210-
executeToolChainProgram(StringRef Executable) const;
211-
212208
void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
213209

214210
virtual Tool *buildAssembler() const;

0 commit comments

Comments
 (0)