OLD | NEW |
1 //===--- Targets.cpp - Implement -arch option and targets -----------------===// | 1 //===--- Targets.cpp - Implement -arch option and targets -----------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements construction of a TargetInfo object from a | 10 // This file implements construction of a TargetInfo object from a |
(...skipping 3511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3522 | 3522 |
3523 unsigned IsAAPCS : 1; | 3523 unsigned IsAAPCS : 1; |
3524 unsigned IsThumb : 1; | 3524 unsigned IsThumb : 1; |
3525 | 3525 |
3526 // Initialized via features. | 3526 // Initialized via features. |
3527 unsigned SoftFloat : 1; | 3527 unsigned SoftFloat : 1; |
3528 unsigned SoftFloatABI : 1; | 3528 unsigned SoftFloatABI : 1; |
3529 | 3529 |
3530 static const Builtin::Info BuiltinInfo[]; | 3530 static const Builtin::Info BuiltinInfo[]; |
3531 | 3531 |
3532 static bool shouldUseInlineAtomic(const llvm::Triple &T) { | |
3533 // On linux, binaries targeting old cpus call functions in libgcc to | |
3534 // perform atomic operations. The implementation in libgcc then calls into | |
3535 // the kernel which on armv6 and newer uses ldrex and strex. The net result | |
3536 // is that if we assume the kernel is at least as recent as the hardware, | |
3537 // it is safe to use atomic instructions on armv6 and newer. | |
3538 if (T.getOS() != llvm::Triple::Linux) | |
3539 return false; | |
3540 StringRef ArchName = T.getArchName(); | |
3541 if (T.getArch() == llvm::Triple::arm) { | |
3542 if (!ArchName.startswith("armv")) | |
3543 return false; | |
3544 StringRef VersionStr = ArchName.substr(4); | |
3545 unsigned Version; | |
3546 if (VersionStr.getAsInteger(10, Version)) | |
3547 return false; | |
3548 return Version >= 6; | |
3549 } | |
3550 assert(T.getArch() == llvm::Triple::thumb); | |
3551 if (!ArchName.startswith("thumbv")) | |
3552 return false; | |
3553 StringRef VersionStr = ArchName.substr(6); | |
3554 unsigned Version; | |
3555 if (VersionStr.getAsInteger(10, Version)) | |
3556 return false; | |
3557 return Version >= 7; | |
3558 } | |
3559 | |
3560 public: | 3532 public: |
3561 ARMTargetInfo(const std::string &TripleStr) | 3533 ARMTargetInfo(const std::string &TripleStr) |
3562 : TargetInfo(TripleStr), ABI("aapcs-linux"), CPU("arm1136j-s"), IsAAPCS(true
) | 3534 : TargetInfo(TripleStr), ABI("aapcs-linux"), CPU("arm1136j-s"), IsAAPCS(true
) |
3563 { | 3535 { |
3564 BigEndian = false; | 3536 BigEndian = false; |
3565 SizeType = UnsignedInt; | 3537 SizeType = UnsignedInt; |
3566 PtrDiffType = SignedInt; | 3538 PtrDiffType = SignedInt; |
3567 // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int. | 3539 // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int. |
3568 WCharType = UnsignedInt; | 3540 WCharType = UnsignedInt; |
3569 | 3541 |
(...skipping 12 matching lines...) Expand all Loading... |
3582 } else { | 3554 } else { |
3583 DescriptionString = ("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" | 3555 DescriptionString = ("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" |
3584 "i64:64:64-f32:32:32-f64:64:64-" | 3556 "i64:64:64-f32:32:32-f64:64:64-" |
3585 "v64:64:64-v128:64:128-a0:0:64-n32-S64"); | 3557 "v64:64:64-v128:64:128-a0:0:64-n32-S64"); |
3586 } | 3558 } |
3587 | 3559 |
3588 // ARM targets default to using the ARM C++ ABI. | 3560 // ARM targets default to using the ARM C++ ABI. |
3589 TheCXXABI.set(TargetCXXABI::GenericARM); | 3561 TheCXXABI.set(TargetCXXABI::GenericARM); |
3590 | 3562 |
3591 // ARM has atomics up to 8 bytes | 3563 // ARM has atomics up to 8 bytes |
| 3564 // FIXME: Set MaxAtomicInlineWidth if we have the feature v6e |
3592 MaxAtomicPromoteWidth = 64; | 3565 MaxAtomicPromoteWidth = 64; |
3593 if (shouldUseInlineAtomic(getTriple())) | |
3594 MaxAtomicInlineWidth = 64; | |
3595 | 3566 |
3596 // Do force alignment of members that follow zero length bitfields. If | 3567 // Do force alignment of members that follow zero length bitfields. If |
3597 // the alignment of the zero-length bitfield is greater than the member | 3568 // the alignment of the zero-length bitfield is greater than the member |
3598 // that follows it, `bar', `bar' will be aligned as the type of the | 3569 // that follows it, `bar', `bar' will be aligned as the type of the |
3599 // zero length bitfield. | 3570 // zero length bitfield. |
3600 UseZeroLengthBitfieldAlignment = true; | 3571 UseZeroLengthBitfieldAlignment = true; |
3601 } | 3572 } |
3602 virtual const char *getABI() const { return ABI.c_str(); } | 3573 virtual const char *getABI() const { return ABI.c_str(); } |
3603 virtual bool setABI(const std::string &Name) { | 3574 virtual bool setABI(const std::string &Name) { |
3604 ABI = Name; | 3575 ABI = Name; |
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5582 // FIXME: If we are completely confident that we have the right set, we only | 5553 // FIXME: If we are completely confident that we have the right set, we only |
5583 // need to pass the minuses. | 5554 // need to pass the minuses. |
5584 Opts->Features.clear(); | 5555 Opts->Features.clear(); |
5585 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), | 5556 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), |
5586 ie = Features.end(); it != ie; ++it) | 5557 ie = Features.end(); it != ie; ++it) |
5587 Opts->Features.push_back((it->second ? "+" : "-") + it->first().str()); | 5558 Opts->Features.push_back((it->second ? "+" : "-") + it->first().str()); |
5588 Target->HandleTargetFeatures(Opts->Features); | 5559 Target->HandleTargetFeatures(Opts->Features); |
5589 | 5560 |
5590 return Target.take(); | 5561 return Target.take(); |
5591 } | 5562 } |
OLD | NEW |