| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef LLVM_CODEGEN_REGALLOCREGISTRY_H |
| 15 |
#define LLVM_CODEGEN_REGALLOCREGISTRY_H |
| 16 |
|
| 17 |
#include "llvm/CodeGen/RegAllocCommon.h" |
| 18 |
#include "llvm/CodeGen/MachinePassRegistry.h" |
| 19 |
|
| 20 |
namespace llvm { |
| 21 |
|
| 22 |
class FunctionPass; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
template <class SubClass> |
| 30 |
class RegisterRegAllocBase : public MachinePassRegistryNode<FunctionPass *(*)()> { |
| 31 |
public: |
| 32 |
using FunctionPassCtor = FunctionPass *(*)(); |
| 33 |
|
| 34 |
static MachinePassRegistry<FunctionPassCtor> Registry; |
| 35 |
|
| 36 |
RegisterRegAllocBase(const char *N, const char *D, FunctionPassCtor C) |
| 37 |
: MachinePassRegistryNode(N, D, C) { |
| 38 |
Registry.Add(this); |
| 39 |
} |
| 40 |
|
| 41 |
~RegisterRegAllocBase() { Registry.Remove(this); } |
| 42 |
|
| 43 |
|
| 44 |
SubClass *getNext() const { |
| 45 |
return static_cast<SubClass *>(MachinePassRegistryNode::getNext()); |
| 46 |
} |
| 47 |
|
| 48 |
static SubClass *getList() { |
| 49 |
return static_cast<SubClass *>(Registry.getList()); |
| 50 |
} |
| 51 |
|
| 52 |
static FunctionPassCtor getDefault() { return Registry.getDefault(); } |
| 53 |
|
| 54 |
static void setDefault(FunctionPassCtor C) { Registry.setDefault(C); } |
| 55 |
|
| 56 |
static void setListener(MachinePassRegistryListener<FunctionPassCtor> *L) { |
| 57 |
Registry.setListener(L); |
| 58 |
} |
| 59 |
}; |
| 60 |
|
| 61 |
class RegisterRegAlloc : public RegisterRegAllocBase<RegisterRegAlloc> { |
| 62 |
public: |
| 63 |
RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C) |
| 64 |
: RegisterRegAllocBase(N, D, C) {} |
| 65 |
}; |
| 66 |
|
| 67 |
|
| 68 |
template <class T> |
| 69 |
MachinePassRegistry<RegisterRegAlloc::FunctionPassCtor> |
| 70 |
RegisterRegAllocBase<T>::Registry; |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
#endif |