LLVM  16.0.0git
DXILBitcodeWriter.cpp
Go to the documentation of this file.
1 //===- Bitcode/Writer/DXILBitcodeWriter.cpp - DXIL Bitcode Writer ---------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Bitcode writer implementation.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "DXILBitcodeWriter.h"
14 #include "DXILValueEnumerator.h"
15 #include "PointerTypeAnalysis.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/ADT/Triple.h"
23 #include "llvm/IR/Attributes.h"
24 #include "llvm/IR/BasicBlock.h"
25 #include "llvm/IR/Comdat.h"
26 #include "llvm/IR/Constant.h"
27 #include "llvm/IR/Constants.h"
29 #include "llvm/IR/DebugLoc.h"
30 #include "llvm/IR/DerivedTypes.h"
31 #include "llvm/IR/Function.h"
32 #include "llvm/IR/GlobalAlias.h"
33 #include "llvm/IR/GlobalIFunc.h"
34 #include "llvm/IR/GlobalObject.h"
35 #include "llvm/IR/GlobalValue.h"
36 #include "llvm/IR/GlobalVariable.h"
37 #include "llvm/IR/InlineAsm.h"
38 #include "llvm/IR/InstrTypes.h"
39 #include "llvm/IR/Instruction.h"
40 #include "llvm/IR/Instructions.h"
41 #include "llvm/IR/LLVMContext.h"
42 #include "llvm/IR/Metadata.h"
43 #include "llvm/IR/Module.h"
45 #include "llvm/IR/Operator.h"
46 #include "llvm/IR/Type.h"
47 #include "llvm/IR/UseListOrder.h"
48 #include "llvm/IR/Value.h"
50 #include "llvm/Object/IRSymtab.h"
52 #include "llvm/Support/ModRef.h"
53 #include "llvm/Support/SHA1.h"
54 
55 namespace llvm {
56 namespace dxil {
57 
58 // Generates an enum to use as an index in the Abbrev array of Metadata record.
59 enum MetadataAbbrev : unsigned {
60 #define HANDLE_MDNODE_LEAF(CLASS) CLASS##AbbrevID,
61 #include "llvm/IR/Metadata.def"
63 };
64 
66 
67  /// These are manifest constants used by the bitcode writer. They do not need
68  /// to be kept in sync with the reader, but need to be consistent within this
69  /// file.
70  enum {
71  // VALUE_SYMTAB_BLOCK abbrev id's.
72  VST_ENTRY_8_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
73  VST_ENTRY_7_ABBREV,
74  VST_ENTRY_6_ABBREV,
75  VST_BBENTRY_6_ABBREV,
76 
77  // CONSTANTS_BLOCK abbrev id's.
78  CONSTANTS_SETTYPE_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
79  CONSTANTS_INTEGER_ABBREV,
80  CONSTANTS_CE_CAST_Abbrev,
81  CONSTANTS_NULL_Abbrev,
82 
83  // FUNCTION_BLOCK abbrev id's.
84  FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_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,
92  };
93 
94  // Cache some types
95  Type *I8Ty;
96  Type *I8PtrTy;
97 
98  /// The stream created and owned by the client.
99  BitstreamWriter &Stream;
100 
101  StringTableBuilder &StrtabBuilder;
102 
103  /// The Module to write to bitcode.
104  const Module &M;
105 
106  /// Enumerates ids for all values in the module.
107  ValueEnumerator VE;
108 
109  /// Map that holds the correspondence between GUIDs in the summary index,
110  /// that came from indirect call profiles, and a value id generated by this
111  /// class to use in the VST and summary block records.
112  std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
113 
114  /// Tracks the last value id recorded in the GUIDToValueMap.
115  unsigned GlobalValueId;
116 
117  /// Saves the offset of the VSTOffset record that must eventually be
118  /// backpatched with the offset of the actual VST.
119  uint64_t VSTOffsetPlaceholder = 0;
120 
121  /// Pointer to the buffer allocated by caller for bitcode writing.
122  const SmallVectorImpl<char> &Buffer;
123 
124  /// The start bit of the identification block.
125  uint64_t BitcodeStartBit;
126 
127  /// This maps values to their typed pointers
128  PointerTypeMap PointerMap;
129 
130 public:
131  /// Constructs a ModuleBitcodeWriter object for the given Module,
132  /// writing to the provided \p Buffer.
134  StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream)
135  : I8Ty(Type::getInt8Ty(M.getContext())),
136  I8PtrTy(TypedPointerType::get(I8Ty, 0)), Stream(Stream),
137  StrtabBuilder(StrtabBuilder), M(M), VE(M, I8PtrTy), Buffer(Buffer),
138  BitcodeStartBit(Stream.GetCurrentBitNo()),
139  PointerMap(PointerTypeAnalysis::run(M)) {
140  GlobalValueId = VE.getValues().size();
141  // Enumerate the typed pointers
142  for (auto El : PointerMap)
143  VE.EnumerateType(El.second);
144  }
145 
146  /// Emit the current module to the bitstream.
147  void write();
148 
150  static void writeStringRecord(BitstreamWriter &Stream, unsigned Code,
151  StringRef Str, unsigned AbbrevToUse);
152  static void writeIdentificationBlock(BitstreamWriter &Stream);
153  static void emitSignedInt64(SmallVectorImpl<uint64_t> &Vals, uint64_t V);
154  static void emitWideAPInt(SmallVectorImpl<uint64_t> &Vals, const APInt &A);
155 
156  static unsigned getEncodedComdatSelectionKind(const Comdat &C);
157  static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage);
158  static unsigned getEncodedLinkage(const GlobalValue &GV);
159  static unsigned getEncodedVisibility(const GlobalValue &GV);
160  static unsigned getEncodedThreadLocalMode(const GlobalValue &GV);
161  static unsigned getEncodedDLLStorageClass(const GlobalValue &GV);
162  static unsigned getEncodedCastOpcode(unsigned Opcode);
163  static unsigned getEncodedUnaryOpcode(unsigned Opcode);
164  static unsigned getEncodedBinaryOpcode(unsigned Opcode);
166  static unsigned getEncodedOrdering(AtomicOrdering Ordering);
167  static uint64_t getOptimizationFlags(const Value *V);
168 
169 private:
170  void writeModuleVersion();
171  void writePerModuleGlobalValueSummary();
172 
173  void writePerModuleFunctionSummaryRecord(SmallVector<uint64_t, 64> &NameVals,
174  GlobalValueSummary *Summary,
175  unsigned ValueID,
176  unsigned FSCallsAbbrev,
177  unsigned FSCallsProfileAbbrev,
178  const Function &F);
179  void writeModuleLevelReferences(const GlobalVariable &V,
180  SmallVector<uint64_t, 64> &NameVals,
181  unsigned FSModRefsAbbrev,
182  unsigned FSModVTableRefsAbbrev);
183 
184  void assignValueId(GlobalValue::GUID ValGUID) {
185  GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
186  }
187 
188  unsigned getValueId(GlobalValue::GUID ValGUID) {
189  const auto &VMI = GUIDToValueIdMap.find(ValGUID);
190  // Expect that any GUID value had a value Id assigned by an
191  // earlier call to assignValueId.
192  assert(VMI != GUIDToValueIdMap.end() &&
193  "GUID does not have assigned value Id");
194  return VMI->second;
195  }
196 
197  // Helper to get the valueId for the type of value recorded in VI.
198  unsigned getValueId(ValueInfo VI) {
199  if (!VI.haveGVs() || !VI.getValue())
200  return getValueId(VI.getGUID());
201  return VE.getValueID(VI.getValue());
202  }
203 
204  std::map<GlobalValue::GUID, unsigned> &valueIds() { return GUIDToValueIdMap; }
205 
206  uint64_t bitcodeStartBit() { return BitcodeStartBit; }
207 
208  size_t addToStrtab(StringRef Str);
209 
210  unsigned createDILocationAbbrev();
211  unsigned createGenericDINodeAbbrev();
212 
213  void writeAttributeGroupTable();
214  void writeAttributeTable();
215  void writeTypeTable();
216  void writeComdats();
217  void writeValueSymbolTableForwardDecl();
218  void writeModuleInfo();
219  void writeValueAsMetadata(const ValueAsMetadata *MD,
221  void writeMDTuple(const MDTuple *N, SmallVectorImpl<uint64_t> &Record,
222  unsigned Abbrev);
223  void writeDILocation(const DILocation *N, SmallVectorImpl<uint64_t> &Record,
224  unsigned &Abbrev);
225  void writeGenericDINode(const GenericDINode *N,
226  SmallVectorImpl<uint64_t> &Record, unsigned &Abbrev) {
227  llvm_unreachable("DXIL cannot contain GenericDI Nodes");
228  }
229  void writeDISubrange(const DISubrange *N, SmallVectorImpl<uint64_t> &Record,
230  unsigned Abbrev);
231  void writeDIGenericSubrange(const DIGenericSubrange *N,
233  unsigned Abbrev) {
234  llvm_unreachable("DXIL cannot contain DIGenericSubrange Nodes");
235  }
236  void writeDIEnumerator(const DIEnumerator *N,
237  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
238  void writeDIBasicType(const DIBasicType *N, SmallVectorImpl<uint64_t> &Record,
239  unsigned Abbrev);
240  void writeDIStringType(const DIStringType *N,
241  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
242  llvm_unreachable("DXIL cannot contain DIStringType Nodes");
243  }
244  void writeDIDerivedType(const DIDerivedType *N,
245  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
246  void writeDICompositeType(const DICompositeType *N,
247  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
248  void writeDISubroutineType(const DISubroutineType *N,
250  unsigned Abbrev);
251  void writeDIFile(const DIFile *N, SmallVectorImpl<uint64_t> &Record,
252  unsigned Abbrev);
253  void writeDICompileUnit(const DICompileUnit *N,
254  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
255  void writeDISubprogram(const DISubprogram *N,
256  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
257  void writeDILexicalBlock(const DILexicalBlock *N,
258  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
259  void writeDILexicalBlockFile(const DILexicalBlockFile *N,
261  unsigned Abbrev);
262  void writeDICommonBlock(const DICommonBlock *N,
263  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
264  llvm_unreachable("DXIL cannot contain DICommonBlock Nodes");
265  }
266  void writeDINamespace(const DINamespace *N, SmallVectorImpl<uint64_t> &Record,
267  unsigned Abbrev);
268  void writeDIMacro(const DIMacro *N, SmallVectorImpl<uint64_t> &Record,
269  unsigned Abbrev) {
270  llvm_unreachable("DXIL cannot contain DIMacro Nodes");
271  }
272  void writeDIMacroFile(const DIMacroFile *N, SmallVectorImpl<uint64_t> &Record,
273  unsigned Abbrev) {
274  llvm_unreachable("DXIL cannot contain DIMacroFile Nodes");
275  }
276  void writeDIArgList(const DIArgList *N, SmallVectorImpl<uint64_t> &Record,
277  unsigned Abbrev) {
278  llvm_unreachable("DXIL cannot contain DIArgList Nodes");
279  }
280  void writeDIAssignID(const DIAssignID *N, SmallVectorImpl<uint64_t> &Record,
281  unsigned Abbrev) {
282  // DIAssignID is experimental feature to track variable location in IR..
283  // FIXME: translate DIAssignID to debug info DXIL supports.
284  // See https://github.com/llvm/llvm-project/issues/58989
285  llvm_unreachable("DXIL cannot contain DIAssignID Nodes");
286  }
287  void writeDIModule(const DIModule *N, SmallVectorImpl<uint64_t> &Record,
288  unsigned Abbrev);
289  void writeDITemplateTypeParameter(const DITemplateTypeParameter *N,
291  unsigned Abbrev);
292  void writeDITemplateValueParameter(const DITemplateValueParameter *N,
294  unsigned Abbrev);
295  void writeDIGlobalVariable(const DIGlobalVariable *N,
297  unsigned Abbrev);
298  void writeDILocalVariable(const DILocalVariable *N,
299  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
300  void writeDILabel(const DILabel *N, SmallVectorImpl<uint64_t> &Record,
301  unsigned Abbrev) {
302  llvm_unreachable("DXIL cannot contain DILabel Nodes");
303  }
304  void writeDIExpression(const DIExpression *N,
305  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
306  void writeDIGlobalVariableExpression(const DIGlobalVariableExpression *N,
308  unsigned Abbrev) {
309  llvm_unreachable("DXIL cannot contain GlobalVariableExpression Nodes");
310  }
311  void writeDIObjCProperty(const DIObjCProperty *N,
312  SmallVectorImpl<uint64_t> &Record, unsigned Abbrev);
313  void writeDIImportedEntity(const DIImportedEntity *N,
315  unsigned Abbrev);
316  unsigned createNamedMetadataAbbrev();
317  void writeNamedMetadata(SmallVectorImpl<uint64_t> &Record);
318  unsigned createMetadataStringsAbbrev();
319  void writeMetadataStrings(ArrayRef<const Metadata *> Strings,
321  void writeMetadataRecords(ArrayRef<const Metadata *> MDs,
323  std::vector<unsigned> *MDAbbrevs = nullptr,
324  std::vector<uint64_t> *IndexPos = nullptr);
325  void writeModuleMetadata();
326  void writeFunctionMetadata(const Function &F);
327  void writeFunctionMetadataAttachment(const Function &F);
328  void pushGlobalMetadataAttachment(SmallVectorImpl<uint64_t> &Record,
329  const GlobalObject &GO);
330  void writeModuleMetadataKinds();
331  void writeOperandBundleTags();
332  void writeSyncScopeNames();
333  void writeConstants(unsigned FirstVal, unsigned LastVal, bool isGlobal);
334  void writeModuleConstants();
335  bool pushValueAndType(const Value *V, unsigned InstID,
337  void writeOperandBundles(const CallBase &CB, unsigned InstID);
338  void pushValue(const Value *V, unsigned InstID,
340  void pushValueSigned(const Value *V, unsigned InstID,
342  void writeInstruction(const Instruction &I, unsigned InstID,
344  void writeFunctionLevelValueSymbolTable(const ValueSymbolTable &VST);
345  void writeGlobalValueSymbolTable(
346  DenseMap<const Function *, uint64_t> &FunctionToBitcodeIndex);
347  void writeUseList(UseListOrder &&Order);
348  void writeUseListBlock(const Function *F);
349  void writeFunction(const Function &F);
350  void writeBlockInfo();
351 
352  unsigned getEncodedSyncScopeID(SyncScope::ID SSID) { return unsigned(SSID); }
353 
354  unsigned getEncodedAlign(MaybeAlign Alignment) { return encode(Alignment); }
355 
356  unsigned getTypeID(Type *T, const Value *V = nullptr);
357  /// getGlobalObjectValueTypeID - returns the element type for a GlobalObject
358  ///
359  /// GlobalObject types are saved by PointerTypeAnalysis as pointers to the
360  /// GlobalObject, but in the bitcode writer we need the pointer element type.
361  unsigned getGlobalObjectValueTypeID(Type *T, const GlobalObject *G);
362 };
363 
364 } // namespace dxil
365 } // namespace llvm
366 
367 using namespace llvm;
368 using namespace llvm::dxil;
369 
370 ////////////////////////////////////////////////////////////////////////////////
371 /// Begin dxil::BitcodeWriter Implementation
372 ////////////////////////////////////////////////////////////////////////////////
373 
375  raw_fd_stream *FS)
376  : Buffer(Buffer), Stream(new BitstreamWriter(Buffer, FS, 512)) {
377  // Emit the file header.
378  Stream->Emit((unsigned)'B', 8);
379  Stream->Emit((unsigned)'C', 8);
380  Stream->Emit(0x0, 4);
381  Stream->Emit(0xC, 4);
382  Stream->Emit(0xE, 4);
383  Stream->Emit(0xD, 4);
384 }
385 
387 
388 /// Write the specified module to the specified output stream.
390  SmallVector<char, 0> Buffer;
391  Buffer.reserve(256 * 1024);
392 
393  // If this is darwin or another generic macho target, reserve space for the
394  // header.
395  Triple TT(M.getTargetTriple());
396  if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
397  Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0);
398 
399  BitcodeWriter Writer(Buffer, dyn_cast<raw_fd_stream>(&Out));
400  Writer.writeModule(M);
401  Writer.writeSymtab();
402  Writer.writeStrtab();
403 
404  // Write the generated bitstream to "Out".
405  if (!Buffer.empty())
406  Out.write((char *)&Buffer.front(), Buffer.size());
407 }
408 
409 void BitcodeWriter::writeBlob(unsigned Block, unsigned Record, StringRef Blob) {
410  Stream->EnterSubblock(Block, 3);
411 
412  auto Abbv = std::make_shared<BitCodeAbbrev>();
413  Abbv->Add(BitCodeAbbrevOp(Record));
415  auto AbbrevNo = Stream->EmitAbbrev(std::move(Abbv));
416 
417  Stream->EmitRecordWithBlob(AbbrevNo, ArrayRef<uint64_t>{Record}, Blob);
418 
419  Stream->ExitBlock();
420 }
421 
423  assert(!WroteStrtab && !WroteSymtab);
424 
425  // If any module has module-level inline asm, we will require a registered asm
426  // parser for the target so that we can create an accurate symbol table for
427  // the module.
428  for (Module *M : Mods) {
429  if (M->getModuleInlineAsm().empty())
430  continue;
431  }
432 
433  WroteSymtab = true;
434  SmallVector<char, 0> Symtab;
435  // The irsymtab::build function may be unable to create a symbol table if the
436  // module is malformed (e.g. it contains an invalid alias). Writing a symbol
437  // table is not required for correctness, but we still want to be able to
438  // write malformed modules to bitcode files, so swallow the error.
439  if (Error E = irsymtab::build(Mods, Symtab, StrtabBuilder, Alloc)) {
441  return;
442  }
443 
445  {Symtab.data(), Symtab.size()});
446 }
447 
449  assert(!WroteStrtab);
450 
451  std::vector<char> Strtab;
452  StrtabBuilder.finalizeInOrder();
453  Strtab.resize(StrtabBuilder.getSize());
454  StrtabBuilder.write((uint8_t *)Strtab.data());
455 
457  {Strtab.data(), Strtab.size()});
458 
459  WroteStrtab = true;
460 }
461 
463  writeBlob(bitc::STRTAB_BLOCK_ID, bitc::STRTAB_BLOB, Strtab);
464  WroteStrtab = true;
465 }
466 
468  assert(!WroteStrtab);
469 
470  // The Mods vector is used by irsymtab::build, which requires non-const
471  // Modules in case it needs to materialize metadata. But the bitcode writer
472  // requires that the module is materialized, so we can cast to non-const here,
473  // after checking that it is in fact materialized.
474  assert(M.isMaterialized());
475  Mods.push_back(const_cast<Module *>(&M));
476 
477  DXILBitcodeWriter ModuleWriter(M, Buffer, StrtabBuilder, *Stream);
478  ModuleWriter.write();
479 }
480 
481 ////////////////////////////////////////////////////////////////////////////////
482 /// Begin dxil::BitcodeWriterBase Implementation
483 ////////////////////////////////////////////////////////////////////////////////
484 
485 unsigned DXILBitcodeWriter::getEncodedCastOpcode(unsigned Opcode) {
486  switch (Opcode) {
487  default:
488  llvm_unreachable("Unknown cast instruction!");
489  case Instruction::Trunc:
490  return bitc::CAST_TRUNC;
491  case Instruction::ZExt:
492  return bitc::CAST_ZEXT;
493  case Instruction::SExt:
494  return bitc::CAST_SEXT;
495  case Instruction::FPToUI:
496  return bitc::CAST_FPTOUI;
497  case Instruction::FPToSI:
498  return bitc::CAST_FPTOSI;
499  case Instruction::UIToFP:
500  return bitc::CAST_UITOFP;
501  case Instruction::SIToFP:
502  return bitc::CAST_SITOFP;
503  case Instruction::FPTrunc:
504  return bitc::CAST_FPTRUNC;
505  case Instruction::FPExt:
506  return bitc::CAST_FPEXT;
507  case Instruction::PtrToInt:
508  return bitc::CAST_PTRTOINT;
509  case Instruction::IntToPtr:
510  return bitc::CAST_INTTOPTR;
511  case Instruction::BitCast:
512  return bitc::CAST_BITCAST;
513  case Instruction::AddrSpaceCast:
515  }
516 }
517 
518 unsigned DXILBitcodeWriter::getEncodedUnaryOpcode(unsigned Opcode) {
519  switch (Opcode) {
520  default:
521  llvm_unreachable("Unknown binary instruction!");
522  case Instruction::FNeg:
523  return bitc::UNOP_FNEG;
524  }
525 }
526 
527 unsigned DXILBitcodeWriter::getEncodedBinaryOpcode(unsigned Opcode) {
528  switch (Opcode) {
529  default:
530  llvm_unreachable("Unknown binary instruction!");
531  case Instruction::Add:
532  case Instruction::FAdd:
533  return bitc::BINOP_ADD;
534  case Instruction::Sub:
535  case Instruction::FSub:
536  return bitc::BINOP_SUB;
537  case Instruction::Mul:
538  case Instruction::FMul:
539  return bitc::BINOP_MUL;
540  case Instruction::UDiv:
541  return bitc::BINOP_UDIV;
542  case Instruction::FDiv:
543  case Instruction::SDiv:
544  return bitc::BINOP_SDIV;
545  case Instruction::URem:
546  return bitc::BINOP_UREM;
547  case Instruction::FRem:
548  case Instruction::SRem:
549  return bitc::BINOP_SREM;
550  case Instruction::Shl:
551  return bitc::BINOP_SHL;
552  case Instruction::LShr:
553  return bitc::BINOP_LSHR;
554  case Instruction::AShr:
555  return bitc::BINOP_ASHR;
556  case Instruction::And:
557  return bitc::BINOP_AND;
558  case Instruction::Or:
559  return bitc::BINOP_OR;
560  case Instruction::Xor:
561  return bitc::BINOP_XOR;
562  }
563 }
564 
565 unsigned DXILBitcodeWriter::getTypeID(Type *T, const Value *V) {
566  if (!T->isOpaquePointerTy() &&
567  // For Constant, always check PointerMap to make sure OpaquePointer in
568  // things like constant struct/array works.
569  (!V || !isa<Constant>(V)))
570  return VE.getTypeID(T);
571  auto It = PointerMap.find(V);
572  if (It != PointerMap.end())
573  return VE.getTypeID(It->second);
574  // For Constant, return T when cannot find in PointerMap.
575  // FIXME: support ConstantPointerNull which could map to more than one
576  // TypedPointerType.
577  // See https://github.com/llvm/llvm-project/issues/57942.
578  if (V && isa<Constant>(V) && !isa<ConstantPointerNull>(V))
579  return VE.getTypeID(T);
580  return VE.getTypeID(I8PtrTy);
581 }
582 
583 unsigned DXILBitcodeWriter::getGlobalObjectValueTypeID(Type *T,
584  const GlobalObject *G) {
585  auto It = PointerMap.find(G);
586  if (It != PointerMap.end()) {
587  TypedPointerType *PtrTy = cast<TypedPointerType>(It->second);
588  return VE.getTypeID(PtrTy->getElementType());
589  }
590  return VE.getTypeID(T);
591 }
592 
594  switch (Op) {
595  default:
596  llvm_unreachable("Unknown RMW operation!");
597  case AtomicRMWInst::Xchg:
598  return bitc::RMW_XCHG;
599  case AtomicRMWInst::Add:
600  return bitc::RMW_ADD;
601  case AtomicRMWInst::Sub:
602  return bitc::RMW_SUB;
603  case AtomicRMWInst::And:
604  return bitc::RMW_AND;
605  case AtomicRMWInst::Nand:
606  return bitc::RMW_NAND;
607  case AtomicRMWInst::Or:
608  return bitc::RMW_OR;
609  case AtomicRMWInst::Xor:
610  return bitc::RMW_XOR;
611  case AtomicRMWInst::Max:
612  return bitc::RMW_MAX;
613  case AtomicRMWInst::Min:
614  return bitc::RMW_MIN;
615  case AtomicRMWInst::UMax:
616  return bitc::RMW_UMAX;
617  case AtomicRMWInst::UMin:
618  return bitc::RMW_UMIN;
619  case AtomicRMWInst::FAdd:
620  return bitc::RMW_FADD;
621  case AtomicRMWInst::FSub:
622  return bitc::RMW_FSUB;
623  case AtomicRMWInst::FMax:
624  return bitc::RMW_FMAX;
625  case AtomicRMWInst::FMin:
626  return bitc::RMW_FMIN;
627  }
628 }
629 
631  switch (Ordering) {
639  return bitc::ORDERING_ACQUIRE;
641  return bitc::ORDERING_RELEASE;
643  return bitc::ORDERING_ACQREL;
645  return bitc::ORDERING_SEQCST;
646  }
647  llvm_unreachable("Invalid ordering");
648 }
649 
651  unsigned Code, StringRef Str,
652  unsigned AbbrevToUse) {
654 
655  // Code: [strchar x N]
656  for (char C : Str) {
657  if (AbbrevToUse && !BitCodeAbbrevOp::isChar6(C))
658  AbbrevToUse = 0;
659  Vals.push_back(C);
660  }
661 
662  // Emit the finished record.
663  Stream.EmitRecord(Code, Vals, AbbrevToUse);
664 }
665 
667  switch (Kind) {
668  case Attribute::Alignment:
670  case Attribute::AlwaysInline:
672  case Attribute::Builtin:
674  case Attribute::ByVal:
675  return bitc::ATTR_KIND_BY_VAL;
678  case Attribute::InAlloca:
680  case Attribute::Cold:
681  return bitc::ATTR_KIND_COLD;
682  case Attribute::InlineHint:
684  case Attribute::InReg:
685  return bitc::ATTR_KIND_IN_REG;
688  case Attribute::MinSize:
690  case Attribute::Naked:
691  return bitc::ATTR_KIND_NAKED;
692  case Attribute::Nest:
693  return bitc::ATTR_KIND_NEST;
694  case Attribute::NoAlias:
696  case Attribute::NoBuiltin:
698  case Attribute::NoCapture:
700  case Attribute::NoDuplicate:
702  case Attribute::NoImplicitFloat:
704  case Attribute::NoInline:
706  case Attribute::NonLazyBind:
708  case Attribute::NonNull:
710  case Attribute::Dereferenceable:
712  case Attribute::DereferenceableOrNull:
714  case Attribute::NoRedZone:
716  case Attribute::NoReturn:
718  case Attribute::NoUnwind:
720  case Attribute::OptimizeForSize:
722  case Attribute::OptimizeNone:
724  case Attribute::ReadNone:
726  case Attribute::ReadOnly:
728  case Attribute::Returned:
730  case Attribute::ReturnsTwice:
732  case Attribute::SExt:
733  return bitc::ATTR_KIND_S_EXT;
734  case Attribute::StackAlignment:
736  case Attribute::StackProtect:
738  case Attribute::StackProtectReq:
740  case Attribute::StackProtectStrong:
742  case Attribute::SafeStack:
744  case Attribute::StructRet:
746  case Attribute::SanitizeAddress:
748  case Attribute::SanitizeThread:
750  case Attribute::SanitizeMemory:
752  case Attribute::UWTable:
754  case Attribute::ZExt:
755  return bitc::ATTR_KIND_Z_EXT;
757  llvm_unreachable("Can not encode end-attribute kinds marker.");
758  case Attribute::None:
759  llvm_unreachable("Can not encode none-attribute.");
760  case Attribute::EmptyKey:
762  llvm_unreachable("Trying to encode EmptyKey/TombstoneKey");
763  default:
764  llvm_unreachable("Trying to encode attribute not supported by DXIL. These "
765  "should be stripped in DXILPrepare");
766  }
767 
768  llvm_unreachable("Trying to encode unknown attribute");
769 }
770 
772  uint64_t V) {
773  if ((int64_t)V >= 0)
774  Vals.push_back(V << 1);
775  else
776  Vals.push_back((-V << 1) | 1);
777 }
778 
780  const APInt &A) {
781  // We have an arbitrary precision integer value to write whose
782  // bit width is > 64. However, in canonical unsigned integer
783  // format it is likely that the high bits are going to be zero.
784  // So, we only write the number of active words.
785  unsigned NumWords = A.getActiveWords();
786  const uint64_t *RawData = A.getRawData();
787  for (unsigned i = 0; i < NumWords; i++)
788  emitSignedInt64(Vals, RawData[i]);
789 }
790 
792  uint64_t Flags = 0;
793 
794  if (const auto *OBO = dyn_cast<OverflowingBinaryOperator>(V)) {
795  if (OBO->hasNoSignedWrap())
796  Flags |= 1 << bitc::OBO_NO_SIGNED_WRAP;
797  if (OBO->hasNoUnsignedWrap())
798  Flags |= 1 << bitc::OBO_NO_UNSIGNED_WRAP;
799  } else if (const auto *PEO = dyn_cast<PossiblyExactOperator>(V)) {
800  if (PEO->isExact())
801  Flags |= 1 << bitc::PEO_EXACT;
802  } else if (const auto *FPMO = dyn_cast<FPMathOperator>(V)) {
803  if (FPMO->hasAllowReassoc())
804  Flags |= bitc::AllowReassoc;
805  if (FPMO->hasNoNaNs())
806  Flags |= bitc::NoNaNs;
807  if (FPMO->hasNoInfs())
808  Flags |= bitc::NoInfs;
809  if (FPMO->hasNoSignedZeros())
810  Flags |= bitc::NoSignedZeros;
811  if (FPMO->hasAllowReciprocal())
812  Flags |= bitc::AllowReciprocal;
813  if (FPMO->hasAllowContract())
814  Flags |= bitc::AllowContract;
815  if (FPMO->hasApproxFunc())
816  Flags |= bitc::ApproxFunc;
817  }
818 
819  return Flags;
820 }
821 
822 unsigned
824  switch (Linkage) {
826  return 0;
828  return 16;
830  return 2;
832  return 3;
834  return 18;
836  return 7;
838  return 8;
840  return 9;
842  return 17;
844  return 19;
846  return 12;
847  }
848  llvm_unreachable("Invalid linkage");
849 }
850 
852  return getEncodedLinkage(GV.getLinkage());
853 }
854 
856  switch (GV.getVisibility()) {
858  return 0;
860  return 1;
862  return 2;
863  }
864  llvm_unreachable("Invalid visibility");
865 }
866 
868  switch (GV.getDLLStorageClass()) {
870  return 0;
872  return 1;
874  return 2;
875  }
876  llvm_unreachable("Invalid DLL storage class");
877 }
878 
880  switch (GV.getThreadLocalMode()) {
882  return 0;
884  return 1;
886  return 2;
888  return 3;
890  return 4;
891  }
892  llvm_unreachable("Invalid TLS model");
893 }
894 
896  switch (C.getSelectionKind()) {
897  case Comdat::Any:
899  case Comdat::ExactMatch:
901  case Comdat::Largest:
905  case Comdat::SameSize:
907  }
908  llvm_unreachable("Invalid selection kind");
909 }
910 
911 ////////////////////////////////////////////////////////////////////////////////
912 /// Begin DXILBitcodeWriter Implementation
913 ////////////////////////////////////////////////////////////////////////////////
914 
915 void DXILBitcodeWriter::writeAttributeGroupTable() {
916  const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
917  VE.getAttributeGroups();
918  if (AttrGrps.empty())
919  return;
920 
922 
924  for (ValueEnumerator::IndexAndAttrSet Pair : AttrGrps) {
925  unsigned AttrListIndex = Pair.first;
926  AttributeSet AS = Pair.second;
927  Record.push_back(VE.getAttributeGroupID(Pair));
928  Record.push_back(AttrListIndex);
929 
930  for (Attribute Attr : AS) {
931  if (Attr.isEnumAttribute()) {
932  uint64_t Val = getAttrKindEncoding(Attr.getKindAsEnum());
934  "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
935  Record.push_back(0);
936  Record.push_back(Val);
937  } else if (Attr.isIntAttribute()) {
938  if (Attr.getKindAsEnum() == Attribute::AttrKind::Memory) {
939  MemoryEffects ME = Attr.getMemoryEffects();
940  if (ME.doesNotAccessMemory()) {
941  Record.push_back(0);
943  } else {
944  if (ME.onlyReadsMemory()) {
945  Record.push_back(0);
947  }
948  if (ME.onlyAccessesArgPointees()) {
949  Record.push_back(0);
951  }
952  }
953  } else {
954  uint64_t Val = getAttrKindEncoding(Attr.getKindAsEnum());
956  "DXIL does not support attributes above ATTR_KIND_ARGMEMONLY");
957  Record.push_back(1);
958  Record.push_back(Val);
959  Record.push_back(Attr.getValueAsInt());
960  }
961  } else {
962  StringRef Kind = Attr.getKindAsString();
963  StringRef Val = Attr.getValueAsString();
964 
965  Record.push_back(Val.empty() ? 3 : 4);
966  Record.append(Kind.begin(), Kind.end());
967  Record.push_back(0);
968  if (!Val.empty()) {
969  Record.append(Val.begin(), Val.end());
970  Record.push_back(0);
971  }
972  }
973  }
974 
976  Record.clear();
977  }
978 
979  Stream.ExitBlock();
980 }
981 
982 void DXILBitcodeWriter::writeAttributeTable() {
983  const std::vector<AttributeList> &Attrs = VE.getAttributeLists();
984  if (Attrs.empty())
985  return;
986 
988 
990  for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
991  AttributeList AL = Attrs[i];
992  for (unsigned i : AL.indexes()) {
993  AttributeSet AS = AL.getAttributes(i);
994  if (AS.hasAttributes())
995  Record.push_back(VE.getAttributeGroupID({i, AS}));
996  }
997 
999  Record.clear();
1000  }
1001 
1002  Stream.ExitBlock();
1003 }
1004 
1005 /// WriteTypeTable - Write out the type table for a module.
1006 void DXILBitcodeWriter::writeTypeTable() {
1007  const ValueEnumerator::TypeList &TypeList = VE.getTypes();
1008 
1009  Stream.EnterSubblock(bitc::TYPE_BLOCK_ID_NEW, 4 /*count from # abbrevs */);
1010  SmallVector<uint64_t, 64> TypeVals;
1011 
1013 
1014  // Abbrev for TYPE_CODE_POINTER.
1015  auto Abbv = std::make_shared<BitCodeAbbrev>();
1017  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
1018  Abbv->Add(BitCodeAbbrevOp(0)); // Addrspace = 0
1019  unsigned PtrAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1020 
1021  // Abbrev for TYPE_CODE_FUNCTION.
1022  Abbv = std::make_shared<BitCodeAbbrev>();
1024  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isvararg
1026  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
1027  unsigned FunctionAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1028 
1029  // Abbrev for TYPE_CODE_STRUCT_ANON.
1030  Abbv = std::make_shared<BitCodeAbbrev>();
1032  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked
1034  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
1035  unsigned StructAnonAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1036 
1037  // Abbrev for TYPE_CODE_STRUCT_NAME.
1038  Abbv = std::make_shared<BitCodeAbbrev>();
1042  unsigned StructNameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1043 
1044  // Abbrev for TYPE_CODE_STRUCT_NAMED.
1045  Abbv = std::make_shared<BitCodeAbbrev>();
1047  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked
1049  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
1050  unsigned StructNamedAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1051 
1052  // Abbrev for TYPE_CODE_ARRAY.
1053  Abbv = std::make_shared<BitCodeAbbrev>();
1055  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // size
1056  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits));
1057  unsigned ArrayAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1058 
1059  // Emit an entry count so the reader can reserve space.
1060  TypeVals.push_back(TypeList.size());
1061  Stream.EmitRecord(bitc::TYPE_CODE_NUMENTRY, TypeVals);
1062  TypeVals.clear();
1063 
1064  // Loop over all of the types, emitting each in turn.
1065  for (Type *T : TypeList) {
1066  int AbbrevToUse = 0;
1067  unsigned Code = 0;
1068 
1069  switch (T->getTypeID()) {
1070  case Type::BFloatTyID:
1071  case Type::X86_AMXTyID:
1072  case Type::TokenTyID:
1073  llvm_unreachable("These should never be used!!!");
1074  break;
1075  case Type::VoidTyID:
1077  break;
1078  case Type::HalfTyID:
1080  break;
1081  case Type::FloatTyID:
1083  break;
1084  case Type::DoubleTyID:
1086  break;
1087  case Type::X86_FP80TyID:
1089  break;
1090  case Type::FP128TyID:
1092  break;
1093  case Type::PPC_FP128TyID:
1095  break;
1096  case Type::LabelTyID:
1098  break;
1099  case Type::MetadataTyID:
1101  break;
1102  case Type::X86_MMXTyID:
1104  break;
1105  case Type::IntegerTyID:
1106  // INTEGER: [width]
1108  TypeVals.push_back(cast<IntegerType>(T)->getBitWidth());
1109  break;
1110  case Type::TypedPointerTyID: {
1111  TypedPointerType *PTy = cast<TypedPointerType>(T);
1112  // POINTER: [pointee type, address space]
1114  TypeVals.push_back(getTypeID(PTy->getElementType()));
1115  unsigned AddressSpace = PTy->getAddressSpace();
1116  TypeVals.push_back(AddressSpace);
1117  if (AddressSpace == 0)
1118  AbbrevToUse = PtrAbbrev;
1119  break;
1120  }
1121  case Type::PointerTyID: {
1122  PointerType *PTy = cast<PointerType>(T);
1123  // POINTER: [pointee type, address space]
1125  // Emitting an empty struct type for the opaque pointer's type allows
1126  // this to be order-independent. Non-struct types must be emitted in
1127  // bitcode before they can be referenced.
1128  if (PTy->isOpaquePointerTy()) {
1129  TypeVals.push_back(false);
1132  "dxilOpaquePtrReservedName", StructNameAbbrev);
1133  } else {
1134  TypeVals.push_back(getTypeID(PTy->getNonOpaquePointerElementType()));
1135  unsigned AddressSpace = PTy->getAddressSpace();
1136  TypeVals.push_back(AddressSpace);
1137  if (AddressSpace == 0)
1138  AbbrevToUse = PtrAbbrev;
1139  }
1140  break;
1141  }
1142  case Type::FunctionTyID: {
1143  FunctionType *FT = cast<FunctionType>(T);
1144  // FUNCTION: [isvararg, retty, paramty x N]
1146  TypeVals.push_back(FT->isVarArg());
1147  TypeVals.push_back(getTypeID(FT->getReturnType()));
1148  for (Type *PTy : FT->params())
1149  TypeVals.push_back(getTypeID(PTy));
1150  AbbrevToUse = FunctionAbbrev;
1151  break;
1152  }
1153  case Type::StructTyID: {
1154  StructType *ST = cast<StructType>(T);
1155  // STRUCT: [ispacked, eltty x N]
1156  TypeVals.push_back(ST->isPacked());
1157  // Output all of the element types.
1158  for (Type *ElTy : ST->elements())
1159  TypeVals.push_back(getTypeID(ElTy));
1160 
1161  if (ST->isLiteral()) {
1163  AbbrevToUse = StructAnonAbbrev;
1164  } else {
1165  if (ST->isOpaque()) {
1167  } else {
1169  AbbrevToUse = StructNamedAbbrev;
1170  }
1171 
1172  // Emit the name if it is present.
1173  if (!ST->getName().empty())
1174  writeStringRecord(Stream, bitc::TYPE_CODE_STRUCT_NAME, ST->getName(),
1175  StructNameAbbrev);
1176  }
1177  break;
1178  }
1179  case Type::ArrayTyID: {
1180  ArrayType *AT = cast<ArrayType>(T);
1181  // ARRAY: [numelts, eltty]
1183  TypeVals.push_back(AT->getNumElements());
1184  TypeVals.push_back(getTypeID(AT->getElementType()));
1185  AbbrevToUse = ArrayAbbrev;
1186  break;
1187  }
1188  case Type::FixedVectorTyID:
1189  case Type::ScalableVectorTyID: {
1190  VectorType *VT = cast<VectorType>(T);
1191  // VECTOR [numelts, eltty]
1193  TypeVals.push_back(VT->getElementCount().getKnownMinValue());
1194  TypeVals.push_back(getTypeID(VT->getElementType()));
1195  break;
1196  }
1197  }
1198 
1199  // Emit the finished record.
1200  Stream.EmitRecord(Code, TypeVals, AbbrevToUse);
1201  TypeVals.clear();
1202  }
1203 
1204  Stream.ExitBlock();
1205 }
1206 
1207 void DXILBitcodeWriter::writeComdats() {
1209  for (const Comdat *C : VE.getComdats()) {
1210  // COMDAT: [selection_kind, name]
1211  Vals.push_back(getEncodedComdatSelectionKind(*C));
1212  size_t Size = C->getName().size();
1213  assert(isUInt<16>(Size));
1214  Vals.push_back(Size);
1215  for (char Chr : C->getName())
1216  Vals.push_back((unsigned char)Chr);
1217  Stream.EmitRecord(bitc::MODULE_CODE_COMDAT, Vals, /*AbbrevToUse=*/0);
1218  Vals.clear();
1219  }
1220 }
1221 
1222 void DXILBitcodeWriter::writeValueSymbolTableForwardDecl() {}
1223 
1224 /// Emit top-level description of module, including target triple, inline asm,
1225 /// descriptors for global variables, and function prototype info.
1226 /// Returns the bit offset to backpatch with the location of the real VST.
1227 void DXILBitcodeWriter::writeModuleInfo() {
1228  // Emit various pieces of data attached to a module.
1229  if (!M.getTargetTriple().empty())
1230  writeStringRecord(Stream, bitc::MODULE_CODE_TRIPLE, M.getTargetTriple(),
1231  0 /*TODO*/);
1232  const std::string &DL = M.getDataLayoutStr();
1233  if (!DL.empty())
1234  writeStringRecord(Stream, bitc::MODULE_CODE_DATALAYOUT, DL, 0 /*TODO*/);
1235  if (!M.getModuleInlineAsm().empty())
1236  writeStringRecord(Stream, bitc::MODULE_CODE_ASM, M.getModuleInlineAsm(),
1237  0 /*TODO*/);
1238 
1239  // Emit information about sections and GC, computing how many there are. Also
1240  // compute the maximum alignment value.
1241  std::map<std::string, unsigned> SectionMap;
1242  std::map<std::string, unsigned> GCMap;
1243  MaybeAlign MaxAlignment;
1244  unsigned MaxGlobalType = 0;
1245  const auto UpdateMaxAlignment = [&MaxAlignment](const MaybeAlign A) {
1246  if (A)
1247  MaxAlignment = !MaxAlignment ? *A : std::max(*MaxAlignment, *A);
1248  };
1249  for (const GlobalVariable &GV : M.globals()) {
1250  UpdateMaxAlignment(GV.getAlign());
1251  // Use getGlobalObjectValueTypeID to look up the enumerated type ID for
1252  // Global Variable types.
1253  MaxGlobalType = std::max(
1254  MaxGlobalType, getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1255  if (GV.hasSection()) {
1256  // Give section names unique ID's.
1257  unsigned &Entry = SectionMap[std::string(GV.getSection())];
1258  if (!Entry) {
1260  GV.getSection(), 0 /*TODO*/);
1261  Entry = SectionMap.size();
1262  }
1263  }
1264  }
1265  for (const Function &F : M) {
1266  UpdateMaxAlignment(F.getAlign());
1267  if (F.hasSection()) {
1268  // Give section names unique ID's.
1269  unsigned &Entry = SectionMap[std::string(F.getSection())];
1270  if (!Entry) {
1271  writeStringRecord(Stream, bitc::MODULE_CODE_SECTIONNAME, F.getSection(),
1272  0 /*TODO*/);
1273  Entry = SectionMap.size();
1274  }
1275  }
1276  if (F.hasGC()) {
1277  // Same for GC names.
1278  unsigned &Entry = GCMap[F.getGC()];
1279  if (!Entry) {
1280  writeStringRecord(Stream, bitc::MODULE_CODE_GCNAME, F.getGC(),
1281  0 /*TODO*/);
1282  Entry = GCMap.size();
1283  }
1284  }
1285  }
1286 
1287  // Emit abbrev for globals, now that we know # sections and max alignment.
1288  unsigned SimpleGVarAbbrev = 0;
1289  if (!M.global_empty()) {
1290  // Add an abbrev for common globals with no visibility or thread
1291  // localness.
1292  auto Abbv = std::make_shared<BitCodeAbbrev>();
1295  Log2_32_Ceil(MaxGlobalType + 1)));
1296  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddrSpace << 2
1297  //| explicitType << 1
1298  //| constant
1299  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Initializer.
1300  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // Linkage.
1301  if (!MaxAlignment) // Alignment.
1302  Abbv->Add(BitCodeAbbrevOp(0));
1303  else {
1304  unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1306  Log2_32_Ceil(MaxEncAlignment + 1)));
1307  }
1308  if (SectionMap.empty()) // Section.
1309  Abbv->Add(BitCodeAbbrevOp(0));
1310  else
1312  Log2_32_Ceil(SectionMap.size() + 1)));
1313  // Don't bother emitting vis + thread local.
1314  SimpleGVarAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1315  }
1316 
1317  // Emit the global variable information.
1319  for (const GlobalVariable &GV : M.globals()) {
1320  unsigned AbbrevToUse = 0;
1321 
1322  // GLOBALVAR: [type, isconst, initid,
1323  // linkage, alignment, section, visibility, threadlocal,
1324  // unnamed_addr, externally_initialized, dllstorageclass,
1325  // comdat]
1326  Vals.push_back(getGlobalObjectValueTypeID(GV.getValueType(), &GV));
1327  Vals.push_back(
1328  GV.getType()->getAddressSpace() << 2 | 2 |
1329  (GV.isConstant() ? 1 : 0)); // HLSL Change - bitwise | was used with
1330  // unsigned int and bool
1331  Vals.push_back(
1332  GV.isDeclaration() ? 0 : (VE.getValueID(GV.getInitializer()) + 1));
1333  Vals.push_back(getEncodedLinkage(GV));
1334  Vals.push_back(getEncodedAlign(GV.getAlign()));
1335  Vals.push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1336  : 0);
1337  if (GV.isThreadLocal() ||
1338  GV.getVisibility() != GlobalValue::DefaultVisibility ||
1339  GV.getUnnamedAddr() != GlobalValue::UnnamedAddr::None ||
1340  GV.isExternallyInitialized() ||
1341  GV.getDLLStorageClass() != GlobalValue::DefaultStorageClass ||
1342  GV.hasComdat()) {
1343  Vals.push_back(getEncodedVisibility(GV));
1344  Vals.push_back(getEncodedThreadLocalMode(GV));
1345  Vals.push_back(GV.getUnnamedAddr() != GlobalValue::UnnamedAddr::None);
1346  Vals.push_back(GV.isExternallyInitialized());
1347  Vals.push_back(getEncodedDLLStorageClass(GV));
1348  Vals.push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1349  } else {
1350  AbbrevToUse = SimpleGVarAbbrev;
1351  }
1352 
1353  Stream.EmitRecord(bitc::MODULE_CODE_GLOBALVAR, Vals, AbbrevToUse);
1354  Vals.clear();
1355  }
1356 
1357  // Emit the function proto information.
1358  for (const Function &F : M) {
1359  // FUNCTION: [type, callingconv, isproto, linkage, paramattrs, alignment,
1360  // section, visibility, gc, unnamed_addr, prologuedata,
1361  // dllstorageclass, comdat, prefixdata, personalityfn]
1362  Vals.push_back(getGlobalObjectValueTypeID(F.getFunctionType(), &F));
1363  Vals.push_back(F.getCallingConv());
1364  Vals.push_back(F.isDeclaration());
1365  Vals.push_back(getEncodedLinkage(F));
1366  Vals.push_back(VE.getAttributeListID(F.getAttributes()));
1367  Vals.push_back(getEncodedAlign(F.getAlign()));
1368  Vals.push_back(F.hasSection() ? SectionMap[std::string(F.getSection())]
1369  : 0);
1370  Vals.push_back(getEncodedVisibility(F));
1371  Vals.push_back(F.hasGC() ? GCMap[F.getGC()] : 0);
1372  Vals.push_back(F.getUnnamedAddr() != GlobalValue::UnnamedAddr::None);
1373  Vals.push_back(
1374  F.hasPrologueData() ? (VE.getValueID(F.getPrologueData()) + 1) : 0);
1375  Vals.push_back(getEncodedDLLStorageClass(F));
1376  Vals.push_back(F.hasComdat() ? VE.getComdatID(F.getComdat()) : 0);
1377  Vals.push_back(F.hasPrefixData() ? (VE.getValueID(F.getPrefixData()) + 1)
1378  : 0);
1379  Vals.push_back(
1380  F.hasPersonalityFn() ? (VE.getValueID(F.getPersonalityFn()) + 1) : 0);
1381 
1382  unsigned AbbrevToUse = 0;
1383  Stream.EmitRecord(bitc::MODULE_CODE_FUNCTION, Vals, AbbrevToUse);
1384  Vals.clear();
1385  }
1386 
1387  // Emit the alias information.
1388  for (const GlobalAlias &A : M.aliases()) {
1389  // ALIAS: [alias type, aliasee val#, linkage, visibility]
1390  Vals.push_back(getTypeID(A.getValueType(), &A));
1391  Vals.push_back(VE.getValueID(A.getAliasee()));
1392  Vals.push_back(getEncodedLinkage(A));
1393  Vals.push_back(getEncodedVisibility(A));
1394  Vals.push_back(getEncodedDLLStorageClass(A));
1395  Vals.push_back(getEncodedThreadLocalMode(A));
1396  Vals.push_back(A.getUnnamedAddr() != GlobalValue::UnnamedAddr::None);
1397  unsigned AbbrevToUse = 0;
1398  Stream.EmitRecord(bitc::MODULE_CODE_ALIAS_OLD, Vals, AbbrevToUse);
1399  Vals.clear();
1400  }
1401 }
1402 
1403 void DXILBitcodeWriter::writeValueAsMetadata(
1405  // Mimic an MDNode with a value as one operand.
1406  Value *V = MD->getValue();
1407  Type *Ty = V->getType();
1408  if (Function *F = dyn_cast<Function>(V))
1409  Ty = TypedPointerType::get(F->getFunctionType(), F->getAddressSpace());
1410  else if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
1411  Ty = TypedPointerType::get(GV->getValueType(), GV->getAddressSpace());
1412  Record.push_back(getTypeID(Ty));
1413  Record.push_back(VE.getValueID(V));
1415  Record.clear();
1416 }
1417 
1418 void DXILBitcodeWriter::writeMDTuple(const MDTuple *N,
1420  unsigned Abbrev) {
1421  for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
1422  Metadata *MD = N->getOperand(i);
1423  assert(!(MD && isa<LocalAsMetadata>(MD)) &&
1424  "Unexpected function-local metadata");
1425  Record.push_back(VE.getMetadataOrNullID(MD));
1426  }
1427  Stream.EmitRecord(N->isDistinct() ? bitc::METADATA_DISTINCT_NODE
1429  Record, Abbrev);
1430  Record.clear();
1431 }
1432 
1433 void DXILBitcodeWriter::writeDILocation(const DILocation *N,
1435  unsigned &Abbrev) {
1436  if (!Abbrev)
1437  Abbrev = createDILocationAbbrev();
1438  Record.push_back(N->isDistinct());
1439  Record.push_back(N->getLine());
1440  Record.push_back(N->getColumn());
1441  Record.push_back(VE.getMetadataID(N->getScope()));
1442  Record.push_back(VE.getMetadataOrNullID(N->getInlinedAt()));
1443 
1444  Stream.EmitRecord(bitc::METADATA_LOCATION, Record, Abbrev);
1445  Record.clear();
1446 }
1447 
1449  int64_t I = Val.getSExtValue();
1450  uint64_t U = I;
1451  return I < 0 ? ~(U << 1) : U << 1;
1452 }
1453 
1454 static uint64_t rotateSign(DISubrange::BoundType Val) {
1455  return rotateSign(Val.get<ConstantInt *>()->getValue());
1456 }
1457 
1458 void DXILBitcodeWriter::writeDISubrange(const DISubrange *N,
1460  unsigned Abbrev) {
1461  Record.push_back(N->isDistinct());
1462  Record.push_back(
1463  N->getCount().get<ConstantInt *>()->getValue().getSExtValue());
1464  Record.push_back(rotateSign(N->getLowerBound()));
1465 
1466  Stream.EmitRecord(bitc::METADATA_SUBRANGE, Record, Abbrev);
1467  Record.clear();
1468 }
1469 
1470 void DXILBitcodeWriter::writeDIEnumerator(const DIEnumerator *N,
1472  unsigned Abbrev) {
1473  Record.push_back(N->isDistinct());
1474  Record.push_back(rotateSign(N->getValue()));
1475  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1476 
1477  Stream.EmitRecord(bitc::METADATA_ENUMERATOR, Record, Abbrev);
1478  Record.clear();
1479 }
1480 
1481 void DXILBitcodeWriter::writeDIBasicType(const DIBasicType *N,
1483  unsigned Abbrev) {
1484  Record.push_back(N->isDistinct());
1485  Record.push_back(N->getTag());
1486  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1487  Record.push_back(N->getSizeInBits());
1488  Record.push_back(N->getAlignInBits());
1489  Record.push_back(N->getEncoding());
1490 
1491  Stream.EmitRecord(bitc::METADATA_BASIC_TYPE, Record, Abbrev);
1492  Record.clear();
1493 }
1494 
1495 void DXILBitcodeWriter::writeDIDerivedType(const DIDerivedType *N,
1497  unsigned Abbrev) {
1498  Record.push_back(N->isDistinct());
1499  Record.push_back(N->getTag());
1500  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1501  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1502  Record.push_back(N->getLine());
1503  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1504  Record.push_back(VE.getMetadataOrNullID(N->getBaseType()));
1505  Record.push_back(N->getSizeInBits());
1506  Record.push_back(N->getAlignInBits());
1507  Record.push_back(N->getOffsetInBits());
1508  Record.push_back(N->getFlags());
1509  Record.push_back(VE.getMetadataOrNullID(N->getExtraData()));
1510 
1512  Record.clear();
1513 }
1514 
1515 void DXILBitcodeWriter::writeDICompositeType(const DICompositeType *N,
1517  unsigned Abbrev) {
1518  Record.push_back(N->isDistinct());
1519  Record.push_back(N->getTag());
1520  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1521  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1522  Record.push_back(N->getLine());
1523  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1524  Record.push_back(VE.getMetadataOrNullID(N->getBaseType()));
1525  Record.push_back(N->getSizeInBits());
1526  Record.push_back(N->getAlignInBits());
1527  Record.push_back(N->getOffsetInBits());
1528  Record.push_back(N->getFlags());
1529  Record.push_back(VE.getMetadataOrNullID(N->getElements().get()));
1530  Record.push_back(N->getRuntimeLang());
1531  Record.push_back(VE.getMetadataOrNullID(N->getVTableHolder()));
1532  Record.push_back(VE.getMetadataOrNullID(N->getTemplateParams().get()));
1533  Record.push_back(VE.getMetadataOrNullID(N->getRawIdentifier()));
1534 
1536  Record.clear();
1537 }
1538 
1539 void DXILBitcodeWriter::writeDISubroutineType(const DISubroutineType *N,
1541  unsigned Abbrev) {
1542  Record.push_back(N->isDistinct());
1543  Record.push_back(N->getFlags());
1544  Record.push_back(VE.getMetadataOrNullID(N->getTypeArray().get()));
1545 
1547  Record.clear();
1548 }
1549 
1550 void DXILBitcodeWriter::writeDIFile(const DIFile *N,
1552  unsigned Abbrev) {
1553  Record.push_back(N->isDistinct());
1554  Record.push_back(VE.getMetadataOrNullID(N->getRawFilename()));
1555  Record.push_back(VE.getMetadataOrNullID(N->getRawDirectory()));
1556 
1557  Stream.EmitRecord(bitc::METADATA_FILE, Record, Abbrev);
1558  Record.clear();
1559 }
1560 
1561 void DXILBitcodeWriter::writeDICompileUnit(const DICompileUnit *N,
1563  unsigned Abbrev) {
1564  Record.push_back(N->isDistinct());
1565  Record.push_back(N->getSourceLanguage());
1566  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1567  Record.push_back(VE.getMetadataOrNullID(N->getRawProducer()));
1568  Record.push_back(N->isOptimized());
1569  Record.push_back(VE.getMetadataOrNullID(N->getRawFlags()));
1570  Record.push_back(N->getRuntimeVersion());
1571  Record.push_back(VE.getMetadataOrNullID(N->getRawSplitDebugFilename()));
1572  Record.push_back(N->getEmissionKind());
1573  Record.push_back(VE.getMetadataOrNullID(N->getEnumTypes().get()));
1574  Record.push_back(VE.getMetadataOrNullID(N->getRetainedTypes().get()));
1575  Record.push_back(/* subprograms */ 0);
1576  Record.push_back(VE.getMetadataOrNullID(N->getGlobalVariables().get()));
1577  Record.push_back(VE.getMetadataOrNullID(N->getImportedEntities().get()));
1578  Record.push_back(N->getDWOId());
1579 
1581  Record.clear();
1582 }
1583 
1584 void DXILBitcodeWriter::writeDISubprogram(const DISubprogram *N,
1586  unsigned Abbrev) {
1587  Record.push_back(N->isDistinct());
1588  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1589  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1590  Record.push_back(VE.getMetadataOrNullID(N->getRawLinkageName()));
1591  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1592  Record.push_back(N->getLine());
1593  Record.push_back(VE.getMetadataOrNullID(N->getType()));
1594  Record.push_back(N->isLocalToUnit());
1595  Record.push_back(N->isDefinition());
1596  Record.push_back(N->getScopeLine());
1597  Record.push_back(VE.getMetadataOrNullID(N->getContainingType()));
1598  Record.push_back(N->getVirtuality());
1599  Record.push_back(N->getVirtualIndex());
1600  Record.push_back(N->getFlags());
1601  Record.push_back(N->isOptimized());
1602  Record.push_back(VE.getMetadataOrNullID(N->getRawUnit()));
1603  Record.push_back(VE.getMetadataOrNullID(N->getTemplateParams().get()));
1604  Record.push_back(VE.getMetadataOrNullID(N->getDeclaration()));
1605  Record.push_back(VE.getMetadataOrNullID(N->getRetainedNodes().get()));
1606 
1607  Stream.EmitRecord(bitc::METADATA_SUBPROGRAM, Record, Abbrev);
1608  Record.clear();
1609 }
1610 
1611 void DXILBitcodeWriter::writeDILexicalBlock(const DILexicalBlock *N,
1613  unsigned Abbrev) {
1614  Record.push_back(N->isDistinct());
1615  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1616  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1617  Record.push_back(N->getLine());
1618  Record.push_back(N->getColumn());
1619 
1621  Record.clear();
1622 }
1623 
1624 void DXILBitcodeWriter::writeDILexicalBlockFile(
1626  unsigned Abbrev) {
1627  Record.push_back(N->isDistinct());
1628  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1629  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1630  Record.push_back(N->getDiscriminator());
1631 
1633  Record.clear();
1634 }
1635 
1636 void DXILBitcodeWriter::writeDINamespace(const DINamespace *N,
1638  unsigned Abbrev) {
1639  Record.push_back(N->isDistinct());
1640  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1641  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1642  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1643  Record.push_back(/* line number */ 0);
1644 
1645  Stream.EmitRecord(bitc::METADATA_NAMESPACE, Record, Abbrev);
1646  Record.clear();
1647 }
1648 
1649 void DXILBitcodeWriter::writeDIModule(const DIModule *N,
1651  unsigned Abbrev) {
1652  Record.push_back(N->isDistinct());
1653  for (auto &I : N->operands())
1654  Record.push_back(VE.getMetadataOrNullID(I));
1655 
1656  Stream.EmitRecord(bitc::METADATA_MODULE, Record, Abbrev);
1657  Record.clear();
1658 }
1659 
1660 void DXILBitcodeWriter::writeDITemplateTypeParameter(
1662  unsigned Abbrev) {
1663  Record.push_back(N->isDistinct());
1664  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1665  Record.push_back(VE.getMetadataOrNullID(N->getType()));
1666 
1668  Record.clear();
1669 }
1670 
1671 void DXILBitcodeWriter::writeDITemplateValueParameter(
1673  unsigned Abbrev) {
1674  Record.push_back(N->isDistinct());
1675  Record.push_back(N->getTag());
1676  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1677  Record.push_back(VE.getMetadataOrNullID(N->getType()));
1678  Record.push_back(VE.getMetadataOrNullID(N->getValue()));
1679 
1681  Record.clear();
1682 }
1683 
1684 void DXILBitcodeWriter::writeDIGlobalVariable(const DIGlobalVariable *N,
1686  unsigned Abbrev) {
1687  Record.push_back(N->isDistinct());
1688  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1689  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1690  Record.push_back(VE.getMetadataOrNullID(N->getRawLinkageName()));
1691  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1692  Record.push_back(N->getLine());
1693  Record.push_back(VE.getMetadataOrNullID(N->getType()));
1694  Record.push_back(N->isLocalToUnit());
1695  Record.push_back(N->isDefinition());
1696  Record.push_back(/* N->getRawVariable() */ 0);
1697  Record.push_back(VE.getMetadataOrNullID(N->getStaticDataMemberDeclaration()));
1698 
1699  Stream.EmitRecord(bitc::METADATA_GLOBAL_VAR, Record, Abbrev);
1700  Record.clear();
1701 }
1702 
1703 void DXILBitcodeWriter::writeDILocalVariable(const DILocalVariable *N,
1705  unsigned Abbrev) {
1706  Record.push_back(N->isDistinct());
1707  Record.push_back(N->getTag());
1708  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1709  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1710  Record.push_back(VE.getMetadataOrNullID(N->getFile()));
1711  Record.push_back(N->getLine());
1712  Record.push_back(VE.getMetadataOrNullID(N->getType()));
1713  Record.push_back(N->getArg());
1714  Record.push_back(N->getFlags());
1715 
1716  Stream.EmitRecord(bitc::METADATA_LOCAL_VAR, Record, Abbrev);
1717  Record.clear();
1718 }
1719 
1720 void DXILBitcodeWriter::writeDIExpression(const DIExpression *N,
1722  unsigned Abbrev) {
1723  Record.reserve(N->getElements().size() + 1);
1724 
1725  Record.push_back(N->isDistinct());
1726  Record.append(N->elements_begin(), N->elements_end());
1727 
1728  Stream.EmitRecord(bitc::METADATA_EXPRESSION, Record, Abbrev);
1729  Record.clear();
1730 }
1731 
1732 void DXILBitcodeWriter::writeDIObjCProperty(const DIObjCProperty *N,
1734  unsigned Abbrev) {
1735  llvm_unreachable("DXIL does not support objc!!!");
1736 }
1737 
1738 void DXILBitcodeWriter::writeDIImportedEntity(const DIImportedEntity *N,
1740  unsigned Abbrev) {
1741  Record.push_back(N->isDistinct());
1742  Record.push_back(N->getTag());
1743  Record.push_back(VE.getMetadataOrNullID(N->getScope()));
1744  Record.push_back(VE.getMetadataOrNullID(N->getEntity()));
1745  Record.push_back(N->getLine());
1746  Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
1747 
1749  Record.clear();
1750 }
1751 
1752 unsigned DXILBitcodeWriter::createDILocationAbbrev() {
1753  // Abbrev for METADATA_LOCATION.
1754  //
1755  // Assume the column is usually under 128, and always output the inlined-at
1756  // location (it's never more expensive than building an array size 1).
1757  std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1759  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1760  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1761  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
1762  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1763  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1764  return Stream.EmitAbbrev(std::move(Abbv));
1765 }
1766 
1767 unsigned DXILBitcodeWriter::createGenericDINodeAbbrev() {
1768  // Abbrev for METADATA_GENERIC_DEBUG.
1769  //
1770  // Assume the column is usually under 128, and always output the inlined-at
1771  // location (it's never more expensive than building an array size 1).
1772  std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1774  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1775  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1776  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
1777  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1779  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
1780  return Stream.EmitAbbrev(std::move(Abbv));
1781 }
1782 
1783 void DXILBitcodeWriter::writeMetadataRecords(ArrayRef<const Metadata *> MDs,
1785  std::vector<unsigned> *MDAbbrevs,
1786  std::vector<uint64_t> *IndexPos) {
1787  if (MDs.empty())
1788  return;
1789 
1790  // Initialize MDNode abbreviations.
1791 #define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1792 #include "llvm/IR/Metadata.def"
1793 
1794  for (const Metadata *MD : MDs) {
1795  if (IndexPos)
1796  IndexPos->push_back(Stream.GetCurrentBitNo());
1797  if (const MDNode *N = dyn_cast<MDNode>(MD)) {
1798  assert(N->isResolved() && "Expected forward references to be resolved");
1799 
1800  switch (N->getMetadataID()) {
1801  default:
1802  llvm_unreachable("Invalid MDNode subclass");
1803 #define HANDLE_MDNODE_LEAF(CLASS) \
1804  case Metadata::CLASS##Kind: \
1805  if (MDAbbrevs) \
1806  write##CLASS(cast<CLASS>(N), Record, \
1807  (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1808  else \
1809  write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1810  continue;
1811 #include "llvm/IR/Metadata.def"
1812  }
1813  }
1814  writeValueAsMetadata(cast<ValueAsMetadata>(MD), Record);
1815  }
1816 }
1817 
1818 unsigned DXILBitcodeWriter::createMetadataStringsAbbrev() {
1819  auto Abbv = std::make_shared<BitCodeAbbrev>();
1822  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
1823  return Stream.EmitAbbrev(std::move(Abbv));
1824 }
1825 
1826 void DXILBitcodeWriter::writeMetadataStrings(
1828  for (const Metadata *MD : Strings) {
1829  const MDString *MDS = cast<MDString>(MD);
1830  // Code: [strchar x N]
1831  Record.append(MDS->bytes_begin(), MDS->bytes_end());
1832 
1833  // Emit the finished record.
1835  createMetadataStringsAbbrev());
1836  Record.clear();
1837  }
1838 }
1839 
1840 void DXILBitcodeWriter::writeModuleMetadata() {
1841  if (!VE.hasMDs() && M.named_metadata_empty())
1842  return;
1843 
1845 
1846  // Emit all abbrevs upfront, so that the reader can jump in the middle of the
1847  // block and load any metadata.
1848  std::vector<unsigned> MDAbbrevs;
1849 
1850  MDAbbrevs.resize(MetadataAbbrev::LastPlusOne);
1851  MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1852  MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1853  createGenericDINodeAbbrev();
1854 
1855  unsigned NameAbbrev = 0;
1856  if (!M.named_metadata_empty()) {
1857  // Abbrev for METADATA_NAME.
1858  std::shared_ptr<BitCodeAbbrev> Abbv = std::make_shared<BitCodeAbbrev>();
1861  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
1862  NameAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1863  }
1864 
1866  writeMetadataStrings(VE.getMDStrings(), Record);
1867 
1868  std::vector<uint64_t> IndexPos;
1869  IndexPos.reserve(VE.getNonMDStrings().size());
1870  writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1871 
1872  // Write named metadata.
1873  for (const NamedMDNode &NMD : M.named_metadata()) {
1874  // Write name.
1875  StringRef Str = NMD.getName();
1876  Record.append(Str.bytes_begin(), Str.bytes_end());
1877  Stream.EmitRecord(bitc::METADATA_NAME, Record, NameAbbrev);
1878  Record.clear();
1879 
1880  // Write named metadata operands.
1881  for (const MDNode *N : NMD.operands())
1882  Record.push_back(VE.getMetadataID(N));
1884  Record.clear();
1885  }
1886 
1887  Stream.ExitBlock();
1888 }
1889 
1890 void DXILBitcodeWriter::writeFunctionMetadata(const Function &F) {
1891  if (!VE.hasMDs())
1892  return;
1893 
1896  writeMetadataStrings(VE.getMDStrings(), Record);
1897  writeMetadataRecords(VE.getNonMDStrings(), Record);
1898  Stream.ExitBlock();
1899 }
1900 
1901 void DXILBitcodeWriter::writeFunctionMetadataAttachment(const Function &F) {
1903 
1905 
1906  // Write metadata attachments
1907  // METADATA_ATTACHMENT - [m x [value, [n x [id, mdnode]]]
1909  F.getAllMetadata(MDs);
1910  if (!MDs.empty()) {
1911  for (const auto &I : MDs) {
1912  Record.push_back(I.first);
1913  Record.push_back(VE.getMetadataID(I.second));
1914  }
1916  Record.clear();
1917  }
1918 
1919  for (const BasicBlock &BB : F)
1920  for (const Instruction &I : BB) {
1921  MDs.clear();
1922  I.getAllMetadataOtherThanDebugLoc(MDs);
1923 
1924  // If no metadata, ignore instruction.
1925  if (MDs.empty())
1926  continue;
1927 
1928  Record.push_back(VE.getInstructionID(&I));
1929 
1930  for (unsigned i = 0, e = MDs.size(); i != e; ++i) {
1931  Record.push_back(MDs[i].first);
1932  Record.push_back(VE.getMetadataID(MDs[i].second));
1933  }
1935  Record.clear();
1936  }
1937 
1938  Stream.ExitBlock();
1939 }
1940 
1941 void DXILBitcodeWriter::writeModuleMetadataKinds() {
1943 
1944  // Write metadata kinds
1945  // METADATA_KIND - [n x [id, name]]
1947  M.getMDKindNames(Names);
1948 
1949  if (Names.empty())
1950  return;
1951 
1953 
1954  for (unsigned MDKindID = 0, e = Names.size(); MDKindID != e; ++MDKindID) {
1955  Record.push_back(MDKindID);
1956  StringRef KName = Names[MDKindID];
1957  Record.append(KName.begin(), KName.end());
1958 
1960  Record.clear();
1961  }
1962 
1963  Stream.ExitBlock();
1964 }
1965 
1966 void DXILBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal,
1967  bool isGlobal) {
1968  if (FirstVal == LastVal)
1969  return;
1970 
1972 
1973  unsigned AggregateAbbrev = 0;
1974  unsigned String8Abbrev = 0;
1975  unsigned CString7Abbrev = 0;
1976  unsigned CString6Abbrev = 0;
1977  // If this is a constant pool for the module, emit module-specific abbrevs.
1978  if (isGlobal) {
1979  // Abbrev for CST_CODE_AGGREGATE.
1980  auto Abbv = std::make_shared<BitCodeAbbrev>();
1983  Abbv->Add(
1985  AggregateAbbrev = Stream.EmitAbbrev(std::move(Abbv));
1986 
1987  // Abbrev for CST_CODE_STRING.
1988  Abbv = std::make_shared<BitCodeAbbrev>();
1991  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
1992  String8Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1993  // Abbrev for CST_CODE_CSTRING.
1994  Abbv = std::make_shared<BitCodeAbbrev>();
1997  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
1998  CString7Abbrev = Stream.EmitAbbrev(std::move(Abbv));
1999  // Abbrev for CST_CODE_CSTRING.
2000  Abbv = std::make_shared<BitCodeAbbrev>();
2004  CString6Abbrev = Stream.EmitAbbrev(std::move(Abbv));
2005  }
2006 
2008 
2009  const ValueEnumerator::ValueList &Vals = VE.getValues();
2010  Type *LastTy = nullptr;
2011  for (unsigned i = FirstVal; i != LastVal; ++i) {
2012  const Value *V = Vals[i].first;
2013  // If we need to switch types, do so now.
2014  if (V->getType() != LastTy) {
2015  LastTy = V->getType();
2016  Record.push_back(getTypeID(LastTy, V));
2018  CONSTANTS_SETTYPE_ABBREV);
2019  Record.clear();
2020  }
2021 
2022  if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
2023  Record.push_back(unsigned(IA->hasSideEffects()) |
2024  unsigned(IA->isAlignStack()) << 1 |
2025  unsigned(IA->getDialect() & 1) << 2);
2026 
2027  // Add the asm string.
2028  const std::string &AsmStr = IA->getAsmString();
2029  Record.push_back(AsmStr.size());
2030  Record.append(AsmStr.begin(), AsmStr.end());
2031 
2032  // Add the constraint string.
2033  const std::string &ConstraintStr = IA->getConstraintString();
2034  Record.push_back(ConstraintStr.size());
2035  Record.append(ConstraintStr.begin(), ConstraintStr.end());
2037  Record.clear();
2038  continue;
2039  }
2040  const Constant *C = cast<Constant>(V);
2041  unsigned Code = -1U;
2042  unsigned AbbrevToUse = 0;
2043  if (C->isNullValue()) {
2045  } else if (isa<UndefValue>(C)) {
2047  } else if (const ConstantInt *IV = dyn_cast<ConstantInt>(C)) {
2048  if (IV->getBitWidth() <= 64) {
2049  uint64_t V = IV->getSExtValue();
2050  emitSignedInt64(Record, V);
2052  AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2053  } else { // Wide integers, > 64 bits in size.
2054  // We have an arbitrary precision integer value to write whose
2055  // bit width is > 64. However, in canonical unsigned integer
2056  // format it is likely that the high bits are going to be zero.
2057  // So, we only write the number of active words.
2058  unsigned NWords = IV->getValue().getActiveWords();
2059  const uint64_t *RawWords = IV->getValue().getRawData();
2060  for (unsigned i = 0; i != NWords; ++i) {
2061  emitSignedInt64(Record, RawWords[i]);
2062  }
2064  }
2065  } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
2067  Type *Ty = CFP->getType();
2068  if (Ty->isHalfTy() || Ty->isFloatTy() || Ty->isDoubleTy()) {
2069  Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2070  } else if (Ty->isX86_FP80Ty()) {
2071  // api needed to prevent premature destruction
2072  // bits are not in the same order as a normal i80 APInt, compensate.
2073  APInt api = CFP->getValueAPF().bitcastToAPInt();
2074  const uint64_t *p = api.getRawData();
2075  Record.push_back((p[1] << 48) | (p[0] >> 16));
2076  Record.push_back(p[0] & 0xffffLL);
2077  } else if (Ty->isFP128Ty() || Ty->isPPC_FP128Ty()) {
2078  APInt api = CFP->getValueAPF().bitcastToAPInt();
2079  const uint64_t *p = api.getRawData();
2080  Record.push_back(p[0]);
2081  Record.push_back(p[1]);
2082  } else {
2083  assert(0 && "Unknown FP type!");
2084  }
2085  } else if (isa<ConstantDataSequential>(C) &&
2086  cast<ConstantDataSequential>(C)->isString()) {
2087  const ConstantDataSequential *Str = cast<ConstantDataSequential>(C);
2088  // Emit constant strings specially.
2089  unsigned NumElts = Str->getNumElements();
2090  // If this is a null-terminated string, use the denser CSTRING encoding.
2091  if (Str->isCString()) {
2093  --NumElts; // Don't encode the null, which isn't allowed by char6.
2094  } else {
2096  AbbrevToUse = String8Abbrev;
2097  }
2098  bool isCStr7 = Code == bitc::CST_CODE_CSTRING;
2099  bool isCStrChar6 = Code == bitc::CST_CODE_CSTRING;
2100  for (unsigned i = 0; i != NumElts; ++i) {
2101  unsigned char V = Str->getElementAsInteger(i);
2102  Record.push_back(V);
2103  isCStr7 &= (V & 128) == 0;
2104  if (isCStrChar6)
2105  isCStrChar6 = BitCodeAbbrevOp::isChar6(V);
2106  }
2107 
2108  if (isCStrChar6)
2109  AbbrevToUse = CString6Abbrev;
2110  else if (isCStr7)
2111  AbbrevToUse = CString7Abbrev;
2112  } else if (const ConstantDataSequential *CDS =
2113  dyn_cast<ConstantDataSequential>(C)) {
2115  Type *EltTy = CDS->getElementType();
2116  if (isa<IntegerType>(EltTy)) {
2117  for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2118  Record.push_back(CDS->getElementAsInteger(i));
2119  } else if (EltTy->isFloatTy()) {
2120  for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2121  union {
2122  float F;
2123  uint32_t I;
2124  };
2125  F = CDS->getElementAsFloat(i);
2126  Record.push_back(I);
2127  }
2128  } else {
2129  assert(EltTy->isDoubleTy() && "Unknown ConstantData element type");
2130  for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
2131  union {
2132  double F;
2133  uint64_t I;
2134  };
2135  F = CDS->getElementAsDouble(i);
2136  Record.push_back(I);
2137  }
2138  }
2139  } else if (isa<ConstantArray>(C) || isa<ConstantStruct>(C) ||
2140  isa<ConstantVector>(C)) {
2142  for (const Value *Op : C->operands())
2143  Record.push_back(VE.getValueID(Op));
2144  AbbrevToUse = AggregateAbbrev;
2145  } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
2146  switch (CE->getOpcode()) {
2147  default:
2148  if (Instruction::isCast(CE->getOpcode())) {
2150  Record.push_back(getEncodedCastOpcode(CE->getOpcode()));
2151  Record.push_back(
2152  getTypeID(C->getOperand(0)->getType(), C->getOperand(0)));
2153  Record.push_back(VE.getValueID(C->getOperand(0)));
2154  AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2155  } else {
2156  assert(CE->getNumOperands() == 2 && "Unknown constant expr!");
2158  Record.push_back(getEncodedBinaryOpcode(CE->getOpcode()));
2159  Record.push_back(VE.getValueID(C->getOperand(0)));
2160  Record.push_back(VE.getValueID(C->getOperand(1)));
2162  if (Flags != 0)
2163  Record.push_back(Flags);
2164  }
2165  break;
2166  case Instruction::GetElementPtr: {
2168  const auto *GO = cast<GEPOperator>(C);
2169  if (GO->isInBounds())
2171  Record.push_back(getTypeID(GO->getSourceElementType()));
2172  for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i) {
2173  Record.push_back(
2174  getTypeID(C->getOperand(i)->getType(), C->getOperand(i)));
2175  Record.push_back(VE.getValueID(C->getOperand(i)));
2176  }
2177  break;
2178  }
2179  case Instruction::Select:
2181  Record.push_back(VE.getValueID(C->getOperand(0)));
2182  Record.push_back(VE.getValueID(C->getOperand(1)));
2183  Record.push_back(VE.getValueID(C->getOperand(2)));
2184  break;
2185  case Instruction::ExtractElement:
2187  Record.push_back(getTypeID(C->getOperand(0)->getType()));
2188  Record.push_back(VE.getValueID(C->getOperand(0)));
2189  Record.push_back(getTypeID(C->getOperand(1)->getType()));
2190  Record.push_back(VE.getValueID(C->getOperand(1)));
2191  break;
2192  case Instruction::InsertElement:
2194  Record.push_back(VE.getValueID(C->getOperand(0)));
2195  Record.push_back(VE.getValueID(C->getOperand(1)));
2196  Record.push_back(getTypeID(C->getOperand(2)->getType()));
2197  Record.push_back(VE.getValueID(C->getOperand(2)));
2198  break;
2199  case Instruction::ShuffleVector:
2200  // If the return type and argument types are the same, this is a
2201  // standard shufflevector instruction. If the types are different,
2202  // then the shuffle is widening or truncating the input vectors, and
2203  // the argument type must also be encoded.
2204  if (C->getType() == C->getOperand(0)->getType()) {
2206  } else {
2208  Record.push_back(getTypeID(C->getOperand(0)->getType()));
2209  }
2210  Record.push_back(VE.getValueID(C->getOperand(0)));
2211  Record.push_back(VE.getValueID(C->getOperand(1)));
2212  Record.push_back(VE.getValueID(C->getOperand(2)));
2213  break;
2214  case Instruction::ICmp:
2215  case Instruction::FCmp:
2217  Record.push_back(getTypeID(C->getOperand(0)->getType()));
2218  Record.push_back(VE.getValueID(C->getOperand(0)));
2219  Record.push_back(VE.getValueID(C->getOperand(1)));
2220  Record.push_back(CE->getPredicate());
2221  break;
2222  }
2223  } else if (const BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
2225  Record.push_back(getTypeID(BA->getFunction()->getType()));
2226  Record.push_back(VE.getValueID(BA->getFunction()));
2227  Record.push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2228  } else {
2229 #ifndef NDEBUG
2230  C->dump();
2231 #endif
2232  llvm_unreachable("Unknown constant!");
2233  }
2234  Stream.EmitRecord(Code, Record, AbbrevToUse);
2235  Record.clear();
2236  }
2237 
2238  Stream.ExitBlock();
2239 }
2240 
2241 void DXILBitcodeWriter::writeModuleConstants() {
2242  const ValueEnumerator::ValueList &Vals = VE.getValues();
2243 
2244  // Find the first constant to emit, which is the first non-globalvalue value.
2245  // We know globalvalues have been emitted by WriteModuleInfo.
2246  for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
2247  if (!isa<GlobalValue>(Vals[i].first)) {
2248  writeConstants(i, Vals.size(), true);
2249  return;
2250  }
2251  }
2252 }
2253 
2254 /// pushValueAndType - The file has to encode both the value and type id for
2255 /// many values, because we need to know what type to create for forward
2256 /// references. However, most operands are not forward references, so this type
2257 /// field is not needed.
2258 ///
2259 /// This function adds V's value ID to Vals. If the value ID is higher than the
2260 /// instruction ID, then it is a forward reference, and it also includes the
2261 /// type ID. The value ID that is written is encoded relative to the InstID.
2262 bool DXILBitcodeWriter::pushValueAndType(const Value *V, unsigned InstID,
2263  SmallVectorImpl<unsigned> &Vals) {
2264  unsigned ValID = VE.getValueID(V);
2265  // Make encoding relative to the InstID.
2266  Vals.push_back(InstID - ValID);
2267  if (ValID >= InstID) {
2268  Vals.push_back(getTypeID(V->getType(), V));
2269  return true;
2270  }
2271  return false;
2272 }
2273 
2274 /// pushValue - Like pushValueAndType, but where the type of the value is
2275 /// omitted (perhaps it was already encoded in an earlier operand).
2276 void DXILBitcodeWriter::pushValue(const Value *V, unsigned InstID,
2277  SmallVectorImpl<unsigned> &Vals) {
2278  unsigned ValID = VE.getValueID(V);
2279  Vals.push_back(InstID - ValID);
2280 }
2281 
2282 void DXILBitcodeWriter::pushValueSigned(const Value *V, unsigned InstID,
2283  SmallVectorImpl<uint64_t> &Vals) {
2284  unsigned ValID = VE.getValueID(V);
2285  int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2286  emitSignedInt64(Vals, diff);
2287 }
2288 
2289 /// WriteInstruction - Emit an instruction
2290 void DXILBitcodeWriter::writeInstruction(const Instruction &I, unsigned InstID,
2291  SmallVectorImpl<unsigned> &Vals) {
2292  unsigned Code = 0;
2293  unsigned AbbrevToUse = 0;
2294  VE.setInstructionID(&I);
2295  switch (I.getOpcode()) {
2296  default:
2297  if (Instruction::isCast(I.getOpcode())) {
2299  if (!pushValueAndType(I.getOperand(0), InstID, Vals))
2300  AbbrevToUse = (unsigned)FUNCTION_INST_CAST_ABBREV;
2301  Vals.push_back(getTypeID(I.getType(), &I));
2302  Vals.push_back(getEncodedCastOpcode(I.getOpcode()));
2303  } else {
2304  assert(isa<BinaryOperator>(I) && "Unknown instruction!");
2306  if (!pushValueAndType(I.getOperand(0), InstID, Vals))
2307  AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_ABBREV;
2308  pushValue(I.getOperand(1), InstID, Vals);
2309  Vals.push_back(getEncodedBinaryOpcode(I.getOpcode()));
2311  if (Flags != 0) {
2312  if (AbbrevToUse == (unsigned)FUNCTION_INST_BINOP_ABBREV)
2313  AbbrevToUse = (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV;
2314  Vals.push_back(Flags);
2315  }
2316  }
2317  break;
2318 
2319  case Instruction::GetElementPtr: {
2321  AbbrevToUse = (unsigned)FUNCTION_INST_GEP_ABBREV;
2322  auto &GEPInst = cast<GetElementPtrInst>(I);
2323  Vals.push_back(GEPInst.isInBounds());
2324  Vals.push_back(getTypeID(GEPInst.getSourceElementType()));
2325  for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
2326  pushValueAndType(I.getOperand(i), InstID, Vals);
2327  break;
2328  }
2329  case Instruction::ExtractValue: {
2331  pushValueAndType(I.getOperand(0), InstID, Vals);
2332  const ExtractValueInst *EVI = cast<ExtractValueInst>(&I);
2333  Vals.append(EVI->idx_begin(), EVI->idx_end());
2334  break;
2335  }
2336  case Instruction::InsertValue: {
2338  pushValueAndType(I.getOperand(0), InstID, Vals);
2339  pushValueAndType(I.getOperand(1), InstID, Vals);
2340  const InsertValueInst *IVI = cast<InsertValueInst>(&I);
2341  Vals.append(IVI->idx_begin(), IVI->idx_end());
2342  break;
2343  }
2344  case Instruction::Select:
2346  pushValueAndType(I.getOperand(1), InstID, Vals);
2347  pushValue(I.getOperand(2), InstID, Vals);
2348  pushValueAndType(I.getOperand(0), InstID, Vals);
2349  break;
2350  case Instruction::ExtractElement:
2352  pushValueAndType(I.getOperand(0), InstID, Vals);
2353  pushValueAndType(I.getOperand(1), InstID, Vals);
2354  break;
2355  case Instruction::InsertElement:
2357  pushValueAndType(I.getOperand(0), InstID, Vals);
2358  pushValue(I.getOperand(1), InstID, Vals);
2359  pushValueAndType(I.getOperand(2), InstID, Vals);
2360  break;
2361  case Instruction::ShuffleVector:
2363  pushValueAndType(I.getOperand(0), InstID, Vals);
2364  pushValue(I.getOperand(1), InstID, Vals);
2365  pushValue(cast<ShuffleVectorInst>(&I)->getShuffleMaskForBitcode(), InstID,
2366  Vals);
2367  break;
2368  case Instruction::ICmp:
2369  case Instruction::FCmp: {
2370  // compare returning Int1Ty or vector of Int1Ty
2372  pushValueAndType(I.getOperand(0), InstID, Vals);
2373  pushValue(I.getOperand(1), InstID, Vals);
2374  Vals.push_back(cast<CmpInst>(I).getPredicate());
2376  if (Flags != 0)
2377  Vals.push_back(Flags);
2378  break;
2379  }
2380 
2381  case Instruction::Ret: {
2383  unsigned NumOperands = I.getNumOperands();
2384  if (NumOperands == 0)
2385  AbbrevToUse = (unsigned)FUNCTION_INST_RET_VOID_ABBREV;
2386  else if (NumOperands == 1) {
2387  if (!pushValueAndType(I.getOperand(0), InstID, Vals))
2388  AbbrevToUse = (unsigned)FUNCTION_INST_RET_VAL_ABBREV;
2389  } else {
2390  for (unsigned i = 0, e = NumOperands; i != e; ++i)
2391  pushValueAndType(I.getOperand(i), InstID, Vals);
2392  }
2393  } break;
2394  case Instruction::Br: {
2396  const BranchInst &II = cast<BranchInst>(I);
2397  Vals.push_back(VE.getValueID(II.getSuccessor(0)));
2398  if (II.isConditional()) {
2399  Vals.push_back(VE.getValueID(II.getSuccessor(1)));
2400  pushValue(II.getCondition(), InstID, Vals);
2401  }
2402  } break;
2403  case Instruction::Switch: {
2405  const SwitchInst &SI = cast<SwitchInst>(I);
2406  Vals.push_back(getTypeID(SI.getCondition()->getType()));
2407  pushValue(SI.getCondition(), InstID, Vals);
2408  Vals.push_back(VE.getValueID(SI.getDefaultDest()));
2409  for (auto Case : SI.cases()) {
2410  Vals.push_back(VE.getValueID(Case.getCaseValue()));
2411  Vals.push_back(VE.getValueID(Case.getCaseSuccessor()));
2412  }
2413  } break;
2414  case Instruction::IndirectBr:
2416  Vals.push_back(getTypeID(I.getOperand(0)->getType()));
2417  // Encode the address operand as relative, but not the basic blocks.
2418  pushValue(I.getOperand(0), InstID, Vals);
2419  for (unsigned i = 1, e = I.getNumOperands(); i != e; ++i)
2420  Vals.push_back(VE.getValueID(I.getOperand(i)));
2421  break;
2422 
2423  case Instruction::Invoke: {
2424  const InvokeInst *II = cast<InvokeInst>(&I);
2425  const Value *Callee = II->getCalledOperand();
2426  FunctionType *FTy = II->getFunctionType();
2428 
2429  Vals.push_back(VE.getAttributeListID(II->getAttributes()));
2430  Vals.push_back(II->getCallingConv() | 1 << 13);
2431  Vals.push_back(VE.getValueID(II->getNormalDest()));
2432  Vals.push_back(VE.getValueID(II->getUnwindDest()));
2433  Vals.push_back(getTypeID(FTy));
2434  pushValueAndType(Callee, InstID, Vals);
2435 
2436  // Emit value #'s for the fixed parameters.
2437  for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2438  pushValue(I.getOperand(i), InstID, Vals); // fixed param.
2439 
2440  // Emit type/value pairs for varargs params.
2441  if (FTy->isVarArg()) {
2442  for (unsigned i = FTy->getNumParams(), e = I.getNumOperands() - 3; i != e;
2443  ++i)
2444  pushValueAndType(I.getOperand(i), InstID, Vals); // vararg
2445  }
2446  break;
2447  }
2448  case Instruction::Resume:
2450  pushValueAndType(I.getOperand(0), InstID, Vals);
2451  break;
2452  case Instruction::Unreachable:
2454  AbbrevToUse = (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV;
2455  break;
2456 
2457  case Instruction::PHI: {
2458  const PHINode &PN = cast<PHINode>(I);
2460  // With the newer instruction encoding, forward references could give
2461  // negative valued IDs. This is most common for PHIs, so we use
2462  // signed VBRs.
2464  Vals64.push_back(getTypeID(PN.getType()));
2465  for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
2466  pushValueSigned(PN.getIncomingValue(i), InstID, Vals64);
2467  Vals64.push_back(VE.getValueID(PN.getIncomingBlock(i)));
2468  }
2469  // Emit a Vals64 vector and exit.
2470  Stream.EmitRecord(Code, Vals64, AbbrevToUse);
2471  Vals64.clear();
2472  return;
2473  }
2474 
2475  case Instruction::LandingPad: {
2476  const LandingPadInst &LP = cast<LandingPadInst>(I);
2478  Vals.push_back(getTypeID(LP.getType()));
2479  Vals.push_back(LP.isCleanup());
2480  Vals.push_back(LP.getNumClauses());
2481  for (unsigned I = 0, E = LP.getNumClauses(); I != E; ++I) {
2482  if (LP.isCatch(I))
2483  Vals.push_back(LandingPadInst::Catch);
2484  else
2485  Vals.push_back(LandingPadInst::Filter);
2486  pushValueAndType(LP.getClause(I), InstID, Vals);
2487  }
2488  break;
2489  }
2490 
2491  case Instruction::Alloca: {
2493  const AllocaInst &AI = cast<AllocaInst>(I);
2494  Vals.push_back(getTypeID(AI.getAllocatedType()));
2495  Vals.push_back(getTypeID(I.getOperand(0)->getType()));
2496  Vals.push_back(VE.getValueID(I.getOperand(0))); // size.
2497  unsigned AlignRecord = Log2_32(AI.getAlign().value()) + 1;
2498  assert(AlignRecord < 1 << 5 && "alignment greater than 1 << 64");
2499  AlignRecord |= AI.isUsedWithInAlloca() << 5;
2500  AlignRecord |= 1 << 6;
2501  Vals.push_back(AlignRecord);
2502  break;
2503  }
2504 
2505  case Instruction::Load:
2506  if (cast<LoadInst>(I).isAtomic()) {
2508  pushValueAndType(I.getOperand(0), InstID, Vals);
2509  } else {
2511  if (!pushValueAndType(I.getOperand(0), InstID, Vals)) // ptr
2512  AbbrevToUse = (unsigned)FUNCTION_INST_LOAD_ABBREV;
2513  }
2514  Vals.push_back(getTypeID(I.getType()));
2515  Vals.push_back(Log2(cast<LoadInst>(I).getAlign()) + 1);
2516  Vals.push_back(cast<LoadInst>(I).isVolatile());
2517  if (cast<LoadInst>(I).isAtomic()) {
2518  Vals.push_back(getEncodedOrdering(cast<LoadInst>(I).getOrdering()));
2519  Vals.push_back(getEncodedSyncScopeID(cast<LoadInst>(I).getSyncScopeID()));
2520  }
2521  break;
2522  case Instruction::Store:
2523  if (cast<StoreInst>(I).isAtomic())
2525  else
2527  pushValueAndType(I.getOperand(1), InstID, Vals); // ptrty + ptr
2528  pushValueAndType(I.getOperand(0), InstID, Vals); // valty + val
2529  Vals.push_back(Log2(cast<StoreInst>(I).getAlign()) + 1);
2530  Vals.push_back(cast<StoreInst>(I).isVolatile());
2531  if (cast<StoreInst>(I).isAtomic()) {
2532  Vals.push_back(getEncodedOrdering(cast<StoreInst>(I).getOrdering()));
2533  Vals.push_back(
2534  getEncodedSyncScopeID(cast<StoreInst>(I).getSyncScopeID()));
2535  }
2536  break;
2537  case Instruction::AtomicCmpXchg:
2539  pushValueAndType(I.getOperand(0), InstID, Vals); // ptrty + ptr
2540  pushValueAndType(I.getOperand(1), InstID, Vals); // cmp.
2541  pushValue(I.getOperand(2), InstID, Vals); // newval.
2542  Vals.push_back(cast<AtomicCmpXchgInst>(I).isVolatile());
2543  Vals.push_back(
2544  getEncodedOrdering(cast<AtomicCmpXchgInst>(I).getSuccessOrdering()));
2545  Vals.push_back(
2546  getEncodedSyncScopeID(cast<AtomicCmpXchgInst>(I).getSyncScopeID()));
2547  Vals.push_back(
2548  getEncodedOrdering(cast<AtomicCmpXchgInst>(I).getFailureOrdering()));
2549  Vals.push_back(cast<AtomicCmpXchgInst>(I).isWeak());
2550  break;
2551  case Instruction::AtomicRMW:
2553  pushValueAndType(I.getOperand(0), InstID, Vals); // ptrty + ptr
2554  pushValue(I.getOperand(1), InstID, Vals); // val.
2555  Vals.push_back(
2556  getEncodedRMWOperation(cast<AtomicRMWInst>(I).getOperation()));
2557  Vals.push_back(cast<AtomicRMWInst>(I).isVolatile());
2558  Vals.push_back(getEncodedOrdering(cast<AtomicRMWInst>(I).getOrdering()));
2559  Vals.push_back(
2560  getEncodedSyncScopeID(cast<AtomicRMWInst>(I).getSyncScopeID()));
2561  break;
2562  case Instruction::Fence:
2564  Vals.push_back(getEncodedOrdering(cast<FenceInst>(I).getOrdering()));
2565  Vals.push_back(getEncodedSyncScopeID(cast<FenceInst>(I).getSyncScopeID()));
2566  break;
2567  case Instruction::Call: {
2568  const CallInst &CI = cast<CallInst>(I);
2569  FunctionType *FTy = CI.getFunctionType();
2570 
2572 
2573  Vals.push_back(VE.getAttributeListID(CI.getAttributes()));
2574  Vals.push_back((CI.getCallingConv() << 1) | unsigned(CI.isTailCall()) |
2575  unsigned(CI.isMustTailCall()) << 14 | 1 << 15);
2576  Vals.push_back(getGlobalObjectValueTypeID(FTy, CI.getCalledFunction()));
2577  pushValueAndType(CI.getCalledOperand(), InstID, Vals); // Callee
2578 
2579  // Emit value #'s for the fixed parameters.
2580  for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
2581  // Check for labels (can happen with asm labels).
2582  if (FTy->getParamType(i)->isLabelTy())
2583  Vals.push_back(VE.getValueID(CI.getArgOperand(i)));
2584  else
2585  pushValue(CI.getArgOperand(i), InstID, Vals); // fixed param.
2586  }
2587 
2588  // Emit type/value pairs for varargs params.
2589  if (FTy->isVarArg()) {
2590  for (unsigned i = FTy->getNumParams(), e = CI.arg_size(); i != e; ++i)
2591  pushValueAndType(CI.getArgOperand(i), InstID, Vals); // varargs
2592  }
2593  break;
2594  }
2595  case Instruction::VAArg:
2597  Vals.push_back(getTypeID(I.getOperand(0)->getType())); // valistty
2598  pushValue(I.getOperand(0), InstID, Vals); // valist.
2599  Vals.push_back(getTypeID(I.getType())); // restype.
2600  break;
2601  }
2602 
2603  Stream.EmitRecord(Code, Vals, AbbrevToUse);
2604  Vals.clear();
2605 }
2606 
2607 // Emit names for globals/functions etc.
2608 void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
2609  const ValueSymbolTable &VST) {
2610  if (VST.empty())
2611  return;
2613 
2614  SmallVector<unsigned, 64> NameVals;
2615 
2616  // HLSL Change
2617  // Read the named values from a sorted list instead of the original list
2618  // to ensure the binary is the same no matter what values ever existed.
2620 
2621  for (auto &VI : VST) {
2622  SortedTable.push_back(VI.second->getValueName());
2623  }
2624  // The keys are unique, so there shouldn't be stability issues.
2625  llvm::sort(SortedTable, [](const ValueName *A, const ValueName *B) {
2626  return A->first() < B->first();
2627  });
2628 
2629  for (const ValueName *SI : SortedTable) {
2630  auto &Name = *SI;
2631 
2632  // Figure out the encoding to use for the name.
2633  bool is7Bit = true;
2634  bool isChar6 = true;
2635  for (const char *C = Name.getKeyData(), *E = C + Name.getKeyLength();
2636  C != E; ++C) {
2637  if (isChar6)
2638  isChar6 = BitCodeAbbrevOp::isChar6(*C);
2639  if ((unsigned char)*C & 128) {
2640  is7Bit = false;
2641  break; // don't bother scanning the rest.
2642  }
2643  }
2644 
2645  unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2646 
2647  // VST_ENTRY: [valueid, namechar x N]
2648  // VST_BBENTRY: [bbid, namechar x N]
2649  unsigned Code;
2650  if (isa<BasicBlock>(SI->getValue())) {
2652  if (isChar6)
2653  AbbrevToUse = VST_BBENTRY_6_ABBREV;
2654  } else {
2656  if (isChar6)
2657  AbbrevToUse = VST_ENTRY_6_ABBREV;
2658  else if (is7Bit)
2659  AbbrevToUse = VST_ENTRY_7_ABBREV;
2660  }
2661 
2662  NameVals.push_back(VE.getValueID(SI->getValue()));
2663  for (const char *P = Name.getKeyData(),
2664  *E = Name.getKeyData() + Name.getKeyLength();
2665  P != E; ++P)
2666  NameVals.push_back((unsigned char)*P);
2667 
2668  // Emit the finished record.
2669  Stream.EmitRecord(Code, NameVals, AbbrevToUse);
2670  NameVals.clear();
2671  }
2672  Stream.ExitBlock();
2673 }
2674 
2675 void DXILBitcodeWriter::writeUseList(UseListOrder &&Order) {
2676  assert(Order.Shuffle.size() >= 2 && "Shuffle too small");
2677  unsigned Code;
2678  if (isa<BasicBlock>(Order.V))
2680  else
2682 
2683  SmallVector<uint64_t, 64> Record(Order.Shuffle.begin(), Order.Shuffle.end());
2684  Record.push_back(VE.getValueID(Order.V));
2685  Stream.EmitRecord(Code, Record);
2686 }
2687 
2688 void DXILBitcodeWriter::writeUseListBlock(const Function *F) {
2689  auto hasMore = [&]() {
2690  return !VE.UseListOrders.empty() && VE.UseListOrders.back().F == F;
2691  };
2692  if (!hasMore())
2693  // Nothing to do.
2694  return;
2695 
2697  while (hasMore()) {
2698  writeUseList(std::move(VE.UseListOrders.back()));
2699  VE.UseListOrders.pop_back();
2700  }
2701  Stream.ExitBlock();
2702 }
2703 
2704 /// Emit a function body to the module stream.
2705 void DXILBitcodeWriter::writeFunction(const Function &F) {
2707  VE.incorporateFunction(F);
2708 
2710 
2711  // Emit the number of basic blocks, so the reader can create them ahead of
2712  // time.
2713  Vals.push_back(VE.getBasicBlocks().size());
2715  Vals.clear();
2716 
2717  // If there are function-local constants, emit them now.
2718  unsigned CstStart, CstEnd;
2719  VE.getFunctionConstantRange(CstStart, CstEnd);
2720  writeConstants(CstStart, CstEnd, false);
2721 
2722  // If there is function-local metadata, emit it now.
2723  writeFunctionMetadata(F);
2724 
2725  // Keep a running idea of what the instruction ID is.
2726  unsigned InstID = CstEnd;
2727 
2728  bool NeedsMetadataAttachment = F.hasMetadata();
2729 
2730  DILocation *LastDL = nullptr;
2731 
2732  // Finally, emit all the instructions, in order.
2733  for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
2734  for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E;
2735  ++I) {
2736  writeInstruction(*I, InstID, Vals);
2737 
2738  if (!I->getType()->isVoidTy())
2739  ++InstID;
2740 
2741  // If the instruction has metadata, write a metadata attachment later.
2742  NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc();
2743 
2744  // If the instruction has a debug location, emit it.
2745  DILocation *DL = I->getDebugLoc();
2746  if (!DL)
2747  continue;
2748 
2749  if (DL == LastDL) {
2750  // Just repeat the same debug loc as last time.
2752  continue;
2753  }
2754 
2755  Vals.push_back(DL->getLine());
2756  Vals.push_back(DL->getColumn());
2757  Vals.push_back(VE.getMetadataOrNullID(DL->getScope()));
2758  Vals.push_back(VE.getMetadataOrNullID(DL->getInlinedAt()));
2759  Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals);
2760  Vals.clear();
2761 
2762  LastDL = DL;
2763  }
2764 
2765  // Emit names for all the instructions etc.
2766  if (auto *Symtab = F.getValueSymbolTable())
2767  writeFunctionLevelValueSymbolTable(*Symtab);
2768 
2769  if (NeedsMetadataAttachment)
2770  writeFunctionMetadataAttachment(F);
2771 
2772  writeUseListBlock(&F);
2773  VE.purgeFunction();
2774  Stream.ExitBlock();
2775 }
2776 
2777 // Emit blockinfo, which defines the standard abbreviations etc.
2778 void DXILBitcodeWriter::writeBlockInfo() {
2779  // We only want to emit block info records for blocks that have multiple
2780  // instances: CONSTANTS_BLOCK, FUNCTION_BLOCK and VALUE_SYMTAB_BLOCK.
2781  // Other blocks can define their abbrevs inline.
2782  Stream.EnterBlockInfoBlock();
2783 
2784  { // 8-bit fixed-width VST_ENTRY/VST_BBENTRY strings.
2785  auto Abbv = std::make_shared<BitCodeAbbrev>();
2786  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
2787  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2789  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
2791  std::move(Abbv)) != VST_ENTRY_8_ABBREV)
2792  assert(false && "Unexpected abbrev ordering!");
2793  }
2794 
2795  { // 7-bit fixed width VST_ENTRY strings.
2796  auto Abbv = std::make_shared<BitCodeAbbrev>();
2798  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2800  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
2802  std::move(Abbv)) != VST_ENTRY_7_ABBREV)
2803  assert(false && "Unexpected abbrev ordering!");
2804  }
2805  { // 6-bit char6 VST_ENTRY strings.
2806  auto Abbv = std::make_shared<BitCodeAbbrev>();
2808  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2812  std::move(Abbv)) != VST_ENTRY_6_ABBREV)
2813  assert(false && "Unexpected abbrev ordering!");
2814  }
2815  { // 6-bit char6 VST_BBENTRY strings.
2816  auto Abbv = std::make_shared<BitCodeAbbrev>();
2818  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2822  std::move(Abbv)) != VST_BBENTRY_6_ABBREV)
2823  assert(false && "Unexpected abbrev ordering!");
2824  }
2825 
2826  { // SETTYPE abbrev for CONSTANTS_BLOCK.
2827  auto Abbv = std::make_shared<BitCodeAbbrev>();
2832  CONSTANTS_SETTYPE_ABBREV)
2833  assert(false && "Unexpected abbrev ordering!");
2834  }
2835 
2836  { // INTEGER abbrev for CONSTANTS_BLOCK.
2837  auto Abbv = std::make_shared<BitCodeAbbrev>();
2839  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
2841  CONSTANTS_INTEGER_ABBREV)
2842  assert(false && "Unexpected abbrev ordering!");
2843  }
2844 
2845  { // CE_CAST abbrev for CONSTANTS_BLOCK.
2846  auto Abbv = std::make_shared<BitCodeAbbrev>();
2848  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // cast opc
2849  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // typeid
2851  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id
2852 
2854  CONSTANTS_CE_CAST_Abbrev)
2855  assert(false && "Unexpected abbrev ordering!");
2856  }
2857  { // NULL abbrev for CONSTANTS_BLOCK.
2858  auto Abbv = std::make_shared<BitCodeAbbrev>();
2861  CONSTANTS_NULL_Abbrev)
2862  assert(false && "Unexpected abbrev ordering!");
2863  }
2864 
2865  // FIXME: This should only use space for first class types!
2866 
2867  { // INST_LOAD abbrev for FUNCTION_BLOCK.
2868  auto Abbv = std::make_shared<BitCodeAbbrev>();
2870  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Ptr
2871  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // dest ty
2873  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // Align
2874  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // volatile
2876  (unsigned)FUNCTION_INST_LOAD_ABBREV)
2877  assert(false && "Unexpected abbrev ordering!");
2878  }
2879  { // INST_BINOP abbrev for FUNCTION_BLOCK.
2880  auto Abbv = std::make_shared<BitCodeAbbrev>();
2882  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
2883  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS
2884  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
2886  (unsigned)FUNCTION_INST_BINOP_ABBREV)
2887  assert(false && "Unexpected abbrev ordering!");
2888  }
2889  { // INST_BINOP_FLAGS abbrev for FUNCTION_BLOCK.
2890  auto Abbv = std::make_shared<BitCodeAbbrev>();
2892  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
2893  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS
2894  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
2895  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); // flags
2897  (unsigned)FUNCTION_INST_BINOP_FLAGS_ABBREV)
2898  assert(false && "Unexpected abbrev ordering!");
2899  }
2900  { // INST_CAST abbrev for FUNCTION_BLOCK.
2901  auto Abbv = std::make_shared<BitCodeAbbrev>();
2903  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpVal
2904  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // dest ty
2906  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
2908  (unsigned)FUNCTION_INST_CAST_ABBREV)
2909  assert(false && "Unexpected abbrev ordering!");
2910  }
2911 
2912  { // INST_RET abbrev for FUNCTION_BLOCK.
2913  auto Abbv = std::make_shared<BitCodeAbbrev>();
2916  (unsigned)FUNCTION_INST_RET_VOID_ABBREV)
2917  assert(false && "Unexpected abbrev ordering!");
2918  }
2919  { // INST_RET abbrev for FUNCTION_BLOCK.
2920  auto Abbv = std::make_shared<BitCodeAbbrev>();
2922  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ValID
2924  (unsigned)FUNCTION_INST_RET_VAL_ABBREV)
2925  assert(false && "Unexpected abbrev ordering!");
2926  }
2927  { // INST_UNREACHABLE abbrev for FUNCTION_BLOCK.
2928  auto Abbv = std::make_shared<BitCodeAbbrev>();
2931  (unsigned)FUNCTION_INST_UNREACHABLE_ABBREV)
2932  assert(false && "Unexpected abbrev ordering!");
2933  }
2934  {
2935  auto Abbv = std::make_shared<BitCodeAbbrev>();
2937  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
2938  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // dest ty
2939  Log2_32_Ceil(VE.getTypes().size() + 1)));
2941  Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
2943  (unsigned)FUNCTION_INST_GEP_ABBREV)
2944  assert(false && "Unexpected abbrev ordering!");
2945  }
2946 
2947  Stream.ExitBlock();
2948 }
2949 
2950 void DXILBitcodeWriter::writeModuleVersion() {
2951  // VERSION: [version#]
2953 }
2954 
2955 /// WriteModule - Emit the specified module to the bitstream.
2957  // The identification block is new since llvm-3.7, but the old bitcode reader
2958  // will skip it.
2959  // writeIdentificationBlock(Stream);
2960 
2962 
2963  // It is redundant to fully-specify this here, but nice to make it explicit
2964  // so that it is clear the DXIL module version is different.
2965  DXILBitcodeWriter::writeModuleVersion();
2966 
2967  // Emit blockinfo, which defines the standard abbreviations etc.
2968  writeBlockInfo();
2969 
2970  // Emit information about attribute groups.
2971  writeAttributeGroupTable();
2972 
2973  // Emit information about parameter attributes.
2974  writeAttributeTable();
2975 
2976  // Emit information describing all of the types in the module.
2977  writeTypeTable();
2978 
2979  writeComdats();
2980 
2981  // Emit top-level description of module, including target triple, inline asm,
2982  // descriptors for global variables, and function prototype info.
2983  writeModuleInfo();
2984 
2985  // Emit constants.
2986  writeModuleConstants();
2987 
2988  // Emit metadata.
2989  writeModuleMetadataKinds();
2990 
2991  // Emit metadata.
2992  writeModuleMetadata();
2993 
2994  // Emit names for globals/functions etc.
2995  // DXIL uses the same format for module-level value symbol table as for the
2996  // function level table.
2997  writeFunctionLevelValueSymbolTable(M.getValueSymbolTable());
2998 
2999  // Emit module-level use-lists.
3000  writeUseListBlock(nullptr);
3001 
3002  // Emit function bodies.
3003  for (const Function &F : M)
3004  if (!F.isDeclaration())
3005  writeFunction(F);
3006 
3007  Stream.ExitBlock();
3008 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:77
llvm::bitc::CST_CODE_CE_SHUFFLEVEC
@ CST_CODE_CE_SHUFFLEVEC
Definition: LLVMBitCodes.h:390
i
i
Definition: README.txt:29
llvm::InvokeInst::getNormalDest
BasicBlock * getNormalDest() const
Definition: Instructions.h:3943
llvm::bitc::CST_CODE_BLOCKADDRESS
@ CST_CODE_BLOCKADDRESS
Definition: LLVMBitCodes.h:396
llvm::bitc::CST_CODE_NULL
@ CST_CODE_NULL
Definition: LLVMBitCodes.h:376
llvm::Attribute::EndAttrKinds
@ EndAttrKinds
Sentinal value useful for loops.
Definition: Attributes.h:90
llvm::Type::ArrayTyID
@ ArrayTyID
Arrays.
Definition: Type.h:75
llvm::bitc::FUNC_CODE_INST_LANDINGPAD
@ FUNC_CODE_INST_LANDINGPAD
Definition: LLVMBitCodes.h:598
llvm::AtomicOrdering::AcquireRelease
@ AcquireRelease
llvm::Type::FloatTyID
@ FloatTyID
32-bit floating point type
Definition: Type.h:58
Attrs
Function Attrs
Definition: README_ALTIVEC.txt:215
llvm::dxil::DXILBitcodeWriter::DXILBitcodeWriter
DXILBitcodeWriter(const Module &M, SmallVectorImpl< char > &Buffer, StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream)
Constructs a ModuleBitcodeWriter object for the given Module, writing to the provided Buffer.
Definition: DXILBitcodeWriter.cpp:133
llvm::bitc::ATTR_KIND_SANITIZE_MEMORY
@ ATTR_KIND_SANITIZE_MEMORY
Definition: LLVMBitCodes.h:656
llvm::DIArgList
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
Definition: DebugInfoMetadata.h:3603
llvm::BitstreamWriter::EmitRecordWithBlob
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...
Definition: BitstreamWriter.h:514
llvm::Type::DoubleTyID
@ DoubleTyID
64-bit floating point type
Definition: Type.h:59
GlobalIFunc.h
llvm::ValueSymbolTable::empty
bool empty() const
Definition: ValueSymbolTable.h:83
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::bitc::ATTR_KIND_BY_VAL
@ ATTR_KIND_BY_VAL
Definition: LLVMBitCodes.h:627
llvm::LandingPadInst::isCleanup
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
Definition: Instructions.h:2998
llvm::bitc::NoInfs
@ NoInfs
Definition: LLVMBitCodes.h:496
ModRef.h
llvm::bitc::FUNC_CODE_INST_RET
@ FUNC_CODE_INST_RET
Definition: LLVMBitCodes.h:543
llvm::bitc::CST_CODE_CE_SHUFVEC_EX
@ CST_CODE_CE_SHUFVEC_EX
Definition: LLVMBitCodes.h:394
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::AttributeSet::hasAttributes
bool hasAttributes() const
Return true if attributes exists in this set.
Definition: Attributes.h:354
llvm::AArch64CC::AL
@ AL
Definition: AArch64BaseInfo.h:269
llvm::bitc::FUNC_CODE_INST_STOREATOMIC
@ FUNC_CODE_INST_STOREATOMIC
Definition: LLVMBitCodes.h:594
Comdat.h
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1588
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMapEntry.h:102
llvm::dxil::BitcodeWriter::BitcodeWriter
BitcodeWriter(SmallVectorImpl< char > &Buffer, raw_fd_stream *FS=nullptr)
Create a BitcodeWriter that writes to Buffer.
Definition: DXILBitcodeWriter.cpp:374
llvm::GlobalValue::LinkOnceAnyLinkage
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:50
Metadata.h
llvm::bitc::BINOP_AND
@ BINOP_AND
Definition: LLVMBitCodes.h:457
llvm::Comdat::ExactMatch
@ ExactMatch
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:37
PHI
Rewrite undef for PHI
Definition: AMDGPURewriteUndefForPHI.cpp:101
llvm::dxil::ValueEnumerator::getAttributeGroupID
unsigned getAttributeGroupID(IndexAndAttrSet Group) const
Definition: DXILValueEnumerator.h:182
llvm::AllocaInst::getAlign
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Definition: Instructions.h:122
llvm::bitc::PARAMATTR_GROUP_BLOCK_ID
@ PARAMATTR_GROUP_BLOCK_ID
Definition: LLVMBitCodes.h:34
DebugInfoMetadata.h
llvm::MDString::bytes_begin
const unsigned char * bytes_begin() const
Definition: Metadata.h:641
llvm::Function::empty
bool empty() const
Definition: Function.h:713
llvm::GlobalValue::LocalDynamicTLSModel
@ LocalDynamicTLSModel
Definition: GlobalValue.h:194
llvm::bitc::RMW_OR
@ RMW_OR
Definition: LLVMBitCodes.h:471
llvm::GlobalValue::getLinkage
LinkageTypes getLinkage() const
Definition: GlobalValue.h:541
llvm::DIGenericSubrange
Definition: DebugInfoMetadata.h:401
llvm::GlobalValue::HiddenVisibility
@ HiddenVisibility
The GV is hidden.
Definition: GlobalValue.h:64
T
llvm::bitc::METADATA_DISTINCT_NODE
@ METADATA_DISTINCT_NODE
Definition: LLVMBitCodes.h:327
llvm::bitc::FUNC_CODE_INST_INSERTELT
@ FUNC_CODE_INST_INSERTELT
Definition: LLVMBitCodes.h:539
llvm::Function
Definition: Function.h:60
llvm::Attribute
Definition: Attributes.h:66
llvm::bitc::ATTR_KIND_READ_ONLY
@ ATTR_KIND_READ_ONLY
Definition: LLVMBitCodes.h:645
llvm::Instruction::isCast
bool isCast() const
Definition: Instruction.h:177
llvm::Type::VoidTyID
@ VoidTyID
type with no size
Definition: Type.h:63
llvm::BitCodeAbbrevOp::isChar6
static bool isChar6(char C)
isChar6 - Return true if this character is legal in the Char6 encoding.
Definition: BitCodes.h:82
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::dxil::ValueEnumerator::purgeFunction
void purgeFunction()
llvm::bitc::ATTR_KIND_NO_RETURN
@ ATTR_KIND_NO_RETURN
Definition: LLVMBitCodes.h:641
llvm::bitc::TYPE_CODE_LABEL
@ TYPE_CODE_LABEL
Definition: LLVMBitCodes.h:142
llvm::bitc::ATTR_KIND_OPTIMIZE_FOR_SIZE
@ ATTR_KIND_OPTIMIZE_FOR_SIZE
Definition: LLVMBitCodes.h:643
llvm::AtomicRMWInst::Xor
@ Xor
*p = old ^ v
Definition: Instructions.h:741
llvm::bitc::ATTR_KIND_ARGMEMONLY
@ ATTR_KIND_ARGMEMONLY
Definition: LLVMBitCodes.h:669
llvm::bitc::RMW_XCHG
@ RMW_XCHG
Definition: LLVMBitCodes.h:466
llvm::bitc::MODULE_CODE_COMDAT
@ MODULE_CODE_COMDAT
Definition: LLVMBitCodes.h:106
llvm::bitc::CST_CODE_CE_INSERTELT
@ CST_CODE_CE_INSERTELT
Definition: LLVMBitCodes.h:389
llvm::bitc::FUNC_CODE_INST_VSELECT
@ FUNC_CODE_INST_VSELECT
Definition: LLVMBitCodes.h:569
llvm::Attribute::TombstoneKey
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
Definition: Attributes.h:92
llvm::bitc::ATTR_KIND_STACK_PROTECT
@ ATTR_KIND_STACK_PROTECT
Definition: LLVMBitCodes.h:650
rotateSign
static uint64_t rotateSign(APInt Val)
Definition: DXILBitcodeWriter.cpp:1448
llvm::bitc::ATTR_KIND_IN_ALLOCA
@ ATTR_KIND_IN_ALLOCA
Definition: LLVMBitCodes.h:662
llvm::bitc::MODULE_BLOCK_ID
@ MODULE_BLOCK_ID
Definition: LLVMBitCodes.h:30
llvm::bitc::CST_CODE_CE_CAST
@ CST_CODE_CE_CAST
Definition: LLVMBitCodes.h:385
llvm::GlobalValue::NotThreadLocal
@ NotThreadLocal
Definition: GlobalValue.h:192
llvm::BitCodeAbbrevOp::Fixed
@ Fixed
Definition: BitCodes.h:39
llvm::ConstantInt::getValue
const APInt & getValue() const
Return the constant as an APInt value reference.
Definition: Constants.h:133
llvm::Comdat::NoDeduplicate
@ NoDeduplicate
No deduplication is performed.
Definition: Comdat.h:39
llvm::AtomicRMWInst::BinOp
BinOp
This enumeration lists the possible modifications atomicrmw can make.
Definition: Instructions.h:727
llvm::DILexicalBlockFile
Definition: DebugInfoMetadata.h:2178
llvm::SmallVector< uint64_t, 64 >
llvm::tgtok::Code
@ Code
Definition: TGLexer.h:50
InlineAsm.h
llvm::bitc::METADATA_SUBRANGE
@ METADATA_SUBRANGE
Definition: LLVMBitCodes.h:335
llvm::LandingPadInst
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Definition: Instructions.h:2951
llvm::bitc::ATTR_KIND_CONVERGENT
@ ATTR_KIND_CONVERGENT
Definition: LLVMBitCodes.h:667
llvm::DIStringType
String type, Fortran CHARACTER(n)
Definition: DebugInfoMetadata.h:870
llvm::APInt::getSExtValue
int64_t getSExtValue() const
Get sign extended value.
Definition: APInt.h:1498
llvm::bitc::CAST_TRUNC
@ CAST_TRUNC
Definition: LLVMBitCodes.h:419
ErrorHandling.h
llvm::GlobalValue::UnnamedAddr::None
@ None
DXILValueEnumerator.h
llvm::bitc::ATTR_KIND_S_EXT
@ ATTR_KIND_S_EXT
Definition: LLVMBitCodes.h:648
llvm::bitc::SYMTAB_BLOB
@ SYMTAB_BLOB
Definition: LLVMBitCodes.h:726
llvm::StringTableBuilder::finalizeInOrder
void finalizeInOrder()
Finalize the string table without reording it.
Definition: StringTableBuilder.cpp:133
llvm::bitc::FUNC_CODE_INST_ATOMICRMW
@ FUNC_CODE_INST_ATOMICRMW
Definition: LLVMBitCodes.h:612
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::PointerType::getAddressSpace
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:682
llvm::CallingConv::Cold
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
Definition: CallingConv.h:47
llvm::BitstreamWriter::EmitRecord
void EmitRecord(unsigned Code, const Container &Vals, unsigned Abbrev=0)
EmitRecord - Emit the specified record to the stream, using an abbrev if we have one to compress the ...
Definition: BitstreamWriter.h:484
llvm::Type::X86_AMXTyID
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
Definition: Type.h:67
llvm::GlobalAlias
Definition: GlobalAlias.h:28
llvm::BitstreamWriter::Emit
void Emit(uint32_t Val, unsigned NumBits)
Definition: BitstreamWriter.h:197
llvm::bitc::RMW_NAND
@ RMW_NAND
Definition: LLVMBitCodes.h:470
llvm::dxil::DXILBitcodeWriter::getAttrKindEncoding
static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind)
Definition: DXILBitcodeWriter.cpp:666
llvm::AtomicOrdering::SequentiallyConsistent
@ SequentiallyConsistent
llvm::Attribute::EmptyKey
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
Definition: Attributes.h:91
llvm::bitc::ATTR_KIND_NO_BUILTIN
@ ATTR_KIND_NO_BUILTIN
Definition: LLVMBitCodes.h:634
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::bitc::COMDAT_SELECTION_KIND_NO_DUPLICATES
@ COMDAT_SELECTION_KIND_NO_DUPLICATES
Definition: LLVMBitCodes.h:717
llvm::dxil::DXILBitcodeWriter::getEncodedBinaryOpcode
static unsigned getEncodedBinaryOpcode(unsigned Opcode)
Definition: DXILBitcodeWriter.cpp:527
llvm::bitc::CST_CODE_INTEGER
@ CST_CODE_INTEGER
Definition: LLVMBitCodes.h:378
llvm::bitc::METADATA_BASIC_TYPE
@ METADATA_BASIC_TYPE
Definition: LLVMBitCodes.h:337
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1595
llvm::bitc::ATTR_KIND_NON_LAZY_BIND
@ ATTR_KIND_NON_LAZY_BIND
Definition: LLVMBitCodes.h:639
llvm::bitc::CST_CODE_CE_EXTRACTELT
@ CST_CODE_CE_EXTRACTELT
Definition: LLVMBitCodes.h:388
llvm::dxil::ValueEnumerator::getInstructionID
unsigned getInstructionID(const Instruction *I) const
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::dxil::DXILBitcodeWriter::getEncodedDLLStorageClass
static unsigned getEncodedDLLStorageClass(const GlobalValue &GV)
Definition: DXILBitcodeWriter.cpp:867
Module.h
llvm::AttributeList
Definition: Attributes.h:430
llvm::CallBase::getAttributes
AttributeList getAttributes() const
Return the parameter attributes for this call.
Definition: InstrTypes.h:1475
llvm::bitc::ATTR_KIND_NEST
@ ATTR_KIND_NEST
Definition: LLVMBitCodes.h:632
BitcodeCommon.h
llvm::bitc::BINOP_XOR
@ BINOP_XOR
Definition: LLVMBitCodes.h:459
llvm::X86AS::FS
@ FS
Definition: X86.h:200
llvm::CallBase::getFunctionType
FunctionType * getFunctionType() const
Definition: InstrTypes.h:1255
llvm::bitc::PARAMATTR_CODE_ENTRY
@ PARAMATTR_CODE_ENTRY
Definition: LLVMBitCodes.h:130
llvm::bitc::BINOP_SDIV
@ BINOP_SDIV
Definition: LLVMBitCodes.h:451
llvm::GlobalValue::DefaultStorageClass
@ DefaultStorageClass
Definition: GlobalValue.h:70
llvm::bitc::TYPE_CODE_HALF
@ TYPE_CODE_HALF
Definition: LLVMBitCodes.h:150
llvm::bitc::TYPE_CODE_VOID
@ TYPE_CODE_VOID
Definition: LLVMBitCodes.h:139
llvm::bitc::ORDERING_ACQUIRE
@ ORDERING_ACQUIRE
Definition: LLVMBitCodes.h:513
llvm::bitc::FUNC_CODE_INST_ALLOCA
@ FUNC_CODE_INST_ALLOCA
Definition: LLVMBitCodes.h:553
llvm::bitc::RMW_UMIN
@ RMW_UMIN
Definition: LLVMBitCodes.h:476
llvm::bitc::MODULE_CODE_GLOBALVAR
@ MODULE_CODE_GLOBALVAR
Definition: LLVMBitCodes.h:96
llvm::bitc::TYPE_CODE_DOUBLE
@ TYPE_CODE_DOUBLE
Definition: LLVMBitCodes.h:141
llvm::Type::isX86_FP80Ty
bool isX86_FP80Ty() const
Return true if this is x86 long double.
Definition: Type.h:159
llvm::GlobalValue::DefaultVisibility
@ DefaultVisibility
The GV is visible.
Definition: GlobalValue.h:63
GlobalObject.h
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
llvm::MCID::Convergent
@ Convergent
Definition: MCInstrDesc.h:184
llvm::Comdat::Largest
@ Largest
The linker will choose the largest COMDAT.
Definition: Comdat.h:38
Operator.h
llvm::VectorType::getElementType
Type * getElementType() const
Definition: DerivedTypes.h:422
llvm::bitc::CAST_ZEXT
@ CAST_ZEXT
Definition: LLVMBitCodes.h:420
getBitWidth
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Definition: ValueTracking.cpp:100
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
llvm::bitc::METADATA_EXPRESSION
@ METADATA_EXPRESSION
Definition: LLVMBitCodes.h:351
llvm::bitc::CST_CODE_FLOAT
@ CST_CODE_FLOAT
Definition: LLVMBitCodes.h:380
llvm::FunctionType::getNumParams
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Definition: DerivedTypes.h:139
llvm::bitc::USELIST_CODE_BB
@ USELIST_CODE_BB
Definition: LLVMBitCodes.h:620
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
llvm::dxil::DXILBitcodeWriter::emitWideAPInt
static void emitWideAPInt(SmallVectorImpl< uint64_t > &Vals, const APInt &A)
Definition: DXILBitcodeWriter.cpp:779
STLExtras.h
llvm::dxil::ValueEnumerator::UseListOrders
UseListOrderStack UseListOrders
Definition: DXILValueEnumerator.h:57
llvm::DIExpression
DWARF expression.
Definition: DebugInfoMetadata.h:2596
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:357
llvm::bitc::ATTR_KIND_DEREFERENCEABLE_OR_NULL
@ ATTR_KIND_DEREFERENCEABLE_OR_NULL
Definition: LLVMBitCodes.h:666
llvm::dxil::LastPlusOne
@ LastPlusOne
Definition: DXILBitcodeWriter.cpp:62
llvm::bitc::TYPE_CODE_X86_MMX
@ TYPE_CODE_X86_MMX
Definition: LLVMBitCodes.h:164
llvm::bitc::CAST_SEXT
@ CAST_SEXT
Definition: LLVMBitCodes.h:421
llvm::dxil::ValueEnumerator::setInstructionID
void setInstructionID(const Instruction *I)
llvm::GlobalValue::DLLImportStorageClass
@ DLLImportStorageClass
Function to be imported from DLL.
Definition: GlobalValue.h:71
llvm::Type::getNonOpaquePointerElementType
Type * getNonOpaquePointerElementType() const
Only use this method in code that is not reachable with opaque pointers, or part of deprecated method...
Definition: Type.h:401
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1042
llvm::bitc::BINOP_ASHR
@ BINOP_ASHR
Definition: LLVMBitCodes.h:456
p
the resulting code requires compare and branches when and if * p
Definition: README.txt:396
llvm::AtomicRMWInst::FMin
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
Definition: Instructions.h:763
llvm::DINamespace
Definition: DebugInfoMetadata.h:2296
ModuleSummaryIndex.h
llvm::bitc::SYMTAB_BLOCK_ID
@ SYMTAB_BLOCK_ID
Definition: LLVMBitCodes.h:63
llvm::DILexicalBlock
Definition: DebugInfoMetadata.h:2125
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:159
llvm::bitc::ATTR_KIND_NO_CAPTURE
@ ATTR_KIND_NO_CAPTURE
Definition: LLVMBitCodes.h:635
llvm::bitc::CST_CODE_WIDE_INTEGER
@ CST_CODE_WIDE_INTEGER
Definition: LLVMBitCodes.h:379
llvm::bitc::ATTR_KIND_STRUCT_RET
@ ATTR_KIND_STRUCT_RET
Definition: LLVMBitCodes.h:653
llvm::bitc::ATTR_KIND_OPTIMIZE_NONE
@ ATTR_KIND_OPTIMIZE_NONE
Definition: LLVMBitCodes.h:661
new
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj * new
Definition: README.txt:125
llvm::dxil::ValueEnumerator::getValueID
unsigned getValueID(const Value *V) const
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::bitc::ATTR_KIND_JUMP_TABLE
@ ATTR_KIND_JUMP_TABLE
Definition: LLVMBitCodes.h:664
llvm::bitc::METADATA_FILE
@ METADATA_FILE
Definition: LLVMBitCodes.h:338
llvm::FunctionType::isVarArg
bool isVarArg() const
Definition: DerivedTypes.h:123
llvm::AtomicOrdering::Monotonic
@ Monotonic
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
PointerTypeAnalysis.h
llvm::bitc::FUNC_CODE_INST_CAST
@ FUNC_CODE_INST_CAST
Definition: LLVMBitCodes.h:535
llvm::bitc::METADATA_NAMESPACE
@ METADATA_NAMESPACE
Definition: LLVMBitCodes.h:346
llvm::MemoryEffects
Summary of how a function affects memory in the program.
Definition: ModRef.h:63
llvm::dxil::ValueEnumerator::getTypeID
unsigned getTypeID(Type *T) const
Definition: DXILValueEnumerator.h:165
llvm::bitc::ORDERING_NOTATOMIC
@ ORDERING_NOTATOMIC
Definition: LLVMBitCodes.h:510
Instruction.h
llvm::bitc::VALUE_SYMTAB_BLOCK_ID
@ VALUE_SYMTAB_BLOCK_ID
Definition: LLVMBitCodes.h:44
llvm::BitstreamWriter::EnterSubblock
void EnterSubblock(unsigned BlockID, unsigned CodeLen)
Definition: BitstreamWriter.h:276
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
llvm::DIObjCProperty
Definition: DebugInfoMetadata.h:3251
llvm::GlobalValueSummary
Function and variable summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:364
llvm::Type::MetadataTyID
@ MetadataTyID
Metadata.
Definition: Type.h:65
GlobalValue.h
llvm::ConstantDataSequential
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
Definition: Constants.h:570
llvm::Type::FunctionTyID
@ FunctionTyID
Functions.
Definition: Type.h:72
llvm::ArrayType::getNumElements
uint64_t getNumElements() const
Definition: DerivedTypes.h:369
Constants.h
llvm::BitCodeAbbrevOp::Char6
@ Char6
Definition: BitCodes.h:42
llvm::PHINode::getIncomingValue
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
Definition: Instructions.h:2795
llvm::bitc::TYPE_CODE_INTEGER
@ TYPE_CODE_INTEGER
Definition: LLVMBitCodes.h:144
llvm::AllocaInst::getAllocatedType
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
Definition: Instructions.h:115
llvm::DILocalVariable
Local variable.
Definition: DebugInfoMetadata.h:3096
llvm::dxil::ValueEnumerator
Definition: DXILValueEnumerator.h:46
llvm::bitc::ATTR_KIND_NO_DUPLICATE
@ ATTR_KIND_NO_DUPLICATE
Definition: LLVMBitCodes.h:636
llvm::bitc::FUNC_CODE_INST_SHUFFLEVEC
@ FUNC_CODE_INST_SHUFFLEVEC
Definition: LLVMBitCodes.h:540
llvm::DIMacro
Definition: DebugInfoMetadata.h:3486
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::bitc::TYPE_CODE_VECTOR
@ TYPE_CODE_VECTOR
Definition: LLVMBitCodes.h:153
llvm::bitc::CST_CODE_SETTYPE
@ CST_CODE_SETTYPE
Definition: LLVMBitCodes.h:375
llvm::bitc::FUNC_CODE_INST_BINOP
@ FUNC_CODE_INST_BINOP
Definition: LLVMBitCodes.h:534
llvm::bitc::ATTR_KIND_UW_TABLE
@ ATTR_KIND_UW_TABLE
Definition: LLVMBitCodes.h:657
llvm::dxil::ValueEnumerator::getAttributeGroups
const std::vector< IndexAndAttrSet > & getAttributeGroups() const
Definition: DXILValueEnumerator.h:222
llvm::bitc::TYPE_CODE_OPAQUE
@ TYPE_CODE_OPAQUE
Definition: LLVMBitCodes.h:143
llvm::dxil::ValueEnumerator::getFunctionConstantRange
void getFunctionConstantRange(unsigned &Start, unsigned &End) const
getFunctionConstantRange - Return the range of values that corresponds to function-local constants.
Definition: DXILValueEnumerator.h:192
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::ARM_PROC::A
@ A
Definition: ARMBaseInfo.h:34
llvm::bitc::CAST_FPTOSI
@ CAST_FPTOSI
Definition: LLVMBitCodes.h:423
llvm::bitc::BINOP_SHL
@ BINOP_SHL
Definition: LLVMBitCodes.h:454
llvm::bitc::UNOP_FNEG
@ UNOP_FNEG
Definition: LLVMBitCodes.h:439
llvm::GlobalValue::getThreadLocalMode
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:267
llvm::LandingPadInst::getNumClauses
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
Definition: Instructions.h:3023
InstrTypes.h
llvm::Log2
unsigned Log2(Align A)
Returns the log2 of the alignment.
Definition: Alignment.h:209
llvm::CallBase::getCalledFunction
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1397
llvm::GlobalObject
Definition: GlobalObject.h:27
llvm::BitstreamWriter::GetCurrentBitNo
uint64_t GetCurrentBitNo() const
Retrieve the current position in the stream, in bits.
Definition: BitstreamWriter.h:123
llvm::bitc::METADATA_COMPILE_UNIT
@ METADATA_COMPILE_UNIT
Definition: LLVMBitCodes.h:342
llvm::dxil::DXILBitcodeWriter::writeStringRecord
static void writeStringRecord(BitstreamWriter &Stream, unsigned Code, StringRef Str, unsigned AbbrevToUse)
Definition: DXILBitcodeWriter.cpp:650
SI
@ SI
Definition: SIInstrInfo.cpp:7966
llvm::bitc::OBO_NO_SIGNED_WRAP
@ OBO_NO_SIGNED_WRAP
Definition: LLVMBitCodes.h:487
llvm::MDTuple
Tuple of metadata.
Definition: Metadata.h:1329
llvm::bitc::ATTR_KIND_ALIGNMENT
@ ATTR_KIND_ALIGNMENT
Definition: LLVMBitCodes.h:625
llvm::dxil::DXILBitcodeWriter::getEncodedUnaryOpcode
static unsigned getEncodedUnaryOpcode(unsigned Opcode)
Definition: DXILBitcodeWriter.cpp:518
llvm::dxil::ValueEnumerator::getComdatID
unsigned getComdatID(const Comdat *C) const
llvm::bitc::BINOP_OR
@ BINOP_OR
Definition: LLVMBitCodes.h:458
llvm::dxil::ValueEnumerator::getMDStrings
ArrayRef< const Metadata * > getMDStrings() const
Get the MDString metadata for this block.
Definition: DXILValueEnumerator.h:203
llvm::Comdat::Any
@ Any
The linker may choose any COMDAT.
Definition: Comdat.h:36
llvm::DISubrange
Array subrange.
Definition: DebugInfoMetadata.h:338
llvm::bitc::METADATA_ENUMERATOR
@ METADATA_ENUMERATOR
Definition: LLVMBitCodes.h:336
llvm::VectorType::getElementCount
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Definition: DerivedTypes.h:627
llvm::dxil::BitcodeWriter::writeStrtab
void writeStrtab()
Write the bitcode file's string table.
llvm::DITemplateTypeParameter
Definition: DebugInfoMetadata.h:2441
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
llvm::Log2_32
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Definition: MathExtras.h:547
llvm::MemoryEffects::doesNotAccessMemory
bool doesNotAccessMemory() const
Whether this function accesses no memory.
Definition: ModRef.h:191
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::dxil::DXILBitcodeWriter::emitSignedInt64
static void emitSignedInt64(SmallVectorImpl< uint64_t > &Vals, uint64_t V)
Definition: DXILBitcodeWriter.cpp:771
llvm::bitc::METADATA_LEXICAL_BLOCK
@ METADATA_LEXICAL_BLOCK
Definition: LLVMBitCodes.h:344
llvm::bitc::METADATA_MODULE
@ METADATA_MODULE
Definition: LLVMBitCodes.h:354
llvm::BitstreamWriter
Definition: BitstreamWriter.h:30
llvm::BitstreamWriter::EmitAbbrev
unsigned EmitAbbrev(std::shared_ptr< BitCodeAbbrev > Abbv)
Emits the abbreviation Abbv to the stream.
Definition: BitstreamWriter.h:564
llvm::Instruction
Definition: Instruction.h:42
llvm::StringTableBuilder::getSize
size_t getSize() const
Definition: StringTableBuilder.h:82
llvm::bitc::MODULE_CODE_GCNAME
@ MODULE_CODE_GCNAME
Definition: LLVMBitCodes.h:105
llvm::ExtractValueInst::idx_end
idx_iterator idx_end() const
Definition: Instructions.h:2496
llvm::raw_ostream::write
raw_ostream & write(unsigned char C)
Definition: raw_ostream.cpp:218
llvm::dxil::ValueEnumerator::getBasicBlocks
const std::vector< const BasicBlock * > & getBasicBlocks() const
Definition: DXILValueEnumerator.h:214
llvm::dxil::ValueEnumerator::getAttributeListID
unsigned getAttributeListID(AttributeList PAL) const
Definition: DXILValueEnumerator.h:174
llvm::AtomicOrdering::Acquire
@ Acquire
llvm::AtomicRMWInst::Nand
@ Nand
*p = ~(old & v)
Definition: Instructions.h:737
llvm::bitc::CAST_PTRTOINT
@ CAST_PTRTOINT
Definition: LLVMBitCodes.h:428
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::ConstantFP
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:257
llvm::bitc::BINOP_SREM
@ BINOP_SREM
Definition: LLVMBitCodes.h:453
llvm::bitc::METADATA_LOCATION
@ METADATA_LOCATION
Definition: LLVMBitCodes.h:329
llvm::bitc::NoNaNs
@ NoNaNs
Definition: LLVMBitCodes.h:495
llvm::Comdat::SameSize
@ SameSize
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:40
llvm::FunctionType::params
ArrayRef< Type * > params() const
Definition: DerivedTypes.h:130
llvm::dxil::ValueEnumerator::getNonMDStrings
ArrayRef< const Metadata * > getNonMDStrings() const
Get the non-MDString metadata for this block.
Definition: DXILValueEnumerator.h:208
llvm::AArch64PACKey::IA
@ IA
Definition: AArch64BaseInfo.h:819
llvm::encode
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
Definition: Alignment.h:218
DebugLoc.h
llvm::bitc::METADATA_NAME
@ METADATA_NAME
Definition: LLVMBitCodes.h:326
llvm::bitc::FUNC_CODE_INST_PHI
@ FUNC_CODE_INST_PHI
Definition: LLVMBitCodes.h:550
llvm::SmallVectorImpl::append
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:687
llvm::bitc::ATTR_KIND_STACK_PROTECT_REQ
@ ATTR_KIND_STACK_PROTECT_REQ
Definition: LLVMBitCodes.h:651
llvm::Type::PointerTyID
@ PointerTyID
Pointers.
Definition: Type.h:73
llvm::dxil::DXILBitcodeWriter::getEncodedCastOpcode
static unsigned getEncodedCastOpcode(unsigned Opcode)
Begin dxil::BitcodeWriterBase Implementation.
Definition: DXILBitcodeWriter.cpp:485
llvm::BitstreamWriter::EmitBlockInfoAbbrev
unsigned EmitBlockInfoAbbrev(unsigned BlockID, std::shared_ptr< BitCodeAbbrev > Abbv)
EmitBlockInfoAbbrev - Emit a DEFINE_ABBREV record for the specified BlockID.
Definition: BitstreamWriter.h:606
llvm::AtomicRMWInst::FMax
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
Definition: Instructions.h:759
llvm::CallInst::isTailCall
bool isTailCall() const
Definition: Instructions.h:1668
llvm::GlobalValue::InternalLinkage
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:55
llvm::MCID::Call
@ Call
Definition: MCInstrDesc.h:155
llvm::Comdat
Definition: Comdat.h:33
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::bitc::METADATA_COMPOSITE_TYPE
@ METADATA_COMPOSITE_TYPE
Definition: LLVMBitCodes.h:340
llvm::bitc::ATTR_KIND_INLINE_HINT
@ ATTR_KIND_INLINE_HINT
Definition: LLVMBitCodes.h:628
llvm::AtomicRMWInst::Xchg
@ Xchg
*p = v
Definition: Instructions.h:729
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::CallBase::getCallingConv
CallingConv::ID getCallingConv() const
Definition: InstrTypes.h:1456
llvm::Type::BFloatTyID
@ BFloatTyID
16-bit floating point type (7-bit significand)
Definition: Type.h:57
llvm::bitc::MODULE_CODE_FUNCTION
@ MODULE_CODE_FUNCTION
Definition: LLVMBitCodes.h:100
llvm::bitc::TYPE_CODE_STRUCT_ANON
@ TYPE_CODE_STRUCT_ANON
Definition: LLVMBitCodes.h:166
llvm::PHINode::getNumIncomingValues
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Definition: Instructions.h:2791
llvm::BitCodeAbbrevOp::Blob
@ Blob
Definition: BitCodes.h:43
llvm::AtomicRMWInst::Add
@ Add
*p = old + v
Definition: Instructions.h:731
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::BWH_HeaderSize
@ BWH_HeaderSize
Definition: BitCodeEnums.h:32
Type.h
llvm::bitc::TYPE_CODE_ARRAY
@ TYPE_CODE_ARRAY
Definition: LLVMBitCodes.h:152
llvm::Log2_32_Ceil
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
Definition: MathExtras.h:560
llvm::ValueInfo
Struct that holds a reference to a particular GUID in a global value summary.
Definition: ModuleSummaryIndex.h:169
llvm::bitc::FUNC_CODE_INST_STORE
@ FUNC_CODE_INST_STORE
Definition: LLVMBitCodes.h:593
llvm::Record::dump
void dump() const
Definition: Record.cpp:2584
llvm::dxil::PointerTypeAnalysis::run
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
Definition: PointerTypeAnalysis.cpp:189
llvm::dxil::ValueEnumerator::IndexAndAttrSet
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
Definition: DXILValueEnumerator.h:55
llvm::BranchInst::getCondition
Value * getCondition() const
Definition: Instructions.h:3215
ValueSymbolTable.h
llvm::InvokeInst
Invoke instruction.
Definition: Instructions.h:3811
llvm::bitc::FUNC_CODE_INST_INSERTVAL
@ FUNC_CODE_INST_INSERTVAL
Definition: LLVMBitCodes.h:564
llvm::GlobalValue::DLLExportStorageClass
@ DLLExportStorageClass
Function to be accessible from DLL.
Definition: GlobalValue.h:72
llvm::DICommonBlock
Definition: DebugInfoMetadata.h:3037
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1682
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::InlineAsm
Definition: InlineAsm.h:33
llvm::VectorType
Base class of all SIMD vector types.
Definition: DerivedTypes.h:389
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::bitc::TYPE_CODE_X86_FP80
@ TYPE_CODE_X86_FP80
Definition: LLVMBitCodes.h:158
llvm::bitc::CAST_FPEXT
@ CAST_FPEXT
Definition: LLVMBitCodes.h:427
llvm::bitc::FUNC_CODE_INST_INVOKE
@ FUNC_CODE_INST_INVOKE
Definition: LLVMBitCodes.h:546
llvm::bitc::METADATA_KIND
@ METADATA_KIND
Definition: LLVMBitCodes.h:328
llvm::AtomicOrdering
AtomicOrdering
Atomic ordering for LLVM's memory model.
Definition: AtomicOrdering.h:56
llvm::bitc::FUNC_CODE_INST_CMP2
@ FUNC_CODE_INST_CMP2
Definition: LLVMBitCodes.h:567
llvm::AtomicRMWInst::UMin
@ UMin
*p = old <unsigned v ? old : v
Definition: Instructions.h:749
BasicBlock.h
IRSymtab.h
llvm::MDString::bytes_end
const unsigned char * bytes_end() const
Definition: Metadata.h:642
llvm::GlobalValue
Definition: GlobalValue.h:44
VI
@ VI
Definition: SIInstrInfo.cpp:7967
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::dxil::ValueEnumerator::getValues
const ValueList & getValues() const
Definition: DXILValueEnumerator.h:197
llvm::dxil
Definition: DXILOperationCommon.h:23
llvm::bitc::ATTR_KIND_NO_ALIAS
@ ATTR_KIND_NO_ALIAS
Definition: LLVMBitCodes.h:633
llvm::dxil::ValueEnumerator::computeBitsRequiredForTypeIndicies
uint64_t computeBitsRequiredForTypeIndicies() const
llvm::bitc::TYPE_CODE_POINTER
@ TYPE_CODE_POINTER
Definition: LLVMBitCodes.h:145
llvm::dxil::ValueEnumerator::getTypes
const TypeList & getTypes() const
Definition: DXILValueEnumerator.h:212
llvm::DIEnumerator
Enumeration value.
Definition: DebugInfoMetadata.h:449
llvm::AtomicRMWInst::Sub
@ Sub
*p = old - v
Definition: Instructions.h:733
llvm::bitc::ATTR_KIND_COLD
@ ATTR_KIND_COLD
Definition: LLVMBitCodes.h:660
llvm::bitc::TYPE_CODE_FLOAT
@ TYPE_CODE_FLOAT
Definition: LLVMBitCodes.h:140
llvm::bitc::PARAMATTR_BLOCK_ID
@ PARAMATTR_BLOCK_ID
Definition: LLVMBitCodes.h:33
uint64_t
llvm::bitc::CST_CODE_CE_CMP
@ CST_CODE_CE_CMP
Definition: LLVMBitCodes.h:391
llvm::APInt::getRawData
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
Definition: APInt.h:550
llvm::BitstreamWriter::EnterBlockInfoBlock
void EnterBlockInfoBlock()
EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK.
Definition: BitstreamWriter.h:576
llvm::GlobalValue::getVisibility
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:244
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:113
llvm::Attribute::None
@ None
No attributes have been set.
Definition: Attributes.h:87
llvm::bitc::CST_CODE_CE_BINOP
@ CST_CODE_CE_BINOP
Definition: LLVMBitCodes.h:384
llvm::GlobalValue::GeneralDynamicTLSModel
@ GeneralDynamicTLSModel
Definition: GlobalValue.h:193
llvm::Type::X86_MMXTyID
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
Definition: Type.h:66
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
llvm::bitc::USELIST_CODE_DEFAULT
@ USELIST_CODE_DEFAULT
Definition: LLVMBitCodes.h:619
llvm::bitc::METADATA_DERIVED_TYPE
@ METADATA_DERIVED_TYPE
Definition: LLVMBitCodes.h:339
llvm::bitc::ATTR_KIND_NAKED
@ ATTR_KIND_NAKED
Definition: LLVMBitCodes.h:631
llvm::GlobalValue::WeakAnyLinkage
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:52
llvm::bitc::RMW_FSUB
@ RMW_FSUB
Definition: LLVMBitCodes.h:478
llvm::dxil::BitcodeWriter::writeSymtab
void writeSymtab()
Attempt to write a symbol table to the bitcode file.
llvm::DIGlobalVariable
Global variables.
Definition: DebugInfoMetadata.h:2952
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::bitc::RMW_XOR
@ RMW_XOR
Definition: LLVMBitCodes.h:472
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:53
llvm::dxil::DXILBitcodeWriter::write
void write()
Emit the current module to the bitstream.
Definition: DXILBitcodeWriter.cpp:2956
llvm::bitc::FUNC_CODE_INST_LOADATOMIC
@ FUNC_CODE_INST_LOADATOMIC
Definition: LLVMBitCodes.h:588
llvm::DenseMap< const Value *, Type * >
llvm::SyncScope::ID
uint8_t ID
Definition: LLVMContext.h:46
llvm::GlobalValue::getDLLStorageClass
DLLStorageClassTypes getDLLStorageClass() const
Definition: GlobalValue.h:271
llvm::bitc::FUNC_CODE_INST_CALL
@ FUNC_CODE_INST_CALL
Definition: LLVMBitCodes.h:575
llvm::ExtractValueInst::idx_begin
idx_iterator idx_begin() const
Definition: Instructions.h:2495
llvm::AtomicOrdering::Unordered
@ Unordered
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::bitc::BINOP_UDIV
@ BINOP_UDIV
Definition: LLVMBitCodes.h:450
llvm::FunctionType::getParamType
Type * getParamType(unsigned i) const
Parameter type accessors.
Definition: DerivedTypes.h:135
llvm::bitc::CST_CODE_CE_GEP
@ CST_CODE_CE_GEP
Definition: LLVMBitCodes.h:386
llvm::bitc::RMW_MIN
@ RMW_MIN
Definition: LLVMBitCodes.h:474
llvm::AtomicRMWInst::Min
@ Min
*p = old <signed v ? old : v
Definition: Instructions.h:745
llvm::Attribute::AttrKind
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:85
llvm::bitc::METADATA_STRING_OLD
@ METADATA_STRING_OLD
Definition: LLVMBitCodes.h:323
llvm::MemoryEffects::onlyReadsMemory
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
Definition: ModRef.h:194
llvm::DICompileUnit
Compile unit.
Definition: DebugInfoMetadata.h:1360
llvm::DIImportedEntity
An imported module (C++ using directive or similar).
Definition: DebugInfoMetadata.h:3331
llvm::bitc::CAST_INTTOPTR
@ CAST_INTTOPTR
Definition: LLVMBitCodes.h:429
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:632
llvm::AtomicRMWInst::Or
@ Or
*p = old | v
Definition: Instructions.h:739
llvm::bitc::METADATA_NAMED_NODE
@ METADATA_NAMED_NODE
Definition: LLVMBitCodes.h:332
llvm::bitc::BINOP_UREM
@ BINOP_UREM
Definition: LLVMBitCodes.h:452
llvm::bitc::CAST_ADDRSPACECAST
@ CAST_ADDRSPACECAST
Definition: LLVMBitCodes.h:431
llvm::bitc::MODULE_CODE_SECTIONNAME
@ MODULE_CODE_SECTIONNAME
Definition: LLVMBitCodes.h:89
llvm::bitc::ATTR_KIND_MIN_SIZE
@ ATTR_KIND_MIN_SIZE
Definition: LLVMBitCodes.h:630
llvm::LandingPadInst::getClause
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
Definition: Instructions.h:3008
llvm::Type::isHalfTy
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:142
llvm::BitCodeAbbrevOp::VBR
@ VBR
Definition: BitCodes.h:40
llvm::BitCodeAbbrevOp::Array
@ Array
Definition: BitCodes.h:41
llvm::bitc::METADATA_SUBROUTINE_TYPE
@ METADATA_SUBROUTINE_TYPE
Definition: LLVMBitCodes.h:341
llvm::bitc::RMW_MAX
@ RMW_MAX
Definition: LLVMBitCodes.h:473
llvm::bitc::MODULE_CODE_DATALAYOUT
@ MODULE_CODE_DATALAYOUT
Definition: LLVMBitCodes.h:87
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
llvm::DIMacroFile
Definition: DebugInfoMetadata.h:3537
llvm::BitstreamWriter::ExitBlock
void ExitBlock()
Definition: BitstreamWriter.h:303
llvm::InsertValueInst::idx_begin
idx_iterator idx_begin() const
Definition: Instructions.h:2615
llvm::dxil::BitcodeWriter::writeModule
void writeModule(const Module &M)
Write the specified module to the buffer specified at construction time.
Definition: DXILBitcodeWriter.cpp:467
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::bitc::METADATA_NODE
@ METADATA_NODE
Definition: LLVMBitCodes.h:325
llvm::bitc::BINOP_SUB
@ BINOP_SUB
Definition: LLVMBitCodes.h:448
llvm::InsertValueInst::idx_end
idx_iterator idx_end() const
Definition: Instructions.h:2616
llvm::bitc::MODULE_CODE_ASM
@ MODULE_CODE_ASM
Definition: LLVMBitCodes.h:88
llvm::bitc::PARAMATTR_GRP_CODE_ENTRY
@ PARAMATTR_GRP_CODE_ENTRY
Definition: LLVMBitCodes.h:131
llvm::WinEH::EncodingType::CE
@ CE
Windows NT (Windows on ARM)
llvm::bitc::CST_CODE_CE_SELECT
@ CST_CODE_CE_SELECT
Definition: LLVMBitCodes.h:387
llvm::Record
Definition: Record.h:1573
llvm::dxil::DXILBitcodeWriter::getEncodedOrdering
static unsigned getEncodedOrdering(AtomicOrdering Ordering)
Definition: DXILBitcodeWriter.cpp:630
llvm::ValueAsMetadata::getValue
Value * getValue() const
Definition: Metadata.h:385
llvm::ValID
ValID - Represents a reference of a definition of some sort with no type.
Definition: LLParser.h:52
llvm::bitc::NoSignedZeros
@ NoSignedZeros
Definition: LLVMBitCodes.h:497
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MDNode
Metadata node.
Definition: Metadata.h:944
llvm::bitc::TYPE_CODE_STRUCT_NAME
@ TYPE_CODE_STRUCT_NAME
Definition: LLVMBitCodes.h:167
llvm::LinearPolySize::getKnownMinValue
ScalarTy getKnownMinValue() const
Returns the minimum value this size can represent.
Definition: TypeSize.h:296
llvm::bitc::ATTR_KIND_Z_EXT
@ ATTR_KIND_Z_EXT
Definition: LLVMBitCodes.h:658
llvm::dxil::BitcodeWriter::copyStrtab
void copyStrtab(StringRef Strtab)
Copy the string table for another module into this bitcode file.
llvm::StringTableBuilder::write
void write(raw_ostream &OS) const
Definition: StringTableBuilder.cpp:60
llvm::DIBasicType
Basic type, like 'int' or 'float'.
Definition: DebugInfoMetadata.h:802
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::bitc::TYPE_CODE_STRUCT_NAMED
@ TYPE_CODE_STRUCT_NAMED
Definition: LLVMBitCodes.h:168
llvm::dxil::ValueEnumerator::getAttributeLists
const std::vector< AttributeList > & getAttributeLists() const
Definition: DXILValueEnumerator.h:218
llvm::GlobalValue::AppendingLinkage
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:54
Triple.h
llvm::Type::FP128TyID
@ FP128TyID
128-bit floating point type (112-bit significand)
Definition: Type.h:61
llvm::DISubroutineType
Type array for a subprogram.
Definition: DebugInfoMetadata.h:1303
llvm::bitc::ORDERING_UNORDERED
@ ORDERING_UNORDERED
Definition: LLVMBitCodes.h:511
llvm::DICompositeType
Composite types.
Definition: DebugInfoMetadata.h:1080
llvm::bitc::MODULE_CODE_VERSION
@ MODULE_CODE_VERSION
Definition: LLVMBitCodes.h:85
llvm::BlockAddress
The address of a basic block.
Definition: Constants.h:849
llvm::bitc::AllowReassoc
@ AllowReassoc
Definition: LLVMBitCodes.h:501
llvm::dxil::ValueEnumerator::getMetadataID
unsigned getMetadataID(const Metadata *MD) const
Definition: DXILValueEnumerator.h:153
llvm::bitc::METADATA_TEMPLATE_VALUE
@ METADATA_TEMPLATE_VALUE
Definition: LLVMBitCodes.h:348
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::bitc::VST_CODE_ENTRY
@ VST_CODE_ENTRY
Definition: LLVMBitCodes.h:190
llvm::bitc::TYPE_CODE_PPC_FP128
@ TYPE_CODE_PPC_FP128
Definition: LLVMBitCodes.h:160
BitCodes.h
llvm::bitc::STRTAB_BLOCK_ID
@ STRTAB_BLOCK_ID
Definition: LLVMBitCodes.h:59
Mul
BinaryOperator * Mul
Definition: X86PartialReduction.cpp:70
DXILBitcodeWriter.h
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:213
llvm::bitc::TYPE_CODE_FUNCTION
@ TYPE_CODE_FUNCTION
Definition: LLVMBitCodes.h:170
llvm::dxil::DXILBitcodeWriter::getEncodedRMWOperation
static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op)
Definition: DXILBitcodeWriter.cpp:593
llvm::Type::PPC_FP128TyID
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:62
llvm::UseListOrder
Structure to hold a use-list order.
Definition: UseListOrder.h:26
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::bitc::METADATA_LEXICAL_BLOCK_FILE
@ METADATA_LEXICAL_BLOCK_FILE
Definition: LLVMBitCodes.h:345
llvm::bitc::ORDERING_MONOTONIC
@ ORDERING_MONOTONIC
Definition: LLVMBitCodes.h:512
llvm::bitc::RMW_SUB
@ RMW_SUB
Definition: LLVMBitCodes.h:468
llvm::bitc::ATTR_KIND_SANITIZE_THREAD
@ ATTR_KIND_SANITIZE_THREAD
Definition: LLVMBitCodes.h:655
llvm::bitc::CST_CODE_CE_INBOUNDS_GEP
@ CST_CODE_CE_INBOUNDS_GEP
Definition: LLVMBitCodes.h:395
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::GlobalValue::WeakODRLinkage
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:53
uint32_t
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::bitc::ATTR_KIND_NO_RED_ZONE
@ ATTR_KIND_NO_RED_ZONE
Definition: LLVMBitCodes.h:640
llvm::bitc::ATTR_KIND_DEREFERENCEABLE
@ ATTR_KIND_DEREFERENCEABLE
Definition: LLVMBitCodes.h:665
llvm::dxil::ValueEnumerator::getComdats
const ComdatSetType & getComdats() const
Definition: DXILValueEnumerator.h:226
llvm::bitc::OBO_NO_UNSIGNED_WRAP
@ OBO_NO_UNSIGNED_WRAP
Definition: LLVMBitCodes.h:486
llvm::bitc::FUNC_CODE_INST_BR
@ FUNC_CODE_INST_BR
Definition: LLVMBitCodes.h:544
llvm::dxil::DXILBitcodeWriter
Definition: DXILBitcodeWriter.cpp:65
llvm::GenericDINode
Generic tagged DWARF-like metadata node.
Definition: DebugInfoMetadata.h:230
llvm::dxil::ValueEnumerator::getGlobalBasicBlockID
unsigned getGlobalBasicBlockID(const BasicBlock *BB) const
getGlobalBasicBlockID - This returns the function-specific ID for the specified basic block.
llvm::Type::isLabelTy
bool isLabelTy() const
Return true if this is 'label'.
Definition: Type.h:201
llvm::bitc::CONSTANTS_BLOCK_ID
@ CONSTANTS_BLOCK_ID
Definition: LLVMBitCodes.h:36
llvm::bitc::MODULE_CODE_TRIPLE
@ MODULE_CODE_TRIPLE
Definition: LLVMBitCodes.h:86
llvm::LandingPadInst::Catch
@ Catch
Definition: Instructions.h:2961
llvm::CallInst::isMustTailCall
bool isMustTailCall() const
Definition: Instructions.h:1673
llvm::bitc::BINOP_ADD
@ BINOP_ADD
Definition: LLVMBitCodes.h:447
llvm::bitc::VST_CODE_BBENTRY
@ VST_CODE_BBENTRY
Definition: LLVMBitCodes.h:191
llvm::bitc::RMW_ADD
@ RMW_ADD
Definition: LLVMBitCodes.h:467
llvm::GlobalValue::AvailableExternallyLinkage
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition: GlobalValue.h:49
llvm::Type::TypedPointerTyID
@ TypedPointerTyID
Typed pointer used by some GPU targets.
Definition: Type.h:78
llvm::bitc::PEO_EXACT
@ PEO_EXACT
Definition: LLVMBitCodes.h:506
llvm::bitc::FUNC_CODE_DEBUG_LOC_AGAIN
@ FUNC_CODE_DEBUG_LOC_AGAIN
Definition: LLVMBitCodes.h:573
llvm::GlobalValue::CommonLinkage
@ CommonLinkage
Tentative definitions.
Definition: GlobalValue.h:58
llvm::bitc::FUNC_CODE_INST_VAARG
@ FUNC_CODE_INST_VAARG
Definition: LLVMBitCodes.h:557
llvm::GlobalValue::LocalExecTLSModel
@ LocalExecTLSModel
Definition: GlobalValue.h:196
llvm::Type::IntegerTyID
@ IntegerTyID
Arbitrary bit width integers.
Definition: Type.h:71
Callee
amdgpu Simplify well known AMD library false FunctionCallee Callee
Definition: AMDGPULibCalls.cpp:187
llvm::bitc::COMDAT_SELECTION_KIND_ANY
@ COMDAT_SELECTION_KIND_ANY
Definition: LLVMBitCodes.h:714
llvm::AtomicOrdering::Release
@ Release
llvm::bitc::ATTR_KIND_NON_NULL
@ ATTR_KIND_NON_NULL
Definition: LLVMBitCodes.h:663
llvm::MCID::Select
@ Select
Definition: MCInstrDesc.h:164
Attributes.h
llvm::bitc::RMW_UMAX
@ RMW_UMAX
Definition: LLVMBitCodes.h:475
llvm::bitc::FUNC_CODE_INST_GEP
@ FUNC_CODE_INST_GEP
Definition: LLVMBitCodes.h:592
llvm::bitc::TYPE_BLOCK_ID_NEW
@ TYPE_BLOCK_ID_NEW
Definition: LLVMBitCodes.h:48
llvm::bitc::ATTR_KIND_ALWAYS_INLINE
@ ATTR_KIND_ALWAYS_INLINE
Definition: LLVMBitCodes.h:626
llvm::bitc::ATTR_KIND_STACK_PROTECT_STRONG
@ ATTR_KIND_STACK_PROTECT_STRONG
Definition: LLVMBitCodes.h:652
llvm::bitc::FUNC_CODE_INST_INDIRECTBR
@ FUNC_CODE_INST_INDIRECTBR
Definition: LLVMBitCodes.h:571
llvm::bitc::CST_CODE_AGGREGATE
@ CST_CODE_AGGREGATE
Definition: LLVMBitCodes.h:381
Constant.h
LLVMBitCodes.h
llvm::bitc::ATTR_KIND_READ_NONE
@ ATTR_KIND_READ_NONE
Definition: LLVMBitCodes.h:644
LastPlusOne
@ LastPlusOne
Definition: BitcodeWriter.cpp:2211
llvm::ConstantExpr
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:972
llvm::dxil::ValueEnumerator::EnumerateType
void EnumerateType(Type *T)
llvm::bitc::CAST_UITOFP
@ CAST_UITOFP
Definition: LLVMBitCodes.h:424
llvm::PPC::getPredicate
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
Definition: PPCPredicates.h:87
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::bitc::FUNC_CODE_INST_CMPXCHG
@ FUNC_CODE_INST_CMPXCHG
Definition: LLVMBitCodes.h:595
llvm::Type::isFloatTy
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:153
llvm::bitc::RMW_FMAX
@ RMW_FMAX
Definition: LLVMBitCodes.h:479
llvm::TypedPointerType::getAddressSpace
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: TypedPointerType.h:42
llvm::bitc::ORDERING_ACQREL
@ ORDERING_ACQREL
Definition: LLVMBitCodes.h:515
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
llvm::bitc::FIRST_APPLICATION_ABBREV
@ FIRST_APPLICATION_ABBREV
Definition: BitCodeEnums.h:60
llvm::AtomicRMWInst::FSub
@ FSub
*p = old - v
Definition: Instructions.h:755
llvm::DenseMapBase::end
iterator end()
Definition: DenseMap.h:84
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:348
llvm::bitc::CAST_FPTOUI
@ CAST_FPTOUI
Definition: LLVMBitCodes.h:422
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
llvm::Type::FixedVectorTyID
@ FixedVectorTyID
Fixed width SIMD vector type.
Definition: Type.h:76
JumpTable
MIPS Relocation Principles In there are several elements of the llvm::ISD::NodeType enum that deal with addresses and or relocations These are defined in include llvm Target TargetSelectionDAG td JumpTable
Definition: Relocation.txt:6
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::CallBase::arg_size
unsigned arg_size() const
Definition: InstrTypes.h:1340
llvm::SPII::Load
@ Load
Definition: SparcInstrInfo.h:32
llvm::bitc::FUNC_CODE_INST_LOAD
@ FUNC_CODE_INST_LOAD
Definition: LLVMBitCodes.h:554
GlobalVariable.h
llvm::bitc::FUNC_CODE_INST_EXTRACTVAL
@ FUNC_CODE_INST_EXTRACTVAL
Definition: LLVMBitCodes.h:563
llvm::ExtractValueInst
This instruction extracts a struct member or array element value from an aggregate value.
Definition: Instructions.h:2446
llvm::AtomicRMWInst::And
@ And
*p = old & v
Definition: Instructions.h:735
llvm::bitc::CAST_SITOFP
@ CAST_SITOFP
Definition: LLVMBitCodes.h:425
llvm::TypedPointerType::getElementType
Type * getElementType() const
Definition: TypedPointerType.h:44
llvm::bitc::FUNCTION_BLOCK_ID
@ FUNCTION_BLOCK_ID
Definition: LLVMBitCodes.h:37
llvm::bitc::FUNC_CODE_INST_FENCE
@ FUNC_CODE_INST_FENCE
Definition: LLVMBitCodes.h:578
llvm::bitc::TYPE_CODE_NUMENTRY
@ TYPE_CODE_NUMENTRY
Definition: LLVMBitCodes.h:136
Function.h
llvm::Type::TokenTyID
@ TokenTyID
Tokens.
Definition: Type.h:68
llvm::Type::isDoubleTy
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:156
llvm::GlobalValue::ProtectedVisibility
@ ProtectedVisibility
The GV is protected.
Definition: GlobalValue.h:65
llvm::bitc::METADATA_ATTACHMENT_ID
@ METADATA_ATTACHMENT_ID
Definition: LLVMBitCodes.h:46
llvm::Type::isPPC_FP128Ty
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Definition: Type.h:165
llvm::bitc::BINOP_LSHR
@ BINOP_LSHR
Definition: LLVMBitCodes.h:455
llvm::StringTableBuilder
Utility for building string tables with deduplicated suffixes.
Definition: StringTableBuilder.h:23
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:614
llvm::bitc::CST_CODE_UNDEF
@ CST_CODE_UNDEF
Definition: LLVMBitCodes.h:377
llvm::MCID::Add
@ Add
Definition: MCInstrDesc.h:185
llvm::bitc::METADATA_ATTACHMENT
@ METADATA_ATTACHMENT
Definition: LLVMBitCodes.h:333
llvm::CallBase::getCalledOperand
Value * getCalledOperand() const
Definition: InstrTypes.h:1390
llvm::DIDerivedType
Derived types.
Definition: DebugInfoMetadata.h:962
llvm::DIGlobalVariableExpression
A pair of DIGlobalVariable and DIExpression.
Definition: DebugInfoMetadata.h:3396
llvm::bitc::CST_CODE_CSTRING
@ CST_CODE_CSTRING
Definition: LLVMBitCodes.h:383
GlobalAlias.h
llvm::dxil::BitcodeWriter
Definition: DXILBitcodeWriter.h:31
llvm::getAlign
bool getAlign(const Function &F, unsigned index, unsigned &align)
Definition: NVPTXUtilities.cpp:294
llvm::bitc::TYPE_CODE_FP128
@ TYPE_CODE_FP128
Definition: LLVMBitCodes.h:159
llvm::bitc::CAST_FPTRUNC
@ CAST_FPTRUNC
Definition: LLVMBitCodes.h:426
SHA1.h
llvm::dxil::BitcodeWriter::~BitcodeWriter
~BitcodeWriter()
Definition: DXILBitcodeWriter.cpp:386
llvm::BitCodeAbbrevOp
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
Definition: BitCodes.h:33
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
llvm::Type::LabelTyID
@ LabelTyID
Labels.
Definition: Type.h:64
llvm::ValueEnumerator::ValueList
std::vector< std::pair< const Value *, unsigned > > ValueList
Definition: ValueEnumerator.h:48
llvm::MemoryEffects::onlyAccessesArgPointees
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
Definition: ModRef.h:200
llvm::DITemplateValueParameter
Definition: DebugInfoMetadata.h:2480
llvm::bitc::METADATA_GLOBAL_VAR
@ METADATA_GLOBAL_VAR
Definition: LLVMBitCodes.h:349
llvm::Type::StructTyID
@ StructTyID
Structures.
Definition: Type.h:74
llvm::bitc::METADATA_BLOCK_ID
@ METADATA_BLOCK_ID
Definition: LLVMBitCodes.h:45
llvm::Type::isOpaquePointerTy
bool isOpaquePointerTy() const
True if this is an instance of an opaque PointerType.
Definition: Type.cpp:61
llvm::bitc::BINOP_MUL
@ BINOP_MUL
Definition: LLVMBitCodes.h:449
llvm::GlobalValue::PrivateLinkage
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:56
llvm::bitc::TYPE_CODE_METADATA
@ TYPE_CODE_METADATA
Definition: LLVMBitCodes.h:162
Instructions.h
llvm::dxil::ValueEnumerator::hasMDs
bool hasMDs() const
Check whether the current block has any metadata to emit.
Definition: DXILValueEnumerator.h:200
llvm::bitc::METADATA_LOCAL_VAR
@ METADATA_LOCAL_VAR
Definition: LLVMBitCodes.h:350
llvm::bitc::ATTR_KIND_SANITIZE_ADDRESS
@ ATTR_KIND_SANITIZE_ADDRESS
Definition: LLVMBitCodes.h:654
llvm::AllocaInst::isUsedWithInAlloca
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
Definition: Instructions.h:137
llvm::AttributeSet
Definition: Attributes.h:294
llvm::bitc::RMW_AND
@ RMW_AND
Definition: LLVMBitCodes.h:469
llvm::dxil::DXILBitcodeWriter::getEncodedComdatSelectionKind
static unsigned getEncodedComdatSelectionKind(const Comdat &C)
Definition: DXILBitcodeWriter.cpp:895
llvm::ValueSymbolTable
This class provides a symbol table of name/value pairs.
Definition: ValueSymbolTable.h:37
llvm::bitc::ATTR_KIND_NO_INLINE
@ ATTR_KIND_NO_INLINE
Definition: LLVMBitCodes.h:638
llvm::bitc::ATTR_KIND_STACK_ALIGNMENT
@ ATTR_KIND_STACK_ALIGNMENT
Definition: LLVMBitCodes.h:649
llvm::bitc::COMDAT_SELECTION_KIND_LARGEST
@ COMDAT_SELECTION_KIND_LARGEST
Definition: LLVMBitCodes.h:716
llvm::raw_fd_stream
A raw_ostream of a file for reading/writing/seeking.
Definition: raw_ostream.h:598
llvm::LandingPadInst::Filter
@ Filter
Definition: Instructions.h:2961
llvm::bitc::ATTR_KIND_NO_IMPLICIT_FLOAT
@ ATTR_KIND_NO_IMPLICIT_FLOAT
Definition: LLVMBitCodes.h:637
llvm::DIAssignID
Assignment ID.
Definition: DebugInfoMetadata.h:303
llvm::bitc::ORDERING_RELEASE
@ ORDERING_RELEASE
Definition: LLVMBitCodes.h:514
llvm::CallBase::getArgOperand
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1342
N
#define N
llvm::LandingPadInst::isCatch
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
Definition: Instructions.h:3013
llvm::bitc::ATTR_KIND_BUILTIN
@ ATTR_KIND_BUILTIN
Definition: LLVMBitCodes.h:659
llvm::bitc::FUNC_CODE_INST_RESUME
@ FUNC_CODE_INST_RESUME
Definition: LLVMBitCodes.h:585
llvm::bitc::STRTAB_BLOB
@ STRTAB_BLOB
Definition: LLVMBitCodes.h:722
llvm::bitc::METADATA_VALUE
@ METADATA_VALUE
Definition: LLVMBitCodes.h:324
llvm::PHINode::getIncomingBlock
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Definition: Instructions.h:2815
llvm::AtomicRMWInst::FAdd
@ FAdd
*p = old + v
Definition: Instructions.h:752
llvm::MachineBasicBlock::empty
bool empty() const
Definition: MachineBasicBlock.h:277
llvm::PHINode
Definition: Instructions.h:2699
llvm::bitc::RMW_FADD
@ RMW_FADD
Definition: LLVMBitCodes.h:477
IV
static const uint32_t IV[8]
Definition: blake3_impl.h:85
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1841
llvm::SmallVectorImpl< char >
llvm::dxil::DXILBitcodeWriter::getOptimizationFlags
static uint64_t getOptimizationFlags(const Value *V)
Definition: DXILBitcodeWriter.cpp:791
llvm::dxil::MetadataAbbrev
MetadataAbbrev
Definition: DXILBitcodeWriter.cpp:59
llvm::bitc::RMW_FMIN
@ RMW_FMIN
Definition: LLVMBitCodes.h:480
llvm::ValueAsMetadata
Value wrapper in the Metadata hierarchy.
Definition: Metadata.h:345
llvm::DIModule
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Definition: DebugInfoMetadata.h:2345
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1175
llvm::Type::ScalableVectorTyID
@ ScalableVectorTyID
Scalable SIMD vector type.
Definition: Type.h:77
DerivedTypes.h
llvm::bitc::CAST_BITCAST
@ CAST_BITCAST
Definition: LLVMBitCodes.h:430
llvm::bitc::METADATA_SUBPROGRAM
@ METADATA_SUBPROGRAM
Definition: LLVMBitCodes.h:343
llvm::bitc::USELIST_BLOCK_ID
@ USELIST_BLOCK_ID
Definition: LLVMBitCodes.h:50
llvm::TypedPointerType::get
static TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Definition: TypedPointerType.cpp:17
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1474
llvm::omp::RTLDependInfoFields::Flags
@ Flags
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::bitc::METADATA_GENERIC_DEBUG
@ METADATA_GENERIC_DEBUG
Definition: LLVMBitCodes.h:334
llvm::DILabel
Label.
Definition: DebugInfoMetadata.h:3186
llvm::dxil::WriteDXILToFile
void WriteDXILToFile(const Module &M, raw_ostream &Out)
Write the specified module to the specified raw output stream.
Definition: DXILBitcodeWriter.cpp:389
UseListOrder.h
llvm::bitc::FUNC_CODE_INST_UNREACHABLE
@ FUNC_CODE_INST_UNREACHABLE
Definition: LLVMBitCodes.h:548
llvm::bitc::FUNC_CODE_DEBUG_LOC
@ FUNC_CODE_DEBUG_LOC
Definition: LLVMBitCodes.h:577
LLVMContext.h
llvm::SwitchInst
Multiway switch.
Definition: Instructions.h:3278
llvm::bitc::ATTR_KIND_RETURNS_TWICE
@ ATTR_KIND_RETURNS_TWICE
Definition: LLVMBitCodes.h:647
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:59
BitcodeReader.h
llvm::GlobalValue::ExternalWeakLinkage
@ ExternalWeakLinkage
ExternalWeak linkage description.
Definition: GlobalValue.h:57
llvm::dxil::ValueEnumerator::getMetadataOrNullID
unsigned getMetadataOrNullID(const Metadata *MD) const
Definition: DXILValueEnumerator.h:159
llvm::bitc::ORDERING_SEQCST
@ ORDERING_SEQCST
Definition: LLVMBitCodes.h:516
llvm::BranchInst
Conditional or Unconditional Branch instruction.
Definition: Instructions.h:3134
llvm::AtomicRMWInst::UMax
@ UMax
*p = old >unsigned v ? old : v
Definition: Instructions.h:747
llvm::bitc::AllowContract
@ AllowContract
Definition: LLVMBitCodes.h:499
llvm::dxil::ValueEnumerator::incorporateFunction
void incorporateFunction(const Function &F)
incorporateFunction/purgeFunction - If you'd like to deal with a function, use these two methods to g...
llvm::bitc::MODULE_CODE_ALIAS_OLD
@ MODULE_CODE_ALIAS_OLD
Definition: LLVMBitCodes.h:103
llvm::GlobalValue::InitialExecTLSModel
@ InitialExecTLSModel
Definition: GlobalValue.h:195
llvm::bitc::METADATA_TEMPLATE_TYPE
@ METADATA_TEMPLATE_TYPE
Definition: LLVMBitCodes.h:347
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:667
llvm::InsertValueInst
This instruction inserts a struct field of array element value into an aggregate value.
Definition: Instructions.h:2557
llvm::dxil::DXILBitcodeWriter::getEncodedVisibility
static unsigned getEncodedVisibility(const GlobalValue &GV)
Definition: DXILBitcodeWriter.cpp:855
llvm::MDString
A single uniqued string.
Definition: Metadata.h:612
llvm::GlobalValue::LinkOnceODRLinkage
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:51
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:111
llvm::bitc::CST_CODE_STRING
@ CST_CODE_STRING
Definition: LLVMBitCodes.h:382
Value.h
llvm::InvokeInst::getUnwindDest
BasicBlock * getUnwindDest() const
Definition: Instructions.h:3946
llvm::bitc::COMDAT_SELECTION_KIND_EXACT_MATCH
@ COMDAT_SELECTION_KIND_EXACT_MATCH
Definition: LLVMBitCodes.h:715
llvm::bitc::FUNC_CODE_INST_SWITCH
@ FUNC_CODE_INST_SWITCH
Definition: LLVMBitCodes.h:545
llvm::FunctionType::getReturnType
Type * getReturnType() const
Definition: DerivedTypes.h:124
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::bitc::COMDAT_SELECTION_KIND_SAME_SIZE
@ COMDAT_SELECTION_KIND_SAME_SIZE
Definition: LLVMBitCodes.h:718
llvm::Type::isFP128Ty
bool isFP128Ty() const
Return true if this is 'fp128'.
Definition: Type.h:162
llvm::ValueEnumerator::TypeList
std::vector< Type * > TypeList
Definition: ValueEnumerator.h:45
llvm::Type::HalfTyID
@ HalfTyID
16-bit floating point type
Definition: Type.h:56
llvm::Type::X86_FP80TyID
@ X86_FP80TyID
80-bit floating point type (X87)
Definition: Type.h:60
llvm::bitc::ApproxFunc
@ ApproxFunc
Definition: LLVMBitCodes.h:500
BitstreamWriter.h
llvm::dxil::DXILBitcodeWriter::writeIdentificationBlock
static void writeIdentificationBlock(BitstreamWriter &Stream)
llvm::bitc::CST_CODE_DATA
@ CST_CODE_DATA
Definition: LLVMBitCodes.h:397
llvm::BranchInst::isConditional
bool isConditional() const
Definition: Instructions.h:3213
llvm::ArrayType::getElementType
Type * getElementType() const
Definition: DerivedTypes.h:370
llvm::AtomicOrdering::NotAtomic
@ NotAtomic
llvm::TypedPointerType
A few GPU targets, such as DXIL and SPIR-V, have typed pointers.
Definition: TypedPointerType.h:25
llvm::BranchInst::getSuccessor
BasicBlock * getSuccessor(unsigned i) const
Definition: Instructions.h:3227
llvm::bitc::ATTR_KIND_IN_REG
@ ATTR_KIND_IN_REG
Definition: LLVMBitCodes.h:629
llvm::bitc::ATTR_KIND_NO_UNWIND
@ ATTR_KIND_NO_UNWIND
Definition: LLVMBitCodes.h:642
llvm::bitc::FUNC_CODE_INST_EXTRACTELT
@ FUNC_CODE_INST_EXTRACTELT
Definition: LLVMBitCodes.h:538
llvm::Function::const_iterator
BasicBlockListType::const_iterator const_iterator
Definition: Function.h:67
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition: BasicBlock.h:88
llvm::bitc::CST_CODE_INLINEASM
@ CST_CODE_INLINEASM
Definition: LLVMBitCodes.h:408
llvm::bitc::ATTR_KIND_RETURNED
@ ATTR_KIND_RETURNED
Definition: LLVMBitCodes.h:646
llvm::bitc::AllowReciprocal
@ AllowReciprocal
Definition: LLVMBitCodes.h:498
llvm::DIFile
File.
Definition: DebugInfoMetadata.h:563
llvm::bitc::FUNC_CODE_DECLAREBLOCKS
@ FUNC_CODE_DECLAREBLOCKS
Definition: LLVMBitCodes.h:532
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:103
llvm::dxil::DXILBitcodeWriter::getEncodedThreadLocalMode
static unsigned getEncodedThreadLocalMode(const GlobalValue &GV)
Definition: DXILBitcodeWriter.cpp:879
llvm::Function::size
size_t size() const
Definition: Function.h:712
llvm::dxil::DXILBitcodeWriter::getEncodedLinkage
static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage)
Definition: DXILBitcodeWriter.cpp:823
llvm::irsymtab::build
Error build(ArrayRef< Module * > Mods, SmallVector< char, 0 > &Symtab, StringTableBuilder &StrtabBuilder, BumpPtrAllocator &Alloc)
Fills in Symtab and StrtabBuilder with a valid symbol and string table for Mods.
Definition: IRSymtab.cpp:365
llvm::SmallVectorImpl::insert
iterator insert(iterator I, T &&Elt)
Definition: SmallVector.h:809
llvm::AtomicRMWInst::Max
@ Max
*p = old >signed v ? old : v
Definition: Instructions.h:743
llvm::bitc::METADATA_IMPORTED_ENTITY
@ METADATA_IMPORTED_ENTITY
Definition: LLVMBitCodes.h:353
llvm::bitc::ATTR_KIND_SAFESTACK
@ ATTR_KIND_SAFESTACK
Definition: LLVMBitCodes.h:668