LLVM 20.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
18#include <optional>
19
20namespace llvm {
21
22class raw_ostream;
23
24namespace remarks {
25
26struct Remark;
27
28enum class SerializerMode {
29 Separate, // A mode where the metadata is serialized separately from the
30 // remarks. Typically, this is used when the remarks need to be
31 // streamed to a side file and the metadata is embedded into the
32 // final result of the compilation.
33 Standalone // A mode where everything can be retrieved in the same
34 // file/buffer. Typically, this is used for storing remarks for
35 // later use.
36};
37
38struct MetaSerializer;
39
40/// This is the base class for a remark serializer.
41/// It includes support for using a string table while emitting.
43 /// The format of the serializer.
45 /// The open raw_ostream that the remark diagnostics are emitted to.
47 /// The serialization mode.
49 /// The string table containing all the unique strings used in the output.
50 /// The table can be serialized to be consumed after the compilation.
51 std::optional<StringTable> StrTab;
52
56
57 /// This is just an interface.
58 virtual ~RemarkSerializer() = default;
59 /// Emit a remark to the stream.
60 virtual void emit(const Remark &Remark) = 0;
61 /// Return the corresponding metadata serializer.
62 virtual std::unique_ptr<MetaSerializer>
64 std::optional<StringRef> ExternalFilename = std::nullopt) = 0;
65};
66
67/// This is the base class for a remark metadata serializer.
69 /// The open raw_ostream that the metadata is emitted to.
71
73
74 /// This is just an interface.
75 virtual ~MetaSerializer() = default;
76 virtual void emit() = 0;
77};
78
79/// Create a remark serializer.
83
84/// Create a remark serializer that uses a pre-filled string table.
88
89} // end namespace remarks
90} // end namespace llvm
91
92#endif // LLVM_REMARKS_REMARKSERIALIZER_H
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
raw_pwrite_stream & OS
Tagged union holding either a T or a Error.
Definition: Error.h:481
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
@ Standalone
Everything is emitted together.
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:25
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:97
The string table used for serializing remarks.