llvm.org GIT mirror llvm / 78c10ee
Rename TargetAsmBackend to MCAsmBackend; rename createAsmBackend to createMCAsmBackend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136010 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 9 years ago
37 changed file(s) with 319 addition(s) and 333 deletion(s). Raw diff Collapse all Expand all
0 //===-- llvm/MC/MCAsmBack.h - MC Asm Backend --------------------*- 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 #ifndef LLVM_MC_MCASMBACKEND_H
10 #define LLVM_MC_MCASMBACKEND_H
11
12 #include "llvm/MC/MCDirectives.h"
13 #include "llvm/MC/MCFixup.h"
14 #include "llvm/MC/MCFixupKindInfo.h"
15 #include "llvm/Support/DataTypes.h"
16
17 namespace llvm {
18 class MCELFObjectTargetWriter;
19 class MCFixup;
20 class MCInst;
21 class MCObjectWriter;
22 class MCSection;
23 template
24 class SmallVectorImpl;
25 class raw_ostream;
26
27 /// MCAsmBackend - Generic interface to target specific assembler backends.
28 class MCAsmBackend {
29 MCAsmBackend(const MCAsmBackend &); // DO NOT IMPLEMENT
30 void operator=(const MCAsmBackend &); // DO NOT IMPLEMENT
31 protected: // Can only create subclasses.
32 MCAsmBackend();
33
34 unsigned HasReliableSymbolDifference : 1;
35
36 public:
37 virtual ~MCAsmBackend();
38
39 /// createObjectWriter - Create a new MCObjectWriter instance for use by the
40 /// assembler backend to emit the final object file.
41 virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;
42
43 /// createELFObjectTargetWriter - Create a new ELFObjectTargetWriter to enable
44 /// non-standard ELFObjectWriters.
45 virtual MCELFObjectTargetWriter *createELFObjectTargetWriter() const {
46 assert(0 && "createELFObjectTargetWriter is not supported by asm backend");
47 return 0;
48 }
49
50 /// hasReliableSymbolDifference - Check whether this target implements
51 /// accurate relocations for differences between symbols. If not, differences
52 /// between symbols will always be relocatable expressions and any references
53 /// to temporary symbols will be assumed to be in the same atom, unless they
54 /// reside in a different section.
55 ///
56 /// This should always be true (since it results in fewer relocations with no
57 /// loss of functionality), but is currently supported as a way to maintain
58 /// exact object compatibility with Darwin 'as' (on non-x86_64). It should
59 /// eventually should be eliminated.
60 bool hasReliableSymbolDifference() const {
61 return HasReliableSymbolDifference;
62 }
63
64 /// doesSectionRequireSymbols - Check whether the given section requires that
65 /// all symbols (even temporaries) have symbol table entries.
66 virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
67 return false;
68 }
69
70 /// isSectionAtomizable - Check whether the given section can be split into
71 /// atoms.
72 ///
73 /// \see MCAssembler::isSymbolLinkerVisible().
74 virtual bool isSectionAtomizable(const MCSection &Section) const {
75 return true;
76 }
77
78 /// @name Target Fixup Interfaces
79 /// @{
80
81 /// getNumFixupKinds - Get the number of target specific fixup kinds.
82 virtual unsigned getNumFixupKinds() const = 0;
83
84 /// getFixupKindInfo - Get information on a fixup kind.
85 virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const;
86
87 /// @}
88
89 /// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided
90 /// data fragment, at the offset specified by the fixup and following the
91 /// fixup kind as appropriate.
92 virtual void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
93 uint64_t Value) const = 0;
94
95 /// @}
96
97 /// @name Target Relaxation Interfaces
98 /// @{
99
100 /// MayNeedRelaxation - Check whether the given instruction may need
101 /// relaxation.
102 ///
103 /// \param Inst - The instruction to test.
104 virtual bool MayNeedRelaxation(const MCInst &Inst) const = 0;
105
106 /// RelaxInstruction - Relax the instruction in the given fragment to the next
107 /// wider instruction.
108 ///
109 /// \param Inst - The instruction to relax, which may be the same as the
110 /// output.
111 /// \parm Res [output] - On return, the relaxed instruction.
112 virtual void RelaxInstruction(const MCInst &Inst, MCInst &Res) const = 0;
113
114 /// @}
115
116 /// WriteNopData - Write an (optimal) nop sequence of Count bytes to the given
117 /// output. If the target cannot generate such a sequence, it should return an
118 /// error.
119 ///
120 /// \return - True on success.
121 virtual bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const = 0;
122
123 /// HandleAssemblerFlag - Handle any target-specific assembler flags.
124 /// By default, do nothing.
125 virtual void HandleAssemblerFlag(MCAssemblerFlag Flag) {}
126 };
127
128 } // End llvm namespace
129
130 #endif
99 #ifndef LLVM_MC_MCASSEMBLER_H
1010 #define LLVM_MC_MCASSEMBLER_H
1111
12 #include "llvm/MC/MCFixup.h"
13 #include "llvm/MC/MCInst.h"
1214 #include "llvm/ADT/DenseMap.h"
1315 #include "llvm/ADT/SmallPtrSet.h"
1416 #include "llvm/ADT/SmallString.h"
1517 #include "llvm/ADT/ilist.h"
1618 #include "llvm/ADT/ilist_node.h"
1719 #include "llvm/Support/Casting.h"
18 #include "llvm/MC/MCFixup.h"
19 #include "llvm/MC/MCInst.h"
2020 #include "llvm/Support/DataTypes.h"
2121 #include // FIXME: Shouldn't be needed.
2222
3535 class MCSymbol;
3636 class MCSymbolData;
3737 class MCValue;
38 class TargetAsmBackend;
38 class MCAsmBackend;
3939
4040 class MCFragment : public ilist_node {
4141 friend class MCAsmLayout;
659659
660660 MCContext &Context;
661661
662 TargetAsmBackend &Backend;
662 MCAsmBackend &Backend;
663663
664664 MCCodeEmitter &Emitter;
665665
779779 // concrete and require clients to pass in a target like object. The other
780780 // option is to make this abstract, and have targets provide concrete
781781 // implementations as we do with AsmParser.
782 MCAssembler(MCContext &Context_, TargetAsmBackend &Backend_,
782 MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
783783 MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
784784 raw_ostream &OS);
785785 ~MCAssembler();
786786
787787 MCContext &getContext() const { return Context; }
788788
789 TargetAsmBackend &getBackend() const { return Backend; }
789 MCAsmBackend &getBackend() const { return Backend; }
790790
791791 MCCodeEmitter &getEmitter() const { return Emitter; }
792792
1818 class MCExpr;
1919 class MCFragment;
2020 class MCDataFragment;
21 class TargetAsmBackend;
21 class MCAsmBackend;
2222 class raw_ostream;
2323
2424 /// \brief Streaming object file generation interface.
3535 virtual void EmitInstToData(const MCInst &Inst) = 0;
3636
3737 protected:
38 MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB,
38 MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
3939 raw_ostream &_OS, MCCodeEmitter *_Emitter);
40 MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB,
40 MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
4141 raw_ostream &_OS, MCCodeEmitter *_Emitter,
4242 MCAssembler *_Assembler);
4343 ~MCObjectStreamer();
2121 #include "llvm/ADT/SmallVector.h"
2222
2323 namespace llvm {
24 class MCAsmBackend;
2425 class MCAsmInfo;
2526 class MCCodeEmitter;
2627 class MCContext;
3031 class MCSection;
3132 class MCSymbol;
3233 class StringRef;
33 class TargetAsmBackend;
3434 class TargetLoweringObjectFile;
3535 class Twine;
3636 class raw_ostream;
562562 bool useCFI,
563563 MCInstPrinter *InstPrint = 0,
564564 MCCodeEmitter *CE = 0,
565 TargetAsmBackend *TAB = 0,
565 MCAsmBackend *TAB = 0,
566566 bool ShowInst = false);
567567
568568 /// createMachOStreamer - Create a machine code streamer which will generate
569569 /// Mach-O format object files.
570570 ///
571571 /// Takes ownership of \arg TAB and \arg CE.
572 MCStreamer *createMachOStreamer(MCContext &Ctx, TargetAsmBackend &TAB,
572 MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
573573 raw_ostream &OS, MCCodeEmitter *CE,
574574 bool RelaxAll = false);
575575
578578 ///
579579 /// Takes ownership of \arg TAB and \arg CE.
580580 MCStreamer *createWinCOFFStreamer(MCContext &Ctx,
581 TargetAsmBackend &TAB,
581 MCAsmBackend &TAB,
582582 MCCodeEmitter &CE, raw_ostream &OS,
583583 bool RelaxAll = false);
584584
585585 /// createELFStreamer - Create a machine code streamer which will generate
586586 /// ELF format object files.
587 MCStreamer *createELFStreamer(MCContext &Ctx, TargetAsmBackend &TAB,
587 MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
588588 raw_ostream &OS, MCCodeEmitter *CE,
589589 bool RelaxAll, bool NoExecStack);
590590
598598 /// "pure" MC object files, for use with MC-JIT and testing tools.
599599 ///
600600 /// Takes ownership of \arg TAB and \arg CE.
601 MCStreamer *createPureStreamer(MCContext &Ctx, TargetAsmBackend &TAB,
601 MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB,
602602 raw_ostream &OS, MCCodeEmitter *CE);
603603
604604 } // end namespace llvm
+0
-131
include/llvm/MC/TargetAsmBackend.h less more
None //===-- llvm/MC/TargetAsmBackend.h - Target Asm Backend ---------*- 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 #ifndef LLVM_MC_TARGETASMBACKEND_H
10 #define LLVM_MC_TARGETASMBACKEND_H
11
12 #include "llvm/MC/MCDirectives.h"
13 #include "llvm/MC/MCFixup.h"
14 #include "llvm/MC/MCFixupKindInfo.h"
15 #include "llvm/Support/DataTypes.h"
16
17 namespace llvm {
18 class MCELFObjectTargetWriter;
19 class MCFixup;
20 class MCInst;
21 class MCObjectWriter;
22 class MCSection;
23 template
24 class SmallVectorImpl;
25 class raw_ostream;
26
27 /// TargetAsmBackend - Generic interface to target specific assembler backends.
28 class TargetAsmBackend {
29 TargetAsmBackend(const TargetAsmBackend &); // DO NOT IMPLEMENT
30 void operator=(const TargetAsmBackend &); // DO NOT IMPLEMENT
31 protected: // Can only create subclasses.
32 TargetAsmBackend();
33
34 unsigned HasReliableSymbolDifference : 1;
35
36 public:
37 virtual ~TargetAsmBackend();
38
39 /// createObjectWriter - Create a new MCObjectWriter instance for use by the
40 /// assembler backend to emit the final object file.
41 virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;
42
43 /// createELFObjectTargetWriter - Create a new ELFObjectTargetWriter to enable
44 /// non-standard ELFObjectWriters.
45 virtual MCELFObjectTargetWriter *createELFObjectTargetWriter() const {
46 assert(0 && "createELFObjectTargetWriter is not supported by asm backend");
47 return 0;
48 }
49
50 /// hasReliableSymbolDifference - Check whether this target implements
51 /// accurate relocations for differences between symbols. If not, differences
52 /// between symbols will always be relocatable expressions and any references
53 /// to temporary symbols will be assumed to be in the same atom, unless they
54 /// reside in a different section.
55 ///
56 /// This should always be true (since it results in fewer relocations with no
57 /// loss of functionality), but is currently supported as a way to maintain
58 /// exact object compatibility with Darwin 'as' (on non-x86_64). It should
59 /// eventually should be eliminated.
60 bool hasReliableSymbolDifference() const {
61 return HasReliableSymbolDifference;
62 }
63
64 /// doesSectionRequireSymbols - Check whether the given section requires that
65 /// all symbols (even temporaries) have symbol table entries.
66 virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
67 return false;
68 }
69
70 /// isSectionAtomizable - Check whether the given section can be split into
71 /// atoms.
72 ///
73 /// \see MCAssembler::isSymbolLinkerVisible().
74 virtual bool isSectionAtomizable(const MCSection &Section) const {
75 return true;
76 }
77
78 /// @name Target Fixup Interfaces
79 /// @{
80
81 /// getNumFixupKinds - Get the number of target specific fixup kinds.
82 virtual unsigned getNumFixupKinds() const = 0;
83
84 /// getFixupKindInfo - Get information on a fixup kind.
85 virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const;
86
87 /// @}
88
89 /// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided
90 /// data fragment, at the offset specified by the fixup and following the
91 /// fixup kind as appropriate.
92 virtual void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
93 uint64_t Value) const = 0;
94
95 /// @}
96
97 /// @name Target Relaxation Interfaces
98 /// @{
99
100 /// MayNeedRelaxation - Check whether the given instruction may need
101 /// relaxation.
102 ///
103 /// \param Inst - The instruction to test.
104 virtual bool MayNeedRelaxation(const MCInst &Inst) const = 0;
105
106 /// RelaxInstruction - Relax the instruction in the given fragment to the next
107 /// wider instruction.
108 ///
109 /// \param Inst - The instruction to relax, which may be the same as the
110 /// output.
111 /// \parm Res [output] - On return, the relaxed instruction.
112 virtual void RelaxInstruction(const MCInst &Inst, MCInst &Res) const = 0;
113
114 /// @}
115
116 /// WriteNopData - Write an (optimal) nop sequence of Count bytes to the given
117 /// output. If the target cannot generate such a sequence, it should return an
118 /// error.
119 ///
120 /// \return - True on success.
121 virtual bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const = 0;
122
123 /// HandleAssemblerFlag - Handle any target-specific assembler flags.
124 /// By default, do nothing.
125 virtual void HandleAssemblerFlag(MCAssemblerFlag Flag) {}
126 };
127
128 } // End llvm namespace
129
130 #endif
3838 class MCStreamer;
3939 class MCSubtargetInfo;
4040 class MCCodeGenInfo;
41 class TargetAsmBackend;
41 class MCAsmBackend;
4242 class TargetAsmLexer;
4343 class TargetAsmParser;
4444 class TargetMachine;
5050 bool useLoc, bool useCFI,
5151 MCInstPrinter *InstPrint,
5252 MCCodeEmitter *CE,
53 TargetAsmBackend *TAB,
53 MCAsmBackend *TAB,
5454 bool ShowInst);
5555
5656 /// Target - Wrapper for Target specific information.
8585 CodeModel::Model CM);
8686 typedef AsmPrinter *(*AsmPrinterCtorTy)(TargetMachine &TM,
8787 MCStreamer &Streamer);
88 typedef TargetAsmBackend *(*AsmBackendCtorTy)(const Target &T,
89 const std::string &TT);
88 typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T, StringRef TT);
9089 typedef TargetAsmLexer *(*AsmLexerCtorTy)(const Target &T,
9190 const MCRegisterInfo &MRI,
9291 const MCAsmInfo &MAI);
102101 typedef MCStreamer *(*ObjectStreamerCtorTy)(const Target &T,
103102 const std::string &TT,
104103 MCContext &Ctx,
105 TargetAsmBackend &TAB,
104 MCAsmBackend &TAB,
106105 raw_ostream &_OS,
107106 MCCodeEmitter *_Emitter,
108107 bool RelaxAll,
114113 bool useCFI,
115114 MCInstPrinter *InstPrint,
116115 MCCodeEmitter *CE,
117 TargetAsmBackend *TAB,
116 MCAsmBackend *TAB,
118117 bool ShowInst);
119118
120119 private:
159158 /// TargetMachine, if registered.
160159 TargetMachineCtorTy TargetMachineCtorFn;
161160
162 /// AsmBackendCtorFn - Construction function for this target's
163 /// TargetAsmBackend, if registered.
164 AsmBackendCtorTy AsmBackendCtorFn;
161 /// MCAsmBackendCtorFn - Construction function for this target's
162 /// MCAsmBackend, if registered.
163 MCAsmBackendCtorTy MCAsmBackendCtorFn;
165164
166165 /// AsmLexerCtorFn - Construction function for this target's TargetAsmLexer,
167166 /// if registered.
220219 /// hasTargetMachine - Check if this target supports code generation.
221220 bool hasTargetMachine() const { return TargetMachineCtorFn != 0; }
222221
223 /// hasAsmBackend - Check if this target supports .o generation.
224 bool hasAsmBackend() const { return AsmBackendCtorFn != 0; }
222 /// hasMCAsmBackend - Check if this target supports .o generation.
223 bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != 0; }
225224
226225 /// hasAsmLexer - Check if this target supports .s lexing.
227226 bool hasAsmLexer() const { return AsmLexerCtorFn != 0; }
321320 return TargetMachineCtorFn(*this, Triple, CPU, Features, RM, CM);
322321 }
323322
324 /// createAsmBackend - Create a target specific assembly parser.
323 /// createMCAsmBackend - Create a target specific assembly parser.
325324 ///
326325 /// \arg Triple - The target triple string.
327326 /// \arg Backend - The target independent assembler object.
328 TargetAsmBackend *createAsmBackend(const std::string &Triple) const {
329 if (!AsmBackendCtorFn)
330 return 0;
331 return AsmBackendCtorFn(*this, Triple);
327 MCAsmBackend *createMCAsmBackend(StringRef Triple) const {
328 if (!MCAsmBackendCtorFn)
329 return 0;
330 return MCAsmBackendCtorFn(*this, Triple);
332331 }
333332
334333 /// createAsmLexer - Create a target specific assembly lexer.
392391 /// \arg RelaxAll - Relax all fixups?
393392 /// \arg NoExecStack - Mark file as not needing a executable stack.
394393 MCStreamer *createObjectStreamer(const std::string &TT, MCContext &Ctx,
395 TargetAsmBackend &TAB,
394 MCAsmBackend &TAB,
396395 raw_ostream &_OS,
397396 MCCodeEmitter *_Emitter,
398397 bool RelaxAll,
411410 bool useCFI,
412411 MCInstPrinter *InstPrint,
413412 MCCodeEmitter *CE,
414 TargetAsmBackend *TAB,
413 MCAsmBackend *TAB,
415414 bool ShowInst) const {
416415 // AsmStreamerCtorFn is default to llvm::createAsmStreamer
417416 return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI,
604603 T.TargetMachineCtorFn = Fn;
605604 }
606605
607 /// RegisterAsmBackend - Register a TargetAsmBackend implementation for the
606 /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the
608607 /// given target.
609608 ///
610609 /// Clients are responsible for ensuring that registration doesn't occur
613612 ///
614613 /// @param T - The target being registered.
615614 /// @param Fn - A function to construct an AsmBackend for the target.
616 static void RegisterAsmBackend(Target &T, Target::AsmBackendCtorTy Fn) {
617 if (!T.AsmBackendCtorFn)
618 T.AsmBackendCtorFn = Fn;
615 static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn) {
616 if (!T.MCAsmBackendCtorFn)
617 T.MCAsmBackendCtorFn = Fn;
619618 }
620619
621620 /// RegisterAsmLexer - Register a TargetAsmLexer implementation for the
955954 }
956955 };
957956
958 /// RegisterAsmBackend - Helper template for registering a target specific
957 /// RegisterMCAsmBackend - Helper template for registering a target specific
959958 /// assembler backend. Usage:
960959 ///
961 /// extern "C" void LLVMInitializeFooAsmBackend() {
962 /// extern Target TheFooTarget;
963 /// RegisterAsmBackend X(TheFooTarget);
964 /// }
965 template
966 struct RegisterAsmBackend {
967 RegisterAsmBackend(Target &T) {
968 TargetRegistry::RegisterAsmBackend(T, &Allocator);
969 }
970
971 private:
972 static TargetAsmBackend *Allocator(const Target &T,
973 const std::string &Triple) {
974 return new AsmBackendImpl(T, Triple);
960 /// extern "C" void LLVMInitializeFooMCAsmBackend() {
961 /// extern Target TheFooTarget;
962 /// RegisterMCAsmBackend X(TheFooTarget);
963 /// }
964 template
965 struct RegisterMCAsmBackend {
966 RegisterMCAsmBackend(Target &T) {
967 TargetRegistry::RegisterMCAsmBackend(T, &Allocator);
968 }
969
970 private:
971 static MCAsmBackend *Allocator(const Target &T, StringRef Triple) {
972 return new MCAsmBackendImpl(T, Triple);
975973 }
976974 };
977975
136136
137137 // Create a code emitter if asked to show the encoding.
138138 MCCodeEmitter *MCE = 0;
139 TargetAsmBackend *TAB = 0;
139 MCAsmBackend *MAB = 0;
140140 if (ShowMCEncoding) {
141141 const MCSubtargetInfo &STI = getSubtarget();
142142 MCE = getTarget().createCodeEmitter(*getInstrInfo(), STI, *Context);
143 TAB = getTarget().createAsmBackend(getTargetTriple());
143 MAB = getTarget().createMCAsmBackend(getTargetTriple());
144144 }
145145
146146 MCStreamer *S = getTarget().createAsmStreamer(*Context, Out,
148148 hasMCUseLoc(),
149149 hasMCUseCFI(),
150150 InstPrinter,
151 MCE, TAB,
151 MCE, MAB,
152152 ShowMCInst);
153153 AsmStreamer.reset(S);
154154 break;
159159 const MCSubtargetInfo &STI = getSubtarget();
160160 MCCodeEmitter *MCE = getTarget().createCodeEmitter(*getInstrInfo(), STI,
161161 *Context);
162 TargetAsmBackend *TAB = getTarget().createAsmBackend(getTargetTriple());
163 if (MCE == 0 || TAB == 0)
162 MCAsmBackend *MAB = getTarget().createMCAsmBackend(getTargetTriple());
163 if (MCE == 0 || MAB == 0)
164164 return true;
165165
166166 AsmStreamer.reset(getTarget().createObjectStreamer(getTargetTriple(),
167 *Context, *TAB, Out, MCE,
167 *Context, *MAB, Out, MCE,
168168 hasMCRelaxAll(),
169169 hasMCNoExecStack()));
170170 AsmStreamer.get()->InitSections();
236236 // emission fails.
237237 const MCSubtargetInfo &STI = getSubtarget();
238238 MCCodeEmitter *MCE = getTarget().createCodeEmitter(*getInstrInfo(),STI, *Ctx);
239 TargetAsmBackend *TAB = getTarget().createAsmBackend(getTargetTriple());
240 if (MCE == 0 || TAB == 0)
239 MCAsmBackend *MAB = getTarget().createMCAsmBackend(getTargetTriple());
240 if (MCE == 0 || MAB == 0)
241241 return true;
242242
243243 OwningPtr AsmStreamer;
244244 AsmStreamer.reset(getTarget().createObjectStreamer(getTargetTriple(), *Ctx,
245 *TAB, Out, MCE,
245 *MAB, Out, MCE,
246246 hasMCRelaxAll(),
247247 hasMCNoExecStack()));
248248 AsmStreamer.get()->InitSections();
1414 #include "llvm/ADT/STLExtras.h"
1515 #include "llvm/ADT/StringMap.h"
1616 #include "llvm/ADT/Twine.h"
17 #include "llvm/MC/MCAsmBackend.h"
1718 #include "llvm/MC/MCAsmLayout.h"
1819 #include "llvm/MC/MCContext.h"
1920 #include "llvm/MC/MCExpr.h"
2021 #include "llvm/MC/MCSectionELF.h"
2122 #include "llvm/MC/MCValue.h"
22 #include "llvm/MC/TargetAsmBackend.h"
2323 #include "llvm/Support/Debug.h"
2424 #include "llvm/Support/ErrorHandling.h"
2525 #include "llvm/Support/ELF.h"
0 //===-- MCAsmBackend.cpp - Target MC Assembly Backend ----------------------==//
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/MC/MCAsmBackend.h"
10 using namespace llvm;
11
12 MCAsmBackend::MCAsmBackend()
13 : HasReliableSymbolDifference(false)
14 {
15 }
16
17 MCAsmBackend::~MCAsmBackend() {
18 }
19
20 const MCFixupKindInfo &
21 MCAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
22 static const MCFixupKindInfo Builtins[] = {
23 { "FK_Data_1", 0, 8, 0 },
24 { "FK_Data_2", 0, 16, 0 },
25 { "FK_Data_4", 0, 32, 0 },
26 { "FK_Data_8", 0, 64, 0 },
27 { "FK_PCRel_1", 0, 8, MCFixupKindInfo::FKF_IsPCRel },
28 { "FK_PCRel_2", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
29 { "FK_PCRel_4", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
30 { "FK_PCRel_8", 0, 64, MCFixupKindInfo::FKF_IsPCRel }
31 };
32
33 assert((size_t)Kind <= sizeof(Builtins) / sizeof(Builtins[0]) &&
34 "Unknown fixup kind");
35 return Builtins[Kind];
36 }
1818 #include "llvm/MC/MCSectionCOFF.h"
1919 #include "llvm/MC/MCSectionMachO.h"
2020 #include "llvm/MC/MCSymbol.h"
21 #include "llvm/MC/TargetAsmBackend.h"
21 #include "llvm/MC/MCAsmBackend.h"
2222 #include "llvm/ADT/OwningPtr.h"
2323 #include "llvm/ADT/SmallString.h"
2424 #include "llvm/ADT/StringExtras.h"
4040 private:
4141 OwningPtr InstPrinter;
4242 OwningPtr Emitter;
43 OwningPtr<TargetAsmBackend> AsmBackend;
43 OwningPtr<MCAsmBackend> AsmBackend;
4444
4545 SmallString<128> CommentToEmit;
4646 raw_svector_ostream CommentStream;
6363 MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
6464 bool isVerboseAsm, bool useLoc, bool useCFI,
6565 MCInstPrinter *printer, MCCodeEmitter *emitter,
66 TargetAsmBackend *asmbackend,
66 MCAsmBackend *asmbackend,
6767 bool showInst)
6868 : MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
6969 InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend),
12611261 formatted_raw_ostream &OS,
12621262 bool isVerboseAsm, bool useLoc,
12631263 bool useCFI, MCInstPrinter *IP,
1264 MCCodeEmitter *CE, TargetAsmBackend *TAB,
1264 MCCodeEmitter *CE, MCAsmBackend *MAB,
12651265 bool ShowInst) {
12661266 return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc, useCFI,
1267 IP, CE, TAB, ShowInst);
1268 }
1267 IP, CE, MAB, ShowInst);
1268 }
1717 #include "llvm/MC/MCSymbol.h"
1818 #include "llvm/MC/MCValue.h"
1919 #include "llvm/MC/MCDwarf.h"
20 #include "llvm/MC/TargetAsmBackend.h"
20 #include "llvm/MC/MCAsmBackend.h"
2121 #include "llvm/ADT/OwningPtr.h"
2222 #include "llvm/ADT/Statistic.h"
2323 #include "llvm/ADT/StringExtras.h"
193193
194194 /* *** */
195195
196 MCAssembler::MCAssembler(MCContext &Context_, TargetAsmBackend &Backend_,
196 MCAssembler::MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
197197 MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
198198 raw_ostream &OS_)
199199 : Context(Context_), Backend(Backend_), Emitter(Emitter_), Writer(Writer_),
1414 #include "llvm/MC/MCAssembler.h"
1515 #include "llvm/MC/MCELFSymbolFlags.h"
1616 #include "llvm/MC/MCFixupKindInfo.h"
17 #include "llvm/MC/TargetAsmBackend.h"
1817 #include "llvm/Support/ELF.h"
1918
2019 namespace llvm {
2020 #include "llvm/MC/MCSection.h"
2121 #include "llvm/MC/MCSymbol.h"
2222 #include "llvm/MC/MCValue.h"
23 #include "llvm/MC/TargetAsmBackend.h"
23 #include "llvm/MC/MCAsmBackend.h"
2424 #include "llvm/Support/Debug.h"
2525 #include "llvm/Support/ELF.h"
2626 #include "llvm/Support/ErrorHandling.h"
373373 this->MCObjectStreamer::Finish();
374374 }
375375
376 MCStreamer *llvm::createELFStreamer(MCContext &Context, TargetAsmBackend &TAB,
376 MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
377377 raw_ostream &OS, MCCodeEmitter *CE,
378378 bool RelaxAll, bool NoExecStack) {
379 MCELFStreamer *S = new MCELFStreamer(Context, TAB, OS, CE);
379 MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
380380 if (RelaxAll)
381381 S->getAssembler().setRelaxAll(true);
382382 if (NoExecStack)
2424
2525 class MCELFStreamer : public MCObjectStreamer {
2626 public:
27 MCELFStreamer(MCContext &Context, TargetAsmBackend &TAB,
27 MCELFStreamer(MCContext &Context, MCAsmBackend &TAB,
2828 raw_ostream &OS, MCCodeEmitter *Emitter)
2929 : MCObjectStreamer(Context, TAB, OS, Emitter) {}
3030
31 MCELFStreamer(MCContext &Context, TargetAsmBackend &TAB,
31 MCELFStreamer(MCContext &Context, MCAsmBackend &TAB,
3232 raw_ostream &OS, MCCodeEmitter *Emitter,
3333 MCAssembler *Assembler)
3434 : MCObjectStreamer(Context, TAB, OS, Emitter, Assembler) {}
1515 #include "llvm/MC/MCContext.h"
1616 #include "llvm/MC/MCSymbol.h"
1717 #include "llvm/MC/MCValue.h"
18 #include "llvm/MC/TargetAsmBackend.h"
1918 #include "llvm/Support/Debug.h"
2019 #include "llvm/Support/raw_ostream.h"
2120 using namespace llvm;
1919 #include "llvm/MC/MCMachOSymbolFlags.h"
2020 #include "llvm/MC/MCSectionMachO.h"
2121 #include "llvm/MC/MCDwarf.h"
22 #include "llvm/MC/TargetAsmBackend.h"
22 #include "llvm/MC/MCAsmBackend.h"
2323 #include "llvm/Support/Dwarf.h"
2424 #include "llvm/Support/ErrorHandling.h"
2525 #include "llvm/Support/raw_ostream.h"
3333 virtual void EmitInstToData(const MCInst &Inst);
3434
3535 public:
36 MCMachOStreamer(MCContext &Context, TargetAsmBackend &TAB,
36 MCMachOStreamer(MCContext &Context, MCAsmBackend &MAB,
3737 raw_ostream &OS, MCCodeEmitter *Emitter)
38 : MCObjectStreamer(Context, TAB, OS, Emitter) {}
38 : MCObjectStreamer(Context, MAB, OS, Emitter) {}
3939
4040 /// @name MCStreamer Interface
4141 /// @{
409409 this->MCObjectStreamer::Finish();
410410 }
411411
412 MCStreamer *llvm::createMachOStreamer(MCContext &Context, TargetAsmBackend &TAB,
412 MCStreamer *llvm::createMachOStreamer(MCContext &Context, MCAsmBackend &MAB,
413413 raw_ostream &OS, MCCodeEmitter *CE,
414414 bool RelaxAll) {
415 MCMachOStreamer *S = new MCMachOStreamer(Context, TAB, OS, CE);
415 MCMachOStreamer *S = new MCMachOStreamer(Context, MAB, OS, CE);
416416 if (RelaxAll)
417417 S->getAssembler().setRelaxAll(true);
418418 return S;
1616 #include "llvm/MC/MCDwarf.h"
1717 #include "llvm/MC/MCExpr.h"
1818 #include "llvm/MC/MCSymbol.h"
19 #include "llvm/MC/TargetAsmBackend.h"
19 #include "llvm/MC/MCAsmBackend.h"
2020 using namespace llvm;
2121
22 MCObjectStreamer::MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB,
22 MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
2323 raw_ostream &OS, MCCodeEmitter *Emitter_)
2424 : MCStreamer(Context),
2525 Assembler(new MCAssembler(Context, TAB,
2929 {
3030 }
3131
32 MCObjectStreamer::MCObjectStreamer(MCContext &Context, TargetAsmBackend &TAB,
32 MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
3333 raw_ostream &OS, MCCodeEmitter *Emitter_,
3434 MCAssembler *_Assembler)
3535 : MCStreamer(Context), Assembler(_Assembler), CurSectionData(0)
2727 virtual void EmitInstToData(const MCInst &Inst);
2828
2929 public:
30 MCPureStreamer(MCContext &Context, TargetAsmBackend &TAB,
30 MCPureStreamer(MCContext &Context, MCAsmBackend &TAB,
3131 raw_ostream &OS, MCCodeEmitter *Emitter)
3232 : MCObjectStreamer(Context, TAB, OS, Emitter) {}
3333
227227 this->MCObjectStreamer::Finish();
228228 }
229229
230 MCStreamer *llvm::createPureStreamer(MCContext &Context, TargetAsmBackend &TAB,
230 MCStreamer *llvm::createPureStreamer(MCContext &Context, MCAsmBackend &MAB,
231231 raw_ostream &OS, MCCodeEmitter *CE) {
232 return new MCPureStreamer(Context, TAB, OS, CE);
233 }
232 return new MCPureStreamer(Context, MAB, OS, CE);
233 }
1111 #include "llvm/ADT/StringMap.h"
1212 #include "llvm/ADT/Twine.h"
1313 #include "llvm/MC/MCAssembler.h"
14 #include "llvm/MC/MCAsmBackend.h"
1415 #include "llvm/MC/MCAsmLayout.h"
1516 #include "llvm/MC/MCExpr.h"
1617 #include "llvm/MC/MCObjectWriter.h"
1819 #include "llvm/MC/MCSymbol.h"
1920 #include "llvm/MC/MCMachOSymbolFlags.h"
2021 #include "llvm/MC/MCValue.h"
21 #include "llvm/MC/TargetAsmBackend.h"
2222 #include "llvm/Object/MachOFormat.h"
2323 #include "llvm/Support/ErrorHandling.h"
2424
+0
-37
lib/MC/TargetAsmBackend.cpp less more
None //===-- TargetAsmBackend.cpp - Target Assembly Backend ---------------------==//
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/MC/TargetAsmBackend.h"
10 using namespace llvm;
11
12 TargetAsmBackend::TargetAsmBackend()
13 : HasReliableSymbolDifference(false)
14 {
15 }
16
17 TargetAsmBackend::~TargetAsmBackend() {
18 }
19
20 const MCFixupKindInfo &
21 TargetAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
22 static const MCFixupKindInfo Builtins[] = {
23 { "FK_Data_1", 0, 8, 0 },
24 { "FK_Data_2", 0, 16, 0 },
25 { "FK_Data_4", 0, 32, 0 },
26 { "FK_Data_8", 0, 64, 0 },
27 { "FK_PCRel_1", 0, 8, MCFixupKindInfo::FKF_IsPCRel },
28 { "FK_PCRel_2", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
29 { "FK_PCRel_4", 0, 32, MCFixupKindInfo::FKF_IsPCRel },
30 { "FK_PCRel_8", 0, 64, MCFixupKindInfo::FKF_IsPCRel }
31 };
32
33 assert((size_t)Kind <= sizeof(Builtins) / sizeof(Builtins[0]) &&
34 "Unknown fixup kind");
35 return Builtins[Kind];
36 }
2323 #include "llvm/MC/MCCodeEmitter.h"
2424 #include "llvm/MC/MCSectionCOFF.h"
2525 #include "llvm/MC/MCWin64EH.h"
26 #include "llvm/MC/TargetAsmBackend.h"
26 #include "llvm/MC/MCAsmBackend.h"
2727 #include "llvm/Target/TargetRegistry.h"
2828 #include "llvm/ADT/StringMap.h"
2929
3939 MCSymbol const *CurSymbol;
4040
4141 WinCOFFStreamer(MCContext &Context,
42 TargetAsmBackend &TAB,
42 MCAsmBackend &MAB,
4343 MCCodeEmitter &CE,
4444 raw_ostream &OS);
4545
122122 } // end anonymous namespace.
123123
124124 WinCOFFStreamer::WinCOFFStreamer(MCContext &Context,
125 TargetAsmBackend &TAB,
125 MCAsmBackend &MAB,
126126 MCCodeEmitter &CE,
127127 raw_ostream &OS)
128 : MCObjectStreamer(Context, TAB, OS, &CE)
128 : MCObjectStreamer(Context, MAB, OS, &CE)
129129 , CurSymbol(NULL) {
130130 }
131131
394394 namespace llvm
395395 {
396396 MCStreamer *createWinCOFFStreamer(MCContext &Context,
397 TargetAsmBackend &TAB,
397 MCAsmBackend &MAB,
398398 MCCodeEmitter &CE,
399399 raw_ostream &OS,
400400 bool RelaxAll) {
401 WinCOFFStreamer *S = new WinCOFFStreamer(Context, TAB, CE, OS);
401 WinCOFFStreamer *S = new WinCOFFStreamer(Context, MAB, CE, OS);
402402 S->getAssembler().setRelaxAll(RelaxAll);
403403 return S;
404404 }
1818 #include "llvm/MC/MCObjectWriter.h"
1919 #include "llvm/MC/MCSectionELF.h"
2020 #include "llvm/MC/MCSectionMachO.h"
21 #include "llvm/MC/TargetAsmBackend.h"
21 #include "llvm/MC/MCAsmBackend.h"
2222 #include "llvm/Object/MachOFormat.h"
2323 #include "llvm/Support/ELF.h"
2424 #include "llvm/Support/ErrorHandling.h"
3333 /*HasRelocationAddend*/ false) {}
3434 };
3535
36 class ARMAsmBackend : public TargetAsmBackend {
36 class ARMAsmBackend : public MCAsmBackend {
3737 bool isThumbMode; // Currently emitting Thumb code.
3838 public:
39 ARMAsmBackend(const Target &T) : TargetAsmBackend(), isThumbMode(false) {}
39 ARMAsmBackend(const Target &T) : MCAsmBackend(), isThumbMode(false) {}
4040
4141 unsigned getNumFixupKinds() const { return ARM::NumTargetFixupKinds; }
4242
7979 };
8080
8181 if (Kind < FirstTargetFixupKind)
82 return TargetAsmBackend::getFixupKindInfo(Kind);
82 return MCAsmBackend::getFixupKindInfo(Kind);
8383
8484 assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
8585 "Invalid kind!");
490490
491491 } // end anonymous namespace
492492
493 TargetAsmBackend *llvm::createARMAsmBackend(const Target &T,
494 const std::string &TT) {
493 MCAsmBackend *llvm::createARMAsmBackend(const Target &T, StringRef TT) {
495494 Triple TheTriple(TT);
496495
497496 if (TheTriple.isOSDarwin()) {
132132
133133 // This is duplicated code. Refactor this.
134134 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
135 MCContext &Ctx, TargetAsmBackend &TAB,
135 MCContext &Ctx, MCAsmBackend &MAB,
136136 raw_ostream &OS,
137137 MCCodeEmitter *Emitter,
138138 bool RelaxAll,
140140 Triple TheTriple(TT);
141141
142142 if (TheTriple.isOSDarwin())
143 return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
143 return createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
144144
145145 if (TheTriple.isOSWindows()) {
146146 llvm_unreachable("ARM does not support Windows COFF format");
147147 return NULL;
148148 }
149149
150 return createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll, NoExecStack);
150 return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll, NoExecStack);
151151 }
152152
153153 static MCInstPrinter *createARMMCInstPrinter(const Target &T,
188188 TargetRegistry::RegisterCodeEmitter(TheThumbTarget, createARMMCCodeEmitter);
189189
190190 // Register the asm backend.
191 TargetRegistry::RegisterAsmBackend(TheARMTarget, createARMAsmBackend);
192 TargetRegistry::RegisterAsmBackend(TheThumbTarget, createARMAsmBackend);
191 TargetRegistry::RegisterMCAsmBackend(TheARMTarget, createARMAsmBackend);
192 TargetRegistry::RegisterMCAsmBackend(TheThumbTarget, createARMAsmBackend);
193193
194194 // Register the object streamer.
195195 TargetRegistry::RegisterObjectStreamer(TheARMTarget, createMCStreamer);
1717 #include
1818
1919 namespace llvm {
20 class MCAsmBackend;
2021 class MCCodeEmitter;
2122 class MCContext;
2223 class MCInstrInfo;
2425 class MCSubtargetInfo;
2526 class StringRef;
2627 class Target;
27 class TargetAsmBackend;
2828 class raw_ostream;
2929
3030 extern Target TheARMTarget, TheThumbTarget;
4343 const MCSubtargetInfo &STI,
4444 MCContext &Ctx);
4545
46 TargetAsmBackend *createARMAsmBackend(const Target&, const std::string &);
46 MCAsmBackend *createARMAsmBackend(const Target &T, StringRef TT);
4747
4848 /// createARMMachObjectWriter - Construct an ARM Mach-O object writer.
4949 MCObjectWriter *createARMMachObjectWriter(raw_ostream &OS,
1616 #include "llvm/MC/MCFixup.h"
1717 #include "llvm/MC/MCFixupKindInfo.h"
1818 #include "llvm/MC/MCValue.h"
19 #include "llvm/MC/TargetAsmBackend.h"
2019 #include "llvm/Object/MachOFormat.h"
2120 #include "llvm/Support/ErrorHandling.h"
2221 using namespace llvm;
77 //===----------------------------------------------------------------------===//
88
99 #include "MCTargetDesc/MBlazeMCTargetDesc.h"
10 #include "llvm/MC/TargetAsmBackend.h"
10 #include "llvm/MC/MCAsmBackend.h"
1111 #include "llvm/MC/MCAssembler.h"
1212 #include "llvm/MC/MCAsmLayout.h"
1313 #include "llvm/MC/MCELFObjectWriter.h"
4545 /*HasRelocationAddend*/ true) {}
4646 };
4747
48 class MBlazeAsmBackend : public TargetAsmBackend {
48 class MBlazeAsmBackend : public MCAsmBackend {
4949 public:
5050 MBlazeAsmBackend(const Target &T)
51 : TargetAsmBackend() {
51 : MCAsmBackend() {
5252 }
5353
5454 unsigned getNumFixupKinds() const {
145145 }
146146 } // end anonymous namespace
147147
148 TargetAsmBackend *llvm::createMBlazeAsmBackend(const Target &T,
149 const std::string &TT) {
148 MCAsmBackend *llvm::createMBlazeAsmBackend(const Target &T, StringRef TT) {
150149 Triple TheTriple(TT);
151150
152151 if (TheTriple.isOSDarwin())
7171 }
7272
7373 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
74 MCContext &Ctx, TargetAsmBackend &TAB,
74 MCContext &Ctx, MCAsmBackend &MAB,
7575 raw_ostream &_OS,
7676 MCCodeEmitter *_Emitter,
7777 bool RelaxAll,
8888 return NULL;
8989 }
9090
91 return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
91 return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
9292 }
9393
9494 static MCInstPrinter *createMBlazeMCInstPrinter(const Target &T,
124124 llvm::createMBlazeMCCodeEmitter);
125125
126126 // Register the asm backend
127 TargetRegistry::RegisterAsmBackend(TheMBlazeTarget,
128 createMBlazeAsmBackend);
127 TargetRegistry::RegisterMCAsmBackend(TheMBlazeTarget,
128 createMBlazeAsmBackend);
129129
130130 // Register the object streamer
131131 TargetRegistry::RegisterObjectStreamer(TheMBlazeTarget,
1313 #ifndef MBLAZEMCTARGETDESC_H
1414 #define MBLAZEMCTARGETDESC_H
1515
16 #include
17
1816 namespace llvm {
17 class MCAsmBackend;
1918 class MCContext;
2019 class MCCodeEmitter;
2120 class MCInstrInfo;
2221 class MCSubtargetInfo;
2322 class Target;
24 class TargetAsmBackend;
2523 class StringRef;
2624 class formatted_raw_ostream;
2725
3129 const MCSubtargetInfo &STI,
3230 MCContext &Ctx);
3331
34 TargetAsmBackend *createMBlazeAsmBackend(const Target &, const std::string &);
32 MCAsmBackend *createMBlazeAsmBackend(const Target &T, StringRef TT);
3533
3634 } // End llvm namespace
3735
532532 formatted_raw_ostream &OS,
533533 bool isVerboseAsm, bool useLoc, bool useCFI,
534534 MCInstPrinter *IP,
535 MCCodeEmitter *CE, TargetAsmBackend *TAB,
535 MCCodeEmitter *CE, MCAsmBackend *MAB,
536536 bool ShowInst) {
537537 return new PTXMCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
538538 IP, CE, ShowInst);
2424 bool useCFI,
2525 MCInstPrinter *InstPrint,
2626 MCCodeEmitter *CE,
27 TargetAsmBackend *TAB,
27 MCAsmBackend *MAB,
2828 bool ShowInst);
2929 }
3030
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/MC/TargetAsmBackend.h"
9 #include "llvm/MC/MCAsmBackend.h"
1010 #include "MCTargetDesc/PPCMCTargetDesc.h"
1111 #include "MCTargetDesc/PPCFixupKinds.h"
1212 #include "llvm/MC/MCMachObjectWriter.h"
3030 MCValue Target, uint64_t &FixedValue) {}
3131 };
3232
33 class PPCAsmBackend : public TargetAsmBackend {
33 class PPCAsmBackend : public MCAsmBackend {
3434 const Target &TheTarget;
3535 public:
36 PPCAsmBackend(const Target &T) : TargetAsmBackend(), TheTarget(T) {}
36 PPCAsmBackend(const Target &T) : MCAsmBackend(), TheTarget(T) {}
3737
3838 unsigned getNumFixupKinds() const { return PPC::NumTargetFixupKinds; }
3939
4848 };
4949
5050 if (Kind < FirstTargetFixupKind)
51 return TargetAsmBackend::getFixupKindInfo(Kind);
51 return MCAsmBackend::getFixupKindInfo(Kind);
5252
5353 assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
5454 "Invalid kind!");
113113
114114
115115
116 TargetAsmBackend *llvm::createPPCAsmBackend(const Target &T,
117 const std::string &TT) {
116 MCAsmBackend *llvm::createPPCAsmBackend(const Target &T, StringRef TT) {
118117 if (Triple(TT).isOSDarwin())
119118 return new DarwinPPCAsmBackend(T);
120119
9090
9191 // This is duplicated code. Refactor this.
9292 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
93 MCContext &Ctx, TargetAsmBackend &TAB,
93 MCContext &Ctx, MCAsmBackend &MAB,
9494 raw_ostream &OS,
9595 MCCodeEmitter *Emitter,
9696 bool RelaxAll,
9797 bool NoExecStack) {
9898 if (Triple(TT).isOSDarwin())
99 return createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
99 return createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
100100
101101 return NULL;
102102 }
135135 TargetRegistry::RegisterCodeEmitter(ThePPC64Target, createPPCMCCodeEmitter);
136136
137137 // Register the asm backend.
138 TargetRegistry::RegisterAsmBackend(ThePPC32Target, createPPCAsmBackend);
139 TargetRegistry::RegisterAsmBackend(ThePPC64Target, createPPCAsmBackend);
138 TargetRegistry::RegisterMCAsmBackend(ThePPC32Target, createPPCAsmBackend);
139 TargetRegistry::RegisterMCAsmBackend(ThePPC64Target, createPPCAsmBackend);
140140
141141 // Register the object streamer.
142142 TargetRegistry::RegisterObjectStreamer(ThePPC32Target, createMCStreamer);
1313 #ifndef PPCMCTARGETDESC_H
1414 #define PPCMCTARGETDESC_H
1515
16 #include
17
1816 namespace llvm {
17 class MCAsmBackend;
1918 class MCCodeEmitter;
2019 class MCContext;
2120 class MCInstrInfo;
2221 class MCSubtargetInfo;
2322 class Target;
24 class TargetAsmBackend;
2523 class StringRef;
2624
2725 extern Target ThePPC32Target;
3129 const MCSubtargetInfo &STI,
3230 MCContext &Ctx);
3331
34 TargetAsmBackend *createPPCAsmBackend(const Target &, const std::string &);
32 MCAsmBackend *createPPCAsmBackend(const Target &T, StringRef TT);
3533
3634 } // End llvm namespace
3735
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "llvm/MC/TargetAsmBackend.h"
9 #include "llvm/MC/MCAsmBackend.h"
1010 #include "MCTargetDesc/X86BaseInfo.h"
1111 #include "MCTargetDesc/X86FixupKinds.h"
1212 #include "llvm/ADT/Twine.h"
6161 : MCELFObjectTargetWriter(is64Bit, OSType, EMachine, HasRelocationAddend) {}
6262 };
6363
64 class X86AsmBackend : public TargetAsmBackend {
64 class X86AsmBackend : public MCAsmBackend {
6565 public:
6666 X86AsmBackend(const Target &T)
67 : TargetAsmBackend() {}
67 : MCAsmBackend() {}
6868
6969 unsigned getNumFixupKinds() const {
7070 return X86::NumTargetFixupKinds;
7979 };
8080
8181 if (Kind < FirstTargetFixupKind)
82 return TargetAsmBackend::getFixupKindInfo(Kind);
82 return MCAsmBackend::getFixupKindInfo(Kind);
8383
8484 assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
8585 "Invalid kind!");
424424
425425 } // end anonymous namespace
426426
427 TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
428 const std::string &TT) {
427 MCAsmBackend *llvm::createX86_32AsmBackend(const Target &T, StringRef TT) {
429428 Triple TheTriple(TT);
430429
431430 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
437436 return new ELFX86_32AsmBackend(T, TheTriple.getOS());
438437 }
439438
440 TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
441 const std::string &TT) {
439 MCAsmBackend *llvm::createX86_64AsmBackend(const Target &T, StringRef TT) {
442440 Triple TheTriple(TT);
443441
444442 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
366366 }
367367
368368 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
369 MCContext &Ctx, TargetAsmBackend &TAB,
369 MCContext &Ctx, MCAsmBackend &MAB,
370370 raw_ostream &_OS,
371371 MCCodeEmitter *_Emitter,
372372 bool RelaxAll,
374374 Triple TheTriple(TT);
375375
376376 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
377 return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
377 return createMachOStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll);
378378
379379 if (TheTriple.isOSWindows())
380 return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll);
381
382 return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
380 return createWinCOFFStreamer(Ctx, MAB, *_Emitter, _OS, RelaxAll);
381
382 return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
383383 }
384384
385385 static MCInstPrinter *createX86MCInstPrinter(const Target &T,
423423 createX86MCCodeEmitter);
424424
425425 // Register the asm backend.
426 TargetRegistry::RegisterAsmBackend(TheX86_32Target,
427 createX86_32AsmBackend);
428 TargetRegistry::RegisterAsmBackend(TheX86_64Target,
429 createX86_64AsmBackend);
426 TargetRegistry::RegisterMCAsmBackend(TheX86_32Target,
427 createX86_32AsmBackend);
428 TargetRegistry::RegisterMCAsmBackend(TheX86_64Target,
429 createX86_64AsmBackend);
430430
431431 // Register the object streamer.
432432 TargetRegistry::RegisterObjectStreamer(TheX86_32Target,
1717 #include
1818
1919 namespace llvm {
20 class MCAsmBackend;
2021 class MCCodeEmitter;
2122 class MCContext;
2223 class MCInstrInfo;
2425 class MCRegisterInfo;
2526 class MCSubtargetInfo;
2627 class Target;
27 class TargetAsmBackend;
2828 class StringRef;
2929 class raw_ostream;
3030
7373 const MCSubtargetInfo &STI,
7474 MCContext &Ctx);
7575
76 TargetAsmBackend *createX86_32AsmBackend(const Target &, const std::string &);
77 TargetAsmBackend *createX86_64AsmBackend(const Target &, const std::string &);
76 MCAsmBackend *createX86_32AsmBackend(const Target &T, StringRef TT);
77 MCAsmBackend *createX86_64AsmBackend(const Target &T, StringRef TT);
7878
7979 /// createX86MachObjectWriter - Construct an X86 Mach-O object writer.
8080 MCObjectWriter *createX86MachObjectWriter(raw_ostream &OS,
1313
1414 #include "llvm/MC/MCParser/AsmLexer.h"
1515 #include "llvm/MC/MCParser/MCAsmLexer.h"
16 #include "llvm/MC/MCAsmBackend.h"
1617 #include "llvm/MC/MCContext.h"
1718 #include "llvm/MC/MCCodeEmitter.h"
1819 #include "llvm/MC/MCInstPrinter.h"
2324 #include "llvm/MC/MCStreamer.h"
2425 #include "llvm/MC/MCSubtargetInfo.h"
2526 #include "llvm/MC/SubtargetFeature.h"
26 #include "llvm/MC/TargetAsmBackend.h"
2727 #include "llvm/MC/TargetAsmParser.h"
2828 #include "llvm/Target/TargetRegistry.h"
2929 #include "llvm/Target/TargetSelect.h"
367367 MCInstPrinter *IP =
368368 TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI);
369369 MCCodeEmitter *CE = 0;
370 TargetAsmBackend *TAB = 0;
370 MCAsmBackend *MAB = 0;
371371 if (ShowEncoding) {
372372 CE = TheTarget->createCodeEmitter(*MCII, *STI, Ctx);
373 TAB = TheTarget->createAsmBackend(TripleName);
373 MAB = TheTarget->createMCAsmBackend(TripleName);
374374 }
375375 Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true,
376376 /*useLoc*/ true,
377 /*useCFI*/ true, IP, CE, TAB,
377 /*useCFI*/ true, IP, CE, MAB,
378378 ShowInst));
379379 } else if (FileType == OFT_Null) {
380380 Str.reset(createNullStreamer(Ctx));
381381 } else {
382382 assert(FileType == OFT_ObjectFile && "Invalid file type!");
383383 MCCodeEmitter *CE = TheTarget->createCodeEmitter(*MCII, *STI, Ctx);
384 TargetAsmBackend *TAB = TheTarget->createAsmBackend(TripleName);
385 Str.reset(TheTarget->createObjectStreamer(TripleName, Ctx, *TAB,
384 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(TripleName);
385 Str.reset(TheTarget->createObjectStreamer(TripleName, Ctx, *MAB,
386386 FOS, CE, RelaxAll,
387387 NoExecStack));
388388 }