| ... | ... | @@ -2078,7 +2078,6 @@ pub fn genGlobalAsm(mod: *Module, code: *std.ArrayList(u8)) !void { |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | pub fn genErrDecls(o: *Object) !void { |
| 2081 | | if (o.dg.module.global_error_set.size == 0) return; |
| 2082 | 2081 | const writer = o.writer(); |
| 2083 | 2082 | |
| 2084 | 2083 | try writer.writeAll("enum {\n"); |
| ... | ... | @@ -2373,7 +2372,7 @@ fn genBody(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail, OutO |
| 2373 | 2372 | .cmp_neq => try airEquality(f, inst, "!((", "!="), |
| 2374 | 2373 | |
| 2375 | 2374 | .cmp_vector => return f.fail("TODO: C backend: implement cmp_vector", .{}), |
| 2376 | | .cmp_lt_errors_len => return f.fail("TODO: C backend: implement cmp_lt_errors_len", .{}), |
| 2375 | .cmp_lt_errors_len => try airCmpLtErrorsLen(f, inst), |
| 2377 | 2376 | |
| 2378 | 2377 | // bool_and and bool_or are non-short-circuit operations |
| 2379 | 2378 | .bool_and, .bit_and => try airBinOp(f, inst, "&", "and", .None), |
| ... | ... | @@ -3176,6 +3175,21 @@ fn airEquality( |
| 3176 | 3175 | return local; |
| 3177 | 3176 | } |
| 3178 | 3177 | |
| 3178 | fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue { |
| 3179 | if (f.liveness.isUnused(inst)) return CValue.none; |
| 3180 | |
| 3181 | const un_op = f.air.instructions.items(.data)[inst].un_op; |
| 3182 | const inst_ty = f.air.typeOfIndex(inst); |
| 3183 | const operand = try f.resolveInst(un_op); |
| 3184 | |
| 3185 | const writer = f.object.writer(); |
| 3186 | const local = try f.allocLocal(inst_ty, .Const); |
| 3187 | try writer.writeAll(" = "); |
| 3188 | try f.writeCValue(writer, operand, .Other); |
| 3189 | try writer.print(" < sizeof({ }) / sizeof(*{0 });\n", .{fmtIdent("zig_errorName")}); |
| 3190 | return local; |
| 3191 | } |
| 3192 | |
| 3179 | 3193 | fn airPtrAddSub(f: *Function, inst: Air.Inst.Index, operator: u8) !CValue { |
| 3180 | 3194 | if (f.liveness.isUnused(inst)) return CValue.none; |
| 3181 | 3195 | |