From 722d4a11bbba4052558f6f69b7e710d1206f3355 Mon Sep 17 00:00:00 2001 From: John Schmidt Date: Fri, 4 Feb 2022 20:21:15 +0100 Subject: stage2: implement @sqrt for f{16,32,64} 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. --- src/codegen/c.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/codegen/c.zig') diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 44b904f031..fc3848df21 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -1446,6 +1446,8 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO .mul_sat => try airSatOp(f, inst, "muls_"), .shl_sat => try airSatOp(f, inst, "shls_"), + .sqrt => try airSqrt(f, inst), + .add_with_overflow => try airAddWithOverflow(f, inst), .sub_with_overflow => try airSubWithOverflow(f, inst), .mul_with_overflow => try airMulWithOverflow(f, inst), @@ -3393,6 +3395,12 @@ fn airPrefetch(f: *Function, inst: Air.Inst.Index) !CValue { return CValue.none; } +fn airSqrt(f: *Function, inst: Air.Inst.Index) !CValue { + _ = f; + _ = inst; + return f.fail("TODO: C backend: implement sqrt", .{}); +} + fn toMemoryOrder(order: std.builtin.AtomicOrder) [:0]const u8 { return switch (order) { .Unordered => "memory_order_relaxed", -- cgit v1.2.3