99#define DEPOTNAME "__local_depot"
102 assert(V.hasName() &&
"Found texture variable with no name");
107 assert(V.hasName() &&
"Found surface variable with no name");
112 assert(V.hasName() &&
"Found sampler variable with no name");
134 if (SP->getUnit()->isDebugDirectivesOnly() || SP->getUnit()->isNoDebug())
151 for (
const auto &O : U->operands())
164 if (Visited.
count(GV))
168 if (!Visiting.
insert(GV).second)
173 for (
const auto &O : GV->
operands())
186 NVPTX_MC::verifyInstructionPredicates(
MI->getOpcode(),
190 lowerToMCInst(
MI, Inst);
196 for (
const auto MO :
MI->operands())
241unsigned NVPTXAsmPrinter::encodeVirtualRegister(
unsigned Reg) {
245 DenseMap<unsigned, unsigned> &RegMap = VRegMapping[RC];
246 unsigned RegNum = RegMap[
Reg];
251 if (RC == &NVPTX::B1RegClass) {
253 }
else if (RC == &NVPTX::B16RegClass) {
255 }
else if (RC == &NVPTX::B32RegClass) {
257 }
else if (RC == &NVPTX::B64RegClass) {
259 }
else if (RC == &NVPTX::B128RegClass) {
266 Ret |= (RegNum & 0x0FFFFFFF);
271 return Reg & 0x0FFFFFFF;
283 const NVPTXSubtarget &STI =
TM.getSubtarget<NVPTXSubtarget>(*F);
286 Type *Ty = F->getReturnType();
293 auto PrintScalarRetVal = [&](
unsigned Size) {
297 const unsigned TotalSize =
DL.getTypeAllocSize(Ty);
298 const Align RetAlignment =
300 O <<
".param .align " << RetAlignment.
value() <<
" .b8 func_retval0["
305 PrintScalarRetVal(ITy->getBitWidth());
307 PrintScalarRetVal(TLI->getPointerTy(
DL).getSizeInBits());
316 printReturnValStr(&F, O);
319void NVPTXAsmPrinter::emitCallPrototype(
const CallBase &CB,
320 unsigned UniqueCallSite,
323 const NVPTXSubtarget &STI =
MF->getSubtarget<NVPTXSubtarget>();
325 const auto PtrVT = TLI->getPointerTy(
DL);
328 O <<
"prototype_" << UniqueCallSite <<
" : .callprototype ";
335 const Align RetAlign =
337 O <<
".param .align " << RetAlign.
value() <<
" .b8 _["
338 <<
DL.getTypeAllocSize(RetTy) <<
"]";
342 size = ITy->getBitWidth();
345 "Floating point type expected here");
353 O <<
".param .b" <<
size <<
" _";
355 O <<
".param .b" << PtrVT.getSizeInBits() <<
" _";
363 auto MakeArg = [&](
const unsigned I) {
369 &CB, ETy,
I + AttributeList::FirstArgIndex,
DL);
371 O <<
".param .align " << ParamByValAlign.
value() <<
" .b8 _["
372 <<
DL.getTypeAllocSize(ETy) <<
"]";
379 O <<
".param .align " << ParamAlign.
value() <<
" .b8 _["
380 <<
DL.getTypeAllocSize(Ty) <<
"]";
388 sz = PtrVT.getSizeInBits();
392 O <<
".param .b" << sz <<
" _";
396 const unsigned NumArgs = FTy->getNumParams();
406 if (FTy->isVarArg() && CB.
arg_size() > NumArgs)
407 O << (NonEmptyArgs.empty() ?
"" :
",") <<
" .param .align "
418bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll(
433 if (
const BasicBlock *PBB = PMBB->getBasicBlock()) {
435 PBB->getTerminator()->getMetadata(LLVMContext::MD_loop)) {
438 if (MDNode *UnrollCountMD =
452 if (isLoopHeaderOfNoUnroll(
MBB))
453 OutStreamer->emitRawText(StringRef(
"\t.pragma \"nounroll\";\n"));
457 SmallString<128> Str;
458 raw_svector_ostream
O(Str);
460 if (!GlobalsEmitted) {
461 emitGlobals(*
MF->getFunction().getParent());
462 GlobalsEmitted =
true;
466 MRI = &
MF->getRegInfo();
467 F = &
MF->getFunction();
468 emitLinkageDirective(F, O);
473 printReturnValStr(*
MF, O);
478 emitFunctionParamList(F, O);
482 emitKernelFunctionDirectives(*F, O);
492 setAndEmitFunctionVirtualRegisters(*
MF);
493 encodeDebugInfoRegisterNumbers(*
MF);
515 for (
const auto &[Id, CB] : MFI->getCallPrototypes())
516 emitCallPrototype(*CB, Id, O);
531void NVPTXAsmPrinter::emitImplicitDef(
const MachineInstr *
MI)
const {
544void NVPTXAsmPrinter::emitKernelFunctionDirectives(
const Function &
F,
551 O <<
formatv(
".reqntid {0:$[, ]}\n",
556 O <<
formatv(
".maxntid {0:$[, ]}\n",
560 O <<
".minnctapersm " << *Mincta <<
"\n";
563 O <<
".maxnreg " << *Maxnreg <<
"\n";
567 const NVPTXTargetMachine &NTM =
static_cast<const NVPTXTargetMachine &
>(
TM);
568 const NVPTXSubtarget *STI = &NTM.
getSubtarget<NVPTXSubtarget>(F);
576 if (!BlocksAreClusters)
577 O <<
".explicitcluster\n";
579 if (ClusterDim[0] != 0) {
581 "cluster_dim_x != 0 implies cluster_dim_y and cluster_dim_z "
582 "should be non-zero as well");
584 O <<
formatv(
".reqnctapercluster {0:$[, ]}\n",
588 "cluster_dim_x == 0 implies cluster_dim_y and cluster_dim_z "
589 "should be 0 as well");
593 if (BlocksAreClusters) {
594 LLVMContext &Ctx = F.getContext();
596 Ctx.
diagnose(DiagnosticInfoUnsupported(
597 F,
"blocksareclusters requires reqntid and cluster_dim attributes",
600 Ctx.
diagnose(DiagnosticInfoUnsupported(
601 F,
"blocksareclusters requires PTX version >= 9.0",
604 O <<
".blocksareclusters\n";
608 O <<
".maxclusterrank " << *Maxclusterrank <<
"\n";
619 assert(
I != VRegMapping.end() &&
"Bad register class");
623 assert(VI != RegMap.
end() &&
"Bad virtual register");
624 unsigned MappedVR = VI->second;
631void NVPTXAsmPrinter::emitVirtualRegister(
unsigned int vr,
636void NVPTXAsmPrinter::emitAliasDeclaration(
const GlobalAlias *GA,
641 "NVPTX aliasee must be a non-kernel function definition");
651 emitDeclarationWithName(F,
getSymbol(F), O);
656 emitLinkageDirective(F, O);
661 printReturnValStr(F, O);
664 emitFunctionParamList(F, O);
676 return GV->getName() !=
"llvm.used";
678 for (
const User *U :
C->users())
688 if (OtherGV->getName() ==
"llvm.used")
692 if (
const Function *CurFunc =
I->getFunction()) {
693 if (OneFunc && (CurFunc != OneFunc))
734 for (
const User *U :
C->users()) {
739 if (
const Function *Caller =
I->getFunction())
748 SmallPtrSet<const Function *, 32> SeenSet;
749 for (
const Function &F : M) {
750 if (F.getAttributes().hasFnAttr(
"nvptx-libcall-callee")) {
751 emitDeclaration(&F, O);
755 if (F.isDeclaration()) {
758 if (F.getIntrinsicID())
762 if (F.isIntrinsic()) {
763 LLVMContext &Ctx = F.getContext();
764 Ctx.
diagnose(DiagnosticInfoUnsupported(
765 F,
"unknown intrinsic '" + F.getName() +
766 "' cannot be lowered by the NVPTX backend"));
769 emitDeclaration(&F, O);
772 for (
const User *U : F.users()) {
778 emitDeclaration(&F, O);
784 emitDeclaration(&F, O);
799 emitDeclaration(&F, O);
805 for (
const GlobalAlias &GA :
M.aliases())
806 emitAliasDeclaration(&GA, O);
809void NVPTXAsmPrinter::emitStartOfAsmFile(
Module &M) {
813 const NVPTXTargetMachine &NTM =
static_cast<const NVPTXTargetMachine &
>(
TM);
834 GlobalsEmitted =
false;
839void NVPTXAsmPrinter::emitGlobals(
const Module &M) {
843 emitDeclarations(M, OS2);
858 assert(GVVisited.
size() == M.global_size() &&
"Missed a global variable");
859 assert(GVVisiting.
size() == 0 &&
"Did not fully process a global variable");
866 printModuleLevelGV(GV, OS2,
false, STI);
886 return static_cast<NVPTXTargetStreamer *
>(
OutStreamer->getTargetStreamer());
891 switch(
CU->getEmissionKind()) {
905 auto *TS = getTargetStreamer();
910 TS->emitVersionDirective(PTXVersion);
912 const NVPTXTargetMachine &NTM =
static_cast<const NVPTXTargetMachine &
>(
TM);
915 TS->emitTargetDirective(STI.
getTargetName(), TexModeIndependent,
917 TS->emitAddressSizeDirective(
M.getDataLayout().getPointerSizeInBits());
923 if (!GlobalsEmitted) {
925 GlobalsEmitted =
true;
937 TS->closeLastSection();
939 OutStreamer->emitRawText(
"\t.section\t.debug_macinfo\t{\t}");
961void NVPTXAsmPrinter::emitLinkageDirective(
const GlobalValue *V,
964 if (V->hasExternalLinkage()) {
966 O << (GVar->hasInitializer() ?
".visible " :
".extern ");
967 else if (V->isDeclaration())
971 }
else if (V->hasAppendingLinkage()) {
973 "' has unsupported appending linkage type");
974 }
else if (!
V->hasInternalLinkage() && !
V->hasPrivateLinkage()) {
980void NVPTXAsmPrinter::printModuleLevelGV(
const GlobalVariable *GVar,
1028 emitPTXGlobalVariable(GVar, O, STI);
1036 const Constant *Initializer =
nullptr;
1039 const ConstantInt *CI =
nullptr;
1050 O <<
"addr_mode_" << i <<
" = ";
1056 O <<
"clamp_to_border";
1059 O <<
"clamp_to_edge";
1070 O <<
"filter_mode = ";
1085 O <<
", force_unnormalized_coords = 1";
1105 const Function *DemotedFunc =
nullptr;
1107 O <<
"// " << GVar->
getName() <<
" has been demoted\n";
1108 localDecls[DemotedFunc].push_back(GVar);
1118 ".attribute(.managed) requires PTX version >= 4.0 and sm_30");
1119 O <<
" .attribute(.managed)";
1123 << GVar->
getAlign().value_or(
DL.getPrefTypeAlign(ETy)).value();
1132 O << getPTXFundamentalTypeStr(ETy,
false);
1145 printScalarConstant(Initializer, O);
1154 "' is not allowed in addrspace(" +
1170 const uint64_t ElementSize =
DL.getTypeStoreSize(ETy);
1178 AggBuffer aggBuffer(ElementSize, *
this);
1179 bufferAggregateConstant(Initializer, &aggBuffer);
1180 if (aggBuffer.numSymbols()) {
1181 const unsigned int ptrSize =
MAI.getCodePointerSize();
1182 if (ElementSize % ptrSize ||
1183 !aggBuffer.allSymbolsAligned(ptrSize)) {
1187 "initialized packed aggregate with pointers '" +
1189 "' requires at least PTX ISA version 7.1");
1192 O <<
"[" << ElementSize <<
"] = {";
1193 aggBuffer.printBytes(O);
1196 O <<
" .u" << ptrSize * 8 <<
" ";
1198 O <<
"[" << ElementSize / ptrSize <<
"] = {";
1199 aggBuffer.printWords(O);
1205 O <<
"[" << ElementSize <<
"] = {";
1206 aggBuffer.printBytes(O);
1213 O <<
"[" << ElementSize <<
"]";
1219 O <<
"[" << ElementSize <<
"]";
1230void NVPTXAsmPrinter::AggBuffer::printSymbol(
unsigned nSym,
raw_ostream &os) {
1231 const Value *
v = Symbols[nSym];
1232 const Value *v0 = SymbolsBeforeStripping[nSym];
1237 bool isGenericPointer = PTy && PTy->getAddressSpace() == 0;
1240 Name->print(os, AP.MAI);
1243 Name->print(os, AP.MAI);
1246 const MCExpr *Expr = AP.lowerConstantForGV(CExpr,
false);
1247 AP.printMCExpr(*Expr, os);
1252void NVPTXAsmPrinter::AggBuffer::printBytes(raw_ostream &os) {
1253 unsigned int ptrSize = AP.MAI.getCodePointerSize();
1258 unsigned int InitializerCount =
Size;
1261 if (numSymbols() == 0)
1262 while (InitializerCount >= 1 && !buffer[InitializerCount - 1])
1265 symbolPosInBuffer.push_back(InitializerCount);
1266 unsigned int nSym = 0;
1267 unsigned int nextSymbolPos = symbolPosInBuffer[nSym];
1268 for (
unsigned int pos = 0; pos < InitializerCount;) {
1271 if (pos != nextSymbolPos) {
1272 os << (
unsigned int)buffer[pos];
1279 std::string symText;
1280 llvm::raw_string_ostream oss(symText);
1281 printSymbol(nSym, oss);
1282 for (
unsigned i = 0; i < ptrSize; ++i) {
1286 os <<
"(" << symText <<
")";
1289 nextSymbolPos = symbolPosInBuffer[++nSym];
1290 assert(nextSymbolPos >= pos);
1294void NVPTXAsmPrinter::AggBuffer::printWords(raw_ostream &os) {
1295 unsigned int ptrSize = AP.MAI.getCodePointerSize();
1296 symbolPosInBuffer.push_back(
Size);
1297 unsigned int nSym = 0;
1298 unsigned int nextSymbolPos = symbolPosInBuffer[nSym];
1299 assert(nextSymbolPos % ptrSize == 0);
1300 for (
unsigned int pos = 0; pos <
Size; pos += ptrSize) {
1303 if (pos == nextSymbolPos) {
1304 printSymbol(nSym, os);
1305 nextSymbolPos = symbolPosInBuffer[++nSym];
1306 assert(nextSymbolPos % ptrSize == 0);
1307 assert(nextSymbolPos >= pos + ptrSize);
1308 }
else if (ptrSize == 4)
1315void NVPTXAsmPrinter::emitDemotedVars(
const Function *F, raw_ostream &O) {
1316 auto It = localDecls.find(F);
1317 if (It == localDecls.end())
1322 const NVPTXTargetMachine &NTM =
static_cast<const NVPTXTargetMachine &
>(
TM);
1325 for (
const GlobalVariable *GV : GVars) {
1326 O <<
"\t// demoted variable\n\t";
1327 printModuleLevelGV(GV, O,
true, STI);
1331void NVPTXAsmPrinter::emitPTXAddressSpace(
unsigned int AddressSpace,
1332 raw_ostream &O)
const {
1354NVPTXAsmPrinter::getPTXFundamentalTypeStr(
Type *Ty,
bool useB4PTR)
const {
1360 if (NumBits <= 64) {
1361 std::string
name =
"u";
1378 assert((PtrSize == 64 || PtrSize == 32) &&
"Unexpected pointer size");
1396void NVPTXAsmPrinter::emitPTXGlobalVariable(
const GlobalVariable *GVar,
1398 const NVPTXSubtarget &STI) {
1409 ".attribute(.managed) requires PTX version >= 4.0 and sm_30");
1411 O <<
" .attribute(.managed)";
1414 << GVar->
getAlign().value_or(
DL.getPrefTypeAlign(ETy)).value();
1425 O <<
" ." << getPTXFundamentalTypeStr(ETy) <<
" ";
1430 int64_t ElementSize = 0;
1440 ElementSize =
DL.getTypeStoreSize(ETy);
1454void NVPTXAsmPrinter::emitFunctionParamList(
const Function *F, raw_ostream &O) {
1456 const NVPTXSubtarget &STI =
TM.getSubtarget<NVPTXSubtarget>(*F);
1458 const NVPTXMachineFunctionInfo *MFI =
1459 MF ?
MF->getInfo<NVPTXMachineFunctionInfo>() : nullptr;
1461 bool IsFirst =
true;
1468 const auto NonEmptyArgs =
1470 return !Arg.getType()->isEmptyTy();
1473 if (NonEmptyArgs.empty() && !F->isVarArg()) {
1480 for (
const auto &[ParamIndex, Arg] :
enumerate(NonEmptyArgs)) {
1481 Type *Ty = Arg.getType();
1482 const std::string ParamSym = TLI->getParamName(F, ParamIndex);
1498 switch (ArgOpaqueType) {
1500 O <<
".samplerref ";
1516 if (Arg.hasByValAttr()) {
1518 Type *ETy = Arg.getParamByValType();
1519 assert(ETy &&
"Param should have byval type");
1525 const unsigned ParamIdx = Arg.getArgNo() + AttributeList::FirstArgIndex;
1526 const Align OptimalAlign =
1530 O <<
"\t.param .align " << OptimalAlign.
value() <<
" .b8 " << ParamSym
1531 <<
"[" <<
DL.getTypeAllocSize(ETy) <<
"]";
1541 F, Ty, Arg.getArgNo() + AttributeList::FirstArgIndex,
DL);
1543 O <<
"\t.param .align " << OptimalAlign.
value() <<
" .b8 " << ParamSym
1544 <<
"[" <<
DL.getTypeAllocSize(Ty) <<
"]";
1550 unsigned PTySizeInBits = 0;
1553 TLI->getPointerTy(
DL, PTy->getAddressSpace()).getSizeInBits();
1554 assert(PTySizeInBits &&
"Invalid pointer size");
1559 O <<
"\t.param .u" << PTySizeInBits <<
" .ptr";
1561 switch (PTy->getAddressSpace()) {
1578 O <<
" .align " << Arg.getParamAlign().valueOrOne().value() <<
" "
1589 O << getPTXFundamentalTypeStr(Ty);
1590 O <<
" " << ParamSym;
1599 assert(PTySizeInBits &&
"Invalid pointer size");
1600 Size = PTySizeInBits;
1603 O <<
"\t.param .b" <<
Size <<
" " << ParamSym;
1606 if (F->isVarArg()) {
1610 << TLI->getParamName(F, -1) <<
"[]";
1616void NVPTXAsmPrinter::setAndEmitFunctionVirtualRegisters(
1617 const MachineFunction &
MF) {
1618 SmallString<128> Str;
1619 raw_svector_ostream
O(Str);
1623 const TargetRegisterInfo *
TRI =
MF.getSubtarget().getRegisterInfo();
1626 const MachineFrameInfo &MFI =
MF.getFrameInfo();
1631 if (
static_cast<const NVPTXTargetMachine &
>(
MF.getTarget()).is64Bit()) {
1632 O <<
"\t.reg .b64 \t%SP;\n"
1633 <<
"\t.reg .b64 \t%SPL;\n";
1635 O <<
"\t.reg .b32 \t%SP;\n"
1636 <<
"\t.reg .b32 \t%SPL;\n";
1644 for (
unsigned I :
llvm::seq(MRI->getNumVirtRegs())) {
1646 if (MRI->use_empty(VR) && MRI->def_empty(VR))
1648 auto &RCRegMap = VRegMapping[MRI->getRegClass(VR)];
1649 RCRegMap[VR] = RCRegMap.size() + 1;
1655 const unsigned N = VRegMapping[&RC].size();
1661 O <<
"\t.reg " << RCName <<
" \t" << RCStr <<
"<" << (
N + 1) <<
">;\n";
1670void NVPTXAsmPrinter::encodeDebugInfoRegisterNumbers(
1671 const MachineFunction &
MF) {
1672 const NVPTXSubtarget &STI =
MF.getSubtarget<NVPTXSubtarget>();
1680 for (
auto &classMap : VRegMapping) {
1681 for (
auto ®isterMapping : classMap.getSecond()) {
1682 auto reg = registerMapping.getFirst();
1688void NVPTXAsmPrinter::printFPConstant(
const ConstantFP *Fp,
1689 raw_ostream &O)
const {
1692 unsigned int numHex;
1710void NVPTXAsmPrinter::printScalarConstant(
const Constant *CPV, raw_ostream &O) {
1716 printFPConstant(CFP, O);
1725 if (EmitGeneric && !
isa<Function>(CPV) && !IsNonGenericPointer) {
1742void NVPTXAsmPrinter::bufferLEByte(
const Constant *CPV,
int Bytes,
1743 AggBuffer *AggBuffer) {
1745 int AllocSize =
DL.getTypeAllocSize(CPV->
getType());
1749 AggBuffer->addZeros(Bytes ? Bytes : AllocSize);
1754 auto AddIntToBuffer = [AggBuffer, Bytes](
const APInt &Val) {
1755 size_t NumBytes = (Val.getBitWidth() + 7) / 8;
1761 for (
unsigned I = 0;
I < NumBytes - 1; ++
I) {
1762 Buf[
I] = Val.extractBitsAsZExtValue(8,
I * 8);
1764 size_t LastBytePosition = (NumBytes - 1) * 8;
1765 size_t LastByteBits = Val.getBitWidth() - LastBytePosition;
1767 Val.extractBitsAsZExtValue(LastByteBits, LastBytePosition);
1768 AggBuffer->addBytes(Buf.data(), NumBytes, Bytes);
1778 if (
const auto *CI =
1783 if (Cexpr->getOpcode() == Instruction::PtrToInt) {
1784 Value *
V = Cexpr->getOperand(0)->stripPointerCasts();
1785 AggBuffer->addSymbol(V, Cexpr->getOperand(0));
1786 AggBuffer->addZeros(AllocSize);
1793 AggBuffer->addSymbol(Cexpr, Cexpr);
1794 AggBuffer->addZeros(AllocSize);
1809 AggBuffer->addSymbol(GVar, GVar);
1811 const Value *
v = Cexpr->stripPointerCasts();
1812 AggBuffer->addSymbol(v, Cexpr);
1814 AggBuffer->addZeros(AllocSize);
1824 unsigned StartPos = AggBuffer->getCurpos();
1825 bufferAggregateConstant(CPV, AggBuffer);
1826 unsigned Written = AggBuffer->getCurpos() - StartPos;
1827 unsigned SlotSize = std::max<int>(Bytes, AllocSize);
1828 if (SlotSize > Written)
1829 AggBuffer->addZeros(SlotSize - Written);
1831 AggBuffer->addZeros(Bytes);
1842void NVPTXAsmPrinter::bufferAggregateConstant(
const Constant *CPV,
1843 AggBuffer *aggBuffer) {
1846 auto ExtendBuffer = [](APInt Val, AggBuffer *Buffer) {
1849 unsigned NumBits = std::min(8u, Val.
getBitWidth() -
I * 8);
1857 for (
unsigned I :
llvm::seq(VTy->getNumElements()))
1866 ExtendBuffer(CI->
getValue(), aggBuffer);
1872 assert(CFP->getType()->isFloatingPointTy() &&
"Expected fp constant!");
1873 if (CFP->getType()->isFP128Ty()) {
1874 ExtendBuffer(CFP->getValueAPF().bitcastToAPInt(), aggBuffer);
1888 bufferAggregateConstVec(CVec, aggBuffer);
1893 for (
unsigned I :
llvm::seq(CDS->getNumElements()))
1894 bufferLEByte(
cast<Constant>(CDS->getElementAsConstant(
I)), 0, aggBuffer);
1903 ?
DL.getStructLayout(ST)->getElementOffset(0) +
1904 DL.getTypeAllocSize(ST)
1905 :
DL.getStructLayout(ST)->getElementOffset(
I + 1);
1906 int Bytes = EndOffset -
DL.getStructLayout(ST)->getElementOffset(
I);
1915void NVPTXAsmPrinter::bufferAggregateConstVec(
const ConstantVector *CV,
1916 AggBuffer *aggBuffer) {
1918 const unsigned BuffSize = aggBuffer->getBufferSize();
1921 if (BuffSize >= NumElems) {
1934 assert(ElemTySize < 8 &&
"Expected sub-byte data type.");
1935 assert(8 % ElemTySize == 0 &&
"Element type size must evenly divide a byte.");
1937 unsigned NumElemsPerByte = 8 / ElemTySize;
1938 unsigned NumCompleteBytes = NumElems / NumElemsPerByte;
1939 unsigned NumTailElems = NumElems % NumElemsPerByte;
1944 auto ConvertSubCVtoInt8 = [
this, &ElemTy](
const ConstantVector *CV,
1945 unsigned Start,
unsigned End,
1946 unsigned NumPaddingZeros = 0) {
1953 if (NumPaddingZeros)
1960 ConstantInt *MergedElem =
1967 "Cannot lower vector global with unusual element type");
1974 for (
unsigned ByteIdx :
llvm::seq(NumCompleteBytes))
1975 bufferLEByte(ConvertSubCVtoInt8(CV, ByteIdx * NumElemsPerByte,
1976 (ByteIdx + 1) * NumElemsPerByte),
1980 if (NumTailElems > 0)
1981 bufferLEByte(ConvertSubCVtoInt8(CV, NumElems - NumTailElems, NumElems,
1982 NumElemsPerByte - NumTailElems),
1991NVPTXAsmPrinter::lowerConstantForGV(
const Constant *CV,
1992 bool ProcessingGeneric)
const {
2003 if (ProcessingGeneric)
2013 switch (
CE->getOpcode()) {
2017 case Instruction::AddrSpaceCast: {
2020 if (DstTy->getAddressSpace() == 0)
2026 case Instruction::GetElementPtr: {
2030 APInt OffsetAI(
DL.getPointerTypeSizeInBits(
CE->getType()), 0);
2033 const MCExpr *
Base = lowerConstantForGV(
CE->getOperand(0),
2038 int64_t
Offset = OffsetAI.getSExtValue();
2043 case Instruction::Trunc:
2049 case Instruction::BitCast:
2050 return lowerConstantForGV(
CE->getOperand(0), ProcessingGeneric);
2052 case Instruction::IntToPtr: {
2061 return lowerConstantForGV(
Op, ProcessingGeneric);
2066 case Instruction::PtrToInt: {
2072 Type *Ty =
CE->getType();
2074 const MCExpr *OpExpr = lowerConstantForGV(
Op, ProcessingGeneric);
2078 if (
DL.getTypeAllocSize(Ty) ==
DL.getTypeAllocSize(
Op->getType()))
2084 unsigned InBits =
DL.getTypeAllocSizeInBits(
Op->getType());
2091 case Instruction::Add: {
2092 const MCExpr *
LHS = lowerConstantForGV(
CE->getOperand(0), ProcessingGeneric);
2093 const MCExpr *
RHS = lowerConstantForGV(
CE->getOperand(1), ProcessingGeneric);
2094 switch (
CE->getOpcode()) {
2106 return lowerConstantForGV(
C, ProcessingGeneric);
2110 raw_string_ostream OS(S);
2111 OS <<
"Unsupported expression in static initializer: ";
2112 CE->printAsOperand(OS,
false,
2113 !
MF ?
nullptr :
MF->getFunction().getParent());
2117void NVPTXAsmPrinter::printMCExpr(
const MCExpr &Expr, raw_ostream &OS)
const {
2123bool NVPTXAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
2124 const char *ExtraCode, raw_ostream &O) {
2125 if (ExtraCode && ExtraCode[0]) {
2126 if (ExtraCode[1] != 0)
2129 switch (ExtraCode[0]) {
2138 printOperand(
MI, OpNo, O);
2143bool NVPTXAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
2145 const char *ExtraCode,
2147 if (ExtraCode && ExtraCode[0])
2151 printMemOperand(
MI, OpNo, O);
2157void NVPTXAsmPrinter::printOperand(
const MachineInstr *
MI,
unsigned OpNum,
2159 const MachineOperand &MO =
MI->getOperand(OpNum);
2163 if (MO.
getReg() == NVPTX::VRDepot)
2168 emitVirtualRegister(MO.
getReg(), O);
2193void NVPTXAsmPrinter::printMemOperand(
const MachineInstr *
MI,
unsigned OpNum,
2194 raw_ostream &O,
const char *Modifier) {
2195 printOperand(
MI, OpNum, O);
2197 if (Modifier && strcmp(Modifier,
"add") == 0) {
2199 printOperand(
MI, OpNum + 1, O);
2201 if (
MI->getOperand(OpNum + 1).isImm() &&
2202 MI->getOperand(OpNum + 1).getImm() == 0)
2205 printOperand(
MI, OpNum + 1, O);
2213 return !Trimmed.
empty() &&
2214 (std::isalpha(
static_cast<unsigned char>(Trimmed[0])) ||
2221 if (!
MI || !
MI->getDebugLoc())
2223 const DISubprogram *SP =
MI->getMF()->getFunction().getSubprogram();
2227 if (!
DL->getFile() || !
DL->getLine())
2233struct InlineAsmInliningContext {
2235 unsigned FileIA = 0;
2236 unsigned LineIA = 0;
2239 bool hasInlinedAt()
const {
return FuncNameSym !=
nullptr; }
2245static InlineAsmInliningContext
2249 InlineAsmInliningContext Ctx;
2251 if (!InlinedAt || !InlinedAt->getFile() || !NVDD ||
2259 0, InlinedAt->getFile()->getDirectory(),
2260 InlinedAt->getFile()->getFilename(), std::nullopt, std::nullopt, CUID);
2261 Ctx.LineIA = InlinedAt->getLine();
2262 Ctx.ColIA = InlinedAt->getColumn();
2266void NVPTXAsmPrinter::emitInlineAsm(StringRef Str,
const MCSubtargetInfo &STI,
2267 const MCTargetOptions &MCOptions,
2268 const MDNode *LocMDNode,
2270 const MachineInstr *
MI) {
2271 assert(!Str.empty() &&
"Can't emit empty inline asm block");
2272 if (Str.back() == 0)
2273 Str = Str.substr(0, Str.size() - 1);
2275 auto emitAsmStr = [&](StringRef AsmStr) {
2287 const DIFile *
File =
DL->getFile();
2288 unsigned Line =
DL->getLine();
2289 const unsigned Column =
DL->getColumn();
2290 const unsigned CUID =
OutStreamer->getContext().getDwarfCompileUnitID();
2291 const unsigned FileNumber =
OutStreamer->emitDwarfFileDirective(
2292 0,
File->getDirectory(),
File->getFilename(), std::nullopt, std::nullopt,
2295 auto *NVDD =
static_cast<NVPTXDwarfDebug *
>(
getDwarfDebug());
2296 InlineAsmInliningContext InlineCtx =
2299 SmallVector<StringRef, 16>
Lines;
2300 Str.split(Lines,
'\n');
2302 for (
const StringRef &L : Lines) {
2303 StringRef RTrimmed =
L.rtrim(
'\r');
2305 if (InlineCtx.hasInlinedAt()) {
2307 FileNumber, Line, Column, InlineCtx.FileIA, InlineCtx.LineIA,
2309 File->getFilename());
2311 OutStreamer->emitDwarfLocDirective(FileNumber, Line, Column,
2313 File->getFilename());
2329LLVMInitializeNVPTXAsmPrinter() {
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)
Provides some synthesis utilities to produce sequences of values.
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.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a call or parameter.
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
unsigned arg_size() const
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
Type * getReturnType() 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.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
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...
LLVM_ABI bool isEmptyTy() const
Return true if this type is empty, that is, it has no elements or all of its elements are empty.
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
@ 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.
bool isVoidTy() const
Return true if this is 'void'.
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.
bool isManaged(const Value &)
SmallVector< unsigned, 3 > getReqNTID(const Function &)
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...
bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM)
Align getDeviceByValParamAlign(const Function *F, Type *ArgTy, unsigned AttrIdx, const DataLayout &DL)
The .param-space alignment for a byval parameter or call argument: the (possibly promoted) parameter ...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
bool hasBlocksAreClusters(const Function &)
SmallVector< unsigned, 3 > getClusterDim(const Function &)
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
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.
std::optional< unsigned > getMaxNReg(const Function &)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
PTXOpaqueType getPTXOpaqueType(const GlobalVariable &)
std::string utostr(uint64_t X, bool isNeg=false)
constexpr auto equal_to(T &&Arg)
Functor variant of std::equal_to that can be used as a UnaryPredicate in functional algorithms like a...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
std::optional< unsigned > getMinCTASm(const Function &)
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)
SmallVector< unsigned, 3 > getMaxNTID(const Function &)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
bool shouldPassAsArray(Type *Ty)
StringRef getNVPTXRegClassStr(const TargetRegisterClass *RC)
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
std::optional< unsigned > getMaxClusterRank(const Function &)
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...
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
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)
Alignment for a function parameter or return value at AttributeList index AttrIdx (FirstArgIndex + ar...
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.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
StringRef getNVPTXRegClassName(const TargetRegisterClass *RC)
void clearAnnotationCache(const Module *)
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...
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()
MCRegisterClass TargetRegisterClass
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,...