From 69d485e64689533c80e62f530968ca6bf1eef864 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 17 Aug 2004 19:26:03 +0000 Subject: [PATCH] Start using alignment output routines from AsmPrinter. Changes to make this more similar to the X86 asmprinter Fix overalignment of globals. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15891 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PowerPC/PPC32AsmPrinter.cpp | 24 ++++++++++++------------ lib/Target/PowerPC/PPCAsmPrinter.cpp | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/Target/PowerPC/PPC32AsmPrinter.cpp b/lib/Target/PowerPC/PPC32AsmPrinter.cpp index a5fe5c2100c..acd9dfd0ce5 100644 --- a/lib/Target/PowerPC/PPC32AsmPrinter.cpp +++ b/lib/Target/PowerPC/PPC32AsmPrinter.cpp @@ -49,6 +49,7 @@ namespace { GlobalPrefix = "_"; ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. Data64bitsDirective = 0; // we can't emit a 64-bit unit + AlignmentIsInBytes = false; // Alignment is by power of 2. } /// Unique incrementer for label values for referencing Global values. @@ -121,9 +122,8 @@ void PPC32AsmPrinter::printConstantPool(MachineConstantPool *MCP) { for (unsigned i = 0, e = CP.size(); i != e; ++i) { O << "\t.const\n"; - O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType()) - << "\n"; - O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t;" + emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); + O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentChar << *CP[i] << "\n"; emitGlobalConstant(CP[i]); } @@ -140,19 +140,19 @@ bool PPC32AsmPrinter::runOnMachineFunction(MachineFunction &MF) { printConstantPool(MF.getConstantPool()); // Print out labels for the function. - O << "\t.text\n"; + O << "\t.text\n"; + emitAlignment(2); O << "\t.globl\t" << CurrentFnName << "\n"; - O << "\t.align 2\n"; O << CurrentFnName << ":\n"; // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. - O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t; " - << I->getBasicBlock()->getName() << "\n"; + O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t" + << CommentChar << " " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); - II != E; ++II) { + II != E; ++II) { // Print the assembly for the instruction. O << "\t"; printMachineInstruction(II); @@ -399,14 +399,14 @@ bool PPC32AsmPrinter::doFinalization(Module &M) { std::string name = Mang->getValueName(I); Constant *C = I->getInitializer(); unsigned Size = TD.getTypeSize(C->getType()); - unsigned Align = TD.getTypeAlignment(C->getType()); + unsigned Align = TD.getTypeAlignmentShift(C->getType()); if (C->isNullValue() && /* FIXME: Verify correct */ (I->hasInternalLinkage() || I->hasWeakLinkage())) { SwitchSection(O, CurSection, ".data"); if (I->hasInternalLinkage()) O << ".lcomm " << name << "," << TD.getTypeSize(C->getType()) - << "," << (unsigned)TD.getTypeAlignment(C->getType()); + << "," << Align; else O << ".comm " << name << "," << TD.getTypeSize(C->getType()); O << "\t\t; "; @@ -439,7 +439,7 @@ bool PPC32AsmPrinter::doFinalization(Module &M) { break; } - O << "\t.align " << Align << "\n"; + emitAlignment(Align); O << name << ":\t\t\t\t; "; WriteAsOperand(O, I, true, true, &M); O << " = "; @@ -455,7 +455,7 @@ bool PPC32AsmPrinter::doFinalization(Module &M) { { O << ".data\n"; O << ".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n"; - O << "\t.align 2\n"; + emitAlignment(2); O << "L" << *i << "$stub:\n"; O << "\t.indirect_symbol " << *i << "\n"; O << "\tmflr r0\n"; diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index a5fe5c2100c..acd9dfd0ce5 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -49,6 +49,7 @@ namespace { GlobalPrefix = "_"; ZeroDirective = "\t.space\t"; // ".space N" emits N zeros. Data64bitsDirective = 0; // we can't emit a 64-bit unit + AlignmentIsInBytes = false; // Alignment is by power of 2. } /// Unique incrementer for label values for referencing Global values. @@ -121,9 +122,8 @@ void PPC32AsmPrinter::printConstantPool(MachineConstantPool *MCP) { for (unsigned i = 0, e = CP.size(); i != e; ++i) { O << "\t.const\n"; - O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType()) - << "\n"; - O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t;" + emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); + O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentChar << *CP[i] << "\n"; emitGlobalConstant(CP[i]); } @@ -140,19 +140,19 @@ bool PPC32AsmPrinter::runOnMachineFunction(MachineFunction &MF) { printConstantPool(MF.getConstantPool()); // Print out labels for the function. - O << "\t.text\n"; + O << "\t.text\n"; + emitAlignment(2); O << "\t.globl\t" << CurrentFnName << "\n"; - O << "\t.align 2\n"; O << CurrentFnName << ":\n"; // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. - O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t; " - << I->getBasicBlock()->getName() << "\n"; + O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t" + << CommentChar << " " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); - II != E; ++II) { + II != E; ++II) { // Print the assembly for the instruction. O << "\t"; printMachineInstruction(II); @@ -399,14 +399,14 @@ bool PPC32AsmPrinter::doFinalization(Module &M) { std::string name = Mang->getValueName(I); Constant *C = I->getInitializer(); unsigned Size = TD.getTypeSize(C->getType()); - unsigned Align = TD.getTypeAlignment(C->getType()); + unsigned Align = TD.getTypeAlignmentShift(C->getType()); if (C->isNullValue() && /* FIXME: Verify correct */ (I->hasInternalLinkage() || I->hasWeakLinkage())) { SwitchSection(O, CurSection, ".data"); if (I->hasInternalLinkage()) O << ".lcomm " << name << "," << TD.getTypeSize(C->getType()) - << "," << (unsigned)TD.getTypeAlignment(C->getType()); + << "," << Align; else O << ".comm " << name << "," << TD.getTypeSize(C->getType()); O << "\t\t; "; @@ -439,7 +439,7 @@ bool PPC32AsmPrinter::doFinalization(Module &M) { break; } - O << "\t.align " << Align << "\n"; + emitAlignment(Align); O << name << ":\t\t\t\t; "; WriteAsOperand(O, I, true, true, &M); O << " = "; @@ -455,7 +455,7 @@ bool PPC32AsmPrinter::doFinalization(Module &M) { { O << ".data\n"; O << ".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n"; - O << "\t.align 2\n"; + emitAlignment(2); O << "L" << *i << "$stub:\n"; O << "\t.indirect_symbol " << *i << "\n"; O << "\tmflr r0\n"; -- 2.11.0