mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
This is the second of three patches to implement support for the .loc directive
and output the dwarf line number tables. This takes the current loc info after an instruction is assembled and saves the needed info into an object that has vector and for each section. These objects will be used for the final patch to build and emit the encoded dwarf line number tables. Again for now this is only in the Mach-O streamer but at some point will move to a more generic place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112668 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -26,6 +26,7 @@ namespace llvm {
|
||||
class MCLabel;
|
||||
class MCDwarfFile;
|
||||
class MCDwarfLoc;
|
||||
class MCLineSection;
|
||||
class StringRef;
|
||||
class Twine;
|
||||
class MCSectionMachO;
|
||||
@@ -75,6 +76,10 @@ namespace llvm {
|
||||
MCDwarfLoc CurrentDwarfLoc;
|
||||
bool DwarfLocSeen;
|
||||
|
||||
/// The dwarf line information from the .loc directives for the sections
|
||||
/// with assembled machine instructions have after seeing .loc directives.
|
||||
DenseMap<const MCSection *, MCLineSection *> MCLineSections;
|
||||
|
||||
/// Allocator - Allocator object used for creating machine code objects.
|
||||
///
|
||||
/// We use a bump pointer allocator to avoid the need to track all allocated
|
||||
@@ -163,6 +168,9 @@ namespace llvm {
|
||||
const std::vector<StringRef> &getMCDwarfDirs() {
|
||||
return MCDwarfDirs;
|
||||
}
|
||||
DenseMap<const MCSection *, MCLineSection *> &getMCLineSections() {
|
||||
return MCLineSections;
|
||||
}
|
||||
|
||||
/// setCurrentDwarfLoc - saves the information from the currently parsed
|
||||
/// dwarf .loc directive and sets DwarfLocSeen. When the next instruction /// is assembled an entry in the line number table with this information and
|
||||
@@ -176,6 +184,10 @@ namespace llvm {
|
||||
CurrentDwarfLoc.setIsa(Isa);
|
||||
DwarfLocSeen = true;
|
||||
}
|
||||
void clearDwarfLocSeen() { DwarfLocSeen = false; }
|
||||
|
||||
bool getDwarfLocSeen() { return DwarfLocSeen; }
|
||||
const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
|
||||
|
||||
/// @}
|
||||
|
||||
|
@@ -17,9 +17,12 @@
|
||||
#define LLVM_MC_MCDWARF_H
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class MCContext;
|
||||
class MCSection;
|
||||
class MCSymbol;
|
||||
class raw_ostream;
|
||||
|
||||
/// MCDwarfFile - Instances of this class represent the name of the dwarf
|
||||
@@ -57,6 +60,11 @@ namespace llvm {
|
||||
void dump() const;
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile){
|
||||
DwarfFile.print(OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
/// MCDwarfLoc - Instances of this class represent the information from a
|
||||
/// dwarf .loc directive.
|
||||
class MCDwarfLoc {
|
||||
@@ -78,12 +86,14 @@ namespace llvm {
|
||||
|
||||
private: // MCContext manages these
|
||||
friend class MCContext;
|
||||
friend class MCLineEntry;
|
||||
MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags,
|
||||
unsigned isa)
|
||||
: FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa) {}
|
||||
|
||||
MCDwarfLoc(const MCDwarfLoc&); // DO NOT IMPLEMENT
|
||||
void operator=(const MCDwarfLoc&); // DO NOT IMPLEMENT
|
||||
// Allow the default copy constructor and assignment operator to be used
|
||||
// for an MCDwarfLoc object.
|
||||
|
||||
public:
|
||||
/// setFileNum - Set the FileNum of this MCDwarfLoc.
|
||||
void setFileNum(unsigned fileNum) { FileNum = fileNum; }
|
||||
@@ -101,10 +111,46 @@ namespace llvm {
|
||||
void setIsa(unsigned isa) { Isa = isa; }
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile){
|
||||
DwarfFile.print(OS);
|
||||
return OS;
|
||||
}
|
||||
/// MCLineEntry - Instances of this class represent the line information for
|
||||
/// the dwarf line table entries. Which is created after a machine
|
||||
/// instruction is assembled and uses an address from a temporary label
|
||||
/// created at the current address in the current section and the info from
|
||||
/// the last .loc directive seen as stored in the context.
|
||||
class MCLineEntry : public MCDwarfLoc {
|
||||
MCSymbol *Label;
|
||||
|
||||
private:
|
||||
// Allow the default copy constructor and assignment operator to be used
|
||||
// for an MCLineEntry object.
|
||||
|
||||
public:
|
||||
// Constructor to create an MCLineEntry given a symbol and the dwarf loc.
|
||||
MCLineEntry(MCSymbol *label, const MCDwarfLoc loc) : MCDwarfLoc(loc),
|
||||
Label(label) {}
|
||||
};
|
||||
|
||||
/// MCLineSection - Instances of this class represent the line information
|
||||
/// for a section where machine instructions have been assembled after seeing
|
||||
/// .loc directives. This is the information used to build the dwarf line
|
||||
/// table for a section.
|
||||
class MCLineSection {
|
||||
std::vector<MCLineEntry> MCLineEntries;
|
||||
|
||||
private:
|
||||
MCLineSection(const MCLineSection&); // DO NOT IMPLEMENT
|
||||
void operator=(const MCLineSection&); // DO NOT IMPLEMENT
|
||||
|
||||
public:
|
||||
// Constructor to create an MCLineSection with an empty MCLineEntries
|
||||
// vector.
|
||||
MCLineSection(): MCLineEntries() {};
|
||||
|
||||
// addLineEntry - adds an entry to this MCLineSection's line entries
|
||||
void addLineEntry(const MCLineEntry &LineEntry) {
|
||||
MCLineEntries.push_back(LineEntry);
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user