LLVM  14.0.0git
YAMLRemarkSerializer.h
Go to the documentation of this file.
1 //===-- YAMLRemarkSerializer.h - YAML Remark serialization ---*- 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 YAML.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_REMARKS_YAMLREMARKSERIALIZER_H
14 #define LLVM_REMARKS_YAMLREMARKSERIALIZER_H
15 
18 
19 namespace llvm {
20 namespace remarks {
21 
22 /// Serialize the remarks to YAML. One remark entry looks like this:
23 /// --- !<TYPE>
24 /// Pass: <PASSNAME>
25 /// Name: <REMARKNAME>
26 /// DebugLoc: { File: <SOURCEFILENAME>, Line: <SOURCELINE>,
27 /// Column: <SOURCECOLUMN> }
28 /// Function: <FUNCTIONNAME>
29 /// Args:
30 /// - <KEY>: <VALUE>
31 /// DebugLoc: { File: <FILE>, Line: <LINE>, Column: <COL> }
32 /// ...
34  /// The YAML streamer.
35  yaml::Output YAMLOutput;
36 
39 
40  void emit(const Remark &Remark) override;
41  std::unique_ptr<MetaSerializer>
43  Optional<StringRef> ExternalFilename = None) override;
44 
45  static bool classof(const RemarkSerializer *S) {
46  return S->SerializerFormat == Format::YAML;
47  }
48 
49 protected:
53 };
54 
57 
60 
61  void emit() override;
62 };
63 
64 /// Serialize the remarks to YAML using a string table. An remark entry looks
65 /// like the regular YAML remark but instead of string entries it's using
66 /// numbers that map to an index in the string table.
68  /// Wether we already emitted the metadata in standalone mode.
69  /// This should be set to true after the first invocation of `emit`.
70  bool DidEmitMeta = false;
71 
74  // We always need a string table for this type of serializer.
75  StrTab.emplace();
76  }
80 
81  /// Override to emit the metadata if necessary.
82  void emit(const Remark &Remark) override;
83 
84  std::unique_ptr<MetaSerializer>
86  Optional<StringRef> ExternalFilename = None) override;
87 
88  static bool classof(const RemarkSerializer *S) {
89  return S->SerializerFormat == Format::YAMLStrTab;
90  }
91 };
92 
94  /// The string table is part of the metadata.
96 
99  const StringTable &StrTab)
101 
102  void emit() override;
103 };
104 
105 } // end namespace remarks
106 } // end namespace llvm
107 
108 #endif // LLVM_REMARKS_YAMLREMARKSERIALIZER_H
llvm::remarks::SerializerMode
SerializerMode
Definition: RemarkSerializer.h:24
llvm::remarks::YAMLRemarkSerializer::classof
static bool classof(const RemarkSerializer *S)
Definition: YAMLRemarkSerializer.h:45
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::remarks::YAMLStrTabRemarkSerializer::metaSerializer
std::unique_ptr< MetaSerializer > metaSerializer(raw_ostream &OS, Optional< StringRef > ExternalFilename=None) override
Return the corresponding metadata serializer.
Definition: YAMLRemarkSerializer.cpp:201
llvm::remarks::StringTable
The string table used for serializing remarks.
Definition: RemarkStringTable.h:36
llvm::remarks::YAMLStrTabRemarkSerializer::DidEmitMeta
bool DidEmitMeta
Wether we already emitted the metadata in standalone mode.
Definition: YAMLRemarkSerializer.h:70
llvm::remarks::YAMLMetaSerializer::YAMLMetaSerializer
YAMLMetaSerializer(raw_ostream &OS, Optional< StringRef > ExternalFilename)
Definition: YAMLRemarkSerializer.h:58
llvm::remarks::RemarkSerializer::StrTab
Optional< StringTable > StrTab
The string table containing all the unique strings used in the output.
Definition: RemarkSerializer.h:47
llvm::remarks::YAMLRemarkSerializer::YAMLOutput
yaml::Output YAMLOutput
The YAML streamer.
Definition: YAMLRemarkSerializer.h:35
llvm::Optional
Definition: APInt.h:33
llvm::remarks::RemarkSerializer::OS
raw_ostream & OS
The open raw_ostream that the remark diagnostics are emitted to.
Definition: RemarkSerializer.h:42
llvm::remarks::RemarkSerializer::SerializerFormat
Format SerializerFormat
The format of the serializer.
Definition: RemarkSerializer.h:40
llvm::remarks::RemarkSerializer::Mode
SerializerMode Mode
The serialization mode.
Definition: RemarkSerializer.h:44
llvm::remarks::YAMLStrTabMetaSerializer::emit
void emit() override
Definition: YAMLRemarkSerializer.cpp:252
remarks
annotation remarks
Definition: AnnotationRemarks.cpp:117
llvm::remarks::YAMLStrTabMetaSerializer::YAMLStrTabMetaSerializer
YAMLStrTabMetaSerializer(raw_ostream &OS, Optional< StringRef > ExternalFilename, const StringTable &StrTab)
Definition: YAMLRemarkSerializer.h:97
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::Remark
A remark type used for both emission and parsing.
Definition: Remark.h:67
llvm::remarks::YAMLRemarkSerializer::YAMLRemarkSerializer
YAMLRemarkSerializer(raw_ostream &OS, SerializerMode Mode, Optional< StringTable > StrTab=None)
Definition: YAMLRemarkSerializer.cpp:162
llvm::remarks::RemarkSerializer
This is the base class for a remark serializer.
Definition: RemarkSerializer.h:38
llvm::remarks::YAMLMetaSerializer::emit
void emit() override
Definition: YAMLRemarkSerializer.cpp:244
llvm::remarks::Format::YAML
@ YAML
llvm::remarks::Format::YAMLStrTab
@ YAMLStrTab
llvm::remarks::YAMLStrTabRemarkSerializer::YAMLStrTabRemarkSerializer
YAMLStrTabRemarkSerializer(raw_ostream &OS, SerializerMode Mode)
Definition: YAMLRemarkSerializer.h:72
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1639
llvm::remarks::YAMLStrTabRemarkSerializer::classof
static bool classof(const RemarkSerializer *S)
Definition: YAMLRemarkSerializer.h:88
llvm::remarks::MetaSerializer::OS
raw_ostream & OS
The open raw_ostream that the metadata is emitted to.
Definition: RemarkSerializer.h:66
llvm::remarks::YAMLStrTabMetaSerializer::StrTab
const StringTable & StrTab
The string table is part of the metadata.
Definition: YAMLRemarkSerializer.h:95
llvm::remarks::YAMLRemarkSerializer::metaSerializer
std::unique_ptr< MetaSerializer > metaSerializer(raw_ostream &OS, Optional< StringRef > ExternalFilename=None) override
Return the corresponding metadata serializer.
Definition: YAMLRemarkSerializer.cpp:182
YAMLTraits.h
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::remarks::YAMLStrTabRemarkSerializer::emit
void emit(const Remark &Remark) override
Override to emit the metadata if necessary.
Definition: YAMLRemarkSerializer.cpp:187
llvm::remarks::MetaSerializer
This is the base class for a remark metadata serializer.
Definition: RemarkSerializer.h:64
std
Definition: BitVector.h:838
llvm::remarks::YAMLStrTabMetaSerializer
Definition: YAMLRemarkSerializer.h:93
llvm::remarks::YAMLRemarkSerializer::emit
void emit(const Remark &Remark) override
Emit a remark to the stream.
Definition: YAMLRemarkSerializer.cpp:174
llvm::remarks::YAMLRemarkSerializer
Serialize the remarks to YAML.
Definition: YAMLRemarkSerializer.h:33
llvm::remarks::YAMLStrTabRemarkSerializer::YAMLStrTabRemarkSerializer
YAMLStrTabRemarkSerializer(raw_ostream &OS, SerializerMode Mode, StringTable StrTab)
Definition: YAMLRemarkSerializer.h:77
llvm::remarks::YAMLStrTabRemarkSerializer
Serialize the remarks to YAML using a string table.
Definition: YAMLRemarkSerializer.h:67
llvm::remarks::YAMLMetaSerializer
Definition: YAMLRemarkSerializer.h:55
RemarkSerializer.h
llvm::remarks::YAMLMetaSerializer::ExternalFilename
Optional< StringRef > ExternalFilename
Definition: YAMLRemarkSerializer.h:56
llvm::remarks::Format
Format
The format used for serializing/deserializing remarks.
Definition: RemarkFormat.h:25