60#define HANDLE_MDNODE_LEAF(CLASS) CLASS##AbbrevID,
61#include "llvm/IR/Metadata.def"
79 CONSTANTS_INTEGER_ABBREV,
80 CONSTANTS_CE_CAST_Abbrev,
81 CONSTANTS_NULL_Abbrev,
85 FUNCTION_INST_BINOP_ABBREV,
86 FUNCTION_INST_BINOP_FLAGS_ABBREV,
87 FUNCTION_INST_CAST_ABBREV,
88 FUNCTION_INST_RET_VOID_ABBREV,
89 FUNCTION_INST_RET_VAL_ABBREV,
90 FUNCTION_INST_UNREACHABLE_ABBREV,
91 FUNCTION_INST_GEP_ABBREV,
112 std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
115 unsigned GlobalValueId;
135 : I8Ty(
Type::getInt8Ty(M.getContext())),
137 StrtabBuilder(StrtabBuilder), M(M), VE(M, I8PtrTy), Buffer(Buffer),
138 BitcodeStartBit(Stream.GetCurrentBitNo()),
140 GlobalValueId = VE.getValues().
size();
142 for (
auto El : PointerMap)
143 VE.EnumerateType(El.second);
170 void writeModuleVersion();
171 void writePerModuleGlobalValueSummary();
176 unsigned FSCallsAbbrev,
177 unsigned FSCallsProfileAbbrev,
181 unsigned FSModRefsAbbrev,
182 unsigned FSModVTableRefsAbbrev);
185 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
189 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
192 assert(VMI != GUIDToValueIdMap.end() &&
193 "GUID does not have assigned value Id");
199 if (!VI.haveGVs() || !VI.getValue())
200 return getValueId(VI.getGUID());
201 return VE.getValueID(VI.getValue());
204 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
206 uint64_t bitcodeStartBit() {
return BitcodeStartBit; }
208 size_t addToStrtab(StringRef Str);
210 unsigned createDILocationAbbrev();
211 unsigned createGenericDINodeAbbrev();
213 void writeAttributeGroupTable();
214 void writeAttributeTable();
215 void writeTypeTable();
217 void writeValueSymbolTableForwardDecl();
218 void writeModuleInfo();
219 void writeValueAsMetadata(
const ValueAsMetadata *MD,
220 SmallVectorImpl<uint64_t> &Record);
221 void writeMDTuple(
const MDTuple *
N, SmallVectorImpl<uint64_t> &Record,
223 void writeDILocation(
const DILocation *
N, SmallVectorImpl<uint64_t> &Record,
225 void writeGenericDINode(
const GenericDINode *
N,
226 SmallVectorImpl<uint64_t> &Record,
unsigned &Abbrev) {
229 void writeDISubrange(
const DISubrange *
N, SmallVectorImpl<uint64_t> &Record,
231 void writeDIGenericSubrange(
const DIGenericSubrange *
N,
232 SmallVectorImpl<uint64_t> &Record,
236 void writeDIEnumerator(
const DIEnumerator *
N,
237 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
238 void writeDIBasicType(
const DIBasicType *
N, SmallVectorImpl<uint64_t> &Record,
240 void writeDIFixedPointType(
const DIFixedPointType *
N,
241 SmallVectorImpl<uint64_t> &Record,
245 void writeDIStringType(
const DIStringType *
N,
246 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
249 void writeDIDerivedType(
const DIDerivedType *
N,
250 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
251 void writeDISubrangeType(
const DISubrangeType *
N,
252 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
255 void writeDICompositeType(
const DICompositeType *
N,
256 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
257 void writeDISubroutineType(
const DISubroutineType *
N,
258 SmallVectorImpl<uint64_t> &Record,
260 void writeDIFile(
const DIFile *
N, SmallVectorImpl<uint64_t> &Record,
262 void writeDICompileUnit(
const DICompileUnit *
N,
263 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
264 void writeDISubprogram(
const DISubprogram *
N,
265 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
266 void writeDILexicalBlock(
const DILexicalBlock *
N,
267 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
268 void writeDILexicalBlockFile(
const DILexicalBlockFile *
N,
269 SmallVectorImpl<uint64_t> &Record,
271 void writeDICommonBlock(
const DICommonBlock *
N,
272 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
275 void writeDINamespace(
const DINamespace *
N, SmallVectorImpl<uint64_t> &Record,
277 void writeDIMacro(
const DIMacro *
N, SmallVectorImpl<uint64_t> &Record,
281 void writeDIMacroFile(
const DIMacroFile *
N, SmallVectorImpl<uint64_t> &Record,
285 void writeDIArgList(
const DIArgList *
N, SmallVectorImpl<uint64_t> &Record,
289 void writeDIAssignID(
const DIAssignID *
N, SmallVectorImpl<uint64_t> &Record,
296 void writeDIModule(
const DIModule *
N, SmallVectorImpl<uint64_t> &Record,
298 void writeDITemplateTypeParameter(
const DITemplateTypeParameter *
N,
299 SmallVectorImpl<uint64_t> &Record,
301 void writeDITemplateValueParameter(
const DITemplateValueParameter *
N,
302 SmallVectorImpl<uint64_t> &Record,
304 void writeDIGlobalVariable(
const DIGlobalVariable *
N,
305 SmallVectorImpl<uint64_t> &Record,
307 void writeDILocalVariable(
const DILocalVariable *
N,
308 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
309 void writeDILabel(
const DILabel *
N, SmallVectorImpl<uint64_t> &Record,
313 void writeDIExpression(
const DIExpression *
N,
314 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
315 void writeDIGlobalVariableExpression(
const DIGlobalVariableExpression *
N,
316 SmallVectorImpl<uint64_t> &Record,
320 void writeDIObjCProperty(
const DIObjCProperty *
N,
321 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
322 void writeDIImportedEntity(
const DIImportedEntity *
N,
323 SmallVectorImpl<uint64_t> &Record,
325 unsigned createNamedMetadataAbbrev();
326 void writeNamedMetadata(SmallVectorImpl<uint64_t> &Record);
327 unsigned createMetadataStringsAbbrev();
329 SmallVectorImpl<uint64_t> &Record);
331 SmallVectorImpl<uint64_t> &Record,
332 std::vector<unsigned> *MDAbbrevs =
nullptr,
333 std::vector<uint64_t> *IndexPos =
nullptr);
334 void writeModuleMetadata();
335 void writeFunctionMetadata(
const Function &
F);
336 void writeFunctionMetadataAttachment(
const Function &
F);
337 void pushGlobalMetadataAttachment(SmallVectorImpl<uint64_t> &Record,
338 const GlobalObject &GO);
339 void writeModuleMetadataKinds();
340 void writeOperandBundleTags();
341 void writeSyncScopeNames();
342 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
343 void writeModuleConstants();
344 bool pushValueAndType(
const Value *V,
unsigned InstID,
345 SmallVectorImpl<unsigned> &Vals);
346 void writeOperandBundles(
const CallBase &CB,
unsigned InstID);
347 void pushValue(
const Value *V,
unsigned InstID,
348 SmallVectorImpl<unsigned> &Vals);
349 void pushValueSigned(
const Value *V,
unsigned InstID,
350 SmallVectorImpl<uint64_t> &Vals);
351 void writeInstruction(
const Instruction &
I,
unsigned InstID,
352 SmallVectorImpl<unsigned> &Vals);
353 void writeFunctionLevelValueSymbolTable(
const ValueSymbolTable &VST);
354 void writeGlobalValueSymbolTable(
355 DenseMap<const Function *, uint64_t> &FunctionToBitcodeIndex);
356 void writeFunction(
const Function &
F);
357 void writeBlockInfo();
359 unsigned getEncodedSyncScopeID(
SyncScope::ID SSID) {
return unsigned(SSID); }
361 unsigned getEncodedAlign(MaybeAlign Alignment) {
return encode(Alignment); }
363 unsigned getTypeID(
Type *
T,
const Value *V =
nullptr);
368 unsigned getGlobalObjectValueTypeID(
Type *
T,
const GlobalObject *
G);
384 Stream->Emit((
unsigned)
'B', 8);
385 Stream->Emit((
unsigned)
'C', 8);
386 Stream->Emit(0x0, 4);
387 Stream->Emit(0xC, 4);
388 Stream->Emit(0xE, 4);
389 Stream->Emit(0xD, 4);
401 Triple TT(M.getTargetTriple());
402 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
416 auto Abbv = std::make_shared<BitCodeAbbrev>();
419 auto AbbrevNo = Stream->
EmitAbbrev(std::move(Abbv));
432 assert(M.isMaterialized());
433 Mods.push_back(
const_cast<Module *
>(&M));
436 ModuleWriter.
write();
447 case Instruction::Trunc:
449 case Instruction::ZExt:
451 case Instruction::SExt:
453 case Instruction::FPToUI:
455 case Instruction::FPToSI:
457 case Instruction::UIToFP:
459 case Instruction::SIToFP:
461 case Instruction::FPTrunc:
463 case Instruction::FPExt:
465 case Instruction::PtrToInt:
467 case Instruction::IntToPtr:
469 case Instruction::BitCast:
471 case Instruction::AddrSpaceCast:
480 case Instruction::FNeg:
489 case Instruction::Add:
490 case Instruction::FAdd:
492 case Instruction::Sub:
493 case Instruction::FSub:
495 case Instruction::Mul:
496 case Instruction::FMul:
498 case Instruction::UDiv:
500 case Instruction::FDiv:
501 case Instruction::SDiv:
503 case Instruction::URem:
505 case Instruction::FRem:
506 case Instruction::SRem:
508 case Instruction::Shl:
510 case Instruction::LShr:
512 case Instruction::AShr:
514 case Instruction::And:
516 case Instruction::Or:
518 case Instruction::Xor:
523unsigned DXILBitcodeWriter::getTypeID(
Type *
T,
const Value *V) {
524 if (!
T->isPointerTy() &&
528 return VE.getTypeID(
T);
529 auto It = PointerMap.
find(V);
530 if (It != PointerMap.
end())
531 return VE.getTypeID(It->second);
537 return VE.getTypeID(
T);
538 return VE.getTypeID(I8PtrTy);
541unsigned DXILBitcodeWriter::getGlobalObjectValueTypeID(
Type *
T,
543 auto It = PointerMap.
find(
G);
544 if (It != PointerMap.
end()) {
548 return VE.getTypeID(
T);
610 unsigned AbbrevToUse) {
621 Stream.EmitRecord(Code, Vals, AbbrevToUse);
626 case Attribute::Alignment:
628 case Attribute::AlwaysInline:
630 case Attribute::Builtin:
632 case Attribute::ByVal:
634 case Attribute::Convergent:
636 case Attribute::InAlloca:
638 case Attribute::Cold:
640 case Attribute::InlineHint:
642 case Attribute::InReg:
644 case Attribute::JumpTable:
646 case Attribute::MinSize:
648 case Attribute::Naked:
650 case Attribute::Nest:
652 case Attribute::NoAlias:
654 case Attribute::NoBuiltin:
656 case Attribute::NoDuplicate:
658 case Attribute::NoImplicitFloat:
660 case Attribute::NoInline:
662 case Attribute::NonLazyBind:
664 case Attribute::NonNull:
666 case Attribute::Dereferenceable:
668 case Attribute::DereferenceableOrNull:
670 case Attribute::NoRedZone:
672 case Attribute::NoReturn:
674 case Attribute::NoUnwind:
676 case Attribute::OptimizeForSize:
678 case Attribute::OptimizeNone:
680 case Attribute::ReadNone:
682 case Attribute::ReadOnly:
684 case Attribute::Returned:
686 case Attribute::ReturnsTwice:
688 case Attribute::SExt:
690 case Attribute::StackAlignment:
692 case Attribute::StackProtect:
694 case Attribute::StackProtectReq:
696 case Attribute::StackProtectStrong:
698 case Attribute::SafeStack:
700 case Attribute::StructRet:
702 case Attribute::SanitizeAddress:
704 case Attribute::SanitizeThread:
706 case Attribute::SanitizeMemory:
708 case Attribute::UWTable:
710 case Attribute::ZExt:
721 "should be stripped in DXILPrepare");
741 unsigned NumWords =
A.getActiveWords();
742 const uint64_t *RawData =
A.getRawData();
743 for (
unsigned i = 0; i < NumWords; i++)
751 if (OBO->hasNoSignedWrap())
753 if (OBO->hasNoUnsignedWrap())
759 if (FPMO->hasAllowReassoc() || FPMO->hasAllowContract())
761 if (FPMO->hasNoNaNs())
763 if (FPMO->hasNoInfs())
765 if (FPMO->hasNoSignedZeros())
767 if (FPMO->hasAllowReciprocal())
848 switch (
C.getSelectionKind()) {
867void DXILBitcodeWriter::writeAttributeGroupTable() {
868 const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
869 VE.getAttributeGroups();
870 if (AttrGrps.empty())
877 unsigned AttrListIndex = Pair.first;
879 Record.push_back(
VE.getAttributeGroupID(Pair));
880 Record.push_back(AttrListIndex);
883 if (Attr.isEnumAttribute()) {
886 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
889 }
else if (Attr.isIntAttribute()) {
890 if (Attr.getKindAsEnum() == Attribute::AttrKind::Memory) {
908 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
911 Record.push_back(Attr.getValueAsInt());
914 StringRef
Kind = Attr.getKindAsString();
915 StringRef Val = Attr.getValueAsString();
934void DXILBitcodeWriter::writeAttributeTable() {
935 const std::vector<AttributeList> &
Attrs = VE.getAttributeLists();
941 SmallVector<uint64_t, 64>
Record;
942 for (AttributeList AL : Attrs) {
943 for (
unsigned i :
AL.indexes()) {
944 AttributeSet AS =
AL.getAttributes(i);
946 Record.push_back(VE.getAttributeGroupID({i, AS}));
957void DXILBitcodeWriter::writeTypeTable() {
961 SmallVector<uint64_t, 64> TypeVals;
963 uint64_t NumBits = VE.computeBitsRequiredForTypeIndices();
966 auto Abbv = std::make_shared<BitCodeAbbrev>();
969 Abbv->Add(BitCodeAbbrevOp(0));
970 unsigned PtrAbbrev = Stream.EmitAbbrev(std::move(Abbv));
973 Abbv = std::make_shared<BitCodeAbbrev>();
978 unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
981 Abbv = std::make_shared<BitCodeAbbrev>();
986 unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
989 Abbv = std::make_shared<BitCodeAbbrev>();
993 unsigned StructNameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
996 Abbv = std::make_shared<BitCodeAbbrev>();
1001 unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1004 Abbv = std::make_shared<BitCodeAbbrev>();
1008 unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1016 for (
Type *
T : TypeList) {
1017 int AbbrevToUse = 0;
1020 switch (
T->getTypeID()) {
1073 AbbrevToUse = PtrAbbrev;
1084 "dxilOpaquePtrReservedName", StructNameAbbrev);
1092 TypeVals.
push_back(getTypeID(FT->getReturnType()));
1093 for (
Type *PTy : FT->params())
1095 AbbrevToUse = FunctionAbbrev;
1103 for (
Type *ElTy :
ST->elements())
1106 if (
ST->isLiteral()) {
1108 AbbrevToUse = StructAnonAbbrev;
1110 if (
ST->isOpaque()) {
1114 AbbrevToUse = StructNamedAbbrev;
1118 if (!
ST->getName().empty())
1128 TypeVals.
push_back(AT->getNumElements());
1129 TypeVals.
push_back(getTypeID(AT->getElementType()));
1130 AbbrevToUse = ArrayAbbrev;
1138 TypeVals.
push_back(VT->getElementCount().getKnownMinValue());
1139 TypeVals.
push_back(getTypeID(VT->getElementType()));
1145 Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
1152void DXILBitcodeWriter::writeComdats() {
1154 for (
const Comdat *
C : VE.getComdats()) {
1157 size_t Size =
C->getName().size();
1160 for (
char Chr :
C->getName())
1167void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
1172void DXILBitcodeWriter::writeModuleInfo() {
1177 StringRef Triple =
"dxil-ms-dx";
1178 StringRef
DL =
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-"
1179 "f16:16-f32:32-f64:64-n8:16:32:64";
1183 if (!M.getModuleInlineAsm().empty())
1189 std::map<std::string, unsigned> SectionMap;
1190 std::map<std::string, unsigned> GCMap;
1192 unsigned MaxGlobalType = 0;
1193 const auto UpdateMaxAlignment = [&
MaxAlignment](
const MaybeAlign
A) {
1197 for (
const GlobalVariable &GV : M.globals()) {
1198 UpdateMaxAlignment(GV.getAlign());
1201 MaxGlobalType = std::max(
1202 MaxGlobalType, getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1203 if (GV.hasSection()) {
1205 unsigned &
Entry = SectionMap[std::string(GV.getSection())];
1208 GV.getSection(), 0 );
1209 Entry = SectionMap.size();
1213 for (
const Function &
F : M) {
1214 UpdateMaxAlignment(
F.getAlign());
1215 if (
F.hasSection()) {
1217 unsigned &
Entry = SectionMap[std::string(
F.getSection())];
1221 Entry = SectionMap.size();
1226 unsigned &
Entry = GCMap[
F.getGC()];
1230 Entry = GCMap.size();
1236 unsigned SimpleGVarAbbrev = 0;
1237 if (!M.global_empty()) {
1240 auto Abbv = std::make_shared<BitCodeAbbrev>();
1250 Abbv->Add(BitCodeAbbrevOp(0));
1252 unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1256 if (SectionMap.empty())
1257 Abbv->Add(BitCodeAbbrevOp(0));
1262 SimpleGVarAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1267 for (
const GlobalVariable &GV : M.globals()) {
1268 unsigned AbbrevToUse = 0;
1274 Vals.
push_back(getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1276 GV.getType()->getAddressSpace() << 2 | 2 |
1277 (GV.isConstant() ? 1 : 0));
1280 GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1));
1282 Vals.
push_back(getEncodedAlign(GV.getAlign()));
1283 Vals.
push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1285 if (GV.isThreadLocal() ||
1288 GV.isExternallyInitialized() ||
1294 Vals.
push_back(GV.isExternallyInitialized());
1296 Vals.
push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1298 AbbrevToUse = SimpleGVarAbbrev;
1306 for (
const Function &
F : M) {
1310 Vals.
push_back(getGlobalObjectValueTypeID(
F.getFunctionType(), &
F));
1314 Vals.
push_back(VE.getAttributeListID(
F.getAttributes()));
1315 Vals.
push_back(getEncodedAlign(
F.getAlign()));
1316 Vals.
push_back(
F.hasSection() ? SectionMap[std::string(
F.getSection())]
1322 F.hasPrologueData() ? (VE.getValueID(
F.getPrologueData()) + 1) : 0);
1324 Vals.
push_back(
F.hasComdat() ? VE.getComdatID(
F.getComdat()) : 0);
1325 Vals.
push_back(
F.hasPrefixData() ? (VE.getValueID(
F.getPrefixData()) + 1)
1328 F.hasPersonalityFn() ? (VE.getValueID(
F.getPersonalityFn()) + 1) : 0);
1330 unsigned AbbrevToUse = 0;
1336 for (
const GlobalAlias &
A : M.aliases()) {
1339 Vals.
push_back(VE.getValueID(
A.getAliasee()));
1345 unsigned AbbrevToUse = 0;
1351void DXILBitcodeWriter::writeValueAsMetadata(
1352 const ValueAsMetadata *MD, SmallVectorImpl<uint64_t> &Record) {
1355 Type *Ty =
V->getType();
1360 Record.push_back(getTypeID(Ty, V));
1361 Record.push_back(VE.getValueID(V));
1366void DXILBitcodeWriter::writeMDTuple(
const MDTuple *
N,
1367 SmallVectorImpl<uint64_t> &Record,
1369 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
1372 "Unexpected function-local metadata");
1373 Record.push_back(VE.getMetadataOrNullID(MD));
1381void DXILBitcodeWriter::writeDILocation(
const DILocation *
N,
1382 SmallVectorImpl<uint64_t> &Record,
1385 Abbrev = createDILocationAbbrev();
1386 Record.push_back(
N->isDistinct());
1387 Record.push_back(
N->getLine());
1388 Record.push_back(
N->getColumn());
1389 Record.push_back(VE.getMetadataID(
N->getScope()));
1390 Record.push_back(VE.getMetadataOrNullID(
N->getInlinedAt()));
1399 return I < 0 ? ~(U << 1) : U << 1;
1402void DXILBitcodeWriter::writeDISubrange(
const DISubrange *
N,
1403 SmallVectorImpl<uint64_t> &Record,
1405 Record.push_back(
N->isDistinct());
1410 assert(
Count &&
"Count is missing or not ConstantInt");
1411 Record.push_back(
Count->getValue().getSExtValue());
1414 DISubrange::BoundType LowerBound =
N->getLowerBound();
1416 "Lower bound provided but not ConstantInt");
1424void DXILBitcodeWriter::writeDIEnumerator(
const DIEnumerator *
N,
1425 SmallVectorImpl<uint64_t> &Record,
1427 Record.push_back(
N->isDistinct());
1429 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1435void DXILBitcodeWriter::writeDIBasicType(
const DIBasicType *
N,
1436 SmallVectorImpl<uint64_t> &Record,
1438 Record.push_back(
N->isDistinct());
1439 Record.push_back(
N->getTag());
1440 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1441 Record.push_back(
N->getSizeInBits());
1442 Record.push_back(
N->getAlignInBits());
1443 Record.push_back(
N->getEncoding());
1449void DXILBitcodeWriter::writeDIDerivedType(
const DIDerivedType *
N,
1450 SmallVectorImpl<uint64_t> &Record,
1452 Record.push_back(
N->isDistinct());
1453 Record.push_back(
N->getTag());
1454 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1455 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1456 Record.push_back(
N->getLine());
1457 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1458 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1459 Record.push_back(
N->getSizeInBits());
1460 Record.push_back(
N->getAlignInBits());
1461 Record.push_back(
N->getOffsetInBits());
1462 Record.push_back(
N->getFlags());
1463 Record.push_back(VE.getMetadataOrNullID(
N->getExtraData()));
1469void DXILBitcodeWriter::writeDICompositeType(
const DICompositeType *
N,
1470 SmallVectorImpl<uint64_t> &Record,
1472 Record.push_back(
N->isDistinct());
1473 Record.push_back(
N->getTag());
1474 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1475 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1476 Record.push_back(
N->getLine());
1477 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1478 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1479 Record.push_back(
N->getSizeInBits());
1480 Record.push_back(
N->getAlignInBits());
1481 Record.push_back(
N->getOffsetInBits());
1482 Record.push_back(
N->getFlags());
1483 Record.push_back(VE.getMetadataOrNullID(
N->getElements().get()));
1484 Record.push_back(
N->getRuntimeLang());
1485 Record.push_back(VE.getMetadataOrNullID(
N->getVTableHolder()));
1486 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1487 Record.push_back(VE.getMetadataOrNullID(
N->getRawIdentifier()));
1493void DXILBitcodeWriter::writeDISubroutineType(
const DISubroutineType *
N,
1494 SmallVectorImpl<uint64_t> &Record,
1496 Record.push_back(
N->isDistinct());
1497 Record.push_back(
N->getFlags());
1498 Record.push_back(VE.getMetadataOrNullID(
N->getTypeArray().get()));
1504void DXILBitcodeWriter::writeDIFile(
const DIFile *
N,
1505 SmallVectorImpl<uint64_t> &Record,
1507 Record.push_back(
N->isDistinct());
1508 Record.push_back(VE.getMetadataOrNullID(
N->getRawFilename()));
1509 Record.push_back(VE.getMetadataOrNullID(
N->getRawDirectory()));
1515void DXILBitcodeWriter::writeDICompileUnit(
const DICompileUnit *
N,
1516 SmallVectorImpl<uint64_t> &Record,
1518 Record.push_back(
N->isDistinct());
1519 Record.push_back(
N->getSourceLanguage().getUnversionedName());
1520 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1521 Record.push_back(VE.getMetadataOrNullID(
N->getRawProducer()));
1522 Record.push_back(
N->isOptimized());
1523 Record.push_back(VE.getMetadataOrNullID(
N->getRawFlags()));
1524 Record.push_back(
N->getRuntimeVersion());
1525 Record.push_back(VE.getMetadataOrNullID(
N->getRawSplitDebugFilename()));
1526 Record.push_back(
N->getEmissionKind());
1527 Record.push_back(VE.getMetadataOrNullID(
N->getEnumTypes().get()));
1528 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedTypes().get()));
1530 Record.push_back(VE.getMetadataOrNullID(
N->getGlobalVariables().get()));
1531 Record.push_back(VE.getMetadataOrNullID(
N->getImportedEntities().get()));
1532 Record.push_back(
N->getDWOId());
1538void DXILBitcodeWriter::writeDISubprogram(
const DISubprogram *
N,
1539 SmallVectorImpl<uint64_t> &Record,
1541 Record.push_back(
N->isDistinct());
1542 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1543 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1544 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1545 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1546 Record.push_back(
N->getLine());
1547 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1548 Record.push_back(
N->isLocalToUnit());
1549 Record.push_back(
N->isDefinition());
1550 Record.push_back(
N->getScopeLine());
1551 Record.push_back(VE.getMetadataOrNullID(
N->getContainingType()));
1552 Record.push_back(
N->getVirtuality());
1553 Record.push_back(
N->getVirtualIndex());
1554 Record.push_back(
N->getFlags());
1555 Record.push_back(
N->isOptimized());
1556 Record.push_back(VE.getMetadataOrNullID(
N->getRawUnit()));
1557 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1558 Record.push_back(VE.getMetadataOrNullID(
N->getDeclaration()));
1559 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedNodes().get()));
1565void DXILBitcodeWriter::writeDILexicalBlock(
const DILexicalBlock *
N,
1566 SmallVectorImpl<uint64_t> &Record,
1568 Record.push_back(
N->isDistinct());
1569 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1570 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1571 Record.push_back(
N->getLine());
1572 Record.push_back(
N->getColumn());
1578void DXILBitcodeWriter::writeDILexicalBlockFile(
1579 const DILexicalBlockFile *
N, 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(
N->getDiscriminator());
1590void DXILBitcodeWriter::writeDINamespace(
const DINamespace *
N,
1591 SmallVectorImpl<uint64_t> &Record,
1593 Record.push_back(
N->isDistinct());
1594 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1595 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1596 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1603void DXILBitcodeWriter::writeDIModule(
const DIModule *
N,
1604 SmallVectorImpl<uint64_t> &Record,
1606 Record.push_back(
N->isDistinct());
1607 for (
auto &
I :
N->operands())
1608 Record.push_back(VE.getMetadataOrNullID(
I));
1614void DXILBitcodeWriter::writeDITemplateTypeParameter(
1615 const DITemplateTypeParameter *
N, SmallVectorImpl<uint64_t> &Record,
1617 Record.push_back(
N->isDistinct());
1618 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1619 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1625void DXILBitcodeWriter::writeDITemplateValueParameter(
1626 const DITemplateValueParameter *
N, SmallVectorImpl<uint64_t> &Record,
1628 Record.push_back(
N->isDistinct());
1629 Record.push_back(
N->getTag());
1630 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1631 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1632 Record.push_back(VE.getMetadataOrNullID(
N->getValue()));
1638void DXILBitcodeWriter::writeDIGlobalVariable(
const DIGlobalVariable *
N,
1639 SmallVectorImpl<uint64_t> &Record,
1641 Record.push_back(
N->isDistinct());
1642 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1643 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1644 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1645 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1646 Record.push_back(
N->getLine());
1647 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1648 Record.push_back(
N->isLocalToUnit());
1649 Record.push_back(
N->isDefinition());
1651 Record.push_back(VE.getMetadataOrNullID(
N->getStaticDataMemberDeclaration()));
1657void DXILBitcodeWriter::writeDILocalVariable(
const DILocalVariable *
N,
1658 SmallVectorImpl<uint64_t> &Record,
1660 Record.push_back(
N->isDistinct());
1661 Record.push_back(
N->getTag());
1662 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1663 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1664 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1665 Record.push_back(
N->getLine());
1666 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1667 Record.push_back(
N->getArg());
1668 Record.push_back(
N->getFlags());
1674void DXILBitcodeWriter::writeDIExpression(
const DIExpression *
N,
1675 SmallVectorImpl<uint64_t> &Record,
1677 Record.reserve(
N->getElements().size() + 1);
1679 Record.push_back(
N->isDistinct());
1680 Record.append(
N->elements_begin(),
N->elements_end());
1686void DXILBitcodeWriter::writeDIObjCProperty(
const DIObjCProperty *
N,
1687 SmallVectorImpl<uint64_t> &Record,
1692void DXILBitcodeWriter::writeDIImportedEntity(
const DIImportedEntity *
N,
1693 SmallVectorImpl<uint64_t> &Record,
1695 Record.push_back(
N->isDistinct());
1696 Record.push_back(
N->getTag());
1697 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1698 Record.push_back(VE.getMetadataOrNullID(
N->getEntity()));
1699 Record.push_back(
N->getLine());
1700 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1706unsigned DXILBitcodeWriter::createDILocationAbbrev() {
1711 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1718 return Stream.EmitAbbrev(std::move(Abbv));
1721unsigned DXILBitcodeWriter::createGenericDINodeAbbrev() {
1726 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1734 return Stream.EmitAbbrev(std::move(Abbv));
1738 SmallVectorImpl<uint64_t> &Record,
1739 std::vector<unsigned> *MDAbbrevs,
1740 std::vector<uint64_t> *IndexPos) {
1745#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1746#include "llvm/IR/Metadata.def"
1750 IndexPos->push_back(Stream.GetCurrentBitNo());
1752 assert(
N->isResolved() &&
"Expected forward references to be resolved");
1754 switch (
N->getMetadataID()) {
1757#define HANDLE_MDNODE_LEAF(CLASS) \
1758 case Metadata::CLASS##Kind: \
1760 write##CLASS(cast<CLASS>(N), Record, \
1761 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1763 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1765#include "llvm/IR/Metadata.def"
1772unsigned DXILBitcodeWriter::createMetadataStringsAbbrev() {
1773 auto Abbv = std::make_shared<BitCodeAbbrev>();
1777 return Stream.EmitAbbrev(std::move(Abbv));
1780void DXILBitcodeWriter::writeMetadataStrings(
1782 if (Strings.
empty())
1785 unsigned MDSAbbrev = createMetadataStringsAbbrev();
1787 for (
const Metadata *MD : Strings) {
1798void DXILBitcodeWriter::writeModuleMetadata() {
1799 if (!VE.hasMDs() && M.named_metadata_empty())
1806 std::vector<unsigned> MDAbbrevs;
1809 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1810 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1811 createGenericDINodeAbbrev();
1813 unsigned NameAbbrev = 0;
1814 if (!M.named_metadata_empty()) {
1816 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1820 NameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1823 SmallVector<uint64_t, 64>
Record;
1824 writeMetadataStrings(VE.getMDStrings(), Record);
1826 std::vector<uint64_t> IndexPos;
1827 IndexPos.reserve(VE.getNonMDStrings().size());
1828 writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1831 for (
const NamedMDNode &NMD : M.named_metadata()) {
1833 StringRef Str = NMD.getName();
1834 Record.append(Str.bytes_begin(), Str.bytes_end());
1839 for (
const MDNode *
N : NMD.operands())
1840 Record.push_back(VE.getMetadataID(
N));
1848void DXILBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
1853 SmallVector<uint64_t, 64>
Record;
1854 writeMetadataStrings(VE.getMDStrings(), Record);
1855 writeMetadataRecords(VE.getNonMDStrings(), Record);
1859void DXILBitcodeWriter::writeFunctionMetadataAttachment(
const Function &
F) {
1862 SmallVector<uint64_t, 64>
Record;
1867 F.getAllMetadata(MDs);
1869 for (
const auto &
I : MDs) {
1871 Record.push_back(VE.getMetadataID(
I.second));
1877 for (
const BasicBlock &BB :
F)
1878 for (
const Instruction &
I : BB) {
1880 I.getAllMetadataOtherThanDebugLoc(MDs);
1886 Record.push_back(VE.getInstructionID(&
I));
1888 for (
unsigned i = 0, e = MDs.size(); i != e; ++i) {
1889 Record.push_back(MDs[i].first);
1890 Record.push_back(VE.getMetadataID(MDs[i].second));
1899void DXILBitcodeWriter::writeModuleMetadataKinds() {
1900 SmallVector<uint64_t, 64>
Record;
1905 M.getMDKindNames(Names);
1912 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
1913 Record.push_back(MDKindID);
1914 StringRef KName = Names[MDKindID];
1924void DXILBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
1926 if (FirstVal == LastVal)
1931 unsigned AggregateAbbrev = 0;
1932 unsigned String8Abbrev = 0;
1933 unsigned CString7Abbrev = 0;
1934 unsigned CString6Abbrev = 0;
1938 auto Abbv = std::make_shared<BitCodeAbbrev>();
1943 AggregateAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1946 Abbv = std::make_shared<BitCodeAbbrev>();
1950 String8Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1952 Abbv = std::make_shared<BitCodeAbbrev>();
1956 CString7Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1958 Abbv = std::make_shared<BitCodeAbbrev>();
1962 CString6Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1965 SmallVector<uint64_t, 64>
Record;
1968 Type *LastTy =
nullptr;
1969 for (
unsigned i = FirstVal; i != LastVal; ++i) {
1970 const Value *
V = Vals[i].first;
1972 if (
V->getType() != LastTy) {
1973 LastTy =
V->getType();
1974 Record.push_back(getTypeID(LastTy, V));
1976 CONSTANTS_SETTYPE_ABBREV);
1981 Record.push_back(
unsigned(
IA->hasSideEffects()) |
1982 unsigned(
IA->isAlignStack()) << 1 |
1983 unsigned(
IA->getDialect() & 1) << 2);
1986 StringRef AsmStr =
IA->getAsmString();
1991 StringRef ConstraintStr =
IA->getConstraintString();
1999 unsigned Code = -1U;
2000 unsigned AbbrevToUse = 0;
2001 if (
C->isNullValue()) {
2006 if (
IV->getBitWidth() <= 64) {
2007 uint64_t
V =
IV->getSExtValue();
2010 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2016 unsigned NWords =
IV->getValue().getActiveWords();
2017 const uint64_t *RawWords =
IV->getValue().getRawData();
2018 for (
unsigned i = 0; i != NWords; ++i) {
2026 if (BV->getBitWidth() <= 64) {
2027 uint64_t
V = BV->getSExtValue();
2030 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2032 unsigned NWords = BV->getValue().getActiveWords();
2033 const uint64_t *RawWords = BV->getValue().getRawData();
2034 for (
unsigned i = 0; i != NWords; ++i) {
2043 Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2047 APInt api = CFP->getValueAPF().bitcastToAPInt();
2049 Record.push_back((p[1] << 48) | (p[0] >> 16));
2050 Record.push_back(p[0] & 0xffffLL);
2052 APInt api = CFP->getValueAPF().bitcastToAPInt();
2057 assert(0 &&
"Unknown FP type!");
2063 unsigned NumElts = Str->getNumElements();
2065 if (Str->isCString()) {
2070 AbbrevToUse = String8Abbrev;
2074 for (
unsigned i = 0; i != NumElts; ++i) {
2075 unsigned char V = Str->getElementAsInteger(i);
2077 isCStr7 &= (
V & 128) == 0;
2083 AbbrevToUse = CString6Abbrev;
2085 AbbrevToUse = CString7Abbrev;
2086 }
else if (
const ConstantDataSequential *CDS =
2089 Type *EltTy = CDS->getElementType();
2091 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2092 Record.push_back(CDS->getElementAsInteger(i));
2094 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2099 F = CDS->getElementAsFloat(i);
2104 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2109 F = CDS->getElementAsDouble(i);
2116 for (
const Value *
Op :
C->operands())
2117 Record.push_back(VE.getValueID(
Op));
2118 AbbrevToUse = AggregateAbbrev;
2120 switch (
CE->getOpcode()) {
2126 getTypeID(
C->getOperand(0)->getType(),
C->getOperand(0)));
2127 Record.push_back(VE.getValueID(
C->getOperand(0)));
2128 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2130 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2133 Record.push_back(VE.getValueID(
C->getOperand(0)));
2134 Record.push_back(VE.getValueID(
C->getOperand(1)));
2140 case Instruction::GetElementPtr: {
2143 if (GO->isInBounds())
2145 Record.push_back(getTypeID(GO->getSourceElementType()));
2146 for (
unsigned i = 0, e =
CE->getNumOperands(); i != e; ++i) {
2148 getTypeID(
C->getOperand(i)->getType(),
C->getOperand(i)));
2149 Record.push_back(VE.getValueID(
C->getOperand(i)));
2153 case Instruction::Select:
2155 Record.push_back(VE.getValueID(
C->getOperand(0)));
2156 Record.push_back(VE.getValueID(
C->getOperand(1)));
2157 Record.push_back(VE.getValueID(
C->getOperand(2)));
2159 case Instruction::ExtractElement:
2161 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2162 Record.push_back(VE.getValueID(
C->getOperand(0)));
2163 Record.push_back(getTypeID(
C->getOperand(1)->getType()));
2164 Record.push_back(VE.getValueID(
C->getOperand(1)));
2166 case Instruction::InsertElement:
2168 Record.push_back(VE.getValueID(
C->getOperand(0)));
2169 Record.push_back(VE.getValueID(
C->getOperand(1)));
2170 Record.push_back(getTypeID(
C->getOperand(2)->getType()));
2171 Record.push_back(VE.getValueID(
C->getOperand(2)));
2173 case Instruction::ShuffleVector:
2178 if (
C->getType() ==
C->getOperand(0)->getType()) {
2182 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2184 Record.push_back(VE.getValueID(
C->getOperand(0)));
2185 Record.push_back(VE.getValueID(
C->getOperand(1)));
2186 Record.push_back(VE.getValueID(
C->getOperand(2)));
2191 Record.push_back(getTypeID(BA->getFunction()->getType()));
2192 Record.push_back(VE.getValueID(BA->getFunction()));
2193 Record.push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2200 Stream.EmitRecord(Code, Record, AbbrevToUse);
2207void DXILBitcodeWriter::writeModuleConstants() {
2212 for (
unsigned i = 0, e = Vals.size(); i != e; ++i) {
2214 writeConstants(i, Vals.size(),
true);
2228bool DXILBitcodeWriter::pushValueAndType(
const Value *V,
unsigned InstID,
2229 SmallVectorImpl<unsigned> &Vals) {
2230 unsigned ValID = VE.getValueID(V);
2233 if (ValID >= InstID) {
2242void DXILBitcodeWriter::pushValue(
const Value *V,
unsigned InstID,
2243 SmallVectorImpl<unsigned> &Vals) {
2244 unsigned ValID = VE.getValueID(V);
2248void DXILBitcodeWriter::pushValueSigned(
const Value *V,
unsigned InstID,
2249 SmallVectorImpl<uint64_t> &Vals) {
2250 unsigned ValID = VE.getValueID(V);
2251 int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2256void DXILBitcodeWriter::writeInstruction(
const Instruction &
I,
unsigned InstID,
2257 SmallVectorImpl<unsigned> &Vals) {
2259 unsigned AbbrevToUse = 0;
2260 VE.setInstructionID(&
I);
2261 switch (
I.getOpcode()) {
2265 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2266 AbbrevToUse = (unsigned)FUNCTION_INST_CAST_ABBREV;
2272 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2273 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_ABBREV;
2274 pushValue(
I.getOperand(1), InstID, Vals);
2278 if (AbbrevToUse == (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2279 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV;
2285 case Instruction::GetElementPtr: {
2287 AbbrevToUse = (unsigned)FUNCTION_INST_GEP_ABBREV;
2290 Vals.
push_back(getTypeID(GEPInst.getSourceElementType()));
2291 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i)
2292 pushValueAndType(
I.getOperand(i), InstID, Vals);
2295 case Instruction::ExtractValue: {
2297 pushValueAndType(
I.getOperand(0), InstID, Vals);
2302 case Instruction::InsertValue: {
2304 pushValueAndType(
I.getOperand(0), InstID, Vals);
2305 pushValueAndType(
I.getOperand(1), InstID, Vals);
2310 case Instruction::Select:
2312 pushValueAndType(
I.getOperand(1), InstID, Vals);
2313 pushValue(
I.getOperand(2), InstID, Vals);
2314 pushValueAndType(
I.getOperand(0), InstID, Vals);
2316 case Instruction::ExtractElement:
2318 pushValueAndType(
I.getOperand(0), InstID, Vals);
2319 pushValueAndType(
I.getOperand(1), InstID, Vals);
2321 case Instruction::InsertElement:
2323 pushValueAndType(
I.getOperand(0), InstID, Vals);
2324 pushValue(
I.getOperand(1), InstID, Vals);
2325 pushValueAndType(
I.getOperand(2), InstID, Vals);
2327 case Instruction::ShuffleVector:
2329 pushValueAndType(
I.getOperand(0), InstID, Vals);
2330 pushValue(
I.getOperand(1), InstID, Vals);
2334 case Instruction::ICmp:
2335 case Instruction::FCmp: {
2338 pushValueAndType(
I.getOperand(0), InstID, Vals);
2339 pushValue(
I.getOperand(1), InstID, Vals);
2347 case Instruction::Ret: {
2349 unsigned NumOperands =
I.getNumOperands();
2350 if (NumOperands == 0)
2351 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VOID_ABBREV;
2352 else if (NumOperands == 1) {
2353 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2354 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VAL_ABBREV;
2356 for (
unsigned i = 0, e = NumOperands; i !=
e; ++i)
2357 pushValueAndType(
I.getOperand(i), InstID, Vals);
2360 case Instruction::UncondBr:
2364 case Instruction::CondBr: {
2367 Vals.
push_back(VE.getValueID(
II.getSuccessor(0)));
2368 Vals.
push_back(VE.getValueID(
II.getSuccessor(1)));
2369 pushValue(
II.getCondition(), InstID, Vals);
2371 case Instruction::Switch: {
2374 Vals.
push_back(getTypeID(
SI.getCondition()->getType()));
2375 pushValue(
SI.getCondition(), InstID, Vals);
2376 Vals.
push_back(VE.getValueID(
SI.getDefaultDest()));
2377 for (
auto Case :
SI.cases()) {
2378 Vals.
push_back(VE.getValueID(Case.getCaseValue()));
2379 Vals.
push_back(VE.getValueID(Case.getCaseSuccessor()));
2382 case Instruction::IndirectBr:
2384 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2386 pushValue(
I.getOperand(0), InstID, Vals);
2387 for (
unsigned i = 1, e =
I.getNumOperands(); i != e; ++i)
2388 Vals.
push_back(VE.getValueID(
I.getOperand(i)));
2391 case Instruction::Invoke: {
2394 FunctionType *FTy =
II->getFunctionType();
2397 Vals.
push_back(VE.getAttributeListID(
II->getAttributes()));
2399 Vals.
push_back(VE.getValueID(
II->getNormalDest()));
2400 Vals.
push_back(VE.getValueID(
II->getUnwindDest()));
2402 pushValueAndType(Callee, InstID, Vals);
2405 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2406 pushValue(
I.getOperand(i), InstID, Vals);
2409 if (FTy->isVarArg()) {
2410 for (
unsigned i = FTy->getNumParams(), e =
I.getNumOperands() - 3; i != e;
2412 pushValueAndType(
I.getOperand(i), InstID, Vals);
2416 case Instruction::Resume:
2418 pushValueAndType(
I.getOperand(0), InstID, Vals);
2420 case Instruction::Unreachable:
2422 AbbrevToUse = (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV;
2425 case Instruction::PHI: {
2438 Stream.EmitRecord(Code, Vals64, AbbrevToUse);
2443 case Instruction::LandingPad: {
2454 pushValueAndType(LP.
getClause(
I), InstID, Vals);
2459 case Instruction::Alloca: {
2463 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2464 Vals.
push_back(VE.getValueID(
I.getOperand(0)));
2466 assert(AlignRecord < 1 << 5 &&
"alignment greater than 1 << 64");
2468 AlignRecord |= 1 << 6;
2473 case Instruction::Load:
2476 pushValueAndType(
I.getOperand(0), InstID, Vals);
2479 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2480 AbbrevToUse = (unsigned)FUNCTION_INST_LOAD_ABBREV;
2490 case Instruction::Store:
2495 pushValueAndType(
I.getOperand(1), InstID, Vals);
2496 pushValueAndType(
I.getOperand(0), InstID, Vals);
2505 case Instruction::AtomicCmpXchg:
2507 pushValueAndType(
I.getOperand(0), InstID, Vals);
2508 pushValueAndType(
I.getOperand(1), InstID, Vals);
2509 pushValue(
I.getOperand(2), InstID, Vals);
2519 case Instruction::AtomicRMW:
2521 pushValueAndType(
I.getOperand(0), InstID, Vals);
2522 pushValue(
I.getOperand(1), InstID, Vals);
2530 case Instruction::Fence:
2535 case Instruction::Call: {
2548 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
2550 if (FTy->getParamType(i)->isLabelTy())
2557 if (FTy->isVarArg()) {
2558 for (
unsigned i = FTy->getNumParams(), e = CI.
arg_size(); i != e; ++i)
2563 case Instruction::VAArg:
2565 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2566 pushValue(
I.getOperand(0), InstID, Vals);
2571 Stream.EmitRecord(Code, Vals, AbbrevToUse);
2576void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
2577 const ValueSymbolTable &VST) {
2589 for (
auto &VI : VST) {
2594 return A->first() <
B->first();
2597 for (
const ValueName *SI : SortedTable) {
2602 bool isChar6 =
true;
2603 for (
const char *
C =
Name.getKeyData(), *
E =
C +
Name.getKeyLength();
2607 if ((
unsigned char)*
C & 128) {
2613 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2621 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2625 AbbrevToUse = VST_ENTRY_6_ABBREV;
2627 AbbrevToUse = VST_ENTRY_7_ABBREV;
2630 NameVals.
push_back(VE.getValueID(
SI->getValue()));
2631 for (
const char *
P =
Name.getKeyData(),
2632 *
E =
Name.getKeyData() +
Name.getKeyLength();
2637 Stream.EmitRecord(Code, NameVals, AbbrevToUse);
2644void DXILBitcodeWriter::writeFunction(
const Function &
F) {
2646 VE.incorporateFunction(
F);
2652 Vals.
push_back(VE.getBasicBlocks().size());
2657 unsigned CstStart, CstEnd;
2658 VE.getFunctionConstantRange(CstStart, CstEnd);
2659 writeConstants(CstStart, CstEnd,
false);
2662 writeFunctionMetadata(
F);
2665 unsigned InstID = CstEnd;
2667 bool NeedsMetadataAttachment =
F.hasMetadata();
2669 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< 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 the declaration of the GlobalIFunc class, which represents a single indirect funct...
Module.h This file contains the declarations for the Module class.
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
uint64_t IntrinsicInst * II
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
static const uint32_t IV[8]
Class for arbitrary precision integers.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
int64_t getSExtValue() const
Get sign extended value.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ Min
*p = old <signed v ? old : v
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
This class holds the attributes for a particular argument, parameter, function, or return value.
bool hasAttributes() const
Return true if attributes exists in this set.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
@ None
No attributes have been set.
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
@ EndAttrKinds
Sentinel value useful for loops.
InstListType::const_iterator const_iterator
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
static bool isChar6(char C)
isChar6 - Return true if this character is legal in the Char6 encoding.
unsigned EmitAbbrev(std::shared_ptr< BitCodeAbbrev > Abbv)
Emits the abbreviation Abbv to the stream.
void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals, StringRef Blob)
EmitRecordWithBlob - Emit the specified record to the stream, using an abbrev that includes a blob at...
void EnterSubblock(unsigned BlockID, unsigned CodeLen)
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
CallingConv::ID getCallingConv() const
Value * getCalledOperand() const
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
bool isMustTailCall() const
@ Largest
The linker will choose the largest COMDAT.
@ SameSize
The data referenced by the COMDAT must be the same size.
@ Any
The linker may choose any COMDAT.
@ NoDeduplicate
No deduplication is performed.
@ ExactMatch
The data referenced by the COMDAT must be the same.
iterator find(const_arg_type_t< KeyT > Val)
BasicBlockListType::const_iterator const_iterator
Function and variable summary information to aid decisions and implementation of importing.
VisibilityTypes getVisibility() const
LinkageTypes getLinkage() const
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
ThreadLocalMode getThreadLocalMode() const
@ DLLExportStorageClass
Function to be accessible from DLL.
@ DLLImportStorageClass
Function to be imported from DLL.
@ DefaultVisibility
The GV is visible.
@ HiddenVisibility
The GV is hidden.
@ ProtectedVisibility
The GV is protected.
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
DLLStorageClassTypes getDLLStorageClass() const
idx_iterator idx_end() const
idx_iterator idx_begin() const
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
const unsigned char * bytes_begin() const
const unsigned char * bytes_end() const
bool doesNotAccessMemory() const
Whether this function accesses no memory.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
A Module instance is used to store all the information related to an LLVM module.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
Utility for building string tables with deduplicated suffixes.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isX86_FP80Ty() const
Return true if this is x86 long double.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ TypedPointerTyID
Typed pointer used by some GPU targets.
@ HalfTyID
16-bit floating point type
@ TargetExtTyID
Target extension type.
@ VoidTyID
type with no size
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ ByteTyID
Arbitrary bit width bytes.
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
bool isFP128Ty() const
Return true if this is 'fp128'.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
A few GPU targets, such as DXIL and SPIR-V, have typed pointers.
Type * getElementType() const
static LLVM_ABI TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void writeModule(const Module &M)
Write the specified module to the buffer specified at construction time.
BitcodeWriter(SmallVectorImpl< char > &Buffer)
Create a BitcodeWriter that writes to Buffer.
static void emitWideAPInt(SmallVectorImpl< uint64_t > &Vals, const APInt &A)
static unsigned getEncodedThreadLocalMode(const GlobalValue &GV)
static unsigned getEncodedCastOpcode(unsigned Opcode)
Begin dxil::BitcodeWriterBase Implementation.
static void writeStringRecord(BitstreamWriter &Stream, unsigned Code, StringRef Str, unsigned AbbrevToUse)
static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind)
static unsigned getEncodedDLLStorageClass(const GlobalValue &GV)
static unsigned getEncodedOrdering(AtomicOrdering Ordering)
static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage)
static unsigned getEncodedVisibility(const GlobalValue &GV)
void write()
Emit the current module to the bitstream.
static void writeIdentificationBlock(BitstreamWriter &Stream)
static unsigned getEncodedBinaryOpcode(unsigned Opcode)
static void emitSignedInt64(SmallVectorImpl< uint64_t > &Vals, uint64_t V)
static unsigned getEncodedUnaryOpcode(unsigned Opcode)
static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op)
DXILBitcodeWriter(const Module &M, SmallVectorImpl< char > &Buffer, StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream)
Constructs a ModuleBitcodeWriter object for the given Module, writing to the provided Buffer.
static unsigned getEncodedComdatSelectionKind(const Comdat &C)
static uint64_t getOptimizationFlags(const Value *V)
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
std::vector< std::pair< const Value *, unsigned > > ValueList
std::vector< Type * > TypeList
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write(unsigned char C)
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
@ C
The default llvm calling convention, compatible with C.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
@ CE
Windows NT (Windows on ARM)
@ METADATA_TEMPLATE_VALUE
@ METADATA_LEXICAL_BLOCK_FILE
@ METADATA_SUBROUTINE_TYPE
@ METADATA_IMPORTED_ENTITY
@ METADATA_COMPOSITE_TYPE
@ CST_CODE_CE_INBOUNDS_GEP
@ COMDAT_SELECTION_KIND_LARGEST
@ COMDAT_SELECTION_KIND_ANY
@ COMDAT_SELECTION_KIND_SAME_SIZE
@ COMDAT_SELECTION_KIND_EXACT_MATCH
@ COMDAT_SELECTION_KIND_NO_DUPLICATES
@ ATTR_KIND_STACK_PROTECT
@ ATTR_KIND_STACK_PROTECT_STRONG
@ ATTR_KIND_SANITIZE_MEMORY
@ ATTR_KIND_OPTIMIZE_FOR_SIZE
@ ATTR_KIND_SANITIZE_ADDRESS
@ ATTR_KIND_NO_IMPLICIT_FLOAT
@ ATTR_KIND_STACK_ALIGNMENT
@ ATTR_KIND_STACK_PROTECT_REQ
@ ATTR_KIND_RETURNS_TWICE
@ ATTR_KIND_NON_LAZY_BIND
@ ATTR_KIND_DEREFERENCEABLE
@ ATTR_KIND_OPTIMIZE_NONE
@ ATTR_KIND_DEREFERENCEABLE_OR_NULL
@ ATTR_KIND_ALWAYS_INLINE
@ ATTR_KIND_SANITIZE_THREAD
@ PARAMATTR_GROUP_BLOCK_ID
@ MODULE_CODE_SECTIONNAME
@ FUNC_CODE_INST_LANDINGPAD
@ FUNC_CODE_INST_EXTRACTVAL
@ FUNC_CODE_INST_LOADATOMIC
@ FUNC_CODE_INST_STOREATOMIC
@ FUNC_CODE_INST_ATOMICRMW
@ FUNC_CODE_DEBUG_LOC_AGAIN
@ FUNC_CODE_INST_EXTRACTELT
@ FUNC_CODE_INST_INDIRECTBR
@ FUNC_CODE_INST_INSERTVAL
@ FUNC_CODE_DECLAREBLOCKS
@ FUNC_CODE_INST_INSERTELT
@ FUNC_CODE_INST_SHUFFLEVEC
@ FUNC_CODE_INST_UNREACHABLE
@ FIRST_APPLICATION_ABBREV
@ PARAMATTR_GRP_CODE_ENTRY
An analysis to compute the PointerTypes for pointers in a Module.
void WriteDXILToFile(const Module &M, raw_ostream &Out)
Write the specified module to the specified raw output stream.
DenseMap< const Value *, Type * > PointerTypeMap
NodeAddr< CodeNode * > Code
constexpr size_t MaxAlignment
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
FunctionAddr VTableAddr Value
StringMapEntry< Value * > ValueName
MaybeAlign getAlign(const CallInst &I, unsigned Index)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
FunctionAddr VTableAddr Count
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
AtomicOrdering
Atomic ordering for LLVM's memory model.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
unsigned Log2(Align A)
Returns the log2 of the alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
Struct that holds a reference to a particular GUID in a global value summary.