1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Target Register and Register Classes Information *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9namespace llvm {
10
11extern const MCRegisterClassStorage<33, 340, 61, 86, 12, 3, 153> AVRMCRegisterClassStorage;
12
13static const MVT::SimpleValueType AVRVTLists[] = {
14 /* 0 */ MVT::i8, MVT::Other,
15 /* 2 */ MVT::i16, MVT::Other,
16};
17
18#ifdef __GNUC__
19#pragma GCC diagnostic push
20#pragma GCC diagnostic ignored "-Woverlength-strings"
21#endif
22static constexpr char AVRSubRegIndexStrings[] = {
23 /* 0 */ "sub_hi\000"
24 /* 7 */ "sub_lo\000"
25};
26#ifdef __GNUC__
27#pragma GCC diagnostic pop
28#endif
29
30
31static constexpr uint32_t AVRSubRegIndexNameOffsets[] = {
32 0,
33 7,
34};
35
36static const TargetRegisterInfo::SubRegCoveredBits AVRSubRegIdxRangeTable[] = {
37 { .Offset: 4294967295, .Size: 4294967295 },
38 { .Offset: 8, .Size: 8 }, // sub_hi
39 { .Offset: 0, .Size: 8 }, // sub_lo
40};
41
42
43static const LaneBitmask AVRSubRegIndexLaneMaskTable[] = {
44 LaneBitmask::getAll(),
45 LaneBitmask(0x0000000000000001), // sub_hi
46 LaneBitmask(0x0000000000000002), // sub_lo
47 };
48
49
50
51static const TargetRegisterInfo::RegClassInfo AVRRegClassInfos[] = {
52 // Mode = 0 (DefaultMode)
53 { .RegSize: 8, .SpillSize: 8, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 0 }, // GPR8
54 { .RegSize: 8, .SpillSize: 8, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 0 }, // GPR8NOZ
55 { .RegSize: 8, .SpillSize: 8, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 0 }, // GPR8lo
56 { .RegSize: 8, .SpillSize: 8, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 0 }, // LD8
57 { .RegSize: 8, .SpillSize: 8, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 0 }, // GPR8NOZ_and_LD8
58 { .RegSize: 8, .SpillSize: 8, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 0 }, // LD8lo
59 { .RegSize: 8, .SpillSize: 8, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 0 }, // CCR
60 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS
61 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSNOZ
62 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSMOVW
63 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSMOVW_and_DREGSNOZ
64 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS_with_sub_hi_in_LD8
65 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSNOZ_and_DREGS_with_sub_hi_in_LD8
66 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS_with_sub_lo_in_LD8
67 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSNOZ_and_DREGS_with_sub_lo_in_LD8
68 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS_with_sub_lo_in_GPR8lo
69 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS_with_sub_hi_in_GPR8lo
70 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DLDREGS
71 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS_with_sub_hi_in_LD8lo
72 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS_with_sub_lo_in_LD8lo
73 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSlo
74 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DLDREGS_and_DREGSNOZ
75 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8
76 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSLD8lo
77 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // IWREGS
78 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSNOZ_and_IWREGS
79 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // PTRREGS
80 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSNOZ_and_PTRREGS
81 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // PTRDISPREGS
82 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGSNOZ_and_PTRDISPREGS
83 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo
84 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // GPRSP
85 { .RegSize: 16, .SpillSize: 16, .SpillAlignment: 8, /*AVRVTLists+*/.VTListOffset: 2 }, // ZREG
86};
87
88static const uint8_t AVRCostPerUseTable[] = {
890, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
90
91
92static const bool AVRInAllocatableClassTable[] = {
93false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, };
94
95
96static const TargetRegisterInfoDesc AVRRegInfoDesc = { // Extra Descriptors
97.CostPerUse: AVRCostPerUseTable, .NumCosts: 1, .InAllocatableClass: AVRInAllocatableClassTable};
98
99unsigned AVRGenRegisterInfo::composeSubRegIndicesImpl(unsigned IdxA, unsigned IdxB) const {
100 static const uint8_t Rows[1][2] = {
101 { 0, 0, },
102 };
103
104 --IdxA; assert(IdxA < 2); (void) IdxA;
105 --IdxB; assert(IdxB < 2);
106 return Rows[0][IdxB];
107}
108
109unsigned AVRGenRegisterInfo::reverseComposeSubRegIndicesImpl(unsigned IdxA, unsigned IdxB) const {
110 static const uint8_t Table[2][2] = {
111 { 0, 0, },
112 { 0, 0, },
113 };
114
115 --IdxA; assert(IdxA < 2);
116 --IdxB; assert(IdxB < 2);
117 return Table[IdxA][IdxB];
118 }
119
120 struct MaskRolOp {
121 LaneBitmask Mask;
122 uint8_t RotateLeft;
123 };
124 static const MaskRolOp LaneMaskComposeSequences[] = {
125 { .Mask: LaneBitmask(0xFFFFFFFFFFFFFFFF), .RotateLeft: 0 }, { .Mask: LaneBitmask::getNone(), .RotateLeft: 0 }, // Sequence 0
126 { .Mask: LaneBitmask(0xFFFFFFFFFFFFFFFF), .RotateLeft: 1 }, { .Mask: LaneBitmask::getNone(), .RotateLeft: 0 } // Sequence 2
127 };
128 static const uint8_t CompositeSequences[] = {
129 0, // to sub_hi
130 2 // to sub_lo
131 };
132
133LaneBitmask AVRGenRegisterInfo::composeSubRegIndexLaneMaskImpl(unsigned IdxA, LaneBitmask LaneMask) const {
134 --IdxA; assert(IdxA < 2 && "Subregister index out of bounds");
135 LaneBitmask Result;
136 for (const MaskRolOp *Ops =
137 &LaneMaskComposeSequences[CompositeSequences[IdxA]];
138 Ops->Mask.any(); ++Ops) {
139 LaneBitmask::Type M = LaneMask.getAsInteger() & Ops->Mask.getAsInteger();
140 if (unsigned S = Ops->RotateLeft)
141 Result |= LaneBitmask((M << S) | (M >> (LaneBitmask::BitWidth - S)));
142 else
143 Result |= LaneBitmask(M);
144 }
145 return Result;
146}
147
148LaneBitmask AVRGenRegisterInfo::reverseComposeSubRegIndexLaneMaskImpl(unsigned IdxA, LaneBitmask LaneMask) const {
149 LaneMask &= getSubRegIndexLaneMask(SubIdx: IdxA);
150 --IdxA; assert(IdxA < 2 && "Subregister index out of bounds");
151 LaneBitmask Result;
152 for (const MaskRolOp *Ops =
153 &LaneMaskComposeSequences[CompositeSequences[IdxA]];
154 Ops->Mask.any(); ++Ops) {
155 LaneBitmask::Type M = LaneMask.getAsInteger();
156 if (unsigned S = Ops->RotateLeft)
157 Result |= LaneBitmask((M >> S) | (M << (LaneBitmask::BitWidth - S)));
158 else
159 Result |= LaneBitmask(M);
160 }
161 return Result;
162}
163
164const TargetRegisterClass *AVRGenRegisterInfo::getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const {
165 static constexpr uint8_t Table[33][2] = {
166 { // GPR8
167 0, // sub_hi
168 0, // sub_lo
169 },
170 { // GPR8NOZ
171 0, // sub_hi
172 0, // sub_lo
173 },
174 { // GPR8lo
175 0, // sub_hi
176 0, // sub_lo
177 },
178 { // LD8
179 0, // sub_hi
180 0, // sub_lo
181 },
182 { // GPR8NOZ_and_LD8
183 0, // sub_hi
184 0, // sub_lo
185 },
186 { // LD8lo
187 0, // sub_hi
188 0, // sub_lo
189 },
190 { // CCR
191 0, // sub_hi
192 0, // sub_lo
193 },
194 { // DREGS
195 8, // sub_hi -> DREGS
196 8, // sub_lo -> DREGS
197 },
198 { // DREGSNOZ
199 9, // sub_hi -> DREGSNOZ
200 9, // sub_lo -> DREGSNOZ
201 },
202 { // DREGSMOVW
203 10, // sub_hi -> DREGSMOVW
204 10, // sub_lo -> DREGSMOVW
205 },
206 { // DREGSMOVW_and_DREGSNOZ
207 11, // sub_hi -> DREGSMOVW_and_DREGSNOZ
208 11, // sub_lo -> DREGSMOVW_and_DREGSNOZ
209 },
210 { // DREGS_with_sub_hi_in_LD8
211 12, // sub_hi -> DREGS_with_sub_hi_in_LD8
212 12, // sub_lo -> DREGS_with_sub_hi_in_LD8
213 },
214 { // DREGSNOZ_and_DREGS_with_sub_hi_in_LD8
215 13, // sub_hi -> DREGSNOZ_and_DREGS_with_sub_hi_in_LD8
216 13, // sub_lo -> DREGSNOZ_and_DREGS_with_sub_hi_in_LD8
217 },
218 { // DREGS_with_sub_lo_in_LD8
219 14, // sub_hi -> DREGS_with_sub_lo_in_LD8
220 14, // sub_lo -> DREGS_with_sub_lo_in_LD8
221 },
222 { // DREGSNOZ_and_DREGS_with_sub_lo_in_LD8
223 15, // sub_hi -> DREGSNOZ_and_DREGS_with_sub_lo_in_LD8
224 15, // sub_lo -> DREGSNOZ_and_DREGS_with_sub_lo_in_LD8
225 },
226 { // DREGS_with_sub_lo_in_GPR8lo
227 16, // sub_hi -> DREGS_with_sub_lo_in_GPR8lo
228 16, // sub_lo -> DREGS_with_sub_lo_in_GPR8lo
229 },
230 { // DREGS_with_sub_hi_in_GPR8lo
231 17, // sub_hi -> DREGS_with_sub_hi_in_GPR8lo
232 17, // sub_lo -> DREGS_with_sub_hi_in_GPR8lo
233 },
234 { // DLDREGS
235 18, // sub_hi -> DLDREGS
236 18, // sub_lo -> DLDREGS
237 },
238 { // DREGS_with_sub_hi_in_LD8lo
239 19, // sub_hi -> DREGS_with_sub_hi_in_LD8lo
240 19, // sub_lo -> DREGS_with_sub_hi_in_LD8lo
241 },
242 { // DREGS_with_sub_lo_in_LD8lo
243 20, // sub_hi -> DREGS_with_sub_lo_in_LD8lo
244 20, // sub_lo -> DREGS_with_sub_lo_in_LD8lo
245 },
246 { // DREGSlo
247 21, // sub_hi -> DREGSlo
248 21, // sub_lo -> DREGSlo
249 },
250 { // DLDREGS_and_DREGSNOZ
251 22, // sub_hi -> DLDREGS_and_DREGSNOZ
252 22, // sub_lo -> DLDREGS_and_DREGSNOZ
253 },
254 { // DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8
255 23, // sub_hi -> DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8
256 23, // sub_lo -> DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8
257 },
258 { // DREGSLD8lo
259 24, // sub_hi -> DREGSLD8lo
260 24, // sub_lo -> DREGSLD8lo
261 },
262 { // IWREGS
263 25, // sub_hi -> IWREGS
264 25, // sub_lo -> IWREGS
265 },
266 { // DREGSNOZ_and_IWREGS
267 26, // sub_hi -> DREGSNOZ_and_IWREGS
268 26, // sub_lo -> DREGSNOZ_and_IWREGS
269 },
270 { // PTRREGS
271 27, // sub_hi -> PTRREGS
272 27, // sub_lo -> PTRREGS
273 },
274 { // DREGSNOZ_and_PTRREGS
275 28, // sub_hi -> DREGSNOZ_and_PTRREGS
276 28, // sub_lo -> DREGSNOZ_and_PTRREGS
277 },
278 { // PTRDISPREGS
279 29, // sub_hi -> PTRDISPREGS
280 29, // sub_lo -> PTRDISPREGS
281 },
282 { // DREGSNOZ_and_PTRDISPREGS
283 30, // sub_hi -> DREGSNOZ_and_PTRDISPREGS
284 30, // sub_lo -> DREGSNOZ_and_PTRDISPREGS
285 },
286 { // DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo
287 31, // sub_hi -> DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo
288 31, // sub_lo -> DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo
289 },
290 { // GPRSP
291 32, // sub_hi -> GPRSP
292 32, // sub_lo -> GPRSP
293 },
294 { // ZREG
295 33, // sub_hi -> ZREG
296 33, // sub_lo -> ZREG
297 },
298
299 };
300 assert(RC && "Missing regclass");
301 if (!Idx) return RC;
302 --Idx;
303 assert(Idx < 2 && "Bad subreg");
304 unsigned TV = Table[RC->getID()][Idx];
305 return TV ? getRegClass(i: TV - 1) : nullptr;
306}const TargetRegisterClass *AVRGenRegisterInfo::getSubRegisterClass(const TargetRegisterClass *RC, unsigned Idx) const {
307 static constexpr uint8_t Table[33][2] = {
308 { // GPR8
309 0, // GPR8:sub_hi
310 0, // GPR8:sub_lo
311 },
312 { // GPR8NOZ
313 0, // GPR8NOZ:sub_hi
314 0, // GPR8NOZ:sub_lo
315 },
316 { // GPR8lo
317 0, // GPR8lo:sub_hi
318 0, // GPR8lo:sub_lo
319 },
320 { // LD8
321 0, // LD8:sub_hi
322 0, // LD8:sub_lo
323 },
324 { // GPR8NOZ_and_LD8
325 0, // GPR8NOZ_and_LD8:sub_hi
326 0, // GPR8NOZ_and_LD8:sub_lo
327 },
328 { // LD8lo
329 0, // LD8lo:sub_hi
330 0, // LD8lo:sub_lo
331 },
332 { // CCR
333 0, // CCR:sub_hi
334 0, // CCR:sub_lo
335 },
336 { // DREGS
337 1, // DREGS:sub_hi -> GPR8
338 1, // DREGS:sub_lo -> GPR8
339 },
340 { // DREGSNOZ
341 2, // DREGSNOZ:sub_hi -> GPR8NOZ
342 2, // DREGSNOZ:sub_lo -> GPR8NOZ
343 },
344 { // DREGSMOVW
345 1, // DREGSMOVW:sub_hi -> GPR8
346 1, // DREGSMOVW:sub_lo -> GPR8
347 },
348 { // DREGSMOVW_and_DREGSNOZ
349 2, // DREGSMOVW_and_DREGSNOZ:sub_hi -> GPR8NOZ
350 2, // DREGSMOVW_and_DREGSNOZ:sub_lo -> GPR8NOZ
351 },
352 { // DREGS_with_sub_hi_in_LD8
353 4, // DREGS_with_sub_hi_in_LD8:sub_hi -> LD8
354 1, // DREGS_with_sub_hi_in_LD8:sub_lo -> GPR8
355 },
356 { // DREGSNOZ_and_DREGS_with_sub_hi_in_LD8
357 5, // DREGSNOZ_and_DREGS_with_sub_hi_in_LD8:sub_hi -> GPR8NOZ_and_LD8
358 2, // DREGSNOZ_and_DREGS_with_sub_hi_in_LD8:sub_lo -> GPR8NOZ
359 },
360 { // DREGS_with_sub_lo_in_LD8
361 4, // DREGS_with_sub_lo_in_LD8:sub_hi -> LD8
362 4, // DREGS_with_sub_lo_in_LD8:sub_lo -> LD8
363 },
364 { // DREGSNOZ_and_DREGS_with_sub_lo_in_LD8
365 5, // DREGSNOZ_and_DREGS_with_sub_lo_in_LD8:sub_hi -> GPR8NOZ_and_LD8
366 5, // DREGSNOZ_and_DREGS_with_sub_lo_in_LD8:sub_lo -> GPR8NOZ_and_LD8
367 },
368 { // DREGS_with_sub_lo_in_GPR8lo
369 2, // DREGS_with_sub_lo_in_GPR8lo:sub_hi -> GPR8NOZ
370 3, // DREGS_with_sub_lo_in_GPR8lo:sub_lo -> GPR8lo
371 },
372 { // DREGS_with_sub_hi_in_GPR8lo
373 3, // DREGS_with_sub_hi_in_GPR8lo:sub_hi -> GPR8lo
374 3, // DREGS_with_sub_hi_in_GPR8lo:sub_lo -> GPR8lo
375 },
376 { // DLDREGS
377 4, // DLDREGS:sub_hi -> LD8
378 4, // DLDREGS:sub_lo -> LD8
379 },
380 { // DREGS_with_sub_hi_in_LD8lo
381 6, // DREGS_with_sub_hi_in_LD8lo:sub_hi -> LD8lo
382 2, // DREGS_with_sub_hi_in_LD8lo:sub_lo -> GPR8NOZ
383 },
384 { // DREGS_with_sub_lo_in_LD8lo
385 5, // DREGS_with_sub_lo_in_LD8lo:sub_hi -> GPR8NOZ_and_LD8
386 6, // DREGS_with_sub_lo_in_LD8lo:sub_lo -> LD8lo
387 },
388 { // DREGSlo
389 3, // DREGSlo:sub_hi -> GPR8lo
390 3, // DREGSlo:sub_lo -> GPR8lo
391 },
392 { // DLDREGS_and_DREGSNOZ
393 5, // DLDREGS_and_DREGSNOZ:sub_hi -> GPR8NOZ_and_LD8
394 5, // DLDREGS_and_DREGSNOZ:sub_lo -> GPR8NOZ_and_LD8
395 },
396 { // DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8
397 6, // DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8:sub_hi -> LD8lo
398 6, // DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8:sub_lo -> LD8lo
399 },
400 { // DREGSLD8lo
401 6, // DREGSLD8lo:sub_hi -> LD8lo
402 6, // DREGSLD8lo:sub_lo -> LD8lo
403 },
404 { // IWREGS
405 4, // IWREGS:sub_hi -> LD8
406 4, // IWREGS:sub_lo -> LD8
407 },
408 { // DREGSNOZ_and_IWREGS
409 5, // DREGSNOZ_and_IWREGS:sub_hi -> GPR8NOZ_and_LD8
410 5, // DREGSNOZ_and_IWREGS:sub_lo -> GPR8NOZ_and_LD8
411 },
412 { // PTRREGS
413 4, // PTRREGS:sub_hi -> LD8
414 4, // PTRREGS:sub_lo -> LD8
415 },
416 { // DREGSNOZ_and_PTRREGS
417 5, // DREGSNOZ_and_PTRREGS:sub_hi -> GPR8NOZ_and_LD8
418 5, // DREGSNOZ_and_PTRREGS:sub_lo -> GPR8NOZ_and_LD8
419 },
420 { // PTRDISPREGS
421 4, // PTRDISPREGS:sub_hi -> LD8
422 4, // PTRDISPREGS:sub_lo -> LD8
423 },
424 { // DREGSNOZ_and_PTRDISPREGS
425 5, // DREGSNOZ_and_PTRDISPREGS:sub_hi -> GPR8NOZ_and_LD8
426 5, // DREGSNOZ_and_PTRDISPREGS:sub_lo -> GPR8NOZ_and_LD8
427 },
428 { // DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo
429 6, // DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo:sub_hi -> LD8lo
430 3, // DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo:sub_lo -> GPR8lo
431 },
432 { // GPRSP
433 0, // GPRSP:sub_hi
434 0, // GPRSP:sub_lo
435 },
436 { // ZREG
437 4, // ZREG:sub_hi -> LD8
438 4, // ZREG:sub_lo -> LD8
439 },
440
441 };
442 assert(RC && "Missing regclass");
443 if (!Idx) return RC;
444 --Idx;
445 assert(Idx < 2 && "Bad subreg");
446 unsigned TV = Table[RC->getID()][Idx];
447 return TV ? getRegClass(i: TV - 1) : nullptr;
448}/// Get the weight in units of pressure for this register class.
449const RegClassWeight &AVRGenRegisterInfo::
450getRegClassWeight(const TargetRegisterClass *RC) const {
451 static const RegClassWeight RCWeightTable[] = {
452 {.RegWeight: 1, .WeightLimit: 32}, // GPR8
453 {.RegWeight: 1, .WeightLimit: 30}, // GPR8NOZ
454 {.RegWeight: 1, .WeightLimit: 16}, // GPR8lo
455 {.RegWeight: 1, .WeightLimit: 16}, // LD8
456 {.RegWeight: 1, .WeightLimit: 14}, // GPR8NOZ_and_LD8
457 {.RegWeight: 1, .WeightLimit: 8}, // LD8lo
458 {.RegWeight: 1, .WeightLimit: 1}, // CCR
459 {.RegWeight: 2, .WeightLimit: 32}, // DREGS
460 {.RegWeight: 2, .WeightLimit: 30}, // DREGSNOZ
461 {.RegWeight: 2, .WeightLimit: 32}, // DREGSMOVW
462 {.RegWeight: 2, .WeightLimit: 30}, // DREGSMOVW_and_DREGSNOZ
463 {.RegWeight: 2, .WeightLimit: 17}, // DREGS_with_sub_hi_in_LD8
464 {.RegWeight: 2, .WeightLimit: 15}, // DREGSNOZ_and_DREGS_with_sub_hi_in_LD8
465 {.RegWeight: 2, .WeightLimit: 16}, // DREGS_with_sub_lo_in_LD8
466 {.RegWeight: 2, .WeightLimit: 14}, // DREGSNOZ_and_DREGS_with_sub_lo_in_LD8
467 {.RegWeight: 2, .WeightLimit: 17}, // DREGS_with_sub_lo_in_GPR8lo
468 {.RegWeight: 2, .WeightLimit: 16}, // DREGS_with_sub_hi_in_GPR8lo
469 {.RegWeight: 2, .WeightLimit: 16}, // DLDREGS
470 {.RegWeight: 2, .WeightLimit: 9}, // DREGS_with_sub_hi_in_LD8lo
471 {.RegWeight: 2, .WeightLimit: 9}, // DREGS_with_sub_lo_in_LD8lo
472 {.RegWeight: 2, .WeightLimit: 16}, // DREGSlo
473 {.RegWeight: 2, .WeightLimit: 14}, // DLDREGS_and_DREGSNOZ
474 {.RegWeight: 2, .WeightLimit: 8}, // DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8
475 {.RegWeight: 2, .WeightLimit: 8}, // DREGSLD8lo
476 {.RegWeight: 2, .WeightLimit: 8}, // IWREGS
477 {.RegWeight: 2, .WeightLimit: 6}, // DREGSNOZ_and_IWREGS
478 {.RegWeight: 2, .WeightLimit: 6}, // PTRREGS
479 {.RegWeight: 2, .WeightLimit: 4}, // DREGSNOZ_and_PTRREGS
480 {.RegWeight: 2, .WeightLimit: 4}, // PTRDISPREGS
481 {.RegWeight: 2, .WeightLimit: 2}, // DREGSNOZ_and_PTRDISPREGS
482 {.RegWeight: 2, .WeightLimit: 2}, // DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo
483 {.RegWeight: 0, .WeightLimit: 0}, // GPRSP
484 {.RegWeight: 2, .WeightLimit: 2}, // ZREG
485 };
486 return RCWeightTable[RC->getID()];
487}
488
489/// Get the weight in units of pressure for this register unit.
490unsigned AVRGenRegisterInfo::
491getRegUnitWeight(MCRegUnit RegUnit) const {
492 assert(static_cast<unsigned>(RegUnit) < 35 && "invalid register unit");
493 // All register units have unit weight.
494 return 1;
495}
496
497
498// Get the number of dimensions of register pressure.
499unsigned AVRGenRegisterInfo::getNumRegPressureSets() const {
500 return 8;
501}
502
503// Get the name of this register unit pressure set.
504const char *AVRGenRegisterInfo::
505getRegPressureSetName(unsigned Idx) const {
506 static const char *PressureNameTable[] = {
507 "CCR",
508 "DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo",
509 "IWREGS",
510 "LD8lo",
511 "LD8",
512 "GPR8lo",
513 "GPR8lo_with_LD8lo",
514 "GPR8",
515 };
516 return PressureNameTable[Idx];
517}
518
519// Get the register unit pressure limit for this dimension.
520// This limit must be adjusted dynamically for reserved registers.
521unsigned AVRGenRegisterInfo::
522getRegPressureSetLimit(const MachineFunction &MF, unsigned Idx) const {
523 static const uint8_t PressureLimitTable[] = {
524 1, // 0: CCR
525 2, // 1: DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo
526 8, // 2: IWREGS
527 10, // 3: LD8lo
528 17, // 4: LD8
529 17, // 5: GPR8lo
530 25, // 6: GPR8lo_with_LD8lo
531 32, // 7: GPR8
532 };
533 return PressureLimitTable[Idx];
534}
535
536/// Get the register class for this pressure set with the largest
537/// `RegClassWeight::WeightLimit`.
538const TargetRegisterClass *AVRGenRegisterInfo::
539getLargestRegClassForRegPressureSet(unsigned Idx) const {
540 static const uint8_t PSetRegClassTable[] = {
541 AVR::CCRRegClassID, // 0: CCR
542 AVR::DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8loRegClassID, // 1: DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8lo
543 AVR::IWREGSRegClassID, // 2: IWREGS
544 AVR::DREGS_with_sub_hi_in_LD8loRegClassID, // 3: LD8lo
545 AVR::DREGS_with_sub_hi_in_LD8RegClassID, // 4: LD8
546 AVR::DREGS_with_sub_lo_in_GPR8loRegClassID, // 5: GPR8lo
547 AVR::DREGS_with_sub_lo_in_GPR8loRegClassID, // 6: GPR8lo_with_LD8lo
548 AVR::GPR8RegClassID, // 7: GPR8
549 };
550 return getRegClass(i: PSetRegClassTable[Idx]);
551}
552
553/// Table of pressure sets per register class or unit.
554static const int RCSetsTable[] = {
555 /* 0 */ 0, -1,
556 /* 2 */ 2, 4, 7, -1,
557 /* 6 */ 2, 3, 4, 6, 7, -1,
558 /* 12 */ 1, 3, 4, 5, 6, 7, -1,
559};
560
561/// Get the dimensions of register pressure impacted by this register class.
562/// Returns a -1 terminated array of pressure set IDs
563const int *AVRGenRegisterInfo::
564getRegClassPressureSets(const TargetRegisterClass *RC) const {
565 static const uint8_t RCSetStartTable[] = {
566 4,4,15,3,3,7,0,4,4,4,4,3,3,3,3,15,15,3,7,7,15,3,7,7,2,2,2,2,2,2,12,1,2,};
567 return &RCSetsTable[RCSetStartTable[RC->getID()]];
568}
569
570/// Get the dimensions of register pressure impacted by this register unit.
571/// Returns a -1 terminated array of pressure set IDs
572const int *AVRGenRegisterInfo::
573getRegUnitPressureSets(MCRegUnit RegUnit) const {
574 assert(static_cast<unsigned>(RegUnit) < 35 && "invalid register unit");
575 static const uint8_t RUSetStartTable[] = {
576 1,1,0,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,12,12,7,7,7,7,7,7,7,6,2,2,2,2,2,2,2,};
577 return &RCSetsTable[RUSetStartTable[static_cast<unsigned>(RegUnit)]];
578}
579
580
581// Register to minimal register class mapping
582
583const TargetRegisterClass *AVRGenRegisterInfo::getMinimalPhysRegClass(MCRegister Reg) const {
584 static const uint16_t InvalidRegClassID = UINT16_MAX;
585
586 static const uint16_t Mapping[62] = {
587 InvalidRegClassID, // NoRegister
588 AVR::GPRSPRegClassID, // SP
589 InvalidRegClassID, // SPH
590 InvalidRegClassID, // SPL
591 AVR::CCRRegClassID, // SREG
592 AVR::GPR8loRegClassID, // R0
593 AVR::GPR8loRegClassID, // R1
594 AVR::GPR8loRegClassID, // R2
595 AVR::GPR8loRegClassID, // R3
596 AVR::GPR8loRegClassID, // R4
597 AVR::GPR8loRegClassID, // R5
598 AVR::GPR8loRegClassID, // R6
599 AVR::GPR8loRegClassID, // R7
600 AVR::GPR8loRegClassID, // R8
601 AVR::GPR8loRegClassID, // R9
602 AVR::GPR8loRegClassID, // R10
603 AVR::GPR8loRegClassID, // R11
604 AVR::GPR8loRegClassID, // R12
605 AVR::GPR8loRegClassID, // R13
606 AVR::GPR8loRegClassID, // R14
607 AVR::GPR8loRegClassID, // R15
608 AVR::LD8loRegClassID, // R16
609 AVR::LD8loRegClassID, // R17
610 AVR::LD8loRegClassID, // R18
611 AVR::LD8loRegClassID, // R19
612 AVR::LD8loRegClassID, // R20
613 AVR::LD8loRegClassID, // R21
614 AVR::LD8loRegClassID, // R22
615 AVR::LD8loRegClassID, // R23
616 AVR::GPR8NOZ_and_LD8RegClassID, // R24
617 AVR::GPR8NOZ_and_LD8RegClassID, // R25
618 AVR::GPR8NOZ_and_LD8RegClassID, // R26
619 AVR::GPR8NOZ_and_LD8RegClassID, // R27
620 AVR::GPR8NOZ_and_LD8RegClassID, // R28
621 AVR::GPR8NOZ_and_LD8RegClassID, // R29
622 AVR::LD8RegClassID, // R30
623 AVR::LD8RegClassID, // R31
624 AVR::DREGSloRegClassID, // R1R0
625 AVR::DREGSloRegClassID, // R3R2
626 AVR::DREGSloRegClassID, // R5R4
627 AVR::DREGSloRegClassID, // R7R6
628 AVR::DREGSloRegClassID, // R9R8
629 AVR::DREGS_with_sub_hi_in_GPR8loRegClassID, // R10R9
630 AVR::DREGSloRegClassID, // R11R10
631 AVR::DREGS_with_sub_hi_in_GPR8loRegClassID, // R12R11
632 AVR::DREGSloRegClassID, // R13R12
633 AVR::DREGS_with_sub_hi_in_GPR8loRegClassID, // R14R13
634 AVR::DREGSloRegClassID, // R15R14
635 AVR::DREGS_with_sub_hi_in_LD8_and_DREGS_with_sub_lo_in_GPR8loRegClassID, // R16R15
636 AVR::DREGSLD8loRegClassID, // R17R16
637 AVR::DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8RegClassID, // R18R17
638 AVR::DREGSLD8loRegClassID, // R19R18
639 AVR::DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8RegClassID, // R20R19
640 AVR::DREGSLD8loRegClassID, // R21R20
641 AVR::DREGS_with_sub_hi_in_LD8lo_and_DREGS_with_sub_lo_in_LD8RegClassID, // R22R21
642 AVR::DREGSLD8loRegClassID, // R23R22
643 AVR::DREGS_with_sub_lo_in_LD8loRegClassID, // R24R23
644 AVR::DREGSNOZ_and_IWREGSRegClassID, // R25R24
645 AVR::DREGSNOZ_and_DREGS_with_sub_lo_in_LD8RegClassID, // R26R25
646 AVR::DREGSNOZ_and_PTRREGSRegClassID, // R27R26
647 AVR::DREGSNOZ_and_PTRDISPREGSRegClassID, // R29R28
648 AVR::ZREGRegClassID, // R31R30
649 };
650
651 assert(Reg < ArrayRef(Mapping).size());
652 unsigned RCID = Mapping[Reg.id()];
653 if (RCID == InvalidRegClassID)
654 return nullptr;
655 return &AVRMCRegisterClassStorage.Classes[RCID];
656}
657extern const MCRegisterDesc AVRRegDesc[];
658extern const int16_t AVRRegDiffLists[];
659extern const LaneBitmask AVRLaneMaskLists[];
660extern const char AVRRegStrings[];
661extern const char AVRRegClassStrings[];
662extern const MCPhysReg AVRRegUnitRoots[][2];
663extern const uint16_t AVRSubRegIdxLists[];
664extern const uint16_t AVRRegEncodingTable[];
665// AVR Dwarf<->LLVM register mappings.
666extern const MCRegisterInfo::DwarfLLVMRegPair AVRDwarfFlavour0Dwarf2L[];
667extern const unsigned AVRDwarfFlavour0Dwarf2LSize;
668
669extern const MCRegisterInfo::DwarfLLVMRegPair AVREHFlavour0Dwarf2L[];
670extern const unsigned AVREHFlavour0Dwarf2LSize;
671
672extern const MCRegisterInfo::DwarfLLVMRegPair AVRDwarfFlavour0L2Dwarf[];
673extern const unsigned AVRDwarfFlavour0L2DwarfSize;
674
675extern const MCRegisterInfo::DwarfLLVMRegPair AVREHFlavour0L2Dwarf[];
676extern const unsigned AVREHFlavour0L2DwarfSize;
677
678
679AVRGenRegisterInfo::
680AVRGenRegisterInfo(unsigned RA, unsigned DwarfFlavour, unsigned EHFlavour,
681 unsigned PC, unsigned HwMode)
682 : TargetRegisterInfo(&AVRRegInfoDesc,
683 AVRSubRegIndexStrings, AVRSubRegIndexNameOffsets,
684 AVRSubRegIdxRangeTable, AVRSubRegIndexLaneMaskTable,
685
686 LaneBitmask(0xFFFFFFFFFFFFFFFF), AVRRegClassInfos, AVRVTLists, HwMode) {
687 InitMCRegisterInfo(D: AVRRegDesc, NR: 62, RA, PC,
688 C: &getAVRMCRegisterClass(RC: 0), NC: 33, RURoots: AVRRegUnitRoots, NRU: 35, DL: AVRRegDiffLists,
689 RUMS: AVRLaneMaskLists, Strings: AVRRegStrings, ClassStrings: AVRRegClassStrings, SubIndices: AVRSubRegIdxLists, NumIndices: 3,
690 RET: AVRRegEncodingTable, RUI: nullptr);
691
692 switch (DwarfFlavour) {
693 default:
694 llvm_unreachable("Unknown DWARF flavour");
695 case 0:
696 mapDwarfRegsToLLVMRegs(Map: AVRDwarfFlavour0Dwarf2L, Size: AVRDwarfFlavour0Dwarf2LSize, isEH: false);
697 break;
698 }
699 switch (EHFlavour) {
700 default:
701 llvm_unreachable("Unknown DWARF flavour");
702 case 0:
703 mapDwarfRegsToLLVMRegs(Map: AVREHFlavour0Dwarf2L, Size: AVREHFlavour0Dwarf2LSize, isEH: true);
704 break;
705 }
706 switch (DwarfFlavour) {
707 default:
708 llvm_unreachable("Unknown DWARF flavour");
709 case 0:
710 mapLLVMRegsToDwarfRegs(Map: AVRDwarfFlavour0L2Dwarf, Size: AVRDwarfFlavour0L2DwarfSize, isEH: false);
711 break;
712 }
713 switch (EHFlavour) {
714 default:
715 llvm_unreachable("Unknown DWARF flavour");
716 case 0:
717 mapLLVMRegsToDwarfRegs(Map: AVREHFlavour0L2Dwarf, Size: AVREHFlavour0L2DwarfSize, isEH: true);
718 break;
719 }
720}
721
722static const MCPhysReg CSR_Interrupts_SaveList[] = { AVR::R31, AVR::R30, AVR::R29, AVR::R28, AVR::R27, AVR::R26, AVR::R25, AVR::R24, AVR::R23, AVR::R22, AVR::R21, AVR::R20, AVR::R19, AVR::R18, AVR::R17, AVR::R16, AVR::R15, AVR::R14, AVR::R13, AVR::R12, AVR::R11, AVR::R10, AVR::R9, AVR::R8, AVR::R7, AVR::R6, AVR::R5, AVR::R4, AVR::R3, AVR::R2, 0 };
723static const uint32_t CSR_Interrupts_RegMask[] = { 0xffffff80, 0x3fffffdf, };
724static const MCPhysReg CSR_InterruptsTiny_SaveList[] = { AVR::R31, AVR::R30, AVR::R29, AVR::R28, AVR::R27, AVR::R26, AVR::R25, AVR::R24, AVR::R23, AVR::R22, AVR::R21, AVR::R20, AVR::R19, AVR::R18, 0 };
725static const uint32_t CSR_InterruptsTiny_RegMask[] = { 0xff800000, 0x3ff8001f, };
726static const MCPhysReg CSR_Normal_SaveList[] = { AVR::R29, AVR::R28, AVR::R17, AVR::R16, AVR::R15, AVR::R14, AVR::R13, AVR::R12, AVR::R11, AVR::R10, AVR::R9, AVR::R8, AVR::R7, AVR::R6, AVR::R5, AVR::R4, AVR::R3, AVR::R2, 0 };
727static const uint32_t CSR_Normal_RegMask[] = { 0x007fff80, 0x1003ffc6, };
728static const MCPhysReg CSR_NormalTiny_SaveList[] = { AVR::R29, AVR::R28, AVR::R19, AVR::R18, 0 };
729static const uint32_t CSR_NormalTiny_RegMask[] = { 0x01800000, 0x10080006, };
730
731
732ArrayRef<const uint32_t *> AVRGenRegisterInfo::getRegMasks() const {
733 static const uint32_t *const Masks[] = {
734 CSR_Interrupts_RegMask,
735 CSR_InterruptsTiny_RegMask,
736 CSR_Normal_RegMask,
737 CSR_NormalTiny_RegMask,
738 };
739 return ArrayRef(Masks);
740}
741
742bool AVRGenRegisterInfo::
743isGeneralPurposeRegister(const MachineFunction &MF, MCRegister PhysReg) const {
744 return
745 false;
746}
747
748bool AVRGenRegisterInfo::
749isGeneralPurposeRegisterClass(const TargetRegisterClass *RC) const {
750 return
751 false;
752}
753
754bool AVRGenRegisterInfo::
755isFixedRegister(const MachineFunction &MF, MCRegister PhysReg) const {
756 return
757 false;
758}
759
760bool AVRGenRegisterInfo::
761isArgumentRegister(const MachineFunction &MF, MCRegister PhysReg) const {
762 return
763 false;
764}
765
766bool AVRGenRegisterInfo::
767isConstantPhysReg(MCRegister PhysReg) const {
768 return
769 false;
770}
771
772ArrayRef<const char *> AVRGenRegisterInfo::getRegMaskNames() const {
773 static const char *Names[] = {
774 "CSR_Interrupts",
775 "CSR_InterruptsTiny",
776 "CSR_Normal",
777 "CSR_NormalTiny",
778 };
779 return ArrayRef(Names);
780}
781
782const AVRFrameLowering *
783AVRGenRegisterInfo::getFrameLowering(const MachineFunction &MF) {
784 return static_cast<const AVRFrameLowering *>(
785 MF.getSubtarget().getFrameLowering());
786}
787
788
789} // namespace llvm
790