[PATCH] D55282: CodeGen: Make RegAllocRegistry a template class
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 09:58:41 PST 2018
arsenm created this revision.
arsenm added a reviewer: MatzeB.
Herald added subscribers: tpr, wdng, qcolombet.
Will allow re-using the machinery for independent
sets of register allocators.
This will allow AMDGPU to use separate command line
options for the allocator to use for SGPRs separate
from VGPRs.
https://reviews.llvm.org/D55282
Files:
include/llvm/CodeGen/RegAllocRegistry.h
lib/CodeGen/TargetPassConfig.cpp
Index: lib/CodeGen/TargetPassConfig.cpp
===================================================================
--- lib/CodeGen/TargetPassConfig.cpp
+++ lib/CodeGen/TargetPassConfig.cpp
@@ -1028,10 +1028,6 @@
llvm_unreachable("Invalid optimize-regalloc state");
}
-/// RegisterRegAlloc's global Registry tracks allocator registration.
-MachinePassRegistry<RegisterRegAlloc::FunctionPassCtor>
- RegisterRegAlloc::Registry;
-
/// A dummy default pass factory indicates whether the register allocator is
/// overridden on the command line.
static llvm::once_flag InitializeDefaultRegisterAllocatorFlag;
Index: include/llvm/CodeGen/RegAllocRegistry.h
===================================================================
--- include/llvm/CodeGen/RegAllocRegistry.h
+++ include/llvm/CodeGen/RegAllocRegistry.h
@@ -23,29 +23,30 @@
//===----------------------------------------------------------------------===//
///
-/// RegisterRegAlloc class - Track the registration of register allocators.
+/// RegisterRegAllocBase class - Track the registration of register allocators.
///
//===----------------------------------------------------------------------===//
-class RegisterRegAlloc : public MachinePassRegistryNode<FunctionPass *(*)()> {
+template <class SubClass>
+class RegisterRegAllocBase : public MachinePassRegistryNode<FunctionPass *(*)()> {
public:
using FunctionPassCtor = FunctionPass *(*)();
static MachinePassRegistry<FunctionPassCtor> Registry;
- RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
+ RegisterRegAllocBase(const char *N, const char *D, FunctionPassCtor C)
: MachinePassRegistryNode(N, D, C) {
Registry.Add(this);
}
- ~RegisterRegAlloc() { Registry.Remove(this); }
+ ~RegisterRegAllocBase() { Registry.Remove(this); }
// Accessors.
- RegisterRegAlloc *getNext() const {
- return (RegisterRegAlloc *)MachinePassRegistryNode::getNext();
+ SubClass *getNext() const {
+ return static_cast<SubClass *>(MachinePassRegistryNode::getNext());
}
- static RegisterRegAlloc *getList() {
- return (RegisterRegAlloc *)Registry.getList();
+ static SubClass *getList() {
+ return static_cast<SubClass *>(Registry.getList());
}
static FunctionPassCtor getDefault() { return Registry.getDefault(); }
@@ -57,6 +58,17 @@
}
};
+class RegisterRegAlloc : public RegisterRegAllocBase<RegisterRegAlloc> {
+public:
+ RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
+ : RegisterRegAllocBase(N, D, C) {}
+};
+
+/// RegisterRegAlloc's global Registry tracks allocator registration.
+template <class T>
+MachinePassRegistry<RegisterRegAlloc::FunctionPassCtor>
+RegisterRegAllocBase<T>::Registry;
+
} // end namespace llvm
#endif // LLVM_CODEGEN_REGALLOCREGISTRY_H
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55282.176662.patch
Type: text/x-patch
Size: 2784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/b1072566/attachment.bin>
More information about the llvm-commits
mailing list