aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/floatop.zig
AgeCommit message (Collapse)Author
2022-08-17Sema: error on ambiguous coercion of comptime float and intsMartin Hafskjold Thoresen
The following, from the documentation as of the time of writing, illustrates the problem: ```zig // Compile time coercion of float to int test "implicit cast to comptime_int" { var f: f32 = 54.0 / 5; _ = f; } ``` It is not clear how to unify the types of 54.0 and 5 to perform the division. We can either - cast 54.0 to comptime_int resulting in @as(comptime_int, 10), which is casted to @as(f32, 10), or - cast 5 to comptime_float resulting in @as(comptime_float, 10.8), which is casted to @as(f32, 10.8) Since the two resulting values are different, a compiler error is appropriate. If we know that casting to either type will result in the same value we don't need to error. For instance, 10.0 / 2 is okay, as is 10 / 2.0. Fixes: #12364
2022-06-30stage2: lower float negation explicitlyAndrew Kelley
Rather than lowering float negation as `0.0 - x`. * Add AIR instruction for float negation. * Add compiler-rt functions for f128, f80 negation closes #11853
2022-06-24Revert "wasm: Enable f16 behavior tests"Luuk de Gram
This reverts commit 3c34c9f13c67ff1716a9531e87d23a6dad12b45e.
2022-06-24wasm: Enable f16 behavior testsLuuk de Gram
2022-05-26clean up some behavior testsAndrew Kelley
* improve names * properly categorize a couple of bug cases * mark one as already passing
2022-05-03Sema: fix bigIntToFloatAndrew Kelley
The implementation had the `@mulAdd` parameters mixed up.
2022-05-01stage1: disable new behavior testsAndrew Kelley
Oops, I forgot to check if the new behavior tests are passing for stage1.
2022-05-01disable failing behavior testsAndrew Kelley
Oops, I forgot to run the non-LLVM backend tests on that last commit.
2022-05-01stage2: fix comptime fixed-width float divisionAndrew Kelley
2022-04-27enable newly passing behavior testsAndrew Kelley
closes #11030
2022-04-02wasm: Enable passing behavior testsLuuk de Gram
This shuffles some tests do ensure the new instructions are tested for the wasm backend, by moving vectors into their own tests as well as move the f16 test cases as those require special operating also.
2022-03-30replace other uses of `std.meta.Vector` with `@Vector` (#11346)Meghan
2022-03-14Sema: fix shl_sat with comptime rhsAndrew Kelley
2022-03-14Sema: improve lowering of stores to bitcasted vector pointersAndrew Kelley
Detect if we are storing an array operand to a bitcasted vector pointer. If so, we instead reach through the bitcasted pointer to the vector pointer, bitcast the array operand to a vector, and then lower this as a store of a vector value to a vector pointer. This generally results in better code, as well as working around an LLVM bug. See #11154
2022-03-13stage2: add debug info for locals in the LLVM backendAndrew Kelley
Adds 2 new AIR instructions: * dbg_var_ptr * dbg_var_val Sema no longer emits dbg_stmt AIR instructions when strip=true. LLVM backend: fixed lowerPtrToVoid when calling ptrAlignment on the element type is problematic. LLVM backend: fixed alloca instructions improperly getting debug location annotated, causing chaotic debug info behavior. zig_llvm.cpp: fixed incorrect bindings for a function that should use unsigned integers for line and column. A bunch of C test cases regressed because the new dbg_var AIR instructions caused their operands to be alive, exposing latent bugs. Mostly it's just a problem that the C backend lowers mutable and const slices to the same C type, so we need to represent that in the C backend instead of printing two duplicate typedefs.
2022-03-05stage2 AArch64: add more slice supportjoachimschmidt557
* airSlice * airArrayToSlice * and initial support for airSlicePtr and co
2022-03-04stage2 ARM: generate less no-op branchesjoachimschmidt557
The checks detecting such no-op branches (essentially instructions that branch to the instruction immediately following the branch) were tightened to catch more of these occurrences.
2022-03-02Sema: detect comptime-known union initializationsAndrew Kelley
Follow a similar pattern as we already do for validate_array_init and validate_struct_init. I threw in a bit of behavior test cleanup on top of it.
2022-02-26Sema: Module.Union.abiAlignment can return 0Andrew Kelley
When the union is a 0-bit type.
2022-02-26Sema: make `align(a) T` same as `align(a:0:N) T`Andrew Kelley
where `@sizeOf(T) == N`.
2022-02-17stage1: fix f80 negationVeikka Tuominen
2022-02-17stage2: add more functions to freestanding libcAndrew Kelley
The log functions are not passing behavior tests.
2022-02-17stage2: implement vector floatopsJohn Schmidt
2022-02-12Skip @sqrt f80 test on freebsdJakub Konka
2022-02-12make f80 less hacky; lower as u80 on non-x86Andrew Kelley
Get rid of `std.math.F80Repr`. Instead of trying to match the memory layout of f80, we treat it as a value, same as the other floating point types. The functions `make_f80` and `break_f80` are introduced to compose an f80 value out of its parts, and the inverse operation. stage2 LLVM backend: fix pointer to zero length array tripping LLVM assertion. It now checks for when the element type is a zero-bit type and lowers such thing the same way that pointers to other zero-bit types are lowered. Both stage1 and stage2 LLVM backends are adjusted so that f80 is lowered as x86_fp80 on x86_64 and i386 architectures, and identical to a u80 on others. LLVM constants are lowered in a less hacky way now that #10860 is fixed, by using the expression `(exp << 64) | fraction` using llvm constants. Sema is improved to handle c_longdouble by recursively handling it correctly for whatever the float bit width is. In both stage1 and stage2.
2022-02-09stage2: implement all builtin floatops for f{16,32,64}John Schmidt
- Merge `floatop.zig` and `floatop_stage1.zig` since most tests now pass on stage2. - Add more behavior tests for a bunch of functions.
2022-02-07stage2: implement @sqrt for f{16,32,64}John Schmidt
Support for f128, comptime_float, and c_longdouble require improvements to compiler_rt and will implemented in a later PR. Some of the code in this commit could be made more generic, for instance `llvm.airSqrt` could probably be `llvm.airUnaryMath`, but let's cross that bridge when we get to it.
2022-01-14stage1: fix bigint_init_bigfloat for single-limb negative floatsMarc Tiehuis
Fixes #10592.
2021-10-20AstGen: make the index variable of `inline for` a `alloc_comptime`Andrew Kelley
Before it was being emitted as an `alloc` which caused inline for loops to not work correctly.
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.