llvm.org GIT mirror llvm / 2286f8d
Revert 75762, 75763, 75766..75769, 75772..75775, 75778, 75780, 75782 to repair broken LLVM-GCC build. Will revert 75770 in the llvm-gcc trunk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75799 91177308-0d34-0410-b5e6-96231b3b80d8 Stuart Hastings 11 years ago
53 changed file(s) with 563 addition(s) and 312 deletion(s). Raw diff Collapse all Expand all
1818
1919 namespace llvm {
2020
21 class Target;
2221 class TargetAsmInfo;
2322 class TargetData;
2423 class TargetSubtarget;
9998 TargetMachine(const TargetMachine &); // DO NOT IMPLEMENT
10099 void operator=(const TargetMachine &); // DO NOT IMPLEMENT
101100 protected: // Can only create subclasses.
102 TargetMachine(const Target &);
101 TargetMachine();
103102
104103 /// getSubtargetImpl - virtual method implemented by subclasses that returns
105104 /// a reference to that target's TargetSubtarget-derived member variable.
106105 virtual const TargetSubtarget *getSubtargetImpl() const { return 0; }
107
108 /// TheTarget - The Target that this machine was created for.
109 const Target &TheTarget;
110106
111107 /// AsmInfo - Contains target specific asm information.
112108 ///
119115 public:
120116 virtual ~TargetMachine();
121117
122 const Target &getTarget() const { return TheTarget; }
118 /// getModuleMatchQuality - This static method should be implemented by
119 /// targets to indicate how closely they match the specified module. This is
120 /// used by the LLC tool to determine which target to use when an explicit
121 /// -march option is not specified. If a target returns zero, it will never
122 /// be chosen without an explicit -march option.
123 static unsigned getModuleMatchQuality(const Module &) { return 0; }
124
125 /// getJITMatchQuality - This static method should be implemented by targets
126 /// that provide JIT capabilities to indicate how suitable they are for
127 /// execution on the current host. If a value of 0 is returned, the target
128 /// will not be used unless an explicit -march option is used.
129 static unsigned getJITMatchQuality() { return 0; }
123130
124131 // Interfaces to the major aspects of target machine information:
125132 // -- Instruction opcode and operand information
300307 ///
301308 class LLVMTargetMachine : public TargetMachine {
302309 protected: // Can only create subclasses.
303 LLVMTargetMachine(const Target &T) : TargetMachine(T) { }
310 LLVMTargetMachine() { }
304311
305312 /// addCommonCodeGenPasses - Add standard LLVM codegen passes used for
306313 /// both emitting to assembly files or machine code output.
1818
1919 #include "llvm/Module.h"
2020 #include "llvm/Support/Registry.h"
21 #include "llvm/Target/TargetRegistry.h"
2221
2322 namespace llvm {
2423 class Module;
25 class Target;
2624 class TargetMachine;
2725
2826 struct TargetMachineRegistryEntry {
29 const Target &TheTarget;
3027 const char *Name;
3128 const char *ShortDesc;
29 TargetMachine *(*CtorFn)(const Module &, const std::string &);
30 unsigned (*ModuleMatchQualityFn)(const Module &M);
31 unsigned (*JITMatchQualityFn)();
3232
3333 public:
34 TargetMachineRegistryEntry(const Target &T, const char *N, const char *SD)
35 : TheTarget(T), Name(N), ShortDesc(SD) {}
34 TargetMachineRegistryEntry(const char *N, const char *SD,
35 TargetMachine *(*CF)(const Module &, const std::string &),
36 unsigned (*MMF)(const Module &M),
37 unsigned (*JMF)())
38 : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF),
39 JITMatchQualityFn(JMF) {}
3640 };
3741
3842 template<>
4549 };
4650
4751 struct TargetMachineRegistry : public Registry {
52 /// getClosestStaticTargetForModule - Given an LLVM module, pick the best
53 /// target that is compatible with the module. If no close target can be
54 /// found, this returns null and sets the Error string to a reason.
55 static const entry *getClosestStaticTargetForModule(const Module &M,
56 std::string &Error);
57
58 /// getClosestTargetForJIT - Pick the best target that is compatible with
59 /// the current host. If no close target can be found, this returns null
60 /// and sets the Error string to a reason.
61 static const entry *getClosestTargetForJIT(std::string &Error);
4862
4963 };
5064
5165 //===--------------------------------------------------------------------===//
5266 /// RegisterTarget - This class is used to make targets automatically register
53 /// themselves with the tools they are linked with. Targets should define an
54 /// single global Target instance and register it using the TargetRegistry
55 /// interfaces. Targets must also include a static instance of this class.
56 ///
67 /// themselves with the tool they are linked. Targets should define an
68 /// instance of this and implement the static methods described in the
69 /// TargetMachine comments.
5770 /// The type 'TargetMachineImpl' should provide a constructor with two
5871 /// parameters:
5972 /// - const Module& M: the module that is being compiled:
6275
6376 template
6477 struct RegisterTarget {
65 RegisterTarget(Target &T, const char *Name, const char *ShortDesc)
66 : Entry(T, Name, ShortDesc),
67 Node(Entry) {
68 TargetRegistry::RegisterTargetMachine(T, &Allocator);
69 }
78 RegisterTarget(const char *Name, const char *ShortDesc)
79 : Entry(Name, ShortDesc, &Allocator,
80 &TargetMachineImpl::getModuleMatchQuality,
81 &TargetMachineImpl::getJITMatchQuality),
82 Node(Entry)
83 {}
7084
7185 private:
7286 TargetMachineRegistry::entry Entry;
7387 TargetMachineRegistry::node Node;
7488
75 static TargetMachine *Allocator(const Target &T, const Module &M,
76 const std::string &FS) {
77 return new TargetMachineImpl(T, M, FS);
89 static TargetMachine *Allocator(const Module &M, const std::string &FS) {
90 return new TargetMachineImpl(M, FS);
7891 }
7992 };
8093
4141 typedef unsigned (*ModuleMatchQualityFnTy)(const Module &M);
4242 typedef unsigned (*JITMatchQualityFnTy)();
4343
44 typedef TargetMachine *(*TargetMachineCtorTy)(const Target &,
45 const Module &,
44 typedef TargetMachine *(*TargetMachineCtorTy)(const Module &,
4645 const std::string &);
4746 typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &,
4847 TargetMachine &,
8786 /// getShortDescription - Get a short description of the target.
8887 const char *getShortDescription() const { return ShortDesc; }
8988
90 /// getJITMatchQuality - Get the quality of this targets match for use as a
91 /// JIT.
92 unsigned getJITMatchQuality() const { return JITMatchQualityFn(); }
93
9489 /// createTargetMachine - Create a target specific machine implementation.
9590 TargetMachine *createTargetMachine(const Module &M,
96 const std::string &Features) const {
91 const std::string &Features) {
9792 if (!TargetMachineCtorFn)
9893 return 0;
99 return TargetMachineCtorFn(*this, M, Features);
94 return TargetMachineCtorFn(M, Features);
10095 }
10196
10297 /// createAsmPrinter - Create a target specific assembly printer pass.
10398 FunctionPass *createAsmPrinter(formatted_raw_ostream &OS,
10499 TargetMachine &M,
105 bool Verbose) const {
100 bool Verbose) {
106101 if (!AsmPrinterCtorFn)
107102 return 0;
108103 return AsmPrinterCtorFn(OS, M, Verbose);
139134 /// @name Target Registration
140135 /// @{
141136
142 /// RegisterTarget - Register the given target. Attempts to register a
143 /// target which has already been registered will be ignored.
137 /// RegisterTarget - Register the given target.
144138 ///
145139 /// Clients are responsible for ensuring that registration doesn't occur
146140 /// while another thread is attempting to access the registry. Typically
5757 inline bool InitializeNativeTarget() {
5858 // If we have a native target, initialize it to ensure it is linked in.
5959 #ifdef LLVM_NATIVE_ARCH
60 #define DoInit2(TARG) \
61 LLVMInitialize ## TARG ## Info (); \
62 LLVMInitialize ## TARG ()
60 #define DoInit2(TARG) LLVMInitialize ## TARG ()
6361 #define DoInit(T) DoInit2(T)
6462 DoInit(LLVM_NATIVE_ARCH);
6563 return false;
4444 JITMemoryManager *JMM,
4545 CodeGenOpt::Level OptLevel,
4646 bool AllocateGVsWithCode) {
47 const Target *TheTarget;
48 if (MArch == 0) {
47 const TargetMachineRegistry::entry *TheArch = MArch;
48 if (TheArch == 0) {
4949 std::string Error;
50 TheTarget = TargetRegistry::getClosestTargetForJIT(Error);
51 if (TheTarget == 0) {
50 TheArch = TargetMachineRegistry::getClosestTargetForJIT(Error);
51 if (TheArch == 0) {
5252 if (ErrorStr)
5353 *ErrorStr = Error;
5454 return 0;
5555 }
56 } else if (TheTarget->getJITMatchQuality() == 0) {
56 } else if (TheArch->JITMatchQualityFn() == 0) {
5757 cerr << "WARNING: This target JIT is not designed for the host you are"
5858 << " running. If bad things happen, please choose a different "
5959 << "-march switch.\n";
7070 }
7171
7272 // Allocate a target...
73 TargetMachine *Target =
74 TheTarget->createTargetMachine(*MP->getModule(), FeaturesStr);
73 TargetMachine *Target = TheArch->CtorFn(*MP->getModule(), FeaturesStr);
7574 assert(Target && "Could not allocate target machine!");
7675
7776 // If the target supports JIT code generation, return a new JIT now.
110110 Target::TripleMatchQualityFnTy TQualityFn,
111111 Target::ModuleMatchQualityFnTy MQualityFn,
112112 Target::JITMatchQualityFnTy JITQualityFn) {
113 // Note that we don't require the constructor functions already be defined, in
114 // case a module happens to initialize the optional functionality before the
115 // target.
116 assert(!T.Next && !T.Name && !T.ShortDesc && !T.TripleMatchQualityFn &&
117 !T.ModuleMatchQualityFn && !T.JITMatchQualityFn &&
118 "This Target already registered!");
119
113120 assert(Name && ShortDesc && TQualityFn && MQualityFn && JITQualityFn &&
114121 "Missing required target information!");
115
116 // Check if this target has already been initialized, we allow this as a
117 // convenience to some clients.
118 if (T.Name)
119 return;
120122
121123 // Add to the list of targets.
122124 T.Next = FirstTarget;
9393
9494 FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM);
9595 FunctionPass *createARMCodePrinterPass(formatted_raw_ostream &O,
96 TargetMachine &TM,
96 ARMBaseTargetMachine &TM,
9797 bool Verbose);
9898 FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM,
9999 MachineCodeEmitter &MCE);
3535 int ARMTargetMachineModule = 0;
3636
3737 // Register the target.
38 extern Target TheARMTarget;
39 static RegisterTarget X(TheARMTarget, "arm", "ARM");
40
41 extern Target TheThumbTarget;
42 static RegisterTarget<ThumbTargetMachine> Y(TheThumbTarget, "thumb", "Thumb");
38 static RegisterTarget<ARMTargetMachine> X("arm", "ARM");
39 static RegisterTarget Y("thumb", "Thumb");
4340
4441 // Force static initialization.
4542 extern "C" void LLVMInitializeARMTarget() { }
4744 // No assembler printer by default
4845 ARMBaseTargetMachine::AsmPrinterCtorFn ARMBaseTargetMachine::AsmPrinterCtor = 0;
4946
47 /// ThumbTargetMachine - Create an Thumb architecture model.
48 ///
49 unsigned ThumbTargetMachine::getJITMatchQuality() {
50 #if defined(__thumb__)
51 return 10;
52 #endif
53 return 0;
54 }
55
56 unsigned ThumbTargetMachine::getModuleMatchQuality(const Module &M) {
57 std::string TT = M.getTargetTriple();
58 // Match thumb-foo-bar, as well as things like thumbv5blah-*
59 if (TT.size() >= 6 &&
60 (TT.substr(0, 6) == "thumb-" || TT.substr(0, 6) == "thumbv"))
61 return 20;
62
63 // If the target triple is something non-thumb, we don't match.
64 if (!TT.empty()) return 0;
65
66 if (M.getEndianness() == Module::LittleEndian &&
67 M.getPointerSize() == Module::Pointer32)
68 return 10; // Weak match
69 else if (M.getEndianness() != Module::AnyEndianness ||
70 M.getPointerSize() != Module::AnyPointerSize)
71 return 0; // Match for some other target
72
73 return getJITMatchQuality()/2;
74 }
75
5076 /// TargetMachine ctor - Create an ARM architecture model.
5177 ///
52 ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T,
53 const Module &M,
78 ARMBaseTargetMachine::ARMBaseTargetMachine(const Module &M,
5479 const std::string &FS,
5580 bool isThumb)
56 : LLVMTargetMachine(T),
57 Subtarget(M, FS, isThumb),
81 : Subtarget(M, FS, isThumb),
5882 FrameInfo(Subtarget),
5983 JITInfo(),
6084 InstrItins(Subtarget.getInstrItineraryData()) {
6185 DefRelocModel = getRelocationModel();
6286 }
6387
64 ARMTargetMachine::ARMTargetMachine(const Target &T, const Module &M,
65 const std::string &FS)
66 : ARMBaseTargetMachine(T, M, FS, false), InstrInfo(Subtarget),
88 ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
89 : ARMBaseTargetMachine(M, FS, false), InstrInfo(Subtarget),
6790 DataLayout(Subtarget.isAPCS_ABI() ?
6891 std::string("e-p:32:32-f64:32:32-i64:32:32") :
6992 std::string("e-p:32:32-f64:64:64-i64:64:64")),
7093 TLInfo(*this) {
7194 }
7295
73 ThumbTargetMachine::ThumbTargetMachine(const Target &T, const Module &M,
74 const std::string &FS)
75 : ARMBaseTargetMachine(T, M, FS, true),
96 ThumbTargetMachine::ThumbTargetMachine(const Module &M, const std::string &FS)
97 : ARMBaseTargetMachine(M, FS, true),
7698 DataLayout(Subtarget.isAPCS_ABI() ?
7799 std::string("e-p:32:32-f64:32:32-i64:32:32-"
78100 "i16:16:32-i8:8:32-i1:8:32-a:0:32") :
86108 InstrInfo = new Thumb1InstrInfo(Subtarget);
87109 }
88110
111 unsigned ARMTargetMachine::getJITMatchQuality() {
112 #if defined(__arm__)
113 return 10;
114 #endif
115 return 0;
116 }
117
118 unsigned ARMTargetMachine::getModuleMatchQuality(const Module &M) {
119 std::string TT = M.getTargetTriple();
120 // Match arm-foo-bar, as well as things like armv5blah-*
121 if (TT.size() >= 4 &&
122 (TT.substr(0, 4) == "arm-" || TT.substr(0, 4) == "armv"))
123 return 20;
124 // If the target triple is something non-arm, we don't match.
125 if (!TT.empty()) return 0;
126
127 if (M.getEndianness() == Module::LittleEndian &&
128 M.getPointerSize() == Module::Pointer32)
129 return 10; // Weak match
130 else if (M.getEndianness() != Module::AnyEndianness ||
131 M.getPointerSize() != Module::AnyPointerSize)
132 return 0; // Match for some other target
133
134 return getJITMatchQuality()/2;
135 }
136
89137
90138 const TargetAsmInfo *ARMBaseTargetMachine::createTargetAsmInfo() const {
91139 switch (Subtarget.TargetType) {
4141 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4242 // set this functions to ctor pointer at startup time if they are linked in.
4343 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
44 TargetMachine &tm,
44 ARMBaseTargetMachine &tm,
4545 bool verbose);
4646 static AsmPrinterCtorFn AsmPrinterCtor;
4747
4848 public:
49 ARMBaseTargetMachine(const Target &T, const Module &M, const std::string &FS,
50 bool isThumb);
49 ARMBaseTargetMachine(const Module &M, const std::string &FS, bool isThumb);
5150
5251 virtual const ARMFrameInfo *getFrameInfo() const { return &FrameInfo; }
5352 virtual ARMJITInfo *getJITInfo() { return &JITInfo; }
5958 static void registerAsmPrinter(AsmPrinterCtorFn F) {
6059 AsmPrinterCtor = F;
6160 }
61
62 static unsigned getModuleMatchQuality(const Module &M);
63 static unsigned getJITMatchQuality();
6264
6365 virtual const TargetAsmInfo *createTargetAsmInfo() const;
6466
9698 const TargetData DataLayout; // Calculates type size & alignment
9799 ARMTargetLowering TLInfo;
98100 public:
99 ARMTargetMachine(const Target &T, const Module &M, const std::string &FS);
101 ARMTargetMachine(const Module &M, const std::string &FS);
100102
101103 virtual const ARMRegisterInfo *getRegisterInfo() const {
102104 return &InstrInfo.getRegisterInfo();
122124 const TargetData DataLayout; // Calculates type size & alignment
123125 ARMTargetLowering TLInfo;
124126 public:
125 ThumbTargetMachine(const Target &T, const Module &M, const std::string &FS);
127 ThumbTargetMachine(const Module &M, const std::string &FS);
126128
127129 /// returns either Thumb1RegisterInfo of Thumb2RegisterInfo
128130 virtual const ARMBaseRegisterInfo *getRegisterInfo() const {
3030 #include "llvm/Target/TargetData.h"
3131 #include "llvm/Target/TargetMachine.h"
3232 #include "llvm/Target/TargetOptions.h"
33 #include "llvm/Target/TargetRegistry.h"
3433 #include "llvm/ADT/Statistic.h"
3534 #include "llvm/ADT/StringExtras.h"
3635 #include "llvm/ADT/StringSet.h"
12871286 /// regardless of whether the function is in SSA form.
12881287 ///
12891288 FunctionPass *llvm::createARMCodePrinterPass(formatted_raw_ostream &o,
1290 TargetMachine &tm,
1289 ARMBaseTargetMachine &tm,
12911290 bool verbose) {
12921291 return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
12931292 }
13011300 }
13021301
13031302 // Force static initialization.
1304 extern "C" void LLVMInitializeARMAsmPrinter() {
1305 extern Target TheARMTarget, TheThumbTarget;
1306 TargetRegistry::RegisterAsmPrinter(TheARMTarget, createARMCodePrinterPass);
1307 TargetRegistry::RegisterAsmPrinter(TheThumbTarget, createARMCodePrinterPass);
1308 }
1303 extern "C" void LLVMInitializeARMAsmPrinter() { }
2121 using namespace llvm;
2222
2323 // Register the targets
24 extern Target TheAlphaTarget;
25 static RegisterTarget X(TheAlphaTarget, "alpha",
26 "Alpha [experimental]");
24 static RegisterTarget X("alpha", "Alpha [experimental]");
2725
2826 // No assembler printer by default
2927 AlphaTargetMachine::AsmPrinterCtorFn AlphaTargetMachine::AsmPrinterCtor = 0;
3533 return new AlphaTargetAsmInfo(*this);
3634 }
3735
38 AlphaTargetMachine::AlphaTargetMachine(const Target &T, const Module &M,
39 const std::string &FS)
40 : LLVMTargetMachine(T),
41 DataLayout("e-f128:128:128"),
36 unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) {
37 // We strongly match "alpha*".
38 std::string TT = M.getTargetTriple();
39 if (TT.size() >= 5 && TT[0] == 'a' && TT[1] == 'l' && TT[2] == 'p' &&
40 TT[3] == 'h' && TT[4] == 'a')
41 return 20;
42 // If the target triple is something non-alpha, we don't match.
43 if (!TT.empty()) return 0;
44
45 if (M.getEndianness() == Module::LittleEndian &&
46 M.getPointerSize() == Module::Pointer64)
47 return 10; // Weak match
48 else if (M.getEndianness() != Module::AnyEndianness ||
49 M.getPointerSize() != Module::AnyPointerSize)
50 return 0; // Match for some other target
51
52 return getJITMatchQuality()/2;
53 }
54
55 unsigned AlphaTargetMachine::getJITMatchQuality() {
56 #ifdef __alpha
57 return 10;
58 #else
59 return 0;
60 #endif
61 }
62
63 AlphaTargetMachine::AlphaTargetMachine(const Module &M, const std::string &FS)
64 : DataLayout("e-f128:128:128"),
4265 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
4366 JITInfo(*this),
4467 Subtarget(M, FS),
4444 static AsmPrinterCtorFn AsmPrinterCtor;
4545
4646 public:
47 AlphaTargetMachine(const Target &T, const Module &M, const std::string &FS);
47 AlphaTargetMachine(const Module &M, const std::string &FS);
4848
4949 virtual const AlphaInstrInfo *getInstrInfo() const { return &InstrInfo; }
5050 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
5959 virtual AlphaJITInfo* getJITInfo() {
6060 return &JITInfo;
6161 }
62
63 static unsigned getJITMatchQuality();
64 static unsigned getModuleMatchQuality(const Module &M);
6265
6366 // Pass Pipeline Configuration
6467 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
2323 #include "llvm/CodeGen/DwarfWriter.h"
2424 #include "llvm/Target/TargetAsmInfo.h"
2525 #include "llvm/Target/TargetMachine.h"
26 #include "llvm/Target/TargetRegistry.h"
2726 #include "llvm/Support/Compiler.h"
2827 #include "llvm/Support/ErrorHandling.h"
2928 #include "llvm/Support/Mangler.h"
292291 return false;
293292 }
294293
294 // Force static initialization.
295 extern "C" void LLVMInitializeAlphaAsmPrinter() { }
296
295297 namespace {
296298 static struct Register {
297299 Register() {
299301 }
300302 } Registrator;
301303 }
302
303 // Force static initialization.
304 extern "C" void LLVMInitializeAlphaAsmPrinter() {
305 extern Target TheAlphaTarget;
306 TargetRegistry::RegisterAsmPrinter(TheAlphaTarget,
307 createAlphaCodePrinterPass);
308 }
2929 #include "llvm/CodeGen/Passes.h"
3030 #include "llvm/CodeGen/IntrinsicLowering.h"
3131 #include "llvm/Transforms/Scalar.h"
32 #include "llvm/Target/TargetMachineRegistry.h"
3233 #include "llvm/Target/TargetAsmInfo.h"
3334 #include "llvm/Target/TargetData.h"
34 #include "llvm/Target/TargetMachineRegistry.h"
35 #include "llvm/Target/TargetRegistry.h"
3635 #include "llvm/Support/CallSite.h"
3736 #include "llvm/Support/CFG.h"
3837 #include "llvm/Support/ErrorHandling.h"
5857 int CBackendTargetMachineModule = 0;
5958
6059 // Register the target.
61 extern Target TheCBackendTarget;
62 static RegisterTarget X(TheCBackendTarget, "c", "C backend");
60 static RegisterTarget X("c", "C backend");
6361
6462 // Force static initialization.
6563 extern "C" void LLVMInitializeCBackendTarget() { }
31873185
31883186 const char *const *table = 0;
31893187
3190 // Grab the translation table from TargetAsmInfo if it exists.
3188 //Grab the translation table from TargetAsmInfo if it exists
31913189 if (!TAsm) {
31923190 std::string E;
3193 const Target *Match =
3194 TargetRegistry::getClosestStaticTargetForModule(*TheModule, E);
3191 const TargetMachineRegistry::entry* Match =
3192 TargetMachineRegistry::getClosestStaticTargetForModule(*TheModule, E);
31953193 if (Match) {
3196 // Per platform Target Machines don't exist, so create it;
3197 // this must be done only once.
3198 const TargetMachine* TM = Match->createTargetMachine(*TheModule, "");
3194 //Per platform Target Machines don't exist, so create it
3195 // this must be done only once
3196 const TargetMachine* TM = Match->CtorFn(*TheModule, "");
31993197 TAsm = TM->getTargetAsmInfo();
32003198 }
32013199 }
32023200 if (TAsm)
32033201 table = TAsm->getAsmCBE();
32043202
3205 // Search the translation table if it exists.
3203 //Search the translation table if it exists
32063204 for (int i = 0; table && table[i]; i += 2)
32073205 if (c.Codes[0] == table[i])
32083206 return table[i+1];
32093207
3210 // Default is identity.
3208 //default is identity
32113209 return c.Codes[0];
32123210 }
32133211
2121 struct CTargetMachine : public TargetMachine {
2222 const TargetData DataLayout; // Calculates type size & alignment
2323
24 CTargetMachine(const Target &T, const Module &M, const std::string &FS)
25 : TargetMachine(T), DataLayout(&M) {}
24 CTargetMachine(const Module &M, const std::string &FS)
25 : DataLayout(&M) {}
2626
2727 virtual bool WantsWholeFile() const { return true; }
2828 virtual bool addPassesToEmitWholeFile(PassManager &PM,
2929 formatted_raw_ostream &Out,
3030 CodeGenFileType FileType,
3131 CodeGenOpt::Level OptLevel);
32
33 // This class always works, but must be requested explicitly on
34 // llc command line.
35 static unsigned getModuleMatchQuality(const Module &M) { return 0; }
3236
3337 virtual const TargetData *getTargetData() const { return &DataLayout; }
3438 };
3636 #include "llvm/Target/TargetRegisterInfo.h"
3737 #include "llvm/Target/TargetInstrInfo.h"
3838 #include "llvm/Target/TargetOptions.h"
39 #include "llvm/Target/TargetRegistry.h"
4039 #include "llvm/ADT/Statistic.h"
4140 #include "llvm/ADT/StringExtras.h"
4241 #include
289288 class VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter {
290289 DwarfWriter *DW;
291290 public:
292 explicit LinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
291 explicit LinuxAsmPrinter(formatted_raw_ostream &O, SPUTargetMachine &TM,
293292 const TargetAsmInfo *T, bool V)
294293 : SPUAsmPrinter(O, TM, T, V), DW(0) {}
295294
599598 /// that the Linux SPU assembler can deal with.
600599 ///
601600 FunctionPass *llvm::createSPUAsmPrinterPass(formatted_raw_ostream &o,
602 TargetMachine &tm,
601 SPUTargetMachine &tm,
603602 bool verbose) {
604603 return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
605604 }
605
606 // Force static initialization.
607 extern "C" void LLVMInitializeCellSPUAsmPrinter() { }
606608
607609 namespace {
608610 static struct Register {
611613 }
612614 } Registrator;
613615 }
614
615 // Force static initialization.
616 extern "C" void LLVMInitializeCellSPUAsmPrinter() {
617 extern Target TheCellSPUTarget;
618 TargetRegistry::RegisterAsmPrinter(TheCellSPUTarget, createSPUAsmPrinterPass);
619 }
2424
2525 FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
2626 FunctionPass *createSPUAsmPrinterPass(formatted_raw_ostream &o,
27 TargetMachine &tm,
27 SPUTargetMachine &tm,
2828 bool verbose);
2929
3030 /*--== Utility functions/predicates/etc used all over the place: --==*/
2222
2323 using namespace llvm;
2424
25 extern Target TheCellSPUTarget;
2625 namespace {
2726 // Register the targets
2827 RegisterTarget
29 CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]");
28 CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]");
3029 }
3130
3231 // No assembler printer by default
4746 return new SPULinuxTargetAsmInfo(*this);
4847 }
4948
50 SPUTargetMachine::SPUTargetMachine(const Target &T, const Module &M,
51 const std::string &FS)
52 : LLVMTargetMachine(T),
53 Subtarget(*this, M, FS),
49 unsigned
50 SPUTargetMachine::getModuleMatchQuality(const Module &M)
51 {
52 // We strongly match "spu-*" or "cellspu-*".
53 std::string TT = M.getTargetTriple();
54 if ((TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "spu")
55 || (TT.size() == 7 && std::string(TT.begin(), TT.begin()+7) == "cellspu")
56 || (TT.size() >= 4 && std::string(TT.begin(), TT.begin()+4) == "spu-")
57 || (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "cellspu-"))
58 return 20;
59
60 return 0; // No match at all...
61 }
62
63 SPUTargetMachine::SPUTargetMachine(const Module &M, const std::string &FS)
64 : Subtarget(*this, M, FS),
5465 DataLayout(Subtarget.getTargetDataString()),
5566 InstrInfo(*this),
5667 FrameInfo(*this),
4141 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4242 // set this functions to ctor pointer at startup time if they are linked in.
4343 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
44 TargetMachine &tm,
44 SPUTargetMachine &tm,
4545 bool verbose);
4646 static AsmPrinterCtorFn AsmPrinterCtor;
4747
4848 public:
49 SPUTargetMachine(const Target &T, const Module &M, const std::string &FS);
49 SPUTargetMachine(const Module &M, const std::string &FS);
5050
5151 /// Return the subtarget implementation object
5252 virtual const SPUSubtarget *getSubtargetImpl() const {
6565 virtual TargetJITInfo *getJITInfo() {
6666 return NULL;
6767 }
68
69 //! Module match function
70 /*!
71 Module matching function called by TargetMachineRegistry().
72 */
73 static unsigned getModuleMatchQuality(const Module &M);
6874
6975 virtual SPUTargetLowering *getTargetLowering() const {
7076 return const_cast(&TLInfo);
8080 int CppBackendTargetMachineModule = 0;
8181
8282 // Register the target.
83 extern Target TheCppBackendTarget;
84 static RegisterTarget X(TheCppBackendTarget, "cpp", "C++ backend");
83 static RegisterTarget X("cpp", "C++ backend");
8584
8685 // Force static initialization.
8786 extern "C" void LLVMInitializeCppBackendTarget() { }
2323 struct CPPTargetMachine : public TargetMachine {
2424 const TargetData DataLayout; // Calculates type size & alignment
2525
26 CPPTargetMachine(const Target &T, const Module &M, const std::string &FS)
27 : TargetMachine(T), DataLayout(&M) {}
26 CPPTargetMachine(const Module &M, const std::string &FS)
27 : DataLayout(&M) {}
2828
2929 virtual bool WantsWholeFile() const { return true; }
3030 virtual bool addPassesToEmitWholeFile(PassManager &PM,
3131 formatted_raw_ostream &Out,
3232 CodeGenFileType FileType,
3333 CodeGenOpt::Level OptLevel);
34
35 // This class always works, but shouldn't be the default in most cases.
36 static unsigned getModuleMatchQuality(const Module &M) { return 1; }
3437
3538 virtual const TargetData *getTargetData() const { return &DataLayout; }
3639 };
2525 #include "llvm/CodeGen/DwarfWriter.h"
2626 #include "llvm/CodeGen/MachineFunctionPass.h"
2727 #include "llvm/Target/TargetAsmInfo.h"
28 #include "llvm/Target/TargetRegistry.h"
2928 #include "llvm/Support/ErrorHandling.h"
3029 #include "llvm/Support/FormattedStream.h"
3130 #include "llvm/Support/Mangler.h"
369368 /// the given target machine description.
370369 ///
371370 FunctionPass *llvm::createIA64CodePrinterPass(formatted_raw_ostream &o,
372 TargetMachine &tm,
371 IA64TargetMachine &tm,
373372 bool verbose) {
374373 return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
375374 }
384383
385384
386385 // Force static initialization.
387 extern "C" void LLVMInitializeIA64AsmPrinter() {
388 extern Target TheIA64Target;
389 TargetRegistry::RegisterAsmPrinter(TheIA64Target, createIA64CodePrinterPass);
390 }
386 extern "C" void LLVMInitializeIA64AsmPrinter() { }
3737 /// regardless of whether the function is in SSA form.
3838 ///
3939 FunctionPass *createIA64CodePrinterPass(formatted_raw_ostream &o,
40 TargetMachine &tm,
40 IA64TargetMachine &tm,
4141 bool verbose);
4242
4343 } // End llvm namespace
1919 using namespace llvm;
2020
2121 // Register the target
22 extern Target TheIA64Target;
23 static RegisterTarget X(TheIA64Target, "ia64",
22 static RegisterTarget X("ia64",
2423 "IA-64 (Itanium) [experimental]");
2524
2625 // No assembler printer by default
3332 return new IA64TargetAsmInfo(*this);
3433 }
3534
35 unsigned IA64TargetMachine::getModuleMatchQuality(const Module &M) {
36 // we match [iI][aA]*64
37 bool seenIA64=false;
38 std::string TT = M.getTargetTriple();
39
40 if (TT.size() >= 4) {
41 if( (TT[0]=='i' || TT[0]=='I') &&
42 (TT[1]=='a' || TT[1]=='A') ) {
43 for(unsigned int i=2; i<(TT.size()-1); i++)
44 if(TT[i]=='6' && TT[i+1]=='4')
45 seenIA64=true;
46 }
47
48 if (seenIA64)
49 return 20; // strong match
50 }
51 // If the target triple is something non-ia64, we don't match.
52 if (!TT.empty()) return 0;
53
54 #if defined(__ia64__) || defined(__IA64__)
55 return 5;
56 #else
57 return 0;
58 #endif
59 }
60
3661 /// IA64TargetMachine ctor - Create an LP64 architecture model
3762 ///
38 IA64TargetMachine::IA64TargetMachine(const Target &T, const Module &M,
39 const std::string &FS)
40 : LLVMTargetMachine(T),
41 DataLayout("e-f80:128:128"),
63 IA64TargetMachine::IA64TargetMachine(const Module &M, const std::string &FS)
64 : DataLayout("e-f80:128:128"),
4265 FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0),
4366 TLInfo(*this) { // FIXME? check this stuff
4467 }
3636 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
3737 // set this functions to ctor pointer at startup time if they are linked in.
3838 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
39 TargetMachine &tm,
39 IA64TargetMachine &tm,
4040 bool verbose);
4141 static AsmPrinterCtorFn AsmPrinterCtor;
4242
4343 public:
44 IA64TargetMachine(const Target &T, const Module &M, const std::string &FS);
44 IA64TargetMachine(const Module &M, const std::string &FS);
4545
4646 virtual const IA64InstrInfo *getInstrInfo() const { return &InstrInfo; }
4747 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
5353 return &InstrInfo.getRegisterInfo();
5454 }
5555 virtual const TargetData *getTargetData() const { return &DataLayout; }
56
57 static unsigned getModuleMatchQuality(const Module &M);
5658
5759 // Pass Pipeline Configuration
5860 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
3030 struct VISIBILITY_HIDDEN MSILTarget : public TargetMachine {
3131 const TargetData DataLayout; // Calculates type size & alignment
3232
33 MSILTarget(const Target &T, const Module &M, const std::string &FS)
34 : TargetMachine(T), DataLayout(&M) {}
33 MSILTarget(const Module &M, const std::string &FS)
34 : DataLayout(&M) {}
3535
3636 virtual bool WantsWholeFile() const { return true; }
3737 virtual bool addPassesToEmitWholeFile(PassManager &PM,
5454 extern "C" int MSILTargetMachineModule;
5555 int MSILTargetMachineModule = 0;
5656
57 extern Target TheMSILTarget;
58 static RegisterTarget X(TheMSILTarget, "msil", "MSIL backend");
57 static RegisterTarget X("msil", "MSIL backend");
5958
6059 // Force static initialization.
6160 extern "C" void LLVMInitializeMSILTarget() { }
3131
3232
3333 // Register the targets
34 extern Target TheMSP430Target;
3534 static RegisterTarget
36 X(TheMSP430Target, "msp430", "MSP430 [experimental]");
35 X("msp430", "MSP430 [experimental]");
3736
3837 // Force static initialization.
3938 extern "C" void LLVMInitializeMSP430Target() { }
4039
41 MSP430TargetMachine::MSP430TargetMachine(const Target &T,
42 const Module &M,
40 MSP430TargetMachine::MSP430TargetMachine(const Module &M,
4341 const std::string &FS) :
44 LLVMTargetMachine(T),
4542 Subtarget(*this, M, FS),
4643 // FIXME: Check TargetData string.
4744 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
6865 return false;
6966 }
7067
68 unsigned MSP430TargetMachine::getModuleMatchQuality(const Module &M) {
69 std::string TT = M.getTargetTriple();
70
71 // We strongly match msp430
72 if (TT.size() >= 6 && TT[0] == 'm' && TT[1] == 's' && TT[2] == 'p' &&
73 TT[3] == '4' && TT[4] == '3' && TT[5] == '0')
74 return 20;
75
76 return 0;
77 }
78
4040 virtual const TargetAsmInfo *createTargetAsmInfo() const;
4141
4242 public:
43 MSP430TargetMachine(const Target &T, const Module &M, const std::string &FS);
43 MSP430TargetMachine(const Module &M, const std::string &FS);
4444
4545 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
4646 virtual const MSP430InstrInfo *getInstrInfo() const { return &InstrInfo; }
5959 virtual bool addAssemblyEmitter(PassManagerBase &PM,
6060 CodeGenOpt::Level OptLevel, bool Verbose,
6161 formatted_raw_ostream &Out);
62 static unsigned getModuleMatchQuality(const Module &M);
6263 }; // MSP430TargetMachine.
6364
6465 } // end namespace llvm
3232 #include "llvm/Target/TargetData.h"
3333 #include "llvm/Target/TargetMachine.h"
3434 #include "llvm/Target/TargetOptions.h"
35 #include "llvm/Target/TargetRegistry.h"
3635 #include "llvm/Support/ErrorHandling.h"
3736 #include "llvm/Support/Mangler.h"
3837 #include "llvm/ADT/Statistic.h"
5150 class VISIBILITY_HIDDEN MipsAsmPrinter : public AsmPrinter {
5251 const MipsSubtarget *Subtarget;
5352 public:
54 explicit MipsAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
53 explicit MipsAsmPrinter(formatted_raw_ostream &O, MipsTargetMachine &TM,
5554 const TargetAsmInfo *T, bool V)
5655 : AsmPrinter(O, TM, T, V) {
5756 Subtarget = &TM.getSubtarget();
9291 /// using the given target machine description. This should work
9392 /// regardless of whether the function is in SSA form.
9493 FunctionPass *llvm::createMipsCodePrinterPass(formatted_raw_ostream &o,
95 TargetMachine &tm,
94 MipsTargetMachine &tm,
9695 bool verbose) {
9796 return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
9897 }
584583 }
585584
586585 // Force static initialization.
587 extern "C" void LLVMInitializeMipsAsmPrinter() {
588 extern Target TheMipsTarget;
589 TargetRegistry::RegisterAsmPrinter(TheMipsTarget, createMipsCodePrinterPass);
590
591 extern Target TheMipselTarget;
592 TargetRegistry::RegisterAsmPrinter(TheMipselTarget,
593 createMipsCodePrinterPass);
594 }
586 extern "C" void LLVMInitializeMipsAsmPrinter() { }
2525 FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
2626 FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
2727 FunctionPass *createMipsCodePrinterPass(formatted_raw_ostream &OS,
28 TargetMachine &TM,
28 MipsTargetMachine &TM,
2929 bool Verbose);
3030 } // end namespace llvm;
3131
2727 int MipsTargetMachineModule = 0;
2828
2929 // Register the target.
30 extern Target TheMipsTarget;
31 static RegisterTarget X(TheMipsTarget, "mips", "Mips");
32
33 extern Target TheMipselTarget;
34 static RegisterTarget Y(TheMipselTarget, "mipsel",
35 "Mipsel");
30 static RegisterTarget X("mips", "Mips");
31 static RegisterTarget Y("mipsel", "Mipsel");
3632
3733 MipsTargetMachine::AsmPrinterCtorFn MipsTargetMachine::AsmPrinterCtor = 0;
3834
5450 // an easier handling.
5551 // Using CodeModel::Large enables different CALL behavior.
5652 MipsTargetMachine::
57 MipsTargetMachine(const Target &T, const Module &M, const std::string &FS,
58 bool isLittle=false):
59 LLVMTargetMachine(T),
53 MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle=false):
6054 Subtarget(*this, M, FS, isLittle),
6155 DataLayout(isLittle ? std::string("e-p:32:32:32-i8:8:32-i16:16:32") :
6256 std::string("E-p:32:32:32-i8:8:32-i16:16:32")),
7569 }
7670
7771 MipselTargetMachine::
78 MipselTargetMachine(const Target &T, const Module &M, const std::string &FS) :
79 MipsTargetMachine(T, M, FS, true) {}
72 MipselTargetMachine(const Module &M, const std::string &FS) :
73 MipsTargetMachine(M, FS, true) {}
74
75 // return 0 and must specify -march to gen MIPS code.
76 unsigned MipsTargetMachine::
77 getModuleMatchQuality(const Module &M)
78 {
79 // We strongly match "mips*-*".
80 std::string TT = M.getTargetTriple();
81 if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-")
82 return 20;
83
84 if (TT.size() >= 13 && std::string(TT.begin(),
85 TT.begin()+13) == "mipsallegrex-")
86 return 20;
87
88 return 0;
89 }
90
91 // return 0 and must specify -march to gen MIPSEL code.
92 unsigned MipselTargetMachine::
93 getModuleMatchQuality(const Module &M)
94 {
95 // We strongly match "mips*el-*".
96 std::string TT = M.getTargetTriple();
97 if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-")
98 return 20;
99
100 if (TT.size() >= 15 && std::string(TT.begin(),
101 TT.begin()+15) == "mipsallegrexel-")
102 return 20;
103
104 if (TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "psp")
105 return 20;
106
107 return 0;
108 }
80109
81110 // Install an instruction selector pass using
82111 // the ISelDag to gen Mips code.
3737 // asmprinter set this functions to ctor pointer at startup time if they are
3838 // linked in.
3939 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
40 TargetMachine &tm,
40 MipsTargetMachine &tm,
4141 bool verbose);
4242 static AsmPrinterCtorFn AsmPrinterCtor;
4343
4444 public:
45 MipsTargetMachine(const Target &T, const Module &M, const std::string &FS,
46 bool isLittle);
45 MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle);
4746
4847 static void registerAsmPrinter(AsmPrinterCtorFn F) {
4948 AsmPrinterCtor = F;
6665 return const_cast(&TLInfo);
6766 }
6867
68 static unsigned getModuleMatchQuality(const Module &M);
69
6970 // Pass Pipeline Configuration
7071 virtual bool addInstSelector(PassManagerBase &PM,
7172 CodeGenOpt::Level OptLevel);
8081 ///
8182 class MipselTargetMachine : public MipsTargetMachine {
8283 public:
83 MipselTargetMachine(const Target &T, const Module &M, const std::string &FS);
84 MipselTargetMachine(const Module &M, const std::string &FS);
8485
8586 static unsigned getModuleMatchQuality(const Module &M);
8687 };
3131
3232
3333 // Register the targets
34 extern Target ThePIC16Target;
3534 static RegisterTarget
36 X(ThePIC16Target, "pic16", "PIC16 14-bit [experimental].");
37
38 extern Target TheCooperTarget;
35 X("pic16", "PIC16 14-bit [experimental].");
3936 static RegisterTarget
40 Y(TheCooperTarget, "cooper", "PIC16 Cooper [experimental].");
37 Y("cooper", "PIC16 Cooper [experimental].");
4138
4239 // Force static initialization.
4340 extern "C" void LLVMInitializePIC16Target() { }
4441
4542 // PIC16TargetMachine - Traditional PIC16 Machine.
46 PIC16TargetMachine::PIC16TargetMachine(const Target &T, const Module &M,
47 const std::string &FS, bool Cooper)
48 : LLVMTargetMachine(T),
49 Subtarget(M, FS, Cooper),
43 PIC16TargetMachine::PIC16TargetMachine(const Module &M, const std::string &FS,
44 bool Cooper)
45 : Subtarget(M, FS, Cooper),
5046 DataLayout("e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"),
5147 InstrInfo(*this), TLInfo(*this),
5248 FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0) { }
5349
5450 // CooperTargetMachine - Uses the same PIC16TargetMachine, but makes IsCooper
5551 // as true.
56 CooperTargetMachine::CooperTargetMachine(const Target &T, const Module &M,
57 const std::string &FS)
58 : PIC16TargetMachine(T, M, FS, true) {}
52 CooperTargetMachine::CooperTargetMachine(const Module &M, const std::string &FS)
53 : PIC16TargetMachine(M, FS, true) {}
5954
6055
6156 const TargetAsmInfo *PIC16TargetMachine::createTargetAsmInfo() const {
4040 virtual const TargetAsmInfo *createTargetAsmInfo() const;
4141
4242 public:
43 PIC16TargetMachine(const Target &T, const Module &M, const std::string &FS,
43 PIC16TargetMachine(const Module &M, const std::string &FS,
4444 bool Cooper = false);
4545
4646 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
6767 /// CooperTargetMachine
6868 class CooperTargetMachine : public PIC16TargetMachine {
6969 public:
70 CooperTargetMachine(const Target &T, const Module &M, const std::string &FS);
70 CooperTargetMachine(const Module &M, const std::string &FS);
7171 }; // CooperTargetMachine.
7272
7373 } // end namespace llvm
4242 #include "llvm/Target/TargetRegisterInfo.h"
4343 #include "llvm/Target/TargetInstrInfo.h"
4444 #include "llvm/Target/TargetOptions.h"
45 #include "llvm/Target/TargetRegistry.h"
4645 #include "llvm/ADT/Statistic.h"
4746 #include "llvm/ADT/StringExtras.h"
4847 #include "llvm/ADT/StringSet.h"
317316 /// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
318317 class VISIBILITY_HIDDEN PPCLinuxAsmPrinter : public PPCAsmPrinter {
319318 public:
320 explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
319 explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM,
321320 const TargetAsmInfo *T, bool V)
322321 : PPCAsmPrinter(O, TM, T, V){}
323322
343342 class VISIBILITY_HIDDEN PPCDarwinAsmPrinter : public PPCAsmPrinter {
344343 formatted_raw_ostream &OS;
345344 public:
346 explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
345 explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM,
347346 const TargetAsmInfo *T, bool V)
348347 : PPCAsmPrinter(O, TM, T, V), OS(O) {}
349348
10801079 /// Darwin assembler can deal with.
10811080 ///
10821081 FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o,
1083 TargetMachine &tm,
1082 PPCTargetMachine &tm,
10841083 bool verbose) {
10851084 const PPCSubtarget *Subtarget = &tm.getSubtarget();
10861085
11031102 int PowerPCAsmPrinterForceLink = 0;
11041103
11051104 // Force static initialization.
1106 extern "C" void LLVMInitializePowerPCAsmPrinter() {
1107 extern Target ThePPC32Target;
1108 TargetRegistry::RegisterAsmPrinter(ThePPC32Target, createPPCAsmPrinterPass);
1109
1110 extern Target ThePPC64Target;
1111 TargetRegistry::RegisterAsmPrinter(ThePPC64Target, createPPCAsmPrinterPass);
1112 }
1105 extern "C" void LLVMInitializePowerPCAsmPrinter() { }
2929 FunctionPass *createPPCBranchSelectionPass();
3030 FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
3131 FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &OS,
32 TargetMachine &TM,
32 PPCTargetMachine &TM,
3333 bool Verbose);
3434 FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
3535 MachineCodeEmitter &MCE);
2929 int PowerPCTargetMachineModule = 0;
3030
3131 // Register the targets
32 extern Target ThePPC32Target;
3332 static RegisterTarget
34 X(ThePPC32Target, "ppc32", "PowerPC 32");
35
36 extern Target ThePPC64Target;
33 X("ppc32", "PowerPC 32");
3734 static RegisterTarget
38 Y(ThePPC64Target, "ppc64", "PowerPC 64");
35 Y("ppc64", "PowerPC 64");
3936
4037 // Force static initialization.
4138 extern "C" void LLVMInitializePowerPCTarget() { }
5047 return new PPCLinuxTargetAsmInfo(*this);
5148 }
5249
53 PPCTargetMachine::PPCTargetMachine(const Target&T, const Module &M,
54 const std::string &FS, bool is64Bit)
55 : LLVMTargetMachine(T),
56 Subtarget(*this, M, FS, is64Bit),
50 unsigned PPC32TargetMachine::getJITMatchQuality() {
51 #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__)
52 if (sizeof(void*) == 4)
53 return 10;
54 #endif
55 return 0;
56 }
57 unsigned PPC64TargetMachine::getJITMatchQuality() {
58 #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER) || defined(__PPC__)
59 if (sizeof(void*) == 8)
60 return 10;
61 #endif
62 return 0;
63 }
64
65 unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
66 // We strongly match "powerpc-*".
67 std::string TT = M.getTargetTriple();
68 if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
69 return 20;
70
71 // If the target triple is something non-powerpc, we don't match.
72 if (!TT.empty()) return 0;
73
74 if (M.getEndianness() == Module::BigEndian &&
75 M.getPointerSize() == Module::Pointer32)
76 return 10; // Weak match
77 else if (M.getEndianness() != Module::AnyEndianness ||
78 M.getPointerSize() != Module::AnyPointerSize)
79 return 0; // Match for some other target
80
81 return getJITMatchQuality()/2;
82 }
83
84 unsigned PPC64TargetMachine::getModuleMatchQuality(const Module &M) {
85 // We strongly match "powerpc64-*".
86 std::string TT = M.getTargetTriple();
87 if (TT.size() >= 10 && std::string(TT.begin(), TT.begin()+10) == "powerpc64-")
88 return 20;
89
90 if (M.getEndianness() == Module::BigEndian &&
91 M.getPointerSize() == Module::Pointer64)
92 return 10; // Weak match
93 else if (M.getEndianness() != Module::AnyEndianness ||
94 M.getPointerSize() != Module::AnyPointerSize)
95 return 0; // Match for some other target
96
97 return getJITMatchQuality()/2;
98 }
99
100
101 PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS,
102 bool is64Bit)
103 : Subtarget(*this, M, FS, is64Bit),
57104 DataLayout(Subtarget.getTargetDataString()), InstrInfo(*this),
58105 FrameInfo(*this, is64Bit), JITInfo(*this, is64Bit), TLInfo(*this),
59106 InstrItins(Subtarget.getInstrItineraryData()), MachOWriterInfo(*this) {
70117 /// groups, which typically degrades performance.
71118 bool PPCTargetMachine::getEnableTailMergeDefault() const { return false; }
72119
73 PPC32TargetMachine::PPC32TargetMachine(const Target &T, const Module &M,
74 const std::string &FS)
75 : PPCTargetMachine(T, M, FS, false) {
76 }
77
78
79 PPC64TargetMachine::PPC64TargetMachine(const Target &T, const Module &M,
80 const std::string &FS)
81 : PPCTargetMachine(T, M, FS, true) {
120 PPC32TargetMachine::PPC32TargetMachine(const Module &M, const std::string &FS)
121 : PPCTargetMachine(M, FS, false) {
122 }
123
124
125 PPC64TargetMachine::PPC64TargetMachine(const Module &M, const std::string &FS)
126 : PPCTargetMachine(M, FS, true) {
82127 }
83128
84129
4444 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4545 // set this functions to ctor pointer at startup time if they are linked in.
4646 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
47 TargetMachine &m,
47 PPCTargetMachine &tm,
4848 bool verbose);
4949 static AsmPrinterCtorFn AsmPrinterCtor;
5050
5151 public:
52 PPCTargetMachine(const Target &T, const Module &M, const std::string &FS,
53 bool is64Bit);
52 PPCTargetMachine(const Module &M, const std::string &FS, bool is64Bit);
5453
5554 virtual const PPCInstrInfo *getInstrInfo() const { return &InstrInfo; }
5655 virtual const PPCFrameInfo *getFrameInfo() const { return &FrameInfo; }
103102 ///
104103 class PPC32TargetMachine : public PPCTargetMachine {
105104 public:
106 PPC32TargetMachine(const Target &T, const Module &M, const std::string &FS);
105 PPC32TargetMachine(const Module &M, const std::string &FS);
106
107 static unsigned getJITMatchQuality();
108 static unsigned getModuleMatchQuality(const Module &M);
107109 };
108110
109111 /// PPC64TargetMachine - PowerPC 64-bit target machine.
110112 ///
111113 class PPC64TargetMachine : public PPCTargetMachine {
112114 public:
113 PPC64TargetMachine(const Target &T, const Module &M, const std::string &FS);
115 PPC64TargetMachine(const Module &M, const std::string &FS);
116
117 static unsigned getJITMatchQuality();
118 static unsigned getModuleMatchQuality(const Module &M);
114119 };
115120
116121 } // end namespace llvm
2525 #include "llvm/CodeGen/MachineConstantPool.h"
2626 #include "llvm/CodeGen/MachineInstr.h"
2727 #include "llvm/Target/TargetAsmInfo.h"
28 #include "llvm/Target/TargetRegistry.h"
2928 #include "llvm/Support/ErrorHandling.h"
3029 #include "llvm/Support/FormattedStream.h"
3130 #include "llvm/Support/Mangler.h"
359358 }
360359
361360 // Force static initialization.
362 extern "C" void LLVMInitializeSparcAsmPrinter() {
363 extern Target TheSparcTarget;
364 TargetRegistry::RegisterAsmPrinter(TheSparcTarget,
365 createSparcCodePrinterPass);
366 }
361 extern "C" void LLVMInitializeSparcAsmPrinter() { }
1818 using namespace llvm;
1919
2020 // Register the target.
21 extern Target TheSparcTarget;
22 static RegisterTarget X(TheSparcTarget, "sparc", "SPARC");
21 static RegisterTarget X("sparc", "SPARC");
2322
2423 // No assembler printer by default
2524 SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0;
3534
3635 /// SparcTargetMachine ctor - Create an ILP32 architecture model
3736 ///
38 SparcTargetMachine::SparcTargetMachine(const Target &T, const Module &M,
39 const std::string &FS)
40 : LLVMTargetMachine(T),
41 DataLayout("E-p:32:32-f128:128:128"),
37 SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
38 : DataLayout("E-p:32:32-f128:128:128"),
4239 Subtarget(M, FS), TLInfo(*this), InstrInfo(Subtarget),
4340 FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
41 }
42
43 unsigned SparcTargetMachine::getModuleMatchQuality(const Module &M) {
44 std::string TT = M.getTargetTriple();
45 if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "sparc-")
46 return 20;
47
48 // If the target triple is something non-sparc, we don't match.
49 if (!TT.empty()) return 0;
50
51 if (M.getEndianness() == Module::BigEndian &&
52 M.getPointerSize() == Module::Pointer32)
53 #ifdef __sparc__
54 return 20; // BE/32 ==> Prefer sparc on sparc
55 #else
56 return 5; // BE/32 ==> Prefer ppc elsewhere
57 #endif
58 else if (M.getEndianness() != Module::AnyEndianness ||
59 M.getPointerSize() != Module::AnyPointerSize)
60 return 0; // Match for some other target
61
62 #if defined(__sparc__)
63 return 10;
64 #else
65 return 0;
66 #endif
4467 }
4568
4669 bool SparcTargetMachine::addInstSelector(PassManagerBase &PM,
4242 static AsmPrinterCtorFn AsmPrinterCtor;
4343
4444 public:
45 SparcTargetMachine(const Target &T, const Module &M, const std::string &FS);
45 SparcTargetMachine(const Module &M, const std::string &FS);
4646
4747 virtual const SparcInstrInfo *getInstrInfo() const { return &InstrInfo; }
4848 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
5454 return const_cast(&TLInfo);
5555 }
5656 virtual const TargetData *getTargetData() const { return &DataLayout; }
57 static unsigned getModuleMatchQuality(const Module &M);
5758
5859 // Pass Pipeline Configuration
5960 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
175175 // TargetMachine Class
176176 //
177177
178 TargetMachine::TargetMachine(const Target &T)
179 : TheTarget(T), AsmInfo(0) {
178 TargetMachine::TargetMachine()
179 : AsmInfo(0) {
180180 // Typically it will be subtargets that will adjust FloatABIType from Default
181181 // to Soft or Hard.
182182 if (UseSoftFloat)
3636 MCContext *Context;
3737 MCStreamer *Streamer;
3838 public:
39 explicit X86ATTAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
39 explicit X86ATTAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
4040 const TargetAsmInfo *T, bool V)
4141 : AsmPrinter(O, TM, T, V) {
4242 Subtarget = &TM.getSubtarget();
1616 #include "X86ATTAsmPrinter.h"
1717 #include "X86IntelAsmPrinter.h"
1818 #include "X86Subtarget.h"
19 #include "llvm/Target/TargetRegistry.h"
2019 using namespace llvm;
2120
2221 /// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code
2423 /// machine description.
2524 ///
2625 FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o,
27 TargetMachine &tm,
26 X86TargetMachine &tm,
2827 bool verbose) {
2928 const X86Subtarget *Subtarget = &tm.getSubtarget();
3029
4544 int X86AsmPrinterForceLink = 0;
4645
4746 // Force static initialization.
48 extern "C" void LLVMInitializeX86AsmPrinter() {
49 extern Target TheX86_32Target;
50 TargetRegistry::RegisterAsmPrinter(TheX86_32Target, createX86CodePrinterPass);
51
52 extern Target TheX86_64Target;
53 TargetRegistry::RegisterAsmPrinter(TheX86_64Target, createX86CodePrinterPass);
54 }
47 extern "C" void LLVMInitializeX86AsmPrinter() { }
2424 namespace llvm {
2525
2626 struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter {
27 explicit X86IntelAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
27 explicit X86IntelAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
2828 const TargetAsmInfo *T, bool V)
2929 : AsmPrinter(O, TM, T, V) {}
3030
4646 /// using the given target machine description.
4747 ///
4848 FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
49 TargetMachine &tm,
49 X86TargetMachine &tm,
5050 bool Verbose);
5151
5252 /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
3030 int X86TargetMachineModule = 0;
3131
3232 // Register the target.
33 extern Target TheX86_32Target;
3433 static RegisterTarget
35 X(TheX86_32Target, "x86", "32-bit X86: Pentium-Pro and above");
36
37 extern Target TheX86_64Target;
34 X("x86", "32-bit X86: Pentium-Pro and above");
3835 static RegisterTarget
39 Y(TheX86_64Target, "x86-64", "64-bit X86: EM64T and AMD64");
36 Y("x86-64", "64-bit X86: EM64T and AMD64");
4037
4138 // Force static initialization.
42 extern "C" void LLVMInitializeX86Target() {
43
44 }
39 extern "C" void LLVMInitializeX86Target() { }
4540
4641 // No assembler printer by default
4742 X86TargetMachine::AsmPrinterCtorFn X86TargetMachine::AsmPrinterCtor = 0;
6560 }
6661 }
6762
68 X86_32TargetMachine::X86_32TargetMachine(const Target &T, const Module &M,
69 const std::string &FS)
70 : X86TargetMachine(T, M, FS, false) {
71 }
72
73
74 X86_64TargetMachine::X86_64TargetMachine(const Target &T, const Module &M,
75 const std::string &FS)
76 : X86TargetMachine(T, M, FS, true) {
63 unsigned X86_32TargetMachine::getJITMatchQuality() {
64 #if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
65 return 10;
66 #endif
67 return 0;
68 }
69
70 unsigned X86_64TargetMachine::getJITMatchQuality() {
71 #if defined(__x86_64__) || defined(_M_AMD64)
72 return 10;
73 #endif
74 return 0;
75 }
76
77 unsigned X86_32TargetMachine::getModuleMatchQuality(const Module &M) {
78 // We strongly match "i[3-9]86-*".
79 std::string TT = M.getTargetTriple();
80 if (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' &&
81 TT[4] == '-' && TT[1] - '3' < 6)
82 return 20;
83 // If the target triple is something non-X86, we don't match.
84 if (!TT.empty()) return 0;
85
86 if (M.getEndianness() == Module::LittleEndian &&
87 M.getPointerSize() == Module::Pointer32)
88 return 10; // Weak match
89 else if (M.getEndianness() != Module::AnyEndianness ||
90 M.getPointerSize() != Module::AnyPointerSize)
91 return 0; // Match for some other target
92
93 return getJITMatchQuality()/2;
94 }
95
96 unsigned X86_64TargetMachine::getModuleMatchQuality(const Module &M) {
97 // We strongly match "x86_64-*".
98 std::string TT = M.getTargetTriple();
99 if (TT.size() >= 7 && TT[0] == 'x' && TT[1] == '8' && TT[2] == '6' &&
100 TT[3] == '_' && TT[4] == '6' && TT[5] == '4' && TT[6] == '-')
101 return 20;
102
103 // We strongly match "amd64-*".
104 if (TT.size() >= 6 && TT[0] == 'a' && TT[1] == 'm' && TT[2] == 'd' &&
105 TT[3] == '6' && TT[4] == '4' && TT[5] == '-')
106 return 20;
107
108 // If the target triple is something non-X86-64, we don't match.
109 if (!TT.empty()) return 0;
110
111 if (M.getEndianness() == Module::LittleEndian &&
112 M.getPointerSize() == Module::Pointer64)
113 return 10; // Weak match
114 else if (M.getEndianness() != Module::AnyEndianness ||
115 M.getPointerSize() != Module::AnyPointerSize)
116 return 0; // Match for some other target
117
118 return getJITMatchQuality()/2;
119 }
120
121 X86_32TargetMachine::X86_32TargetMachine(const Module &M, const std::string &FS)
122 : X86TargetMachine(M, FS, false) {
123 }
124
125
126 X86_64TargetMachine::X86_64TargetMachine(const Module &M, const std::string &FS)
127 : X86TargetMachine(M, FS, true) {
77128 }
78129
79130 /// X86TargetMachine ctor - Create an X86 target.
80131 ///
81 X86TargetMachine::X86TargetMachine(const Target &T, const Module &M,
82 const std::string &FS, bool is64Bit)
83 : LLVMTargetMachine(T),
84 Subtarget(M, FS, is64Bit),
132 X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS,
133 bool is64Bit)
134 : Subtarget(M, FS, is64Bit),
85135 DataLayout(Subtarget.getDataLayout()),
86136 FrameInfo(TargetFrameInfo::StackGrowsDown,
87137 Subtarget.getStackAlignment(), Subtarget.is64Bit() ? -8 : -4),
4343 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4444 // set this functions to ctor pointer at startup time if they are linked in.
4545 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
46 TargetMachine &tm,
46 X86TargetMachine &tm,
4747 bool verbose);
4848 static AsmPrinterCtorFn AsmPrinterCtor;
4949
5050 public:
51 X86TargetMachine(const Target &T, const Module &M, const std::string &FS,
52 bool is64Bit);
51 X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit);
5352
5453 virtual const X86InstrInfo *getInstrInfo() const { return &InstrInfo; }
5554 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
6564 virtual const X86ELFWriterInfo *getELFWriterInfo() const {
6665 return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
6766 }
67
68 static unsigned getModuleMatchQuality(const Module &M);
69 static unsigned getJITMatchQuality();
6870
6971 static void registerAsmPrinter(AsmPrinterCtorFn F) {
7072 AsmPrinterCtor = F;
98100 ///
99101 class X86_32TargetMachine : public X86TargetMachine {
100102 public:
101 X86_32TargetMachine(const Target &T, const Module &M, const std::string &FS);
103 X86_32TargetMachine(const Module &M, const std::string &FS);
102104
103105 static unsigned getJITMatchQuality();
104106 static unsigned getModuleMatchQuality(const Module &M);
108110 ///
109111 class X86_64TargetMachine : public X86TargetMachine {
110112 public:
111 X86_64TargetMachine(const Target &T, const Module &M, const std::string &FS);
113 X86_64TargetMachine(const Module &M, const std::string &FS);
112114
113115 static unsigned getJITMatchQuality();
114116 static unsigned getModuleMatchQuality(const Module &M);
2525 extern "C" int XCoreTargetMachineModule;
2626 int XCoreTargetMachineModule = 0;
2727
28 extern Target TheXCoreTarget;
2928 namespace {
3029 // Register the target.
31 RegisterTarget X(TheXCoreTarget, "xcore", "XCore");
30 RegisterTarget X("xcore", "XCore");
3231 }
3332
3433 // Force static initialization.
4039
4140 /// XCoreTargetMachine ctor - Create an ILP32 architecture model
4241 ///
43 XCoreTargetMachine::XCoreTargetMachine(const Target &T, const Module &M,
44 const std::string &FS)
45 : LLVMTargetMachine(T),
46 Subtarget(*this, M, FS),
42 XCoreTargetMachine::XCoreTargetMachine(const Module &M, const std::string &FS)
43 : Subtarget(*this, M, FS),
4744 DataLayout("e-p:32:32:32-a0:0:32-f32:32:32-f64:32:32-i1:8:32-i8:8:32-"
4845 "i16:16:32-i32:32:32-i64:32:32"),
4946 InstrInfo(),
5047 FrameInfo(*this),
5148 TLInfo(*this) {
49 }
50
51 unsigned XCoreTargetMachine::getModuleMatchQuality(const Module &M) {
52 std::string TT = M.getTargetTriple();
53 if (TT.size() >= 6 && std::string(TT.begin(), TT.begin()+6) == "xcore-")
54 return 20;
55
56 // Otherwise we don't match.
57 return 0;
5258 }
5359
5460 bool XCoreTargetMachine::addInstSelector(PassManagerBase &PM,
3535 virtual const TargetAsmInfo *createTargetAsmInfo() const;
3636
3737 public:
38 XCoreTargetMachine(const Target &T, const Module &M, const std::string &FS);
38 XCoreTargetMachine(const Module &M, const std::string &FS);
3939
4040 virtual const XCoreInstrInfo *getInstrInfo() const { return &InstrInfo; }
4141 virtual const XCoreFrameInfo *getFrameInfo() const { return &FrameInfo; }
4848 return &InstrInfo.getRegisterInfo();
4949 }
5050 virtual const TargetData *getTargetData() const { return &DataLayout; }
51 static unsigned getModuleMatchQuality(const Module &M);
5152
5253 // Pass Pipeline Configuration
5354 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
127127 return outputFilename;
128128 }
129129
130 static formatted_raw_ostream *GetOutputStream(const char *TargetName,
131 const char *ProgName) {
130 static formatted_raw_ostream *GetOutputStream(const char *ProgName) {
132131 if (OutputFilename != "") {
133132 if (OutputFilename == "-")
134133 return &fouts();
169168 bool Binary = false;
170169 switch (FileType) {
171170 case TargetMachine::AssemblyFile:
172 if (TargetName[0] == 'c') {
173 if (TargetName[1] == 0)
171 if (MArch->Name[0] == 'c') {
172 if (MArch->Name[1] == 0)
174173 OutputFilename += ".cbe.c";
175 else if (TargetName[1] == 'p' && TargetName[2] == 'p')
174 else if (MArch->Name[1] == 'p' && MArch->Name[2] == 'p')
176175 OutputFilename += ".cpp";
177176 else
178177 OutputFilename += ".s";
248247
249248 // Allocate target machine. First, check whether the user has
250249 // explicitly specified an architecture to compile for.
251 const Target *TheTarget;
252 if (MArch) {
253 TheTarget = &MArch->TheTarget;
254 } else {
250 if (MArch == 0) {
255251 std::string Err;
256 TheTarget = TargetRegistry::getClosestStaticTargetForModule(mod, Err);
257 if (TheTarget == 0) {
252 MArch = TargetMachineRegistry::getClosestStaticTargetForModule(mod, Err);
253 if (MArch == 0) {
258254 errs() << argv[0] << ": error auto-selecting target for module '"
259255 << Err << "'. Please use the -march option to explicitly "
260256 << "pick a target.\n";
272268 FeaturesStr = Features.getString();
273269 }
274270
275 std::auto_ptr
276 target(TheTarget->createTargetMachine(mod, FeaturesStr));
271 std::auto_ptr target(MArch->CtorFn(mod, FeaturesStr));
277272 assert(target.get() && "Could not allocate target machine!");
278273 TargetMachine &Target = *target.get();
279274
280275 // Figure out where we are going to send the output...
281 formatted_raw_ostream *Out = GetOutputStream(TheTarget->getName(), argv[0]);
276 formatted_raw_ostream *Out = GetOutputStream(argv[0]);
282277 if (Out == 0) return 1;
283278
284279 CodeGenOpt::Level OLvl = CodeGenOpt::Default;
327327 if ( _target == NULL ) {
328328 // create target machine from info for merged modules
329329 Module* mergedModule = _linker.getModule();
330 const Target *march =
331 TargetRegistry::getClosestStaticTargetForModule(*mergedModule,
332 errMsg);
330 const TargetMachineRegistry::entry* march =
331 TargetMachineRegistry::getClosestStaticTargetForModule(
332 *mergedModule, errMsg);
333333 if ( march == NULL )
334334 return true;
335335
350350 // construct LTModule, hand over ownership of module and target
351351 std::string FeatureStr =
352352 getFeatureString(_linker.getModule()->getTargetTriple().c_str());
353 _target = march->createTargetMachine(*mergedModule, FeatureStr.c_str());
353 _target = march->CtorFn(*mergedModule, FeatureStr.c_str());
354354 }
355355 return false;
356356 }
146146 if ( !m )
147147 return NULL;
148148 // find machine architecture for this module
149 const Target* march =
150 TargetRegistry::getClosestStaticTargetForModule(*m, errMsg);
149 const TargetMachineRegistry::entry* march =
150 TargetMachineRegistry::getClosestStaticTargetForModule(*m, errMsg);
151151
152152 if ( march == NULL )
153153 return NULL;
154154
155155 // construct LTModule, hand over ownership of module and target
156156 std::string FeatureStr = getFeatureString(m->getTargetTriple().c_str());
157 TargetMachine* target = march->createTargetMachine(*m, FeatureStr);
157 TargetMachine* target = march->CtorFn(*m, FeatureStr);
158158 return new LTOModule(m.take(), target);
159159 }
160160