blob: acbee86ae386b29a20f646e5e76a5e0e93826df0 [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
Artem Belevich64dc9be2017-01-13 20:56:17 +000026static 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
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000031// Pin the vtable to this file.
32void NVPTXSubtarget::anchor() {}
33
Eric Christopher493f91b2014-06-27 04:33:14 +000034NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,
35 StringRef FS) {
36 // Provide the default CPU if we don't have one.
Eric Christopherd8132862014-06-27 02:05:19 +000037 TargetName = CPU.empty() ? "sm_20" : CPU;
38
39 ParseSubtargetFeatures(TargetName, FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +000040
Justin Holewinski602fa5b2014-06-27 18:35:18 +000041 // Set default to PTX 3.2 (CUDA 5.5)
42 if (PTXVersion == 0) {
43 PTXVersion = 32;
44 }
Eric Christopher493f91b2014-06-27 04:33:14 +000045
46 return *this;
47}
48
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000049NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
Eric Christopher6aad8b12015-02-19 00:08:14 +000050 const std::string &FS,
Eric Christopher02389e32015-02-19 00:08:27 +000051 const NVPTXTargetMachine &TM)
Daniel Sanders50f17232015-09-15 16:17:27 +000052 : NVPTXGenSubtargetInfo(TT, CPU, FS), PTXVersion(0), SmVersion(20), TM(TM),
53 InstrInfo(), TLInfo(TM, initializeSubtargetDependencies(CPU, FS)),
Mehdi Amini157e5a62015-07-09 02:10:08 +000054 FrameLowering() {}
Eric Christopher493f91b2014-06-27 04:33:14 +000055
Eric Christopherbeffc4e2015-02-19 00:08:23 +000056bool 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;
Justin Holewinskiae556d32012-05-04 20:18:50 +000064}
Artem Belevich64dc9be2017-01-13 20:56:17 +000065
66bool NVPTXSubtarget::allowFP16Math() const {
67 return hasFP16Math() && NoF16Math == false;
68}