From owner-svn-src-all@freebsd.org Fri Nov 25 18:12:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42841C55274; Fri, 25 Nov 2016 18:12:15 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 114F6E47; Fri, 25 Nov 2016 18:12:14 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uAPICEfk051061; Fri, 25 Nov 2016 18:12:14 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uAPICDfM051054; Fri, 25 Nov 2016 18:12:13 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201611251812.uAPICDfM051054@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Fri, 25 Nov 2016 18:12:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309149 - in head/contrib/llvm: lib/Target/PowerPC tools/clang/lib/CodeGen tools/clang/lib/Driver X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2016 18:12:15 -0000 Author: dim Date: Fri Nov 25 18:12:13 2016 New Revision: 309149 URL: https://svnweb.freebsd.org/changeset/base/309149 Log: Pull in r283060 from upstream llvm trunk (by Hal Finkel): [PowerPC] Refactor soft-float support, and enable PPC64 soft float This change enables soft-float for PowerPC64, and also makes soft-float disable all vector instruction sets for both 32-bit and 64-bit modes. This latter part is necessary because the PPC backend canonicalizes many Altivec vector types to floating-point types, and so soft-float breaks scalarization support for many operations. Both for embedded targets and for operating-system kernels desiring soft-float support, it seems reasonable that disabling hardware floating-point also disables vector instructions (embedded targets without hardware floating point support are unlikely to have Altivec, etc. and operating system kernels desiring not to use floating-point registers to lower syscall cost are unlikely to want to use vector registers either). If someone needs this to work, we'll need to change the fact that we promote many Altivec operations to act on v4f32. To make it possible to disable Altivec when soft-float is enabled, hardware floating-point support needs to be expressed as a positive feature, like the others, and not a negative feature, because target features cannot have dependencies on the disabling of some other feature. So +soft-float has now become -hard-float. Fixes PR26970. Pull in r283061 from upstream clang trunk (by Hal Finkel): [PowerPC] Enable soft-float for PPC64, and +soft-float -> -hard-float Enable soft-float support on PPC64, as the backend now supports it. Also, the backend now uses -hard-float instead of +soft-float, so set the target features accordingly. Fixes PR26970. Reported by: Mark Millard PR: 214433 Modified: head/contrib/llvm/lib/Target/PowerPC/PPC.td head/contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp head/contrib/llvm/lib/Target/PowerPC/PPCSubtarget.cpp head/contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h head/contrib/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp head/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Modified: head/contrib/llvm/lib/Target/PowerPC/PPC.td ============================================================================== --- head/contrib/llvm/lib/Target/PowerPC/PPC.td Fri Nov 25 18:02:43 2016 (r309148) +++ head/contrib/llvm/lib/Target/PowerPC/PPC.td Fri Nov 25 18:12:13 2016 (r309149) @@ -53,40 +53,52 @@ def DirectivePwr9: SubtargetFeature<"", def Feature64Bit : SubtargetFeature<"64bit","Has64BitSupport", "true", "Enable 64-bit instructions">; -def FeatureSoftFloat : SubtargetFeature<"soft-float", "UseSoftFloat", "true", - "Use software emulation for floating point">; +def FeatureHardFloat : SubtargetFeature<"hard-float", "HasHardFloat", "true", + "Enable floating-point instructions">; def Feature64BitRegs : SubtargetFeature<"64bitregs","Use64BitRegs", "true", "Enable 64-bit registers usage for ppc32 [beta]">; def FeatureCRBits : SubtargetFeature<"crbits", "UseCRBits", "true", "Use condition-register bits individually">; def FeatureAltivec : SubtargetFeature<"altivec","HasAltivec", "true", - "Enable Altivec instructions">; + "Enable Altivec instructions", + [FeatureHardFloat]>; def FeatureSPE : SubtargetFeature<"spe","HasSPE", "true", - "Enable SPE instructions">; + "Enable SPE instructions", + [FeatureHardFloat]>; def FeatureMFOCRF : SubtargetFeature<"mfocrf","HasMFOCRF", "true", "Enable the MFOCRF instruction">; def FeatureFSqrt : SubtargetFeature<"fsqrt","HasFSQRT", "true", - "Enable the fsqrt instruction">; + "Enable the fsqrt instruction", + [FeatureHardFloat]>; def FeatureFCPSGN : SubtargetFeature<"fcpsgn", "HasFCPSGN", "true", - "Enable the fcpsgn instruction">; + "Enable the fcpsgn instruction", + [FeatureHardFloat]>; def FeatureFRE : SubtargetFeature<"fre", "HasFRE", "true", - "Enable the fre instruction">; + "Enable the fre instruction", + [FeatureHardFloat]>; def FeatureFRES : SubtargetFeature<"fres", "HasFRES", "true", - "Enable the fres instruction">; + "Enable the fres instruction", + [FeatureHardFloat]>; def FeatureFRSQRTE : SubtargetFeature<"frsqrte", "HasFRSQRTE", "true", - "Enable the frsqrte instruction">; + "Enable the frsqrte instruction", + [FeatureHardFloat]>; def FeatureFRSQRTES : SubtargetFeature<"frsqrtes", "HasFRSQRTES", "true", - "Enable the frsqrtes instruction">; + "Enable the frsqrtes instruction", + [FeatureHardFloat]>; def FeatureRecipPrec : SubtargetFeature<"recipprec", "HasRecipPrec", "true", "Assume higher precision reciprocal estimates">; def FeatureSTFIWX : SubtargetFeature<"stfiwx","HasSTFIWX", "true", - "Enable the stfiwx instruction">; + "Enable the stfiwx instruction", + [FeatureHardFloat]>; def FeatureLFIWAX : SubtargetFeature<"lfiwax","HasLFIWAX", "true", - "Enable the lfiwax instruction">; + "Enable the lfiwax instruction", + [FeatureHardFloat]>; def FeatureFPRND : SubtargetFeature<"fprnd", "HasFPRND", "true", - "Enable the fri[mnpz] instructions">; + "Enable the fri[mnpz] instructions", + [FeatureHardFloat]>; def FeatureFPCVT : SubtargetFeature<"fpcvt", "HasFPCVT", "true", - "Enable fc[ft]* (unsigned and single-precision) and lfiwzx instructions">; + "Enable fc[ft]* (unsigned and single-precision) and lfiwzx instructions", + [FeatureHardFloat]>; def FeatureISEL : SubtargetFeature<"isel","HasISEL", "true", "Enable the isel instruction">; def FeatureBPERMD : SubtargetFeature<"bpermd", "HasBPERMD", "true", @@ -112,7 +124,8 @@ def FeaturePPC4xx : SubtargetFeature< def FeaturePPC6xx : SubtargetFeature<"ppc6xx", "IsPPC6xx", "true", "Enable PPC 6xx instructions">; def FeatureQPX : SubtargetFeature<"qpx","HasQPX", "true", - "Enable QPX instructions">; + "Enable QPX instructions", + [FeatureHardFloat]>; def FeatureVSX : SubtargetFeature<"vsx","HasVSX", "true", "Enable VSX instructions", [FeatureAltivec]>; @@ -282,7 +295,8 @@ include "PPCInstrInfo.td" // PowerPC processors supported. // -def : Processor<"generic", G3Itineraries, [Directive32, FeatureMFTB]>; +def : Processor<"generic", G3Itineraries, [Directive32, FeatureHardFloat, + FeatureMFTB]>; def : ProcessorModel<"440", PPC440Model, [Directive440, FeatureISEL, FeatureFRES, FeatureFRSQRTE, FeatureICBT, FeatureBookE, @@ -291,8 +305,8 @@ def : ProcessorModel<"450", PPC440Model, FeatureFRES, FeatureFRSQRTE, FeatureICBT, FeatureBookE, FeatureMSYNC, FeatureMFTB]>; -def : Processor<"601", G3Itineraries, [Directive601]>; -def : Processor<"602", G3Itineraries, [Directive602, +def : Processor<"601", G3Itineraries, [Directive601, FeatureHardFloat]>; +def : Processor<"602", G3Itineraries, [Directive602, FeatureHardFloat, FeatureMFTB]>; def : Processor<"603", G3Itineraries, [Directive603, FeatureFRES, FeatureFRSQRTE, @@ -406,7 +420,10 @@ def : ProcessorModel<"pwr7", P7Model, Pr def : ProcessorModel<"pwr8", P8Model, ProcessorFeatures.Power8FeatureList>; // FIXME: Same as P8 until the POWER9 scheduling info is available def : ProcessorModel<"pwr9", P8Model, ProcessorFeatures.Power9FeatureList>; -def : Processor<"ppc", G3Itineraries, [Directive32, FeatureMFTB]>; +def : Processor<"ppc", G3Itineraries, [Directive32, FeatureHardFloat, + FeatureMFTB]>; +def : Processor<"ppc32", G3Itineraries, [Directive32, FeatureHardFloat, + FeatureMFTB]>; def : ProcessorModel<"ppc64", G5Model, [Directive64, FeatureAltivec, FeatureMFOCRF, FeatureFSqrt, FeatureFRES, Modified: head/contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp ============================================================================== --- head/contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp Fri Nov 25 18:02:43 2016 (r309148) +++ head/contrib/llvm/lib/Target/PowerPC/PPCISelLowering.cpp Fri Nov 25 18:12:13 2016 (r309149) @@ -3144,7 +3144,7 @@ SDValue PPCTargetLowering::LowerFormalAr }; const unsigned Num_GPR_Regs = array_lengthof(GPR); - const unsigned Num_FPR_Regs = 13; + const unsigned Num_FPR_Regs = useSoftFloat() ? 0 : 13; const unsigned Num_VR_Regs = array_lengthof(VR); const unsigned Num_QFPR_Regs = Num_FPR_Regs; @@ -3557,7 +3557,7 @@ SDValue PPCTargetLowering::LowerFormalAr }; const unsigned Num_GPR_Regs = array_lengthof(GPR_32); - const unsigned Num_FPR_Regs = 13; + const unsigned Num_FPR_Regs = useSoftFloat() ? 0 : 13; const unsigned Num_VR_Regs = array_lengthof( VR); unsigned GPR_idx = 0, FPR_idx = 0, VR_idx = 0; @@ -10340,7 +10340,7 @@ SDValue PPCTargetLowering::combineFPToIn N->getOpcode() == ISD::UINT_TO_FP) && "Need an int -> FP conversion node here"); - if (!Subtarget.has64BitSupport()) + if (useSoftFloat() || !Subtarget.has64BitSupport()) return SDValue(); SelectionDAG &DAG = DCI.DAG; Modified: head/contrib/llvm/lib/Target/PowerPC/PPCSubtarget.cpp ============================================================================== --- head/contrib/llvm/lib/Target/PowerPC/PPCSubtarget.cpp Fri Nov 25 18:02:43 2016 (r309148) +++ head/contrib/llvm/lib/Target/PowerPC/PPCSubtarget.cpp Fri Nov 25 18:12:13 2016 (r309149) @@ -62,7 +62,7 @@ void PPCSubtarget::initializeEnvironment Has64BitSupport = false; Use64BitRegs = false; UseCRBits = false; - UseSoftFloat = false; + HasHardFloat = false; HasAltivec = false; HasSPE = false; HasQPX = false; Modified: head/contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h ============================================================================== --- head/contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h Fri Nov 25 18:02:43 2016 (r309148) +++ head/contrib/llvm/lib/Target/PowerPC/PPCSubtarget.h Fri Nov 25 18:12:13 2016 (r309149) @@ -91,7 +91,7 @@ protected: bool Has64BitSupport; bool Use64BitRegs; bool UseCRBits; - bool UseSoftFloat; + bool HasHardFloat; bool IsPPC64; bool HasAltivec; bool HasSPE; @@ -205,7 +205,7 @@ public: /// instructions, regardless of whether we are in 32-bit or 64-bit mode. bool has64BitSupport() const { return Has64BitSupport; } // useSoftFloat - Return true if soft-float option is turned on. - bool useSoftFloat() const { return UseSoftFloat; } + bool useSoftFloat() const { return !HasHardFloat; } /// use64BitRegs - Return true if in 64-bit mode or if we should use 64-bit /// registers in 32-bit mode when possible. This can only true if Modified: head/contrib/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp ============================================================================== --- head/contrib/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Fri Nov 25 18:02:43 2016 (r309148) +++ head/contrib/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp Fri Nov 25 18:12:13 2016 (r309149) @@ -268,7 +268,7 @@ PPCTargetMachine::getSubtargetImpl(const // If the soft float attribute is set on the function turn on the soft float // subtarget feature. if (SoftFloat) - FS += FS.empty() ? "+soft-float" : ",+soft-float"; + FS += FS.empty() ? "-hard-float" : ",-hard-float"; auto &I = SubtargetMap[CPU + FS]; if (!I) { Modified: head/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp ============================================================================== --- head/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp Fri Nov 25 18:02:43 2016 (r309148) +++ head/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp Fri Nov 25 18:12:13 2016 (r309149) @@ -3859,6 +3859,7 @@ private: static const unsigned GPRBits = 64; ABIKind Kind; bool HasQPX; + bool IsSoftFloatABI; // A vector of float or double will be promoted to <4 x f32> or <4 x f64> and // will be passed in a QPX register. @@ -3889,8 +3890,10 @@ private: } public: - PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, ABIKind Kind, bool HasQPX) - : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX) {} + PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, ABIKind Kind, bool HasQPX, + bool SoftFloatABI) + : ABIInfo(CGT), Kind(Kind), HasQPX(HasQPX), + IsSoftFloatABI(SoftFloatABI) {} bool isPromotableTypeForABI(QualType Ty) const; CharUnits getParamTypeAlignment(QualType Ty) const; @@ -3938,8 +3941,10 @@ class PPC64_SVR4_TargetCodeGenInfo : pub public: PPC64_SVR4_TargetCodeGenInfo(CodeGenTypes &CGT, - PPC64_SVR4_ABIInfo::ABIKind Kind, bool HasQPX) - : TargetCodeGenInfo(new PPC64_SVR4_ABIInfo(CGT, Kind, HasQPX)) {} + PPC64_SVR4_ABIInfo::ABIKind Kind, bool HasQPX, + bool SoftFloatABI) + : TargetCodeGenInfo(new PPC64_SVR4_ABIInfo(CGT, Kind, HasQPX, + SoftFloatABI)) {} int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override { // This is recovered from gcc output. @@ -4157,8 +4162,11 @@ bool PPC64_SVR4_ABIInfo::isHomogeneousAg if (const BuiltinType *BT = Ty->getAs()) { if (BT->getKind() == BuiltinType::Float || BT->getKind() == BuiltinType::Double || - BT->getKind() == BuiltinType::LongDouble) + BT->getKind() == BuiltinType::LongDouble) { + if (IsSoftFloatABI) + return false; return true; + } } if (const VectorType *VT = Ty->getAs()) { if (getContext().getTypeSize(VT) == 128 || IsQPXVectorTy(Ty)) @@ -7964,8 +7972,10 @@ const TargetCodeGenInfo &CodeGenModule:: if (getTarget().getABI() == "elfv2") Kind = PPC64_SVR4_ABIInfo::ELFv2; bool HasQPX = getTarget().getABI() == "elfv1-qpx"; + bool IsSoftFloat = CodeGenOpts.FloatABI == "soft"; - return SetCGInfo(new PPC64_SVR4_TargetCodeGenInfo(Types, Kind, HasQPX)); + return SetCGInfo(new PPC64_SVR4_TargetCodeGenInfo(Types, Kind, HasQPX, + IsSoftFloat)); } else return SetCGInfo(new PPC64TargetCodeGenInfo(Types)); case llvm::Triple::ppc64le: { @@ -7974,8 +7984,10 @@ const TargetCodeGenInfo &CodeGenModule:: if (getTarget().getABI() == "elfv1" || getTarget().getABI() == "elfv1-qpx") Kind = PPC64_SVR4_ABIInfo::ELFv1; bool HasQPX = getTarget().getABI() == "elfv1-qpx"; + bool IsSoftFloat = CodeGenOpts.FloatABI == "soft"; - return SetCGInfo(new PPC64_SVR4_TargetCodeGenInfo(Types, Kind, HasQPX)); + return SetCGInfo(new PPC64_SVR4_TargetCodeGenInfo(Types, Kind, HasQPX, + IsSoftFloat)); } case llvm::Triple::nvptx: Modified: head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp ============================================================================== --- head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Fri Nov 25 18:02:43 2016 (r309148) +++ head/contrib/llvm/tools/clang/lib/Driver/Tools.cpp Fri Nov 25 18:12:13 2016 (r309149) @@ -1601,15 +1601,8 @@ static void getPPCTargetFeatures(const D handleTargetFeaturesGroup(Args, Features, options::OPT_m_ppc_Features_Group); ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args); - if (FloatABI == ppc::FloatABI::Soft && - !(Triple.getArch() == llvm::Triple::ppc64 || - Triple.getArch() == llvm::Triple::ppc64le)) - Features.push_back("+soft-float"); - else if (FloatABI == ppc::FloatABI::Soft && - (Triple.getArch() == llvm::Triple::ppc64 || - Triple.getArch() == llvm::Triple::ppc64le)) - D.Diag(diag::err_drv_invalid_mfloat_abi) - << "soft float is not supported for ppc64"; + if (FloatABI == ppc::FloatABI::Soft) + Features.push_back("-hard-float"); // Altivec is a bit weird, allow overriding of the Altivec feature here. AddTargetFeature(Args, Features, options::OPT_faltivec,