Thanks to visit codestin.com
Credit goes to llvm.org
LLVM
22.0.0git
include
llvm
Remarks
RemarkSerializer.h
Go to the documentation of this file.
1
//===-- RemarkSerializer.h - Remark serialization interface -----*- 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
//
9
// This file provides an interface for serializing remarks to different formats.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_REMARKS_REMARKSERIALIZER_H
14
#define LLVM_REMARKS_REMARKSERIALIZER_H
15
16
#include "
llvm/Remarks/RemarkFormat.h
"
17
#include "
llvm/Remarks/RemarkStringTable.h
"
18
#include "
llvm/Support/Compiler.h
"
19
#include <optional>
20
21
namespace
llvm
{
22
23
class
raw_ostream
;
24
25
namespace
remarks
{
26
27
struct
Remark
;
28
29
struct
MetaSerializer
;
30
31
/// This is the base class for a remark serializer.
32
/// It includes support for using a string table while emitting.
33
struct
RemarkSerializer
{
34
/// The format of the serializer.
35
Format
SerializerFormat
;
36
/// The open raw_ostream that the remark diagnostics are emitted to.
37
raw_ostream
&
OS
;
38
/// The string table containing all the unique strings used in the output.
39
/// The table can be serialized to be consumed after the compilation.
40
std::optional<StringTable>
StrTab
;
41
42
RemarkSerializer
(
Format
SerializerFormat
,
raw_ostream
&
OS
)
43
:
SerializerFormat
(
SerializerFormat
),
OS
(
OS
) {}
44
45
virtual
~RemarkSerializer
() =
default
;
46
47
/// Finalize remark emission (e.g. finish writing metadata, flush internal
48
/// buffers). It is safe to call this function multiple times, and it should
49
/// have the same behavior as destructing the RemarkSerializer.
50
/// After finalizing, the behavior of emit is unspecified.
51
virtual
void
finalize
() {}
52
53
/// Emit a remark to the stream.
54
virtual
void
emit
(
const
Remark
&
Remark
) = 0;
55
56
/// Return the corresponding metadata serializer.
57
virtual
std::unique_ptr<MetaSerializer>
58
metaSerializer
(
raw_ostream
&
OS
,
StringRef
ExternalFilename) = 0;
59
};
60
61
/// This is the base class for a remark metadata serializer.
62
struct
MetaSerializer
{
63
/// The open raw_ostream that the metadata is emitted to.
64
raw_ostream
&
OS
;
65
66
MetaSerializer
(
raw_ostream
&
OS
) :
OS
(
OS
) {}
67
68
/// This is just an interface.
69
virtual
~MetaSerializer
() =
default
;
70
virtual
void
emit
() = 0;
71
};
72
73
/// Create a remark serializer.
74
LLVM_ABI
Expected<std::unique_ptr<RemarkSerializer>
>
75
createRemarkSerializer
(
Format
RemarksFormat
,
raw_ostream
&OS);
76
77
/// Create a remark serializer that uses a pre-filled string table.
78
LLVM_ABI
Expected<std::unique_ptr<RemarkSerializer>
>
79
createRemarkSerializer
(
Format
RemarksFormat
,
raw_ostream
&OS,
80
remarks::StringTable
StrTab);
81
82
}
// end namespace remarks
83
}
// end namespace llvm
84
85
#endif
// LLVM_REMARKS_REMARKSERIALIZER_H
Compiler.h
LLVM_ABI
#define LLVM_ABI
Definition
Compiler.h:213
RemarkFormat.h
RemarkStringTable.h
llvm::Expected
Tagged union holding either a T or a Error.
Definition
Error.h:485
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition
StringRef.h:55
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition
raw_ostream.h:53
llvm::remarks
Definition
AsmPrinter.h:86
llvm::remarks::Format
Format
The format used for serializing/deserializing remarks.
Definition
RemarkFormat.h:26
llvm::remarks::createRemarkSerializer
LLVM_ABI Expected< std::unique_ptr< RemarkSerializer > > createRemarkSerializer(Format RemarksFormat, raw_ostream &OS)
Create a remark serializer.
Definition
RemarkSerializer.cpp:21
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
AddressRanges.h:18
llvm::RemarksFormat
cl::opt< std::string > RemarksFormat("lto-pass-remarks-format", cl::desc("The format used for serializing remarks (default: YAML)"), cl::value_desc("format"), cl::init("yaml"))
Definition
ThinLTOCodeGenerator.cpp:81
llvm::remarks::MetaSerializer
This is the base class for a remark metadata serializer.
Definition
RemarkSerializer.h:62
llvm::remarks::MetaSerializer::emit
virtual void emit()=0
llvm::remarks::MetaSerializer::MetaSerializer
MetaSerializer(raw_ostream &OS)
Definition
RemarkSerializer.h:66
llvm::remarks::MetaSerializer::OS
raw_ostream & OS
The open raw_ostream that the metadata is emitted to.
Definition
RemarkSerializer.h:64
llvm::remarks::MetaSerializer::~MetaSerializer
virtual ~MetaSerializer()=default
This is just an interface.
llvm::remarks::RemarkSerializer::SerializerFormat
Format SerializerFormat
The format of the serializer.
Definition
RemarkSerializer.h:35
llvm::remarks::RemarkSerializer::metaSerializer
virtual std::unique_ptr< MetaSerializer > metaSerializer(raw_ostream &OS, StringRef ExternalFilename)=0
Return the corresponding metadata serializer.
llvm::remarks::RemarkSerializer::finalize
virtual void finalize()
Finalize remark emission (e.g.
Definition
RemarkSerializer.h:51
llvm::remarks::RemarkSerializer::RemarkSerializer
RemarkSerializer(Format SerializerFormat, raw_ostream &OS)
Definition
RemarkSerializer.h:42
llvm::remarks::RemarkSerializer::StrTab
std::optional< StringTable > StrTab
The string table containing all the unique strings used in the output.
Definition
RemarkSerializer.h:40
llvm::remarks::RemarkSerializer::OS
raw_ostream & OS
The open raw_ostream that the remark diagnostics are emitted to.
Definition
RemarkSerializer.h:37
llvm::remarks::RemarkSerializer::~RemarkSerializer
virtual ~RemarkSerializer()=default
llvm::remarks::RemarkSerializer::emit
virtual void emit(const Remark &Remark)=0
Emit a remark to the stream.
llvm::remarks::Remark
A remark type used for both emission and parsing.
Definition
Remark.h:98
llvm::remarks::StringTable
The string table used for serializing remarks.
Definition
RemarkStringTable.h:37
Generated on
for LLVM by
1.14.0