1//===- AddressRanges.h ------------------------------------------*- C++ -*-===// 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 7//===----------------------------------------------------------------------===// 9#ifndef LLVM_ADT_ADDRESSRANGES_H 10#define LLVM_ADT_ADDRESSRANGES_H 20/// A class that represents an address range. The range is specified using 21/// a start and an end address: [Start, End). 34return Start <= R.Start && R.End <= End;
37return Start < R.End && R.Start < End;
40return Start == R.Start && End == R.End;
44return std::make_pair(Start, End) < std::make_pair(R.Start, R.End);
52/// The AddressRangesBase class presents the base functionality for the 53/// normalized address ranges collection. This class keeps a sorted vector 54/// of AddressRange-like objects and can perform searches efficiently. 55/// The address ranges are always sorted and never contain any invalid, 56/// empty or intersected address ranges. 76typename Collection::const_iterator It =
find(
Addr,
Addr + 1);
83typename Collection::const_iterator
begin()
const{
returnRanges.begin(); }
84typename Collection::const_iterator
end()
const{
returnRanges.end(); }
101 std::partition_point(
Ranges.begin(),
Ranges.end(), [=](
constT &R) {
102 return AddressRange(R).start() <= Start;
116/// The AddressRanges class helps normalize address range collections. 117/// This class keeps a sorted vector of AddressRange objects and can perform 118/// insertions and searches efficiently. Intersecting([100,200), [150,300)) 119/// and adjacent([100,200), [200,300)) address ranges are combined during 137 *It = {It->start(), std::max(It->end(),
Range.end())};
158/// AddressRangesMap class maps values to the address ranges. 159/// It keeps normalized address ranges and corresponding values. 160/// This class keeps a sorted vector of AddressRangeValuePair objects 161/// and can perform insertions and searches efficiently. 162/// Intersecting([100,200), [150,300)) ranges splitted into non-conflicting 163/// parts([100,200), [200,300)). Adjacent([100,200), [200,300)) address 164/// ranges are not combined during insertion. 171// Search for range which is less than or equal incoming Range. 174 return R.Range.start() <= Range.start();
180while (!
Range.empty()) {
181// Inserted range does not overlap with any range. 182// Store it into the Ranges collection. 188// Inserted range partially overlaps with current range. 189// Store not overlapped part of inserted range. 190if (
Range.start() < It->Range.start()) {
197// Inserted range fully overlaps with current range. 198if (
Range.end() <= It->Range.end())
201// Inserted range partially overlaps with current range. 202// Remove overlapped part from the inserted range. 203if (
Range.start() < It->Range.end())
213#endif// LLVM_ADT_ADDRESSRANGES_H static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallVector class.
A class that represents an address range.
AddressRange(uint64_t S, uint64_t E)
bool operator<(const AddressRange &R) const
bool contains(const AddressRange &R) const
bool intersects(const AddressRange &R) const
bool operator!=(const AddressRange &R) const
bool contains(uint64_t Addr) const
bool operator==(const AddressRange &R) const
The AddressRangesBase class presents the base functionality for the normalized address ranges collect...
const T & operator[](size_t i) const
void reserve(size_t Capacity)
bool contains(uint64_t Addr) const
bool operator==(const AddressRangesBase< T > &RHS) const
SmallVector< T > Collection
Collection::const_iterator find(uint64_t Start, uint64_t End) const
std::optional< T > getRangeThatContains(uint64_t Addr) const
bool contains(AddressRange Range) const
Collection::const_iterator end() const
Collection::const_iterator begin() const
AddressRangesMap class maps values to the address ranges.
void insert(AddressRange Range, int64_t Value)
The AddressRanges class helps normalize address range collections.
Collection::const_iterator insert(AddressRange Range)
iterator erase(const_iterator CI)
iterator insert(iterator I, T &&Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
Value(Type *Ty, unsigned scid)
This is an optimization pass for GlobalISel generic memory operations.
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)