Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:42

0001 //===-- LVLine.h ------------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the LVLine class, which is used to describe a debug
0010 // information line.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLINE_H
0015 #define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLINE_H
0016 
0017 #include "llvm/DebugInfo/LogicalView/Core/LVElement.h"
0018 
0019 namespace llvm {
0020 namespace logicalview {
0021 
0022 enum class LVLineKind {
0023   IsBasicBlock,
0024   IsDiscriminator,
0025   IsEndSequence,
0026   IsEpilogueBegin,
0027   IsLineDebug,
0028   IsLineAssembler,
0029   IsNewStatement, // Shared with CodeView 'IsStatement' flag.
0030   IsPrologueEnd,
0031   IsAlwaysStepInto, // CodeView
0032   IsNeverStepInto,  // CodeView
0033   LastEntry
0034 };
0035 using LVLineKindSet = std::set<LVLineKind>;
0036 using LVLineDispatch = std::map<LVLineKind, LVLineGetFunction>;
0037 using LVLineRequest = std::vector<LVLineGetFunction>;
0038 
0039 // Class to represent a logical line.
0040 class LVLine : public LVElement {
0041   // Typed bitvector with kinds for this line.
0042   LVProperties<LVLineKind> Kinds;
0043   static LVLineDispatch Dispatch;
0044 
0045   // Find the current line in the given 'Targets'.
0046   LVLine *findIn(const LVLines *Targets) const;
0047 
0048 public:
0049   LVLine() : LVElement(LVSubclassID::LV_LINE) {
0050     setIsLine();
0051     setIncludeInPrint();
0052   }
0053   LVLine(const LVLine &) = delete;
0054   LVLine &operator=(const LVLine &) = delete;
0055   virtual ~LVLine() = default;
0056 
0057   static bool classof(const LVElement *Element) {
0058     return Element->getSubclassID() == LVSubclassID::LV_LINE;
0059   }
0060 
0061   KIND(LVLineKind, IsBasicBlock);
0062   KIND(LVLineKind, IsDiscriminator);
0063   KIND(LVLineKind, IsEndSequence);
0064   KIND(LVLineKind, IsEpilogueBegin);
0065   KIND(LVLineKind, IsLineDebug);
0066   KIND(LVLineKind, IsLineAssembler);
0067   KIND(LVLineKind, IsNewStatement);
0068   KIND(LVLineKind, IsPrologueEnd);
0069   KIND(LVLineKind, IsAlwaysStepInto);
0070   KIND(LVLineKind, IsNeverStepInto);
0071 
0072   const char *kind() const override;
0073 
0074   // Use the offset to store the line address.
0075   uint64_t getAddress() const { return getOffset(); }
0076   void setAddress(uint64_t address) { setOffset(address); }
0077 
0078   // String used for printing objects with no line number.
0079   std::string noLineAsString(bool ShowZero = false) const override;
0080 
0081   // Line number for display; in the case of Inlined Functions, we use the
0082   // DW_AT_call_line attribute; otherwise use DW_AT_decl_line attribute.
0083   std::string lineNumberAsString(bool ShowZero = false) const override {
0084     return lineAsString(getLineNumber(), getDiscriminator(), ShowZero);
0085   }
0086 
0087   static LVLineDispatch &getDispatch() { return Dispatch; }
0088 
0089   // Iterate through the 'References' set and check that all its elements
0090   // are present in the 'Targets' set. For a missing element, mark its
0091   // parents as missing.
0092   static void markMissingParents(const LVLines *References,
0093                                  const LVLines *Targets);
0094 
0095   // Returns true if current line is logically equal to the given 'Line'.
0096   virtual bool equals(const LVLine *Line) const;
0097 
0098   // Returns true if the given 'References' are logically equal to the
0099   // given 'Targets'.
0100   static bool equals(const LVLines *References, const LVLines *Targets);
0101 
0102   // Report the current line as missing or added during comparison.
0103   void report(LVComparePass Pass) override;
0104 
0105   void print(raw_ostream &OS, bool Full = true) const override;
0106   void printExtra(raw_ostream &OS, bool Full = true) const override {}
0107 
0108 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0109   void dump() const override { print(dbgs()); }
0110 #endif
0111 };
0112 
0113 // Class to represent a DWARF line record object.
0114 class LVLineDebug final : public LVLine {
0115   // Discriminator value (DW_LNE_set_discriminator). The DWARF standard
0116   // defines the discriminator as an unsigned LEB128 integer.
0117   uint32_t Discriminator = 0;
0118 
0119 public:
0120   LVLineDebug() : LVLine() { setIsLineDebug(); }
0121   LVLineDebug(const LVLineDebug &) = delete;
0122   LVLineDebug &operator=(const LVLineDebug &) = delete;
0123   ~LVLineDebug() = default;
0124 
0125   // Additional line information. It includes attributes that describes
0126   // states in the machine instructions (basic block, end prologue, etc).
0127   std::string statesInfo(bool Formatted) const;
0128 
0129   // Access DW_LNE_set_discriminator attribute.
0130   uint32_t getDiscriminator() const override { return Discriminator; }
0131   void setDiscriminator(uint32_t Value) override {
0132     Discriminator = Value;
0133     setIsDiscriminator();
0134   }
0135 
0136   // Returns true if current line is logically equal to the given 'Line'.
0137   bool equals(const LVLine *Line) const override;
0138 
0139   void printExtra(raw_ostream &OS, bool Full = true) const override;
0140 };
0141 
0142 // Class to represent an assembler line extracted from the text section.
0143 class LVLineAssembler final : public LVLine {
0144 public:
0145   LVLineAssembler() : LVLine() { setIsLineAssembler(); }
0146   LVLineAssembler(const LVLineAssembler &) = delete;
0147   LVLineAssembler &operator=(const LVLineAssembler &) = delete;
0148   ~LVLineAssembler() = default;
0149 
0150   // Print blanks as the line number.
0151   std::string noLineAsString(bool ShowZero) const override {
0152     return std::string(8, ' ');
0153   };
0154 
0155   // Returns true if current line is logically equal to the given 'Line'.
0156   bool equals(const LVLine *Line) const override;
0157 
0158   void printExtra(raw_ostream &OS, bool Full = true) const override;
0159 };
0160 
0161 } // end namespace logicalview
0162 } // end namespace llvm
0163 
0164 #endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLINE_H