From owner-svn-src-head@freebsd.org Thu Apr 19 20:36:17 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C54A1FA0208; Thu, 19 Apr 2018 20:36:16 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 70D9B78773; Thu, 19 Apr 2018 20:36:16 +0000 (UTC) (envelope-from brooks@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6BC646BE2; Thu, 19 Apr 2018 20:36:16 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3JKaGm7019968; Thu, 19 Apr 2018 20:36:16 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3JKaFEp019960; Thu, 19 Apr 2018 20:36:15 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804192036.w3JKaFEp019960@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 19 Apr 2018 20:36:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332792 - in head/lib: libc/riscv libc/riscv/gen msun/riscv X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head/lib: libc/riscv libc/riscv/gen msun/riscv X-SVN-Commit-Revision: 332792 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Apr 2018 20:36:17 -0000 Author: brooks Date: Thu Apr 19 20:36:15 2018 New Revision: 332792 URL: https://svnweb.freebsd.org/changeset/base/332792 Log: Replace SOFTFLOAT with __riscv_float_abi_*. With SOFTFLOAT, libc and libm were built correctly, but any program including fenv.h itself assumed it was on a hardfloat systen and emitted inline fpu instructions for fedisableexcept() and friends. Unlike r315424 which did this for MIPS, I've used riscv_float_abi_soft and riscv_float_abi_double macros as appropriate rather than using __riscv_float_abi_soft exclusively. This ensures that attempts to use an unsupported hardfloat ABI will fail. Reviewed by: br Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D10039 Modified: head/lib/libc/riscv/Makefile.inc head/lib/libc/riscv/gen/_setjmp.S head/lib/libc/riscv/gen/fabs.S head/lib/libc/riscv/gen/flt_rounds.c head/lib/libc/riscv/gen/setjmp.S head/lib/msun/riscv/Makefile.inc head/lib/msun/riscv/fenv.c head/lib/msun/riscv/fenv.h Modified: head/lib/libc/riscv/Makefile.inc ============================================================================== --- head/lib/libc/riscv/Makefile.inc Thu Apr 19 20:31:52 2018 (r332791) +++ head/lib/libc/riscv/Makefile.inc Thu Apr 19 20:36:15 2018 (r332792) @@ -3,10 +3,6 @@ # Machine dependent definitions for the RISC-V architecture. # -.if ${MACHINE_ARCH:Mriscv*sf} != "" -CFLAGS+=-DSOFTFLOAT -.endif - # Long double is quad precision GDTOASRCS+=strtorQ.c SRCS+=machdep_ldisQ.c Modified: head/lib/libc/riscv/gen/_setjmp.S ============================================================================== --- head/lib/libc/riscv/gen/_setjmp.S Thu Apr 19 20:31:52 2018 (r332791) +++ head/lib/libc/riscv/gen/_setjmp.S Thu Apr 19 20:36:15 2018 (r332792) @@ -61,7 +61,7 @@ ENTRY(_setjmp) sd ra, (12 * 8)(a0) addi a0, a0, (13 * 8) -#if !defined(_STANDALONE) && !defined(SOFTFLOAT) +#if !defined(_STANDALONE) && defined(__riscv_float_abi_double) /* Store the fpe registers */ fsd fs0, (0 * 16)(a0) fsd fs1, (1 * 16)(a0) @@ -114,7 +114,7 @@ ENTRY(_longjmp) ld ra, (12 * 8)(a0) addi a0, a0, (13 * 8) -#if !defined(_STANDALONE) && !defined(SOFTFLOAT) +#if !defined(_STANDALONE) && defined(__riscv_float_abi_double) /* Restore the fpe registers */ fld fs0, (0 * 16)(a0) fld fs1, (1 * 16)(a0) Modified: head/lib/libc/riscv/gen/fabs.S ============================================================================== --- head/lib/libc/riscv/gen/fabs.S Thu Apr 19 20:31:52 2018 (r332791) +++ head/lib/libc/riscv/gen/fabs.S Thu Apr 19 20:36:15 2018 (r332792) @@ -35,7 +35,7 @@ #include __FBSDID("$FreeBSD$"); -#ifndef SOFTFLOAT +#ifdef __riscv_float_abi_double ENTRY(fabs) fabs.d fa0, fa0 ret Modified: head/lib/libc/riscv/gen/flt_rounds.c ============================================================================== --- head/lib/libc/riscv/gen/flt_rounds.c Thu Apr 19 20:31:52 2018 (r332791) +++ head/lib/libc/riscv/gen/flt_rounds.c Thu Apr 19 20:36:15 2018 (r332792) @@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef SOFTFLOAT +#ifdef __riscv_float_abi_soft #include "softfloat-for-gcc.h" #include "milieu.h" #include "softfloat.h" @@ -51,7 +51,7 @@ __flt_rounds(void) { uint64_t mode; -#ifdef SOFTFLOAT +#ifdef __riscv_float_abi_soft mode = __softfloat_float_rounding_mode; #else __asm __volatile("csrr %0, fcsr" : "=r" (mode)); Modified: head/lib/libc/riscv/gen/setjmp.S ============================================================================== --- head/lib/libc/riscv/gen/setjmp.S Thu Apr 19 20:31:52 2018 (r332791) +++ head/lib/libc/riscv/gen/setjmp.S Thu Apr 19 20:36:15 2018 (r332792) @@ -75,7 +75,7 @@ ENTRY(setjmp) sd ra, (12 * 8)(a0) addi a0, a0, (13 * 8) -#ifndef SOFTFLOAT +#ifdef __riscv_float_abi_double /* Store the fpe registers */ fsd fs0, (0 * 16)(a0) fsd fs1, (1 * 16)(a0) @@ -144,7 +144,7 @@ ENTRY(longjmp) ld ra, (12 * 8)(a0) addi a0, a0, (13 * 8) -#ifndef SOFTFLOAT +#ifdef __riscv_float_abi_double /* Restore the fpe registers */ fld fs0, (0 * 16)(a0) fld fs1, (1 * 16)(a0) Modified: head/lib/msun/riscv/Makefile.inc ============================================================================== --- head/lib/msun/riscv/Makefile.inc Thu Apr 19 20:31:52 2018 (r332791) +++ head/lib/msun/riscv/Makefile.inc Thu Apr 19 20:36:15 2018 (r332792) @@ -1,8 +1,4 @@ # $FreeBSD$ -.if ${MACHINE_ARCH:Mriscv*sf} != "" -CFLAGS+=-DSOFTFLOAT -.endif - LDBL_PREC = 113 SYM_MAPS += ${.CURDIR}/riscv/Symbol.map Modified: head/lib/msun/riscv/fenv.c ============================================================================== --- head/lib/msun/riscv/fenv.c Thu Apr 19 20:31:52 2018 (r332791) +++ head/lib/msun/riscv/fenv.c Thu Apr 19 20:36:15 2018 (r332792) @@ -39,7 +39,7 @@ */ const fenv_t __fe_dfl_env = 0; -#ifdef SOFTFLOAT +#ifdef __riscv_float_abi_soft #define __set_env(env, flags, mask, rnd) env = ((flags) | (rnd) << 5) #define __env_flags(env) ((env) & FE_ALL_EXCEPT) #define __env_mask(env) (0) /* No exception traps. */ Modified: head/lib/msun/riscv/fenv.h ============================================================================== --- head/lib/msun/riscv/fenv.h Thu Apr 19 20:31:52 2018 (r332791) +++ head/lib/msun/riscv/fenv.h Thu Apr 19 20:36:15 2018 (r332792) @@ -73,12 +73,20 @@ __BEGIN_DECLS extern const fenv_t __fe_dfl_env; #define FE_DFL_ENV (&__fe_dfl_env) -#ifndef SOFTFLOAT +#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double) +#if defined(__riscv_float_abi_single) +#error single precision floating point ABI not supported +#else +#error compiler did not set soft/hard float macros +#endif +#endif + +#ifndef __riscv_float_abi_soft #define __rfs(__fcsr) __asm __volatile("csrr %0, fcsr" : "=r" (__fcsr)) #define __wfs(__fcsr) __asm __volatile("csrw fcsr, %0" :: "r" (__fcsr)) #endif -#ifdef SOFTFLOAT +#ifdef __riscv_float_abi_soft int feclearexcept(int __excepts); int fegetexceptflag(fexcept_t *__flagp, int __excepts); int fesetexceptflag(const fexcept_t *__flagp, int __excepts); @@ -206,13 +214,13 @@ feupdateenv(const fenv_t *__envp) return (0); } -#endif /* !SOFTFLOAT */ +#endif /* !__riscv_float_abi_soft */ #if __BSD_VISIBLE /* We currently provide no external definitions of the functions below. */ -#ifdef SOFTFLOAT +#ifdef __riscv_float_abi_soft int feenableexcept(int __mask); int fedisableexcept(int __mask); int fegetexcept(void); @@ -243,7 +251,7 @@ fegetexcept(void) return (0); } -#endif /* !SOFTFLOAT */ +#endif /* !__riscv_float_abi_soft */ #endif /* __BSD_VISIBLE */