LLVM  4.0.0
NVPTXSubtarget.cpp
Go to the documentation of this file.
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 
30  StringRef FS) {
31  // Provide the default CPU if we don't have one.
32  TargetName = CPU.empty() ? "sm_20" : CPU;
33 
34  ParseSubtargetFeatures(TargetName, FS);
35 
36  // Set default to PTX 3.2 (CUDA 5.5)
37  if (PTXVersion == 0) {
38  PTXVersion = 32;
39  }
40 
41  return *this;
42 }
43 
44 NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
45  const std::string &FS,
46  const NVPTXTargetMachine &TM)
47  : NVPTXGenSubtargetInfo(TT, CPU, FS), PTXVersion(0), SmVersion(20), TM(TM),
48  InstrInfo(), TLInfo(TM, initializeSubtargetDependencies(CPU, FS)),
49  FrameLowering() {}
50 
52  // Enable handles for Kepler+, where CUDA supports indirect surfaces and
53  // textures
54  if (TM.getDrvInterface() == NVPTX::CUDA)
55  return (SmVersion >= 30);
56 
57  // Disabled, otherwise
58  return false;
59 }
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
NVPTXSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const NVPTXTargetMachine &TM)
This constructor initializes the data members to match that of the specified module.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:130
NVPTXTargetMachine.
bool hasImageHandles() const
NVPTXSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
NVPTX::DrvInterface getDrvInterface() const