authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-23 14:54:40+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-28 16:47:02+00:00
logfb224178aaeeb5d8e37392f5c168afca771147ca
tree0c69accaff106cf7801feba1ea6905a221ac6d37
parentc0f3a238314315a1e4a578b23cc66237eac90689
signaturelock-open Commit is signed but in an unrecognized format.

Air: change misleading instruction tag name


13 files changed, 24 insertions(+), 26 deletions(-)

src/Air.zig+3-4
......@@ -874,7 +874,6 @@ pub const Inst = struct {
874874 /// size as the error integer type, is less than *or equal to* the total
875875 /// number of errors in the Zcu. The "or equal to" is a consequence of
876876 /// value 0 being reserved for the "non-error" status in error unions.
877 /// MLUGG TODO: rename this instruction to `cmp_lte_errors_len`
878877 ///
879878 /// This instruction exists (as opposed to just using `cmp_lte` against
880879 /// a constant) because the number of errors in the Zcu is not known
......@@ -884,7 +883,7 @@ pub const Inst = struct {
884883 /// Result type is always `bool`.
885884 ///
886885 /// Uses the `un_op` field.
887 cmp_lt_errors_len,
886 cmp_lte_errors_len,
888887
889888 /// Returns pointer to current error return trace.
890889 err_return_trace,
......@@ -1623,7 +1622,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)
16231622 .cmp_gte_optimized,
16241623 .cmp_gt_optimized,
16251624 .cmp_neq_optimized,
1626 .cmp_lt_errors_len,
1625 .cmp_lte_errors_len,
16271626 .is_null,
16281627 .is_non_null,
16291628 .is_null_ptr,
......@@ -2059,7 +2058,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
20592058 .mul_add,
20602059 .field_parent_ptr,
20612060 .wasm_memory_size,
2062 .cmp_lt_errors_len,
2061 .cmp_lte_errors_len,
20632062 .err_return_trace,
20642063 .addrspace_cast,
20652064 .save_err_return_trace_index,
src/Air/Legalize.zig+1-1
......@@ -884,7 +884,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void {
884884 .field_parent_ptr,
885885 .wasm_memory_size,
886886 .wasm_memory_grow,
887 .cmp_lt_errors_len,
887 .cmp_lte_errors_len,
888888 .err_return_trace,
889889 .set_err_return_trace,
890890 .addrspace_cast,
src/Air/Liveness.zig+1-1
......@@ -565,7 +565,7 @@ fn analyzeInst(
565565 .trunc_float,
566566 .neg,
567567 .neg_optimized,
568 .cmp_lt_errors_len,
568 .cmp_lte_errors_len,
569569 .set_err_return_trace,
570570 .c_va_end,
571571 => {
src/Air/Liveness/Verify.zig+1-1
......@@ -152,7 +152,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
152152 .trunc_float,
153153 .neg,
154154 .neg_optimized,
155 .cmp_lt_errors_len,
155 .cmp_lte_errors_len,
156156 .set_err_return_trace,
157157 .c_va_end,
158158 => {
src/Air/print.zig+1-1
......@@ -211,7 +211,7 @@ const Writer = struct {
211211 .trunc_float,
212212 .neg,
213213 .neg_optimized,
214 .cmp_lt_errors_len,
214 .cmp_lte_errors_len,
215215 .set_err_return_trace,
216216 .c_va_end,
217217 => try w.writeUnOp(s, inst),
src/Sema.zig+2-2
......@@ -7832,10 +7832,10 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
78327832 }
78337833 try sema.requireRuntimeBlock(block, src, operand_src);
78347834 if (block.wantSafety()) {
7835 const is_lt_len = try block.addUnOp(.cmp_lt_errors_len, operand);
7835 const is_lte_len = try block.addUnOp(.cmp_lte_errors_len, operand);
78367836 const zero_val = Air.internedToRef((try pt.intValue(err_int_ty, 0)).toIntern());
78377837 const is_non_zero = try block.addBinOp(.cmp_neq, operand, zero_val);
7838 const ok = try block.addBinOp(.bool_and, is_lt_len, is_non_zero);
7838 const ok = try block.addBinOp(.bool_and, is_lte_len, is_non_zero);
78397839 try sema.addSafetyCheck(block, src, ok, .invalid_error_code);
78407840 }
78417841 return block.addInst(.{
src/codegen/aarch64/Select.zig+2-2
......@@ -522,7 +522,7 @@ pub fn analyze(isel: *Select, air_body: []const Air.Inst.Index) !void {
522522 .is_named_enum_value,
523523 .tag_name,
524524 .error_name,
525 .cmp_lt_errors_len,
525 .cmp_lte_errors_len,
526526 => {
527527 const un_op = air_data[@intFromEnum(air_inst_index)].un_op;
528528
......@@ -7175,7 +7175,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
71757175 if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
71767176 },
71777177 .wasm_memory_size, .wasm_memory_grow => unreachable,
7178 .cmp_lt_errors_len => {
7178 .cmp_lte_errors_len => {
71797179 if (isel.live_values.fetchRemove(air.inst_index)) |is_vi| unused: {
71807180 defer is_vi.value.deref(isel);
71817181 const is_ra = try is_vi.value.defReg(isel) orelse break :unused;
src/codegen/c.zig+2-2
......@@ -2722,7 +2722,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) Error!void {
27222722 const extra = f.air.extraData(Air.VectorCmp, ty_pl.payload).data;
27232723 break :blk try airCmpOp(f, inst, extra, extra.compareOperator());
27242724 },
2725 .cmp_lt_errors_len => try airCmpLtErrorsLen(f, inst),
2725 .cmp_lte_errors_len => try airCmpLteErrorsLen(f, inst),
27262726
27272727 // bool_and and bool_or are non-short-circuit operations
27282728 .bool_and, .bit_and => try airBinOp(f, inst, "&", "and", .none),
......@@ -3728,7 +3728,7 @@ fn airEquality(
37283728 return local;
37293729}
37303730
3731fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue {
3731fn airCmpLteErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue {
37323732 const un_op = f.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
37333733
37343734 const operand = try f.resolveInst(un_op);
src/codegen/llvm/FuncGen.zig+2-3
......@@ -302,7 +302,7 @@ pub fn genBody(self: *FuncGen, body: []const Air.Inst.Index, coverage_point: Air
302302
303303 .cmp_vector => try self.airCmpVector(inst, .normal),
304304 .cmp_vector_optimized => try self.airCmpVector(inst, .fast),
305 .cmp_lt_errors_len => try self.airCmpLtErrorsLen(inst),
305 .cmp_lte_errors_len => try self.airCmpLteErrorsLen(inst),
306306
307307 .is_non_null => try self.airIsNonNull(inst, false, .ne),
308308 .is_non_null_ptr => try self.airIsNonNull(inst, true , .ne),
......@@ -1105,7 +1105,7 @@ fn airCmpVector(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind
11051105 return self.cmp(fast, cmp_op, vec_ty, lhs, rhs);
11061106}
11071107
1108fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
1108fn airCmpLteErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value {
11091109 const o = self.object;
11101110 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
11111111 const operand = try self.resolveInst(un_op);
......@@ -1117,7 +1117,6 @@ fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build
11171117 Type.errorAbiAlignment(o.zcu).toLlvm(),
11181118 "",
11191119 );
1120 // Despite the name, this instruction is actually lte. MLUGG TODO RENAME
11211120 return self.wip.icmp(.ule, operand, errors_len_val, "");
11221121}
11231122
src/codegen/riscv64/CodeGen.zig+3-3
......@@ -1477,7 +1477,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
14771477 => try func.airCmp(inst, tag),
14781478
14791479 .cmp_vector => try func.airCmpVector(inst),
1480 .cmp_lt_errors_len => try func.airCmpLtErrorsLen(inst),
1480 .cmp_lte_errors_len => try func.airCmpLteErrorsLen(inst),
14811481
14821482 .slice => try func.airSlice(inst),
14831483 .array_to_slice => try func.airArrayToSlice(inst),
......@@ -5186,11 +5186,11 @@ fn airCmpVector(func: *Func, inst: Air.Inst.Index) !void {
51865186 return func.fail("TODO implement airCmpVector for {}", .{func.target.cpu.arch});
51875187}
51885188
5189fn airCmpLtErrorsLen(func: *Func, inst: Air.Inst.Index) !void {
5189fn airCmpLteErrorsLen(func: *Func, inst: Air.Inst.Index) !void {
51905190 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
51915191 const operand = try func.resolveInst(un_op);
51925192 _ = operand;
5193 const result: MCValue = if (func.liveness.isUnused(inst)) .unreach else return func.fail("TODO implement airCmpLtErrorsLen for {}", .{func.target.cpu.arch});
5193 const result: MCValue = if (func.liveness.isUnused(inst)) .unreach else return func.fail("TODO implement airCmpLteErrorsLen for {}", .{func.target.cpu.arch});
51945194 return func.finishAir(inst, result, .{ un_op, .none, .none });
51955195}
51965196
src/codegen/sparc64/CodeGen.zig+3-3
......@@ -545,7 +545,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
545545 .cmp_gt => try self.airCmp(inst, .gt),
546546 .cmp_neq => try self.airCmp(inst, .neq),
547547 .cmp_vector => @panic("TODO try self.airCmpVector(inst)"),
548 .cmp_lt_errors_len => try self.airCmpLtErrorsLen(inst),
548 .cmp_lte_errors_len => try self.airCmpLteErrorsLen(inst),
549549
550550 .alloc => try self.airAlloc(inst),
551551 .ret_ptr => try self.airRetPtr(inst),
......@@ -1425,11 +1425,11 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
14251425 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
14261426}
14271427
1428fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void {
1428fn airCmpLteErrorsLen(self: *Self, inst: Air.Inst.Index) !void {
14291429 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
14301430 const operand = try self.resolveInst(un_op);
14311431 _ = operand;
1432 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airCmpLtErrorsLen for {}", .{self.target.cpu.arch});
1432 const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airCmpLteErrorsLen for {}", .{self.target.cpu.arch});
14331433 return self.finishAir(inst, result, .{ un_op, .none, .none });
14341434}
14351435
src/codegen/wasm/CodeGen.zig+2-2
......@@ -1718,7 +1718,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
17181718 .cmp_neq => cg.airCmp(inst, .neq),
17191719
17201720 .cmp_vector => cg.airCmpVector(inst),
1721 .cmp_lt_errors_len => cg.airCmpLtErrorsLen(inst),
1721 .cmp_lte_errors_len => cg.airCmpLteErrorsLen(inst),
17221722
17231723 .array_elem_val => cg.airArrayElemVal(inst),
17241724 .array_to_slice => cg.airArrayToSlice(inst),
......@@ -4841,7 +4841,7 @@ fn airCmpVector(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
48414841 return cg.fail("TODO implement airCmpVector for wasm", .{});
48424842}
48434843
4844fn airCmpLtErrorsLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4844fn airCmpLteErrorsLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
48454845 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
48464846 const operand = try cg.resolveInst(un_op);
48474847
src/codegen/x86_64/CodeGen.zig+1-1
......@@ -172921,7 +172921,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
172921172921 try ops[0].finish(inst, &.{field_parent_ptr.field_ptr}, &ops, cg);
172922172922 },
172923172923 .wasm_memory_size, .wasm_memory_grow => unreachable,
172924 .cmp_lt_errors_len => |air_tag| {
172924 .cmp_lte_errors_len => |air_tag| {
172925172925 const un_op = air_datas[@intFromEnum(inst)].un_op;
172926172926 var ops = try cg.tempsFromOperands(inst, .{un_op});
172927172927 var res: [1]Temp = undefined;