[llvm-commits] CVS: llvm/include/llvm/Target/TargetMachineRegistry.h
Chris Lattner
lattner at cs.uiuc.edu
Sun Jul 11 01:04:11 PDT 2004
Changes in directory llvm/include/llvm/Target:
TargetMachineRegistry.h updated: 1.2 -> 1.3
---
Log message:
Add a new listener class for things that want to be informed about new
targets that are loaded
---
Diffs of the changes: (+21 -6)
Index: llvm/include/llvm/Target/TargetMachineRegistry.h
diff -u llvm/include/llvm/Target/TargetMachineRegistry.h:1.2 llvm/include/llvm/Target/TargetMachineRegistry.h:1.3
--- llvm/include/llvm/Target/TargetMachineRegistry.h:1.2 Sat Jul 10 22:59:46 2004
+++ llvm/include/llvm/Target/TargetMachineRegistry.h Sun Jul 11 01:02:59 2004
@@ -58,11 +58,7 @@
protected:
Entry(const char *N, const char *SD,
TargetMachine *(*CF)(const Module &, IntrinsicLowering*),
- unsigned (*MMF)(const Module &M), unsigned (*JMF)())
- : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF),
- JITMatchQualityFn(JMF), Next(List) {
- List = this;
- }
+ unsigned (*MMF)(const Module &M), unsigned (*JMF)());
private:
const Entry *Next; // Next entry in the linked list.
};
@@ -89,10 +85,24 @@
}
};
+ /// TargetRegistrationListener - This class allows code to listen for targets
+ /// that are dynamically registered, and be notified of it when they are.
+ class TargetRegistrationListener {
+ TargetRegistrationListener **Prev, *Next;
+ public:
+ TargetRegistrationListener();
+ virtual ~TargetRegistrationListener();
+
+ TargetRegistrationListener *getNext() const { return Next; }
+
+ virtual void targetRegistered(const TargetMachineRegistry::Entry *E) = 0;
+ };
+
+
//===--------------------------------------------------------------------===//
/// TargetNameParser - This option can be used to provide a command line
/// option to choose among the various registered targets (commonly -march).
- class TargetNameParser :
+ class TargetNameParser : public TargetRegistrationListener,
public cl::parser<const TargetMachineRegistry::Entry*> {
public:
void initialize(cl::Option &O) {
@@ -102,6 +112,11 @@
std::make_pair(E, E->ShortDesc)));
cl::parser<const TargetMachineRegistry::Entry*>::initialize(O);
}
+
+ virtual void targetRegistered(const TargetMachineRegistry::Entry *E) {
+ Values.push_back(std::make_pair(E->Name,
+ std::make_pair(E, E->ShortDesc)));
+ }
};
}
More information about the llvm-commits
mailing list