diff options
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/Driver/Compilation.h')
-rw-r--r-- | contrib/llvm/tools/clang/include/clang/Driver/Compilation.h | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h b/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h index 3ed1913..3f38715 100644 --- a/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h +++ b/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h @@ -15,6 +15,7 @@ #include "clang/Driver/Util.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Path.h" +#include <map> namespace llvm { namespace opt { @@ -38,8 +39,16 @@ class Compilation { /// The default tool chain. const ToolChain &DefaultToolChain; - const ToolChain *CudaHostToolChain; - const ToolChain *CudaDeviceToolChain; + /// A mask of all the programming models the host has to support in the + /// current compilation. + unsigned ActiveOffloadMask; + + /// Array with the toolchains of offloading host and devices in the order they + /// were requested by the user. We are preserving that order in case the code + /// generation needs to derive a programming-model-specific semantic out of + /// it. + std::multimap<Action::OffloadKind, const ToolChain *> + OrderedOffloadingToolchains; /// The original (untranslated) input argument list. llvm::opt::InputArgList *Args; @@ -89,16 +98,46 @@ public: const Driver &getDriver() const { return TheDriver; } const ToolChain &getDefaultToolChain() const { return DefaultToolChain; } - const ToolChain *getCudaHostToolChain() const { return CudaHostToolChain; } - const ToolChain *getCudaDeviceToolChain() const { - return CudaDeviceToolChain; + + unsigned isOffloadingHostKind(Action::OffloadKind Kind) const { + return ActiveOffloadMask & Kind; + } + + /// Iterator that visits device toolchains of a given kind. + typedef const std::multimap<Action::OffloadKind, + const ToolChain *>::const_iterator + const_offload_toolchains_iterator; + typedef std::pair<const_offload_toolchains_iterator, + const_offload_toolchains_iterator> + const_offload_toolchains_range; + + template <Action::OffloadKind Kind> + const_offload_toolchains_range getOffloadToolChains() const { + return OrderedOffloadingToolchains.equal_range(Kind); } - void setCudaHostToolChain(const ToolChain *HostToolChain) { - CudaHostToolChain = HostToolChain; + /// Return an offload toolchain of the provided kind. Only one is expected to + /// exist. + template <Action::OffloadKind Kind> + const ToolChain *getSingleOffloadToolChain() const { + auto TCs = getOffloadToolChains<Kind>(); + + assert(TCs.first != TCs.second && + "No tool chains of the selected kind exist!"); + assert(std::next(TCs.first) == TCs.second && + "More than one tool chain of the this kind exist."); + return TCs.first->second; } - void setCudaDeviceToolChain(const ToolChain *DeviceToolChain) { - CudaDeviceToolChain = DeviceToolChain; + + void addOffloadDeviceToolChain(const ToolChain *DeviceToolChain, + Action::OffloadKind OffloadKind) { + assert(OffloadKind != Action::OFK_Host && OffloadKind != Action::OFK_None && + "This is not a device tool chain!"); + + // Update the host offload kind to also contain this kind. + ActiveOffloadMask |= OffloadKind; + OrderedOffloadingToolchains.insert( + std::make_pair(OffloadKind, DeviceToolChain)); } const llvm::opt::InputArgList &getInputArgs() const { return *Args; } @@ -208,6 +247,15 @@ public: /// Return true if we're compiling for diagnostics. bool isForDiagnostics() const { return ForDiagnostics; } + + /// Redirect - Redirect output of this compilation. Can only be done once. + /// + /// \param Redirects - array of pointers to paths. The array + /// should have a size of three. The inferior process's + /// stdin(0), stdout(1), and stderr(2) will be redirected to the + /// corresponding paths. This compilation instance becomes + /// the owner of Redirects and will delete the array and StringRef's. + void Redirect(const StringRef** Redirects); }; } // end namespace driver |