diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-06 15:23:21 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-06 16:11:39 -0700 |
| commit | 71b8760d3b145c92dc6e331aefff7dac5cabebeb (patch) | |
| tree | 66b92748616634b689eb5c984f143042132d5e6c /test | |
| parent | 6637335981f7179b449fced78cfd4052b1618051 (diff) | |
| download | zig-71b8760d3b145c92dc6e331aefff7dac5cabebeb.tar.gz zig-71b8760d3b145c92dc6e331aefff7dac5cabebeb.zip | |
stage2: rework `@mulAdd`
* mul_add AIR instruction: use `pl_op` instead of `ty_pl`. The type is
always the same as the operand; no need to waste bytes redundantly
storing the type.
* AstGen: use coerced_ty for all the operands except for one which we
use to communicate the type.
* Sema: use the correct source location for requireRuntimeBlock in
handling of `@mulAdd`.
* native backends: handle liveness even for the functions that are
TODO.
* C backend: implement `@mulAdd`. It lowers to libc calls.
* LLVM backend: make `@mulAdd` handle all float types.
- improved fptrunc and fpext to handle f80 with compiler-rt calls.
* Value.mulAdd: handle all float types and use the `@mulAdd` builtin.
* behavior tests: revert the changes to testing `@mulAdd`. These
changes broke the test coverage, making it only tested at
compile-time.
Improved f80 support:
* std.math.fma handles f80
* move fma functions from freestanding libc to compiler-rt
- add __fmax and fmal
- make __fmax and fmaq only exported when they don't alias fmal.
- make their linkage weak just like the rest of compiler-rt symbols.
* removed `longDoubleIsF128` and replaced it with `longDoubleIs` which
takes a type as a parameter. The implementation is now more accurate
and handles more targets. Similarly, in stage2 the function
CTypes.sizeInBits is more accurate for long double for more targets.
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/muladd.zig | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/test/behavior/muladd.zig b/test/behavior/muladd.zig index 4ef0e44acb..53ab6b64ec 100644 --- a/test/behavior/muladd.zig +++ b/test/behavior/muladd.zig @@ -2,8 +2,8 @@ const builtin = @import("builtin"); const expect = @import("std").testing.expect; test "@mulAdd" { - if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO @@ -13,22 +13,22 @@ test "@mulAdd" { } fn testMulAdd() !void { - if (builtin.zig_backend == .stage1) { - const a: f16 = 5.5; - const b: f16 = 2.5; - const c: f16 = 6.25; + { + var a: f16 = 5.5; + var b: f16 = 2.5; + var c: f16 = 6.25; try expect(@mulAdd(f16, a, b, c) == 20); } { - const a: f32 = 5.5; - const b: f32 = 2.5; - const c: f32 = 6.25; + var a: f32 = 5.5; + var b: f32 = 2.5; + var c: f32 = 6.25; try expect(@mulAdd(f32, a, b, c) == 20); } { - const a: f64 = 5.5; - const b: f64 = 2.5; - const c: f64 = 6.25; + var a: f64 = 5.5; + var b: f64 = 2.5; + var c: f64 = 6.25; try expect(@mulAdd(f64, a, b, c) == 20); } } @@ -39,9 +39,7 @@ test "@mulAdd f80" { return error.SkipZigTest; } - // TODO: missing f80 implementation of FMA in `std.math.fma` or compiler-rt - // comptime try testMulAdd80(); - + comptime try testMulAdd80(); try testMulAdd80(); } @@ -53,11 +51,12 @@ fn testMulAdd80() !void { } test "@mulAdd f128" { - if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.os.tag == .macos and builtin.cpu.arch == .aarch64) { // https://github.com/ziglang/zig/issues/9900 return error.SkipZigTest; @@ -68,8 +67,8 @@ test "@mulAdd f128" { } fn testMulAdd128() !void { - const a: f16 = 5.5; - const b: f128 = 2.5; - const c: f128 = 6.25; + var a: f16 = 5.5; + var b: f128 = 2.5; + var c: f128 = 6.25; try expect(@mulAdd(f128, a, b, c) == 20); } |
