blob: bd2509a3c8c93f31b7c4d8b522bc9d4c21959abe [file] [log] [blame]
Justin Holewinskiae556d32012-05-04 20:18:50 +00001//===- 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"
Eric Christopher6aad8b12015-02-19 00:08:14 +000015#include "NVPTXTargetMachine.h"
Chandler Carruthe96dd892014-04-21 22:55:11 +000016
Chandler Carruthd174b722014-04-22 02:03:14 +000017using namespace llvm;
18
Chandler Carruthe96dd892014-04-21 22:55:11 +000019#define DEBUG_TYPE "nvptx-subtarget"
20
Justin Holewinskiae556d32012-05-04 20:18:50 +000021#define GET_SUBTARGETINFO_ENUM
22#define GET_SUBTARGETINFO_TARGET_DESC
23#define GET_SUBTARGETINFO_CTOR
24#include "NVPTXGenSubtargetInfo.inc"
25
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000026// Pin the vtable to this file.
27void NVPTXSubtarget::anchor() {}
28
Eric Christopher493f91b2014-06-27 04:33:14 +000029NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,
30 StringRef FS) {
31 // Provide the default CPU if we don't have one.
Eric Christopherd8132862014-06-27 02:05:19 +000032 if (CPU.empty() && FS.size())
Justin Holewinskiae556d32012-05-04 20:18:50 +000033 llvm_unreachable("we are not using FeatureStr");
Eric Christopherd8132862014-06-27 02:05:19 +000034 TargetName = CPU.empty() ? "sm_20" : CPU;
35
36 ParseSubtargetFeatures(TargetName, FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +000037
Justin Holewinski602fa5b2014-06-27 18:35:18 +000038 // Set default to PTX 3.2 (CUDA 5.5)
39 if (PTXVersion == 0) {
40 PTXVersion = 32;
41 }
Eric Christopher493f91b2014-06-27 04:33:14 +000042
43 return *this;
44}
45
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000046NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
Eric Christopher6aad8b12015-02-19 00:08:14 +000047 const std::string &FS,
Eric Christopher02389e32015-02-19 00:08:27 +000048 const NVPTXTargetMachine &TM)
Daniel Sanders50f17232015-09-15 16:17:27 +000049 : NVPTXGenSubtargetInfo(TT, CPU, FS), PTXVersion(0), SmVersion(20), TM(TM),
50 InstrInfo(), TLInfo(TM, initializeSubtargetDependencies(CPU, FS)),
Mehdi Amini157e5a62015-07-09 02:10:08 +000051 FrameLowering() {}
Eric Christopher493f91b2014-06-27 04:33:14 +000052
Eric Christopherbeffc4e2015-02-19 00:08:23 +000053bool NVPTXSubtarget::hasImageHandles() const {
54 // Enable handles for Kepler+, where CUDA supports indirect surfaces and
55 // textures
56 if (TM.getDrvInterface() == NVPTX::CUDA)
57 return (SmVersion >= 30);
58
59 // Disabled, otherwise
60 return false;
Justin Holewinskiae556d32012-05-04 20:18:50 +000061}