1 //===- NVPTXSubtarget.cpp - NVPTX Subtarget Information -------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the NVPTX specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #include "NVPTXSubtarget.h"
18 #define DEBUG_TYPE "nvptx-subtarget"
20 #define GET_SUBTARGETINFO_ENUM
21 #define GET_SUBTARGETINFO_TARGET_DESC
22 #define GET_SUBTARGETINFO_CTOR
23 #include "NVPTXGenSubtargetInfo.inc"
25 // Pin the vtable to this file.
26 void NVPTXSubtarget::anchor() {}
28 NVPTXSubtarget::NVPTXSubtarget(const std::string &TT, const std::string &CPU,
29 const std::string &FS, bool is64Bit)
30 : NVPTXGenSubtargetInfo(TT, CPU, FS), Is64Bit(is64Bit), PTXVersion(0),
35 if (T.getOS() == Triple::NVCL)
36 drvInterface = NVPTX::NVCL;
38 drvInterface = NVPTX::CUDA;
40 // Provide the default CPU if we don't have one.
41 if (CPU.empty() && FS.size())
42 llvm_unreachable("we are not using FeatureStr");
43 TargetName = CPU.empty() ? "sm_20" : CPU;
45 ParseSubtargetFeatures(TargetName, FS);
47 // We default to PTX 3.1, but we cannot just default to it in the initializer
48 // since the attribute parser checks if the given option is >= the default.
49 // So if we set ptx31 as the default, the ptx30 attribute would never match.
50 // Instead, we use 0 as the default and manually set 31 if the default is
52 if (PTXVersion == 0) {