| 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 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 this->LongLongWidth = 64; | 751 this->LongLongWidth = 64; |
| 752 this->LongLongAlign = 64; | 752 this->LongLongAlign = 64; |
| 753 this->SizeType = TargetInfo::UnsignedInt; | 753 this->SizeType = TargetInfo::UnsignedInt; |
| 754 this->PtrDiffType = TargetInfo::SignedInt; | 754 this->PtrDiffType = TargetInfo::SignedInt; |
| 755 this->IntPtrType = TargetInfo::SignedInt; | 755 this->IntPtrType = TargetInfo::SignedInt; |
| 756 // RegParmMax is inherited from the underlying architecture | 756 // RegParmMax is inherited from the underlying architecture |
| 757 this->LongDoubleFormat = &llvm::APFloat::IEEEdouble; | 757 this->LongDoubleFormat = &llvm::APFloat::IEEEdouble; |
| 758 if (Triple.getArch() == llvm::Triple::arm) { | 758 if (Triple.getArch() == llvm::Triple::arm) { |
| 759 // Handled in ARM's setABI(). | 759 // Handled in ARM's setABI(). |
| 760 } else if (Triple.getArch() == llvm::Triple::x86) { | 760 } else if (Triple.getArch() == llvm::Triple::x86) { |
| 761 // @LOCALMOD MERGETODO: upstream this if it actually works. | 761 // Handled in X86_32's setDescriptionString. |
| 762 this->DescriptionString = "e-m:e-p:32:32-i64:64-n8:16:32-S128"; | |
| 763 } else if (Triple.getArch() == llvm::Triple::x86_64) { | 762 } else if (Triple.getArch() == llvm::Triple::x86_64) { |
| 764 this->DescriptionString = "e-m:e-p:32:32-i64:64-n8:16:32:64-S128"; | 763 this->DescriptionString = "e-m:e-p:32:32-i64:64-n8:16:32:64-S128"; |
| 765 } else if (Triple.getArch() == llvm::Triple::mipsel) { | 764 } else if (Triple.getArch() == llvm::Triple::mipsel) { |
| 766 // Handled on mips' setDescriptionString. | 765 // Handled on mips' setDescriptionString. |
| 767 } else { | 766 } else { |
| 768 assert(Triple.getArch() == llvm::Triple::le32); | 767 assert(Triple.getArch() == llvm::Triple::le32); |
| 769 this->DescriptionString = "e-p:32:32-i64:64-n32"; | 768 this->DescriptionString = "e-p:32:32-i64:64-n32"; |
| 770 } | 769 } |
| 771 } | 770 } |
| 772 }; | 771 }; |
| (...skipping 2680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3453 return std::string("{st}"); | 3452 return std::string("{st}"); |
| 3454 case 'u': // second from top of floating point stack. | 3453 case 'u': // second from top of floating point stack. |
| 3455 return std::string("{st(1)}"); // second from top of floating point stack. | 3454 return std::string("{st(1)}"); // second from top of floating point stack. |
| 3456 default: | 3455 default: |
| 3457 return std::string(1, *Constraint); | 3456 return std::string(1, *Constraint); |
| 3458 } | 3457 } |
| 3459 } | 3458 } |
| 3460 | 3459 |
| 3461 // X86-32 generic target | 3460 // X86-32 generic target |
| 3462 class X86_32TargetInfo : public X86TargetInfo { | 3461 class X86_32TargetInfo : public X86TargetInfo { |
| 3462 // @LOCALMOD-START |
| 3463 virtual void setDescriptionString() { |
| 3464 if (getTriple().isOSNaCl()) |
| 3465 DescriptionString = "e-m:e-p:32:32-i64:64-n8:16:32-S128"; |
| 3466 else if (HasAlignedDouble) |
| 3467 DescriptionString = "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-S128"; |
| 3468 else |
| 3469 DescriptionString = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"; |
| 3470 } |
| 3471 bool HasAlignedDouble; |
| 3472 // @LOCALMOD-END |
| 3463 public: | 3473 public: |
| 3464 X86_32TargetInfo(const llvm::Triple &Triple) : X86TargetInfo(Triple) { | 3474 X86_32TargetInfo(const llvm::Triple &Triple) : X86TargetInfo(Triple) { |
| 3465 DoubleAlign = LongLongAlign = 32; | 3475 DoubleAlign = LongLongAlign = 32; |
| 3466 LongDoubleWidth = 96; | 3476 LongDoubleWidth = 96; |
| 3467 LongDoubleAlign = 32; | 3477 LongDoubleAlign = 32; |
| 3468 SuitableAlign = 128; | 3478 SuitableAlign = 128; |
| 3469 DescriptionString = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"; | |
| 3470 SizeType = UnsignedInt; | 3479 SizeType = UnsignedInt; |
| 3471 PtrDiffType = SignedInt; | 3480 PtrDiffType = SignedInt; |
| 3472 IntPtrType = SignedInt; | 3481 IntPtrType = SignedInt; |
| 3473 RegParmMax = 3; | 3482 RegParmMax = 3; |
| 3474 | 3483 |
| 3475 // Use fpret for all types. | 3484 // Use fpret for all types. |
| 3476 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) | | 3485 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) | |
| 3477 (1 << TargetInfo::Double) | | 3486 (1 << TargetInfo::Double) | |
| 3478 (1 << TargetInfo::LongDouble)); | 3487 (1 << TargetInfo::LongDouble)); |
| 3479 | 3488 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3504 case 'd': | 3513 case 'd': |
| 3505 case 'S': | 3514 case 'S': |
| 3506 case 'D': | 3515 case 'D': |
| 3507 return Size <= 32; | 3516 return Size <= 32; |
| 3508 case 'A': | 3517 case 'A': |
| 3509 return Size <= 64; | 3518 return Size <= 64; |
| 3510 } | 3519 } |
| 3511 | 3520 |
| 3512 return X86TargetInfo::validateOperandSize(Constraint, Size); | 3521 return X86TargetInfo::validateOperandSize(Constraint, Size); |
| 3513 } | 3522 } |
| 3523 // @LOCALMOD-START |
| 3524 bool handleTargetFeatures(std::vector<std::string> &Features, |
| 3525 DiagnosticsEngine &Diags) override { |
| 3526 HasAlignedDouble = false; |
| 3527 auto it = std::find(Features.begin(), Features.end(), "+align-double"); |
| 3528 if (it != Features.end()) { |
| 3529 HasAlignedDouble = true; |
| 3530 Features.erase(it); |
| 3531 } |
| 3532 |
| 3533 setDescriptionString(); |
| 3534 |
| 3535 return X86TargetInfo::handleTargetFeatures(Features, Diags); |
| 3536 } |
| 3537 // @LOCALMOD-END |
| 3514 }; | 3538 }; |
| 3515 | 3539 |
| 3516 class NetBSDI386TargetInfo : public NetBSDTargetInfo<X86_32TargetInfo> { | 3540 class NetBSDI386TargetInfo : public NetBSDTargetInfo<X86_32TargetInfo> { |
| 3517 public: | 3541 public: |
| 3518 NetBSDI386TargetInfo(const llvm::Triple &Triple) | 3542 NetBSDI386TargetInfo(const llvm::Triple &Triple) |
| 3519 : NetBSDTargetInfo<X86_32TargetInfo>(Triple) {} | 3543 : NetBSDTargetInfo<X86_32TargetInfo>(Triple) {} |
| 3520 | 3544 |
| 3521 unsigned getFloatEvalMethod() const override { | 3545 unsigned getFloatEvalMethod() const override { |
| 3522 unsigned Major, Minor, Micro; | 3546 unsigned Major, Minor, Micro; |
| 3523 getTriple().getOSVersion(Major, Minor, Micro); | 3547 getTriple().getOSVersion(Major, Minor, Micro); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3543 public: | 3567 public: |
| 3544 BitrigI386TargetInfo(const llvm::Triple &Triple) | 3568 BitrigI386TargetInfo(const llvm::Triple &Triple) |
| 3545 : BitrigTargetInfo<X86_32TargetInfo>(Triple) { | 3569 : BitrigTargetInfo<X86_32TargetInfo>(Triple) { |
| 3546 SizeType = UnsignedLong; | 3570 SizeType = UnsignedLong; |
| 3547 IntPtrType = SignedLong; | 3571 IntPtrType = SignedLong; |
| 3548 PtrDiffType = SignedLong; | 3572 PtrDiffType = SignedLong; |
| 3549 } | 3573 } |
| 3550 }; | 3574 }; |
| 3551 | 3575 |
| 3552 class DarwinI386TargetInfo : public DarwinTargetInfo<X86_32TargetInfo> { | 3576 class DarwinI386TargetInfo : public DarwinTargetInfo<X86_32TargetInfo> { |
| 3577 // @LOCALMOD-START |
| 3578 void setDescriptionString() override { |
| 3579 DescriptionString = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"; |
| 3580 } |
| 3581 // @LOCALMOD-END |
| 3553 public: | 3582 public: |
| 3554 DarwinI386TargetInfo(const llvm::Triple &Triple) | 3583 DarwinI386TargetInfo(const llvm::Triple &Triple) |
| 3555 : DarwinTargetInfo<X86_32TargetInfo>(Triple) { | 3584 : DarwinTargetInfo<X86_32TargetInfo>(Triple) { |
| 3556 LongDoubleWidth = 128; | 3585 LongDoubleWidth = 128; |
| 3557 LongDoubleAlign = 128; | 3586 LongDoubleAlign = 128; |
| 3558 SuitableAlign = 128; | 3587 SuitableAlign = 128; |
| 3559 MaxVectorAlign = 256; | 3588 MaxVectorAlign = 256; |
| 3560 SizeType = UnsignedLong; | 3589 SizeType = UnsignedLong; |
| 3561 IntPtrType = SignedLong; | 3590 IntPtrType = SignedLong; |
| 3562 DescriptionString = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"; | |
| 3563 HasAlignMac68kSupport = true; | 3591 HasAlignMac68kSupport = true; |
| 3564 } | 3592 } |
| 3565 | 3593 |
| 3566 }; | 3594 }; |
| 3567 | 3595 |
| 3568 // x86-32 Windows target | 3596 // x86-32 Windows target |
| 3569 class WindowsX86_32TargetInfo : public WindowsTargetInfo<X86_32TargetInfo> { | 3597 class WindowsX86_32TargetInfo : public WindowsTargetInfo<X86_32TargetInfo> { |
| 3598 // @LOCALMOD-START |
| 3599 void setDescriptionString() override { |
| 3600 if (getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF()) |
| 3601 DescriptionString = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-S32"; |
| 3602 else |
| 3603 DescriptionString = "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-S32"; |
| 3604 } |
| 3605 // @LOCALMOD-END |
| 3570 public: | 3606 public: |
| 3571 WindowsX86_32TargetInfo(const llvm::Triple &Triple) | 3607 WindowsX86_32TargetInfo(const llvm::Triple &Triple) |
| 3572 : WindowsTargetInfo<X86_32TargetInfo>(Triple) { | 3608 : WindowsTargetInfo<X86_32TargetInfo>(Triple) { |
| 3573 WCharType = UnsignedShort; | 3609 WCharType = UnsignedShort; |
| 3574 DoubleAlign = LongLongAlign = 64; | 3610 DoubleAlign = LongLongAlign = 64; |
| 3575 bool IsWinCOFF = | |
| 3576 getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); | |
| 3577 DescriptionString = IsWinCOFF ? "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-S32" | |
| 3578 : "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-S32"; | |
| 3579 } | 3611 } |
| 3580 void getTargetDefines(const LangOptions &Opts, | 3612 void getTargetDefines(const LangOptions &Opts, |
| 3581 MacroBuilder &Builder) const override { | 3613 MacroBuilder &Builder) const override { |
| 3582 WindowsTargetInfo<X86_32TargetInfo>::getTargetDefines(Opts, Builder); | 3614 WindowsTargetInfo<X86_32TargetInfo>::getTargetDefines(Opts, Builder); |
| 3583 } | 3615 } |
| 3584 }; | 3616 }; |
| 3585 | 3617 |
| 3586 // x86-32 Windows Visual Studio target | 3618 // x86-32 Windows Visual Studio target |
| 3587 class MicrosoftX86_32TargetInfo : public WindowsX86_32TargetInfo { | 3619 class MicrosoftX86_32TargetInfo : public WindowsX86_32TargetInfo { |
| 3588 public: | 3620 public: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3641 WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); | 3673 WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder); |
| 3642 DefineStd(Builder, "WIN32", Opts); | 3674 DefineStd(Builder, "WIN32", Opts); |
| 3643 DefineStd(Builder, "WINNT", Opts); | 3675 DefineStd(Builder, "WINNT", Opts); |
| 3644 Builder.defineMacro("_X86_"); | 3676 Builder.defineMacro("_X86_"); |
| 3645 addMinGWDefines(Opts, Builder); | 3677 addMinGWDefines(Opts, Builder); |
| 3646 } | 3678 } |
| 3647 }; | 3679 }; |
| 3648 | 3680 |
| 3649 // x86-32 Cygwin target | 3681 // x86-32 Cygwin target |
| 3650 class CygwinX86_32TargetInfo : public X86_32TargetInfo { | 3682 class CygwinX86_32TargetInfo : public X86_32TargetInfo { |
| 3683 // @LOCALMOD-START |
| 3684 void setDescriptionString() override { |
| 3685 DescriptionString = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-S32"; |
| 3686 } |
| 3687 // @LOCALMOD-END |
| 3651 public: | 3688 public: |
| 3652 CygwinX86_32TargetInfo(const llvm::Triple &Triple) | 3689 CygwinX86_32TargetInfo(const llvm::Triple &Triple) |
| 3653 : X86_32TargetInfo(Triple) { | 3690 : X86_32TargetInfo(Triple) { |
| 3654 TLSSupported = false; | 3691 TLSSupported = false; |
| 3655 WCharType = UnsignedShort; | 3692 WCharType = UnsignedShort; |
| 3656 DoubleAlign = LongLongAlign = 64; | 3693 DoubleAlign = LongLongAlign = 64; |
| 3657 DescriptionString = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-S32"; | |
| 3658 } | 3694 } |
| 3659 void getTargetDefines(const LangOptions &Opts, | 3695 void getTargetDefines(const LangOptions &Opts, |
| 3660 MacroBuilder &Builder) const override { | 3696 MacroBuilder &Builder) const override { |
| 3661 X86_32TargetInfo::getTargetDefines(Opts, Builder); | 3697 X86_32TargetInfo::getTargetDefines(Opts, Builder); |
| 3662 Builder.defineMacro("_X86_"); | 3698 Builder.defineMacro("_X86_"); |
| 3663 Builder.defineMacro("__CYGWIN__"); | 3699 Builder.defineMacro("__CYGWIN__"); |
| 3664 Builder.defineMacro("__CYGWIN32__"); | 3700 Builder.defineMacro("__CYGWIN32__"); |
| 3665 DefineStd(Builder, "unix", Opts); | 3701 DefineStd(Builder, "unix", Opts); |
| 3666 if (Opts.CPlusPlus) | 3702 if (Opts.CPlusPlus) |
| 3667 Builder.defineMacro("_GNU_SOURCE"); | 3703 Builder.defineMacro("_GNU_SOURCE"); |
| (...skipping 3596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7264 // need to pass the minuses. | 7300 // need to pass the minuses. |
| 7265 Opts->Features.clear(); | 7301 Opts->Features.clear(); |
| 7266 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), | 7302 for (llvm::StringMap<bool>::const_iterator it = Features.begin(), |
| 7267 ie = Features.end(); it != ie; ++it) | 7303 ie = Features.end(); it != ie; ++it) |
| 7268 Opts->Features.push_back((it->second ? "+" : "-") + it->first().str()); | 7304 Opts->Features.push_back((it->second ? "+" : "-") + it->first().str()); |
| 7269 if (!Target->handleTargetFeatures(Opts->Features, Diags)) | 7305 if (!Target->handleTargetFeatures(Opts->Features, Diags)) |
| 7270 return nullptr; | 7306 return nullptr; |
| 7271 | 7307 |
| 7272 return Target.release(); | 7308 return Target.release(); |
| 7273 } | 7309 } |
| OLD | NEW |