1. Make MachineDebugInfo a pass.

2. Add label uniquing code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25092 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Laskey
2006-01-04 13:46:37 +00:00
parent 2c4ec70233
commit 780a61cf04

View File

@@ -15,6 +15,7 @@
#ifndef LLVM_CODEGEN_MACHINEDEBUGINFO_H #ifndef LLVM_CODEGEN_MACHINEDEBUGINFO_H
#define LLVM_CODEGEN_MACHINEDEBUGINFO_H #define LLVM_CODEGEN_MACHINEDEBUGINFO_H
#include "llvm/Pass.h"
#include <string> #include <string>
#include <map> #include <map>
#include <vector> #include <vector>
@@ -25,7 +26,7 @@ namespace llvm {
/// module. Queries can be made by different debugging schemes and reformated /// module. Queries can be made by different debugging schemes and reformated
/// for specific use. /// for specific use.
/// ///
class MachineDebugInfo { class MachineDebugInfo : public ImmutablePass {
private: private:
// convenience types // convenience types
typedef std::map<std::string, unsigned> StrIntMap; typedef std::map<std::string, unsigned> StrIntMap;
@@ -34,46 +35,35 @@ private:
StrIntMap SourceMap; // Map of source file path to id StrIntMap SourceMap; // Map of source file path to id
unsigned SourceCount; // Number of source files (used to unsigned SourceCount; // Number of source files (used to
// generate id) // generate id)
unsigned UniqueID; // Number used to unique labels used
// by debugger.
public: public:
// Ctor. // Ctor.
MachineDebugInfo() : SourceMap(), SourceCount(0) {} MachineDebugInfo()
: SourceMap()
, SourceCount(0)
, UniqueID(1)
{}
~MachineDebugInfo() { }
/// RecordSource - Register a source file with debug info. Returns an id. /// NextUniqueID - Returns a unique number for labels used by debugger.
/// ///
unsigned RecordSource(std::string fname, std::string dirname) { unsigned NextUniqueID() { return UniqueID++; }
// Compose a key
std::string path = dirname + "/" + fname; bool doInitialization();
// Check if the source file is already recorded bool doFinalization();
StrIntMapIter SMI = SourceMap.find(path); unsigned RecordSource(std::string fname, std::string dirname);
// If already there return existing id std::vector<std::string> getSourceFiles();
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 class MachineDebugInfo
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// FIXME - temporary hack until we can find a place to hang debug info from.
MachineDebugInfo &getMachineDebugInfo();
// FIXME - temporary hack until we can find a place to hand debug info from.
ModulePass *createDebugInfoPass();
} // End llvm namespace } // End llvm namespace