[llvm-commits] CVS: llvm/include/llvm/PassSupport.h
Jim Laskey
jlaskey at apple.com
Thu Jul 27 13:05:15 PDT 2006
Changes in directory llvm/include/llvm:
PassSupport.h updated: 1.24 -> 1.25
---
Log message:
Working toward registration of register allocators.
---
Diffs of the changes: (+70 -0)
PassSupport.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 70 insertions(+)
Index: llvm/include/llvm/PassSupport.h
diff -u llvm/include/llvm/PassSupport.h:1.24 llvm/include/llvm/PassSupport.h:1.25
--- llvm/include/llvm/PassSupport.h:1.24 Wed Jul 26 11:18:00 2006
+++ llvm/include/llvm/PassSupport.h Thu Jul 27 15:04:59 2006
@@ -368,6 +368,76 @@
virtual void passEnumerate(const PassInfo *P) {}
};
+
+//===---------------------------------------------------------------------===//
+///
+/// RegisterRegAlloc class - Track the registration of register allocators.
+///
+class RegisterRegAlloc {
+
+public:
+
+ typedef FunctionPass *(*FunctionPassCtor)();
+
+private:
+
+ static RegisterRegAlloc *List; // Linked list of register allocators.
+
+ RegisterRegAlloc *Next; // Next allocation scheme in list.
+ const char *Name; // Name of register allocator.
+ const char *Description; // Description string.
+ FunctionPassCtor Ctor; // Function to construct register
+ // allocator pass.
+public:
+
+ RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
+ : Name(N)
+ , Description(D)
+ , Ctor(C) {
+ Add();
+ }
+
+ ~RegisterRegAlloc() {
+ Remove();
+ }
+
+
+ // Accessors
+ const char *getName() const { return Name; }
+ const char *getDescription() const { return Description; }
+ FunctionPassCtor getCtor() const { return Ctor; }
+
+
+ /// Add - Adds a register allocator to the registration list.
+ ///
+ void Add() {
+ Next = List;
+ List = this;
+ }
+
+
+ /// Remove - Removes a register allocator from the registration list.
+ ///
+ void Remove() {
+ for (RegisterRegAlloc **RA = &List; *RA; RA = &(*RA)->Next) {
+ if (*RA == this) {
+ *RA = Next;
+ break;
+ }
+ }
+ }
+
+
+ /// Find - Finds a register allocator in registration list.
+ ///
+ static FunctionPassCtor Find(const char *N);
+
+#ifndef NDEBUG
+ static void print();
+#endif
+};
+
+
} // End llvm namespace
#endif
More information about the llvm-commits
mailing list