diff options
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/Basic/Cuda.h | 77 | ||||
-rw-r--r-- | clang/include/clang/Driver/Action.h | 19 |
2 files changed, 85 insertions, 11 deletions
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h new file mode 100644 index 00000000000..ad1139b8c19 --- /dev/null +++ b/clang/include/clang/Basic/Cuda.h @@ -0,0 +1,77 @@ +//===--- Cuda.h - Utilities for compiling CUDA code ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_BASIC_CUDA_H +#define LLVM_CLANG_BASIC_CUDA_H + +namespace llvm { +class StringRef; +} // namespace llvm + +namespace clang { + +enum class CudaVersion { + UNKNOWN, + CUDA_70, + CUDA_75, + CUDA_80, +}; +const char *CudaVersionToString(CudaVersion V); + +// No string -> CudaVersion conversion function because there's no canonical +// spelling of the various CUDA versions. + +enum class CudaArch { + UNKNOWN, + SM_20, + SM_21, + SM_30, + SM_32, + SM_35, + SM_37, + SM_50, + SM_52, + SM_53, + SM_60, + SM_61, + SM_62, +}; +const char *CudaArchToString(CudaArch A); + +// The input should have the form "sm_20". +CudaArch StringToCudaArch(llvm::StringRef S); + +enum class CudaVirtualArch { + UNKNOWN, + COMPUTE_20, + COMPUTE_30, + COMPUTE_32, + COMPUTE_35, + COMPUTE_37, + COMPUTE_50, + COMPUTE_52, + COMPUTE_53, + COMPUTE_60, + COMPUTE_61, + COMPUTE_62, +}; +const char *CudaVirtualArchToString(CudaVirtualArch A); + +// The input should have the form "compute_20". +CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S); + +/// Get the compute_xx corresponding to an sm_yy. +CudaVirtualArch VirtualArchForCudaArch(CudaArch A); + +/// Get the earliest CudaVersion that supports the given CudaArch. +CudaVersion MinVersionForCudaArch(CudaArch A); + +} // namespace clang + +#endif diff --git a/clang/include/clang/Driver/Action.h b/clang/include/clang/Driver/Action.h index 81d3f3331fd..c54a2a4195a 100644 --- a/clang/include/clang/Driver/Action.h +++ b/clang/include/clang/Driver/Action.h @@ -10,6 +10,7 @@ #ifndef LLVM_CLANG_DRIVER_ACTION_H #define LLVM_CLANG_DRIVER_ACTION_H +#include "clang/Basic/Cuda.h" #include "clang/Driver/Types.h" #include "clang/Driver/Util.h" #include "llvm/ADT/SmallVector.h" @@ -157,26 +158,22 @@ public: class CudaDeviceAction : public Action { virtual void anchor(); - /// GPU architecture to bind. Always of the form /sm_\d+/ or null (when the - /// action applies to multiple architectures). - const char *GpuArchName; + + const CudaArch GpuArch; + /// True when action results are not consumed by the host action (e.g when /// -fsyntax-only or --cuda-device-only options are used). bool AtTopLevel; public: - CudaDeviceAction(Action *Input, const char *ArchName, bool AtTopLevel); + CudaDeviceAction(Action *Input, CudaArch Arch, bool AtTopLevel); - const char *getGpuArchName() const { return GpuArchName; } - - /// Gets the compute_XX that corresponds to getGpuArchName(). Returns null - /// when getGpuArchName() is null. - const char *getComputeArchName() const; + /// Get the CUDA GPU architecture to which this Action corresponds. Returns + /// UNKNOWN if this Action corresponds to multiple architectures. + CudaArch getGpuArch() const { return GpuArch; } bool isAtTopLevel() const { return AtTopLevel; } - static bool IsValidGpuArchName(llvm::StringRef ArchName); - static bool classof(const Action *A) { return A->getKind() == CudaDeviceClass; } |