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 | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h b/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h index 3f38715..114e0b3 100644 --- a/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h +++ b/contrib/llvm/tools/clang/include/clang/Driver/Compilation.h @@ -14,7 +14,6 @@ #include "clang/Driver/Job.h" #include "clang/Driver/Util.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/Support/Path.h" #include <map> namespace llvm { @@ -68,10 +67,27 @@ class Compilation { /// The root list of jobs. JobList Jobs; - /// Cache of translated arguments for a particular tool chain and bound - /// architecture. - llvm::DenseMap<std::pair<const ToolChain *, const char *>, - llvm::opt::DerivedArgList *> TCArgs; + /// Cache of translated arguments for a particular tool chain, bound + /// architecture, and device offload kind. + struct TCArgsKey final { + const ToolChain *TC = nullptr; + StringRef BoundArch; + Action::OffloadKind DeviceOffloadKind = Action::OFK_None; + bool operator<(const TCArgsKey &K) const { + if (TC < K.TC) + return true; + else if (TC == K.TC && BoundArch < K.BoundArch) + return true; + else if (TC == K.TC && BoundArch == K.BoundArch && + DeviceOffloadKind < K.DeviceOffloadKind) + return true; + return false; + } + TCArgsKey(const ToolChain *TC, StringRef BoundArch, + Action::OffloadKind DeviceOffloadKind) + : TC(TC), BoundArch(BoundArch), DeviceOffloadKind(DeviceOffloadKind) {} + }; + std::map<TCArgsKey, llvm::opt::DerivedArgList *> TCArgs; /// Temporary files which should be removed on exit. llvm::opt::ArgStringList TempFiles; @@ -116,6 +132,12 @@ public: return OrderedOffloadingToolchains.equal_range(Kind); } + /// Return true if an offloading tool chain of a given kind exists. + template <Action::OffloadKind Kind> bool hasOffloadToolChain() const { + return OrderedOffloadingToolchains.find(Kind) != + OrderedOffloadingToolchains.end(); + } + /// Return an offload toolchain of the provided kind. Only one is expected to /// exist. template <Action::OffloadKind Kind> @@ -176,10 +198,15 @@ public: /// getArgsForToolChain - Return the derived argument list for the /// tool chain \p TC (or the default tool chain, if TC is not specified). + /// If a device offloading kind is specified, a translation specific for that + /// kind is performed, if any. /// /// \param BoundArch - The bound architecture name, or 0. - const llvm::opt::DerivedArgList &getArgsForToolChain(const ToolChain *TC, - const char *BoundArch); + /// \param DeviceOffloadKind - The offload device kind that should be used in + /// the translation, if any. + const llvm::opt::DerivedArgList & + getArgsForToolChain(const ToolChain *TC, StringRef BoundArch, + Action::OffloadKind DeviceOffloadKind); /// addTempFile - Add a file to remove on exit, and returns its /// argument. |