]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r303291, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / 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 static cl::opt<bool>
27     NoF16Math("nvptx-no-f16-math", cl::ZeroOrMore, cl::Hidden,
28               cl::desc("NVPTX Specific: Disable generation of f16 math ops."),
29               cl::init(false));
30
31 // Pin the vtable to this file.
32 void NVPTXSubtarget::anchor() {}
33
34 NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,
35                                                                 StringRef FS) {
36     // Provide the default CPU if we don't have one.
37   TargetName = CPU.empty() ? "sm_20" : CPU;
38
39   ParseSubtargetFeatures(TargetName, FS);
40
41   // Set default to PTX 3.2 (CUDA 5.5)
42   if (PTXVersion == 0) {
43     PTXVersion = 32;
44   }
45
46   return *this;
47 }
48
49 NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
50                                const std::string &FS,
51                                const NVPTXTargetMachine &TM)
52     : NVPTXGenSubtargetInfo(TT, CPU, FS), PTXVersion(0), SmVersion(20), TM(TM),
53       InstrInfo(), TLInfo(TM, initializeSubtargetDependencies(CPU, FS)),
54       FrameLowering() {}
55
56 bool NVPTXSubtarget::hasImageHandles() const {
57   // Enable handles for Kepler+, where CUDA supports indirect surfaces and
58   // textures
59   if (TM.getDrvInterface() == NVPTX::CUDA)
60     return (SmVersion >= 30);
61
62   // Disabled, otherwise
63   return false;
64 }
65
66 bool NVPTXSubtarget::allowFP16Math() const {
67   return hasFP16Math() && NoF16Math == false;
68 }