Changes in directory llvm/lib/Target/X86:
X86ATTAsmPrinter.cpp updated: 1.47 -> 1.48 X86AsmPrinter.cpp updated: 1.181 -> 1.182 X86AsmPrinter.h updated: 1.18 -> 1.19 X86Subtarget.cpp updated: 1.26 -> 1.27 --- Log message: X86 / Cygwin asm / alignment fixes. Patch contributed by Anton Korobeynikov! --- Diffs of the changes: (+42 -30) X86ATTAsmPrinter.cpp | 32 ++++++++++++++++++++------------ X86AsmPrinter.cpp | 30 +++++++++++++++++------------- X86AsmPrinter.h | 8 ++++---- X86Subtarget.cpp | 2 +- 4 files changed, 42 insertions(+), 30 deletions(-) Index: llvm/lib/Target/X86/X86ATTAsmPrinter.cpp diff -u llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.47 llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.48 --- llvm/lib/Target/X86/X86ATTAsmPrinter.cpp:1.47 Tue May 16 02:21:53 2006 +++ llvm/lib/Target/X86/X86ATTAsmPrinter.cpp Thu May 25 16:59:08 2006 @@ -26,11 +26,9 @@ /// method to print assembly for each instruction. /// bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) { - // if (forDarwin) { - // Let PassManager know we need debug information and relay - // the MachineDebugInfo address on to DwarfWriter. - DW.SetDebugInfo(&getAnalysis<MachineDebugInfo>()); - // } + // Let PassManager know we need debug information and relay + // the MachineDebugInfo address on to DwarfWriter. + DW.SetDebugInfo(&getAnalysis<MachineDebugInfo>()); SetupMachineFunction(MF); O << "\n\n"; @@ -56,11 +54,17 @@ break; case Function::WeakLinkage: case Function::LinkOnceLinkage: - if (forDarwin) { + if (Subtarget->TargetType == X86Subtarget::isDarwin) { SwitchToTextSection( ".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F); O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.weak_definition\t" << CurrentFnName << "\n"; + } else if (Subtarget->TargetType == X86Subtarget::isCygwin) { + EmitAlignment(4, F); // FIXME: This should be parameterized somewhere. + O << "\t.section\t.llvm.linkonce.t." << CurrentFnName + << ",\"ax\"\n"; + SwitchToTextSection("", F); + O << "\t.weak " << CurrentFnName << "\n"; } else { EmitAlignment(4, F); // FIXME: This should be parameterized somewhere. O << "\t.section\t.llvm.linkonce.t." << CurrentFnName @@ -72,7 +76,7 @@ } O << CurrentFnName << ":\n"; - if (forDarwin) { + if (Subtarget->TargetType == X86Subtarget::isDarwin) { // Emit pre-function debug information. DW.BeginFunction(&MF); } @@ -95,7 +99,7 @@ if (HasDotTypeDotSizeDirective) O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n"; - if (forDarwin) { + if (Subtarget->TargetType == X86Subtarget::isDarwin) { // Emit post-function debug information. DW.EndFunction(); } @@ -145,7 +149,8 @@ if (!isMemOp) O << '$'; O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" << MO.getConstantPoolIndex(); - if (forDarwin && TM.getRelocationModel() == Reloc::PIC) + if (Subtarget->TargetType == X86Subtarget::isDarwin && + TM.getRelocationModel() == Reloc::PIC) O << "-\"L" << getFunctionNumber() << "$pb\""; int Offset = MO.getOffset(); if (Offset > 0) @@ -159,7 +164,8 @@ bool isMemOp = Modifier && !strcmp(Modifier, "mem"); if (!isMemOp && !isCallOp) O << '$'; // Darwin block shameless ripped from PPCAsmPrinter.cpp - if (forDarwin && TM.getRelocationModel() != Reloc::Static) { + if (Subtarget->TargetType == X86Subtarget::isDarwin && + TM.getRelocationModel() != Reloc::Static) { GlobalValue *GV = MO.getGlobal(); std::string Name = Mang->getValueName(GV); // Link-once, External, or Weakly-linked global variables need @@ -190,7 +196,9 @@ } case MachineOperand::MO_ExternalSymbol: { bool isCallOp = Modifier && !strcmp(Modifier, "call"); - if (isCallOp && forDarwin && TM.getRelocationModel() != Reloc::Static) { + if (isCallOp && + Subtarget->TargetType == X86Subtarget::isDarwin && + TM.getRelocationModel() != Reloc::Static) { std::string Name(GlobalPrefix); Name += MO.getSymbolName(); FnStubs.insert(Name); @@ -332,7 +340,7 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) { ++EmittedInsts; // This works around some Darwin assembler bugs. - if (forDarwin) { + if (Subtarget->TargetType == X86Subtarget::isDarwin) { switch (MI->getOpcode()) { case X86::REP_MOVSB: O << "rep/movsb (%esi),(%edi)\n"; Index: llvm/lib/Target/X86/X86AsmPrinter.cpp diff -u llvm/lib/Target/X86/X86AsmPrinter.cpp:1.181 llvm/lib/Target/X86/X86AsmPrinter.cpp:1.182 --- llvm/lib/Target/X86/X86AsmPrinter.cpp:1.181 Tue May 9 00:12:53 2006 +++ llvm/lib/Target/X86/X86AsmPrinter.cpp Thu May 25 16:59:08 2006 @@ -46,9 +46,6 @@ /// doInitialization bool X86SharedAsmPrinter::doInitialization(Module &M) { - const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>(); - - forDarwin = false; PrivateGlobalPrefix = ".L"; DefaultTextSection = ".text"; DefaultDataSection = ".data"; @@ -65,7 +62,6 @@ LCOMMDirective = "\t.lcomm\t"; COMMDirectiveTakesAlignment = false; HasDotTypeDotSizeDirective = false; - forDarwin = true; StaticCtorsSection = ".mod_init_func"; StaticDtorsSection = ".mod_term_func"; InlineAsmStart = "# InlineAsm Start"; @@ -75,6 +71,8 @@ GlobalPrefix = "_"; COMMDirectiveTakesAlignment = false; HasDotTypeDotSizeDirective = false; + StaticCtorsSection = "\t.section .ctors,\"aw\""; + StaticDtorsSection = "\t.section .dtors,\"aw\""; break; case X86Subtarget::isWindows: GlobalPrefix = "_"; @@ -83,7 +81,7 @@ default: break; } - if (forDarwin) { + if (Subtarget->TargetType == X86Subtarget::isDarwin) { // Emit initial debug information. DW.BeginModule(&M); } @@ -114,7 +112,8 @@ if (C->isNullValue() && /* FIXME: Verify correct */ (I->hasInternalLinkage() || I->hasWeakLinkage() || I->hasLinkOnceLinkage() || - (forDarwin && I->hasExternalLinkage() && !I->hasSection()))) { + (Subtarget->TargetType == X86Subtarget::isDarwin && + I->hasExternalLinkage() && !I->hasSection()))) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. if (I->hasExternalLinkage()) { O << "\t.globl\t" << name << "\n"; @@ -125,13 +124,15 @@ if (LCOMMDirective != NULL) { if (I->hasInternalLinkage()) { O << LCOMMDirective << name << "," << Size; - if (forDarwin) + if (Subtarget->TargetType == X86Subtarget::isDarwin) O << "," << (AlignmentIsInBytes ? (1 << Align) : Align); } else O << COMMDirective << name << "," << Size; } else { - if (I->hasInternalLinkage()) - O << "\t.local\t" << name << "\n"; + if (Subtarget->TargetType == X86Subtarget::isCygwin) { + if (I->hasInternalLinkage()) + O << "\t.local\t" << name << "\n"; + } O << COMMDirective << name << "," << Size; if (COMMDirectiveTakesAlignment) O << "," << (AlignmentIsInBytes ? (1 << Align) : Align); @@ -142,13 +143,16 @@ switch (I->getLinkage()) { case GlobalValue::LinkOnceLinkage: case GlobalValue::WeakLinkage: - if (forDarwin) { + if (Subtarget->TargetType == X86Subtarget::isDarwin) { O << "\t.globl " << name << "\n" << "\t.weak_definition " << name << "\n"; SwitchToDataSection(".section __DATA,__datacoal_nt,coalesced", I); + } else if (Subtarget->TargetType == X86Subtarget::isCygwin) { + O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\"\n" + << "\t.weak " << name << "\n"; } else { - O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n"; - O << "\t.weak " << name << "\n"; + O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n" + << "\t.weak " << name << "\n"; } break; case GlobalValue::AppendingLinkage: @@ -176,7 +180,7 @@ } } - if (forDarwin) { + if (Subtarget->TargetType == X86Subtarget::isDarwin) { SwitchToDataSection("", 0); // Output stubs for dynamically-linked functions Index: llvm/lib/Target/X86/X86AsmPrinter.h diff -u llvm/lib/Target/X86/X86AsmPrinter.h:1.18 llvm/lib/Target/X86/X86AsmPrinter.h:1.19 --- llvm/lib/Target/X86/X86AsmPrinter.h:1.18 Tue May 9 00:12:53 2006 +++ llvm/lib/Target/X86/X86AsmPrinter.h Thu May 25 16:59:08 2006 @@ -57,7 +57,9 @@ X86DwarfWriter DW; X86SharedAsmPrinter(std::ostream &O, X86TargetMachine &TM) - : AsmPrinter(O, TM), DW(O, this), forDarwin(false) { } + : AsmPrinter(O, TM), DW(O, this) { + Subtarget = &TM.getSubtarget<X86Subtarget>(); + } bool doInitialization(Module &M); bool doFinalization(Module &M); @@ -68,11 +70,9 @@ MachineFunctionPass::getAnalysisUsage(AU); } - bool forDarwin; // FIXME: eliminate. - const char *DefaultTextSection; // "_text" for MASM, ".text" for others. const char *DefaultDataSection; // "_data" for MASM, ".data" for others. - + const X86Subtarget *Subtarget; // Necessary for Darwin to print out the apprioriate types of linker stubs std::set<std::string> FnStubs, GVStubs, LinkOnceStubs; Index: llvm/lib/Target/X86/X86Subtarget.cpp diff -u llvm/lib/Target/X86/X86Subtarget.cpp:1.26 llvm/lib/Target/X86/X86Subtarget.cpp:1.27 --- llvm/lib/Target/X86/X86Subtarget.cpp:1.26 Fri Feb 17 18:15:05 2006 +++ llvm/lib/Target/X86/X86Subtarget.cpp Thu May 25 16:59:08 2006 @@ -182,6 +182,6 @@ #endif } - if (TargetType == isDarwin) + if (TargetType == isDarwin || TargetType == isCygwin) stackAlignment = 16; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits