#ifndef LLVM_CODEGEN_DEBUGLOC_H
#define LLVM_CODEGEN_DEBUGLOC_H
#include "llvm/ADT/DenseMap.h"
#include <vector>
namespace llvm {
class GlobalVariable;
struct DebugLocTuple {
GlobalVariable *CompileUnit;
unsigned Line, Col;
DebugLocTuple(GlobalVariable *v, unsigned l, unsigned c)
: CompileUnit(v), Line(l), Col(c) {};
bool operator==(const DebugLocTuple &DLT) const {
return CompileUnit == DLT.CompileUnit &&
Line == DLT.Line && Col == DLT.Col;
}
bool operator!=(const DebugLocTuple &DLT) const {
return !(*this == DLT);
}
};
class DebugLoc {
unsigned Idx;
public:
DebugLoc() : Idx(~0U) {}
static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = ~0U; return L; }
static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
unsigned getIndex() const { return Idx; }
bool isUnknown() const { return Idx == ~0U; }
bool operator==(const DebugLoc &DL) const { return Idx == DL.Idx; }
bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
};
template<> struct DenseMapInfo<DebugLocTuple> {
static inline DebugLocTuple getEmptyKey() {
return DebugLocTuple(0, ~0U, ~0U);
}
static inline DebugLocTuple getTombstoneKey() {
return DebugLocTuple((GlobalVariable*)~1U, ~1U, ~1U);
}
static unsigned getHashValue(const DebugLocTuple &Val) {
return DenseMapInfo<GlobalVariable*>::getHashValue(Val.CompileUnit) ^
DenseMapInfo<unsigned>::getHashValue(Val.Line) ^
DenseMapInfo<unsigned>::getHashValue(Val.Col);
}
static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) {
return LHS.CompileUnit == RHS.CompileUnit &&
LHS.Line == RHS.Line &&
LHS.Col == RHS.Col;
}
static bool isPod() { return true; }
};
struct DebugLocTracker {
std::vector<DebugLocTuple> DebugLocations;
DenseMap<DebugLocTuple, unsigned> DebugIdMap;
DebugLocTracker() {}
};
}
#endif