1 //===---- llvm/CodeGen/DebugLoc.h - Debug Location Information --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a number of light weight data structures used by the code
11 // generator to describe and track debug location information.
13 #ifndef LLVM_CODEGEN_DEBUGLOC_H
14 #define LLVM_CODEGEN_DEBUGLOC_H
16 #include "llvm/ADT/DenseMap.h"
21 /// DebugLocTuple - Debug location tuple of filename id, line and column.
23 struct DebugLocTuple {
24 unsigned Src, Line, Col;
26 DebugLocTuple(unsigned s, unsigned l, unsigned c)
27 : Src(s), Line(l), Col(c) {};
30 /// DebugLoc - Debug location id. This is carried by SDNode and
31 /// MachineInstr to index into a vector of unique debug location tuples.
36 DebugLoc() : Idx(~0U) {}
38 static DebugLoc getNoDebugLoc() { DebugLoc L; L.Idx = 0; return L; }
39 static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
41 bool isInvalid() { return Idx == ~0U; }
42 bool isUnknown() { return Idx == 0; }
45 struct DebugLocTupleDenseMapInfo {
46 static inline DebugLocTuple getEmptyKey() {
47 return DebugLocTuple(~0U, ~0U, ~0U);
49 static inline DebugLocTuple getTombstoneKey() {
50 return DebugLocTuple(~1U, ~1U, ~1U);
52 static unsigned getHashValue(const DebugLocTuple &Val) {
53 return DenseMapInfo<unsigned>::getHashValue(Val.Src) ^
54 DenseMapInfo<unsigned>::getHashValue(Val.Line) ^
55 DenseMapInfo<unsigned>::getHashValue(Val.Col);
57 static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) {
58 return LHS.Src == RHS.Src &&
59 LHS.Line == RHS.Line &&
63 static bool isPod() { return true; }
66 typedef DenseMap<DebugLocTuple, unsigned, DebugLocTupleDenseMapInfo>
69 /// DebugLocTracker - This class tracks debug location information.
71 struct DebugLocTracker {
72 // DebugLocations - A vector of unique DebugLocTuple's.
74 std::vector<DebugLocTuple> DebugLocations;
76 // DebugIdsMap - This maps DebugLocTuple's to indices into
77 // DebugLocations vector.
78 DebugIdMapType DebugIdMap;
83 DebugLocations.clear();
88 } // end namespace llvm
90 #endif /* LLVM_CODEGEN_DEBUGLOC_H */