2121namespace llvm {
2222class AsmPrinter ;
2323
24+ struct TargetIndexLocation {
25+ int Index;
26+ int Offset;
27+
28+ TargetIndexLocation () = default ;
29+ TargetIndexLocation (unsigned Idx, int64_t Offset)
30+ : Index(Idx), Offset(Offset) {}
31+
32+ bool operator ==(const TargetIndexLocation &Other) const {
33+ return Index == Other.Index && Offset == Other.Offset ;
34+ }
35+ };
36+
2437// / This struct describes location entries emitted in the .debug_loc
2538// / section.
2639class DebugLocEntry {
@@ -47,12 +60,20 @@ class DebugLocEntry {
4760 : Expression(Expr), EntryKind(E_Location), Loc(Loc) {
4861 assert (cast<DIExpression>(Expr)->isValid ());
4962 }
63+ Value (const DIExpression *Expr, TargetIndexLocation Loc)
64+ : Expression(Expr), EntryKind(E_TargetIndexLocation), TIL(Loc) {}
5065
5166 // / Any complex address location expression for this Value.
5267 const DIExpression *Expression;
5368
5469 // / Type of entry that this represents.
55- enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt };
70+ enum EntryType {
71+ E_Location,
72+ E_Integer,
73+ E_ConstantFP,
74+ E_ConstantInt,
75+ E_TargetIndexLocation
76+ };
5677 enum EntryType EntryKind;
5778
5879 // / Either a constant,
@@ -62,17 +83,25 @@ class DebugLocEntry {
6283 const ConstantInt *CIP;
6384 } Constant;
6485
65- // Or a location in the machine frame.
66- MachineLocation Loc;
86+ union {
87+ // Or a location in the machine frame.
88+ MachineLocation Loc;
89+ // Or a location from target specific location.
90+ TargetIndexLocation TIL;
91+ };
6792
6893 bool isLocation () const { return EntryKind == E_Location; }
94+ bool isTargetIndexLocation () const {
95+ return EntryKind == E_TargetIndexLocation;
96+ }
6997 bool isInt () const { return EntryKind == E_Integer; }
7098 bool isConstantFP () const { return EntryKind == E_ConstantFP; }
7199 bool isConstantInt () const { return EntryKind == E_ConstantInt; }
72100 int64_t getInt () const { return Constant.Int ; }
73101 const ConstantFP *getConstantFP () const { return Constant.CFP ; }
74102 const ConstantInt *getConstantInt () const { return Constant.CIP ; }
75103 MachineLocation getLoc () const { return Loc; }
104+ TargetIndexLocation getTargetIndexLocation () const { return TIL; }
76105 bool isFragment () const { return getExpression ()->isFragment (); }
77106 const DIExpression *getExpression () const { return Expression; }
78107 friend bool operator ==(const Value &, const Value &);
@@ -165,6 +194,8 @@ inline bool operator==(const DebugLocEntry::Value &A,
165194 switch (A.EntryKind ) {
166195 case DebugLocEntry::Value::E_Location:
167196 return A.Loc == B.Loc ;
197+ case DebugLocEntry::Value::E_TargetIndexLocation:
198+ return A.TIL == B.TIL ;
168199 case DebugLocEntry::Value::E_Integer:
169200 return A.Constant .Int == B.Constant .Int ;
170201 case DebugLocEntry::Value::E_ConstantFP:
0 commit comments