about summary refs log tree commit diff
path: root/src/fenv/superh
diff options
context:
space:
mode:
authorBobby Bingham <koorogi@koorogi.info>2013-10-05 05:13:18 -0500
committerBobby Bingham <koorogi@koorogi.info>2014-02-23 16:15:54 -0600
commit3a3c813e08d808224c12fd0e9104aeff7c45c9a7 (patch)
tree508b28c42438615d711afcb9b44d7b0e0842f28d /src/fenv/superh
parentd05aaedaabd4f5472c233dbbd1ff4bb9c9c99794 (diff)
downloadmusl-3a3c813e08d808224c12fd0e9104aeff7c45c9a7.tar.gz
musl-3a3c813e08d808224c12fd0e9104aeff7c45c9a7.tar.xz
musl-3a3c813e08d808224c12fd0e9104aeff7c45c9a7.zip
superh port
Diffstat (limited to 'src/fenv/superh')
-rw-r--r--src/fenv/superh/fenv.s74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/fenv/superh/fenv.s b/src/fenv/superh/fenv.s
new file mode 100644
index 00000000..7f5c6277
--- /dev/null
+++ b/src/fenv/superh/fenv.s
@@ -0,0 +1,74 @@
+.global fegetround
+.type   fegetround, @function
+fegetround:
+	sts fpscr, r0
+	rts
+	 and #3, r0
+
+.global __fesetround
+.type   __fesetround, @function
+__fesetround:
+	sts fpscr, r0
+	or  r4, r0
+	lds r0, fpscr
+	rts
+	 mov #0, r0
+
+.global fetestexcept
+.type   fetestexcept, @function
+fetestexcept:
+	sts fpscr, r0
+	and r4, r0
+	rts
+	 and #0x7c, r0
+
+.global feclearexcept
+.type   feclearexcept, @function
+feclearexcept:
+	mov r4, r0
+	and #0x7c, r0
+	not r0, r4
+	sts fpscr, r0
+	and r4, r0
+	lds r0, fpscr
+	rts
+	 mov #0, r0
+
+.global feraiseexcept
+.type   feraiseexcept, @function
+feraiseexcept:
+	mov r4, r0
+	and #0x7c, r0
+	sts fpscr, r4
+	or  r4, r0
+	lds r0, fpscr
+	rts
+	 mov #0, r0
+
+.global fegetenv
+.type   fegetenv, @function
+fegetenv:
+	sts fpscr, r0
+	mov.l r0, @r4
+	rts
+	 mov #0, r0
+
+.global fesetenv
+.type   fesetenv, @function
+fesetenv:
+	mov r4, r0
+	cmp/eq #-1, r0
+	bf 1f
+
+	! the default environment is complicated by the fact that we need to
+	! preserve the current precision bit, which we do not know a priori
+	sts fpscr, r0
+	mov #8, r1
+	swap.w r1, r1
+	bra 2f
+	 and r1, r0
+
+1:	mov.l @r4, r0      ! non-default environment
+2:	lds r0, fpscr
+	rts
+	 mov #0, r0