LLVM 20.0.0git
AArch64RegisterBankInfo.h
Go to the documentation of this file.
1//===- AArch64RegisterBankInfo -----------------------------------*- 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/// \file
9/// This file declares the targeting of the RegisterBankInfo class for AArch64.
10/// \todo This should be generated by TableGen.
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64REGISTERBANKINFO_H
14#define LLVM_LIB_TARGET_AARCH64_AARCH64REGISTERBANKINFO_H
15
18
19#define GET_REGBANK_DECLARATIONS
20#include "AArch64GenRegisterBank.inc"
21
22namespace llvm {
23
24class TargetRegisterInfo;
25
27protected:
44 };
45
49
63 };
64
65 static bool checkPartialMap(unsigned Idx, unsigned ValStartIdx,
66 unsigned ValLength, const RegisterBank &RB);
67 static bool checkValueMapImpl(unsigned Idx, unsigned FirstInBank,
68 unsigned Size, unsigned Offset);
70 PartialMappingIdx LastAlias,
72
73 static unsigned getRegBankBaseIdxOffset(unsigned RBIdx, TypeSize Size);
74
75 /// Get the pointer to the ValueMapping representing the RegisterBank
76 /// at \p RBIdx with a size of \p Size.
77 ///
78 /// The returned mapping works for instructions with the same kind of
79 /// operands for up to 3 operands.
80 ///
81 /// \pre \p RBIdx != PartialMappingIdx::None
84
85 /// Get the pointer to the ValueMapping of the operands of a copy
86 /// instruction from the \p SrcBankID register bank to the \p DstBankID
87 /// register bank with a size of \p Size.
89 getCopyMapping(unsigned DstBankID, unsigned SrcBankID, TypeSize Size);
90
91 /// Get the instruction mapping for G_FPEXT.
92 ///
93 /// \pre (DstSize, SrcSize) pair is one of the following:
94 /// (32, 16), (64, 16), (64, 32), (128, 64)
95 ///
96 /// \return An InstructionMapping with statically allocated OperandsMapping.
98 getFPExtMapping(unsigned DstSize, unsigned SrcSize);
99
100#define GET_TARGET_REGBANK_CLASS
101#include "AArch64GenRegisterBank.inc"
102};
103
104/// This class provides the information for the target register banks.
106 /// See RegisterBankInfo::applyMapping.
107 void applyMappingImpl(MachineIRBuilder &Builder,
108 const OperandsMapper &OpdMapper) const override;
109
110 /// Get an instruction mapping where all the operands map to
111 /// the same register bank and have similar size.
112 ///
113 /// \pre MI.getNumOperands() <= 3
114 ///
115 /// \return An InstructionMappings with a statically allocated
116 /// OperandsMapping.
117 const InstructionMapping &
118 getSameKindOfOperandsMapping(const MachineInstr &MI) const;
119
120 /// Maximum recursion depth for hasFPConstraints.
121 const unsigned MaxFPRSearchDepth = 2;
122
123 /// \returns true if \p MI is a PHI that its def is used by
124 /// any instruction that onlyUsesFP.
125 bool isPHIWithFPContraints(const MachineInstr &MI,
127 const TargetRegisterInfo &TRI,
128 unsigned Depth = 0) const;
129
130 /// \returns true if \p MI only uses and defines FPRs.
131 bool hasFPConstraints(const MachineInstr &MI, const MachineRegisterInfo &MRI,
132 const TargetRegisterInfo &TRI, unsigned Depth = 0) const;
133
134 /// \returns true if \p MI only uses FPRs.
135 bool onlyUsesFP(const MachineInstr &MI, const MachineRegisterInfo &MRI,
136 const TargetRegisterInfo &TRI, unsigned Depth = 0) const;
137
138 /// \returns true if \p MI only defines FPRs.
139 bool onlyDefinesFP(const MachineInstr &MI, const MachineRegisterInfo &MRI,
140 const TargetRegisterInfo &TRI, unsigned Depth = 0) const;
141
142 /// \returns true if the load \p MI is likely loading from a floating-point
143 /// type.
144 bool isLoadFromFPType(const MachineInstr &MI) const;
145
146public:
148
149 unsigned copyCost(const RegisterBank &A, const RegisterBank &B,
150 TypeSize Size) const override;
151
153 LLT Ty) const override;
154
156 getInstrAlternativeMappings(const MachineInstr &MI) const override;
157
158 const InstructionMapping &
159 getInstrMapping(const MachineInstr &MI) const override;
160};
161} // End llvm namespace.
162#endif
unsigned const MachineRegisterInfo * MRI
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint64_t Size
Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...
IRTranslator LLVM IR MI
unsigned const TargetRegisterInfo * TRI
static unsigned getRegBankBaseIdxOffset(unsigned RBIdx, TypeSize Size)
static const RegisterBankInfo::ValueMapping * getCopyMapping(unsigned DstBankID, unsigned SrcBankID, TypeSize Size)
Get the pointer to the ValueMapping of the operands of a copy instruction from the SrcBankID register...
static bool checkPartialMappingIdx(PartialMappingIdx FirstAlias, PartialMappingIdx LastAlias, ArrayRef< PartialMappingIdx > Order)
static const RegisterBankInfo::PartialMapping PartMappings[]
static const RegisterBankInfo::ValueMapping * getFPExtMapping(unsigned DstSize, unsigned SrcSize)
Get the instruction mapping for G_FPEXT.
static bool checkValueMapImpl(unsigned Idx, unsigned FirstInBank, unsigned Size, unsigned Offset)
static const PartialMappingIdx BankIDToCopyMapIdx[]
static const RegisterBankInfo::ValueMapping * getValueMapping(PartialMappingIdx RBIdx, TypeSize Size)
Get the pointer to the ValueMapping representing the RegisterBank at RBIdx with a size of Size.
static const RegisterBankInfo::ValueMapping ValMappings[]
static bool checkPartialMap(unsigned Idx, unsigned ValStartIdx, unsigned ValLength, const RegisterBank &RB)
This class provides the information for the target register banks.
InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const override
Get the alternative mappings for MI.
unsigned copyCost(const RegisterBank &A, const RegisterBank &B, TypeSize Size) const override
Get the cost of a copy from B to A, or put differently, get the cost of A = COPY B.
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT Ty) const override
Get a register bank that covers RC.
const InstructionMapping & getInstrMapping(const MachineInstr &MI) const override
Get the mapping of the different operands of MI on the register bank.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Helper class to build MachineInstr.
Representation of each machine instruction.
Definition: MachineInstr.h:69
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Helper class that represents how the value of an instruction may be mapped and what is the related co...
Helper class used to get/create the virtual registers that will be used to replace the MachineOperand...
Holds all the information related to register banks.
This class implements the register bank concept.
Definition: RegisterBank.h:28
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
Helper struct that represents how a value is partially mapped into a register.
Helper struct that represents how a value is mapped through different register banks.