[llvm-commits] [llvm] r70761 - /llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp

Anton Korobeynikov asl at math.spbu.ru
Sun May 3 06:17:12 PDT 2009


Author: asl
Date: Sun May  3 08:17:11 2009
New Revision: 70761

URL: http://llvm.org/viewvc/llvm-project?rev=70761&view=rev
Log:
Print function header / footer

Modified:
    llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp

Modified: llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp?rev=70761&r1=70760&r2=70761&view=diff

==============================================================================
--- llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp Sun May  3 08:17:11 2009
@@ -54,6 +54,8 @@
     void printCCOperand(const MachineInstr *MI, int OpNum);
     bool printInstruction(const MachineInstr *MI);  // autogenerated.
     void printMachineInstruction(const MachineInstr * MI);
+
+    void emitFunctionHeader(const MachineFunction &MF);
     bool runOnMachineFunction(MachineFunction &F);
     bool doInitialization(Module &M);
     bool doFinalization(Module &M);
@@ -88,7 +90,45 @@
   return AsmPrinter::doFinalization(M);
 }
 
+void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
+  const Function *F = MF.getFunction();
+
+  SwitchToSection(TAI->SectionForGlobal(F));
+
+  unsigned FnAlign = 4;
+  if (F->hasFnAttr(Attribute::OptimizeForSize))
+    FnAlign = 1;
+
+  EmitAlignment(FnAlign, F);
+
+  switch (F->getLinkage()) {
+  default: assert(0 && "Unknown linkage type!");
+  case Function::InternalLinkage:  // Symbols default to internal.
+  case Function::PrivateLinkage:
+    break;
+  case Function::ExternalLinkage:
+    O << "\t.globl\t" << CurrentFnName << '\n';
+    break;
+  case Function::LinkOnceAnyLinkage:
+  case Function::LinkOnceODRLinkage:
+  case Function::WeakAnyLinkage:
+  case Function::WeakODRLinkage:
+    O << "\t.weak\t" << CurrentFnName << '\n';
+    break;
+  }
+
+  printVisibility(CurrentFnName, F->getVisibility());
+
+  O << "\t.type\t" << CurrentFnName << ", at function\n"
+    << CurrentFnName << ":\n";
+}
+
 bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
+  SetupMachineFunction(MF);
+
+  // Print the 'header' of function
+  emitFunctionHeader(MF);
+
   // Print out code for the function.
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
        I != E; ++I) {
@@ -109,6 +149,11 @@
     O << '\n';
   }
 
+  if (TAI->hasDotTypeDotSizeDirective())
+    O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
+
+  O.flush();
+
   // We didn't modify anything
   return false;
 }





More information about the llvm-commits mailing list