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;
121 uint64_t VSTOffsetPlaceholder = 0;
127 uint64_t BitcodeStartBit;
143 StrtabBuilder(StrtabBuilder), M(M), VE(M, I8PtrTy, DebugInfo),
144 Buffer(Buffer), BitcodeStartBit(Stream.GetCurrentBitNo()),
146 GlobalValueId = VE.getValues().
size();
148 for (
auto El : PointerMap)
149 VE.EnumerateType(El.second);
176 void writeModuleVersion();
177 void writePerModuleGlobalValueSummary();
182 unsigned FSCallsAbbrev,
183 unsigned FSCallsProfileAbbrev,
187 unsigned FSModRefsAbbrev,
188 unsigned FSModVTableRefsAbbrev);
191 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
195 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
198 assert(VMI != GUIDToValueIdMap.end() &&
199 "GUID does not have assigned value Id");
205 if (!VI.haveGVs() || !VI.getValue())
206 return getValueId(VI.getGUID());
207 return VE.getValueID(VI.getValue());
210 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
212 uint64_t bitcodeStartBit() {
return BitcodeStartBit; }
214 size_t addToStrtab(StringRef Str);
216 unsigned createDILocationAbbrev();
217 unsigned createGenericDINodeAbbrev();
219 void writeAttributeGroupTable();
220 void writeAttributeTable();
221 void writeTypeTable();
223 void writeValueSymbolTableForwardDecl();
224 void writeModuleInfo();
225 void writeValueAsMetadata(
const ValueAsMetadata *MD,
226 SmallVectorImpl<uint64_t> &Record);
227 void writeMDTuple(
const MDTuple *
N, SmallVectorImpl<uint64_t> &Record,
229 void writeDILocation(
const DILocation *
N, SmallVectorImpl<uint64_t> &Record,
231 void writeGenericDINode(
const GenericDINode *
N,
232 SmallVectorImpl<uint64_t> &Record,
unsigned &Abbrev) {
235 void writeDISubrange(
const DISubrange *
N, SmallVectorImpl<uint64_t> &Record,
237 void writeDIGenericSubrange(
const DIGenericSubrange *
N,
238 SmallVectorImpl<uint64_t> &Record,
242 void writeDIEnumerator(
const DIEnumerator *
N,
243 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
244 void writeDIBasicType(
const DIBasicType *
N, SmallVectorImpl<uint64_t> &Record,
246 void writeDIFixedPointType(
const DIFixedPointType *
N,
247 SmallVectorImpl<uint64_t> &Record,
251 void writeDIStringType(
const DIStringType *
N,
252 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
255 void writeDIDerivedType(
const DIDerivedType *
N,
256 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
257 void writeDISubrangeType(
const DISubrangeType *
N,
258 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
261 void writeDICompositeType(
const DICompositeType *
N,
262 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
263 void writeDISubroutineType(
const DISubroutineType *
N,
264 SmallVectorImpl<uint64_t> &Record,
266 void writeDIFile(
const DIFile *
N, SmallVectorImpl<uint64_t> &Record,
268 void writeDICompileUnit(
const DICompileUnit *
N,
269 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
270 void writeDISubprogram(
const DISubprogram *
N,
271 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
272 void writeDILexicalBlock(
const DILexicalBlock *
N,
273 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
274 void writeDILexicalBlockFile(
const DILexicalBlockFile *
N,
275 SmallVectorImpl<uint64_t> &Record,
277 void writeDICommonBlock(
const DICommonBlock *
N,
278 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
281 void writeDINamespace(
const DINamespace *
N, SmallVectorImpl<uint64_t> &Record,
283 void writeDIMacro(
const DIMacro *
N, SmallVectorImpl<uint64_t> &Record,
287 void writeDIMacroFile(
const DIMacroFile *
N, SmallVectorImpl<uint64_t> &Record,
291 void writeDIArgList(
const DIArgList *
N, SmallVectorImpl<uint64_t> &Record,
295 void writeDIAssignID(
const DIAssignID *
N, SmallVectorImpl<uint64_t> &Record,
302 void writeDIModule(
const DIModule *
N, SmallVectorImpl<uint64_t> &Record,
304 void writeDITemplateTypeParameter(
const DITemplateTypeParameter *
N,
305 SmallVectorImpl<uint64_t> &Record,
307 void writeDITemplateValueParameter(
const DITemplateValueParameter *
N,
308 SmallVectorImpl<uint64_t> &Record,
310 void writeDIGlobalVariable(
const DIGlobalVariable *
N,
311 SmallVectorImpl<uint64_t> &Record,
313 void writeDILocalVariable(
const DILocalVariable *
N,
314 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
315 void writeDILabel(
const DILabel *
N, SmallVectorImpl<uint64_t> &Record,
319 void writeDIExpression(
const DIExpression *
N,
320 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
321 void writeDIGlobalVariableExpression(
const DIGlobalVariableExpression *
N,
322 SmallVectorImpl<uint64_t> &Record,
326 void writeDIObjCProperty(
const DIObjCProperty *
N,
327 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
328 void writeDIProperty(
const DIProperty *
N, SmallVectorImpl<uint64_t> &Record,
332 void writeDIImportedEntity(
const DIImportedEntity *
N,
333 SmallVectorImpl<uint64_t> &Record,
335 unsigned createNamedMetadataAbbrev();
336 void writeNamedMetadata(SmallVectorImpl<uint64_t> &Record);
337 unsigned createMetadataStringsAbbrev();
339 SmallVectorImpl<uint64_t> &Record);
341 SmallVectorImpl<uint64_t> &Record,
342 std::vector<unsigned> *MDAbbrevs =
nullptr,
343 std::vector<uint64_t> *IndexPos =
nullptr);
344 void writeModuleMetadata();
345 void writeFunctionMetadata(
const Function &
F);
346 void writeFunctionMetadataAttachment(
const Function &
F);
347 void pushGlobalMetadataAttachment(SmallVectorImpl<uint64_t> &Record,
348 const GlobalObject &GO);
349 void writeModuleMetadataKinds();
350 void writeOperandBundleTags();
351 void writeSyncScopeNames();
352 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
353 void writeModuleConstants();
354 bool pushValueAndType(
const Value *V,
unsigned InstID,
355 SmallVectorImpl<unsigned> &Vals);
356 void writeOperandBundles(
const CallBase &CB,
unsigned InstID);
357 void pushValue(
const Value *V,
unsigned InstID,
358 SmallVectorImpl<unsigned> &Vals);
359 void pushValueSigned(
const Value *V,
unsigned InstID,
360 SmallVectorImpl<uint64_t> &Vals);
361 void writeInstruction(
const Instruction &
I,
unsigned InstID,
362 SmallVectorImpl<unsigned> &Vals);
363 void writeFunctionLevelValueSymbolTable(
const ValueSymbolTable &VST);
364 void writeGlobalValueSymbolTable(
365 DenseMap<const Function *, uint64_t> &FunctionToBitcodeIndex);
367 void writeBlockInfo();
369 unsigned getEncodedSyncScopeID(
SyncScope::ID SSID) {
return unsigned(SSID); }
371 unsigned getEncodedAlign(MaybeAlign Alignment) {
return encode(Alignment); }
373 unsigned getTypeID(
Type *
T,
const Value *V =
nullptr);
378 unsigned getGlobalObjectValueTypeID(
Type *
T,
const GlobalObject *
G);
394 Stream->Emit((
unsigned)
'B', 8);
395 Stream->Emit((
unsigned)
'C', 8);
396 Stream->Emit(0x0, 4);
397 Stream->Emit(0xC, 4);
398 Stream->Emit(0xE, 4);
399 Stream->Emit(0xD, 4);
412 Triple TT(M.getTargetTriple());
413 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
427 auto Abbv = std::make_shared<BitCodeAbbrev>();
430 auto AbbrevNo = Stream->
EmitAbbrev(std::move(Abbv));
444 assert(M.isMaterialized());
445 Mods.push_back(
const_cast<Module *
>(&M));
448 ModuleWriter.
write();
459 case Instruction::Trunc:
461 case Instruction::ZExt:
463 case Instruction::SExt:
465 case Instruction::FPToUI:
467 case Instruction::FPToSI:
469 case Instruction::UIToFP:
471 case Instruction::SIToFP:
473 case Instruction::FPTrunc:
475 case Instruction::FPExt:
477 case Instruction::PtrToInt:
479 case Instruction::IntToPtr:
481 case Instruction::BitCast:
483 case Instruction::AddrSpaceCast:
492 case Instruction::FNeg:
501 case Instruction::Add:
502 case Instruction::FAdd:
504 case Instruction::Sub:
505 case Instruction::FSub:
507 case Instruction::Mul:
508 case Instruction::FMul:
510 case Instruction::UDiv:
512 case Instruction::FDiv:
513 case Instruction::SDiv:
515 case Instruction::URem:
517 case Instruction::FRem:
518 case Instruction::SRem:
520 case Instruction::Shl:
522 case Instruction::LShr:
524 case Instruction::AShr:
526 case Instruction::And:
528 case Instruction::Or:
530 case Instruction::Xor:
535unsigned DXILBitcodeWriter::getTypeID(
Type *
T,
const Value *V) {
539 return VE.getTypeID(
T);
540 auto It = PointerMap.
find(V);
541 if (It != PointerMap.
end())
542 return VE.getTypeID(It->second);
546 if (
T->isPointerTy())
547 return VE.getTypeID(I8PtrTy);
548 return VE.getTypeID(
T);
551unsigned DXILBitcodeWriter::getGlobalObjectValueTypeID(
Type *
T,
553 auto It = PointerMap.
find(
G);
554 if (It != PointerMap.
end()) {
558 return VE.getTypeID(
T);
620 unsigned AbbrevToUse) {
631 Stream.EmitRecord(Code, Vals, AbbrevToUse);
636 case Attribute::Alignment:
638 case Attribute::AlwaysInline:
640 case Attribute::Builtin:
642 case Attribute::ByVal:
644 case Attribute::Convergent:
646 case Attribute::InAlloca:
648 case Attribute::Cold:
650 case Attribute::InlineHint:
652 case Attribute::InReg:
654 case Attribute::JumpTable:
656 case Attribute::MinSize:
658 case Attribute::Naked:
660 case Attribute::Nest:
662 case Attribute::NoAlias:
664 case Attribute::NoBuiltin:
666 case Attribute::NoDuplicate:
668 case Attribute::NoImplicitFloat:
670 case Attribute::NoInline:
672 case Attribute::NonLazyBind:
674 case Attribute::NonNull:
676 case Attribute::Dereferenceable:
678 case Attribute::DereferenceableOrNull:
680 case Attribute::NoRedZone:
682 case Attribute::NoReturn:
684 case Attribute::NoUnwind:
686 case Attribute::OptimizeForSize:
688 case Attribute::OptimizeNone:
690 case Attribute::ReadNone:
692 case Attribute::ReadOnly:
694 case Attribute::Returned:
696 case Attribute::ReturnsTwice:
698 case Attribute::SExt:
700 case Attribute::StackAlignment:
702 case Attribute::StackProtect:
704 case Attribute::StackProtectReq:
706 case Attribute::StackProtectStrong:
708 case Attribute::SafeStack:
710 case Attribute::StructRet:
712 case Attribute::SanitizeAddress:
714 case Attribute::SanitizeThread:
716 case Attribute::SanitizeMemory:
718 case Attribute::UWTable:
720 case Attribute::ZExt:
731 "should be stripped in DXILPrepare");
751 unsigned NumWords =
A.getActiveWords();
752 const uint64_t *RawData =
A.getRawData();
753 for (
unsigned i = 0; i < NumWords; i++)
761 if (OBO->hasNoSignedWrap())
763 if (OBO->hasNoUnsignedWrap())
769 if (FPMO->hasAllowReassoc() || FPMO->hasAllowContract())
771 if (FPMO->hasNoNaNs())
773 if (FPMO->hasNoInfs())
775 if (FPMO->hasNoSignedZeros())
777 if (FPMO->hasAllowReciprocal())
858 switch (
C.getSelectionKind()) {
877void DXILBitcodeWriter::writeAttributeGroupTable() {
878 const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
879 VE.getAttributeGroups();
880 if (AttrGrps.empty())
887 unsigned AttrListIndex = Pair.first;
889 Record.push_back(
VE.getAttributeGroupID(Pair));
890 Record.push_back(AttrListIndex);
893 if (Attr.isEnumAttribute()) {
896 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
899 }
else if (Attr.isIntAttribute()) {
900 if (Attr.getKindAsEnum() == Attribute::AttrKind::Memory) {
918 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
921 Record.push_back(Attr.getValueAsInt());
924 StringRef
Kind = Attr.getKindAsString();
925 StringRef Val = Attr.getValueAsString();
944void DXILBitcodeWriter::writeAttributeTable() {
945 const std::vector<AttributeList> &
Attrs = VE.getAttributeLists();
951 SmallVector<uint64_t, 64>
Record;
952 for (AttributeList AL : Attrs) {
953 for (
unsigned i :
AL.indexes()) {
954 AttributeSet AS =
AL.getAttributes(i);
956 Record.push_back(VE.getAttributeGroupID({i, AS}));
967void DXILBitcodeWriter::writeTypeTable() {
971 SmallVector<uint64_t, 64> TypeVals;
973 uint64_t NumBits = VE.computeBitsRequiredForTypeIndices();
976 auto Abbv = std::make_shared<BitCodeAbbrev>();
979 Abbv->Add(BitCodeAbbrevOp(0));
980 unsigned PtrAbbrev = Stream.EmitAbbrev(std::move(Abbv));
983 Abbv = std::make_shared<BitCodeAbbrev>();
988 unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
991 Abbv = std::make_shared<BitCodeAbbrev>();
996 unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
999 Abbv = std::make_shared<BitCodeAbbrev>();
1003 unsigned StructNameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1006 Abbv = std::make_shared<BitCodeAbbrev>();
1011 unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1014 Abbv = std::make_shared<BitCodeAbbrev>();
1018 unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1026 for (
Type *
T : TypeList) {
1027 int AbbrevToUse = 0;
1030 switch (
T->getTypeID()) {
1083 AbbrevToUse = PtrAbbrev;
1094 "dxilOpaquePtrReservedName", StructNameAbbrev);
1102 TypeVals.
push_back(getTypeID(FT->getReturnType()));
1103 for (
Type *PTy : FT->params())
1105 AbbrevToUse = FunctionAbbrev;
1113 for (
Type *ElTy :
ST->elements())
1116 if (
ST->isLiteral()) {
1118 AbbrevToUse = StructAnonAbbrev;
1120 if (
ST->isOpaque()) {
1124 AbbrevToUse = StructNamedAbbrev;
1128 if (!
ST->getName().empty())
1138 TypeVals.
push_back(AT->getNumElements());
1139 TypeVals.
push_back(getTypeID(AT->getElementType()));
1140 AbbrevToUse = ArrayAbbrev;
1148 TypeVals.
push_back(VT->getElementCount().getKnownMinValue());
1149 TypeVals.
push_back(getTypeID(VT->getElementType()));
1155 Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
1162void DXILBitcodeWriter::writeComdats() {
1164 for (
const Comdat *
C : VE.getComdats()) {
1167 size_t Size =
C->getName().size();
1170 for (
char Chr :
C->getName())
1177void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
1182void DXILBitcodeWriter::writeModuleInfo() {
1187 StringRef Triple =
"dxil-ms-dx";
1188 StringRef
DL =
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-"
1189 "f16:16-f32:32-f64:64-n8:16:32:64";
1198 std::map<std::string, unsigned> SectionMap;
1199 std::map<std::string, unsigned> GCMap;
1201 unsigned MaxGlobalType = 0;
1202 const auto UpdateMaxAlignment = [&
MaxAlignment](
const MaybeAlign
A) {
1206 for (
const GlobalVariable &GV : M.globals()) {
1207 UpdateMaxAlignment(GV.getAlign());
1210 MaxGlobalType = std::max(
1211 MaxGlobalType, getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1212 if (GV.hasSection()) {
1214 unsigned &
Entry = SectionMap[std::string(GV.getSection())];
1217 GV.getSection(), 0 );
1218 Entry = SectionMap.size();
1223 UpdateMaxAlignment(
F.getAlign());
1224 if (
F.hasSection()) {
1226 unsigned &
Entry = SectionMap[std::string(
F.getSection())];
1230 Entry = SectionMap.size();
1235 unsigned &
Entry = GCMap[
F.getGC()];
1239 Entry = GCMap.size();
1245 unsigned SimpleGVarAbbrev = 0;
1246 if (!M.global_empty()) {
1249 auto Abbv = std::make_shared<BitCodeAbbrev>();
1259 Abbv->Add(BitCodeAbbrevOp(0));
1261 unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1265 if (SectionMap.empty())
1266 Abbv->Add(BitCodeAbbrevOp(0));
1271 SimpleGVarAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1276 for (
const GlobalVariable &GV : M.globals()) {
1277 unsigned AbbrevToUse = 0;
1283 Vals.
push_back(getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1285 GV.getType()->getAddressSpace() << 2 | 2 |
1286 (GV.isConstant() ? 1 : 0));
1289 GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1));
1291 Vals.
push_back(getEncodedAlign(GV.getAlign()));
1292 Vals.
push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1294 if (GV.isThreadLocal() ||
1297 GV.isExternallyInitialized() ||
1303 Vals.
push_back(GV.isExternallyInitialized());
1305 Vals.
push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1307 AbbrevToUse = SimpleGVarAbbrev;
1316 const Function &
F = VE.getDXILFunction(OrigF);
1321 Vals.
push_back(getGlobalObjectValueTypeID(
F.getFunctionType(), &
F));
1325 Vals.
push_back(VE.getAttributeListID(
F.getAttributes()));
1326 Vals.
push_back(getEncodedAlign(
F.getAlign()));
1327 Vals.
push_back(
F.hasSection() ? SectionMap[std::string(
F.getSection())]
1333 F.hasPrologueData() ? (VE.getValueID(
F.getPrologueData()) + 1) : 0);
1335 Vals.
push_back(
F.hasComdat() ? VE.getComdatID(
F.getComdat()) : 0);
1336 Vals.
push_back(
F.hasPrefixData() ? (VE.getValueID(
F.getPrefixData()) + 1)
1339 F.hasPersonalityFn() ? (VE.getValueID(
F.getPersonalityFn()) + 1) : 0);
1341 unsigned AbbrevToUse = 0;
1347 for (
const GlobalAlias &
A : M.aliases()) {
1350 Vals.
push_back(VE.getValueID(
A.getAliasee()));
1356 unsigned AbbrevToUse = 0;
1362void DXILBitcodeWriter::writeValueAsMetadata(
1363 const ValueAsMetadata *MD, SmallVectorImpl<uint64_t> &Record) {
1366 Type *Ty =
V->getType();
1371 Record.push_back(getTypeID(Ty, V));
1372 Record.push_back(VE.getValueID(V));
1377void DXILBitcodeWriter::writeMDTuple(
const MDTuple *
N,
1378 SmallVectorImpl<uint64_t> &Record,
1380 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
1383 "Unexpected function-local metadata");
1384 Record.push_back(VE.getMetadataOrNullID(MD));
1392void DXILBitcodeWriter::writeDILocation(
const DILocation *
N,
1393 SmallVectorImpl<uint64_t> &Record,
1396 Abbrev = createDILocationAbbrev();
1397 Record.push_back(
N->isDistinct());
1398 Record.push_back(
N->getLine());
1399 Record.push_back(
N->getColumn());
1400 Record.push_back(VE.getMetadataID(
N->getScope()));
1401 Record.push_back(VE.getMetadataOrNullID(
N->getInlinedAt()));
1410 return I < 0 ? ~(U << 1) : U << 1;
1413void DXILBitcodeWriter::writeDISubrange(
const DISubrange *
N,
1414 SmallVectorImpl<uint64_t> &Record,
1416 Record.push_back(
N->isDistinct());
1422 Record.push_back(
Count->getValue().getSExtValue());
1428 DISubrange::BoundType
LowerBound =
N->getLowerBound();
1439void DXILBitcodeWriter::writeDIEnumerator(
const DIEnumerator *
N,
1440 SmallVectorImpl<uint64_t> &Record,
1442 Record.push_back(
N->isDistinct());
1444 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1450void DXILBitcodeWriter::writeDIBasicType(
const DIBasicType *
N,
1451 SmallVectorImpl<uint64_t> &Record,
1453 Record.push_back(
N->isDistinct());
1454 Record.push_back(
N->getTag());
1455 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1456 Record.push_back(
N->getSizeInBits());
1457 Record.push_back(
N->getAlignInBits());
1458 Record.push_back(
N->getEncoding());
1464void DXILBitcodeWriter::writeDIDerivedType(
const DIDerivedType *
N,
1465 SmallVectorImpl<uint64_t> &Record,
1467 Record.push_back(
N->isDistinct());
1468 Record.push_back(
N->getTag());
1469 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1470 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1471 Record.push_back(
N->getLine());
1472 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1473 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1474 Record.push_back(
N->getSizeInBits());
1475 Record.push_back(
N->getAlignInBits());
1476 Record.push_back(
N->getOffsetInBits());
1477 Record.push_back(
N->getFlags());
1478 Record.push_back(VE.getMetadataOrNullID(
N->getExtraData()));
1484void DXILBitcodeWriter::writeDICompositeType(
const DICompositeType *
N,
1485 SmallVectorImpl<uint64_t> &Record,
1487 Record.push_back(
N->isDistinct());
1488 Record.push_back(
N->getTag());
1489 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1490 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1491 Record.push_back(
N->getLine());
1492 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1493 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1494 Record.push_back(
N->getSizeInBits());
1495 Record.push_back(
N->getAlignInBits());
1496 Record.push_back(
N->getOffsetInBits());
1497 Record.push_back(
N->getFlags());
1498 Record.push_back(VE.getMetadataOrNullID(
N->getElements().get()));
1499 Record.push_back(
N->getRuntimeLang());
1500 Record.push_back(VE.getMetadataOrNullID(
N->getVTableHolder()));
1501 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1502 Record.push_back(VE.getMetadataOrNullID(
N->getRawIdentifier()));
1508void DXILBitcodeWriter::writeDISubroutineType(
const DISubroutineType *
N,
1509 SmallVectorImpl<uint64_t> &Record,
1511 Record.push_back(
N->isDistinct());
1512 Record.push_back(
N->getFlags());
1513 Record.push_back(VE.getMetadataOrNullID(
N->getTypeArray().get()));
1519void DXILBitcodeWriter::writeDIFile(
const DIFile *
N,
1520 SmallVectorImpl<uint64_t> &Record,
1522 Record.push_back(
N->isDistinct());
1523 Record.push_back(VE.getMetadataOrNullID(
N->getRawFilename()));
1524 Record.push_back(VE.getMetadataOrNullID(
N->getRawDirectory()));
1530void DXILBitcodeWriter::writeDICompileUnit(
const DICompileUnit *
N,
1531 SmallVectorImpl<uint64_t> &Record,
1533 Record.push_back(
N->isDistinct());
1534 Record.push_back(
N->getSourceLanguage().getUnversionedName());
1535 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1536 Record.push_back(VE.getMetadataOrNullID(
N->getRawProducer()));
1537 Record.push_back(
N->isOptimized());
1538 Record.push_back(VE.getMetadataOrNullID(
N->getRawFlags()));
1539 Record.push_back(
N->getRuntimeVersion());
1540 Record.push_back(VE.getMetadataOrNullID(
N->getRawSplitDebugFilename()));
1541 Record.push_back(
N->getEmissionKind());
1542 Record.push_back(VE.getMetadataOrNullID(
N->getEnumTypes().get()));
1543 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedTypes().get()));
1544 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1545 Record.push_back(VE.getMetadataOrNullID(
N->getGlobalVariables().get()));
1546 Record.push_back(VE.getMetadataOrNullID(
N->getImportedEntities().get()));
1547 Record.push_back(
N->getDWOId());
1553void DXILBitcodeWriter::writeDISubprogram(
const DISubprogram *
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->getRawName()));
1559 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1560 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1561 Record.push_back(
N->getLine());
1562 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1563 Record.push_back(
N->isLocalToUnit());
1564 Record.push_back(
N->isDefinition());
1565 Record.push_back(
N->getScopeLine());
1566 Record.push_back(VE.getMetadataOrNullID(
N->getContainingType()));
1567 Record.push_back(
N->getVirtuality());
1568 Record.push_back(
N->getVirtualIndex());
1569 Record.push_back(
N->getFlags());
1570 Record.push_back(
N->isOptimized());
1571 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1572 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1573 Record.push_back(VE.getMetadataOrNullID(
N->getDeclaration()));
1574 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedNodes().get()));
1580void DXILBitcodeWriter::writeDILexicalBlock(
const DILexicalBlock *
N,
1581 SmallVectorImpl<uint64_t> &Record,
1583 Record.push_back(
N->isDistinct());
1584 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1585 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1586 Record.push_back(
N->getLine());
1587 Record.push_back(
N->getColumn());
1593void DXILBitcodeWriter::writeDILexicalBlockFile(
1594 const DILexicalBlockFile *
N, SmallVectorImpl<uint64_t> &Record,
1596 Record.push_back(
N->isDistinct());
1597 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1598 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1599 Record.push_back(
N->getDiscriminator());
1605void DXILBitcodeWriter::writeDINamespace(
const DINamespace *
N,
1606 SmallVectorImpl<uint64_t> &Record,
1608 Record.push_back(
N->isDistinct());
1609 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1610 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1611 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1618void DXILBitcodeWriter::writeDIModule(
const DIModule *
N,
1619 SmallVectorImpl<uint64_t> &Record,
1621 Record.push_back(
N->isDistinct());
1622 for (
auto &
I :
N->operands())
1623 Record.push_back(VE.getMetadataOrNullID(
I));
1629void DXILBitcodeWriter::writeDITemplateTypeParameter(
1630 const DITemplateTypeParameter *
N, SmallVectorImpl<uint64_t> &Record,
1632 Record.push_back(
N->isDistinct());
1633 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1634 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1640void DXILBitcodeWriter::writeDITemplateValueParameter(
1641 const DITemplateValueParameter *
N, SmallVectorImpl<uint64_t> &Record,
1643 Record.push_back(
N->isDistinct());
1644 Record.push_back(
N->getTag());
1645 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1646 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1647 Record.push_back(VE.getMetadataOrNullID(
N->getValue()));
1653void DXILBitcodeWriter::writeDIGlobalVariable(
const DIGlobalVariable *
N,
1654 SmallVectorImpl<uint64_t> &Record,
1656 Record.push_back(
N->isDistinct());
1657 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1658 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1659 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1660 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1661 Record.push_back(
N->getLine());
1662 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1663 Record.push_back(
N->isLocalToUnit());
1664 Record.push_back(
N->isDefinition());
1665 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1666 Record.push_back(VE.getMetadataOrNullID(
N->getStaticDataMemberDeclaration()));
1672void DXILBitcodeWriter::writeDILocalVariable(
const DILocalVariable *
N,
1673 SmallVectorImpl<uint64_t> &Record,
1675 constexpr unsigned DW_TAG_auto_variable = 0x0100;
1676 constexpr unsigned DW_TAG_arg_variable = 0x0101;
1677 Record.push_back(
N->isDistinct());
1678 assert(
N->getTag() == dwarf::DW_TAG_variable);
1679 Record.push_back(
N->getArg() ? DW_TAG_arg_variable : DW_TAG_auto_variable);
1680 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1681 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1682 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1683 Record.push_back(
N->getLine());
1684 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1685 Record.push_back(
N->getArg());
1686 Record.push_back(
N->getFlags());
1692void DXILBitcodeWriter::writeDIExpression(
const DIExpression *
N,
1693 SmallVectorImpl<uint64_t> &Record,
1695 Record.reserve(
N->getElements().size() + 1);
1697 Record.push_back(
N->isDistinct());
1698 Record.append(
N->elements_begin(),
N->elements_end());
1704void DXILBitcodeWriter::writeDIObjCProperty(
const DIObjCProperty *
N,
1705 SmallVectorImpl<uint64_t> &Record,
1710void DXILBitcodeWriter::writeDIImportedEntity(
const DIImportedEntity *
N,
1711 SmallVectorImpl<uint64_t> &Record,
1713 Record.push_back(
N->isDistinct());
1714 Record.push_back(
N->getTag());
1715 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1716 Record.push_back(VE.getMetadataOrNullID(
N->getEntity()));
1717 Record.push_back(
N->getLine());
1718 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1724unsigned DXILBitcodeWriter::createDILocationAbbrev() {
1729 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1736 return Stream.EmitAbbrev(std::move(Abbv));
1739unsigned DXILBitcodeWriter::createGenericDINodeAbbrev() {
1744 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1752 return Stream.EmitAbbrev(std::move(Abbv));
1756 SmallVectorImpl<uint64_t> &Record,
1757 std::vector<unsigned> *MDAbbrevs,
1758 std::vector<uint64_t> *IndexPos) {
1763#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1764#include "llvm/IR/Metadata.def"
1768 IndexPos->push_back(Stream.GetCurrentBitNo());
1770 assert(
N->isResolved() &&
"Expected forward references to be resolved");
1772 switch (
N->getMetadataID()) {
1775#define HANDLE_MDNODE_LEAF(CLASS) \
1776 case Metadata::CLASS##Kind: \
1778 write##CLASS(cast<CLASS>(N), Record, \
1779 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1781 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1783#include "llvm/IR/Metadata.def"
1790unsigned DXILBitcodeWriter::createMetadataStringsAbbrev() {
1791 auto Abbv = std::make_shared<BitCodeAbbrev>();
1795 return Stream.EmitAbbrev(std::move(Abbv));
1798void DXILBitcodeWriter::writeMetadataStrings(
1800 if (Strings.
empty())
1803 unsigned MDSAbbrev = createMetadataStringsAbbrev();
1805 for (
const Metadata *MD : Strings) {
1816void DXILBitcodeWriter::writeModuleMetadata() {
1817 if (!VE.hasMDs() && M.named_metadata_empty())
1824 std::vector<unsigned> MDAbbrevs;
1827 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1828 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1829 createGenericDINodeAbbrev();
1831 unsigned NameAbbrev = 0;
1832 if (!M.named_metadata_empty()) {
1834 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1838 NameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1841 SmallVector<uint64_t, 64>
Record;
1842 writeMetadataStrings(VE.getMDStrings(), Record);
1844 std::vector<uint64_t> IndexPos;
1845 IndexPos.reserve(VE.getNonMDStrings().size());
1846 writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1849 for (
const NamedMDNode &NMD : M.named_metadata()) {
1851 StringRef Str = NMD.getName();
1852 Record.append(Str.bytes_begin(), Str.bytes_end());
1857 for (
const MDNode *
N : NMD.operands())
1858 Record.push_back(VE.getMetadataID(
N));
1866void DXILBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
1871 SmallVector<uint64_t, 64>
Record;
1872 writeMetadataStrings(VE.getMDStrings(), Record);
1873 writeMetadataRecords(VE.getNonMDStrings(), Record);
1877void DXILBitcodeWriter::writeFunctionMetadataAttachment(
const Function &
F) {
1880 SmallVector<uint64_t, 64>
Record;
1885 F.getAllMetadata(MDs);
1887 for (
const auto &
I : MDs) {
1888 if (
I.first == LLVMContext::MD_dbg)
1891 Record.push_back(VE.getMetadataID(
I.second));
1899 for (
const BasicBlock &BB :
F)
1900 for (
const Instruction &OrigI : BB) {
1904 I.getAllMetadataOtherThanDebugLoc(MDs);
1910 Record.push_back(VE.getInstructionID(&
I));
1912 for (
unsigned i = 0, e = MDs.size(); i != e; ++i) {
1913 Record.push_back(MDs[i].first);
1914 Record.push_back(VE.getMetadataID(MDs[i].second));
1923void DXILBitcodeWriter::writeModuleMetadataKinds() {
1924 SmallVector<uint64_t, 64>
Record;
1929 M.getMDKindNames(Names);
1936 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
1937 Record.push_back(MDKindID);
1938 StringRef KName = Names[MDKindID];
1948void DXILBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
1950 if (FirstVal == LastVal)
1955 unsigned AggregateAbbrev = 0;
1956 unsigned String8Abbrev = 0;
1957 unsigned CString7Abbrev = 0;
1958 unsigned CString6Abbrev = 0;
1962 auto Abbv = std::make_shared<BitCodeAbbrev>();
1967 AggregateAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1970 Abbv = std::make_shared<BitCodeAbbrev>();
1974 String8Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1976 Abbv = std::make_shared<BitCodeAbbrev>();
1980 CString7Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1982 Abbv = std::make_shared<BitCodeAbbrev>();
1986 CString6Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1989 SmallVector<uint64_t, 64>
Record;
1992 Type *LastTy =
nullptr;
1993 for (
unsigned i = FirstVal; i != LastVal; ++i) {
1994 const Value *
V = Vals[i].first;
1996 if (
V->getType() != LastTy) {
1997 LastTy =
V->getType();
1998 Record.push_back(getTypeID(LastTy, V));
2000 CONSTANTS_SETTYPE_ABBREV);
2005 Record.push_back(
unsigned(
IA->hasSideEffects()) |
2006 unsigned(
IA->isAlignStack()) << 1 |
2007 unsigned(
IA->getDialect() & 1) << 2);
2010 StringRef AsmStr =
IA->getAsmString();
2015 StringRef ConstraintStr =
IA->getConstraintString();
2023 unsigned Code = -1U;
2024 unsigned AbbrevToUse = 0;
2025 if (
C->isNullValue()) {
2030 if (
IV->getBitWidth() <= 64) {
2034 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2040 unsigned NWords =
IV->getValue().getActiveWords();
2041 const uint64_t *RawWords =
IV->getValue().getRawData();
2042 for (
unsigned i = 0; i != NWords; ++i) {
2050 if (BV->getBitWidth() <= 64) {
2054 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2056 unsigned NWords = BV->getValue().getActiveWords();
2057 const uint64_t *RawWords = BV->getValue().getRawData();
2058 for (
unsigned i = 0; i != NWords; ++i) {
2067 Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2071 APInt api = CFP->getValueAPF().bitcastToAPInt();
2073 Record.push_back((p[1] << 48) | (p[0] >> 16));
2074 Record.push_back(p[0] & 0xffffLL);
2076 APInt api = CFP->getValueAPF().bitcastToAPInt();
2081 assert(0 &&
"Unknown FP type!");
2087 unsigned NumElts = Str->getNumElements();
2089 if (Str->isCString()) {
2094 AbbrevToUse = String8Abbrev;
2098 for (
unsigned i = 0; i != NumElts; ++i) {
2099 unsigned char V = Str->getElementAsInteger(i);
2101 isCStr7 &= (
V & 128) == 0;
2107 AbbrevToUse = CString6Abbrev;
2109 AbbrevToUse = CString7Abbrev;
2110 }
else if (
const ConstantDataSequential *CDS =
2113 Type *EltTy = CDS->getElementType();
2115 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2116 Record.push_back(CDS->getElementAsInteger(i));
2118 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2123 F = CDS->getElementAsFloat(i);
2128 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2133 F = CDS->getElementAsDouble(i);
2140 for (
const Value *
Op :
C->operands())
2141 Record.push_back(VE.getValueID(
Op));
2142 AbbrevToUse = AggregateAbbrev;
2144 switch (
CE->getOpcode()) {
2150 getTypeID(
C->getOperand(0)->getType(),
C->getOperand(0)));
2151 Record.push_back(VE.getValueID(
C->getOperand(0)));
2152 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2154 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2157 Record.push_back(VE.getValueID(
C->getOperand(0)));
2158 Record.push_back(VE.getValueID(
C->getOperand(1)));
2164 case Instruction::GetElementPtr: {
2167 if (GO->isInBounds())
2169 Record.push_back(getTypeID(GO->getSourceElementType()));
2170 for (
unsigned i = 0, e =
CE->getNumOperands(); i != e; ++i) {
2172 getTypeID(
C->getOperand(i)->getType(),
C->getOperand(i)));
2173 Record.push_back(VE.getValueID(
C->getOperand(i)));
2177 case Instruction::Select:
2179 Record.push_back(VE.getValueID(
C->getOperand(0)));
2180 Record.push_back(VE.getValueID(
C->getOperand(1)));
2181 Record.push_back(VE.getValueID(
C->getOperand(2)));
2183 case Instruction::ExtractElement:
2185 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2186 Record.push_back(VE.getValueID(
C->getOperand(0)));
2187 Record.push_back(getTypeID(
C->getOperand(1)->getType()));
2188 Record.push_back(VE.getValueID(
C->getOperand(1)));
2190 case Instruction::InsertElement:
2192 Record.push_back(VE.getValueID(
C->getOperand(0)));
2193 Record.push_back(VE.getValueID(
C->getOperand(1)));
2194 Record.push_back(getTypeID(
C->getOperand(2)->getType()));
2195 Record.push_back(VE.getValueID(
C->getOperand(2)));
2197 case Instruction::ShuffleVector:
2202 if (
C->getType() ==
C->getOperand(0)->getType()) {
2206 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2208 Record.push_back(VE.getValueID(
C->getOperand(0)));
2209 Record.push_back(VE.getValueID(
C->getOperand(1)));
2210 Record.push_back(VE.getValueID(
C->getOperand(2)));
2215 Record.push_back(getTypeID(BA->getFunction()->getType()));
2216 Record.push_back(VE.getValueID(BA->getFunction()));
2217 Record.push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2224 Stream.EmitRecord(Code, Record, AbbrevToUse);
2231void DXILBitcodeWriter::writeModuleConstants() {
2236 for (
unsigned i = 0, e = Vals.size(); i != e; ++i) {
2238 writeConstants(i, Vals.size(),
true);
2252bool DXILBitcodeWriter::pushValueAndType(
const Value *V,
unsigned InstID,
2253 SmallVectorImpl<unsigned> &Vals) {
2254 unsigned ValID = VE.getValueID(V);
2257 if (ValID >= InstID) {
2266void DXILBitcodeWriter::pushValue(
const Value *V,
unsigned InstID,
2267 SmallVectorImpl<unsigned> &Vals) {
2268 unsigned ValID = VE.getValueID(V);
2272void DXILBitcodeWriter::pushValueSigned(
const Value *V,
unsigned InstID,
2273 SmallVectorImpl<uint64_t> &Vals) {
2274 unsigned ValID = VE.getValueID(V);
2275 int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2280void DXILBitcodeWriter::writeInstruction(
const Instruction &
I,
unsigned InstID,
2281 SmallVectorImpl<unsigned> &Vals) {
2283 unsigned AbbrevToUse = 0;
2284 VE.setInstructionID(&
I);
2285 switch (
I.getOpcode()) {
2289 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2290 AbbrevToUse = (unsigned)FUNCTION_INST_CAST_ABBREV;
2296 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2297 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_ABBREV;
2298 pushValue(
I.getOperand(1), InstID, Vals);
2302 if (AbbrevToUse == (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2303 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV;
2309 case Instruction::GetElementPtr: {
2311 AbbrevToUse = (unsigned)FUNCTION_INST_GEP_ABBREV;
2314 Vals.
push_back(getTypeID(GEPInst.getSourceElementType()));
2315 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i)
2316 pushValueAndType(
I.getOperand(i), InstID, Vals);
2319 case Instruction::ExtractValue: {
2321 pushValueAndType(
I.getOperand(0), InstID, Vals);
2326 case Instruction::InsertValue: {
2328 pushValueAndType(
I.getOperand(0), InstID, Vals);
2329 pushValueAndType(
I.getOperand(1), InstID, Vals);
2334 case Instruction::Select:
2336 pushValueAndType(
I.getOperand(1), InstID, Vals);
2337 pushValue(
I.getOperand(2), InstID, Vals);
2338 pushValueAndType(
I.getOperand(0), InstID, Vals);
2340 case Instruction::ExtractElement:
2342 pushValueAndType(
I.getOperand(0), InstID, Vals);
2343 pushValueAndType(
I.getOperand(1), InstID, Vals);
2345 case Instruction::InsertElement:
2347 pushValueAndType(
I.getOperand(0), InstID, Vals);
2348 pushValue(
I.getOperand(1), InstID, Vals);
2349 pushValueAndType(
I.getOperand(2), InstID, Vals);
2351 case Instruction::ShuffleVector:
2353 pushValueAndType(
I.getOperand(0), InstID, Vals);
2354 pushValue(
I.getOperand(1), InstID, Vals);
2358 case Instruction::ICmp:
2359 case Instruction::FCmp: {
2362 pushValueAndType(
I.getOperand(0), InstID, Vals);
2363 pushValue(
I.getOperand(1), InstID, Vals);
2371 case Instruction::Ret: {
2373 unsigned NumOperands =
I.getNumOperands();
2374 if (NumOperands == 0)
2375 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VOID_ABBREV;
2376 else if (NumOperands == 1) {
2377 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2378 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VAL_ABBREV;
2380 for (
unsigned i = 0, e = NumOperands; i !=
e; ++i)
2381 pushValueAndType(
I.getOperand(i), InstID, Vals);
2384 case Instruction::UncondBr:
2388 case Instruction::CondBr: {
2391 Vals.
push_back(VE.getValueID(
II.getSuccessor(0)));
2392 Vals.
push_back(VE.getValueID(
II.getSuccessor(1)));
2393 pushValue(
II.getCondition(), InstID, Vals);
2395 case Instruction::Switch: {
2398 Vals.
push_back(getTypeID(
SI.getCondition()->getType()));
2399 pushValue(
SI.getCondition(), InstID, Vals);
2400 Vals.
push_back(VE.getValueID(
SI.getDefaultDest()));
2401 for (
auto Case :
SI.cases()) {
2402 Vals.
push_back(VE.getValueID(Case.getCaseValue()));
2403 Vals.
push_back(VE.getValueID(Case.getCaseSuccessor()));
2406 case Instruction::IndirectBr:
2408 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2410 pushValue(
I.getOperand(0), InstID, Vals);
2411 for (
unsigned i = 1, e =
I.getNumOperands(); i != e; ++i)
2412 Vals.
push_back(VE.getValueID(
I.getOperand(i)));
2415 case Instruction::Invoke: {
2418 FunctionType *FTy =
II->getFunctionType();
2421 Vals.
push_back(VE.getAttributeListID(
II->getAttributes()));
2423 Vals.
push_back(VE.getValueID(
II->getNormalDest()));
2424 Vals.
push_back(VE.getValueID(
II->getUnwindDest()));
2426 pushValueAndType(Callee, InstID, Vals);
2429 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2430 pushValue(
I.getOperand(i), InstID, Vals);
2433 if (FTy->isVarArg()) {
2434 for (
unsigned i = FTy->getNumParams(), e =
I.getNumOperands() - 3; i != e;
2436 pushValueAndType(
I.getOperand(i), InstID, Vals);
2440 case Instruction::Resume:
2442 pushValueAndType(
I.getOperand(0), InstID, Vals);
2444 case Instruction::Unreachable:
2446 AbbrevToUse = (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV;
2449 case Instruction::PHI: {
2462 Stream.EmitRecord(Code, Vals64, AbbrevToUse);
2467 case Instruction::LandingPad: {
2478 pushValueAndType(LP.
getClause(
I), InstID, Vals);
2483 case Instruction::Alloca: {
2487 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2488 Vals.
push_back(VE.getValueID(
I.getOperand(0)));
2490 assert(AlignRecord < 1 << 5 &&
"alignment greater than 1 << 64");
2492 AlignRecord |= 1 << 6;
2497 case Instruction::Load:
2500 pushValueAndType(
I.getOperand(0), InstID, Vals);
2503 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2504 AbbrevToUse = (unsigned)FUNCTION_INST_LOAD_ABBREV;
2514 case Instruction::Store:
2519 pushValueAndType(
I.getOperand(1), InstID, Vals);
2520 pushValueAndType(
I.getOperand(0), InstID, Vals);
2529 case Instruction::AtomicCmpXchg:
2531 pushValueAndType(
I.getOperand(0), InstID, Vals);
2532 pushValueAndType(
I.getOperand(1), InstID, Vals);
2533 pushValue(
I.getOperand(2), InstID, Vals);
2543 case Instruction::AtomicRMW:
2545 pushValueAndType(
I.getOperand(0), InstID, Vals);
2546 pushValue(
I.getOperand(1), InstID, Vals);
2554 case Instruction::Fence:
2559 case Instruction::Call: {
2572 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
2574 if (FTy->getParamType(i)->isLabelTy())
2581 if (FTy->isVarArg()) {
2582 for (
unsigned i = FTy->getNumParams(), e = CI.
arg_size(); i != e; ++i)
2587 case Instruction::VAArg:
2589 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2590 pushValue(
I.getOperand(0), InstID, Vals);
2595 Stream.EmitRecord(Code, Vals, AbbrevToUse);
2600void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
2601 const ValueSymbolTable &VST) {
2613 for (
auto &VI : VST) {
2614 const Value &
V = VE.getDXILValue(*
VI.second);
2619 return A->first() <
B->first();
2622 for (
const ValueName *SI : SortedTable) {
2627 bool isChar6 =
true;
2628 for (
const char *
C =
Name.getKeyData(), *
E =
C +
Name.getKeyLength();
2632 if ((
unsigned char)*
C & 128) {
2638 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2646 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2650 AbbrevToUse = VST_ENTRY_6_ABBREV;
2652 AbbrevToUse = VST_ENTRY_7_ABBREV;
2655 NameVals.
push_back(VE.getValueID(
SI->getValue()));
2656 for (
const char *
P =
Name.getKeyData(),
2657 *
E =
Name.getKeyData() +
Name.getKeyLength();
2662 Stream.EmitRecord(Code, NameVals, AbbrevToUse);
2669void DXILBitcodeWriter::writeFunction(
const Function &
F) {
2671 VE.incorporateFunction(
F);
2677 Vals.
push_back(VE.getBasicBlocks().size());
2682 unsigned CstStart, CstEnd;
2683 VE.getFunctionConstantRange(CstStart, CstEnd);
2684 writeConstants(CstStart, CstEnd,
false);
2687 writeFunctionMetadata(
F);
2690 unsigned InstID = CstEnd;
2692 bool NeedsMetadataAttachment =
F.hasMetadata();
2694 DILocation *LastDL =
nullptr;
2702 writeInstruction(
I, InstID, Vals);
2704 if (!
I.getType()->isVoidTy())
2708 NeedsMetadataAttachment |=
I.hasMetadataOtherThanDebugLoc();
2711 DILocation *
DL =
I.getDebugLoc();
2723 Vals.
push_back(VE.getMetadataOrNullID(
DL->getScope()));
2724 Vals.
push_back(VE.getMetadataOrNullID(
DL->getInlinedAt()));
2732 if (
auto *Symtab =
F.getValueSymbolTable())
2733 writeFunctionLevelValueSymbolTable(*Symtab);
2735 if (NeedsMetadataAttachment)
2736 writeFunctionMetadataAttachment(
F);
2743void DXILBitcodeWriter::writeBlockInfo() {
2747 Stream.EnterBlockInfoBlock();
2750 auto Abbv = std::make_shared<BitCodeAbbrev>();
2756 std::move(Abbv)) != VST_ENTRY_8_ABBREV)
2757 assert(
false &&
"Unexpected abbrev ordering!");
2761 auto Abbv = std::make_shared<BitCodeAbbrev>();
2767 std::move(Abbv)) != VST_ENTRY_7_ABBREV)
2768 assert(
false &&
"Unexpected abbrev ordering!");
2771 auto Abbv = std::make_shared<BitCodeAbbrev>();
2777 std::move(Abbv)) != VST_ENTRY_6_ABBREV)
2778 assert(
false &&
"Unexpected abbrev ordering!");
2781 auto Abbv = std::make_shared<BitCodeAbbrev>();
2787 std::move(Abbv)) != VST_BBENTRY_6_ABBREV)
2788 assert(
false &&
"Unexpected abbrev ordering!");
2792 auto Abbv = std::make_shared<BitCodeAbbrev>();
2795 VE.computeBitsRequiredForTypeIndices()));
2797 CONSTANTS_SETTYPE_ABBREV)
2798 assert(
false &&
"Unexpected abbrev ordering!");
2802 auto Abbv = std::make_shared<BitCodeAbbrev>();
2806 CONSTANTS_INTEGER_ABBREV)
2807 assert(
false &&
"Unexpected abbrev ordering!");
2811 auto Abbv = std::make_shared<BitCodeAbbrev>();
2815 VE.computeBitsRequiredForTypeIndices()));
2819 CONSTANTS_CE_CAST_Abbrev)
2820 assert(
false &&
"Unexpected abbrev ordering!");
2823 auto Abbv = std::make_shared<BitCodeAbbrev>();
2826 CONSTANTS_NULL_Abbrev)
2827 assert(
false &&
"Unexpected abbrev ordering!");
2833 auto Abbv = std::make_shared<BitCodeAbbrev>();
2837 VE.computeBitsRequiredForTypeIndices()));
2841 (
unsigned)FUNCTION_INST_LOAD_ABBREV)
2842 assert(
false &&
"Unexpected abbrev ordering!");
2845 auto Abbv = std::make_shared<BitCodeAbbrev>();
2851 (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2852 assert(
false &&
"Unexpected abbrev ordering!");
2855 auto Abbv = std::make_shared<BitCodeAbbrev>();
2862 (
unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV)
2863 assert(
false &&
"Unexpected abbrev ordering!");
2866 auto Abbv = std::make_shared<BitCodeAbbrev>();
2870 VE.computeBitsRequiredForTypeIndices()));
2873 (
unsigned)FUNCTION_INST_CAST_ABBREV)
2874 assert(
false &&
"Unexpected abbrev ordering!");
2878 auto Abbv = std::make_shared<BitCodeAbbrev>();
2881 (
unsigned)FUNCTION_INST_RET_VOID_ABBREV)
2882 assert(
false &&
"Unexpected abbrev ordering!");
2885 auto Abbv = std::make_shared<BitCodeAbbrev>();
2889 (
unsigned)FUNCTION_INST_RET_VAL_ABBREV)
2890 assert(
false &&
"Unexpected abbrev ordering!");
2893 auto Abbv = std::make_shared<BitCodeAbbrev>();
2896 (
unsigned)FUNCTION_INST_UNREACHABLE_ABBREV)
2897 assert(
false &&
"Unexpected abbrev ordering!");
2900 auto Abbv = std::make_shared<BitCodeAbbrev>();
2908 (
unsigned)FUNCTION_INST_GEP_ABBREV)
2909 assert(
false &&
"Unexpected abbrev ordering!");
2915void DXILBitcodeWriter::writeModuleVersion() {
2930 DXILBitcodeWriter::writeModuleVersion();
2936 writeAttributeGroupTable();
2939 writeAttributeTable();
2951 writeModuleConstants();
2954 writeModuleMetadataKinds();
2957 writeModuleMetadata();
2962 writeFunctionLevelValueSymbolTable(M.getValueSymbolTable());
2966 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
Function and variable summary information to aid decisions and implementation of importing.
VisibilityTypes getVisibility() const
LinkageTypes getLinkage() const
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
ThreadLocalMode getThreadLocalMode() const
@ DLLExportStorageClass
Function to be accessible from DLL.
@ DLLImportStorageClass
Function to be imported from DLL.
@ DefaultVisibility
The GV is visible.
@ HiddenVisibility
The GV is hidden.
@ ProtectedVisibility
The GV is protected.
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
DLLStorageClassTypes getDLLStorageClass() const
idx_iterator idx_end() const
idx_iterator idx_begin() const
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
const unsigned char * bytes_begin() const
const unsigned char * bytes_end() const
bool doesNotAccessMemory() const
Whether this function accesses no memory.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
A Module instance is used to store all the information related to an LLVM module.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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 void writeIdentificationBlock(BitstreamWriter &Stream)
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.
raw_ostream & write(unsigned char C)
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
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_LANDINGPAD
@ FUNC_CODE_INST_EXTRACTVAL
@ FUNC_CODE_INST_LOADATOMIC
@ FUNC_CODE_INST_STOREATOMIC
@ FUNC_CODE_INST_ATOMICRMW
@ FUNC_CODE_DEBUG_LOC_AGAIN
@ FUNC_CODE_INST_EXTRACTELT
@ FUNC_CODE_INST_INDIRECTBR
@ FUNC_CODE_INST_INSERTVAL
@ FUNC_CODE_DECLAREBLOCKS
@ FUNC_CODE_INST_INSERTELT
@ FUNC_CODE_INST_SHUFFLEVEC
@ FUNC_CODE_INST_UNREACHABLE
@ FIRST_APPLICATION_ABBREV
@ PARAMATTR_GRP_CODE_ENTRY
An analysis to compute the PointerTypes for pointers in a Module.
DenseMap< const Value *, Type * > PointerTypeMap
void WriteDXILToFile(const Module &M, raw_ostream &Out, const DXILDebugInfoMap &DebugInfo)
Write the specified module to the specified raw output stream.
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.