Recommit [NFC] Better encapsulation of llvm::Optional Storage
[llvm-complete.git] / include / llvm / CodeGen / RegAllocRegistry.h
blob7077aa30450ba7cc51281fa0072385b9062a8317
1 //===- llvm/CodeGen/RegAllocRegistry.h --------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
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"
19 namespace llvm {
21 class FunctionPass;
23 //===----------------------------------------------------------------------===//
24 ///
25 /// RegisterRegAlloc class - Track the registration of register allocators.
26 ///
27 //===----------------------------------------------------------------------===//
28 class RegisterRegAlloc : public MachinePassRegistryNode<FunctionPass *(*)()> {
29 public:
30 using FunctionPassCtor = FunctionPass *(*)();
32 static MachinePassRegistry<FunctionPassCtor> Registry;
34 RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
35 : MachinePassRegistryNode(N, D, C) {
36 Registry.Add(this);
39 ~RegisterRegAlloc() { Registry.Remove(this); }
41 // Accessors.
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