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