From 4931b8dc93ee4a99a415dffab03d400e95d1a90a Mon Sep 17 00:00:00 2001 From: Robin Voetter Date: Sat, 8 Jan 2022 02:02:01 +0100 Subject: stage2: @errorName sema+llvm --- src/codegen/c.zig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/codegen/c.zig') diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 922e1d9c3e..e85ca6c705 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -1244,6 +1244,7 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO .ctz => try airBuiltinCall(f, inst, "ctz"), .popcount => try airBuiltinCall(f, inst, "popcount"), .tag_name => try airTagName(f, inst), + .error_name => try airErrorName(f, inst), .int_to_float, .float_to_int, @@ -2998,6 +2999,22 @@ fn airTagName(f: *Function, inst: Air.Inst.Index) !CValue { //return local; } +fn airErrorName(f: *Function, inst: Air.Inst.Index) !CValue { + if (f.liveness.isUnused(inst)) return CValue.none; + + const un_op = f.air.instructions.items(.data)[inst].un_op; + const writer = f.object.writer(); + const inst_ty = f.air.typeOfIndex(inst); + const operand = try f.resolveInst(un_op); + const local = try f.allocLocal(inst_ty, .Const); + + try writer.writeAll(" = "); + + _ = operand; + _ = local; + return f.fail("TODO: C backend: implement airErrorName", .{}); +} + fn toMemoryOrder(order: std.builtin.AtomicOrder) [:0]const u8 { return switch (order) { .Unordered => "memory_order_relaxed", -- cgit v1.2.3