Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
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
19#include <optional>
20
21namespace llvm {
22
23class raw_ostream;
24
25namespace remarks {
26
27struct Remark;
28
29struct MetaSerializer;
30
31/// This is the base class for a remark serializer.
32/// It includes support for using a string table while emitting.
34 /// The format of the serializer.
36 /// The open raw_ostream that the remark diagnostics are emitted to.
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
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.
63 /// The open raw_ostream that the metadata is emitted to.
65
67
68 /// This is just an interface.
69 virtual ~MetaSerializer() = default;
70 virtual void emit() = 0;
71};
72
73/// Create a remark serializer.
76
77/// Create a remark serializer that uses a pre-filled string table.
81
82} // end namespace remarks
83} // end namespace llvm
84
85#endif // LLVM_REMARKS_REMARKSERIALIZER_H
#define LLVM_ABI
Definition Compiler.h:213
Tagged union holding either a T or a Error.
Definition Error.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
Format
The format used for serializing/deserializing remarks.
LLVM_ABI Expected< std::unique_ptr< RemarkSerializer > > createRemarkSerializer(Format RemarksFormat, raw_ostream &OS)
Create a remark serializer.
This is an optimization pass for GlobalISel generic memory operations.
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"))
This is the base class for a remark metadata serializer.
raw_ostream & OS
The open raw_ostream that the metadata is emitted to.
virtual ~MetaSerializer()=default
This is just an interface.
Format SerializerFormat
The format of the serializer.
virtual std::unique_ptr< MetaSerializer > metaSerializer(raw_ostream &OS, StringRef ExternalFilename)=0
Return the corresponding metadata serializer.
virtual void finalize()
Finalize remark emission (e.g.
RemarkSerializer(Format SerializerFormat, raw_ostream &OS)
std::optional< StringTable > StrTab
The string table containing all the unique strings used in the output.
raw_ostream & OS
The open raw_ostream that the remark diagnostics are emitted to.
virtual ~RemarkSerializer()=default
virtual void emit(const Remark &Remark)=0
Emit a remark to the stream.
A remark type used for both emission and parsing.
Definition Remark.h:98
The string table used for serializing remarks.