aboutsummaryrefslogtreecommitdiff
path: root/core/math/math_basic.odin
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-11-16 14:11:20 +0000
committergingerBill <bill@gingerbill.org>2021-11-16 14:11:20 +0000
commit91949b09929707ee969a5be778973e044d22d85c (patch)
treec87c41e2190ec1ebeca618d6dcfe6690319d8df1 /core/math/math_basic.odin
parent6a101e69a26c09d6a0c8c5ebd6ed27a8ab89d5ee (diff)
Implement `math.sqrt` with `intrinsics.sqrt`
Diffstat (limited to 'core/math/math_basic.odin')
-rw-r--r--core/math/math_basic.odin19
1 files changed, 12 insertions, 7 deletions
diff --git a/core/math/math_basic.odin b/core/math/math_basic.odin
index 4995ac9e3..fe7b07d98 100644
--- a/core/math/math_basic.odin
+++ b/core/math/math_basic.odin
@@ -1,15 +1,10 @@
//+build !js
package math
+import "core:intrinsics"
+
@(default_calling_convention="none")
foreign _ {
- @(link_name="llvm.sqrt.f16")
- sqrt_f16 :: proc(x: f16) -> f16 ---
- @(link_name="llvm.sqrt.f32")
- sqrt_f32 :: proc(x: f32) -> f32 ---
- @(link_name="llvm.sqrt.f64")
- sqrt_f64 :: proc(x: f64) -> f64 ---
-
@(link_name="llvm.sin.f16")
sin_f16 :: proc(θ: f16) -> f16 ---
@(link_name="llvm.sin.f32")
@@ -52,3 +47,13 @@ foreign _ {
@(link_name="llvm.exp.f64")
exp_f64 :: proc(x: f64) -> f64 ---
}
+
+sqrt_f16 :: proc "contextless" (x: f16) -> f16 {
+ return intrinsics.sqrt(x)
+}
+sqrt_f32 :: proc "contextless" (x: f32) -> f32 {
+ return intrinsics.sqrt(x)
+}
+sqrt_f64 :: proc "contextless" (x: f64) -> f64 {
+ return intrinsics.sqrt(x)
+}