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
29enum class SerializerMode {
30 Separate, // A mode where the metadata is serialized separately from the
31 // remarks. Typically, this is used when the remarks need to be
32 // streamed to a side file and the metadata is embedded into the
33 // final result of the compilation.
34 Standalone // A mode where everything can be retrieved in the same
35 // file/buffer. Typically, this is used for storing remarks for
36 // later use.
37};
38
39struct MetaSerializer;
40
41/// This is the base class for a remark serializer.
42/// It includes support for using a string table while emitting.
44 /// The format of the serializer.
46 /// The open raw_ostream that the remark diagnostics are emitted to.
48 /// The serialization mode.
50 /// The string table containing all the unique strings used in the output.
51 /// The table can be serialized to be consumed after the compilation.
52 std::optional<StringTable> StrTab;
53
57
58 /// This is just an interface.
59 virtual ~RemarkSerializer() = default;
60 /// Emit a remark to the stream.
61 virtual void emit(const Remark &Remark) = 0;
62 /// Return the corresponding metadata serializer.
63 virtual std::unique_ptr<MetaSerializer>
65 std::optional<StringRef> ExternalFilename = std::nullopt) = 0;
66};
67
68/// This is the base class for a remark metadata serializer.
70 /// The open raw_ostream that the metadata is emitted to.
72
74
75 /// This is just an interface.
76 virtual ~MetaSerializer() = default;
77 virtual void emit() = 0;
78};
79
80/// Create a remark serializer.
84
85/// Create a remark serializer that uses a pre-filled string table.
89
90} // end namespace remarks
91} // end namespace llvm
92
93#endif // LLVM_REMARKS_REMARKSERIALIZER_H
#define LLVM_ABI
Definition: Compiler.h:213
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
raw_pwrite_stream & OS
Tagged union holding either a T or a Error.
Definition: Error.h:485
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
@ Standalone
Everything is emitted together.
LLVM_ABI Expected< std::unique_ptr< RemarkSerializer > > createRemarkSerializer(Format RemarksFormat, SerializerMode Mode, raw_ostream &OS)
Create a remark serializer.
Format
The format used for serializing/deserializing remarks.
Definition: RemarkFormat.h:26
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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.
This is the base class for a remark serializer.
Format SerializerFormat
The format of the serializer.
SerializerMode Mode
The serialization mode.
virtual std::unique_ptr< MetaSerializer > metaSerializer(raw_ostream &OS, std::optional< StringRef > ExternalFilename=std::nullopt)=0
Return the corresponding metadata serializer.
RemarkSerializer(Format SerializerFormat, raw_ostream &OS, SerializerMode Mode)
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
This is just an interface.
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.