diff options
| author | Robin Voetter <robin@voetter.nl> | 2022-01-08 02:02:01 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-08 14:30:11 -0500 |
| commit | 4931b8dc93ee4a99a415dffab03d400e95d1a90a (patch) | |
| tree | 8586196d647638d70dd7c3c3e657f9adeabdb39c /src/codegen/c.zig | |
| parent | 3f586781b6c8d698468cc58ab64797097323c253 (diff) | |
| download | zig-4931b8dc93ee4a99a415dffab03d400e95d1a90a.tar.gz zig-4931b8dc93ee4a99a415dffab03d400e95d1a90a.zip | |
stage2: @errorName sema+llvm
Diffstat (limited to 'src/codegen/c.zig')
| -rw-r--r-- | src/codegen/c.zig | 17 |
1 files changed, 17 insertions, 0 deletions
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", |
