math_basic.odin 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //+build !js
  2. package math
  3. import "core:intrinsics"
  4. @(default_calling_convention="none")
  5. foreign _ {
  6. @(link_name="llvm.sin.f16")
  7. sin_f16 :: proc(θ: f16) -> f16 ---
  8. @(link_name="llvm.sin.f32")
  9. sin_f32 :: proc(θ: f32) -> f32 ---
  10. @(link_name="llvm.sin.f64")
  11. sin_f64 :: proc(θ: f64) -> f64 ---
  12. @(link_name="llvm.cos.f16")
  13. cos_f16 :: proc(θ: f16) -> f16 ---
  14. @(link_name="llvm.cos.f32")
  15. cos_f32 :: proc(θ: f32) -> f32 ---
  16. @(link_name="llvm.cos.f64")
  17. cos_f64 :: proc(θ: f64) -> f64 ---
  18. @(link_name="llvm.pow.f16")
  19. pow_f16 :: proc(x, power: f16) -> f16 ---
  20. @(link_name="llvm.pow.f32")
  21. pow_f32 :: proc(x, power: f32) -> f32 ---
  22. @(link_name="llvm.pow.f64")
  23. pow_f64 :: proc(x, power: f64) -> f64 ---
  24. @(link_name="llvm.fmuladd.f16")
  25. fmuladd_f16 :: proc(a, b, c: f16) -> f16 ---
  26. @(link_name="llvm.fmuladd.f32")
  27. fmuladd_f32 :: proc(a, b, c: f32) -> f32 ---
  28. @(link_name="llvm.fmuladd.f64")
  29. fmuladd_f64 :: proc(a, b, c: f64) -> f64 ---
  30. @(link_name="llvm.log.f16")
  31. ln_f16 :: proc(x: f16) -> f16 ---
  32. @(link_name="llvm.log.f32")
  33. ln_f32 :: proc(x: f32) -> f32 ---
  34. @(link_name="llvm.log.f64")
  35. ln_f64 :: proc(x: f64) -> f64 ---
  36. @(link_name="llvm.exp.f16")
  37. exp_f16 :: proc(x: f16) -> f16 ---
  38. @(link_name="llvm.exp.f32")
  39. exp_f32 :: proc(x: f32) -> f32 ---
  40. @(link_name="llvm.exp.f64")
  41. exp_f64 :: proc(x: f64) -> f64 ---
  42. }
  43. sqrt_f16 :: proc "contextless" (x: f16) -> f16 {
  44. return intrinsics.sqrt(x)
  45. }
  46. sqrt_f32 :: proc "contextless" (x: f32) -> f32 {
  47. return intrinsics.sqrt(x)
  48. }
  49. sqrt_f64 :: proc "contextless" (x: f64) -> f64 {
  50. return intrinsics.sqrt(x)
  51. }