LLVM 19.0.0git
ExtractRanges.cpp
Go to the documentation of this file.
1//===- ExtractRanges.cpp ----------------------------------------*- 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
12#include <algorithm>
13#include <inttypes.h>
14
15namespace llvm {
16namespace gsym {
17
18void encodeRange(const AddressRange &Range, FileWriter &O, uint64_t BaseAddr) {
19 assert(Range.start() >= BaseAddr);
20 O.writeULEB(Range.start() - BaseAddr);
21 O.writeULEB(Range.size());
22}
23
26 const uint64_t AddrOffset = Data.getULEB128(&Offset);
27 const uint64_t Size = Data.getULEB128(&Offset);
28 const uint64_t StartAddr = BaseAddr + AddrOffset;
29
30 return {StartAddr, StartAddr + Size};
31}
32
33void encodeRanges(const AddressRanges &Ranges, FileWriter &O,
34 uint64_t BaseAddr) {
35 O.writeULEB(Ranges.size());
36 if (Ranges.empty())
37 return;
38 for (auto Range : Ranges)
39 encodeRange(Range, O, BaseAddr);
40}
41
44 Ranges.clear();
45 uint64_t NumRanges = Data.getULEB128(&Offset);
46 Ranges.reserve(NumRanges);
47 for (uint64_t RangeIdx = 0; RangeIdx < NumRanges; RangeIdx++)
48 Ranges.insert(decodeRange(Data, BaseAddr, Offset));
49}
50
52 Data.getULEB128(&Offset);
53 Data.getULEB128(&Offset);
54}
55
57 uint64_t NumRanges = Data.getULEB128(&Offset);
58 for (uint64_t I = 0; I < NumRanges; ++I)
60 return NumRanges;
61}
62
63} // namespace gsym
64
66 return OS << '[' << HEX64(R.start()) << " - " << HEX64(R.end()) << ")";
67}
68
70 size_t Size = AR.size();
71 for (size_t I = 0; I < Size; ++I) {
72 if (I)
73 OS << ' ';
74 OS << AR[I];
75 }
76 return OS;
77}
78
79} // namespace llvm
uint64_t Size
#define HEX64(v)
Definition: ExtractRanges.h:20
#define I(x, y, z)
Definition: MD5.cpp:58
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
A class that represents an address range.
Definition: AddressRanges.h:22
The AddressRanges class helps normalize address range collections.
A simplified binary data writer class that doesn't require targets, target definitions,...
Definition: FileWriter.h:29
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
AddressRange decodeRange(DataExtractor &Data, uint64_t BaseAddr, uint64_t &Offset)
AddressRange objects are encoded and decoded to be relative to a base address.
void encodeRanges(const AddressRanges &Ranges, FileWriter &O, uint64_t BaseAddr)
void decodeRanges(AddressRanges &Ranges, DataExtractor &Data, uint64_t BaseAddr, uint64_t &Offset)
Address ranges are decoded and encoded to be relative to a base address.
uint64_t skipRanges(DataExtractor &Data, uint64_t &Offset)
Skip an address range object in the specified data a the specified offset.
void encodeRange(const AddressRange &Range, FileWriter &O, uint64_t BaseAddr)
void skipRange(DataExtractor &Data, uint64_t &Offset)
Skip an address range object in the specified data a the specified offset.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:293