From: Anton Korobeynikov Date: Thu, 7 Aug 2008 09:54:23 +0000 (+0000) Subject: Switch ARM to new section handling stuff X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0f3cc657387d44cd7c56e4ddea896a50ab9106b8;p=oota-llvm.git Switch ARM to new section handling stuff git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54458 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index b853a84d401..3b30f9c5a0d 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -113,12 +113,17 @@ namespace { virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode); + void printModuleLevelGV(const GlobalVariable* GVar); bool printInstruction(const MachineInstr *MI); // autogenerated. void printMachineInstruction(const MachineInstr *MI); bool runOnMachineFunction(MachineFunction &F); bool doInitialization(Module &M); bool doFinalization(Module &M); + /// getSectionForFunction - Return the section that we should emit the + /// specified function body into. + virtual std::string getSectionForFunction(const Function &F) const; + virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) { printDataDirective(MCPV->getType()); @@ -172,6 +177,11 @@ FunctionPass *llvm::createARMCodePrinterPass(std::ostream &o, return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo()); } +// Substitute old hook with new one temporary +std::string ARMAsmPrinter::getSectionForFunction(const Function &F) const { + return TAI->SectionForGlobal(&F); +} + /// runOnMachineFunction - This uses the printInstruction() /// method to print assembly for each instruction. /// @@ -821,176 +831,127 @@ static void PrintUnmangledNameSafely(const Value *V, std::ostream &OS) { OS << *Name; } -bool ARMAsmPrinter::doFinalization(Module &M) { +void ARMAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { const TargetData *TD = TM.getTargetData(); - for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) { - if (!I->hasInitializer()) // External global require no code - continue; - - if (EmitSpecialLLVMGlobal(I)) { - if (Subtarget->isTargetDarwin() && - TM.getRelocationModel() == Reloc::Static) { - if (I->getName() == "llvm.global_ctors") - O << ".reference .constructors_used\n"; - else if (I->getName() == "llvm.global_dtors") - O << ".reference .destructors_used\n"; - } - continue; + if (!GVar->hasInitializer()) // External global require no code + return; + + // Check to see if this is a special global used by LLVM, if so, emit it. + + if (EmitSpecialLLVMGlobal(GVar)) { + if (Subtarget->isTargetDarwin() && + TM.getRelocationModel() == Reloc::Static) { + if (GVar->getName() == "llvm.global_ctors") + O << ".reference .constructors_used\n"; + else if (GVar->getName() == "llvm.global_dtors") + O << ".reference .destructors_used\n"; } + return; + } + + std::string SectionName = TAI->SectionForGlobal(GVar); + std::string name = Mang->getValueName(GVar); + Constant *C = GVar->getInitializer(); + const Type *Type = C->getType(); + unsigned Size = TD->getABITypeSize(Type); + unsigned Align = TD->getPreferredAlignmentLog(GVar); - std::string name = Mang->getValueName(I); - Constant *C = I->getInitializer(); - const Type *Type = C->getType(); - unsigned Size = TD->getABITypeSize(Type); - unsigned Align = TD->getPreferredAlignmentLog(I); + const char *VisibilityDirective = NULL; + if (GVar->hasHiddenVisibility()) + VisibilityDirective = TAI->getHiddenDirective(); + else if (GVar->hasProtectedVisibility()) + VisibilityDirective = TAI->getProtectedDirective(); - const char *VisibilityDirective = NULL; - if (I->hasHiddenVisibility()) - VisibilityDirective = TAI->getHiddenDirective(); - else if (I->hasProtectedVisibility()) - VisibilityDirective = TAI->getProtectedDirective(); + if (VisibilityDirective) + O << VisibilityDirective << name << "\n"; - if (VisibilityDirective) - O << VisibilityDirective << name << "\n"; + if (Subtarget->isTargetELF()) + O << "\t.type " << name << ",%object\n"; - if (Subtarget->isTargetELF()) - O << "\t.type " << name << ",%object\n"; - - if (C->isNullValue() && !I->hasSection() && !I->isThreadLocal()) { - if (I->hasExternalLinkage()) { - if (const char *Directive = TAI->getZeroFillDirective()) { - O << "\t.globl\t" << name << "\n"; - O << Directive << "__DATA, __common, " << name << ", " - << Size << ", " << Align << "\n"; - continue; - } - } + SwitchToDataSection(SectionName.c_str()); - if (I->hasInternalLinkage() || I->hasWeakLinkage() || - I->hasLinkOnceLinkage()) { - if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (!NoZerosInBSS && TAI->getBSSSection()) - SwitchToDataSection(TAI->getBSSSection(), I); - else - SwitchToDataSection(TAI->getDataSection(), I); - if (TAI->getLCOMMDirective() != NULL) { - if (I->hasInternalLinkage()) { - O << TAI->getLCOMMDirective() << name << "," << Size; - if (Subtarget->isTargetDarwin()) - O << "," << Align; - } else - O << TAI->getCOMMDirective() << name << "," << Size; - } else { - if (I->hasInternalLinkage()) - O << "\t.local\t" << name << "\n"; - O << TAI->getCOMMDirective() << name << "," << Size; - if (TAI->getCOMMDirectiveTakesAlignment()) - O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); - } - O << "\t\t" << TAI->getCommentString() << " "; - PrintUnmangledNameSafely(I, O); - O << "\n"; - continue; + if (C->isNullValue() && !GVar->hasSection() && !GVar->isThreadLocal()) { + // FIXME: This seems to be pretty darwin-specific + + if (GVar->hasExternalLinkage()) { + if (const char *Directive = TAI->getZeroFillDirective()) { + O << "\t.globl\t" << name << "\n"; + O << Directive << "__DATA, __common, " << name << ", " + << Size << ", " << Align << "\n"; + return; } } - switch (I->getLinkage()) { - case GlobalValue::LinkOnceLinkage: - case GlobalValue::WeakLinkage: - if (Subtarget->isTargetDarwin()) { - O << "\t.globl " << name << "\n" - << "\t.weak_definition " << name << "\n"; - SwitchToDataSection("\t.section __DATA,__datacoal_nt,coalesced", I); - } else { - std::string SectionName("\t.section\t.llvm.linkonce.d." + - name + - ",\"aw\",%progbits"); - SwitchToDataSection(SectionName.c_str(), I); - O << "\t.weak " << name << "\n"; - } - break; - case GlobalValue::AppendingLinkage: - // FIXME: appending linkage variables should go into a section of - // their name or something. For now, just emit them as external. - case GlobalValue::ExternalLinkage: - O << "\t.globl " << name << "\n"; - // FALL THROUGH - case GlobalValue::InternalLinkage: { - if (I->isConstant()) { - const ConstantArray *CVA = dyn_cast(C); - if (TAI->getCStringSection() && CVA && CVA->isCString()) { - SwitchToDataSection(TAI->getCStringSection(), I); - break; - } - } - // FIXME: special handling for ".ctors" & ".dtors" sections - if (I->hasSection() && - (I->getSection() == ".ctors" || - I->getSection() == ".dtors")) { - assert(!Subtarget->isTargetDarwin()); - std::string SectionName = ".section " + I->getSection(); - SectionName += ",\"aw\",%progbits"; - SwitchToDataSection(SectionName.c_str()); - } else if (I->hasSection() && Subtarget->isTargetDarwin()) { - // Honor all section names on Darwin; ObjC uses this - std::string SectionName = ".section " + I->getSection(); - SwitchToDataSection(SectionName.c_str()); + if (GVar->hasInternalLinkage() || GVar->isWeakForLinker()) { + if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. + + if (TAI->getLCOMMDirective() != NULL) { + if (GVar->hasInternalLinkage()) { + O << TAI->getLCOMMDirective() << name << "," << Size; + if (Subtarget->isTargetDarwin()) + O << "," << Align; + } else + O << TAI->getCOMMDirective() << name << "," << Size; } else { - if (C->isNullValue() && !NoZerosInBSS && TAI->getBSSSection()) - SwitchToDataSection(I->isThreadLocal() ? TAI->getTLSBSSSection() : - TAI->getBSSSection(), I); - else if (!I->isConstant()) - SwitchToDataSection(I->isThreadLocal() ? TAI->getTLSDataSection() : - TAI->getDataSection(), I); - else if (I->isThreadLocal()) - SwitchToDataSection(TAI->getTLSDataSection()); - else { - // Read-only data. - bool HasReloc = C->ContainsRelocations(); - if (HasReloc && - Subtarget->isTargetDarwin() && - TM.getRelocationModel() != Reloc::Static) - SwitchToDataSection("\t.const_data\n"); - else if (!HasReloc && Size == 4 && - TAI->getFourByteConstantSection()) - SwitchToDataSection(TAI->getFourByteConstantSection(), I); - else if (!HasReloc && Size == 8 && - TAI->getEightByteConstantSection()) - SwitchToDataSection(TAI->getEightByteConstantSection(), I); - else if (!HasReloc && Size == 16 && - TAI->getSixteenByteConstantSection()) - SwitchToDataSection(TAI->getSixteenByteConstantSection(), I); - else if (TAI->getReadOnlySection()) - SwitchToDataSection(TAI->getReadOnlySection(), I); - else - SwitchToDataSection(TAI->getDataSection(), I); - } + if (GVar->hasInternalLinkage()) + O << "\t.local\t" << name << "\n"; + O << TAI->getCOMMDirective() << name << "," << Size; + if (TAI->getCOMMDirectiveTakesAlignment()) + O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align); } - - break; + O << "\t\t" << TAI->getCommentString() << " "; + PrintUnmangledNameSafely(GVar, O); + O << "\n"; + return; } - default: - assert(0 && "Unknown linkage type!"); - break; + } + + switch (GVar->getLinkage()) { + case GlobalValue::LinkOnceLinkage: + case GlobalValue::WeakLinkage: + if (Subtarget->isTargetDarwin()) { + O << "\t.globl " << name << "\n" + << "\t.weak_definition " << name << "\n"; + } else { + O << "\t.weak " << name << "\n"; } + break; + case GlobalValue::AppendingLinkage: + // FIXME: appending linkage variables should go into a section of + // their name or something. For now, just emit them as external. + case GlobalValue::ExternalLinkage: + O << "\t.globl " << name << "\n"; + // FALL THROUGH + case GlobalValue::InternalLinkage: + break; + default: + assert(0 && "Unknown linkage type!"); + break; + } - EmitAlignment(Align, I); - O << name << ":\t\t\t\t" << TAI->getCommentString() << " "; - PrintUnmangledNameSafely(I, O); - O << "\n"; - if (TAI->hasDotTypeDotSizeDirective()) - O << "\t.size " << name << ", " << Size << "\n"; - // If the initializer is a extern weak symbol, remember to emit the weak - // reference! - if (const GlobalValue *GV = dyn_cast(C)) - if (GV->hasExternalWeakLinkage()) + EmitAlignment(Align, GVar); + O << name << ":\t\t\t\t" << TAI->getCommentString() << " "; + PrintUnmangledNameSafely(GVar, O); + O << "\n"; + if (TAI->hasDotTypeDotSizeDirective()) + O << "\t.size " << name << ", " << Size << "\n"; + + // If the initializer is a extern weak symbol, remember to emit the weak + // reference! + if (const GlobalValue *GV = dyn_cast(C)) + if (GV->hasExternalWeakLinkage()) ExtWeakSymbols.insert(GV); - EmitGlobalConstant(C); - O << '\n'; - } + EmitGlobalConstant(C); + O << '\n'; +} + + +bool ARMAsmPrinter::doFinalization(Module &M) { + for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); + I != E; ++I) + printModuleLevelGV(I); if (Subtarget->isTargetDarwin()) { SwitchToDataSection(""); diff --git a/lib/Target/ARM/ARMTargetAsmInfo.cpp b/lib/Target/ARM/ARMTargetAsmInfo.cpp index 47abcc6f407..3e057359582 100644 --- a/lib/Target/ARM/ARMTargetAsmInfo.cpp +++ b/lib/Target/ARM/ARMTargetAsmInfo.cpp @@ -43,85 +43,8 @@ static const char *const arm_asm_table[] = { 0,0}; ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) { - Subtarget = &TM.getSubtarget(); AsmTransCBE = arm_asm_table; - if (Subtarget->isTargetDarwin()) { - GlobalPrefix = "_"; - PrivateGlobalPrefix = "L"; - StringConstantPrefix = "\1LC"; - BSSSection = 0; // no BSS section. - ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill - SetDirective = "\t.set\t"; - WeakRefDirective = "\t.weak_reference\t"; - HiddenDirective = "\t.private_extern\t"; - ProtectedDirective = NULL; - JumpTableDataSection = ".const"; - CStringSection = "\t.cstring"; - FourByteConstantSection = "\t.literal4\n"; - EightByteConstantSection = "\t.literal8\n"; - ReadOnlySection = "\t.const\n"; - HasDotTypeDotSizeDirective = false; - NeedsIndirectEncoding = true; - if (TM.getRelocationModel() == Reloc::Static) { - StaticCtorsSection = ".constructor"; - StaticDtorsSection = ".destructor"; - } else { - StaticCtorsSection = ".mod_init_func"; - StaticDtorsSection = ".mod_term_func"; - } - - // In non-PIC modes, emit a special label before jump tables so that the - // linker can perform more accurate dead code stripping. - if (TM.getRelocationModel() != Reloc::PIC_) { - // Emit a local label that is preserved until the linker runs. - JumpTableSpecialLabelPrefix = "l"; - } - - NeedsSet = true; - DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; - DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; - DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; - DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; - DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; - DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; - DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; - DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; - DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; - DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; - DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; - } else { - NeedsSet = false; - HasLEB128 = true; - AbsoluteDebugSectionOffsets = true; - ReadOnlySection = "\t.section\t.rodata\n"; - PrivateGlobalPrefix = ".L"; - WeakRefDirective = "\t.weak\t"; - SetDirective = "\t.set\t"; - DwarfRequiresFrameSection = false; - DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",%progbits"; - DwarfInfoSection = "\t.section\t.debug_info,\"\",%progbits"; - DwarfLineSection = "\t.section\t.debug_line,\"\",%progbits"; - DwarfFrameSection = "\t.section\t.debug_frame,\"\",%progbits"; - DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",%progbits"; - DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",%progbits"; - DwarfStrSection = "\t.section\t.debug_str,\"\",%progbits"; - DwarfLocSection = "\t.section\t.debug_loc,\"\",%progbits"; - DwarfARangesSection = "\t.section\t.debug_aranges,\"\",%progbits"; - DwarfRangesSection = "\t.section\t.debug_ranges,\"\",%progbits"; - DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",%progbits"; - - if (Subtarget->isAAPCS_ABI()) { - StaticCtorsSection = "\t.section .init_array,\"aw\",%init_array"; - StaticDtorsSection = "\t.section .fini_array,\"aw\",%fini_array"; - } else { - StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits"; - StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits"; - } - TLSDataSection = "\t.section .tdata,\"awT\",%progbits"; - TLSBSSSection = "\t.section .tbss,\"awT\",%nobits"; - } - ZeroDirective = "\t.space\t"; AlignmentIsInBytes = false; Data64bitsDirective = 0; CommentString = "@"; @@ -133,6 +56,95 @@ ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) { LCOMMDirective = "\t.lcomm\t"; } +ARMDarwinTargetAsmInfo::ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM): + ARMTargetAsmInfo(TM), DarwinTargetAsmInfo(TM) { + Subtarget = &DTM->getSubtarget(); + + GlobalPrefix = "_"; + PrivateGlobalPrefix = "L"; + StringConstantPrefix = "\1LC"; + BSSSection = 0; // no BSS section + ZeroDirective = "\t.space\t"; + ZeroFillDirective = "\t.zerofill\t"; // Uses .zerofill + SetDirective = "\t.set\t"; + WeakRefDirective = "\t.weak_reference\t"; + HiddenDirective = "\t.private_extern\t"; + ProtectedDirective = NULL; + JumpTableDataSection = ".const"; + CStringSection = "\t.cstring"; + FourByteConstantSection = "\t.literal4\n"; + EightByteConstantSection = "\t.literal8\n"; + ReadOnlySection = "\t.const\n"; + HasDotTypeDotSizeDirective = false; + NeedsIndirectEncoding = true; + if (TM.getRelocationModel() == Reloc::Static) { + StaticCtorsSection = ".constructor"; + StaticDtorsSection = ".destructor"; + } else { + StaticCtorsSection = ".mod_init_func"; + StaticDtorsSection = ".mod_term_func"; + } + + // In non-PIC modes, emit a special label before jump tables so that the + // linker can perform more accurate dead code stripping. + if (TM.getRelocationModel() != Reloc::PIC_) { + // Emit a local label that is preserved until the linker runs. + JumpTableSpecialLabelPrefix = "l"; + } + + NeedsSet = true; + DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; + DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; + DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; + DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; + DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; + DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; + DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; + DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; + DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; + DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; + DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; +} + +ARMELFTargetAsmInfo::ARMELFTargetAsmInfo(const ARMTargetMachine &TM): + ARMTargetAsmInfo(TM), ELFTargetAsmInfo(TM) { + Subtarget = &ETM->getSubtarget(); + + NeedsSet = false; + HasLEB128 = true; + AbsoluteDebugSectionOffsets = true; + CStringSection = ".rodata.str"; + ReadOnlySection = "\t.section\t.rodata\n"; + FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\",@progbits,4"; + EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\",@progbits,8"; + SixteenByteConstantSection = "\t.section\t.rodata.cst16,\"aM\",@progbits,16"; + PrivateGlobalPrefix = ".L"; + WeakRefDirective = "\t.weak\t"; + SetDirective = "\t.set\t"; + DwarfRequiresFrameSection = false; + DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",%progbits"; + DwarfInfoSection = "\t.section\t.debug_info,\"\",%progbits"; + DwarfLineSection = "\t.section\t.debug_line,\"\",%progbits"; + DwarfFrameSection = "\t.section\t.debug_frame,\"\",%progbits"; + DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",%progbits"; + DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",%progbits"; + DwarfStrSection = "\t.section\t.debug_str,\"\",%progbits"; + DwarfLocSection = "\t.section\t.debug_loc,\"\",%progbits"; + DwarfARangesSection = "\t.section\t.debug_aranges,\"\",%progbits"; + DwarfRangesSection = "\t.section\t.debug_ranges,\"\",%progbits"; + DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",%progbits"; + + if (Subtarget->isAAPCS_ABI()) { + StaticCtorsSection = "\t.section .init_array,\"aw\",%init_array"; + StaticDtorsSection = "\t.section .fini_array,\"aw\",%fini_array"; + } else { + StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits"; + StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits"; + } + TLSDataSection = "\t.section .tdata,\"awT\",%progbits"; + TLSBSSSection = "\t.section .tbss,\"awT\",%nobits"; +} + /// Count the number of comma-separated arguments. /// Do not try to detect errors. unsigned ARMTargetAsmInfo::countArguments(const char* p) const { diff --git a/lib/Target/ARM/ARMTargetAsmInfo.h b/lib/Target/ARM/ARMTargetAsmInfo.h index 56539696cde..9030d065bd6 100644 --- a/lib/Target/ARM/ARMTargetAsmInfo.h +++ b/lib/Target/ARM/ARMTargetAsmInfo.h @@ -15,6 +15,9 @@ #define ARMTARGETASMINFO_H #include "llvm/Target/TargetAsmInfo.h" +#include "llvm/Target/ELFTargetAsmInfo.h" +#include "llvm/Target/DarwinTargetAsmInfo.h" + #include "ARMSubtarget.h" namespace llvm { @@ -22,7 +25,7 @@ namespace llvm { // Forward declaration. class ARMTargetMachine; - struct ARMTargetAsmInfo : public TargetAsmInfo { + struct ARMTargetAsmInfo : public virtual TargetAsmInfo { explicit ARMTargetAsmInfo(const ARMTargetMachine &TM); const ARMSubtarget *Subtarget; @@ -32,6 +35,15 @@ namespace llvm { unsigned countString(const char *p) const; }; + struct ARMDarwinTargetAsmInfo : public virtual ARMTargetAsmInfo, + public virtual DarwinTargetAsmInfo { + explicit ARMDarwinTargetAsmInfo(const ARMTargetMachine &TM); + }; + + struct ARMELFTargetAsmInfo : public virtual ARMTargetAsmInfo, + public virtual ELFTargetAsmInfo { + explicit ARMELFTargetAsmInfo(const ARMTargetMachine &TM); + }; } // namespace llvm diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index 913ebe0fa5e..468507427c5 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -58,7 +58,7 @@ unsigned ThumbTargetMachine::getModuleMatchQuality(const Module &M) { return getJITMatchQuality()/2; } -ThumbTargetMachine::ThumbTargetMachine(const Module &M, const std::string &FS) +ThumbTargetMachine::ThumbTargetMachine(const Module &M, const std::string &FS) : ARMTargetMachine(M, FS, true) { } @@ -110,7 +110,14 @@ unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) { const TargetAsmInfo *ARMTargetMachine::createTargetAsmInfo() const { - return new ARMTargetAsmInfo(*this); + switch (Subtarget.TargetType) { + case ARMSubtarget::isDarwin: + return new ARMDarwinTargetAsmInfo(*this); + case ARMSubtarget::isELF: + return new ARMELFTargetAsmInfo(*this); + default: + return new ARMTargetAsmInfo(*this); + } } @@ -124,7 +131,7 @@ bool ARMTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) { // FIXME: temporarily disabling load / store optimization pass for Thumb mode. if (!Fast && !DisableLdStOpti && !Subtarget.isThumb()) PM.add(createARMLoadStoreOptimizationPass()); - + if (!Fast && !DisableIfConversion && !Subtarget.isThumb()) PM.add(createIfConverterPass()); @@ -132,7 +139,7 @@ bool ARMTargetMachine::addPreEmitPass(PassManagerBase &PM, bool Fast) { return true; } -bool ARMTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, +bool ARMTargetMachine::addAssemblyEmitter(PassManagerBase &PM, bool Fast, std::ostream &Out) { // Output assembly language. PM.add(createARMCodePrinterPass(Out, *this)); diff --git a/lib/Target/X86/X86ATTAsmPrinter.cpp b/lib/Target/X86/X86ATTAsmPrinter.cpp index 8c688f354fa..88787e1996d 100644 --- a/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/X86ATTAsmPrinter.cpp @@ -754,8 +754,6 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { if (!GVar->hasInitializer()) return; // External global require no code - std::string SectionName = TAI->SectionForGlobal(GVar); - // Check to see if this is a special global used by LLVM, if so, emit it. if (EmitSpecialLLVMGlobal(GVar)) { if (Subtarget->isTargetDarwin() && @@ -768,6 +766,7 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { return; } + std::string SectionName = TAI->SectionForGlobal(GVar); std::string name = Mang->getValueName(GVar); Constant *C = GVar->getInitializer(); const Type *Type = C->getType();