LLVM  8.0.1
Macros | Functions
NVPTXAsmPrinter.cpp File Reference
#include "NVPTXAsmPrinter.h"
#include "InstPrinter/NVPTXInstPrinter.h"
#include "MCTargetDesc/NVPTXBaseInfo.h"
#include "MCTargetDesc/NVPTXMCAsmInfo.h"
#include "MCTargetDesc/NVPTXTargetStreamer.h"
#include "NVPTX.h"
#include "NVPTXMCExpr.h"
#include "NVPTXMachineFunctionInfo.h"
#include "NVPTXRegisterInfo.h"
#include "NVPTXSubtarget.h"
#include "NVPTXTargetMachine.h"
#include "NVPTXUtilities.h"
#include "cl_common_defines.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/User.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MachineValueType.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/UnrollLoop.h"
#include <cassert>
#include <cstdint>
#include <cstring>
#include <new>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Macros

#define DEPOTNAME   "__local_depot"
 

Functions

static void DiscoverDependentGlobals (const Value *V, DenseSet< const GlobalVariable *> &Globals)
 DiscoverDependentGlobals - Return a set of GlobalVariables on which V depends. More...
 
static void VisitGlobalVariableForEmission (const GlobalVariable *GV, SmallVectorImpl< const GlobalVariable *> &Order, DenseSet< const GlobalVariable *> &Visited, DenseSet< const GlobalVariable *> &Visiting)
 VisitGlobalVariableForEmission - Add GV to the list of GlobalVariable instances to be emitted, but only after any dependents have been added first.s. More...
 
static bool usedInGlobalVarDef (const Constant *C)
 
static bool usedInOneFunc (const User *U, Function const *&oneFunc)
 
static bool canDemoteGlobalVar (const GlobalVariable *gv, Function const *&f)
 
static bool useFuncSeen (const Constant *C, DenseMap< const Function *, bool > &seenMap)
 
static bool isEmptyXXStructor (GlobalVariable *GV)
 
static unsigned int getOpenCLAlignment (const DataLayout &DL, Type *Ty)
 
template<typename T >
static void ConvertIntToBytes (unsigned char *p, T val)
 
static void ConvertFloatToBytes (unsigned char *p, float val)
 
static void ConvertDoubleToBytes (unsigned char *p, double val)
 
void LLVMInitializeNVPTXAsmPrinter ()
 

Macro Definition Documentation

◆ DEPOTNAME

#define DEPOTNAME   "__local_depot"

Function Documentation

◆ canDemoteGlobalVar()

static bool canDemoteGlobalVar ( const GlobalVariable gv,
Function const *&  f 
)
static

◆ ConvertDoubleToBytes()

static void ConvertDoubleToBytes ( unsigned char p,
double  val 
)
static

Definition at line 1805 of file NVPTXAsmPrinter.cpp.

