2009-06-19 22:08:58 +00:00
|
|
|
//===---- llvm/DebugLoc.h - Debug Location Information ----------*- C++ -*-===//
|
2009-01-26 07:41:49 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-06-19 22:08:58 +00:00
|
|
|
// This file defines a number of light weight data structures used
|
|
|
|
// to describe and track debug location information.
|
2009-01-28 01:19:52 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-01-26 07:41:49 +00:00
|
|
|
|
2009-06-19 22:08:58 +00:00
|
|
|
#ifndef LLVM_DEBUGLOC_H
|
|
|
|
#define LLVM_DEBUGLOC_H
|
2009-01-26 07:41:49 +00:00
|
|
|
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
2009-08-28 23:24:31 +00:00
|
|
|
class MDNode;
|
2009-01-26 07:41:49 +00:00
|
|
|
|
2009-05-21 00:04:55 +00:00
|
|
|
/// DebugLocTuple - Debug location tuple of filename id, line and column.
|
2009-01-26 07:41:49 +00:00
|
|
|
///
|
|
|
|
struct DebugLocTuple {
|
2009-10-13 23:28:53 +00:00
|
|
|
MDNode *Scope;
|
|
|
|
MDNode *InlinedAtLoc;
|
2009-04-30 23:22:31 +00:00
|
|
|
unsigned Line, Col;
|
2009-01-26 07:41:49 +00:00
|
|
|
|
2009-07-16 21:07:26 +00:00
|
|
|
DebugLocTuple()
|
2009-10-14 20:39:01 +00:00
|
|
|
: Scope(0), InlinedAtLoc(0), Line(~0U), Col(~0U) {}
|
2009-07-16 21:07:26 +00:00
|
|
|
|
2009-10-01 01:15:28 +00:00
|
|
|
DebugLocTuple(MDNode *n, MDNode *i, unsigned l, unsigned c)
|
2009-10-14 20:39:01 +00:00
|
|
|
: Scope(n), InlinedAtLoc(i), Line(l), Col(c) {}
|
2009-02-19 09:16:38 +00:00
|
|
|
|
|
|
|
bool operator==(const DebugLocTuple &DLT) const {
|
2009-10-13 23:28:53 +00:00
|
|
|
return Scope == DLT.Scope &&
|
|
|
|
InlinedAtLoc == DLT.InlinedAtLoc &&
|
2009-10-01 01:15:28 +00:00
|
|
|
Line == DLT.Line && Col == DLT.Col;
|
2009-02-19 09:16:38 +00:00
|
|
|
}
|
|
|
|
bool operator!=(const DebugLocTuple &DLT) const {
|
|
|
|
return !(*this == DLT);
|
|
|
|
}
|
2009-01-26 07:41:49 +00:00
|
|
|
};
|
|
|
|
|
2009-01-28 01:19:52 +00:00
|
|
|
/// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr
|
|
|
|
/// to index into a vector of unique debug location tuples.
|
2009-01-26 07:41:49 +00:00
|
|
|
class DebugLoc {
|
|
|
|
unsigned Idx;
|
|
|
|
|
|
|
|
public:
|
2009-01-27 21:15:07 +00:00
|
|
|
DebugLoc() : Idx(~0U) {} // Defaults to invalid.
|
2009-01-26 07:41:49 +00:00
|
|
|
|
2009-02-17 01:04:54 +00:00
|
|
|
static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = ~0U; return L; }
|
2009-01-26 07:41:49 +00:00
|
|
|
static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
|
|
|
|
|
2009-02-03 22:49:14 +00:00
|
|
|
unsigned getIndex() const { return Idx; }
|
|
|
|
|
2009-01-28 01:19:52 +00:00
|
|
|
/// isUnknown - Return true if there is no debug info for the SDNode /
|
|
|
|
/// MachineInstr.
|
2009-02-17 01:04:54 +00:00
|
|
|
bool isUnknown() const { return Idx == ~0U; }
|
2009-02-06 21:34:12 +00:00
|
|
|
|
2009-02-06 23:17:54 +00:00
|
|
|
bool operator==(const DebugLoc &DL) const { return Idx == DL.Idx; }
|
|
|
|
bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
|
2009-01-26 07:41:49 +00:00
|
|
|
};
|
|
|
|
|
2009-09-23 20:40:16 +00:00
|
|
|
// Specialize DenseMapInfo for DebugLocTuple.
|
2009-01-27 21:15:07 +00:00
|
|
|
template<> struct DenseMapInfo<DebugLocTuple> {
|
2009-01-26 07:41:49 +00:00
|
|
|
static inline DebugLocTuple getEmptyKey() {
|
2009-10-01 01:15:28 +00:00
|
|
|
return DebugLocTuple(0, 0, ~0U, ~0U);
|
2009-01-26 07:41:49 +00:00
|
|
|
}
|
|
|
|
static inline DebugLocTuple getTombstoneKey() {
|
2009-10-01 01:15:28 +00:00
|
|
|
return DebugLocTuple((MDNode*)~1U, (MDNode*)~1U, ~1U, ~1U);
|
2009-01-26 07:41:49 +00:00
|
|
|
}
|
|
|
|
static unsigned getHashValue(const DebugLocTuple &Val) {
|
2009-10-13 23:28:53 +00:00
|
|
|
return DenseMapInfo<MDNode*>::getHashValue(Val.Scope) ^
|
|
|
|
DenseMapInfo<MDNode*>::getHashValue(Val.InlinedAtLoc) ^
|
2009-01-26 07:41:49 +00:00
|
|
|
DenseMapInfo<unsigned>::getHashValue(Val.Line) ^
|
|
|
|
DenseMapInfo<unsigned>::getHashValue(Val.Col);
|
|
|
|
}
|
|
|
|
static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) {
|
2009-10-13 23:28:53 +00:00
|
|
|
return LHS.Scope == RHS.Scope &&
|
|
|
|
LHS.InlinedAtLoc == RHS.InlinedAtLoc &&
|
|
|
|
LHS.Line == RHS.Line &&
|
|
|
|
LHS.Col == RHS.Col;
|
2009-01-26 07:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool isPod() { return true; }
|
|
|
|
};
|
|
|
|
|
|
|
|
/// DebugLocTracker - This class tracks debug location information.
|
|
|
|
///
|
|
|
|
struct DebugLocTracker {
|
2009-01-28 01:19:52 +00:00
|
|
|
/// DebugLocations - A vector of unique DebugLocTuple's.
|
|
|
|
///
|
2009-01-26 07:41:49 +00:00
|
|
|
std::vector<DebugLocTuple> DebugLocations;
|
|
|
|
|
2009-02-11 00:18:15 +00:00
|
|
|
/// DebugIdMap - This maps DebugLocTuple's to indices into the
|
|
|
|
/// DebugLocations vector.
|
2009-01-27 21:15:07 +00:00
|
|
|
DenseMap<DebugLocTuple, unsigned> DebugIdMap;
|
2009-01-26 07:41:49 +00:00
|
|
|
|
2009-01-26 23:47:30 +00:00
|
|
|
DebugLocTracker() {}
|
2009-01-26 07:41:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
2009-06-19 22:08:58 +00:00
|
|
|
#endif /* LLVM_DEBUGLOC_H */
|