LLVM 22.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;
25class AArch64RegisterInfo;
26
28protected:
45 };
46
50
64 };
65
66 static bool checkPartialMap(unsigned Idx, unsigned ValStartIdx,
67 unsigned ValLength, const RegisterBank &RB);
68 static bool checkValueMapImpl(unsigned Idx, unsigned FirstInBank,
69 unsigned Size, unsigned Offset);
71 PartialMappingIdx LastAlias,
73
74 static unsigned getRegBankBaseIdxOffset(unsigned RBIdx, TypeSize Size);
75
76 /// Get the pointer to the ValueMapping representing the RegisterBank
77 /// at \p RBIdx with a size of \p Size.
78 ///
79 /// The returned mapping works for instructions with the same kind of
80 /// operands for up to 3 operands.
81 ///
82 /// \pre \p RBIdx != PartialMappingIdx::None
85
86 /// Get the pointer to the ValueMapping of the operands of a copy
87 /// instruction from the \p SrcBankID register bank to the \p DstBankID
88 /// register bank with a size of \p Size.
90 getCopyMapping(unsigned DstBankID, unsigned SrcBankID, TypeSize Size);
91
92 /// Get the instruction mapping for G_FPEXT.
93 ///
94 /// \pre (DstSize, SrcSize) pair is one of the following:
95 /// (32, 16), (64, 16), (64, 32), (128, 64)
96 ///
97 /// \return An InstructionMapping with statically allocated OperandsMapping.
99 getFPExtMapping(unsigned DstSize, unsigned SrcSize);
100
101#define GET_TARGET_REGBANK_CLASS
102#include "AArch64GenRegisterBank.inc"
103};
104
105/// This class provides the information for the target register banks.
107 /// See RegisterBankInfo::applyMapping.
108 void applyMappingImpl(MachineIRBuilder &Builder,
109 const OperandsMapper &OpdMapper) const override;
110
111 /// Get an instruction mapping where all the operands map to
112 /// the same register bank and have similar size.
113 ///
114 /// \pre MI.getNumOperands() <= 3
115 ///
116 /// \return An InstructionMappings with a statically allocated
117 /// OperandsMapping.
118 const InstructionMapping &
119 getSameKindOfOperandsMapping(const MachineInstr &MI) const;
120
121 /// Maximum recursion depth for hasFPConstraints.
122 const unsigned MaxFPRSearchDepth = 2;
123
124 /// \returns true if \p MI is a PHI that its def is used by
125 /// any instruction that onlyUsesFP.
126 bool isPHIWithFPConstraints(const MachineInstr &MI,
129 unsigned Depth = 0) const;
130
131 /// \returns true if \p MI only uses and defines FPRs.
132 bool hasFPConstraints(const MachineInstr &MI, const MachineRegisterInfo &MRI,
134 unsigned Depth = 0) const;
135
136 /// \returns true if \p MI only uses FPRs.
137 bool onlyUsesFP(const MachineInstr &MI, const MachineRegisterInfo &MRI,
138 const AArch64RegisterInfo &TRI, unsigned Depth = 0) const;
139
140 /// \returns true if \p MI only defines FPRs.
141 bool onlyDefinesFP(const MachineInstr &MI, const MachineRegisterInfo &MRI,
142 const AArch64RegisterInfo &TRI, unsigned Depth = 0) const;
143
144 /// \returns true if \p MI can take both fpr and gpr uses, but prefers fp.
145 bool prefersFPUse(const MachineInstr &MI, const MachineRegisterInfo &MRI,
146 const AArch64RegisterInfo &TRI, unsigned Depth = 0) const;
147
148 /// \returns true if the load \p MI is likely loading from a floating-point
149 /// type.
150 bool isLoadFromFPType(const MachineInstr &MI) const;
151
152public:
154
155 unsigned copyCost(const RegisterBank &A, const RegisterBank &B,
156 TypeSize Size) const override;
157
159 LLT Ty) const override;
160
162 getInstrAlternativeMappings(const MachineInstr &MI) const override;
163
164 const InstructionMapping &
165 getInstrMapping(const MachineInstr &MI) const override;
166};
167} // End llvm namespace.
168#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
Register 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:72
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:29
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
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:477
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.