[RISCV] Refactor predicates for rvv intrinsic patterns.
[llvm-project.git] / llvm / lib / MC / DXContainerPSVInfo.cpp
bloba3444d0adb7267a0926cd59a6ca32283299b8a7f
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 //===----------------------------------------------------------------------===//
9 #include "llvm/MC/DXContainerPSVInfo.h"
10 #include "llvm/BinaryFormat/DXContainer.h"
11 #include "llvm/Support/raw_ostream.h"
13 using namespace llvm;
14 using namespace llvm::mcdxbc;
15 using namespace llvm::dxbc::PSV;
17 void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const {
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);
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);