/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/RegAllocRegistry.h
Line | Count | Source |
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 | | |
17 | | #include "llvm/CodeGen/MachinePassRegistry.h" |
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: |
31 | | using FunctionPassCtor = FunctionPass *(*)(); |
32 | | |
33 | | static MachinePassRegistry<FunctionPassCtor> Registry; |
34 | | |
35 | | RegisterRegAllocBase(const char *N, const char *D, FunctionPassCtor C) |
36 | 515k | : MachinePassRegistryNode(N, D, C) { |
37 | 515k | Registry.Add(this); |
38 | 515k | } |
39 | | |
40 | 515k | ~RegisterRegAllocBase() { Registry.Remove(this); } |
41 | | |
42 | | // Accessors. |
43 | 412k | SubClass *getNext() const { |
44 | 412k | return static_cast<SubClass *>(MachinePassRegistryNode::getNext()); |
45 | 412k | } |
46 | | |
47 | 103k | static SubClass *getList() { |
48 | 103k | return static_cast<SubClass *>(Registry.getList()); |
49 | 103k | } |
50 | | |
51 | 70.9k | static FunctionPassCtor getDefault() { return Registry.getDefault(); } |
52 | | |
53 | 35.3k | static void setDefault(FunctionPassCtor C) { Registry.setDefault(C); } |
54 | | |
55 | 206k | static void setListener(MachinePassRegistryListener<FunctionPassCtor> *L) { |
56 | 206k | Registry.setListener(L); |
57 | 206k | } |
58 | | }; |
59 | | |
60 | | class RegisterRegAlloc : public RegisterRegAllocBase<RegisterRegAlloc> { |
61 | | public: |
62 | | RegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C) |
63 | 515k | : RegisterRegAllocBase(N, D, C) {} |
64 | | }; |
65 | | |
66 | | /// RegisterRegAlloc's global Registry tracks allocator registration. |
67 | | template <class T> |
68 | | MachinePassRegistry<RegisterRegAlloc::FunctionPassCtor> |
69 | | RegisterRegAllocBase<T>::Registry; |
70 | | |
71 | | } // end namespace llvm |
72 | | |
73 | | #endif // LLVM_CODEGEN_REGALLOCREGISTRY_H |