LLVM: lib/CodeGen/AsmPrinter/DebugLocEntry.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGLOCENTRY_H

10#define LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGLOCENTRY_H

11

13#include "llvm/Config/llvm-config.h"

19

20namespace llvm {

22

23

36

37

38

39

41

42

43 enum EntryType {

44 E_Location,

45 E_Integer,

46 E_ConstantFP,

47 E_ConstantInt,

48 E_TargetIndexLocation

49 };

50 enum EntryType EntryKind;

51

52

53 union {

58

59 union {

60

62

64 };

65

66public:

67 DbgValueLocEntry(int64_t i) : EntryKind(E_Integer) { Constant.Int = i; }

69 Constant.CFP = CFP;

70 }

72 Constant.CIP = CIP;

73 }

76 : EntryKind(E_TargetIndexLocation), TIL(Loc) {}

77

78 bool isLocation() const { return EntryKind == E_Location; }

80 return EntryKind == E_Location && Loc.isIndirect();

81 }

83 return EntryKind == E_TargetIndexLocation;

84 }

85 bool isInt() const { return EntryKind == E_Integer; }

86 bool isConstantFP() const { return EntryKind == E_ConstantFP; }

87 bool isConstantInt() const { return EntryKind == E_ConstantInt; }

88 int64_t getInt() const { return Constant.Int; }

94#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

97 llvm::dbgs() << "Loc = { reg=" << Loc.getReg() << " ";

98 if (Loc.isIndirect())

102 Constant.CIP->dump();

104 Constant.CFP->dump();

105 }

106#endif

107};

108

109

110

112

114

116

117 bool IsVariadic;

118

119public:

121 : Expression(Expr), ValueLocEntries(Locs), IsVariadic(true) {}

122

124 bool IsVariadic)

125 : Expression(Expr), ValueLocEntries(Locs), IsVariadic(IsVariadic) {

126#ifndef NDEBUG

128 any\_of(Locs, [](auto LE) { return LE.isLocation(); }));

129 if (!IsVariadic) {

130 assert(ValueLocEntries.size() == 1);

131 }

132#endif

133 }

134

136 : Expression(Expr), ValueLocEntries(1, Loc), IsVariadic(false) {

138 "DBG_VALUE with a machine location must have a valid expression.");

139 }

140

145

146 if (ValueLocEntries.size() != Other.ValueLocEntries.size())

147 return false;

148 bool ThisIsIndirect =

149 !IsVariadic && ValueLocEntries[0].isIndirectLocation();

150 bool OtherIsIndirect =

151 Other.IsVariadic && Other.ValueLocEntries[0].isIndirectLocation();

152

154 Other.Expression, OtherIsIndirect))

155 return false;

156

157

158 if (ThisIsIndirect || OtherIsIndirect) {

163 }

164

165 return ValueLocEntries == Other.ValueLocEntries;

166 }

171#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

174 DV.dump();

175 if (Expression)

176 Expression->dump();

177 }

178#endif

179};

180

181

182

184

187

188

189

191

192public:

193

194

195

198 : Begin(Begin), End(End) {

200 }

201

202

203

204

205

207

208 if (End != Next.Begin)

209 return false;

210 if (Values.size() != Next.Values.size())

211 return false;

212 for (unsigned EntryIdx = 0; EntryIdx < Values.size(); ++EntryIdx)

213 if (!Values[EntryIdx].isEquivalent(Next.Values[EntryIdx]))

214 return false;

215 End = Next.End;

216 return true;

217 }

218

223 Values.append(Vals.begin(), Vals.end());

226 return V.isFragment();

227 })) && "must either have a single value or multiple pieces");

228 }

229

230

231

233

234

235

236 if (Values.size() == 1)

237 return;

241 return A.getExpression() == B.getExpression();

242 }),

243 Values.end());

244 }

245

246

251};

252

253

255 if (A.EntryKind != B.EntryKind)

256 return false;

257

258 switch (A.EntryKind) {

259 case DbgValueLocEntry::E_Location:

260 return A.Loc == B.Loc;

261 case DbgValueLocEntry::E_TargetIndexLocation:

262 return A.TIL == B.TIL;

263 case DbgValueLocEntry::E_Integer:

264 return A.Constant.Int == B.Constant.Int;

265 case DbgValueLocEntry::E_ConstantFP:

266 return A.Constant.CFP == B.Constant.CFP;

267 case DbgValueLocEntry::E_ConstantInt:

268 return A.Constant.CIP == B.Constant.CIP;

269 }

271}

272

273

275 return A.ValueLocEntries == B.ValueLocEntries &&

276 A.Expression == B.Expression && A.IsVariadic == B.IsVariadic;

277}

278

279

282 return A.getExpression()->getFragmentInfo()->OffsetInBits <

283 B.getExpression()->getFragmentInfo()->OffsetInBits;

284}

285

286}

287

288#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

This file contains the declarations for the subclasses of Constant, which represent the different fla...

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

This class is intended to be used as a driving class for all asm writers.

ConstantFP - Floating Point Values [float, double].

This is the shared class of boolean and integer constants.

This is an important base class in LLVM.

Basic type, like 'int' or 'float'.

LLVM_ABI bool isEntryValue() const

Check if the expression consists of exactly one entry value operand.

bool isFragment() const

Return whether this is a piece of an aggregate variable.

