LLVM 22.0.0git
DXContainer.cpp
Go to the documentation of this file.
1//===- DXContainer.cpp - DXContainer object file implementation -----------===//
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
11#include "llvm/Object/Error.h"
12#include "llvm/Support/Endian.h"
15
16using namespace llvm;
17using namespace llvm::object;
18
19static Error parseFailed(const Twine &Msg) {
20 return make_error<GenericBinaryError>(Msg.str(), object_error::parse_failed);
21}
22
23template <typename T>
24static Error readStruct(StringRef Buffer, const char *Src, T &Struct) {
25 // Don't read before the beginning or past the end of the file
26 if (Src < Buffer.begin() || Src + sizeof(T) > Buffer.end())
27 return parseFailed("Reading structure out of file bounds");
28
29 memcpy(&Struct, Src, sizeof(T));
30 // DXContainer is always little endian
32 Struct.swapBytes();
33 return Error::success();
34}
35
36template <typename T>
37static Error readInteger(StringRef Buffer, const char *Src, T &Val,
38 Twine Str = "structure") {
39 static_assert(std::is_integral_v<T>,
40 "Cannot call readInteger on non-integral type.");
41 // Don't read before the beginning or past the end of the file
42 if (Src < Buffer.begin() || Src + sizeof(T) > Buffer.end())
43 return parseFailed(Twine("Reading ") + Str + " out of file bounds");
44
45 // The DXContainer offset table is comprised of uint32_t values but not padded
46 // to a 64-bit boundary. So Parts may start unaligned if there is an odd
47 // number of parts and part data itself is not required to be padded.
48 if (reinterpret_cast<uintptr_t>(Src) % alignof(T) != 0)
49 memcpy(reinterpret_cast<char *>(&Val), Src, sizeof(T));
50 else
51 Val = *reinterpret_cast<const T *>(Src);
52 // DXContainer is always little endian
55 return Error::success();
56}
57
58DXContainer::DXContainer(MemoryBufferRef O) : Data(O) {}
59
60Error DXContainer::parseHeader() {
61 return readStruct(Data.getBuffer(), Data.getBuffer().data(), Header);
62}
63
64Error DXContainer::parseDXILHeader(StringRef Part) {
65 if (DXIL)
66 return parseFailed("More than one DXIL part is present in the file");
67 const char *Current = Part.begin();
69 if (Error Err = readStruct(Part, Current, Header))
70 return Err;
71 Current += offsetof(dxbc::ProgramHeader, Bitcode) + Header.Bitcode.Offset;
72 DXIL.emplace(std::make_pair(Header, Current));
73 return Error::success();
74}
75
76Error DXContainer::parseShaderFeatureFlags(StringRef Part) {
77 if (ShaderFeatureFlags)
78 return parseFailed("More than one SFI0 part is present in the file");
79 uint64_t FlagValue = 0;
80 if (Error Err = readInteger(Part, Part.begin(), FlagValue))
81 return Err;
82 ShaderFeatureFlags = FlagValue;
83 return Error::success();
84}
85
86Error DXContainer::parseHash(StringRef Part) {
87 if (Hash)
88 return parseFailed("More than one HASH part is present in the file");
89 dxbc::ShaderHash ReadHash;
90 if (Error Err = readStruct(Part, Part.begin(), ReadHash))
91 return Err;
92 Hash = ReadHash;
93 return Error::success();
94}
95
96Error DXContainer::parseRootSignature(StringRef Part) {
97 if (RootSignature)
98 return parseFailed("More than one RTS0 part is present in the file");
99 RootSignature = DirectX::RootSignature(Part);
100 if (Error Err = RootSignature->parse())
101 return Err;
102 return Error::success();
103}
104
105Error DXContainer::parsePSVInfo(StringRef Part) {
106 if (PSVInfo)
107 return parseFailed("More than one PSV0 part is present in the file");
108 PSVInfo = DirectX::PSVRuntimeInfo(Part);
109 // Parsing the PSVRuntime info occurs late because we need to read data from
110 // other parts first.
111 return Error::success();
112}
113
116 if (Error Err = readStruct(Part, Part.begin(), SigHeader))
117 return Err;
118 size_t Size = sizeof(dxbc::ProgramSignatureElement) * SigHeader.ParamCount;
119
120 if (Part.size() < Size + SigHeader.FirstParamOffset)
121 return parseFailed("Signature parameters extend beyond the part boundary");
122
123 Parameters.Data = Part.substr(SigHeader.FirstParamOffset, Size);
124
125 StringTableOffset = SigHeader.FirstParamOffset + static_cast<uint32_t>(Size);
126 StringTable = Part.substr(SigHeader.FirstParamOffset + Size);
127
128 for (const auto &Param : Parameters) {
129 if (Param.NameOffset < StringTableOffset)
130 return parseFailed("Invalid parameter name offset: name starts before "
131 "the first name offset");
132 if (Param.NameOffset - StringTableOffset > StringTable.size())
133 return parseFailed("Invalid parameter name offset: name starts after the "
134 "end of the part data");
135 }
136 return Error::success();
137}
138
139Error DXContainer::parsePartOffsets() {
140 uint32_t LastOffset =
141 sizeof(dxbc::Header) + (Header.PartCount * sizeof(uint32_t));
142 const char *Current = Data.getBuffer().data() + sizeof(dxbc::Header);
143 for (uint32_t Part = 0; Part < Header.PartCount; ++Part) {
144 uint32_t PartOffset;
145 if (Error Err = readInteger(Data.getBuffer(), Current, PartOffset))
146 return Err;
147 if (PartOffset < LastOffset)
148 return parseFailed(
149 formatv(
150 "Part offset for part {0} begins before the previous part ends",
151 Part)
152 .str());
153 Current += sizeof(uint32_t);
154 if (PartOffset >= Data.getBufferSize())
155 return parseFailed("Part offset points beyond boundary of the file");
156 // To prevent overflow when reading the part name, we subtract the part name
157 // size from the buffer size, rather than adding to the offset. Since the
158 // file header is larger than the part header we can't reach this code
159 // unless the buffer is at least as large as a part header, so this
160 // subtraction can't underflow.
161 if (PartOffset >= Data.getBufferSize() - sizeof(dxbc::PartHeader::Name))
162 return parseFailed("File not large enough to read part name");
163 PartOffsets.push_back(PartOffset);
164
165 dxbc::PartType PT =
166 dxbc::parsePartType(Data.getBuffer().substr(PartOffset, 4));
167 uint32_t PartDataStart = PartOffset + sizeof(dxbc::PartHeader);
168 uint32_t PartSize;
169 if (Error Err = readInteger(Data.getBuffer(),
170 Data.getBufferStart() + PartOffset + 4,
171 PartSize, "part size"))
172 return Err;
173 StringRef PartData = Data.getBuffer().substr(PartDataStart, PartSize);
174 LastOffset = PartOffset + PartSize;
175 switch (PT) {
176 case dxbc::PartType::DXIL:
177 if (Error Err = parseDXILHeader(PartData))
178 return Err;
179 break;
180 case dxbc::PartType::SFI0:
181 if (Error Err = parseShaderFeatureFlags(PartData))
182 return Err;
183 break;
184 case dxbc::PartType::HASH:
185 if (Error Err = parseHash(PartData))
186 return Err;
187 break;
188 case dxbc::PartType::PSV0:
189 if (Error Err = parsePSVInfo(PartData))
190 return Err;
191 break;
192 case dxbc::PartType::ISG1:
193 if (Error Err = InputSignature.initialize(PartData))
194 return Err;
195 break;
196 case dxbc::PartType::OSG1:
197 if (Error Err = OutputSignature.initialize(PartData))
198 return Err;
199 break;
200 case dxbc::PartType::PSG1:
201 if (Error Err = PatchConstantSignature.initialize(PartData))
202 return Err;
203 break;
205 break;
206 case dxbc::PartType::RTS0:
207 if (Error Err = parseRootSignature(PartData))
208 return Err;
209 break;
210 }
211 }
212
213 // Fully parsing the PSVInfo requires knowing the shader kind which we read
214 // out of the program header in the DXIL part.
215 if (PSVInfo) {
216 if (!DXIL)
217 return parseFailed("Cannot fully parse pipeline state validation "
218 "information without DXIL part.");
219 if (Error Err = PSVInfo->parse(DXIL->first.ShaderKind))
220 return Err;
221 }
222 return Error::success();
223}
224
226 DXContainer Container(Object);
227 if (Error Err = Container.parseHeader())
228 return std::move(Err);
229 if (Error Err = Container.parsePartOffsets())
230 return std::move(Err);
231 return Container;
232}
233
234void DXContainer::PartIterator::updateIteratorImpl(const uint32_t Offset) {
235 StringRef Buffer = Container.Data.getBuffer();
236 const char *Current = Buffer.data() + Offset;
237 // Offsets are validated during parsing, so all offsets in the container are
238 // valid and contain enough readable data to read a header.
239 cantFail(readStruct(Buffer, Current, IteratorState.Part));
240 IteratorState.Data =
241 StringRef(Current + sizeof(dxbc::PartHeader), IteratorState.Part.Size);
242 IteratorState.Offset = Offset;
243}
244
246 const char *Current = PartData.begin();
247
248 // Root Signature headers expects 6 integers to be present.
249 if (PartData.size() < 6 * sizeof(uint32_t))
250 return parseFailed(
251 "Invalid root signature, insufficient space for header.");
252
253 Version = support::endian::read<uint32_t, llvm::endianness::little>(Current);
254 Current += sizeof(uint32_t);
255
256 NumParameters =
257 support::endian::read<uint32_t, llvm::endianness::little>(Current);
258 Current += sizeof(uint32_t);
259
260 RootParametersOffset =
261 support::endian::read<uint32_t, llvm::endianness::little>(Current);
262 Current += sizeof(uint32_t);
263
264 NumStaticSamplers =
265 support::endian::read<uint32_t, llvm::endianness::little>(Current);
266 Current += sizeof(uint32_t);
267
268 StaticSamplersOffset =
269 support::endian::read<uint32_t, llvm::endianness::little>(Current);
270 Current += sizeof(uint32_t);
271
272 Flags = support::endian::read<uint32_t, llvm::endianness::little>(Current);
273 Current += sizeof(uint32_t);
274
275 ParametersHeaders.Data = PartData.substr(
276 RootParametersOffset,
277 NumParameters * sizeof(dxbc::RTS0::v1::RootParameterHeader));
278
279 StaticSamplers.Stride = sizeof(dxbc::RTS0::v1::StaticSampler);
280 StaticSamplers.Data = PartData.substr(
281 StaticSamplersOffset,
282 NumStaticSamplers * sizeof(dxbc::RTS0::v1::StaticSampler));
283
284 return Error::success();
285}
286
288 Triple::EnvironmentType ShaderStage = dxbc::getShaderStage(ShaderKind);
289
290 const char *Current = Data.begin();
291 if (Error Err = readInteger(Data, Current, Size))
292 return Err;
293 Current += sizeof(uint32_t);
294
295 StringRef PSVInfoData = Data.substr(sizeof(uint32_t), Size);
296
297 if (PSVInfoData.size() < Size)
298 return parseFailed(
299 "Pipeline state data extends beyond the bounds of the part");
300
301 using namespace dxbc::PSV;
302
303 const uint32_t PSVVersion = getVersion();
304
305 // Detect the PSVVersion by looking at the size field.
306 if (PSVVersion == 3) {
307 v3::RuntimeInfo Info;
308 if (Error Err = readStruct(PSVInfoData, Current, Info))
309 return Err;
311 Info.swapBytes(ShaderStage);
312 BasicInfo = Info;
313 } else if (PSVVersion == 2) {
314 v2::RuntimeInfo Info;
315 if (Error Err = readStruct(PSVInfoData, Current, Info))
316 return Err;
318 Info.swapBytes(ShaderStage);
319 BasicInfo = Info;
320 } else if (PSVVersion == 1) {
321 v1::RuntimeInfo Info;
322 if (Error Err = readStruct(PSVInfoData, Current, Info))
323 return Err;
325 Info.swapBytes(ShaderStage);
326 BasicInfo = Info;
327 } else if (PSVVersion == 0) {
328 v0::RuntimeInfo Info;
329 if (Error Err = readStruct(PSVInfoData, Current, Info))
330 return Err;
332 Info.swapBytes(ShaderStage);
333 BasicInfo = Info;
334 } else
335 return parseFailed(
336 "Cannot read PSV Runtime Info, unsupported PSV version.");
337
338 Current += Size;
339
340 uint32_t ResourceCount = 0;
341 if (Error Err = readInteger(Data, Current, ResourceCount))
342 return Err;
343 Current += sizeof(uint32_t);
344
345 if (ResourceCount > 0) {
346 if (Error Err = readInteger(Data, Current, Resources.Stride))
347 return Err;
348 Current += sizeof(uint32_t);
349
350 size_t BindingDataSize = Resources.Stride * ResourceCount;
351 Resources.Data = Data.substr(Current - Data.begin(), BindingDataSize);
352
353 if (Resources.Data.size() < BindingDataSize)
354 return parseFailed(
355 "Resource binding data extends beyond the bounds of the part");
356
357 Current += BindingDataSize;
358 } else
359 Resources.Stride = sizeof(v2::ResourceBindInfo);
360
361 // PSV version 0 ends after the resource bindings.
362 if (PSVVersion == 0)
363 return Error::success();
364
365 // String table starts at a 4-byte offset.
366 Current = reinterpret_cast<const char *>(
367 alignTo<4>(reinterpret_cast<uintptr_t>(Current)));
368
369 uint32_t StringTableSize = 0;
370 if (Error Err = readInteger(Data, Current, StringTableSize))
371 return Err;
372 if (StringTableSize % 4 != 0)
373 return parseFailed("String table misaligned");
374 Current += sizeof(uint32_t);
375 StringTable = StringRef(Current, StringTableSize);
376
377 Current += StringTableSize;
378
379 uint32_t SemanticIndexTableSize = 0;
380 if (Error Err = readInteger(Data, Current, SemanticIndexTableSize))
381 return Err;
382 Current += sizeof(uint32_t);
383
384 SemanticIndexTable.reserve(SemanticIndexTableSize);
385 for (uint32_t I = 0; I < SemanticIndexTableSize; ++I) {
386 uint32_t Index = 0;
387 if (Error Err = readInteger(Data, Current, Index))
388 return Err;
389 Current += sizeof(uint32_t);
390 SemanticIndexTable.push_back(Index);
391 }
392
393 uint8_t InputCount = getSigInputCount();
394 uint8_t OutputCount = getSigOutputCount();
395 uint8_t PatchOrPrimCount = getSigPatchOrPrimCount();
396
397 uint32_t ElementCount = InputCount + OutputCount + PatchOrPrimCount;
398
399 if (ElementCount > 0) {
400 if (Error Err = readInteger(Data, Current, SigInputElements.Stride))
401 return Err;
402 Current += sizeof(uint32_t);
403 // Assign the stride to all the arrays.
404 SigOutputElements.Stride = SigPatchOrPrimElements.Stride =
405 SigInputElements.Stride;
406
407 if (Data.end() - Current <
408 (ptrdiff_t)(ElementCount * SigInputElements.Stride))
409 return parseFailed(
410 "Signature elements extend beyond the size of the part");
411
412 size_t InputSize = SigInputElements.Stride * InputCount;
413 SigInputElements.Data = Data.substr(Current - Data.begin(), InputSize);
414 Current += InputSize;
415
416 size_t OutputSize = SigOutputElements.Stride * OutputCount;
417 SigOutputElements.Data = Data.substr(Current - Data.begin(), OutputSize);
418 Current += OutputSize;
419
420 size_t PSize = SigPatchOrPrimElements.Stride * PatchOrPrimCount;
421 SigPatchOrPrimElements.Data = Data.substr(Current - Data.begin(), PSize);
422 Current += PSize;
423 }
424
425 ArrayRef<uint8_t> OutputVectorCounts = getOutputVectorCounts();
426 uint8_t PatchConstOrPrimVectorCount = getPatchConstOrPrimVectorCount();
427 uint8_t InputVectorCount = getInputVectorCount();
428
429 auto maskDwordSize = [](uint8_t Vector) {
430 return (static_cast<uint32_t>(Vector) + 7) >> 3;
431 };
432
433 auto mapTableSize = [maskDwordSize](uint8_t X, uint8_t Y) {
434 return maskDwordSize(Y) * X * 4;
435 };
436
437 if (usesViewID()) {
438 for (uint32_t I = 0; I < OutputVectorCounts.size(); ++I) {
439 // The vector mask is one bit per component and 4 components per vector.
440 // We can compute the number of dwords required by rounding up to the next
441 // multiple of 8.
442 uint32_t NumDwords =
443 maskDwordSize(static_cast<uint32_t>(OutputVectorCounts[I]));
444 size_t NumBytes = NumDwords * sizeof(uint32_t);
445 OutputVectorMasks[I].Data = Data.substr(Current - Data.begin(), NumBytes);
446 Current += NumBytes;
447 }
448
449 if (ShaderStage == Triple::Hull && PatchConstOrPrimVectorCount > 0) {
450 uint32_t NumDwords = maskDwordSize(PatchConstOrPrimVectorCount);
451 size_t NumBytes = NumDwords * sizeof(uint32_t);
452 PatchOrPrimMasks.Data = Data.substr(Current - Data.begin(), NumBytes);
453 Current += NumBytes;
454 }
455 }
456
457 // Input/Output mapping table
458 for (uint32_t I = 0; I < OutputVectorCounts.size(); ++I) {
459 if (InputVectorCount == 0 || OutputVectorCounts[I] == 0)
460 continue;
461 uint32_t NumDwords = mapTableSize(InputVectorCount, OutputVectorCounts[I]);
462 size_t NumBytes = NumDwords * sizeof(uint32_t);
463 InputOutputMap[I].Data = Data.substr(Current - Data.begin(), NumBytes);
464 Current += NumBytes;
465 }
466
467 // Hull shader: Input/Patch mapping table
468 if (ShaderStage == Triple::Hull && PatchConstOrPrimVectorCount > 0 &&
469 InputVectorCount > 0) {
470 uint32_t NumDwords =
471 mapTableSize(InputVectorCount, PatchConstOrPrimVectorCount);
472 size_t NumBytes = NumDwords * sizeof(uint32_t);
473 InputPatchMap.Data = Data.substr(Current - Data.begin(), NumBytes);
474 Current += NumBytes;
475 }
476
477 // Domain Shader: Patch/Output mapping table
478 if (ShaderStage == Triple::Domain && PatchConstOrPrimVectorCount > 0 &&
479 OutputVectorCounts[0] > 0) {
480 uint32_t NumDwords =
481 mapTableSize(PatchConstOrPrimVectorCount, OutputVectorCounts[0]);
482 size_t NumBytes = NumDwords * sizeof(uint32_t);
483 PatchOutputMap.Data = Data.substr(Current - Data.begin(), NumBytes);
484 Current += NumBytes;
485 }
486
487 return Error::success();
488}
489
491 if (const auto *P = std::get_if<dxbc::PSV::v3::RuntimeInfo>(&BasicInfo))
492 return P->SigInputElements;
493 if (const auto *P = std::get_if<dxbc::PSV::v2::RuntimeInfo>(&BasicInfo))
494 return P->SigInputElements;
495 if (const auto *P = std::get_if<dxbc::PSV::v1::RuntimeInfo>(&BasicInfo))
496 return P->SigInputElements;
497 return 0;
498}
499
501 if (const auto *P = std::get_if<dxbc::PSV::v3::RuntimeInfo>(&BasicInfo))
502 return P->SigOutputElements;
503 if (const auto *P = std::get_if<dxbc::PSV::v2::RuntimeInfo>(&BasicInfo))
504 return P->SigOutputElements;
505 if (const auto *P = std::get_if<dxbc::PSV::v1::RuntimeInfo>(&BasicInfo))
506 return P->SigOutputElements;
507 return 0;
508}
509
511 if (const auto *P = std::get_if<dxbc::PSV::v3::RuntimeInfo>(&BasicInfo))
512 return P->SigPatchOrPrimElements;
513 if (const auto *P = std::get_if<dxbc::PSV::v2::RuntimeInfo>(&BasicInfo))
514 return P->SigPatchOrPrimElements;
515 if (const auto *P = std::get_if<dxbc::PSV::v1::RuntimeInfo>(&BasicInfo))
516 return P->SigPatchOrPrimElements;
517 return 0;
518}
519
520class DXNotSupportedError : public ErrorInfo<DXNotSupportedError> {
521public:
522 static char ID;
523
524 DXNotSupportedError(StringRef S) : FeatureString(S) {}
525
526 void log(raw_ostream &OS) const override {
527 OS << "DXContainer does not support " << FeatureString;
528 }
529
530 std::error_code convertToErrorCode() const override {
531 return inconvertibleErrorCode();
532 }
533
534private:
535 StringRef FeatureString;
536};
537
539
542 return make_error<DXNotSupportedError>("Symbol sections");
543}
544
546 return make_error<DXNotSupportedError>("Symbol names");
547}
548
551 return make_error<DXNotSupportedError>("Symbol addresses");
552}
553
555 llvm_unreachable("DXContainer does not support symbols");
556}
559 llvm_unreachable("DXContainer does not support symbols");
560}
561
564 return make_error<DXNotSupportedError>("Symbol types");
565}
566
568 PartIterator It = reinterpret_cast<PartIterator>(Sec.p);
569 if (It == Parts.end())
570 return;
571
572 ++It;
573 Sec.p = reinterpret_cast<uintptr_t>(It);
574}
575
578 PartIterator It = reinterpret_cast<PartIterator>(Sec.p);
579 return StringRef(It->Part.getName());
580}
581
583 PartIterator It = reinterpret_cast<PartIterator>(Sec.p);
584 return It->Offset;
585}
586
588 return (Sec.p - reinterpret_cast<uintptr_t>(Parts.begin())) /
589 sizeof(PartIterator);
590}
591
593 PartIterator It = reinterpret_cast<PartIterator>(Sec.p);
594 return It->Data.size();
595}
598 PartIterator It = reinterpret_cast<PartIterator>(Sec.p);
599 return ArrayRef<uint8_t>(It->Data.bytes_begin(), It->Data.size());
600}
601
603 return 1;
604}
605
607 return false;
608}
609
611 return false;
612}
613
615 return false;
616}
617
619 return false;
620}
621
623 return false;
624}
625
629}
630
634}
635
637 llvm_unreachable("DXContainer does not support relocations");
638}
639
641 llvm_unreachable("DXContainer does not support relocations");
642}
643
646 return symbol_iterator(SymbolRef());
647}
648
650 llvm_unreachable("DXContainer does not support relocations");
651}
652
654 DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
655 llvm_unreachable("DXContainer does not support relocations");
656}
657
659 DataRefImpl Sec;
660 Sec.p = reinterpret_cast<uintptr_t>(Parts.begin());
661 return section_iterator(SectionRef(Sec, this));
662}
664 DataRefImpl Sec;
665 Sec.p = reinterpret_cast<uintptr_t>(Parts.end());
666 return section_iterator(SectionRef(Sec, this));
667}
668
670
672 return "DirectX Container";
673}
674
676
678 return SubtargetFeatures();
679}
680
682 DataRefImpl Symb) const {
683 return make_error<DXNotSupportedError>("Symbol names");
684}
685
688 return make_error<DXNotSupportedError>("Symbol flags");
689}
690
693 auto ExC = DXContainer::create(Object);
694 if (!ExC)
695 return ExC.takeError();
696 std::unique_ptr<DXContainerObjectFile> Obj(new DXContainerObjectFile(*ExC));
697 return std::move(Obj);
698}
#define offsetof(TYPE, MEMBER)
write Write Bitcode
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
uint64_t Size
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
#define I(x, y, z)
Definition: MD5.cpp:58
static Error parseFailed(const Twine &Msg)
Definition: DXContainer.cpp:19
static Error readStruct(StringRef Buffer, const char *Src, T &Struct)
Definition: DXContainer.cpp:24
static Error readInteger(StringRef Buffer, const char *Src, T &Val, Twine Str="structure")
Definition: DXContainer.cpp:37
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
#define P(N)
if(PassOpts->AAPipeline)
raw_pwrite_stream & OS
@ Struct
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
DXNotSupportedError(StringRef S)
void log(raw_ostream &OS) const override
Print an error message to an output stream.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:147
Base class for user error types.
Definition: Error.h:354
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
static ErrorSuccess success()
Create a success value.
Definition: Error.h:336
Tagged union holding either a T or a Error.
Definition: Error.h:485
StringRef getBuffer() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:581
iterator begin() const
Definition: StringRef.h:120
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:154
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:148
iterator end() const
Definition: StringRef.h:122
A table of densely packed, null-terminated strings indexed by offset.
Definition: StringTable.h:33
constexpr size_t size() const
Returns the byte size of the table.
Definition: StringTable.h:101
Manages the enabling and disabling of subtarget specific features.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:82
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
Definition: Twine.cpp:17
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
uint64_t getRelocationOffset(DataRefImpl Rel) const override
uint64_t getSectionSize(DataRefImpl Sec) const override
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
Triple::ArchType getArch() const override
bool isSectionCompressed(DataRefImpl Sec) const override
section_iterator section_end() const override
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
uint64_t getSectionIndex(DataRefImpl Sec) const override
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
uint64_t getSectionAddress(DataRefImpl Sec) const override
Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const override
section_iterator section_begin() const override
bool isSectionVirtual(DataRefImpl Sec) const override
void moveRelocationNext(DataRefImpl &Rel) const override
relocation_iterator section_rel_end(DataRefImpl Sec) const override
void moveSectionNext(DataRefImpl &Sec) const override
bool isSectionData(DataRefImpl Sec) const override
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
StringRef getFileFormatName() const override
uint64_t getSectionAlignment(DataRefImpl Sec) const override
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
uint64_t getRelocationType(DataRefImpl Rel) const override
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
bool isSectionBSS(DataRefImpl Sec) const override
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
bool isSectionText(DataRefImpl Sec) const override
Expected< SubtargetFeatures > getFeatures() const override
Expected< StringRef > getSymbolName(DataRefImpl) const override
static LLVM_ABI Expected< DXContainer > create(MemoryBufferRef Object)
LLVM_ABI uint8_t getSigInputCount() const
LLVM_ABI uint8_t getSigPatchOrPrimCount() const
LLVM_ABI Error parse(uint16_t ShaderKind)
LLVM_ABI uint8_t getSigOutputCount() const
LLVM_ABI Error initialize(StringRef Part)
static Expected< std::unique_ptr< DXContainerObjectFile > > createDXContainerObjectFile(MemoryBufferRef Object)
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:54
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:83
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:170
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI PartType parsePartType(StringRef S)
Definition: DXContainer.cpp:21
Triple::EnvironmentType getShaderStage(uint32_t Kind)
Definition: DXContainer.h:47
static Error parseFailed(const Twine &Msg)
Definition: DXContainer.h:217
content_iterator< SectionRef > section_iterator
Definition: ObjectFile.h:49
content_iterator< RelocationRef > relocation_iterator
Definition: ObjectFile.h:79
constexpr bool IsBigEndianHost
Definition: SwapByteOrder.h:26
void swapByteOrder(T &Value)
Definition: SwapByteOrder.h:61
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:98
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:769
Use this type to describe the size and type of a DXIL container part.
Definition: DXContainer.h:99