Commit graph

255 commits

Author SHA1 Message Date
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 5b8ac9821d.
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
Veikka Tuominen
622311fb9a update uses of overflow arithmetic builtins 2022-12-27 15:13:14 +02:00
Frank Denis
8d66aacb64
compiler-rt: implement __udivei4 and __umodei4 (#14023)
Allows dividing and formatting arbitrary-large unsigned integers.
2022-12-22 16:29:19 -05:00
zenith391
471f3c470f compiler_rt: Remove errdefer in ObjectArray.init
These errdefer where never executed, while this didn't bother the stage1
compiler, it caused an error in stage2.

The fix is just removing those errdefer which doesn't change any
behaviour because they were never executed in the first place.
2022-12-20 16:42:12 -05:00
zooster
e02e4757b1 compiler_rt: test clzsi2 on zero on CPUs where possible 2022-12-18 01:42:15 +02:00
r00ster91
171e6c7aa7 compiler_rt: remove workaround for past LLVM optimizer bug 2022-12-16 00:41:30 +01:00
r00ster91
41a7670a38 compiler_rt: remove stage1 switch case 2022-12-16 00:34:30 +01:00
r00ster91
20c5b6ad65 compiler_rt: no longer skip f80 conversion test
This is working again.

Closes #11408
2022-12-16 00:18:25 +01:00
Veikka Tuominen
08b2d491bc update usages of @call 2022-12-13 13:14:20 +02:00
Veikka Tuominen
4fb9c75fc9 compiler-rt: do not export complex arithmetic on ofmt=c
These functions cannot be properly implemented without #8465

Closes #13800
2022-12-07 14:54:29 +02:00
Jacob Young
c4dc8515b6 compiler_rt: don't use the llvm windows v2u64 abi with the C backend 2022-12-06 12:27:28 -07:00
Andrew Kelley
2c49a6c190 compiler_rt: avoid using weak aliases
This is a partial revert of 0d533433e2,
which regressed this behavior. The idea here is to avoid aliases, which
happens when the same function is exported with multiple names. The
problem with aliases is that weak aliases don't seem to work, causing
symbol collisions when multiple of the same symbol are provided, despite
the desired behavior that weak symbols are overridden.

In this case we export redundant functions with different names. Thanks
to -ffunction-sections, the unused functions will be garbage-collected
at link time. This leaves us with the best of both worlds: Zig's
compiler-rt will provide both sets of symbols, and it will be
binary-compatible with different compilers that expect different names,
while still resulting in binaries without garbage.
2022-12-05 18:09:37 -07:00
Veikka Tuominen
98037a0238 compiler-rt: disable some exports for ofmt=c 2022-11-30 17:20:34 +02:00
Andrew Kelley
545c3117ff rename lse_atomics.zig to aarch64_outline_atomics.zig 2022-11-21 17:17:02 -07:00
Andrew Kelley
58430ae6d1 outline atomics: ret instead of jump to ret
After this, the machine code generated by zig matches identically to
gcc's after the differences in loading the have_lse flag.
2022-11-21 17:17:02 -07:00
Andrew Kelley
95ee8ab77d simplify outline atomics
* Rely on libSystem when targeting macOS.
 * Make tools/gen_outline_atomics.zig more idiomatic.
 * Remove the CPU detection / auxval checking from compiler_rt. This
   functionality belongs in a different component. Zig's compiler_rt
   must not rely on constructors. Instead it will export a symbol for
   setting the value, and start code can detect and activate it.
 * Remove the separate logic for inline assembly when the target does or
   does not have lse support. `.inst` works in both cases.
2022-11-21 17:17:02 -07:00
Devin Singh
a8f2d00ec4 compiler_rt: add outlined lse atomics for aarch64 2022-11-21 17:17:02 -07:00