Path: blob/main/contrib/llvm-project/llvm/lib/Target/NVPTX/NVPTXSubtarget.h
35271 views
//=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- C++ -*--====//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file declares the NVPTX specific subclass of TargetSubtarget.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H13#define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H1415#include "NVPTX.h"16#include "NVPTXFrameLowering.h"17#include "NVPTXISelLowering.h"18#include "NVPTXInstrInfo.h"19#include "NVPTXRegisterInfo.h"20#include "llvm/CodeGen/SelectionDAGTargetInfo.h"21#include "llvm/CodeGen/TargetSubtargetInfo.h"22#include "llvm/IR/DataLayout.h"23#include <string>2425#define GET_SUBTARGETINFO_HEADER26#include "NVPTXGenSubtargetInfo.inc"2728namespace llvm {2930class NVPTXSubtarget : public NVPTXGenSubtargetInfo {31virtual void anchor();32std::string TargetName;3334// PTX version x.y is represented as 10*x+y, e.g. 3.1 == 3135unsigned PTXVersion;3637// Full SM version x.y is represented as 100*x+10*y+feature, e.g. 3.1 == 31038// sm_90a == 90139unsigned int FullSmVersion;4041// SM version x.y is represented as 10*x+y, e.g. 3.1 == 31. Derived from42// FullSmVersion.43unsigned int SmVersion;4445const NVPTXTargetMachine &TM;46NVPTXInstrInfo InstrInfo;47NVPTXTargetLowering TLInfo;48SelectionDAGTargetInfo TSInfo;4950// NVPTX does not have any call stack frame, but need a NVPTX specific51// FrameLowering class because TargetFrameLowering is abstract.52NVPTXFrameLowering FrameLowering;5354public:55/// This constructor initializes the data members to match that56/// of the specified module.57///58NVPTXSubtarget(const Triple &TT, const std::string &CPU,59const std::string &FS, const NVPTXTargetMachine &TM);6061const TargetFrameLowering *getFrameLowering() const override {62return &FrameLowering;63}64const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }65const NVPTXRegisterInfo *getRegisterInfo() const override {66return &InstrInfo.getRegisterInfo();67}68const NVPTXTargetLowering *getTargetLowering() const override {69return &TLInfo;70}71const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {72return &TSInfo;73}7475bool hasAtomAddF64() const { return SmVersion >= 60; }76bool hasAtomScope() const { return SmVersion >= 60; }77bool hasAtomBitwise64() const { return SmVersion >= 32; }78bool hasAtomMinMax64() const { return SmVersion >= 32; }79bool hasLDG() const { return SmVersion >= 32; }80inline bool hasHWROT32() const { return SmVersion >= 32; }81bool hasImageHandles() const;82bool hasFP16Math() const { return SmVersion >= 53; }83bool hasBF16Math() const { return SmVersion >= 80; }84bool allowFP16Math() const;85bool hasMaskOperator() const { return PTXVersion >= 71; }86bool hasNoReturn() const { return SmVersion >= 30 && PTXVersion >= 64; }87unsigned int getFullSmVersion() const { return FullSmVersion; }88unsigned int getSmVersion() const { return getFullSmVersion() / 10; }89// GPUs with "a" suffix have include architecture-accelerated features that90// are supported on the specified architecture only, hence such targets do not91// follow the onion layer model. hasAAFeatures() allows distinguishing such92// GPU variants from the base GPU architecture.93// - 0 represents base GPU model,94// - non-zero value identifies particular architecture-accelerated variant.95bool hasAAFeatures() const { return getFullSmVersion() % 10; }96std::string getTargetName() const { return TargetName; }9798// Get maximum value of required alignments among the supported data types.99// From the PTX ISA doc, section 8.2.3:100// The memory consistency model relates operations executed on memory101// locations with scalar data-types, which have a maximum size and alignment102// of 64 bits. Memory operations with a vector data-type are modelled as a103// set of equivalent memory operations with a scalar data-type, executed in104// an unspecified order on the elements in the vector.105unsigned getMaxRequiredAlignment() const { return 8; }106107unsigned getPTXVersion() const { return PTXVersion; }108109NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);110void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);111};112113} // End llvm namespace114115#endif116117118