1 //===- llvm/CodeGen/RegAllocRegistry.h --------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains the implementation for register allocator function
10 // pass registry (RegisterRegAlloc).
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_REGALLOCREGISTRY_H
15 #define LLVM_CODEGEN_REGALLOCREGISTRY_H
17 #include "llvm/CodeGen/MachinePassRegistry.h"
23 //===----------------------------------------------------------------------===//
25 /// RegisterRegAlloc class - Track the registration of register allocators.
27 //===----------------------------------------------------------------------===//
28 class RegisterRegAlloc
: public MachinePassRegistryNode
<FunctionPass
*(*)()> {
30 using FunctionPassCtor
= FunctionPass
*(*)();
32 static MachinePassRegistry
<FunctionPassCtor
> Registry
;
34 RegisterRegAlloc(const char *N
, const char *D
, FunctionPassCtor C
)
35 : MachinePassRegistryNode(N
, D
, C
) {
39 ~RegisterRegAlloc() { Registry
.Remove(this); }
42 RegisterRegAlloc
*getNext() const {
43 return (RegisterRegAlloc
*)MachinePassRegistryNode::getNext();
46 static RegisterRegAlloc
*getList() {
47 return (RegisterRegAlloc
*)Registry
.getList();
50 static FunctionPassCtor
getDefault() { return Registry
.getDefault(); }
52 static void setDefault(FunctionPassCtor C
) { Registry
.setDefault(C
); }
54 static void setListener(MachinePassRegistryListener
<FunctionPassCtor
> *L
) {
55 Registry
.setListener(L
);
59 } // end namespace llvm
61 #endif // LLVM_CODEGEN_REGALLOCREGISTRY_H