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