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;
136 : I8Ty(
Type::getInt8Ty(M.getContext())),
138 StrtabBuilder(StrtabBuilder), M(M), VE(M, I8PtrTy), Buffer(Buffer),
139 BitcodeStartBit(Stream.GetCurrentBitNo()),
141 GlobalValueId = VE.getValues().
size();
143 for (
auto El : PointerMap)
144 VE.EnumerateType(El.second);
171 void writeModuleVersion();
172 void writePerModuleGlobalValueSummary();
177 unsigned FSCallsAbbrev,
178 unsigned FSCallsProfileAbbrev,
182 unsigned FSModRefsAbbrev,
183 unsigned FSModVTableRefsAbbrev);
186 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
190 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
193 assert(VMI != GUIDToValueIdMap.end() &&
194 "GUID does not have assigned value Id");
200 if (!VI.haveGVs() || !VI.getValue())
201 return getValueId(VI.getGUID());
202 return VE.getValueID(VI.getValue());
205 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
207 uint64_t bitcodeStartBit() {
return BitcodeStartBit; }
209 size_t addToStrtab(StringRef Str);
211 unsigned createDILocationAbbrev();
212 unsigned createGenericDINodeAbbrev();
214 void writeAttributeGroupTable();
215 void writeAttributeTable();
216 void writeTypeTable();
218 void writeValueSymbolTableForwardDecl();
219 void writeModuleInfo();
220 void writeValueAsMetadata(
const ValueAsMetadata *MD,
221 SmallVectorImpl<uint64_t> &Record);
222 void writeMDTuple(
const MDTuple *
N, SmallVectorImpl<uint64_t> &Record,
224 void writeDILocation(
const DILocation *
N, SmallVectorImpl<uint64_t> &Record,
226 void writeGenericDINode(
const GenericDINode *
N,
227 SmallVectorImpl<uint64_t> &Record,
unsigned &Abbrev) {
230 void writeDISubrange(
const DISubrange *
N, SmallVectorImpl<uint64_t> &Record,
232 void writeDIGenericSubrange(
const DIGenericSubrange *
N,
233 SmallVectorImpl<uint64_t> &Record,
237 void writeDIEnumerator(
const DIEnumerator *
N,
238 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
239 void writeDIBasicType(
const DIBasicType *
N, SmallVectorImpl<uint64_t> &Record,
241 void writeDIFixedPointType(
const DIFixedPointType *
N,
242 SmallVectorImpl<uint64_t> &Record,
246 void writeDIStringType(
const DIStringType *
N,
247 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
250 void writeDIDerivedType(
const DIDerivedType *
N,
251 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
252 void writeDISubrangeType(
const DISubrangeType *
N,
253 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
256 void writeDICompositeType(
const DICompositeType *
N,
257 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
258 void writeDISubroutineType(
const DISubroutineType *
N,
259 SmallVectorImpl<uint64_t> &Record,
261 void writeDIFile(
const DIFile *
N, SmallVectorImpl<uint64_t> &Record,
263 void writeDICompileUnit(
const DICompileUnit *
N,
264 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
265 void writeDISubprogram(
const DISubprogram *
N,
266 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
267 void writeDILexicalBlock(
const DILexicalBlock *
N,
268 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
269 void writeDILexicalBlockFile(
const DILexicalBlockFile *
N,
270 SmallVectorImpl<uint64_t> &Record,
272 void writeDICommonBlock(
const DICommonBlock *
N,
273 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
276 void writeDINamespace(
const DINamespace *
N, SmallVectorImpl<uint64_t> &Record,
278 void writeDIMacro(
const DIMacro *
N, SmallVectorImpl<uint64_t> &Record,
282 void writeDIMacroFile(
const DIMacroFile *
N, SmallVectorImpl<uint64_t> &Record,
286 void writeDIArgList(
const DIArgList *
N, SmallVectorImpl<uint64_t> &Record,
290 void writeDIAssignID(
const DIAssignID *
N, SmallVectorImpl<uint64_t> &Record,
297 void writeDIModule(
const DIModule *
N, SmallVectorImpl<uint64_t> &Record,
299 void writeDITemplateTypeParameter(
const DITemplateTypeParameter *
N,
300 SmallVectorImpl<uint64_t> &Record,
302 void writeDITemplateValueParameter(
const DITemplateValueParameter *
N,
303 SmallVectorImpl<uint64_t> &Record,
305 void writeDIGlobalVariable(
const DIGlobalVariable *
N,
306 SmallVectorImpl<uint64_t> &Record,
308 void writeDILocalVariable(
const DILocalVariable *
N,
309 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
310 void writeDILabel(
const DILabel *
N, SmallVectorImpl<uint64_t> &Record,
314 void writeDIExpression(
const DIExpression *
N,
315 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
316 void writeDIGlobalVariableExpression(
const DIGlobalVariableExpression *
N,
317 SmallVectorImpl<uint64_t> &Record,
321 void writeDIObjCProperty(
const DIObjCProperty *
N,
322 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
323 void writeDIImportedEntity(
const DIImportedEntity *
N,
324 SmallVectorImpl<uint64_t> &Record,
326 unsigned createNamedMetadataAbbrev();
327 void writeNamedMetadata(SmallVectorImpl<uint64_t> &Record);
328 unsigned createMetadataStringsAbbrev();
330 SmallVectorImpl<uint64_t> &Record);
332 SmallVectorImpl<uint64_t> &Record,
333 std::vector<unsigned> *MDAbbrevs =
nullptr,
334 std::vector<uint64_t> *IndexPos =
nullptr);
335 void writeModuleMetadata();
336 void writeFunctionMetadata(
const Function &
F);
337 void writeFunctionMetadataAttachment(
const Function &
F);
338 void pushGlobalMetadataAttachment(SmallVectorImpl<uint64_t> &Record,
339 const GlobalObject &GO);
340 void writeModuleMetadataKinds();
341 void writeOperandBundleTags();
342 void writeSyncScopeNames();
343 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
344 void writeModuleConstants();
345 bool pushValueAndType(
const Value *V,
unsigned InstID,
346 SmallVectorImpl<unsigned> &Vals);
347 void writeOperandBundles(
const CallBase &CB,
unsigned InstID);
348 void pushValue(
const Value *V,
unsigned InstID,
349 SmallVectorImpl<unsigned> &Vals);
350 void pushValueSigned(
const Value *V,
unsigned InstID,
351 SmallVectorImpl<uint64_t> &Vals);
352 void writeInstruction(
const Instruction &
I,
unsigned InstID,
353 SmallVectorImpl<unsigned> &Vals);
354 void writeFunctionLevelValueSymbolTable(
const ValueSymbolTable &VST);
355 void writeGlobalValueSymbolTable(
356 DenseMap<const Function *, uint64_t> &FunctionToBitcodeIndex);
357 void writeFunction(
const Function &
F);
358 void writeBlockInfo();
360 unsigned getEncodedSyncScopeID(
SyncScope::ID SSID) {
return unsigned(SSID); }
362 unsigned getEncodedAlign(MaybeAlign Alignment) {
return encode(Alignment); }
364 unsigned getTypeID(
Type *
T,
const Value *V =
nullptr);
369 unsigned getGlobalObjectValueTypeID(
Type *
T,
const GlobalObject *
G);
385 Stream->Emit((
unsigned)
'B', 8);
386 Stream->Emit((
unsigned)
'C', 8);
387 Stream->Emit(0x0, 4);
388 Stream->Emit(0xC, 4);
389 Stream->Emit(0xE, 4);
390 Stream->Emit(0xD, 4);
402 Triple TT(M.getTargetTriple());
403 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
417 auto Abbv = std::make_shared<BitCodeAbbrev>();
420 auto AbbrevNo = Stream->
EmitAbbrev(std::move(Abbv));
433 assert(M.isMaterialized());
434 Mods.push_back(
const_cast<Module *
>(&M));
437 ModuleWriter.
write();
448 case Instruction::Trunc:
450 case Instruction::ZExt:
452 case Instruction::SExt:
454 case Instruction::FPToUI:
456 case Instruction::FPToSI:
458 case Instruction::UIToFP:
460 case Instruction::SIToFP:
462 case Instruction::FPTrunc:
464 case Instruction::FPExt:
466 case Instruction::PtrToInt:
468 case Instruction::IntToPtr:
470 case Instruction::BitCast:
472 case Instruction::AddrSpaceCast:
481 case Instruction::FNeg:
490 case Instruction::Add:
491 case Instruction::FAdd:
493 case Instruction::Sub:
494 case Instruction::FSub:
496 case Instruction::Mul:
497 case Instruction::FMul:
499 case Instruction::UDiv:
501 case Instruction::FDiv:
502 case Instruction::SDiv:
504 case Instruction::URem:
506 case Instruction::FRem:
507 case Instruction::SRem:
509 case Instruction::Shl:
511 case Instruction::LShr:
513 case Instruction::AShr:
515 case Instruction::And:
517 case Instruction::Or:
519 case Instruction::Xor:
524unsigned DXILBitcodeWriter::getTypeID(
Type *
T,
const Value *V) {
525 if (!
T->isPointerTy() &&
529 return VE.getTypeID(
T);
530 auto It = PointerMap.
find(V);
531 if (It != PointerMap.
end())
532 return VE.getTypeID(It->second);
538 return VE.getTypeID(
T);
539 return VE.getTypeID(I8PtrTy);
542unsigned DXILBitcodeWriter::getGlobalObjectValueTypeID(
Type *
T,
544 auto It = PointerMap.
find(
G);
545 if (It != PointerMap.
end()) {
549 return VE.getTypeID(
T);
611 unsigned AbbrevToUse) {
622 Stream.EmitRecord(Code, Vals, AbbrevToUse);
627 case Attribute::Alignment:
629 case Attribute::AlwaysInline:
631 case Attribute::Builtin:
633 case Attribute::ByVal:
635 case Attribute::Convergent:
637 case Attribute::InAlloca:
639 case Attribute::Cold:
641 case Attribute::InlineHint:
643 case Attribute::InReg:
645 case Attribute::JumpTable:
647 case Attribute::MinSize:
649 case Attribute::Naked:
651 case Attribute::Nest:
653 case Attribute::NoAlias:
655 case Attribute::NoBuiltin:
657 case Attribute::NoDuplicate:
659 case Attribute::NoImplicitFloat:
661 case Attribute::NoInline:
663 case Attribute::NonLazyBind:
665 case Attribute::NonNull:
667 case Attribute::Dereferenceable:
669 case Attribute::DereferenceableOrNull:
671 case Attribute::NoRedZone:
673 case Attribute::NoReturn:
675 case Attribute::NoUnwind:
677 case Attribute::OptimizeForSize:
679 case Attribute::OptimizeNone:
681 case Attribute::ReadNone:
683 case Attribute::ReadOnly:
685 case Attribute::Returned:
687 case Attribute::ReturnsTwice:
689 case Attribute::SExt:
691 case Attribute::StackAlignment:
693 case Attribute::StackProtect:
695 case Attribute::StackProtectReq:
697 case Attribute::StackProtectStrong:
699 case Attribute::SafeStack:
701 case Attribute::StructRet:
703 case Attribute::SanitizeAddress:
705 case Attribute::SanitizeThread:
707 case Attribute::SanitizeMemory:
709 case Attribute::UWTable:
711 case Attribute::ZExt:
722 "should be stripped in DXILPrepare");
742 unsigned NumWords =
A.getActiveWords();
743 const uint64_t *RawData =
A.getRawData();
744 for (
unsigned i = 0; i < NumWords; i++)
752 if (OBO->hasNoSignedWrap())
754 if (OBO->hasNoUnsignedWrap())
760 if (FPMO->hasAllowReassoc() || FPMO->hasAllowContract())
762 if (FPMO->hasNoNaNs())
764 if (FPMO->hasNoInfs())
766 if (FPMO->hasNoSignedZeros())
768 if (FPMO->hasAllowReciprocal())
849 switch (
C.getSelectionKind()) {
868void DXILBitcodeWriter::writeAttributeGroupTable() {
869 const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
870 VE.getAttributeGroups();
871 if (AttrGrps.empty())
878 unsigned AttrListIndex = Pair.first;
880 Record.push_back(
VE.getAttributeGroupID(Pair));
881 Record.push_back(AttrListIndex);
884 if (Attr.isEnumAttribute()) {
887 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
890 }
else if (Attr.isIntAttribute()) {
891 if (Attr.getKindAsEnum() == Attribute::AttrKind::Memory) {
909 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
912 Record.push_back(Attr.getValueAsInt());
915 StringRef
Kind = Attr.getKindAsString();
916 StringRef Val = Attr.getValueAsString();
935void DXILBitcodeWriter::writeAttributeTable() {
936 const std::vector<AttributeList> &
Attrs = VE.getAttributeLists();
942 SmallVector<uint64_t, 64>
Record;
943 for (AttributeList AL : Attrs) {
944 for (
unsigned i :
AL.indexes()) {
945 AttributeSet AS =
AL.getAttributes(i);
947 Record.push_back(VE.getAttributeGroupID({i, AS}));
958void DXILBitcodeWriter::writeTypeTable() {
962 SmallVector<uint64_t, 64> TypeVals;
964 uint64_t NumBits = VE.computeBitsRequiredForTypeIndices();
967 auto Abbv = std::make_shared<BitCodeAbbrev>();
970 Abbv->Add(BitCodeAbbrevOp(0));
971 unsigned PtrAbbrev = Stream.EmitAbbrev(std::move(Abbv));
974 Abbv = std::make_shared<BitCodeAbbrev>();
979 unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
982 Abbv = std::make_shared<BitCodeAbbrev>();
987 unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
990 Abbv = std::make_shared<BitCodeAbbrev>();
994 unsigned StructNameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
997 Abbv = std::make_shared<BitCodeAbbrev>();
1002 unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1005 Abbv = std::make_shared<BitCodeAbbrev>();
1009 unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1017 for (
Type *
T : TypeList) {
1018 int AbbrevToUse = 0;
1021 switch (
T->getTypeID()) {
1074 AbbrevToUse = PtrAbbrev;
1085 "dxilOpaquePtrReservedName", StructNameAbbrev);
1093 TypeVals.
push_back(getTypeID(FT->getReturnType()));
1094 for (
Type *PTy : FT->params())
1096 AbbrevToUse = FunctionAbbrev;
1104 for (
Type *ElTy :
ST->elements())
1107 if (
ST->isLiteral()) {
1109 AbbrevToUse = StructAnonAbbrev;
1111 if (
ST->isOpaque()) {
1115 AbbrevToUse = StructNamedAbbrev;
1119 if (!
ST->getName().empty())
1129 TypeVals.
push_back(AT->getNumElements());
1130 TypeVals.
push_back(getTypeID(AT->getElementType()));
1131 AbbrevToUse = ArrayAbbrev;
1139 TypeVals.
push_back(VT->getElementCount().getKnownMinValue());
1140 TypeVals.
push_back(getTypeID(VT->getElementType()));
1146 Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
1153void DXILBitcodeWriter::writeComdats() {
1155 for (
const Comdat *
C : VE.getComdats()) {
1158 size_t Size =
C->getName().size();
1161 for (
char Chr :
C->getName())
1168void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
1173void DXILBitcodeWriter::writeModuleInfo() {
1178 StringRef Triple =
"dxil-ms-dx";
1179 StringRef
DL =
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-"
1180 "f16:16-f32:32-f64:64-n8:16:32:64";
1184 if (!M.getModuleInlineAsm().empty())
1190 std::map<std::string, unsigned> SectionMap;
1191 std::map<std::string, unsigned> GCMap;
1193 unsigned MaxGlobalType = 0;
1194 const auto UpdateMaxAlignment = [&
MaxAlignment](
const MaybeAlign
A) {
1198 for (
const GlobalVariable &GV : M.globals()) {
1199 UpdateMaxAlignment(GV.getAlign());
1202 MaxGlobalType = std::max(
1203 MaxGlobalType, getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1204 if (GV.hasSection()) {
1206 unsigned &
Entry = SectionMap[std::string(GV.getSection())];
1209 GV.getSection(), 0 );
1210 Entry = SectionMap.size();
1214 for (
const Function &
F : M) {
1215 UpdateMaxAlignment(
F.getAlign());
1216 if (
F.hasSection()) {
1218 unsigned &
Entry = SectionMap[std::string(
F.getSection())];
1222 Entry = SectionMap.size();
1227 unsigned &
Entry = GCMap[
F.getGC()];
1231 Entry = GCMap.size();
1237 unsigned SimpleGVarAbbrev = 0;
1238 if (!M.global_empty()) {
1241 auto Abbv = std::make_shared<BitCodeAbbrev>();
1251 Abbv->Add(BitCodeAbbrevOp(0));
1253 unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1257 if (SectionMap.empty())
1258 Abbv->Add(BitCodeAbbrevOp(0));
1263 SimpleGVarAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1268 for (
const GlobalVariable &GV : M.globals()) {
1269 unsigned AbbrevToUse = 0;
1275 Vals.
push_back(getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1277 GV.getType()->getAddressSpace() << 2 | 2 |
1278 (GV.isConstant() ? 1 : 0));
1281 GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1));
1283 Vals.
push_back(getEncodedAlign(GV.getAlign()));
1284 Vals.
push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1286 if (GV.isThreadLocal() ||
1289 GV.isExternallyInitialized() ||
1295 Vals.
push_back(GV.isExternallyInitialized());
1297 Vals.
push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1299 AbbrevToUse = SimpleGVarAbbrev;
1307 for (
const Function &
F : M) {
1311 Vals.
push_back(getGlobalObjectValueTypeID(
F.getFunctionType(), &
F));
1315 Vals.
push_back(VE.getAttributeListID(
F.getAttributes()));
1316 Vals.
push_back(getEncodedAlign(
F.getAlign()));
1317 Vals.
push_back(
F.hasSection() ? SectionMap[std::string(
F.getSection())]
1323 F.hasPrologueData() ? (VE.getValueID(
F.getPrologueData()) + 1) : 0);
1325 Vals.
push_back(
F.hasComdat() ? VE.getComdatID(
F.getComdat()) : 0);
1326 Vals.
push_back(
F.hasPrefixData() ? (VE.getValueID(
F.getPrefixData()) + 1)
1329 F.hasPersonalityFn() ? (VE.getValueID(
F.getPersonalityFn()) + 1) : 0);
1331 unsigned AbbrevToUse = 0;
1337 for (
const GlobalAlias &
A : M.aliases()) {
1340 Vals.
push_back(VE.getValueID(
A.getAliasee()));
1346 unsigned AbbrevToUse = 0;
1352void DXILBitcodeWriter::writeValueAsMetadata(
1353 const ValueAsMetadata *MD, SmallVectorImpl<uint64_t> &Record) {
1356 Type *Ty =
V->getType();
1361 Record.push_back(getTypeID(Ty, V));
1362 Record.push_back(VE.getValueID(V));
1367void DXILBitcodeWriter::writeMDTuple(
const MDTuple *
N,
1368 SmallVectorImpl<uint64_t> &Record,
1370 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
1373 "Unexpected function-local metadata");
1374 Record.push_back(VE.getMetadataOrNullID(MD));
1382void DXILBitcodeWriter::writeDILocation(
const DILocation *
N,
1383 SmallVectorImpl<uint64_t> &Record,
1386 Abbrev = createDILocationAbbrev();
1387 Record.push_back(
N->isDistinct());
1388 Record.push_back(
N->getLine());
1389 Record.push_back(
N->getColumn());
1390 Record.push_back(VE.getMetadataID(
N->getScope()));
1391 Record.push_back(VE.getMetadataOrNullID(
N->getInlinedAt()));
1400 return I < 0 ? ~(U << 1) : U << 1;
1403void DXILBitcodeWriter::writeDISubrange(
const DISubrange *
N,
1404 SmallVectorImpl<uint64_t> &Record,
1406 Record.push_back(
N->isDistinct());
1412 Record.push_back(
Count->getValue().getSExtValue());
1418 DISubrange::BoundType LowerBound =
N->getLowerBound();
1429void DXILBitcodeWriter::writeDIEnumerator(
const DIEnumerator *
N,
1430 SmallVectorImpl<uint64_t> &Record,
1432 Record.push_back(
N->isDistinct());
1434 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1440void DXILBitcodeWriter::writeDIBasicType(
const DIBasicType *
N,
1441 SmallVectorImpl<uint64_t> &Record,
1443 Record.push_back(
N->isDistinct());
1444 Record.push_back(
N->getTag());
1445 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1446 Record.push_back(
N->getSizeInBits());
1447 Record.push_back(
N->getAlignInBits());
1448 Record.push_back(
N->getEncoding());
1454void DXILBitcodeWriter::writeDIDerivedType(
const DIDerivedType *
N,
1455 SmallVectorImpl<uint64_t> &Record,
1457 Record.push_back(
N->isDistinct());
1458 Record.push_back(
N->getTag());
1459 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1460 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1461 Record.push_back(
N->getLine());
1462 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1463 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1464 Record.push_back(
N->getSizeInBits());
1465 Record.push_back(
N->getAlignInBits());
1466 Record.push_back(
N->getOffsetInBits());
1467 Record.push_back(
N->getFlags());
1468 Record.push_back(VE.getMetadataOrNullID(
N->getExtraData()));
1474void DXILBitcodeWriter::writeDICompositeType(
const DICompositeType *
N,
1475 SmallVectorImpl<uint64_t> &Record,
1477 Record.push_back(
N->isDistinct());
1478 Record.push_back(
N->getTag());
1479 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1480 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1481 Record.push_back(
N->getLine());
1482 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1483 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1484 Record.push_back(
N->getSizeInBits());
1485 Record.push_back(
N->getAlignInBits());
1486 Record.push_back(
N->getOffsetInBits());
1487 Record.push_back(
N->getFlags());
1488 Record.push_back(VE.getMetadataOrNullID(
N->getElements().get()));
1489 Record.push_back(
N->getRuntimeLang());
1490 Record.push_back(VE.getMetadataOrNullID(
N->getVTableHolder()));
1491 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1492 Record.push_back(VE.getMetadataOrNullID(
N->getRawIdentifier()));
1498void DXILBitcodeWriter::writeDISubroutineType(
const DISubroutineType *
N,
1499 SmallVectorImpl<uint64_t> &Record,
1501 Record.push_back(
N->isDistinct());
1502 Record.push_back(
N->getFlags());
1503 Record.push_back(VE.getMetadataOrNullID(
N->getTypeArray().get()));
1509void DXILBitcodeWriter::writeDIFile(
const DIFile *
N,
1510 SmallVectorImpl<uint64_t> &Record,
1512 Record.push_back(
N->isDistinct());
1513 Record.push_back(VE.getMetadataOrNullID(
N->getRawFilename()));
1514 Record.push_back(VE.getMetadataOrNullID(
N->getRawDirectory()));
1520void DXILBitcodeWriter::writeDICompileUnit(
const DICompileUnit *
N,
1521 SmallVectorImpl<uint64_t> &Record,
1523 Record.push_back(
N->isDistinct());
1524 DISourceLanguageName Lang =
N->getSourceLanguage();
1531 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1532 Record.push_back(VE.getMetadataOrNullID(
N->getRawProducer()));
1533 Record.push_back(
N->isOptimized());
1534 Record.push_back(VE.getMetadataOrNullID(
N->getRawFlags()));
1535 Record.push_back(
N->getRuntimeVersion());
1536 Record.push_back(VE.getMetadataOrNullID(
N->getRawSplitDebugFilename()));
1537 Record.push_back(
N->getEmissionKind());
1538 Record.push_back(VE.getMetadataOrNullID(
N->getEnumTypes().get()));
1539 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedTypes().get()));
1541 Record.push_back(VE.getMetadataOrNullID(
N->getGlobalVariables().get()));
1542 Record.push_back(VE.getMetadataOrNullID(
N->getImportedEntities().get()));
1543 Record.push_back(
N->getDWOId());
1549void DXILBitcodeWriter::writeDISubprogram(
const DISubprogram *
N,
1550 SmallVectorImpl<uint64_t> &Record,
1552 Record.push_back(
N->isDistinct());
1553 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1554 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1555 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1556 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1557 Record.push_back(
N->getLine());
1558 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1559 Record.push_back(
N->isLocalToUnit());
1560 Record.push_back(
N->isDefinition());
1561 Record.push_back(
N->getScopeLine());
1562 Record.push_back(VE.getMetadataOrNullID(
N->getContainingType()));
1563 Record.push_back(
N->getVirtuality());
1564 Record.push_back(
N->getVirtualIndex());
1565 Record.push_back(
N->getFlags());
1566 Record.push_back(
N->isOptimized());
1567 Record.push_back(VE.getMetadataOrNullID(
N->getRawUnit()));
1568 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1569 Record.push_back(VE.getMetadataOrNullID(
N->getDeclaration()));
1570 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedNodes().get()));
1576void DXILBitcodeWriter::writeDILexicalBlock(
const DILexicalBlock *
N,
1577 SmallVectorImpl<uint64_t> &Record,
1579 Record.push_back(
N->isDistinct());
1580 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1581 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1582 Record.push_back(
N->getLine());
1583 Record.push_back(
N->getColumn());
1589void DXILBitcodeWriter::writeDILexicalBlockFile(
1590 const DILexicalBlockFile *
N, SmallVectorImpl<uint64_t> &Record,
1592 Record.push_back(
N->isDistinct());
1593 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1594 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1595 Record.push_back(
N->getDiscriminator());
1601void DXILBitcodeWriter::writeDINamespace(
const DINamespace *
N,
1602 SmallVectorImpl<uint64_t> &Record,
1604 Record.push_back(
N->isDistinct());
1605 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1606 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1607 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1614void DXILBitcodeWriter::writeDIModule(
const DIModule *
N,
1615 SmallVectorImpl<uint64_t> &Record,
1617 Record.push_back(
N->isDistinct());
1618 for (
auto &
I :
N->operands())
1619 Record.push_back(VE.getMetadataOrNullID(
I));
1625void DXILBitcodeWriter::writeDITemplateTypeParameter(
1626 const DITemplateTypeParameter *
N, SmallVectorImpl<uint64_t> &Record,
1628 Record.push_back(
N->isDistinct());
1629 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1630 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1636void DXILBitcodeWriter::writeDITemplateValueParameter(
1637 const DITemplateValueParameter *
N, SmallVectorImpl<uint64_t> &Record,
1639 Record.push_back(
N->isDistinct());
1640 Record.push_back(
N->getTag());
1641 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1642 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1643 Record.push_back(VE.getMetadataOrNullID(
N->getValue()));
1649void DXILBitcodeWriter::writeDIGlobalVariable(
const DIGlobalVariable *
N,
1650 SmallVectorImpl<uint64_t> &Record,
1652 Record.push_back(
N->isDistinct());
1653 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1654 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1655 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1656 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1657 Record.push_back(
N->getLine());
1658 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1659 Record.push_back(
N->isLocalToUnit());
1660 Record.push_back(
N->isDefinition());
1662 Record.push_back(VE.getMetadataOrNullID(
N->getStaticDataMemberDeclaration()));
1668void DXILBitcodeWriter::writeDILocalVariable(
const DILocalVariable *
N,
1669 SmallVectorImpl<uint64_t> &Record,
1671 constexpr unsigned DW_TAG_auto_variable = 0x0100;
1672 constexpr unsigned DW_TAG_arg_variable = 0x0101;
1673 Record.push_back(
N->isDistinct());
1674 assert(
N->getTag() == dwarf::DW_TAG_variable);
1675 Record.push_back(
N->getArg() ? DW_TAG_arg_variable : DW_TAG_auto_variable);
1676 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1677 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1678 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1679 Record.push_back(
N->getLine());
1680 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1681 Record.push_back(
N->getArg());
1682 Record.push_back(
N->getFlags());
1688void DXILBitcodeWriter::writeDIExpression(
const DIExpression *
N,
1689 SmallVectorImpl<uint64_t> &Record,
1691 Record.reserve(
N->getElements().size() + 1);
1693 Record.push_back(
N->isDistinct());
1694 Record.append(
N->elements_begin(),
N->elements_end());
1700void DXILBitcodeWriter::writeDIObjCProperty(
const DIObjCProperty *
N,
1701 SmallVectorImpl<uint64_t> &Record,
1706void DXILBitcodeWriter::writeDIImportedEntity(
const DIImportedEntity *
N,
1707 SmallVectorImpl<uint64_t> &Record,
1709 Record.push_back(
N->isDistinct());
1710 Record.push_back(
N->getTag());
1711 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1712 Record.push_back(VE.getMetadataOrNullID(
N->getEntity()));
1713 Record.push_back(
N->getLine());
1714 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1720unsigned DXILBitcodeWriter::createDILocationAbbrev() {
1725 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1732 return Stream.EmitAbbrev(std::move(Abbv));
1735unsigned DXILBitcodeWriter::createGenericDINodeAbbrev() {
1740 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1748 return Stream.EmitAbbrev(std::move(Abbv));
1752 SmallVectorImpl<uint64_t> &Record,
1753 std::vector<unsigned> *MDAbbrevs,
1754 std::vector<uint64_t> *IndexPos) {
1759#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1760#include "llvm/IR/Metadata.def"
1764 IndexPos->push_back(Stream.GetCurrentBitNo());
1766 assert(
N->isResolved() &&
"Expected forward references to be resolved");
1768 switch (
N->getMetadataID()) {
1771#define HANDLE_MDNODE_LEAF(CLASS) \
1772 case Metadata::CLASS##Kind: \
1774 write##CLASS(cast<CLASS>(N), Record, \
1775 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1777 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1779#include "llvm/IR/Metadata.def"
1786unsigned DXILBitcodeWriter::createMetadataStringsAbbrev() {
1787 auto Abbv = std::make_shared<BitCodeAbbrev>();
1791 return Stream.EmitAbbrev(std::move(Abbv));
1794void DXILBitcodeWriter::writeMetadataStrings(
1796 if (Strings.
empty())
1799 unsigned MDSAbbrev = createMetadataStringsAbbrev();
1801 for (
const Metadata *MD : Strings) {
1812void DXILBitcodeWriter::writeModuleMetadata() {
1813 if (!VE.hasMDs() && M.named_metadata_empty())
1820 std::vector<unsigned> MDAbbrevs;
1823 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1824 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1825 createGenericDINodeAbbrev();
1827 unsigned NameAbbrev = 0;
1828 if (!M.named_metadata_empty()) {
1830 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1834 NameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1837 SmallVector<uint64_t, 64>
Record;
1838 writeMetadataStrings(VE.getMDStrings(), Record);
1840 std::vector<uint64_t> IndexPos;
1841 IndexPos.reserve(VE.getNonMDStrings().size());
1842 writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1845 for (
const NamedMDNode &NMD : M.named_metadata()) {
1847 StringRef Str = NMD.getName();
1848 Record.append(Str.bytes_begin(), Str.bytes_end());
1853 for (
const MDNode *
N : NMD.operands())
1854 Record.push_back(VE.getMetadataID(
N));
1862void DXILBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
1867 SmallVector<uint64_t, 64>
Record;
1868 writeMetadataStrings(VE.getMDStrings(), Record);
1869 writeMetadataRecords(VE.getNonMDStrings(), Record);
1873void DXILBitcodeWriter::writeFunctionMetadataAttachment(
const Function &
F) {
1876 SmallVector<uint64_t, 64>
Record;
1881 F.getAllMetadata(MDs);
1883 for (
const auto &
I : MDs) {
1885 Record.push_back(VE.getMetadataID(
I.second));
1891 for (
const BasicBlock &BB :
F)
1892 for (
const Instruction &
I : BB) {
1894 I.getAllMetadataOtherThanDebugLoc(MDs);
1900 Record.push_back(VE.getInstructionID(&
I));
1902 for (
unsigned i = 0, e = MDs.size(); i != e; ++i) {
1903 Record.push_back(MDs[i].first);
1904 Record.push_back(VE.getMetadataID(MDs[i].second));
1913void DXILBitcodeWriter::writeModuleMetadataKinds() {
1914 SmallVector<uint64_t, 64>
Record;
1919 M.getMDKindNames(Names);
1926 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
1927 Record.push_back(MDKindID);
1928 StringRef KName = Names[MDKindID];
1938void DXILBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
1940 if (FirstVal == LastVal)
1945 unsigned AggregateAbbrev = 0;
1946 unsigned String8Abbrev = 0;
1947 unsigned CString7Abbrev = 0;
1948 unsigned CString6Abbrev = 0;
1952 auto Abbv = std::make_shared<BitCodeAbbrev>();
1957 AggregateAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1960 Abbv = std::make_shared<BitCodeAbbrev>();
1964 String8Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1966 Abbv = std::make_shared<BitCodeAbbrev>();
1970 CString7Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1972 Abbv = std::make_shared<BitCodeAbbrev>();
1976 CString6Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1979 SmallVector<uint64_t, 64>
Record;
1982 Type *LastTy =
nullptr;
1983 for (
unsigned i = FirstVal; i != LastVal; ++i) {
1984 const Value *
V = Vals[i].first;
1986 if (
V->getType() != LastTy) {
1987 LastTy =
V->getType();
1988 Record.push_back(getTypeID(LastTy, V));
1990 CONSTANTS_SETTYPE_ABBREV);
1995 Record.push_back(
unsigned(
IA->hasSideEffects()) |
1996 unsigned(
IA->isAlignStack()) << 1 |
1997 unsigned(
IA->getDialect() & 1) << 2);
2000 StringRef AsmStr =
IA->getAsmString();
2005 StringRef ConstraintStr =
IA->getConstraintString();
2013 unsigned Code = -1U;
2014 unsigned AbbrevToUse = 0;
2015 if (
C->isNullValue()) {
2020 if (
IV->getBitWidth() <= 64) {
2021 uint64_t
V =
IV->getSExtValue();
2024 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2030 unsigned NWords =
IV->getValue().getActiveWords();
2031 const uint64_t *RawWords =
IV->getValue().getRawData();
2032 for (
unsigned i = 0; i != NWords; ++i) {
2040 if (BV->getBitWidth() <= 64) {
2041 uint64_t
V = BV->getSExtValue();
2044 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2046 unsigned NWords = BV->getValue().getActiveWords();
2047 const uint64_t *RawWords = BV->getValue().getRawData();
2048 for (
unsigned i = 0; i != NWords; ++i) {
2057 Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2061 APInt api = CFP->getValueAPF().bitcastToAPInt();
2063 Record.push_back((p[1] << 48) | (p[0] >> 16));
2064 Record.push_back(p[0] & 0xffffLL);
2066 APInt api = CFP->getValueAPF().bitcastToAPInt();
2071 assert(0 &&
"Unknown FP type!");
2077 unsigned NumElts = Str->getNumElements();
2079 if (Str->isCString()) {
2084 AbbrevToUse = String8Abbrev;
2088 for (
unsigned i = 0; i != NumElts; ++i) {
2089 unsigned char V = Str->getElementAsInteger(i);
2091 isCStr7 &= (
V & 128) == 0;
2097 AbbrevToUse = CString6Abbrev;
2099 AbbrevToUse = CString7Abbrev;
2100 }
else if (
const ConstantDataSequential *CDS =
2103 Type *EltTy = CDS->getElementType();
2105 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2106 Record.push_back(CDS->getElementAsInteger(i));
2108 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2113 F = CDS->getElementAsFloat(i);
2118 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2123 F = CDS->getElementAsDouble(i);
2130 for (
const Value *
Op :
C->operands())
2131 Record.push_back(VE.getValueID(
Op));
2132 AbbrevToUse = AggregateAbbrev;
2134 switch (
CE->getOpcode()) {
2140 getTypeID(
C->getOperand(0)->getType(),
C->getOperand(0)));
2141 Record.push_back(VE.getValueID(
C->getOperand(0)));
2142 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2144 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2147 Record.push_back(VE.getValueID(
C->getOperand(0)));
2148 Record.push_back(VE.getValueID(
C->getOperand(1)));
2154 case Instruction::GetElementPtr: {
2157 if (GO->isInBounds())
2159 Record.push_back(getTypeID(GO->getSourceElementType()));
2160 for (
unsigned i = 0, e =
CE->getNumOperands(); i != e; ++i) {
2162 getTypeID(
C->getOperand(i)->getType(),
C->getOperand(i)));
2163 Record.push_back(VE.getValueID(
C->getOperand(i)));
2167 case Instruction::Select:
2169 Record.push_back(VE.getValueID(
C->getOperand(0)));
2170 Record.push_back(VE.getValueID(
C->getOperand(1)));
2171 Record.push_back(VE.getValueID(
C->getOperand(2)));
2173 case Instruction::ExtractElement:
2175 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2176 Record.push_back(VE.getValueID(
C->getOperand(0)));
2177 Record.push_back(getTypeID(
C->getOperand(1)->getType()));
2178 Record.push_back(VE.getValueID(
C->getOperand(1)));
2180 case Instruction::InsertElement:
2182 Record.push_back(VE.getValueID(
C->getOperand(0)));
2183 Record.push_back(VE.getValueID(
C->getOperand(1)));
2184 Record.push_back(getTypeID(
C->getOperand(2)->getType()));
2185 Record.push_back(VE.getValueID(
C->getOperand(2)));
2187 case Instruction::ShuffleVector:
2192 if (
C->getType() ==
C->getOperand(0)->getType()) {
2196 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2198 Record.push_back(VE.getValueID(
C->getOperand(0)));
2199 Record.push_back(VE.getValueID(
C->getOperand(1)));
2200 Record.push_back(VE.getValueID(
C->getOperand(2)));
2205 Record.push_back(getTypeID(BA->getFunction()->getType()));
2206 Record.push_back(VE.getValueID(BA->getFunction()));
2207 Record.push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2214 Stream.EmitRecord(Code, Record, AbbrevToUse);
2221void DXILBitcodeWriter::writeModuleConstants() {
2226 for (
unsigned i = 0, e = Vals.size(); i != e; ++i) {
2228 writeConstants(i, Vals.size(),
true);
2242bool DXILBitcodeWriter::pushValueAndType(
const Value *V,
unsigned InstID,
2243 SmallVectorImpl<unsigned> &Vals) {
2244 unsigned ValID = VE.getValueID(V);
2247 if (ValID >= InstID) {
2256void DXILBitcodeWriter::pushValue(
const Value *V,
unsigned InstID,
2257 SmallVectorImpl<unsigned> &Vals) {
2258 unsigned ValID = VE.getValueID(V);
2262void DXILBitcodeWriter::pushValueSigned(
const Value *V,
unsigned InstID,
2263 SmallVectorImpl<uint64_t> &Vals) {
2264 unsigned ValID = VE.getValueID(V);
2265 int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2270void DXILBitcodeWriter::writeInstruction(
const Instruction &
I,
unsigned InstID,
2271 SmallVectorImpl<unsigned> &Vals) {
2273 unsigned AbbrevToUse = 0;
2274 VE.setInstructionID(&
I);
2275 switch (
I.getOpcode()) {
2279 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2280 AbbrevToUse = (unsigned)FUNCTION_INST_CAST_ABBREV;
2286 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2287 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_ABBREV;
2288 pushValue(
I.getOperand(1), InstID, Vals);
2292 if (AbbrevToUse == (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2293 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV;
2299 case Instruction::GetElementPtr: {
2301 AbbrevToUse = (unsigned)FUNCTION_INST_GEP_ABBREV;
2304 Vals.
push_back(getTypeID(GEPInst.getSourceElementType()));
2305 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i)
2306 pushValueAndType(
I.getOperand(i), InstID, Vals);
2309 case Instruction::ExtractValue: {
2311 pushValueAndType(
I.getOperand(0), InstID, Vals);
2316 case Instruction::InsertValue: {
2318 pushValueAndType(
I.getOperand(0), InstID, Vals);
2319 pushValueAndType(
I.getOperand(1), InstID, Vals);
2324 case Instruction::Select:
2326 pushValueAndType(
I.getOperand(1), InstID, Vals);
2327 pushValue(
I.getOperand(2), InstID, Vals);
2328 pushValueAndType(
I.getOperand(0), InstID, Vals);
2330 case Instruction::ExtractElement:
2332 pushValueAndType(
I.getOperand(0), InstID, Vals);
2333 pushValueAndType(
I.getOperand(1), InstID, Vals);
2335 case Instruction::InsertElement:
2337 pushValueAndType(
I.getOperand(0), InstID, Vals);
2338 pushValue(
I.getOperand(1), InstID, Vals);
2339 pushValueAndType(
I.getOperand(2), InstID, Vals);
2341 case Instruction::ShuffleVector:
2343 pushValueAndType(
I.getOperand(0), InstID, Vals);
2344 pushValue(
I.getOperand(1), InstID, Vals);
2348 case Instruction::ICmp:
2349 case Instruction::FCmp: {
2352 pushValueAndType(
I.getOperand(0), InstID, Vals);
2353 pushValue(
I.getOperand(1), InstID, Vals);
2361 case Instruction::Ret: {
2363 unsigned NumOperands =
I.getNumOperands();
2364 if (NumOperands == 0)
2365 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VOID_ABBREV;
2366 else if (NumOperands == 1) {
2367 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2368 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VAL_ABBREV;
2370 for (
unsigned i = 0, e = NumOperands; i !=
e; ++i)
2371 pushValueAndType(
I.getOperand(i), InstID, Vals);
2374 case Instruction::UncondBr:
2378 case Instruction::CondBr: {
2381 Vals.
push_back(VE.getValueID(
II.getSuccessor(0)));
2382 Vals.
push_back(VE.getValueID(
II.getSuccessor(1)));
2383 pushValue(
II.getCondition(), InstID, Vals);
2385 case Instruction::Switch: {
2388 Vals.
push_back(getTypeID(
SI.getCondition()->getType()));
2389 pushValue(
SI.getCondition(), InstID, Vals);
2390 Vals.
push_back(VE.getValueID(
SI.getDefaultDest()));
2391 for (
auto Case :
SI.cases()) {
2392 Vals.
push_back(VE.getValueID(Case.getCaseValue()));
2393 Vals.
push_back(VE.getValueID(Case.getCaseSuccessor()));
2396 case Instruction::IndirectBr:
2398 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2400 pushValue(
I.getOperand(0), InstID, Vals);
2401 for (
unsigned i = 1, e =
I.getNumOperands(); i != e; ++i)
2402 Vals.
push_back(VE.getValueID(
I.getOperand(i)));
2405 case Instruction::Invoke: {
2408 FunctionType *FTy =
II->getFunctionType();
2411 Vals.
push_back(VE.getAttributeListID(
II->getAttributes()));
2413 Vals.
push_back(VE.getValueID(
II->getNormalDest()));
2414 Vals.
push_back(VE.getValueID(
II->getUnwindDest()));
2416 pushValueAndType(Callee, InstID, Vals);
2419 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2420 pushValue(
I.getOperand(i), InstID, Vals);
2423 if (FTy->isVarArg()) {
2424 for (
unsigned i = FTy->getNumParams(), e =
I.getNumOperands() - 3; i != e;
2426 pushValueAndType(
I.getOperand(i), InstID, Vals);
2430 case Instruction::Resume:
2432 pushValueAndType(
I.getOperand(0), InstID, Vals);
2434 case Instruction::Unreachable:
2436 AbbrevToUse = (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV;
2439 case Instruction::PHI: {
2452 Stream.EmitRecord(Code, Vals64, AbbrevToUse);
2457 case Instruction::LandingPad: {
2468 pushValueAndType(LP.
getClause(
I), InstID, Vals);
2473 case Instruction::Alloca: {
2477 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2478 Vals.
push_back(VE.getValueID(
I.getOperand(0)));
2480 assert(AlignRecord < 1 << 5 &&
"alignment greater than 1 << 64");
2482 AlignRecord |= 1 << 6;
2487 case Instruction::Load:
2490 pushValueAndType(
I.getOperand(0), InstID, Vals);
2493 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2494 AbbrevToUse = (unsigned)FUNCTION_INST_LOAD_ABBREV;
2504 case Instruction::Store:
2509 pushValueAndType(
I.getOperand(1), InstID, Vals);
2510 pushValueAndType(
I.getOperand(0), InstID, Vals);
2519 case Instruction::AtomicCmpXchg:
2521 pushValueAndType(
I.getOperand(0), InstID, Vals);
2522 pushValueAndType(
I.getOperand(1), InstID, Vals);
2523 pushValue(
I.getOperand(2), InstID, Vals);
2533 case Instruction::AtomicRMW:
2535 pushValueAndType(
I.getOperand(0), InstID, Vals);
2536 pushValue(
I.getOperand(1), InstID, Vals);
2544 case Instruction::Fence:
2549 case Instruction::Call: {
2562 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
2564 if (FTy->getParamType(i)->isLabelTy())
2571 if (FTy->isVarArg()) {
2572 for (
unsigned i = FTy->getNumParams(), e = CI.
arg_size(); i != e; ++i)
2577 case Instruction::VAArg:
2579 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2580 pushValue(
I.getOperand(0), InstID, Vals);
2585 Stream.EmitRecord(Code, Vals, AbbrevToUse);
2590void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
2591 const ValueSymbolTable &VST) {
2603 for (
auto &VI : VST) {
2608 return A->first() <
B->first();
2611 for (
const ValueName *SI : SortedTable) {
2616 bool isChar6 =
true;
2617 for (
const char *
C =
Name.getKeyData(), *
E =
C +
Name.getKeyLength();
2621 if ((
unsigned char)*
C & 128) {
2627 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2635 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2639 AbbrevToUse = VST_ENTRY_6_ABBREV;
2641 AbbrevToUse = VST_ENTRY_7_ABBREV;
2644 NameVals.
push_back(VE.getValueID(
SI->getValue()));
2645 for (
const char *
P =
Name.getKeyData(),
2646 *
E =
Name.getKeyData() +
Name.getKeyLength();
2651 Stream.EmitRecord(Code, NameVals, AbbrevToUse);
2658void DXILBitcodeWriter::writeFunction(
const Function &
F) {
2660 VE.incorporateFunction(
F);
2666 Vals.
push_back(VE.getBasicBlocks().size());
2671 unsigned CstStart, CstEnd;
2672 VE.getFunctionConstantRange(CstStart, CstEnd);
2673 writeConstants(CstStart, CstEnd,
false);
2676 writeFunctionMetadata(
F);
2679 unsigned InstID = CstEnd;
2681 bool NeedsMetadataAttachment =
F.hasMetadata();
2683 DILocation *LastDL =
nullptr;
2689 writeInstruction(*
I, InstID, Vals);
2691 if (!
I->getType()->isVoidTy())
2695 NeedsMetadataAttachment |=
I->hasMetadataOtherThanDebugLoc();
2698 DILocation *
DL =
I->getDebugLoc();
2710 Vals.
push_back(VE.getMetadataOrNullID(
DL->getScope()));
2711 Vals.
push_back(VE.getMetadataOrNullID(
DL->getInlinedAt()));
2719 if (
auto *Symtab =
F.getValueSymbolTable())
2720 writeFunctionLevelValueSymbolTable(*Symtab);
2722 if (NeedsMetadataAttachment)
2723 writeFunctionMetadataAttachment(
F);
2730void DXILBitcodeWriter::writeBlockInfo() {
2734 Stream.EnterBlockInfoBlock();
2737 auto Abbv = std::make_shared<BitCodeAbbrev>();
2743 std::move(Abbv)) != VST_ENTRY_8_ABBREV)
2744 assert(
false &&
"Unexpected abbrev ordering!");
2748 auto Abbv = std::make_shared<BitCodeAbbrev>();
2754 std::move(Abbv)) != VST_ENTRY_7_ABBREV)
2755 assert(
false &&
"Unexpected abbrev ordering!");
2758 auto Abbv = std::make_shared<BitCodeAbbrev>();
2764 std::move(Abbv)) != VST_ENTRY_6_ABBREV)
2765 assert(
false &&
"Unexpected abbrev ordering!");
2768 auto Abbv = std::make_shared<BitCodeAbbrev>();
2774 std::move(Abbv)) != VST_BBENTRY_6_ABBREV)
2775 assert(
false &&
"Unexpected abbrev ordering!");
2779 auto Abbv = std::make_shared<BitCodeAbbrev>();
2782 VE.computeBitsRequiredForTypeIndices()));
2784 CONSTANTS_SETTYPE_ABBREV)
2785 assert(
false &&
"Unexpected abbrev ordering!");
2789 auto Abbv = std::make_shared<BitCodeAbbrev>();
2793 CONSTANTS_INTEGER_ABBREV)
2794 assert(
false &&
"Unexpected abbrev ordering!");
2798 auto Abbv = std::make_shared<BitCodeAbbrev>();
2802 VE.computeBitsRequiredForTypeIndices()));
2806 CONSTANTS_CE_CAST_Abbrev)
2807 assert(
false &&
"Unexpected abbrev ordering!");
2810 auto Abbv = std::make_shared<BitCodeAbbrev>();
2813 CONSTANTS_NULL_Abbrev)
2814 assert(
false &&
"Unexpected abbrev ordering!");
2820 auto Abbv = std::make_shared<BitCodeAbbrev>();
2824 VE.computeBitsRequiredForTypeIndices()));
2828 (
unsigned)FUNCTION_INST_LOAD_ABBREV)
2829 assert(
false &&
"Unexpected abbrev ordering!");
2832 auto Abbv = std::make_shared<BitCodeAbbrev>();
2838 (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2839 assert(
false &&
"Unexpected abbrev ordering!");
2842 auto Abbv = std::make_shared<BitCodeAbbrev>();
2849 (
unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV)
2850 assert(
false &&
"Unexpected abbrev ordering!");
2853 auto Abbv = std::make_shared<BitCodeAbbrev>();
2857 VE.computeBitsRequiredForTypeIndices()));
2860 (
unsigned)FUNCTION_INST_CAST_ABBREV)
2861 assert(
false &&
"Unexpected abbrev ordering!");
2865 auto Abbv = std::make_shared<BitCodeAbbrev>();
2868 (
unsigned)FUNCTION_INST_RET_VOID_ABBREV)
2869 assert(
false &&
"Unexpected abbrev ordering!");
2872 auto Abbv = std::make_shared<BitCodeAbbrev>();
2876 (
unsigned)FUNCTION_INST_RET_VAL_ABBREV)
2877 assert(
false &&
"Unexpected abbrev ordering!");
2880 auto Abbv = std::make_shared<BitCodeAbbrev>();
2883 (
unsigned)FUNCTION_INST_UNREACHABLE_ABBREV)
2884 assert(
false &&
"Unexpected abbrev ordering!");
2887 auto Abbv = std::make_shared<BitCodeAbbrev>();
2895 (
unsigned)FUNCTION_INST_GEP_ABBREV)
2896 assert(
false &&
"Unexpected abbrev ordering!");
2902void DXILBitcodeWriter::writeModuleVersion() {
2917 DXILBitcodeWriter::writeModuleVersion();
2923 writeAttributeGroupTable();
2926 writeAttributeTable();
2938 writeModuleConstants();
2941 writeModuleMetadataKinds();
2944 writeModuleMetadata();
2949 writeFunctionLevelValueSymbolTable(M.getValueSymbolTable());
2953 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< 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...
Module.h This file contains the declarations for the Module class.
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
uint64_t IntrinsicInst * II
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - 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,...
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
@ None
No attributes have been set.
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
@ 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.
uint16_t getUnversionedName() const
Transitional API for cases where we do not yet support versioned source language names.
uint32_t getVersion() const
Returns language version. Only valid for versioned language names.
bool hasVersionedName() const
uint16_t getName() const
Returns a versioned or unversioned language name.
iterator find(const_arg_type_t< KeyT > Val)
BasicBlockListType::const_iterator const_iterator
Function and variable summary information to aid decisions and implementation of importing.
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)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - 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.
void writeModule(const Module &M)
Write the specified module to the buffer specified at construction time.
BitcodeWriter(SmallVectorImpl< char > &Buffer)
Create a BitcodeWriter that writes to Buffer.
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 void writeIdentificationBlock(BitstreamWriter &Stream)
static unsigned getEncodedBinaryOpcode(unsigned Opcode)
static void emitSignedInt64(SmallVectorImpl< uint64_t > &Vals, uint64_t V)
static unsigned getEncodedUnaryOpcode(unsigned Opcode)
static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op)
DXILBitcodeWriter(const Module &M, SmallVectorImpl< char > &Buffer, StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream)
Constructs a ModuleBitcodeWriter object for the given Module, writing to the provided Buffer.
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.
raw_ostream & write(unsigned char C)
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.
@ C
The default llvm calling convention, compatible with C.
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_LANDINGPAD
@ FUNC_CODE_INST_EXTRACTVAL
@ FUNC_CODE_INST_LOADATOMIC
@ FUNC_CODE_INST_STOREATOMIC
@ FUNC_CODE_INST_ATOMICRMW
@ 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
std::optional< SourceLanguage > toDW_LANG(SourceLanguageName name, uint32_t version)
Convert a DWARF 6 pair of language name and version to a DWARF 5 DW_LANG.
An analysis to compute the PointerTypes for pointers in a Module.
void WriteDXILToFile(const Module &M, raw_ostream &Out)
Write the specified module to the specified raw output stream.
DenseMap< const Value *, Type * > PointerTypeMap
NodeAddr< CodeNode * > Code
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.
FunctionAddr VTableAddr Value
StringMapEntry< Value * > ValueName
MaybeAlign getAlign(const CallInst &I, unsigned Index)
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.
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)
FunctionAddr VTableAddr Count
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.
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.