Include the Target& in the TargetMachineRegisterEntry.

llvm-svn: 75772
This commit is contained in:
Daniel Dunbar 2009-07-15 11:23:49 +00:00
parent 50859c907a
commit 95b534f80e
2 changed files with 8 additions and 6 deletions

View File

@ -23,9 +23,11 @@
namespace llvm { namespace llvm {
class Module; class Module;
class Target;
class TargetMachine; class TargetMachine;
struct TargetMachineRegistryEntry { struct TargetMachineRegistryEntry {
const Target &TheTarget;
const char *Name; const char *Name;
const char *ShortDesc; const char *ShortDesc;
TargetMachine *(*CtorFn)(const Module &, const std::string &); TargetMachine *(*CtorFn)(const Module &, const std::string &);
@ -33,12 +35,12 @@ namespace llvm {
unsigned (*JITMatchQualityFn)(); unsigned (*JITMatchQualityFn)();
public: public:
TargetMachineRegistryEntry(const char *N, const char *SD, TargetMachineRegistryEntry(const Target &T, const char *N, const char *SD,
TargetMachine *(*CF)(const Module &, const std::string &), TargetMachine *(*CF)(const Module &, const std::string &),
unsigned (*MMF)(const Module &M), unsigned (*MMF)(const Module &M),
unsigned (*JMF)()) unsigned (*JMF)())
: Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF), : TheTarget(T), Name(N), ShortDesc(SD), CtorFn(CF),
JITMatchQualityFn(JMF) {} ModuleMatchQualityFn(MMF), JITMatchQualityFn(JMF) {}
}; };
template<> template<>
@ -78,7 +80,7 @@ namespace llvm {
template<class TargetMachineImpl> template<class TargetMachineImpl>
struct RegisterTarget { struct RegisterTarget {
RegisterTarget(Target &T, const char *Name, const char *ShortDesc) RegisterTarget(Target &T, const char *Name, const char *ShortDesc)
: Entry(Name, ShortDesc, &Allocator, : Entry(T, Name, ShortDesc, &Allocator,
&TargetMachineImpl::getModuleMatchQuality, &TargetMachineImpl::getModuleMatchQuality,
&TargetMachineImpl::getJITMatchQuality), &TargetMachineImpl::getJITMatchQuality),
Node(Entry) { Node(Entry) {

View File

@ -28,7 +28,7 @@ TargetMachineRegistry::getClosestStaticTargetForModule(const Module &M,
if (!T) if (!T)
return 0; return 0;
// FIXME: Temporary hack, please remove. // FIXME: Temporary hack, please remove.
return new TargetMachineRegistry::entry(T->Name, T->ShortDesc, return new TargetMachineRegistry::entry(*T, T->Name, T->ShortDesc,
T->TargetMachineCtorFn, T->TargetMachineCtorFn,
T->ModuleMatchQualityFn, T->ModuleMatchQualityFn,
T->JITMatchQualityFn); T->JITMatchQualityFn);
@ -43,7 +43,7 @@ TargetMachineRegistry::getClosestTargetForJIT(std::string &Error) {
if (!T) if (!T)
return 0; return 0;
// FIXME: Temporary hack, please remove. // FIXME: Temporary hack, please remove.
return new TargetMachineRegistry::entry(T->Name, T->ShortDesc, return new TargetMachineRegistry::entry(*T, T->Name, T->ShortDesc,
T->TargetMachineCtorFn, T->TargetMachineCtorFn,
T->ModuleMatchQualityFn, T->ModuleMatchQualityFn,
T->JITMatchQualityFn); T->JITMatchQualityFn);