1 //===- NVPTXSubtarget.cpp - NVPTX Subtarget Information -------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the NVPTX specific subclass of TargetSubtarget.
11 //===----------------------------------------------------------------------===//
13 #include "NVPTXSubtarget.h"
14 #include "NVPTXTargetMachine.h"
18 #define DEBUG_TYPE "nvptx-subtarget"
20 #define GET_SUBTARGETINFO_ENUM
21 #define GET_SUBTARGETINFO_TARGET_DESC
22 #define GET_SUBTARGETINFO_CTOR
23 #include "NVPTXGenSubtargetInfo.inc"
26 NoF16Math("nvptx-no-f16-math", cl::Hidden
,
27 cl::desc("NVPTX Specific: Disable generation of f16 math ops."),
29 // Pin the vtable to this file.
30 void NVPTXSubtarget::anchor() {}
32 NVPTXSubtarget
&NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU
,
34 // Provide the default CPU if we don't have one.
35 TargetName
= std::string(CPU
.empty() ? "sm_30" : CPU
);
37 ParseSubtargetFeatures(TargetName
, /*TuneCPU*/ TargetName
, FS
);
39 // Set default to PTX 6.0 (CUDA 9.0)
40 if (PTXVersion
== 0) {
47 NVPTXSubtarget::NVPTXSubtarget(const Triple
&TT
, const std::string
&CPU
,
48 const std::string
&FS
,
49 const NVPTXTargetMachine
&TM
)
50 : NVPTXGenSubtargetInfo(TT
, CPU
, /*TuneCPU*/ CPU
, FS
), PTXVersion(0),
51 SmVersion(20), TM(TM
),
52 TLInfo(TM
, initializeSubtargetDependencies(CPU
, FS
)) {}
54 bool NVPTXSubtarget::hasImageHandles() const {
55 // Enable handles for Kepler+, where CUDA supports indirect surfaces and
57 if (TM
.getDrvInterface() == NVPTX::CUDA
)
58 return (SmVersion
>= 30);
60 // Disabled, otherwise
64 bool NVPTXSubtarget::allowFP16Math() const {
65 return hasFP16Math() && NoF16Math
== false;