Parse and remember discriminators in .loc line. I try to output them with
authorRafael Espindola <rafael.espindola@gmail.com>
Sat, 13 Nov 2010 03:18:27 +0000 (03:18 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sat, 13 Nov 2010 03:18:27 +0000 (03:18 +0000)
another patch.
This lets us parse a bit more of the gcc 4.5 output.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118975 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCContext.h
include/llvm/MC/MCDwarf.h
lib/MC/MCContext.cpp
lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/directive_loc.s

index a721e54dc02817881f65d37384499be192bfa6f9..cec29fad63958a5670cc838a305978de9cf0691d 100644 (file)
@@ -186,12 +186,14 @@ namespace llvm {
     /// 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) {
+                            unsigned Flags, unsigned Isa,
+                            unsigned Discriminator) {
       CurrentDwarfLoc.setFileNum(FileNum);
       CurrentDwarfLoc.setLine(Line);
       CurrentDwarfLoc.setColumn(Column);
       CurrentDwarfLoc.setFlags(Flags);
       CurrentDwarfLoc.setIsa(Isa);
+      CurrentDwarfLoc.setDiscriminator(Discriminator);
       DwarfLocSeen = true;
     }
     void ClearDwarfLocSeen() { DwarfLocSeen = false; }
index 925991eb832bbafa07e647b5718169760ce8d179..609d819626fc72d78315cedd586d223714fa2299 100644 (file)
@@ -83,6 +83,8 @@ namespace llvm {
     unsigned Flags;
     // Isa
     unsigned Isa;
+    // Discriminator
+    unsigned Discriminator;
 
 // Flag that indicates the initial value of the is_stmt_start flag.
 #define DWARF2_LINE_DEFAULT_IS_STMT     1
@@ -96,8 +98,9 @@ namespace llvm {
     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) {}
+               unsigned isa, unsigned discriminator)
+      : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa),
+        Discriminator(discriminator) {}
 
     // Allow the default copy constructor and assignment operator to be used
     // for an MCDwarfLoc object.
@@ -118,6 +121,9 @@ namespace llvm {
     /// getIsa - Get the Isa of this MCDwarfLoc.
     unsigned getIsa() { return Isa; }
 
+    /// getDiscriminator - Get the Discriminator of this MCDwarfLoc.
+    unsigned getDiscriminator() { return Discriminator; }
+
     /// setFileNum - Set the FileNum of this MCDwarfLoc.
     void setFileNum(unsigned fileNum) { FileNum = fileNum; }
 
@@ -132,6 +138,11 @@ namespace llvm {
 
     /// setIsa - Set the Isa of this MCDwarfLoc.
     void setIsa(unsigned isa) { Isa = isa; }
+
+    /// setDiscriminator - Set the Discriminator of this MCDwarfLoc.
+    void setDiscriminator(unsigned discriminator) {
+      Discriminator = discriminator;
+    }
   };
 
   /// MCLineEntry - Instances of this class represent the line information for
index 311f383a3aa20c21d131ce909c472c5a32a4f8f9..87619d5cece16e7722eee755eddf00e45d770ef8 100644 (file)
@@ -25,7 +25,7 @@ typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
 
 
 MCContext::MCContext(const MCAsmInfo &mai) : MAI(mai), NextUniqueID(0),
-                     CurrentDwarfLoc(0,0,0,0,0) {
+                     CurrentDwarfLoc(0,0,0,0,0,0) {
   MachOUniquingMap = 0;
   ELFUniquingMap = 0;
   COFFUniquingMap = 0;
index 489d451f7fbf39e303b31bc3943aa2c940b952f2..24b94d11cb072fb5ad20ab3bfdc6b3a3e423e434 100644 (file)
@@ -2019,6 +2019,7 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
 
   unsigned Flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0;
   unsigned Isa = 0;
+  int64_t Discriminator = 0;
   if (getLexer().isNot(AsmToken::EndOfStatement)) {
     for (;;) {
       if (getLexer().is(AsmToken::EndOfStatement))
@@ -2070,6 +2071,10 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
           return Error(Loc, "isa number not a constant value");
         }
       }
+      else if (Name == "discriminator") {
+        if (getParser().ParseAbsoluteExpression(Discriminator))
+          return true;
+      }
       else {
         return Error(Loc, "unknown sub-directive in '.loc' directive");
       }
@@ -2079,7 +2084,8 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) {
     }
   }
 
-  getContext().setCurrentDwarfLoc(FileNumber, LineNumber, ColumnPos, Flags,Isa);
+  getContext().setCurrentDwarfLoc(FileNumber, LineNumber, ColumnPos, Flags,
+                                  Isa, Discriminator);
 
   return false;
 }
index b122fdc2cf293181d11da365d303074e6aceb02a..164d42a3fa7c080ca3ff9bab9b3e29124c524149 100644 (file)
@@ -5,4 +5,4 @@
         .loc 1
         .loc 1 2
         .loc 1 2 3
-
+        .loc 1 2 discriminator 1