221 Commits

Author SHA1 Message Date
matu3ba
f335d92b28
compiler_rt: arm frsub, drsub with tests (#17629)
Tests with +-0, numbers with accuracy 0.001, 0.000001, +-max for inf.
2023-10-21 02:12:02 -07:00
matu3ba
3c22cecee2
compiler_rt: add tests for arm routines (#17573)
* __aeabi_ldivmod
* __aeabi_uldivmod
* __aeabi_idivmod
* __aeabi_uidivmod
2023-10-20 00:57:11 -07:00
Jacob Young
8470652f10 x86_64: implement float compare and cast builtins 2023-10-01 15:09:52 -04:00
antlilja
bcf4a13913 Remove @fabs, fabs and absCast/Int from std lib
Replaces occurences of @fabs absCast and absInt with new @abs builtin.
Also removes the std.math.fabs alias from math.zig.
2023-09-27 11:24:28 -07:00
Jacob Young
401de6dd2f compiler_rt: fix arm hard-float f16 abi
Closes #16848
2023-09-19 09:37:53 -07:00
Jacob Young
17e3fcc3a5 compiler_rt: fight off @as invasion
Importantly, fixes incorrectly annotated types in `__aeabi_?2h`.
2023-09-19 09:37:52 -07:00
Jacob Young
d65318847f compiler_rt: fix fp sub being optimized to call itself
Closes #16844
Reduces #16846
2023-09-19 09:37:52 -07:00
Carl Åstholm
60fc18bd1c compiler_rt: fix f80 comparisons
This corrects comparisons between negative numbers.
2023-08-21 11:26:25 -07:00
Lewis Gaul
387b0ac4f1
Make NaNs quiet by default and other NaN tidy-up (#16826)
* Generalise NaN handling and make std.math.nan() give quiet NaNs

* Address uses of std.math.qnan_* and std.math.nan_* consts

* Comment out failing test due to issues with signalling NaN

* Fix issue in c_builtins.zig where we need qnan_u32
2023-08-18 02:07:49 -04:00
Jacob Young
228c956377 std: finish cleanup up asm
This also required implementing the necessary syntax in the x86_64 backend.
2023-07-31 03:49:21 -04:00
Zachary Raineri
d82b359010 Use builtin inference over @as where possible 2023-07-24 10:23:51 -07:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
Jan Philipp Hafer
539e0b0469 compiler_rt: fixup exports of PPC routines
PPC targets can also use the functionality-equivalent standard routine, so
unconditionally export the standard routine.

Fixup of #16054 merged in f043071cdfb956ff16b1441c9d01ce43eea9fb7b.
2023-06-18 15:27:47 -07:00
Andrew Kelley
8d0a8c2859
Merge pull request #15265 from tiehuis/optimize-udivmod
optimize udivmod
2023-06-17 14:19:07 -07:00
Jan Philipp Hafer
f043071cdf compiler_rt: add missing PPC routines
Adds conditional exports
- __fixkfti
- __fixunskfti
- __floattikf
- __negkf2
- __mulkc3
- __divkc3
- __powikf2
and adjusts tools/gen_stubs.zig.

From https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html:
"When long double transitions to __float128 on PowerPC in the future,
__ibm128 will remain for use in conversions between the two types."

Hence `__extendkftf2` and `__trunctfkf2` for conversion are superfluous
and only using f128 for `kf` routines is justified.

Closes #16057.
2023-06-16 23:37:50 -07:00
Marc Tiehuis
59a6f482e2 disable udivmod asm divq on windows 2023-06-17 13:50:05 +12:00
Marc Tiehuis
947dd36341 optimize udivmod
See https://reviews.llvm.org/D81809 for upstream description.

In summary this is ~10x improvement for small divisors and similar
performance for equal divisors.

Closes #13523.
2023-06-17 13:50:04 +12:00
r00ster91
2593156068 migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -07:00
Eric Joldasov
d04a262a3d
std.math: hard deprecate obsolete constants (soft deprecated in 0.10)
Followup to 5b8ac9821dd25c3e5282130b4d93d6c5b7debb08.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:12 +06:00
mlugg
4976b58ab1
Prevent analysis of functions only referenced at comptime
The idea here is that there are two ways we can reference a function at runtime:

* Through a direct call, i.e. where the function is comptime-known
* Through a function pointer

This means we can easily perform a form of rudimentary escape analysis
on functions. If we ever see a `decl_ref` or `ref` of a function, we
have a function pointer, which could "leak" into runtime code, so we
emit the function; but for a plain `decl_val`, there's no need to.

This change means that `comptime { _ = f; }` no longer forces a function
to be emitted, which was used for some things (mainly tests). These use
sites have been replaced with `_ = &f;`, which still triggers analysis
of the function body, since you're taking a pointer to the function.

Resolves: #6256
Resolves: #15353
2023-05-29 23:06:08 +01:00
Andrew Kelley
8de2f77f3b remove the compiler-rt README file
What's the point of this file? It has way too much information and it
attracts contribution churn.

Somebody else should maintain this somewhere else.
2023-05-11 17:40:50 -07:00
frmdstryr
0ad692e76c
compiler_rt: fix ARM memset signatures 2023-05-11 11:33:47 +03:00
Andrew Kelley
0794e48b91 update a couple more callsites to @memset 2023-04-28 13:24:43 -07:00
Jan Philipp Hafer
f618398b24 compiler_rt: document ARM status
This commit documents the status of Run-time ABI 2022Q3 for ARM excluding
C++ helper functions.
2023-04-26 15:32:05 -07:00
Andrew Kelley
a5c910adb6 change semantics of @memcpy and @memset
Now they use slices or array pointers with any element type instead of
requiring byte pointers.

This is a breaking enhancement to the language.

The safety check for overlapping pointers will be implemented in a
future commit.

closes #14040
2023-04-25 11:23:40 -07:00
Jan Philipp Hafer
8674418454 compiler_rt: README stubs for arbitrary precision big integer library routines
Document current status of exports and intended design being inspired by
Integer Operations.
2023-04-20 16:04:10 -07:00
Andrew Kelley
9b631b2b32 compiler_rt: use default visibility for non-exported symbols 2023-04-15 10:33:08 -07:00
Andrew Kelley
60bd13bdf2 never use C pointers!!
you maniacs, you absolute monsters. degenerates. hooligans. criminals.

issue #2984 is coming for you.
2023-04-12 15:21:03 -07:00
Jacob Young
5870ffeb82 compiler_rt: change the abi of f16 on mac to depend on the other type 2023-04-05 22:05:10 -07:00
Jacob Young
243848167b compiler_rt: attempt to fix f16 abi on mac with llvm 16 2023-04-05 22:05:06 -07:00
Jacob Young
c1d16a2b80 compiler_rt: fix rare case in udivei4
Unsigned integers are never less than zero, and so zig
helpfully deleted the entire case. :D

Closes #14816
2023-03-07 03:00:08 -05:00
matu3ba
97b9facb98
compiler_rt: declutter int.zig, add mulXi3 tests (#14623)
- Combine mulXi3 routines for follow-up cleanup.
- DRY up Dwords and Twords
- rename both to HalveInt and use instance
  * Justification: Not all processors have word size 32 bit.
* remove test file from CMakeLists
* DRY things.
2023-02-24 13:27:02 -05:00
Jan Philipp Hafer
476bdc8b0b compiler_rt: restructure compiler_rt.zig according to README.md
Justifications
- compiler_rt base routines are almost finished, so make 1:1
mapping of code and documentation.
- Make adjustments to code + documentation simpler to prevent technical or
  documentation debt.
2023-02-19 14:00:55 -05:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
flexicoding
c993af6234
compiler_rt: remove unexported functions 2023-02-18 17:07:35 +00:00
matu3ba
1fa2b37d29
compiler_rt: document math functions (#14552)
This documents the currently implemented math functions in alphabetical
order and sorts the remaining items.
2023-02-13 02:18:26 -05:00
Jan Philipp Hafer
e10c0eefde compiler_rt: add __powihf2, __powisf2, __powidf2, __powitf2, __powixf2
Implementation and tests ported from LLVM release 80.
Tests of __powihf2 created from __powisf2 tests with minor adjustments.
2023-02-12 00:10:27 +02:00
matu3ba
d976b4e4a5
compiler_rt: __divmodti4 for libgcc symbol compatibility
- Copy and adjust __divmodsi4 tests for __divmoddi4 and __divmodti4.
- Assuming d = a/b does not overflow (MIN/-1) or uses div by 0,
  then tmp = (d * b) = (a/b * b) = a does not overflow.
  => Remove wraparound for remainder in applicable routines.
2023-02-11 14:41:08 +02:00
matu3ba
1bda8be2a3
compiler_rt: __ashlsi3, __ashrsi3, __lshrsi3 for symbol compatibility
These are unused in LLVM, but in gcc used for example by rl78.
Move test files into common file, add tests for aforementioned routines
and missing ones for __lshrti3.
2023-02-11 14:25:01 +02:00
Manlio Perillo
c1f71963a9 compiler_rt: fix and improve documentation
- In Integer Bit Operations, use zeros consistently and fix the
    incorrect function descriptions
  - In ucmp, fix the incorrect signedness of the operands
  - In Integer Arithmetic, document the signedness of the operands in
    div, udiv, mod, umod, udivmod and divmod as it is done in LLVM
    documentation
  - In Float Conversion, replace "int_to_float" to "int to float" and
    "uint_to_float" to "uint to float"
2023-02-04 17:23:03 +02:00
Jan Philipp Hafer
03cdb4fb58 compiler_rt: make README visually nice and improve explanations
This commit makes the text more dense with sources, noes the outstanding
audit and adds an explanation of the table before converting everything
to markdown tables.

For the status a checkmark or cross in utf8 encoding are used and the
input and output sizes of all operations are given inclusive comments for
understanding of the routines.

This should document all compiler_rt integer and float routines, but
does not include a documentation of existing ieee floating and math
routines.
2023-02-02 17:45:38 -05:00
kcbanner
a9b68308b9 cbe: fixes for tls, support for not linking libc, and enabling tests
- cbe: Implement linksection support, to support TLS when not linking libc
- cbe: Support under-aligned variables / struct fields
- cbe: Support packed structs (in the C definition of packed)
- windows: Fix regression with x86 _tls_array
- compiler_rt: Add 128-bit atomics to compiler_rt
- tests: Re-enable threadlocal tests on cbe+windows, and llvm+x86
- tests: Re-enable f80 tests that now pass
- ci: change windows ci to run the CBE behaviour tests with -lc, to match how the compiler is bootstrapped
- update zig1.wasm
2023-01-29 15:04:13 -05:00
Andrew Kelley
cb9d00e1af
Merge pull request #14402 from kcbanner/cbe_x86_fixes
CBE: x86 support and MSVC ABI fixes
2023-01-24 17:53:54 -05:00
kcbanner
5d46addd25 compiler_rt: re-enable divxf3 test on windows/llvm 2023-01-24 13:06:59 +02:00
kcbanner
1aa2c32055 cbe: fixes for x86
- Emit calling convention
- Fix .Naked handling for msvc
- Add teb helper for x86
- Fix 128-bit shl implementation when rhs is >= 64
- Add 128-bit shl tests
2023-01-23 13:48:36 -05:00
kcbanner
0251ce1e1b compiler_rt: skip "__udivei4/__umodei4" on cbe due to missing > 128 bit integer support 2023-01-02 13:55:45 -07:00
kcbanner
fbd3459a52 compiler_rt: fixup divti3 and fixunshfti 2023-01-01 16:44:28 -05:00
Andrew Kelley
40ba4d4a89
Merge pull request #14102 from Luukdegram/wasm-undefined-symbols
WebAssembly: remove unconditional --allow-undefined flag
2022-12-29 17:59:44 -05:00
Luuk de Gram
30f2bb8464
compiler-rt: Set the symbol visibility
When we're compiling compiler_rt for any WebAssembly target, we do
not want to expose all the compiler-rt functions to the host runtime.
By setting the visibility of all exports to `hidden`, we allow the
linker to resolve the symbols during linktime, while not expose the
functions to the host runtime. This also means the linker can
properly garbage collect any compiler-rt function that does not get
resolved. The symbol visibility for all target remains the same as
before: `default`.
2022-12-28 14:57:17 +01:00