Start using alignment output routines from AsmPrinter.

Changes to make this more similar to the ppc asmprinter


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15890 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-08-17 19:25:42 +00:00
parent e265504e82
commit c6393f82bf

View File

@ -149,9 +149,8 @@ void X86AsmPrinter::printConstantPool(MachineConstantPool *MCP) {
for (unsigned i = 0, e = CP.size(); i != e; ++i) { for (unsigned i = 0, e = CP.size(); i != e; ++i) {
O << "\t.section .rodata\n"; O << "\t.section .rodata\n";
O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType()) emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
<< "\n"; O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentChar
O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t#"
<< *CP[i] << "\n"; << *CP[i] << "\n";
emitGlobalConstant(CP[i]); emitGlobalConstant(CP[i]);
} }
@ -169,7 +168,7 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Print out labels for the function. // Print out labels for the function.
O << "\t.text\n"; O << "\t.text\n";
O << "\t.align 16\n"; emitAlignment(4);
O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.globl\t" << CurrentFnName << "\n";
O << "\t.type\t" << CurrentFnName << ", @function\n"; O << "\t.type\t" << CurrentFnName << ", @function\n";
O << CurrentFnName << ":\n"; O << CurrentFnName << ":\n";
@ -178,8 +177,8 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) { I != E; ++I) {
// Print a label for the basic block. // Print a label for the basic block.
O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t# " O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t"
<< I->getBasicBlock()->getName() << "\n"; << CommentChar << " " << I->getBasicBlock()->getName() << "\n";
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) { II != E; ++II) {
// Print the assembly for the instruction. // Print the assembly for the instruction.
@ -387,7 +386,7 @@ bool X86AsmPrinter::doFinalization(Module &M) {
std::string name = Mang->getValueName(I); std::string name = Mang->getValueName(I);
Constant *C = I->getInitializer(); Constant *C = I->getInitializer();
unsigned Size = TD.getTypeSize(C->getType()); unsigned Size = TD.getTypeSize(C->getType());
unsigned Align = TD.getTypeAlignment(C->getType()); unsigned Align = TD.getTypeAlignmentShift(C->getType());
if (C->isNullValue() && if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() || (I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
@ -397,7 +396,7 @@ bool X86AsmPrinter::doFinalization(Module &M) {
O << "\t.local " << name << "\n"; O << "\t.local " << name << "\n";
O << "\t.comm " << name << "," << TD.getTypeSize(C->getType()) O << "\t.comm " << name << "," << TD.getTypeSize(C->getType())
<< "," << (unsigned)TD.getTypeAlignment(C->getType()); << "," << (1 << Align);
O << "\t\t# "; O << "\t\t# ";
WriteAsOperand(O, I, true, true, &M); WriteAsOperand(O, I, true, true, &M);
O << "\n"; O << "\n";
@ -410,7 +409,6 @@ bool X86AsmPrinter::doFinalization(Module &M) {
SwitchSection(O, CurSection, ""); SwitchSection(O, CurSection, "");
O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n"; O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
break; break;
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
// FIXME: appending linkage variables should go into a section of // FIXME: appending linkage variables should go into a section of
// their name or something. For now, just emit them as external. // their name or something. For now, just emit them as external.
@ -426,7 +424,7 @@ bool X86AsmPrinter::doFinalization(Module &M) {
break; break;
} }
O << "\t.align " << Align << "\n"; emitAlignment(Align);
O << "\t.type " << name << ",@object\n"; O << "\t.type " << name << ",@object\n";
O << "\t.size " << name << "," << Size << "\n"; O << "\t.size " << name << "," << Size << "\n";
O << name << ":\t\t\t\t# "; O << name << ":\t\t\t\t# ";