Path: blob/main/contrib/llvm-project/llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
35271 views
//===- NVPTXSubtarget.cpp - NVPTX Subtarget Information -------------------===//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 implements the NVPTX specific subclass of TargetSubtarget.9//10//===----------------------------------------------------------------------===//1112#include "NVPTXSubtarget.h"13#include "NVPTXTargetMachine.h"1415using namespace llvm;1617#define DEBUG_TYPE "nvptx-subtarget"1819#define GET_SUBTARGETINFO_ENUM20#define GET_SUBTARGETINFO_TARGET_DESC21#define GET_SUBTARGETINFO_CTOR22#include "NVPTXGenSubtargetInfo.inc"2324static cl::opt<bool>25NoF16Math("nvptx-no-f16-math", cl::Hidden,26cl::desc("NVPTX Specific: Disable generation of f16 math ops."),27cl::init(false));28// Pin the vtable to this file.29void NVPTXSubtarget::anchor() {}3031NVPTXSubtarget &NVPTXSubtarget::initializeSubtargetDependencies(StringRef CPU,32StringRef FS) {33// Provide the default CPU if we don't have one.34TargetName = std::string(CPU.empty() ? "sm_30" : CPU);3536ParseSubtargetFeatures(TargetName, /*TuneCPU*/ TargetName, FS);3738// Re-map SM version numbers, SmVersion carries the regular SMs which do39// have relative order, while FullSmVersion allows distinguishing sm_90 from40// sm_90a, which would *not* be a subset of sm_91.41SmVersion = getSmVersion();4243// Set default to PTX 6.0 (CUDA 9.0)44if (PTXVersion == 0) {45PTXVersion = 60;46}4748return *this;49}5051NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,52const std::string &FS,53const NVPTXTargetMachine &TM)54: NVPTXGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS), PTXVersion(0),55FullSmVersion(200), SmVersion(getSmVersion()), TM(TM),56TLInfo(TM, initializeSubtargetDependencies(CPU, FS)) {}5758bool NVPTXSubtarget::hasImageHandles() const {59// Enable handles for Kepler+, where CUDA supports indirect surfaces and60// textures61if (TM.getDrvInterface() == NVPTX::CUDA)62return (SmVersion >= 30);6364// Disabled, otherwise65return false;66}6768bool NVPTXSubtarget::allowFP16Math() const {69return hasFP16Math() && NoF16Math == false;70}717273