LLVM 20.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 <inttypes.h>
13
14namespace llvm {
15namespace gsym {
16
17void encodeRange(const AddressRange &Range, FileWriter &O, uint64_t BaseAddr) {
18 assert(Range.start() >= BaseAddr);
19 O.writeULEB(Range.start() - BaseAddr);
20 O.writeULEB(Range.size());
21}
22
25 const uint64_t AddrOffset = Data.getULEB128(&Offset);
26 const uint64_t Size = Data.getULEB128(&Offset);
27 const uint64_t StartAddr = BaseAddr + AddrOffset;
28
29 return {StartAddr, StartAddr + Size};
30}
31
32void encodeRanges(const AddressRanges &Ranges, FileWriter &O,
33 uint64_t BaseAddr) {
34 O.writeULEB(Ranges.size());
35 if (Ranges.empty())
36 return;
37 for (auto Range : Ranges)
38 encodeRange(Range, O, BaseAddr);
39}
40
43 Ranges.clear();
44 uint64_t NumRanges = Data.getULEB128(&Offset);
45 Ranges.reserve(NumRanges);
46 for (uint64_t RangeIdx = 0; RangeIdx < NumRanges; RangeIdx++)
47 Ranges.insert(decodeRange(Data, BaseAddr, Offset));
48}
49
51 Data.getULEB128(&Offset);
52 Data.getULEB128(&Offset);
53}
54
56 uint64_t NumRanges = Data.getULEB128(&Offset);
57 for (uint64_t I = 0; I < NumRanges; ++I)
59 return NumRanges;
60}
61
62} // namespace gsym
63
65 return OS << '[' << HEX64(R.start()) << " - " << HEX64(R.end()) << ")";
66}
67
69 size_t Size = AR.size();
70 for (size_t I = 0; I < Size; ++I) {
71 if (I)
72 OS << ' ';
73 OS << AR[I];
74 }
75 return OS;
76}
77
78} // 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:480
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:303