1 //===-- TargetSelect.cpp - Target Chooser Code ----------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This just asks the TargetMachineRegistry for the appropriate JIT to use, and
11 // allows the user to specify a specific one on the commandline with -march=x.
13 //===----------------------------------------------------------------------===//
16 #include "llvm/Module.h"
17 #include "llvm/ModuleProvider.h"
18 #include "llvm/Target/TargetMachine.h"
19 #include "llvm/Target/TargetMachineRegistry.h"
23 static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser>
24 MArch("march", cl::desc("Architecture to generate assembly for:"));
26 /// create - Create an return a new JIT compiler if there is one available
27 /// for the current target. Otherwise, return null.
29 ExecutionEngine *JIT::create(ModuleProvider *MP, IntrinsicLowering *IL) {
32 MArch = TargetMachineRegistry::getClosestTargetForJIT(Error);
33 if (MArch == 0) return 0;
34 } else if (MArch->JITMatchQualityFn() == 0) {
35 std::cerr << "WARNING: This target JIT is not designed for the host you are"
36 << " running. If bad things happen, please choose a different "
37 << "-march switch.\n";
40 // Allocate a target...
41 TargetMachine *Target = MArch->CtorFn(*MP->getModule(), IL);
42 assert(Target && "Could not allocate target machine!");
44 // If the target supports JIT code generation, return a new JIT now.
45 if (TargetJITInfo *TJ = Target->getJITInfo())
46 return new JIT(MP, *Target, *TJ);