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