LLVM  10.0.0svn
RegAllocRegistry.h
Go to the documentation of this file.
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).
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_REGALLOCREGISTRY_H
15 #define LLVM_CODEGEN_REGALLOCREGISTRY_H
16 
18 
19 namespace llvm {
20 
21 class FunctionPass;
22 
23 //===----------------------------------------------------------------------===//
24 ///
25 /// RegisterRegAllocBase class - Track the registration of register allocators.
26 ///
27 //===----------------------------------------------------------------------===//
28 template <class SubClass>
29 class RegisterRegAllocBase : public MachinePassRegistryNode<FunctionPass *(*)()> {
30 public:
32 
34 
35  RegisterRegAllocBase(const char *N, const char *D, FunctionPassCtor C)
36  : MachinePassRegistryNode(N, D, C) {
37  Registry.Add(this);
38  }
39 
40  ~RegisterRegAllocBase() { Registry.Remove(this); }
41 
42  // Accessors.
43  SubClass *getNext() const {
44  return static_cast<SubClass *>(MachinePassRegistryNode::getNext());
45  }
46 
47  static SubClass *getList() {
48  return static_cast<SubClass *>(Registry.getList());
49  }
50 
51  static FunctionPassCtor getDefault() { return Registry.getDefault(); }
52 
53  static void setDefault(FunctionPassCtor C) { Registry.setDefault(C); }
54 
56  Registry.setListener(L);
57  }
58 };
59 
60 class RegisterRegAlloc : public RegisterRegAllocBase<RegisterRegAlloc> {
61 public:
62  RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
63  : RegisterRegAllocBase(N, D, C) {}
64 };
65 
66 /// RegisterRegAlloc's global Registry tracks allocator registration.
67 template <class T>
70 
71 } // end namespace llvm
72 
73 #endif // LLVM_CODEGEN_REGALLOCREGISTRY_H
uint64_t CallInst * C
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void Remove(MachinePassRegistryNode< PassCtorTy > *Node)
Remove - Removes a function pass from the registration list.
RegisterRegAllocBase(const char *N, const char *D, FunctionPassCtor C)
void setDefault(PassCtorTy C)
void setListener(MachinePassRegistryListener< PassCtorTy > *L)
RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
RegisterRegAllocBase class - Track the registration of register allocators.
static void setListener(MachinePassRegistryListener< FunctionPassCtor > *L)
void Add(MachinePassRegistryNode< PassCtorTy > *Node)
Add - Adds a function pass to the registration list.
static MachinePassRegistry< FunctionPassCtor > Registry
RegisterRegAlloc&#39;s global Registry tracks allocator registration.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:284
MachinePassRegistryNode< PassCtorTy > * getList()
static SubClass * getList()
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
MachinePassRegistryNode * getNext() const
#define N
SubClass * getNext() const
MachinePassRegistryNode - Machine pass node stored in registration list.
static void setDefault(FunctionPassCtor C)
static FunctionPassCtor getDefault()