clang 19.0.0git
AArch64.cpp
Go to the documentation of this file.
1//===--- AArch64.cpp - Implement AArch64 target feature support -----------===//
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 implements AArch64 TargetInfo objects.
10//
11//===----------------------------------------------------------------------===//
12
13#include "AArch64.h"
18#include "llvm/ADT/APSInt.h"
19#include "llvm/ADT/ArrayRef.h"
20#include "llvm/ADT/StringExtras.h"
21#include "llvm/ADT/StringSwitch.h"
22#include "llvm/TargetParser/AArch64TargetParser.h"
23#include "llvm/TargetParser/ARMTargetParserCommon.h"
24#include <optional>
25
26using namespace clang;
27using namespace clang::targets;
28
29static constexpr Builtin::Info BuiltinInfo[] = {
30#define BUILTIN(ID, TYPE, ATTRS) \
31 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
32#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
33 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
34#include "clang/Basic/BuiltinsNEON.def"
35
36#define BUILTIN(ID, TYPE, ATTRS) \
37 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
38#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
39 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
40#include "clang/Basic/BuiltinsSVE.def"
41
42#define BUILTIN(ID, TYPE, ATTRS) \
43 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
44#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
45 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
46#include "clang/Basic/BuiltinsSME.def"
47
48#define BUILTIN(ID, TYPE, ATTRS) \
49 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
50#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
51 {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG},
52#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
53 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
54#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
55 {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS},
56#include "clang/Basic/BuiltinsAArch64.def"
57};
58
60 if (*ArchInfo == llvm::AArch64::ARMV8R) {
61 HasDotProd = true;
62 HasDIT = true;
63 HasFlagM = true;
64 HasRCPC = true;
65 FPU |= NeonMode;
66 HasCCPP = true;
67 HasCRC = true;
68 HasLSE = true;
69 HasRDM = true;
70 } else if (ArchInfo->Version.getMajor() == 8) {
71 if (ArchInfo->Version.getMinor() >= 7u) {
72 HasWFxT = true;
73 }
74 if (ArchInfo->Version.getMinor() >= 6u) {
75 HasBFloat16 = true;
76 HasMatMul = true;
77 }
78 if (ArchInfo->Version.getMinor() >= 5u) {
79 HasAlternativeNZCV = true;
80 HasFRInt3264 = true;
81 HasSSBS = true;
82 HasSB = true;
83 HasPredRes = true;
84 HasBTI = true;
85 }
86 if (ArchInfo->Version.getMinor() >= 4u) {
87 HasDotProd = true;
88 HasDIT = true;
89 HasFlagM = true;
90 }
91 if (ArchInfo->Version.getMinor() >= 3u) {
92 HasRCPC = true;
93 FPU |= NeonMode;
94 }
95 if (ArchInfo->Version.getMinor() >= 2u) {
96 HasCCPP = true;
97 }
98 if (ArchInfo->Version.getMinor() >= 1u) {
99 HasCRC = true;
100 HasLSE = true;
101 HasRDM = true;
102 }
103 } else if (ArchInfo->Version.getMajor() == 9) {
104 if (ArchInfo->Version.getMinor() >= 2u) {
105 HasWFxT = true;
106 }
107 if (ArchInfo->Version.getMinor() >= 1u) {
108 HasBFloat16 = true;
109 HasMatMul = true;
110 }
111 FPU |= SveMode;
112 HasSVE2 = true;
113 HasFullFP16 = true;
114 HasAlternativeNZCV = true;
115 HasFRInt3264 = true;
116 HasSSBS = true;
117 HasSB = true;
118 HasPredRes = true;
119 HasBTI = true;
120 HasDotProd = true;
121 HasDIT = true;
122 HasFlagM = true;
123 HasRCPC = true;
124 FPU |= NeonMode;
125 HasCCPP = true;
126 HasCRC = true;
127 HasLSE = true;
128 HasRDM = true;
129 }
130}
131
132AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
133 const TargetOptions &Opts)
134 : TargetInfo(Triple), ABI("aapcs") {
135 if (getTriple().isOSOpenBSD()) {
138 } else {
139 if (!getTriple().isOSDarwin() && !getTriple().isOSNetBSD())
141
144 }
145
146 // All AArch64 implementations support ARMv8 FP, which makes half a legal type.
147 HasLegalHalfType = true;
148 HalfArgsAndReturns = true;
149 HasFloat16 = true;
150 HasStrictFP = true;
151
152 if (Triple.isArch64Bit())
154 else
156
157 BitIntMaxAlign = 128;
158 MaxVectorAlign = 128;
161
163 LongDoubleFormat = &llvm::APFloat::IEEEquad();
164
166 BFloat16Format = &llvm::APFloat::BFloat();
167
168 // Make __builtin_ms_va_list available.
169 HasBuiltinMSVaList = true;
170
171 // Make the SVE types available. Note that this deliberately doesn't
172 // depend on SveMode, since in principle it should be possible to turn
173 // SVE on and off within a translation unit. It should also be possible
174 // to compile the global declaration:
175 //
176 // __SVInt8_t *ptr;
177 //
178 // even without SVE.
179 HasAArch64SVETypes = true;
180
181 // {} in inline assembly are neon specifiers, not assembly variant
182 // specifiers.
183 NoAsmVariants = true;
184
185 // AAPCS gives rules for bitfields. 7.1.7 says: "The container type
186 // contributes to the alignment of the containing aggregate in the same way
187 // a plain (non bit-field) member of that type would, without exception for
188 // zero-sized or anonymous bit-fields."
189 assert(UseBitFieldTypeAlignment && "bitfields affect type alignment");
191
192 HasUnalignedAccess = true;
193
194 // AArch64 targets default to using the ARM C++ ABI.
195 TheCXXABI.set(TargetCXXABI::GenericAArch64);
196
197 if (Triple.getOS() == llvm::Triple::Linux)
198 this->MCountName = "\01_mcount";
199 else if (Triple.getOS() == llvm::Triple::UnknownOS)
200 this->MCountName =
201 Opts.EABIVersion == llvm::EABI::GNU ? "\01_mcount" : "mcount";
202}
203
204StringRef AArch64TargetInfo::getABI() const { return ABI; }
205
206bool AArch64TargetInfo::setABI(const std::string &Name) {
207 if (Name != "aapcs" && Name != "aapcs-soft" && Name != "darwinpcs")
208 return false;
209
210 ABI = Name;
211 return true;
212}
213
215 if (hasFeature("fp") && ABI == "aapcs-soft") {
216 // aapcs-soft is not allowed for targets with an FPU, to avoid there being
217 // two incomatible ABIs.
218 Diags.Report(diag::err_target_unsupported_abi_with_fpu) << ABI;
219 return false;
220 }
221 return true;
222}
223
224bool AArch64TargetInfo::validateBranchProtection(StringRef Spec, StringRef,
226 StringRef &Err) const {
227 llvm::ARM::ParsedBranchProtection PBP;
228 if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err, HasPAuthLR))
229 return false;
230
231 BPI.SignReturnAddr =
232 llvm::StringSwitch<LangOptions::SignReturnAddressScopeKind>(PBP.Scope)
236
237 if (PBP.Key == "a_key")
239 else
241
242 BPI.BranchTargetEnforcement = PBP.BranchTargetEnforcement;
243 BPI.BranchProtectionPAuthLR = PBP.BranchProtectionPAuthLR;
244 BPI.GuardedControlStack = PBP.GuardedControlStack;
245 return true;
246}
247
248bool AArch64TargetInfo::isValidCPUName(StringRef Name) const {
249 return Name == "generic" || llvm::AArch64::parseCpu(Name);
250}
251
252bool AArch64TargetInfo::setCPU(const std::string &Name) {
253 return isValidCPUName(Name);
254}
255
257 SmallVectorImpl<StringRef> &Values) const {
258 llvm::AArch64::fillValidCPUArchList(Values);
259}
260
262 MacroBuilder &Builder) const {
263 Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
264}
265
267 MacroBuilder &Builder) const {
268 // Also include the ARMv8.1 defines
269 getTargetDefinesARMV81A(Opts, Builder);
270}
271
273 MacroBuilder &Builder) const {
274 Builder.defineMacro("__ARM_FEATURE_COMPLEX", "1");
275 Builder.defineMacro("__ARM_FEATURE_JCVT", "1");
276 // Also include the Armv8.2 defines
277 getTargetDefinesARMV82A(Opts, Builder);
278}
279
281 MacroBuilder &Builder) const {
282 // Also include the Armv8.3 defines
283 getTargetDefinesARMV83A(Opts, Builder);
284}
285
287 MacroBuilder &Builder) const {
288 Builder.defineMacro("__ARM_FEATURE_FRINT", "1");
289 Builder.defineMacro("__ARM_FEATURE_BTI", "1");
290 // Also include the Armv8.4 defines
291 getTargetDefinesARMV84A(Opts, Builder);
292}
293
295 MacroBuilder &Builder) const {
296 // Also include the Armv8.5 defines
297 // FIXME: Armv8.6 makes the following extensions mandatory:
298 // - __ARM_FEATURE_BF16
299 // - __ARM_FEATURE_MATMUL_INT8
300 // Handle them here.
301 getTargetDefinesARMV85A(Opts, Builder);
302}
303
305 MacroBuilder &Builder) const {
306 // Also include the Armv8.6 defines
307 getTargetDefinesARMV86A(Opts, Builder);
308}
309
311 MacroBuilder &Builder) const {
312 // Also include the Armv8.7 defines
313 getTargetDefinesARMV87A(Opts, Builder);
314}
315
317 MacroBuilder &Builder) const {
318 // Also include the Armv8.8 defines
319 getTargetDefinesARMV88A(Opts, Builder);
320}
321
323 MacroBuilder &Builder) const {
324 // Armv9-A maps to Armv8.5-A
325 getTargetDefinesARMV85A(Opts, Builder);
326}
327
329 MacroBuilder &Builder) const {
330 // Armv9.1-A maps to Armv8.6-A
331 getTargetDefinesARMV86A(Opts, Builder);
332}
333
335 MacroBuilder &Builder) const {
336 // Armv9.2-A maps to Armv8.7-A
337 getTargetDefinesARMV87A(Opts, Builder);
338}
339
341 MacroBuilder &Builder) const {
342 // Armv9.3-A maps to Armv8.8-A
343 getTargetDefinesARMV88A(Opts, Builder);
344}
345
347 MacroBuilder &Builder) const {
348 // Armv9.4-A maps to Armv8.9-A
349 getTargetDefinesARMV89A(Opts, Builder);
350}
351
353 MacroBuilder &Builder) const {
354 // Armv9.5-A does not have a v8.* equivalent, but is a superset of v9.4-A.
355 getTargetDefinesARMV94A(Opts, Builder);
356}
357
359 MacroBuilder &Builder) const {
360 // Target identification.
361 if (getTriple().isWindowsArm64EC()) {
362 // Define the same set of macros as would be defined on x86_64 to ensure that
363 // ARM64EC datatype layouts match those of x86_64 compiled code
364 Builder.defineMacro("__amd64__");
365 Builder.defineMacro("__amd64");
366 Builder.defineMacro("__x86_64");
367 Builder.defineMacro("__x86_64__");
368 Builder.defineMacro("__arm64ec__");
369 } else {
370 Builder.defineMacro("__aarch64__");
371 }
372
373 // Inline assembly supports AArch64 flag outputs.
374 Builder.defineMacro("__GCC_ASM_FLAG_OUTPUTS__");
375
376 std::string CodeModel = getTargetOpts().CodeModel;
377 if (CodeModel == "default")
378 CodeModel = "small";
379 for (char &c : CodeModel)
380 c = toupper(c);
381 Builder.defineMacro("__AARCH64_CMODEL_" + CodeModel + "__");
382
383 // ACLE predefines. Many can only have one possible value on v8 AArch64.
384 Builder.defineMacro("__ARM_ACLE", "200");
385 Builder.defineMacro("__ARM_ARCH",
386 std::to_string(ArchInfo->Version.getMajor()));
387 Builder.defineMacro("__ARM_ARCH_PROFILE",
388 std::string("'") + (char)ArchInfo->Profile + "'");
389
390 Builder.defineMacro("__ARM_64BIT_STATE", "1");
391 Builder.defineMacro("__ARM_PCS_AAPCS64", "1");
392 Builder.defineMacro("__ARM_ARCH_ISA_A64", "1");
393
394 Builder.defineMacro("__ARM_FEATURE_CLZ", "1");
395 Builder.defineMacro("__ARM_FEATURE_FMA", "1");
396 Builder.defineMacro("__ARM_FEATURE_LDREX", "0xF");
397 Builder.defineMacro("__ARM_FEATURE_IDIV", "1"); // As specified in ACLE
398 Builder.defineMacro("__ARM_FEATURE_DIV"); // For backwards compatibility
399 Builder.defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN", "1");
400 Builder.defineMacro("__ARM_FEATURE_DIRECTED_ROUNDING", "1");
401
402 Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4");
403
404 // These macros are set when Clang can parse declarations with these
405 // attributes.
406 Builder.defineMacro("__ARM_STATE_ZA", "1");
407 Builder.defineMacro("__ARM_STATE_ZT0", "1");
408
409 // 0xe implies support for half, single and double precision operations.
410 if (FPU & FPUMode)
411 Builder.defineMacro("__ARM_FP", "0xE");
412
413 // PCS specifies this for SysV variants, which is all we support. Other ABIs
414 // may choose __ARM_FP16_FORMAT_ALTERNATIVE.
415 Builder.defineMacro("__ARM_FP16_FORMAT_IEEE", "1");
416 Builder.defineMacro("__ARM_FP16_ARGS", "1");
417
418 if (Opts.UnsafeFPMath)
419 Builder.defineMacro("__ARM_FP_FAST", "1");
420
421 Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
422 Twine(Opts.WCharSize ? Opts.WCharSize : 4));
423
424 Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : "4");
425
426 if (FPU & NeonMode) {
427 Builder.defineMacro("__ARM_NEON", "1");
428 // 64-bit NEON supports half, single and double precision operations.
429 Builder.defineMacro("__ARM_NEON_FP", "0xE");
430 }
431
432 if (FPU & SveMode)
433 Builder.defineMacro("__ARM_FEATURE_SVE", "1");
434
435 if ((FPU & NeonMode) && (FPU & SveMode))
436 Builder.defineMacro("__ARM_NEON_SVE_BRIDGE", "1");
437
438 if (HasSVE2)
439 Builder.defineMacro("__ARM_FEATURE_SVE2", "1");
440
441 if (HasSVE2 && HasSVE2AES)
442 Builder.defineMacro("__ARM_FEATURE_SVE2_AES", "1");
443
444 if (HasSVE2 && HasSVE2BitPerm)
445 Builder.defineMacro("__ARM_FEATURE_SVE2_BITPERM", "1");
446
447 if (HasSVE2 && HasSVE2SHA3)
448 Builder.defineMacro("__ARM_FEATURE_SVE2_SHA3", "1");
449
450 if (HasSVE2 && HasSVE2SM4)
451 Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
452
453 if (HasSME) {
454 Builder.defineMacro("__ARM_FEATURE_SME");
455 Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
456 }
457
458 if (HasSME2) {
459 Builder.defineMacro("__ARM_FEATURE_SME");
460 Builder.defineMacro("__ARM_FEATURE_SME2");
461 Builder.defineMacro("__ARM_FEATURE_LOCALLY_STREAMING", "1");
462 }
463
464 if (HasCRC)
465 Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
466
467 if (HasRCPC3)
468 Builder.defineMacro("__ARM_FEATURE_RCPC", "3");
469 else if (HasRCPC)
470 Builder.defineMacro("__ARM_FEATURE_RCPC", "1");
471
472 if (HasFMV)
473 Builder.defineMacro("__HAVE_FUNCTION_MULTI_VERSIONING", "1");
474
475 // The __ARM_FEATURE_CRYPTO is deprecated in favor of finer grained feature
476 // macros for AES, SHA2, SHA3 and SM4
477 if (HasAES && HasSHA2)
478 Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
479
480 if (HasAES)
481 Builder.defineMacro("__ARM_FEATURE_AES", "1");
482
483 if (HasSHA2)
484 Builder.defineMacro("__ARM_FEATURE_SHA2", "1");
485
486 if (HasSHA3) {
487 Builder.defineMacro("__ARM_FEATURE_SHA3", "1");
488 Builder.defineMacro("__ARM_FEATURE_SHA512", "1");
489 }
490
491 if (HasSM4) {
492 Builder.defineMacro("__ARM_FEATURE_SM3", "1");
493 Builder.defineMacro("__ARM_FEATURE_SM4", "1");
494 }
495
496 if (HasPAuth)
497 Builder.defineMacro("__ARM_FEATURE_PAUTH", "1");
498
499 if (HasPAuthLR)
500 Builder.defineMacro("__ARM_FEATURE_PAUTH_LR", "1");
501
503 Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
504
505 if ((FPU & NeonMode) && HasFullFP16)
506 Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
507 if (HasFullFP16)
508 Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
509
510 if (HasDotProd)
511 Builder.defineMacro("__ARM_FEATURE_DOTPROD", "1");
512
513 if (HasMTE)
514 Builder.defineMacro("__ARM_FEATURE_MEMORY_TAGGING", "1");
515
516 if (HasTME)
517 Builder.defineMacro("__ARM_FEATURE_TME", "1");
518
519 if (HasMatMul)
520 Builder.defineMacro("__ARM_FEATURE_MATMUL_INT8", "1");
521
522 if (HasLSE)
523 Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1");
524
525 if (HasBFloat16) {
526 Builder.defineMacro("__ARM_FEATURE_BF16", "1");
527 Builder.defineMacro("__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", "1");
528 Builder.defineMacro("__ARM_BF16_FORMAT_ALTERNATIVE", "1");
529 Builder.defineMacro("__ARM_FEATURE_BF16_SCALAR_ARITHMETIC", "1");
530 }
531
532 if ((FPU & SveMode) && HasBFloat16) {
533 Builder.defineMacro("__ARM_FEATURE_SVE_BF16", "1");
534 }
535
536 if ((FPU & SveMode) && HasMatmulFP64)
537 Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_FP64", "1");
538
539 if ((FPU & SveMode) && HasMatmulFP32)
540 Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_FP32", "1");
541
542 if ((FPU & SveMode) && HasMatMul)
543 Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_INT8", "1");
544
545 if ((FPU & NeonMode) && HasFP16FML)
546 Builder.defineMacro("__ARM_FEATURE_FP16_FML", "1");
547
548 if (Opts.hasSignReturnAddress()) {
549 // Bitmask:
550 // 0: Protection using the A key
551 // 1: Protection using the B key
552 // 2: Protection including leaf functions
553 // 3: Protection using PC as a diversifier
554 unsigned Value = 0;
555
557 Value |= (1 << 0);
558 else
559 Value |= (1 << 1);
560
562 Value |= (1 << 2);
563
564 if (Opts.BranchProtectionPAuthLR)
565 Value |= (1 << 3);
566
567 Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", std::to_string(Value));
568 }
569
570 if (Opts.BranchTargetEnforcement)
571 Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
572
573 if (Opts.GuardedControlStack)
574 Builder.defineMacro("__ARM_FEATURE_GCS_DEFAULT", "1");
575
576 if (HasLS64)
577 Builder.defineMacro("__ARM_FEATURE_LS64", "1");
578
579 if (HasRandGen)
580 Builder.defineMacro("__ARM_FEATURE_RNG", "1");
581
582 if (HasMOPS)
583 Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
584
585 if (HasD128)
586 Builder.defineMacro("__ARM_FEATURE_SYSREG128", "1");
587
588 if (HasGCS)
589 Builder.defineMacro("__ARM_FEATURE_GCS", "1");
590
591 if (*ArchInfo == llvm::AArch64::ARMV8_1A)
592 getTargetDefinesARMV81A(Opts, Builder);
593 else if (*ArchInfo == llvm::AArch64::ARMV8_2A)
594 getTargetDefinesARMV82A(Opts, Builder);
595 else if (*ArchInfo == llvm::AArch64::ARMV8_3A)
596 getTargetDefinesARMV83A(Opts, Builder);
597 else if (*ArchInfo == llvm::AArch64::ARMV8_4A)
598 getTargetDefinesARMV84A(Opts, Builder);
599 else if (*ArchInfo == llvm::AArch64::ARMV8_5A)
600 getTargetDefinesARMV85A(Opts, Builder);
601 else if (*ArchInfo == llvm::AArch64::ARMV8_6A)
602 getTargetDefinesARMV86A(Opts, Builder);
603 else if (*ArchInfo == llvm::AArch64::ARMV8_7A)
604 getTargetDefinesARMV87A(Opts, Builder);
605 else if (*ArchInfo == llvm::AArch64::ARMV8_8A)
606 getTargetDefinesARMV88A(Opts, Builder);
607 else if (*ArchInfo == llvm::AArch64::ARMV8_9A)
608 getTargetDefinesARMV89A(Opts, Builder);
609 else if (*ArchInfo == llvm::AArch64::ARMV9A)
610 getTargetDefinesARMV9A(Opts, Builder);
611 else if (*ArchInfo == llvm::AArch64::ARMV9_1A)
612 getTargetDefinesARMV91A(Opts, Builder);
613 else if (*ArchInfo == llvm::AArch64::ARMV9_2A)
614 getTargetDefinesARMV92A(Opts, Builder);
615 else if (*ArchInfo == llvm::AArch64::ARMV9_3A)
616 getTargetDefinesARMV93A(Opts, Builder);
617 else if (*ArchInfo == llvm::AArch64::ARMV9_4A)
618 getTargetDefinesARMV94A(Opts, Builder);
619 else if (*ArchInfo == llvm::AArch64::ARMV9_5A)
620 getTargetDefinesARMV95A(Opts, Builder);
621
622 // All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8|16) builtins work.
623 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
624 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
625 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
626 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
627 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
628
629 // Allow detection of fast FMA support.
630 Builder.defineMacro("__FP_FAST_FMA", "1");
631 Builder.defineMacro("__FP_FAST_FMAF", "1");
632
633 // C/C++ operators work on both VLS and VLA SVE types
634 if (FPU & SveMode)
635 Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS", "2");
636
637 if (Opts.VScaleMin && Opts.VScaleMin == Opts.VScaleMax) {
638 Builder.defineMacro("__ARM_FEATURE_SVE_BITS", Twine(Opts.VScaleMin * 128));
639 }
640}
641
645}
646
647std::optional<std::pair<unsigned, unsigned>>
649 if (LangOpts.VScaleMin || LangOpts.VScaleMax)
650 return std::pair<unsigned, unsigned>(
651 LangOpts.VScaleMin ? LangOpts.VScaleMin : 1, LangOpts.VScaleMax);
652
653 if (hasFeature("sve"))
654 return std::pair<unsigned, unsigned>(1, 16);
655
656 return std::nullopt;
657}
658
659unsigned AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const {
660 if (Name == "default")
661 return 0;
662 if (auto Ext = llvm::AArch64::parseArchExtension(Name))
663 return Ext->FmvPriority;
664 return 0;
665}
666
668 // Take the maximum priority as per feature cost, so more features win.
669 return llvm::AArch64::ExtensionInfo::MaxFMVPriority;
670}
671
673 if (auto Ext = llvm::AArch64::parseArchExtension(Name))
674 return !Ext->DependentFeatures.empty();
675 return false;
676}
677
678StringRef AArch64TargetInfo::getFeatureDependencies(StringRef Name) const {
679 if (auto Ext = llvm::AArch64::parseArchExtension(Name))
680 return Ext->DependentFeatures;
681 return StringRef();
682}
683
684bool AArch64TargetInfo::validateCpuSupports(StringRef FeatureStr) const {
685 // CPU features might be separated by '+', extract them and check
687 FeatureStr.split(Features, "+");
688 for (auto &Feature : Features)
689 if (!llvm::AArch64::parseArchExtension(Feature.trim()).has_value())
690 return false;
691 return true;
692}
693
694bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
695 return llvm::StringSwitch<bool>(Feature)
696 .Cases("aarch64", "arm64", "arm", true)
697 .Case("fmv", HasFMV)
698 .Case("fp", FPU & FPUMode)
699 .Cases("neon", "simd", FPU & NeonMode)
700 .Case("jscvt", HasJSCVT)
701 .Case("fcma", HasFCMA)
702 .Case("rng", HasRandGen)
703 .Case("flagm", HasFlagM)
704 .Case("flagm2", HasAlternativeNZCV)
705 .Case("fp16fml", HasFP16FML)
706 .Case("dotprod", HasDotProd)
707 .Case("sm4", HasSM4)
708 .Case("rdm", HasRDM)
709 .Case("lse", HasLSE)
710 .Case("crc", HasCRC)
711 .Case("sha2", HasSHA2)
712 .Case("sha3", HasSHA3)
713 .Cases("aes", "pmull", HasAES)
714 .Cases("fp16", "fullfp16", HasFullFP16)
715 .Case("dit", HasDIT)
716 .Case("dpb", HasCCPP)
717 .Case("dpb2", HasCCDP)
718 .Case("rcpc", HasRCPC)
719 .Case("frintts", HasFRInt3264)
720 .Case("i8mm", HasMatMul)
721 .Case("bf16", HasBFloat16)
722 .Case("sve", FPU & SveMode)
723 .Case("sve-bf16", FPU & SveMode && HasBFloat16)
724 .Case("sve-i8mm", FPU & SveMode && HasMatMul)
725 .Case("f32mm", FPU & SveMode && HasMatmulFP32)
726 .Case("f64mm", FPU & SveMode && HasMatmulFP64)
727 .Case("sve2", FPU & SveMode && HasSVE2)
728 .Case("sve2-pmull128", FPU & SveMode && HasSVE2AES)
729 .Case("sve2-bitperm", FPU & SveMode && HasSVE2BitPerm)
730 .Case("sve2-sha3", FPU & SveMode && HasSVE2SHA3)
731 .Case("sve2-sm4", FPU & SveMode && HasSVE2SM4)
732 .Case("sme", HasSME)
733 .Case("sme2", HasSME2)
734 .Case("sme-f64f64", HasSMEF64F64)
735 .Case("sme-i16i64", HasSMEI16I64)
736 .Case("sme-fa64", HasSMEFA64)
737 .Cases("memtag", "memtag2", HasMTE)
738 .Case("sb", HasSB)
739 .Case("predres", HasPredRes)
740 .Cases("ssbs", "ssbs2", HasSSBS)
741 .Case("bti", HasBTI)
742 .Cases("ls64", "ls64_v", "ls64_accdata", HasLS64)
743 .Case("wfxt", HasWFxT)
744 .Case("rcpc3", HasRCPC3)
745 .Default(false);
746}
747
748void AArch64TargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
749 StringRef Name, bool Enabled) const {
750 Features[Name] = Enabled;
751 // If the feature is an architecture feature (like v8.2a), add all previous
752 // architecture versions and any dependant target features.
753 const std::optional<llvm::AArch64::ArchInfo> ArchInfo =
754 llvm::AArch64::ArchInfo::findBySubArch(Name);
755
756 if (!ArchInfo)
757 return; // Not an architecture, nothing more to do.
758
759 // Disabling an architecture feature does not affect dependent features
760 if (!Enabled)
761 return;
762
763 for (const auto *OtherArch : llvm::AArch64::ArchInfos)
764 if (ArchInfo->implies(*OtherArch))
765 Features[OtherArch->getSubArch()] = true;
766
767 // Set any features implied by the architecture
768 std::vector<StringRef> CPUFeats;
769 if (llvm::AArch64::getExtensionFeatures(ArchInfo->DefaultExts, CPUFeats)) {
770 for (auto F : CPUFeats) {
771 assert(F[0] == '+' && "Expected + in target feature!");
772 Features[F.drop_front(1)] = true;
773 }
774 }
775}
776
777bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
778 DiagnosticsEngine &Diags) {
779 for (const auto &Feature : Features) {
780 if (Feature == "-fp-armv8")
781 HasNoFP = true;
782 if (Feature == "-neon")
783 HasNoNeon = true;
784 if (Feature == "-sve")
785 HasNoSVE = true;
786
787 if (Feature == "+neon" || Feature == "+fp-armv8")
788 FPU |= NeonMode;
789 if (Feature == "+jscvt") {
790 HasJSCVT = true;
791 FPU |= NeonMode;
792 }
793 if (Feature == "+fcma") {
794 HasFCMA = true;
795 FPU |= NeonMode;
796 }
797
798 if (Feature == "+sve") {
799 FPU |= NeonMode;
800 FPU |= SveMode;
801 HasFullFP16 = true;
802 }
803 if (Feature == "+sve2") {
804 FPU |= NeonMode;
805 FPU |= SveMode;
806 HasFullFP16 = true;
807 HasSVE2 = true;
808 }
809 if (Feature == "+sve2-aes") {
810 FPU |= NeonMode;
811 FPU |= SveMode;
812 HasFullFP16 = true;
813 HasSVE2 = true;
814 HasSVE2AES = true;
815 }
816 if (Feature == "+sve2-sha3") {
817 FPU |= NeonMode;
818 FPU |= SveMode;
819 HasFullFP16 = true;
820 HasSVE2 = true;
821 HasSVE2SHA3 = true;
822 }
823 if (Feature == "+sve2-sm4") {
824 FPU |= NeonMode;
825 FPU |= SveMode;
826 HasFullFP16 = true;
827 HasSVE2 = true;
828 HasSVE2SM4 = true;
829 }
830 if (Feature == "+sve2-bitperm") {
831 FPU |= NeonMode;
832 FPU |= SveMode;
833 HasFullFP16 = true;
834 HasSVE2 = true;
835 HasSVE2BitPerm = true;
836 }
837 if (Feature == "+f32mm") {
838 FPU |= NeonMode;
839 FPU |= SveMode;
840 HasFullFP16 = true;
841 HasMatmulFP32 = true;
842 }
843 if (Feature == "+f64mm") {
844 FPU |= NeonMode;
845 FPU |= SveMode;
846 HasFullFP16 = true;
847 HasMatmulFP64 = true;
848 }
849 if (Feature == "+sme") {
850 HasSME = true;
851 HasBFloat16 = true;
852 HasFullFP16 = true;
853 }
854 if (Feature == "+sme2") {
855 HasSME = true;
856 HasSME2 = true;
857 HasBFloat16 = true;
858 HasFullFP16 = true;
859 }
860 if (Feature == "+sme-f64f64") {
861 HasSME = true;
862 HasSMEF64F64 = true;
863 HasBFloat16 = true;
864 HasFullFP16 = true;
865 }
866 if (Feature == "+sme-i16i64") {
867 HasSME = true;
868 HasSMEI16I64 = true;
869 HasBFloat16 = true;
870 HasFullFP16 = true;
871 }
872 if (Feature == "+sme-fa64") {
873 FPU |= NeonMode;
874 FPU |= SveMode;
875 HasSME = true;
876 HasSVE2 = true;
877 HasSMEFA64 = true;
878 }
879 if (Feature == "+sb")
880 HasSB = true;
881 if (Feature == "+predres")
882 HasPredRes = true;
883 if (Feature == "+ssbs")
884 HasSSBS = true;
885 if (Feature == "+bti")
886 HasBTI = true;
887 if (Feature == "+wfxt")
888 HasWFxT = true;
889 if (Feature == "-fmv")
890 HasFMV = false;
891 if (Feature == "+crc")
892 HasCRC = true;
893 if (Feature == "+rcpc")
894 HasRCPC = true;
895 if (Feature == "+aes") {
896 FPU |= NeonMode;
897 HasAES = true;
898 }
899 if (Feature == "+sha2") {
900 FPU |= NeonMode;
901 HasSHA2 = true;
902 }
903 if (Feature == "+sha3") {
904 FPU |= NeonMode;
905 HasSHA2 = true;
906 HasSHA3 = true;
907 }
908 if (Feature == "+rdm") {
909 FPU |= NeonMode;
910 HasRDM = true;
911 }
912 if (Feature == "+dit")
913 HasDIT = true;
914 if (Feature == "+cccp")
915 HasCCPP = true;
916 if (Feature == "+ccdp") {
917 HasCCPP = true;
918 HasCCDP = true;
919 }
920 if (Feature == "+fptoint")
921 HasFRInt3264 = true;
922 if (Feature == "+sm4") {
923 FPU |= NeonMode;
924 HasSM4 = true;
925 }
926 if (Feature == "+strict-align")
927 HasUnalignedAccess = false;
928
929 // All predecessor archs are added but select the latest one for ArchKind.
930 if (Feature == "+v8a" && ArchInfo->Version < llvm::AArch64::ARMV8A.Version)
931 ArchInfo = &llvm::AArch64::ARMV8A;
932 if (Feature == "+v8.1a" &&
933 ArchInfo->Version < llvm::AArch64::ARMV8_1A.Version)
934 ArchInfo = &llvm::AArch64::ARMV8_1A;
935 if (Feature == "+v8.2a" &&
936 ArchInfo->Version < llvm::AArch64::ARMV8_2A.Version)
937 ArchInfo = &llvm::AArch64::ARMV8_2A;
938 if (Feature == "+v8.3a" &&
939 ArchInfo->Version < llvm::AArch64::ARMV8_3A.Version)
940 ArchInfo = &llvm::AArch64::ARMV8_3A;
941 if (Feature == "+v8.4a" &&
942 ArchInfo->Version < llvm::AArch64::ARMV8_4A.Version)
943 ArchInfo = &llvm::AArch64::ARMV8_4A;
944 if (Feature == "+v8.5a" &&
945 ArchInfo->Version < llvm::AArch64::ARMV8_5A.Version)
946 ArchInfo = &llvm::AArch64::ARMV8_5A;
947 if (Feature == "+v8.6a" &&
948 ArchInfo->Version < llvm::AArch64::ARMV8_6A.Version)
949 ArchInfo = &llvm::AArch64::ARMV8_6A;
950 if (Feature == "+v8.7a" &&
951 ArchInfo->Version < llvm::AArch64::ARMV8_7A.Version)
952 ArchInfo = &llvm::AArch64::ARMV8_7A;
953 if (Feature == "+v8.8a" &&
954 ArchInfo->Version < llvm::AArch64::ARMV8_8A.Version)
955 ArchInfo = &llvm::AArch64::ARMV8_8A;
956 if (Feature == "+v8.9a" &&
957 ArchInfo->Version < llvm::AArch64::ARMV8_9A.Version)
958 ArchInfo = &llvm::AArch64::ARMV8_9A;
959 if (Feature == "+v9a" && ArchInfo->Version < llvm::AArch64::ARMV9A.Version)
960 ArchInfo = &llvm::AArch64::ARMV9A;
961 if (Feature == "+v9.1a" &&
962 ArchInfo->Version < llvm::AArch64::ARMV9_1A.Version)
963 ArchInfo = &llvm::AArch64::ARMV9_1A;
964 if (Feature == "+v9.2a" &&
965 ArchInfo->Version < llvm::AArch64::ARMV9_2A.Version)
966 ArchInfo = &llvm::AArch64::ARMV9_2A;
967 if (Feature == "+v9.3a" &&
968 ArchInfo->Version < llvm::AArch64::ARMV9_3A.Version)
969 ArchInfo = &llvm::AArch64::ARMV9_3A;
970 if (Feature == "+v9.4a" &&
971 ArchInfo->Version < llvm::AArch64::ARMV9_4A.Version)
972 ArchInfo = &llvm::AArch64::ARMV9_4A;
973 if (Feature == "+v9.5a" &&
974 ArchInfo->Version < llvm::AArch64::ARMV9_5A.Version)
975 ArchInfo = &llvm::AArch64::ARMV9_5A;
976 if (Feature == "+v8r")
977 ArchInfo = &llvm::AArch64::ARMV8R;
978 if (Feature == "+fullfp16") {
979 FPU |= NeonMode;
980 HasFullFP16 = true;
981 }
982 if (Feature == "+dotprod") {
983 FPU |= NeonMode;
984 HasDotProd = true;
985 }
986 if (Feature == "+fp16fml") {
987 FPU |= NeonMode;
988 HasFullFP16 = true;
989 HasFP16FML = true;
990 }
991 if (Feature == "+mte")
992 HasMTE = true;
993 if (Feature == "+tme")
994 HasTME = true;
995 if (Feature == "+pauth")
996 HasPAuth = true;
997 if (Feature == "+i8mm")
998 HasMatMul = true;
999 if (Feature == "+bf16")
1000 HasBFloat16 = true;
1001 if (Feature == "+lse")
1002 HasLSE = true;
1003 if (Feature == "+ls64")
1004 HasLS64 = true;
1005 if (Feature == "+rand")
1006 HasRandGen = true;
1007 if (Feature == "+flagm")
1008 HasFlagM = true;
1009 if (Feature == "+altnzcv") {
1010 HasFlagM = true;
1011 HasAlternativeNZCV = true;
1012 }
1013 if (Feature == "+mops")
1014 HasMOPS = true;
1015 if (Feature == "+d128")
1016 HasD128 = true;
1017 if (Feature == "+gcs")
1018 HasGCS = true;
1019 if (Feature == "+rcpc3")
1020 HasRCPC3 = true;
1021 if (Feature == "+pauth-lr") {
1022 HasPAuthLR = true;
1023 HasPAuth = true;
1024 }
1025 }
1026
1027 // Check features that are manually disabled by command line options.
1028 // This needs to be checked after architecture-related features are handled,
1029 // making sure they are properly disabled when required.
1030 for (const auto &Feature : Features) {
1031 if (Feature == "-d128")
1032 HasD128 = false;
1033 }
1034
1035 setDataLayout();
1037
1038 if (HasNoFP) {
1039 FPU &= ~FPUMode;
1040 FPU &= ~NeonMode;
1041 FPU &= ~SveMode;
1042 }
1043 if (HasNoNeon) {
1044 FPU &= ~NeonMode;
1045 FPU &= ~SveMode;
1046 }
1047 if (HasNoSVE)
1048 FPU &= ~SveMode;
1049
1050 return true;
1051}
1052
1054 llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
1055 const std::vector<std::string> &FeaturesVec) const {
1056 std::vector<std::string> UpdatedFeaturesVec;
1057 // Parse the CPU and add any implied features.
1058 std::optional<llvm::AArch64::CpuInfo> CpuInfo = llvm::AArch64::parseCpu(CPU);
1059 if (CpuInfo) {
1060 auto Exts = CpuInfo->getImpliedExtensions();
1061 std::vector<StringRef> CPUFeats;
1062 llvm::AArch64::getExtensionFeatures(Exts, CPUFeats);
1063 for (auto F : CPUFeats) {
1064 assert((F[0] == '+' || F[0] == '-') && "Expected +/- in target feature!");
1065 UpdatedFeaturesVec.push_back(F.str());
1066 }
1067 }
1068
1069 // Process target and dependent features. This is done in two loops collecting
1070 // them into UpdatedFeaturesVec: first to add dependent '+'features, second to
1071 // add target '+/-'features that can later disable some of features added on
1072 // the first loop. Function Multi Versioning features begin with '?'.
1073 for (const auto &Feature : FeaturesVec)
1074 if (((Feature[0] == '?' || Feature[0] == '+')) &&
1076 StringRef DepFeatures =
1078 SmallVector<StringRef, 1> AttrFeatures;
1079 DepFeatures.split(AttrFeatures, ",");
1080 for (auto F : AttrFeatures)
1081 UpdatedFeaturesVec.push_back(F.str());
1082 }
1083 for (const auto &Feature : FeaturesVec)
1084 if (Feature[0] != '?') {
1085 std::string UpdatedFeature = Feature;
1086 if (Feature[0] == '+') {
1087 std::optional<llvm::AArch64::ExtensionInfo> Extension =
1088 llvm::AArch64::parseArchExtension(Feature.substr(1));
1089 if (Extension)
1090 UpdatedFeature = Extension->Feature.str();
1091 }
1092 UpdatedFeaturesVec.push_back(UpdatedFeature);
1093 }
1094
1095 return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
1096}
1097
1098// Parse AArch64 Target attributes, which are a comma separated list of:
1099// "arch=<arch>" - parsed to features as per -march=..
1100// "cpu=<cpu>" - parsed to features as per -mcpu=.., with CPU set to <cpu>
1101// "tune=<cpu>" - TuneCPU set to <cpu>
1102// "feature", "no-feature" - Add (or remove) feature.
1103// "+feature", "+nofeature" - Add (or remove) feature.
1105 ParsedTargetAttr Ret;
1106 if (Features == "default")
1107 return Ret;
1108 SmallVector<StringRef, 1> AttrFeatures;
1109 Features.split(AttrFeatures, ",");
1110 bool FoundArch = false;
1111
1112 auto SplitAndAddFeatures = [](StringRef FeatString,
1113 std::vector<std::string> &Features) {
1114 SmallVector<StringRef, 8> SplitFeatures;
1115 FeatString.split(SplitFeatures, StringRef("+"), -1, false);
1116 for (StringRef Feature : SplitFeatures) {
1117 StringRef FeatureName = llvm::AArch64::getArchExtFeature(Feature);
1118 if (!FeatureName.empty())
1119 Features.push_back(FeatureName.str());
1120 else
1121 // Pushing the original feature string to give a sema error later on
1122 // when they get checked.
1123 if (Feature.starts_with("no"))
1124 Features.push_back("-" + Feature.drop_front(2).str());
1125 else
1126 Features.push_back("+" + Feature.str());
1127 }
1128 };
1129
1130 for (auto &Feature : AttrFeatures) {
1131 Feature = Feature.trim();
1132 if (Feature.starts_with("fpmath="))
1133 continue;
1134
1135 if (Feature.starts_with("branch-protection=")) {
1136 Ret.BranchProtection = Feature.split('=').second.trim();
1137 continue;
1138 }
1139
1140 if (Feature.starts_with("arch=")) {
1141 if (FoundArch)
1142 Ret.Duplicate = "arch=";
1143 FoundArch = true;
1144 std::pair<StringRef, StringRef> Split =
1145 Feature.split("=").second.trim().split("+");
1146 const llvm::AArch64::ArchInfo *AI = llvm::AArch64::parseArch(Split.first);
1147
1148 // Parse the architecture version, adding the required features to
1149 // Ret.Features.
1150 if (!AI)
1151 continue;
1152 Ret.Features.push_back(AI->ArchFeature.str());
1153 // Add any extra features, after the +
1154 SplitAndAddFeatures(Split.second, Ret.Features);
1155 } else if (Feature.starts_with("cpu=")) {
1156 if (!Ret.CPU.empty())
1157 Ret.Duplicate = "cpu=";
1158 else {
1159 // Split the cpu string into "cpu=", "cortex-a710" and any remaining
1160 // "+feat" features.
1161 std::pair<StringRef, StringRef> Split =
1162 Feature.split("=").second.trim().split("+");
1163 Ret.CPU = Split.first;
1164 SplitAndAddFeatures(Split.second, Ret.Features);
1165 }
1166 } else if (Feature.starts_with("tune=")) {
1167 if (!Ret.Tune.empty())
1168 Ret.Duplicate = "tune=";
1169 else
1170 Ret.Tune = Feature.split("=").second.trim();
1171 } else if (Feature.starts_with("+")) {
1172 SplitAndAddFeatures(Feature, Ret.Features);
1173 } else if (Feature.starts_with("no-")) {
1174 StringRef FeatureName =
1175 llvm::AArch64::getArchExtFeature(Feature.split("-").second);
1176 if (!FeatureName.empty())
1177 Ret.Features.push_back("-" + FeatureName.drop_front(1).str());
1178 else
1179 Ret.Features.push_back("-" + Feature.split("-").second.str());
1180 } else {
1181 // Try parsing the string to the internal target feature name. If it is
1182 // invalid, add the original string (which could already be an internal
1183 // name). These should be checked later by isValidFeatureName.
1184 StringRef FeatureName = llvm::AArch64::getArchExtFeature(Feature);
1185 if (!FeatureName.empty())
1186 Ret.Features.push_back(FeatureName.str());
1187 else
1188 Ret.Features.push_back("+" + Feature.str());
1189 }
1190 }
1191 return Ret;
1192}
1193
1195 return true;
1196}
1197
1200 switch (CC) {
1201 case CC_C:
1202 case CC_Swift:
1203 case CC_SwiftAsync:
1204 case CC_PreserveMost:
1205 case CC_PreserveAll:
1206 case CC_OpenCLKernel:
1208 case CC_AArch64SVEPCS:
1209 case CC_Win64:
1210 return CCCR_OK;
1211 default:
1212 return CCCR_Warning;
1213 }
1214}
1215
1216bool AArch64TargetInfo::isCLZForZeroUndef() const { return false; }
1217
1220}
1221
1222const char *const AArch64TargetInfo::GCCRegNames[] = {
1223 // clang-format off
1224
1225 // 32-bit Integer registers
1226 "w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w11",
1227 "w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21", "w22",
1228 "w23", "w24", "w25", "w26", "w27", "w28", "w29", "w30", "wsp",
1229
1230 // 64-bit Integer registers
1231 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11",
1232 "x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19", "x20", "x21", "x22",
1233 "x23", "x24", "x25", "x26", "x27", "x28", "fp", "lr", "sp",
1234
1235 // 32-bit floating point regsisters
1236 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11",
1237 "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22",
1238 "s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
1239
1240 // 64-bit floating point regsisters
1241 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11",
1242 "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", "d22",
1243 "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
1244
1245 // Neon vector registers
1246 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
1247 "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", "v22",
1248 "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
1249
1250 // SVE vector registers
1251 "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8", "z9", "z10",
1252 "z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", "z21",
1253 "z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
1254
1255 // SVE predicate registers
1256 "p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8", "p9", "p10",
1257 "p11", "p12", "p13", "p14", "p15",
1258
1259 // SVE predicate-as-counter registers
1260 "pn0", "pn1", "pn2", "pn3", "pn4", "pn5", "pn6", "pn7", "pn8",
1261 "pn9", "pn10", "pn11", "pn12", "pn13", "pn14", "pn15",
1262
1263 // SME registers
1264 "za", "zt0",
1265
1266 // clang-format on
1267};
1268
1270 return llvm::ArrayRef(GCCRegNames);
1271}
1272
1273const TargetInfo::GCCRegAlias AArch64TargetInfo::GCCRegAliases[] = {
1274 {{"w31"}, "wsp"},
1275 {{"x31"}, "sp"},
1276 // GCC rN registers are aliases of xN registers.
1277 {{"r0"}, "x0"},
1278 {{"r1"}, "x1"},
1279 {{"r2"}, "x2"},
1280 {{"r3"}, "x3"},
1281 {{"r4"}, "x4"},
1282 {{"r5"}, "x5"},
1283 {{"r6"}, "x6"},
1284 {{"r7"}, "x7"},
1285 {{"r8"}, "x8"},
1286 {{"r9"}, "x9"},
1287 {{"r10"}, "x10"},
1288 {{"r11"}, "x11"},
1289 {{"r12"}, "x12"},
1290 {{"r13"}, "x13"},
1291 {{"r14"}, "x14"},
1292 {{"r15"}, "x15"},
1293 {{"r16"}, "x16"},
1294 {{"r17"}, "x17"},
1295 {{"r18"}, "x18"},
1296 {{"r19"}, "x19"},
1297 {{"r20"}, "x20"},
1298 {{"r21"}, "x21"},
1299 {{"r22"}, "x22"},
1300 {{"r23"}, "x23"},
1301 {{"r24"}, "x24"},
1302 {{"r25"}, "x25"},
1303 {{"r26"}, "x26"},
1304 {{"r27"}, "x27"},
1305 {{"r28"}, "x28"},
1306 {{"r29", "x29"}, "fp"},
1307 {{"r30", "x30"}, "lr"},
1308 // The S/D/Q and W/X registers overlap, but aren't really aliases; we
1309 // don't want to substitute one of these for a different-sized one.
1310};
1311
1313 return llvm::ArrayRef(GCCRegAliases);
1314}
1315
1316// Returns the length of cc constraint.
1317static unsigned matchAsmCCConstraint(const char *Name) {
1318 constexpr unsigned len = 5;
1319 auto RV = llvm::StringSwitch<unsigned>(Name)
1320 .Case("@cceq", len)
1321 .Case("@ccne", len)
1322 .Case("@cchs", len)
1323 .Case("@cccs", len)
1324 .Case("@cccc", len)
1325 .Case("@cclo", len)
1326 .Case("@ccmi", len)
1327 .Case("@ccpl", len)
1328 .Case("@ccvs", len)
1329 .Case("@ccvc", len)
1330 .Case("@cchi", len)
1331 .Case("@ccls", len)
1332 .Case("@ccge", len)
1333 .Case("@cclt", len)
1334 .Case("@ccgt", len)
1335 .Case("@ccle", len)
1336 .Default(0);
1337 return RV;
1338}
1339
1340std::string
1341AArch64TargetInfo::convertConstraint(const char *&Constraint) const {
1342 std::string R;
1343 switch (*Constraint) {
1344 case 'U': // Three-character constraint; add "@3" hint for later parsing.
1345 R = std::string("@3") + std::string(Constraint, 3);
1346 Constraint += 2;
1347 break;
1348 case '@':
1349 if (const unsigned Len = matchAsmCCConstraint(Constraint)) {
1350 std::string Converted = "{" + std::string(Constraint, Len) + "}";
1351 Constraint += Len - 1;
1352 return Converted;
1353 }
1354 return std::string(1, *Constraint);
1355 default:
1356 R = TargetInfo::convertConstraint(Constraint);
1357 break;
1358 }
1359 return R;
1360}
1361
1363 const char *&Name, TargetInfo::ConstraintInfo &Info) const {
1364 switch (*Name) {
1365 default:
1366 return false;
1367 case 'w': // Floating point and SIMD registers (V0-V31)
1368 Info.setAllowsRegister();
1369 return true;
1370 case 'I': // Constant that can be used with an ADD instruction
1371 case 'J': // Constant that can be used with a SUB instruction
1372 case 'K': // Constant that can be used with a 32-bit logical instruction
1373 case 'L': // Constant that can be used with a 64-bit logical instruction
1374 case 'M': // Constant that can be used as a 32-bit MOV immediate
1375 case 'N': // Constant that can be used as a 64-bit MOV immediate
1376 case 'Y': // Floating point constant zero
1377 case 'Z': // Integer constant zero
1378 return true;
1379 case 'Q': // A memory reference with base register and no offset
1380 Info.setAllowsMemory();
1381 return true;
1382 case 'S': // A symbolic address
1383 Info.setAllowsRegister();
1384 return true;
1385 case 'U':
1386 if (Name[1] == 'p' &&
1387 (Name[2] == 'l' || Name[2] == 'a' || Name[2] == 'h')) {
1388 // SVE predicate registers ("Upa"=P0-15, "Upl"=P0-P7, "Uph"=P8-P15)
1389 Info.setAllowsRegister();
1390 Name += 2;
1391 return true;
1392 }
1393 if (Name[1] == 'c' && (Name[2] == 'i' || Name[2] == 'j')) {
1394 // Gpr registers ("Uci"=w8-11, "Ucj"=w12-15)
1395 Info.setAllowsRegister();
1396 Name += 2;
1397 return true;
1398 }
1399 // Ump: A memory address suitable for ldp/stp in SI, DI, SF and DF modes.
1400 // Utf: A memory address suitable for ldp/stp in TF mode.
1401 // Usa: An absolute symbolic address.
1402 // Ush: The high part (bits 32:12) of a pc-relative symbolic address.
1403
1404 // Better to return an error saying that it's an unrecognised constraint
1405 // even if this is a valid constraint in gcc.
1406 return false;
1407 case 'z': // Zero register, wzr or xzr
1408 Info.setAllowsRegister();
1409 return true;
1410 case 'x': // Floating point and SIMD registers (V0-V15)
1411 Info.setAllowsRegister();
1412 return true;
1413 case 'y': // SVE registers (V0-V7)
1414 Info.setAllowsRegister();
1415 return true;
1416 case '@':
1417 // CC condition
1418 if (const unsigned Len = matchAsmCCConstraint(Name)) {
1419 Name += Len - 1;
1420 Info.setAllowsRegister();
1421 return true;
1422 }
1423 }
1424 return false;
1425}
1426
1428 StringRef Constraint, char Modifier, unsigned Size,
1429 std::string &SuggestedModifier) const {
1430 // Strip off constraint modifiers.
1431 Constraint = Constraint.ltrim("=+&");
1432
1433 switch (Constraint[0]) {
1434 default:
1435 return true;
1436 case 'z':
1437 case 'r': {
1438 switch (Modifier) {
1439 case 'x':
1440 case 'w':
1441 // For now assume that the person knows what they're
1442 // doing with the modifier.
1443 return true;
1444 default:
1445 // By default an 'r' constraint will be in the 'x'
1446 // registers.
1447 if (Size == 64)
1448 return true;
1449
1450 if (Size == 512)
1451 return HasLS64;
1452
1453 SuggestedModifier = "w";
1454 return false;
1455 }
1456 }
1457 }
1458}
1459
1460std::string_view AArch64TargetInfo::getClobbers() const { return ""; }
1461
1463 if (RegNo == 0)
1464 return 0;
1465 if (RegNo == 1)
1466 return 1;
1467 return -1;
1468}
1469
1471 const llvm::APSInt &value) const {
1472 return 0 <= value && value <= 3;
1473}
1474
1475bool AArch64TargetInfo::hasInt128Type() const { return true; }
1476
1478 const TargetOptions &Opts)
1479 : AArch64TargetInfo(Triple, Opts) {}
1480
1481void AArch64leTargetInfo::setDataLayout() {
1482 if (getTriple().isOSBinFormatMachO()) {
1483 if(getTriple().isArch32Bit())
1484 resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128-Fn32", "_");
1485 else
1486 resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128-Fn32", "_");
1487 } else
1488 resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32");
1489}
1490
1492 MacroBuilder &Builder) const {
1493 Builder.defineMacro("__AARCH64EL__");
1495}
1496
1498 const TargetOptions &Opts)
1499 : AArch64TargetInfo(Triple, Opts) {}
1500
1502 MacroBuilder &Builder) const {
1503 Builder.defineMacro("__AARCH64EB__");
1504 Builder.defineMacro("__AARCH_BIG_ENDIAN");
1505 Builder.defineMacro("__ARM_BIG_ENDIAN");
1507}
1508
1509void AArch64beTargetInfo::setDataLayout() {
1510 assert(!getTriple().isOSBinFormatMachO());
1511 resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32");
1512}
1513
1515 const TargetOptions &Opts)
1516 : WindowsTargetInfo<AArch64leTargetInfo>(Triple, Opts), Triple(Triple) {
1517
1518 // This is an LLP64 platform.
1519 // int:4, long:4, long long:8, long double:8.
1520 IntWidth = IntAlign = 32;
1521 LongWidth = LongAlign = 32;
1522 DoubleAlign = LongLongAlign = 64;
1523 LongDoubleWidth = LongDoubleAlign = 64;
1524 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
1525 IntMaxType = SignedLongLong;
1526 Int64Type = SignedLongLong;
1527 SizeType = UnsignedLongLong;
1528 PtrDiffType = SignedLongLong;
1529 IntPtrType = SignedLongLong;
1530}
1531
1533 resetDataLayout(Triple.isOSBinFormatMachO()
1534 ? "e-m:o-i64:64-i128:128-n32:64-S128-Fn32"
1535 : "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32",
1536 Triple.isOSBinFormatMachO() ? "_" : "");
1537}
1538
1542}
1543
1546 switch (CC) {
1547 case CC_X86VectorCall:
1548 if (getTriple().isWindowsArm64EC())
1549 return CCCR_OK;
1550 return CCCR_Ignore;
1551 case CC_X86StdCall:
1552 case CC_X86ThisCall:
1553 case CC_X86FastCall:
1554 return CCCR_Ignore;
1555 case CC_C:
1556 case CC_OpenCLKernel:
1557 case CC_PreserveMost:
1558 case CC_PreserveAll:
1559 case CC_Swift:
1560 case CC_SwiftAsync:
1561 case CC_Win64:
1562 return CCCR_OK;
1563 default:
1564 return CCCR_Warning;
1565 }
1566}
1567
1569 const TargetOptions &Opts)
1570 : WindowsARM64TargetInfo(Triple, Opts) {
1571 TheCXXABI.set(TargetCXXABI::Microsoft);
1572}
1573
1575 MacroBuilder &Builder) const {
1577 if (getTriple().isWindowsArm64EC()) {
1578 Builder.defineMacro("_M_X64", "100");
1579 Builder.defineMacro("_M_AMD64", "100");
1580 Builder.defineMacro("_M_ARM64EC", "1");
1581 } else {
1582 Builder.defineMacro("_M_ARM64", "1");
1583 }
1584}
1585
1588 return CCK_MicrosoftWin64;
1589}
1590
1592 bool HasNonWeakDef) const {
1593 unsigned Align =
1594 WindowsARM64TargetInfo::getMinGlobalAlign(TypeSize, HasNonWeakDef);
1595
1596 // MSVC does size based alignment for arm64 based on alignment section in
1597 // below document, replicate that to keep alignment consistent with object
1598 // files compiled by MSVC.
1599 // https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions
1600 if (TypeSize >= 512) { // TypeSize >= 64 bytes
1601 Align = std::max(Align, 128u); // align type at least 16 bytes
1602 } else if (TypeSize >= 64) { // TypeSize >= 8 bytes
1603 Align = std::max(Align, 64u); // align type at least 8 butes
1604 } else if (TypeSize >= 16) { // TypeSize >= 2 bytes
1605 Align = std::max(Align, 32u); // align type at least 4 bytes
1606 }
1607 return Align;
1608}
1609
1611 const TargetOptions &Opts)
1612 : WindowsARM64TargetInfo(Triple, Opts) {
1613 TheCXXABI.set(TargetCXXABI::GenericAArch64);
1614}
1615
1617 const TargetOptions &Opts)
1618 : DarwinTargetInfo<AArch64leTargetInfo>(Triple, Opts) {
1619 Int64Type = SignedLongLong;
1620 if (getTriple().isArch32Bit())
1621 IntMaxType = SignedLongLong;
1622
1623 WCharType = SignedInt;
1624 UseSignedCharForObjCBool = false;
1625
1626 LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64;
1627 LongDoubleFormat = &llvm::APFloat::IEEEdouble();
1628
1629 UseZeroLengthBitfieldAlignment = false;
1630
1631 if (getTriple().isArch32Bit()) {
1632 UseBitFieldTypeAlignment = false;
1633 ZeroLengthBitfieldBoundary = 32;
1634 UseZeroLengthBitfieldAlignment = true;
1635 TheCXXABI.set(TargetCXXABI::WatchOS);
1636 } else
1637 TheCXXABI.set(TargetCXXABI::AppleARM64);
1638}
1639
1641 const llvm::Triple &Triple,
1642 MacroBuilder &Builder) const {
1643 Builder.defineMacro("__AARCH64_SIMD__");
1644 if (Triple.isArch32Bit())
1645 Builder.defineMacro("__ARM64_ARCH_8_32__");
1646 else
1647 Builder.defineMacro("__ARM64_ARCH_8__");
1648 Builder.defineMacro("__ARM_NEON__");
1649 Builder.defineMacro("__REGISTER_PREFIX__", "");
1650 Builder.defineMacro("__arm64", "1");
1651 Builder.defineMacro("__arm64__", "1");
1652
1653 if (Triple.isArm64e())
1654 Builder.defineMacro("__arm64e__", "1");
1655
1656 getDarwinDefines(Builder, Opts, Triple, PlatformName, PlatformMinVersion);
1657}
1658
1662}
1663
1664// 64-bit RenderScript is aarch64
1666 const TargetOptions &Opts)
1667 : AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(),
1668 Triple.getOSName(),
1669 Triple.getEnvironmentName()),
1670 Opts) {
1671 IsRenderScriptTarget = true;
1672}
1673
1675 MacroBuilder &Builder) const {
1676 Builder.defineMacro("__RENDERSCRIPT__");
1678}
Defines the Diagnostic-related interfaces.
static unsigned matchAsmCCConstraint(const char *Name)
Definition: AArch64.cpp:1317
static constexpr Builtin::Info BuiltinInfo[]
Definition: AArch64.cpp:29
static constexpr Builtin::Info BuiltinInfo[]
Definition: Builtins.cpp:32
Defines the clang::LangOptions interface.
Enumerates target-specific builtins in their own namespaces within namespace clang.
__device__ __2f16 float c
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:192
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1547
@ NonLeaf
Sign the return address of functions that spill LR.
@ All
Sign the return address of all functions,.
@ BKey
Return address signing uses APIB key.
@ AKey
Return address signing uses APIA key.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:461
bool isSignReturnAddressWithAKey() const
Check if return address signing uses AKey.
Definition: LangOptions.h:683
bool hasSignReturnAddress() const
Check if return address signing is enabled.
Definition: LangOptions.h:678
bool isSignReturnAddressScopeAll() const
Check if leaf functions are also signed.
Definition: LangOptions.h:688
void set(Kind kind)
Definition: TargetCXXABI.h:76
Exposes information about the current target.
Definition: TargetInfo.h:218
TargetOptions & getTargetOpts() const
Retrieve the target options.
Definition: TargetInfo.h:312
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:1256
unsigned HasAArch64SVETypes
Definition: TargetInfo.h:267
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
Definition: TargetInfo.cpp:190
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:319
@ AArch64ABIBuiltinVaList
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com....
Definition: TargetInfo.h:328
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
Definition: TargetInfo.h:321
const char * MCountName
Definition: TargetInfo.h:245
unsigned IsRenderScriptTarget
Definition: TargetInfo.h:264
unsigned HasUnalignedAccess
Definition: TargetInfo.h:276
unsigned char MaxAtomicPromoteWidth
Definition: TargetInfo.h:242
virtual bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeatureVec) const
Initialize the map with the default set of target features for the CPU this should include all legal ...
Definition: TargetInfo.cpp:532
virtual std::string convertConstraint(const char *&Constraint) const
Definition: TargetInfo.h:1233
unsigned char MaxAtomicInlineWidth
Definition: TargetInfo.h:242
TargetCXXABI TheCXXABI
Definition: TargetInfo.h:247
unsigned HasBuiltinMSVaList
Definition: TargetInfo.h:261
Options for controlling the target.
Definition: TargetOptions.h:26
llvm::EABI EABIVersion
The EABI version to use.
Definition: TargetOptions.h:48
void getTargetDefinesARMV95A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:352
unsigned multiVersionSortPriority(StringRef Name) const override
Definition: AArch64.cpp:659
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: AArch64.cpp:1460
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: AArch64.cpp:694
std::string convertConstraint(const char *&Constraint) const override
Definition: AArch64.cpp:1341
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: AArch64.cpp:1312
bool hasBFloat16Type() const override
Determine whether the _BFloat16 type is supported on this target.
Definition: AArch64.cpp:1194
ParsedTargetAttr parseTargetAttr(StringRef Str) const override
Definition: AArch64.cpp:1104
AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: AArch64.cpp:132
bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeaturesVec) const override
Initialize the map with the default set of target features for the CPU this should include all legal ...
Definition: AArch64.cpp:1053
unsigned multiVersionFeatureCost() const override
Definition: AArch64.cpp:667
ArrayRef< const char * > getGCCRegNames() const override
Definition: AArch64.cpp:1269
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
Perform initialization based on the user configured set of features (e.g., +sse4).
Definition: AArch64.cpp:777
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition: AArch64.cpp:358
void setFeatureEnabled(llvm::StringMap< bool > &Features, StringRef Name, bool Enabled) const override
Enable or disable a specific target feature; the feature name must be valid.
Definition: AArch64.cpp:748
void getTargetDefinesARMV89A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:316
void getTargetDefinesARMV92A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:334
StringRef getFeatureDependencies(StringRef Name) const override
For given feature return dependent ones.
Definition: AArch64.cpp:678
bool validateTarget(DiagnosticsEngine &Diags) const override
Check the target is valid after it is fully initialized.
Definition: AArch64.cpp:214
void getTargetDefinesARMV93A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:340
bool setABI(const std::string &Name) override
Use the specified ABI.
Definition: AArch64.cpp:206
void getTargetDefinesARMV84A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:280
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
Definition: AArch64.cpp:248
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
Definition: AArch64.cpp:256
StringRef getABI() const override
Get the ABI currently in use.
Definition: AArch64.cpp:204
bool hasInt128Type() const override
Determine whether the __int128 type is supported on this target.
Definition: AArch64.cpp:1475
void getTargetDefinesARMV88A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:310
bool validateBranchProtection(StringRef Spec, StringRef Arch, BranchProtectionInfo &BPI, StringRef &Err) const override
Determine if this TargetInfo supports the given branch protection specification.
Definition: AArch64.cpp:224
void getTargetDefinesARMV87A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:304
void getTargetDefinesARMV9A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:322
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition: AArch64.cpp:1199
void getTargetDefinesARMV91A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:328
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: AArch64.cpp:1218
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
Definition: AArch64.cpp:1462
void getTargetDefinesARMV81A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:261
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: AArch64.cpp:642
void getTargetDefinesARMV86A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:294
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition: AArch64.cpp:252
std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts) const override
Returns target-specific min and max values VScale_Range.
Definition: AArch64.cpp:648
void getTargetDefinesARMV94A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:346
bool validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size, std::string &SuggestedModifier) const override
Definition: AArch64.cpp:1427
bool isCLZForZeroUndef() const override
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
Definition: AArch64.cpp:1216
void getTargetDefinesARMV82A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:266
void getTargetDefinesARMV83A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:272
bool validateCpuSupports(StringRef FeatureStr) const override
Definition: AArch64.cpp:684
bool validatePointerAuthKey(const llvm::APSInt &value) const override
Determine whether the given pointer-authentication key is valid.
Definition: AArch64.cpp:1470
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
Definition: AArch64.cpp:1362
bool doesFeatureAffectCodeGen(StringRef Name) const override
Returns true if feature has an impact on target code generation.
Definition: AArch64.cpp:672
void getTargetDefinesARMV85A(const LangOptions &Opts, MacroBuilder &Builder) const
Definition: AArch64.cpp:286
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition: AArch64.cpp:1501
AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: AArch64.cpp:1497
AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: AArch64.cpp:1477
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition: AArch64.cpp:1491
DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: AArch64.cpp:1616
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
Definition: AArch64.cpp:1640
BuiltinVaListKind getBuiltinVaListKind() const override
Definition: AArch64.cpp:1660
unsigned getMinGlobalAlign(uint64_t TypeSize, bool HasNonWeakDef) const override
Definition: AArch64.cpp:1591
MicrosoftARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: AArch64.cpp:1568
TargetInfo::CallingConvKind getCallingConvKind(bool ClangABICompat4) const override
Definition: AArch64.cpp:1587
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
Definition: AArch64.cpp:1574
MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: AArch64.cpp:1610
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
Definition: OSTargets.h:30
RenderScript64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: AArch64.cpp:1665
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition: AArch64.cpp:1674
BuiltinVaListKind getBuiltinVaListKind() const override
Definition: AArch64.cpp:1540
WindowsARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: AArch64.cpp:1514
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Definition: AArch64.cpp:1545
Defines the clang::TargetInfo interface.
void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, const llvm::Triple &Triple, StringRef &PlatformName, VersionTuple &PlatformMinVersion)
Definition: OSTargets.cpp:22
The JSON file list parser is used to communicate input to InstallAPI.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:275
@ CC_Swift
Definition: Specifiers.h:290
@ CC_OpenCLKernel
Definition: Specifiers.h:289
@ CC_PreserveMost
Definition: Specifiers.h:292
@ CC_Win64
Definition: Specifiers.h:282
@ CC_X86ThisCall
Definition: Specifiers.h:279
@ CC_AArch64VectorCall
Definition: Specifiers.h:294
@ CC_C
Definition: Specifiers.h:276
@ CC_SwiftAsync
Definition: Specifiers.h:291
@ CC_X86VectorCall
Definition: Specifiers.h:280
@ CC_AArch64SVEPCS
Definition: Specifiers.h:295
@ CC_X86StdCall
Definition: Specifiers.h:277
@ CC_PreserveAll
Definition: Specifiers.h:293
@ CC_X86FastCall
Definition: Specifiers.h:278
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
Contains information gathered from parsing the contents of TargetAttr.
Definition: TargetInfo.h:57
LangOptions::SignReturnAddressScopeKind SignReturnAddr
Definition: TargetInfo.h:1409
LangOptions::SignReturnAddressKeyKind SignKey
Definition: TargetInfo.h:1410
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
Definition: TargetInfo.h:183
const llvm::fltSemantics * LongDoubleFormat
Definition: TargetInfo.h:139
std::optional< unsigned > BitIntMaxAlign
Definition: TargetInfo.h:102
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
Definition: TargetInfo.h:174
const llvm::fltSemantics * BFloat16Format
Definition: TargetInfo.h:138