LLVM 22.0.0git
LVCompare.h
Go to the documentation of this file.
1//===-- LVCompare.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 LVCompare class, which is used to describe a logical
10// view comparison.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVCOMPARE_H
15#define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVCOMPARE_H
16
19
20namespace llvm {
21namespace logicalview {
22
23class LVReader;
24
25// Record the elements missing or added and their compare pass.
26using LVPassEntry = std::tuple<LVReader *, LVElement *, LVComparePass>;
27using LVPassTable = std::vector<LVPassEntry>;
28
29class LVCompare final {
30 raw_ostream &OS;
31 LVScopes ScopeStack;
32
33 // As the comparison is performed twice (by exchanging the reference
34 // and target readers) the element missing/added status does specify
35 // the comparison pass.
36 // By recording each missing/added elements along with its pass, it
37 // allows checking which elements were missing/added during each pass.
38 LVPassTable PassTable;
39
40 // Reader used on the LHS of the comparison.
41 // In the 'Missing' pass, it points to the reference reader.
42 // In the 'Added' pass it points to the target reader.
43 LVReader *Reader = nullptr;
44
45 bool FirstMissing = true;
46 bool PrintLines = false;
47 bool PrintScopes = false;
48 bool PrintSymbols = false;
49 bool PrintTypes = false;
50
51 static void setInstance(LVCompare *Compare);
52
53 void printCurrentStack();
54 void printSummary() const;
55
56public:
57 LVCompare() = delete;
59 LVCompare(const LVCompare &) = delete;
60 LVCompare &operator=(const LVCompare &) = delete;
61 ~LVCompare() = default;
62
64
65 // Scopes stack used during the missing/added reporting.
66 void push(LVScope *Scope) { ScopeStack.push_back(Scope); }
67 void pop() { ScopeStack.pop_back(); }
68
69 // Perform comparison between the 'Reference' and 'Target' scopes tree.
70 LLVM_ABI Error execute(LVReader *ReferenceReader, LVReader *TargetReader);
71
73 PassTable.emplace_back(Reader, Element, Pass);
74 }
75 const LVPassTable &getPassTable() const & { return PassTable; }
76
78 LLVM_ABI void print(raw_ostream &OS) const;
79
80#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
81 void dump() const { print(dbgs()); }
82#endif
83};
84
86
87} // end namespace logicalview
88} // end namespace llvm
89
90#endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVCOMPARE_H
aarch64 promote const
#define LLVM_ABI
Definition: Compiler.h:213
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:99
void push_back(const T &Elt)
Definition: SmallVector.h:414
LLVM_ABI void print(raw_ostream &OS) const
Definition: LVCompare.cpp:428
LLVM_ABI void printItem(LVElement *Element, LVComparePass Pass)
Definition: LVCompare.cpp:362
LVCompare(const LVCompare &)=delete
static LLVM_ABI LVCompare & getInstance()
Definition: LVCompare.cpp:101
LVCompare & operator=(const LVCompare &)=delete
const LVPassTable & getPassTable() const &
Definition: LVCompare.h:75
void push(LVScope *Scope)
Definition: LVCompare.h:66
LLVM_ABI Error execute(LVReader *ReferenceReader, LVReader *TargetReader)
Definition: LVCompare.cpp:118
void addPassEntry(LVReader *Reader, LVElement *Element, LVComparePass Pass)
Definition: LVCompare.h:72
The logical reader owns of all the logical elements created during the debug information parsing.
Definition: LVReader.h:61
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
std::tuple< LVReader *, LVElement *, LVComparePass > LVPassEntry
Definition: LVCompare.h:26
std::vector< LVPassEntry > LVPassTable
Definition: LVCompare.h:27
LVCompare & getComparator()
Definition: LVCompare.h:85
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:207