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