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;
1365 assert(!F->isVarArg() &&
"VarArg functions lowered in ExpandVariadics");
1367 if (F->arg_empty()) {
1374 auto EmitParam = [&](
const Argument &Arg) {
1375 Type *Ty = Arg.getType();
1376 const std::string ParamSym = TLI->getParamName(F, Arg.getArgNo());
1387 switch (ArgOpaqueType) {
1389 O <<
".samplerref ";
1405 if (Arg.hasByValAttr()) {
1407 Type *ETy = Arg.getParamByValType();
1408 assert(ETy &&
"Param should have byval type");
1414 const Align OptimalAlign =
1417 F, ETy, Arg.getArgNo() + AttributeList::FirstArgIndex,
DL)
1419 Arg.getParamAlign().valueOrOne(),
DL);
1421 O <<
"\t.param .align " << OptimalAlign.
value() <<
" .b8 " << ParamSym
1422 <<
"[" <<
DL.getTypeAllocSize(ETy) <<
"]";
1432 F, Ty, Arg.getArgNo() + AttributeList::FirstArgIndex,
DL);
1434 O <<
"\t.param .align " << OptimalAlign.
value() <<
" .b8 " << ParamSym
1435 <<
"[" <<
DL.getTypeAllocSize(Ty) <<
"]";
1441 unsigned PTySizeInBits = 0;
1444 TLI->getPointerTy(
DL, PTy->getAddressSpace()).getSizeInBits();
1445 assert(PTySizeInBits &&
"Invalid pointer size");
1450 O <<
"\t.param .u" << PTySizeInBits <<
" .ptr";
1452 switch (PTy->getAddressSpace()) {
1469 O <<
" .align " << Arg.getParamAlign().valueOrOne().value() <<
" "
1480 O << getPTXFundamentalTypeStr(Ty);
1481 O <<
" " << ParamSym;
1490 assert(PTySizeInBits &&
"Invalid pointer size");
1491 Size = PTySizeInBits;
1494 O <<
"\t.param .b" <<
Size <<
" " << ParamSym;
1501void NVPTXAsmPrinter::setAndEmitFunctionVirtualRegisters(
1502 const MachineFunction &
MF) {
1503 SmallString<128> Str;
1504 raw_svector_ostream
O(Str);
1508 const TargetRegisterInfo *
TRI =
MF.getSubtarget().getRegisterInfo();
1511 const MachineFrameInfo &MFI =
MF.getFrameInfo();
1516 if (
static_cast<const NVPTXTargetMachine &
>(
MF.getTarget()).is64Bit()) {
1517 O <<
"\t.reg .b64 \t%SP;\n"
1518 <<
"\t.reg .b64 \t%SPL;\n";
1520 O <<
"\t.reg .b32 \t%SP;\n"
1521 <<
"\t.reg .b32 \t%SPL;\n";
1529 for (
unsigned I :
llvm::seq(MRI->getNumVirtRegs())) {
1531 if (MRI->use_empty(VR) && MRI->def_empty(VR))
1533 auto &RCRegMap = VRegMapping[MRI->getRegClass(VR)];
1534 RCRegMap[VR] = RCRegMap.size() + 1;
1539 for (
const TargetRegisterClass *RC :
TRI->regclasses()) {
1540 const unsigned N = VRegMapping[RC].size();
1546 O <<
"\t.reg " << RCName <<
" \t" << RCStr <<
"<" << (
N + 1) <<
">;\n";
1555void NVPTXAsmPrinter::encodeDebugInfoRegisterNumbers(
1556 const MachineFunction &
MF) {
1557 const NVPTXSubtarget &STI =
MF.getSubtarget<NVPTXSubtarget>();
1565 for (
auto &classMap : VRegMapping) {
1566 for (
auto ®isterMapping : classMap.getSecond()) {
1567 auto reg = registerMapping.getFirst();
1573void NVPTXAsmPrinter::printFPConstant(
const ConstantFP *Fp,
1574 raw_ostream &O)
const {
1577 unsigned int numHex;
1595void NVPTXAsmPrinter::printScalarConstant(
const Constant *CPV, raw_ostream &O) {
1601 printFPConstant(CFP, O);
1610 if (EmitGeneric && !
isa<Function>(CPV) && !IsNonGenericPointer) {
1627void NVPTXAsmPrinter::bufferLEByte(
const Constant *CPV,
int Bytes,
1628 AggBuffer *AggBuffer) {
1630 int AllocSize =
DL.getTypeAllocSize(CPV->
getType());
1634 AggBuffer->addZeros(Bytes ? Bytes : AllocSize);
1639 auto AddIntToBuffer = [AggBuffer, Bytes](
const APInt &Val) {
1640 size_t NumBytes = (Val.getBitWidth() + 7) / 8;
1646 for (
unsigned I = 0;
I < NumBytes - 1; ++
I) {
1647 Buf[
I] = Val.extractBitsAsZExtValue(8,
I * 8);
1649 size_t LastBytePosition = (NumBytes - 1) * 8;
1650 size_t LastByteBits = Val.getBitWidth() - LastBytePosition;
1652 Val.extractBitsAsZExtValue(LastByteBits, LastBytePosition);
1653 AggBuffer->addBytes(Buf.data(), NumBytes, Bytes);
1663 if (
const auto *CI =
1668 if (Cexpr->getOpcode() == Instruction::PtrToInt) {
1669 Value *
V = Cexpr->getOperand(0)->stripPointerCasts();
1670 AggBuffer->addSymbol(V, Cexpr->getOperand(0));
1671 AggBuffer->addZeros(AllocSize);
1678 AggBuffer->addSymbol(Cexpr, Cexpr);
1679 AggBuffer->addZeros(AllocSize);
1694 AggBuffer->addSymbol(GVar, GVar);
1696 const Value *
v = Cexpr->stripPointerCasts();
1697 AggBuffer->addSymbol(v, Cexpr);
1699 AggBuffer->addZeros(AllocSize);
1709 unsigned StartPos = AggBuffer->getCurpos();
1710 bufferAggregateConstant(CPV, AggBuffer);
1711 unsigned Written = AggBuffer->getCurpos() - StartPos;
1712 unsigned SlotSize = std::max<int>(Bytes, AllocSize);
1713 if (SlotSize > Written)
1714 AggBuffer->addZeros(SlotSize - Written);
1716 AggBuffer->addZeros(Bytes);
1727void NVPTXAsmPrinter::bufferAggregateConstant(
const Constant *CPV,
1728 AggBuffer *aggBuffer) {
1731 auto ExtendBuffer = [](APInt Val, AggBuffer *Buffer) {
1734 unsigned NumBits = std::min(8u, Val.
getBitWidth() -
I * 8);
1742 for (
unsigned I :
llvm::seq(VTy->getNumElements()))
1751 ExtendBuffer(CI->
getValue(), aggBuffer);
1757 assert(CFP->getType()->isFloatingPointTy() &&
"Expected fp constant!");
1758 if (CFP->getType()->isFP128Ty()) {
1759 ExtendBuffer(CFP->getValueAPF().bitcastToAPInt(), aggBuffer);
1773 bufferAggregateConstVec(CVec, aggBuffer);
1778 for (
unsigned I :
llvm::seq(CDS->getNumElements()))
1779 bufferLEByte(
cast<Constant>(CDS->getElementAsConstant(
I)), 0, aggBuffer);
1788 ?
DL.getStructLayout(ST)->getElementOffset(0) +
1789 DL.getTypeAllocSize(ST)
1790 :
DL.getStructLayout(ST)->getElementOffset(
I + 1);
1791 int Bytes = EndOffset -
DL.getStructLayout(ST)->getElementOffset(
I);
1800void NVPTXAsmPrinter::bufferAggregateConstVec(
const ConstantVector *CV,
1801 AggBuffer *aggBuffer) {
1803 const unsigned BuffSize = aggBuffer->getBufferSize();
1806 if (BuffSize >= NumElems) {
1819 assert(ElemTySize < 8 &&
"Expected sub-byte data type.");
1820 assert(8 % ElemTySize == 0 &&
"Element type size must evenly divide a byte.");
1822 unsigned NumElemsPerByte = 8 / ElemTySize;
1823 unsigned NumCompleteBytes = NumElems / NumElemsPerByte;
1824 unsigned NumTailElems = NumElems % NumElemsPerByte;
1829 auto ConvertSubCVtoInt8 = [
this, &ElemTy](
const ConstantVector *CV,
1830 unsigned Start,
unsigned End,
1831 unsigned NumPaddingZeros = 0) {
1838 if (NumPaddingZeros)
1845 ConstantInt *MergedElem =
1852 "Cannot lower vector global with unusual element type");
1859 for (
unsigned ByteIdx :
llvm::seq(NumCompleteBytes))
1860 bufferLEByte(ConvertSubCVtoInt8(CV, ByteIdx * NumElemsPerByte,
1861 (ByteIdx + 1) * NumElemsPerByte),
1865 if (NumTailElems > 0)
1866 bufferLEByte(ConvertSubCVtoInt8(CV, NumElems - NumTailElems, NumElems,
1867 NumElemsPerByte - NumTailElems),
1876NVPTXAsmPrinter::lowerConstantForGV(
const Constant *CV,
1877 bool ProcessingGeneric)
const {
1888 if (ProcessingGeneric)
1898 switch (
CE->getOpcode()) {
1902 case Instruction::AddrSpaceCast: {
1905 if (DstTy->getAddressSpace() == 0)
1911 case Instruction::GetElementPtr: {
1915 APInt OffsetAI(
DL.getPointerTypeSizeInBits(
CE->getType()), 0);
1918 const MCExpr *
Base = lowerConstantForGV(
CE->getOperand(0),
1923 int64_t
Offset = OffsetAI.getSExtValue();
1928 case Instruction::Trunc:
1934 case Instruction::BitCast:
1935 return lowerConstantForGV(
CE->getOperand(0), ProcessingGeneric);
1937 case Instruction::IntToPtr: {
1946 return lowerConstantForGV(
Op, ProcessingGeneric);
1951 case Instruction::PtrToInt: {
1957 Type *Ty =
CE->getType();
1959 const MCExpr *OpExpr = lowerConstantForGV(
Op, ProcessingGeneric);
1963 if (
DL.getTypeAllocSize(Ty) ==
DL.getTypeAllocSize(
Op->getType()))
1969 unsigned InBits =
DL.getTypeAllocSizeInBits(
Op->getType());
1976 case Instruction::Add: {
1977 const MCExpr *
LHS = lowerConstantForGV(
CE->getOperand(0), ProcessingGeneric);
1978 const MCExpr *
RHS = lowerConstantForGV(
CE->getOperand(1), ProcessingGeneric);
1979 switch (
CE->getOpcode()) {
1991 return lowerConstantForGV(
C, ProcessingGeneric);
1995 raw_string_ostream OS(S);
1996 OS <<
"Unsupported expression in static initializer: ";
1997 CE->printAsOperand(OS,
false,
1998 !
MF ?
nullptr :
MF->getFunction().getParent());
2002void NVPTXAsmPrinter::printMCExpr(
const MCExpr &Expr, raw_ostream &OS)
const {
2008bool NVPTXAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
2009 const char *ExtraCode, raw_ostream &O) {
2010 if (ExtraCode && ExtraCode[0]) {
2011 if (ExtraCode[1] != 0)
2014 switch (ExtraCode[0]) {
2023 printOperand(
MI, OpNo, O);
2028bool NVPTXAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
2030 const char *ExtraCode,
2032 if (ExtraCode && ExtraCode[0])
2036 printMemOperand(
MI, OpNo, O);
2042void NVPTXAsmPrinter::printOperand(
const MachineInstr *
MI,
unsigned OpNum,
2044 const MachineOperand &MO =
MI->getOperand(OpNum);
2048 if (MO.
getReg() == NVPTX::VRDepot)
2053 emitVirtualRegister(MO.
getReg(), O);
2078void NVPTXAsmPrinter::printMemOperand(
const MachineInstr *
MI,
unsigned OpNum,
2079 raw_ostream &O,
const char *Modifier) {
2080 printOperand(
MI, OpNum, O);
2082 if (Modifier && strcmp(Modifier,
"add") == 0) {
2084 printOperand(
MI, OpNum + 1, O);
2086 if (
MI->getOperand(OpNum + 1).isImm() &&
2087 MI->getOperand(OpNum + 1).getImm() == 0)
2090 printOperand(
MI, OpNum + 1, O);
2098 return !Trimmed.
empty() &&
2099 (std::isalpha(
static_cast<unsigned char>(Trimmed[0])) ||
2106 if (!
MI || !
MI->getDebugLoc())
2108 const DISubprogram *SP =
MI->getMF()->getFunction().getSubprogram();
2112 if (!
DL->getFile() || !
DL->getLine())
2118struct InlineAsmInliningContext {
2120 unsigned FileIA = 0;
2121 unsigned LineIA = 0;
2124 bool hasInlinedAt()
const {
return FuncNameSym !=
nullptr; }
2130static InlineAsmInliningContext
2134 InlineAsmInliningContext Ctx;
2136 if (!InlinedAt || !InlinedAt->getFile() || !NVDD ||
2144 0, InlinedAt->getFile()->getDirectory(),
2145 InlinedAt->getFile()->getFilename(), std::nullopt, std::nullopt, CUID);
2146 Ctx.LineIA = InlinedAt->getLine();
2147 Ctx.ColIA = InlinedAt->getColumn();
2151void NVPTXAsmPrinter::emitInlineAsm(StringRef Str,
const MCSubtargetInfo &STI,
2152 const MCTargetOptions &MCOptions,
2153 const MDNode *LocMDNode,
2155 const MachineInstr *
MI) {
2156 assert(!Str.empty() &&
"Can't emit empty inline asm block");
2157 if (Str.back() == 0)
2158 Str = Str.substr(0, Str.size() - 1);
2160 auto emitAsmStr = [&](StringRef AsmStr) {
2172 const DIFile *
File =
DL->getFile();
2173 unsigned Line =
DL->getLine();
2174 const unsigned Column =
DL->getColumn();
2175 const unsigned CUID =
OutStreamer->getContext().getDwarfCompileUnitID();
2176 const unsigned FileNumber =
OutStreamer->emitDwarfFileDirective(
2177 0,
File->getDirectory(),
File->getFilename(), std::nullopt, std::nullopt,
2180 auto *NVDD =
static_cast<NVPTXDwarfDebug *
>(
getDwarfDebug());
2181 InlineAsmInliningContext InlineCtx =
2184 SmallVector<StringRef, 16>
Lines;
2185 Str.split(Lines,
'\n');
2187 for (
const StringRef &L : Lines) {
2188 StringRef RTrimmed =
L.rtrim(
'\r');
2190 if (InlineCtx.hasInlinedAt()) {
2192 FileNumber, Line, Column, InlineCtx.FileIA, InlineCtx.LineIA,
2194 File->getFilename());
2196 OutStreamer->emitDwarfLocDirective(FileNumber, Line, Column,
2198 File->getFilename());
2214LLVMInitializeNVPTXAsmPrinter() {
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.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
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...
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
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.
std::optional< unsigned > getMaxNReg(const Function &F)
void interleave(ForwardIterator begin, ForwardIterator end, UnaryFunctor each_fn, NullaryFunctor between_fn)
An STL-style algorithm similar to std::for_each that applies a second functor between every pair of e...
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)
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
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
Align getPTXParamAlign(const Function *F, Type *Ty, unsigned AttrIdx, const DataLayout &DL)
Get the alignment for a function parameter or return value.
ArrayRef(const T &OneElt) -> ArrayRef< T >
Align getDeviceByValParamAlign(const Function *F, Type *ArgTy, Align InitialAlign, const DataLayout &DL)
Target & getTheNVPTXTarget64()
bool isKernelFunction(const Function &F)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
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.
Target & getTheNVPTXTarget32()
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...