blob: 7077aa30450ba7cc51281fa0072385b9062a8317 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- llvm/CodeGen/RegAllocRegistry.h --------------------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the implementation for register allocator function
10// pass registry (RegisterRegAlloc).
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_REGALLOCREGISTRY_H
15#define LLVM_CODEGEN_REGALLOCREGISTRY_H
16
17#include "llvm/CodeGen/MachinePassRegistry.h"
18
19namespace llvm {
20
21class FunctionPass;
22
23//===----------------------------------------------------------------------===//
24///
25/// RegisterRegAlloc class - Track the registration of register allocators.
26///
27//===----------------------------------------------------------------------===//
Andrew Walbran16937d02019-10-22 13:54:20 +010028class RegisterRegAlloc : public MachinePassRegistryNode<FunctionPass *(*)()> {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010029public:
30 using FunctionPassCtor = FunctionPass *(*)();
31
Andrew Walbran16937d02019-10-22 13:54:20 +010032 static MachinePassRegistry<FunctionPassCtor> Registry;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010033
34 RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
Andrew Walbran16937d02019-10-22 13:54:20 +010035 : MachinePassRegistryNode(N, D, C) {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010036 Registry.Add(this);
37 }
38
39 ~RegisterRegAlloc() { Registry.Remove(this); }
40
41 // Accessors.
42 RegisterRegAlloc *getNext() const {
43 return (RegisterRegAlloc *)MachinePassRegistryNode::getNext();
44 }
45
46 static RegisterRegAlloc *getList() {
47 return (RegisterRegAlloc *)Registry.getList();
48 }
49
Andrew Walbran16937d02019-10-22 13:54:20 +010050 static FunctionPassCtor getDefault() { return Registry.getDefault(); }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010051
Andrew Walbran16937d02019-10-22 13:54:20 +010052 static void setDefault(FunctionPassCtor C) { Registry.setDefault(C); }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010053
Andrew Walbran16937d02019-10-22 13:54:20 +010054 static void setListener(MachinePassRegistryListener<FunctionPassCtor> *L) {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010055 Registry.setListener(L);
56 }
57};
58
59} // end namespace llvm
60
61#endif // LLVM_CODEGEN_REGALLOCREGISTRY_H