1 //===-- llvm/CodeGen/DebugLocEntry.h - Entry in debug_loc list -*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CODEGEN_ASMPRINTER_DEBUGLOCENTRY_H__
11 #define CODEGEN_ASMPRINTER_DEBUGLOCENTRY_H__
12 #include "llvm/IR/Constants.h"
13 #include "llvm/MC/MachineLocation.h"
14 #include "llvm/MC/MCSymbol.h"
17 class DwarfCompileUnit;
19 /// \brief This struct describes location entries emitted in the .debug_loc
22 // Begin and end symbols for the address range that this location is valid.
23 const MCSymbol *Begin;
26 // Type of entry that this represents.
27 enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt };
28 enum EntryType EntryKind;
32 const ConstantFP *CFP;
33 const ConstantInt *CIP;
36 // The location in the machine frame.
39 // The variable to which this location entry corresponds.
40 const MDNode *Variable;
42 // The compile unit to which this location entry is referenced by.
43 const DwarfCompileUnit *Unit;
46 DebugLocEntry() : Begin(0), End(0), Variable(0), Unit(0) {
49 DebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
50 const MDNode *V, const DwarfCompileUnit *U)
51 : Begin(B), End(E), Loc(L), Variable(V), Unit(U) {
53 EntryKind = E_Location;
55 DebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i,
56 const DwarfCompileUnit *U)
57 : Begin(B), End(E), Variable(0), Unit(U) {
59 EntryKind = E_Integer;
61 DebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantFP *FPtr,
62 const DwarfCompileUnit *U)
63 : Begin(B), End(E), Variable(0), Unit(U) {
65 EntryKind = E_ConstantFP;
67 DebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantInt *IPtr,
68 const DwarfCompileUnit *U)
69 : Begin(B), End(E), Variable(0), Unit(U) {
71 EntryKind = E_ConstantInt;
74 /// \brief Empty entries are also used as a trigger to emit temp label. Such
75 /// labels are referenced is used to find debug_loc offset for a given DIE.
76 bool isEmpty() const { return Begin == 0 && End == 0; }
77 bool Merge(const DebugLocEntry &Next) {
78 if (End != Next.Begin)
81 if (EntryKind != Next.EntryKind)
86 if (Loc != Next.Loc) return false;
88 if (Constants.Int != Next.Constants.Int) return false;
90 if (Constants.CFP != Next.Constants.CFP) return false;
92 if (Constants.CIP != Next.Constants.CIP) return false;
97 bool isLocation() const { return EntryKind == E_Location; }
98 bool isInt() const { return EntryKind == E_Integer; }
99 bool isConstantFP() const { return EntryKind == E_ConstantFP; }
100 bool isConstantInt() const { return EntryKind == E_ConstantInt; }
101 int64_t getInt() const { return Constants.Int; }
102 const ConstantFP *getConstantFP() const { return Constants.CFP; }
103 const ConstantInt *getConstantInt() const { return Constants.CIP; }
104 const MDNode *getVariable() const { return Variable; }
105 const MCSymbol *getBeginSym() const { return Begin; }
106 const MCSymbol *getEndSym() const { return End; }
107 const DwarfCompileUnit *getCU() const { return Unit; }
108 MachineLocation getLoc() const { return Loc; }