llvm.org GIT mirror llvm / e09411d
Pass the Mangler by reference. It is never null and it is not used in casts, so there is no reason to use a pointer. This matches how we pass TM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201025 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
25 changed file(s) with 104 addition(s) and 102 deletion(s). Raw diff Collapse all Expand all
4545 const MCSection *getSectionForConstant(SectionKind Kind) const LLVM_OVERRIDE;
4646
4747 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
48 SectionKind Kind, Mangler *Mang,
48 SectionKind Kind, Mangler &Mang,
4949 const TargetMachine &TM) const
5050 LLVM_OVERRIDE;
5151
5252 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
53 SectionKind Kind, Mangler *Mang,
53 SectionKind Kind, Mangler &Mang,
5454 const TargetMachine &TM) const
5555 LLVM_OVERRIDE;
5656
5757 /// Return an MCExpr to use for a reference to the specified type info global
5858 /// variable from exception handling information.
59 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
59 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
6060 MachineModuleInfo *MMI,
6161 unsigned Encoding,
6262 MCStreamer &Streamer) const
6363 LLVM_OVERRIDE;
6464
6565 // The symbol that gets passed to .cfi_personality.
66 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
66 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
6767 MachineModuleInfo *MMI) const LLVM_OVERRIDE;
6868
6969 void InitializeELF(bool UseInitArray_);
8686 /// Emit the module flags that specify the garbage collection information.
8787 void emitModuleFlags(MCStreamer &Streamer,
8888 ArrayRef ModuleFlags,
89 Mangler *Mang, const TargetMachine &TM) const
89 Mangler &Mang, const TargetMachine &TM) const
9090 LLVM_OVERRIDE;
9191
9292 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
93 SectionKind Kind, Mangler *Mang,
93 SectionKind Kind, Mangler &Mang,
9494 const TargetMachine &TM) const
9595 LLVM_OVERRIDE;
9696
9797 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
98 SectionKind Kind, Mangler *Mang,
98 SectionKind Kind, Mangler &Mang,
9999 const TargetMachine &TM) const
100100 LLVM_OVERRIDE;
101101
104104 /// This hook allows targets to selectively decide not to emit the
105105 /// UsedDirective for some symbols in llvm.used.
106106 /// FIXME: REMOVE this (rdar://7071300)
107 bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const
107 bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang) const
108108 LLVM_OVERRIDE;
109109
110110 /// The mach-o version of this method defaults to returning a stub reference.
111 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
111 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
112112 MachineModuleInfo *MMI,
113113 unsigned Encoding,
114114 MCStreamer &Streamer) const
115115 LLVM_OVERRIDE;
116116
117117 // The symbol that gets passed to .cfi_personality.
118 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
118 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
119119 MachineModuleInfo *MMI) const LLVM_OVERRIDE;
120120 };
121121
126126 virtual ~TargetLoweringObjectFileCOFF() {}
127127
128128 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
129 SectionKind Kind, Mangler *Mang,
129 SectionKind Kind, Mangler &Mang,
130130 const TargetMachine &TM) const
131131 LLVM_OVERRIDE;
132132
133133 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
134 SectionKind Kind, Mangler *Mang,
134 SectionKind Kind, Mangler &Mang,
135135 const TargetMachine &TM) const
136136 LLVM_OVERRIDE;
137137
143143 /// emission is implemented for COFF.
144144 void emitModuleFlags(MCStreamer &Streamer,
145145 ArrayRef ModuleFlags,
146 Mangler *Mang, const TargetMachine &TM) const
146 Mangler &Mang, const TargetMachine &TM) const
147147 LLVM_OVERRIDE;
148148 };
149149
6363 }
6464
6565 /// Emit the module flags that the platform cares about.
66 virtual void emitModuleFlags(MCStreamer &,
67 ArrayRef,
68 Mangler *, const TargetMachine &) const {
69 }
66 virtual void emitModuleFlags(MCStreamer &Streamer,
67 ArrayRef Flags,
68 Mangler &Mang, const TargetMachine &TM) const {}
7069
7170 /// This hook allows targets to selectively decide not to emit the
7271 /// UsedDirective for some symbols in llvm.used.
7372 /// FIXME: REMOVE this (rdar://7071300)
7473 virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
75 Mangler *) const {
74 Mangler &Mang) const {
7675 return GV != 0;
7776 }
7877
8988 /// variable or function definition. This should not be passed external (or
9089 /// available externally) globals.
9190 const MCSection *SectionForGlobal(const GlobalValue *GV,
92 SectionKind Kind, Mangler *Mang,
91 SectionKind Kind, Mangler &Mang,
9392 const TargetMachine &TM) const;
9493
9594 /// This method computes the appropriate section to emit the specified global
9695 /// variable or function definition. This should not be passed external (or
9796 /// available externally) globals.
9897 const MCSection *SectionForGlobal(const GlobalValue *GV,
99 Mangler *Mang,
98 Mangler &Mang,
10099 const TargetMachine &TM) const {
101100 return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
102101 }
106105 /// assume that GV->hasSection() is true.
107106 virtual const MCSection *
108107 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
109 Mangler *Mang, const TargetMachine &TM) const = 0;
108 Mangler &Mang, const TargetMachine &TM) const = 0;
110109
111110 /// Allow the target to completely override section assignment of a global.
112111 virtual const MCSection *
113 getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
112 getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler &Mang,
114113 SectionKind Kind) const {
115114 return 0;
116115 }
118117 /// Return an MCExpr to use for a reference to the specified global variable
119118 /// from exception handling information.
120119 virtual const MCExpr *
121 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
120 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
122121 MachineModuleInfo *MMI, unsigned Encoding,
123122 MCStreamer &Streamer) const;
124123
133132
134133 // The symbol that gets passed to .cfi_personality.
135134 virtual MCSymbol *
136 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
135 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
137136 MachineModuleInfo *MMI) const;
138137
139138 const MCExpr *
156155 virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
157156
158157 virtual const MCExpr *
159 getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler *Mang) const {
158 getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler &Mang) const {
160159 return 0;
161160 }
162161
163162 protected:
164163 virtual const MCSection *
165164 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
166 Mangler *Mang, const TargetMachine &TM) const;
165 Mangler &Mang, const TargetMachine &TM) const;
167166 };
168167
169168 } // end namespace llvm
371371 // Handle local BSS symbols.
372372 if (MAI->hasMachoZeroFillDirective()) {
373373 const MCSection *TheSection =
374 getObjFileLowering().SectionForGlobal(GV, GVKind, Mang, TM);
374 getObjFileLowering().SectionForGlobal(GV, GVKind, *Mang, TM);
375375 // .zerofill __DATA, __bss, _foo, 400, 5
376376 OutStreamer.EmitZerofill(TheSection, GVSym, Size, Align);
377377 return;
400400 }
401401
402402 const MCSection *TheSection =
403 getObjFileLowering().SectionForGlobal(GV, GVKind, Mang, TM);
403 getObjFileLowering().SectionForGlobal(GV, GVKind, *Mang, TM);
404404
405405 // Handle the zerofill directive on darwin, which is a special form of BSS
406406 // emission.
491491 // Print the 'header' of function.
492492 const Function *F = MF->getFunction();
493493
494 OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
494 OutStreamer.SwitchSection(
495 getObjFileLowering().SectionForGlobal(F, *Mang, TM));
495496 EmitVisibility(CurrentFnSym, F->getVisibility());
496497
497498 EmitLinkage(F, CurrentFnSym);
934935 SmallVector ModuleFlags;
935936 M.getModuleFlagsMetadata(ModuleFlags);
936937 if (!ModuleFlags.empty())
937 getObjFileLowering().emitModuleFlags(OutStreamer, ModuleFlags, Mang, TM);
938 getObjFileLowering().emitModuleFlags(OutStreamer, ModuleFlags, *Mang, TM);
938939
939940 // Make sure we wrote out everything we need.
940941 OutStreamer.Flush();
11541155 // FIXME: this isn't the right predicate, should be based on the MCSection
11551156 // for the function.
11561157 F->isWeakForLinker()) {
1157 OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F,Mang,TM));
1158 OutStreamer.SwitchSection(
1159 getObjFileLowering().SectionForGlobal(F, *Mang, TM));
11581160 } else {
11591161 // Otherwise, drop it in the readonly section.
11601162 const MCSection *ReadOnlySection =
13381340 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
13391341 const GlobalValue *GV =
13401342 dyn_cast(InitList->getOperand(i)->stripPointerCasts());
1341 if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, Mang))
1343 if (GV && getObjFileLowering().shouldEmitUsedDirectiveFor(GV, *Mang))
13421344 OutStreamer.EmitSymbolAttribute(getSymbol(GV), MCSA_NoDeadStrip);
13431345 }
13441346 }
15431545 }
15441546
15451547 if (const MCExpr *RelocExpr =
1546 AP.getObjFileLowering().getExecutableRelativeSymbol(CE, AP.Mang))
1548 AP.getObjFileLowering().getExecutableRelativeSymbol(CE, *AP.Mang))
15471549 return RelocExpr;
15481550
15491551 switch (CE->getOpcode()) {
142142 const TargetLoweringObjectFile &TLOF = getObjFileLowering();
143143
144144 const MCExpr *Exp =
145 TLOF.getTTypeGlobalReference(GV, Mang, MMI, Encoding, OutStreamer);
145 TLOF.getTTypeGlobalReference(GV, *Mang, MMI, Encoding, OutStreamer);
146146 OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding));
147147 } else
148148 OutStreamer.EmitIntValue(0, GetSizeOfEncodedValue(Encoding));
118118 if (!shouldEmitPersonality)
119119 return;
120120
121 const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, Asm->Mang, MMI);
121 const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, MMI);
122122 Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding);
123123
124124 Asm->OutStreamer.EmitDebugLabel
100100 if (shouldEmitPersonality) {
101101 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
102102 const Function *Per = MMI->getPersonalities()[MMI->getPersonalityIndex()];
103 const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, Asm->Mang, MMI);
103 const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, MMI);
104104
105105 Asm->OutStreamer.PushSection();
106106 Asm->OutStreamer.EmitWin64EHHandlerData();
4444
4545 MCSymbol *
4646 TargetLoweringObjectFileELF::getCFIPersonalitySymbol(const GlobalValue *GV,
47 Mangler *Mang,
47 Mangler &Mang,
4848 MachineModuleInfo *MMI) const {
4949 unsigned Encoding = getPersonalityEncoding();
5050 switch (Encoding & 0x70) {
5151 default:
5252 report_fatal_error("We do not support this DWARF encoding yet!");
5353 case dwarf::DW_EH_PE_absptr:
54 return getSymbol(*Mang, GV);
54 return getSymbol(Mang, GV);
5555 case dwarf::DW_EH_PE_pcrel: {
5656 return getContext().GetOrCreateSymbol(StringRef("DW.ref.") +
57 getSymbol(*Mang, GV)->getName());
57 getSymbol(Mang, GV)->getName());
5858 }
5959 }
6060 }
8787 }
8888
8989 const MCExpr *TargetLoweringObjectFileELF::
90 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
90 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
9191 MachineModuleInfo *MMI, unsigned Encoding,
9292 MCStreamer &Streamer) const {
9393
9494 if (Encoding & dwarf::DW_EH_PE_indirect) {
9595 MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo();
9696
97 MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, ".DW.stub");
97 MCSymbol *SSym = getSymbolWithGlobalValueBase(Mang, GV, ".DW.stub");
9898
9999 // Add information about the stub reference to ELFMMI so that the stub
100100 // gets emitted by the asmprinter.
101101 MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
102102 if (StubSym.getPointer() == 0) {
103 MCSymbol *Sym = getSymbol(*Mang, GV);
103 MCSymbol *Sym = getSymbol(Mang, GV);
104104 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
105105 }
106106
198198
199199 const MCSection *TargetLoweringObjectFileELF::
200200 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
201 Mangler *Mang, const TargetMachine &TM) const {
201 Mangler &Mang, const TargetMachine &TM) const {
202202 StringRef SectionName = GV->getSection();
203203
204204 // Infer section flags from the section name if we can.
231231
232232 const MCSection *TargetLoweringObjectFileELF::
233233 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
234 Mangler *Mang, const TargetMachine &TM) const {
234 Mangler &Mang, const TargetMachine &TM) const {
235235 // If we have -ffunction-section or -fdata-section then we should emit the
236236 // global value to a uniqued section specifically for it.
237237 bool EmitUniquedSection;
248248 Prefix = getSectionPrefixForGlobal(Kind);
249249
250250 SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
251 MCSymbol *Sym = getSymbol(*Mang, GV);
251 MCSymbol *Sym = getSymbol(Mang, GV);
252252 Name.append(Sym->getName().begin(), Sym->getName().end());
253253 StringRef Group = "";
254254 unsigned Flags = getELFSectionFlags(Kind);
415415 void TargetLoweringObjectFileMachO::
416416 emitModuleFlags(MCStreamer &Streamer,
417417 ArrayRef ModuleFlags,
418 Mangler *Mang, const TargetMachine &TM) const {
418 Mangler &Mang, const TargetMachine &TM) const {
419419 unsigned VersionVal = 0;
420420 unsigned ImageInfoFlags = 0;
421421 MDNode *LinkerOptions = 0;
489489
490490 const MCSection *TargetLoweringObjectFileMachO::
491491 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
492 Mangler *Mang, const TargetMachine &TM) const {
492 Mangler &Mang, const TargetMachine &TM) const {
493493 // Parse the section specifier and create it if valid.
494494 StringRef Segment, Section;
495495 unsigned TAA = 0, StubSize = 0;
528528
529529 const MCSection *TargetLoweringObjectFileMachO::
530530 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
531 Mangler *Mang, const TargetMachine &TM) const {
531 Mangler &Mang, const TargetMachine &TM) const {
532532
533533 // Handle thread local data.
534534 if (Kind.isThreadBSS()) return TLSBSSSection;
610610 /// not to emit the UsedDirective for some symbols in llvm.used.
611611 // FIXME: REMOVE this (rdar://7071300)
612612 bool TargetLoweringObjectFileMachO::
613 shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *Mang) const {
613 shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang) const {
614614 /// On Darwin, internally linked data beginning with "L" or "l" does not have
615615 /// the directive emitted (this occurs in ObjC metadata).
616616 if (!GV) return false;
620620 // FIXME: ObjC metadata is currently emitted as internal symbols that have
621621 // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and
622622 // this horrible hack can go away.
623 MCSymbol *Sym = getSymbol(*Mang, GV);
623 MCSymbol *Sym = getSymbol(Mang, GV);
624624 if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l')
625625 return false;
626626 }
629629 }
630630
631631 const MCExpr *TargetLoweringObjectFileMachO::
632 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
632 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
633633 MachineModuleInfo *MMI, unsigned Encoding,
634634 MCStreamer &Streamer) const {
635635 // The mach-o version of this method defaults to returning a stub reference.
638638 MachineModuleInfoMachO &MachOMMI =
639639 MMI->getObjFileInfo();
640640
641 MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, "$non_lazy_ptr");
641 MCSymbol *SSym = getSymbolWithGlobalValueBase(Mang, GV, "$non_lazy_ptr");
642642
643643 // Add information about the stub reference to MachOMMI so that the stub
644644 // gets emitted by the asmprinter.
646646 GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) :
647647 MachOMMI.getGVStubEntry(SSym);
648648 if (StubSym.getPointer() == 0) {
649 MCSymbol *Sym = getSymbol(*Mang, GV);
649 MCSymbol *Sym = getSymbol(Mang, GV);
650650 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
651651 }
652652
660660 }
661661
662662 MCSymbol *TargetLoweringObjectFileMachO::
663 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
663 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
664664 MachineModuleInfo *MMI) const {
665665 // The mach-o version of this method defaults to returning a stub reference.
666666 MachineModuleInfoMachO &MachOMMI =
667667 MMI->getObjFileInfo();
668668
669 MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, "$non_lazy_ptr");
669 MCSymbol *SSym = getSymbolWithGlobalValueBase(Mang, GV, "$non_lazy_ptr");
670670
671671 // Add information about the stub reference to MachOMMI so that the stub
672672 // gets emitted by the asmprinter.
673673 MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
674674 if (StubSym.getPointer() == 0) {
675 MCSymbol *Sym = getSymbol(*Mang, GV);
675 MCSymbol *Sym = getSymbol(Mang, GV);
676676 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
677677 }
678678
720720
721721 const MCSection *TargetLoweringObjectFileCOFF::
722722 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
723 Mangler *Mang, const TargetMachine &TM) const {
723 Mangler &Mang, const TargetMachine &TM) const {
724724 int Selection = 0;
725725 unsigned Characteristics = getCOFFSectionFlags(Kind);
726726 StringRef Name = GV->getSection();
728728 if (GV->isWeakForLinker()) {
729729 Selection = COFF::IMAGE_COMDAT_SELECT_ANY;
730730 Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
731 MCSymbol *Sym = getSymbol(*Mang, GV);
731 MCSymbol *Sym = getSymbol(Mang, GV);
732732 COMDATSymName = Sym->getName();
733733 }
734734 return getContext().getCOFFSection(Name,
753753
754754 const MCSection *TargetLoweringObjectFileCOFF::
755755 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
756 Mangler *Mang, const TargetMachine &TM) const {
756 Mangler &Mang, const TargetMachine &TM) const {
757757
758758 // If this global is linkonce/weak and the target handles this by emitting it
759759 // into a 'uniqued' section name, create and return the section now.
762762 unsigned Characteristics = getCOFFSectionFlags(Kind);
763763
764764 Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
765 MCSymbol *Sym = getSymbol(*Mang, GV);
765 MCSymbol *Sym = getSymbol(Mang, GV);
766766 return getContext().getCOFFSection(Name, Characteristics,
767767 Kind, Sym->getName(),
768768 COFF::IMAGE_COMDAT_SELECT_ANY);
794794 void TargetLoweringObjectFileCOFF::
795795 emitModuleFlags(MCStreamer &Streamer,
796796 ArrayRef ModuleFlags,
797 Mangler *Mang, const TargetMachine &TM) const {
797 Mangler &Mang, const TargetMachine &TM) const {
798798 MDNode *LinkerOptions = 0;
799799
800800 // Look for the "Linker Options" flag, since it's the only one we support.
473473 // Now any user defined text sections from function attributes.
474474 for (Module::iterator F = M.begin(), e = M.end(); F != e; ++F)
475475 if (!F->isDeclaration() && !F->hasAvailableExternallyLinkage())
476 TextSections.insert(TLOFMacho.SectionForGlobal(F, Mang, TM));
476 TextSections.insert(TLOFMacho.SectionForGlobal(F, *Mang, TM));
477477 // Now the coalescable sections.
478478 TextSections.insert(TLOFMacho.getTextCoalSection());
479479 TextSections.insert(TLOFMacho.getConstTextCoalSection());
4141 }
4242
4343 const MCExpr *ARMElfTargetObjectFile::
44 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
44 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
4545 MachineModuleInfo *MMI, unsigned Encoding,
4646 MCStreamer &Streamer) const {
4747 assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
4848
49 return MCSymbolRefExpr::Create(getSymbol(*Mang, GV),
49 return MCSymbolRefExpr::Create(getSymbol(Mang, GV),
5050 MCSymbolRefExpr::VK_ARM_TARGET2,
5151 getContext());
5252 }
2727
2828 void Initialize(MCContext &Ctx, const TargetMachine &TM) LLVM_OVERRIDE;
2929
30 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
30 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
3131 MachineModuleInfo *MMI,
3232 unsigned Encoding,
3333 MCStreamer &Streamer) const
8484 return false;
8585 }
8686
87 const MCSection *HexagonTargetObjectFile::
88 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
89 Mangler *Mang, const TargetMachine &TM) const {
87 const MCSection *
88 HexagonTargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
89 SectionKind Kind, Mangler &Mang,
90 const TargetMachine &TM) const {
9091
9192 // Handle Small Section classification here.
9293 if (Kind.isBSS() && IsGlobalInSmallSection(GV, TM, Kind))
3030
3131 bool IsSmallDataEnabled () const;
3232 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
33 SectionKind Kind, Mangler *Mang,
33 SectionKind Kind, Mangler &Mang,
3434 const TargetMachine &TM) const
3535 LLVM_OVERRIDE;
3636 };
8787
8888 const MCSection *MipsTargetObjectFile::
8989 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
90 Mangler *Mang, const TargetMachine &TM) const {
90 Mangler &Mang, const TargetMachine &TM) const {
9191 // TODO: Could also support "weak" symbols as well with ".gnu.linkonce.s.*"
9292 // sections?
9393
2929 const TargetMachine &TM) const;
3030
3131 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
32 SectionKind Kind, Mangler *Mang,
32 SectionKind Kind, Mangler &Mang,
3333 const TargetMachine &TM) const
3434 LLVM_OVERRIDE;
3535 };
9191 }
9292
9393 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
94 SectionKind Kind, Mangler *Mang,
94 SectionKind Kind, Mangler &Mang,
9595 const TargetMachine &TM) const
9696 LLVM_OVERRIDE {
9797 return DataSection;
2121 InitializeELF(TM.Options.UseInitArray);
2222 }
2323
24 const MCSection * PPC64LinuxTargetObjectFile::
25 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
26 Mangler *Mang, const TargetMachine &TM) const {
24 const MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal(
25 const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
26 const TargetMachine &TM) const {
2727
2828 const MCSection *DefaultSection =
2929 TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang, TM);
2222 void Initialize(MCContext &Ctx, const TargetMachine &TM) LLVM_OVERRIDE;
2323
2424 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
25 SectionKind Kind, Mangler *Mang,
25 SectionKind Kind, Mangler &Mang,
2626 const TargetMachine &TM) const
2727 LLVM_OVERRIDE;
2828
1515
1616
1717 const MCExpr *SparcELFTargetObjectFile::
18 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
18 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
1919 MachineModuleInfo *MMI, unsigned Encoding,
2020 MCStreamer &Streamer) const {
2121
2222 if (Encoding & dwarf::DW_EH_PE_pcrel) {
2323 MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo();
2424
25 MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, ".DW.stub");
25 MCSymbol *SSym = getSymbolWithGlobalValueBase(Mang, GV, ".DW.stub");
2626
2727 // Add information about the stub reference to ELFMMI so that the stub
2828 // gets emitted by the asmprinter.
2929 MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
3030 if (StubSym.getPointer() == 0) {
31 MCSymbol *Sym = getSymbol(*Mang, GV);
31 MCSymbol *Sym = getSymbol(Mang, GV);
3232 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
3333 }
3434
2222 TargetLoweringObjectFileELF()
2323 {}
2424
25 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
25 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
2626 MachineModuleInfo *MMI,
2727 unsigned Encoding,
2828 MCStreamer &Streamer) const
119119 }
120120
121121 MCSymbol *TargetLoweringObjectFile::
122 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
122 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
123123 MachineModuleInfo *MMI) const {
124 return getSymbol(*Mang, GV);
124 return getSymbol(Mang, GV);
125125 }
126126
127127 void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
263263 /// the specified global variable or function definition. This should not
264264 /// be passed external (or available externally) globals.
265265 const MCSection *TargetLoweringObjectFile::
266 SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang,
266 SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
267267 const TargetMachine &TM) const {
268268 // Select section name.
269269 if (GV->hasSection())
279279 const MCSection *
280280 TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV,
281281 SectionKind Kind,
282 Mangler *Mang,
282 Mangler &Mang,
283283 const TargetMachine &TM) const{
284284 assert(!Kind.isThreadLocal() && "Doesn't support TLS");
285285
310310 /// reference to the specified global variable from exception
311311 /// handling information.
312312 const MCExpr *TargetLoweringObjectFile::
313 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
313 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
314314 MachineModuleInfo *MMI, unsigned Encoding,
315315 MCStreamer &Streamer) const {
316316 const MCSymbolRefExpr *Ref =
317 MCSymbolRefExpr::Create(getSymbol(*Mang, GV), getContext());
317 MCSymbolRefExpr::Create(getSymbol(Mang, GV), getContext());
318318
319319 return getTTypeReference(Ref, Encoding, Streamer);
320320 }
1818 using namespace dwarf;
1919
2020 const MCExpr *X86_64MachoTargetObjectFile::
21 getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
21 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
2222 MachineModuleInfo *MMI, unsigned Encoding,
2323 MCStreamer &Streamer) const {
2424
2525 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
2626 // is an indirect pc-relative reference.
2727 if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
28 const MCSymbol *Sym = getSymbol(*Mang, GV);
28 const MCSymbol *Sym = getSymbol(Mang, GV);
2929 const MCExpr *Res =
3030 MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
3131 const MCExpr *Four = MCConstantExpr::Create(4, getContext());
3737 }
3838
3939 MCSymbol *X86_64MachoTargetObjectFile::
40 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
40 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
4141 MachineModuleInfo *MMI) const {
42 return getSymbol(*Mang, GV);
42 return getSymbol(Mang, GV);
4343 }
4444
4545 void
5656
5757 const MCExpr *
5858 X86WindowsTargetObjectFile::getExecutableRelativeSymbol(const ConstantExpr *CE,
59 Mangler *Mang) const {
59 Mangler &Mang) const {
6060 // We are looking for the difference of two symbols, need a subtraction
6161 // operation.
6262 const SubOperator *Sub = dyn_cast(CE);
102102 return 0;
103103
104104 return MCSymbolRefExpr::Create(
105 getSymbol(*Mang, GVLHS), MCSymbolRefExpr::VK_COFF_IMGREL32, getContext());
105 getSymbol(Mang, GVLHS), MCSymbolRefExpr::VK_COFF_IMGREL32, getContext());
106106 }
1919 /// x86-64.
2020 class X86_64MachoTargetObjectFile : public TargetLoweringObjectFileMachO {
2121 public:
22 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
22 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
2323 MachineModuleInfo *MMI,
2424 unsigned Encoding,
2525 MCStreamer &Streamer) const
2727
2828 // getCFIPersonalitySymbol - The symbol that gets passed to
2929 // .cfi_personality.
30 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
30 MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
3131 MachineModuleInfo *MMI) const
3232 LLVM_OVERRIDE;
3333 };
4545 /// \brief This implementation is used for Windows targets on x86 and x86-64.
4646 class X86WindowsTargetObjectFile : public TargetLoweringObjectFileCOFF {
4747 const MCExpr *getExecutableRelativeSymbol(const ConstantExpr *CE,
48 Mangler *Mang) const
48 Mangler &Mang) const
4949 LLVM_OVERRIDE;
5050 };
5151
112112 return;
113113
114114 const DataLayout *TD = TM.getDataLayout();
115 OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang,TM));
116
117
115 OutStreamer.SwitchSection(
116 getObjFileLowering().SectionForGlobal(GV, *Mang, TM));
117
118118 MCSymbol *GVSym = getSymbol(GV);
119119 const Constant *C = GV->getInitializer();
120120 unsigned Align = (unsigned)TD->getPreferredTypeAlignmentShift(C->getType());
119119
120120 const MCSection *XCoreTargetObjectFile::
121121 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
122 Mangler *Mang, const TargetMachine &TM) const {
122 Mangler &Mang, const TargetMachine &TM) const {
123123 StringRef SectionName = GV->getSection();
124124 // Infer section flags from the section name if we can.
125125 Kind = getXCoreKindForNamedSection(SectionName, Kind);
128128 }
129129
130130 const MCSection *XCoreTargetObjectFile::
131 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang,
131 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
132132 const TargetMachine &TM) const{
133133 if (Kind.isText()) return TextSection;
134134 if (Kind.isMergeable1ByteCString()) return CStringSection;
2323 void Initialize(MCContext &Ctx, const TargetMachine &TM);
2424
2525 const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
26 SectionKind Kind, Mangler *Mang,
26 SectionKind Kind, Mangler &Mang,
2727 const TargetMachine &TM) const
2828 LLVM_OVERRIDE;
2929
3030 const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
31 SectionKind Kind, Mangler *Mang,
31 SectionKind Kind, Mangler &Mang,
3232 const TargetMachine &TM) const
3333 LLVM_OVERRIDE;
3434