llvm.org GIT mirror llvm / 203576a
Goodbye TargetAsmInfo. This eliminate last bit of CodeGen and Target in llvm-mc. There is still a bit more refactoring left to do in Targets. But we are now very close to fixing all the layering issues in MC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135611 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 8 years ago
28 changed file(s) with 96 addition(s) and 298 deletion(s). Raw diff Collapse all Expand all
174174 MachineModuleInfo(); // DUMMY CONSTRUCTOR, DO NOT CALL.
175175 // Real constructor.
176176 MachineModuleInfo(const MCAsmInfo &MAI, const MCRegisterInfo &MRI,
177 const MCObjectFileInfo *MOFI,
178 const TargetAsmInfo *TAI);
177 const MCObjectFileInfo *MOFI);
179178 ~MachineModuleInfo();
180179
181180 bool doInitialization();
9999 virtual MCSymbol *
100100 getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
101101 MachineModuleInfo *MMI) const;
102
103 virtual unsigned getPersonalityEncoding() const;
104 virtual unsigned getLSDAEncoding() const;
105 virtual unsigned getFDEEncoding(bool CFI) const;
106 virtual unsigned getTTypeEncoding() const;
107102 };
108103
109104
3030 class MCLineSection;
3131 class StringRef;
3232 class Twine;
33 class TargetAsmInfo;
3433 class MCSectionMachO;
3534 class MCSectionELF;
3635
5251
5352 /// The MCObjectFileInfo for this target.
5453 const MCObjectFileInfo *MOFI;
55
56 const TargetAsmInfo *TAI;
5754
5855 /// Allocator - Allocator object used for creating machine code objects.
5956 ///
118115
119116 public:
120117 explicit MCContext(const MCAsmInfo &MAI, const MCRegisterInfo &MRI,
121 const MCObjectFileInfo *MOFI, const TargetAsmInfo *TAI);
118 const MCObjectFileInfo *MOFI);
122119 ~MCContext();
123120
124121 const MCAsmInfo &getAsmInfo() const { return MAI; }
126123 const MCRegisterInfo &getRegisterInfo() const { return MRI; }
127124
128125 const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
129
130 const TargetAsmInfo &getTargetAsmInfo() const { return *TAI; }
131126
132127 void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
133128
3939 /// non-.globl label. This defaults to true.
4040 bool IsFunctionEHFrameSymbolPrivate;
4141
42 /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
43 /// encoding values for EH.
44 unsigned PersonalityEncoding;
45 unsigned LSDAEncoding;
46 unsigned FDEEncoding;
47 unsigned FDECFIEncoding;
48 unsigned TTypeEncoding;
4249
4350 /// TextSection - Section directive for standard text.
4451 ///
150157 const MCSection *XDataSection;
151158
152159 public:
153 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, MCContext &ctx);
160 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
161 MCContext &ctx);
154162
155163 bool isFunctionEHFrameSymbolPrivate() const {
156164 return IsFunctionEHFrameSymbolPrivate;
161169 bool getCommDirectiveSupportsAlignment() const {
162170 return CommDirectiveSupportsAlignment;
163171 }
172
173 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
174 unsigned getLSDAEncoding() const { return LSDAEncoding; }
175 unsigned getFDEEncoding(bool CFI) const {
176 return CFI ? FDECFIEncoding : FDEEncoding;
177 }
178 unsigned getTTypeEncoding() const { return TTypeEncoding; }
164179
165180 const MCSection *getTextSection() const { return TextSection; }
166181 const MCSection *getDataSection() const { return DataSection; }
261276 enum Environment { IsMachO, IsELF, IsCOFF };
262277 Environment Env;
263278 Reloc::Model RelocM;
279 CodeModel::Model CMModel;
264280 MCContext *Ctx;
265281
266282 void InitMachOMCObjectFileInfo(Triple T);
+0
-35
include/llvm/Target/TargetAsmInfo.h less more
None //===-- llvm/Target/TargetAsmInfo.h -----------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Interface to provide the information necessary for producing assembly files.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #ifndef LLVM_TARGET_TARGETASMINFO_H
14 #define LLVM_TARGET_TARGETASMINFO_H
15
16 #include "llvm/Target/TargetLoweringObjectFile.h"
17
18 namespace llvm {
19 class TargetMachine;
20 class TargetLoweringObjectFile;
21
22 class TargetAsmInfo {
23 const TargetLoweringObjectFile *TLOF;
24
25 public:
26 explicit TargetAsmInfo(const TargetMachine &TM);
27
28 unsigned getFDEEncoding(bool CFI) const {
29 return TLOF->getFDEEncoding(CFI);
30 }
31 };
32
33 }
34 #endif
121121 getExprForDwarfReference(const MCSymbol *Sym, unsigned Encoding,
122122 MCStreamer &Streamer) const;
123123
124 virtual unsigned getPersonalityEncoding() const;
125 virtual unsigned getLSDAEncoding() const;
126 virtual unsigned getFDEEncoding(bool CFI) const;
127 virtual unsigned getTTypeEncoding() const;
128
129124 protected:
130125 virtual const MCSection *
131126 SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
3232 #include "llvm/MC/MCStreamer.h"
3333 #include "llvm/MC/MCSymbol.h"
3434 #include "llvm/Target/Mangler.h"
35 #include "llvm/Target/TargetAsmInfo.h"
3635 #include "llvm/Target/TargetData.h"
3736 #include "llvm/Target/TargetInstrInfo.h"
3837 #include "llvm/Target/TargetLowering.h"
4444 #include "llvm/MC/MCSectionELF.h"
4545 #include "llvm/MC/MCAsmInfo.h"
4646 #include "llvm/Target/Mangler.h"
47 #include "llvm/Target/TargetAsmInfo.h"
4847 #include "llvm/Target/TargetData.h"
4948 #include "llvm/Target/TargetELFWriterInfo.h"
5049 #include "llvm/Target/TargetLowering.h"
6665 ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm)
6766 : MachineFunctionPass(ID), O(o), TM(tm),
6867 OutContext(*new MCContext(*TM.getMCAsmInfo(), *TM.getRegisterInfo(),
69 &TM.getTargetLowering()->getObjFileLowering(),
70 new TargetAsmInfo(tm))),
68 &TM.getTargetLowering()->getObjFileLowering())),
7169 TLOF(TM.getTargetLowering()->getObjFileLowering()),
7270 is64Bit(TM.getTargetData()->getPointerSizeInBits() == 64),
7371 isLittleEndian(TM.getTargetData()->isLittleEndian()),
2626 #include "llvm/MC/MCInstrInfo.h"
2727 #include "llvm/MC/MCStreamer.h"
2828 #include "llvm/MC/MCSubtargetInfo.h"
29 #include "llvm/Target/TargetAsmInfo.h"
3029 #include "llvm/Target/TargetData.h"
3130 #include "llvm/Target/TargetInstrInfo.h"
31 #include "llvm/Target/TargetLowering.h"
32 #include "llvm/Target/TargetLoweringObjectFile.h"
3233 #include "llvm/Target/TargetRegisterInfo.h"
3334 #include "llvm/Target/TargetRegistry.h"
3435 #include "llvm/Target/TargetSubtargetInfo.h"
352353
353354 // Install a MachineModuleInfo class, which is an immutable pass that holds
354355 // all the per-module stuff we're generating, including MCContext.
355 TargetAsmInfo *TAI = new TargetAsmInfo(*this);
356356 MachineModuleInfo *MMI = new MachineModuleInfo(*getMCAsmInfo(),
357357 *getRegisterInfo(),
358 &getTargetLowering()->getObjFileLowering(),
359 TAI);
358 &getTargetLowering()->getObjFileLowering());
360359 PM.add(MMI);
361360 OutContext = &MMI->getContext(); // Return the MCContext specifically by-ref.
362361
1616 #include "llvm/CodeGen/MachineFunctionPass.h"
1717 #include "llvm/CodeGen/MachineFunction.h"
1818 #include "llvm/CodeGen/Passes.h"
19 #include "llvm/Target/TargetAsmInfo.h"
2019 #include "llvm/MC/MCObjectFileInfo.h"
2120 #include "llvm/MC/MCSymbol.h"
2221 #include "llvm/ADT/PointerUnion.h"
253252
254253 MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI,
255254 const MCRegisterInfo &MRI,
256 const MCObjectFileInfo *MOFI,
257 const TargetAsmInfo *TAI)
258 : ImmutablePass(ID), Context(MAI, MRI, MOFI, TAI),
255 const MCObjectFileInfo *MOFI)
256 : ImmutablePass(ID), Context(MAI, MRI, MOFI),
259257 ObjFileMMI(0), CompactUnwindEncoding(0), CurCallSite(0), CallsEHReturn(0),
260258 CallsUnwindInit(0), DbgInfoAvailable(false),
261259 CallsExternalVAFunctionWithFloatingPointArguments(false) {
268266
269267 MachineModuleInfo::MachineModuleInfo()
270268 : ImmutablePass(ID),
271 Context(*(MCAsmInfo*)0, *(MCRegisterInfo*)0, (MCObjectFileInfo*)0, NULL) {
269 Context(*(MCAsmInfo*)0, *(MCRegisterInfo*)0, (MCObjectFileInfo*)0) {
272270 assert(0 && "This MachineModuleInfo constructor should never be called, MMI "
273271 "should always be explicitly constructed by LLVMTargetMachine");
274272 abort();
542542 return SSym;
543543 }
544544
545 unsigned TargetLoweringObjectFileMachO::getPersonalityEncoding() const {
546 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
547 }
548
549 unsigned TargetLoweringObjectFileMachO::getLSDAEncoding() const {
550 return DW_EH_PE_pcrel;
551 }
552
553 unsigned TargetLoweringObjectFileMachO::getFDEEncoding(bool CFI) const {
554 return DW_EH_PE_pcrel;
555 }
556
557 unsigned TargetLoweringObjectFileMachO::getTTypeEncoding() const {
558 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
559 }
560
561545 //===----------------------------------------------------------------------===//
562546 // COFF
563547 //===----------------------------------------------------------------------===//
2727 #include "llvm/Support/Format.h"
2828 #include "llvm/Support/FormattedStream.h"
2929 #include "llvm/Target/TargetAsmBackend.h"
30 #include "llvm/Target/TargetAsmInfo.h"
3130 #include "llvm/Target/TargetLoweringObjectFile.h"
3231 #include
3332 using namespace llvm;
1616 #include "llvm/MC/MCSymbol.h"
1717 #include "llvm/MC/MCLabel.h"
1818 #include "llvm/MC/MCDwarf.h"
19 #include "llvm/Target/TargetAsmInfo.h"
2019 #include "llvm/ADT/SmallString.h"
2120 #include "llvm/ADT/Twine.h"
2221 #include "llvm/Support/ELF.h"
2827
2928
3029 MCContext::MCContext(const MCAsmInfo &mai, const MCRegisterInfo &mri,
31 const MCObjectFileInfo *mofi, const TargetAsmInfo *tai) :
32 MAI(mai), MRI(mri), MOFI(mofi), TAI(tai),
30 const MCObjectFileInfo *mofi) :
31 MAI(mai), MRI(mri), MOFI(mofi),
3332 Allocator(), Symbols(Allocator), UsedNames(Allocator),
3433 NextUniqueID(0),
3534 CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0),
5655
5756 // If the stream for the .secure_log_unique directive was created free it.
5857 delete (raw_ostream*)SecureLog;
59
60 delete TAI;
6158 }
6259
6360 //===----------------------------------------------------------------------===//
1616 #include "llvm/MC/MCInstPrinter.h"
1717 #include "llvm/MC/MCRegisterInfo.h"
1818 #include "llvm/Target/TargetRegistry.h"
19 #include "llvm/Target/TargetAsmInfo.h" // FIXME.
20 #include "llvm/Target/TargetMachine.h" // FIXME.
2119 #include "llvm/Target/TargetSelect.h"
2220 #include "llvm/Support/MemoryObject.h"
2321
3836 LLVMSymbolLookupCallback SymbolLookUp) {
3937 // Initialize targets and assembly printers/parsers.
4038 llvm::InitializeAllTargetInfos();
41 // FIXME: We shouldn't need to initialize the Target(Machine)s.
42 llvm::InitializeAllTargets();
4339 llvm::InitializeAllMCAsmInfos();
4440 llvm::InitializeAllMCCodeGenInfos();
4541 llvm::InitializeAllMCRegisterInfos();
6359 std::string FeaturesStr;
6460 std::string CPU;
6561
66 // FIXME: We shouldn't need to do this (and link in codegen).
67 // When we split this out, we should do it in a way that makes
68 // it straightforward to switch subtargets on the fly.
69 TargetMachine *TM = TheTarget->createTargetMachine(TripleName, CPU,
70 FeaturesStr);
71 assert(TM && "Unable to create target machine!");
72
73 // Get the target assembler info needed to setup the context.
74 const TargetAsmInfo *tai = new TargetAsmInfo(*TM);
75 assert(tai && "Unable to create target assembler!");
76
7762 // Set up the MCContext for creating symbols and MCExpr's.
78 MCContext *Ctx = new MCContext(*MAI, *MRI, 0, tai);
63 MCContext *Ctx = new MCContext(*MAI, *MRI, 0);
7964 assert(Ctx && "Unable to create MCContext!");
8065
8166 // Set up disassembler.
9176
9277 LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType,
9378 GetOpInfo, SymbolLookUp,
94 TheTarget, MAI, MRI, TM, tai,
79 TheTarget, MAI, MRI,
9580 Ctx, DisAsm, IP);
9681 assert(DC && "Allocation failure!");
9782 return DC;
2121 #include "llvm/ADT/OwningPtr.h"
2222
2323 namespace llvm {
24 class TargetAsmInfo;
2524 class MCContext;
2625 class MCAsmInfo;
2726 class MCDisassembler;
2827 class MCInstPrinter;
2928 class MCRegisterInfo;
3029 class Target;
31 class TargetMachine;
3230
3331 //
3432 // This is the disassembler context returned by LLVMCreateDisasm().
6058 llvm::OwningPtr MAI;
6159 // The register information for the target architecture.
6260 llvm::OwningPtr MRI;
63 // The target machine instance.
64 llvm::OwningPtr TM;
65 // The disassembler for the target architecture.
66 // FIXME: using llvm::OwningPtr causes a malloc
67 // error when this LLVMDisasmContext is deleted.
68 const TargetAsmInfo *Tai;
6961 // The assembly context for creating symbols and MCExprs.
7062 llvm::OwningPtr Ctx;
7163 // The disassembler for the target architecture.
7971 LLVMSymbolLookupCallback symbolLookUp,
8072 const Target *theTarget, const MCAsmInfo *mAI,
8173 const MCRegisterInfo *mRI,
82 llvm::TargetMachine *tM, const TargetAsmInfo *tai,
8374 llvm::MCContext *ctx, const MCDisassembler *disAsm,
8475 MCInstPrinter *iP) : TripleName(tripleName),
8576 DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo),
86 SymbolLookUp(symbolLookUp), TheTarget(theTarget), Tai(tai) {
87 TM.reset(tM);
77 SymbolLookUp(symbolLookUp), TheTarget(theTarget) {
8878 MAI.reset(mAI);
8979 MRI.reset(mRI);
9080 Ctx.reset(ctx);
376376 SourceMgr sourceMgr;
377377 sourceMgr.setDiagHandler(diag_handler, static_cast(this));
378378 sourceMgr.AddNewSourceBuffer(buf, SMLoc()); // ownership of buf handed over
379 MCContext context(*AsmInfo, *MRI, NULL, NULL);
379 MCContext context(*AsmInfo, *MRI, NULL);
380380 OwningPtr streamer(createNullStreamer(context));
381381 OwningPtr genericParser(createMCAsmParser(*Tgt, sourceMgr,
382382 context, *streamer,
1818 #include "llvm/Support/Debug.h"
1919 #include "llvm/Support/ErrorHandling.h"
2020 #include "llvm/Support/raw_ostream.h"
21 #include "llvm/Target/TargetAsmInfo.h"
2221 #include "llvm/ADT/FoldingSet.h"
2322 #include "llvm/ADT/SmallString.h"
2423 #include "llvm/ADT/StringExtras.h"
690689 const MCDwarfFrameInfo &Frame) {
691690 MCContext &Context = Streamer.getContext();
692691 const MCObjectFileInfo *MOFI = Context.getObjectFileInfo();
693 const TargetAsmInfo &TAI = Context.getTargetAsmInfo();
694692 bool VerboseAsm = Streamer.isVerboseAsm();
695693
696694 // range-start range-length compact-unwind-enc personality-func lsda
725723 Streamer.SwitchSection(MOFI->getCompactUnwindSection());
726724
727725 // Range Start
728 unsigned FDEEncoding = TAI.getFDEEncoding(UsingCFI);
726 unsigned FDEEncoding = MOFI->getFDEEncoding(UsingCFI);
729727 unsigned Size = getSizeForEncoding(Streamer, FDEEncoding);
730728 if (VerboseAsm) Streamer.AddComment("Range Start");
731729 Streamer.EmitSymbolValue(Frame.Function, Size);
770768 MCContext &context = streamer.getContext();
771769 const MCRegisterInfo &MRI = context.getRegisterInfo();
772770 const MCObjectFileInfo *MOFI = context.getObjectFileInfo();
773 const TargetAsmInfo &TAI = context.getTargetAsmInfo();
774771 bool verboseAsm = streamer.isVerboseAsm();
775772
776773 MCSymbol *sectionStart;
857854 EmitEncodingByte(streamer, lsdaEncoding, "LSDA Encoding");
858855
859856 // Encoding of the FDE pointers
860 EmitEncodingByte(streamer, TAI.getFDEEncoding(UsingCFI),
857 EmitEncodingByte(streamer, MOFI->getFDEEncoding(UsingCFI),
861858 "FDE Encoding");
862859 }
863860
894891 MCSymbol *fdeStart = context.CreateTempSymbol();
895892 MCSymbol *fdeEnd = context.CreateTempSymbol();
896893 const MCObjectFileInfo *MOFI = context.getObjectFileInfo();
897 const TargetAsmInfo &TAI = context.getTargetAsmInfo();
898894 bool verboseAsm = streamer.isVerboseAsm();
899895
900896 if (!MOFI->isFunctionEHFrameSymbolPrivate() && IsEH) {
926922 streamer.EmitSymbolValue(&cieStart, 4);
927923 }
928924
929 unsigned fdeEncoding = TAI.getFDEEncoding(UsingCFI);
925 unsigned fdeEncoding = MOFI->getFDEEncoding(UsingCFI);
930926 unsigned size = getSizeForEncoding(streamer, fdeEncoding);
931927
932928 // PC Begin
1919 // MachO
2020 IsFunctionEHFrameSymbolPrivate = false;
2121 SupportsWeakOmittedEHFrame = false;
22
23 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel
24 | dwarf::DW_EH_PE_sdata4;
25 LSDAEncoding = FDEEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
26 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
27 dwarf::DW_EH_PE_sdata4;
2228
2329 // .comm doesn't support alignment before Leopard.
2430 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
198204 }
199205
200206 void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
207 if (T.getArch() == Triple::x86) {
208 PersonalityEncoding = (RelocM == Reloc::PIC_)
209 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
210 : dwarf::DW_EH_PE_absptr;
211 LSDAEncoding = (RelocM == Reloc::PIC_)
212 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
213 : dwarf::DW_EH_PE_absptr;
214 FDEEncoding = FDECFIEncoding = (RelocM == Reloc::PIC_)
215 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
216 : dwarf::DW_EH_PE_absptr;
217 TTypeEncoding = (RelocM == Reloc::PIC_)
218 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
219 : dwarf::DW_EH_PE_absptr;
220 } else if (T.getArch() == Triple::x86_64) {
221 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
222
223 if (RelocM == Reloc::PIC_) {
224 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
225 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
226 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
227 LSDAEncoding = dwarf::DW_EH_PE_pcrel |
228 (CMModel == CodeModel::Small
229 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
230 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
231 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
232 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
233 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
234 } else {
235 PersonalityEncoding =
236 (CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
237 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
238 LSDAEncoding = (CMModel == CodeModel::Small)
239 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
240 FDEEncoding = dwarf::DW_EH_PE_udata4;
241 TTypeEncoding = (CMModel == CodeModel::Small)
242 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
243 }
244 }
245
201246 // ELF
202247 BSSSection =
203248 Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
445490 }
446491
447492 void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
493 CodeModel::Model cm,
448494 MCContext &ctx) {
449495 RelocM = relocm;
496 CMModel = cm;
450497 Ctx = &ctx;
451498
452499 // Common.
453500 CommDirectiveSupportsAlignment = true;
454501 SupportsWeakOmittedEHFrame = true;
455502 IsFunctionEHFrameSymbolPrivate = true;
456 EHFrameSection = 0;
503
504 PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding =
505 TTypeEncoding = dwarf::DW_EH_PE_absptr;
506
507 EHFrameSection = 0; // Created on demand.
457508
458509 Triple T(TT);
459510 Triple::ArchType Arch = T.getArch();
3232 #include "llvm/Support/MemoryBuffer.h"
3333 #include "llvm/Support/SourceMgr.h"
3434 #include "llvm/Support/raw_ostream.h"
35 #include "llvm/Target/TargetAsmInfo.h"
3635 #include "llvm/Target/TargetAsmParser.h"
3736 #include
3837 #include
16751675 #endif
16761676 TAsm = new CBEMCAsmInfo();
16771677 MRI = new MCRegisterInfo();
1678 TCtx = new MCContext(*TAsm, *MRI, NULL, NULL);
1678 TCtx = new MCContext(*TAsm, *MRI, NULL);
16791679 Mang = new Mangler(*TCtx, *TD);
16801680
16811681 // Keep track of which functions are static ctors/dtors so they can have
+0
-18
lib/Target/TargetAsmInfo.cpp less more
None //===-- llvm/Target/TargetAsmInfo.cpp - Target Assembly Info --------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/Target/TargetAsmInfo.h"
10 #include "llvm/Target/TargetLowering.h"
11 #include "llvm/Target/TargetLoweringObjectFile.h"
12 #include "llvm/Target/TargetMachine.h"
13 using namespace llvm;
14
15 TargetAsmInfo::TargetAsmInfo(const TargetMachine &TM) {
16 TLOF = &TM.getTargetLowering()->getObjFileLowering();
17 }
4040 void TargetLoweringObjectFile::Initialize(MCContext &ctx,
4141 const TargetMachine &TM) {
4242 Ctx = &ctx;
43 InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(), *Ctx);
43 InitMCObjectFileInfo(TM.getTargetTriple(),
44 TM.getRelocationModel(), TM.getCodeModel(), *Ctx);
4445 }
4546
4647 TargetLoweringObjectFile::~TargetLoweringObjectFile() {
321322 }
322323 }
323324 }
324
325 unsigned TargetLoweringObjectFile::getPersonalityEncoding() const {
326 return dwarf::DW_EH_PE_absptr;
327 }
328
329 unsigned TargetLoweringObjectFile::getLSDAEncoding() const {
330 return dwarf::DW_EH_PE_absptr;
331 }
332
333 unsigned TargetLoweringObjectFile::getFDEEncoding(bool CFI) const {
334 return dwarf::DW_EH_PE_absptr;
335 }
336
337 unsigned TargetLoweringObjectFile::getTTypeEncoding() const {
338 return dwarf::DW_EH_PE_absptr;
339 }
340
196196 return new TargetLoweringObjectFileMachO();
197197 }
198198
199 if (Subtarget->isTargetELF()) {
200 if (is64Bit)
201 return new X8664_ELFTargetObjectFile(TM);
202 return new X8632_ELFTargetObjectFile(TM);
203 }
199 if (Subtarget->isTargetELF())
200 return new TargetLoweringObjectFileELF();
204201 if (Subtarget->isTargetCOFF() && !Subtarget->isTargetEnvMacho())
205202 return new TargetLoweringObjectFileCOFF();
206203 llvm_unreachable("unknown subtarget type");
4242 MachineModuleInfo *MMI) const {
4343 return Mang->getSymbol(GV);
4444 }
45
46 unsigned X8632_ELFTargetObjectFile::getPersonalityEncoding() const {
47 if (TM.getRelocationModel() == Reloc::PIC_)
48 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
49 else
50 return DW_EH_PE_absptr;
51 }
52
53 unsigned X8632_ELFTargetObjectFile::getLSDAEncoding() const {
54 if (TM.getRelocationModel() == Reloc::PIC_)
55 return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
56 else
57 return DW_EH_PE_absptr;
58 }
59
60 unsigned X8632_ELFTargetObjectFile::getFDEEncoding(bool FDE) const {
61 if (TM.getRelocationModel() == Reloc::PIC_)
62 return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
63 else
64 return DW_EH_PE_absptr;
65 }
66
67 unsigned X8632_ELFTargetObjectFile::getTTypeEncoding() const {
68 if (TM.getRelocationModel() == Reloc::PIC_)
69 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
70 else
71 return DW_EH_PE_absptr;
72 }
73
74 unsigned X8664_ELFTargetObjectFile::getPersonalityEncoding() const {
75 CodeModel::Model Model = TM.getCodeModel();
76 if (TM.getRelocationModel() == Reloc::PIC_)
77 return DW_EH_PE_indirect | DW_EH_PE_pcrel | (Model == CodeModel::Small ||
78 Model == CodeModel::Medium ?
79 DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
80
81 if (Model == CodeModel::Small || Model == CodeModel::Medium)
82 return DW_EH_PE_udata4;
83
84 return DW_EH_PE_absptr;
85 }
86
87 unsigned X8664_ELFTargetObjectFile::getLSDAEncoding() const {
88 CodeModel::Model Model = TM.getCodeModel();
89 if (TM.getRelocationModel() == Reloc::PIC_)
90 return DW_EH_PE_pcrel | (Model == CodeModel::Small ?
91 DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
92
93 if (Model == CodeModel::Small)
94 return DW_EH_PE_udata4;
95
96 return DW_EH_PE_absptr;
97 }
98
99 unsigned X8664_ELFTargetObjectFile::getFDEEncoding(bool CFI) const {
100 if (CFI)
101 return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
102
103 if (TM.getRelocationModel() == Reloc::PIC_)
104 return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
105
106 return DW_EH_PE_udata4;
107 }
108
109 unsigned X8664_ELFTargetObjectFile::getTTypeEncoding() const {
110 CodeModel::Model Model = TM.getCodeModel();
111 if (TM.getRelocationModel() == Reloc::PIC_)
112 return DW_EH_PE_indirect | DW_EH_PE_pcrel | (Model == CodeModel::Small ||
113 Model == CodeModel::Medium ?
114 DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
115
116 if (Model == CodeModel::Small)
117 return DW_EH_PE_udata4;
118
119 return DW_EH_PE_absptr;
120 }
3232 MachineModuleInfo *MMI) const;
3333 };
3434
35 class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF {
36 const X86TargetMachine &TM;
37 public:
38 X8632_ELFTargetObjectFile(const X86TargetMachine &tm)
39 :TM(tm) { }
40 virtual unsigned getPersonalityEncoding() const;
41 virtual unsigned getLSDAEncoding() const;
42 virtual unsigned getFDEEncoding(bool CFI) const;
43 virtual unsigned getTTypeEncoding() const;
44 };
45
46 class X8664_ELFTargetObjectFile : public TargetLoweringObjectFileELF {
47 const X86TargetMachine &TM;
48 public:
49 X8664_ELFTargetObjectFile(const X86TargetMachine &tm)
50 :TM(tm) { }
51 virtual unsigned getPersonalityEncoding() const;
52 virtual unsigned getLSDAEncoding() const;
53 virtual unsigned getFDEEncoding(bool CFI) const;
54 virtual unsigned getTTypeEncoding() const;
55 };
56
5735 } // end namespace llvm
5836
5937 #endif
2727 #include "llvm/Target/TargetAsmParser.h"
2828 #include "llvm/Target/TargetData.h"
2929 #include "llvm/Target/TargetRegistry.h"
30 #include "llvm/Target/TargetAsmInfo.h" // FIXME.
31 #include "llvm/Target/TargetLowering.h" // FIXME.
32 #include "llvm/Target/TargetLoweringObjectFile.h" // FIXME.
33 #include "llvm/Target/TargetMachine.h" // FIXME.
3430 #include "llvm/Target/TargetSelect.h"
3531 #include "llvm/ADT/OwningPtr.h"
3632 #include "llvm/Support/CommandLine.h"
347343 // Package up features to be passed to target/subtarget
348344 std::string FeaturesStr;
349345
350 // FIXME: We shouldn't need to do this (and link in codegen).
351 // When we split this out, we should do it in a way that makes
352 // it straightforward to switch subtargets on the fly (.e.g,
353 // the .cpu and .code16 directives).
354 OwningPtr TM(TheTarget->createTargetMachine(TripleName,
355 MCPU,
356 FeaturesStr,
357 RelocModel,
358 CMModel));
359
360 if (!TM) {
361 errs() << ProgName << ": error: could not create target for triple '"
362 << TripleName << "'.\n";
363 return 1;
364 }
365
366 const TargetAsmInfo *tai = new TargetAsmInfo(*TM);
367346 // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
368347 // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
369348 OwningPtr MOFI(new MCObjectFileInfo());
370 MCContext Ctx(*MAI, *MRI, MOFI.get(), tai);
371 MOFI->InitMCObjectFileInfo(TripleName, RelocModel, Ctx);
349 MCContext Ctx(*MAI, *MRI, MOFI.get());
350 MOFI->InitMCObjectFileInfo(TripleName, RelocModel, CMModel, Ctx);
372351
373352 if (SaveTempLabels)
374353 Ctx.setAllowTemporaryLabels(false);
379358
380359 formatted_raw_ostream FOS(Out->os());
381360 OwningPtr Str;
382
383 const TargetLoweringObjectFile &TLOF =
384 TM->getTargetLowering()->getObjFileLowering();
385 const_cast(TLOF).Initialize(Ctx, *TM);
386361
387362 OwningPtr MCII(TheTarget->createMCInstrInfo());
388363 OwningPtr
312312 passes.add(createVerifierPass());
313313
314314 // mark which symbols can not be internalized
315 MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),
316 NULL, NULL);
315 MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(), NULL);
317316 Mangler mangler(Context, *_target->getTargetData());
318317 std::vector mustPreserveList;
319318 SmallPtrSet asmUsed;
663663
664664 bool LTOModule::ParseSymbols() {
665665 // Use mangler to add GlobalPrefix to names to match linker names.
666 MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),
667 NULL, NULL);
666 MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),NULL);
668667 Mangler mangler(Context, *_target->getTargetData());
669668
670669 // add functions