LLVM 22.0.0git
RegisterBank.h
Go to the documentation of this file.
1//==-- llvm/CodeGen/RegisterBank.h - Register Bank ---------------*- 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/// \file This file declares the API of register banks.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CODEGEN_REGISTERBANK_H
14#define LLVM_CODEGEN_REGISTERBANK_H
15
17#include <cstdint>
18
19namespace llvm {
20// Forward declarations.
22class raw_ostream;
25
26/// This class implements the register bank concept.
27/// Two instances of RegisterBank must have different ID.
28/// This property is enforced by the RegisterBankInfo class.
30private:
31 unsigned ID;
32 unsigned NumRegClasses;
33 const char *Name;
34 const uint32_t *CoveredClasses;
35
36 /// Only the RegisterBankInfo can initialize RegisterBank properly.
37 friend RegisterBankInfo;
38
39public:
40 constexpr RegisterBank(unsigned ID, const char *Name,
41 const uint32_t *CoveredClasses, unsigned NumRegClasses)
42 : ID(ID), NumRegClasses(NumRegClasses), Name(Name),
43 CoveredClasses(CoveredClasses) {}
44
45 /// Get the identifier of this register bank.
46 unsigned getID() const { return ID; }
47
48 /// Get a user friendly name of this register bank.
49 /// Should be used only for debugging purposes.
50 const char *getName() const { return Name; }
51
52 /// Check if this register bank is valid. In other words,
53 /// if it has been properly constructed.
54 ///
55 /// \note This method does not check anything when assertions are disabled.
56 ///
57 /// \return True is the check was successful.
58 LLVM_ABI bool verify(const RegisterBankInfo &RBI,
59 const TargetRegisterInfo &TRI) const;
60
61 /// Check whether this register bank covers \p RC.
62 /// In other words, check if this register bank fully covers
63 /// the registers that \p RC contains.
64 LLVM_ABI bool covers(const TargetRegisterClass &RC) const;
65
66 /// Check whether \p OtherRB is the same as this.
67 LLVM_ABI bool operator==(const RegisterBank &OtherRB) const;
68 bool operator!=(const RegisterBank &OtherRB) const {
69 return !this->operator==(OtherRB);
70 }
71
72 /// Dump the register mask on dbgs() stream.
73 /// The dump is verbose.
74 LLVM_ABI void dump(const TargetRegisterInfo *TRI = nullptr) const;
75
76 /// Print the register mask on OS.
77 /// If IsForDebug is false, then only the name of the register bank
78 /// is printed. Otherwise, all the fields are printing.
79 /// TRI is then used to print the name of the register classes that
80 /// this register bank covers.
81 LLVM_ABI void print(raw_ostream &OS, bool IsForDebug = false,
82 const TargetRegisterInfo *TRI = nullptr) const;
83};
84
85inline raw_ostream &operator<<(raw_ostream &OS, const RegisterBank &RegBank) {
86 RegBank.print(OS);
87 return OS;
88}
89} // End namespace llvm.
90
91#endif
#define LLVM_ABI
Definition Compiler.h:213
Register const TargetRegisterInfo * TRI
ppc ctr loops verify
Holds all the information related to register banks.
This class implements the register bank concept.
constexpr RegisterBank(unsigned ID, const char *Name, const uint32_t *CoveredClasses, unsigned NumRegClasses)
LLVM_ABI void print(raw_ostream &OS, bool IsForDebug=false, const TargetRegisterInfo *TRI=nullptr) const
Print the register mask on OS.
LLVM_ABI void dump(const TargetRegisterInfo *TRI=nullptr) const
Dump the register mask on dbgs() stream.
LLVM_ABI bool covers(const TargetRegisterClass &RC) const
Check whether this register bank covers RC.
const char * getName() const
Get a user friendly name of this register bank.
unsigned getID() const
Get the identifier of this register bank.
bool operator!=(const RegisterBank &OtherRB) const
LLVM_ABI bool operator==(const RegisterBank &OtherRB) const
Check whether OtherRB is the same as this.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)