From: Artem Belevich Date: Tue, 22 Sep 2015 17:23:13 +0000 (+0000) Subject: Augmented CudaHostAction to carry device-side triple. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20db8d08e59176291d746d4f65cedf639d308594;p=clang Augmented CudaHostAction to carry device-side triple. Differential Revision: http://reviews.llvm.org/D12893 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248298 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Action.h b/include/clang/Driver/Action.h index f6d4ad579c..077f1a9efb 100644 --- a/include/clang/Driver/Action.h +++ b/include/clang/Driver/Action.h @@ -160,14 +160,16 @@ public: class CudaHostAction : public Action { virtual void anchor(); ActionList DeviceActions; + const char *DeviceTriple; public: - CudaHostAction(std::unique_ptr Input, - const ActionList &DeviceActions); + CudaHostAction(std::unique_ptr Input, const ActionList &DeviceActions, + const char *DeviceTriple); ~CudaHostAction() override; ActionList &getDeviceActions() { return DeviceActions; } const ActionList &getDeviceActions() const { return DeviceActions; } + const char *getDeviceTriple() const { return DeviceTriple; } static bool classof(const Action *A) { return A->getKind() == CudaHostClass; } }; diff --git a/lib/Driver/Action.cpp b/lib/Driver/Action.cpp index 6fe2a50346..fdbae113ff 100644 --- a/lib/Driver/Action.cpp +++ b/lib/Driver/Action.cpp @@ -66,8 +66,10 @@ CudaDeviceAction::CudaDeviceAction(std::unique_ptr Input, void CudaHostAction::anchor() {} CudaHostAction::CudaHostAction(std::unique_ptr Input, - const ActionList &DeviceActions) - : Action(CudaHostClass, std::move(Input)), DeviceActions(DeviceActions) {} + const ActionList &DeviceActions, + const char *DeviceTriple) + : Action(CudaHostClass, std::move(Input)), DeviceActions(DeviceActions), + DeviceTriple(DeviceTriple) {} CudaHostAction::~CudaHostAction() { for (auto &DA : DeviceActions) diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index ebf8b7d953..c29059bdeb 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1246,13 +1246,18 @@ static std::unique_ptr buildCudaActions(const Driver &D, const ToolChain &TC, DerivedArgList &Args, const Arg *InputArg, std::unique_ptr HostAction, ActionList &Actions) { + // Figure out which NVPTX triple to use for device-side compilation based on + // whether host is 64-bit. + const char *DeviceTriple = TC.getTriple().isArch64Bit() + ? "nvptx64-nvidia-cuda" + : "nvptx-nvidia-cuda"; Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only, options::OPT_cuda_device_only); // Host-only compilation case. if (PartialCompilationArg && PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only)) return std::unique_ptr( - new CudaHostAction(std::move(HostAction), {})); + new CudaHostAction(std::move(HostAction), {}, DeviceTriple)); // Collect all cuda_gpu_arch parameters, removing duplicates. SmallVector GpuArchList; @@ -1290,12 +1295,6 @@ buildCudaActions(const Driver &D, const ToolChain &TC, DerivedArgList &Args, } } - // Figure out which NVPTX triple to use for device-side compilation based on - // whether host is 64-bit. - const char *DeviceTriple = TC.getTriple().isArch64Bit() - ? "nvptx64-nvidia-cuda" - : "nvptx-nvidia-cuda"; - // Figure out what to do with device actions -- pass them as inputs to the // host action or run each of them independently. bool DeviceOnlyCompilation = PartialCompilationArg != nullptr; @@ -1331,7 +1330,7 @@ buildCudaActions(const Driver &D, const ToolChain &TC, DerivedArgList &Args, // Return a new host action that incorporates original host action and all // device actions. return std::unique_ptr( - new CudaHostAction(std::move(HostAction), DeviceActions)); + new CudaHostAction(std::move(HostAction), DeviceActions, DeviceTriple)); } void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,