61#define HANDLE_MDNODE_LEAF(CLASS) CLASS##AbbrevID,
62#include "llvm/IR/Metadata.def"
80 CONSTANTS_INTEGER_ABBREV,
81 CONSTANTS_CE_CAST_Abbrev,
82 CONSTANTS_NULL_Abbrev,
86 FUNCTION_INST_BINOP_ABBREV,
87 FUNCTION_INST_BINOP_FLAGS_ABBREV,
88 FUNCTION_INST_CAST_ABBREV,
89 FUNCTION_INST_RET_VOID_ABBREV,
90 FUNCTION_INST_RET_VAL_ABBREV,
91 FUNCTION_INST_UNREACHABLE_ABBREV,
92 FUNCTION_INST_GEP_ABBREV,
113 std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
116 unsigned GlobalValueId;
122 uint64_t BitcodeStartBit;
138 StrtabBuilder(StrtabBuilder), M(M), VE(M, I8PtrTy, DebugInfo),
139 Buffer(Buffer), BitcodeStartBit(Stream.GetCurrentBitNo()),
141 GlobalValueId = VE.getValues().
size();
143 for (
auto El : PointerMap)
144 VE.EnumerateType(El.second);
170 void writeModuleVersion();
171 void writePerModuleGlobalValueSummary();
174 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
178 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
181 assert(VMI != GUIDToValueIdMap.end() &&
182 "GUID does not have assigned value Id");
188 if (!VI.haveGVs() || !VI.getValue())
189 return getValueId(VI.getGUID());
190 return VE.getValueID(VI.getValue());
193 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
195 uint64_t bitcodeStartBit() {
return BitcodeStartBit; }
197 unsigned createDILocationAbbrev();
198 unsigned createGenericDINodeAbbrev();
200 void writeAttributeGroupTable();
201 void writeAttributeTable();
202 void writeTypeTable();
204 void writeValueSymbolTableForwardDecl();
205 void writeModuleInfo();
206 void writeValueAsMetadata(
const ValueAsMetadata *MD,
207 SmallVectorImpl<uint64_t> &Record);
208 void writeMDTuple(
const MDTuple *
N, SmallVectorImpl<uint64_t> &Record,
210 void writeDILocation(
const DILocation *
N, SmallVectorImpl<uint64_t> &Record,
212 void writeGenericDINode(
const GenericDINode *
N,
213 SmallVectorImpl<uint64_t> &Record,
unsigned &Abbrev) {
216 void writeDISubrange(
const DISubrange *
N, SmallVectorImpl<uint64_t> &Record,
218 void writeDIGenericSubrange(
const DIGenericSubrange *
N,
219 SmallVectorImpl<uint64_t> &Record,
223 void writeDIEnumerator(
const DIEnumerator *
N,
224 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
225 void writeDIBasicType(
const DIBasicType *
N, SmallVectorImpl<uint64_t> &Record,
227 void writeDIFixedPointType(
const DIFixedPointType *
N,
228 SmallVectorImpl<uint64_t> &Record,
232 void writeDIStringType(
const DIStringType *
N,
233 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
236 void writeDIDerivedType(
const DIDerivedType *
N,
237 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
238 void writeDISubrangeType(
const DISubrangeType *
N,
239 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
242 void writeDICompositeType(
const DICompositeType *
N,
243 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
244 void writeDISubroutineType(
const DISubroutineType *
N,
245 SmallVectorImpl<uint64_t> &Record,
247 void writeDIFile(
const DIFile *
N, SmallVectorImpl<uint64_t> &Record,
249 void writeDICompileUnit(
const DICompileUnit *
N,
250 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
251 void writeDISubprogram(
const DISubprogram *
N,
252 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
253 void writeDILexicalBlock(
const DILexicalBlock *
N,
254 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
255 void writeDILexicalBlockFile(
const DILexicalBlockFile *
N,
256 SmallVectorImpl<uint64_t> &Record,
258 void writeDICommonBlock(
const DICommonBlock *
N,
259 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
262 void writeDINamespace(
const DINamespace *
N, SmallVectorImpl<uint64_t> &Record,
264 void writeDIMacro(
const DIMacro *
N, SmallVectorImpl<uint64_t> &Record,
268 void writeDIMacroFile(
const DIMacroFile *
N, SmallVectorImpl<uint64_t> &Record,
272 void writeDIArgList(
const DIArgList *
N, SmallVectorImpl<uint64_t> &Record,
276 void writeDIAssignID(
const DIAssignID *
N, SmallVectorImpl<uint64_t> &Record,
283 void writeDILayerLoc(
const DILayerLoc *
N, SmallVectorImpl<uint64_t> &Record,
287 void writeDILayerLocList(
const DILayerLocList *
N,
288 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
291 void writeDIModule(
const DIModule *
N, SmallVectorImpl<uint64_t> &Record,
293 void writeDITemplateTypeParameter(
const DITemplateTypeParameter *
N,
294 SmallVectorImpl<uint64_t> &Record,
296 void writeDITemplateValueParameter(
const DITemplateValueParameter *
N,
297 SmallVectorImpl<uint64_t> &Record,
299 void writeDIGlobalVariable(
const DIGlobalVariable *
N,
300 SmallVectorImpl<uint64_t> &Record,
302 void writeDILocalVariable(
const DILocalVariable *
N,
303 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
304 void writeDILabel(
const DILabel *
N, SmallVectorImpl<uint64_t> &Record,
308 void writeDIExpression(
const DIExpression *
N,
309 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
310 void writeDIGlobalVariableExpression(
const DIGlobalVariableExpression *
N,
311 SmallVectorImpl<uint64_t> &Record,
315 void writeDIObjCProperty(
const DIObjCProperty *
N,
316 SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev);
317 void writeDIProperty(
const DIProperty *
N, SmallVectorImpl<uint64_t> &Record,
321 void writeDIImportedEntity(
const DIImportedEntity *
N,
322 SmallVectorImpl<uint64_t> &Record,
324 unsigned createMetadataStringsAbbrev();
326 SmallVectorImpl<uint64_t> &Record);
328 SmallVectorImpl<uint64_t> &Record,
329 std::vector<unsigned> *MDAbbrevs =
nullptr,
330 std::vector<uint64_t> *IndexPos =
nullptr);
331 void writeModuleMetadata();
332 void writeFunctionMetadata(
const Function &
F);
333 void writeFunctionMetadataAttachment(
const Function &
F);
334 void writeModuleMetadataKinds();
335 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
336 void writeModuleConstants();
337 bool pushValueAndType(
const Value *
V,
unsigned InstID,
338 SmallVectorImpl<unsigned> &Vals);
339 void pushValue(
const Value *
V,
unsigned InstID,
340 SmallVectorImpl<unsigned> &Vals);
341 void pushValueSigned(
const Value *
V,
unsigned InstID,
342 SmallVectorImpl<uint64_t> &Vals);
343 void writeInstruction(
const Instruction &
I,
unsigned InstID,
344 SmallVectorImpl<unsigned> &Vals);
345 void writeFunctionLevelValueSymbolTable(
const ValueSymbolTable &VST);
347 void writeBlockInfo();
349 unsigned getEncodedSyncScopeID(
SyncScope::ID SSID) {
return unsigned(SSID); }
351 unsigned getEncodedAlign(MaybeAlign Alignment) {
return encode(Alignment); }
353 unsigned getTypeID(
Type *
T,
const Value *
V =
nullptr);
358 unsigned getGlobalObjectValueTypeID(
Type *
T,
const GlobalObject *
G);
374 Stream->Emit((
unsigned)
'B', 8);
375 Stream->Emit((
unsigned)
'C', 8);
376 Stream->Emit(0x0, 4);
377 Stream->Emit(0xC, 4);
378 Stream->Emit(0xE, 4);
379 Stream->Emit(0xD, 4);
391 Triple TT(M.getTargetTriple());
392 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
401 Out.write((
char *)&Buffer.
front(), Buffer.
size());
407 auto Abbv = std::make_shared<BitCodeAbbrev>();
410 auto AbbrevNo = Stream->
EmitAbbrev(std::move(Abbv));
424 assert(M.isMaterialized());
425 Mods.push_back(
const_cast<Module *
>(&M));
428 ModuleWriter.
write();
439 case Instruction::Trunc:
441 case Instruction::ZExt:
443 case Instruction::SExt:
445 case Instruction::FPToUI:
447 case Instruction::FPToSI:
449 case Instruction::UIToFP:
451 case Instruction::SIToFP:
453 case Instruction::FPTrunc:
455 case Instruction::FPExt:
457 case Instruction::PtrToInt:
459 case Instruction::IntToPtr:
461 case Instruction::BitCast:
463 case Instruction::AddrSpaceCast:
472 case Instruction::FNeg:
481 case Instruction::Add:
482 case Instruction::FAdd:
484 case Instruction::Sub:
485 case Instruction::FSub:
487 case Instruction::Mul:
488 case Instruction::FMul:
490 case Instruction::UDiv:
492 case Instruction::FDiv:
493 case Instruction::SDiv:
495 case Instruction::URem:
497 case Instruction::FRem:
498 case Instruction::SRem:
500 case Instruction::Shl:
502 case Instruction::LShr:
504 case Instruction::AShr:
506 case Instruction::And:
508 case Instruction::Or:
510 case Instruction::Xor:
515unsigned DXILBitcodeWriter::getTypeID(
Type *
T,
const Value *V) {
519 return VE.getTypeID(
T);
520 auto It = PointerMap.
find(V);
521 if (It != PointerMap.
end())
522 return VE.getTypeID(It->second);
526 if (
T->isPointerTy())
527 return VE.getTypeID(I8PtrTy);
528 return VE.getTypeID(
T);
531unsigned DXILBitcodeWriter::getGlobalObjectValueTypeID(
Type *
T,
533 auto It = PointerMap.
find(
G);
534 if (It != PointerMap.
end()) {
538 return VE.getTypeID(
T);
600 unsigned AbbrevToUse) {
611 Stream.EmitRecord(Code, Vals, AbbrevToUse);
616 case Attribute::Alignment:
618 case Attribute::AlwaysInline:
620 case Attribute::Builtin:
622 case Attribute::ByVal:
624 case Attribute::Convergent:
626 case Attribute::InAlloca:
628 case Attribute::Cold:
630 case Attribute::InlineHint:
632 case Attribute::InReg:
634 case Attribute::JumpTable:
636 case Attribute::MinSize:
638 case Attribute::Naked:
640 case Attribute::Nest:
642 case Attribute::NoAlias:
644 case Attribute::NoBuiltin:
646 case Attribute::NoDuplicate:
648 case Attribute::NoImplicitFloat:
650 case Attribute::NoInline:
652 case Attribute::NonLazyBind:
654 case Attribute::NonNull:
656 case Attribute::Dereferenceable:
658 case Attribute::DereferenceableOrNull:
660 case Attribute::NoRedZone:
662 case Attribute::NoReturn:
664 case Attribute::NoUnwind:
666 case Attribute::OptimizeForSize:
668 case Attribute::OptimizeNone:
670 case Attribute::ReadNone:
672 case Attribute::ReadOnly:
674 case Attribute::Returned:
676 case Attribute::ReturnsTwice:
678 case Attribute::SExt:
680 case Attribute::StackAlignment:
682 case Attribute::StackProtect:
684 case Attribute::StackProtectReq:
686 case Attribute::StackProtectStrong:
688 case Attribute::SafeStack:
690 case Attribute::StructRet:
692 case Attribute::SanitizeAddress:
694 case Attribute::SanitizeThread:
696 case Attribute::SanitizeMemory:
698 case Attribute::UWTable:
700 case Attribute::ZExt:
711 "should be stripped in DXILPrepare");
731 unsigned NumWords =
A.getActiveWords();
732 const uint64_t *RawData =
A.getRawData();
733 for (
unsigned i = 0; i < NumWords; i++)
741 if (OBO->hasNoSignedWrap())
743 if (OBO->hasNoUnsignedWrap())
749 if (FPMO->hasAllowReassoc() || FPMO->hasAllowContract())
751 if (FPMO->hasNoNaNs())
753 if (FPMO->hasNoInfs())
755 if (FPMO->hasNoSignedZeros())
757 if (FPMO->hasAllowReciprocal())
838 switch (
C.getSelectionKind()) {
857void DXILBitcodeWriter::writeAttributeGroupTable() {
858 const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
859 VE.getAttributeGroups();
860 if (AttrGrps.empty())
867 unsigned AttrListIndex = Pair.first;
869 Record.push_back(
VE.getAttributeGroupID(Pair));
870 Record.push_back(AttrListIndex);
873 if (Attr.isEnumAttribute()) {
876 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
879 }
else if (Attr.isIntAttribute()) {
880 if (Attr.getKindAsEnum() == Attribute::AttrKind::Memory) {
898 "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
901 Record.push_back(Attr.getValueAsInt());
904 StringRef
Kind = Attr.getKindAsString();
905 StringRef Val = Attr.getValueAsString();
924void DXILBitcodeWriter::writeAttributeTable() {
925 const std::vector<AttributeList> &
Attrs = VE.getAttributeLists();
931 SmallVector<uint64_t, 64>
Record;
932 for (AttributeList AL : Attrs) {
933 for (
unsigned i :
AL.indexes()) {
934 AttributeSet AS =
AL.getAttributes(i);
936 Record.push_back(VE.getAttributeGroupID({i, AS}));
947void DXILBitcodeWriter::writeTypeTable() {
951 SmallVector<uint64_t, 64> TypeVals;
953 uint64_t NumBits = VE.computeBitsRequiredForTypeIndices();
956 auto Abbv = std::make_shared<BitCodeAbbrev>();
959 Abbv->Add(BitCodeAbbrevOp(0));
960 unsigned PtrAbbrev = Stream.EmitAbbrev(std::move(Abbv));
963 Abbv = std::make_shared<BitCodeAbbrev>();
968 unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
971 Abbv = std::make_shared<BitCodeAbbrev>();
976 unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
979 Abbv = std::make_shared<BitCodeAbbrev>();
983 unsigned StructNameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
986 Abbv = std::make_shared<BitCodeAbbrev>();
991 unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
994 Abbv = std::make_shared<BitCodeAbbrev>();
998 unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1006 for (
Type *
T : TypeList) {
1007 int AbbrevToUse = 0;
1010 switch (
T->getTypeID()) {
1063 AbbrevToUse = PtrAbbrev;
1074 "dxilOpaquePtrReservedName", StructNameAbbrev);
1082 TypeVals.
push_back(getTypeID(FT->getReturnType()));
1083 for (
Type *PTy : FT->params())
1085 AbbrevToUse = FunctionAbbrev;
1093 for (
Type *ElTy :
ST->elements())
1096 if (
ST->isLiteral()) {
1098 AbbrevToUse = StructAnonAbbrev;
1100 if (
ST->isOpaque()) {
1104 AbbrevToUse = StructNamedAbbrev;
1108 if (!
ST->getName().empty())
1118 TypeVals.
push_back(AT->getNumElements());
1119 TypeVals.
push_back(getTypeID(AT->getElementType()));
1120 AbbrevToUse = ArrayAbbrev;
1128 TypeVals.
push_back(VT->getElementCount().getKnownMinValue());
1129 TypeVals.
push_back(getTypeID(VT->getElementType()));
1135 Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
1142void DXILBitcodeWriter::writeComdats() {
1144 for (
const Comdat *
C : VE.getComdats()) {
1147 size_t Size =
C->getName().size();
1150 for (
char Chr :
C->getName())
1157void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
1162void DXILBitcodeWriter::writeModuleInfo() {
1167 StringRef Triple =
"dxil-ms-dx";
1168 StringRef
DL =
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-"
1169 "f16:16-f32:32-f64:64-n8:16:32:64";
1178 std::map<std::string, unsigned> SectionMap;
1179 std::map<std::string, unsigned> GCMap;
1181 unsigned MaxGlobalType = 0;
1182 const auto UpdateMaxAlignment = [&
MaxAlignment](
const MaybeAlign
A) {
1186 for (
const GlobalVariable &GV : M.globals()) {
1187 UpdateMaxAlignment(GV.getAlign());
1190 MaxGlobalType = std::max(
1191 MaxGlobalType, getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1192 if (GV.hasSection()) {
1194 unsigned &
Entry = SectionMap[std::string(GV.getSection())];
1197 GV.getSection(), 0 );
1198 Entry = SectionMap.size();
1203 UpdateMaxAlignment(
F.getAlign());
1204 if (
F.hasSection()) {
1206 unsigned &
Entry = SectionMap[std::string(
F.getSection())];
1210 Entry = SectionMap.size();
1215 unsigned &
Entry = GCMap[
F.getGC()];
1219 Entry = GCMap.size();
1225 unsigned SimpleGVarAbbrev = 0;
1226 if (!M.global_empty()) {
1229 auto Abbv = std::make_shared<BitCodeAbbrev>();
1239 Abbv->Add(BitCodeAbbrevOp(0));
1241 unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1245 if (SectionMap.empty())
1246 Abbv->Add(BitCodeAbbrevOp(0));
1251 SimpleGVarAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1256 for (
const GlobalVariable &GV : M.globals()) {
1257 unsigned AbbrevToUse = 0;
1263 Vals.
push_back(getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1265 GV.getType()->getAddressSpace() << 2 | 2 |
1266 (GV.isConstant() ? 1 : 0));
1269 GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1));
1271 Vals.
push_back(getEncodedAlign(GV.getAlign()));
1272 Vals.
push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1274 if (GV.isThreadLocal() ||
1277 GV.isExternallyInitialized() ||
1283 Vals.
push_back(GV.isExternallyInitialized());
1285 Vals.
push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1287 AbbrevToUse = SimpleGVarAbbrev;
1296 const Function &
F = VE.getDXILFunction(OrigF);
1301 Vals.
push_back(getGlobalObjectValueTypeID(
F.getFunctionType(), &
F));
1305 Vals.
push_back(VE.getAttributeListID(
F.getAttributes()));
1306 Vals.
push_back(getEncodedAlign(
F.getAlign()));
1307 Vals.
push_back(
F.hasSection() ? SectionMap[std::string(
F.getSection())]
1313 F.hasPrologueData() ? (VE.getValueID(
F.getPrologueData()) + 1) : 0);
1315 Vals.
push_back(
F.hasComdat() ? VE.getComdatID(
F.getComdat()) : 0);
1316 Vals.
push_back(
F.hasPrefixData() ? (VE.getValueID(
F.getPrefixData()) + 1)
1319 F.hasPersonalityFn() ? (VE.getValueID(
F.getPersonalityFn()) + 1) : 0);
1321 unsigned AbbrevToUse = 0;
1327 for (
const GlobalAlias &
A : M.aliases()) {
1330 Vals.
push_back(VE.getValueID(
A.getAliasee()));
1336 unsigned AbbrevToUse = 0;
1342void DXILBitcodeWriter::writeValueAsMetadata(
1343 const ValueAsMetadata *MD, SmallVectorImpl<uint64_t> &Record) {
1351 Record.push_back(getTypeID(Ty,
V));
1352 Record.push_back(VE.getValueID(
V));
1357void DXILBitcodeWriter::writeMDTuple(
const MDTuple *
N,
1358 SmallVectorImpl<uint64_t> &Record,
1360 for (
unsigned i = 0, e =
N->getNumOperands(); i != e; ++i) {
1363 "Unexpected function-local metadata");
1364 Record.push_back(VE.getMetadataOrNullID(MD));
1372void DXILBitcodeWriter::writeDILocation(
const DILocation *
N,
1373 SmallVectorImpl<uint64_t> &Record,
1376 Abbrev = createDILocationAbbrev();
1377 Record.push_back(
N->isDistinct());
1378 Record.push_back(
N->getLine());
1379 Record.push_back(
N->getColumn());
1380 Record.push_back(VE.getMetadataID(
N->getScope()));
1381 Record.push_back(VE.getMetadataOrNullID(
N->getInlinedAt()));
1390 return I < 0 ? ~(U << 1) : U << 1;
1393void DXILBitcodeWriter::writeDISubrange(
const DISubrange *
N,
1394 SmallVectorImpl<uint64_t> &Record,
1396 Record.push_back(
N->isDistinct());
1402 Record.push_back(
Count->getValue().getSExtValue());
1408 DISubrange::BoundType
LowerBound =
N->getLowerBound();
1419void DXILBitcodeWriter::writeDIEnumerator(
const DIEnumerator *
N,
1420 SmallVectorImpl<uint64_t> &Record,
1422 Record.push_back(
N->isDistinct());
1424 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1430void DXILBitcodeWriter::writeDIBasicType(
const DIBasicType *
N,
1431 SmallVectorImpl<uint64_t> &Record,
1433 Record.push_back(
N->isDistinct());
1434 Record.push_back(
N->getTag());
1435 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1436 Record.push_back(
N->getSizeInBits());
1437 Record.push_back(
N->getAlignInBits());
1438 Record.push_back(
N->getEncoding());
1444void DXILBitcodeWriter::writeDIDerivedType(
const DIDerivedType *
N,
1445 SmallVectorImpl<uint64_t> &Record,
1447 Record.push_back(
N->isDistinct());
1448 Record.push_back(
N->getTag());
1449 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1450 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1451 Record.push_back(
N->getLine());
1452 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1453 Record.push_back(VE.getMetadataOrNullID(
N->getBaseType()));
1454 Record.push_back(
N->getSizeInBits());
1455 Record.push_back(
N->getAlignInBits());
1456 Record.push_back(
N->getOffsetInBits());
1457 Record.push_back(
N->getFlags());
1458 Record.push_back(VE.getMetadataOrNullID(
N->getExtraData()));
1464void DXILBitcodeWriter::writeDICompositeType(
const DICompositeType *
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->getElements().get()));
1479 Record.push_back(
N->getRuntimeLang());
1480 Record.push_back(VE.getMetadataOrNullID(
N->getVTableHolder()));
1481 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1482 Record.push_back(VE.getMetadataOrNullID(
N->getRawIdentifier()));
1488void DXILBitcodeWriter::writeDISubroutineType(
const DISubroutineType *
N,
1489 SmallVectorImpl<uint64_t> &Record,
1491 Record.push_back(
N->isDistinct());
1492 Record.push_back(
N->getFlags());
1493 Record.push_back(VE.getMetadataOrNullID(
N->getTypeArray().get()));
1499void DXILBitcodeWriter::writeDIFile(
const DIFile *
N,
1500 SmallVectorImpl<uint64_t> &Record,
1502 Record.push_back(
N->isDistinct());
1503 Record.push_back(VE.getMetadataOrNullID(
N->getRawFilename()));
1504 Record.push_back(VE.getMetadataOrNullID(
N->getRawDirectory()));
1510void DXILBitcodeWriter::writeDICompileUnit(
const DICompileUnit *
N,
1511 SmallVectorImpl<uint64_t> &Record,
1513 Record.push_back(
N->isDistinct());
1514 Record.push_back(
N->getSourceLanguage().getUnversionedName());
1515 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1516 Record.push_back(VE.getMetadataOrNullID(
N->getRawProducer()));
1517 Record.push_back(
N->isOptimized());
1518 Record.push_back(VE.getMetadataOrNullID(
N->getRawFlags()));
1519 Record.push_back(
N->getRuntimeVersion());
1520 Record.push_back(VE.getMetadataOrNullID(
N->getRawSplitDebugFilename()));
1521 Record.push_back(
N->getEmissionKind());
1522 Record.push_back(VE.getMetadataOrNullID(
N->getEnumTypes().get()));
1523 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedTypes().get()));
1524 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1525 Record.push_back(VE.getMetadataOrNullID(
N->getGlobalVariables().get()));
1526 Record.push_back(VE.getMetadataOrNullID(
N->getImportedEntities().get()));
1527 Record.push_back(
N->getDWOId());
1533void DXILBitcodeWriter::writeDISubprogram(
const DISubprogram *
N,
1534 SmallVectorImpl<uint64_t> &Record,
1536 Record.push_back(
N->isDistinct());
1537 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1538 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1539 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1540 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1541 Record.push_back(
N->getLine());
1542 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1543 Record.push_back(
N->isLocalToUnit());
1544 Record.push_back(
N->isDefinition());
1545 Record.push_back(
N->getScopeLine());
1546 Record.push_back(VE.getMetadataOrNullID(
N->getContainingType()));
1547 Record.push_back(
N->getVirtuality());
1548 Record.push_back(
N->getVirtualIndex());
1549 Record.push_back(
N->getFlags());
1550 Record.push_back(
N->isOptimized());
1551 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1552 Record.push_back(VE.getMetadataOrNullID(
N->getTemplateParams().get()));
1553 Record.push_back(VE.getMetadataOrNullID(
N->getDeclaration()));
1554 Record.push_back(VE.getMetadataOrNullID(
N->getRetainedNodes().get()));
1560void DXILBitcodeWriter::writeDILexicalBlock(
const DILexicalBlock *
N,
1561 SmallVectorImpl<uint64_t> &Record,
1563 Record.push_back(
N->isDistinct());
1564 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1565 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1566 Record.push_back(
N->getLine());
1567 Record.push_back(
N->getColumn());
1573void DXILBitcodeWriter::writeDILexicalBlockFile(
1574 const DILexicalBlockFile *
N, SmallVectorImpl<uint64_t> &Record,
1576 Record.push_back(
N->isDistinct());
1577 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1578 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1579 Record.push_back(
N->getDiscriminator());
1585void DXILBitcodeWriter::writeDINamespace(
const DINamespace *
N,
1586 SmallVectorImpl<uint64_t> &Record,
1588 Record.push_back(
N->isDistinct());
1589 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1590 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1591 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1598void DXILBitcodeWriter::writeDIModule(
const DIModule *
N,
1599 SmallVectorImpl<uint64_t> &Record,
1601 Record.push_back(
N->isDistinct());
1602 for (
auto &
I :
N->operands())
1603 Record.push_back(VE.getMetadataOrNullID(
I));
1609void DXILBitcodeWriter::writeDITemplateTypeParameter(
1610 const DITemplateTypeParameter *
N, SmallVectorImpl<uint64_t> &Record,
1612 Record.push_back(
N->isDistinct());
1613 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1614 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1620void DXILBitcodeWriter::writeDITemplateValueParameter(
1621 const DITemplateValueParameter *
N, SmallVectorImpl<uint64_t> &Record,
1623 Record.push_back(
N->isDistinct());
1624 Record.push_back(
N->getTag());
1625 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1626 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1627 Record.push_back(VE.getMetadataOrNullID(
N->getValue()));
1633void DXILBitcodeWriter::writeDIGlobalVariable(
const DIGlobalVariable *
N,
1634 SmallVectorImpl<uint64_t> &Record,
1636 Record.push_back(
N->isDistinct());
1637 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1638 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1639 Record.push_back(VE.getMetadataOrNullID(
N->getRawLinkageName()));
1640 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1641 Record.push_back(
N->getLine());
1642 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1643 Record.push_back(
N->isLocalToUnit());
1644 Record.push_back(
N->isDefinition());
1645 Record.push_back(VE.getMetadataOrNullID(DebugInfo.MDExtra.lookup(
N)));
1646 Record.push_back(VE.getMetadataOrNullID(
N->getStaticDataMemberDeclaration()));
1652void DXILBitcodeWriter::writeDILocalVariable(
const DILocalVariable *
N,
1653 SmallVectorImpl<uint64_t> &Record,
1655 constexpr unsigned DW_TAG_auto_variable = 0x0100;
1656 constexpr unsigned DW_TAG_arg_variable = 0x0101;
1657 Record.push_back(
N->isDistinct());
1658 assert(
N->getTag() == dwarf::DW_TAG_variable);
1659 Record.push_back(
N->getArg() ? DW_TAG_arg_variable : DW_TAG_auto_variable);
1660 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1661 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1662 Record.push_back(VE.getMetadataOrNullID(
N->getFile()));
1663 Record.push_back(
N->getLine());
1664 Record.push_back(VE.getMetadataOrNullID(
N->getType()));
1665 Record.push_back(
N->getArg());
1666 Record.push_back(
N->getFlags());
1672void DXILBitcodeWriter::writeDIExpression(
const DIExpression *
N,
1673 SmallVectorImpl<uint64_t> &Record,
1675 Record.reserve(
N->getElements().size() + 1);
1677 Record.push_back(
N->isDistinct());
1678 Record.append(
N->elements_begin(),
N->elements_end());
1684void DXILBitcodeWriter::writeDIObjCProperty(
const DIObjCProperty *
N,
1685 SmallVectorImpl<uint64_t> &Record,
1690void DXILBitcodeWriter::writeDIImportedEntity(
const DIImportedEntity *
N,
1691 SmallVectorImpl<uint64_t> &Record,
1693 Record.push_back(
N->isDistinct());
1694 Record.push_back(
N->getTag());
1695 Record.push_back(VE.getMetadataOrNullID(
N->getScope()));
1696 Record.push_back(VE.getMetadataOrNullID(
N->getEntity()));
1697 Record.push_back(
N->getLine());
1698 Record.push_back(VE.getMetadataOrNullID(
N->getRawName()));
1704unsigned DXILBitcodeWriter::createDILocationAbbrev() {
1709 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1716 return Stream.EmitAbbrev(std::move(Abbv));
1719unsigned DXILBitcodeWriter::createGenericDINodeAbbrev() {
1724 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1732 return Stream.EmitAbbrev(std::move(Abbv));
1736 SmallVectorImpl<uint64_t> &Record,
1737 std::vector<unsigned> *MDAbbrevs,
1738 std::vector<uint64_t> *IndexPos) {
1743#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1744#include "llvm/IR/Metadata.def"
1748 IndexPos->push_back(Stream.GetCurrentBitNo());
1750 assert(
N->isResolved() &&
"Expected forward references to be resolved");
1752 switch (
N->getMetadataID()) {
1755#define HANDLE_MDNODE_LEAF(CLASS) \
1756 case Metadata::CLASS##Kind: \
1758 write##CLASS(cast<CLASS>(N), Record, \
1759 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1761 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1763#include "llvm/IR/Metadata.def"
1770unsigned DXILBitcodeWriter::createMetadataStringsAbbrev() {
1771 auto Abbv = std::make_shared<BitCodeAbbrev>();
1775 return Stream.EmitAbbrev(std::move(Abbv));
1778void DXILBitcodeWriter::writeMetadataStrings(
1780 if (Strings.
empty())
1783 unsigned MDSAbbrev = createMetadataStringsAbbrev();
1785 for (
const Metadata *MD : Strings) {
1796void DXILBitcodeWriter::writeModuleMetadata() {
1797 if (!VE.hasMDs() && M.named_metadata_empty())
1804 std::vector<unsigned> MDAbbrevs;
1807 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1808 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1809 createGenericDINodeAbbrev();
1811 unsigned NameAbbrev = 0;
1812 if (!M.named_metadata_empty()) {
1814 std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1818 NameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1821 SmallVector<uint64_t, 64>
Record;
1822 writeMetadataStrings(VE.getMDStrings(), Record);
1824 std::vector<uint64_t> IndexPos;
1825 IndexPos.reserve(VE.getNonMDStrings().size());
1826 writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1829 for (
const NamedMDNode &NMD : M.named_metadata()) {
1831 StringRef Str = NMD.getName();
1832 Record.append(Str.bytes_begin(), Str.bytes_end());
1837 for (
const MDNode *
N : NMD.operands())
1838 Record.push_back(VE.getMetadataID(
N));
1846void DXILBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
1851 SmallVector<uint64_t, 64>
Record;
1852 writeMetadataStrings(VE.getMDStrings(), Record);
1853 writeMetadataRecords(VE.getNonMDStrings(), Record);
1857void DXILBitcodeWriter::writeFunctionMetadataAttachment(
const Function &
F) {
1860 SmallVector<uint64_t, 64>
Record;
1865 F.getAllMetadata(MDs);
1867 for (
const auto &
I : MDs) {
1868 if (
I.first == LLVMContext::MD_dbg)
1871 Record.push_back(VE.getMetadataID(
I.second));
1879 for (
const BasicBlock &BB :
F)
1880 for (
const Instruction &OrigI : BB) {
1884 I.getAllMetadataOtherThanDebugLoc(MDs);
1890 Record.push_back(VE.getInstructionID(&
I));
1892 for (
unsigned i = 0, e = MDs.size(); i != e; ++i) {
1893 Record.push_back(MDs[i].first);
1894 Record.push_back(VE.getMetadataID(MDs[i].second));
1903void DXILBitcodeWriter::writeModuleMetadataKinds() {
1904 SmallVector<uint64_t, 64>
Record;
1909 M.getMDKindNames(Names);
1916 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
1917 Record.push_back(MDKindID);
1918 StringRef KName = Names[MDKindID];
1928void DXILBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
1930 if (FirstVal == LastVal)
1935 unsigned AggregateAbbrev = 0;
1936 unsigned String8Abbrev = 0;
1937 unsigned CString7Abbrev = 0;
1938 unsigned CString6Abbrev = 0;
1942 auto Abbv = std::make_shared<BitCodeAbbrev>();
1947 AggregateAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1950 Abbv = std::make_shared<BitCodeAbbrev>();
1954 String8Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1956 Abbv = std::make_shared<BitCodeAbbrev>();
1960 CString7Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1962 Abbv = std::make_shared<BitCodeAbbrev>();
1966 CString6Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1969 SmallVector<uint64_t, 64>
Record;
1972 Type *LastTy =
nullptr;
1973 for (
unsigned i = FirstVal; i != LastVal; ++i) {
1974 const Value *
V = Vals[i].first;
1976 if (
V->getType() != LastTy) {
1977 LastTy =
V->getType();
1978 Record.push_back(getTypeID(LastTy,
V));
1980 CONSTANTS_SETTYPE_ABBREV);
1985 Record.push_back(
unsigned(
IA->hasSideEffects()) |
1986 unsigned(
IA->isAlignStack()) << 1 |
1987 unsigned(
IA->getDialect() & 1) << 2);
1990 StringRef AsmStr =
IA->getAsmString();
1995 StringRef ConstraintStr =
IA->getConstraintString();
2003 unsigned Code = -1U;
2004 unsigned AbbrevToUse = 0;
2005 if (
C->isNullValue()) {
2010 if (
IV->getBitWidth() <= 64) {
2014 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2020 unsigned NWords =
IV->getValue().getActiveWords();
2021 const uint64_t *RawWords =
IV->getValue().getRawData();
2022 for (
unsigned i = 0; i != NWords; ++i) {
2030 if (BV->getBitWidth() <= 64) {
2034 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2036 unsigned NWords = BV->getValue().getActiveWords();
2037 const uint64_t *RawWords = BV->getValue().getRawData();
2038 for (
unsigned i = 0; i != NWords; ++i) {
2047 Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2051 APInt api = CFP->getValueAPF().bitcastToAPInt();
2053 Record.push_back((p[1] << 48) | (p[0] >> 16));
2054 Record.push_back(p[0] & 0xffffLL);
2056 APInt api = CFP->getValueAPF().bitcastToAPInt();
2061 assert(0 &&
"Unknown FP type!");
2067 unsigned NumElts = Str->getNumElements();
2069 if (Str->isCString()) {
2074 AbbrevToUse = String8Abbrev;
2078 for (
unsigned i = 0; i != NumElts; ++i) {
2079 unsigned char V = Str->getElementAsInteger(i);
2081 isCStr7 &= (
V & 128) == 0;
2087 AbbrevToUse = CString6Abbrev;
2089 AbbrevToUse = CString7Abbrev;
2090 }
else if (
const ConstantDataSequential *CDS =
2093 Type *EltTy = CDS->getElementType();
2095 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2096 Record.push_back(CDS->getElementAsInteger(i));
2098 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2103 F = CDS->getElementAsFloat(i);
2108 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2113 F = CDS->getElementAsDouble(i);
2120 for (
const Value *
Op :
C->operands())
2121 Record.push_back(VE.getValueID(
Op));
2122 AbbrevToUse = AggregateAbbrev;
2124 switch (
CE->getOpcode()) {
2130 getTypeID(
C->getOperand(0)->getType(),
C->getOperand(0)));
2131 Record.push_back(VE.getValueID(
C->getOperand(0)));
2132 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2134 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2137 Record.push_back(VE.getValueID(
C->getOperand(0)));
2138 Record.push_back(VE.getValueID(
C->getOperand(1)));
2144 case Instruction::GetElementPtr: {
2147 if (GO->isInBounds())
2149 Record.push_back(getTypeID(GO->getSourceElementType()));
2150 for (
unsigned i = 0, e =
CE->getNumOperands(); i != e; ++i) {
2152 getTypeID(
C->getOperand(i)->getType(),
C->getOperand(i)));
2153 Record.push_back(VE.getValueID(
C->getOperand(i)));
2157 case Instruction::Select:
2159 Record.push_back(VE.getValueID(
C->getOperand(0)));
2160 Record.push_back(VE.getValueID(
C->getOperand(1)));
2161 Record.push_back(VE.getValueID(
C->getOperand(2)));
2163 case Instruction::ExtractElement:
2165 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2166 Record.push_back(VE.getValueID(
C->getOperand(0)));
2167 Record.push_back(getTypeID(
C->getOperand(1)->getType()));
2168 Record.push_back(VE.getValueID(
C->getOperand(1)));
2170 case Instruction::InsertElement:
2172 Record.push_back(VE.getValueID(
C->getOperand(0)));
2173 Record.push_back(VE.getValueID(
C->getOperand(1)));
2174 Record.push_back(getTypeID(
C->getOperand(2)->getType()));
2175 Record.push_back(VE.getValueID(
C->getOperand(2)));
2177 case Instruction::ShuffleVector:
2182 if (
C->getType() ==
C->getOperand(0)->getType()) {
2186 Record.push_back(getTypeID(
C->getOperand(0)->getType()));
2188 Record.push_back(VE.getValueID(
C->getOperand(0)));
2189 Record.push_back(VE.getValueID(
C->getOperand(1)));
2190 Record.push_back(VE.getValueID(
C->getOperand(2)));
2195 Record.push_back(getTypeID(BA->getFunction()->getType()));
2196 Record.push_back(VE.getValueID(BA->getFunction()));
2197 Record.push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2204 Stream.EmitRecord(Code, Record, AbbrevToUse);
2211void DXILBitcodeWriter::writeModuleConstants() {
2216 for (
unsigned i = 0, e = Vals.size(); i != e; ++i) {
2218 writeConstants(i, Vals.size(),
true);
2232bool DXILBitcodeWriter::pushValueAndType(
const Value *
V,
unsigned InstID,
2233 SmallVectorImpl<unsigned> &Vals) {
2234 unsigned ValID = VE.getValueID(
V);
2237 if (ValID >= InstID) {
2246void DXILBitcodeWriter::pushValue(
const Value *
V,
unsigned InstID,
2247 SmallVectorImpl<unsigned> &Vals) {
2248 unsigned ValID = VE.getValueID(
V);
2252void DXILBitcodeWriter::pushValueSigned(
const Value *
V,
unsigned InstID,
2253 SmallVectorImpl<uint64_t> &Vals) {
2254 unsigned ValID = VE.getValueID(
V);
2255 int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2260void DXILBitcodeWriter::writeInstruction(
const Instruction &
I,
unsigned InstID,
2261 SmallVectorImpl<unsigned> &Vals) {
2263 unsigned AbbrevToUse = 0;
2264 VE.setInstructionID(&
I);
2265 switch (
I.getOpcode()) {
2269 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2270 AbbrevToUse = (unsigned)FUNCTION_INST_CAST_ABBREV;
2276 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2277 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_ABBREV;
2278 pushValue(
I.getOperand(1), InstID, Vals);
2282 if (AbbrevToUse == (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2283 AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV;
2289 case Instruction::GetElementPtr: {
2291 AbbrevToUse = (unsigned)FUNCTION_INST_GEP_ABBREV;
2294 Vals.
push_back(getTypeID(GEPInst.getSourceElementType()));
2295 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i)
2296 pushValueAndType(
I.getOperand(i), InstID, Vals);
2299 case Instruction::ExtractValue: {
2301 pushValueAndType(
I.getOperand(0), InstID, Vals);
2306 case Instruction::InsertValue: {
2308 pushValueAndType(
I.getOperand(0), InstID, Vals);
2309 pushValueAndType(
I.getOperand(1), InstID, Vals);
2314 case Instruction::Select:
2316 pushValueAndType(
I.getOperand(1), InstID, Vals);
2317 pushValue(
I.getOperand(2), InstID, Vals);
2318 pushValueAndType(
I.getOperand(0), InstID, Vals);
2320 case Instruction::ExtractElement:
2322 pushValueAndType(
I.getOperand(0), InstID, Vals);
2323 pushValueAndType(
I.getOperand(1), InstID, Vals);
2325 case Instruction::InsertElement:
2327 pushValueAndType(
I.getOperand(0), InstID, Vals);
2328 pushValue(
I.getOperand(1), InstID, Vals);
2329 pushValueAndType(
I.getOperand(2), InstID, Vals);
2331 case Instruction::ShuffleVector:
2333 pushValueAndType(
I.getOperand(0), InstID, Vals);
2334 pushValue(
I.getOperand(1), InstID, Vals);
2338 case Instruction::ICmp:
2339 case Instruction::FCmp: {
2342 pushValueAndType(
I.getOperand(0), InstID, Vals);
2343 pushValue(
I.getOperand(1), InstID, Vals);
2351 case Instruction::Ret: {
2353 unsigned NumOperands =
I.getNumOperands();
2354 if (NumOperands == 0)
2355 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VOID_ABBREV;
2356 else if (NumOperands == 1) {
2357 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2358 AbbrevToUse = (unsigned)FUNCTION_INST_RET_VAL_ABBREV;
2360 for (
unsigned i = 0, e = NumOperands; i !=
e; ++i)
2361 pushValueAndType(
I.getOperand(i), InstID, Vals);
2364 case Instruction::UncondBr:
2368 case Instruction::CondBr: {
2371 Vals.
push_back(VE.getValueID(
II.getSuccessor(0)));
2372 Vals.
push_back(VE.getValueID(
II.getSuccessor(1)));
2373 pushValue(
II.getCondition(), InstID, Vals);
2375 case Instruction::Switch: {
2378 Vals.
push_back(getTypeID(
SI.getCondition()->getType()));
2379 pushValue(
SI.getCondition(), InstID, Vals);
2380 Vals.
push_back(VE.getValueID(
SI.getDefaultDest()));
2381 for (
auto Case :
SI.cases()) {
2382 Vals.
push_back(VE.getValueID(Case.getCaseValue()));
2383 Vals.
push_back(VE.getValueID(Case.getCaseSuccessor()));
2386 case Instruction::IndirectBr:
2388 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2390 pushValue(
I.getOperand(0), InstID, Vals);
2391 for (
unsigned i = 1, e =
I.getNumOperands(); i != e; ++i)
2392 Vals.
push_back(VE.getValueID(
I.getOperand(i)));
2395 case Instruction::Invoke: {
2398 FunctionType *FTy =
II->getFunctionType();
2401 Vals.
push_back(VE.getAttributeListID(
II->getAttributes()));
2403 Vals.
push_back(VE.getValueID(
II->getNormalDest()));
2404 Vals.
push_back(VE.getValueID(
II->getUnwindDest()));
2406 pushValueAndType(Callee, InstID, Vals);
2409 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2410 pushValue(
I.getOperand(i), InstID, Vals);
2413 if (FTy->isVarArg()) {
2414 for (
unsigned i = FTy->getNumParams(), e =
I.getNumOperands() - 3; i != e;
2416 pushValueAndType(
I.getOperand(i), InstID, Vals);
2420 case Instruction::Resume:
2422 pushValueAndType(
I.getOperand(0), InstID, Vals);
2424 case Instruction::Unreachable:
2426 AbbrevToUse = (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV;
2429 case Instruction::PHI: {
2442 Stream.EmitRecord(Code, Vals64, AbbrevToUse);
2447 case Instruction::LandingPad: {
2458 pushValueAndType(LP.
getClause(
I), InstID, Vals);
2463 case Instruction::Alloca: {
2467 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2468 Vals.
push_back(VE.getValueID(
I.getOperand(0)));
2470 assert(AlignRecord < 1 << 5 &&
"alignment greater than 1 << 64");
2472 AlignRecord |= 1 << 6;
2477 case Instruction::Load:
2480 pushValueAndType(
I.getOperand(0), InstID, Vals);
2483 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
2484 AbbrevToUse = (unsigned)FUNCTION_INST_LOAD_ABBREV;
2494 case Instruction::Store:
2499 pushValueAndType(
I.getOperand(1), InstID, Vals);
2500 pushValueAndType(
I.getOperand(0), InstID, Vals);
2509 case Instruction::AtomicCmpXchg:
2511 pushValueAndType(
I.getOperand(0), InstID, Vals);
2512 pushValueAndType(
I.getOperand(1), InstID, Vals);
2513 pushValue(
I.getOperand(2), InstID, Vals);
2523 case Instruction::AtomicRMW:
2525 pushValueAndType(
I.getOperand(0), InstID, Vals);
2526 pushValue(
I.getOperand(1), InstID, Vals);
2534 case Instruction::Fence:
2539 case Instruction::Call: {
2552 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
2554 if (FTy->getParamType(i)->isLabelTy())
2561 if (FTy->isVarArg()) {
2562 for (
unsigned i = FTy->getNumParams(), e = CI.
arg_size(); i != e; ++i)
2567 case Instruction::VAArg:
2569 Vals.
push_back(getTypeID(
I.getOperand(0)->getType()));
2570 pushValue(
I.getOperand(0), InstID, Vals);
2575 Stream.EmitRecord(Code, Vals, AbbrevToUse);
2580void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
2581 const ValueSymbolTable &VST) {
2593 for (
auto &VI : VST) {
2594 const Value &
V = VE.getDXILValue(*
VI.second);
2599 return A->first() <
B->first();
2602 for (
const ValueName *SI : SortedTable) {
2607 bool isChar6 =
true;
2608 for (
const char *
C =
Name.getKeyData(), *
E =
C +
Name.getKeyLength();
2612 if ((
unsigned char)*
C & 128) {
2618 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2626 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2630 AbbrevToUse = VST_ENTRY_6_ABBREV;
2632 AbbrevToUse = VST_ENTRY_7_ABBREV;
2635 NameVals.
push_back(VE.getValueID(
SI->getValue()));
2636 for (
const char *
P =
Name.getKeyData(),
2637 *
E =
Name.getKeyData() +
Name.getKeyLength();
2642 Stream.EmitRecord(Code, NameVals, AbbrevToUse);
2649void DXILBitcodeWriter::writeFunction(
const Function &
F) {
2651 VE.incorporateFunction(
F);
2657 Vals.
push_back(VE.getBasicBlocks().size());
2662 unsigned CstStart, CstEnd;
2663 VE.getFunctionConstantRange(CstStart, CstEnd);
2664 writeConstants(CstStart, CstEnd,
false);
2667 writeFunctionMetadata(
F);
2670 unsigned InstID = CstEnd;
2672 bool NeedsMetadataAttachment =
F.hasMetadata();
2674 DILocation *LastDL =
nullptr;
2682 writeInstruction(
I, InstID, Vals);
2684 if (!
I.getType()->isVoidTy())
2688 NeedsMetadataAttachment |=
I.hasMetadataOtherThanDebugLoc();
2691 DILocation *
DL =
I.getDebugLoc();
2703 Vals.
push_back(VE.getMetadataOrNullID(
DL->getScope()));
2704 Vals.
push_back(VE.getMetadataOrNullID(
DL->getInlinedAt()));
2712 if (
auto *Symtab =
F.getValueSymbolTable())
2713 writeFunctionLevelValueSymbolTable(*Symtab);
2715 if (NeedsMetadataAttachment)
2716 writeFunctionMetadataAttachment(
F);
2723void DXILBitcodeWriter::writeBlockInfo() {
2727 Stream.EnterBlockInfoBlock();
2730 auto Abbv = std::make_shared<BitCodeAbbrev>();
2736 std::move(Abbv)) != VST_ENTRY_8_ABBREV)
2737 assert(
false &&
"Unexpected abbrev ordering!");
2741 auto Abbv = std::make_shared<BitCodeAbbrev>();
2747 std::move(Abbv)) != VST_ENTRY_7_ABBREV)
2748 assert(
false &&
"Unexpected abbrev ordering!");
2751 auto Abbv = std::make_shared<BitCodeAbbrev>();
2757 std::move(Abbv)) != VST_ENTRY_6_ABBREV)
2758 assert(
false &&
"Unexpected abbrev ordering!");
2761 auto Abbv = std::make_shared<BitCodeAbbrev>();
2767 std::move(Abbv)) != VST_BBENTRY_6_ABBREV)
2768 assert(
false &&
"Unexpected abbrev ordering!");
2772 auto Abbv = std::make_shared<BitCodeAbbrev>();
2775 VE.computeBitsRequiredForTypeIndices()));
2777 CONSTANTS_SETTYPE_ABBREV)
2778 assert(
false &&
"Unexpected abbrev ordering!");
2782 auto Abbv = std::make_shared<BitCodeAbbrev>();
2786 CONSTANTS_INTEGER_ABBREV)
2787 assert(
false &&
"Unexpected abbrev ordering!");
2791 auto Abbv = std::make_shared<BitCodeAbbrev>();
2795 VE.computeBitsRequiredForTypeIndices()));
2799 CONSTANTS_CE_CAST_Abbrev)
2800 assert(
false &&
"Unexpected abbrev ordering!");
2803 auto Abbv = std::make_shared<BitCodeAbbrev>();
2806 CONSTANTS_NULL_Abbrev)
2807 assert(
false &&
"Unexpected abbrev ordering!");
2813 auto Abbv = std::make_shared<BitCodeAbbrev>();
2817 VE.computeBitsRequiredForTypeIndices()));
2821 (
unsigned)FUNCTION_INST_LOAD_ABBREV)
2822 assert(
false &&
"Unexpected abbrev ordering!");
2825 auto Abbv = std::make_shared<BitCodeAbbrev>();
2831 (
unsigned)FUNCTION_INST_BINOP_ABBREV)
2832 assert(
false &&
"Unexpected abbrev ordering!");
2835 auto Abbv = std::make_shared<BitCodeAbbrev>();
2842 (
unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV)
2843 assert(
false &&
"Unexpected abbrev ordering!");
2846 auto Abbv = std::make_shared<BitCodeAbbrev>();
2850 VE.computeBitsRequiredForTypeIndices()));
2853 (
unsigned)FUNCTION_INST_CAST_ABBREV)
2854 assert(
false &&
"Unexpected abbrev ordering!");
2858 auto Abbv = std::make_shared<BitCodeAbbrev>();
2861 (
unsigned)FUNCTION_INST_RET_VOID_ABBREV)
2862 assert(
false &&
"Unexpected abbrev ordering!");
2865 auto Abbv = std::make_shared<BitCodeAbbrev>();
2869 (
unsigned)FUNCTION_INST_RET_VAL_ABBREV)
2870 assert(
false &&
"Unexpected abbrev ordering!");
2873 auto Abbv = std::make_shared<BitCodeAbbrev>();
2876 (
unsigned)FUNCTION_INST_UNREACHABLE_ABBREV)
2877 assert(
false &&
"Unexpected abbrev ordering!");
2880 auto Abbv = std::make_shared<BitCodeAbbrev>();
2888 (
unsigned)FUNCTION_INST_GEP_ABBREV)
2889 assert(
false &&
"Unexpected abbrev ordering!");
2895void DXILBitcodeWriter::writeModuleVersion() {
2910 DXILBitcodeWriter::writeModuleVersion();
2916 writeAttributeGroupTable();
2919 writeAttributeTable();
2931 writeModuleConstants();
2934 writeModuleMetadataKinds();
2937 writeModuleMetadata();
2942 writeFunctionLevelValueSymbolTable(M.getValueSymbolTable());
2946 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)
static bool isAtomic(MachineBasicBlock::iterator I)
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
uint64_t IntrinsicInst * II
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
static const uint32_t IV[8]
Class for arbitrary precision integers.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
int64_t getSExtValue() const
Get sign extended value.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ Min
*p = old <signed v ? old : v
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
This class holds the attributes for a particular argument, parameter, function, or return value.
bool hasAttributes() const
Return true if attributes exists in this set.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
@ None
No attributes have been set.
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
@ EndAttrKinds
Sentinel value useful for loops.
InstListType::const_iterator const_iterator
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
static bool isChar6(char C)
isChar6 - Return true if this character is legal in the Char6 encoding.
unsigned EmitAbbrev(std::shared_ptr< BitCodeAbbrev > Abbv)
Emits the abbreviation Abbv to the stream.
void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals, StringRef Blob)
EmitRecordWithBlob - Emit the specified record to the stream, using an abbrev that includes a blob at...
void EnterSubblock(unsigned BlockID, unsigned CodeLen)
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
CallingConv::ID getCallingConv() const
Value * getCalledOperand() const
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
bool isMustTailCall() const
@ Largest
The linker will choose the largest COMDAT.
@ SameSize
The data referenced by the COMDAT must be the same size.
@ Any
The linker may choose any COMDAT.
@ NoDeduplicate
No deduplication is performed.
@ ExactMatch
The data referenced by the COMDAT must be the same.
iterator find(const_arg_type_t< KeyT > Val)
BasicBlockListType::const_iterator const_iterator
VisibilityTypes getVisibility() const
LinkageTypes getLinkage() const
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
ThreadLocalMode getThreadLocalMode() const
@ DLLExportStorageClass
Function to be accessible from DLL.
@ DLLImportStorageClass
Function to be imported from DLL.
@ DefaultVisibility
The GV is visible.
@ HiddenVisibility
The GV is hidden.
@ ProtectedVisibility
The GV is protected.
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
DLLStorageClassTypes getDLLStorageClass() const
idx_iterator idx_end() const
idx_iterator idx_begin() const
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
const unsigned char * bytes_begin() const
const unsigned char * bytes_end() const
bool doesNotAccessMemory() const
Whether this function accesses no memory.
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
A Module instance is used to store all the information related to an LLVM module.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
constexpr bool empty() const
Check if the string is empty.
constexpr size_t size() const
Get the string size.
Utility for building string tables with deduplicated suffixes.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isX86_FP80Ty() const
Return true if this is x86 long double.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ TypedPointerTyID
Typed pointer used by some GPU targets.
@ HalfTyID
16-bit floating point type
@ TargetExtTyID
Target extension type.
@ VoidTyID
type with no size
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ ByteTyID
Arbitrary bit width bytes.
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
bool isFP128Ty() const
Return true if this is 'fp128'.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
A few GPU targets, such as DXIL and SPIR-V, have typed pointers.
Type * getElementType() const
static LLVM_ABI TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
BitcodeWriter(SmallVectorImpl< char > &Buffer)
Create a BitcodeWriter that writes to Buffer.
void writeModule(const Module &M, const DXILDebugInfoMap &DebugInfo)
Write the specified module to the buffer specified at construction time.
static void emitWideAPInt(SmallVectorImpl< uint64_t > &Vals, const APInt &A)
static unsigned getEncodedThreadLocalMode(const GlobalValue &GV)
static unsigned getEncodedCastOpcode(unsigned Opcode)
Begin dxil::BitcodeWriterBase Implementation.
static void writeStringRecord(BitstreamWriter &Stream, unsigned Code, StringRef Str, unsigned AbbrevToUse)
static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind)
static unsigned getEncodedDLLStorageClass(const GlobalValue &GV)
static unsigned getEncodedOrdering(AtomicOrdering Ordering)
static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage)
static unsigned getEncodedVisibility(const GlobalValue &GV)
void write()
Emit the current module to the bitstream.
static unsigned getEncodedBinaryOpcode(unsigned Opcode)
static void emitSignedInt64(SmallVectorImpl< uint64_t > &Vals, uint64_t V)
static unsigned getEncodedUnaryOpcode(unsigned Opcode)
DXILBitcodeWriter(const Module &M, SmallVectorImpl< char > &Buffer, StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream, const DXILDebugInfoMap &DebugInfo)
Constructs a ModuleBitcodeWriter object for the given Module, writing to the provided Buffer.
static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op)
static unsigned getEncodedComdatSelectionKind(const Comdat &C)
static uint64_t getOptimizationFlags(const Value *V)
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
std::vector< std::pair< const Value *, unsigned > > ValueList
std::vector< Type * > TypeList
This class implements an extremely fast bulk output stream that can only output to a stream.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
@ CE
Windows NT (Windows on ARM)
@ METADATA_TEMPLATE_VALUE
@ METADATA_LEXICAL_BLOCK_FILE
@ METADATA_SUBROUTINE_TYPE
@ METADATA_IMPORTED_ENTITY
@ METADATA_COMPOSITE_TYPE
@ CST_CODE_CE_INBOUNDS_GEP
@ COMDAT_SELECTION_KIND_LARGEST
@ COMDAT_SELECTION_KIND_ANY
@ COMDAT_SELECTION_KIND_SAME_SIZE
@ COMDAT_SELECTION_KIND_EXACT_MATCH
@ COMDAT_SELECTION_KIND_NO_DUPLICATES
@ ATTR_KIND_STACK_PROTECT
@ ATTR_KIND_STACK_PROTECT_STRONG
@ ATTR_KIND_SANITIZE_MEMORY
@ ATTR_KIND_OPTIMIZE_FOR_SIZE
@ ATTR_KIND_SANITIZE_ADDRESS
@ ATTR_KIND_NO_IMPLICIT_FLOAT
@ ATTR_KIND_STACK_ALIGNMENT
@ ATTR_KIND_STACK_PROTECT_REQ
@ ATTR_KIND_RETURNS_TWICE
@ ATTR_KIND_NON_LAZY_BIND
@ ATTR_KIND_DEREFERENCEABLE
@ ATTR_KIND_OPTIMIZE_NONE
@ ATTR_KIND_DEREFERENCEABLE_OR_NULL
@ ATTR_KIND_ALWAYS_INLINE
@ ATTR_KIND_SANITIZE_THREAD
@ PARAMATTR_GROUP_BLOCK_ID
@ MODULE_CODE_SECTIONNAME
@ FUNC_CODE_INST_ATOMICRMW_OLD
@ FUNC_CODE_INST_LANDINGPAD
@ FUNC_CODE_INST_EXTRACTVAL
@ FUNC_CODE_INST_LOADATOMIC
@ FUNC_CODE_INST_STOREATOMIC
@ FUNC_CODE_DEBUG_LOC_AGAIN
@ FUNC_CODE_INST_EXTRACTELT
@ FUNC_CODE_INST_INDIRECTBR
@ FUNC_CODE_INST_INSERTVAL
@ FUNC_CODE_DECLAREBLOCKS
@ FUNC_CODE_INST_INSERTELT
@ FUNC_CODE_INST_SHUFFLEVEC
@ FUNC_CODE_INST_UNREACHABLE
@ FIRST_APPLICATION_ABBREV
@ PARAMATTR_GRP_CODE_ENTRY
An analysis to compute the PointerTypes for pointers in a Module.
DenseMap< const Value *, Type * > PointerTypeMap
void WriteDXILToFile(Module &M, raw_ostream &Out)
Write the specified module to the specified raw output stream.
DXILDebugInfoMap collectDXILDebugInfo(Module &M)
NodeAddr< CodeNode * > Code
friend class Instruction
Iterator for Instructions in a `BasicBlock.
constexpr size_t MaxAlignment
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
StringMapEntry< Value * > ValueName
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
bool isa_and_nonnull(const Y &Val)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
AtomicOrdering
Atomic ordering for LLVM's memory model.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
unsigned Log2(Align A)
Returns the log2 of the alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
Struct that holds a reference to a particular GUID in a global value summary.