aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/CodeGen/DebugLoc.h73
-rw-r--r--include/llvm/CodeGen/FastISel.h1
-rw-r--r--include/llvm/CodeGen/MachineFunction.h10
3 files changed, 77 insertions, 7 deletions
diff --git a/include/llvm/CodeGen/DebugLoc.h b/include/llvm/CodeGen/DebugLoc.h
index 77e6733..495baf4 100644
--- a/include/llvm/CodeGen/DebugLoc.h
+++ b/include/llvm/CodeGen/DebugLoc.h
@@ -20,18 +20,77 @@
namespace llvm {
class GlobalVariable;
+ class MachineFunction;
- /// DebugLocTuple - Debug location tuple of filename id, line and column.
+ /// DebugScope - Debug scope id. This is carried into DebugLocTuple to index
+ /// into a vector of DebugScopeInfos. Provides the ability to associate a
+ /// SDNode/MachineInstr with the debug scope that it belongs to.
+ ///
+ class DebugScope {
+ unsigned Idx;
+
+ public:
+ DebugScope() : Idx(~0U) {} // Defaults to null.
+
+ static DebugScope getInvalid() { DebugScope S; S.Idx = ~0U; return S; }
+ static DebugScope get(unsigned idx) { DebugScope S; S.Idx = idx; return S; }
+
+ unsigned getIndex() const { return Idx; }
+
+ /// isInvalid - Return true if it doesn't refer to any scope.
+ bool isInvalid() const { return Idx == ~0U; }
+
+ bool operator==(const DebugScope &DS) const { return Idx == DS.Idx; }
+ bool operator!=(const DebugScope &DS) const { return !(*this == DS); }
+ };
+
+ /// DebugScopeInfo - Contains info about the scope global variable and the
+ /// parent debug scope. DebugScope is only a "cookie" that can point to a
+ /// specific DebugScopeInfo.
+ ///
+ struct DebugScopeInfo {
+ GlobalVariable *GV;
+ DebugScope Parent;
+
+ DebugScopeInfo(GlobalVariable *gv, DebugScope parent)
+ : GV(gv), Parent(parent) {}
+ DebugScopeInfo()
+ : GV(0), Parent(DebugScope::getInvalid()) {}
+ };
+
+ /// DebugScopeTracker - Create and keep track of the debug scope while
+ /// entering/exiting subprograms and blocks. Used by the instruction
+ /// selectors.
+ ///
+ class DebugScopeTracker {
+ DebugScope CurScope;
+
+ public:
+ /// getCurScope - The current debug scope that we "entered" through
+ /// EnterDebugScope.
+ DebugScope getCurScope() const { return CurScope; }
+
+ /// EnterDebugScope - Start a new debug scope. ScopeGV can be a DISubprogram
+ /// or a DIBlock.
+ void EnterDebugScope(GlobalVariable *ScopeGV, MachineFunction &MF);
+
+ /// ExitDebugScope - "Pop" a DISubprogram or a DIBlock.
+ void ExitDebugScope(GlobalVariable *ScopeGV, MachineFunction &MF);
+ };
+
+ /// DebugLocTuple - Debug location tuple of a DICompileUnit global variable,
+ /// debug scope, line and column.
///
struct DebugLocTuple {
GlobalVariable *CompileUnit;
+ DebugScope Scope;
unsigned Line, Col;
- DebugLocTuple(GlobalVariable *v, unsigned l, unsigned c)
- : CompileUnit(v), Line(l), Col(c) {};
+ DebugLocTuple(GlobalVariable *v, DebugScope s, unsigned l, unsigned c)
+ : CompileUnit(v), Scope(s), Line(l), Col(c) {};
bool operator==(const DebugLocTuple &DLT) const {
- return CompileUnit == DLT.CompileUnit &&
+ return CompileUnit == DLT.CompileUnit && Scope == DLT.Scope &&
Line == DLT.Line && Col == DLT.Col;
}
bool operator!=(const DebugLocTuple &DLT) const {
@@ -63,18 +122,20 @@ namespace llvm {
// Partially specialize DenseMapInfo for DebugLocTyple.
template<> struct DenseMapInfo<DebugLocTuple> {
static inline DebugLocTuple getEmptyKey() {
- return DebugLocTuple(0, ~0U, ~0U);
+ return DebugLocTuple(0, DebugScope::getInvalid(), ~0U, ~0U);
}
static inline DebugLocTuple getTombstoneKey() {
- return DebugLocTuple((GlobalVariable*)~1U, ~1U, ~1U);
+ return DebugLocTuple((GlobalVariable*)~1U,DebugScope::get(~1U), ~1U, ~1U);
}
static unsigned getHashValue(const DebugLocTuple &Val) {
return DenseMapInfo<GlobalVariable*>::getHashValue(Val.CompileUnit) ^
+ DenseMapInfo<unsigned>::getHashValue(Val.Scope.getIndex()) ^
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.Scope == RHS.Scope &&
LHS.Line == RHS.Line &&
LHS.Col == RHS.Col;
}
diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h
index 38c1710..df5c5bb 100644
--- a/include/llvm/CodeGen/FastISel.h
+++ b/include/llvm/CodeGen/FastISel.h
@@ -57,6 +57,7 @@ protected:
MachineFrameInfo &MFI;
MachineConstantPool &MCP;
DebugLoc DL;
+ DebugScopeTracker DbgScopeTrack;
const TargetMachine &TM;
const TargetData &TD;
const TargetInstrInfo &TII;
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h
index a110e58..d1744a0 100644
--- a/include/llvm/CodeGen/MachineFunction.h
+++ b/include/llvm/CodeGen/MachineFunction.h
@@ -111,6 +111,8 @@ class MachineFunction : private Annotation {
// Tracks debug locations.
DebugLocTracker DebugLocInfo;
+ std::vector<DebugScopeInfo> DbgScopeInfos;
+
public:
MachineFunction(const Function *Fn, const TargetMachine &TM);
~MachineFunction();
@@ -332,7 +334,7 @@ public:
/// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
/// source file, line, and column. If none currently exists, create a new
/// DebugLocTuple, and insert it into the DebugIdMap.
- unsigned getOrCreateDebugLocID(GlobalVariable *CompileUnit,
+ unsigned getOrCreateDebugLocID(GlobalVariable *CompileUnit, DebugScope Scope,
unsigned Line, unsigned Col);
/// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object.
@@ -345,6 +347,12 @@ public:
/// setDefaultDebugLoc - Get the default debug location for the machine
/// function.
void setDefaultDebugLoc(DebugLoc DL) { DefaultDebugLoc = DL; }
+
+ /// CreateDebugScope - Create a new debug scope.
+ DebugScope CreateDebugScope(GlobalVariable *ScopeGV, DebugScope Parent);
+
+ /// getDebugScopeInfo - Get the DebugScopeInfo for a given DebugScope object.
+ const DebugScopeInfo &getDebugScopeInfo(DebugScope DS) const;
};
//===--------------------------------------------------------------------===//