File indexing completed on 2026-05-10 08:43:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVRANGE_H
0015 #define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVRANGE_H
0016
0017 #include "llvm/ADT/IntervalTree.h"
0018 #include "llvm/DebugInfo/LogicalView/Core/LVObject.h"
0019
0020 namespace llvm {
0021 namespace logicalview {
0022
0023 using LVAddressRange = std::pair<LVAddress, LVAddress>;
0024
0025 class LVRangeEntry final {
0026 LVAddress Lower = 0;
0027 LVAddress Upper = 0;
0028 LVScope *Scope = nullptr;
0029
0030 public:
0031 using RangeType = LVAddress;
0032
0033 LVRangeEntry() = delete;
0034 LVRangeEntry(LVAddress LowerAddress, LVAddress UpperAddress, LVScope *Scope)
0035 : Lower(LowerAddress), Upper(UpperAddress), Scope(Scope) {}
0036
0037 RangeType lower() const { return Lower; }
0038 RangeType upper() const { return Upper; }
0039 LVAddressRange addressRange() const {
0040 return LVAddressRange(lower(), upper());
0041 }
0042 LVScope *scope() const { return Scope; }
0043 };
0044
0045
0046
0047 using LVRangeEntries = std::vector<LVRangeEntry>;
0048
0049 class LVRange final : public LVObject {
0050
0051 using LVRangesTree = IntervalTree<LVAddress, LVScope *>;
0052 using LVAllocator = LVRangesTree::Allocator;
0053
0054 LVAllocator Allocator;
0055 LVRangesTree RangesTree;
0056 LVRangeEntries RangeEntries;
0057 LVAddress Lower = MaxAddress;
0058 LVAddress Upper = 0;
0059
0060 public:
0061 LVRange() : LVObject(), RangesTree(Allocator) {}
0062 LVRange(const LVRange &) = delete;
0063 LVRange &operator=(const LVRange &) = delete;
0064 ~LVRange() = default;
0065
0066 void addEntry(LVScope *Scope, LVAddress LowerAddress, LVAddress UpperAddress);
0067 void addEntry(LVScope *Scope);
0068 LVScope *getEntry(LVAddress Address) const;
0069 LVScope *getEntry(LVAddress LowerAddress, LVAddress UpperAddress) const;
0070 bool hasEntry(LVAddress Low, LVAddress High) const;
0071 LVAddress getLower() const { return Lower; }
0072 LVAddress getUpper() const { return Upper; }
0073
0074 const LVRangeEntries &getEntries() const { return RangeEntries; }
0075
0076 void clear() {
0077 RangeEntries.clear();
0078 Lower = MaxAddress;
0079 Upper = 0;
0080 }
0081 bool empty() const { return RangeEntries.empty(); }
0082 void sort();
0083
0084 void startSearch();
0085 void endSearch() {}
0086
0087 void print(raw_ostream &OS, bool Full = true) const override;
0088 void printExtra(raw_ostream &OS, bool Full = true) const override {}
0089
0090 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0091 void dump() const override { print(dbgs()); }
0092 #endif
0093 };
0094
0095 }
0096 }
0097
0098 #endif