/// of `new MachineInstr'.
///
MachineInstr *
-MachineFunction::CreateMachineInstr(const TargetInstrDesc &TID, bool NoImp) {
+MachineFunction::CreateMachineInstr(const TargetInstrDesc &TID,
+ DebugLoc DL, bool NoImp) {
return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
- MachineInstr(TID, NoImp);
+ MachineInstr(TID, DL, NoImp);
}
/// CloneMachineInstr - Create a new MachineInstr which is a copy of the
return *mc;
}
-/// lookUpDebugLocId - Look up the DebugLocTuple index with the given
-/// filename, line, and column. It may add a new filename and / or
-/// a new DebugLocTuple.
-unsigned MachineFunction::lookUpDebugLocId(const char *Filename, unsigned Line,
- unsigned Col) {
- unsigned FileId;
- StringMap<unsigned>::iterator I =
- DebugLocInfo.DebugFilenamesMap.find(Filename);
- if (I != DebugLocInfo.DebugFilenamesMap.end())
- FileId = I->second;
- else {
- // Add a new filename.
- FileId = DebugLocInfo.NumFilenames++;
- DebugLocInfo.DebugFilenames.push_back(Filename);
- DebugLocInfo.DebugFilenamesMap[Filename] = FileId;
- }
-
- struct DebugLocTuple Tuple(FileId, Line, Col);
- DebugIdMapType::iterator II = DebugLocInfo.DebugIdMap.find(Tuple);
+/// 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 MachineFunction::getOrCreateDebugLocID(unsigned Src, unsigned Line,
+ unsigned Col) {
+ DebugLocTuple Tuple(Src, Line, Col);
+ DenseMap<DebugLocTuple, unsigned>::iterator II
+ = DebugLocInfo.DebugIdMap.find(Tuple);
if (II != DebugLocInfo.DebugIdMap.end())
return II->second;
// Add a new tuple.
+ unsigned Id = DebugLocInfo.DebugLocations.size();
DebugLocInfo.DebugLocations.push_back(Tuple);
- DebugLocInfo.DebugIdMap[Tuple] = DebugLocInfo.NumDebugLocations;
- return DebugLocInfo.NumDebugLocations++;
+ DebugLocInfo.DebugIdMap[Tuple] = Id;
+ return Id;
+}
+
+/// getDebugLocTuple - Get the DebugLocTuple for a given DebugLoc object.
+DebugLocTuple MachineFunction::getDebugLocTuple(DebugLoc DL) const {
+ unsigned Idx = DL.getIndex();
+ assert(Idx < DebugLocInfo.DebugLocations.size() &&
+ "Invalid index into debug locations!");
+ return DebugLocInfo.DebugLocations[Idx];
}
//===----------------------------------------------------------------------===//