summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2010-08-24 20:32:42 +0000
committerKevin Enderby <enderby@apple.com>2010-08-24 20:32:42 +0000
commitc1840b3da25222680b51f853697a871fedda51d5 (patch)
tree3e8ead8c25c2fc13a34f9fea476aa8def72545cb /include
parenta15a1336478ffe16f3165c99e5c0e434eb6c53a2 (diff)
downloadllvm-c1840b3da25222680b51f853697a871fedda51d5.tar.gz
llvm-c1840b3da25222680b51f853697a871fedda51d5.tar.bz2
llvm-c1840b3da25222680b51f853697a871fedda51d5.tar.xz
First bit of support for the dwarf .loc directive. This patch updates the
needed parsing for the .loc directive and saves the current info from that into the context. The next patch will take the current loc info after an instruction is assembled and save that info into a vector for each section for use to build the line number tables. The patch after that will encode the info from those vectors into the output file as the dwarf line tables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111956 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/MC/MCContext.h21
-rw-r--r--include/llvm/MC/MCDwarf.h44
2 files changed, 65 insertions, 0 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h
index 17e79fb1e9..6686950b72 100644
--- a/include/llvm/MC/MCContext.h
+++ b/include/llvm/MC/MCContext.h
@@ -11,6 +11,7 @@
#define LLVM_MC_MCCONTEXT_H
#include "llvm/MC/SectionKind.h"
+#include "llvm/MC/MCDwarf.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Allocator.h"
@@ -24,6 +25,7 @@ namespace llvm {
class MCSymbol;
class MCLabel;
class MCDwarfFile;
+ class MCDwarfLoc;
class StringRef;
class Twine;
class MCSectionMachO;
@@ -69,6 +71,10 @@ namespace llvm {
std::vector<MCDwarfFile *> MCDwarfFiles;
std::vector<StringRef> MCDwarfDirs;
+ /// The current dwarf line information from the last dwarf .loc directive.
+ MCDwarfLoc CurrentDwarfLoc;
+ bool DwarfLocSeen;
+
/// Allocator - Allocator object used for creating machine code objects.
///
/// We use a bump pointer allocator to avoid the need to track all allocated
@@ -149,6 +155,8 @@ namespace llvm {
/// GetDwarfFile - creates an entry in the dwarf file and directory tables.
unsigned GetDwarfFile(StringRef FileName, unsigned FileNumber);
+ bool ValidateDwarfFileNumber(unsigned FileNumber);
+
const std::vector<MCDwarfFile *> &getMCDwarfFiles() {
return MCDwarfFiles;
}
@@ -156,6 +164,19 @@ namespace llvm {
return MCDwarfDirs;
}
+ /// 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
+ /// the address of the instruction will be created.
+ void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
+ unsigned Flags, unsigned Isa) {
+ CurrentDwarfLoc.setFileNum(FileNum);
+ CurrentDwarfLoc.setLine(Line);
+ CurrentDwarfLoc.setColumn(Column);
+ CurrentDwarfLoc.setFlags(Flags);
+ CurrentDwarfLoc.setIsa(Isa);
+ DwarfLocSeen = true;
+ }
+
/// @}
char *getSecureLogFile() { return SecureLogFile; }
diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h
index e21b42f7bb..4f39f79397 100644
--- a/include/llvm/MC/MCDwarf.h
+++ b/include/llvm/MC/MCDwarf.h
@@ -57,6 +57,50 @@ namespace llvm {
void dump() const;
};
+ /// MCDwarfLoc - Instances of this class represent the information from a
+ /// dwarf .loc directive.
+ class MCDwarfLoc {
+ // FileNum - the file number.
+ unsigned FileNum;
+ // Line - the line number.
+ unsigned Line;
+ // Column - the column position.
+ unsigned Column;
+ // Flags (see #define's below)
+ unsigned Flags;
+ // Isa
+ unsigned Isa;
+
+#define DWARF2_FLAG_IS_STMT (1 << 0)
+#define DWARF2_FLAG_BASIC_BLOCK (1 << 1)
+#define DWARF2_FLAG_PROLOGUE_END (1 << 2)
+#define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3)
+
+ private: // MCContext manages these
+ friend class MCContext;
+ 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
+ public:
+ /// setFileNum - Set the FileNum of this MCDwarfLoc.
+ void setFileNum(unsigned fileNum) { FileNum = fileNum; }
+
+ /// setLine - Set the Line of this MCDwarfLoc.
+ void setLine(unsigned line) { Line = line; }
+
+ /// setColumn - Set the Column of this MCDwarfLoc.
+ void setColumn(unsigned column) { Column = column; }
+
+ /// setFlags - Set the Flags of this MCDwarfLoc.
+ void setFlags(unsigned flags) { Flags = flags; }
+
+ /// setIsa - Set the Isa of this MCDwarfLoc.
+ void setIsa(unsigned isa) { Isa = isa; }
+ };
+
inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile){
DwarfFile.print(OS);
return OS;