static LLVM_ABI bool isEqualExpression(const DIExpression *FirstExpr, bool FirstIndirect, const DIExpression *SecondExpr, bool SecondIndirect)

Determines whether two debug values should produce equivalent DWARF expressions, using their DIExpres...

LLVM_ABI bool isValid() const

A single location or constant within a variable location description, with either a single entry (wit...

Definition DebugLocEntry.h:40

DbgValueLocEntry(const ConstantFP *CFP)

Definition DebugLocEntry.h:68

TargetIndexLocation getTargetIndexLocation() const

Definition DebugLocEntry.h:92

MachineLocation Loc

Or a location in the machine frame.

Definition DebugLocEntry.h:61

const ConstantInt * CIP

Definition DebugLocEntry.h:56

bool isInt() const

Definition DebugLocEntry.h:85

const ConstantFP * getConstantFP() const

Definition DebugLocEntry.h:89

int64_t getInt() const

Definition DebugLocEntry.h:88

friend bool operator==(const DbgValueLocEntry &, const DbgValueLocEntry &)

Compare two DbgValueLocEntries for equality.

Definition DebugLocEntry.h:254

bool isConstantFP() const

Definition DebugLocEntry.h:86

int64_t Int

Definition DebugLocEntry.h:54

DbgValueLocEntry(MachineLocation Loc)

Definition DebugLocEntry.h:74

DbgValueLocEntry(int64_t i)

Definition DebugLocEntry.h:67

bool isConstantInt() const

Definition DebugLocEntry.h:87

TargetIndexLocation TIL

Or a location from target specific location.

Definition DebugLocEntry.h:63

bool isLocation() const

Definition DebugLocEntry.h:78

bool isIndirectLocation() const

Definition DebugLocEntry.h:79

const ConstantInt * getConstantInt() const

Definition DebugLocEntry.h:90

LLVM_DUMP_METHOD void dump() const

Definition DebugLocEntry.h:95

bool isTargetIndexLocation() const

Definition DebugLocEntry.h:82

MachineLocation getLoc() const

Definition DebugLocEntry.h:91

DbgValueLocEntry(const ConstantInt *CIP)

Definition DebugLocEntry.h:71

DbgValueLocEntry(TargetIndexLocation Loc)

Definition DebugLocEntry.h:75

const ConstantFP * CFP

Definition DebugLocEntry.h:55

The location of a single variable, composed of an expression and 0 or more DbgValueLocEntries.

Definition DebugLocEntry.h:111

DbgValueLoc(const DIExpression *Expr, DbgValueLocEntry Loc)

Definition DebugLocEntry.h:135

DbgValueLoc(const DIExpression *Expr, ArrayRef< DbgValueLocEntry > Locs, bool IsVariadic)

Definition DebugLocEntry.h:123

friend bool operator==(const DbgValueLoc &, const DbgValueLoc &)

Compare two DbgValueLocs for equality.

Definition DebugLocEntry.h:274

ArrayRef< DbgValueLocEntry > getLocEntries() const

Definition DebugLocEntry.h:168

DbgValueLoc(const DIExpression *Expr, ArrayRef< DbgValueLocEntry > Locs)

Definition DebugLocEntry.h:120

const DIExpression * getExpression() const

Definition DebugLocEntry.h:167

bool isFragment() const

Definition DebugLocEntry.h:141

LLVM_DUMP_METHOD void dump() const

Definition DebugLocEntry.h:172

bool isVariadic() const

Definition DebugLocEntry.h:143

bool isEquivalent(const DbgValueLoc &Other) const

Definition DebugLocEntry.h:144

friend bool operator<(const DbgValueLoc &, const DbgValueLoc &)

Compare two fragments based on their offset.

Definition DebugLocEntry.h:280

bool isEntryVal() const

Definition DebugLocEntry.h:142

DebugLocEntry(const MCSymbol *Begin, const MCSymbol *End, ArrayRef< DbgValueLoc > Vals)

Create a location list entry for the range [Begin, End).

Definition DebugLocEntry.h:196

void sortUniqueValues()

Definition DebugLocEntry.h:232

void addValues(ArrayRef< DbgValueLoc > Vals)

Definition DebugLocEntry.h:222

ArrayRef< DbgValueLoc > getValues() const

Definition DebugLocEntry.h:221

const MCSymbol * getBeginSym() const

Definition DebugLocEntry.h:219

const MCSymbol * getEndSym() const

Definition DebugLocEntry.h:220

bool MergeRanges(const DebugLocEntry &Next)

Attempt to merge this DebugLocEntry with Next and return true if the merge was successful.

Definition DebugLocEntry.h:206

Builder for DebugLocStream lists.

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

This is an optimization pass for GlobalISel generic memory operations.

bool operator<(int64_t V1, const APSInt &V2)

bool all_of(R &&range, UnaryPredicate P)

Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.

auto unique(Range &&R, Predicate P)

bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)

bool any_of(R &&range, UnaryPredicate P)

Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.

void sort(IteratorTy Start, IteratorTy End)

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

FunctionAddr VTableAddr Next

This struct describes target specific location.

Definition DebugLocEntry.h:24

TargetIndexLocation()=default

bool operator==(const TargetIndexLocation &Other) const

Definition DebugLocEntry.h:32

TargetIndexLocation(unsigned Idx, int64_t Offset)

Definition DebugLocEntry.h:29

int Index

Definition DebugLocEntry.h:25

int Offset

Definition DebugLocEntry.h:26