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 writeDIModule(
const DIModule *
N, SmallVectorImpl<uint64_t> &Record,
286 void writeDITemplateTypeParameter(
const DITemplateTypeParameter *
N,
287 SmallVectorImpl<uint64_t> &Record,
289 void writeDITemplateValueParameter(
const DITemplateValueParameter *
N,
290 SmallVectorImpl<uint64_t> &Record,
292 void writeDIGlobalVariable(
const DIGlobalVariable *
N,
293 SmallVectorImpl<uint64_t> &Record,
295 void writeDILocalVariable(
const DILocalVariable *
N,
296 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
297 void writeDILabel(
const DILabel *
N, SmallVectorImpl<uint64_t> &Record,
301 void writeDIExpression(
const DIExpression *
N,
302 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
303 void writeDIGlobalVariableExpression(
const DIGlobalVariableExpression *
N,
304 SmallVectorImpl<uint64_t> &Record,
308 void writeDIObjCProperty(
const DIObjCProperty *
N,
309 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
310 void writeDIProperty(
const DIProperty *
N, SmallVectorImpl<uint64_t> &Record,
314 void writeDIImportedEntity(
const DIImportedEntity *
N,
315 SmallVectorImpl<uint64_t> &Record,
317 unsigned createMetadataStringsAbbrev();
319 SmallVectorImpl<uint64_t> &Record);
321 SmallVectorImpl<uint64_t> &Record,
322 std::vector<unsigned> *MDAbbrevs =
nullptr,
323 std::vector<uint64_t> *IndexPos =
nullptr);
324 void writeModuleMetadata();
325 void writeFunctionMetadata(
const Function &
F);
326 void writeFunctionMetadataAttachment(
const Function &
F);
327 void writeModuleMetadataKinds();
328 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
329 void writeModuleConstants();
330 bool pushValueAndType(
const Value *V,
unsigned InstID,
331 SmallVectorImpl<unsigned> &Vals);
332 void pushValue(
const Value *V,
unsigned InstID,
333 SmallVectorImpl<unsigned> &Vals);
334 void pushValueSigned(
const Value *V,
unsigned InstID,
335 SmallVectorImpl<uint64_t> &Vals);
336 void writeInstruction(
const Instruction &
I,
unsigned InstID,
337 SmallVectorImpl<unsigned> &Vals);
338 void writeFunctionLevelValueSymbolTable(
const ValueSymbolTable &VST);
340 void writeBlockInfo();
342 unsigned getEncodedSyncScopeID(
SyncScope::ID SSID) {
return unsigned(SSID); }
344 unsigned getEncodedAlign(MaybeAlign Alignment) {
return encode(Alignment); }
346 unsigned getTypeID(
Type *
T,
const Value *V =
nullptr);
351 unsigned getGlobalObjectValueTypeID(
Type *
T,
const GlobalObject *
G);
367 Stream->Emit((
unsigned)
'B', 8);
368 Stream->Emit((
unsigned)
'C', 8);
369 Stream->Emit(0x0, 4);
370 Stream->Emit(0xC, 4);
371 Stream->Emit(0xE, 4);
372 Stream->Emit(0xD, 4);
384 Triple TT(M.getTargetTriple());
385 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
394 Out.write((
char *)&Buffer.
front(), Buffer.
size());
400 auto Abbv = std::make_shared<BitCodeAbbrev>();
403 auto AbbrevNo = Stream->
EmitAbbrev(std::move(Abbv));
417 assert(M.isMaterialized());
418 Mods.push_back(
const_cast<Module *
>(&M));
421 ModuleWriter.
write();
432 case Instruction::Trunc:
434 case Instruction::ZExt:
436 case Instruction::SExt:
438 case Instruction::FPToUI:
440 case Instruction::FPToSI:
442 case Instruction::UIToFP:
444 case Instruction::SIToFP:
446 case Instruction::FPTrunc:
448 case Instruction::FPExt:
450 case Instruction::PtrToInt:
452 case Instruction::IntToPtr:
454 case Instruction::BitCast:
456 case Instruction::AddrSpaceCast:
465 case Instruction::FNeg:
474 case Instruction::Add:
475 case Instruction::FAdd:
477 case Instruction::Sub:
478 case Instruction::FSub:
480 case Instruction::Mul:
481 case Instruction::FMul:
483 case Instruction::UDiv:
485 case Instruction::FDiv:
486 case Instruction::SDiv:
488 case Instruction::URem:
490 case Instruction::FRem:
491 case Instruction::SRem:
493 case Instruction::Shl:
495 case Instruction::LShr:
497 case Instruction::AShr:
499 case Instruction::And:
501 case Instruction::Or:
503 case Instruction::Xor:
508unsigned DXILBitcodeWriter::getTypeID(
Type *
T,
const Value *V) {
512 return VE.getTypeID(
T);
513 auto It = PointerMap.
find(V);
514 if (It != PointerMap.
end())
515 return VE.getTypeID(It->second);
519 if (
T->isPointerTy())
520 return VE.getTypeID(I8PtrTy);
521 return VE.getTypeID(
T);
524unsigned DXILBitcodeWriter::getGlobalObjectValueTypeID(
Type *
T,
526 auto It = PointerMap.
find(
G);
527 if (It != PointerMap.
end()) {
531 return VE.getTypeID(
T);
593 unsigned AbbrevToUse) {
604 Stream.EmitRecord(Code, Vals, AbbrevToUse);
609 case Attribute::Alignment:
611 case Attribute::AlwaysInline:
613 case Attribute::Builtin:
615 case Attribute::ByVal:
617 case Attribute::Convergent:
619 case Attribute::InAlloca:
621 case Attribute::Cold:
623 case Attribute::InlineHint:
625 case Attribute::InReg:
627 case Attribute::JumpTable:
629 case Attribute::MinSize:
631 case Attribute::Naked:
633 case Attribute::Nest:
635 case Attribute::NoAlias:
637 case Attribute::NoBuiltin:
639 case Attribute::NoDuplicate:
641 case Attribute::NoImplicitFloat:
643 case Attribute::NoInline:
645 case Attribute::NonLazyBind:
647 case Attribute::NonNull:
649 case Attribute::Dereferenceable:
651 case Attribute::DereferenceableOrNull:
653 case Attribute::NoRedZone:
655 case Attribute::NoReturn:
657 case Attribute::NoUnwind:
659 case Attribute::OptimizeForSize:
661 case Attribute::OptimizeNone:
663 case Attribute::ReadNone:
665 case Attribute::ReadOnly:
667 case Attribute::Returned:
669 case Attribute::ReturnsTwice:
671 case Attribute::SExt:
673 case Attribute::StackAlignment:
675 case Attribute::StackProtect:
677 case Attribute::StackProtectReq:
679 case Attribute::StackProtectStrong:
681 case Attribute::SafeStack:
683 case Attribute::StructRet:
685 case Attribute::SanitizeAddress:
687 case Attribute::SanitizeThread:
689 case Attribute::SanitizeMemory:
691 case Attribute::UWTable:
693 case Attribute::ZExt:
704 "should be stripped in DXILPrepare");
724 unsigned NumWords =
A.getActiveWords();
725 const uint64_t *RawData =
A.getRawData();
726 for (
unsigned i = 0; i < NumWords; i++)
734 if (OBO->hasNoSignedWrap())
736 if (OBO->hasNoUnsignedWrap())
742 if (FPMO->hasAllowReassoc() || FPMO->hasAllowContract())
744 if (FPMO->hasNoNaNs())
746 if (FPMO->hasNoInfs())
748 if (FPMO->hasNoSignedZeros())
750 if (FPMO->hasAllowReciprocal())
831 switch (
C.getSelectionKind()) {
850void DXILBitcodeWriter::writeAttributeGroupTable() {
851 const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
852 VE.getAttributeGroups();
853 if (AttrGrps.empty())
860 unsigned AttrListIndex = Pair.first;
862 Record.push_back(
VE.getAttributeGroupID(Pair));
863 Record.push_back(AttrListIndex);
866 if (Attr.isEnumAttribute()) {
869 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
872 }
else if (Attr.isIntAttribute()) {
873 if (Attr.getKindAsEnum() == Attribute::AttrKind::Memory) {
891 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
894 Record.push_back(Attr.getValueAsInt());
897 StringRef
Kind = Attr.getKindAsString();
898 StringRef Val = Attr.getValueAsString();
917void DXILBitcodeWriter::writeAttributeTable() {
918 const std::vector<AttributeList> &
Attrs = VE.getAttributeLists();
924 SmallVector<uint64_t, 64>
Record;
925 for (AttributeList AL : Attrs) {
926 for (
unsigned i :
AL.indexes()) {
927 AttributeSet AS =
AL.getAttributes(i);
929 Record.push_back(VE.getAttributeGroupID({i, AS}));
940void DXILBitcodeWriter::writeTypeTable() {
944 SmallVector<uint64_t, 64> TypeVals;
946 uint64_t NumBits = VE.computeBitsRequiredForTypeIndices();
949 auto Abbv = std::make_shared<BitCodeAbbrev>();
952 Abbv->Add(BitCodeAbbrevOp(0));
953 unsigned PtrAbbrev = Stream.EmitAbbrev(std::move(Abbv));
956 Abbv = std::make_shared<BitCodeAbbrev>();
961 unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
964 Abbv = std::make_shared<BitCodeAbbrev>();
969 unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
972 Abbv = std::make_shared<BitCodeAbbrev>();
976 unsigned StructNameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
979 Abbv = std::make_shared<BitCodeAbbrev>();
984 unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
987 Abbv = std::make_shared<BitCodeAbbrev>();
991 unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
999 for (
Type *
T : TypeList) {
1000 int AbbrevToUse = 0;
1003 switch (
T->getTypeID()) {
1056 AbbrevToUse = PtrAbbrev;
1067 "dxilOpaquePtrReservedName", StructNameAbbrev);
1075 TypeVals.
push_back(getTypeID(FT->getReturnType()));
1076 for (
Type *PTy : FT->params())
1078 AbbrevToUse = FunctionAbbrev;
1086 for (
Type *ElTy :
ST->elements())
1089 if (
ST->isLiteral()) {
1091 AbbrevToUse = StructAnonAbbrev;
1093 if (
ST->isOpaque()) {
1097 AbbrevToUse = StructNamedAbbrev;
1101 if (!
ST->getName().empty())
1111 TypeVals.
push_back(AT->getNumElements());
1112 TypeVals.
push_back(getTypeID(AT->getElementType()));
1113 AbbrevToUse = ArrayAbbrev;
1121 TypeVals.
push_back(VT->getElementCount().getKnownMinValue());
1122 TypeVals.
push_back(getTypeID(VT->getElementType()));
1128 Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
1135void DXILBitcodeWriter::writeComdats() {
1137 for (
const Comdat *
C : VE.getComdats()) {
1140 size_t Size =
C->getName().size();
1143 for (
char Chr :
C->getName())
1150void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
1155void DXILBitcodeWriter::writeModuleInfo() {
1160 StringRef Triple =
"dxil-ms-dx";
1161 StringRef
DL =
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-"
1162 "f16:16-f32:32-f64:64-n8:16:32:64";
1171 std::map<std::string, unsigned> SectionMap;
1172 std::map<std::string, unsigned> GCMap;
1174 unsigned MaxGlobalType = 0;
1175 const auto UpdateMaxAlignment = [&
MaxAlignment](
const MaybeAlign
A) {
1179 for (
const GlobalVariable &GV : M.globals()) {
1180 UpdateMaxAlignment(GV.getAlign());
1183 MaxGlobalType = std::max(
1184 MaxGlobalType, getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1185 if (GV.hasSection()) {
1187 unsigned &
Entry = SectionMap[std::string(GV.getSection())];
1190 GV.getSection(), 0 );
1191 Entry = SectionMap.size();
1196 UpdateMaxAlignment(
F.getAlign());
1197 if (
F.hasSection()) {
1199 unsigned &
Entry = SectionMap[std::string(
F.getSection())];
1203 Entry = SectionMap.size();
1208 unsigned &
Entry = GCMap[
F.getGC()];
1212 Entry = GCMap.size();
1218 unsigned SimpleGVarAbbrev = 0;
1219 if (!M.global_empty()) {
1222 auto Abbv = std::make_shared<BitCodeAbbrev>();
1232 Abbv->Add(BitCodeAbbrevOp(0));
1234 unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1238 if (SectionMap.empty())
1239 Abbv->Add(BitCodeAbbrevOp(0));
1244 SimpleGVarAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1249 for (
const GlobalVariable &GV : M.globals()) {
1250 unsigned AbbrevToUse = 0;
1256 Vals.
push_back(getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1258 GV.getType()->getAddressSpace() << 2 | 2 |
1259 (GV.isConstant() ? 1 : 0));
1262 GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1));
1264 Vals.
push_back(getEncodedAlign(GV.getAlign()));
1265 Vals.
push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1267 if (GV.isThreadLocal() ||
1270 GV.isExternallyInitialized() ||
1276 Vals.
push_back(GV.isExternallyInitialized());
1278 Vals.
push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1280 AbbrevToUse = SimpleGVarAbbrev;
1289 const Function &
F = VE.getDXILFunction(OrigF);
1294 Vals.
push_back(getGlobalObjectValueTypeID(
F.getFunctionType(), &
F));
1298 Vals.
push_back(VE.getAttributeListID(
F.getAttributes()));
1299 Vals.
push_back(getEncodedAlign(
F.getAlign()));
1300 Vals.
push_back(
F.hasSection() ? SectionMap[std::string(
F.getSection())]
1306 F.hasPrologueData() ? (VE.getValueID(
F.getPrologueData()) + 1) : 0);
1308 Vals.
push_back(
F.hasComdat() ? VE.getComdatID(
F.getComdat()) : 0);
1309 Vals.
push_back(
F.hasPrefixData() ? (VE.getValueID(
F.getPrefixData()) + 1)
1312 F.hasPersonalityFn() ? (VE.getValueID(
F.getPersonalityFn()) + 1) : 0);
1314 unsigned AbbrevToUse = 0;
1320 for (
const GlobalAlias &
A : M.aliases()) {
1323 Vals.
push_back(VE.getValueID(
A.getAliasee()));
1329 unsigned AbbrevToUse = 0;
1335void DXILBitcodeWriter::writeValueAsMetadata(
1336 const ValueAsMetadata *MD, SmallVectorImpl<uint64_t> &Record) {
1339 Type *Ty =
V->getType();
1344 Record.push_back(getTypeID(Ty, V));
1345 Record.push_back(VE.getValueID(V));
1350void DXILBitcodeWriter::writeMDTuple(
const MDTuple *
N,
1351 SmallVectorImpl<uint64_t> &Record,
1353 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
1356 "Unexpected function-local metadata");
1357 Record.push_back(VE.getMetadataOrNullID(MD));
1365void DXILBitcodeWriter::writeDILocation(
const DILocation *
N,
1366 SmallVectorImpl<uint64_t> &Record,
1369 Abbrev = createDILocationAbbrev();
1370 Record.push_back(
N->isDistinct());
1371 Record.push_back(
N->getLine());
1372 Record.push_back(
N->getColumn());
1373 Record.push_back(VE.getMetadataID(
N->getScope()));
1374 Record.push_back(VE.getMetadataOrNullID(
N->getInlinedAt()));
1383 return I < 0 ? ~(U << 1) : U << 1;
1386void DXILBitcodeWriter::writeDISubrange(
const DISubrange *
N,
1387 SmallVectorImpl<uint64_t> &Record,
1389 Record.push_back(
N->isDistinct());
1395 Record.push_back(
Count->getValue().getSExtValue());
1401 DISubrange::BoundType
LowerBound =
N->getLowerBound();
1412void DXILBitcodeWriter::writeDIEnumerator(
const DIEnumerator *
N,
1413 SmallVectorImpl<uint64_t> &Record,
1415 Record.push_back(
N->isDistinct());
1417 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1423void DXILBitcodeWriter::writeDIBasicType(
const DIBasicType *
N,
1424 SmallVectorImpl<uint64_t> &Record,
1426 Record.push_back(
N->isDistinct());
1427 Record.push_back(
N->getTag());
1428 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1429 Record.push_back(
N->getSizeInBits());
1430 Record.push_back(
N->getAlignInBits());
1431 Record.push_back(
N->getEncoding());
1437void DXILBitcodeWriter::writeDIDerivedType(
const DIDerivedType *
N,
1438 SmallVectorImpl<uint64_t> &Record,
1440 Record.push_back(
N->isDistinct());
1441 Record.push_back(
N->getTag());
1442 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1443 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1444 Record.push_back(
N->getLine());
1445 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1446 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1447 Record.push_back(
N->getSizeInBits());
1448 Record.push_back(
N->getAlignInBits());
1449 Record.push_back(
N->getOffsetInBits());
1450 Record.push_back(
N->getFlags());
1451 Record.push_back(VE.getMetadataOrNullID(
N->getExtraData()));
1457void DXILBitcodeWriter::writeDICompositeType(
const DICompositeType *
N,
1458 SmallVectorImpl<uint64_t> &Record,
1460 Record.push_back(
N->isDistinct());
1461 Record.push_back(
N->getTag());
1462 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1463 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1464 Record.push_back(
N->getLine());
1465 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1466 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1467 Record.push_back(
N->getSizeInBits());
1468 Record.push_back(
N->getAlignInBits());
1469 Record.push_back(
N->getOffsetInBits());
1470 Record.push_back(
N->getFlags());
1471 Record.push_back(VE.getMetadataOrNullID(
N->getElements().get()));
1472 Record.push_back(
N->getRuntimeLang());
1473 Record.push_back(VE.getMetadataOrNullID(
N->getVTableHolder()));
1474 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1475 Record.push_back(VE.getMetadataOrNullID(
N->getRawIdentifier()));
1481void DXILBitcodeWriter::writeDISubroutineType(
const DISubroutineType *
N,
1482 SmallVectorImpl<uint64_t> &Record,
1484 Record.push_back(
N->isDistinct());
1485 Record.push_back(
N->getFlags());
1486 Record.push_back(VE.getMetadataOrNullID(
N->getTypeArray().get()));
1492void DXILBitcodeWriter::writeDIFile(
const DIFile *
N,
1493 SmallVectorImpl<uint64_t> &Record,
1495 Record.push_back(
N->isDistinct());
1496 Record.push_back(VE.getMetadataOrNullID(
N->getRawFilename()));
1497 Record.push_back(VE.getMetadataOrNullID(
N->getRawDirectory()));
1503void DXILBitcodeWriter::writeDICompileUnit(
const DICompileUnit *
N,
1504 SmallVectorImpl<uint64_t> &Record,
1506 Record.push_back(
N->isDistinct());
1507 Record.push_back(
N->getSourceLanguage().getUnversionedName());
1508 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1509 Record.push_back(VE.getMetadataOrNullID(
N->getRawProducer()));
1510 Record.push_back(
N->isOptimized());
1511 Record.push_back(VE.getMetadataOrNullID(
N->getRawFlags()));
1512 Record.push_back(
N->getRuntimeVersion());
1513 Record.push_back(VE.getMetadataOrNullID(
N->getRawSplitDebugFilename()));
1514 Record.push_back(
N->getEmissionKind());
1515 Record.push_back(VE.getMetadataOrNullID(
N->getEnumTypes().get()));
1516 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedTypes().get()));
1517 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1518 Record.push_back(VE.getMetadataOrNullID(
N->getGlobalVariables().get()));
1519 Record.push_back(VE.getMetadataOrNullID(
N->getImportedEntities().get()));
1520 Record.push_back(
N->getDWOId());
1526void DXILBitcodeWriter::writeDISubprogram(
const DISubprogram *
N,
1527 SmallVectorImpl<uint64_t> &Record,
1529 Record.push_back(
N->isDistinct());
1530 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1531 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1532 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1533 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1534 Record.push_back(
N->getLine());
1535 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1536 Record.push_back(
N->isLocalToUnit());
1537 Record.push_back(
N->isDefinition());
1538 Record.push_back(
N->getScopeLine());
1539 Record.push_back(VE.getMetadataOrNullID(
N->getContainingType()));
1540 Record.push_back(
N->getVirtuality());
1541 Record.push_back(
N->getVirtualIndex());
1542 Record.push_back(
N->getFlags());
1543 Record.push_back(
N->isOptimized());
1544 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1545 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1546 Record.push_back(VE.getMetadataOrNullID(
N->getDeclaration()));
1547 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedNodes().get()));
1553void DXILBitcodeWriter::writeDILexicalBlock(
const DILexicalBlock *
N,
1554 SmallVectorImpl<uint64_t> &Record,
1556 Record.push_back(
N->isDistinct());
1557 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1558 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1559 Record.push_back(
N->getLine());
1560 Record.push_back(
N->getColumn());
1566void DXILBitcodeWriter::writeDILexicalBlockFile(
1567 const DILexicalBlockFile *
N, SmallVectorImpl<uint64_t> &Record,
1569 Record.push_back(
N->isDistinct());
1570 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1571 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1572 Record.push_back(
N->getDiscriminator());
1578void DXILBitcodeWriter::writeDINamespace(
const DINamespace *
N,
1579 SmallVectorImpl<uint64_t> &Record,
1581 Record.push_back(
N->isDistinct());
1582 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1583 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1584 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1591void DXILBitcodeWriter::writeDIModule(
const DIModule *
N,
1592 SmallVectorImpl<uint64_t> &Record,
1594 Record.push_back(
N->isDistinct());
1595 for (
auto &
I :
N->operands())
1596 Record.push_back(VE.getMetadataOrNullID(
I));
1602void DXILBitcodeWriter::writeDITemplateTypeParameter(
1603 const DITemplateTypeParameter *
N, SmallVectorImpl<uint64_t> &Record,
1605 Record.push_back(
N->isDistinct());
1606 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1607 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1613void DXILBitcodeWriter::writeDITemplateValueParameter(
1614 const DITemplateValueParameter *
N, SmallVectorImpl<uint64_t> &Record,
1616 Record.push_back(
N->isDistinct());
1617 Record.push_back(
N->getTag());
1618 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1619 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1620 Record.push_back(VE.getMetadataOrNullID(
N->getValue()));
1626void DXILBitcodeWriter::writeDIGlobalVariable(
const DIGlobalVariable *
N,
1627 SmallVectorImpl<uint64_t> &Record,
1629 Record.push_back(
N->isDistinct());
1630 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1631 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1632 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1633 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1634 Record.push_back(
N->getLine());
1635 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1636 Record.push_back(
N->isLocalToUnit());
1637 Record.push_back(
N->isDefinition());
1638 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1639 Record.push_back(VE.getMetadataOrNullID(
N->getStaticDataMemberDeclaration()));
1645void DXILBitcodeWriter::writeDILocalVariable(
const DILocalVariable *
N,
1646 SmallVectorImpl<uint64_t> &Record,
1648 constexpr unsigned DW_TAG_auto_variable = 0x0100;
1649 constexpr unsigned DW_TAG_arg_variable = 0x0101;
1650 Record.push_back(
N->isDistinct());
1651 assert(
N->getTag() == dwarf::DW_TAG_variable);
1652 Record.push_back(
N->getArg() ? DW_TAG_arg_variable : DW_TAG_auto_variable);
1653 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1654 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1655 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1656 Record.push_back(
N->getLine());
1657 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1658 Record.push_back(
N->getArg());
1659 Record.push_back(
N->getFlags());
1665void DXILBitcodeWriter::writeDIExpression(
const DIExpression *
N,
1666 SmallVectorImpl<uint64_t> &Record,
1668 Record.reserve(
N->getElements().size() + 1);
1670 Record.push_back(
N->isDistinct());
1671 Record.append(
N->elements_begin(),
N->elements_end());
1677void DXILBitcodeWriter::writeDIObjCProperty(
const DIObjCProperty *
N,
1678 SmallVectorImpl<uint64_t> &Record,
1683void DXILBitcodeWriter::writeDIImportedEntity(
const DIImportedEntity *
N,
1684 SmallVectorImpl<uint64_t> &Record,
1686 Record.push_back(
N->isDistinct());
1687 Record.push_back(
N->getTag());
1688 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1689 Record.push_back(VE.getMetadataOrNullID(
N->getEntity()));
1690 Record.push_back(
N->getLine());
1691 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1697unsigned DXILBitcodeWriter::createDILocationAbbrev() {
1702 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1709 return Stream.EmitAbbrev(std::move(Abbv));
1712unsigned DXILBitcodeWriter::createGenericDINodeAbbrev() {
1717 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1725 return Stream.EmitAbbrev(std::move(Abbv));
1729 SmallVectorImpl<uint64_t> &Record,
1730 std::vector<unsigned> *MDAbbrevs,
1731 std::vector<uint64_t> *IndexPos) {
1736#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1737#include "llvm/IR/Metadata.def"
1741 IndexPos->push_back(Stream.GetCurrentBitNo());
1743 assert(
N->isResolved() &&
"Expected forward references to be resolved");
1745 switch (
N->getMetadataID()) {
1748#define HANDLE_MDNODE_LEAF(CLASS) \
1749 case Metadata::CLASS##Kind: \
1751 write##CLASS(cast<CLASS>(N), Record, \
1752 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1754 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1756#include "llvm/IR/Metadata.def"
1763unsigned DXILBitcodeWriter::createMetadataStringsAbbrev() {
1764 auto Abbv = std::make_shared<BitCodeAbbrev>();
1768 return Stream.EmitAbbrev(std::move(Abbv));
1771void DXILBitcodeWriter::writeMetadataStrings(
1773 if (Strings.
empty())
1776 unsigned MDSAbbrev = createMetadataStringsAbbrev();
1778 for (
const Metadata *MD : Strings) {
1789void DXILBitcodeWriter::writeModuleMetadata() {
1790 if (!VE.hasMDs() && M.named_metadata_empty())
1797 std::vector<unsigned> MDAbbrevs;
1800 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1801 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1802 createGenericDINodeAbbrev();
1804 unsigned NameAbbrev = 0;
1805 if (!M.named_metadata_empty()) {
1807 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1811 NameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1814 SmallVector<uint64_t, 64>
Record;
1815 writeMetadataStrings(VE.getMDStrings(), Record);
1817 std::vector<uint64_t> IndexPos;
1818 IndexPos.reserve(VE.getNonMDStrings().size());
1819 writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1822 for (
const NamedMDNode &NMD : M.named_metadata()) {
1824 StringRef Str = NMD.getName();
1825 Record.append(Str.bytes_begin(), Str.bytes_end());
1830 for (
const MDNode *
N : NMD.operands())
1831 Record.push_back(VE.getMetadataID(
N));
1839void DXILBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
1844 SmallVector<uint64_t, 64>
Record;
1845 writeMetadataStrings(VE.getMDStrings(), Record);
1846 writeMetadataRecords(VE.getNonMDStrings(), Record);
1850void DXILBitcodeWriter::writeFunctionMetadataAttachment(
const Function &
F) {
1853 SmallVector<uint64_t, 64>
Record;
1858 F.getAllMetadata(MDs);
1860 for (
const auto &
I : MDs) {
1861 if (
I.first == LLVMContext::MD_dbg)
1864 Record.push_back(VE.getMetadataID(
I.second));
1872 for (
const BasicBlock &BB :
F)
1873 for (
const Instruction &OrigI : BB) {
1877 I.getAllMetadataOtherThanDebugLoc(MDs);
1883 Record.push_back(VE.getInstructionID(&
I));
1885 for (
unsigned i = 0, e = MDs.size(); i != e; ++i) {
1886 Record.push_back(MDs[i].first);
1887 Record.push_back(VE.getMetadataID(MDs[i].second));
1896void DXILBitcodeWriter::writeModuleMetadataKinds() {
1897 SmallVector<uint64_t, 64>
Record;
1902 M.getMDKindNames(Names);
1909 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
1910 Record.push_back(MDKindID);
1911 StringRef KName = Names[MDKindID];
1921void DXILBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
1923 if (FirstVal == LastVal)
1928 unsigned AggregateAbbrev = 0;
1929 unsigned String8Abbrev = 0;
1930 unsigned CString7Abbrev = 0;
1931 unsigned CString6Abbrev = 0;
1935 auto Abbv = std::make_shared<BitCodeAbbrev>();
1940 AggregateAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1943 Abbv = std::make_shared<BitCodeAbbrev>();
1947 String8Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1949 Abbv = std::make_shared<BitCodeAbbrev>();
1953 CString7Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1955 Abbv = std::make_shared<BitCodeAbbrev>();
1959 CString6Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1962 SmallVector<uint64_t, 64>
Record;
1965 Type *LastTy =
nullptr;
1966 for (
unsigned i = FirstVal; i != LastVal; ++i) {
1967 const Value *
V = Vals[i].first;
1969 if (
V->getType() != LastTy) {
1970 LastTy =
V->getType();
1971 Record.push_back(getTypeID(LastTy, V));
1973 CONSTANTS_SETTYPE_ABBREV);
1978 Record.push_back(
unsigned(
IA->hasSideEffects()) |
1979 unsigned(
IA->isAlignStack()) << 1 |
1980 unsigned(
IA->getDialect() & 1) << 2);
1983 StringRef AsmStr =
IA->getAsmString();
1988 StringRef ConstraintStr =
IA->getConstraintString();
1996 unsigned Code = -1U;
1997 unsigned AbbrevToUse = 0;
1998 if (
C->isNullValue()) {
2003 if (
IV->getBitWidth() <= 64) {
2007 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2013 unsigned NWords =
IV->getValue().getActiveWords();
2014 const uint64_t *RawWords =
IV->getValue().getRawData();
2015 for (
unsigned i = 0; i != NWords; ++i) {
2023 if (BV->getBitWidth() <= 64) {
2027 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2029 unsigned NWords = BV->getValue().getActiveWords();
2030 const uint64_t *RawWords = BV->getValue().getRawData();
2031 for (
unsigned i = 0; i != NWords; ++i) {
2040 Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2044 APInt api = CFP->getValueAPF().bitcastToAPInt();
2046 Record.push_back((p[1] << 48) | (p[0] >> 16));
2047 Record.push_back(p[0] & 0xffffLL);
2049 APInt api = CFP->getValueAPF().bitcastToAPInt();
2054 assert(0 &&
"Unknown FP type!");
2060 unsigned NumElts = Str->getNumElements();
2062 if (Str->isCString()) {
2067 AbbrevToUse = String8Abbrev;
2071 for (
unsigned i = 0; i != NumElts; ++i) {
2072 unsigned char V = Str->getElementAsInteger(i);
2074 isCStr7 &= (
V & 128) == 0;
2080 AbbrevToUse = CString6Abbrev;
2082 AbbrevToUse = CString7Abbrev;
2083 }
else if (
const ConstantDataSequential *CDS =
2086 Type *EltTy = CDS->getElementType();
2088 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2089 Record.push_back(CDS->getElementAsInteger(i));
2091 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2096 F = CDS->getElementAsFloat(i);
2101 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2106 F = CDS->getElementAsDouble(i);
2113 for (
const Value *
Op :
C->operands())
2114 Record.push_back(VE.getValueID(
Op));
2115 AbbrevToUse = AggregateAbbrev;
2117 switch (
CE->getOpcode()) {
2123 getTypeID(
C->getOperand(0)->getType(),
C->getOperand(0)));
2124 Record.push_back(VE.getValueID(
C->getOperand(0)));
2125 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2127 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2130 Record.push_back(VE.getValueID(
C->getOperand(0)));
2131 Record.push_back(VE.getValueID(
C->getOperand(1)));
2137 case Instruction::GetElementPtr: {
2140 if (GO->isInBounds())
2142 Record.push_back(getTypeID(GO->getSourceElementType()));
2143 for (
unsigned i = 0, e =
CE->getNumOperands(); i != e; ++i) {
2145 getTypeID(
C->getOperand(i)->getType(),
C->getOperand(i)));
2146 Record.push_back(VE.getValueID(
C->getOperand(i)));
2150 case Instruction::Select:
2152 Record.push_back(VE.getValueID(
C->getOperand(0)));
2153 Record.push_back(VE.getValueID(
C->getOperand(1)));
2154 Record.push_back(VE.getValueID(
C->getOperand(2)));
2156 case Instruction::ExtractElement:
2158 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2159 Record.push_back(VE.getValueID(
C->getOperand(0)));
2160 Record.push_back(getTypeID(
C->getOperand(1)->getType()));
2161 Record.push_back(VE.getValueID(
C->getOperand(1)));
2163 case Instruction::InsertElement:
2165 Record.push_back(VE.getValueID(
C->getOperand(0)));
2166 Record.push_back(VE.getValueID(
C->getOperand(1)));
2167 Record.push_back(getTypeID(
C->getOperand(2)->getType()));
2168 Record.push_back(VE.getValueID(
C->getOperand(2)));
2170 case Instruction::ShuffleVector:
2175 if (
C->getType() ==
C->getOperand(0)->getType()) {
2179 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2181 Record.push_back(VE.getValueID(
C->getOperand(0)));
2182 Record.push_back(VE.getValueID(
C->getOperand(1)));
2183 Record.push_back(VE.getValueID(
C->getOperand(2)));
2188 Record.push_back(getTypeID(BA->getFunction()->getType()));
2189 Record.push_back(VE.getValueID(BA->getFunction()));
2190 Record.push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2197 Stream.EmitRecord(Code, Record, AbbrevToUse);
2204void DXILBitcodeWriter::writeModuleConstants() {
2209 for (
unsigned i = 0, e = Vals.size(); i != e; ++i) {
2211 writeConstants(i, Vals.size(),
true);
2225bool DXILBitcodeWriter::pushValueAndType(
const Value *V,
unsigned InstID,
2226 SmallVectorImpl<unsigned> &Vals) {
2227 unsigned ValID = VE.getValueID(V);
2230 if (ValID >= InstID) {
2239void DXILBitcodeWriter::pushValue(
const Value *V,
unsigned InstID,
2240 SmallVectorImpl<unsigned> &Vals) {
2241 unsigned ValID = VE.getValueID(V);
2245void DXILBitcodeWriter::pushValueSigned(
const Value *V,
unsigned InstID,
2246 SmallVectorImpl<uint64_t> &Vals) {
2247 unsigned ValID = VE.getValueID(V);
2248 int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2253void DXILBitcodeWriter::writeInstruction(
const Instruction &
I,
unsigned InstID,
2254 SmallVectorImpl<unsigned> &Vals) {
2256 unsigned AbbrevToUse = 0;
2257 VE.setInstructionID(&
I);
2258 switch (
I.getOpcode()) {
2262 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2263 AbbrevToUse = (unsigned)FUNCTION_INST_CAST_ABBREV;
2269 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2270 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_ABBREV;
2271 pushValue(
I.getOperand(1), InstID, Vals);
2275 if (AbbrevToUse == (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2276 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV;
2282 case Instruction::GetElementPtr: {
2284 AbbrevToUse = (unsigned)FUNCTION_INST_GEP_ABBREV;
2287 Vals.
push_back(getTypeID(GEPInst.getSourceElementType()));
2288 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i)
2289 pushValueAndType(
I.getOperand(i), InstID, Vals);
2292 case Instruction::ExtractValue: {
2294 pushValueAndType(
I.getOperand(0), InstID, Vals);
2299 case Instruction::InsertValue: {
2301 pushValueAndType(
I.getOperand(0), InstID, Vals);
2302 pushValueAndType(
I.getOperand(1), InstID, Vals);
2307 case Instruction::Select:
2309 pushValueAndType(
I.getOperand(1), InstID, Vals);
2310 pushValue(
I.getOperand(2), InstID, Vals);
2311 pushValueAndType(
I.getOperand(0), InstID, Vals);
2313 case Instruction::ExtractElement:
2315 pushValueAndType(
I.getOperand(0), InstID, Vals);
2316 pushValueAndType(
I.getOperand(1), InstID, Vals);
2318 case Instruction::InsertElement:
2320 pushValueAndType(
I.getOperand(0), InstID, Vals);
2321 pushValue(
I.getOperand(1), InstID, Vals);
2322 pushValueAndType(
I.getOperand(2), InstID, Vals);
2324 case Instruction::ShuffleVector:
2326 pushValueAndType(
I.getOperand(0), InstID, Vals);
2327 pushValue(
I.getOperand(1), InstID, Vals);
2331 case Instruction::ICmp:
2332 case Instruction::FCmp: {
2335 pushValueAndType(
I.getOperand(0), InstID, Vals);
2336 pushValue(
I.getOperand(1), InstID, Vals);
2344 case Instruction::Ret: {
2346 unsigned NumOperands =
I.getNumOperands();
2347 if (NumOperands == 0)
2348 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VOID_ABBREV;
2349 else if (NumOperands == 1) {
2350 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2351 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VAL_ABBREV;
2353 for (
unsigned i = 0, e = NumOperands; i !=
e; ++i)
2354 pushValueAndType(
I.getOperand(i), InstID, Vals);
2357 case Instruction::UncondBr:
2361 case Instruction::CondBr: {
2364 Vals.
push_back(VE.getValueID(
II.getSuccessor(0)));
2365 Vals.
push_back(VE.getValueID(
II.getSuccessor(1)));
2366 pushValue(
II.getCondition(), InstID, Vals);
2368 case Instruction::Switch: {
2371 Vals.
push_back(getTypeID(
SI.getCondition()->getType()));
2372 pushValue(
SI.getCondition(), InstID, Vals);
2373 Vals.
push_back(VE.getValueID(
SI.getDefaultDest()));
2374 for (
auto Case :
SI.cases()) {
2375 Vals.
push_back(VE.getValueID(Case.getCaseValue()));
2376 Vals.
push_back(VE.getValueID(Case.getCaseSuccessor()));
2379 case Instruction::IndirectBr:
2381 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2383 pushValue(
I.getOperand(0), InstID, Vals);
2384 for (
unsigned i = 1, e =
I.getNumOperands(); i != e; ++i)
2385 Vals.
push_back(VE.getValueID(
I.getOperand(i)));
2388 case Instruction::Invoke: {
2391 FunctionType *FTy =
II->getFunctionType();
2394 Vals.
push_back(VE.getAttributeListID(
II->getAttributes()));
2396 Vals.
push_back(VE.getValueID(
II->getNormalDest()));
2397 Vals.
push_back(VE.getValueID(
II->getUnwindDest()));
2399 pushValueAndType(Callee, InstID, Vals);
2402 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2403 pushValue(
I.getOperand(i), InstID, Vals);
2406 if (FTy->isVarArg()) {
2407 for (
unsigned i = FTy->getNumParams(), e =
I.getNumOperands() - 3; i != e;
2409 pushValueAndType(
I.getOperand(i), InstID, Vals);
2413 case Instruction::Resume:
2415 pushValueAndType(
I.getOperand(0), InstID, Vals);
2417 case Instruction::Unreachable:
2419 AbbrevToUse = (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV;
2422 case Instruction::PHI: {
2435 Stream.EmitRecord(Code, Vals64, AbbrevToUse);
2440 case Instruction::LandingPad: {
2451 pushValueAndType(LP.
getClause(
I), InstID, Vals);
2456 case Instruction::Alloca: {
2460 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2461 Vals.
push_back(VE.getValueID(
I.getOperand(0)));
2463 assert(AlignRecord < 1 << 5 &&
"alignment greater than 1 << 64");
2465 AlignRecord |= 1 << 6;
2470 case Instruction::Load:
2473 pushValueAndType(
I.getOperand(0), InstID, Vals);
2476 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2477 AbbrevToUse = (unsigned)FUNCTION_INST_LOAD_ABBREV;
2487 case Instruction::Store:
2492 pushValueAndType(
I.getOperand(1), InstID, Vals);
2493 pushValueAndType(
I.getOperand(0), InstID, Vals);
2502 case Instruction::AtomicCmpXchg:
2504 pushValueAndType(
I.getOperand(0), InstID, Vals);
2505 pushValueAndType(
I.getOperand(1), InstID, Vals);
2506 pushValue(
I.getOperand(2), InstID, Vals);
2516 case Instruction::AtomicRMW:
2518 pushValueAndType(
I.getOperand(0), InstID, Vals);
2519 pushValue(
I.getOperand(1), InstID, Vals);
2527 case Instruction::Fence:
2532 case Instruction::Call: {
2545 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
2547 if (FTy->getParamType(i)->isLabelTy())
2554 if (FTy->isVarArg()) {
2555 for (
unsigned i = FTy->getNumParams(), e = CI.
arg_size(); i != e; ++i)
2560 case Instruction::VAArg:
2562 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2563 pushValue(
I.getOperand(0), InstID, Vals);
2568 Stream.EmitRecord(Code, Vals, AbbrevToUse);
2573void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
2574 const ValueSymbolTable &VST) {
2586 for (
auto &VI : VST) {
2587 const Value &
V = VE.getDXILValue(*
VI.second);
2592 return A->first() <
B->first();
2595 for (
const ValueName *SI : SortedTable) {
2600 bool isChar6 =
true;
2601 for (
const char *
C =
Name.getKeyData(), *
E =
C +
Name.getKeyLength();
2605 if ((
unsigned char)*
C & 128) {
2611 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2619 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2623 AbbrevToUse = VST_ENTRY_6_ABBREV;
2625 AbbrevToUse = VST_ENTRY_7_ABBREV;
2628 NameVals.
push_back(VE.getValueID(
SI->getValue()));
2629 for (
const char *
P =
Name.getKeyData(),
2630 *
E =
Name.getKeyData() +
Name.getKeyLength();
2635 Stream.EmitRecord(Code, NameVals, AbbrevToUse);
2642void DXILBitcodeWriter::writeFunction(
const Function &
F) {
2644 VE.incorporateFunction(
F);
2650 Vals.
push_back(VE.getBasicBlocks().size());
2655 unsigned CstStart, CstEnd;
2656 VE.getFunctionConstantRange(CstStart, CstEnd);
2657 writeConstants(CstStart, CstEnd,
false);
2660 writeFunctionMetadata(
F);
2663 unsigned InstID = CstEnd;
2665 bool NeedsMetadataAttachment =
F.hasMetadata();
2667 DILocation *LastDL =
nullptr;
2675 writeInstruction(
I, InstID, Vals);
2677 if (!
I.getType()->isVoidTy())
2681 NeedsMetadataAttachment |=
I.hasMetadataOtherThanDebugLoc();
2684 DILocation *
DL =
I.getDebugLoc();
2696 Vals.
push_back(VE.getMetadataOrNullID(
DL->getScope()));
2697 Vals.
push_back(VE.getMetadataOrNullID(
DL->getInlinedAt()));
2705 if (
auto *Symtab =
F.getValueSymbolTable())
2706 writeFunctionLevelValueSymbolTable(*Symtab);
2708 if (NeedsMetadataAttachment)
2709 writeFunctionMetadataAttachment(
F);
2716void DXILBitcodeWriter::writeBlockInfo() {
2720 Stream.EnterBlockInfoBlock();
2723 auto Abbv = std::make_shared<BitCodeAbbrev>();
2729 std::move(Abbv)) != VST_ENTRY_8_ABBREV)
2730 assert(
false &&
"Unexpected abbrev ordering!");
2734 auto Abbv = std::make_shared<BitCodeAbbrev>();
2740 std::move(Abbv)) != VST_ENTRY_7_ABBREV)
2741 assert(
false &&
"Unexpected abbrev ordering!");
2744 auto Abbv = std::make_shared<BitCodeAbbrev>();
2750 std::move(Abbv)) != VST_ENTRY_6_ABBREV)
2751 assert(
false &&
"Unexpected abbrev ordering!");
2754 auto Abbv = std::make_shared<BitCodeAbbrev>();
2760 std::move(Abbv)) != VST_BBENTRY_6_ABBREV)
2761 assert(
false &&
"Unexpected abbrev ordering!");
2765 auto Abbv = std::make_shared<BitCodeAbbrev>();
2768 VE.computeBitsRequiredForTypeIndices()));
2770 CONSTANTS_SETTYPE_ABBREV)
2771 assert(
false &&
"Unexpected abbrev ordering!");
2775 auto Abbv = std::make_shared<BitCodeAbbrev>();
2779 CONSTANTS_INTEGER_ABBREV)
2780 assert(
false &&
"Unexpected abbrev ordering!");
2784 auto Abbv = std::make_shared<BitCodeAbbrev>();
2788 VE.computeBitsRequiredForTypeIndices()));
2792 CONSTANTS_CE_CAST_Abbrev)
2793 assert(
false &&
"Unexpected abbrev ordering!");
2796 auto Abbv = std::make_shared<BitCodeAbbrev>();
2799 CONSTANTS_NULL_Abbrev)
2800 assert(
false &&
"Unexpected abbrev ordering!");
2806 auto Abbv = std::make_shared<BitCodeAbbrev>();
2810 VE.computeBitsRequiredForTypeIndices()));
2814 (
unsigned)FUNCTION_INST_LOAD_ABBREV)
2815 assert(
false &&
"Unexpected abbrev ordering!");
2818 auto Abbv = std::make_shared<BitCodeAbbrev>();
2824 (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2825 assert(
false &&
"Unexpected abbrev ordering!");
2828 auto Abbv = std::make_shared<BitCodeAbbrev>();
2835 (
unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV)
2836 assert(
false &&
"Unexpected abbrev ordering!");
2839 auto Abbv = std::make_shared<BitCodeAbbrev>();
2843 VE.computeBitsRequiredForTypeIndices()));
2846 (
unsigned)FUNCTION_INST_CAST_ABBREV)
2847 assert(
false &&
"Unexpected abbrev ordering!");
2851 auto Abbv = std::make_shared<BitCodeAbbrev>();
2854 (
unsigned)FUNCTION_INST_RET_VOID_ABBREV)
2855 assert(
false &&
"Unexpected abbrev ordering!");
2858 auto Abbv = std::make_shared<BitCodeAbbrev>();
2862 (
unsigned)FUNCTION_INST_RET_VAL_ABBREV)
2863 assert(
false &&
"Unexpected abbrev ordering!");
2866 auto Abbv = std::make_shared<BitCodeAbbrev>();
2869 (
unsigned)FUNCTION_INST_UNREACHABLE_ABBREV)
2870 assert(
false &&
"Unexpected abbrev ordering!");
2873 auto Abbv = std::make_shared<BitCodeAbbrev>();
2881 (
unsigned)FUNCTION_INST_GEP_ABBREV)
2882 assert(
false &&
"Unexpected abbrev ordering!");
2888void DXILBitcodeWriter::writeModuleVersion() {
2903 DXILBitcodeWriter::writeModuleVersion();
2909 writeAttributeGroupTable();
2912 writeAttributeTable();
2924 writeModuleConstants();
2927 writeModuleMetadataKinds();
2930 writeModuleMetadata();
2935 writeFunctionLevelValueSymbolTable(M.getValueSymbolTable());
2939 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.