References llvm::MCID::Add, llvm::MCBinaryExpr::Add, llvm::NVPTXAsmPrinter::AggBuffer, llvm::Type::ArrayTyID, llvm::MCExpr::Binary, llvm::APFloat::bitcastToAPInt(), C, llvm::MCExpr::Constant, llvm::ConstantFoldConstant(), ConvertFloatToBytes(), llvm::APFloat::convertToDouble(), llvm::APFloat::convertToFloat(), llvm::NVPTXGenericMCSymbolRefExpr::create(), llvm::MCConstantExpr::create(), llvm::MCSymbolRefExpr::create(), llvm::MCBinaryExpr::createAdd(), llvm::MCBinaryExpr::createAnd(), DEPOTNAME, llvm::Type::DoubleTyID, llvm::dyn_cast(), E, llvm::Type::FloatTyID, llvm::PointerType::getAddressSpace(), llvm::Value::getContext(), llvm::AsmPrinter::getDataLayout(), llvm::Type::getDoubleTy(), llvm::StructLayout::getElementOffset(), llvm::Type::getFloatTy(), llvm::MachineOperand::getFPImm(), llvm::MachineFunction::getFunction(), llvm::AsmPrinter::getFunctionNumber(), llvm::MachineOperand::getGlobal(), llvm::Type::getHalfTy(), llvm::MachineOperand::getImm(), llvm::Type::getInt16Ty(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::Type::getInt8Ty(), llvm::ConstantExpr::getIntegerCast(), llvm::DataLayout::getIntPtrType(), llvm::MCExpr::getKind(), llvm::MCBinaryExpr::getLHS(), llvm::APInt::getLoBits(), llvm::MachineOperand::getMBB(), llvm::User::getNumOperands(), llvm::MCUnaryExpr::getOpcode(), llvm::MCBinaryExpr::getOpcode(), llvm::ConstantExpr::getOpcode(), llvm::User::getOperand(), llvm::MachineInstr::getOperand(), llvm::GlobalValue::getParent(), llvm::DataLayout::getPointerTypeSizeInBits(), llvm::MachineOperand::getReg(), llvm::NVPTXInstPrinter::getRegisterName(), llvm::MCBinaryExpr::getRHS(), llvm::APInt::getSExtValue(), llvm::DataLayout::getStructLayout(), llvm::MCUnaryExpr::getSubExpr(), llvm::AsmPrinter::getSymbol(), llvm::MCSymbolRefExpr::getSymbol(), llvm::MachineBasicBlock::getSymbol(), llvm::MachineOperand::getType(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::DataLayout::getTypeAllocSizeInBits(), llvm::Type::getTypeID(), llvm::ConstantFP::getValueAPF(), llvm::APInt::getZExtValue(), llvm::Type::HalfTyID, I, llvm::Type::IntegerTyID, llvm::MachineOperand::isImm(), llvm::Constant::isNullValue(), llvm::TargetRegisterInfo::isPhysicalRegister(), LLVM_FALLTHROUGH, llvm_unreachable, llvm::MCUnaryExpr::LNot, llvm::APInt::lshrInPlace(), llvm::AsmPrinter::MAI, llvm::MCUnaryExpr::Minus, llvm::MachineOperand::MO_FPImmediate, llvm::MachineOperand::MO_GlobalAddress, llvm::MachineOperand::MO_Immediate, llvm::MachineOperand::MO_MachineBasicBlock, llvm::MachineOperand::MO_Register, llvm::MCUnaryExpr::Not, llvm::RISCVFenceField::O, llvm::AsmPrinter::OutContext, llvm::MCUnaryExpr::Plus, llvm::Type::PointerTyID, llvm::Pass::print(), llvm::MCSymbol::print(), llvm::AsmPrinter::PrintAsmOperand(), llvm::Value::printAsOperand(), printMCExpr(), printMemOperand(), printOperand(), llvm::report_fatal_error(), llvm::ARM_MB::ST, llvm::raw_string_ostream::str(), llvm::Value::stripPointerCasts(), llvm::Type::StructTyID, llvm::MCExpr::SymbolRef, llvm::MCExpr::Target, llvm::MCExpr::Unary, and llvm::Type::VectorTyID.

◆ ConvertFloatToBytes()

static void ConvertFloatToBytes ( unsigned char p,
float  val 
)
static

Definition at line 1798 of file NVPTXAsmPrinter.cpp.

Referenced by ConvertDoubleToBytes().

◆ ConvertIntToBytes()

template<typename T >
static void ConvertIntToBytes ( unsigned char p,
T  val 
)
static

Definition at line 1791 of file NVPTXAsmPrinter.cpp.

References T.

◆ DiscoverDependentGlobals()

static void DiscoverDependentGlobals ( const Value V,
DenseSet< const GlobalVariable *> &  Globals 
)
static

DiscoverDependentGlobals - Return a set of GlobalVariables on which V depends.

Definition at line 99 of file NVPTXAsmPrinter.cpp.

References llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert().

Referenced by VisitGlobalVariableForEmission().

◆ getOpenCLAlignment()

static unsigned int getOpenCLAlignment ( const DataLayout DL,
Type Ty 
)
static

Definition at line 1401 of file NVPTXAsmPrinter.cpp.

References llvm::ADDRESS_SPACE_CONST, llvm::ADDRESS_SPACE_GLOBAL, llvm::ADDRESS_SPACE_SHARED, llvm::lltok::APFloat, assert(), llvm::APFloat::bitcastToAPInt(), llvm::Attribute::ByVal, llvm::ComputeValueVTs(), llvm::APFloat::convert(), llvm::NVPTX::CUDA, llvm::AsmPrinter::CurrentFnSym, DEPOTNAME, llvm::Type::DoubleTyID, llvm::dyn_cast(), E, first, llvm::Type::FloatTyID, llvm::format_hex_no_prefix(), llvm::DataLayout::getABITypeAlignment(), llvm::PointerType::getAddressSpace(), llvm::Function::getAttributes(), getBitWidth(), llvm::AsmPrinter::getDataLayout(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getFunction(), llvm::AsmPrinter::getFunctionNumber(), llvm::MachineFrameInfo::getMaxAlignment(), llvm::Value::getName(), llvm::TargetRegisterInfo::getNumRegClasses(), llvm::getNVPTXRegClassName(), llvm::getNVPTXRegClassStr(), llvm::AttributeList::getParamAlignment(), llvm::Argument::getParent(), llvm::DataLayout::getPointerPrefAlignment(), llvm::TargetLoweringBase::getPointerTy(), llvm::DataLayout::getPrefTypeAlignment(), llvm::Type::getPrimitiveSizeInBits(), llvm::TargetRegisterInfo::getRegClass(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::EVT::getSizeInBits(), llvm::MVT::getSizeInBits(), llvm::NVPTXSubtarget::getSmVersion(), llvm::MachineFrameInfo::getStackSize(), llvm::TargetMachine::getSubtarget(), llvm::MachineFunction::getSubtarget(), llvm::AsmPrinter::getSymbol(), llvm::MachineFunction::getTarget(), llvm::NVPTXSubtarget::getTargetLowering(), llvm::Value::getType(), llvm::GlobalValue::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::Type::getTypeID(), llvm::ConstantFP::getValueAPF(), llvm::APInt::getZExtValue(), llvm::NVPTXSubtarget::hasImageHandles(), llvm::AttributeList::hasParamAttribute(), I, llvm::APFloatBase::IEEEdouble(), llvm::APFloatBase::IEEEsingle(), llvm::TargetRegisterInfo::index2VirtReg(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), is64Bit(), llvm::Type::isAggregateType(), llvm::Type::isHalfTy(), llvm::isImage(), llvm::isImageReadWrite(), llvm::isImageWriteOnly(), llvm::EVT::isInteger(), llvm::Type::isIntegerTy(), llvm::isKernelFunction(), llvm::isSampler(), llvm::Type::isSingleValueType(), llvm::HexagonMCInstrInfo::isVector(), llvm::Type::isVectorTy(), llvm_unreachable, llvm::AsmPrinter::lowerConstant(), llvm::AsmPrinter::MAI, MRI, llvm::RISCVFenceField::O, llvm::AsmPrinter::OutStreamer, llvm::MCExpr::print(), llvm::Pass::print(), llvm::MCSymbol::print(), llvm::APFloatBase::rmNearestTiesToEven, llvm::SmallVectorBase::size(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::size(), llvm::raw_svector_ostream::str(), llvm::Value::stripPointerCasts(), llvm::AsmPrinter::TM, and TRI.

◆ isEmptyXXStructor()

static bool isEmptyXXStructor ( GlobalVariable GV)
static

◆ LLVMInitializeNVPTXAsmPrinter()

void LLVMInitializeNVPTXAsmPrinter ( )

Definition at line 2294 of file NVPTXAsmPrinter.cpp.

References llvm::getTheNVPTXTarget32(), llvm::getTheNVPTXTarget64(), X, and Y.

◆ usedInGlobalVarDef()

static bool usedInGlobalVarDef ( const Constant C)
static

Definition at line 643 of file NVPTXAsmPrinter.cpp.

References llvm::Value::users().

Referenced by useFuncSeen().

◆ usedInOneFunc()

static bool usedInOneFunc ( const User U,
Function const *&  oneFunc 
)
static

Definition at line 659 of file NVPTXAsmPrinter.cpp.

References llvm::GlobalValue::getParent(), and llvm::Value::users().

Referenced by canDemoteGlobalVar().

◆ useFuncSeen()

static bool useFuncSeen ( const Constant C,
DenseMap< const Function *, bool > &  seenMap 
)
static

◆ VisitGlobalVariableForEmission()

static void VisitGlobalVariableForEmission ( const GlobalVariable GV,
SmallVectorImpl< const GlobalVariable *> &  Order,
DenseSet< const GlobalVariable *> &  Visited,
DenseSet< const GlobalVariable *> &  Visiting 
)
static

VisitGlobalVariableForEmission - Add GV to the list of GlobalVariable instances to be emitted, but only after any dependents have been added first.s.

Definition at line 116 of file NVPTXAsmPrinter.cpp.

References llvm::MCInst::addOperand(), assert(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::ComputeValueVTs(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::count(), llvm::MCSymbolRefExpr::create(), llvm::NVPTXFloatMCExpr::createConstantFPDouble(), llvm::NVPTXFloatMCExpr::createConstantFPHalf(), llvm::NVPTXFloatMCExpr::createConstantFPSingle(), llvm::MCOperand::createExpr(), llvm::MCOperand::createImm(), llvm::MCOperand::createReg(), llvm::AsmPrinter::CurrentFnSym, DiscoverDependentGlobals(), llvm::Type::DoubleTyID, E, llvm::AsmPrinter::EmitBasicBlockStart(), llvm::AsmPrinter::EmitToStreamer(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::end(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::erase(), F(), llvm::Type::FloatTyID, llvm::DataLayout::getABITypeAlignment(), llvm::getAlign(), llvm::MachineBasicBlock::getBasicBlock(), llvm::AsmPrinter::getDataLayout(), llvm::MachineInstr::getDesc(), llvm::AsmPrinter::GetExternalSymbolSymbol(), llvm::MachineOperand::getFPImm(), llvm::MachineFunction::getFunction(), llvm::MachineOperand::getGlobal(), llvm::NVPTXMachineFunctionInfo::getImageHandleSymbol(), llvm::MachineOperand::getImm(), llvm::MachineFunction::getInfo(), llvm::MachineLoopInfo::getLoopFor(), llvm::ManagedStringPool::getManagedString(), llvm::NVPTXTargetMachine::getManagedStrPool(), llvm::MachineOperand::getMBB(), llvm::MachineInstr::getMF(), llvm::User::getNumOperands(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::User::getOperand(), llvm::MachineInstr::getOperand(), llvm::MCContext::getOrCreateSymbol(), llvm::GlobalValue::getParent(), llvm::TargetLoweringBase::getPointerTy(), llvm::Type::getPrimitiveSizeInBits(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getRegInfo(), llvm::EVT::getSizeInBits(), llvm::MVT::getSizeInBits(), llvm::NVPTXSubtarget::getSmVersion(), llvm::TargetMachine::getSubtarget(), llvm::MachineFunction::getSubtarget(), llvm::AsmPrinter::getSymbol(), llvm::MachineBasicBlock::getSymbol(), llvm::MachineOperand::getSymbolName(), GetSymbolRef(), llvm::MachineFunction::getTarget(), llvm::NVPTXSubtarget::getTargetLowering(), llvm::MachineOperand::getType(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::Type::getTypeID(), llvm::GetUnrollMetadata(), llvm::ConstantFP::getValueAPF(), llvm::Type::HalfTyID, llvm::NVPTXSubtarget::hasImageHandles(), I, llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), llvm::Type::isAggregateType(), llvm::Type::isFloatingPointTy(), llvm::MachineOperand::isImm(), llvm::EVT::isInteger(), llvm::Type::isIntegerTy(), llvm::isKernelFunction(), llvm::MachineLoopInfo::isLoopHeader(), llvm::NVPTXII::IsSuldMask, llvm::NVPTXII::IsSuldShift, llvm::NVPTXII::IsSurfTexQueryFlag, llvm::NVPTXII::IsSustFlag, llvm::NVPTXII::IsTexFlag, llvm::NVPTXII::IsTexModeUnifiedFlag, llvm::HexagonMCInstrInfo::isVector(), llvm::Type::isVectorTy(), llvm::TargetRegisterInfo::isVirtualRegister(), llvm_unreachable, llvm::AsmPrinter::MAI, llvm::LLVMContext::MD_loop, llvm::AsmPrinter::MF, MI, llvm::MachineOperand::MO_ExternalSymbol, llvm::MachineOperand::MO_FPImmediate, llvm::MachineOperand::MO_GlobalAddress, llvm::MachineOperand::MO_Immediate, llvm::MachineOperand::MO_MachineBasicBlock, llvm::MachineOperand::MO_Register, MRI, llvm::RISCVFenceField::O, llvm::AsmPrinter::OutContext, llvm::AsmPrinter::OutStreamer, llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_end(), llvm::MCSymbol::print(), llvm::SmallVectorTemplateBase< T >::push_back(), Reg, llvm::report_fatal_error(), llvm::MipsISD::Ret, llvm::MCInst::setOpcode(), llvm::SmallVectorBase::size(), llvm::size(), llvm::raw_svector_ostream::str(), llvm::ARMBuildAttrs::Symbol, llvm::AsmPrinter::TM, llvm::MCInstrDesc::TSFlags, llvm::MCSymbolRefExpr::VK_None, and llvm::Type::VoidTyID.

Referenced by llvm::NVPTXAsmPrinter::doInitialization().