Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===- llvm/CodeGen/RegAllocRegistry.h --------------------------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 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 | |
| 19 | namespace llvm { |
| 20 | |
| 21 | class FunctionPass; |
| 22 | |
| 23 | //===----------------------------------------------------------------------===// |
| 24 | /// |
| 25 | /// RegisterRegAlloc class - Track the registration of register allocators. |
| 26 | /// |
| 27 | //===----------------------------------------------------------------------===// |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 28 | class RegisterRegAlloc : public MachinePassRegistryNode<FunctionPass *(*)()> { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 29 | public: |
| 30 | using FunctionPassCtor = FunctionPass *(*)(); |
| 31 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 32 | static MachinePassRegistry<FunctionPassCtor> Registry; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 33 | |
| 34 | RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C) |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 35 | : MachinePassRegistryNode(N, D, C) { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 36 | 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 Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 50 | static FunctionPassCtor getDefault() { return Registry.getDefault(); } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 51 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 52 | static void setDefault(FunctionPassCtor C) { Registry.setDefault(C); } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 53 | |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame^] | 54 | static void setListener(MachinePassRegistryListener<FunctionPassCtor> *L) { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 55 | Registry.setListener(L); |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | } // end namespace llvm |
| 60 | |
| 61 | #endif // LLVM_CODEGEN_REGALLOCREGISTRY_H |