xref: /aosp_15_r20/external/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===- AArch64RegisterBankInfo -----------------------------------*- C++ -*-==//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker /// \file
10*9880d681SAndroid Build Coastguard Worker /// This file declares the targeting of the RegisterBankInfo class for AArch64.
11*9880d681SAndroid Build Coastguard Worker /// \todo This should be generated by TableGen.
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64REGISTERBANKINFO_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_AARCH64_AARCH64REGISTERBANKINFO_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
18*9880d681SAndroid Build Coastguard Worker 
19*9880d681SAndroid Build Coastguard Worker namespace llvm {
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker class TargetRegisterInfo;
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker namespace AArch64 {
24*9880d681SAndroid Build Coastguard Worker enum {
25*9880d681SAndroid Build Coastguard Worker   GPRRegBankID = 0, /// General Purpose Registers: W, X.
26*9880d681SAndroid Build Coastguard Worker   FPRRegBankID = 1, /// Floating Point/Vector Registers: B, H, S, D, Q.
27*9880d681SAndroid Build Coastguard Worker   CCRRegBankID = 2, /// Conditional register: NZCV.
28*9880d681SAndroid Build Coastguard Worker   NumRegisterBanks
29*9880d681SAndroid Build Coastguard Worker };
30*9880d681SAndroid Build Coastguard Worker } // End AArch64 namespace.
31*9880d681SAndroid Build Coastguard Worker 
32*9880d681SAndroid Build Coastguard Worker /// This class provides the information for the target register banks.
33*9880d681SAndroid Build Coastguard Worker class AArch64RegisterBankInfo : public RegisterBankInfo {
34*9880d681SAndroid Build Coastguard Worker   /// See RegisterBankInfo::applyMapping.
35*9880d681SAndroid Build Coastguard Worker   void applyMappingImpl(const OperandsMapper &OpdMapper) const override;
36*9880d681SAndroid Build Coastguard Worker 
37*9880d681SAndroid Build Coastguard Worker public:
38*9880d681SAndroid Build Coastguard Worker   AArch64RegisterBankInfo(const TargetRegisterInfo &TRI);
39*9880d681SAndroid Build Coastguard Worker   /// Get the cost of a copy from \p B to \p A, or put differently,
40*9880d681SAndroid Build Coastguard Worker   /// get the cost of A = COPY B. Since register banks may cover
41*9880d681SAndroid Build Coastguard Worker   /// different size, \p Size specifies what will be the size in bits
42*9880d681SAndroid Build Coastguard Worker   /// that will be copied around.
43*9880d681SAndroid Build Coastguard Worker   ///
44*9880d681SAndroid Build Coastguard Worker   /// \note Since this is a copy, both registers have the same size.
45*9880d681SAndroid Build Coastguard Worker   unsigned copyCost(const RegisterBank &A, const RegisterBank &B,
46*9880d681SAndroid Build Coastguard Worker                     unsigned Size) const override;
47*9880d681SAndroid Build Coastguard Worker 
48*9880d681SAndroid Build Coastguard Worker   /// Get a register bank that covers \p RC.
49*9880d681SAndroid Build Coastguard Worker   ///
50*9880d681SAndroid Build Coastguard Worker   /// \pre \p RC is a user-defined register class (as opposed as one
51*9880d681SAndroid Build Coastguard Worker   /// generated by TableGen).
52*9880d681SAndroid Build Coastguard Worker   ///
53*9880d681SAndroid Build Coastguard Worker   /// \note The mapping RC -> RegBank could be built while adding the
54*9880d681SAndroid Build Coastguard Worker   /// coverage for the register banks. However, we do not do it, because,
55*9880d681SAndroid Build Coastguard Worker   /// at least for now, we only need this information for register classes
56*9880d681SAndroid Build Coastguard Worker   /// that are used in the description of instruction. In other words,
57*9880d681SAndroid Build Coastguard Worker   /// there are just a handful of them and we do not want to waste space.
58*9880d681SAndroid Build Coastguard Worker   ///
59*9880d681SAndroid Build Coastguard Worker   /// \todo This should be TableGen'ed.
60*9880d681SAndroid Build Coastguard Worker   const RegisterBank &
61*9880d681SAndroid Build Coastguard Worker   getRegBankFromRegClass(const TargetRegisterClass &RC) const override;
62*9880d681SAndroid Build Coastguard Worker 
63*9880d681SAndroid Build Coastguard Worker   /// Get the alternative mappings for \p MI.
64*9880d681SAndroid Build Coastguard Worker   /// Alternative in the sense different from getInstrMapping.
65*9880d681SAndroid Build Coastguard Worker   InstructionMappings
66*9880d681SAndroid Build Coastguard Worker   getInstrAlternativeMappings(const MachineInstr &MI) const override;
67*9880d681SAndroid Build Coastguard Worker };
68*9880d681SAndroid Build Coastguard Worker } // End llvm namespace.
69*9880d681SAndroid Build Coastguard Worker #endif
70