From 71b8760d3b145c92dc6e331aefff7dac5cabebeb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 6 Mar 2022 15:23:21 -0700 Subject: 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. --- src/AstGen.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/AstGen.zig') diff --git a/src/AstGen.zig b/src/AstGen.zig index cb710af900..fdd58dd948 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -7309,8 +7309,8 @@ fn builtinCall( }, .mul_add => { const float_type = try typeExpr(gz, scope, params[0]); - const mulend1 = try expr(gz, scope, .{ .ty = float_type }, params[1]); - const mulend2 = try expr(gz, scope, .{ .ty = float_type }, params[2]); + const mulend1 = try expr(gz, scope, .{ .coerced_ty = float_type }, params[1]); + const mulend2 = try expr(gz, scope, .{ .coerced_ty = float_type }, params[2]); const addend = try expr(gz, scope, .{ .ty = float_type }, params[3]); const result = try gz.addPlNode(.mul_add, node, Zir.Inst.MulAdd{ .mulend1 = mulend1, -- cgit v1.2.3