LLVM  17.0.0git
DXContainerYAML.h
Go to the documentation of this file.
1 //===- DXContainerYAML.h - DXContainer YAMLIO implementation ----*- C++ -*-===//
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 /// \file
10 /// This file declares classes for handling the YAML representation
11 /// of DXContainer.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_OBJECTYAML_DXCONTAINERYAML_H
16 #define LLVM_OBJECTYAML_DXCONTAINERYAML_H
17 
18 #include "llvm/ADT/StringRef.h"
20 #include "llvm/ObjectYAML/YAML.h"
22 #include <cstdint>
23 #include <optional>
24 #include <string>
25 #include <vector>
26 
27 namespace llvm {
28 namespace DXContainerYAML {
29 
30 struct VersionTuple {
33 };
34 
35 // The optional header fields are required in the binary and will be populated
36 // when reading from binary, but can be omitted in the YAML text because the
37 // emitter can calculate them.
38 struct FileHeader {
39  std::vector<llvm::yaml::Hex8> Hash;
41  std::optional<uint32_t> FileSize;
43  std::optional<std::vector<uint32_t>> PartOffsets;
44 };
45 
46 struct DXILProgram {
47  uint8_t MajorVersion;
48  uint8_t MinorVersion;
50  std::optional<uint32_t> Size;
53  std::optional<uint32_t> DXILOffset;
54  std::optional<uint32_t> DXILSize;
55  std::optional<std::vector<llvm::yaml::Hex8>> DXIL;
56 };
57 
58 #define SHADER_FLAG(Num, Val, Str) bool Val = false;
59 struct ShaderFlags {
60  ShaderFlags() = default;
61  ShaderFlags(uint64_t FlagData);
63 #include "llvm/BinaryFormat/DXContainerConstants.def"
64 };
65 
66 struct ShaderHash {
67  ShaderHash() = default;
69 
71  std::vector<llvm::yaml::Hex8> Digest;
72 };
73 
74 struct Part {
75  Part() = default;
76  Part(std::string N, uint32_t S) : Name(N), Size(S) {}
77  std::string Name;
79  std::optional<DXILProgram> Program;
80  std::optional<ShaderFlags> Flags;
81  std::optional<ShaderHash> Hash;
82 };
83 
84 struct Object {
86  std::vector<Part> Parts;
87 };
88 
89 } // namespace DXContainerYAML
90 } // namespace llvm
91 
93 namespace llvm {
94 
95 class raw_ostream;
96 
97 namespace yaml {
98 
99 template <> struct MappingTraits<DXContainerYAML::VersionTuple> {
100  static void mapping(IO &IO, DXContainerYAML::VersionTuple &Version);
101 };
102 
103 template <> struct MappingTraits<DXContainerYAML::FileHeader> {
104  static void mapping(IO &IO, DXContainerYAML::FileHeader &Header);
105 };
106 
107 template <> struct MappingTraits<DXContainerYAML::DXILProgram> {
108  static void mapping(IO &IO, DXContainerYAML::DXILProgram &Program);
109 };
110 
111 template <> struct MappingTraits<DXContainerYAML::ShaderFlags> {
112  static void mapping(IO &IO, DXContainerYAML::ShaderFlags &Flags);
113 };
114 
115 template <> struct MappingTraits<DXContainerYAML::ShaderHash> {
116  static void mapping(IO &IO, DXContainerYAML::ShaderHash &Hash);
117 };
118 
119 template <> struct MappingTraits<DXContainerYAML::Part> {
120  static void mapping(IO &IO, DXContainerYAML::Part &Version);
121 };
122 
123 template <> struct MappingTraits<DXContainerYAML::Object> {
124  static void mapping(IO &IO, DXContainerYAML::Object &Obj);
125 };
126 
127 } // namespace yaml
128 
129 } // namespace llvm
130 
131 #endif // LLVM_OBJECTYAML_DXCONTAINERYAML_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::DXContainerYAML::ShaderHash
Definition: DXContainerYAML.h:66
StringRef.h
llvm::DXContainerYAML::Object::Parts
std::vector< Part > Parts
Definition: DXContainerYAML.h:86
LLVM_YAML_IS_SEQUENCE_VECTOR
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
llvm::DXContainerYAML::FileHeader::PartOffsets
std::optional< std::vector< uint32_t > > PartOffsets
Definition: DXContainerYAML.h:43
llvm::DXContainerYAML::ShaderHash::ShaderHash
ShaderHash()=default
llvm::DXContainerYAML::Part::Part
Part()=default
llvm::yaml::MappingTraits
Definition: ModuleSummaryIndex.h:53
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::DXContainerYAML::DXILProgram::DXILSize
std::optional< uint32_t > DXILSize
Definition: DXContainerYAML.h:54
llvm::DXContainerYAML::Part::Size
uint32_t Size
Definition: DXContainerYAML.h:78
llvm::DXContainerYAML::DXILProgram::MinorVersion
uint8_t MinorVersion
Definition: DXContainerYAML.h:48
llvm::DXContainerYAML::VersionTuple
Definition: DXContainerYAML.h:30
llvm::DXContainerYAML::Part::Name
std::string Name
Definition: DXContainerYAML.h:77
llvm::DXContainerYAML::Part::Flags
std::optional< ShaderFlags > Flags
Definition: DXContainerYAML.h:80
llvm::DXContainerYAML::Object::Header
FileHeader Header
Definition: DXContainerYAML.h:85
llvm::DXContainerYAML::Part::Part
Part(std::string N, uint32_t S)
Definition: DXContainerYAML.h:76
YAML.h
llvm::DXContainerYAML::FileHeader::Hash
std::vector< llvm::yaml::Hex8 > Hash
Definition: DXContainerYAML.h:39
llvm::VersionTuple
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:31
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:1058
llvm::OutputFileType::Object
@ Object
uint64_t
llvm::DXContainerYAML::ShaderFlags::ShaderFlags
ShaderFlags()=default
llvm::DXContainerYAML::DXILProgram::MajorVersion
uint8_t MajorVersion
Definition: DXContainerYAML.h:47
llvm::DXContainerYAML::DXILProgram::DXIL
std::optional< std::vector< llvm::yaml::Hex8 > > DXIL
Definition: DXContainerYAML.h:55
llvm::DXContainerYAML::DXILProgram::DXILMinorVersion
uint16_t DXILMinorVersion
Definition: DXContainerYAML.h:52
llvm::DXContainerYAML::ShaderFlags::getEncodedFlags
uint64_t getEncodedFlags()
Definition: DXContainerYAML.cpp:30
DXContainer.h
llvm::DXContainerYAML::DXILProgram::ShaderKind
uint16_t ShaderKind
Definition: DXContainerYAML.h:49
llvm::DXContainerYAML::Part::Program
std::optional< DXILProgram > Program
Definition: DXContainerYAML.h:79
YAMLTraits.h
llvm::DXContainerYAML::FileHeader
Definition: DXContainerYAML.h:38
llvm::DXContainerYAML::DXILProgram::DXILOffset
std::optional< uint32_t > DXILOffset
Definition: DXContainerYAML.h:53
uint32_t
llvm::DXContainerYAML::DXILProgram::Size
std::optional< uint32_t > Size
Definition: DXContainerYAML.h:50
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::DXContainerYAML::Part::Hash
std::optional< ShaderHash > Hash
Definition: DXContainerYAML.h:81
llvm::DXContainerYAML::DXILProgram
Definition: DXContainerYAML.h:46
llvm::DXContainerYAML::FileHeader::PartCount
uint32_t PartCount
Definition: DXContainerYAML.h:42
llvm::DXContainerYAML::ShaderFlags
Definition: DXContainerYAML.h:59
llvm::DXContainerYAML::Object
Definition: DXContainerYAML.h:84
uint16_t
llvm::DXContainerYAML::ShaderHash::IncludesSource
bool IncludesSource
Definition: DXContainerYAML.h:70
llvm::DXContainerYAML::ShaderHash::Digest
std::vector< llvm::yaml::Hex8 > Digest
Definition: DXContainerYAML.h:71
llvm::DXContainerYAML::VersionTuple::Minor
uint16_t Minor
Definition: DXContainerYAML.h:32
llvm::DXContainerYAML::DXILProgram::DXILMajorVersion
uint16_t DXILMajorVersion
Definition: DXContainerYAML.h:51
N
#define N
llvm::DXContainerYAML::VersionTuple::Major
uint16_t Major
Definition: DXContainerYAML.h:31
llvm::DXContainerYAML::FileHeader::FileSize
std::optional< uint32_t > FileSize
Definition: DXContainerYAML.h:41
llvm::dxbc::ShaderHash
Definition: DXContainer.h:49
llvm::DXContainerYAML::Part
Definition: DXContainerYAML.h:74
llvm::DXContainerYAML::FileHeader::Version
VersionTuple Version
Definition: DXContainerYAML.h:40