61#define HANDLE_MDNODE_LEAF(CLASS) CLASS##AbbrevID,
62#include "llvm/IR/Metadata.def"
80 CONSTANTS_INTEGER_ABBREV,
81 CONSTANTS_CE_CAST_Abbrev,
82 CONSTANTS_NULL_Abbrev,
86 FUNCTION_INST_BINOP_ABBREV,
87 FUNCTION_INST_BINOP_FLAGS_ABBREV,
88 FUNCTION_INST_CAST_ABBREV,
89 FUNCTION_INST_RET_VOID_ABBREV,
90 FUNCTION_INST_RET_VAL_ABBREV,
91 FUNCTION_INST_UNREACHABLE_ABBREV,
92 FUNCTION_INST_GEP_ABBREV,
113 std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
116 unsigned GlobalValueId;
122 uint64_t BitcodeStartBit;
138 StrtabBuilder(StrtabBuilder), M(M), VE(M, I8PtrTy, DebugInfo),
139 Buffer(Buffer), BitcodeStartBit(Stream.GetCurrentBitNo()),
141 GlobalValueId = VE.getValues().
size();
143 for (
auto El : PointerMap)
144 VE.EnumerateType(El.second);
170 void writeModuleVersion();
171 void writePerModuleGlobalValueSummary();
174 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
178 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
181 assert(VMI != GUIDToValueIdMap.end() &&
182 "GUID does not have assigned value Id");
188 if (!VI.haveGVs() || !VI.getValue())
189 return getValueId(VI.getGUID());
190 return VE.getValueID(VI.getValue());
193 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
195 uint64_t bitcodeStartBit() {
return BitcodeStartBit; }
197 unsigned createDILocationAbbrev();
198 unsigned createGenericDINodeAbbrev();
200 void writeAttributeGroupTable();
201 void writeAttributeTable();
202 void writeTypeTable();
204 void writeValueSymbolTableForwardDecl();
205 void writeModuleInfo();
206 void writeValueAsMetadata(
const ValueAsMetadata *MD,
207 SmallVectorImpl<uint64_t> &Record);
208 void writeMDTuple(
const MDTuple *
N, SmallVectorImpl<uint64_t> &Record,
210 void writeDILocation(
const DILocation *
N, SmallVectorImpl<uint64_t> &Record,
212 void writeGenericDINode(
const GenericDINode *
N,
213 SmallVectorImpl<uint64_t> &Record,
unsigned &Abbrev) {
216 void writeDISubrange(
const DISubrange *
N, SmallVectorImpl<uint64_t> &Record,
218 void writeDIGenericSubrange(
const DIGenericSubrange *
N,
219 SmallVectorImpl<uint64_t> &Record,
223 void writeDIEnumerator(
const DIEnumerator *
N,
224 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
225 void writeDIBasicType(
const DIBasicType *
N, SmallVectorImpl<uint64_t> &Record,
227 void writeDIFixedPointType(
const DIFixedPointType *
N,
228 SmallVectorImpl<uint64_t> &Record,
232 void writeDIStringType(
const DIStringType *
N,
233 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
236 void writeDIDerivedType(
const DIDerivedType *
N,
237 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
238 void writeDISubrangeType(
const DISubrangeType *
N,
239 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
242 void writeDICompositeType(
const DICompositeType *
N,
243 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
244 void writeDISubroutineType(
const DISubroutineType *
N,
245 SmallVectorImpl<uint64_t> &Record,
247 void writeDIFile(
const DIFile *
N, SmallVectorImpl<uint64_t> &Record,
249 void writeDICompileUnit(
const DICompileUnit *
N,
250 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
251 void writeDISubprogram(
const DISubprogram *
N,
252 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
253 void writeDILexicalBlock(
const DILexicalBlock *
N,
254 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
255 void writeDILexicalBlockFile(
const DILexicalBlockFile *
N,
256 SmallVectorImpl<uint64_t> &Record,
258 void writeDICommonBlock(
const DICommonBlock *
N,
259 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
262 void writeDINamespace(
const DINamespace *
N, SmallVectorImpl<uint64_t> &Record,
264 void writeDIMacro(
const DIMacro *
N, SmallVectorImpl<uint64_t> &Record,
268 void writeDIMacroFile(
const DIMacroFile *
N, SmallVectorImpl<uint64_t> &Record,
272 void writeDIArgList(
const DIArgList *
N, SmallVectorImpl<uint64_t> &Record,
276 void writeDIAssignID(
const DIAssignID *
N, SmallVectorImpl<uint64_t> &Record,
283 void writeDILayerLoc(
const DILayerLoc *
N, SmallVectorImpl<uint64_t> &Record,
287 void writeDILayerLocList(
const DILayerLocList *
N,
288 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
291 void writeDIModule(
const DIModule *
N, SmallVectorImpl<uint64_t> &Record,
293 void writeDITemplateTypeParameter(
const DITemplateTypeParameter *
N,
294 SmallVectorImpl<uint64_t> &Record,
296 void writeDITemplateValueParameter(
const DITemplateValueParameter *
N,
297 SmallVectorImpl<uint64_t> &Record,
299 void writeDIGlobalVariable(
const DIGlobalVariable *
N,
300 SmallVectorImpl<uint64_t> &Record,
302 void writeDILocalVariable(
const DILocalVariable *
N,
303 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
304 void writeDILabel(
const DILabel *
N, SmallVectorImpl<uint64_t> &Record,
308 void writeDIExpression(
const DIExpression *
N,
309 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
310 void writeDIGlobalVariableExpression(
const DIGlobalVariableExpression *
N,
311 SmallVectorImpl<uint64_t> &Record,
315 void writeDIObjCProperty(
const DIObjCProperty *
N,
316 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
317 void writeDIProperty(
const DIProperty *
N, SmallVectorImpl<uint64_t> &Record,
321 void writeDIImportedEntity(
const DIImportedEntity *
N,
322 SmallVectorImpl<uint64_t> &Record,
324 void writeMDFunctionLocalContext(
const MDFunctionLocalContext *
N,
325 SmallVectorImpl<uint64_t> &Record,
329 unsigned createMetadataStringsAbbrev();
331 SmallVectorImpl<uint64_t> &Record);
333 SmallVectorImpl<uint64_t> &Record,
334 std::vector<unsigned> *MDAbbrevs =
nullptr,
335 std::vector<uint64_t> *IndexPos =
nullptr);
336 void writeModuleMetadata();
337 void writeFunctionMetadata(
const Function &
F);
338 void writeFunctionMetadataAttachment(
const Function &
F);
339 void writeModuleMetadataKinds();
340 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
341 void writeModuleConstants();
342 bool pushValueAndType(
const Value *
V,
unsigned InstID,
343 SmallVectorImpl<unsigned> &Vals);
344 void pushValue(
const Value *
V,
unsigned InstID,
345 SmallVectorImpl<unsigned> &Vals);
346 void pushValueSigned(
const Value *
V,
unsigned InstID,
347 SmallVectorImpl<uint64_t> &Vals);
348 void writeInstruction(
const Instruction &
I,
unsigned InstID,
349 SmallVectorImpl<unsigned> &Vals);
350 void writeFunctionLevelValueSymbolTable(
const ValueSymbolTable &VST);
352 void writeBlockInfo();
354 unsigned getEncodedSyncScopeID(
SyncScope::ID SSID) {
return unsigned(SSID); }
356 unsigned getEncodedAlign(MaybeAlign Alignment) {
return encode(Alignment); }
358 unsigned getTypeID(
Type *
T,
const Value *
V =
nullptr);
363 unsigned getGlobalObjectValueTypeID(
Type *
T,
const GlobalObject *
G);
379 Stream->Emit((
unsigned)
'B', 8);
380 Stream->Emit((
unsigned)
'C', 8);
381 Stream->Emit(0x0, 4);
382 Stream->Emit(0xC, 4);
383 Stream->Emit(0xE, 4);
384 Stream->Emit(0xD, 4);
396 Triple TT(M.getTargetTriple());
397 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
406 Out.write((
char *)&Buffer.
front(), Buffer.
size());
412 auto Abbv = std::make_shared<BitCodeAbbrev>();
415 auto AbbrevNo = Stream->
EmitAbbrev(std::move(Abbv));
429 assert(M.isMaterialized());
430 Mods.push_back(
const_cast<Module *
>(&M));
433 ModuleWriter.
write();
444 case Instruction::Trunc:
446 case Instruction::ZExt:
448 case Instruction::SExt:
450 case Instruction::FPToUI:
452 case Instruction::FPToSI:
454 case Instruction::UIToFP:
456 case Instruction::SIToFP:
458 case Instruction::FPTrunc:
460 case Instruction::FPExt:
462 case Instruction::PtrToInt:
464 case Instruction::IntToPtr:
466 case Instruction::BitCast:
468 case Instruction::AddrSpaceCast:
477 case Instruction::FNeg:
486 case Instruction::Add:
487 case Instruction::FAdd:
489 case Instruction::Sub:
490 case Instruction::FSub:
492 case Instruction::Mul:
493 case Instruction::FMul:
495 case Instruction::UDiv:
497 case Instruction::FDiv:
498 case Instruction::SDiv:
500 case Instruction::URem:
502 case Instruction::FRem:
503 case Instruction::SRem:
505 case Instruction::Shl:
507 case Instruction::LShr:
509 case Instruction::AShr:
511 case Instruction::And:
513 case Instruction::Or:
515 case Instruction::Xor:
520unsigned DXILBitcodeWriter::getTypeID(
Type *
T,
const Value *V) {
524 return VE.getTypeID(
T);
525 auto It = PointerMap.
find(V);
526 if (It != PointerMap.
end())
527 return VE.getTypeID(It->second);
531 if (
T->isPointerTy())
532 return VE.getTypeID(I8PtrTy);
533 return VE.getTypeID(
T);
536unsigned DXILBitcodeWriter::getGlobalObjectValueTypeID(
Type *
T,
538 auto It = PointerMap.
find(
G);
539 if (It != PointerMap.
end()) {
543 return VE.getTypeID(
T);
605 unsigned AbbrevToUse) {
616 Stream.EmitRecord(Code, Vals, AbbrevToUse);
621 case Attribute::Alignment:
623 case Attribute::AlwaysInline:
625 case Attribute::Builtin:
627 case Attribute::ByVal:
629 case Attribute::Convergent:
631 case Attribute::InAlloca:
633 case Attribute::Cold:
635 case Attribute::InlineHint:
637 case Attribute::InReg:
639 case Attribute::JumpTable:
641 case Attribute::MinSize:
643 case Attribute::Naked:
645 case Attribute::Nest:
647 case Attribute::NoAlias:
649 case Attribute::NoBuiltin:
651 case Attribute::NoDuplicate:
653 case Attribute::NoImplicitFloat:
655 case Attribute::NoInline:
657 case Attribute::NonLazyBind:
659 case Attribute::NonNull:
661 case Attribute::Dereferenceable:
663 case Attribute::DereferenceableOrNull:
665 case Attribute::NoRedZone:
667 case Attribute::NoReturn:
669 case Attribute::NoUnwind:
671 case Attribute::OptimizeForSize:
673 case Attribute::OptimizeNone:
675 case Attribute::ReadNone:
677 case Attribute::ReadOnly:
679 case Attribute::Returned:
681 case Attribute::ReturnsTwice:
683 case Attribute::SExt:
685 case Attribute::StackAlignment:
687 case Attribute::StackProtect:
689 case Attribute::StackProtectReq:
691 case Attribute::StackProtectStrong:
693 case Attribute::SafeStack:
695 case Attribute::StructRet:
697 case Attribute::SanitizeAddress:
699 case Attribute::SanitizeThread:
701 case Attribute::SanitizeMemory:
703 case Attribute::UWTable:
705 case Attribute::ZExt:
713 "should be stripped in DXILPrepare");
733 unsigned NumWords =
A.getActiveWords();
734 const uint64_t *RawData =
A.getRawData();
735 for (
unsigned i = 0; i < NumWords; i++)
743 if (OBO->hasNoSignedWrap())
745 if (OBO->hasNoUnsignedWrap())
751 if (FPMO->hasAllowReassoc() || FPMO->hasAllowContract())
753 if (FPMO->hasNoNaNs())
755 if (FPMO->hasNoInfs())
757 if (FPMO->hasNoSignedZeros())
759 if (FPMO->hasAllowReciprocal())
840 switch (
C.getSelectionKind()) {
859void DXILBitcodeWriter::writeAttributeGroupTable() {
860 const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
861 VE.getAttributeGroups();
862 if (AttrGrps.empty())
869 unsigned AttrListIndex = Pair.first;
871 Record.push_back(
VE.getAttributeGroupID(Pair));
872 Record.push_back(AttrListIndex);
875 if (Attr.isEnumAttribute()) {
878 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
881 }
else if (Attr.isIntAttribute()) {
882 if (Attr.getKindAsEnum() == Attribute::AttrKind::Memory) {
900 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
903 Record.push_back(Attr.getValueAsInt());
906 StringRef
Kind = Attr.getKindAsString();
907 StringRef Val = Attr.getValueAsString();
926void DXILBitcodeWriter::writeAttributeTable() {
927 const std::vector<AttributeList> &
Attrs = VE.getAttributeLists();
933 SmallVector<uint64_t, 64>
Record;
934 for (AttributeList AL : Attrs) {
935 for (
unsigned i :
AL.indexes()) {
936 AttributeSet AS =
AL.getAttributes(i);
938 Record.push_back(VE.getAttributeGroupID({i, AS}));
949void DXILBitcodeWriter::writeTypeTable() {
953 SmallVector<uint64_t, 64> TypeVals;
955 uint64_t NumBits = VE.computeBitsRequiredForTypeIndices();
958 auto Abbv = std::make_shared<BitCodeAbbrev>();
961 Abbv->Add(BitCodeAbbrevOp(0));
962 unsigned PtrAbbrev = Stream.EmitAbbrev(std::move(Abbv));
965 Abbv = std::make_shared<BitCodeAbbrev>();
970 unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
973 Abbv = std::make_shared<BitCodeAbbrev>();
978 unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
981 Abbv = std::make_shared<BitCodeAbbrev>();
985 unsigned StructNameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
988 Abbv = std::make_shared<BitCodeAbbrev>();
993 unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
996 Abbv = std::make_shared<BitCodeAbbrev>();
1000 unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1008 for (
Type *
T : TypeList) {
1009 int AbbrevToUse = 0;
1012 switch (
T->getTypeID()) {
1065 AbbrevToUse = PtrAbbrev;
1076 "dxilOpaquePtrReservedName", StructNameAbbrev);
1084 TypeVals.
push_back(getTypeID(FT->getReturnType()));
1085 for (
Type *PTy : FT->params())
1087 AbbrevToUse = FunctionAbbrev;
1095 for (
Type *ElTy :
ST->elements())
1098 if (
ST->isLiteral()) {
1100 AbbrevToUse = StructAnonAbbrev;
1102 if (
ST->isOpaque()) {
1106 AbbrevToUse = StructNamedAbbrev;
1110 if (!
ST->getName().empty())
1120 TypeVals.
push_back(AT->getNumElements());
1121 TypeVals.
push_back(getTypeID(AT->getElementType()));
1122 AbbrevToUse = ArrayAbbrev;
1130 TypeVals.
push_back(VT->getElementCount().getKnownMinValue());
1131 TypeVals.
push_back(getTypeID(VT->getElementType()));
1137 Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
1144void DXILBitcodeWriter::writeComdats() {
1146 for (
const Comdat *
C : VE.getComdats()) {
1149 size_t Size =
C->getName().size();
1152 for (
char Chr :
C->getName())
1159void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
1164void DXILBitcodeWriter::writeModuleInfo() {
1169 StringRef Triple =
"dxil-ms-dx";
1170 StringRef
DL =
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-"
1171 "f16:16-f32:32-f64:64-n8:16:32:64";
1180 std::map<std::string, unsigned> SectionMap;
1181 std::map<std::string, unsigned> GCMap;
1183 unsigned MaxGlobalType = 0;
1184 const auto UpdateMaxAlignment = [&
MaxAlignment](
const MaybeAlign
A) {
1188 for (
const GlobalVariable &GV : M.globals()) {
1189 UpdateMaxAlignment(GV.getAlign());
1192 MaxGlobalType = std::max(
1193 MaxGlobalType, getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1194 if (GV.hasSection()) {
1196 unsigned &
Entry = SectionMap[std::string(GV.getSection())];
1199 GV.getSection(), 0 );
1200 Entry = SectionMap.size();
1205 UpdateMaxAlignment(
F.getAlign());
1206 if (
F.hasSection()) {
1208 unsigned &
Entry = SectionMap[std::string(
F.getSection())];
1212 Entry = SectionMap.size();
1217 unsigned &
Entry = GCMap[
F.getGC()];
1221 Entry = GCMap.size();
1227 unsigned SimpleGVarAbbrev = 0;
1228 if (!M.global_empty()) {
1231 auto Abbv = std::make_shared<BitCodeAbbrev>();
1241 Abbv->Add(BitCodeAbbrevOp(0));
1243 unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1247 if (SectionMap.empty())
1248 Abbv->Add(BitCodeAbbrevOp(0));
1253 SimpleGVarAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1258 for (
const GlobalVariable &GV : M.globals()) {
1259 unsigned AbbrevToUse = 0;
1265 Vals.
push_back(getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1267 GV.getType()->getAddressSpace() << 2 | 2 |
1268 (GV.isConstant() ? 1 : 0));
1271 GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1));
1273 Vals.
push_back(getEncodedAlign(GV.getAlign()));
1274 Vals.
push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1276 if (GV.isThreadLocal() ||
1279 GV.isExternallyInitialized() ||
1285 Vals.
push_back(GV.isExternallyInitialized());
1287 Vals.
push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1289 AbbrevToUse = SimpleGVarAbbrev;
1298 const Function &
F = VE.getDXILFunction(OrigF);
1303 Vals.
push_back(getGlobalObjectValueTypeID(
F.getFunctionType(), &
F));
1307 Vals.
push_back(VE.getAttributeListID(
F.getAttributes()));
1308 Vals.
push_back(getEncodedAlign(
F.getAlign()));
1309 Vals.
push_back(
F.hasSection() ? SectionMap[std::string(
F.getSection())]
1315 F.hasPrologueData() ? (VE.getValueID(
F.getPrologueData()) + 1) : 0);
1317 Vals.
push_back(
F.hasComdat() ? VE.getComdatID(
F.getComdat()) : 0);
1318 Vals.
push_back(
F.hasPrefixData() ? (VE.getValueID(
F.getPrefixData()) + 1)
1321 F.hasPersonalityFn() ? (VE.getValueID(
F.getPersonalityFn()) + 1) : 0);
1323 unsigned AbbrevToUse = 0;
1329 for (
const GlobalAlias &
A : M.aliases()) {
1332 Vals.
push_back(VE.getValueID(
A.getAliasee()));
1338 unsigned AbbrevToUse = 0;
1344void DXILBitcodeWriter::writeValueAsMetadata(
1345 const ValueAsMetadata *MD, SmallVectorImpl<uint64_t> &Record) {
1353 Record.push_back(getTypeID(Ty,
V));
1354 Record.push_back(VE.getValueID(
V));
1359void DXILBitcodeWriter::writeMDTuple(
const MDTuple *
N,
1360 SmallVectorImpl<uint64_t> &Record,
1362 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
1365 "Unexpected function-local metadata");
1366 Record.push_back(VE.getMetadataOrNullID(MD));
1374void DXILBitcodeWriter::writeDILocation(
const DILocation *
N,
1375 SmallVectorImpl<uint64_t> &Record,
1378 Abbrev = createDILocationAbbrev();
1379 Record.push_back(
N->isDistinct());
1380 Record.push_back(
N->getLine());
1381 Record.push_back(
N->getColumn());
1382 Record.push_back(VE.getMetadataID(
N->getScope()));
1383 Record.push_back(VE.getMetadataOrNullID(
N->getInlinedAt()));
1392 return I < 0 ? ~(U << 1) : U << 1;
1395void DXILBitcodeWriter::writeDISubrange(
const DISubrange *
N,
1396 SmallVectorImpl<uint64_t> &Record,
1398 Record.push_back(
N->isDistinct());
1404 Record.push_back(
Count->getValue().getSExtValue());
1410 DISubrange::BoundType
LowerBound =
N->getLowerBound();
1421void DXILBitcodeWriter::writeDIEnumerator(
const DIEnumerator *
N,
1422 SmallVectorImpl<uint64_t> &Record,
1424 Record.push_back(
N->isDistinct());
1426 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1432void DXILBitcodeWriter::writeDIBasicType(
const DIBasicType *
N,
1433 SmallVectorImpl<uint64_t> &Record,
1435 Record.push_back(
N->isDistinct());
1436 Record.push_back(
N->getTag());
1437 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1438 Record.push_back(
N->getSizeInBits());
1439 Record.push_back(
N->getAlignInBits());
1440 Record.push_back(
N->getEncoding());
1446void DXILBitcodeWriter::writeDIDerivedType(
const DIDerivedType *
N,
1447 SmallVectorImpl<uint64_t> &Record,
1449 Record.push_back(
N->isDistinct());
1450 Record.push_back(
N->getTag());
1451 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1452 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1453 Record.push_back(
N->getLine());
1454 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1455 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1456 Record.push_back(
N->getSizeInBits());
1457 Record.push_back(
N->getAlignInBits());
1458 Record.push_back(
N->getOffsetInBits());
1459 Record.push_back(
N->getFlags());
1460 Record.push_back(VE.getMetadataOrNullID(
N->getExtraData()));
1466void DXILBitcodeWriter::writeDICompositeType(
const DICompositeType *
N,
1467 SmallVectorImpl<uint64_t> &Record,
1469 Record.push_back(
N->isDistinct());
1470 Record.push_back(
N->getTag());
1471 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1472 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1473 Record.push_back(
N->getLine());
1474 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1475 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1476 Record.push_back(
N->getSizeInBits());
1477 Record.push_back(
N->getAlignInBits());
1478 Record.push_back(
N->getOffsetInBits());
1479 Record.push_back(
N->getFlags());
1480 Record.push_back(VE.getMetadataOrNullID(
N->getElements().get()));
1481 Record.push_back(
N->getRuntimeLang());
1482 Record.push_back(VE.getMetadataOrNullID(
N->getVTableHolder()));
1483 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1484 Record.push_back(VE.getMetadataOrNullID(
N->getRawIdentifier()));
1490void DXILBitcodeWriter::writeDISubroutineType(
const DISubroutineType *
N,
1491 SmallVectorImpl<uint64_t> &Record,
1493 Record.push_back(
N->isDistinct());
1494 Record.push_back(
N->getFlags());
1495 Record.push_back(VE.getMetadataOrNullID(
N->getTypeArray().get()));
1501void DXILBitcodeWriter::writeDIFile(
const DIFile *
N,
1502 SmallVectorImpl<uint64_t> &Record,
1504 Record.push_back(
N->isDistinct());
1505 Record.push_back(VE.getMetadataOrNullID(
N->getRawFilename()));
1506 Record.push_back(VE.getMetadataOrNullID(
N->getRawDirectory()));
1512void DXILBitcodeWriter::writeDICompileUnit(
const DICompileUnit *
N,
1513 SmallVectorImpl<uint64_t> &Record,
1515 Record.push_back(
N->isDistinct());
1516 Record.push_back(
N->getSourceLanguage().getUnversionedName());
1517 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1518 Record.push_back(VE.getMetadataOrNullID(
N->getRawProducer()));
1519 Record.push_back(
N->isOptimized());
1520 Record.push_back(VE.getMetadataOrNullID(
N->getRawFlags()));
1521 Record.push_back(
N->getRuntimeVersion());
1522 Record.push_back(VE.getMetadataOrNullID(
N->getRawSplitDebugFilename()));
1523 Record.push_back(
N->getEmissionKind());
1524 Record.push_back(VE.getMetadataOrNullID(
N->getEnumTypes().get()));
1525 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedTypes().get()));
1526 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1527 Record.push_back(VE.getMetadataOrNullID(
N->getGlobalVariables().get()));
1528 Record.push_back(VE.getMetadataOrNullID(
N->getImportedEntities().get()));
1529 Record.push_back(
N->getDWOId());
1535void DXILBitcodeWriter::writeDISubprogram(
const DISubprogram *
N,
1536 SmallVectorImpl<uint64_t> &Record,
1538 Record.push_back(
N->isDistinct());
1539 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1540 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1541 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1542 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1543 Record.push_back(
N->getLine());
1544 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1545 Record.push_back(
N->isLocalToUnit());
1546 Record.push_back(
N->isDefinition());
1547 Record.push_back(
N->getScopeLine());
1548 Record.push_back(VE.getMetadataOrNullID(
N->getContainingType()));
1549 Record.push_back(
N->getVirtuality());
1550 Record.push_back(
N->getVirtualIndex());
1551 Record.push_back(
N->getFlags());
1552 Record.push_back(
N->isOptimized());
1553 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1554 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1555 Record.push_back(VE.getMetadataOrNullID(
N->getDeclaration()));
1556 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedNodes().get()));
1562void DXILBitcodeWriter::writeDILexicalBlock(
const DILexicalBlock *
N,
1563 SmallVectorImpl<uint64_t> &Record,
1565 Record.push_back(
N->isDistinct());
1566 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1567 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1568 Record.push_back(
N->getLine());
1569 Record.push_back(
N->getColumn());
1575void DXILBitcodeWriter::writeDILexicalBlockFile(
1576 const DILexicalBlockFile *
N, SmallVectorImpl<uint64_t> &Record,
1578 Record.push_back(
N->isDistinct());
1579 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1580 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1581 Record.push_back(
N->getDiscriminator());
1587void DXILBitcodeWriter::writeDINamespace(
const DINamespace *
N,
1588 SmallVectorImpl<uint64_t> &Record,
1590 Record.push_back(
N->isDistinct());
1591 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1592 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1593 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1600void DXILBitcodeWriter::writeDIModule(
const DIModule *
N,
1601 SmallVectorImpl<uint64_t> &Record,
1603 Record.push_back(
N->isDistinct());
1604 for (
auto &
I :
N->operands())
1605 Record.push_back(VE.getMetadataOrNullID(
I));
1611void DXILBitcodeWriter::writeDITemplateTypeParameter(
1612 const DITemplateTypeParameter *
N, SmallVectorImpl<uint64_t> &Record,
1614 Record.push_back(
N->isDistinct());
1615 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1616 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1622void DXILBitcodeWriter::writeDITemplateValueParameter(
1623 const DITemplateValueParameter *
N, SmallVectorImpl<uint64_t> &Record,
1625 Record.push_back(
N->isDistinct());
1626 Record.push_back(
N->getTag());
1627 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1628 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1629 Record.push_back(VE.getMetadataOrNullID(
N->getValue()));
1635void DXILBitcodeWriter::writeDIGlobalVariable(
const DIGlobalVariable *
N,
1636 SmallVectorImpl<uint64_t> &Record,
1638 Record.push_back(
N->isDistinct());
1639 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1640 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1641 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1642 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1643 Record.push_back(
N->getLine());
1644 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1645 Record.push_back(
N->isLocalToUnit());
1646 Record.push_back(
N->isDefinition());
1647 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1648 Record.push_back(VE.getMetadataOrNullID(
N->getStaticDataMemberDeclaration()));
1654void DXILBitcodeWriter::writeDILocalVariable(
const DILocalVariable *
N,
1655 SmallVectorImpl<uint64_t> &Record,
1657 constexpr unsigned DW_TAG_auto_variable = 0x0100;
1658 constexpr unsigned DW_TAG_arg_variable = 0x0101;
1659 Record.push_back(
N->isDistinct());
1660 assert(
N->getTag() == dwarf::DW_TAG_variable);
1661 Record.push_back(
N->getArg() ? DW_TAG_arg_variable : DW_TAG_auto_variable);
1662 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1663 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1664 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1665 Record.push_back(
N->getLine());
1666 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1667 Record.push_back(
N->getArg());
1668 Record.push_back(
N->getFlags());
1674void DXILBitcodeWriter::writeDIExpression(
const DIExpression *
N,
1675 SmallVectorImpl<uint64_t> &Record,
1677 Record.reserve(
N->getElements().size() + 1);
1679 Record.push_back(
N->isDistinct());
1680 Record.append(
N->elements_begin(),
N->elements_end());
1686void DXILBitcodeWriter::writeDIObjCProperty(
const DIObjCProperty *
N,
1687 SmallVectorImpl<uint64_t> &Record,
1692void DXILBitcodeWriter::writeDIImportedEntity(
const DIImportedEntity *
N,
1693 SmallVectorImpl<uint64_t> &Record,
1695 Record.push_back(
N->isDistinct());
1696 Record.push_back(
N->getTag());
1697 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1698 Record.push_back(VE.getMetadataOrNullID(
N->getEntity()));
1699 Record.push_back(
N->getLine());
1700 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1706unsigned DXILBitcodeWriter::createDILocationAbbrev() {
1711 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1718 return Stream.EmitAbbrev(std::move(Abbv));
1721unsigned DXILBitcodeWriter::createGenericDINodeAbbrev() {
1726 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1734 return Stream.EmitAbbrev(std::move(Abbv));
1738 SmallVectorImpl<uint64_t> &Record,
1739 std::vector<unsigned> *MDAbbrevs,
1740 std::vector<uint64_t> *IndexPos) {
1745#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1746#include "llvm/IR/Metadata.def"
1750 IndexPos->push_back(Stream.GetCurrentBitNo());
1752 assert(
N->isResolved() &&
"Expected forward references to be resolved");
1754 switch (
N->getMetadataID()) {
1757#define HANDLE_MDNODE_LEAF(CLASS) \
1758 case Metadata::CLASS##Kind: \
1760 write##CLASS(cast<CLASS>(N), Record, \
1761 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1763 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1765#include "llvm/IR/Metadata.def"
1772unsigned DXILBitcodeWriter::createMetadataStringsAbbrev() {
1773 auto Abbv = std::make_shared<BitCodeAbbrev>();
1777 return Stream.EmitAbbrev(std::move(Abbv));
1780void DXILBitcodeWriter::writeMetadataStrings(
1782 if (Strings.
empty())
1785 unsigned MDSAbbrev = createMetadataStringsAbbrev();
1787 for (
const Metadata *MD : Strings) {
1798void DXILBitcodeWriter::writeModuleMetadata() {
1799 if (!VE.hasMDs() && M.named_metadata_empty())
1806 std::vector<unsigned> MDAbbrevs;
1809 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1810 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1811 createGenericDINodeAbbrev();
1813 unsigned NameAbbrev = 0;
1814 if (!M.named_metadata_empty()) {
1816 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1820 NameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1823 SmallVector<uint64_t, 64>
Record;
1824 writeMetadataStrings(VE.getMDStrings(), Record);
1826 std::vector<uint64_t> IndexPos;
1827 IndexPos.reserve(VE.getNonMDStrings().size());
1828 writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1831 for (
const NamedMDNode &NMD : M.named_metadata()) {
1833 StringRef Str = NMD.getName();
1834 Record.append(Str.bytes_begin(), Str.bytes_end());
1839 for (
const MDNode *
N : NMD.operands())
1840 Record.push_back(VE.getMetadataID(
N));
1848void DXILBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
1853 SmallVector<uint64_t, 64>
Record;
1854 writeMetadataStrings(VE.getMDStrings(), Record);
1855 writeMetadataRecords(VE.getNonMDStrings(), Record);
1859void DXILBitcodeWriter::writeFunctionMetadataAttachment(
const Function &
F) {
1862 SmallVector<uint64_t, 64>
Record;
1867 F.getAllMetadata(MDs);
1869 for (
const auto &
I : MDs) {
1870 if (
I.first == LLVMContext::MD_dbg)
1873 Record.push_back(VE.getMetadataID(
I.second));
1881 for (
const BasicBlock &BB :
F)
1882 for (
const Instruction &OrigI : BB) {
1886 I.getAllMetadataOtherThanDebugLoc(MDs);
1892 Record.push_back(VE.getInstructionID(&
I));
1894 for (
unsigned i = 0, e = MDs.size(); i != e; ++i) {
1895 Record.push_back(MDs[i].first);
1896 Record.push_back(VE.getMetadataID(MDs[i].second));
1905void DXILBitcodeWriter::writeModuleMetadataKinds() {
1906 SmallVector<uint64_t, 64>
Record;
1911 M.getMDKindNames(Names);
1918 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
1919 Record.push_back(MDKindID);
1920 StringRef KName = Names[MDKindID];
1930void DXILBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
1932 if (FirstVal == LastVal)
1937 unsigned AggregateAbbrev = 0;
1938 unsigned String8Abbrev = 0;
1939 unsigned CString7Abbrev = 0;
1940 unsigned CString6Abbrev = 0;
1944 auto Abbv = std::make_shared<BitCodeAbbrev>();
1949 AggregateAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1952 Abbv = std::make_shared<BitCodeAbbrev>();
1956 String8Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1958 Abbv = std::make_shared<BitCodeAbbrev>();
1962 CString7Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1964 Abbv = std::make_shared<BitCodeAbbrev>();
1968 CString6Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1971 SmallVector<uint64_t, 64>
Record;
1974 Type *LastTy =
nullptr;
1975 for (
unsigned i = FirstVal; i != LastVal; ++i) {
1976 const Value *
V = Vals[i].first;
1978 if (
V->getType() != LastTy) {
1979 LastTy =
V->getType();
1980 Record.push_back(getTypeID(LastTy,
V));
1982 CONSTANTS_SETTYPE_ABBREV);
1987 Record.push_back(
unsigned(
IA->hasSideEffects()) |
1988 unsigned(
IA->isAlignStack()) << 1 |
1989 unsigned(
IA->getDialect() & 1) << 2);
1992 StringRef AsmStr =
IA->getAsmString();
1997 StringRef ConstraintStr =
IA->getConstraintString();
2005 unsigned Code = -1U;
2006 unsigned AbbrevToUse = 0;
2007 if (
C->isNullValue()) {
2012 if (
IV->getBitWidth() <= 64) {
2016 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2022 unsigned NWords =
IV->getValue().getActiveWords();
2023 const uint64_t *RawWords =
IV->getValue().getRawData();
2024 for (
unsigned i = 0; i != NWords; ++i) {
2032 if (BV->getBitWidth() <= 64) {
2036 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2038 unsigned NWords = BV->getValue().getActiveWords();
2039 const uint64_t *RawWords = BV->getValue().getRawData();
2040 for (
unsigned i = 0; i != NWords; ++i) {
2049 Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2053 APInt api = CFP->getValueAPF().bitcastToAPInt();
2055 Record.push_back((p[1] << 48) | (p[0] >> 16));
2056 Record.push_back(p[0] & 0xffffLL);
2058 APInt api = CFP->getValueAPF().bitcastToAPInt();
2063 assert(0 &&
"Unknown FP type!");
2069 unsigned NumElts = Str->getNumElements();
2071 if (Str->isCString()) {
2076 AbbrevToUse = String8Abbrev;
2080 for (
unsigned i = 0; i != NumElts; ++i) {
2081 unsigned char V = Str->getElementAsInteger(i);
2083 isCStr7 &= (
V & 128) == 0;
2089 AbbrevToUse = CString6Abbrev;
2091 AbbrevToUse = CString7Abbrev;
2092 }
else if (
const ConstantDataSequential *CDS =
2095 Type *EltTy = CDS->getElementType();
2097 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2098 Record.push_back(CDS->getElementAsInteger(i));
2100 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2105 F = CDS->getElementAsFloat(i);
2110 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2115 F = CDS->getElementAsDouble(i);
2122 for (
const Value *
Op :
C->operands())
2123 Record.push_back(VE.getValueID(
Op));
2124 AbbrevToUse = AggregateAbbrev;
2126 switch (
CE->getOpcode()) {
2132 getTypeID(
C->getOperand(0)->getType(),
C->getOperand(0)));
2133 Record.push_back(VE.getValueID(
C->getOperand(0)));
2134 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2136 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2139 Record.push_back(VE.getValueID(
C->getOperand(0)));
2140 Record.push_back(VE.getValueID(
C->getOperand(1)));
2146 case Instruction::GetElementPtr: {
2149 if (GO->isInBounds())
2151 Record.push_back(getTypeID(GO->getSourceElementType()));
2152 for (
unsigned i = 0, e =
CE->getNumOperands(); i != e; ++i) {
2154 getTypeID(
C->getOperand(i)->getType(),
C->getOperand(i)));
2155 Record.push_back(VE.getValueID(
C->getOperand(i)));
2159 case Instruction::Select:
2161 Record.push_back(VE.getValueID(
C->getOperand(0)));
2162 Record.push_back(VE.getValueID(
C->getOperand(1)));
2163 Record.push_back(VE.getValueID(
C->getOperand(2)));
2165 case Instruction::ExtractElement:
2167 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2168 Record.push_back(VE.getValueID(
C->getOperand(0)));
2169 Record.push_back(getTypeID(
C->getOperand(1)->getType()));
2170 Record.push_back(VE.getValueID(
C->getOperand(1)));
2172 case Instruction::InsertElement:
2174 Record.push_back(VE.getValueID(
C->getOperand(0)));
2175 Record.push_back(VE.getValueID(
C->getOperand(1)));
2176 Record.push_back(getTypeID(
C->getOperand(2)->getType()));
2177 Record.push_back(VE.getValueID(
C->getOperand(2)));
2179 case Instruction::ShuffleVector:
2184 if (
C->getType() ==
C->getOperand(0)->getType()) {
2188 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2190 Record.push_back(VE.getValueID(
C->getOperand(0)));
2191 Record.push_back(VE.getValueID(
C->getOperand(1)));
2192 Record.push_back(VE.getValueID(
C->getOperand(2)));
2197 Record.push_back(getTypeID(BA->getFunction()->getType()));
2198 Record.push_back(VE.getValueID(BA->getFunction()));
2199 Record.push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2206 Stream.EmitRecord(Code, Record, AbbrevToUse);
2213void DXILBitcodeWriter::writeModuleConstants() {
2218 for (
unsigned i = 0, e = Vals.size(); i != e; ++i) {
2220 writeConstants(i, Vals.size(),
true);
2234bool DXILBitcodeWriter::pushValueAndType(
const Value *
V,
unsigned InstID,
2235 SmallVectorImpl<unsigned> &Vals) {
2236 unsigned ValID = VE.getValueID(
V);
2239 if (ValID >= InstID) {
2248void DXILBitcodeWriter::pushValue(
const Value *
V,
unsigned InstID,
2249 SmallVectorImpl<unsigned> &Vals) {
2250 unsigned ValID = VE.getValueID(
V);
2254void DXILBitcodeWriter::pushValueSigned(
const Value *
V,
unsigned InstID,
2255 SmallVectorImpl<uint64_t> &Vals) {
2256 unsigned ValID = VE.getValueID(
V);
2257 int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2262void DXILBitcodeWriter::writeInstruction(
const Instruction &
I,
unsigned InstID,
2263 SmallVectorImpl<unsigned> &Vals) {
2265 unsigned AbbrevToUse = 0;
2266 VE.setInstructionID(&
I);
2267 switch (
I.getOpcode()) {
2271 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2272 AbbrevToUse = (unsigned)FUNCTION_INST_CAST_ABBREV;
2278 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2279 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_ABBREV;
2280 pushValue(
I.getOperand(1), InstID, Vals);
2284 if (AbbrevToUse == (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2285 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV;
2291 case Instruction::GetElementPtr: {
2293 AbbrevToUse = (unsigned)FUNCTION_INST_GEP_ABBREV;
2296 Vals.
push_back(getTypeID(GEPInst.getSourceElementType()));
2297 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i)
2298 pushValueAndType(
I.getOperand(i), InstID, Vals);
2301 case Instruction::ExtractValue: {
2303 pushValueAndType(
I.getOperand(0), InstID, Vals);
2308 case Instruction::InsertValue: {
2310 pushValueAndType(
I.getOperand(0), InstID, Vals);
2311 pushValueAndType(
I.getOperand(1), InstID, Vals);
2316 case Instruction::Select:
2318 pushValueAndType(
I.getOperand(1), InstID, Vals);
2319 pushValue(
I.getOperand(2), InstID, Vals);
2320 pushValueAndType(
I.getOperand(0), InstID, Vals);
2322 case Instruction::ExtractElement:
2324 pushValueAndType(
I.getOperand(0), InstID, Vals);
2325 pushValueAndType(
I.getOperand(1), InstID, Vals);
2327 case Instruction::InsertElement:
2329 pushValueAndType(
I.getOperand(0), InstID, Vals);
2330 pushValue(
I.getOperand(1), InstID, Vals);
2331 pushValueAndType(
I.getOperand(2), InstID, Vals);
2333 case Instruction::ShuffleVector:
2335 pushValueAndType(
I.getOperand(0), InstID, Vals);
2336 pushValue(
I.getOperand(1), InstID, Vals);
2340 case Instruction::ICmp:
2341 case Instruction::FCmp: {
2344 pushValueAndType(
I.getOperand(0), InstID, Vals);
2345 pushValue(
I.getOperand(1), InstID, Vals);
2353 case Instruction::Ret: {
2355 unsigned NumOperands =
I.getNumOperands();
2356 if (NumOperands == 0)
2357 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VOID_ABBREV;
2358 else if (NumOperands == 1) {
2359 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2360 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VAL_ABBREV;
2362 for (
unsigned i = 0, e = NumOperands; i !=
e; ++i)
2363 pushValueAndType(
I.getOperand(i), InstID, Vals);
2366 case Instruction::UncondBr:
2370 case Instruction::CondBr: {
2373 Vals.
push_back(VE.getValueID(
II.getSuccessor(0)));
2374 Vals.
push_back(VE.getValueID(
II.getSuccessor(1)));
2375 pushValue(
II.getCondition(), InstID, Vals);
2377 case Instruction::Switch: {
2380 Vals.
push_back(getTypeID(
SI.getCondition()->getType()));
2381 pushValue(
SI.getCondition(), InstID, Vals);
2382 Vals.
push_back(VE.getValueID(
SI.getDefaultDest()));
2383 for (
auto Case :
SI.cases()) {
2384 Vals.
push_back(VE.getValueID(Case.getCaseValue()));
2385 Vals.
push_back(VE.getValueID(Case.getCaseSuccessor()));
2388 case Instruction::IndirectBr:
2390 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2392 pushValue(
I.getOperand(0), InstID, Vals);
2393 for (
unsigned i = 1, e =
I.getNumOperands(); i != e; ++i)
2394 Vals.
push_back(VE.getValueID(
I.getOperand(i)));
2397 case Instruction::Invoke: {
2400 FunctionType *FTy =
II->getFunctionType();
2403 Vals.
push_back(VE.getAttributeListID(
II->getAttributes()));
2405 Vals.
push_back(VE.getValueID(
II->getNormalDest()));
2406 Vals.
push_back(VE.getValueID(
II->getUnwindDest()));
2408 pushValueAndType(Callee, InstID, Vals);
2411 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2412 pushValue(
I.getOperand(i), InstID, Vals);
2415 if (FTy->isVarArg()) {
2416 for (
unsigned i = FTy->getNumParams(), e =
I.getNumOperands() - 3; i != e;
2418 pushValueAndType(
I.getOperand(i), InstID, Vals);
2422 case Instruction::Resume:
2424 pushValueAndType(
I.getOperand(0), InstID, Vals);
2426 case Instruction::Unreachable:
2428 AbbrevToUse = (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV;
2431 case Instruction::PHI: {
2444 Stream.EmitRecord(Code, Vals64, AbbrevToUse);
2449 case Instruction::LandingPad: {
2460 pushValueAndType(LP.
getClause(
I), InstID, Vals);
2465 case Instruction::Alloca: {
2469 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2470 Vals.
push_back(VE.getValueID(
I.getOperand(0)));
2472 assert(AlignRecord < 1 << 5 &&
"alignment greater than 1 << 64");
2474 AlignRecord |= 1 << 6;
2479 case Instruction::Load:
2482 pushValueAndType(
I.getOperand(0), InstID, Vals);
2485 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2486 AbbrevToUse = (unsigned)FUNCTION_INST_LOAD_ABBREV;
2496 case Instruction::Store:
2501 pushValueAndType(
I.getOperand(1), InstID, Vals);
2502 pushValueAndType(
I.getOperand(0), InstID, Vals);
2511 case Instruction::AtomicCmpXchg:
2513 pushValueAndType(
I.getOperand(0), InstID, Vals);
2514 pushValueAndType(
I.getOperand(1), InstID, Vals);
2515 pushValue(
I.getOperand(2), InstID, Vals);
2525 case Instruction::AtomicRMW:
2527 pushValueAndType(
I.getOperand(0), InstID, Vals);
2528 pushValue(
I.getOperand(1), InstID, Vals);
2536 case Instruction::Fence:
2541 case Instruction::Call: {
2554 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
2556 if (FTy->getParamType(i)->isLabelTy())
2563 if (FTy->isVarArg()) {
2564 for (
unsigned i = FTy->getNumParams(), e = CI.
arg_size(); i != e; ++i)
2569 case Instruction::VAArg:
2571 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2572 pushValue(
I.getOperand(0), InstID, Vals);
2577 Stream.EmitRecord(Code, Vals, AbbrevToUse);
2582void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
2583 const ValueSymbolTable &VST) {
2595 for (
auto &VI : VST) {
2596 const Value &
V = VE.getDXILValue(*
VI.second);
2601 return A->first() <
B->first();
2604 for (
const ValueName *SI : SortedTable) {
2609 bool isChar6 =
true;
2610 for (
const char *
C =
Name.getKeyData(), *
E =
C +
Name.getKeyLength();
2614 if ((
unsigned char)*
C & 128) {
2620 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2628 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2632 AbbrevToUse = VST_ENTRY_6_ABBREV;
2634 AbbrevToUse = VST_ENTRY_7_ABBREV;
2637 NameVals.
push_back(VE.getValueID(
SI->getValue()));
2638 for (
const char *
P =
Name.getKeyData(),
2639 *
E =
Name.getKeyData() +
Name.getKeyLength();
2644 Stream.EmitRecord(Code, NameVals, AbbrevToUse);
2651void DXILBitcodeWriter::writeFunction(
const Function &
F) {
2653 VE.incorporateFunction(
F);
2659 Vals.
push_back(VE.getBasicBlocks().size());
2664 unsigned CstStart, CstEnd;
2665 VE.getFunctionConstantRange(CstStart, CstEnd);
2666 writeConstants(CstStart, CstEnd,
false);
2669 writeFunctionMetadata(
F);
2672 unsigned InstID = CstEnd;
2674 bool NeedsMetadataAttachment =
F.hasMetadata();
2676 DILocation *LastDL =
nullptr;
2684 writeInstruction(
I, InstID, Vals);
2686 if (!
I.getType()->isVoidTy())
2690 NeedsMetadataAttachment |=
I.hasMetadataOtherThanDebugLoc();
2693 DILocation *
DL =
I.getDebugLoc();
2705 Vals.
push_back(VE.getMetadataOrNullID(
DL->getScope()));
2706 Vals.
push_back(VE.getMetadataOrNullID(
DL->getInlinedAt()));
2714 if (
auto *Symtab =
F.getValueSymbolTable())
2715 writeFunctionLevelValueSymbolTable(*Symtab);
2717 if (NeedsMetadataAttachment)
2718 writeFunctionMetadataAttachment(
F);
2725void DXILBitcodeWriter::writeBlockInfo() {
2729 Stream.EnterBlockInfoBlock();
2732 auto Abbv = std::make_shared<BitCodeAbbrev>();
2738 std::move(Abbv)) != VST_ENTRY_8_ABBREV)
2739 assert(
false &&
"Unexpected abbrev ordering!");
2743 auto Abbv = std::make_shared<BitCodeAbbrev>();
2749 std::move(Abbv)) != VST_ENTRY_7_ABBREV)
2750 assert(
false &&
"Unexpected abbrev ordering!");
2753 auto Abbv = std::make_shared<BitCodeAbbrev>();
2759 std::move(Abbv)) != VST_ENTRY_6_ABBREV)
2760 assert(
false &&
"Unexpected abbrev ordering!");
2763 auto Abbv = std::make_shared<BitCodeAbbrev>();
2769 std::move(Abbv)) != VST_BBENTRY_6_ABBREV)
2770 assert(
false &&
"Unexpected abbrev ordering!");
2774 auto Abbv = std::make_shared<BitCodeAbbrev>();
2777 VE.computeBitsRequiredForTypeIndices()));
2779 CONSTANTS_SETTYPE_ABBREV)
2780 assert(
false &&
"Unexpected abbrev ordering!");
2784 auto Abbv = std::make_shared<BitCodeAbbrev>();
2788 CONSTANTS_INTEGER_ABBREV)
2789 assert(
false &&
"Unexpected abbrev ordering!");
2793 auto Abbv = std::make_shared<BitCodeAbbrev>();
2797 VE.computeBitsRequiredForTypeIndices()));
2801 CONSTANTS_CE_CAST_Abbrev)
2802 assert(
false &&
"Unexpected abbrev ordering!");
2805 auto Abbv = std::make_shared<BitCodeAbbrev>();
2808 CONSTANTS_NULL_Abbrev)
2809 assert(
false &&
"Unexpected abbrev ordering!");
2815 auto Abbv = std::make_shared<BitCodeAbbrev>();
2819 VE.computeBitsRequiredForTypeIndices()));
2823 (
unsigned)FUNCTION_INST_LOAD_ABBREV)
2824 assert(
false &&
"Unexpected abbrev ordering!");
2827 auto Abbv = std::make_shared<BitCodeAbbrev>();
2833 (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2834 assert(
false &&
"Unexpected abbrev ordering!");
2837 auto Abbv = std::make_shared<BitCodeAbbrev>();
2844 (
unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV)
2845 assert(
false &&
"Unexpected abbrev ordering!");
2848 auto Abbv = std::make_shared<BitCodeAbbrev>();
2852 VE.computeBitsRequiredForTypeIndices()));
2855 (
unsigned)FUNCTION_INST_CAST_ABBREV)
2856 assert(
false &&
"Unexpected abbrev ordering!");
2860 auto Abbv = std::make_shared<BitCodeAbbrev>();
2863 (
unsigned)FUNCTION_INST_RET_VOID_ABBREV)
2864 assert(
false &&
"Unexpected abbrev ordering!");
2867 auto Abbv = std::make_shared<BitCodeAbbrev>();
2871 (
unsigned)FUNCTION_INST_RET_VAL_ABBREV)
2872 assert(
false &&
"Unexpected abbrev ordering!");
2875 auto Abbv = std::make_shared<BitCodeAbbrev>();
2878 (
unsigned)FUNCTION_INST_UNREACHABLE_ABBREV)
2879 assert(
false &&
"Unexpected abbrev ordering!");
2882 auto Abbv = std::make_shared<BitCodeAbbrev>();
2890 (
unsigned)FUNCTION_INST_GEP_ABBREV)
2891 assert(
false &&
"Unexpected abbrev ordering!");
2897void DXILBitcodeWriter::writeModuleVersion() {
2912 DXILBitcodeWriter::writeModuleVersion();
2918 writeAttributeGroupTable();
2921 writeAttributeTable();
2933 writeModuleConstants();
2936 writeModuleMetadataKinds();
2939 writeModuleMetadata();
2944 writeFunctionLevelValueSymbolTable(M.getValueSymbolTable());
2948 if (!
F.isDeclaration())
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static uint64_t rotateSign(APInt Val)
This file contains constants used for implementing Dwarf debug support.
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
static MaybeAlign getAlign(Value *Ptr)
Module.h This file contains the declarations for the Module class.
static constexpr Value * getValue(Ty &ValueOrUse)
static bool isAtomic(MachineBasicBlock::iterator I)
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
uint64_t IntrinsicInst * II
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
static const uint32_t IV[8]
Class for arbitrary precision integers.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
int64_t getSExtValue() const
Get sign extended value.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ Min
*p = old <signed v ? old : v
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
This class holds the attributes for a particular argument, parameter, function, or return value.
bool hasAttributes() const
Return true if attributes exists in this set.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ None
No attributes have been set.
@ EndAttrKinds
Sentinel value useful for loops.
InstListType::const_iterator const_iterator
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
static bool isChar6(char C)
isChar6 - Return true if this character is legal in the Char6 encoding.
unsigned EmitAbbrev(std::shared_ptr< BitCodeAbbrev > Abbv)
Emits the abbreviation Abbv to the stream.
void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals, StringRef Blob)
EmitRecordWithBlob - Emit the specified record to the stream, using an abbrev that includes a blob at...
void EnterSubblock(unsigned BlockID, unsigned CodeLen)
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
CallingConv::ID getCallingConv() const
Value * getCalledOperand() const
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
bool isMustTailCall() const
@ Largest
The linker will choose the largest COMDAT.
@ SameSize
The data referenced by the COMDAT must be the same size.
@ Any
The linker may choose any COMDAT.
@ NoDeduplicate
No deduplication is performed.
@ ExactMatch
The data referenced by the COMDAT must be the same.
iterator find(const_arg_type_t< KeyT > Val)
BasicBlockListType::const_iterator const_iterator
VisibilityTypes getVisibility() const
LinkageTypes getLinkage() const
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
ThreadLocalMode getThreadLocalMode() const
@ DLLExportStorageClass
Function to be accessible from DLL.
@ DLLImportStorageClass
Function to be imported from DLL.
@ DefaultVisibility
The GV is visible.
@ HiddenVisibility
The GV is hidden.
@ ProtectedVisibility
The GV is protected.
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
DLLStorageClassTypes getDLLStorageClass() const
idx_iterator idx_end() const
idx_iterator idx_begin() const
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
const unsigned char * bytes_begin() const
const unsigned char * bytes_end() const
bool doesNotAccessMemory() const
Whether this function accesses no memory.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
A Module instance is used to store all the information related to an LLVM module.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
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.
constexpr bool empty() const
Check if the string is empty.
constexpr size_t size() const
Get the string size.
Utility for building string tables with deduplicated suffixes.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isX86_FP80Ty() const
Return true if this is x86 long double.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ TypedPointerTyID
Typed pointer used by some GPU targets.
@ HalfTyID
16-bit floating point type
@ TargetExtTyID
Target extension type.
@ VoidTyID
type with no size
@ ScalableVectorTyID
Scalable SIMD vector 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
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ ByteTyID
Arbitrary bit width bytes.
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
bool isFP128Ty() const
Return true if this is 'fp128'.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
A few GPU targets, such as DXIL and SPIR-V, have typed pointers.
Type * getElementType() const
static LLVM_ABI TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
BitcodeWriter(SmallVectorImpl< char > &Buffer)
Create a BitcodeWriter that writes to Buffer.
void writeModule(const Module &M, const DXILDebugInfoMap &DebugInfo)
Write the specified module to the buffer specified at construction time.
static void emitWideAPInt(SmallVectorImpl< uint64_t > &Vals, const APInt &A)
static unsigned getEncodedThreadLocalMode(const GlobalValue &GV)
static unsigned getEncodedCastOpcode(unsigned Opcode)
Begin dxil::BitcodeWriterBase Implementation.
static void writeStringRecord(BitstreamWriter &Stream, unsigned Code, StringRef Str, unsigned AbbrevToUse)
static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind)
static unsigned getEncodedDLLStorageClass(const GlobalValue &GV)
static unsigned getEncodedOrdering(AtomicOrdering Ordering)
static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage)
static unsigned getEncodedVisibility(const GlobalValue &GV)
void write()
Emit the current module to the bitstream.
static unsigned getEncodedBinaryOpcode(unsigned Opcode)
static void emitSignedInt64(SmallVectorImpl< uint64_t > &Vals, uint64_t V)
static unsigned getEncodedUnaryOpcode(unsigned Opcode)
DXILBitcodeWriter(const Module &M, SmallVectorImpl< char > &Buffer, StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream, const DXILDebugInfoMap &DebugInfo)
Constructs a ModuleBitcodeWriter object for the given Module, writing to the provided Buffer.
static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op)
static unsigned getEncodedComdatSelectionKind(const Comdat &C)
static uint64_t getOptimizationFlags(const Value *V)
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
std::vector< std::pair< const Value *, unsigned > > ValueList
std::vector< Type * > TypeList
This class implements an extremely fast bulk output stream that can only output to a stream.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
@ CE
Windows NT (Windows on ARM)
@ METADATA_TEMPLATE_VALUE
@ METADATA_LEXICAL_BLOCK_FILE
@ METADATA_SUBROUTINE_TYPE
@ METADATA_IMPORTED_ENTITY
@ METADATA_COMPOSITE_TYPE
@ CST_CODE_CE_INBOUNDS_GEP
@ COMDAT_SELECTION_KIND_LARGEST
@ COMDAT_SELECTION_KIND_ANY
@ COMDAT_SELECTION_KIND_SAME_SIZE
@ COMDAT_SELECTION_KIND_EXACT_MATCH
@ COMDAT_SELECTION_KIND_NO_DUPLICATES
@ ATTR_KIND_STACK_PROTECT
@ ATTR_KIND_STACK_PROTECT_STRONG
@ ATTR_KIND_SANITIZE_MEMORY
@ ATTR_KIND_OPTIMIZE_FOR_SIZE
@ ATTR_KIND_SANITIZE_ADDRESS
@ ATTR_KIND_NO_IMPLICIT_FLOAT
@ ATTR_KIND_STACK_ALIGNMENT
@ ATTR_KIND_STACK_PROTECT_REQ
@ ATTR_KIND_RETURNS_TWICE
@ ATTR_KIND_NON_LAZY_BIND
@ ATTR_KIND_DEREFERENCEABLE
@ ATTR_KIND_OPTIMIZE_NONE
@ ATTR_KIND_DEREFERENCEABLE_OR_NULL
@ ATTR_KIND_ALWAYS_INLINE
@ ATTR_KIND_SANITIZE_THREAD
@ PARAMATTR_GROUP_BLOCK_ID
@ MODULE_CODE_SECTIONNAME
@ FUNC_CODE_INST_ATOMICRMW_OLD
@ FUNC_CODE_INST_LANDINGPAD
@ FUNC_CODE_INST_EXTRACTVAL
@ FUNC_CODE_INST_LOADATOMIC
@ FUNC_CODE_INST_STOREATOMIC
@ FUNC_CODE_DEBUG_LOC_AGAIN
@ FUNC_CODE_INST_EXTRACTELT
@ FUNC_CODE_INST_INDIRECTBR
@ FUNC_CODE_INST_INSERTVAL
@ FUNC_CODE_DECLAREBLOCKS
@ FUNC_CODE_INST_INSERTELT
@ FUNC_CODE_INST_SHUFFLEVEC
@ FUNC_CODE_INST_UNREACHABLE
@ FIRST_APPLICATION_ABBREV
@ PARAMATTR_GRP_CODE_ENTRY
An analysis to compute the PointerTypes for pointers in a Module.
DenseMap< const Value *, Type * > PointerTypeMap
void WriteDXILToFile(Module &M, raw_ostream &Out)
Write the specified module to the specified raw output stream.
DXILDebugInfoMap collectDXILDebugInfo(Module &M)
NodeAddr< CodeNode * > Code
friend class Instruction
Iterator for Instructions in a `BasicBlock.
constexpr size_t MaxAlignment
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
StringMapEntry< Value * > ValueName
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.
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
bool isa_and_nonnull(const Y &Val)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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...
AtomicOrdering
Atomic ordering for LLVM's memory model.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
unsigned Log2(Align A)
Returns the log2 of the alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
Struct that holds a reference to a particular GUID in a global value summary.