llvm.org GIT mirror llvm / 965e3bc
Use a consistent argument order in TargetLoweringObjectFile. These methods normally call each other and it is really annoying if the arguments are in different order. The more common rule was that the arguments specific to call are first (GV, Encoding, Suffix) and the auxiliary objects (Mang, TM) come after. This patch changes the exceptions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201044 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
12 changed file(s) with 72 addition(s) and 78 deletion(s). Raw diff Collapse all Expand all
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,
60 unsigned Encoding, Mangler &Mang,
6061 MachineModuleInfo *MMI,
61 unsigned Encoding,
6262 MCStreamer &Streamer) const
6363 LLVM_OVERRIDE;
6464
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,
112 unsigned Encoding, Mangler &Mang,
112113 MachineModuleInfo *MMI,
113 unsigned Encoding,
114114 MCStreamer &Streamer) const
115115 LLVM_OVERRIDE;
116116
108108 Mangler &Mang, const TargetMachine &TM) const = 0;
109109
110110 /// Allow the target to completely override section assignment of a global.
111 virtual const MCSection *
112 getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler &Mang,
113 SectionKind Kind) const {
111 virtual const MCSection *getSpecialCasedSectionGlobals(const GlobalValue *GV,
112 SectionKind Kind,
113 Mangler &Mang) const {
114114 return 0;
115115 }
116116
117117 /// Return an MCExpr to use for a reference to the specified global variable
118118 /// from exception handling information.
119 virtual const MCExpr *
120 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
121 MachineModuleInfo *MMI, unsigned Encoding,
122 MCStreamer &Streamer) const;
119 virtual const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
120 unsigned Encoding,
121 Mangler &Mang,
122 MachineModuleInfo *MMI,
123 MCStreamer &Streamer) const;
123124
124125 /// Return the MCSymbol for the specified global value. This symbol is the
125126 /// main label that is the address of the global
126 MCSymbol *getSymbol(Mangler &M, const GlobalValue *GV) const;
127 MCSymbol *getSymbol(const GlobalValue *GV, Mangler &M) const;
127128
128129 /// Return the MCSymbol for a private symbol with global value name as its
129130 /// base, with the specified suffix.
130 MCSymbol *getSymbolWithGlobalValueBase(Mangler &M, const GlobalValue *GV,
131 StringRef Suffix) const;
131 MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
132 StringRef Suffix, Mangler &M) const;
132133
133134 // The symbol that gets passed to .cfi_personality.
134135 virtual MCSymbol *
311311 }
312312
313313 MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const {
314 return getObjFileLowering().getSymbol(*Mang, GV);
314 return getObjFileLowering().getSymbol(GV, *Mang);
315315 }
316316
317317 /// EmitGlobalVariable - Emit the specified global variable to the .s file.
20742074
20752075 MCSymbol *AsmPrinter::getSymbolWithGlobalValueBase(const GlobalValue *GV,
20762076 StringRef Suffix) const {
2077 return getObjFileLowering().getSymbolWithGlobalValueBase(*Mang, GV, Suffix);
2077 return getObjFileLowering().getSymbolWithGlobalValueBase(GV, Suffix, *Mang);
20782078 }
20792079
20802080 /// GetExternalSymbolSymbol - Return the MCSymbol for the specified
142142 const TargetLoweringObjectFile &TLOF = getObjFileLowering();
143143
144144 const MCExpr *Exp =
145 TLOF.getTTypeGlobalReference(GV, *Mang, MMI, Encoding, OutStreamer);
145 TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, MMI, OutStreamer);
146146 OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding));
147147 } else
148148 OutStreamer.EmitIntValue(0, GetSizeOfEncodedValue(Encoding));
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(GV, Mang);
5555 case dwarf::DW_EH_PE_pcrel: {
5656 return getContext().GetOrCreateSymbol(StringRef("DW.ref.") +
57 getSymbol(Mang, GV)->getName());
57 getSymbol(GV, Mang)->getName());
5858 }
5959 }
6060 }
8686 Streamer.EmitSymbolValue(Sym, Size);
8787 }
8888
89 const MCExpr *TargetLoweringObjectFileELF::
90 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
91 MachineModuleInfo *MMI, unsigned Encoding,
92 MCStreamer &Streamer) const {
89 const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
90 const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
91 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
9392
9493 if (Encoding & dwarf::DW_EH_PE_indirect) {
9594 MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo();
9695
97 MCSymbol *SSym = getSymbolWithGlobalValueBase(Mang, GV, ".DW.stub");
96 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang);
9897
9998 // Add information about the stub reference to ELFMMI so that the stub
10099 // gets emitted by the asmprinter.
101100 MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
102101 if (StubSym.getPointer() == 0) {
103 MCSymbol *Sym = getSymbol(Mang, GV);
102 MCSymbol *Sym = getSymbol(GV, Mang);
104103 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
105104 }
106105
109108 Encoding & ~dwarf::DW_EH_PE_indirect, Streamer);
110109 }
111110
112 return TargetLoweringObjectFile::
113 getTTypeGlobalReference(GV, Mang, MMI, Encoding, Streamer);
111 return TargetLoweringObjectFile::getTTypeGlobalReference(GV, Encoding, Mang,
112 MMI, Streamer);
114113 }
115114
116115 static SectionKind
248247 Prefix = getSectionPrefixForGlobal(Kind);
249248
250249 SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
251 MCSymbol *Sym = getSymbol(Mang, GV);
250 MCSymbol *Sym = getSymbol(GV, Mang);
252251 Name.append(Sym->getName().begin(), Sym->getName().end());
253252 StringRef Group = "";
254253 unsigned Flags = getELFSectionFlags(Kind);
620619 // FIXME: ObjC metadata is currently emitted as internal symbols that have
621620 // \1L and \0l prefixes on them. Fix them to be Private/LinkerPrivate and
622621 // this horrible hack can go away.
623 MCSymbol *Sym = getSymbol(Mang, GV);
622 MCSymbol *Sym = getSymbol(GV, Mang);
624623 if (Sym->getName()[0] == 'L' || Sym->getName()[0] == 'l')
625624 return false;
626625 }
628627 return true;
629628 }
630629
631 const MCExpr *TargetLoweringObjectFileMachO::
632 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
633 MachineModuleInfo *MMI, unsigned Encoding,
634 MCStreamer &Streamer) const {
630 const MCExpr *TargetLoweringObjectFileMachO::getTTypeGlobalReference(
631 const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
632 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
635633 // The mach-o version of this method defaults to returning a stub reference.
636634
637635 if (Encoding & DW_EH_PE_indirect) {
638636 MachineModuleInfoMachO &MachOMMI =
639637 MMI->getObjFileInfo();
640638
641 MCSymbol *SSym = getSymbolWithGlobalValueBase(Mang, GV, "$non_lazy_ptr");
639 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang);
642640
643641 // Add information about the stub reference to MachOMMI so that the stub
644642 // gets emitted by the asmprinter.
646644 GV->hasHiddenVisibility() ? MachOMMI.getHiddenGVStubEntry(SSym) :
647645 MachOMMI.getGVStubEntry(SSym);
648646 if (StubSym.getPointer() == 0) {
649 MCSymbol *Sym = getSymbol(Mang, GV);
647 MCSymbol *Sym = getSymbol(GV, Mang);
650648 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
651649 }
652650
656654 }
657655
658656 return TargetLoweringObjectFile::
659 getTTypeGlobalReference(GV, Mang, MMI, Encoding, Streamer);
657 getTTypeGlobalReference(GV, Encoding, Mang, MMI, Streamer);
660658 }
661659
662660 MCSymbol *TargetLoweringObjectFileMachO::
666664 MachineModuleInfoMachO &MachOMMI =
667665 MMI->getObjFileInfo();
668666
669 MCSymbol *SSym = getSymbolWithGlobalValueBase(Mang, GV, "$non_lazy_ptr");
667 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr", Mang);
670668
671669 // Add information about the stub reference to MachOMMI so that the stub
672670 // gets emitted by the asmprinter.
673671 MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym);
674672 if (StubSym.getPointer() == 0) {
675 MCSymbol *Sym = getSymbol(Mang, GV);
673 MCSymbol *Sym = getSymbol(GV, Mang);
676674 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
677675 }
678676
728726 if (GV->isWeakForLinker()) {
729727 Selection = COFF::IMAGE_COMDAT_SELECT_ANY;
730728 Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
731 MCSymbol *Sym = getSymbol(Mang, GV);
729 MCSymbol *Sym = getSymbol(GV, Mang);
732730 COMDATSymName = Sym->getName();
733731 }
734732 return getContext().getCOFFSection(Name,
762760 unsigned Characteristics = getCOFFSectionFlags(Kind);
763761
764762 Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
765 MCSymbol *Sym = getSymbol(Mang, GV);
763 MCSymbol *Sym = getSymbol(GV, Mang);
766764 return getContext().getCOFFSection(Name, Characteristics,
767765 Kind, Sym->getName(),
768766 COFF::IMAGE_COMDAT_SELECT_ANY);
4040 SectionKind::getMetadata());
4141 }
4242
43 const MCExpr *ARMElfTargetObjectFile::
44 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
45 MachineModuleInfo *MMI, unsigned Encoding,
46 MCStreamer &Streamer) const {
43 const MCExpr *ARMElfTargetObjectFile::getTTypeGlobalReference(
44 const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
45 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
4746 assert(Encoding == DW_EH_PE_absptr && "Can handle absptr encoding only");
4847
49 return MCSymbolRefExpr::Create(getSymbol(Mang, GV),
48 return MCSymbolRefExpr::Create(getSymbol(GV, Mang),
5049 MCSymbolRefExpr::VK_ARM_TARGET2,
5150 getContext());
5251 }
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,
31 unsigned Encoding, Mangler &Mang,
3132 MachineModuleInfo *MMI,
32 unsigned Encoding,
3333 MCStreamer &Streamer) const
3434 LLVM_OVERRIDE;
3535
1313
1414 using namespace llvm;
1515
16
17 const MCExpr *SparcELFTargetObjectFile::
18 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
19 MachineModuleInfo *MMI, unsigned Encoding,
20 MCStreamer &Streamer) const {
16 const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
17 const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
18 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
2119
2220 if (Encoding & dwarf::DW_EH_PE_pcrel) {
2321 MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo();
2422
25 MCSymbol *SSym = getSymbolWithGlobalValueBase(Mang, GV, ".DW.stub");
23 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang);
2624
2725 // Add information about the stub reference to ELFMMI so that the stub
2826 // gets emitted by the asmprinter.
2927 MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
3028 if (StubSym.getPointer() == 0) {
31 MCSymbol *Sym = getSymbol(Mang, GV);
29 MCSymbol *Sym = getSymbol(GV, Mang);
3230 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
3331 }
3432
3735 MCSymbolRefExpr::Create(SSym, Ctx), Ctx);
3836 }
3937
40 return TargetLoweringObjectFileELF::
41 getTTypeGlobalReference(GV, Mang, MMI, Encoding, Streamer);
38 return TargetLoweringObjectFileELF::getTTypeGlobalReference(
39 GV, Encoding, Mang, MMI, Streamer);
4240 }
2222 TargetLoweringObjectFileELF()
2323 {}
2424
25 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
25 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
26 unsigned Encoding, Mangler &Mang,
2627 MachineModuleInfo *MMI,
27 unsigned Encoding,
2828 MCStreamer &Streamer) const
2929 LLVM_OVERRIDE;
3030 };
100100
101101 /// Return the MCSymbol for the specified global value. This
102102 /// symbol is the main label that is the address of the global.
103 MCSymbol *TargetLoweringObjectFile::getSymbol(Mangler &M,
104 const GlobalValue *GV) const {
103 MCSymbol *TargetLoweringObjectFile::getSymbol(const GlobalValue *GV,
104 Mangler &M) const {
105105 SmallString<60> NameStr;
106106 M.getNameWithPrefix(NameStr, GV);
107107 return Ctx->GetOrCreateSymbol(NameStr.str());
108108 }
109109
110110 MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase(
111 Mangler &M, const GlobalValue *GV, StringRef Suffix) const {
111 const GlobalValue *GV, StringRef Suffix, Mangler &M) const {
112112 assert(!Suffix.empty());
113113
114114 SmallString<60> NameStr;
121121 MCSymbol *TargetLoweringObjectFile::
122122 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
123123 MachineModuleInfo *MMI) const {
124 return getSymbol(Mang, GV);
124 return getSymbol(GV, Mang);
125125 }
126126
127127 void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
309309 /// getTTypeGlobalReference - Return an MCExpr to use for a
310310 /// reference to the specified global variable from exception
311311 /// handling information.
312 const MCExpr *TargetLoweringObjectFile::
313 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
314 MachineModuleInfo *MMI, unsigned Encoding,
315 MCStreamer &Streamer) const {
312 const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference(
313 const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
314 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
316315 const MCSymbolRefExpr *Ref =
317 MCSymbolRefExpr::Create(getSymbol(Mang, GV), getContext());
316 MCSymbolRefExpr::Create(getSymbol(GV, Mang), getContext());
318317
319318 return getTTypeReference(Ref, Encoding, Streamer);
320319 }
1717 using namespace llvm;
1818 using namespace dwarf;
1919
20 const MCExpr *X86_64MachoTargetObjectFile::
21 getTTypeGlobalReference(const GlobalValue *GV, Mangler &Mang,
22 MachineModuleInfo *MMI, unsigned Encoding,
23 MCStreamer &Streamer) const {
20 const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference(
21 const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
22 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
2423
2524 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
2625 // is an indirect pc-relative reference.
2726 if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
28 const MCSymbol *Sym = getSymbol(Mang, GV);
27 const MCSymbol *Sym = getSymbol(GV, Mang);
2928 const MCExpr *Res =
3029 MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
3130 const MCExpr *Four = MCConstantExpr::Create(4, getContext());
3231 return MCBinaryExpr::CreateAdd(Res, Four, getContext());
3332 }
3433
35 return TargetLoweringObjectFileMachO::
36 getTTypeGlobalReference(GV, Mang, MMI, Encoding, Streamer);
34 return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
35 GV, Encoding, Mang, MMI, Streamer);
3736 }
3837
3938 MCSymbol *X86_64MachoTargetObjectFile::
4039 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
4140 MachineModuleInfo *MMI) const {
42 return getSymbol(Mang, GV);
41 return getSymbol(GV, Mang);
4342 }
4443
4544 void
102101 return 0;
103102
104103 return MCSymbolRefExpr::Create(
105 getSymbol(Mang, GVLHS), MCSymbolRefExpr::VK_COFF_IMGREL32, getContext());
104 getSymbol(GVLHS, Mang), MCSymbolRefExpr::VK_COFF_IMGREL32, getContext());
106105 }
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,
23 unsigned Encoding, Mangler &Mang,
2324 MachineModuleInfo *MMI,
24 unsigned Encoding,
2525 MCStreamer &Streamer) const
2626 LLVM_OVERRIDE;
2727