mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-15 16:09:57 +00:00
Migrate llc and the JIT to using the TargetRegistry for lookups.
- They still use the TargetMachineRegistry to populate the contents of the -march option (via the listener interface). We can't just populate it in the option parser because we can't expect the TargetRegistry to be populated yet (we no longer rely on static constructors). - There are a couple ways to finish killing off TargetMachineRegistry, but I haven't figured out the cleanest one yet... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75773 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4d1be777f8
commit
54785e6df0
@ -89,6 +89,10 @@ namespace llvm {
|
|||||||
/// getShortDescription - Get a short description of the target.
|
/// getShortDescription - Get a short description of the target.
|
||||||
const char *getShortDescription() const { return ShortDesc; }
|
const char *getShortDescription() const { return ShortDesc; }
|
||||||
|
|
||||||
|
/// getJITMatchQuality - Get the quality of this targets match for use as a
|
||||||
|
/// JIT.
|
||||||
|
unsigned getJITMatchQuality() const { return JITMatchQualityFn(); }
|
||||||
|
|
||||||
/// createTargetMachine - Create a target specific machine implementation.
|
/// createTargetMachine - Create a target specific machine implementation.
|
||||||
TargetMachine *createTargetMachine(const Module &M,
|
TargetMachine *createTargetMachine(const Module &M,
|
||||||
const std::string &Features) const {
|
const std::string &Features) const {
|
||||||
|
@ -45,16 +45,16 @@ ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr,
|
|||||||
JITMemoryManager *JMM,
|
JITMemoryManager *JMM,
|
||||||
CodeGenOpt::Level OptLevel,
|
CodeGenOpt::Level OptLevel,
|
||||||
bool AllocateGVsWithCode) {
|
bool AllocateGVsWithCode) {
|
||||||
const TargetMachineRegistry::entry *TheArch = MArch;
|
const Target *TheTarget;
|
||||||
if (TheArch == 0) {
|
if (MArch == 0) {
|
||||||
std::string Error;
|
std::string Error;
|
||||||
TheArch = TargetMachineRegistry::getClosestTargetForJIT(Error);
|
TheTarget = TargetRegistry::getClosestTargetForJIT(Error);
|
||||||
if (TheArch == 0) {
|
if (TheTarget == 0) {
|
||||||
if (ErrorStr)
|
if (ErrorStr)
|
||||||
*ErrorStr = Error;
|
*ErrorStr = Error;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if (TheArch->JITMatchQualityFn() == 0) {
|
} else if (TheTarget->getJITMatchQuality() == 0) {
|
||||||
cerr << "WARNING: This target JIT is not designed for the host you are"
|
cerr << "WARNING: This target JIT is not designed for the host you are"
|
||||||
<< " running. If bad things happen, please choose a different "
|
<< " running. If bad things happen, please choose a different "
|
||||||
<< "-march switch.\n";
|
<< "-march switch.\n";
|
||||||
@ -71,7 +71,8 @@ ExecutionEngine *JIT::createJIT(ModuleProvider *MP, std::string *ErrorStr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a target...
|
// Allocate a target...
|
||||||
TargetMachine *Target = TheArch->CtorFn(*MP->getModule(), FeaturesStr);
|
TargetMachine *Target =
|
||||||
|
TheTarget->createTargetMachine(*MP->getModule(), FeaturesStr);
|
||||||
assert(Target && "Could not allocate target machine!");
|
assert(Target && "Could not allocate target machine!");
|
||||||
|
|
||||||
// If the target supports JIT code generation, return a new JIT now.
|
// If the target supports JIT code generation, return a new JIT now.
|
||||||
|
@ -128,7 +128,8 @@ GetFileNameRoot(const std::string &InputFilename) {
|
|||||||
return outputFilename;
|
return outputFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static formatted_raw_ostream *GetOutputStream(const char *ProgName) {
|
static formatted_raw_ostream *GetOutputStream(const char *TargetName,
|
||||||
|
const char *ProgName) {
|
||||||
if (OutputFilename != "") {
|
if (OutputFilename != "") {
|
||||||
if (OutputFilename == "-")
|
if (OutputFilename == "-")
|
||||||
return &fouts();
|
return &fouts();
|
||||||
@ -169,10 +170,10 @@ static formatted_raw_ostream *GetOutputStream(const char *ProgName) {
|
|||||||
bool Binary = false;
|
bool Binary = false;
|
||||||
switch (FileType) {
|
switch (FileType) {
|
||||||
case TargetMachine::AssemblyFile:
|
case TargetMachine::AssemblyFile:
|
||||||
if (MArch->Name[0] == 'c') {
|
if (TargetName[0] == 'c') {
|
||||||
if (MArch->Name[1] == 0)
|
if (TargetName[1] == 0)
|
||||||
OutputFilename += ".cbe.c";
|
OutputFilename += ".cbe.c";
|
||||||
else if (MArch->Name[1] == 'p' && MArch->Name[2] == 'p')
|
else if (TargetName[1] == 'p' && TargetName[2] == 'p')
|
||||||
OutputFilename += ".cpp";
|
OutputFilename += ".cpp";
|
||||||
else
|
else
|
||||||
OutputFilename += ".s";
|
OutputFilename += ".s";
|
||||||
@ -248,10 +249,13 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Allocate target machine. First, check whether the user has
|
// Allocate target machine. First, check whether the user has
|
||||||
// explicitly specified an architecture to compile for.
|
// explicitly specified an architecture to compile for.
|
||||||
if (MArch == 0) {
|
const Target *TheTarget;
|
||||||
|
if (MArch) {
|
||||||
|
TheTarget = &MArch->TheTarget;
|
||||||
|
} else {
|
||||||
std::string Err;
|
std::string Err;
|
||||||
MArch = TargetMachineRegistry::getClosestStaticTargetForModule(mod, Err);
|
TheTarget = TargetRegistry::getClosestStaticTargetForModule(mod, Err);
|
||||||
if (MArch == 0) {
|
if (TheTarget == 0) {
|
||||||
std::cerr << argv[0] << ": error auto-selecting target for module '"
|
std::cerr << argv[0] << ": error auto-selecting target for module '"
|
||||||
<< Err << "'. Please use the -march option to explicitly "
|
<< Err << "'. Please use the -march option to explicitly "
|
||||||
<< "pick a target.\n";
|
<< "pick a target.\n";
|
||||||
@ -269,12 +273,13 @@ int main(int argc, char **argv) {
|
|||||||
FeaturesStr = Features.getString();
|
FeaturesStr = Features.getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::auto_ptr<TargetMachine> target(MArch->CtorFn(mod, FeaturesStr));
|
std::auto_ptr<TargetMachine>
|
||||||
|
target(TheTarget->createTargetMachine(mod, FeaturesStr));
|
||||||
assert(target.get() && "Could not allocate target machine!");
|
assert(target.get() && "Could not allocate target machine!");
|
||||||
TargetMachine &Target = *target.get();
|
TargetMachine &Target = *target.get();
|
||||||
|
|
||||||
// Figure out where we are going to send the output...
|
// Figure out where we are going to send the output...
|
||||||
formatted_raw_ostream *Out = GetOutputStream(argv[0]);
|
formatted_raw_ostream *Out = GetOutputStream(TheTarget->getName(), argv[0]);
|
||||||
if (Out == 0) return 1;
|
if (Out == 0) return 1;
|
||||||
|
|
||||||
CodeGenOpt::Level OLvl = CodeGenOpt::Default;
|
CodeGenOpt::Level OLvl = CodeGenOpt::Default;
|
||||||
|
Loading…
Reference in New Issue
Block a user