1 //===--- ARM.cpp - ARM (not AArch64) Helpers for Tools ----------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "ARM.h" 11 #include "clang/Driver/Driver.h" 12 #include "clang/Driver/DriverDiagnostic.h" 13 #include "clang/Driver/Options.h" 14 #include "llvm/ADT/StringSwitch.h" 15 #include "llvm/Option/ArgList.h" 16 #include "llvm/Support/TargetParser.h" 17 18 using namespace clang::driver; 19 using namespace clang::driver::tools; 20 using namespace clang; 21 using namespace llvm::opt; 22 23 // Get SubArch (vN). 24 int arm::getARMSubArchVersionNumber(const llvm::Triple &Triple) { 25 llvm::StringRef Arch = Triple.getArchName(); 26 return llvm::ARM::parseArchVersion(Arch); 27 } 28 29 // True if M-profile. 30 bool arm::isARMMProfile(const llvm::Triple &Triple) { 31 llvm::StringRef Arch = Triple.getArchName(); 32 return llvm::ARM::parseArchProfile(Arch) == llvm::ARM::ProfileKind::M; 33 } 34 35 // Get Arch/CPU from args. 36 void arm::getARMArchCPUFromArgs(const ArgList &Args, llvm::StringRef &Arch, 37 llvm::StringRef &CPU, bool FromAs) { 38 if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) 39 CPU = A->getValue(); 40 if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) 41 Arch = A->getValue(); 42 if (!FromAs) 43 return; 44 45 for (const Arg *A : 46 Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) { 47 StringRef Value = A->getValue(); 48 if (Value.startswith("-mcpu=")) 49 CPU = Value.substr(6); 50 if (Value.startswith("-march=")) 51 Arch = Value.substr(7); 52 } 53 } 54 55 // Handle -mhwdiv=. 56 // FIXME: Use ARMTargetParser. 57 static void getARMHWDivFeatures(const Driver &D, const Arg *A, 58 const ArgList &Args, StringRef HWDiv, 59 std::vector<StringRef> &Features) { 60 unsigned HWDivID = llvm::ARM::parseHWDiv(HWDiv); 61 if (!llvm::ARM::getHWDivFeatures(HWDivID, Features)) 62 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args); 63 } 64 65 // Handle -mfpu=. 66 static void getARMFPUFeatures(const Driver &D, const Arg *A, 67 const ArgList &Args, StringRef FPU, 68 std::vector<StringRef> &Features) { 69 unsigned FPUID = llvm::ARM::parseFPU(FPU); 70 if (!llvm::ARM::getFPUFeatures(FPUID, Features)) 71 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args); 72 } 73 74 // Decode ARM features from string like +[no]featureA+[no]featureB+... 75 static bool DecodeARMFeatures(const Driver &D, StringRef text, 76 std::vector<StringRef> &Features) { 77 SmallVector<StringRef, 8> Split; 78 text.split(Split, StringRef("+"), -1, false); 79 80 for (StringRef Feature : Split) { 81 StringRef FeatureName = llvm::ARM::getArchExtFeature(Feature); 82 if (!FeatureName.empty()) 83 Features.push_back(FeatureName); 84 else 85 return false; 86 } 87 return true; 88 } 89 90 // Check if -march is valid by checking if it can be canonicalised and parsed. 91 // getARMArch is used here instead of just checking the -march value in order 92 // to handle -march=native correctly. 93 static void checkARMArchName(const Driver &D, const Arg *A, const ArgList &Args, 94 llvm::StringRef ArchName, 95 std::vector<StringRef> &Features, 96 const llvm::Triple &Triple) { 97 std::pair<StringRef, StringRef> Split = ArchName.split("+"); 98 99 std::string MArch = arm::getARMArch(ArchName, Triple); 100 if (llvm::ARM::parseArch(MArch) == llvm::ARM::ArchKind::INVALID || 101 (Split.second.size() && !DecodeARMFeatures(D, Split.second, Features))) 102 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args); 103 } 104 105 // Check -mcpu=. Needs ArchName to handle -mcpu=generic. 106 static void checkARMCPUName(const Driver &D, const Arg *A, const ArgList &Args, 107 llvm::StringRef CPUName, llvm::StringRef ArchName, 108 std::vector<StringRef> &Features, 109 const llvm::Triple &Triple) { 110 std::pair<StringRef, StringRef> Split = CPUName.split("+"); 111 112 std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple); 113 if (arm::getLLVMArchSuffixForARM(CPU, ArchName, Triple).empty() || 114 (Split.second.size() && !DecodeARMFeatures(D, Split.second, Features))) 115 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args); 116 } 117 118 bool arm::useAAPCSForMachO(const llvm::Triple &T) { 119 // The backend is hardwired to assume AAPCS for M-class processors, ensure 120 // the frontend matches that. 121 return T.getEnvironment() == llvm::Triple::EABI || 122 T.getOS() == llvm::Triple::UnknownOS || isARMMProfile(T); 123 } 124 125 // Select the float ABI as determined by -msoft-float, -mhard-float, and 126 // -mfloat-abi=. 127 arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) { 128 const Driver &D = TC.getDriver(); 129 const llvm::Triple &Triple = TC.getEffectiveTriple(); 130 auto SubArch = getARMSubArchVersionNumber(Triple); 131 arm::FloatABI ABI = FloatABI::Invalid; 132 if (Arg *A = 133 Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float, 134 options::OPT_mfloat_abi_EQ)) { 135 if (A->getOption().matches(options::OPT_msoft_float)) { 136 ABI = FloatABI::Soft; 137 } else if (A->getOption().matches(options::OPT_mhard_float)) { 138 ABI = FloatABI::Hard; 139 } else { 140 ABI = llvm::StringSwitch<arm::FloatABI>(A->getValue()) 141 .Case("soft", FloatABI::Soft) 142 .Case("softfp", FloatABI::SoftFP) 143 .Case("hard", FloatABI::Hard) 144 .Default(FloatABI::Invalid); 145 if (ABI == FloatABI::Invalid && !StringRef(A->getValue()).empty()) { 146 D.Diag(diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args); 147 ABI = FloatABI::Soft; 148 } 149 } 150 151 // It is incorrect to select hard float ABI on MachO platforms if the ABI is 152 // "apcs-gnu". 153 if (Triple.isOSBinFormatMachO() && !useAAPCSForMachO(Triple) && 154 ABI == FloatABI::Hard) { 155 D.Diag(diag::err_drv_unsupported_opt_for_target) << A->getAsString(Args) 156 << Triple.getArchName(); 157 } 158 } 159 160 // If unspecified, choose the default based on the platform. 161 if (ABI == FloatABI::Invalid) { 162 switch (Triple.getOS()) { 163 case llvm::Triple::Darwin: 164 case llvm::Triple::MacOSX: 165 case llvm::Triple::IOS: 166 case llvm::Triple::TvOS: { 167 // Darwin defaults to "softfp" for v6 and v7. 168 ABI = (SubArch == 6 || SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft; 169 ABI = Triple.isWatchABI() ? FloatABI::Hard : ABI; 170 break; 171 } 172 case llvm::Triple::WatchOS: 173 ABI = FloatABI::Hard; 174 break; 175 176 // FIXME: this is invalid for WindowsCE 177 case llvm::Triple::Win32: 178 ABI = FloatABI::Hard; 179 break; 180 181 case llvm::Triple::NetBSD: 182 switch (Triple.getEnvironment()) { 183 case llvm::Triple::EABIHF: 184 case llvm::Triple::GNUEABIHF: 185 ABI = FloatABI::Hard; 186 break; 187 default: 188 ABI = FloatABI::Soft; 189 break; 190 } 191 break; 192 193 case llvm::Triple::FreeBSD: 194 switch (Triple.getEnvironment()) { 195 case llvm::Triple::GNUEABIHF: 196 ABI = FloatABI::Hard; 197 break; 198 default: 199 // FreeBSD defaults to soft float 200 ABI = FloatABI::Soft; 201 break; 202 } 203 break; 204 205 case llvm::Triple::OpenBSD: 206 ABI = FloatABI::Soft; 207 break; 208 209 default: 210 switch (Triple.getEnvironment()) { 211 case llvm::Triple::GNUEABIHF: 212 case llvm::Triple::MuslEABIHF: 213 case llvm::Triple::EABIHF: 214 ABI = FloatABI::Hard; 215 break; 216 case llvm::Triple::GNUEABI: 217 case llvm::Triple::MuslEABI: 218 case llvm::Triple::EABI: 219 // EABI is always AAPCS, and if it was not marked 'hard', it's softfp 220 ABI = FloatABI::SoftFP; 221 break; 222 case llvm::Triple::Android: 223 ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft; 224 break; 225 default: 226 // Assume "soft", but warn the user we are guessing. 227 if (Triple.isOSBinFormatMachO() && 228 Triple.getSubArch() == llvm::Triple::ARMSubArch_v7em) 229 ABI = FloatABI::Hard; 230 else 231 ABI = FloatABI::Soft; 232 233 if (Triple.getOS() != llvm::Triple::UnknownOS || 234 !Triple.isOSBinFormatMachO()) 235 D.Diag(diag::warn_drv_assuming_mfloat_abi_is) << "soft"; 236 break; 237 } 238 } 239 } 240 241 assert(ABI != FloatABI::Invalid && "must select an ABI"); 242 return ABI; 243 } 244 245 void arm::getARMTargetFeatures(const ToolChain &TC, 246 const llvm::Triple &Triple, 247 const ArgList &Args, 248 ArgStringList &CmdArgs, 249 std::vector<StringRef> &Features, 250 bool ForAS) { 251 const Driver &D = TC.getDriver(); 252 253 bool KernelOrKext = 254 Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext); 255 arm::FloatABI ABI = arm::getARMFloatABI(TC, Args); 256 const Arg *WaCPU = nullptr, *WaFPU = nullptr; 257 const Arg *WaHDiv = nullptr, *WaArch = nullptr; 258 259 if (!ForAS) { 260 // FIXME: Note, this is a hack, the LLVM backend doesn't actually use these 261 // yet (it uses the -mfloat-abi and -msoft-float options), and it is 262 // stripped out by the ARM target. We should probably pass this a new 263 // -target-option, which is handled by the -cc1/-cc1as invocation. 264 // 265 // FIXME2: For consistency, it would be ideal if we set up the target 266 // machine state the same when using the frontend or the assembler. We don't 267 // currently do that for the assembler, we pass the options directly to the 268 // backend and never even instantiate the frontend TargetInfo. If we did, 269 // and used its handleTargetFeatures hook, then we could ensure the 270 // assembler and the frontend behave the same. 271 272 // Use software floating point operations? 273 if (ABI == arm::FloatABI::Soft) 274 Features.push_back("+soft-float"); 275 276 // Use software floating point argument passing? 277 if (ABI != arm::FloatABI::Hard) 278 Features.push_back("+soft-float-abi"); 279 } else { 280 // Here, we make sure that -Wa,-mfpu/cpu/arch/hwdiv will be passed down 281 // to the assembler correctly. 282 for (const Arg *A : 283 Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) { 284 StringRef Value = A->getValue(); 285 if (Value.startswith("-mfpu=")) { 286 WaFPU = A; 287 } else if (Value.startswith("-mcpu=")) { 288 WaCPU = A; 289 } else if (Value.startswith("-mhwdiv=")) { 290 WaHDiv = A; 291 } else if (Value.startswith("-march=")) { 292 WaArch = A; 293 } 294 } 295 } 296 297 // Check -march. ClangAs gives preference to -Wa,-march=. 298 const Arg *ArchArg = Args.getLastArg(options::OPT_march_EQ); 299 StringRef ArchName; 300 if (WaArch) { 301 if (ArchArg) 302 D.Diag(clang::diag::warn_drv_unused_argument) 303 << ArchArg->getAsString(Args); 304 ArchName = StringRef(WaArch->getValue()).substr(7); 305 checkARMArchName(D, WaArch, Args, ArchName, Features, Triple); 306 // FIXME: Set Arch. 307 D.Diag(clang::diag::warn_drv_unused_argument) << WaArch->getAsString(Args); 308 } else if (ArchArg) { 309 ArchName = ArchArg->getValue(); 310 checkARMArchName(D, ArchArg, Args, ArchName, Features, Triple); 311 } 312 313 // Check -mcpu. ClangAs gives preference to -Wa,-mcpu=. 314 const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ); 315 StringRef CPUName; 316 if (WaCPU) { 317 if (CPUArg) 318 D.Diag(clang::diag::warn_drv_unused_argument) 319 << CPUArg->getAsString(Args); 320 CPUName = StringRef(WaCPU->getValue()).substr(6); 321 checkARMCPUName(D, WaCPU, Args, CPUName, ArchName, Features, Triple); 322 } else if (CPUArg) { 323 CPUName = CPUArg->getValue(); 324 checkARMCPUName(D, CPUArg, Args, CPUName, ArchName, Features, Triple); 325 } 326 327 // Add CPU features for generic CPUs 328 if (CPUName == "native") { 329 llvm::StringMap<bool> HostFeatures; 330 if (llvm::sys::getHostCPUFeatures(HostFeatures)) 331 for (auto &F : HostFeatures) 332 Features.push_back( 333 Args.MakeArgString((F.second ? "+" : "-") + F.first())); 334 } 335 336 // Honor -mfpu=. ClangAs gives preference to -Wa,-mfpu=. 337 const Arg *FPUArg = Args.getLastArg(options::OPT_mfpu_EQ); 338 if (WaFPU) { 339 if (FPUArg) 340 D.Diag(clang::diag::warn_drv_unused_argument) 341 << FPUArg->getAsString(Args); 342 getARMFPUFeatures(D, WaFPU, Args, StringRef(WaFPU->getValue()).substr(6), 343 Features); 344 } else if (FPUArg) { 345 getARMFPUFeatures(D, FPUArg, Args, FPUArg->getValue(), Features); 346 } 347 348 // Honor -mhwdiv=. ClangAs gives preference to -Wa,-mhwdiv=. 349 const Arg *HDivArg = Args.getLastArg(options::OPT_mhwdiv_EQ); 350 if (WaHDiv) { 351 if (HDivArg) 352 D.Diag(clang::diag::warn_drv_unused_argument) 353 << HDivArg->getAsString(Args); 354 getARMHWDivFeatures(D, WaHDiv, Args, 355 StringRef(WaHDiv->getValue()).substr(8), Features); 356 } else if (HDivArg) 357 getARMHWDivFeatures(D, HDivArg, Args, HDivArg->getValue(), Features); 358 359 // Setting -msoft-float effectively disables NEON because of the GCC 360 // implementation, although the same isn't true of VFP or VFP3. 361 if (ABI == arm::FloatABI::Soft) { 362 Features.push_back("-neon"); 363 // Also need to explicitly disable features which imply NEON. 364 Features.push_back("-crypto"); 365 } 366 367 // En/disable crc code generation. 368 if (Arg *A = Args.getLastArg(options::OPT_mcrc, options::OPT_mnocrc)) { 369 if (A->getOption().matches(options::OPT_mcrc)) 370 Features.push_back("+crc"); 371 else 372 Features.push_back("-crc"); 373 } 374 375 // Look for the last occurrence of -mlong-calls or -mno-long-calls. If 376 // neither options are specified, see if we are compiling for kernel/kext and 377 // decide whether to pass "+long-calls" based on the OS and its version. 378 if (Arg *A = Args.getLastArg(options::OPT_mlong_calls, 379 options::OPT_mno_long_calls)) { 380 if (A->getOption().matches(options::OPT_mlong_calls)) 381 Features.push_back("+long-calls"); 382 } else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6)) && 383 !Triple.isWatchOS()) { 384 Features.push_back("+long-calls"); 385 } 386 387 // Generate execute-only output (no data access to code sections). 388 // This only makes sense for the compiler, not for the assembler. 389 if (!ForAS) { 390 // Supported only on ARMv6T2 and ARMv7 and above. 391 // Cannot be combined with -mno-movt or -mlong-calls 392 if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, options::OPT_mno_execute_only)) { 393 if (A->getOption().matches(options::OPT_mexecute_only)) { 394 if (getARMSubArchVersionNumber(Triple) < 7 && 395 llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::ArchKind::ARMV6T2) 396 D.Diag(diag::err_target_unsupported_execute_only) << Triple.getArchName(); 397 else if (Arg *B = Args.getLastArg(options::OPT_mno_movt)) 398 D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args); 399 // Long calls create constant pool entries and have not yet been fixed up 400 // to play nicely with execute-only. Hence, they cannot be used in 401 // execute-only code for now 402 else if (Arg *B = Args.getLastArg(options::OPT_mlong_calls, options::OPT_mno_long_calls)) { 403 if (B->getOption().matches(options::OPT_mlong_calls)) 404 D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args); 405 } 406 Features.push_back("+execute-only"); 407 } 408 } 409 } 410 411 // Kernel code has more strict alignment requirements. 412 if (KernelOrKext) 413 Features.push_back("+strict-align"); 414 else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access, 415 options::OPT_munaligned_access)) { 416 if (A->getOption().matches(options::OPT_munaligned_access)) { 417 // No v6M core supports unaligned memory access (v6M ARM ARM A3.2). 418 if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m) 419 D.Diag(diag::err_target_unsupported_unaligned) << "v6m"; 420 // v8M Baseline follows on from v6M, so doesn't support unaligned memory 421 // access either. 422 else if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8m_baseline) 423 D.Diag(diag::err_target_unsupported_unaligned) << "v8m.base"; 424 } else 425 Features.push_back("+strict-align"); 426 } else { 427 // Assume pre-ARMv6 doesn't support unaligned accesses. 428 // 429 // ARMv6 may or may not support unaligned accesses depending on the 430 // SCTLR.U bit, which is architecture-specific. We assume ARMv6 431 // Darwin and NetBSD targets support unaligned accesses, and others don't. 432 // 433 // ARMv7 always has SCTLR.U set to 1, but it has a new SCTLR.A bit 434 // which raises an alignment fault on unaligned accesses. Linux 435 // defaults this bit to 0 and handles it as a system-wide (not 436 // per-process) setting. It is therefore safe to assume that ARMv7+ 437 // Linux targets support unaligned accesses. The same goes for NaCl. 438 // 439 // The above behavior is consistent with GCC. 440 int VersionNum = getARMSubArchVersionNumber(Triple); 441 if (Triple.isOSDarwin() || Triple.isOSNetBSD()) { 442 if (VersionNum < 6 || 443 Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m) 444 Features.push_back("+strict-align"); 445 } else if (Triple.isOSLinux() || Triple.isOSNaCl()) { 446 if (VersionNum < 7) 447 Features.push_back("+strict-align"); 448 } else 449 Features.push_back("+strict-align"); 450 } 451 452 // llvm does not support reserving registers in general. There is support 453 // for reserving r9 on ARM though (defined as a platform-specific register 454 // in ARM EABI). 455 if (Args.hasArg(options::OPT_ffixed_r9)) 456 Features.push_back("+reserve-r9"); 457 458 // The kext linker doesn't know how to deal with movw/movt. 459 if (KernelOrKext || Args.hasArg(options::OPT_mno_movt)) 460 Features.push_back("+no-movt"); 461 462 if (Args.hasArg(options::OPT_mno_neg_immediates)) 463 Features.push_back("+no-neg-immediates"); 464 } 465 466 const std::string arm::getARMArch(StringRef Arch, const llvm::Triple &Triple) { 467 std::string MArch; 468 if (!Arch.empty()) 469 MArch = Arch; 470 else 471 MArch = Triple.getArchName(); 472 MArch = StringRef(MArch).split("+").first.lower(); 473 474 // Handle -march=native. 475 if (MArch == "native") { 476 std::string CPU = llvm::sys::getHostCPUName(); 477 if (CPU != "generic") { 478 // Translate the native cpu into the architecture suffix for that CPU. 479 StringRef Suffix = arm::getLLVMArchSuffixForARM(CPU, MArch, Triple); 480 // If there is no valid architecture suffix for this CPU we don't know how 481 // to handle it, so return no architecture. 482 if (Suffix.empty()) 483 MArch = ""; 484 else 485 MArch = std::string("arm") + Suffix.str(); 486 } 487 } 488 489 return MArch; 490 } 491 492 /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting. 493 StringRef arm::getARMCPUForMArch(StringRef Arch, const llvm::Triple &Triple) { 494 std::string MArch = getARMArch(Arch, Triple); 495 // getARMCPUForArch defaults to the triple if MArch is empty, but empty MArch 496 // here means an -march=native that we can't handle, so instead return no CPU. 497 if (MArch.empty()) 498 return StringRef(); 499 500 // We need to return an empty string here on invalid MArch values as the 501 // various places that call this function can't cope with a null result. 502 return Triple.getARMCPUForArch(MArch); 503 } 504 505 /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting. 506 std::string arm::getARMTargetCPU(StringRef CPU, StringRef Arch, 507 const llvm::Triple &Triple) { 508 // FIXME: Warn on inconsistent use of -mcpu and -march. 509 // If we have -mcpu=, use that. 510 if (!CPU.empty()) { 511 std::string MCPU = StringRef(CPU).split("+").first.lower(); 512 // Handle -mcpu=native. 513 if (MCPU == "native") 514 return llvm::sys::getHostCPUName(); 515 else 516 return MCPU; 517 } 518 519 return getARMCPUForMArch(Arch, Triple); 520 } 521 522 /// getLLVMArchSuffixForARM - Get the LLVM arch name to use for a particular 523 /// CPU (or Arch, if CPU is generic). 524 // FIXME: This is redundant with -mcpu, why does LLVM use this. 525 StringRef arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch, 526 const llvm::Triple &Triple) { 527 llvm::ARM::ArchKind ArchKind; 528 if (CPU == "generic") { 529 std::string ARMArch = tools::arm::getARMArch(Arch, Triple); 530 ArchKind = llvm::ARM::parseArch(ARMArch); 531 if (ArchKind == llvm::ARM::ArchKind::INVALID) 532 // In case of generic Arch, i.e. "arm", 533 // extract arch from default cpu of the Triple 534 ArchKind = llvm::ARM::parseCPUArch(Triple.getARMCPUForArch(ARMArch)); 535 } else { 536 // FIXME: horrible hack to get around the fact that Cortex-A7 is only an 537 // armv7k triple if it's actually been specified via "-arch armv7k". 538 ArchKind = (Arch == "armv7k" || Arch == "thumbv7k") 539 ? llvm::ARM::ArchKind::ARMV7K 540 : llvm::ARM::parseCPUArch(CPU); 541 } 542 if (ArchKind == llvm::ARM::ArchKind::INVALID) 543 return ""; 544 return llvm::ARM::getSubArch(ArchKind); 545 } 546 547 void arm::appendEBLinkFlags(const ArgList &Args, ArgStringList &CmdArgs, 548 const llvm::Triple &Triple) { 549 if (Args.hasArg(options::OPT_r)) 550 return; 551 552 // ARMv7 (and later) and ARMv6-M do not support BE-32, so instruct the linker 553 // to generate BE-8 executables. 554 if (arm::getARMSubArchVersionNumber(Triple) >= 7 || arm::isARMMProfile(Triple)) 555 CmdArgs.push_back("--be8"); 556 } 557