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
12#include <type_traits>
13
14using namespace llvm;
15using namespace llvm::mcdxbc;
16
17template <typename StructT>
18static void writeStruct(raw_ostream &OS, StructT S) {
19 static_assert(std::is_class<StructT>() &&
20 "This method must be used for writing structure types");
22 S.swapBytes();
23 OS.write(reinterpret_cast<const char *>(&S), sizeof(StructT));
24}
25
26static void writeString(raw_ostream &OS, StringRef S) {
27 OS.write(S.data(), S.size());
28 // Write null terminator.
29 OS.write_zeros(1);
30}
31
32void DebugName::setFilename(StringRef DebugFilename) {
33 Parameters.NameLength = DebugFilename.size();
34 Filename = DebugFilename;
35}
36
39 writeString(OS, Filename.substr(0, Parameters.NameLength));
40}
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.
dxbc::DebugNameHeader Parameters
void setFilename(StringRef DebugFilename)
void write(raw_ostream &OS) const