summaryrefslogtreecommitdiff
path: root/include/llvm/Support/DebugLoc.h
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-06-19 22:08:58 +0000
committerDevang Patel <dpatel@apple.com>2009-06-19 22:08:58 +0000
commit1e86a66b00b94adc4ad6977ef6b47c516ac62cec (patch)
tree32b5b7051ca2f1a59a70deee175fe7b8d88293a7 /include/llvm/Support/DebugLoc.h
parent14a55d952cf238fff42da53a75f39cf06dab184b (diff)
downloadllvm-1e86a66b00b94adc4ad6977ef6b47c516ac62cec.tar.gz
llvm-1e86a66b00b94adc4ad6977ef6b47c516ac62cec.tar.bz2
llvm-1e86a66b00b94adc4ad6977ef6b47c516ac62cec.tar.xz
mv CodeGen/DebugLoc.h Support/DebugLoc.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/DebugLoc.h')
-rw-r--r--include/llvm/Support/DebugLoc.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h
new file mode 100644
index 0000000000..5c089efc98
--- /dev/null
+++ b/include/llvm/Support/DebugLoc.h
@@ -0,0 +1,101 @@
+//===---- llvm/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
+// to describe and track debug location information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGLOC_H
+#define LLVM_DEBUGLOC_H
+
+#include "llvm/ADT/DenseMap.h"
+#include <vector>
+
+namespace llvm {
+ class GlobalVariable;
+
+ /// DebugLocTuple - Debug location tuple of filename id, line and column.
+ ///
+ 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);
+ }
+ };
+
+ /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr
+ /// to index into a vector of unique debug location tuples.
+ class DebugLoc {
+ unsigned Idx;
+
+ public:
+ DebugLoc() : Idx(~0U) {} // Defaults to invalid.
+
+ 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; }
+
+ /// isUnknown - Return true if there is no debug info for the SDNode /
+ /// MachineInstr.
+ 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); }
+ };
+
+ // Partially specialize DenseMapInfo for DebugLocTyple.
+ 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; }
+ };
+
+ /// DebugLocTracker - This class tracks debug location information.
+ ///
+ struct DebugLocTracker {
+ /// DebugLocations - A vector of unique DebugLocTuple's.
+ ///
+ std::vector<DebugLocTuple> DebugLocations;
+
+ /// DebugIdMap - This maps DebugLocTuple's to indices into the
+ /// DebugLocations vector.
+ DenseMap<DebugLocTuple, unsigned> DebugIdMap;
+
+ DebugLocTracker() {}
+ };
+
+} // end namespace llvm
+
+#endif /* LLVM_DEBUGLOC_H */