2009-01-26 07:41:49 +00:00
|
|
|
//===---- llvm/CodeGen/DebugLoc.h - Debug Location Information --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines a number of light weight data structures used by the code
|
|
|
|
// generator to describe and track debug location information.
|
2009-01-28 01:19:52 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-01-26 07:41:49 +00:00
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_DEBUGLOC_H
|
|
|
|
#define LLVM_CODEGEN_DEBUGLOC_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
/// DebugLocTuple - Debug location tuple of filename id, line and column.
|
|
|
|
///
|
|
|
|
struct DebugLocTuple {
|
2009-01-26 07:53:42 +00:00
|
|
|
unsigned Src, Line, Col;
|
2009-01-26 07:41:49 +00:00
|
|
|
|
2009-01-26 07:53:42 +00:00
|
|
|
DebugLocTuple(unsigned s, unsigned l, unsigned c)
|
|
|
|
: Src(s), Line(l), Col(c) {};
|
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-01-27 21:15:07 +00:00
|
|
|
static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = 0; 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
|
|
|
/// isInvalid - Return true if the DebugLoc is invalid.
|
2009-01-27 21:15:07 +00:00
|
|
|
bool isInvalid() const { return Idx == ~0U; }
|
|
|
|
|
2009-01-28 01:19:52 +00:00
|
|
|
/// isUnknown - Return true if there is no debug info for the SDNode /
|
|
|
|
/// MachineInstr.
|
2009-01-27 21:15:07 +00:00
|
|
|
bool isUnknown() const { return Idx == 0; }
|
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() {
|
|
|
|
return DebugLocTuple(~0U, ~0U, ~0U);
|
|
|
|
}
|
|
|
|
static inline DebugLocTuple getTombstoneKey() {
|
|
|
|
return DebugLocTuple(~1U, ~1U, ~1U);
|
|
|
|
}
|
|
|
|
static unsigned getHashValue(const DebugLocTuple &Val) {
|
2009-01-26 07:53:42 +00:00
|
|
|
return DenseMapInfo<unsigned>::getHashValue(Val.Src) ^
|
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-01-26 07:53:42 +00:00
|
|
|
return LHS.Src == RHS.Src &&
|
2009-01-26 07:41:49 +00:00
|
|
|
LHS.Line == RHS.Line &&
|
2009-01-26 07:53:42 +00:00
|
|
|
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-01-28 01:19:52 +00:00
|
|
|
/// DebugIdsMap - This maps DebugLocTuple's to indices into 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
|
|
|
|
|
|
|
~DebugLocTracker() {
|
|
|
|
DebugLocations.clear();
|
|
|
|
DebugIdMap.clear();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif /* LLVM_CODEGEN_DEBUGLOC_H */
|