Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 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"
19
#include "llvm/BinaryFormat/DXContainer.h"
20
#include "llvm/ObjectYAML/YAML.h"
21
#include "llvm/Support/YAMLTraits.h"
22
#include <cstdint>
23
#include <optional>
24
#include <string>
25
#include <vector>
26
 
27
namespace llvm {
28
namespace DXContainerYAML {
29
 
30
struct VersionTuple {
31
  uint16_t Major;
32
  uint16_t Minor;
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;
40
  VersionTuple Version;
41
  std::optional<uint32_t> FileSize;
42
  uint32_t PartCount;
43
  std::optional<std::vector<uint32_t>> PartOffsets;
44
};
45
 
46
struct DXILProgram {
47
  uint8_t MajorVersion;
48
  uint8_t MinorVersion;
49
  uint16_t ShaderKind;
50
  std::optional<uint32_t> Size;
51
  uint16_t DXILMajorVersion;
52
  uint16_t DXILMinorVersion;
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);
62
  uint64_t getEncodedFlags();
63
#include "llvm/BinaryFormat/DXContainerConstants.def"
64
};
65
 
66
struct ShaderHash {
67
  ShaderHash() = default;
68
  ShaderHash(const dxbc::ShaderHash &Data);
69
 
70
  bool IncludesSource;
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;
78
  uint32_t Size;
79
  std::optional<DXILProgram> Program;
80
  std::optional<ShaderFlags> Flags;
81
  std::optional<ShaderHash> Hash;
82
};
83
 
84
struct Object {
85
  FileHeader Header;
86
  std::vector<Part> Parts;
87
};
88
 
89
} // namespace DXContainerYAML
90
} // namespace llvm
91
 
92
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::Part)
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