LLVM 23.0.0git
DXContainerInfo.cpp
Go to the documentation of this file.
1//===- llvm/MC/DXContainerInfo.cpp - DXContainer Info -----*- 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
13#include <type_traits>
14
15using namespace llvm;
16using namespace llvm::mcdxbc;
17
18template <typename StructT>
19static void writeStruct(raw_ostream &OS, StructT S) {
20 static_assert(std::is_class<StructT>() &&
21 "This method must be used for writing structure types");
23 S.swapBytes();
24 OS.write(reinterpret_cast<const char *>(&S), sizeof(StructT));
25}
26
27static void writeString(raw_ostream &OS, StringRef S) {
28 OS.write(S.data(), S.size());
29 // Write null terminator.
30 OS.write_zeros(1);
31}
32
33void DebugName::setFileName(StringRef DebugFileName) {
34 BaseData.first.NameLength = DebugFileName.size();
35 BaseData.second = DebugFileName;
36}
37
39 writeStruct(OS, BaseData.first);
40 writeString(OS, BaseData.second.substr(0, BaseData.first.NameLength));
41}
static void writeString(raw_ostream &OS, StringRef S)
static void writeStruct(raw_ostream &OS, StructT S)
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
Definition StringRef.h:138
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
raw_ostream & write(unsigned char C)
constexpr bool IsBigEndianHost
This is an optimization pass for GlobalISel generic memory operations.
object::DXContainer::ILDNData BaseData
void setFileName(StringRef FileName)
void write(raw_ostream &OS) const