aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PIC16/PIC16AsmPrinter.cpp
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-05-22 13:58:45 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-05-22 13:58:45 +0000
commita57bc3ba02a470ee8cf70f50389489aa80c703cb (patch)
tree8a7695edee0f466707b0d71e73c73b71d886936f /lib/Target/PIC16/PIC16AsmPrinter.cpp
parent2f82376c485f07dd9bfd6f563f6e194843c5060c (diff)
Emit debug information for globals (which include automatic variables as well because on PIC16 they are emitted as globals by the frontend).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PIC16/PIC16AsmPrinter.cpp')
-rw-r--r--lib/Target/PIC16/PIC16AsmPrinter.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp
index 3e8ac016ed..738723bbb5 100644
--- a/lib/Target/PIC16/PIC16AsmPrinter.cpp
+++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp
@@ -273,6 +273,8 @@ void PIC16AsmPrinter::EmitRomData (Module &M)
bool PIC16AsmPrinter::doFinalization(Module &M) {
printLibcallDecls();
+ EmitVarDebugInfo(M);
+ O << "\t" << ".EOF\n";
O << "\t" << "END\n";
bool Result = AsmPrinter::doFinalization(M);
return Result;
@@ -384,3 +386,48 @@ void PIC16AsmPrinter::EmitAutos (Module &M)
}
}
}
+
+void PIC16AsmPrinter::EmitVarDebugInfo(Module &M) {
+ GlobalVariable *Root = M.getGlobalVariable("llvm.dbg.global_variables");
+ if (!Root)
+ return;
+
+ O << TAI->getCommentString() << " Debug Information:";
+ Constant *RootC = cast<Constant>(*Root->use_begin());
+ for (Value::use_iterator UI = RootC->use_begin(), UE = Root->use_end();
+ UI != UE; ++UI) {
+ for (Value::use_iterator UUI = UI->use_begin(), UUE = UI->use_end();
+ UUI != UUE; ++UUI) {
+ DIGlobalVariable DIGV(cast<GlobalVariable>(*UUI));
+ DIType Ty = DIGV.getType();
+ unsigned short TypeNo = 0;
+ bool HasAux = false;
+ int Aux[20] = { 0 };
+ std::string TypeName = "";
+ std::string VarName = TAI->getGlobalPrefix()+DIGV.getGlobal()->getName();
+ DbgInfo.PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TypeName);
+ // Emit debug info only if type information is availaible.
+ if (TypeNo != PIC16Dbg::T_NULL) {
+ O << "\n\t.type " << VarName << ", " << TypeNo;
+ short ClassNo = DbgInfo.getClass(DIGV);
+ O << "\n\t.class " << VarName << ", " << ClassNo;
+ if (HasAux) {
+ if (TypeName != "") {
+ // Emit debug info for structure and union objects after
+ // .dim directive supports structure/union tag name in aux entry.
+ /* O << "\n\t.dim " << VarName << ", 1," << TypeName;
+ for (int i = 0; i<20; i++)
+ O << "," << Aux[i];*/
+ }
+ else {
+ O << "\n\t.dim " << VarName << ", 1" ;
+ for (int i = 0; i<20; i++)
+ O << "," << Aux[i];
+ }
+ }
+ }
+ }
+ }
+ O << "\n";
+}
+