289 Commits

Author SHA1 Message Date
Tristan Ross
9fce1d1ab1
mem: add byteswap array support (#17959)
also make byteswap work with enums
2024-01-14 21:06:31 -05:00
Andrew Kelley
e025ad7b46 std.mem: fix simd.suggestVectorLength merge conflict
Commits
2f8e4347b1f9c2bf093ac48a636576c22359c1ff and
6a32d58876995f18b35ffd89b8875a99417c29cf had a conflict that was
undetected by source control.
2024-01-09 18:20:53 -07:00
Andrew Kelley
6a32d58876
Merge pull request #18318 from castholm/simd-segfault
Rename `simd.suggestVectorSize` to clarify intent and fix related segfault
2024-01-09 17:13:58 -08:00
David Rubin
2f8e4347b1
Optimized std.mem.eql with SIMD (#18389)
* optimized memeql
* add `sched_setaffinity` to `std.os.linux`

Co-authored-by: Protty <45520026+kprotty@users.noreply.github.com>
Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
2024-01-09 02:50:22 -05:00
xdBronch
6ebeb85abd speed up sliceTo when end == sentinel 2024-01-04 17:54:56 +02:00
Carl Åstholm
85869f8225 Correct expected/actual parameter order of some assertions 2024-01-03 21:20:49 +01:00
Carl Åstholm
4c1da0912a Fix compile errors from the expectEqual change 2024-01-03 21:20:48 +01:00
Carl Åstholm
564b1da214 Change < to <= in indexOfSentinel SIMD path 2024-01-01 16:25:17 +01:00
Carl Åstholm
59ac0d1eed Deprecate suggestVectorSize in favor of suggestVectorLength
The function returns the vector length, not the byte size of the vector or the bit size of individual elements. This distinction is very important and some usages of this function in the stdlib operated under these incorrect assumptions.
2024-01-01 16:18:57 +01:00
Carl Åstholm
781c3a985c Prevent reading over a page boundary in mem.indexOfSentinel
The size of the slice element was not correctly taken into account when determining whether a read would cross a page boundary.
2024-01-01 16:18:57 +01:00
David Rubin
1e42a3de89
Remove all usages of std.mem.copy and remove std.mem.set (#18143) 2023-11-29 16:03:02 -05:00
Andrew Kelley
d5e21a4f1a std: remove meta.trait
In general, I don't like the idea of std.meta.trait, and so I am
providing some guidance by deleting the entire namespace from the
standard library and compiler codebase.

My main criticism is that it's overcomplicated machinery that bloats
compile times and is ultimately unnecessary given the existence of Zig's
strong type system and reference traces.

Users who want this can create a third party package that provides this
functionality.

closes #18051
2023-11-22 13:24:27 -05:00
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Jacob Young
509be7cf1f x86_64: fix std test failures 2023-11-03 23:18:21 -04:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young
149200aac5 mem: delete readIntSlice and writeIntSlice
After deleting all potentially incorrect usages, there were no more
remaining.
2023-10-31 21:37:35 -04:00
Jacob Young
d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
Andrew Kelley
49b9e1e69b std.mem.minMax: make it return a tuple
this is a breaking change
2023-10-28 10:14:15 -07:00
Jacob Young
b0cf620fe3 x86_64: fix cond_br 2023-10-27 03:33:49 -04:00
Jacob Young
98cd378208 x86_64: fix behavior of getValue
Old behavior renamed to `getValueIfFree`.
2023-10-26 21:45:58 -04:00
Jacob Young
b55377a5ab x86_64: pass more tests
* 128-bit integer multiplication with overflow
 * more instruction encodings used by std inline asm
 * implement the `try_ptr` air instruction
 * follow correct stack frame abi
 * enable full panic handler
 * enable stack traces
2023-10-25 04:28:30 -04:00
mlugg
f2814caaf0
Sema: don't allow undef values through resolveDefinedValue in typeof block
This logic is not correct in most cases. If any instruction needs to
operate with different semantics within `@TypeOf`, it should be made to
do so explicitly.

This broke a line in `std.mem`: I have opted to fix this in std for now,
since as far as I know it's not yet been discussed which operations (if
any) should be special-cased like this within `@TypeOf`.
2023-10-24 14:28:34 +01:00
Jacob Young
8f69e977f1 x86_64: implement 128-bit builtins
* `@clz`
 * `@ctz`
 * `@popCount`
 * `@byteSwap`
 * `@bitReverse`
 * various encodings used by std
2023-10-23 22:42:18 -04:00
Jacob Young
fe93332ba2 x86_64: implement enough to pass unicode tests
* implement vector comparison
 * implement reduce for bool vectors
 * fix `@memcpy` bug
 * enable passing std tests
2023-10-23 22:42:18 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing
changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young
32e85d44eb x86_64: disable failing tests, enable test-std testing 2023-10-21 10:55:41 -04:00
Jacob Young
2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Andrew Kelley
b171a6f25d Package.Fetch: normalize path separators in symlinks
closes #17549
2023-10-16 16:47:47 -07:00
joadnacer
7b9165b375 std.mem: Improve writeIntSlice performance 2023-10-16 08:49:05 -04:00
Veikka Tuominen
c919e9a280 std.simd: return comptime_int from suggestVectorSize 2023-10-13 16:58:05 +03:00
Karl Seguin
75b48ef503
std.mem: use indexOfScalarPos when indexOf is called where needle.len == 1
When `std.mem.indexOf` is called with a single-item needle, use `indexOfScalarPos` which is significantly faster than the more general `indexOfPosLinear`.  This can be done without introducing overhead to normal cases (where `needle.len > 1`).
2023-10-09 16:50:16 +03:00
Jay Petacat
d8bfbbbf25 std.mem.zeroes: Zero out entire extern union, including padding
Fixes #17258
2023-10-01 02:39:05 -07:00
Marc Tiehuis
08635f08a9 fix indexOfSentinel alignment for types larger than 1 byte 2023-09-30 22:15:47 +13:00
Marc Tiehuis
5b5da0ef8c std.mem: check backend vector support for indexOfSentinel/indexOfScalarPos 2023-09-30 21:22:12 +13:00
Marc Tiehuis
cd766513fe std.mem: add vectorized indexOfScalarPos and indexOfSentinel
These are an order of magnitude quicker than the previous
implementations:

A relative comparison of each, measuring scanning a 1G file.

    Reading 1G (1.0000000009313226GiB)

             std.mem.sliceTo: 281.232ms
          vectorized.sliceTo: 24.769ms
                      strlen: 24.291ms

           std.indexOfScalar: 229.016ms
    vectorized.indexOfScalar: 24.685ms
                      memchr: 24.958ms
2023-09-30 21:19:43 +13:00
Karl Seguin
599641357c
std.mem: use for loop instead of while in indexOf* to reduce bound checking 2023-09-28 15:40:08 +00:00
Jay Petacat
37398ed2a5 std: Reactivate skipped tests w.r.t. llvm/llvm-project#55522 2023-09-27 01:37:25 +03:00
Andrew Kelley
5b8af7a2a9 skip regressed LLVM 17 std lib test on powerpc
Tracked by #16951
2023-09-19 09:37:53 -07:00
Pascal S. de Kloe
4a44b79935 mem: explicit Allocator.Error on concat and join 2023-09-13 13:52:05 +03:00
Jacob Young
151c06cce4 std.mem.sliceAsBytes: support arrays of zero-bit types
This makes `std.ArrayListUnmanaged(void)` usable.
2023-08-09 05:47:13 -04:00
antlilja
b463e429b8 Remove len parameter from splat in standard lib 2023-07-12 15:35:57 -07:00
Meghan
cd0594e4a6
std: add mem.SplitIterator.peek() (#15670) 2023-07-10 14:34:39 -04:00
xdBronch
d7c6cfa7fd std.mem.zeroes work with allowzero pointers 2023-07-10 10:52:27 -07:00
r00ster91
11c32c756f fix u65529 and above overflowing in more places
See also #15537
2023-06-27 19:08:24 -04:00
Jacob Young
b18a72ec35 x86_64: fix crash emitting a packed undefined u128 2023-06-25 19:14:03 -04:00
Eric Joldasov
0a868dacdd std.cstr: deprecate namespace
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-25 14:51:03 -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
Andrew Kelley
e6e8cacab9 std.mem.order: use for loop syntax
Not only does it look nicer, it's a performance enhancement for debug
builds since the safety checks are eliminated.
2023-06-19 12:07:32 -07:00