LLVM 19.0.0git
LVLine.h
Go to the documentation of this file.
1//===-- LVLine.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//===----------------------------------------------------------------------===//
8//
9// This file defines the LVLine class, which is used to describe a debug
10// information line.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLINE_H
15#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLINE_H
16
18
19namespace llvm {
20namespace logicalview {
21
22enum class LVLineKind {
29 IsNewStatement, // Shared with CodeView 'IsStatement' flag.
31 IsAlwaysStepInto, // CodeView
32 IsNeverStepInto, // CodeView
34};
35using LVLineKindSet = std::set<LVLineKind>;
36using LVLineDispatch = std::map<LVLineKind, LVLineGetFunction>;
37using LVLineRequest = std::vector<LVLineGetFunction>;
38
39// Class to represent a logical line.
40class LVLine : public LVElement {
41 // Typed bitvector with kinds for this line.
43 static LVLineDispatch Dispatch;
44
45 // Find the current line in the given 'Targets'.
46 LVLine *findIn(const LVLines *Targets) const;
47
48public:
50 setIsLine();
51 setIncludeInPrint();
52 }
53 LVLine(const LVLine &) = delete;
54 LVLine &operator=(const LVLine &) = delete;
55 virtual ~LVLine() = default;
56
57 static bool classof(const LVElement *Element) {
59 }
60
71
72 const char *kind() const override;
73
74 // Use the offset to store the line address.
75 uint64_t getAddress() const { return getOffset(); }
76 void setAddress(uint64_t address) { setOffset(address); }
77
78 // String used for printing objects with no line number.
79 std::string noLineAsString(bool ShowZero = false) const override;
80
81 // Line number for display; in the case of Inlined Functions, we use the
82 // DW_AT_call_line attribute; otherwise use DW_AT_decl_line attribute.
83 std::string lineNumberAsString(bool ShowZero = false) const override {
84 return lineAsString(getLineNumber(), getDiscriminator(), ShowZero);
85 }
86
87 static LVLineDispatch &getDispatch() { return Dispatch; }
88
89 // Iterate through the 'References' set and check that all its elements
90 // are present in the 'Targets' set. For a missing element, mark its
91 // parents as missing.
92 static void markMissingParents(const LVLines *References,
93 const LVLines *Targets);
94
95 // Returns true if current line is logically equal to the given 'Line'.
96 virtual bool equals(const LVLine *Line) const;
97
98 // Returns true if the given 'References' are logically equal to the
99 // given 'Targets'.
100 static bool equals(const LVLines *References, const LVLines *Targets);
101
102 // Report the current line as missing or added during comparison.
103 void report(LVComparePass Pass) override;
104
105 void print(raw_ostream &OS, bool Full = true) const override;
106 void printExtra(raw_ostream &OS, bool Full = true) const override {}
107
108#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
109 void dump() const override { print(dbgs()); }
110#endif
111};
112
113// Class to represent a DWARF line record object.
114class LVLineDebug final : public LVLine {
115 // Discriminator value (DW_LNE_set_discriminator). The DWARF standard
116 // defines the discriminator as an unsigned LEB128 integer.
117 uint32_t Discriminator = 0;
118
119public:
120 LVLineDebug() : LVLine() { setIsLineDebug(); }
121 LVLineDebug(const LVLineDebug &) = delete;
123 ~LVLineDebug() = default;
124
125 // Additional line information. It includes attributes that describes
126 // states in the machine instructions (basic block, end prologue, etc).
127 std::string statesInfo(bool Formatted) const;
128
129 // Access DW_LNE_set_discriminator attribute.
130 uint32_t getDiscriminator() const override { return Discriminator; }
133 setIsDiscriminator();
134 }
135
136 // Returns true if current line is logically equal to the given 'Line'.
137 bool equals(const LVLine *Line) const override;
138
139 void printExtra(raw_ostream &OS, bool Full = true) const override;
140};
141
142// Class to represent an assembler line extracted from the text section.
143class LVLineAssembler final : public LVLine {
144public:
145 LVLineAssembler() : LVLine() { setIsLineAssembler(); }
148 ~LVLineAssembler() = default;
149
150 // Print blanks as the line number.
151 std::string noLineAsString(bool ShowZero) const override {
152 return std::string(8, ' ');
153 };
154
155 // Returns true if current line is logically equal to the given 'Line'.
156 bool equals(const LVLine *Line) const override;
157
158 void printExtra(raw_ostream &OS, bool Full = true) const override;
159};
160
161} // end namespace logicalview
162} // end namespace llvm
163
164#endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLINE_H
raw_pwrite_stream & OS
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
LLVM Value Representation.
Definition: Value.h:74
virtual uint32_t getDiscriminator() const
Definition: LVElement.h:255
LVSubclassID getSubclassID() const
Definition: LVElement.h:140
std::string noLineAsString(bool ShowZero) const override
Definition: LVLine.h:151
LVLineAssembler(const LVLineAssembler &)=delete
void printExtra(raw_ostream &OS, bool Full=true) const override
Definition: LVLine.cpp:218
bool equals(const LVLine *Line) const override
Definition: LVLine.cpp:214
LVLineAssembler & operator=(const LVLineAssembler &)=delete
bool equals(const LVLine *Line) const override
Definition: LVLine.cpp:193
LVLineDebug & operator=(const LVLineDebug &)=delete
void setDiscriminator(uint32_t Value) override
Definition: LVLine.h:131
LVLineDebug(const LVLineDebug &)=delete
uint32_t getDiscriminator() const override
Definition: LVLine.h:130
std::string statesInfo(bool Formatted) const
Definition: LVLine.cpp:151
void printExtra(raw_ostream &OS, bool Full=true) const override
Definition: LVLine.cpp:199
KIND(LVLineKind, IsEpilogueBegin)
std::string lineNumberAsString(bool ShowZero=false) const override
Definition: LVLine.h:83
std::string noLineAsString(bool ShowZero=false) const override
Definition: LVLine.cpp:62
KIND(LVLineKind, IsNeverStepInto)
static LVLineDispatch & getDispatch()
Definition: LVLine.h:87
void setAddress(uint64_t address)
Definition: LVLine.h:76
virtual ~LVLine()=default
uint64_t getAddress() const
Definition: LVLine.h:75
KIND(LVLineKind, IsLineAssembler)
static void markMissingParents(const LVLines *References, const LVLines *Targets)
Definition: LVLine.cpp:69
KIND(LVLineKind, IsPrologueEnd)
KIND(LVLineKind, IsBasicBlock)
static bool classof(const LVElement *Element)
Definition: LVLine.h:57
void printExtra(raw_ostream &OS, bool Full=true) const override
Definition: LVLine.h:106
KIND(LVLineKind, IsDiscriminator)
KIND(LVLineKind, IsAlwaysStepInto)
KIND(LVLineKind, IsLineDebug)
LVLine & operator=(const LVLine &)=delete
KIND(LVLineKind, IsEndSequence)
void dump() const override
Definition: LVLine.h:109
void report(LVComparePass Pass) override
Definition: LVLine.cpp:136
const char * kind() const override
Definition: LVLine.cpp:40
void print(raw_ostream &OS, bool Full=true) const override
Definition: LVLine.cpp:140
LVLine(const LVLine &)=delete
KIND(LVLineKind, IsNewStatement)
virtual bool equals(const LVLine *Line) const
Definition: LVLine.cpp:120
std::string lineAsString(uint32_t LineNumber, LVHalf Discriminator, bool ShowZero) const
Definition: LVObject.cpp:52
uint32_t getLineNumber() const
Definition: LVObject.h:275
void setOffset(LVOffset DieOffset)
Definition: LVObject.h:239
LVOffset getOffset() const
Definition: LVObject.h:238
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
std::set< LVLineKind > LVLineKindSet
Definition: LVLine.h:35
std::vector< LVLineGetFunction > LVLineRequest
Definition: LVLine.h:37
std::map< LVLineKind, LVLineGetFunction > LVLineDispatch
Definition: LVLine.h:36
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163