LLVM 17.0.0git
DXContainerPSVInfo.cpp
Go to the documentation of this file.
1//===- llvm/MC/DXContainerPSVInfo.cpp - 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
12
13using namespace llvm;
14using namespace llvm::mcdxbc;
15using namespace llvm::dxbc::PSV;
16
18 uint32_t InfoSize;
19 switch (Version) {
20 case 0:
21 InfoSize = sizeof(dxbc::PSV::v0::RuntimeInfo);
22 break;
23 case 1:
24 InfoSize = sizeof(dxbc::PSV::v1::RuntimeInfo);
25 break;
26 case 2:
27 default:
28 InfoSize = sizeof(dxbc::PSV::v2::RuntimeInfo);
29 }
30 uint32_t InfoSizeSwapped = InfoSize;
32 sys::swapByteOrder(InfoSizeSwapped);
33 // Write the size of the info.
34 OS.write(reinterpret_cast<const char *>(&InfoSizeSwapped), sizeof(uint32_t));
35 // Write the info itself.
36 OS.write(reinterpret_cast<const char *>(&BaseData), InfoSize);
37
38 uint32_t ResourceCount = static_cast<uint32_t>(Resources.size());
40 sys::swapByteOrder(ResourceCount);
41 OS.write(reinterpret_cast<const char *>(&ResourceCount), sizeof(uint32_t));
42
43 size_t BindingSize = (Version < 2) ? sizeof(v0::ResourceBindInfo)
44 : sizeof(v2::ResourceBindInfo);
45 for (const auto &Res : Resources)
46 OS.write(reinterpret_cast<const char *>(&Res), BindingSize);
47}
raw_pwrite_stream & OS
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
raw_ostream & write(unsigned char C)
constexpr bool IsBigEndianHost
Definition: SwapByteOrder.h:67
void swapByteOrder(T &Value)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::vector< dxbc::PSV::v2::ResourceBindInfo > Resources
void write(raw_ostream &OS, uint32_t Version=std::numeric_limits< uint32_t >::max()) const
dxbc::PSV::v2::RuntimeInfo BaseData