LLVM 19.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, unsigned 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, unsigned 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 only uses and defines FPRs.
124 bool hasFPConstraints(const MachineInstr &MI, const MachineRegisterInfo &MRI,
125 const TargetRegisterInfo &TRI, unsigned Depth = 0) const;
126
127 /// \returns true if \p MI only uses FPRs.
128 bool onlyUsesFP(const MachineInstr &MI, const MachineRegisterInfo &MRI,
129 const TargetRegisterInfo &TRI, unsigned Depth = 0) const;
130
131 /// \returns true if \p MI only defines FPRs.
132 bool onlyDefinesFP(const MachineInstr &MI, const MachineRegisterInfo &MRI,
133 const TargetRegisterInfo &TRI, unsigned Depth = 0) const;
134
135 /// \returns true if the load \p MI is likely loading from a floating-point
136 /// type.
137 bool isLoadFromFPType(const MachineInstr &MI) const;
138
139public:
141
142 unsigned copyCost(const RegisterBank &A, const RegisterBank &B,
143 TypeSize Size) const override;
144
146 LLT) const override;
147
149 getInstrAlternativeMappings(const MachineInstr &MI) const override;
150
151 const InstructionMapping &
152 getInstrMapping(const MachineInstr &MI) const override;
153};
154} // End llvm namespace.
155#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 const RegisterBankInfo::ValueMapping * getValueMapping(PartialMappingIdx RBIdx, unsigned Size)
Get the pointer to the ValueMapping representing the RegisterBank at RBIdx with a size of Size.
static bool checkPartialMappingIdx(PartialMappingIdx FirstAlias, PartialMappingIdx LastAlias, ArrayRef< PartialMappingIdx > Order)
static const RegisterBankInfo::PartialMapping PartMappings[]
static unsigned getRegBankBaseIdxOffset(unsigned RBIdx, unsigned Size)
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 * getCopyMapping(unsigned DstBankID, unsigned SrcBankID, unsigned Size)
Get the pointer to the ValueMapping of the operands of a copy instruction from the SrcBankID register...
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.
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT) const override
Get a register bank that covers RC.
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 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:1209
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:456
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.