Re-commit r247683: Replace Triple with a new TargetTuple in MCTargetDesc/* and relate...
[oota-llvm.git] / lib / Target / NVPTX / NVPTXSubtarget.cpp
1 //===- NVPTXSubtarget.cpp - NVPTX Subtarget Information -------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the NVPTX specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "NVPTXSubtarget.h"
15 #include "NVPTXTargetMachine.h"
16
17 using namespace llvm;
18
19 #define DEBUG_TYPE "nvptx-subtarget"
20
21 #define GET_SUBTARGETINFO_ENUM
22 #define GET_SUBTARGETINFO_TARGET_DESC
23 #define GET_SUBTARGETINFO_CTOR
24 #include "NVPTXGenSubtargetInfo.inc"
25
26 // Pin the vtable to this file.
27 void NVPTXSubtarget::anchor() {}
28
29 NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,
30                                                                 StringRef FS) {
31     // Provide the default CPU if we don't have one.
32   if (CPU.empty() && FS.size())
33     llvm_unreachable("we are not using FeatureStr");
34   TargetName = CPU.empty() ? "sm_20" : CPU;
35
36   ParseSubtargetFeatures(TargetName, FS);
37
38   // Set default to PTX 3.2 (CUDA 5.5)
39   if (PTXVersion == 0) {
40     PTXVersion = 32;
41   }
42
43   return *this;
44 }
45
46 NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
47                                const std::string &FS,
48                                const NVPTXTargetMachine &TM)
49     : NVPTXGenSubtargetInfo(TargetTuple(TT), CPU, FS), PTXVersion(0),
50       SmVersion(20), TM(TM), InstrInfo(),
51       TLInfo(TM, initializeSubtargetDependencies(CPU, FS)), TSInfo(),
52       FrameLowering() {}
53
54 bool NVPTXSubtarget::hasImageHandles() const {
55   // Enable handles for Kepler+, where CUDA supports indirect surfaces and
56   // textures
57   if (TM.getDrvInterface() == NVPTX::CUDA)
58     return (SmVersion >= 30);
59
60   // Disabled, otherwise
61   return false;
62 }