LLVM 20.0.0git
ArchiveEmitter.cpp
Go to the documentation of this file.
1//===- ArchiveEmitter.cpp ---------------------------- --------------------===//
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 ArchYAML;
15
16namespace llvm {
17namespace yaml {
18
20 Out.write(Doc.Magic.data(), Doc.Magic.size());
21
22 if (Doc.Content) {
23 Doc.Content->writeAsBinary(Out);
24 return true;
25 }
26
27 if (!Doc.Members)
28 return true;
29
30 auto WriteField = [&](StringRef Field, uint8_t Size) {
31 Out.write(Field.data(), Field.size());
32 for (size_t I = Field.size(); I != Size; ++I)
33 Out.write(' ');
34 };
35
36 for (const Archive::Child &C : *Doc.Members) {
37 for (auto &P : C.Fields)
38 WriteField(P.second.Value, P.second.MaxLength);
39
40 if (C.Content)
41 C.Content->writeAsBinary(Out);
42 if (C.PaddingByte)
43 Out.write(*C.PaddingByte);
44 }
45
46 return true;
47}
48
49} // namespace yaml
50} // namespace llvm
This file declares classes for handling the YAML representation of archives.
uint64_t Size
#define I(x, y, z)
Definition: MD5.cpp:58
OptimizedStructLayoutField Field
#define P(N)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:150
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:144
An efficient, type-erasing, non-owning reference to a callable.
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)
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out, ErrorHandler EH)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::optional< yaml::BinaryRef > Content
Definition: ArchiveYAML.h:54
std::optional< std::vector< Child > > Members
Definition: ArchiveYAML.h:53
Common declarations for yaml2obj.