summaryrefslogtreecommitdiff
path: root/lib/math
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2018-05-13 18:07:35 -0400
committerS. Gilles <sgilles@math.umd.edu>2018-05-13 18:07:35 -0400
commitce931f082769f332e545cc477bc85c2bbca71ac2 (patch)
tree3e9d49fcec98232f806214876445302ab2d264e6 /lib/math
parent47faa09b2507bdfb2e3dd983f9aeb1ab54b2f2ef (diff)
parent05e04ed1df3c315aa69b2b5c16f16e83922d5aed (diff)
downloadmc-ce931f082769f332e545cc477bc85c2bbca71ac2.tar.gz
Merge remote-tracking branch 'ori/master' into libmath
Diffstat (limited to 'lib/math')
-rw-r--r--lib/math/bld.sub3
-rw-r--r--lib/math/ftrap-impl+plan9-x64.s14
-rw-r--r--lib/math/ftrap-impl+posixy-x64.s17
-rw-r--r--lib/math/ftrap.myr3
-rw-r--r--lib/math/test/exp-impl.myr1
-rw-r--r--lib/math/test/fma-impl.myr1
-rw-r--r--lib/math/test/sqrt-impl.myr1
-rw-r--r--lib/math/test/trunc-impl.myr1
8 files changed, 41 insertions, 0 deletions
diff --git a/lib/math/bld.sub b/lib/math/bld.sub
index 47d5edd..18d5235 100644
--- a/lib/math/bld.sub
+++ b/lib/math/bld.sub
@@ -34,6 +34,9 @@ lib math =
# util
util.myr
+ ftrap.myr
+ ftrap-impl+plan9-x64.s
+ ftrap-impl+posixy-x64.s
lib ../std:std
;;
diff --git a/lib/math/ftrap-impl+plan9-x64.s b/lib/math/ftrap-impl+plan9-x64.s
new file mode 100644
index 0000000..3374f4c
--- /dev/null
+++ b/lib/math/ftrap-impl+plan9-x64.s
@@ -0,0 +1,14 @@
+TEXT math$fptrap(SB),$0
+ SUBQ $4,SP
+ WAIT
+ STMXCSR (SP)
+ MOVL (SP),AX
+ ANDL $~0x1f80,AX
+ TESTB DI,DI
+ JNZ .apply
+ ORL $0x1f80,AX
+.apply:
+ MOVL AX,(SP)
+ LDMXCSR (SP)
+ ADDQ $4,SP
+ RET
diff --git a/lib/math/ftrap-impl+posixy-x64.s b/lib/math/ftrap-impl+posixy-x64.s
new file mode 100644
index 0000000..08dd7cf
--- /dev/null
+++ b/lib/math/ftrap-impl+posixy-x64.s
@@ -0,0 +1,17 @@
+.globl _math$fptrap
+.globl math$fptrap
+_math$fptrap:
+math$fptrap:
+ subq $4,%rsp
+ wait
+ stmxcsr (%rsp)
+ movl (%rsp),%eax
+ andl $~0x1f80,%eax
+ testb %dil,%dil
+ jnz .apply
+ orl $0x1f80,%eax
+.apply:
+ movl %eax,(%rsp)
+ ldmxcsr (%rsp)
+ addq $4,%rsp
+ ret
diff --git a/lib/math/ftrap.myr b/lib/math/ftrap.myr
new file mode 100644
index 0000000..2be8970
--- /dev/null
+++ b/lib/math/ftrap.myr
@@ -0,0 +1,3 @@
+pkg math =
+ extern const fptrap : (f : bool -> void)
+;;
diff --git a/lib/math/test/exp-impl.myr b/lib/math/test/exp-impl.myr
index a009978..e84d5ab 100644
--- a/lib/math/test/exp-impl.myr
+++ b/lib/math/test/exp-impl.myr
@@ -7,6 +7,7 @@ use testr
are tested extensively in expm101 and expm102.
*/
const main = {
+ math.fptrap(false)
testr.run([
[.name="exp-01", .fn = exp01],
[.name="exp-02", .fn = exp02],
diff --git a/lib/math/test/fma-impl.myr b/lib/math/test/fma-impl.myr
index 0bb30bb..f5d7472 100644
--- a/lib/math/test/fma-impl.myr
+++ b/lib/math/test/fma-impl.myr
@@ -3,6 +3,7 @@ use math
use testr
const main = {
+ math.fptrap(false)
testr.run([
[.name="fma-01", .fn = fma01],
[.name="fma-02", .fn = fma02],
diff --git a/lib/math/test/sqrt-impl.myr b/lib/math/test/sqrt-impl.myr
index a84f15b..79765b0 100644
--- a/lib/math/test/sqrt-impl.myr
+++ b/lib/math/test/sqrt-impl.myr
@@ -3,6 +3,7 @@ use math
use testr
const main = {
+ math.fptrap(false)
testr.run([
[.name="sqrt-01", .fn = sqrt01],
[.name="sqrt-02", .fn = sqrt02],
diff --git a/lib/math/test/trunc-impl.myr b/lib/math/test/trunc-impl.myr
index d86f25d..328b8dd 100644
--- a/lib/math/test/trunc-impl.myr
+++ b/lib/math/test/trunc-impl.myr
@@ -3,6 +3,7 @@ use math
use testr
const main = {
+ math.fptrap(false)
testr.run([
[.name = "trunc-01", .fn = trunc01],
[.name = "trunc-02", .fn = trunc02],