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"
22#include <cstdint>
23#include <optional>
24#include <string>
25#include <vector>
26
27namespace llvm {
28namespace DXContainerYAML {
29
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.
38struct FileHeader {
39 std::vector<llvm::yaml::Hex8> Hash;
41 std::optional<uint32_t> FileSize;
43 std::optional<std::vector<uint32_t>> PartOffsets;
44};
45
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;
60 ShaderFlags() = default;
61 ShaderFlags(uint64_t FlagData);
63#include "llvm/BinaryFormat/DXContainerConstants.def"
64};
65
66struct ShaderHash {
67 ShaderHash() = default;
69
71 std::vector<llvm::yaml::Hex8> Digest;
72};
73
75
76struct PSVInfo {
77 // The version field isn't actually encoded in the file, but it is inferred by
78 // the size of data regions. We include it in the yaml because it simplifies
79 // the format.
81
83 std::vector<ResourceBindInfo> Resources;
84
85 void mapInfoForVersion(yaml::IO &IO);
86
87 PSVInfo();
91};
92
93struct Part {
94 Part() = default;
95 Part(std::string N, uint32_t S) : Name(N), Size(S) {}
96 std::string Name;
98 std::optional<DXILProgram> Program;
99 std::optional<ShaderFlags> Flags;
100 std::optional<ShaderHash> Hash;
101 std::optional<PSVInfo> Info;
102};
103
104struct Object {
106 std::vector<Part> Parts;
107};
108
109} // namespace DXContainerYAML
110} // namespace llvm
111
114namespace llvm {
115
116class raw_ostream;
117
118namespace yaml {
119
120template <> struct MappingTraits<DXContainerYAML::VersionTuple> {
121 static void mapping(IO &IO, DXContainerYAML::VersionTuple &Version);
122};
123
124template <> struct MappingTraits<DXContainerYAML::FileHeader> {
125 static void mapping(IO &IO, DXContainerYAML::FileHeader &Header);
126};
127
128template <> struct MappingTraits<DXContainerYAML::DXILProgram> {
129 static void mapping(IO &IO, DXContainerYAML::DXILProgram &Program);
130};
131
132template <> struct MappingTraits<DXContainerYAML::ShaderFlags> {
133 static void mapping(IO &IO, DXContainerYAML::ShaderFlags &Flags);
134};
135
136template <> struct MappingTraits<DXContainerYAML::ShaderHash> {
137 static void mapping(IO &IO, DXContainerYAML::ShaderHash &Hash);
138};
139
140template <> struct MappingTraits<DXContainerYAML::PSVInfo> {
141 static void mapping(IO &IO, DXContainerYAML::PSVInfo &PSV);
142};
143
144template <> struct MappingTraits<DXContainerYAML::Part> {
145 static void mapping(IO &IO, DXContainerYAML::Part &Version);
146};
147
148template <> struct MappingTraits<DXContainerYAML::Object> {
149 static void mapping(IO &IO, DXContainerYAML::Object &Obj);
150};
151
152template <> struct MappingTraits<DXContainerYAML::ResourceBindInfo> {
153 static void mapping(IO &IO, DXContainerYAML::ResourceBindInfo &Res);
154};
155
156} // namespace yaml
157
158} // namespace llvm
159
160#endif // LLVM_OBJECTYAML_DXCONTAINERYAML_H
#define P(N)
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:31
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
#define N
std::optional< uint32_t > DXILOffset
std::optional< uint32_t > Size
std::optional< std::vector< llvm::yaml::Hex8 > > DXIL
std::optional< uint32_t > DXILSize
std::vector< llvm::yaml::Hex8 > Hash
std::optional< uint32_t > FileSize
std::optional< std::vector< uint32_t > > PartOffsets
std::vector< ResourceBindInfo > Resources
dxbc::PSV::v2::RuntimeInfo Info
void mapInfoForVersion(yaml::IO &IO)
std::optional< PSVInfo > Info
std::optional< ShaderFlags > Flags
std::optional< DXILProgram > Program
std::optional< ShaderHash > Hash
Part(std::string N, uint32_t S)
std::vector< llvm::yaml::Hex8 > Digest