Add NVPTX Support to ValidCPUList (enabling march notes)

A followup to: https://reviews.llvm.org/D42978
This patch adds NVPTX support for
enabling the march notes.

Differential Revision: https://reviews.llvm.org/D43045

llvm-svn: 324675
This commit is contained in:
Erich Keane 2018-02-08 23:16:00 +00:00
parent d1d85f50d0
commit d45879d8ad
4 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,7 @@ enum class CudaArch {
SM_62,
SM_70,
SM_72,
LAST,
};
const char *CudaArchToString(CudaArch A);

View File

@ -26,6 +26,8 @@ const char *CudaVersionToString(CudaVersion V) {
const char *CudaArchToString(CudaArch A) {
switch (A) {
case CudaArch::LAST:
break;
case CudaArch::UNKNOWN:
return "unknown";
case CudaArch::SM_20:
@ -133,6 +135,8 @@ CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S) {
CudaVirtualArch VirtualArchForCudaArch(CudaArch A) {
switch (A) {
case CudaArch::LAST:
break;
case CudaArch::UNKNOWN:
return CudaVirtualArch::UNKNOWN;
case CudaArch::SM_20:
@ -168,6 +172,8 @@ CudaVirtualArch VirtualArchForCudaArch(CudaArch A) {
CudaVersion MinVersionForCudaArch(CudaArch A) {
switch (A) {
case CudaArch::LAST:
break;
case CudaArch::UNKNOWN:
return CudaVersion::UNKNOWN;
case CudaArch::SM_20:

View File

@ -157,6 +157,8 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
// Set __CUDA_ARCH__ for the GPU specified.
std::string CUDAArchCode = [this] {
switch (GPU) {
case CudaArch::LAST:
break;
case CudaArch::UNKNOWN:
assert(false && "No GPU arch when compiling CUDA device code.");
return "";

View File

@ -98,6 +98,12 @@ public:
return StringToCudaArch(Name) != CudaArch::UNKNOWN;
}
void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override {
for (int i = static_cast<int>(CudaArch::SM_20);
i < static_cast<int>(CudaArch::LAST); ++i)
Values.emplace_back(CudaArchToString(static_cast<CudaArch>(i)));
}
bool setCPU(const std::string &Name) override {
GPU = StringToCudaArch(Name);
return GPU != CudaArch::UNKNOWN;