File indexing completed on 2026-05-10 08:43:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLOCATION_H
0015 #define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVLOCATION_H
0016
0017 #include "llvm/DebugInfo/LogicalView/Core/LVObject.h"
0018
0019 namespace llvm {
0020 namespace logicalview {
0021
0022 using LVLineRange = std::pair<LVLine *, LVLine *>;
0023
0024
0025 const LVSmall LVLocationMemberOffset = 0;
0026
0027 class LVOperation final {
0028
0029
0030
0031
0032
0033
0034
0035 LVSmall Opcode = 0;
0036 SmallVector<uint64_t> Operands;
0037
0038 public:
0039 LVOperation() = delete;
0040 LVOperation(LVSmall Opcode, ArrayRef<LVUnsigned> Operands)
0041 : Opcode(Opcode), Operands(Operands) {}
0042 LVOperation(const LVOperation &) = delete;
0043 LVOperation &operator=(const LVOperation &) = delete;
0044 ~LVOperation() = default;
0045
0046 LVSmall getOpcode() const { return Opcode; }
0047 std::string getOperandsDWARFInfo();
0048 std::string getOperandsCodeViewInfo();
0049
0050 void print(raw_ostream &OS, bool Full = true) const;
0051
0052 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0053 void dump() { print(dbgs()); }
0054 #endif
0055 };
0056
0057 class LVLocation : public LVObject {
0058 enum class Property {
0059 IsAddressRange,
0060 IsBaseClassOffset,
0061 IsBaseClassStep,
0062 IsClassOffset,
0063 IsFixedAddress,
0064 IsLocationSimple,
0065 IsGapEntry,
0066 IsOperation,
0067 IsOperationList,
0068 IsRegister,
0069 IsStackOffset,
0070 IsDiscardedRange,
0071 IsInvalidRange,
0072 IsInvalidLower,
0073 IsInvalidUpper,
0074 IsCallSite,
0075 LastEntry
0076 };
0077
0078 LVProperties<Property> Properties;
0079
0080
0081 bool hasAssociatedRange() const {
0082 return !getIsClassOffset() && !getIsDiscardedRange();
0083 }
0084
0085 protected:
0086
0087 LVLine *LowerLine = nullptr;
0088 LVLine *UpperLine = nullptr;
0089
0090
0091
0092
0093 LVAddress LowPC = 0;
0094 LVAddress HighPC = 0;
0095
0096 void setKind();
0097
0098 public:
0099 LVLocation() : LVObject() { setIsLocation(); }
0100 LVLocation(const LVLocation &) = delete;
0101 LVLocation &operator=(const LVLocation &) = delete;
0102 virtual ~LVLocation() = default;
0103
0104 PROPERTY(Property, IsAddressRange);
0105 PROPERTY(Property, IsBaseClassOffset);
0106 PROPERTY(Property, IsBaseClassStep);
0107 PROPERTY_1(Property, IsClassOffset, IsLocationSimple);
0108 PROPERTY_1(Property, IsFixedAddress, IsLocationSimple);
0109 PROPERTY(Property, IsLocationSimple);
0110 PROPERTY(Property, IsGapEntry);
0111 PROPERTY(Property, IsOperationList);
0112 PROPERTY(Property, IsOperation);
0113 PROPERTY(Property, IsRegister);
0114 PROPERTY_1(Property, IsStackOffset, IsLocationSimple);
0115 PROPERTY(Property, IsDiscardedRange);
0116 PROPERTY(Property, IsInvalidRange);
0117 PROPERTY(Property, IsInvalidLower);
0118 PROPERTY(Property, IsInvalidUpper);
0119 PROPERTY(Property, IsCallSite);
0120
0121 const char *kind() const override;
0122
0123 virtual void updateKind() {}
0124
0125
0126 const LVLine *getLowerLine() const { return LowerLine; }
0127 void setLowerLine(LVLine *Line) { LowerLine = Line; }
0128 const LVLine *getUpperLine() const { return UpperLine; }
0129 void setUpperLine(LVLine *Line) { UpperLine = Line; }
0130
0131
0132 LVAddress getLowerAddress() const override { return LowPC; }
0133 void setLowerAddress(LVAddress Address) override { LowPC = Address; }
0134 LVAddress getUpperAddress() const override { return HighPC; }
0135 void setUpperAddress(LVAddress Address) override { HighPC = Address; }
0136
0137 std::string getIntervalInfo() const;
0138
0139 bool validateRanges();
0140
0141
0142
0143
0144
0145
0146
0147 static bool calculateCoverage(LVLocations *Locations, unsigned &Factor,
0148 float &Percentage);
0149
0150 virtual void addObject(LVAddress LowPC, LVAddress HighPC,
0151 LVUnsigned SectionOffset, uint64_t LocDescOffset) {}
0152 virtual void addObject(LVSmall Opcode, ArrayRef<LVUnsigned> Operands) {}
0153
0154 static void print(LVLocations *Locations, raw_ostream &OS, bool Full = true);
0155 void printInterval(raw_ostream &OS, bool Full = true) const;
0156 void printRaw(raw_ostream &OS, bool Full = true) const;
0157 virtual void printRawExtra(raw_ostream &OS, bool Full = true) const {}
0158
0159 void print(raw_ostream &OS, bool Full = true) const override;
0160 void printExtra(raw_ostream &OS, bool Full = true) const override;
0161
0162 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0163 void dump() const override { print(dbgs()); }
0164 #endif
0165 };
0166
0167 class LVLocationSymbol final : public LVLocation {
0168
0169 std::unique_ptr<LVOperations> Entries;
0170
0171 void updateKind() override;
0172
0173 public:
0174 LVLocationSymbol() : LVLocation() {}
0175 LVLocationSymbol(const LVLocationSymbol &) = delete;
0176 LVLocationSymbol &operator=(const LVLocationSymbol &) = delete;
0177 ~LVLocationSymbol() = default;
0178
0179 void addObject(LVAddress LowPC, LVAddress HighPC, LVUnsigned SectionOffset,
0180 uint64_t LocDescOffset) override;
0181 void addObject(LVSmall Opcode, ArrayRef<LVUnsigned> Operands) override;
0182
0183 void printRawExtra(raw_ostream &OS, bool Full = true) const override;
0184 void printExtra(raw_ostream &OS, bool Full = true) const override;
0185 };
0186
0187 }
0188 }
0189
0190 #endif