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 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_DEBUGLOC_H
16 #define LLVM_CODEGEN_DEBUGLOC_H
18 #include "llvm/ADT/DenseMap.h"
23 /// DebugLocTuple - Debug location tuple of filename id, line and column.
25 struct DebugLocTuple {
26 unsigned Src, Line, Col;
28 DebugLocTuple(unsigned s, unsigned l, unsigned c)
29 : Src(s), Line(l), Col(c) {};
32 /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr
33 /// to index into a vector of unique debug location tuples.
38 DebugLoc() : Idx(~0U) {} // Defaults to invalid.
40 static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = 0; return L; }
41 static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
43 /// isInvalid - Return true if the DebugLoc is invalid.
44 bool isInvalid() const { return Idx == ~0U; }
46 /// isUnknown - Return true if there is no debug info for the SDNode /
48 bool isUnknown() const { return Idx == 0; }
51 // Partially specialize DenseMapInfo for DebugLocTyple.
52 template<> struct DenseMapInfo<DebugLocTuple> {
53 static inline DebugLocTuple getEmptyKey() {
54 return DebugLocTuple(~0U, ~0U, ~0U);
56 static inline DebugLocTuple getTombstoneKey() {
57 return DebugLocTuple(~1U, ~1U, ~1U);
59 static unsigned getHashValue(const DebugLocTuple &Val) {
60 return DenseMapInfo<unsigned>::getHashValue(Val.Src) ^
61 DenseMapInfo<unsigned>::getHashValue(Val.Line) ^
62 DenseMapInfo<unsigned>::getHashValue(Val.Col);
64 static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) {
65 return LHS.Src == RHS.Src &&
66 LHS.Line == RHS.Line &&
70 static bool isPod() { return true; }
73 /// DebugLocTracker - This class tracks debug location information.
75 struct DebugLocTracker {
76 /// DebugLocations - A vector of unique DebugLocTuple's.
78 std::vector<DebugLocTuple> DebugLocations;
80 /// DebugIdsMap - This maps DebugLocTuple's to indices into DebugLocations
82 DenseMap<DebugLocTuple, unsigned> DebugIdMap;
87 DebugLocations.clear();
92 } // end namespace llvm
94 #endif /* LLVM_CODEGEN_DEBUGLOC_H */