LLVM 20.0.0git
StableFunctionMapRecord.h
Go to the documentation of this file.
1//===- StableFunctionMapRecord.h -------------------------------*- 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 defines the StableFunctionMapRecord structure, which provides
10// functionality for managing and serializing a StableFunctionMap. It includes
11// methods for serialization to and from raw and YAML streams, as well as
12// utilities for merging and finalizing function maps.
13//
14//===---------------------------------------------------------------------===//
15
16#ifndef LLVM_CGDATA_STABLEFUNCTIONMAPRECORD_H
17#define LLVM_CGDATA_STABLEFUNCTIONMAPRECORD_H
18
22
23namespace llvm {
24
26 std::unique_ptr<StableFunctionMap> FunctionMap;
27
29 FunctionMap = std::make_unique<StableFunctionMap>();
30 }
31
32 StableFunctionMapRecord(std::unique_ptr<StableFunctionMap> FunctionMap)
34
35 /// A static helper function to serialize the stable function map without
36 /// owning the stable function map.
38
39 /// Serialize the stable function map to a raw_ostream.
40 void serialize(raw_ostream &OS) const;
41
42 /// Deserialize the stable function map from a raw_ostream.
43 void deserialize(const unsigned char *&Ptr);
44
45 /// Serialize the stable function map to a YAML stream.
46 void serializeYAML(yaml::Output &YOS) const;
47
48 /// Deserialize the stable function map from a YAML stream.
49 void deserializeYAML(yaml::Input &YIS);
50
51 /// Finalize the stable function map by trimming content.
52 void finalize(bool SkipTrim = false) { FunctionMap->finalize(SkipTrim); }
53
54 /// Merge the stable function map into this one.
56 FunctionMap->merge(*Other.FunctionMap);
57 }
58
59 /// \returns true if the stable function map is empty.
60 bool empty() const { return FunctionMap->empty(); }
61
62 /// Print the stable function map in a YAML format.
63 void print(raw_ostream &OS = llvm::errs()) const {
64 yaml::Output YOS(OS);
65 serializeYAML(YOS);
66 }
67};
68
69} // namespace llvm
70
71#endif
raw_pwrite_stream & OS
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Other
Any other memory.
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:1873
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
void merge(const StableFunctionMapRecord &Other)
Merge the stable function map into this one.
void finalize(bool SkipTrim=false)
Finalize the stable function map by trimming content.
void deserialize(const unsigned char *&Ptr)
Deserialize the stable function map from a raw_ostream.
std::unique_ptr< StableFunctionMap > FunctionMap
void print(raw_ostream &OS=llvm::errs()) const
Print the stable function map in a YAML format.
static void serialize(raw_ostream &OS, const StableFunctionMap *FunctionMap)
A static helper function to serialize the stable function map without owning the stable function map.
StableFunctionMapRecord(std::unique_ptr< StableFunctionMap > FunctionMap)
void deserializeYAML(yaml::Input &YIS)
Deserialize the stable function map from a YAML stream.
void serializeYAML(yaml::Output &YOS) const
Serialize the stable function map to a YAML stream.