LLVM 20.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"
15#include "NVPTXTargetMachine.h"
18
19using namespace llvm;
20
21#define DEBUG_TYPE "nvptx-subtarget"
22
23#define GET_SUBTARGETINFO_ENUM
24#define GET_SUBTARGETINFO_TARGET_DESC
25#define GET_SUBTARGETINFO_CTOR
26#include "NVPTXGenSubtargetInfo.inc"
27
28static cl::opt<bool>
29 NoF16Math("nvptx-no-f16-math", cl::Hidden,
30 cl::desc("NVPTX Specific: Disable generation of f16 math ops."),
31 cl::init(false));
32// Pin the vtable to this file.
33void NVPTXSubtarget::anchor() {}
34
36 StringRef FS) {
37 TargetName = std::string(CPU);
38
40
41 // Re-map SM version numbers, SmVersion carries the regular SMs which do
42 // have relative order, while FullSmVersion allows distinguishing sm_90 from
43 // sm_90a, which would *not* be a subset of sm_91.
44 SmVersion = getSmVersion();
45
46 // Set default to PTX 6.0 (CUDA 9.0)
47 if (PTXVersion == 0) {
48 PTXVersion = 60;
49 }
50
51 return *this;
52}
53
54NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
55 const std::string &FS,
56 const NVPTXTargetMachine &TM)
57 : NVPTXGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), PTXVersion(0),
58 FullSmVersion(200), SmVersion(getSmVersion()),
59 TLInfo(TM, initializeSubtargetDependencies(CPU, FS)) {
60 TSInfo = std::make_unique<NVPTXSelectionDAGInfo>();
61}
62
64
66 return TSInfo.get();
67}
68
70 return hasFP16Math() && NoF16Math == false;
71}
72
74 std::string const &FailureMessage) const {
75 if (hasClusters())
76 return;
77
79 "NVPTX SM architecture \"{}\" and PTX version \"{}\" do not support {}. "
80 "Requires SM >= 90 and PTX >= 78.",
81 getFullSmVersion(), PTXVersion, FailureMessage));
82}
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:79
void failIfClustersUnsupported(std::string const &FailureMessage) const
std::string getTargetName() const
bool hasClusters() const
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
~NVPTXSubtarget() override
unsigned int getFullSmVersion() const
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)
const SelectionDAGTargetInfo * getSelectionDAGInfo() const override
bool hasFP16Math() const
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167