[llvm-commits] [llvm] r72781 - in /llvm/trunk/lib/Target/PIC16: PIC16AsmPrinter.cpp PIC16DebugInfo.cpp PIC16DebugInfo.h

Sanjiv Gupta sanjiv.gupta at microchip.com
Wed Jun 3 09:27:49 PDT 2009


Author: sgupta
Date: Wed Jun  3 11:27:49 2009
New Revision: 72781

URL: http://llvm.org/viewvc/llvm-project?rev=72781&view=rev
Log:
Emit file directives correctly in case of a .bc is generated by llvm-ld after linking in several .bc files.

Modified:
    llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
    llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp
    llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h

Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=72781&r1=72780&r2=72781&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Wed Jun  3 11:27:49 2009
@@ -47,6 +47,7 @@
   const Function *F = MF.getFunction();
   CurrentFnName = Mang->getValueName(F);
 
+  DbgInfo.EmitFileDirective(F);
   // Emit the function variables.
   EmitFunctionFrame(MF);
 
@@ -181,17 +182,11 @@
 
 bool PIC16AsmPrinter::doInitialization (Module &M) {
   bool Result = AsmPrinter::doInitialization(M);
-  DbgInfo.EmitFileDirective(M);
 
   // FIXME:: This is temporary solution to generate the include file.
   // The processor should be passed to llc as in input and the header file
   // should be generated accordingly.
   O << "\n\t#include P16F1937.INC\n";
-  MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
-  assert(MMI);
-  DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
-  assert(DW && "Dwarf Writer is not available");
-  DW->BeginModule(&M, MMI, O, this, TAI);
 
   // Set the section names for all globals.
   for (Module::global_iterator I = M.global_begin(), E = M.global_end();
@@ -199,13 +194,14 @@
     I->setSection(TAI->SectionForGlobal(I)->getName());
   }
 
+  DbgInfo.EmitFileDirective(M);
   EmitFunctionDecls(M);
   EmitUndefinedVars(M);
   EmitDefinedVars(M);
   EmitIData(M);
   EmitUData(M);
   EmitRomData(M);
-  DbgInfo.PopulateFunctsDI(M); 
+  DbgInfo.PopulateFunctsDI(M);
   return Result;
 }
 
@@ -285,7 +281,7 @@
 bool PIC16AsmPrinter::doFinalization(Module &M) {
   printLibcallDecls();
   DbgInfo.EmitVarDebugInfo(M);
-  O << "\n\t" << ".EOF";
+  DbgInfo.EmitEOF();
   O << "\n\t" << "END\n";
   bool Result = AsmPrinter::doFinalization(M);
   return Result;

Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=72781&r1=72780&r2=72781&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Wed Jun  3 11:27:49 2009
@@ -264,7 +264,29 @@
   if (CU) {
     DICompileUnit DIUnit(CU);
     std::string Dir, FN;
-    O << "\n\t.file\t\"" << DIUnit.getDirectory(Dir) <<"/"
-      << DIUnit.getFilename(FN) << "\"" ;
+    std::string File = DIUnit.getDirectory(Dir) + "/" + DIUnit.getFilename(FN);
+    O << "\n\t.file\t\"" << File << "\"\n" ;
+    CurFile = File;
   }
 }
+
+void PIC16DbgInfo::EmitFileDirective(const Function *F) {
+  std::string FunctName = F->getName();
+  DISubprogram *SP = getFunctDI(FunctName);
+  if (SP) {
+    std::string Dir, FN;
+    DICompileUnit CU = SP->getCompileUnit();
+    std::string File = CU.getDirectory(Dir) + "/" + CU.getFilename(FN);
+    if ( File != CurFile) {
+      EmitEOF();
+      O << "\n\t.file\t\"" << File << "\"\n" ;
+      CurFile = File;
+    }
+  }
+}
+
+void PIC16DbgInfo::EmitEOF() {
+  if (CurFile != "")
+    O << "\n\t.EOF";
+}
+

Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h?rev=72781&r1=72780&r2=72781&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h Wed Jun  3 11:27:49 2009
@@ -94,8 +94,11 @@
     std::map <std::string, DISubprogram *> FunctNameMap;
     raw_ostream &O;
     const TargetAsmInfo *TAI;
+    std::string CurFile;
   public:
-     PIC16DbgInfo(raw_ostream &o, const TargetAsmInfo *T) : O(o), TAI(T) {}
+    PIC16DbgInfo(raw_ostream &o, const TargetAsmInfo *T) : O(o), TAI(T) {
+      CurFile = "";  
+    }
     ~PIC16DbgInfo();
     void PopulateDebugInfo(DIType Ty, unsigned short &TypeNo, bool &HasAux,
                            int Aux[], std::string &TypeName);
@@ -109,6 +112,8 @@
     inline void EmitSymbol(std::string Name, int Class);
     void EmitVarDebugInfo(Module &M);
     void EmitFileDirective(Module &M);
+    void EmitFileDirective(const Function *F);
+    void EmitEOF();
   };
 } // end namespace llvm;
 #endif





More information about the llvm-commits mailing list