39 uint64_t PartOffset = 0;
40 bool HasPrivate =
false;
44 "PRIV must be the last section in a DXContainer");
45 if (Part.Name ==
"PRIV")
48 uint64_t SectionSize = Part.Data.size();
49 assert(SectionSize < std::numeric_limits<uint32_t>::max() &&
50 "Section size too large for DXContainer");
61 assert(PartOffset < std::numeric_limits<uint32_t>::max() &&
62 "Part data too large for DXContainer");
66 uint64_t FileSize = PartStart + PartOffset;
67 assert(FileSize < std::numeric_limits<uint32_t>::max() &&
68 "File size too large for DXContainer");
71 W.write<
char>({
'D',
'X',
'B',
'C'});
75 W.write<uint16_t>(1u);
76 W.write<uint16_t>(0u);
82 for (uint64_t
Offset : PartOffsets)
86 uint64_t SectionSize = Part.Data.size();
87 unsigned Start = W.OS.tell();
91 uint64_t PartSize = SectionSize;
96 bool IsPrivate = Part.Name ==
"PRIV";
110 if (TT.hasEnvironment())
116 memcpy(Header.Bitcode.Magic,
"DXIL", 4);
118 Header.Bitcode.MajorVersion = DXILVersion.
getMajor();
119 Header.Bitcode.MinorVersion = DXILVersion.
getMinor().value_or(0);
121 Header.Bitcode.Size = SectionSize;
127 W.write<
char>(Part.Data);
129 unsigned Size = W.OS.tell() - Start;
135void DXContainerObjectWriter::clearParts() {
137 SectionBuffers.clear();
146 SectionBuffers.emplace_back();
148 Asm->writeSectionData(OS, &Sec);
149 Parts.push_back({Sec.getName(),
StringRef(SectionBuffers.back())});
155 size_t SectionSize) {
156 if (TargetObjectWriter->shouldSkipSection(
SectionName))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Represent a constant reference to an array (0 or more elements consecutively in memory),...
uint64_t writeObject() override
Write the object file and returns the number of bytes written.
bool shouldSkipSection(StringRef SectionName, size_t SectionSize) override
ArrayRef< MCDXContainerPart > collectParts() override
void write(raw_ostream &OS, const Triple &TT)
virtual ArrayRef< MCDXContainerPart > collectParts()
virtual ~MCDXContainerBaseWriter()
virtual bool shouldSkipSection(StringRef SectionName, size_t SectionSize)
~MCDXContainerTargetWriter() override
MCContext & getContext() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned getMajor() const
Retrieve the major version number.
std::optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
LLVM_ABI bool isProgramPart(StringRef PartName)
constexpr bool IsBigEndianHost
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
static constexpr StringLiteral ModuleHashSectionName
Contains module hash.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
static constexpr StringLiteral PdbFileNameSectionName
Contains PDB output file name.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Adapter to write values to a stream in a particular byte order.