aboutsummaryrefslogtreecommitdiffhomepage
path: root/builder
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-08-28 19:08:07 +0200
committerRon Evans <[email protected]>2022-08-30 17:33:16 +0200
commit9e8739bb47d70f633962976458955cb8a5ce615c (patch)
treed368104b4a2887216aa264fdd33afa4404bd94db /builder
parent20a7a6fd54d4ffb1fa7e37cfd85246300e372e21 (diff)
downloadtinygo-9e8739bb47d70f633962976458955cb8a5ce615c.tar.gz
tinygo-9e8739bb47d70f633962976458955cb8a5ce615c.zip
compiler: replace math aliases with intrinsics
This is really a few more-or-less separate changes: * Remove all math aliases that were used in Go 1.16 and below (the math.[A-Z] aliases). * Replace math aliases with an assembly implementation (the math.arch* aliases) with a LLVM intrinsic, where one is available. * Include missing math functions in picolibc build. This leaves just four math aliases: * math.archHypot and math.archModf do not have a LLVM builtin equivalent. They could be replaced with calls to libm, and I think that would be a good idea in the long term. * math.archMax and math.archMin do have a LLVM builtin equivalent (llvm.maximum.f64, llvm.minimum.f64), but unfortunately they crash when used. Apparently these exact operations are not yet widely supported in hardware and they don't have a libm equivalent either. There are more LLVM builtins that we could use for the math package (such as FMA), but I will leave that to a future change. It could potentially speed up some math operations.
Diffstat (limited to 'builder')
-rw-r--r--builder/picolibc.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/builder/picolibc.go b/builder/picolibc.go
index d9025a41e..d0786ee3a 100644
--- a/builder/picolibc.go
+++ b/builder/picolibc.go
@@ -28,6 +28,8 @@ var Picolibc = Library{
"-DHAVE_ALIAS_ATTRIBUTE",
"-DTINY_STDIO",
"-D_IEEE_LIBM",
+ "-D__OBSOLETE_MATH_FLOAT=1", // use old math code that doesn't expect a FPU
+ "-D__OBSOLETE_MATH_DOUBLE=0",
"-nostdlibinc",
"-isystem", newlibDir + "/libc/include",
"-I" + newlibDir + "/libc/tinystdio",
@@ -325,6 +327,24 @@ var picolibcSources = []string{
"libm/common/s_scalbln.c",
"libm/common/s_signbit.c",
"libm/common/s_trunc.c",
+ "libm/common/exp.c",
+ "libm/common/exp2.c",
+ "libm/common/exp_data.c",
+ "libm/common/math_err_with_errno.c",
+ "libm/common/math_err_xflow.c",
+ "libm/common/math_err_uflow.c",
+ "libm/common/math_err_oflow.c",
+ "libm/common/math_err_divzero.c",
+ "libm/common/math_err_invalid.c",
+ "libm/common/math_err_may_uflow.c",
+ "libm/common/math_err_check_uflow.c",
+ "libm/common/math_err_check_oflow.c",
+ "libm/common/log.c",
+ "libm/common/log_data.c",
+ "libm/common/log2.c",
+ "libm/common/log2_data.c",
+ "libm/common/pow.c",
+ "libm/common/pow_log_data.c",
"libm/math/e_acos.c",
"libm/math/e_acosh.c",