Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:33

0001 //===- llvm/CodeGen/RegAllocRegistry.h --------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file contains the implementation for register allocator function
0010 // pass registry (RegisterRegAlloc).
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CODEGEN_REGALLOCREGISTRY_H
0015 #define LLVM_CODEGEN_REGALLOCREGISTRY_H
0016 
0017 #include "llvm/CodeGen/RegAllocCommon.h"
0018 #include "llvm/CodeGen/MachinePassRegistry.h"
0019 
0020 namespace llvm {
0021 
0022 class FunctionPass;
0023 
0024 //===----------------------------------------------------------------------===//
0025 ///
0026 /// RegisterRegAllocBase class - Track the registration of register allocators.
0027 ///
0028 //===----------------------------------------------------------------------===//
0029 template <class SubClass>
0030 class RegisterRegAllocBase : public MachinePassRegistryNode<FunctionPass *(*)()> {
0031 public:
0032   using FunctionPassCtor = FunctionPass *(*)();
0033 
0034   static MachinePassRegistry<FunctionPassCtor> Registry;
0035 
0036   RegisterRegAllocBase(const char *N, const char *D, FunctionPassCtor C)
0037       : MachinePassRegistryNode(N, D, C) {
0038     Registry.Add(this);
0039   }
0040 
0041   ~RegisterRegAllocBase() { Registry.Remove(this); }
0042 
0043   // Accessors.
0044   SubClass *getNext() const {
0045     return static_cast<SubClass *>(MachinePassRegistryNode::getNext());
0046   }
0047 
0048   static SubClass *getList() {
0049     return static_cast<SubClass *>(Registry.getList());
0050   }
0051 
0052   static FunctionPassCtor getDefault() { return Registry.getDefault(); }
0053 
0054   static void setDefault(FunctionPassCtor C) { Registry.setDefault(C); }
0055 
0056   static void setListener(MachinePassRegistryListener<FunctionPassCtor> *L) {
0057     Registry.setListener(L);
0058   }
0059 };
0060 
0061 class RegisterRegAlloc : public RegisterRegAllocBase<RegisterRegAlloc> {
0062 public:
0063   RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
0064     : RegisterRegAllocBase(N, D, C) {}
0065 };
0066 
0067 /// RegisterRegAlloc's global Registry tracks allocator registration.
0068 template <class T>
0069 MachinePassRegistry<typename RegisterRegAllocBase<T>::FunctionPassCtor>
0070 RegisterRegAllocBase<T>::Registry;
0071 
0072 } // end namespace llvm
0073 
0074 #endif // LLVM_CODEGEN_REGALLOCREGISTRY_H