1 //===- AArch64GenRegisterBankInfo.def
----------------------------*- C
++ -*-==//
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
7 //===----------------------------------------------------------------------===//
9 /// This file defines all the static objects used by AArch64RegisterBankInfo.
10 /// \todo This should be generated by TableGen.
11 //===----------------------------------------------------------------------===//
14 RegisterBankInfo
::PartialMapping AArch64GenRegisterBankInfo
::PartMappings
[]{
15 /* StartIdx
, Length
, RegBank
*/
16 // 0: FPR
16-bit value.
17 {0, 16, AArch64
::FPRRegBank
},
18 // 1: FPR
32-bit value.
19 {0, 32, AArch64
::FPRRegBank
},
20 // 2: FPR
64-bit value.
21 {0, 64, AArch64
::FPRRegBank
},
22 // 3: FPR
128-bit value.
23 {0, 128, AArch64
::FPRRegBank
},
24 // 4: FPR
256-bit value.
25 {0, 256, AArch64
::FPRRegBank
},
26 // 5: FPR
512-bit value.
27 {0, 512, AArch64
::FPRRegBank
},
28 // 6: GPR
32-bit value.
29 {0, 32, AArch64
::GPRRegBank
},
30 // 7: GPR
64-bit value.
31 {0, 64, AArch64
::GPRRegBank
},
35 RegisterBankInfo
::ValueMapping AArch64GenRegisterBankInfo
::ValMappings
[]{
36 /* BreakDown
, NumBreakDowns
*/
39 // 3-operands
instructions (all binary operations should end up with one of
41 // 1: FPR
16-bit value.
<-- This must match First3OpsIdx.
42 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR16
- PMI_Min
], 1},
43 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR16
- PMI_Min
], 1},
44 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR16
- PMI_Min
], 1},
45 // 4: FPR
32-bit value.
<-- This must match First3OpsIdx.
46 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR32
- PMI_Min
], 1},
47 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR32
- PMI_Min
], 1},
48 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR32
- PMI_Min
], 1},
49 // 7: FPR
64-bit value.
50 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR64
- PMI_Min
], 1},
51 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR64
- PMI_Min
], 1},
52 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR64
- PMI_Min
], 1},
53 // 10: FPR
128-bit value.
54 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR128
- PMI_Min
], 1},
55 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR128
- PMI_Min
], 1},
56 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR128
- PMI_Min
], 1},
57 // 13: FPR
256-bit value.
58 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR256
- PMI_Min
], 1},
59 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR256
- PMI_Min
], 1},
60 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR256
- PMI_Min
], 1},
61 // 16: FPR
512-bit value.
62 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR512
- PMI_Min
], 1},
63 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR512
- PMI_Min
], 1},
64 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR512
- PMI_Min
], 1},
65 // 19: GPR
32-bit value.
66 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR32
- PMI_Min
], 1},
67 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR32
- PMI_Min
], 1},
68 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR32
- PMI_Min
], 1},
69 // 22: GPR
64-bit value.
<-- This must match Last3OpsIdx.
70 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR64
- PMI_Min
], 1},
71 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR64
- PMI_Min
], 1},
72 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR64
- PMI_Min
], 1},
73 // Cross register bank copies.
74 // 25: FPR
16-bit value to GPR
16-bit.
<-- This must match
75 // FirstCrossRegCpyIdx.
76 // Note
: This is the kind of copy we see with physical registers.
77 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR16
- PMI_Min
], 1},
78 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR32
- PMI_Min
], 1},
79 // 27: FPR
32-bit value to GPR
32-bit value.
80 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR32
- PMI_Min
], 1},
81 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR32
- PMI_Min
], 1},
82 // 29: FPR
64-bit value to GPR
64-bit value.
83 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR64
- PMI_Min
], 1},
84 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR64
- PMI_Min
], 1},
85 // 31: FPR
128-bit value to GPR
128-bit
value (invalid
)
88 // 33: FPR
256-bit value to GPR
256-bit
value (invalid
)
91 // 35: FPR
512-bit value to GPR
512-bit
value (invalid
)
94 // 37: GPR
32-bit value to FPR
32-bit value.
95 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR32
- PMI_Min
], 1},
96 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR32
- PMI_Min
], 1},
97 // 39: GPR
64-bit value to FPR
64-bit value.
<-- This must match
98 // LastCrossRegCpyIdx.
99 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_GPR64
- PMI_Min
], 1},
100 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR64
- PMI_Min
], 1},
101 // 41: FPExt
: 16 to
32.
<-- This must match FPExt16To32Idx.
102 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR32
- PMI_Min
], 1},
103 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR16
- PMI_Min
], 1},
104 // 43: FPExt
: 16 to
32.
<-- This must match FPExt16To64Idx.
105 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR64
- PMI_Min
], 1},
106 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR16
- PMI_Min
], 1},
107 // 45: FPExt
: 32 to
64.
<-- This must match FPExt32To64Idx.
108 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR64
- PMI_Min
], 1},
109 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR32
- PMI_Min
], 1},
110 // 47: FPExt vector
: 64 to
128.
<-- This must match FPExt64To128Idx.
111 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR128
- PMI_Min
], 1},
112 {&AArch64GenRegisterBankInfo
::PartMappings
[PMI_FPR64
- PMI_Min
], 1},
115 bool AArch64GenRegisterBankInfo
::checkPartialMap(unsigned Idx
,
116 unsigned ValStartIdx
,
118 const RegisterBank
&RB
) {
119 const PartialMapping
&Map
= PartMappings
[Idx
- PartialMappingIdx
::PMI_Min
];
120 return Map.StartIdx
== ValStartIdx
&& Map.Length
== ValLength
&&
124 bool AArch64GenRegisterBankInfo
::checkValueMapImpl(unsigned Idx
,
125 unsigned FirstInBank
,
128 unsigned PartialMapBaseIdx
= Idx
- PartialMappingIdx
::PMI_Min
;
129 const ValueMapping
&Map
=
130 AArch64GenRegisterBankInfo
::getValueMapping((PartialMappingIdx
)FirstInBank
, Size
)[Offset
];
131 return Map.BreakDown
== &PartMappings
[PartialMapBaseIdx
] &&
132 Map.NumBreakDowns
== 1;
135 bool AArch64GenRegisterBankInfo
::checkPartialMappingIdx(
136 PartialMappingIdx FirstAlias
, PartialMappingIdx LastAlias
,
137 ArrayRef
<PartialMappingIdx
> Order
) {
138 if (Order.
front() != FirstAlias
)
140 if (Order.
back() != LastAlias
)
142 if (Order.
front() > Order.
back())
145 PartialMappingIdx Previous
= Order.
front();
147 for (const auto
&Current
: Order
) {
152 if (Previous
+ 1 != Current
)
159 unsigned AArch64GenRegisterBankInfo
::getRegBankBaseIdxOffset(unsigned RBIdx
,
161 if (RBIdx
== PMI_FirstGPR
) {
168 if (RBIdx
== PMI_FirstFPR
) {
186 const RegisterBankInfo
::ValueMapping
*
187 AArch64GenRegisterBankInfo
::getValueMapping(PartialMappingIdx RBIdx
,
189 assert(RBIdx
!= PartialMappingIdx
::PMI_None
&& "No mapping needed for that");
190 unsigned BaseIdxOffset
= getRegBankBaseIdxOffset(RBIdx
, Size
);
191 if (BaseIdxOffset
== -1u)
192 return
&ValMappings
[InvalidIdx
];
194 unsigned ValMappingIdx
=
195 First3OpsIdx
+ (RBIdx
- PartialMappingIdx
::PMI_Min
+ BaseIdxOffset
) *
196 ValueMappingIdx
::DistanceBetweenRegBanks
;
197 assert(ValMappingIdx
>= First3OpsIdx
&& ValMappingIdx
<= Last3OpsIdx
&&
198 "Mapping out of bound");
200 return
&ValMappings
[ValMappingIdx
];
203 AArch64GenRegisterBankInfo
::PartialMappingIdx
204 AArch64GenRegisterBankInfo
::BankIDToCopyMapIdx
[]{
210 const RegisterBankInfo
::ValueMapping
*
211 AArch64GenRegisterBankInfo
::getCopyMapping(unsigned DstBankID
,
212 unsigned SrcBankID
, unsigned Size
) {
213 assert(DstBankID
< AArch64
::NumRegisterBanks
&& "Invalid bank ID");
214 assert(SrcBankID
< AArch64
::NumRegisterBanks
&& "Invalid bank ID");
215 PartialMappingIdx DstRBIdx
= BankIDToCopyMapIdx
[DstBankID
];
216 PartialMappingIdx SrcRBIdx
= BankIDToCopyMapIdx
[SrcBankID
];
217 assert(DstRBIdx
!= PMI_None
&& "No such mapping");
218 assert(SrcRBIdx
!= PMI_None
&& "No such mapping");
220 if (DstRBIdx
== SrcRBIdx
)
221 return
getValueMapping(DstRBIdx
, Size
);
223 assert(Size
<= 64 && "GPR cannot handle that size");
224 unsigned ValMappingIdx
=
225 FirstCrossRegCpyIdx
+
226 (DstRBIdx
- PMI_Min
+ getRegBankBaseIdxOffset(DstRBIdx
, Size
)) *
227 ValueMappingIdx
::DistanceBetweenCrossRegCpy
;
228 assert(ValMappingIdx
>= FirstCrossRegCpyIdx
&&
229 ValMappingIdx
<= LastCrossRegCpyIdx
&& "Mapping out of bound");
230 return
&ValMappings
[ValMappingIdx
];
233 const RegisterBankInfo
::ValueMapping
*
234 AArch64GenRegisterBankInfo
::getFPExtMapping(unsigned DstSize
,
241 // => FPR
16 to FPR
32|
64
242 // => FPR
32 to FPR
64
246 // => FPR
64 to FPR
128
248 // Check that we have been asked sensible sizes.
250 assert((DstSize
== 32 || DstSize
== 64) && "Unexpected half extension");
252 return
&ValMappings
[FPExt16To32Idx
];
253 return
&ValMappings
[FPExt16To64Idx
];
257 assert(DstSize
== 64 && "Unexpected float extension");
258 return
&ValMappings
[FPExt32To64Idx
];
260 assert((SrcSize
== 64 || DstSize
== 128) && "Unexpected vector extension");
261 return
&ValMappings
[FPExt64To128Idx
];
263 } // End llvm namespace.