LLVM 22.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
19
20namespace llvm {
21namespace logicalview {
22
23enum class LVLineKind {
30 IsNewStatement, // Shared with CodeView 'IsStatement' flag.
32 IsAlwaysStepInto, // CodeView
33 IsNeverStepInto, // CodeView
35};
36using LVLineKindSet = std::set<LVLineKind>;
37using LVLineDispatch = std::map<LVLineKind, LVLineGetFunction>;
38using LVLineRequest = std::vector<LVLineGetFunction>;
39
40// Class to represent a logical line.
41class LLVM_ABI LVLine : public LVElement {
42 // Typed bitvector with kinds for this line.
44 static LVLineDispatch Dispatch;
45
46 // Find the current line in the given 'Targets'.
47 LVLine *findIn(const LVLines *Targets) const;
48
49public:
51 setIsLine();
52 setIncludeInPrint();
53 }
54 LVLine(const LVLine &) = delete;
55 LVLine &operator=(const LVLine &) = delete;
56 virtual ~LVLine() = default;
57
58 static bool classof(const LVElement *Element) {
59 return Element->getSubclassID() == LVSubclassID::LV_LINE;
60 }
61
62 KIND(LVLineKind, IsBasicBlock);
63 KIND(LVLineKind, IsDiscriminator);
64 KIND(LVLineKind, IsEndSequence);
65 KIND(LVLineKind, IsEpilogueBegin);
66 KIND(LVLineKind, IsLineDebug);
67 KIND(LVLineKind, IsLineAssembler);
68 KIND(LVLineKind, IsNewStatement);
69 KIND(LVLineKind, IsPrologueEnd);
70 KIND(LVLineKind, IsAlwaysStepInto);
71 KIND(LVLineKind, IsNeverStepInto);
72
73 const char *kind() const override;
74
75 // Use the offset to store the line address.
76 uint64_t getAddress() const { return getOffset(); }
77 void setAddress(uint64_t address) { setOffset(address); }
78
79 // String used for printing objects with no line number.
80 std::string noLineAsString(bool ShowZero = false) const override;
81
82 // Line number for display; in the case of Inlined Functions, we use the
83 // DW_AT_call_line attribute; otherwise use DW_AT_decl_line attribute.
84 std::string lineNumberAsString(bool ShowZero = false) const override {
85 return lineAsString(getLineNumber(), getDiscriminator(), ShowZero);
86 }
87
88 static LVLineDispatch &getDispatch() { return Dispatch; }
89
90 // Iterate through the 'References' set and check that all its elements
91 // are present in the 'Targets' set. For a missing element, mark its
92 // parents as missing.
93 static void markMissingParents(const LVLines *References,
94 const LVLines *Targets);
95
96 // Returns true if current line is logically equal to the given 'Line'.
97 virtual bool equals(const LVLine *Line) const;
98
99 // Returns true if the given 'References' are logically equal to the
100 // given 'Targets'.
101 static bool equals(const LVLines *References, const LVLines *Targets);
102
103 // Report the current line as missing or added during comparison.
104 void report(LVComparePass Pass) override;
105
106 void print(raw_ostream &OS, bool Full = true) const override;
107 void printExtra(raw_ostream &OS, bool Full = true) const override {}
108};
109
110// Class to represent a DWARF line record object.
111class LLVM_ABI LVLineDebug final : public LVLine {
112 // Discriminator value (DW_LNE_set_discriminator). The DWARF standard
113 // defines the discriminator as an unsigned LEB128 integer.
115
116public:
117 LVLineDebug() : LVLine() { setIsLineDebug(); }
118 LVLineDebug(const LVLineDebug &) = delete;
120 ~LVLineDebug() = default;
121
122 // Additional line information. It includes attributes that describes
123 // states in the machine instructions (basic block, end prologue, etc).
124 std::string statesInfo(bool Formatted) const;
125
126 // Access DW_LNE_set_discriminator attribute.
127 uint32_t getDiscriminator() const override { return Discriminator; }
130 setIsDiscriminator();
131 }
132
133 // Returns true if current line is logically equal to the given 'Line'.
134 bool equals(const LVLine *Line) const override;
135
136 void printExtra(raw_ostream &OS, bool Full = true) const override;
137};
138
139// Class to represent an assembler line extracted from the text section.
140class LLVM_ABI LVLineAssembler final : public LVLine {
141public:
142 LVLineAssembler() : LVLine() { setIsLineAssembler(); }
145 ~LVLineAssembler() = default;
146
147 // Print blanks as the line number.
148 std::string noLineAsString(bool ShowZero) const override {
149 return std::string(8, ' ');
150 };
151
152 // Returns true if current line is logically equal to the given 'Line'.
153 bool equals(const LVLine *Line) const override;
154
155 void printExtra(raw_ostream &OS, bool Full = true) const override;
156};
157
158} // end namespace logicalview
159} // end namespace llvm
160
161#endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLINE_H
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
#define LLVM_ABI
Definition: Compiler.h:213
static std::optional< int32_t > getOffset(ArrayRef< int32_t > Offsets, size_t Idx)
raw_pwrite_stream & OS
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:99
LLVM Value Representation.
Definition: Value.h:75
LVSubclassID getSubclassID() const
Definition: LVElement.h:148
std::string noLineAsString(bool ShowZero) const override
Definition: LVLine.h:148
LVLineAssembler(const LVLineAssembler &)=delete
LVLineAssembler & operator=(const LVLineAssembler &)=delete
LVLineDebug & operator=(const LVLineDebug &)=delete
void setDiscriminator(uint32_t Value) override
Definition: LVLine.h:128
LVLineDebug(const LVLineDebug &)=delete
uint32_t getDiscriminator() const override
Definition: LVLine.h:127
KIND(LVLineKind, IsEpilogueBegin)
std::string lineNumberAsString(bool ShowZero=false) const override
Definition: LVLine.h:84
KIND(LVLineKind, IsNeverStepInto)
static LVLineDispatch & getDispatch()
Definition: LVLine.h:88
void setAddress(uint64_t address)
Definition: LVLine.h:77
virtual ~LVLine()=default
uint64_t getAddress() const
Definition: LVLine.h:76
KIND(LVLineKind, IsLineAssembler)
KIND(LVLineKind, IsPrologueEnd)
KIND(LVLineKind, IsBasicBlock)
static bool classof(const LVElement *Element)
Definition: LVLine.h:58
void printExtra(raw_ostream &OS, bool Full=true) const override
Definition: LVLine.h:107
KIND(LVLineKind, IsDiscriminator)
KIND(LVLineKind, IsAlwaysStepInto)
KIND(LVLineKind, IsLineDebug)
LVLine & operator=(const LVLine &)=delete
KIND(LVLineKind, IsEndSequence)
LVLine(const LVLine &)=delete
KIND(LVLineKind, IsNewStatement)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
std::set< LVLineKind > LVLineKindSet
Definition: LVLine.h:36
std::vector< LVLineGetFunction > LVLineRequest
Definition: LVLine.h:38
std::map< LVLineKind, LVLineGetFunction > LVLineDispatch
Definition: LVLine.h:37
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18