mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Print function header / footer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70761 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d9e89f6ea4
commit
6130fc8ea3
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user