97#define DEPOTNAME "__local_depot"
100 assert(V.hasName() &&
"Found texture variable with no name");
105 assert(V.hasName() &&
"Found surface variable with no name");
110 assert(V.hasName() &&
"Found sampler variable with no name");
132 if (SP->getUnit()->isDebugDirectivesOnly() || SP->getUnit()->isNoDebug())
149 for (
const auto &O : U->operands())
162 if (Visited.
count(GV))
166 if (!Visiting.
insert(GV).second)
171 for (
const auto &O : GV->
operands())
184 NVPTX_MC::verifyInstructionPredicates(
MI->getOpcode(),
188 lowerToMCInst(
MI, Inst);
195 if (
MI->getOpcode() == NVPTX::CALL_PROTOTYPE) {
196 const MachineOperand &MO =
MI->getOperand(0);
202 for (
const auto MO :
MI->operands())
247unsigned NVPTXAsmPrinter::encodeVirtualRegister(
unsigned Reg) {
249 const TargetRegisterClass *RC = MRI->getRegClass(
Reg);
251 DenseMap<unsigned, unsigned> &RegMap = VRegMapping[RC];
252 unsigned RegNum = RegMap[
Reg];
257 if (RC == &NVPTX::B1RegClass) {
259 }
else if (RC == &NVPTX::B16RegClass) {
261 }
else if (RC == &NVPTX::B32RegClass) {
263 }
else if (RC == &NVPTX::B64RegClass) {
265 }
else if (RC == &NVPTX::B128RegClass) {
272 Ret |= (RegNum & 0x0FFFFFFF);
277 return Reg & 0x0FFFFFFF;
289 const NVPTXSubtarget &STI =
TM.getSubtarget<NVPTXSubtarget>(*F);
292 Type *Ty = F->getReturnType();
297 auto PrintScalarRetVal = [&](
unsigned Size) {
301 const unsigned TotalSize =
DL.getTypeAllocSize(Ty);
302 const Align RetAlignment =
304 O <<
".param .align " << RetAlignment.
value() <<
" .b8 func_retval0["
309 PrintScalarRetVal(ITy->getBitWidth());
311 PrintScalarRetVal(TLI->getPointerTy(
DL).getSizeInBits());
320 printReturnValStr(&F, O);
325bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll(
340 if (
const BasicBlock *PBB = PMBB->getBasicBlock()) {
342 PBB->getTerminator()->getMetadata(LLVMContext::MD_loop)) {
345 if (MDNode *UnrollCountMD =
359 if (isLoopHeaderOfNoUnroll(
MBB))
360 OutStreamer->emitRawText(StringRef(
"\t.pragma \"nounroll\";\n"));
364 SmallString<128> Str;
365 raw_svector_ostream
O(Str);
367 if (!GlobalsEmitted) {
368 emitGlobals(*
MF->getFunction().getParent());
369 GlobalsEmitted =
true;
373 MRI = &
MF->getRegInfo();
374 F = &
MF->getFunction();
375 emitLinkageDirective(F, O);
380 printReturnValStr(*
MF, O);
385 emitFunctionParamList(F, O);
389 emitKernelFunctionDirectives(*F, O);
399 setAndEmitFunctionVirtualRegisters(*
MF);
400 encodeDebugInfoRegisterNumbers(*
MF);
433void NVPTXAsmPrinter::emitImplicitDef(
const MachineInstr *
MI)
const {
446void NVPTXAsmPrinter::emitKernelFunctionDirectives(
const Function &
F,
453 O <<
formatv(
".reqntid {0:$[, ]}\n",
458 O <<
formatv(
".maxntid {0:$[, ]}\n",
462 O <<
".minnctapersm " << *Mincta <<
"\n";
465 O <<
".maxnreg " << *Maxnreg <<
"\n";
469 const NVPTXTargetMachine &NTM =
static_cast<const NVPTXTargetMachine &
>(
TM);
470 const NVPTXSubtarget *STI = &NTM.
getSubtarget<NVPTXSubtarget>(F);
478 if (!BlocksAreClusters)
479 O <<
".explicitcluster\n";
481 if (ClusterDim[0] != 0) {
483 "cluster_dim_x != 0 implies cluster_dim_y and cluster_dim_z "
484 "should be non-zero as well");
486 O <<
formatv(
".reqnctapercluster {0:$[, ]}\n",
490 "cluster_dim_x == 0 implies cluster_dim_y and cluster_dim_z "
491 "should be 0 as well");
495 if (BlocksAreClusters) {
496 LLVMContext &Ctx = F.getContext();
498 Ctx.
diagnose(DiagnosticInfoUnsupported(
499 F,
"blocksareclusters requires reqntid and cluster_dim attributes",
502 Ctx.
diagnose(DiagnosticInfoUnsupported(
503 F,
"blocksareclusters requires PTX version >= 9.0",
506 O <<
".blocksareclusters\n";
510 O <<
".maxclusterrank " << *Maxclusterrank <<
"\n";
521 assert(
I != VRegMapping.end() &&
"Bad register class");
525 assert(VI != RegMap.
end() &&
"Bad virtual register");
526 unsigned MappedVR = VI->second;
533void NVPTXAsmPrinter::emitVirtualRegister(
unsigned int vr,
538void NVPTXAsmPrinter::emitAliasDeclaration(
const GlobalAlias *GA,
543 "NVPTX aliasee must be a non-kernel function definition");
553 emitDeclarationWithName(F,
getSymbol(F), O);
558 emitLinkageDirective(F, O);
563 printReturnValStr(F, O);
566 emitFunctionParamList(F, O);
578 return GV->getName() !=
"llvm.used";
580 for (
const User *U :
C->users())
590 if (OtherGV->getName() ==
"llvm.used")
594 if (
const Function *CurFunc =
I->getFunction()) {
595 if (OneFunc && (CurFunc != OneFunc))
636 for (
const User *U :
C->users()) {
641 if (
const Function *Caller =
I->getFunction())
650 SmallPtrSet<const Function *, 32> SeenSet;
651 for (
const Function &F : M) {
652 if (F.getAttributes().hasFnAttr(
"nvptx-libcall-callee")) {
653 emitDeclaration(&F, O);
657 if (F.isDeclaration()) {
660 if (F.getIntrinsicID())
664 if (F.isIntrinsic()) {
665 LLVMContext &Ctx = F.getContext();
666 Ctx.
diagnose(DiagnosticInfoUnsupported(
667 F,
"unknown intrinsic '" + F.getName() +
668 "' cannot be lowered by the NVPTX backend"));
671 emitDeclaration(&F, O);
674 for (
const User *U : F.users()) {
680 emitDeclaration(&F, O);
686 emitDeclaration(&F, O);
701 emitDeclaration(&F, O);
707 for (
const GlobalAlias &GA :
M.aliases())
708 emitAliasDeclaration(&GA, O);
711void NVPTXAsmPrinter::emitStartOfAsmFile(
Module &M) {
715 const NVPTXTargetMachine &NTM =
static_cast<const NVPTXTargetMachine &
>(
TM);
736 GlobalsEmitted =
false;
741void NVPTXAsmPrinter::emitGlobals(
const Module &M) {
745 emitDeclarations(M, OS2);
760 assert(GVVisited.
size() == M.global_size() &&
"Missed a global variable");
761 assert(GVVisiting.
size() == 0 &&
"Did not fully process a global variable");
768 printModuleLevelGV(GV, OS2,
false, STI);
788 return static_cast<NVPTXTargetStreamer *
>(
OutStreamer->getTargetStreamer());
793 switch(
CU->getEmissionKind()) {
807 auto *TS = getTargetStreamer();
812 TS->emitVersionDirective(PTXVersion);
814 const NVPTXTargetMachine &NTM =
static_cast<const NVPTXTargetMachine &
>(
TM);
817 TS->emitTargetDirective(STI.
getTargetName(), TexModeIndependent,
819 TS->emitAddressSizeDirective(
M.getDataLayout().getPointerSizeInBits());
825 if (!GlobalsEmitted) {
827 GlobalsEmitted =
true;
839 TS->closeLastSection();
841 OutStreamer->emitRawText(
"\t.section\t.debug_macinfo\t{\t}");
863void NVPTXAsmPrinter::emitLinkageDirective(
const GlobalValue *V,
866 if (V->hasExternalLinkage()) {
868 O << (GVar->hasInitializer() ?
".visible " :
".extern ");
869 else if (V->isDeclaration())
873 }
else if (V->hasAppendingLinkage()) {
875 "' has unsupported appending linkage type");
876 }
else if (!
V->hasInternalLinkage() && !
V->hasPrivateLinkage()) {
882void NVPTXAsmPrinter::printModuleLevelGV(
const GlobalVariable *GVar,
930 emitPTXGlobalVariable(GVar, O, STI);
938 const Constant *Initializer =
nullptr;
941 const ConstantInt *CI =
nullptr;
952 O <<
"addr_mode_" << i <<
" = ";
958 O <<
"clamp_to_border";
961 O <<
"clamp_to_edge";
972 O <<
"filter_mode = ";
987 O <<
", force_unnormalized_coords = 1";
1007 const Function *DemotedFunc =
nullptr;
1009 O <<
"// " << GVar->
getName() <<
" has been demoted\n";
1010 localDecls[DemotedFunc].push_back(GVar);
1020 ".attribute(.managed) requires PTX version >= 4.0 and sm_30");
1021 O <<
" .attribute(.managed)";
1025 << GVar->
getAlign().value_or(
DL.getPrefTypeAlign(ETy)).value();
1034 O << getPTXFundamentalTypeStr(ETy,
false);
1047 printScalarConstant(Initializer, O);
1056 "' is not allowed in addrspace(" +
1072 const uint64_t ElementSize =
DL.getTypeStoreSize(ETy);
1080 AggBuffer aggBuffer(ElementSize, *
this);
1081 bufferAggregateConstant(Initializer, &aggBuffer);
1082 if (aggBuffer.numSymbols()) {
1083 const unsigned int ptrSize =
MAI.getCodePointerSize();
1084 if (ElementSize % ptrSize ||
1085 !aggBuffer.allSymbolsAligned(ptrSize)) {
1089 "initialized packed aggregate with pointers '" +
1091 "' requires at least PTX ISA version 7.1");
1094 O <<
"[" << ElementSize <<
"] = {";
1095 aggBuffer.printBytes(O);
1098 O <<
" .u" << ptrSize * 8 <<
" ";
1100 O <<
"[" << ElementSize / ptrSize <<
"] = {";
1101 aggBuffer.printWords(O);
1107 O <<
"[" << ElementSize <<
"] = {";
1108 aggBuffer.printBytes(O);
1115 O <<
"[" << ElementSize <<
"]";
1121 O <<
"[" << ElementSize <<
"]";
1132void NVPTXAsmPrinter::AggBuffer::printSymbol(
unsigned nSym,
raw_ostream &os) {
1133 const Value *
v = Symbols[nSym];
1134 const Value *v0 = SymbolsBeforeStripping[nSym];
1139 bool isGenericPointer = PTy && PTy->getAddressSpace() == 0;
1142 Name->print(os, AP.MAI);
1145 Name->print(os, AP.MAI);
1148 const MCExpr *Expr = AP.lowerConstantForGV(CExpr,
false);
1149 AP.printMCExpr(*Expr, os);
1154void NVPTXAsmPrinter::AggBuffer::printBytes(raw_ostream &os) {
1155 unsigned int ptrSize = AP.MAI.getCodePointerSize();
1160 unsigned int InitializerCount =
Size;
1163 if (numSymbols() == 0)
1164 while (InitializerCount >= 1 && !buffer[InitializerCount - 1])
1167 symbolPosInBuffer.push_back(InitializerCount);
1168 unsigned int nSym = 0;
1169 unsigned int nextSymbolPos = symbolPosInBuffer[nSym];
1170 for (
unsigned int pos = 0; pos < InitializerCount;) {
1173 if (pos != nextSymbolPos) {
1174 os << (
unsigned int)buffer[pos];
1181 std::string symText;
1182 llvm::raw_string_ostream oss(symText);
1183 printSymbol(nSym, oss);
1184 for (
unsigned i = 0; i < ptrSize; ++i) {
1188 os <<
"(" << symText <<
")";
1191 nextSymbolPos = symbolPosInBuffer[++nSym];
1192 assert(nextSymbolPos >= pos);
1196void NVPTXAsmPrinter::AggBuffer::printWords(raw_ostream &os) {
1197 unsigned int ptrSize = AP.MAI.getCodePointerSize();
1198 symbolPosInBuffer.push_back(
Size);
1199 unsigned int nSym = 0;
1200 unsigned int nextSymbolPos = symbolPosInBuffer[nSym];
1201 assert(nextSymbolPos % ptrSize == 0);
1202 for (
unsigned int pos = 0; pos <
Size; pos += ptrSize) {
1205 if (pos == nextSymbolPos) {
1206 printSymbol(nSym, os);
1207 nextSymbolPos = symbolPosInBuffer[++nSym];
1208 assert(nextSymbolPos % ptrSize == 0);
1209 assert(nextSymbolPos >= pos + ptrSize);
1210 }
else if (ptrSize == 4)
1217void NVPTXAsmPrinter::emitDemotedVars(
const Function *F, raw_ostream &O) {
1218 auto It = localDecls.find(F);
1219 if (It == localDecls.end())
1224 const NVPTXTargetMachine &NTM =
static_cast<const NVPTXTargetMachine &
>(
TM);
1227 for (
const GlobalVariable *GV : GVars) {
1228 O <<
"\t// demoted variable\n\t";
1229 printModuleLevelGV(GV, O,
true, STI);
1233void NVPTXAsmPrinter::emitPTXAddressSpace(
unsigned int AddressSpace,
1234 raw_ostream &O)
const {
1256NVPTXAsmPrinter::getPTXFundamentalTypeStr(
Type *Ty,
bool useB4PTR)
const {
1262 if (NumBits <= 64) {
1263 std::string
name =
"u";
1280 assert((PtrSize == 64 || PtrSize == 32) &&
"Unexpected pointer size");
1298void NVPTXAsmPrinter::emitPTXGlobalVariable(
const GlobalVariable *GVar,
1300 const NVPTXSubtarget &STI) {
1311 ".attribute(.managed) requires PTX version >= 4.0 and sm_30");
1313 O <<
" .attribute(.managed)";
1316 << GVar->
getAlign().value_or(
DL.getPrefTypeAlign(ETy)).value();
1327 O <<
" ." << getPTXFundamentalTypeStr(ETy) <<
" ";
1332 int64_t ElementSize = 0;
1342 ElementSize =
DL.getTypeStoreSize(ETy);
1356void NVPTXAsmPrinter::emitFunctionParamList(
const Function *F, raw_ostream &O) {
1358 const NVPTXSubtarget &STI =
TM.getSubtarget<NVPTXSubtarget>(*F);
1360 const NVPTXMachineFunctionInfo *MFI =
1361 MF ?
MF->getInfo<NVPTXMachineFunctionInfo>() : nullptr;
1363 bool IsFirst =
true;
1366 if (F->arg_empty() && !F->isVarArg()) {
1373 for (
const Argument &Arg : F->args()) {
1374 Type *Ty = Arg.getType();
1375 const std::string ParamSym = TLI->getParamName(F, Arg.getArgNo());
1391 switch (ArgOpaqueType) {
1393 O <<
".samplerref ";
1409 auto GetOptimalAlignForParam = [&
DL, F, &Arg](
Type *Ty) -> Align {
1410 if (MaybeAlign StackAlign =
1411 getAlign(*F, Arg.getArgNo() + AttributeList::FirstArgIndex))
1412 return StackAlign.value();
1415 MaybeAlign ParamAlign =
1416 Arg.hasByValAttr() ? Arg.getParamAlign() : MaybeAlign();
1417 return std::max(TypeAlign, ParamAlign.
valueOrOne());
1420 if (Arg.hasByValAttr()) {
1422 Type *ETy = Arg.getParamByValType();
1423 assert(ETy &&
"Param should have byval type");
1429 const Align OptimalAlign =
1430 IsKernelFunc ? GetOptimalAlignForParam(ETy)
1432 F, ETy, Arg.getParamAlign().valueOrOne(),
DL);
1434 O <<
"\t.param .align " << OptimalAlign.
value() <<
" .b8 " << ParamSym
1435 <<
"[" <<
DL.getTypeAllocSize(ETy) <<
"]";
1444 Align OptimalAlign = GetOptimalAlignForParam(Ty);
1446 O <<
"\t.param .align " << OptimalAlign.
value() <<
" .b8 " << ParamSym
1447 <<
"[" <<
DL.getTypeAllocSize(Ty) <<
"]";
1453 unsigned PTySizeInBits = 0;
1456 TLI->getPointerTy(
DL, PTy->getAddressSpace()).getSizeInBits();
1457 assert(PTySizeInBits &&
"Invalid pointer size");
1462 O <<
"\t.param .u" << PTySizeInBits <<
" .ptr";
1464 switch (PTy->getAddressSpace()) {
1481 O <<
" .align " << Arg.getParamAlign().valueOrOne().value() <<
" "
1492 O << getPTXFundamentalTypeStr(Ty);
1493 O <<
" " << ParamSym;
1502 assert(PTySizeInBits &&
"Invalid pointer size");
1503 Size = PTySizeInBits;
1506 O <<
"\t.param .b" <<
Size <<
" " << ParamSym;
1509 if (F->isVarArg()) {
1513 << TLI->getParamName(F, -1) <<
"[]";
1519void NVPTXAsmPrinter::setAndEmitFunctionVirtualRegisters(
1520 const MachineFunction &
MF) {
1521 SmallString<128> Str;
1522 raw_svector_ostream
O(Str);
1526 const TargetRegisterInfo *
TRI =
MF.getSubtarget().getRegisterInfo();
1529 const MachineFrameInfo &MFI =
MF.getFrameInfo();
1534 if (
static_cast<const NVPTXTargetMachine &
>(
MF.getTarget()).is64Bit()) {
1535 O <<
"\t.reg .b64 \t%SP;\n"
1536 <<
"\t.reg .b64 \t%SPL;\n";
1538 O <<
"\t.reg .b32 \t%SP;\n"
1539 <<
"\t.reg .b32 \t%SPL;\n";
1547 for (
unsigned I :
llvm::seq(MRI->getNumVirtRegs())) {
1549 if (MRI->use_empty(VR) && MRI->def_empty(VR))
1551 auto &RCRegMap = VRegMapping[MRI->getRegClass(VR)];
1552 RCRegMap[VR] = RCRegMap.size() + 1;
1557 for (
const TargetRegisterClass *RC :
TRI->regclasses()) {
1558 const unsigned N = VRegMapping[RC].size();
1564 O <<
"\t.reg " << RCName <<
" \t" << RCStr <<
"<" << (
N + 1) <<
">;\n";
1573void NVPTXAsmPrinter::encodeDebugInfoRegisterNumbers(
1574 const MachineFunction &
MF) {
1575 const NVPTXSubtarget &STI =
MF.getSubtarget<NVPTXSubtarget>();
1583 for (
auto &classMap : VRegMapping) {
1584 for (
auto ®isterMapping : classMap.getSecond()) {
1585 auto reg = registerMapping.getFirst();
1591void NVPTXAsmPrinter::printFPConstant(
const ConstantFP *Fp,
1592 raw_ostream &O)
const {
1595 unsigned int numHex;
1613void NVPTXAsmPrinter::printScalarConstant(
const Constant *CPV, raw_ostream &O) {
1619 printFPConstant(CFP, O);
1628 if (EmitGeneric && !
isa<Function>(CPV) && !IsNonGenericPointer) {
1645void NVPTXAsmPrinter::bufferLEByte(
const Constant *CPV,
int Bytes,
1646 AggBuffer *AggBuffer) {
1648 int AllocSize =
DL.getTypeAllocSize(CPV->
getType());
1652 AggBuffer->addZeros(Bytes ? Bytes : AllocSize);
1657 auto AddIntToBuffer = [AggBuffer, Bytes](
const APInt &Val) {
1658 size_t NumBytes = (Val.getBitWidth() + 7) / 8;
1664 for (
unsigned I = 0;
I < NumBytes - 1; ++
I) {
1665 Buf[
I] = Val.extractBitsAsZExtValue(8,
I * 8);
1667 size_t LastBytePosition = (NumBytes - 1) * 8;
1668 size_t LastByteBits = Val.getBitWidth() - LastBytePosition;
1670 Val.extractBitsAsZExtValue(LastByteBits, LastBytePosition);
1671 AggBuffer->addBytes(Buf.data(), NumBytes, Bytes);
1681 if (
const auto *CI =
1686 if (Cexpr->getOpcode() == Instruction::PtrToInt) {
1687 Value *
V = Cexpr->getOperand(0)->stripPointerCasts();
1688 AggBuffer->addSymbol(V, Cexpr->getOperand(0));
1689 AggBuffer->addZeros(AllocSize);
1705 AggBuffer->addSymbol(GVar, GVar);
1707 const Value *
v = Cexpr->stripPointerCasts();
1708 AggBuffer->addSymbol(v, Cexpr);
1710 AggBuffer->addZeros(AllocSize);
1718 bufferAggregateConstant(CPV, AggBuffer);
1719 if (Bytes > AllocSize)
1720 AggBuffer->addZeros(Bytes - AllocSize);
1722 AggBuffer->addZeros(Bytes);
1733void NVPTXAsmPrinter::bufferAggregateConstant(
const Constant *CPV,
1734 AggBuffer *aggBuffer) {
1737 auto ExtendBuffer = [](APInt Val, AggBuffer *Buffer) {
1745 for (
unsigned I :
llvm::seq(VTy->getNumElements()))
1754 ExtendBuffer(CI->
getValue(), aggBuffer);
1760 assert(CFP->getType()->isFloatingPointTy() &&
"Expected fp constant!");
1761 if (CFP->getType()->isFP128Ty()) {
1762 ExtendBuffer(CFP->getValueAPF().bitcastToAPInt(), aggBuffer);
1776 bufferAggregateConstVec(CVec, aggBuffer);
1781 for (
unsigned I :
llvm::seq(CDS->getNumElements()))
1782 bufferLEByte(
cast<Constant>(CDS->getElementAsConstant(
I)), 0, aggBuffer);
1791 ?
DL.getStructLayout(ST)->getElementOffset(0) +
1792 DL.getTypeAllocSize(ST)
1793 :
DL.getStructLayout(ST)->getElementOffset(
I + 1);
1794 int Bytes = EndOffset -
DL.getStructLayout(ST)->getElementOffset(
I);
1803void NVPTXAsmPrinter::bufferAggregateConstVec(
const ConstantVector *CV,
1804 AggBuffer *aggBuffer) {
1806 const unsigned BuffSize = aggBuffer->getBufferSize();
1809 if (BuffSize >= NumElems) {
1822 assert(ElemTySize < 8 &&
"Expected sub-byte data type.");
1823 assert(8 % ElemTySize == 0 &&
"Element type size must evenly divide a byte.");
1825 unsigned NumElemsPerByte = 8 / ElemTySize;
1826 unsigned NumCompleteBytes = NumElems / NumElemsPerByte;
1827 unsigned NumTailElems = NumElems % NumElemsPerByte;
1832 auto ConvertSubCVtoInt8 = [
this, &ElemTy](
const ConstantVector *CV,
1833 unsigned Start,
unsigned End,
1834 unsigned NumPaddingZeros = 0) {
1841 if (NumPaddingZeros)
1848 ConstantInt *MergedElem =
1855 "Cannot lower vector global with unusual element type");
1862 for (
unsigned ByteIdx :
llvm::seq(NumCompleteBytes))
1863 bufferLEByte(ConvertSubCVtoInt8(CV, ByteIdx * NumElemsPerByte,
1864 (ByteIdx + 1) * NumElemsPerByte),
1868 if (NumTailElems > 0)
1869 bufferLEByte(ConvertSubCVtoInt8(CV, NumElems - NumTailElems, NumElems,
1870 NumElemsPerByte - NumTailElems),
1879NVPTXAsmPrinter::lowerConstantForGV(
const Constant *CV,
1880 bool ProcessingGeneric)
const {
1891 if (ProcessingGeneric)
1901 switch (
CE->getOpcode()) {
1905 case Instruction::AddrSpaceCast: {
1908 if (DstTy->getAddressSpace() == 0)
1914 case Instruction::GetElementPtr: {
1918 APInt OffsetAI(
DL.getPointerTypeSizeInBits(
CE->getType()), 0);
1921 const MCExpr *
Base = lowerConstantForGV(
CE->getOperand(0),
1926 int64_t
Offset = OffsetAI.getSExtValue();
1931 case Instruction::Trunc:
1937 case Instruction::BitCast:
1938 return lowerConstantForGV(
CE->getOperand(0), ProcessingGeneric);
1940 case Instruction::IntToPtr: {
1949 return lowerConstantForGV(
Op, ProcessingGeneric);
1954 case Instruction::PtrToInt: {
1960 Type *Ty =
CE->getType();
1962 const MCExpr *OpExpr = lowerConstantForGV(
Op, ProcessingGeneric);
1966 if (
DL.getTypeAllocSize(Ty) ==
DL.getTypeAllocSize(
Op->getType()))
1972 unsigned InBits =
DL.getTypeAllocSizeInBits(
Op->getType());
1979 case Instruction::Add: {
1980 const MCExpr *
LHS = lowerConstantForGV(
CE->getOperand(0), ProcessingGeneric);
1981 const MCExpr *
RHS = lowerConstantForGV(
CE->getOperand(1), ProcessingGeneric);
1982 switch (
CE->getOpcode()) {
1994 return lowerConstantForGV(
C, ProcessingGeneric);
1998 raw_string_ostream OS(S);
1999 OS <<
"Unsupported expression in static initializer: ";
2000 CE->printAsOperand(OS,
false,
2001 !
MF ?
nullptr :
MF->getFunction().getParent());
2005void NVPTXAsmPrinter::printMCExpr(
const MCExpr &Expr, raw_ostream &OS)
const {
2011bool NVPTXAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
2012 const char *ExtraCode, raw_ostream &O) {
2013 if (ExtraCode && ExtraCode[0]) {
2014 if (ExtraCode[1] != 0)
2017 switch (ExtraCode[0]) {
2026 printOperand(
MI, OpNo, O);
2031bool NVPTXAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
2033 const char *ExtraCode,
2035 if (ExtraCode && ExtraCode[0])
2039 printMemOperand(
MI, OpNo, O);
2045void NVPTXAsmPrinter::printOperand(
const MachineInstr *
MI,
unsigned OpNum,
2047 const MachineOperand &MO =
MI->getOperand(OpNum);
2051 if (MO.
getReg() == NVPTX::VRDepot)
2056 emitVirtualRegister(MO.
getReg(), O);
2081void NVPTXAsmPrinter::printMemOperand(
const MachineInstr *
MI,
unsigned OpNum,
2082 raw_ostream &O,
const char *Modifier) {
2083 printOperand(
MI, OpNum, O);
2085 if (Modifier && strcmp(Modifier,
"add") == 0) {
2087 printOperand(
MI, OpNum + 1, O);
2089 if (
MI->getOperand(OpNum + 1).isImm() &&
2090 MI->getOperand(OpNum + 1).getImm() == 0)
2093 printOperand(
MI, OpNum + 1, O);
2101 return !Trimmed.
empty() &&
2102 (std::isalpha(
static_cast<unsigned char>(Trimmed[0])) ||
2109 if (!
MI || !
MI->getDebugLoc())
2111 const DISubprogram *SP =
MI->getMF()->getFunction().getSubprogram();
2115 if (!
DL->getFile() || !
DL->getLine())
2121struct InlineAsmInliningContext {
2123 unsigned FileIA = 0;
2124 unsigned LineIA = 0;
2127 bool hasInlinedAt()
const {
return FuncNameSym !=
nullptr; }
2133static InlineAsmInliningContext
2137 InlineAsmInliningContext Ctx;
2139 if (!InlinedAt || !InlinedAt->getFile() || !NVDD ||
2147 0, InlinedAt->getFile()->getDirectory(),
2148 InlinedAt->getFile()->getFilename(), std::nullopt, std::nullopt, CUID);
2149 Ctx.LineIA = InlinedAt->getLine();
2150 Ctx.ColIA = InlinedAt->getColumn();
2154void NVPTXAsmPrinter::emitInlineAsm(StringRef Str,
const MCSubtargetInfo &STI,
2155 const MCTargetOptions &MCOptions,
2156 const MDNode *LocMDNode,
2158 const MachineInstr *
MI) {
2159 assert(!Str.empty() &&
"Can't emit empty inline asm block");
2160 if (Str.back() == 0)
2161 Str = Str.substr(0, Str.size() - 1);
2163 auto emitAsmStr = [&](StringRef AsmStr) {
2175 const DIFile *
File =
DL->getFile();
2176 unsigned Line =
DL->getLine();
2177 const unsigned Column =
DL->getColumn();
2178 const unsigned CUID =
OutStreamer->getContext().getDwarfCompileUnitID();
2179 const unsigned FileNumber =
OutStreamer->emitDwarfFileDirective(
2180 0,
File->getDirectory(),
File->getFilename(), std::nullopt, std::nullopt,
2183 auto *NVDD =
static_cast<NVPTXDwarfDebug *
>(
getDwarfDebug());
2184 InlineAsmInliningContext InlineCtx =
2187 SmallVector<StringRef, 16>
Lines;
2188 Str.split(Lines,
'\n');
2190 for (
const StringRef &L : Lines) {
2191 StringRef RTrimmed =
L.rtrim(
'\r');
2193 if (InlineCtx.hasInlinedAt()) {
2195 FileNumber, Line, Column, InlineCtx.FileIA, InlineCtx.LineIA,
2197 File->getFilename());
2199 OutStreamer->emitDwarfLocDirective(FileNumber, Line, Column,
2201 File->getFilename());
2217LLVMInitializeNVPTXAsmPrinter() {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
Module.h This file contains the declarations for the Module class.
#define DWARF2_FLAG_IS_STMT
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static StringRef getTextureName(const Value &V)
static const DILocation * getInlineAsmDebugLoc(const MachineInstr *MI)
Returns the DILocation for an inline asm MachineInstr if debug line info should be emitted,...
static void discoverDependentGlobals(const Value *V, DenseSet< const GlobalVariable * > &Globals)
discoverDependentGlobals - Return a set of GlobalVariables on which V depends.
static bool hasFullDebugInfo(Module &M)
static StringRef getSurfaceName(const Value &V)
static bool canDemoteGlobalVar(const GlobalVariable *GV, Function const *&f)
static StringRef getSamplerName(const Value &V)
static bool useFuncSeen(const Constant *C, const SmallPtrSetImpl< const Function * > &SeenSet)
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,...
static bool usedInGlobalVarDef(const Constant *C)
static InlineAsmInliningContext getInlineAsmInliningContext(const DILocation *DL, const MachineFunction &MF, NVPTXDwarfDebug *NVDD, MCStreamer &Streamer, unsigned CUID)
Resolves the enhanced-lineinfo inlining context for an inline asm debug location.
static bool isPTXInstruction(StringRef Line)
Returns true if Line begins with an alphabetic character or underscore, indicating it is a PTX instru...
static bool usedInOneFunc(const User *U, Function const *&OneFunc)
static void emitInitialRawDwarfLocDirective(const MachineFunction &MF, DwarfDebug *DD, MCStreamer &OutStreamer)
Emits initial debug location directive.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallString class.
This file defines the SmallVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static const fltSemantics & IEEEsingle()
static const fltSemantics & IEEEdouble()
static constexpr roundingMode rmNearestTiesToEven
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
APInt bitcastToAPInt() const
uint64_t getZExtValue() const
Get zero extended value.
LLVM_ABI uint64_t extractBitsAsZExtValue(unsigned numBits, unsigned bitPosition) const
unsigned getBitWidth() const
Return the number of bits in the APInt.
MCSymbol * getSymbol(const GlobalValue *GV) const
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
DwarfDebug * getDwarfDebug()
virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo, const MachineInstr *MI)
Let the target do anything it needs to do after emitting inlineasm.
TargetMachine & TM
Target machine description.
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
MachineFunction * MF
The current machine function.
bool hasDebugInfo() const
Returns true if valid debug info is present.
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
unsigned getFunctionNumber() const
Return a unique ID for the current function.
MCSymbol * CurrentFnSym
The symbol for the current function.
MCContext & OutContext
This is the context for the output file that we are streaming.
bool doFinalization(Module &M) override
Shut down the asmprinter.
virtual void emitBasicBlockStart(const MachineBasicBlock &MBB)
Targets can override this to emit stuff at the start of a basic block.
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
const MCAsmInfo & MAI
Target Asm Printer information.
virtual void emitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
const DataLayout & getDataLayout() const
Return information about data layout.
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
MCSymbol * GetExternalSymbolSymbol(const Twine &Sym) const
Return the MCSymbol for the specified ExternalSymbol.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
virtual void emitInlineAsmStart() const
Let the target do anything it needs to do before emitting inlineasm.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
static LLVM_ABI Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
const APFloat & getValueAPF() const
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
const APInt & getValue() const
Return the constant as an APInt value reference.
FixedVectorType * getType() const
Specialize the getType() method to always return a FixedVectorType, which reduces the amount of casti...
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
LLVM_ABI Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
LLVM_ABI bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
Subprogram description. Uses SubclassData1.
iterator find(const_arg_type_t< KeyT > Val)
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
Implements a dense probed hash-table based set.
Collects and handles dwarf debug information.
const MachineInstr * emitInitialLocDirective(const MachineFunction &MF, unsigned CUID)
Emits inital debug location directive.
unsigned getNumElements() const
DISubprogram * getSubprogram() const
Get the attached subprogram.
LLVM_ABI const GlobalObject * getAliaseeObject() const
StringRef getSection() const
Get the custom section of this global if it has one.
bool hasSection() const
Check if this global has a custom object file section.
bool hasLinkOnceLinkage() const
bool hasExternalLinkage() const
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool hasLocalLinkage() const
bool hasPrivateLinkage() const
unsigned getAddressSpace() const
PointerType * getType() const
Global values are always pointers.
bool hasWeakLinkage() const
bool hasCommonLinkage() const
bool hasAvailableExternallyLinkage() const
Type * getValueType() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
MaybeAlign getAlign() const
Returns the alignment of the given variable.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
bool isLoopHeader(const BlockT *BB) const
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Instances of this class represent a single low-level machine instruction.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
Instances of this class represent operands of the MCInst class.
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
Streaming machine code generation interface.
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText.
unsigned emitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, std::optional< MD5::MD5Result > Checksum=std::nullopt, std::optional< StringRef > Source=std::nullopt, unsigned CUID=0)
Associate a filename with a specified logical file number.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
LLVM_ABI MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
iterator_range< pred_iterator > predecessors()
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
Align getMaxAlign() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
MachineBasicBlock * getMBB() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
Register getReg() const
getReg - Returns the register number.
const ConstantFP * getFPImm() const
@ MO_Immediate
Immediate operand.
@ MO_GlobalAddress
Address of a global value.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_FPImmediate
Floating-point immediate operand.
A Module instance is used to store all the information related to an LLVM module.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
bool runOnMachineFunction(MachineFunction &F) override
Emit the specified function out to the OutStreamer.
DwarfDebug * createDwarfDebug() override
Create NVPTX-specific DwarfDebug handler.
std::string getVirtualRegisterName(unsigned) const
bool doFinalization(Module &M) override
Shut down the asmprinter.
const MCSymbol * getFunctionFrameSymbol() const override
Return symbol for the function pseudo stack if the stack frame is not a register based.
NVPTX-specific DwarfDebug implementation.
bool isEnhancedLineinfo(const MachineFunction &MF) const
Returns true if the enhanced lineinfo mode (with inlined_at) is active for the given MachineFunction.
MCSymbol * getOrCreateFuncNameSymbol(StringRef LinkageName)
Get or create an MCSymbol in .debug_str for a function's linkage name.
static const NVPTXFloatMCExpr * createConstantBFPHalf(const APFloat &Flt, MCContext &Ctx)
static const NVPTXFloatMCExpr * createConstantFPHalf(const APFloat &Flt, MCContext &Ctx)
static const NVPTXFloatMCExpr * createConstantFPSingle(const APFloat &Flt, MCContext &Ctx)
static const NVPTXFloatMCExpr * createConstantFPDouble(const APFloat &Flt, MCContext &Ctx)
static const NVPTXGenericMCSymbolRefExpr * create(const MCSymbolRefExpr *SymExpr, MCContext &Ctx)
static const char * getRegisterName(MCRegister Reg)
bool checkImageHandleSymbol(StringRef Symbol) const
Check if the symbol has a mapping.
void clearDebugRegisterMap() const
const char * getName(unsigned RegNo) const
std::string getTargetName() const
unsigned getMaxRequiredAlignment() const
bool hasMaskOperator() const
const NVPTXTargetLowering * getTargetLowering() const override
unsigned getPTXVersion() const
const NVPTXRegisterInfo * getRegisterInfo() const override
unsigned int getSmVersion() const
NVPTX::DrvInterface getDrvInterface() const
const NVPTXSubtarget * getSubtargetImpl(const Function &) const override
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
Implments NVPTX-specific streamer.
void outputDwarfFileDirectives()
Outputs the list of the DWARF '.file' directives to the streamer.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Wrapper class representing virtual and physical registers.
static Register index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static constexpr bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
StringRef ltrim(char Char) const
Return string with consecutive Char characters starting from the the left removed.
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
@ HalfTyID
16-bit floating point type
@ VoidTyID
type with no size
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ FP128TyID
128-bit floating point type (112-bit significand)
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isIntOrPtrTy() const
Return true if this is an integer type or a pointer type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
TypeID getTypeID() const
Return the type id for the type.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
iterator_range< user_iterator > users()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Type * getElementType() const
std::pair< iterator, bool > insert(const ValueT &V)
bool erase(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
A raw_ostream that writes to an SmallVector or SmallString.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
@ C
The default llvm calling convention, compatible with C.
constexpr StringLiteral MaxNTID("nvvm.maxntid")
constexpr StringLiteral ReqNTID("nvvm.reqntid")
constexpr StringLiteral ClusterDim("nvvm.cluster_dim")
constexpr StringLiteral BlocksAreClusters("nvvm.blocksareclusters")
@ CE
Windows NT (Windows on ARM)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
uint64_t read64le(const void *P)
uint32_t read32le(const void *P)
This is an optimization pass for GlobalISel generic memory operations.
constexpr auto not_equal_to(T &&Arg)
Functor variant of std::not_equal_to that can be used as a UnaryPredicate in functional algorithms li...
FunctionAddr VTableAddr Value
bool isManaged(const Value &V)
StringRef getNVPTXRegClassStr(TargetRegisterClass const *RC)
bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
MaybeAlign getAlign(const CallInst &I, unsigned Index)
std::optional< unsigned > getMaxNReg(const Function &F)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
std::string utostr(uint64_t X, bool isNeg=false)
std::optional< unsigned > getMinCTASm(const Function &F)
constexpr auto equal_to(T &&Arg)
Functor variant of std::equal_to that can be used as a UnaryPredicate in functional algorithms like a...
SmallVector< unsigned, 3 > getReqNTID(const Function &F)
LLVM_ABI Constant * ConstantFoldConstant(const Constant *C, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldConstant - Fold the constant using the specified DataLayout.
auto dyn_cast_or_null(const Y &Val)
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
unsigned promoteScalarArgumentSize(unsigned size)
void clearAnnotationCache(const Module *Mod)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
bool shouldPassAsArray(Type *Ty)
StringRef getNVPTXRegClassName(TargetRegisterClass const *RC)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
std::optional< unsigned > getMaxClusterRank(const Function &F)
Align getFunctionByValParamAlign(const Function *F, Type *ArgTy, Align InitialAlign, const DataLayout &DL)
SmallVector< unsigned, 3 > getMaxNTID(const Function &F)
LLVM_ABI void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, std::optional< size_t > Width=std::nullopt)
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
Target & getTheNVPTXTarget64()
bool isKernelFunction(const Function &F)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Align getFunctionArgumentAlignment(const Function *F, Type *Ty, unsigned Idx, const DataLayout &DL)
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
bool hasBlocksAreClusters(const Function &F)
SmallVector< unsigned, 3 > getClusterDim(const Function &F)
LLVM_ABI Constant * ConstantFoldIntegerCast(Constant *C, Type *DestTy, bool IsSigned, const DataLayout &DL)
Constant fold a zext, sext or trunc, depending on IsSigned and whether the DestTy is wider or narrowe...
PTXOpaqueType getPTXOpaqueType(const GlobalVariable &GV)
LLVM_ABI MDNode * GetUnrollMetadata(MDNode *LoopID, StringRef Name)
Given an llvm.loop loop id metadata node, returns the loop hint metadata node with the given name (fo...
LLVM_ABI DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Align getFunctionParamOptimizedAlign(const Function *F, Type *ArgTy, const DataLayout &DL)
Since function arguments are passed via .param space, we may want to increase their alignment in a wa...
Target & getTheNVPTXTarget32()
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...