LLVM  8.0.1
DWARFAddressRange.h
Go to the documentation of this file.
1 //===- DWARFAddressRange.h --------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H
11 #define LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H
12 
14 #include <cstdint>
15 #include <tuple>
16 #include <vector>
17 
18 namespace llvm {
19 
20 class raw_ostream;
21 
23  uint64_t LowPC;
24  uint64_t HighPC;
25  uint64_t SectionIndex;
26 
27  DWARFAddressRange() = default;
28 
29  /// Used for unit testing.
30  DWARFAddressRange(uint64_t LowPC, uint64_t HighPC, uint64_t SectionIndex = 0)
31  : LowPC(LowPC), HighPC(HighPC), SectionIndex(SectionIndex) {}
32 
33  /// Returns true if LowPC is smaller or equal to HighPC. This accounts for
34  /// dead-stripped ranges.
35  bool valid() const { return LowPC <= HighPC; }
36 
37  /// Returns true if [LowPC, HighPC) intersects with [RHS.LowPC, RHS.HighPC).
38  bool intersects(const DWARFAddressRange &RHS) const {
39  assert(valid() && RHS.valid());
40  // Empty ranges can't intersect.
41  if (LowPC == HighPC || RHS.LowPC == RHS.HighPC)
42  return false;
43  return LowPC < RHS.HighPC && RHS.LowPC < HighPC;
44  }
45 
46  /// Returns true if [LowPC, HighPC) fully contains [RHS.LowPC, RHS.HighPC).
47  bool contains(const DWARFAddressRange &RHS) const {
48  assert(valid() && RHS.valid());
49  return LowPC <= RHS.LowPC && RHS.HighPC <= HighPC;
50  }
51 
52  void dump(raw_ostream &OS, uint32_t AddressSize,
53  DIDumpOptions DumpOpts = {}) const;
54 };
55 
56 static inline bool operator<(const DWARFAddressRange &LHS,
57  const DWARFAddressRange &RHS) {
58  return std::tie(LHS.LowPC, LHS.HighPC) < std::tie(RHS.LowPC, RHS.HighPC);
59 }
60 
62 
63 /// DWARFAddressRangesVector - represents a set of absolute address ranges.
64 using DWARFAddressRangesVector = std::vector<DWARFAddressRange>;
65 
66 } // end namespace llvm
67 
68 #endif // LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
bool intersects(const DWARFAddressRange &RHS) const
Returns true if [LowPC, HighPC) intersects with [RHS.LowPC, RHS.HighPC).
Container for dump options that control which debug information will be dumped.
Definition: DIContext.h:159
void dump(raw_ostream &OS, uint32_t AddressSize, DIDumpOptions DumpOpts={}) const
bool valid() const
Returns true if LowPC is smaller or equal to HighPC.
DWARFAddressRange(uint64_t LowPC, uint64_t HighPC, uint64_t SectionIndex=0)
Used for unit testing.
bool contains(const DWARFAddressRange &RHS) const
Returns true if [LowPC, HighPC) fully contains [RHS.LowPC, RHS.HighPC).
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:2039
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:326
std::vector< DWARFAddressRange > DWARFAddressRangesVector
DWARFAddressRangesVector - represents a set of absolute address ranges.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46