diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:17:11 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:17:11 +0000 |
commit | 6130fc8ea37e02b85c367a8726a3da58ae675278 (patch) | |
tree | 586ebe8baca0fb11a7e7c87e95180553e586bd80 /lib/Target/MSP430/MSP430AsmPrinter.cpp | |
parent | d9e89f6ea4fb050127b1e1123d65db6b42bad180 (diff) | |
download | llvm-6130fc8ea37e02b85c367a8726a3da58ae675278.tar.gz llvm-6130fc8ea37e02b85c367a8726a3da58ae675278.tar.bz2 llvm-6130fc8ea37e02b85c367a8726a3da58ae675278.tar.xz |
Print function header / footer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70761 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/MSP430/MSP430AsmPrinter.cpp')
-rw-r--r-- | lib/Target/MSP430/MSP430AsmPrinter.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp index 7c1871131d..0755e36981 100644 --- a/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -54,6 +54,8 @@ namespace { 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 @@ bool MSP430AsmPrinter::doFinalization(Module &M) { 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 << ",@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 @@ bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) { O << '\n'; } + if (TAI->hasDotTypeDotSizeDirective()) + O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; + + O.flush(); + // We didn't modify anything return false; } |