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-26 05:01:18 +00:00
|
|
|
class GlobalVariable;
|
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-08-26 05:01:18 +00:00
|
|
|
GlobalVariable *CompileUnit;
|
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()
|
|
|
|
: CompileUnit(0), Line(~0U), Col(~0U) {};
|
|
|
|
|
2009-08-26 05:01:18 +00:00
|
|
|
DebugLocTuple(GlobalVariable *v, unsigned l, unsigned c)
|
|
|
|
: CompileUnit(v), Line(l), Col(c) {};
|
2009-02-19 09:16:38 +00:00
|
|
|
|
|
|
|
bool operator==(const DebugLocTuple &DLT) const {
|
2009-05-21 00:04:55 +00:00
|
|
|
return CompileUnit == DLT.CompileUnit &&
|
2009-04-30 23:22:31 +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-01-27 21:15:07 +00:00
|
|
|
// Partially specialize DenseMapInfo for DebugLocTyple.
|
|
|
|
template<> struct DenseMapInfo<DebugLocTuple> {
|
2009-01-26 07:41:49 +00:00
|
|
|
static inline DebugLocTuple getEmptyKey() {
|
2009-05-21 00:04:55 +00:00
|
|
|
return DebugLocTuple(0, ~0U, ~0U);
|
2009-01-26 07:41:49 +00:00
|
|
|
}
|
|
|
|
static inline DebugLocTuple getTombstoneKey() {
|
2009-08-26 05:01:18 +00:00
|
|
|
return DebugLocTuple((GlobalVariable*)~1U, ~1U, ~1U);
|
2009-01-26 07:41:49 +00:00
|
|
|
}
|
|
|
|
static unsigned getHashValue(const DebugLocTuple &Val) {
|
2009-08-26 05:01:18 +00:00
|
|
|
return DenseMapInfo<GlobalVariable*>::getHashValue(Val.CompileUnit) ^
|
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-04-30 23:22:31 +00:00
|
|
|
return LHS.CompileUnit == RHS.CompileUnit &&
|
|
|
|
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 */
|