LLVM
17.0.0git
include
llvm
Remarks
RemarkStringTable.h
Go to the documentation of this file.
1
//===-- RemarkStringTable.h - Serializing string table ----------*- 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 class is used to deduplicate and serialize a string table used for
10
// generating remarks.
11
//
12
// For parsing a string table, use ParsedStringTable in RemarkParser.h
13
//
14
//===----------------------------------------------------------------------===//
15
16
#ifndef LLVM_REMARKS_REMARKSTRINGTABLE_H
17
#define LLVM_REMARKS_REMARKSTRINGTABLE_H
18
19
#include "
llvm/ADT/StringMap.h
"
20
#include "
llvm/Support/Allocator.h
"
21
#include <vector>
22
23
namespace
llvm
{
24
25
class
raw_ostream;
26
class
StringRef;
27
28
namespace
remarks {
29
30
struct
ParsedStringTable;
31
struct
Remark
;
32
33
/// The string table used for serializing remarks.
34
/// This table can be for example serialized in a section to be consumed after
35
/// the compilation.
36
struct
StringTable
{
37
/// The string table containing all the unique strings used in the output.
38
/// It maps a string to an unique ID.
39
StringMap<unsigned, BumpPtrAllocator>
StrTab
;
40
/// Total size of the string table when serialized.
41
size_t
SerializedSize
= 0;
42
43
StringTable
() =
default
;
44
45
/// Disable copy.
46
StringTable
(
const
StringTable
&) =
delete
;
47
StringTable
&
operator=
(
const
StringTable
&) =
delete
;
48
/// Should be movable.
49
StringTable
(
StringTable
&&) =
default
;
50
StringTable
&
operator=
(
StringTable
&&) =
default
;
51
52
/// Construct a string table from a ParsedStringTable.
53
StringTable
(
const
ParsedStringTable
&Other);
54
55
/// Add a string to the table. It returns an unique ID of the string.
56
std::pair<unsigned, StringRef>
add
(
StringRef
Str);
57
/// Modify \p R to use strings from this string table. If the string table
58
/// does not contain the strings, it adds them.
59
void
internalize
(
Remark
&R);
60
/// Serialize the string table to a stream. It is serialized as a little
61
/// endian uint64 (the size of the table in bytes) followed by a sequence of
62
/// NULL-terminated strings, where the N-th string is the string with the ID N
63
/// in the StrTab map.
64
void
serialize
(
raw_ostream
&OS)
const
;
65
/// Serialize the string table to a vector. This allows users to do the actual
66
/// writing to file/memory/other.
67
/// The string with the ID == N should be the N-th element in the vector.
68
std::vector<StringRef>
serialize
()
const
;
69
};
70
71
}
// end namespace remarks
72
}
// end namespace llvm
73
74
#endif // LLVM_REMARKS_REMARKSTRINGTABLE_H
llvm::remarks::StringTable::internalize
void internalize(Remark &R)
Modify R to use strings from this string table.
Definition:
RemarkStringTable.cpp:41
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
llvm::remarks::StringTable
The string table used for serializing remarks.
Definition:
RemarkStringTable.h:36
llvm::remarks::StringTable::StrTab
StringMap< unsigned, BumpPtrAllocator > StrTab
The string table containing all the unique strings used in the output.
Definition:
RemarkStringTable.h:39
Allocator.h
llvm::remarks::StringTable::serialize
std::vector< StringRef > serialize() const
Serialize the string table to a vector.
Definition:
RemarkStringTable.cpp:65
llvm::remarks::StringTable::operator=
StringTable & operator=(const StringTable &)=delete
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:
raw_ostream.h:52
llvm::remarks::Remark
A remark type used for both emission and parsing.
Definition:
Remark.h:67
llvm::remarks::StringTable::StringTable
StringTable()=default
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition:
StringMap.h:110
llvm::HighlightColor::Remark
@ Remark
llvm::remarks::StringTable::SerializedSize
size_t SerializedSize
Total size of the string table when serialized.
Definition:
RemarkStringTable.h:41
llvm::remarks::ParsedStringTable
In-memory representation of the string table parsed from a buffer (e.g.
Definition:
RemarkParser.h:60
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:50
llvm::remarks::StringTable::add
std::pair< unsigned, StringRef > add(StringRef Str)
Add a string to the table. It returns an unique ID of the string.
Definition:
RemarkStringTable.cpp:31
StringMap.h
Generated on Sat Jan 28 2023 08:50:04 for LLVM by
1.8.17