62#define HANDLE_MDNODE_LEAF(CLASS) CLASS##AbbrevID,
63#include "llvm/IR/Metadata.def"
81 CONSTANTS_INTEGER_ABBREV,
82 CONSTANTS_CE_CAST_Abbrev,
83 CONSTANTS_NULL_Abbrev,
87 FUNCTION_INST_BINOP_ABBREV,
88 FUNCTION_INST_BINOP_FLAGS_ABBREV,
89 FUNCTION_INST_CAST_ABBREV,
90 FUNCTION_INST_RET_VOID_ABBREV,
91 FUNCTION_INST_RET_VAL_ABBREV,
92 FUNCTION_INST_UNREACHABLE_ABBREV,
93 FUNCTION_INST_GEP_ABBREV,
114 std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
117 unsigned GlobalValueId;
123 uint64_t BitcodeStartBit;
139 StrtabBuilder(StrtabBuilder), M(M), VE(M, I8PtrTy, DebugInfo),
140 Buffer(Buffer), BitcodeStartBit(Stream.GetCurrentBitNo()),
142 GlobalValueId = VE.getValues().
size();
144 for (
auto El : PointerMap)
145 VE.EnumerateType(El.second);
171 void writeModuleVersion();
172 void writePerModuleGlobalValueSummary();
175 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
179 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
182 assert(VMI != GUIDToValueIdMap.end() &&
183 "GUID does not have assigned value Id");
189 if (!VI.haveGVs() || !VI.getValue())
190 return getValueId(VI.getGUID());
191 return VE.getValueID(VI.getValue());
194 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
196 uint64_t bitcodeStartBit() {
return BitcodeStartBit; }
198 unsigned createDILocationAbbrev();
199 unsigned createGenericDINodeAbbrev();
201 void writeAttributeGroupTable();
202 void writeAttributeTable();
203 void writeTypeTable();
205 void writeValueSymbolTableForwardDecl();
206 void writeModuleInfo();
207 void writeValueAsMetadata(
const ValueAsMetadata *MD,
208 SmallVectorImpl<uint64_t> &Record);
209 void writeMDTuple(
const MDTuple *
N, SmallVectorImpl<uint64_t> &Record,
211 void writeDILocation(
const DILocation *
N, SmallVectorImpl<uint64_t> &Record,
213 void writeGenericDINode(
const GenericDINode *
N,
214 SmallVectorImpl<uint64_t> &Record,
unsigned &Abbrev) {
217 void writeDISubrange(
const DISubrange *
N, SmallVectorImpl<uint64_t> &Record,
219 void writeDIGenericSubrange(
const DIGenericSubrange *
N,
220 SmallVectorImpl<uint64_t> &Record,
224 void writeDIEnumerator(
const DIEnumerator *
N,
225 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
226 void writeDIBasicType(
const DIBasicType *
N, SmallVectorImpl<uint64_t> &Record,
228 void writeDIFixedPointType(
const DIFixedPointType *
N,
229 SmallVectorImpl<uint64_t> &Record,
233 void writeDIStringType(
const DIStringType *
N,
234 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
237 void writeDIDerivedType(
const DIDerivedType *
N,
238 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
239 void writeDISubrangeType(
const DISubrangeType *
N,
240 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
243 void writeDICompositeType(
const DICompositeType *
N,
244 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
245 void writeDISubroutineType(
const DISubroutineType *
N,
246 SmallVectorImpl<uint64_t> &Record,
248 void writeDIFile(
const DIFile *
N, SmallVectorImpl<uint64_t> &Record,
250 void writeDICompileUnit(
const DICompileUnit *
N,
251 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
252 void writeDISubprogram(
const DISubprogram *
N,
253 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
254 void writeDILexicalBlock(
const DILexicalBlock *
N,
255 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
256 void writeDILexicalBlockFile(
const DILexicalBlockFile *
N,
257 SmallVectorImpl<uint64_t> &Record,
259 void writeDICommonBlock(
const DICommonBlock *
N,
260 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
263 void writeDINamespace(
const DINamespace *
N, SmallVectorImpl<uint64_t> &Record,
265 void writeDIMacro(
const DIMacro *
N, SmallVectorImpl<uint64_t> &Record,
269 void writeDIMacroFile(
const DIMacroFile *
N, SmallVectorImpl<uint64_t> &Record,
273 void writeDIArgList(
const DIArgList *
N, SmallVectorImpl<uint64_t> &Record,
277 void writeDIAssignID(
const DIAssignID *
N, SmallVectorImpl<uint64_t> &Record,
284 void writeDILayerLoc(
const DILayerLoc *
N, SmallVectorImpl<uint64_t> &Record,
288 void writeDILayerLocList(
const DILayerLocList *
N,
289 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
292 void writeDIModule(
const DIModule *
N, SmallVectorImpl<uint64_t> &Record,
294 void writeDITemplateTypeParameter(
const DITemplateTypeParameter *
N,
295 SmallVectorImpl<uint64_t> &Record,
297 void writeDITemplateValueParameter(
const DITemplateValueParameter *
N,
298 SmallVectorImpl<uint64_t> &Record,
300 void writeDIGlobalVariable(
const DIGlobalVariable *
N,
301 SmallVectorImpl<uint64_t> &Record,
303 void writeDILocalVariable(
const DILocalVariable *
N,
304 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
305 void writeDILabel(
const DILabel *
N, SmallVectorImpl<uint64_t> &Record,
309 void writeDIExpression(
const DIExpression *
N,
310 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
311 void writeDIGlobalVariableExpression(
const DIGlobalVariableExpression *
N,
312 SmallVectorImpl<uint64_t> &Record,
316 void writeDIObjCProperty(
const DIObjCProperty *
N,
317 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
318 void writeDIProperty(
const DIProperty *
N, SmallVectorImpl<uint64_t> &Record,
322 void writeDIImportedEntity(
const DIImportedEntity *
N,
323 SmallVectorImpl<uint64_t> &Record,
325 unsigned createMetadataStringsAbbrev();
327 SmallVectorImpl<uint64_t> &Record);
329 SmallVectorImpl<uint64_t> &Record,
330 std::vector<unsigned> *MDAbbrevs =
nullptr,
331 std::vector<uint64_t> *IndexPos =
nullptr);
332 void writeModuleMetadata();
333 void writeFunctionMetadata(
const Function &
F);
334 void writeFunctionMetadataAttachment(
const Function &
F);
335 void writeModuleMetadataKinds();
336 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
337 void writeModuleConstants();
338 bool pushValueAndType(
const Value *V,
unsigned InstID,
339 SmallVectorImpl<unsigned> &Vals);
340 void pushValue(
const Value *V,
unsigned InstID,
341 SmallVectorImpl<unsigned> &Vals);
342 void pushValueSigned(
const Value *V,
unsigned InstID,
343 SmallVectorImpl<uint64_t> &Vals);
344 void writeInstruction(
const Instruction &
I,
unsigned InstID,
345 SmallVectorImpl<unsigned> &Vals);
346 void writeFunctionLevelValueSymbolTable(
const ValueSymbolTable &VST);
348 void writeBlockInfo();
350 unsigned getEncodedSyncScopeID(
SyncScope::ID SSID) {
return unsigned(SSID); }
352 unsigned getEncodedAlign(MaybeAlign Alignment) {
return encode(Alignment); }
354 unsigned getTypeID(
Type *
T,
const Value *V =
nullptr);
359 unsigned getGlobalObjectValueTypeID(
Type *
T,
const GlobalObject *
G);
375 Stream->Emit((
unsigned)
'B', 8);
376 Stream->Emit((
unsigned)
'C', 8);
377 Stream->Emit(0x0, 4);
378 Stream->Emit(0xC, 4);
379 Stream->Emit(0xE, 4);
380 Stream->Emit(0xD, 4);
392 Triple TT(M.getTargetTriple());
393 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
402 Out.write((
char *)&Buffer.
front(), Buffer.
size());
408 auto Abbv = std::make_shared<BitCodeAbbrev>();
411 auto AbbrevNo = Stream->
EmitAbbrev(std::move(Abbv));
425 assert(M.isMaterialized());
426 Mods.push_back(
const_cast<Module *
>(&M));
429 ModuleWriter.
write();
440 case Instruction::Trunc:
442 case Instruction::ZExt:
444 case Instruction::SExt:
446 case Instruction::FPToUI:
448 case Instruction::FPToSI:
450 case Instruction::UIToFP:
452 case Instruction::SIToFP:
454 case Instruction::FPTrunc:
456 case Instruction::FPExt:
458 case Instruction::PtrToInt:
460 case Instruction::IntToPtr:
462 case Instruction::BitCast:
464 case Instruction::AddrSpaceCast:
473 case Instruction::FNeg:
482 case Instruction::Add:
483 case Instruction::FAdd:
485 case Instruction::Sub:
486 case Instruction::FSub:
488 case Instruction::Mul:
489 case Instruction::FMul:
491 case Instruction::UDiv:
493 case Instruction::FDiv:
494 case Instruction::SDiv:
496 case Instruction::URem:
498 case Instruction::FRem:
499 case Instruction::SRem:
501 case Instruction::Shl:
503 case Instruction::LShr:
505 case Instruction::AShr:
507 case Instruction::And:
509 case Instruction::Or:
511 case Instruction::Xor:
516unsigned DXILBitcodeWriter::getTypeID(
Type *
T,
const Value *V) {
520 return VE.getTypeID(
T);
521 auto It = PointerMap.
find(V);
522 if (It != PointerMap.
end())
523 return VE.getTypeID(It->second);
527 if (
T->isPointerTy())
528 return VE.getTypeID(I8PtrTy);
529 return VE.getTypeID(
T);
532unsigned DXILBitcodeWriter::getGlobalObjectValueTypeID(
Type *
T,
534 auto It = PointerMap.
find(
G);
535 if (It != PointerMap.
end()) {
539 return VE.getTypeID(
T);
601 unsigned AbbrevToUse) {
612 Stream.EmitRecord(Code, Vals, AbbrevToUse);
617 case Attribute::Alignment:
619 case Attribute::AlwaysInline:
621 case Attribute::Builtin:
623 case Attribute::ByVal:
625 case Attribute::Convergent:
627 case Attribute::InAlloca:
629 case Attribute::Cold:
631 case Attribute::InlineHint:
633 case Attribute::InReg:
635 case Attribute::JumpTable:
637 case Attribute::MinSize:
639 case Attribute::Naked:
641 case Attribute::Nest:
643 case Attribute::NoAlias:
645 case Attribute::NoBuiltin:
647 case Attribute::NoDuplicate:
649 case Attribute::NoImplicitFloat:
651 case Attribute::NoInline:
653 case Attribute::NonLazyBind:
655 case Attribute::NonNull:
657 case Attribute::Dereferenceable:
659 case Attribute::DereferenceableOrNull:
661 case Attribute::NoRedZone:
663 case Attribute::NoReturn:
665 case Attribute::NoUnwind:
667 case Attribute::OptimizeForSize:
669 case Attribute::OptimizeNone:
671 case Attribute::ReadNone:
673 case Attribute::ReadOnly:
675 case Attribute::Returned:
677 case Attribute::ReturnsTwice:
679 case Attribute::SExt:
681 case Attribute::StackAlignment:
683 case Attribute::StackProtect:
685 case Attribute::StackProtectReq:
687 case Attribute::StackProtectStrong:
689 case Attribute::SafeStack:
691 case Attribute::StructRet:
693 case Attribute::SanitizeAddress:
695 case Attribute::SanitizeThread:
697 case Attribute::SanitizeMemory:
699 case Attribute::UWTable:
701 case Attribute::ZExt:
712 "should be stripped in DXILPrepare");
732 unsigned NumWords =
A.getActiveWords();
733 const uint64_t *RawData =
A.getRawData();
734 for (
unsigned i = 0; i < NumWords; i++)
742 if (OBO->hasNoSignedWrap())
744 if (OBO->hasNoUnsignedWrap())
750 if (FPMO->hasAllowReassoc() || FPMO->hasAllowContract())
752 if (FPMO->hasNoNaNs())
754 if (FPMO->hasNoInfs())
756 if (FPMO->hasNoSignedZeros())
758 if (FPMO->hasAllowReciprocal())
839 switch (
C.getSelectionKind()) {
858void DXILBitcodeWriter::writeAttributeGroupTable() {
859 const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
860 VE.getAttributeGroups();
861 if (AttrGrps.empty())
868 unsigned AttrListIndex = Pair.first;
870 Record.push_back(
VE.getAttributeGroupID(Pair));
871 Record.push_back(AttrListIndex);
874 if (Attr.isEnumAttribute()) {
877 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
880 }
else if (Attr.isIntAttribute()) {
881 if (Attr.getKindAsEnum() == Attribute::AttrKind::Memory) {
899 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
902 Record.push_back(Attr.getValueAsInt());
905 StringRef
Kind = Attr.getKindAsString();
906 StringRef Val = Attr.getValueAsString();
925void DXILBitcodeWriter::writeAttributeTable() {
926 const std::vector<AttributeList> &
Attrs = VE.getAttributeLists();
932 SmallVector<uint64_t, 64>
Record;
933 for (AttributeList AL : Attrs) {
934 for (
unsigned i :
AL.indexes()) {
935 AttributeSet AS =
AL.getAttributes(i);
937 Record.push_back(VE.getAttributeGroupID({i, AS}));
948void DXILBitcodeWriter::writeTypeTable() {
952 SmallVector<uint64_t, 64> TypeVals;
954 uint64_t NumBits = VE.computeBitsRequiredForTypeIndices();
957 auto Abbv = std::make_shared<BitCodeAbbrev>();
960 Abbv->Add(BitCodeAbbrevOp(0));
961 unsigned PtrAbbrev = Stream.EmitAbbrev(std::move(Abbv));
964 Abbv = std::make_shared<BitCodeAbbrev>();
969 unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
972 Abbv = std::make_shared<BitCodeAbbrev>();
977 unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
980 Abbv = std::make_shared<BitCodeAbbrev>();
984 unsigned StructNameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
987 Abbv = std::make_shared<BitCodeAbbrev>();
992 unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
995 Abbv = std::make_shared<BitCodeAbbrev>();
999 unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1007 for (
Type *
T : TypeList) {
1008 int AbbrevToUse = 0;
1011 switch (
T->getTypeID()) {
1064 AbbrevToUse = PtrAbbrev;
1075 "dxilOpaquePtrReservedName", StructNameAbbrev);
1083 TypeVals.
push_back(getTypeID(FT->getReturnType()));
1084 for (
Type *PTy : FT->params())
1086 AbbrevToUse = FunctionAbbrev;
1094 for (
Type *ElTy :
ST->elements())
1097 if (
ST->isLiteral()) {
1099 AbbrevToUse = StructAnonAbbrev;
1101 if (
ST->isOpaque()) {
1105 AbbrevToUse = StructNamedAbbrev;
1109 if (!
ST->getName().empty())
1119 TypeVals.
push_back(AT->getNumElements());
1120 TypeVals.
push_back(getTypeID(AT->getElementType()));
1121 AbbrevToUse = ArrayAbbrev;
1129 TypeVals.
push_back(VT->getElementCount().getKnownMinValue());
1130 TypeVals.
push_back(getTypeID(VT->getElementType()));
1136 Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
1143void DXILBitcodeWriter::writeComdats() {
1145 for (
const Comdat *
C : VE.getComdats()) {
1148 size_t Size =
C->getName().size();
1151 for (
char Chr :
C->getName())
1158void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
1163void DXILBitcodeWriter::writeModuleInfo() {
1168 StringRef Triple =
"dxil-ms-dx";
1169 StringRef
DL =
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-"
1170 "f16:16-f32:32-f64:64-n8:16:32:64";
1179 std::map<std::string, unsigned> SectionMap;
1180 std::map<std::string, unsigned> GCMap;
1182 unsigned MaxGlobalType = 0;
1183 const auto UpdateMaxAlignment = [&
MaxAlignment](
const MaybeAlign
A) {
1187 for (
const GlobalVariable &GV : M.globals()) {
1188 UpdateMaxAlignment(GV.getAlign());
1191 MaxGlobalType = std::max(
1192 MaxGlobalType, getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1193 if (GV.hasSection()) {
1195 unsigned &
Entry = SectionMap[std::string(GV.getSection())];
1198 GV.getSection(), 0 );
1199 Entry = SectionMap.size();
1204 UpdateMaxAlignment(
F.getAlign());
1205 if (
F.hasSection()) {
1207 unsigned &
Entry = SectionMap[std::string(
F.getSection())];
1211 Entry = SectionMap.size();
1216 unsigned &
Entry = GCMap[
F.getGC()];
1220 Entry = GCMap.size();
1226 unsigned SimpleGVarAbbrev = 0;
1227 if (!M.global_empty()) {
1230 auto Abbv = std::make_shared<BitCodeAbbrev>();
1240 Abbv->Add(BitCodeAbbrevOp(0));
1242 unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1246 if (SectionMap.empty())
1247 Abbv->Add(BitCodeAbbrevOp(0));
1252 SimpleGVarAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1257 for (
const GlobalVariable &GV : M.globals()) {
1258 unsigned AbbrevToUse = 0;
1264 Vals.
push_back(getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1266 GV.getType()->getAddressSpace() << 2 | 2 |
1267 (GV.isConstant() ? 1 : 0));
1270 GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1));
1272 Vals.
push_back(getEncodedAlign(GV.getAlign()));
1273 Vals.
push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1275 if (GV.isThreadLocal() ||
1278 GV.isExternallyInitialized() ||
1284 Vals.
push_back(GV.isExternallyInitialized());
1286 Vals.
push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1288 AbbrevToUse = SimpleGVarAbbrev;
1297 const Function &
F = VE.getDXILFunction(OrigF);
1302 Vals.
push_back(getGlobalObjectValueTypeID(
F.getFunctionType(), &
F));
1306 Vals.
push_back(VE.getAttributeListID(
F.getAttributes()));
1307 Vals.
push_back(getEncodedAlign(
F.getAlign()));
1308 Vals.
push_back(
F.hasSection() ? SectionMap[std::string(
F.getSection())]
1314 F.hasPrologueData() ? (VE.getValueID(
F.getPrologueData()) + 1) : 0);
1316 Vals.
push_back(
F.hasComdat() ? VE.getComdatID(
F.getComdat()) : 0);
1317 Vals.
push_back(
F.hasPrefixData() ? (VE.getValueID(
F.getPrefixData()) + 1)
1320 F.hasPersonalityFn() ? (VE.getValueID(
F.getPersonalityFn()) + 1) : 0);
1322 unsigned AbbrevToUse = 0;
1328 for (
const GlobalAlias &
A : M.aliases()) {
1331 Vals.
push_back(VE.getValueID(
A.getAliasee()));
1337 unsigned AbbrevToUse = 0;
1343void DXILBitcodeWriter::writeValueAsMetadata(
1344 const ValueAsMetadata *MD, SmallVectorImpl<uint64_t> &Record) {
1347 Type *Ty =
V->getType();
1352 Record.push_back(getTypeID(Ty, V));
1353 Record.push_back(VE.getValueID(V));
1358void DXILBitcodeWriter::writeMDTuple(
const MDTuple *
N,
1359 SmallVectorImpl<uint64_t> &Record,
1361 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
1364 "Unexpected function-local metadata");
1365 Record.push_back(VE.getMetadataOrNullID(MD));
1373void DXILBitcodeWriter::writeDILocation(
const DILocation *
N,
1374 SmallVectorImpl<uint64_t> &Record,
1377 Abbrev = createDILocationAbbrev();
1378 Record.push_back(
N->isDistinct());
1379 Record.push_back(
N->getLine());
1380 Record.push_back(
N->getColumn());
1381 Record.push_back(VE.getMetadataID(
N->getScope()));
1382 Record.push_back(VE.getMetadataOrNullID(
N->getInlinedAt()));
1391 return I < 0 ? ~(U << 1) : U << 1;
1394void DXILBitcodeWriter::writeDISubrange(
const DISubrange *
N,
1395 SmallVectorImpl<uint64_t> &Record,
1397 Record.push_back(
N->isDistinct());
1403 Record.push_back(
Count->getValue().getSExtValue());
1409 DISubrange::BoundType
LowerBound =
N->getLowerBound();
1420void DXILBitcodeWriter::writeDIEnumerator(
const DIEnumerator *
N,
1421 SmallVectorImpl<uint64_t> &Record,
1423 Record.push_back(
N->isDistinct());
1425 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1431void DXILBitcodeWriter::writeDIBasicType(
const DIBasicType *
N,
1432 SmallVectorImpl<uint64_t> &Record,
1434 Record.push_back(
N->isDistinct());
1435 Record.push_back(
N->getTag());
1436 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1437 Record.push_back(
N->getSizeInBits());
1438 Record.push_back(
N->getAlignInBits());
1439 Record.push_back(
N->getEncoding());
1445void DXILBitcodeWriter::writeDIDerivedType(
const DIDerivedType *
N,
1446 SmallVectorImpl<uint64_t> &Record,
1448 Record.push_back(
N->isDistinct());
1449 Record.push_back(
N->getTag());
1450 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1451 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1452 Record.push_back(
N->getLine());
1453 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1454 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1455 Record.push_back(
N->getSizeInBits());
1456 Record.push_back(
N->getAlignInBits());
1457 Record.push_back(
N->getOffsetInBits());
1458 Record.push_back(
N->getFlags());
1459 Record.push_back(VE.getMetadataOrNullID(
N->getExtraData()));
1465void DXILBitcodeWriter::writeDICompositeType(
const DICompositeType *
N,
1466 SmallVectorImpl<uint64_t> &Record,
1468 Record.push_back(
N->isDistinct());
1469 Record.push_back(
N->getTag());
1470 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1471 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1472 Record.push_back(
N->getLine());
1473 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1474 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1475 Record.push_back(
N->getSizeInBits());
1476 Record.push_back(
N->getAlignInBits());
1477 Record.push_back(
N->getOffsetInBits());
1478 Record.push_back(
N->getFlags());
1479 Record.push_back(VE.getMetadataOrNullID(
N->getElements().get()));
1480 Record.push_back(
N->getRuntimeLang());
1481 Record.push_back(VE.getMetadataOrNullID(
N->getVTableHolder()));
1482 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1483 Record.push_back(VE.getMetadataOrNullID(
N->getRawIdentifier()));
1489void DXILBitcodeWriter::writeDISubroutineType(
const DISubroutineType *
N,
1490 SmallVectorImpl<uint64_t> &Record,
1492 Record.push_back(
N->isDistinct());
1493 Record.push_back(
N->getFlags());
1494 Record.push_back(VE.getMetadataOrNullID(
N->getTypeArray().get()));
1500void DXILBitcodeWriter::writeDIFile(
const DIFile *
N,
1501 SmallVectorImpl<uint64_t> &Record,
1503 Record.push_back(
N->isDistinct());
1504 Record.push_back(VE.getMetadataOrNullID(
N->getRawFilename()));
1505 Record.push_back(VE.getMetadataOrNullID(
N->getRawDirectory()));
1511void DXILBitcodeWriter::writeDICompileUnit(
const DICompileUnit *
N,
1512 SmallVectorImpl<uint64_t> &Record,
1514 Record.push_back(
N->isDistinct());
1515 Record.push_back(
N->getSourceLanguage().getUnversionedName());
1516 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1517 Record.push_back(VE.getMetadataOrNullID(
N->getRawProducer()));
1518 Record.push_back(
N->isOptimized());
1519 Record.push_back(VE.getMetadataOrNullID(
N->getRawFlags()));
1520 Record.push_back(
N->getRuntimeVersion());
1521 Record.push_back(VE.getMetadataOrNullID(
N->getRawSplitDebugFilename()));
1522 Record.push_back(
N->getEmissionKind());
1523 Record.push_back(VE.getMetadataOrNullID(
N->getEnumTypes().get()));
1524 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedTypes().get()));
1525 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1526 Record.push_back(VE.getMetadataOrNullID(
N->getGlobalVariables().get()));
1527 Record.push_back(VE.getMetadataOrNullID(
N->getImportedEntities().get()));
1528 Record.push_back(
N->getDWOId());
1534void DXILBitcodeWriter::writeDISubprogram(
const DISubprogram *
N,
1535 SmallVectorImpl<uint64_t> &Record,
1537 Record.push_back(
N->isDistinct());
1538 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1539 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1540 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1541 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1542 Record.push_back(
N->getLine());
1543 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1544 Record.push_back(
N->isLocalToUnit());
1545 Record.push_back(
N->isDefinition());
1546 Record.push_back(
N->getScopeLine());
1547 Record.push_back(VE.getMetadataOrNullID(
N->getContainingType()));
1548 Record.push_back(
N->getVirtuality());
1549 Record.push_back(
N->getVirtualIndex());
1550 Record.push_back(
N->getFlags());
1551 Record.push_back(
N->isOptimized());
1552 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1553 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1554 Record.push_back(VE.getMetadataOrNullID(
N->getDeclaration()));
1555 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedNodes().get()));
1561void DXILBitcodeWriter::writeDILexicalBlock(
const DILexicalBlock *
N,
1562 SmallVectorImpl<uint64_t> &Record,
1564 Record.push_back(
N->isDistinct());
1565 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1566 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1567 Record.push_back(
N->getLine());
1568 Record.push_back(
N->getColumn());
1574void DXILBitcodeWriter::writeDILexicalBlockFile(
1575 const DILexicalBlockFile *
N, SmallVectorImpl<uint64_t> &Record,
1577 Record.push_back(
N->isDistinct());
1578 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1579 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1580 Record.push_back(
N->getDiscriminator());
1586void DXILBitcodeWriter::writeDINamespace(
const DINamespace *
N,
1587 SmallVectorImpl<uint64_t> &Record,
1589 Record.push_back(
N->isDistinct());
1590 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1591 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1592 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1599void DXILBitcodeWriter::writeDIModule(
const DIModule *
N,
1600 SmallVectorImpl<uint64_t> &Record,
1602 Record.push_back(
N->isDistinct());
1603 for (
auto &
I :
N->operands())
1604 Record.push_back(VE.getMetadataOrNullID(
I));
1610void DXILBitcodeWriter::writeDITemplateTypeParameter(
1611 const DITemplateTypeParameter *
N, SmallVectorImpl<uint64_t> &Record,
1613 Record.push_back(
N->isDistinct());
1614 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1615 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1621void DXILBitcodeWriter::writeDITemplateValueParameter(
1622 const DITemplateValueParameter *
N, SmallVectorImpl<uint64_t> &Record,
1624 Record.push_back(
N->isDistinct());
1625 Record.push_back(
N->getTag());
1626 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1627 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1628 Record.push_back(VE.getMetadataOrNullID(
N->getValue()));
1634void DXILBitcodeWriter::writeDIGlobalVariable(
const DIGlobalVariable *
N,
1635 SmallVectorImpl<uint64_t> &Record,
1637 Record.push_back(
N->isDistinct());
1638 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1639 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1640 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1641 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1642 Record.push_back(
N->getLine());
1643 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1644 Record.push_back(
N->isLocalToUnit());
1645 Record.push_back(
N->isDefinition());
1646 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1647 Record.push_back(VE.getMetadataOrNullID(
N->getStaticDataMemberDeclaration()));
1653void DXILBitcodeWriter::writeDILocalVariable(
const DILocalVariable *
N,
1654 SmallVectorImpl<uint64_t> &Record,
1656 constexpr unsigned DW_TAG_auto_variable = 0x0100;
1657 constexpr unsigned DW_TAG_arg_variable = 0x0101;
1658 Record.push_back(
N->isDistinct());
1659 assert(
N->getTag() == dwarf::DW_TAG_variable);
1660 Record.push_back(
N->getArg() ? DW_TAG_arg_variable : DW_TAG_auto_variable);
1661 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1662 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1663 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1664 Record.push_back(
N->getLine());
1665 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1666 Record.push_back(
N->getArg());
1667 Record.push_back(
N->getFlags());
1673void DXILBitcodeWriter::writeDIExpression(
const DIExpression *
N,
1674 SmallVectorImpl<uint64_t> &Record,
1676 Record.reserve(
N->getElements().size() + 1);
1678 Record.push_back(
N->isDistinct());
1679 Record.append(
N->elements_begin(),
N->elements_end());
1685void DXILBitcodeWriter::writeDIObjCProperty(
const DIObjCProperty *
N,
1686 SmallVectorImpl<uint64_t> &Record,
1691void DXILBitcodeWriter::writeDIImportedEntity(
const DIImportedEntity *
N,
1692 SmallVectorImpl<uint64_t> &Record,
1694 Record.push_back(
N->isDistinct());
1695 Record.push_back(
N->getTag());
1696 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1697 Record.push_back(VE.getMetadataOrNullID(
N->getEntity()));
1698 Record.push_back(
N->getLine());
1699 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1705unsigned DXILBitcodeWriter::createDILocationAbbrev() {
1710 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1717 return Stream.EmitAbbrev(std::move(Abbv));
1720unsigned DXILBitcodeWriter::createGenericDINodeAbbrev() {
1725 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1733 return Stream.EmitAbbrev(std::move(Abbv));
1737 SmallVectorImpl<uint64_t> &Record,
1738 std::vector<unsigned> *MDAbbrevs,
1739 std::vector<uint64_t> *IndexPos) {
1744#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1745#include "llvm/IR/Metadata.def"
1749 IndexPos->push_back(Stream.GetCurrentBitNo());
1751 assert(
N->isResolved() &&
"Expected forward references to be resolved");
1753 switch (
N->getMetadataID()) {
1756#define HANDLE_MDNODE_LEAF(CLASS) \
1757 case Metadata::CLASS##Kind: \
1759 write##CLASS(cast<CLASS>(N), Record, \
1760 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1762 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1764#include "llvm/IR/Metadata.def"
1771unsigned DXILBitcodeWriter::createMetadataStringsAbbrev() {
1772 auto Abbv = std::make_shared<BitCodeAbbrev>();
1776 return Stream.EmitAbbrev(std::move(Abbv));
1779void DXILBitcodeWriter::writeMetadataStrings(
1781 if (Strings.
empty())
1784 unsigned MDSAbbrev = createMetadataStringsAbbrev();
1786 for (
const Metadata *MD : Strings) {
1797void DXILBitcodeWriter::writeModuleMetadata() {
1798 if (!VE.hasMDs() && M.named_metadata_empty())
1805 std::vector<unsigned> MDAbbrevs;
1808 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1809 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1810 createGenericDINodeAbbrev();
1812 unsigned NameAbbrev = 0;
1813 if (!M.named_metadata_empty()) {
1815 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1819 NameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1822 SmallVector<uint64_t, 64>
Record;
1823 writeMetadataStrings(VE.getMDStrings(), Record);
1825 std::vector<uint64_t> IndexPos;
1826 IndexPos.reserve(VE.getNonMDStrings().size());
1827 writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1830 for (
const NamedMDNode &NMD : M.named_metadata()) {
1832 StringRef Str = NMD.getName();
1833 Record.append(Str.bytes_begin(), Str.bytes_end());
1838 for (
const MDNode *
N : NMD.operands())
1839 Record.push_back(VE.getMetadataID(
N));
1847void DXILBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
1852 SmallVector<uint64_t, 64>
Record;
1853 writeMetadataStrings(VE.getMDStrings(), Record);
1854 writeMetadataRecords(VE.getNonMDStrings(), Record);
1858void DXILBitcodeWriter::writeFunctionMetadataAttachment(
const Function &
F) {
1861 SmallVector<uint64_t, 64>
Record;
1866 F.getAllMetadata(MDs);
1868 for (
const auto &
I : MDs) {
1869 if (
I.first == LLVMContext::MD_dbg)
1872 Record.push_back(VE.getMetadataID(
I.second));
1880 for (
const BasicBlock &BB :
F)
1881 for (
const Instruction &OrigI : BB) {
1885 I.getAllMetadataOtherThanDebugLoc(MDs);
1891 Record.push_back(VE.getInstructionID(&
I));
1893 for (
unsigned i = 0, e = MDs.size(); i != e; ++i) {
1894 Record.push_back(MDs[i].first);
1895 Record.push_back(VE.getMetadataID(MDs[i].second));
1904void DXILBitcodeWriter::writeModuleMetadataKinds() {
1905 SmallVector<uint64_t, 64>
Record;
1910 M.getMDKindNames(Names);
1917 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
1918 Record.push_back(MDKindID);
1919 StringRef KName = Names[MDKindID];
1929void DXILBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
1931 if (FirstVal == LastVal)
1936 unsigned AggregateAbbrev = 0;
1937 unsigned String8Abbrev = 0;
1938 unsigned CString7Abbrev = 0;
1939 unsigned CString6Abbrev = 0;
1943 auto Abbv = std::make_shared<BitCodeAbbrev>();
1948 AggregateAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1951 Abbv = std::make_shared<BitCodeAbbrev>();
1955 String8Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1957 Abbv = std::make_shared<BitCodeAbbrev>();
1961 CString7Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1963 Abbv = std::make_shared<BitCodeAbbrev>();
1967 CString6Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1970 SmallVector<uint64_t, 64>
Record;
1973 Type *LastTy =
nullptr;
1974 for (
unsigned i = FirstVal; i != LastVal; ++i) {
1975 const Value *
V = Vals[i].first;
1977 if (
V->getType() != LastTy) {
1978 LastTy =
V->getType();
1979 Record.push_back(getTypeID(LastTy, V));
1981 CONSTANTS_SETTYPE_ABBREV);
1986 Record.push_back(
unsigned(
IA->hasSideEffects()) |
1987 unsigned(
IA->isAlignStack()) << 1 |
1988 unsigned(
IA->getDialect() & 1) << 2);
1991 StringRef AsmStr =
IA->getAsmString();
1996 StringRef ConstraintStr =
IA->getConstraintString();
2004 unsigned Code = -1U;
2005 unsigned AbbrevToUse = 0;
2006 if (
C->isNullValue()) {
2011 if (
IV->getBitWidth() <= 64) {
2015 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2021 unsigned NWords =
IV->getValue().getActiveWords();
2022 const uint64_t *RawWords =
IV->getValue().getRawData();
2023 for (
unsigned i = 0; i != NWords; ++i) {
2031 if (BV->getBitWidth() <= 64) {
2035 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2037 unsigned NWords = BV->getValue().getActiveWords();
2038 const uint64_t *RawWords = BV->getValue().getRawData();
2039 for (
unsigned i = 0; i != NWords; ++i) {
2048 Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2052 APInt api = CFP->getValueAPF().bitcastToAPInt();
2054 Record.push_back((p[1] << 48) | (p[0] >> 16));
2055 Record.push_back(p[0] & 0xffffLL);
2057 APInt api = CFP->getValueAPF().bitcastToAPInt();
2062 assert(0 &&
"Unknown FP type!");
2068 unsigned NumElts = Str->getNumElements();
2070 if (Str->isCString()) {
2075 AbbrevToUse = String8Abbrev;
2079 for (
unsigned i = 0; i != NumElts; ++i) {
2080 unsigned char V = Str->getElementAsInteger(i);
2082 isCStr7 &= (
V & 128) == 0;
2088 AbbrevToUse = CString6Abbrev;
2090 AbbrevToUse = CString7Abbrev;
2091 }
else if (
const ConstantDataSequential *CDS =
2094 Type *EltTy = CDS->getElementType();
2096 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2097 Record.push_back(CDS->getElementAsInteger(i));
2099 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2104 F = CDS->getElementAsFloat(i);
2109 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2114 F = CDS->getElementAsDouble(i);
2121 for (
const Value *
Op :
C->operands())
2122 Record.push_back(VE.getValueID(
Op));
2123 AbbrevToUse = AggregateAbbrev;
2125 switch (
CE->getOpcode()) {
2131 getTypeID(
C->getOperand(0)->getType(),
C->getOperand(0)));
2132 Record.push_back(VE.getValueID(
C->getOperand(0)));
2133 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2135 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2138 Record.push_back(VE.getValueID(
C->getOperand(0)));
2139 Record.push_back(VE.getValueID(
C->getOperand(1)));
2145 case Instruction::GetElementPtr: {
2148 if (GO->isInBounds())
2150 Record.push_back(getTypeID(GO->getSourceElementType()));
2151 for (
unsigned i = 0, e =
CE->getNumOperands(); i != e; ++i) {
2153 getTypeID(
C->getOperand(i)->getType(),
C->getOperand(i)));
2154 Record.push_back(VE.getValueID(
C->getOperand(i)));
2158 case Instruction::Select:
2160 Record.push_back(VE.getValueID(
C->getOperand(0)));
2161 Record.push_back(VE.getValueID(
C->getOperand(1)));
2162 Record.push_back(VE.getValueID(
C->getOperand(2)));
2164 case Instruction::ExtractElement:
2166 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2167 Record.push_back(VE.getValueID(
C->getOperand(0)));
2168 Record.push_back(getTypeID(
C->getOperand(1)->getType()));
2169 Record.push_back(VE.getValueID(
C->getOperand(1)));
2171 case Instruction::InsertElement:
2173 Record.push_back(VE.getValueID(
C->getOperand(0)));
2174 Record.push_back(VE.getValueID(
C->getOperand(1)));
2175 Record.push_back(getTypeID(
C->getOperand(2)->getType()));
2176 Record.push_back(VE.getValueID(
C->getOperand(2)));
2178 case Instruction::ShuffleVector:
2183 if (
C->getType() ==
C->getOperand(0)->getType()) {
2187 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2189 Record.push_back(VE.getValueID(
C->getOperand(0)));
2190 Record.push_back(VE.getValueID(
C->getOperand(1)));
2191 Record.push_back(VE.getValueID(
C->getOperand(2)));
2196 Record.push_back(getTypeID(BA->getFunction()->getType()));
2197 Record.push_back(VE.getValueID(BA->getFunction()));
2198 Record.push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2205 Stream.EmitRecord(Code, Record, AbbrevToUse);
2212void DXILBitcodeWriter::writeModuleConstants() {
2217 for (
unsigned i = 0, e = Vals.size(); i != e; ++i) {
2219 writeConstants(i, Vals.size(),
true);
2233bool DXILBitcodeWriter::pushValueAndType(
const Value *V,
unsigned InstID,
2234 SmallVectorImpl<unsigned> &Vals) {
2235 unsigned ValID = VE.getValueID(V);
2238 if (ValID >= InstID) {
2247void DXILBitcodeWriter::pushValue(
const Value *V,
unsigned InstID,
2248 SmallVectorImpl<unsigned> &Vals) {
2249 unsigned ValID = VE.getValueID(V);
2253void DXILBitcodeWriter::pushValueSigned(
const Value *V,
unsigned InstID,
2254 SmallVectorImpl<uint64_t> &Vals) {
2255 unsigned ValID = VE.getValueID(V);
2256 int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2261void DXILBitcodeWriter::writeInstruction(
const Instruction &
I,
unsigned InstID,
2262 SmallVectorImpl<unsigned> &Vals) {
2264 unsigned AbbrevToUse = 0;
2265 VE.setInstructionID(&
I);
2266 switch (
I.getOpcode()) {
2270 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2271 AbbrevToUse = (unsigned)FUNCTION_INST_CAST_ABBREV;
2277 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2278 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_ABBREV;
2279 pushValue(
I.getOperand(1), InstID, Vals);
2283 if (AbbrevToUse == (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2284 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV;
2290 case Instruction::GetElementPtr: {
2292 AbbrevToUse = (unsigned)FUNCTION_INST_GEP_ABBREV;
2295 Vals.
push_back(getTypeID(GEPInst.getSourceElementType()));
2296 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i)
2297 pushValueAndType(
I.getOperand(i), InstID, Vals);
2300 case Instruction::ExtractValue: {
2302 pushValueAndType(
I.getOperand(0), InstID, Vals);
2307 case Instruction::InsertValue: {
2309 pushValueAndType(
I.getOperand(0), InstID, Vals);
2310 pushValueAndType(
I.getOperand(1), InstID, Vals);
2315 case Instruction::Select:
2317 pushValueAndType(
I.getOperand(1), InstID, Vals);
2318 pushValue(
I.getOperand(2), InstID, Vals);
2319 pushValueAndType(
I.getOperand(0), InstID, Vals);
2321 case Instruction::ExtractElement:
2323 pushValueAndType(
I.getOperand(0), InstID, Vals);
2324 pushValueAndType(
I.getOperand(1), InstID, Vals);
2326 case Instruction::InsertElement:
2328 pushValueAndType(
I.getOperand(0), InstID, Vals);
2329 pushValue(
I.getOperand(1), InstID, Vals);
2330 pushValueAndType(
I.getOperand(2), InstID, Vals);
2332 case Instruction::ShuffleVector:
2334 pushValueAndType(
I.getOperand(0), InstID, Vals);
2335 pushValue(
I.getOperand(1), InstID, Vals);
2339 case Instruction::ICmp:
2340 case Instruction::FCmp: {
2343 pushValueAndType(
I.getOperand(0), InstID, Vals);
2344 pushValue(
I.getOperand(1), InstID, Vals);
2352 case Instruction::Ret: {
2354 unsigned NumOperands =
I.getNumOperands();
2355 if (NumOperands == 0)
2356 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VOID_ABBREV;
2357 else if (NumOperands == 1) {
2358 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2359 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VAL_ABBREV;
2361 for (
unsigned i = 0, e = NumOperands; i !=
e; ++i)
2362 pushValueAndType(
I.getOperand(i), InstID, Vals);
2365 case Instruction::UncondBr:
2369 case Instruction::CondBr: {
2372 Vals.
push_back(VE.getValueID(
II.getSuccessor(0)));
2373 Vals.
push_back(VE.getValueID(
II.getSuccessor(1)));
2374 pushValue(
II.getCondition(), InstID, Vals);
2376 case Instruction::Switch: {
2379 Vals.
push_back(getTypeID(
SI.getCondition()->getType()));
2380 pushValue(
SI.getCondition(), InstID, Vals);
2381 Vals.
push_back(VE.getValueID(
SI.getDefaultDest()));
2382 for (
auto Case :
SI.cases()) {
2383 Vals.
push_back(VE.getValueID(Case.getCaseValue()));
2384 Vals.
push_back(VE.getValueID(Case.getCaseSuccessor()));
2387 case Instruction::IndirectBr:
2389 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2391 pushValue(
I.getOperand(0), InstID, Vals);
2392 for (
unsigned i = 1, e =
I.getNumOperands(); i != e; ++i)
2393 Vals.
push_back(VE.getValueID(
I.getOperand(i)));
2396 case Instruction::Invoke: {
2399 FunctionType *FTy =
II->getFunctionType();
2402 Vals.
push_back(VE.getAttributeListID(
II->getAttributes()));
2404 Vals.
push_back(VE.getValueID(
II->getNormalDest()));
2405 Vals.
push_back(VE.getValueID(
II->getUnwindDest()));
2407 pushValueAndType(Callee, InstID, Vals);
2410 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2411 pushValue(
I.getOperand(i), InstID, Vals);
2414 if (FTy->isVarArg()) {
2415 for (
unsigned i = FTy->getNumParams(), e =
I.getNumOperands() - 3; i != e;
2417 pushValueAndType(
I.getOperand(i), InstID, Vals);
2421 case Instruction::Resume:
2423 pushValueAndType(
I.getOperand(0), InstID, Vals);
2425 case Instruction::Unreachable:
2427 AbbrevToUse = (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV;
2430 case Instruction::PHI: {
2443 Stream.EmitRecord(Code, Vals64, AbbrevToUse);
2448 case Instruction::LandingPad: {
2459 pushValueAndType(LP.
getClause(
I), InstID, Vals);
2464 case Instruction::Alloca: {
2468 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2469 Vals.
push_back(VE.getValueID(
I.getOperand(0)));
2471 assert(AlignRecord < 1 << 5 &&
"alignment greater than 1 << 64");
2473 AlignRecord |= 1 << 6;
2478 case Instruction::Load:
2481 pushValueAndType(
I.getOperand(0), InstID, Vals);
2484 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2485 AbbrevToUse = (unsigned)FUNCTION_INST_LOAD_ABBREV;
2495 case Instruction::Store:
2500 pushValueAndType(
I.getOperand(1), InstID, Vals);
2501 pushValueAndType(
I.getOperand(0), InstID, Vals);
2510 case Instruction::AtomicCmpXchg:
2512 pushValueAndType(
I.getOperand(0), InstID, Vals);
2513 pushValueAndType(
I.getOperand(1), InstID, Vals);
2514 pushValue(
I.getOperand(2), InstID, Vals);
2524 case Instruction::AtomicRMW:
2526 pushValueAndType(
I.getOperand(0), InstID, Vals);
2527 pushValue(
I.getOperand(1), InstID, Vals);
2535 case Instruction::Fence:
2540 case Instruction::Call: {
2553 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
2555 if (FTy->getParamType(i)->isLabelTy())
2562 if (FTy->isVarArg()) {
2563 for (
unsigned i = FTy->getNumParams(), e = CI.
arg_size(); i != e; ++i)
2568 case Instruction::VAArg:
2570 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2571 pushValue(
I.getOperand(0), InstID, Vals);
2576 Stream.EmitRecord(Code, Vals, AbbrevToUse);
2581void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
2582 const ValueSymbolTable &VST) {
2594 for (
auto &VI : VST) {
2595 const Value &
V = VE.getDXILValue(*
VI.second);
2600 return A->first() <
B->first();
2603 for (
const ValueName *SI : SortedTable) {
2608 bool isChar6 =
true;
2609 for (
const char *
C =
Name.getKeyData(), *
E =
C +
Name.getKeyLength();
2613 if ((
unsigned char)*
C & 128) {
2619 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2627 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2631 AbbrevToUse = VST_ENTRY_6_ABBREV;
2633 AbbrevToUse = VST_ENTRY_7_ABBREV;
2636 NameVals.
push_back(VE.getValueID(
SI->getValue()));
2637 for (
const char *
P =
Name.getKeyData(),
2638 *
E =
Name.getKeyData() +
Name.getKeyLength();
2643 Stream.EmitRecord(Code, NameVals, AbbrevToUse);
2650void DXILBitcodeWriter::writeFunction(
const Function &
F) {
2652 VE.incorporateFunction(
F);
2658 Vals.
push_back(VE.getBasicBlocks().size());
2663 unsigned CstStart, CstEnd;
2664 VE.getFunctionConstantRange(CstStart, CstEnd);
2665 writeConstants(CstStart, CstEnd,
false);
2668 writeFunctionMetadata(
F);
2671 unsigned InstID = CstEnd;
2673 bool NeedsMetadataAttachment =
F.hasMetadata();
2675 DILocation *LastDL =
nullptr;
2683 writeInstruction(
I, InstID, Vals);
2685 if (!
I.getType()->isVoidTy())
2689 NeedsMetadataAttachment |=
I.hasMetadataOtherThanDebugLoc();
2692 DILocation *
DL =
I.getDebugLoc();
2704 Vals.
push_back(VE.getMetadataOrNullID(
DL->getScope()));
2705 Vals.
push_back(VE.getMetadataOrNullID(
DL->getInlinedAt()));
2713 if (
auto *Symtab =
F.getValueSymbolTable())
2714 writeFunctionLevelValueSymbolTable(*Symtab);
2716 if (NeedsMetadataAttachment)
2717 writeFunctionMetadataAttachment(
F);
2724void DXILBitcodeWriter::writeBlockInfo() {
2728 Stream.EnterBlockInfoBlock();
2731 auto Abbv = std::make_shared<BitCodeAbbrev>();
2737 std::move(Abbv)) != VST_ENTRY_8_ABBREV)
2738 assert(
false &&
"Unexpected abbrev ordering!");
2742 auto Abbv = std::make_shared<BitCodeAbbrev>();
2748 std::move(Abbv)) != VST_ENTRY_7_ABBREV)
2749 assert(
false &&
"Unexpected abbrev ordering!");
2752 auto Abbv = std::make_shared<BitCodeAbbrev>();
2758 std::move(Abbv)) != VST_ENTRY_6_ABBREV)
2759 assert(
false &&
"Unexpected abbrev ordering!");
2762 auto Abbv = std::make_shared<BitCodeAbbrev>();
2768 std::move(Abbv)) != VST_BBENTRY_6_ABBREV)
2769 assert(
false &&
"Unexpected abbrev ordering!");
2773 auto Abbv = std::make_shared<BitCodeAbbrev>();
2776 VE.computeBitsRequiredForTypeIndices()));
2778 CONSTANTS_SETTYPE_ABBREV)
2779 assert(
false &&
"Unexpected abbrev ordering!");
2783 auto Abbv = std::make_shared<BitCodeAbbrev>();
2787 CONSTANTS_INTEGER_ABBREV)
2788 assert(
false &&
"Unexpected abbrev ordering!");
2792 auto Abbv = std::make_shared<BitCodeAbbrev>();
2796 VE.computeBitsRequiredForTypeIndices()));
2800 CONSTANTS_CE_CAST_Abbrev)
2801 assert(
false &&
"Unexpected abbrev ordering!");
2804 auto Abbv = std::make_shared<BitCodeAbbrev>();
2807 CONSTANTS_NULL_Abbrev)
2808 assert(
false &&
"Unexpected abbrev ordering!");
2814 auto Abbv = std::make_shared<BitCodeAbbrev>();
2818 VE.computeBitsRequiredForTypeIndices()));
2822 (
unsigned)FUNCTION_INST_LOAD_ABBREV)
2823 assert(
false &&
"Unexpected abbrev ordering!");
2826 auto Abbv = std::make_shared<BitCodeAbbrev>();
2832 (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2833 assert(
false &&
"Unexpected abbrev ordering!");
2836 auto Abbv = std::make_shared<BitCodeAbbrev>();
2843 (
unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV)
2844 assert(
false &&
"Unexpected abbrev ordering!");
2847 auto Abbv = std::make_shared<BitCodeAbbrev>();
2851 VE.computeBitsRequiredForTypeIndices()));
2854 (
unsigned)FUNCTION_INST_CAST_ABBREV)
2855 assert(
false &&
"Unexpected abbrev ordering!");
2859 auto Abbv = std::make_shared<BitCodeAbbrev>();
2862 (
unsigned)FUNCTION_INST_RET_VOID_ABBREV)
2863 assert(
false &&
"Unexpected abbrev ordering!");
2866 auto Abbv = std::make_shared<BitCodeAbbrev>();
2870 (
unsigned)FUNCTION_INST_RET_VAL_ABBREV)
2871 assert(
false &&
"Unexpected abbrev ordering!");
2874 auto Abbv = std::make_shared<BitCodeAbbrev>();
2877 (
unsigned)FUNCTION_INST_UNREACHABLE_ABBREV)
2878 assert(
false &&
"Unexpected abbrev ordering!");
2881 auto Abbv = std::make_shared<BitCodeAbbrev>();
2889 (
unsigned)FUNCTION_INST_GEP_ABBREV)
2890 assert(
false &&
"Unexpected abbrev ordering!");
2896void DXILBitcodeWriter::writeModuleVersion() {
2911 DXILBitcodeWriter::writeModuleVersion();
2917 writeAttributeGroupTable();
2920 writeAttributeTable();
2932 writeModuleConstants();
2935 writeModuleMetadataKinds();
2938 writeModuleMetadata();
2943 writeFunctionLevelValueSymbolTable(M.getValueSymbolTable());
2947 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)
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,...
@ 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.
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)
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.
constexpr bool isAtomic(const T &...O)
@ 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.