LLVM 23.0.0git
BBAddrMapYAML.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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/// \file
10/// This file declares the YAML representation of BB address maps
11/// (SHT_LLVM_BB_ADDR_MAP / .llvm_bb_addr_map). The types here are
12/// format-agnostic so they can be reused by ELFYAML and COFFYAML.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_OBJECTYAML_BBADDRMAPYAML_H
17#define LLVM_OBJECTYAML_BBADDRMAPYAML_H
18
20#include <cstdint>
21#include <optional>
22#include <vector>
23
24namespace llvm {
25namespace BBAddrMapYAML {
26
28 struct BBEntry {
30 llvm::yaml::Hex64 AddressOffset;
31 llvm::yaml::Hex64 Size;
32 llvm::yaml::Hex64 Metadata;
33 std::optional<std::vector<llvm::yaml::Hex64>> CallsiteEndOffsets;
34 std::optional<llvm::yaml::Hex64> Hash;
35 };
37 llvm::yaml::Hex16 Feature;
38
39 struct BBRangeEntry {
40 llvm::yaml::Hex64 BaseAddress;
41 std::optional<uint64_t> NumBlocks;
42 std::optional<std::vector<BBEntry>> BBEntries;
43 };
44
45 std::optional<uint64_t> NumBBRanges;
46 std::optional<std::vector<BBRangeEntry>> BBRanges;
47
48 llvm::yaml::Hex64 getFunctionAddress() const {
49 if (!BBRanges || BBRanges->empty())
50 return 0;
51 return BBRanges->front().BaseAddress;
52 }
53
54 // Returns if any BB entries have non-empty callsite offsets.
56 if (!BBRanges)
57 return false;
58 for (const BBRangeEntry &BBR : *BBRanges) {
59 if (!BBR.BBEntries)
60 continue;
61 for (const BBEntry &BBE : *BBR.BBEntries)
62 if (BBE.CallsiteEndOffsets && !BBE.CallsiteEndOffsets->empty())
63 return true;
64 }
65 return false;
66 }
67};
68
70 struct PGOBBEntry {
73 llvm::yaml::Hex32 BrProb;
74 std::optional<uint32_t> PostLinkBrFreq;
75 };
76 std::optional<uint64_t> BBFreq;
77 std::optional<uint32_t> PostLinkBBFreq;
78 std::optional<std::vector<SuccessorEntry>> Successors;
79 };
80 std::optional<uint64_t> FuncEntryCount;
81 std::optional<std::vector<PGOBBEntry>> PGOBBEntries;
82};
83
84} // end namespace BBAddrMapYAML
85} // end namespace llvm
86
95
96namespace llvm {
97namespace yaml {
98
99template <> struct MappingTraits<BBAddrMapYAML::BBAddrMapEntry> {
100 static void mapping(IO &IO, BBAddrMapYAML::BBAddrMapEntry &E);
101};
102
103template <> struct MappingTraits<BBAddrMapYAML::BBAddrMapEntry::BBRangeEntry> {
104 static void mapping(IO &IO, BBAddrMapYAML::BBAddrMapEntry::BBRangeEntry &E);
105};
106
107template <> struct MappingTraits<BBAddrMapYAML::BBAddrMapEntry::BBEntry> {
108 static void mapping(IO &IO, BBAddrMapYAML::BBAddrMapEntry::BBEntry &E);
109};
110
111template <> struct MappingTraits<BBAddrMapYAML::PGOAnalysisMapEntry> {
112 static void mapping(IO &IO, BBAddrMapYAML::PGOAnalysisMapEntry &E);
113};
114
115template <>
116struct MappingTraits<BBAddrMapYAML::PGOAnalysisMapEntry::PGOBBEntry> {
117 static void mapping(IO &IO,
118 BBAddrMapYAML::PGOAnalysisMapEntry::PGOBBEntry &E);
119};
120
121template <>
122struct MappingTraits<
123 BBAddrMapYAML::PGOAnalysisMapEntry::PGOBBEntry::SuccessorEntry> {
124 static void
125 mapping(IO &IO,
126 BBAddrMapYAML::PGOAnalysisMapEntry::PGOBBEntry::SuccessorEntry &E);
127};
128
129} // end namespace yaml
130} // end namespace llvm
131
132#endif // LLVM_OBJECTYAML_BBADDRMAPYAML_H
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.
This is an optimization pass for GlobalISel generic memory operations.
std::optional< std::vector< llvm::yaml::Hex64 > > CallsiteEndOffsets
std::optional< llvm::yaml::Hex64 > Hash
std::optional< std::vector< BBEntry > > BBEntries
std::optional< std::vector< BBRangeEntry > > BBRanges
llvm::yaml::Hex64 getFunctionAddress() const
std::optional< uint64_t > NumBBRanges
std::optional< std::vector< SuccessorEntry > > Successors
std::optional< uint64_t > FuncEntryCount
std::optional< std::vector< PGOBBEntry > > PGOBBEntries
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
Definition YAMLTraits.h:63