LLVM 20.0.0git
AArch64BaseInfo.h
Go to the documentation of this file.
1//===-- AArch64BaseInfo.h - Top level definitions for AArch64 ---*- 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//
9// This file contains small standalone helper functions and enum definitions for
10// the AArch64 target useful for the compiler back-end and the MC libraries.
11// As such, it deliberately does not include references to LLVM core
12// code gen types, passes, etc..
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_AARCH64_UTILS_AARCH64BASEINFO_H
17#define LLVM_LIB_TARGET_AARCH64_UTILS_AARCH64BASEINFO_H
18
19// FIXME: Is it easiest to fix this layering violation by moving the .inc
20// #includes from AArch64MCTargetDesc.h to here?
21#include "MCTargetDesc/AArch64MCTargetDesc.h" // For AArch64::X0 and friends.
23#include "llvm/ADT/STLExtras.h"
27
28namespace llvm {
29
31 switch (Reg.id()) {
32 case AArch64::X0: return AArch64::W0;
33 case AArch64::X1: return AArch64::W1;
34 case AArch64::X2: return AArch64::W2;
35 case AArch64::X3: return AArch64::W3;
36 case AArch64::X4: return AArch64::W4;
37 case AArch64::X5: return AArch64::W5;
38 case AArch64::X6: return AArch64::W6;
39 case AArch64::X7: return AArch64::W7;
40 case AArch64::X8: return AArch64::W8;
41 case AArch64::X9: return AArch64::W9;
42 case AArch64::X10: return AArch64::W10;
43 case AArch64::X11: return AArch64::W11;
44 case AArch64::X12: return AArch64::W12;
45 case AArch64::X13: return AArch64::W13;
46 case AArch64::X14: return AArch64::W14;
47 case AArch64::X15: return AArch64::W15;
48 case AArch64::X16: return AArch64::W16;
49 case AArch64::X17: return AArch64::W17;
50 case AArch64::X18: return AArch64::W18;
51 case AArch64::X19: return AArch64::W19;
52 case AArch64::X20: return AArch64::W20;
53 case AArch64::X21: return AArch64::W21;
54 case AArch64::X22: return AArch64::W22;
55 case AArch64::X23: return AArch64::W23;
56 case AArch64::X24: return AArch64::W24;
57 case AArch64::X25: return AArch64::W25;
58 case AArch64::X26: return AArch64::W26;
59 case AArch64::X27: return AArch64::W27;
60 case AArch64::X28: return AArch64::W28;
61 case AArch64::FP: return AArch64::W29;
62 case AArch64::LR: return AArch64::W30;
63 case AArch64::SP: return AArch64::WSP;
64 case AArch64::XZR: return AArch64::WZR;
65 }
66 // For anything else, return it unchanged.
67 return Reg;
68}
69
71 switch (Reg.id()) {
72 case AArch64::W0: return AArch64::X0;
73 case AArch64::W1: return AArch64::X1;
74 case AArch64::W2: return AArch64::X2;
75 case AArch64::W3: return AArch64::X3;
76 case AArch64::W4: return AArch64::X4;
77 case AArch64::W5: return AArch64::X5;
78 case AArch64::W6: return AArch64::X6;
79 case AArch64::W7: return AArch64::X7;
80 case AArch64::W8: return AArch64::X8;
81 case AArch64::W9: return AArch64::X9;
82 case AArch64::W10: return AArch64::X10;
83 case AArch64::W11: return AArch64::X11;
84 case AArch64::W12: return AArch64::X12;
85 case AArch64::W13: return AArch64::X13;
86 case AArch64::W14: return AArch64::X14;
87 case AArch64::W15: return AArch64::X15;
88 case AArch64::W16: return AArch64::X16;
89 case AArch64::W17: return AArch64::X17;
90 case AArch64::W18: return AArch64::X18;
91 case AArch64::W19: return AArch64::X19;
92 case AArch64::W20: return AArch64::X20;
93 case AArch64::W21: return AArch64::X21;
94 case AArch64::W22: return AArch64::X22;
95 case AArch64::W23: return AArch64::X23;
96 case AArch64::W24: return AArch64::X24;
97 case AArch64::W25: return AArch64::X25;
98 case AArch64::W26: return AArch64::X26;
99 case AArch64::W27: return AArch64::X27;
100 case AArch64::W28: return AArch64::X28;
101 case AArch64::W29: return AArch64::FP;
102 case AArch64::W30: return AArch64::LR;
103 case AArch64::WSP: return AArch64::SP;
104 case AArch64::WZR: return AArch64::XZR;
105 }
106 // For anything else, return it unchanged.
107 return Reg;
108}
109
111 switch (RegTuple.id()) {
112 case AArch64::X0_X1_X2_X3_X4_X5_X6_X7: return AArch64::X0;
113 case AArch64::X2_X3_X4_X5_X6_X7_X8_X9: return AArch64::X2;
114 case AArch64::X4_X5_X6_X7_X8_X9_X10_X11: return AArch64::X4;
115 case AArch64::X6_X7_X8_X9_X10_X11_X12_X13: return AArch64::X6;
116 case AArch64::X8_X9_X10_X11_X12_X13_X14_X15: return AArch64::X8;
117 case AArch64::X10_X11_X12_X13_X14_X15_X16_X17: return AArch64::X10;
118 case AArch64::X12_X13_X14_X15_X16_X17_X18_X19: return AArch64::X12;
119 case AArch64::X14_X15_X16_X17_X18_X19_X20_X21: return AArch64::X14;
120 case AArch64::X16_X17_X18_X19_X20_X21_X22_X23: return AArch64::X16;
121 case AArch64::X18_X19_X20_X21_X22_X23_X24_X25: return AArch64::X18;
122 case AArch64::X20_X21_X22_X23_X24_X25_X26_X27: return AArch64::X20;
123 case AArch64::X22_X23_X24_X25_X26_X27_X28_FP: return AArch64::X22;
124 }
125 // For anything else, return it unchanged.
126 return RegTuple;
127}
128
130 switch (Reg.id()) {
131 case AArch64::D0: return AArch64::B0;
132 case AArch64::D1: return AArch64::B1;
133 case AArch64::D2: return AArch64::B2;
134 case AArch64::D3: return AArch64::B3;
135 case AArch64::D4: return AArch64::B4;
136 case AArch64::D5: return AArch64::B5;
137 case AArch64::D6: return AArch64::B6;
138 case AArch64::D7: return AArch64::B7;
139 case AArch64::D8: return AArch64::B8;
140 case AArch64::D9: return AArch64::B9;
141 case AArch64::D10: return AArch64::B10;
142 case AArch64::D11: return AArch64::B11;
143 case AArch64::D12: return AArch64::B12;
144 case AArch64::D13: return AArch64::B13;
145 case AArch64::D14: return AArch64::B14;
146 case AArch64::D15: return AArch64::B15;
147 case AArch64::D16: return AArch64::B16;
148 case AArch64::D17: return AArch64::B17;
149 case AArch64::D18: return AArch64::B18;
150 case AArch64::D19: return AArch64::B19;
151 case AArch64::D20: return AArch64::B20;
152 case AArch64::D21: return AArch64::B21;
153 case AArch64::D22: return AArch64::B22;
154 case AArch64::D23: return AArch64::B23;
155 case AArch64::D24: return AArch64::B24;
156 case AArch64::D25: return AArch64::B25;
157 case AArch64::D26: return AArch64::B26;
158 case AArch64::D27: return AArch64::B27;
159 case AArch64::D28: return AArch64::B28;
160 case AArch64::D29: return AArch64::B29;
161 case AArch64::D30: return AArch64::B30;
162 case AArch64::D31: return AArch64::B31;
163 }
164 // For anything else, return it unchanged.
165 return Reg;
166}
167
169 switch (Reg.id()) {
170 case AArch64::B0: return AArch64::D0;
171 case AArch64::B1: return AArch64::D1;
172 case AArch64::B2: return AArch64::D2;
173 case AArch64::B3: return AArch64::D3;
174 case AArch64::B4: return AArch64::D4;
175 case AArch64::B5: return AArch64::D5;
176 case AArch64::B6: return AArch64::D6;
177 case AArch64::B7: return AArch64::D7;
178 case AArch64::B8: return AArch64::D8;
179 case AArch64::B9: return AArch64::D9;
180 case AArch64::B10: return AArch64::D10;
181 case AArch64::B11: return AArch64::D11;
182 case AArch64::B12: return AArch64::D12;
183 case AArch64::B13: return AArch64::D13;
184 case AArch64::B14: return AArch64::D14;
185 case AArch64::B15: return AArch64::D15;
186 case AArch64::B16: return AArch64::D16;
187 case AArch64::B17: return AArch64::D17;
188 case AArch64::B18: return AArch64::D18;
189 case AArch64::B19: return AArch64::D19;
190 case AArch64::B20: return AArch64::D20;
191 case AArch64::B21: return AArch64::D21;
192 case AArch64::B22: return AArch64::D22;
193 case AArch64::B23: return AArch64::D23;
194 case AArch64::B24: return AArch64::D24;
195 case AArch64::B25: return AArch64::D25;
196 case AArch64::B26: return AArch64::D26;
197 case AArch64::B27: return AArch64::D27;
198 case AArch64::B28: return AArch64::D28;
199 case AArch64::B29: return AArch64::D29;
200 case AArch64::B30: return AArch64::D30;
201 case AArch64::B31: return AArch64::D31;
202 }
203 // For anything else, return it unchanged.
204 return Reg;
205}
206
207static inline bool atomicBarrierDroppedOnZero(unsigned Opcode) {
208 switch (Opcode) {
209 case AArch64::LDADDAB: case AArch64::LDADDAH:
210 case AArch64::LDADDAW: case AArch64::LDADDAX:
211 case AArch64::LDADDALB: case AArch64::LDADDALH:
212 case AArch64::LDADDALW: case AArch64::LDADDALX:
213 case AArch64::LDCLRAB: case AArch64::LDCLRAH:
214 case AArch64::LDCLRAW: case AArch64::LDCLRAX:
215 case AArch64::LDCLRALB: case AArch64::LDCLRALH:
216 case AArch64::LDCLRALW: case AArch64::LDCLRALX:
217 case AArch64::LDEORAB: case AArch64::LDEORAH:
218 case AArch64::LDEORAW: case AArch64::LDEORAX:
219 case AArch64::LDEORALB: case AArch64::LDEORALH:
220 case AArch64::LDEORALW: case AArch64::LDEORALX:
221 case AArch64::LDSETAB: case AArch64::LDSETAH:
222 case AArch64::LDSETAW: case AArch64::LDSETAX:
223 case AArch64::LDSETALB: case AArch64::LDSETALH:
224 case AArch64::LDSETALW: case AArch64::LDSETALX:
225 case AArch64::LDSMAXAB: case AArch64::LDSMAXAH:
226 case AArch64::LDSMAXAW: case AArch64::LDSMAXAX:
227 case AArch64::LDSMAXALB: case AArch64::LDSMAXALH:
228 case AArch64::LDSMAXALW: case AArch64::LDSMAXALX:
229 case AArch64::LDSMINAB: case AArch64::LDSMINAH:
230 case AArch64::LDSMINAW: case AArch64::LDSMINAX:
231 case AArch64::LDSMINALB: case AArch64::LDSMINALH:
232 case AArch64::LDSMINALW: case AArch64::LDSMINALX:
233 case AArch64::LDUMAXAB: case AArch64::LDUMAXAH:
234 case AArch64::LDUMAXAW: case AArch64::LDUMAXAX:
235 case AArch64::LDUMAXALB: case AArch64::LDUMAXALH:
236 case AArch64::LDUMAXALW: case AArch64::LDUMAXALX:
237 case AArch64::LDUMINAB: case AArch64::LDUMINAH:
238 case AArch64::LDUMINAW: case AArch64::LDUMINAX:
239 case AArch64::LDUMINALB: case AArch64::LDUMINALH:
240 case AArch64::LDUMINALW: case AArch64::LDUMINALX:
241 case AArch64::SWPAB: case AArch64::SWPAH:
242 case AArch64::SWPAW: case AArch64::SWPAX:
243 case AArch64::SWPALB: case AArch64::SWPALH:
244 case AArch64::SWPALW: case AArch64::SWPALX:
245 return true;
246 }
247 return false;
248}
249
250namespace AArch64CC {
251
252// The CondCodes constants map directly to the 4-bit encoding of the condition
253// field for predicated instructions.
254enum CondCode { // Meaning (integer) Meaning (floating-point)
255 EQ = 0x0, // Equal Equal
256 NE = 0x1, // Not equal Not equal, or unordered
257 HS = 0x2, // Unsigned higher or same >, ==, or unordered
258 LO = 0x3, // Unsigned lower Less than
259 MI = 0x4, // Minus, negative Less than
260 PL = 0x5, // Plus, positive or zero >, ==, or unordered
261 VS = 0x6, // Overflow Unordered
262 VC = 0x7, // No overflow Not unordered
263 HI = 0x8, // Unsigned higher Greater than, or unordered
264 LS = 0x9, // Unsigned lower or same Less than or equal
265 GE = 0xa, // Greater than or equal Greater than or equal
266 LT = 0xb, // Less than Less than, or unordered
267 GT = 0xc, // Greater than Greater than
268 LE = 0xd, // Less than or equal <, ==, or unordered
269 AL = 0xe, // Always (unconditional) Always (unconditional)
270 NV = 0xf, // Always (unconditional) Always (unconditional)
271 // Note the NV exists purely to disassemble 0b1111. Execution is "always".
273
274 // Common aliases used for SVE.
275 ANY_ACTIVE = NE, // (!Z)
276 FIRST_ACTIVE = MI, // ( N)
277 LAST_ACTIVE = LO, // (!C)
278 NONE_ACTIVE = EQ // ( Z)
280
281inline static const char *getCondCodeName(CondCode Code) {
282 switch (Code) {
283 default: llvm_unreachable("Unknown condition code");
284 case EQ: return "eq";
285 case NE: return "ne";
286 case HS: return "hs";
287 case LO: return "lo";
288 case MI: return "mi";
289 case PL: return "pl";
290 case VS: return "vs";
291 case VC: return "vc";
292 case HI: return "hi";
293 case LS: return "ls";
294 case GE: return "ge";
295 case LT: return "lt";
296 case GT: return "gt";
297 case LE: return "le";
298 case AL: return "al";
299 case NV: return "nv";
300 }
301}
302
304 // To reverse a condition it's necessary to only invert the low bit:
305
306 return static_cast<CondCode>(static_cast<unsigned>(Code) ^ 0x1);
307}
308
309/// Given a condition code, return NZCV flags that would satisfy that condition.
310/// The flag bits are in the format expected by the ccmp instructions.
311/// Note that many different flag settings can satisfy a given condition code,
312/// this function just returns one of them.
313inline static unsigned getNZCVToSatisfyCondCode(CondCode Code) {
314 // NZCV flags encoded as expected by ccmp instructions, ARMv8 ISA 5.5.7.
315 enum { N = 8, Z = 4, C = 2, V = 1 };
316 switch (Code) {
317 default: llvm_unreachable("Unknown condition code");
318 case EQ: return Z; // Z == 1
319 case NE: return 0; // Z == 0
320 case HS: return C; // C == 1
321 case LO: return 0; // C == 0
322 case MI: return N; // N == 1
323 case PL: return 0; // N == 0
324 case VS: return V; // V == 1
325 case VC: return 0; // V == 0
326 case HI: return C; // C == 1 && Z == 0
327 case LS: return 0; // C == 0 || Z == 1
328 case GE: return 0; // N == V
329 case LT: return N; // N != V
330 case GT: return 0; // Z == 0 && N == V
331 case LE: return Z; // Z == 1 || N != V
332 }
333}
334
335} // end namespace AArch64CC
336
337struct SysAlias {
338 const char *Name;
341
342 constexpr SysAlias(const char *N, uint16_t E) : Name(N), Encoding(E) {}
343 constexpr SysAlias(const char *N, uint16_t E, FeatureBitset F)
345
346 bool haveFeatures(FeatureBitset ActiveFeatures) const {
347 return ActiveFeatures[llvm::AArch64::FeatureAll] ||
348 (FeaturesRequired & ActiveFeatures) == FeaturesRequired;
349 }
350
352};
353
356 constexpr SysAliasReg(const char *N, uint16_t E, bool R)
357 : SysAlias(N, E), NeedsReg(R) {}
358 constexpr SysAliasReg(const char *N, uint16_t E, bool R, FeatureBitset F)
359 : SysAlias(N, E, F), NeedsReg(R) {}
360};
361
364 constexpr SysAliasImm(const char *N, uint16_t E, uint16_t I)
365 : SysAlias(N, E), ImmValue(I) {}
366 constexpr SysAliasImm(const char *N, uint16_t E, uint16_t I, FeatureBitset F)
367 : SysAlias(N, E, F), ImmValue(I) {}
368};
369
370namespace AArch64SVCR {
371 struct SVCR : SysAlias{
372 using SysAlias::SysAlias;
373 };
374 #define GET_SVCR_DECL
375 #include "AArch64GenSystemOperands.inc"
376}
377
378namespace AArch64AT{
379 struct AT : SysAlias {
380 using SysAlias::SysAlias;
381 };
382 #define GET_AT_DECL
383 #include "AArch64GenSystemOperands.inc"
384}
385
386namespace AArch64DB {
387 struct DB : SysAlias {
388 using SysAlias::SysAlias;
389 };
390 #define GET_DB_DECL
391 #include "AArch64GenSystemOperands.inc"
392}
393
394namespace AArch64DBnXS {
397 };
398 #define GET_DBNXS_DECL
399 #include "AArch64GenSystemOperands.inc"
400}
401
402namespace AArch64DC {
403 struct DC : SysAlias {
404 using SysAlias::SysAlias;
405 };
406 #define GET_DC_DECL
407 #include "AArch64GenSystemOperands.inc"
408}
409
410namespace AArch64IC {
411 struct IC : SysAliasReg {
413 };
414 #define GET_IC_DECL
415 #include "AArch64GenSystemOperands.inc"
416}
417
418namespace AArch64ISB {
419 struct ISB : SysAlias {
420 using SysAlias::SysAlias;
421 };
422 #define GET_ISB_DECL
423 #include "AArch64GenSystemOperands.inc"
424}
425
426namespace AArch64TSB {
427 struct TSB : SysAlias {
428 using SysAlias::SysAlias;
429 };
430 #define GET_TSB_DECL
431 #include "AArch64GenSystemOperands.inc"
432}
433
434namespace AArch64PRFM {
435 struct PRFM : SysAlias {
436 using SysAlias::SysAlias;
437 };
438 #define GET_PRFM_DECL
439 #include "AArch64GenSystemOperands.inc"
440}
441
442namespace AArch64SVEPRFM {
443 struct SVEPRFM : SysAlias {
444 using SysAlias::SysAlias;
445 };
446#define GET_SVEPRFM_DECL
447#include "AArch64GenSystemOperands.inc"
448}
449
450namespace AArch64RPRFM {
451struct RPRFM : SysAlias {
452 using SysAlias::SysAlias;
453};
454#define GET_RPRFM_DECL
455#include "AArch64GenSystemOperands.inc"
456} // namespace AArch64RPRFM
457
458namespace AArch64SVEPredPattern {
459 struct SVEPREDPAT {
460 const char *Name;
462 };
463#define GET_SVEPREDPAT_DECL
464#include "AArch64GenSystemOperands.inc"
465}
466
467namespace AArch64SVEVecLenSpecifier {
469 const char *Name;
471 };
472#define GET_SVEVECLENSPECIFIER_DECL
473#include "AArch64GenSystemOperands.inc"
474} // namespace AArch64SVEVecLenSpecifier
475
476/// Return the number of active elements for VL1 to VL256 predicate pattern,
477/// zero for all other patterns.
478inline unsigned getNumElementsFromSVEPredPattern(unsigned Pattern) {
479 switch (Pattern) {
480 default:
481 return 0;
482 case AArch64SVEPredPattern::vl1:
483 case AArch64SVEPredPattern::vl2:
484 case AArch64SVEPredPattern::vl3:
485 case AArch64SVEPredPattern::vl4:
486 case AArch64SVEPredPattern::vl5:
487 case AArch64SVEPredPattern::vl6:
488 case AArch64SVEPredPattern::vl7:
489 case AArch64SVEPredPattern::vl8:
490 return Pattern;
491 case AArch64SVEPredPattern::vl16:
492 return 16;
493 case AArch64SVEPredPattern::vl32:
494 return 32;
495 case AArch64SVEPredPattern::vl64:
496 return 64;
497 case AArch64SVEPredPattern::vl128:
498 return 128;
499 case AArch64SVEPredPattern::vl256:
500 return 256;
501 }
502}
503
504/// Return specific VL predicate pattern based on the number of elements.
505inline std::optional<unsigned>
507 switch (MinNumElts) {
508 default:
509 return std::nullopt;
510 case 1:
511 case 2:
512 case 3:
513 case 4:
514 case 5:
515 case 6:
516 case 7:
517 case 8:
518 return MinNumElts;
519 case 16:
520 return AArch64SVEPredPattern::vl16;
521 case 32:
522 return AArch64SVEPredPattern::vl32;
523 case 64:
524 return AArch64SVEPredPattern::vl64;
525 case 128:
526 return AArch64SVEPredPattern::vl128;
527 case 256:
528 return AArch64SVEPredPattern::vl256;
529 }
530}
531
532/// An enum to describe what types of loops we should attempt to tail-fold:
533/// Disabled: None
534/// Reductions: Loops containing reductions
535/// Recurrences: Loops with first-order recurrences, i.e. that would
536/// require a SVE splice instruction
537/// Reverse: Reverse loops
538/// Simple: Loops that are not reversed and don't contain reductions
539/// or first-order recurrences.
540/// All: All
542 Disabled = 0x00,
543 Simple = 0x01,
544 Reductions = 0x02,
545 Recurrences = 0x04,
546 Reverse = 0x08,
548};
549
551 /* LargestValue */ (long)TailFoldingOpts::Reverse);
552
553namespace AArch64ExactFPImm {
554 struct ExactFPImm {
555 const char *Name;
556 int Enum;
557 const char *Repr;
558 };
559#define GET_EXACTFPIMM_DECL
560#include "AArch64GenSystemOperands.inc"
561}
562
563namespace AArch64PState {
565 using SysAlias::SysAlias;
566 };
567 #define GET_PSTATEIMM0_15_DECL
568 #include "AArch64GenSystemOperands.inc"
569
571 using SysAlias::SysAlias;
572 };
573 #define GET_PSTATEIMM0_1_DECL
574 #include "AArch64GenSystemOperands.inc"
575}
576
577namespace AArch64PSBHint {
578 struct PSB : SysAlias {
579 using SysAlias::SysAlias;
580 };
581 #define GET_PSB_DECL
582 #include "AArch64GenSystemOperands.inc"
583}
584
585namespace AArch64PHint {
586struct PHint {
587 const char *Name;
588 const char *AltName;
589 unsigned Encoding;
591
592 bool haveFeatures(FeatureBitset ActiveFeatures) const {
593 return ActiveFeatures[llvm::AArch64::FeatureAll] ||
594 (FeaturesRequired & ActiveFeatures) == FeaturesRequired;
595 }
596};
597
598#define GET_PHINT_DECL
599#include "AArch64GenSystemOperands.inc"
600
603} // namespace AArch64PHint
604
605namespace AArch64BTIHint {
606 struct BTI : SysAlias {
607 using SysAlias::SysAlias;
608 };
609 #define GET_BTI_DECL
610 #include "AArch64GenSystemOperands.inc"
611}
612
613namespace AArch64SME {
614enum ToggleCondition : unsigned {
619}
620
621namespace AArch64SE {
629
634
638 SXTX
639 };
640}
641
642namespace AArch64Layout {
649
654
655 // Bare layout for the 128-bit vector
656 // (only show ".b", ".h", ".s", ".d" without vector number)
660 VL_D
661 };
662}
663
664inline static const char *
666 switch (Layout) {
667 case AArch64Layout::VL_8B: return ".8b";
668 case AArch64Layout::VL_4H: return ".4h";
669 case AArch64Layout::VL_2S: return ".2s";
670 case AArch64Layout::VL_1D: return ".1d";
671 case AArch64Layout::VL_16B: return ".16b";
672 case AArch64Layout::VL_8H: return ".8h";
673 case AArch64Layout::VL_4S: return ".4s";
674 case AArch64Layout::VL_2D: return ".2d";
675 case AArch64Layout::VL_B: return ".b";
676 case AArch64Layout::VL_H: return ".h";
677 case AArch64Layout::VL_S: return ".s";
678 case AArch64Layout::VL_D: return ".d";
679 default: llvm_unreachable("Unknown Vector Layout");
680 }
681}
682
683inline static AArch64Layout::VectorLayout
699}
700
701namespace AArch64SysReg {
702 struct SysReg {
703 const char *Name;
704 const char *AltName;
705 unsigned Encoding;
709
710 bool haveFeatures(FeatureBitset ActiveFeatures) const {
711 return ActiveFeatures[llvm::AArch64::FeatureAll] ||
712 (FeaturesRequired & ActiveFeatures) == FeaturesRequired;
713 }
714 };
715
716 #define GET_SYSREG_DECL
717 #include "AArch64GenSystemOperands.inc"
718
721
723 std::string genericRegisterString(uint32_t Bits);
724}
725
726namespace AArch64TLBI {
727 struct TLBI : SysAliasReg {
729 };
730 #define GET_TLBITable_DECL
731 #include "AArch64GenSystemOperands.inc"
732}
733
734namespace AArch64PRCTX {
737 };
738 #define GET_PRCTX_DECL
739 #include "AArch64GenSystemOperands.inc"
740}
741
742namespace AArch64II {
743/// Target Operand Flag enum.
744enum TOF {
745 //===------------------------------------------------------------------===//
746 // AArch64 Specific MachineOperand flags.
747
749
751
752 /// MO_PAGE - A symbol operand with this flag represents the pc-relative
753 /// offset of the 4K page containing the symbol. This is used with the
754 /// ADRP instruction.
756
757 /// MO_PAGEOFF - A symbol operand with this flag represents the offset of
758 /// that symbol within a 4K page. This offset is added to the page address
759 /// to produce the complete address.
761
762 /// MO_G3 - A symbol operand with this flag (granule 3) represents the high
763 /// 16-bits of a 64-bit address, used in a MOVZ or MOVK instruction
764 MO_G3 = 3,
765
766 /// MO_G2 - A symbol operand with this flag (granule 2) represents the bits
767 /// 32-47 of a 64-bit address, used in a MOVZ or MOVK instruction
768 MO_G2 = 4,
769
770 /// MO_G1 - A symbol operand with this flag (granule 1) represents the bits
771 /// 16-31 of a 64-bit address, used in a MOVZ or MOVK instruction
772 MO_G1 = 5,
773
774 /// MO_G0 - A symbol operand with this flag (granule 0) represents the bits
775 /// 0-15 of a 64-bit address, used in a MOVZ or MOVK instruction
776 MO_G0 = 6,
777
778 /// MO_HI12 - This flag indicates that a symbol operand represents the bits
779 /// 13-24 of a 64-bit address, used in a arithmetic immediate-shifted-left-
780 /// by-12-bits instruction.
782
783 /// MO_COFFSTUB - On a symbol operand "FOO", this indicates that the
784 /// reference is actually to the ".refptr.FOO" symbol. This is used for
785 /// stub symbols on windows.
787
788 /// MO_GOT - This flag indicates that a symbol operand represents the
789 /// address of the GOT entry for the symbol, rather than the address of
790 /// the symbol itself.
791 MO_GOT = 0x10,
792
793 /// MO_NC - Indicates whether the linker is expected to check the symbol
794 /// reference for overflow. For example in an ADRP/ADD pair of relocations
795 /// the ADRP usually does check, but not the ADD.
796 MO_NC = 0x20,
797
798 /// MO_TLS - Indicates that the operand being accessed is some kind of
799 /// thread-local symbol. On Darwin, only one type of thread-local access
800 /// exists (pre linker-relaxation), but on ELF the TLSModel used for the
801 /// referee will affect interpretation.
802 MO_TLS = 0x40,
803
804 /// MO_DLLIMPORT - On a symbol operand, this represents that the reference
805 /// to the symbol is for an import stub. This is used for DLL import
806 /// storage class indication on Windows.
808
809 /// MO_S - Indicates that the bits of the symbol operand represented by
810 /// MO_G0 etc are signed.
811 MO_S = 0x100,
812
813 /// MO_PREL - Indicates that the bits of the symbol operand represented by
814 /// MO_G0 etc are PC relative.
815 MO_PREL = 0x200,
816
817 /// MO_TAGGED - With MO_PAGE, indicates that the page includes a memory tag
818 /// in bits 56-63.
819 /// On a FrameIndex operand, indicates that the underlying memory is tagged
820 /// with an unknown tag value (MTE); this needs to be lowered either to an
821 /// SP-relative load or store instruction (which do not check tags), or to
822 /// an LDG instruction to obtain the tag value.
823 MO_TAGGED = 0x400,
824
825 /// MO_ARM64EC_CALLMANGLE - Operand refers to the Arm64EC-mangled version
826 /// of a symbol, not the original. For dllimport symbols, this means it
827 /// uses "__imp_aux". For other symbols, this means it uses the mangled
828 /// ("#" prefix for C) name.
830};
831} // end namespace AArch64II
832
833//===----------------------------------------------------------------------===//
834// v8.3a Pointer Authentication
835//
836
837namespace AArch64PACKey {
838enum ID : uint8_t {
839 IA = 0,
840 IB = 1,
841 DA = 2,
842 DB = 3,
843 LAST = DB
845} // namespace AArch64PACKey
846
847/// Return 2-letter identifier string for numeric key ID.
849 switch (KeyID) {
851 return StringRef("ia");
853 return StringRef("ib");
855 return StringRef("da");
857 return StringRef("db");
858 }
859 llvm_unreachable("Unhandled AArch64PACKey::ID enum");
860}
861
862/// Return numeric key ID for 2-letter identifier string.
863inline static std::optional<AArch64PACKey::ID>
865 if (Name == "ia")
866 return AArch64PACKey::IA;
867 if (Name == "ib")
868 return AArch64PACKey::IB;
869 if (Name == "da")
870 return AArch64PACKey::DA;
871 if (Name == "db")
872 return AArch64PACKey::DB;
873 return std::nullopt;
874}
875
876namespace AArch64 {
877// The number of bits in a SVE register is architecturally defined
878// to be a multiple of this value. If <M x t> has this number of bits,
879// a <n x M x t> vector can be stored in a SVE register without any
880// redundant bits. If <M x t> has this number of bits divided by P,
881// a <n x M x t> vector is stored in a SVE register by placing index i
882// in index i*P of a <n x (M*P) x t> vector. The other elements of the
883// <n x (M*P) x t> vector (such as index 1) are undefined.
884static constexpr unsigned SVEBitsPerBlock = 128;
885static constexpr unsigned SVEMaxBitsPerVector = 2048;
886} // end namespace AArch64
887} // end namespace llvm
888
889#endif
#define LLVM_DECLARE_ENUM_AS_BITMASK(Enum, LargestValue)
LLVM_DECLARE_ENUM_AS_BITMASK can be used to declare an enum type as a bit set, so that bitwise operat...
Definition: BitmaskEnum.h:66
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::string Name
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned Reg
This file contains some templates that are useful if you are working with the STL at all.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Container class for subtarget features.
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
constexpr unsigned id() const
Definition: MCRegister.h:79
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:44
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:69
R Default(T Value)
Definition: StringSwitch.h:182
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const char * getCondCodeName(CondCode Code)
static CondCode getInvertedCondCode(CondCode Code)
static unsigned getNZCVToSatisfyCondCode(CondCode Code)
Given a condition code, return NZCV flags that would satisfy that condition.
TOF
Target Operand Flag enum.
@ MO_DLLIMPORT
MO_DLLIMPORT - On a symbol operand, this represents that the reference to the symbol is for an import...
@ MO_NC
MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow.
@ MO_G1
MO_G1 - A symbol operand with this flag (granule 1) represents the bits 16-31 of a 64-bit address,...
@ MO_S
MO_S - Indicates that the bits of the symbol operand represented by MO_G0 etc are signed.
@ MO_PAGEOFF
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page.
@ MO_GOT
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
@ MO_PREL
MO_PREL - Indicates that the bits of the symbol operand represented by MO_G0 etc are PC relative.
@ MO_G0
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address,...
@ MO_ARM64EC_CALLMANGLE
MO_ARM64EC_CALLMANGLE - Operand refers to the Arm64EC-mangled version of a symbol,...
@ MO_PAGE
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
@ MO_HI12
MO_HI12 - This flag indicates that a symbol operand represents the bits 13-24 of a 64-bit address,...
@ MO_TLS
MO_TLS - Indicates that the operand being accessed is some kind of thread-local symbol.
@ MO_G2
MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address,...
@ MO_TAGGED
MO_TAGGED - With MO_PAGE, indicates that the page includes a memory tag in bits 56-63.
@ MO_G3
MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address,...
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
const PHint * lookupPHintByName(StringRef)
const PHint * lookupPHintByEncoding(uint16_t)
const SysReg * lookupSysRegByEncoding(uint16_t)
uint32_t parseGenericRegister(StringRef Name)
std::string genericRegisterString(uint32_t Bits)
const SysReg * lookupSysRegByName(StringRef)
static constexpr unsigned SVEMaxBitsPerVector
static constexpr unsigned SVEBitsPerBlock
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
static std::optional< AArch64PACKey::ID > AArch64StringToPACKeyID(StringRef Name)
Return numeric key ID for 2-letter identifier string.
TailFoldingOpts
An enum to describe what types of loops we should attempt to tail-fold: Disabled: None Reductions: Lo...
static AArch64Layout::VectorLayout AArch64StringToVectorLayout(StringRef LayoutStr)
static const char * AArch64VectorLayoutToString(AArch64Layout::VectorLayout Layout)
std::optional< unsigned > getSVEPredPatternFromNumElements(unsigned MinNumElts)
Return specific VL predicate pattern based on the number of elements.
static bool atomicBarrierDroppedOnZero(unsigned Opcode)
static MCRegister getXRegFromWReg(MCRegister Reg)
static MCRegister getXRegFromXRegTuple(MCRegister RegTuple)
static MCRegister getWRegFromXReg(MCRegister Reg)
unsigned getNumElementsFromSVEPredPattern(unsigned Pattern)
Return the number of active elements for VL1 to VL256 predicate pattern, zero for all other patterns.
static MCRegister getDRegFromBReg(MCRegister Reg)
static MCRegister getBRegFromDReg(MCRegister Reg)
static StringRef AArch64PACKeyIDToString(AArch64PACKey::ID KeyID)
Return 2-letter identifier string for numeric key ID.
#define N
bool haveFeatures(FeatureBitset ActiveFeatures) const
bool haveFeatures(FeatureBitset ActiveFeatures) const
constexpr SysAliasImm(const char *N, uint16_t E, uint16_t I)
constexpr SysAliasImm(const char *N, uint16_t E, uint16_t I, FeatureBitset F)
constexpr SysAliasReg(const char *N, uint16_t E, bool R, FeatureBitset F)
constexpr SysAliasReg(const char *N, uint16_t E, bool R)
bool haveFeatures(FeatureBitset ActiveFeatures) const
constexpr SysAlias(const char *N, uint16_t E)
FeatureBitset getRequiredFeatures() const
const char * Name
FeatureBitset FeaturesRequired
constexpr SysAlias(const char *N, uint16_t E, FeatureBitset F)