aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJim Laskey <jlaskey@mac.com>2005-12-16 22:45:29 +0000
committerJim Laskey <jlaskey@mac.com>2005-12-16 22:45:29 +0000
commitf5395cee6a24699a016b2e379cf4804b09ce5030 (patch)
treef3d1e7436810c4ed6e5bcbe66b60cb50ae866724 /include
parentd9e0ba49a4cf288eee9b58857b92a89f5a141c4b (diff)
downloadexternal_llvm-f5395cee6a24699a016b2e379cf4804b09ce5030.zip
external_llvm-f5395cee6a24699a016b2e379cf4804b09ce5030.tar.gz
external_llvm-f5395cee6a24699a016b2e379cf4804b09ce5030.tar.bz2
Added source file/line correspondence for dwarf (PowerPC only at this point.)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24748 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/MachineDebugInfo.h80
-rw-r--r--include/llvm/CodeGen/MachineFunction.h10
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h6
3 files changed, 96 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/MachineDebugInfo.h b/include/llvm/CodeGen/MachineDebugInfo.h
new file mode 100644
index 0000000..0dba586
--- /dev/null
+++ b/include/llvm/CodeGen/MachineDebugInfo.h
@@ -0,0 +1,80 @@
+//===-- llvm/CodeGen/MachineDebugInfo.h -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by James M. Laskey and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Collect debug information for a module. This information should be in a
+// neutral form that can be used by different debugging schemes.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CODEGEN_MACHINEDEBUGINFO_H
+#define LLVM_CODEGEN_MACHINEDEBUGINFO_H
+
+#include <string>
+#include <map>
+#include <vector>
+
+namespace llvm {
+//===----------------------------------------------------------------------===//
+/// MachineDebugInfo - This class contains debug information specific to a
+/// module. Queries can be made by different debugging schemes and reformated
+/// for specific use.
+///
+class MachineDebugInfo {
+private:
+ // convenience types
+ typedef std::map<std::string, unsigned> StrIntMap;
+ typedef StrIntMap::iterator StrIntMapIter;
+
+ StrIntMap SourceMap; // Map of source file path to id
+ unsigned SourceCount; // Number of source files (used to
+ // generate id)
+
+public:
+ // Ctor.
+ MachineDebugInfo() : SourceMap(), SourceCount(0) {}
+
+ /// RecordSource - Register a source file with debug info. Returns an id.
+ ///
+ unsigned RecordSource(std::string fname, std::string dirname) {
+ // Compose a key
+ std::string path = dirname + "/" + fname;
+ // Check if the source file is already recorded
+ StrIntMapIter SMI = SourceMap.find(path);
+ // If already there return existing id
+ if (SMI != SourceMap.end()) return SMI->second;
+ // Bump up the count
+ ++SourceCount;
+ // Record the count
+ SourceMap[path] = SourceCount;
+ // Return id
+ return SourceCount;
+ }
+
+ /// getSourceFiles - Return a vector of files. Vector index + 1 equals id.
+ ///
+ std::vector<std::string> getSourceFiles() {
+ std::vector<std::string> Sources(SourceCount);
+
+ for (StrIntMapIter SMI = SourceMap.begin(), E = SourceMap.end(); SMI != E;
+ SMI++) {
+ unsigned Index = SMI->second - 1;
+ std::string Path = SMI->first;
+ Sources[Index] = Path;
+ }
+ return Sources;
+ }
+
+}; // End class MachineDebugInfo
+//===----------------------------------------------------------------------===//
+
+
+
+} // End llvm namespace
+
+#endif
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h
index 8727793..05077fe 100644
--- a/include/llvm/CodeGen/MachineFunction.h
+++ b/include/llvm/CodeGen/MachineFunction.h
@@ -18,6 +18,7 @@
#ifndef LLVM_CODEGEN_MACHINEFUNCTION_H
#define LLVM_CODEGEN_MACHINEFUNCTION_H
+#include "llvm/CodeGen/MachineDebugInfo.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/Support/Annotation.h"
@@ -112,6 +113,10 @@ class MachineFunction : private Annotation {
/// stored in the second element.
std::vector<std::pair<unsigned, unsigned> > LiveIns;
std::vector<unsigned> LiveOuts;
+
+ /// DebugInfo - Keep track of debug information for the function.
+ ///
+ MachineDebugInfo DebugInfo;
public:
MachineFunction(const Function *Fn, const TargetMachine &TM);
@@ -212,6 +217,11 @@ public:
const MachineBasicBlock *getLastBlock() const {
return MBBNumbering.back();
}
+
+ /// getDebugInfo - Returns the DebugInfo.
+ MachineDebugInfo &getDebugInfo() {
+ return DebugInfo;
+ }
/// print - Print out the MachineFunction in a format suitable for debugging
/// to the specified stream.
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index 10b9050..bf01910 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -352,6 +352,12 @@ namespace ISD {
// as output.
LOCATION,
+ // DEBUG_LOC - This node is used to represent source line information
+ // embedded in the code. It takes token chain as input, then a line number,
+ // then a column then a file id (provided by MachineDebugInfo. It produces
+ // a token chain as output.
+ DEBUG_LOC,
+
// BUILTIN_OP_END - This must be the last enum value in this list.
BUILTIN_OP_END,
};