LLVM 19.0.0git
NVPTXSubtarget.cpp
Go to the documentation of this file.
1//===- NVPTXSubtarget.cpp - NVPTX Subtarget Information -------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the NVPTX specific subclass of TargetSubtarget.
10//
11//===----------------------------------------------------------------------===//
12
13#include "NVPTXSubtarget.h"
14#include "NVPTXTargetMachine.h"
15
16using namespace llvm;
17
18#define DEBUG_TYPE "nvptx-subtarget"
19
20#define GET_SUBTARGETINFO_ENUM
21#define GET_SUBTARGETINFO_TARGET_DESC
22#define GET_SUBTARGETINFO_CTOR
23#include "NVPTXGenSubtargetInfo.inc"
24
25static cl::opt<bool>
26 NoF16Math("nvptx-no-f16-math", cl::Hidden,
27 cl::desc("NVPTX Specific: Disable generation of f16 math ops."),
28 cl::init(false));
29// Pin the vtable to this file.
30void NVPTXSubtarget::anchor() {}
31
33 StringRef FS) {
34 // Provide the default CPU if we don't have one.
35 TargetName = std::string(CPU.empty() ? "sm_30" : CPU);
36
37 ParseSubtargetFeatures(TargetName, /*TuneCPU*/ TargetName, FS);
38
39 // Re-map SM version numbers, SmVersion carries the regular SMs which do
40 // have relative order, while FullSmVersion allows distinguishing sm_90 from
41 // sm_90a, which would *not* be a subset of sm_91.
42 SmVersion = getSmVersion();
43
44 // Set default to PTX 6.0 (CUDA 9.0)
45 if (PTXVersion == 0) {
46 PTXVersion = 60;
47 }
48
49 return *this;
50}
51
52NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
53 const std::string &FS,
55 : NVPTXGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), PTXVersion(0),
56 FullSmVersion(200), SmVersion(getSmVersion()), TM(TM),
57 TLInfo(TM, initializeSubtargetDependencies(CPU, FS)) {}
58
60 // Enable handles for Kepler+, where CUDA supports indirect surfaces and
61 // textures
62 if (TM.getDrvInterface() == NVPTX::CUDA)
63 return (SmVersion >= 30);
64
65 // Disabled, otherwise
66 return false;
67}
68
70 return hasFP16Math() && NoF16Math == false;
71}
static cl::opt< bool > NoF16Math("nvptx-no-f16-math", cl::Hidden, cl::desc("NVPTX Specific: Disable generation of f16 math ops."), cl::init(false))
unsigned SmVersion
Definition: NVVMReflect.cpp:81
const char LLVMTargetMachineRef TM
bool hasImageHandles() const
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
unsigned int getSmVersion() const
bool allowFP16Math() const
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.
NVPTXSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
bool hasFP16Math() const
NVPTX::DrvInterface getDrvInterface() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
@ CUDA
Definition: NVPTX.h:75
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:450
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18