LLVM 20.0.0git
LVRange.h
Go to the documentation of this file.
1//===-- LVRange.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 file defines the LVRange class, which is used to describe a debug
10// information range.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVRANGE_H
15#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVRANGE_H
16
19
20namespace llvm {
21namespace logicalview {
22
23using LVAddressRange = std::pair<LVAddress, LVAddress>;
24
25class LVRangeEntry final {
26 LVAddress Lower = 0;
27 LVAddress Upper = 0;
28 LVScope *Scope = nullptr;
29
30public:
32
33 LVRangeEntry() = delete;
34 LVRangeEntry(LVAddress LowerAddress, LVAddress UpperAddress, LVScope *Scope)
35 : Lower(LowerAddress), Upper(UpperAddress), Scope(Scope) {}
36
37 RangeType lower() const { return Lower; }
38 RangeType upper() const { return Upper; }
40 return LVAddressRange(lower(), upper());
41 }
42 LVScope *scope() const { return Scope; }
43};
44
45// Class to represent a list of range addresses associated with a
46// scope; the addresses are stored in ascending order and can overlap.
47using LVRangeEntries = std::vector<LVRangeEntry>;
48
49class LVRange final : public LVObject {
50 /// Map of where a user value is live, and its location.
53
54 LVAllocator Allocator;
55 LVRangesTree RangesTree;
56 LVRangeEntries RangeEntries;
57 LVAddress Lower = MaxAddress;
58 LVAddress Upper = 0;
59
60public:
61 LVRange() : LVObject(), RangesTree(Allocator) {}
62 LVRange(const LVRange &) = delete;
63 LVRange &operator=(const LVRange &) = delete;
64 ~LVRange() = default;
65
66 void addEntry(LVScope *Scope, LVAddress LowerAddress, LVAddress UpperAddress);
67 void addEntry(LVScope *Scope);
69 LVScope *getEntry(LVAddress LowerAddress, LVAddress UpperAddress) const;
70 bool hasEntry(LVAddress Low, LVAddress High) const;
71 LVAddress getLower() const { return Lower; }
72 LVAddress getUpper() const { return Upper; }
73
74 const LVRangeEntries &getEntries() const { return RangeEntries; }
75
76 void clear() {
77 RangeEntries.clear();
78 Lower = MaxAddress;
79 Upper = 0;
80 }
81 bool empty() const { return RangeEntries.empty(); }
82 void sort();
83
84 void startSearch();
85 void endSearch() {}
86
87 void print(raw_ostream &OS, bool Full = true) const override;
88 void printExtra(raw_ostream &OS, bool Full = true) const override {}
89
90#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
91 void dump() const override { print(dbgs()); }
92#endif
93};
94
95} // end namespace logicalview
96} // end namespace llvm
97
98#endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVRANGE_H
uint64_t High
Basic Register Allocator
raw_pwrite_stream & OS
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
LVRangeEntry(LVAddress LowerAddress, LVAddress UpperAddress, LVScope *Scope)
Definition: LVRange.h:34
LVAddressRange addressRange() const
Definition: LVRange.h:39
RangeType lower() const
Definition: LVRange.h:37
RangeType upper() const
Definition: LVRange.h:38
LVScope * scope() const
Definition: LVRange.h:42
LVScope * getEntry(LVAddress Address) const
Definition: LVRange.cpp:83
bool hasEntry(LVAddress Low, LVAddress High) const
Definition: LVRange.cpp:118
void printExtra(raw_ostream &OS, bool Full=true) const override
Definition: LVRange.h:88
void print(raw_ostream &OS, bool Full=true) const override
Definition: LVRange.cpp:145
const LVRangeEntries & getEntries() const
Definition: LVRange.h:74
bool empty() const
Definition: LVRange.h:81
LVRange & operator=(const LVRange &)=delete
void dump() const override
Definition: LVRange.h:91
LVAddress getLower() const
Definition: LVRange.h:71
LVRange(const LVRange &)=delete
void addEntry(LVScope *Scope, LVAddress LowerAddress, LVAddress UpperAddress)
Definition: LVRange.cpp:52
LVAddress getUpper() const
Definition: LVRange.h:72
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
const LVAddress MaxAddress
Definition: LVObject.h:86
std::pair< LVAddress, LVAddress > LVAddressRange
Definition: LVRange.h:23
std::vector< LVRangeEntry > LVRangeEntries
Definition: LVRange.h:47
uint64_t LVAddress
Definition: LVObject.h:36
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163