Switch some obvious clients to using the new TargetRegistry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75767 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-07-15 10:05:03 +00:00
parent e0bda7df1a
commit dec9803b69
3 changed files with 17 additions and 16 deletions

View File

@ -30,9 +30,10 @@
#include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/CodeGen/IntrinsicLowering.h"
#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar.h"
#include "llvm/Target/TargetMachineRegistry.h"
#include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachineRegistry.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Support/CallSite.h" #include "llvm/Support/CallSite.h"
#include "llvm/Support/CFG.h" #include "llvm/Support/CFG.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
@ -3187,27 +3188,27 @@ std::string CWriter::InterpretASMConstraint(InlineAsm::ConstraintInfo& c) {
const char *const *table = 0; const char *const *table = 0;
//Grab the translation table from TargetAsmInfo if it exists // Grab the translation table from TargetAsmInfo if it exists.
if (!TAsm) { if (!TAsm) {
std::string E; std::string E;
const TargetMachineRegistry::entry* Match = const Target *Match =
TargetMachineRegistry::getClosestStaticTargetForModule(*TheModule, E); TargetRegistry::getClosestStaticTargetForModule(*TheModule, E);
if (Match) { if (Match) {
//Per platform Target Machines don't exist, so create it // Per platform Target Machines don't exist, so create it;
// this must be done only once // this must be done only once.
const TargetMachine* TM = Match->CtorFn(*TheModule, ""); const TargetMachine* TM = Match->createTargetMachine(*TheModule, "");
TAsm = TM->getTargetAsmInfo(); TAsm = TM->getTargetAsmInfo();
} }
} }
if (TAsm) if (TAsm)
table = TAsm->getAsmCBE(); table = TAsm->getAsmCBE();
//Search the translation table if it exists // Search the translation table if it exists.
for (int i = 0; table && table[i]; i += 2) for (int i = 0; table && table[i]; i += 2)
if (c.Codes[0] == table[i]) if (c.Codes[0] == table[i])
return table[i+1]; return table[i+1];
//default is identity // Default is identity.
return c.Codes[0]; return c.Codes[0];
} }

View File

@ -328,9 +328,9 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
if ( _target == NULL ) { if ( _target == NULL ) {
// create target machine from info for merged modules // create target machine from info for merged modules
Module* mergedModule = _linker.getModule(); Module* mergedModule = _linker.getModule();
const TargetMachineRegistry::entry* march = const Target *march =
TargetMachineRegistry::getClosestStaticTargetForModule( TargetRegistry::getClosestStaticTargetForModule(*mergedModule,
*mergedModule, errMsg); errMsg);
if ( march == NULL ) if ( march == NULL )
return true; return true;
@ -351,7 +351,7 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
// construct LTModule, hand over ownership of module and target // construct LTModule, hand over ownership of module and target
std::string FeatureStr = std::string FeatureStr =
getFeatureString(_linker.getModule()->getTargetTriple().c_str()); getFeatureString(_linker.getModule()->getTargetTriple().c_str());
_target = march->CtorFn(*mergedModule, FeatureStr.c_str()); _target = march->createTargetMachine(*mergedModule, FeatureStr.c_str());
} }
return false; return false;
} }

View File

@ -147,15 +147,15 @@ LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
if ( !m ) if ( !m )
return NULL; return NULL;
// find machine architecture for this module // find machine architecture for this module
const TargetMachineRegistry::entry* march = const Target* march =
TargetMachineRegistry::getClosestStaticTargetForModule(*m, errMsg); TargetRegistry::getClosestStaticTargetForModule(*m, errMsg);
if ( march == NULL ) if ( march == NULL )
return NULL; return NULL;
// construct LTModule, hand over ownership of module and target // construct LTModule, hand over ownership of module and target
std::string FeatureStr = getFeatureString(m->getTargetTriple().c_str()); std::string FeatureStr = getFeatureString(m->getTargetTriple().c_str());
TargetMachine* target = march->CtorFn(*m, FeatureStr); TargetMachine* target = march->createTargetMachine(*m, FeatureStr);
return new LTOModule(m.take(), target); return new LTOModule(m.take(), target);
} }