From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2306 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: powerpc fenv Date: Sun, 18 Nov 2012 20:57:15 +0100 Message-ID: <20121118195715.GM12537@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="IS0zKkzwUGydFO0o" X-Trace: ger.gmane.org 1353268648 8291 80.91.229.3 (18 Nov 2012 19:57:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Nov 2012 19:57:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2307-gllmg-musl=m.gmane.org@lists.openwall.com Sun Nov 18 20:57:39 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TaAzq-00020Q-RV for gllmg-musl@plane.gmane.org; Sun, 18 Nov 2012 20:57:39 +0100 Original-Received: (qmail 26529 invoked by uid 550); 18 Nov 2012 19:57:27 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 26521 invoked from network); 18 Nov 2012 19:57:27 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2306 Archived-At: --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline i wrote an initial version of fenv for ppc (absolutely not tested) i followed glibc and used double for fenv_t (it makes fesetenv and fegetenv a bit shorter than with using a 32bit type) i don't know what section the target of the FE_DFL_ENV pointer should go and what's the proper asm syntax for objects (i put a 0 value in .sdata for now) ps. the current feholdexcept is wrong, it should feclearexcept(FE_ALL_EXCEPT) pps. i put a FENV_ACCESS ON pragma in feupdateenv. it's silly, since there is no fp operation that could go wrong there, but c99 implies that every time c code may access the fenv it must be present, so probably the other c functions need it as well (it does not hurt as it's a nop on gcc) --IS0zKkzwUGydFO0o Content-Type: text/x-chdr; charset=us-ascii Content-Disposition: attachment; filename="fenv.h" #define FE_TONEAREST 0 #define FE_TOWARDZERO 1 #define FE_UPWARD 2 #define FE_DOWNWARD 3 #define FE_INEXACT 0x02000000 #define FE_DIVBYZERO 0x04000000 #define FE_UNDERFLOW 0x08000000 #define FE_OVERFLOW 0x10000000 #define FE_INVALID 0x20000000 #define FE_ALL_EXCEPT 0x3e000000 #ifdef _GNU_SOURCE #define FE_INVALID_SNAN 0x01000000 #define FE_INVALID_ISI 0x00800000 #define FE_INVALID_IDI 0x00400000 #define FE_INVALID_ZDZ 0x00200000 #define FE_INVALID_IMZ 0x00100000 #define FE_INVALID_COMPARE 0x00080000 #define FE_INVALID_SOFTWARE 0x00000400 #define FE_INVALID_SQRT 0x00000200 #define FE_INVALID_INTEGER_CONVERSION 0x00000100 #define FE_ALL_INVALID 0x01f80700 #endif typedef unsigned int fexcept_t; typedef double fenv_t; extern const fenv_t __fe_dfl_env; #define FE_DFL_ENV (&__fe_dfl_env) --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fenv.s" .global feclearexcept .type feclearexcept,@function feclearexcept: # if (r3 & FE_INVALID) r3 |= all_invalid_flags andis. 0,3,0x2000 stwu 1,-16(1) beq- 0,1f oris 3,3,0x01f8 ori 3,3,0x0700 1: # note: fpscr contains various fpu status and control # flags and we dont check if r3 may alter other flags # than the exception related ones # fpscr &= ~r3 mffs 0 stfd 0,8(1) lwz 9,12(1) andc 9,9,3 stw 9,12(1) lfd 0,8(1) mtfsf 255,0 # return 0 li 3,0 addi 1,1,16 blr .global feraiseexcept .type feraiseexcept,@function feraiseexcept: # if (r3 & FE_INVALID) r3 |= software_invalid_flag andis. 0,3,0x2000 stwu 1,-16(1) beq- 0,1f ori 3,3,0x0400 1: # fpscr |= r3 mffs 0 stfd 0,8(1) lwz 9,12(1) or 9,9,3 stw 9,12(1) lfd 0,8(1) mtfsf 255,0 # return 0 li 3,0 addi 1,1,16 blr .global fetestexcept .type fetestexcept,@function fetestexcept: # return r3 & fpscr stwu 1,-16(1) mffs 0 stfd 0,8(1) lwz 9,12(1) addi 1,1,16 and 3,3,9 blr .global fegetround .type fegetround,@function fegetround: # return fpscr & 3 stwu 1,-16(1) mffs 0 stfd 0,8(1) lwz 3,12(1) addi 1,1,16 clrlwi 3,3,30 blr .global fesetround .type fesetround,@function fesetround: # note: invalid input is not checked, r3 < 4 must hold # fpscr = (fpscr & -4U) | r3 stwu 1,-16(1) mffs 0 stfd 0,8(1) lwz 9,12(1) clrrwi 9,9,2 or 9,9,3 stw 9,12(1) lfd 0,8(1) mtfsf 255,0 # return 0 li 3,0 addi 1,1,16 blr .global fegetenv .type fegetenv,@function fegetenv: # *r3 = fpscr mffs 0 stfd 0,0(3) # return 0 li 3,0 blr .global fesetenv .type fesetenv,@function fesetenv: # fpscr = *r3 lfd 0,0(3) mtfsf 255,0 # return 0 li 3,0 blr .section .sdata .type __fe_dfl_env,@object __fe_dfl_env: .zero 8 --IS0zKkzwUGydFO0o--