diff options
Diffstat (limited to 'include/clang/Driver/Action.h')
-rw-r--r-- | include/clang/Driver/Action.h | 95 |
1 files changed, 88 insertions, 7 deletions
diff --git a/include/clang/Driver/Action.h b/include/clang/Driver/Action.h index 3fe6510fec98..72456d34a0d9 100644 --- a/include/clang/Driver/Action.h +++ b/include/clang/Driver/Action.h @@ -66,9 +66,11 @@ public: DsymutilJobClass, VerifyDebugInfoJobClass, VerifyPCHJobClass, + OffloadBundlingJobClass, + OffloadUnbundlingJobClass, JobClassFirst = PreprocessJobClass, - JobClassLast = VerifyPCHJobClass + JobClassLast = OffloadUnbundlingJobClass }; // The offloading kind determines if this action is binded to a particular @@ -80,6 +82,7 @@ public: OFK_Host = 0x01, // The device offloading tool chains - one bit for each programming model. OFK_Cuda = 0x02, + OFK_OpenMP = 0x04, }; static const char *getClassName(ActionClass AC); @@ -92,6 +95,12 @@ private: ActionList Inputs; + /// Flag that is set to true if this action can be collapsed with others + /// actions that depend on it. This is true by default and set to false when + /// the action is used by two different tool chains, which is enabled by the + /// offloading support implementation. + bool CanBeCollapsedWithNextDependentAction = true; + protected: /// /// Offload information. @@ -136,12 +145,26 @@ public: return input_const_range(input_begin(), input_end()); } + /// Mark this action as not legal to collapse. + void setCannotBeCollapsedWithNextDependentAction() { + CanBeCollapsedWithNextDependentAction = false; + } + /// Return true if this function can be collapsed with others. + bool isCollapsingWithNextDependentActionLegal() const { + return CanBeCollapsedWithNextDependentAction; + } + /// Return a string containing the offload kind of the action. std::string getOffloadingKindPrefix() const; /// Return a string that can be used as prefix in order to generate unique - /// files for each offloading kind. - std::string - getOffloadingFileNamePrefix(llvm::StringRef NormalizedTriple) const; + /// files for each offloading kind. By default, no prefix is used for + /// non-device kinds, except if \a CreatePrefixForHost is set. + static std::string + GetOffloadingFileNamePrefix(OffloadKind Kind, + llvm::StringRef NormalizedTriple, + bool CreatePrefixForHost = false); + /// Return a string containing a offload kind name. + static StringRef GetOffloadKindName(OffloadKind Kind); /// Set the device offload info of this action and propagate it to its /// dependences. @@ -190,12 +213,12 @@ class BindArchAction : public Action { virtual void anchor(); /// The architecture to bind, or 0 if the default architecture /// should be bound. - const char *ArchName; + StringRef ArchName; public: - BindArchAction(Action *Input, const char *ArchName); + BindArchAction(Action *Input, StringRef ArchName); - const char *getArchName() const { return ArchName; } + StringRef getArchName() const { return ArchName; } static bool classof(const Action *A) { return A->getKind() == BindArchClass; @@ -465,6 +488,64 @@ public: } }; +class OffloadBundlingJobAction : public JobAction { + void anchor() override; + +public: + // Offloading bundling doesn't change the type of output. + OffloadBundlingJobAction(ActionList &Inputs); + + static bool classof(const Action *A) { + return A->getKind() == OffloadBundlingJobClass; + } +}; + +class OffloadUnbundlingJobAction final : public JobAction { + void anchor() override; + +public: + /// Type that provides information about the actions that depend on this + /// unbundling action. + struct DependentActionInfo final { + /// \brief The tool chain of the dependent action. + const ToolChain *DependentToolChain = nullptr; + /// \brief The bound architecture of the dependent action. + StringRef DependentBoundArch; + /// \brief The offload kind of the dependent action. + const OffloadKind DependentOffloadKind = OFK_None; + DependentActionInfo(const ToolChain *DependentToolChain, + StringRef DependentBoundArch, + const OffloadKind DependentOffloadKind) + : DependentToolChain(DependentToolChain), + DependentBoundArch(DependentBoundArch), + DependentOffloadKind(DependentOffloadKind){}; + }; + +private: + /// Container that keeps information about each dependence of this unbundling + /// action. + SmallVector<DependentActionInfo, 6> DependentActionInfoArray; + +public: + // Offloading unbundling doesn't change the type of output. + OffloadUnbundlingJobAction(Action *Input); + + /// Register information about a dependent action. + void registerDependentActionInfo(const ToolChain *TC, StringRef BoundArch, + OffloadKind Kind) { + DependentActionInfoArray.push_back({TC, BoundArch, Kind}); + } + + /// Return the information about all depending actions. + ArrayRef<DependentActionInfo> getDependentActionsInfo() const { + return DependentActionInfoArray; + } + + static bool classof(const Action *A) { + return A->getKind() == OffloadUnbundlingJobClass; + } +}; + } // end namespace driver } // end namespace clang |