1 //===- llvm/MC/DXContainerPSVInfo.h - DXContainer PSVInfo -*- 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 #ifndef LLVM_MC_DXCONTAINERPSVINFO_H
10 #define LLVM_MC_DXCONTAINERPSVINFO_H
11 
12 #include "llvm/BinaryFormat/DXContainer.h"
13 #include "llvm/TargetParser/Triple.h"
14 
15 #include <numeric>
16 #include <stdint.h>
17 #include <vector>
18 
19 namespace llvm {
20 
21 class raw_ostream;
22 
23 namespace mcdxbc {
24 // This data structure is a helper for reading and writing PSV RuntimeInfo data.
25 // It is implemented in the BinaryFormat library so that it can be used by both
26 // the MC layer and Object tools.
27 // This structure is used to represent the extracted data in an inspectable and
28 // modifiable format, and can be used to serialize the data back into valid PSV
29 // RuntimeInfo.
30 struct PSVRuntimeInfo {
31   dxbc::PSV::v2::RuntimeInfo BaseData;
32   std::vector<dxbc::PSV::v2::ResourceBindInfo> Resources;
33 
34   // Serialize PSVInfo into the provided raw_ostream. The version field
35   // specifies the data version to encode, the default value specifies encoding
36   // the highest supported version.
37   void write(raw_ostream &OS,
38              uint32_t Version = std::numeric_limits<uint32_t>::max()) const;
39 
40   void swapBytes(Triple::EnvironmentType Stage) {
41     BaseData.swapBytes();
42     BaseData.swapBytes(Stage);
43     for (auto &Res : Resources)
44       Res.swapBytes();
45   }
46 };
47 
48 } // namespace mcdxbc
49 } // namespace llvm
50 
51 #endif // LLVM_MC_DXCONTAINERPSVINFO_H
52