clang 18.0.0git
AArch64.cpp
Go to the documentation of this file.
1//===--- AArch64.cpp - AArch64 (not ARM) Helpers for Tools ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "AArch64.h"
10#include "../CommonArgs.h"
11#include "clang/Driver/Driver.h"
14#include "llvm/Option/ArgList.h"
15#include "llvm/TargetParser/AArch64TargetParser.h"
16#include "llvm/TargetParser/Host.h"
17
18using namespace clang::driver;
19using namespace clang::driver::tools;
20using namespace clang;
21using namespace llvm::opt;
22
23/// \returns true if the given triple can determine the default CPU type even
24/// if -arch is not specified.
25static bool isCPUDeterminedByTriple(const llvm::Triple &Triple) {
26 return Triple.isOSDarwin();
27}
28
29/// getAArch64TargetCPU - Get the (LLVM) name of the AArch64 cpu we are
30/// targeting. Set \p A to the Arg corresponding to the -mcpu argument if it is
31/// provided, or to nullptr otherwise.
32std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
33 const llvm::Triple &Triple, Arg *&A) {
34 std::string CPU;
35 // If we have -mcpu, use that.
36 if ((A = Args.getLastArg(options::OPT_mcpu_EQ))) {
37 StringRef Mcpu = A->getValue();
38 CPU = Mcpu.split("+").first.lower();
39 }
40
41 CPU = llvm::AArch64::resolveCPUAlias(CPU);
42
43 // Handle CPU name is 'native'.
44 if (CPU == "native")
45 return std::string(llvm::sys::getHostCPUName());
46
47 if (CPU.size())
48 return CPU;
49
50 if (Triple.isTargetMachineMac() &&
51 Triple.getArch() == llvm::Triple::aarch64) {
52 // Apple Silicon macs default to M1 CPUs.
53 return "apple-m1";
54 }
55
56 // arm64e requires v8.3a and only runs on apple-a12 and later CPUs.
57 if (Triple.isArm64e())
58 return "apple-a12";
59
60 // Make sure we pick the appropriate Apple CPU if -arch is used or when
61 // targetting a Darwin OS.
62 if (Args.getLastArg(options::OPT_arch) || Triple.isOSDarwin())
63 return Triple.getArch() == llvm::Triple::aarch64_32 ? "apple-s4"
64 : "apple-a7";
65
66 return "generic";
67}
68
69// Decode AArch64 features from string like +[no]featureA+[no]featureB+...
70static bool DecodeAArch64Features(const Driver &D, StringRef text,
71 std::vector<StringRef> &Features,
72 const llvm::AArch64::ArchInfo &ArchInfo) {
74 text.split(Split, StringRef("+"), -1, false);
75
76 for (StringRef Feature : Split) {
77 StringRef FeatureName = llvm::AArch64::getArchExtFeature(Feature);
78 if (!FeatureName.empty())
79 Features.push_back(FeatureName);
80 else if (Feature == "neon" || Feature == "noneon")
81 D.Diag(clang::diag::err_drv_no_neon_modifier);
82 else
83 return false;
84
85 // +sme implies +bf16.
86 // +sme-f64f64 and +sme-i16i64 both imply +sme.
87 if (Feature == "sme") {
88 Features.push_back("+bf16");
89 } else if (Feature == "nosme") {
90 Features.push_back("-sme-f64f64");
91 Features.push_back("-sme-i16i64");
92 } else if (Feature == "sme-f64f64") {
93 Features.push_back("+sme");
94 Features.push_back("+bf16");
95 } else if (Feature == "sme-i16i64") {
96 Features.push_back("+sme");
97 Features.push_back("+bf16");
98 } else if (Feature == "nobf16") {
99 Features.push_back("-sme");
100 Features.push_back("-sme-f64f64");
101 Features.push_back("-sme-i16i64");
102 }
103
104 if (Feature == "sve2")
105 Features.push_back("+sve");
106 else if (Feature == "sve2-bitperm" || Feature == "sve2-sha3" ||
107 Feature == "sve2-aes" || Feature == "sve2-sm4") {
108 Features.push_back("+sve");
109 Features.push_back("+sve2");
110 } else if (Feature == "nosve") {
111 Features.push_back("-sve2");
112 Features.push_back("-sve2-bitperm");
113 Features.push_back("-sve2-sha3");
114 Features.push_back("-sve2-aes");
115 Features.push_back("-sve2-sm4");
116 } else if (Feature == "nosve2") {
117 Features.push_back("-sve2-bitperm");
118 Features.push_back("-sve2-sha3");
119 Features.push_back("-sve2-aes");
120 Features.push_back("-sve2-sm4");
121 }
122
123 // +sve implies +f32mm if the base architecture is >= v8.6A (except v9A)
124 // It isn't the case in general that sve implies both f64mm and f32mm
125 if ((ArchInfo == llvm::AArch64::ARMV8_6A ||
126 ArchInfo == llvm::AArch64::ARMV8_7A ||
127 ArchInfo == llvm::AArch64::ARMV8_8A ||
128 ArchInfo == llvm::AArch64::ARMV8_9A ||
129 ArchInfo == llvm::AArch64::ARMV9_1A ||
130 ArchInfo == llvm::AArch64::ARMV9_2A ||
131 ArchInfo == llvm::AArch64::ARMV9_3A ||
132 ArchInfo == llvm::AArch64::ARMV9_4A) &&
133 Feature == "sve")
134 Features.push_back("+f32mm");
135 }
136 return true;
137}
138
139// Check if the CPU name and feature modifiers in -mcpu are legal. If yes,
140// decode CPU and feature.
141static bool DecodeAArch64Mcpu(const Driver &D, StringRef Mcpu, StringRef &CPU,
142 std::vector<StringRef> &Features) {
143 std::pair<StringRef, StringRef> Split = Mcpu.split("+");
144 CPU = Split.first;
145 const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
146
147 if (CPU == "native")
148 CPU = llvm::sys::getHostCPUName();
149
150 if (CPU == "generic") {
151 Features.push_back("+neon");
152 } else {
153 const std::optional<llvm::AArch64::CpuInfo> CpuInfo =
154 llvm::AArch64::parseCpu(CPU);
155 if (!CpuInfo)
156 return false;
157 ArchInfo = &CpuInfo->Arch;
158
159 Features.push_back(ArchInfo->ArchFeature);
160
161 auto Extension = CpuInfo->getImpliedExtensions();
162 if (!llvm::AArch64::getExtensionFeatures(Extension, Features))
163 return false;
164 }
165
166 if (Split.second.size() &&
167 !DecodeAArch64Features(D, Split.second, Features, *ArchInfo))
168 return false;
169
170 return true;
171}
172
173static bool
174getAArch64ArchFeaturesFromMarch(const Driver &D, StringRef March,
175 const ArgList &Args,
176 std::vector<StringRef> &Features) {
177 std::string MarchLowerCase = March.lower();
178 std::pair<StringRef, StringRef> Split = StringRef(MarchLowerCase).split("+");
179
180 std::optional <llvm::AArch64::ArchInfo> ArchInfo =
181 llvm::AArch64::parseArch(Split.first);
182 if (Split.first == "native")
183 ArchInfo = llvm::AArch64::getArchForCpu(llvm::sys::getHostCPUName().str());
184 if (!ArchInfo)
185 return false;
186 Features.push_back(ArchInfo->ArchFeature);
187
188 // Enable SVE2 by default on Armv9-A.
189 // It can still be disabled if +nosve2 is present.
190 // We must do this early so that DecodeAArch64Features has the correct state
191 if ((*ArchInfo == llvm::AArch64::ARMV9A ||
192 *ArchInfo == llvm::AArch64::ARMV9_1A ||
193 *ArchInfo == llvm::AArch64::ARMV9_2A)) {
194 Features.push_back("+sve");
195 Features.push_back("+sve2");
196 }
197
198 if ((Split.second.size() &&
199 !DecodeAArch64Features(D, Split.second, Features, *ArchInfo)))
200 return false;
201
202 return true;
203}
204
205static bool
206getAArch64ArchFeaturesFromMcpu(const Driver &D, StringRef Mcpu,
207 const ArgList &Args,
208 std::vector<StringRef> &Features) {
209 StringRef CPU;
210 std::string McpuLowerCase = Mcpu.lower();
211 if (!DecodeAArch64Mcpu(D, McpuLowerCase, CPU, Features))
212 return false;
213
214 return true;
215}
216
217static bool
219 const ArgList &Args,
220 std::vector<StringRef> &Features) {
221 std::string MtuneLowerCase = Mtune.lower();
222 // Check CPU name is valid
223 std::vector<StringRef> MtuneFeatures;
224 StringRef Tune;
225 if (!DecodeAArch64Mcpu(D, MtuneLowerCase, Tune, MtuneFeatures))
226 return false;
227
228 // Handle CPU name is 'native'.
229 if (MtuneLowerCase == "native")
230 MtuneLowerCase = std::string(llvm::sys::getHostCPUName());
231 if (MtuneLowerCase == "cyclone" ||
232 StringRef(MtuneLowerCase).startswith("apple")) {
233 Features.push_back("+zcm");
234 Features.push_back("+zcz");
235 }
236 return true;
237}
238
239static bool
241 const ArgList &Args,
242 std::vector<StringRef> &Features) {
243 StringRef CPU;
244 std::vector<StringRef> DecodedFeature;
245 std::string McpuLowerCase = Mcpu.lower();
246 if (!DecodeAArch64Mcpu(D, McpuLowerCase, CPU, DecodedFeature))
247 return false;
248
249 return getAArch64MicroArchFeaturesFromMtune(D, CPU, Args, Features);
250}
251
253 const llvm::Triple &Triple,
254 const ArgList &Args,
255 std::vector<StringRef> &Features,
256 bool ForAS) {
257 Arg *A;
258 bool success = true;
259 // Enable NEON by default.
260 Features.push_back("+neon");
261 llvm::StringRef WaMArch;
262 if (ForAS)
263 for (const auto *A :
264 Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler))
265 for (StringRef Value : A->getValues())
266 if (Value.startswith("-march="))
267 WaMArch = Value.substr(7);
268 // Call getAArch64ArchFeaturesFromMarch only if "-Wa,-march=" or
269 // "-Xassembler -march" is detected. Otherwise it may return false
270 // and causes Clang to error out.
271 if (!WaMArch.empty())
272 success = getAArch64ArchFeaturesFromMarch(D, WaMArch, Args, Features);
273 else if ((A = Args.getLastArg(options::OPT_march_EQ)))
274 success = getAArch64ArchFeaturesFromMarch(D, A->getValue(), Args, Features);
275 else if ((A = Args.getLastArg(options::OPT_mcpu_EQ)))
276 success = getAArch64ArchFeaturesFromMcpu(D, A->getValue(), Args, Features);
277 else if (Args.hasArg(options::OPT_arch) || isCPUDeterminedByTriple(Triple))
279 D, getAArch64TargetCPU(Args, Triple, A), Args, Features);
280 else
281 // Default to 'A' profile if the architecture is not specified.
282 success = getAArch64ArchFeaturesFromMarch(D, "armv8-a", Args, Features);
283
284 if (success && (A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)))
285 success =
286 getAArch64MicroArchFeaturesFromMtune(D, A->getValue(), Args, Features);
287 else if (success && (A = Args.getLastArg(options::OPT_mcpu_EQ)))
288 success =
289 getAArch64MicroArchFeaturesFromMcpu(D, A->getValue(), Args, Features);
290 else if (success &&
291 (Args.hasArg(options::OPT_arch) || isCPUDeterminedByTriple(Triple)))
293 D, getAArch64TargetCPU(Args, Triple, A), Args, Features);
294
295 if (!success) {
296 auto Diag = D.Diag(diag::err_drv_unsupported_option_argument);
297 // If "-Wa,-march=" is used, 'WaMArch' will contain the argument's value,
298 // while 'A' is uninitialized. Only dereference 'A' in the other case.
299 if (!WaMArch.empty())
300 Diag << "-march=" << WaMArch;
301 else
302 Diag << A->getSpelling() << A->getValue();
303 }
304
305 if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {
306 Features.push_back("-fp-armv8");
307 Features.push_back("-crypto");
308 Features.push_back("-neon");
309 }
310
311 if (Arg *A = Args.getLastArg(options::OPT_mtp_mode_EQ)) {
312 StringRef Mtp = A->getValue();
313 if (Mtp == "el3" || Mtp == "tpidr_el3")
314 Features.push_back("+tpidr-el3");
315 else if (Mtp == "el2" || Mtp == "tpidr_el2")
316 Features.push_back("+tpidr-el2");
317 else if (Mtp == "el1" || Mtp == "tpidr_el1")
318 Features.push_back("+tpidr-el1");
319 else if (Mtp == "tpidrro_el0")
320 Features.push_back("+tpidrro-el0");
321 else if (Mtp != "el0" && Mtp != "tpidr_el0")
322 D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args);
323 }
324
325 // Enable/disable straight line speculation hardening.
326 if (Arg *A = Args.getLastArg(options::OPT_mharden_sls_EQ)) {
327 StringRef Scope = A->getValue();
328 bool EnableRetBr = false;
329 bool EnableBlr = false;
330 bool DisableComdat = false;
331 if (Scope != "none") {
333 Scope.split(Opts, ",");
334 for (auto Opt : Opts) {
335 Opt = Opt.trim();
336 if (Opt == "all") {
337 EnableBlr = true;
338 EnableRetBr = true;
339 continue;
340 }
341 if (Opt == "retbr") {
342 EnableRetBr = true;
343 continue;
344 }
345 if (Opt == "blr") {
346 EnableBlr = true;
347 continue;
348 }
349 if (Opt == "comdat") {
350 DisableComdat = false;
351 continue;
352 }
353 if (Opt == "nocomdat") {
354 DisableComdat = true;
355 continue;
356 }
357 D.Diag(diag::err_drv_unsupported_option_argument)
358 << A->getSpelling() << Scope;
359 break;
360 }
361 }
362
363 if (EnableRetBr)
364 Features.push_back("+harden-sls-retbr");
365 if (EnableBlr)
366 Features.push_back("+harden-sls-blr");
367 if (DisableComdat) {
368 Features.push_back("+harden-sls-nocomdat");
369 }
370 }
371
372 // En/disable crc
373 if (Arg *A = Args.getLastArg(options::OPT_mcrc, options::OPT_mnocrc)) {
374 if (A->getOption().matches(options::OPT_mcrc))
375 Features.push_back("+crc");
376 else
377 Features.push_back("-crc");
378 }
379
380 int V8Version = -1;
381 int V9Version = -1;
382 bool HasNoSM4 = false;
383 bool HasNoSHA3 = false;
384 bool HasNoSHA2 = false;
385 bool HasNoAES = false;
386 bool HasSM4 = false;
387 bool HasSHA3 = false;
388 bool HasSHA2 = false;
389 bool HasAES = false;
390 bool HasCrypto = false;
391 bool HasNoCrypto = false;
392 int FullFP16Pos = -1;
393 int NoFullFP16Pos = -1;
394 int FP16FMLPos = -1;
395 int NoFP16FMLPos = -1;
396 int ArchFeatPos = -1;
397
398 for (auto I = Features.begin(), E = Features.end(); I != E; I++) {
399 if (*I == "+v8a") V8Version = 0;
400 else if (*I == "+v8.1a") V8Version = 1;
401 else if (*I == "+v8.2a") V8Version = 2;
402 else if (*I == "+v8.3a") V8Version = 3;
403 else if (*I == "+v8.4a") V8Version = 4;
404 else if (*I == "+v8.5a") V8Version = 5;
405 else if (*I == "+v8.6a") V8Version = 6;
406 else if (*I == "+v8.7a") V8Version = 7;
407 else if (*I == "+v8.8a") V8Version = 8;
408 else if (*I == "+v8.9a") V8Version = 9;
409 else if (*I == "+v9a") V9Version = 0;
410 else if (*I == "+v9.1a") V9Version = 1;
411 else if (*I == "+v9.2a") V9Version = 2;
412 else if (*I == "+v9.3a") V9Version = 3;
413 else if (*I == "+v9.4a") V9Version = 4;
414 else if (*I == "+v9.5a") V9Version = 5;
415 else if (*I == "+sm4") HasSM4 = true;
416 else if (*I == "+sha3") HasSHA3 = true;
417 else if (*I == "+sha2") HasSHA2 = true;
418 else if (*I == "+aes") HasAES = true;
419 else if (*I == "-sm4") HasNoSM4 = true;
420 else if (*I == "-sha3") HasNoSHA3 = true;
421 else if (*I == "-sha2") HasNoSHA2 = true;
422 else if (*I == "-aes") HasNoAES = true;
423 else if (*I == "+fp16fml") FP16FMLPos = I - Features.begin();
424 else if (*I == "-fp16fml") NoFP16FMLPos = I - Features.begin();
425 else if (*I == "-fullfp16") NoFullFP16Pos = I - Features.begin();
426 else if (*I == "+fullfp16") FullFP16Pos = I - Features.begin();
427 // Whichever option comes after (right-most option) will win
428 else if (*I == "+crypto") {
429 HasCrypto = true;
430 HasNoCrypto = false;
431 } else if (*I == "-crypto" || *I == "-neon") {
432 HasCrypto = false;
433 HasNoCrypto = true;
434 HasSM4 = HasSHA2 = HasSHA3 = HasAES = false;
435 }
436 // Register the iterator position if this is an architecture feature
437 if (ArchFeatPos == -1 && (V8Version != -1 || V9Version != -1))
438 ArchFeatPos = I - Features.begin();
439 }
440
441 // Handle (arch-dependent) fp16fml/fullfp16 relationship.
442 // FIXME: this fp16fml option handling will be reimplemented after the
443 // TargetParser rewrite.
444 if (V8Version >= 4) {
445 // "-fullfp16" "+fullfp16" && "+fp16fml" "+fullfp16" && no "+fullfp16" "-fp16fml" = "+fp16fml"
446 if (FullFP16Pos > NoFullFP16Pos && FullFP16Pos > FP16FMLPos && FullFP16Pos > NoFP16FMLPos)
447 // Only entangled feature that can be to the right of this +fullfp16 is -fp16fml.
448 // Only append the +fp16fml if there is no -fp16fml after the +fullfp16.
449 Features.push_back("+fp16fml");
450 else
451 goto fp16_fml_fallthrough;
452 } else {
453fp16_fml_fallthrough:
454 // In both of these cases, putting the 'other' feature on the end of the vector will
455 // result in the same effect as placing it immediately after the current feature.
456 // "+fp16fml" "-fullfp16" = "-fp16fml"
457 if (NoFullFP16Pos > FP16FMLPos)
458 Features.push_back("-fp16fml");
459 // "-fullfp16" "+fp16fml" = "+fullfp16"
460 else if (NoFullFP16Pos < FP16FMLPos)
461 Features.push_back("+fullfp16");
462 }
463
464 // FIXME: this needs reimplementation too after the TargetParser rewrite
465 //
466 // Context sensitive meaning of Crypto:
467 // 1) For Arch >= ARMv8.4a: crypto = sm4 + sha3 + sha2 + aes
468 // 2) For Arch <= ARMv8.3a: crypto = sha2 + aes
469 if (V8Version >= 4 || V9Version >= 0) {
470 if (HasCrypto && !HasNoCrypto) {
471 // Check if we have NOT disabled an algorithm with something like:
472 // +crypto, -algorithm
473 // And if "-algorithm" does not occur, we enable that crypto algorithm.
474 if (!HasNoSM4)
475 Features.push_back("+sm4");
476 if (!HasNoSHA3)
477 Features.push_back("+sha3");
478 if (!HasNoSHA2)
479 Features.push_back("+sha2");
480 if (!HasNoAES)
481 Features.push_back("+aes");
482 } else if (HasNoCrypto) {
483 // Check if we have NOT enabled a crypto algorithm with something like:
484 // -crypto, +algorithm
485 // And if "+algorithm" does not occur, we disable that crypto algorithm.
486 if (!HasSM4)
487 Features.push_back("-sm4");
488 if (!HasSHA3)
489 Features.push_back("-sha3");
490 if (!HasSHA2)
491 Features.push_back("-sha2");
492 if (!HasAES)
493 Features.push_back("-aes");
494 }
495 } else {
496 if (HasCrypto && !HasNoCrypto) {
497 if (!HasNoSHA2)
498 Features.push_back("+sha2");
499 if (!HasNoAES)
500 Features.push_back("+aes");
501 } else if (HasNoCrypto) {
502 if (!HasSHA2)
503 Features.push_back("-sha2");
504 if (!HasAES)
505 Features.push_back("-aes");
506 if (V8Version == 2 || V8Version == 3) {
507 Features.push_back("-sm4");
508 Features.push_back("-sha3");
509 }
510 }
511 }
512
513 if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
514 options::OPT_munaligned_access)) {
515 if (A->getOption().matches(options::OPT_mno_unaligned_access))
516 Features.push_back("+strict-align");
517 } else if (Triple.isOSOpenBSD())
518 Features.push_back("+strict-align");
519
520 if (Args.hasArg(options::OPT_ffixed_x1))
521 Features.push_back("+reserve-x1");
522
523 if (Args.hasArg(options::OPT_ffixed_x2))
524 Features.push_back("+reserve-x2");
525
526 if (Args.hasArg(options::OPT_ffixed_x3))
527 Features.push_back("+reserve-x3");
528
529 if (Args.hasArg(options::OPT_ffixed_x4))
530 Features.push_back("+reserve-x4");
531
532 if (Args.hasArg(options::OPT_ffixed_x5))
533 Features.push_back("+reserve-x5");
534
535 if (Args.hasArg(options::OPT_ffixed_x6))
536 Features.push_back("+reserve-x6");
537
538 if (Args.hasArg(options::OPT_ffixed_x7))
539 Features.push_back("+reserve-x7");
540
541 if (Args.hasArg(options::OPT_ffixed_x9))
542 Features.push_back("+reserve-x9");
543
544 if (Args.hasArg(options::OPT_ffixed_x10))
545 Features.push_back("+reserve-x10");
546
547 if (Args.hasArg(options::OPT_ffixed_x11))
548 Features.push_back("+reserve-x11");
549
550 if (Args.hasArg(options::OPT_ffixed_x12))
551 Features.push_back("+reserve-x12");
552
553 if (Args.hasArg(options::OPT_ffixed_x13))
554 Features.push_back("+reserve-x13");
555
556 if (Args.hasArg(options::OPT_ffixed_x14))
557 Features.push_back("+reserve-x14");
558
559 if (Args.hasArg(options::OPT_ffixed_x15))
560 Features.push_back("+reserve-x15");
561
562 if (Args.hasArg(options::OPT_ffixed_x18))
563 Features.push_back("+reserve-x18");
564
565 if (Args.hasArg(options::OPT_ffixed_x20))
566 Features.push_back("+reserve-x20");
567
568 if (Args.hasArg(options::OPT_ffixed_x21))
569 Features.push_back("+reserve-x21");
570
571 if (Args.hasArg(options::OPT_ffixed_x22))
572 Features.push_back("+reserve-x22");
573
574 if (Args.hasArg(options::OPT_ffixed_x23))
575 Features.push_back("+reserve-x23");
576
577 if (Args.hasArg(options::OPT_ffixed_x24))
578 Features.push_back("+reserve-x24");
579
580 if (Args.hasArg(options::OPT_ffixed_x25))
581 Features.push_back("+reserve-x25");
582
583 if (Args.hasArg(options::OPT_ffixed_x26))
584 Features.push_back("+reserve-x26");
585
586 if (Args.hasArg(options::OPT_ffixed_x27))
587 Features.push_back("+reserve-x27");
588
589 if (Args.hasArg(options::OPT_ffixed_x28))
590 Features.push_back("+reserve-x28");
591
592 if (Args.hasArg(options::OPT_ffixed_x30))
593 Features.push_back("+reserve-x30");
594
595 if (Args.hasArg(options::OPT_fcall_saved_x8))
596 Features.push_back("+call-saved-x8");
597
598 if (Args.hasArg(options::OPT_fcall_saved_x9))
599 Features.push_back("+call-saved-x9");
600
601 if (Args.hasArg(options::OPT_fcall_saved_x10))
602 Features.push_back("+call-saved-x10");
603
604 if (Args.hasArg(options::OPT_fcall_saved_x11))
605 Features.push_back("+call-saved-x11");
606
607 if (Args.hasArg(options::OPT_fcall_saved_x12))
608 Features.push_back("+call-saved-x12");
609
610 if (Args.hasArg(options::OPT_fcall_saved_x13))
611 Features.push_back("+call-saved-x13");
612
613 if (Args.hasArg(options::OPT_fcall_saved_x14))
614 Features.push_back("+call-saved-x14");
615
616 if (Args.hasArg(options::OPT_fcall_saved_x15))
617 Features.push_back("+call-saved-x15");
618
619 if (Args.hasArg(options::OPT_fcall_saved_x18))
620 Features.push_back("+call-saved-x18");
621
622 if (Args.hasArg(options::OPT_mno_neg_immediates))
623 Features.push_back("+no-neg-immediates");
624
625 if (Arg *A = Args.getLastArg(options::OPT_mfix_cortex_a53_835769,
626 options::OPT_mno_fix_cortex_a53_835769)) {
627 if (A->getOption().matches(options::OPT_mfix_cortex_a53_835769))
628 Features.push_back("+fix-cortex-a53-835769");
629 else
630 Features.push_back("-fix-cortex-a53-835769");
631 } else if (Triple.isAndroid() || Triple.isOHOSFamily()) {
632 // Enabled A53 errata (835769) workaround by default on android
633 Features.push_back("+fix-cortex-a53-835769");
634 } else if (Triple.isOSFuchsia()) {
635 std::string CPU = getCPUName(D, Args, Triple);
636 if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
637 Features.push_back("+fix-cortex-a53-835769");
638 }
639
640 if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
641 Features.push_back("+no-bti-at-return-twice");
642}
static bool getAArch64ArchFeaturesFromMarch(const Driver &D, StringRef March, const ArgList &Args, std::vector< StringRef > &Features)
Definition: AArch64.cpp:174
static bool getAArch64MicroArchFeaturesFromMcpu(const Driver &D, StringRef Mcpu, const ArgList &Args, std::vector< StringRef > &Features)
Definition: AArch64.cpp:240
static bool getAArch64MicroArchFeaturesFromMtune(const Driver &D, StringRef Mtune, const ArgList &Args, std::vector< StringRef > &Features)
Definition: AArch64.cpp:218
static bool DecodeAArch64Features(const Driver &D, StringRef text, std::vector< StringRef > &Features, const llvm::AArch64::ArchInfo &ArchInfo)
Definition: AArch64.cpp:70
static bool DecodeAArch64Mcpu(const Driver &D, StringRef Mcpu, StringRef &CPU, std::vector< StringRef > &Features)
Definition: AArch64.cpp:141
static bool isCPUDeterminedByTriple(const llvm::Triple &Triple)
Definition: AArch64.cpp:25
static bool getAArch64ArchFeaturesFromMcpu(const Driver &D, StringRef Mcpu, const ArgList &Args, std::vector< StringRef > &Features)
Definition: AArch64.cpp:206
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:41
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:144
void getAArch64TargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, std::vector< llvm::StringRef > &Features, bool ForAS)
std::string getAArch64TargetCPU(const llvm::opt::ArgList &Args, const llvm::Triple &Triple, llvm::opt::Arg *&A)
std::string getCPUName(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &T, bool FromAs=false)