1 //===- llvm/MC/DXContainerPSVInfo.cpp - DXContainer PSVInfo -----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/MC/DXContainerPSVInfo.h"
10 #include "llvm/BinaryFormat/DXContainer.h"
11 #include "llvm/Support/raw_ostream.h"
14 using namespace llvm::mcdxbc
;
15 using namespace llvm::dxbc::PSV
;
17 void PSVRuntimeInfo::write(raw_ostream
&OS
, uint32_t Version
) const {
21 InfoSize
= sizeof(dxbc::PSV::v0::RuntimeInfo
);
24 InfoSize
= sizeof(dxbc::PSV::v1::RuntimeInfo
);
28 InfoSize
= sizeof(dxbc::PSV::v2::RuntimeInfo
);
30 uint32_t InfoSizeSwapped
= InfoSize
;
31 if (sys::IsBigEndianHost
)
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
);
38 uint32_t ResourceCount
= static_cast<uint32_t>(Resources
.size());
39 if (sys::IsBigEndianHost
)
40 sys::swapByteOrder(ResourceCount
);
41 OS
.write(reinterpret_cast<const char *>(&ResourceCount
), sizeof(uint32_t));
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
);