aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/bit_shifting.zig
AgeCommit message (Collapse)Author
2025-08-12make `>>` a compile error with any undef arg ; add a bunch of test casesJustus Klausecker
2025-08-12Sema: Improve comptime arithmetic undef handlingJustus Klausecker
This commit expands on the foundations laid by https://github.com/ziglang/zig/pull/23177 and moves even more `Sema`-only functionality from `Value` to `Sema.arith`. Specifically all shift and bitwise operations, `@truncate`, `@bitReverse` and `@byteSwap` have been moved and adapted to the new rules around `undefined`. Especially the comptime shift operations have been basically rewritten, fixing many open issues in the process. New rules applied to operators: * `<<`, `@shlExact`, `@shlWithOverflow`, `>>`, `@shrExact`: compile error if any operand is undef * `<<|`, `~`, `^`, `@truncate`, `@bitReverse`, `@byteSwap`: return undef if any operand is undef * `&`, `|`: Return undef if both operands are undef, turn undef into actual `0xAA` bytes otherwise Additionally this commit canonicalizes the representation of aggregates with all-undefined members in the `InternPool` by disallowing them and enforcing the usage of a single typed `undef` value instead. This reduces the amount of edge cases and fixes a bunch of bugs related to partially undefined vecs. List of operations directly affected by this patch: * `<<`, `<<|`, `@shlExact`, `@shlWithOverflow` * `>>`, `@shrExact` * `&`, `|`, `~`, `^` and their atomic rmw + reduce pendants * `@truncate`, `@bitReverse`, `@byteSwap`
2025-07-30Sema: remove incorrect safety check for saturating left shiftJustus Klausecker
2025-07-22aarch64: add new from scratch self-hosted backendJacob Young
2025-06-19x86_64: increase passing test coverage on windowsJacob Young
Now that codegen has no references to linker state this is much easier. Closes #24153
2025-06-16rename spirv backend nameAli Cheraghi
`stage2_spirv64` -> `stage2_spirv`
2025-05-17x86_64: rewrite scalar `<<|`Jacob Young
Closes #23035
2025-03-02x86_64: add behavior tests for saturating shift leftBingwu Zhang
Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com> Signed-off-by: Bingwu Zhang <xtex@aosc.io>
2025-03-02x86_64: implement integer saturating left shifting codegenxtex
Simliarly to shl_with_overflow, we first SHL/SAL the integer, then SHR/SAR it back to compare if overflow happens. If overflow happened, set result to the upper limit to make it saturating. Bug: #17645 Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com> Signed-off-by: Bingwu Zhang <xtex@aosc.io>
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-07-26riscv: fix logic bug in `ptr_elem_ptr`David Rubin
I was doing duplicate work with `elemOffset` multiplying by the abi size and then the `ptr_add` `genBinOp` also multiplying. This led to having writes happening in the wrong place.
2024-05-11riscv: add stage2_riscv to test matrix and bypass failing testsDavid Rubin
2024-01-06categorize `behavior/bugs/<issueno>.zig` testsVeikka Tuominen
2023-12-22use `casted_rhs` instead of `rhs` so `icmp` works correctly for `airShlSat`Stefan Su
2023-11-19test: update behavior to silence 'var is never mutated' errorsmlugg
2023-06-24all: migrate code to new cast builtin syntaxmlugg
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-05-11setup spirv backend in behavior testsAli Chraghi
2023-03-15behavior: enable passing behavior tests on stage2_x86_64Jacob Young
2023-02-18update existing behavior tests and std lib to new for loop semanticsAndrew Kelley
2022-12-10stage2: sparc64: Skip unimplemented testsKoakuma
2022-10-30behavior: enable fixed cbe testsJacob Young
2022-02-14stage2 AArch64: Enable behavior testingjoachimschmidt557
2022-01-25wasm: Implement genTypedValue for enumsLuuk de Gram
This makes all union test cases succeed. `rem` was also implemented as all we had to do is enable the instruction. Loading and storing values based on ABI-size was simplified to a direct abiSize() call. We also enabled all the newly passing test cases and disable them for all non-passing backends. All of those test cases were verified to see if they perhaps already pass for the c-backend.
2022-01-07bit_shifting.zig now passes stage2 llvm backendJimmi Holst Christensen
2021-06-21std, src, doc, test: remove unused variablesJacob G-W
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-04-29move behavior tests from test/stage1/ to test/Andrew Kelley
And fix test cases to make them pass. This is in preparation for starting to pass behavior tests with self-hosted.