[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / include / llvm / DebugInfo / DWARF / DWARFDebugLoc.h
blobc79d98e34f6e0d3b3ba7a1942a025fe615bf1b66
1 //===- DWARFDebugLoc.h ------------------------------------------*- 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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H
12 #include "llvm/ADT/Optional.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/DebugInfo/DIContext.h"
15 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
16 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
17 #include <cstdint>
19 namespace llvm {
20 class DWARFUnit;
21 class MCRegisterInfo;
22 class raw_ostream;
24 class DWARFDebugLoc {
25 public:
26 /// A single location within a location list.
27 struct Entry {
28 /// The beginning address of the instruction range.
29 uint64_t Begin;
30 /// The ending address of the instruction range.
31 uint64_t End;
32 /// The location of the variable within the specified range.
33 SmallVector<uint8_t, 4> Loc;
36 /// A list of locations that contain one variable.
37 struct LocationList {
38 /// The beginning offset where this location list is stored in the debug_loc
39 /// section.
40 uint64_t Offset;
41 /// All the locations in which the variable is stored.
42 SmallVector<Entry, 2> Entries;
43 /// Dump this list on OS.
44 void dump(raw_ostream &OS, uint64_t BaseAddress, bool IsLittleEndian,
45 unsigned AddressSize, const MCRegisterInfo *MRI, DWARFUnit *U,
46 DIDumpOptions DumpOpts,
47 unsigned Indent) const;
50 private:
51 using LocationLists = SmallVector<LocationList, 4>;
53 /// A list of all the variables in the debug_loc section, each one describing
54 /// the locations in which the variable is stored.
55 LocationLists Locations;
57 unsigned AddressSize;
59 bool IsLittleEndian;
61 public:
62 /// Print the location lists found within the debug_loc section.
63 void dump(raw_ostream &OS, const MCRegisterInfo *RegInfo, DIDumpOptions DumpOpts,
64 Optional<uint64_t> Offset) const;
66 /// Parse the debug_loc section accessible via the 'data' parameter using the
67 /// address size also given in 'data' to interpret the address ranges.
68 void parse(const DWARFDataExtractor &data);
70 /// Return the location list at the given offset or nullptr.
71 LocationList const *getLocationListAtOffset(uint64_t Offset) const;
73 Expected<LocationList>
74 parseOneLocationList(const DWARFDataExtractor &Data, uint64_t *Offset);
77 class DWARFDebugLoclists {
78 public:
79 struct Entry {
80 uint8_t Kind;
81 uint64_t Offset;
82 uint64_t Value0;
83 uint64_t Value1;
84 SmallVector<uint8_t, 4> Loc;
85 void dump(raw_ostream &OS, uint64_t &BaseAddr, bool IsLittleEndian,
86 unsigned AddressSize, const MCRegisterInfo *MRI, DWARFUnit *U,
87 DIDumpOptions DumpOpts, unsigned Indent, size_t MaxEncodingStringLength) const;
90 struct LocationList {
91 uint64_t Offset;
92 SmallVector<Entry, 2> Entries;
93 void dump(raw_ostream &OS, uint64_t BaseAddr, bool IsLittleEndian,
94 unsigned AddressSize, const MCRegisterInfo *RegInfo,
95 DWARFUnit *U, DIDumpOptions DumpOpts, unsigned Indent) const;
98 private:
99 using LocationLists = SmallVector<LocationList, 4>;
101 LocationLists Locations;
103 unsigned AddressSize;
105 bool IsLittleEndian;
107 public:
108 void parse(DataExtractor data, uint64_t Offset, uint64_t EndOffset, uint16_t Version);
109 void dump(raw_ostream &OS, uint64_t BaseAddr, const MCRegisterInfo *RegInfo,
110 DIDumpOptions DumpOpts, Optional<uint64_t> Offset) const;
112 /// Return the location list at the given offset or nullptr.
113 LocationList const *getLocationListAtOffset(uint64_t Offset) const;
115 static Expected<LocationList> parseOneLocationList(const DataExtractor &Data,
116 uint64_t *Offset,
117 unsigned Version);
120 } // end namespace llvm
122 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGLOC_H