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 {...@@ -874,7 +874,6 @@ pub const Inst = struct {
874 /// size as the error integer type, is less than *or equal to* the total874 /// size as the error integer type, is less than *or equal to* the total
875 /// number of errors in the Zcu. The "or equal to" is a consequence of875 /// number of errors in the Zcu. The "or equal to" is a consequence of
876 /// value 0 being reserved for the "non-error" status in error unions.876 /// value 0 being reserved for the "non-error" status in error unions.
877 /// MLUGG TODO: rename this instruction to `cmp_lte_errors_len`
878 ///877 ///
879 /// This instruction exists (as opposed to just using `cmp_lte` against878 /// This instruction exists (as opposed to just using `cmp_lte` against
880 /// a constant) because the number of errors in the Zcu is not known879 /// a constant) because the number of errors in the Zcu is not known
...@@ -884,7 +883,7 @@ pub const Inst = struct {...@@ -884,7 +883,7 @@ pub const Inst = struct {
884 /// Result type is always `bool`.883 /// Result type is always `bool`.
885 ///884 ///
886 /// Uses the `un_op` field.885 /// Uses the `un_op` field.
887 cmp_lt_errors_len,886 cmp_lte_errors_len,
888887
889 /// Returns pointer to current error return trace.888 /// Returns pointer to current error return trace.
890 err_return_trace,889 err_return_trace,
...@@ -1623,7 +1622,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)...@@ -1623,7 +1622,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool)
1623 .cmp_gte_optimized,1622 .cmp_gte_optimized,
1624 .cmp_gt_optimized,1623 .cmp_gt_optimized,
1625 .cmp_neq_optimized,1624 .cmp_neq_optimized,
1626 .cmp_lt_errors_len,1625 .cmp_lte_errors_len,
1627 .is_null,1626 .is_null,
1628 .is_non_null,1627 .is_non_null,
1629 .is_null_ptr,1628 .is_null_ptr,
...@@ -2059,7 +2058,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {...@@ -2059,7 +2058,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool {
2059 .mul_add,2058 .mul_add,
2060 .field_parent_ptr,2059 .field_parent_ptr,
2061 .wasm_memory_size,2060 .wasm_memory_size,
2062 .cmp_lt_errors_len,2061 .cmp_lte_errors_len,
2063 .err_return_trace,2062 .err_return_trace,
2064 .addrspace_cast,2063 .addrspace_cast,
2065 .save_err_return_trace_index,2064 .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 {...@@ -884,7 +884,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void {
884 .field_parent_ptr,884 .field_parent_ptr,
885 .wasm_memory_size,885 .wasm_memory_size,
886 .wasm_memory_grow,886 .wasm_memory_grow,
887 .cmp_lt_errors_len,887 .cmp_lte_errors_len,
888 .err_return_trace,888 .err_return_trace,
889 .set_err_return_trace,889 .set_err_return_trace,
890 .addrspace_cast,890 .addrspace_cast,
src/Air/Liveness.zig+1-1
...@@ -565,7 +565,7 @@ fn analyzeInst(...@@ -565,7 +565,7 @@ fn analyzeInst(
565 .trunc_float,565 .trunc_float,
566 .neg,566 .neg,
567 .neg_optimized,567 .neg_optimized,
568 .cmp_lt_errors_len,568 .cmp_lte_errors_len,
569 .set_err_return_trace,569 .set_err_return_trace,
570 .c_va_end,570 .c_va_end,
571 => {571 => {
src/Air/Liveness/Verify.zig+1-1
...@@ -152,7 +152,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {...@@ -152,7 +152,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void {
152 .trunc_float,152 .trunc_float,
153 .neg,153 .neg,
154 .neg_optimized,154 .neg_optimized,
155 .cmp_lt_errors_len,155 .cmp_lte_errors_len,
156 .set_err_return_trace,156 .set_err_return_trace,
157 .c_va_end,157 .c_va_end,
158 => {158 => {
src/Air/print.zig+1-1
...@@ -211,7 +211,7 @@ const Writer = struct {...@@ -211,7 +211,7 @@ const Writer = struct {
211 .trunc_float,211 .trunc_float,
212 .neg,212 .neg,
213 .neg_optimized,213 .neg_optimized,
214 .cmp_lt_errors_len,214 .cmp_lte_errors_len,
215 .set_err_return_trace,215 .set_err_return_trace,
216 .c_va_end,216 .c_va_end,
217 => try w.writeUnOp(s, inst),217 => 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...@@ -7832,10 +7832,10 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
7832 }7832 }
7833 try sema.requireRuntimeBlock(block, src, operand_src);7833 try sema.requireRuntimeBlock(block, src, operand_src);
7834 if (block.wantSafety()) {7834 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);
7836 const zero_val = Air.internedToRef((try pt.intValue(err_int_ty, 0)).toIntern());7836 const zero_val = Air.internedToRef((try pt.intValue(err_int_ty, 0)).toIntern());
7837 const is_non_zero = try block.addBinOp(.cmp_neq, operand, zero_val);7837 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);
7839 try sema.addSafetyCheck(block, src, ok, .invalid_error_code);7839 try sema.addSafetyCheck(block, src, ok, .invalid_error_code);
7840 }7840 }
7841 return block.addInst(.{7841 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 {...@@ -522,7 +522,7 @@ pub fn analyze(isel: *Select, air_body: []const Air.Inst.Index) !void {
522 .is_named_enum_value,522 .is_named_enum_value,
523 .tag_name,523 .tag_name,
524 .error_name,524 .error_name,
525 .cmp_lt_errors_len,525 .cmp_lte_errors_len,
526 => {526 => {
527 const un_op = air_data[@intFromEnum(air_inst_index)].un_op;527 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,...@@ -7175,7 +7175,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
7175 if (air.next()) |next_air_tag| continue :air_tag next_air_tag;7175 if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
7176 },7176 },
7177 .wasm_memory_size, .wasm_memory_grow => unreachable,7177 .wasm_memory_size, .wasm_memory_grow => unreachable,
7178 .cmp_lt_errors_len => {7178 .cmp_lte_errors_len => {
7179 if (isel.live_values.fetchRemove(air.inst_index)) |is_vi| unused: {7179 if (isel.live_values.fetchRemove(air.inst_index)) |is_vi| unused: {
7180 defer is_vi.value.deref(isel);7180 defer is_vi.value.deref(isel);
7181 const is_ra = try is_vi.value.defReg(isel) orelse break :unused;7181 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 {...@@ -2722,7 +2722,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) Error!void {
2722 const extra = f.air.extraData(Air.VectorCmp, ty_pl.payload).data;2722 const extra = f.air.extraData(Air.VectorCmp, ty_pl.payload).data;
2723 break :blk try airCmpOp(f, inst, extra, extra.compareOperator());2723 break :blk try airCmpOp(f, inst, extra, extra.compareOperator());
2724 },2724 },
2725 .cmp_lt_errors_len => try airCmpLtErrorsLen(f, inst),2725 .cmp_lte_errors_len => try airCmpLteErrorsLen(f, inst),
27262726
2727 // bool_and and bool_or are non-short-circuit operations2727 // bool_and and bool_or are non-short-circuit operations
2728 .bool_and, .bit_and => try airBinOp(f, inst, "&", "and", .none),2728 .bool_and, .bit_and => try airBinOp(f, inst, "&", "and", .none),
...@@ -3728,7 +3728,7 @@ fn airEquality(...@@ -3728,7 +3728,7 @@ fn airEquality(
3728 return local;3728 return local;
3729}3729}
37303730
3731fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue {3731fn airCmpLteErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue {
3732 const un_op = f.air.instructions.items(.data)[@intFromEnum(inst)].un_op;3732 const un_op = f.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
37333733
3734 const operand = try f.resolveInst(un_op);3734 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...@@ -302,7 +302,7 @@ pub fn genBody(self: *FuncGen, body: []const Air.Inst.Index, coverage_point: Air
302302
303 .cmp_vector => try self.airCmpVector(inst, .normal),303 .cmp_vector => try self.airCmpVector(inst, .normal),
304 .cmp_vector_optimized => try self.airCmpVector(inst, .fast),304 .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
307 .is_non_null => try self.airIsNonNull(inst, false, .ne),307 .is_non_null => try self.airIsNonNull(inst, false, .ne),
308 .is_non_null_ptr => try self.airIsNonNull(inst, true , .ne),308 .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...@@ -1105,7 +1105,7 @@ fn airCmpVector(self: *FuncGen, inst: Air.Inst.Index, fast: Builder.FastMathKind
1105 return self.cmp(fast, cmp_op, vec_ty, lhs, rhs);1105 return self.cmp(fast, cmp_op, vec_ty, lhs, rhs);
1106}1106}
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 {
1109 const o = self.object;1109 const o = self.object;
1110 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;1110 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
1111 const operand = try self.resolveInst(un_op);1111 const operand = try self.resolveInst(un_op);
...@@ -1117,7 +1117,6 @@ fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build...@@ -1117,7 +1117,6 @@ fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build
1117 Type.errorAbiAlignment(o.zcu).toLlvm(),1117 Type.errorAbiAlignment(o.zcu).toLlvm(),
1118 "",1118 "",
1119 );1119 );
1120 // Despite the name, this instruction is actually lte. MLUGG TODO RENAME
1121 return self.wip.icmp(.ule, operand, errors_len_val, "");1120 return self.wip.icmp(.ule, operand, errors_len_val, "");
1122}1121}
11231122
src/codegen/riscv64/CodeGen.zig+3-3
...@@ -1477,7 +1477,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {...@@ -1477,7 +1477,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void {
1477 => try func.airCmp(inst, tag),1477 => try func.airCmp(inst, tag),
14781478
1479 .cmp_vector => try func.airCmpVector(inst),1479 .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
1482 .slice => try func.airSlice(inst),1482 .slice => try func.airSlice(inst),
1483 .array_to_slice => try func.airArrayToSlice(inst),1483 .array_to_slice => try func.airArrayToSlice(inst),
...@@ -5186,11 +5186,11 @@ fn airCmpVector(func: *Func, inst: Air.Inst.Index) !void {...@@ -5186,11 +5186,11 @@ fn airCmpVector(func: *Func, inst: Air.Inst.Index) !void {
5186 return func.fail("TODO implement airCmpVector for {}", .{func.target.cpu.arch});5186 return func.fail("TODO implement airCmpVector for {}", .{func.target.cpu.arch});
5187}5187}
51885188
5189fn airCmpLtErrorsLen(func: *Func, inst: Air.Inst.Index) !void {5189fn airCmpLteErrorsLen(func: *Func, inst: Air.Inst.Index) !void {
5190 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;5190 const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
5191 const operand = try func.resolveInst(un_op);5191 const operand = try func.resolveInst(un_op);
5192 _ = operand;5192 _ = 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});
5194 return func.finishAir(inst, result, .{ un_op, .none, .none });5194 return func.finishAir(inst, result, .{ un_op, .none, .none });
5195}5195}
51965196
src/codegen/sparc64/CodeGen.zig+3-3
...@@ -545,7 +545,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {...@@ -545,7 +545,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
545 .cmp_gt => try self.airCmp(inst, .gt),545 .cmp_gt => try self.airCmp(inst, .gt),
546 .cmp_neq => try self.airCmp(inst, .neq),546 .cmp_neq => try self.airCmp(inst, .neq),
547 .cmp_vector => @panic("TODO try self.airCmpVector(inst)"),547 .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
550 .alloc => try self.airAlloc(inst),550 .alloc => try self.airAlloc(inst),
551 .ret_ptr => try self.airRetPtr(inst),551 .ret_ptr => try self.airRetPtr(inst),
...@@ -1425,11 +1425,11 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {...@@ -1425,11 +1425,11 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
1425 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });1425 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
1426}1426}
14271427
1428fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void {1428fn airCmpLteErrorsLen(self: *Self, inst: Air.Inst.Index) !void {
1429 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;1429 const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
1430 const operand = try self.resolveInst(un_op);1430 const operand = try self.resolveInst(un_op);
1431 _ = operand;1431 _ = 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});
1433 return self.finishAir(inst, result, .{ un_op, .none, .none });1433 return self.finishAir(inst, result, .{ un_op, .none, .none });
1434}1434}
14351435
src/codegen/wasm/CodeGen.zig+2-2
...@@ -1718,7 +1718,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -1718,7 +1718,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
1718 .cmp_neq => cg.airCmp(inst, .neq),1718 .cmp_neq => cg.airCmp(inst, .neq),
17191719
1720 .cmp_vector => cg.airCmpVector(inst),1720 .cmp_vector => cg.airCmpVector(inst),
1721 .cmp_lt_errors_len => cg.airCmpLtErrorsLen(inst),1721 .cmp_lte_errors_len => cg.airCmpLteErrorsLen(inst),
17221722
1723 .array_elem_val => cg.airArrayElemVal(inst),1723 .array_elem_val => cg.airArrayElemVal(inst),
1724 .array_to_slice => cg.airArrayToSlice(inst),1724 .array_to_slice => cg.airArrayToSlice(inst),
...@@ -4841,7 +4841,7 @@ fn airCmpVector(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4841,7 +4841,7 @@ fn airCmpVector(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4841 return cg.fail("TODO implement airCmpVector for wasm", .{});4841 return cg.fail("TODO implement airCmpVector for wasm", .{});
4842}4842}
48434843
4844fn airCmpLtErrorsLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {4844fn airCmpLteErrorsLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4845 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;4845 const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op;
4846 const operand = try cg.resolveInst(un_op);4846 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 {...@@ -172921,7 +172921,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
172921 try ops[0].finish(inst, &.{field_parent_ptr.field_ptr}, &ops, cg);172921 try ops[0].finish(inst, &.{field_parent_ptr.field_ptr}, &ops, cg);
172922 },172922 },
172923 .wasm_memory_size, .wasm_memory_grow => unreachable,172923 .wasm_memory_size, .wasm_memory_grow => unreachable,
172924 .cmp_lt_errors_len => |air_tag| {172924 .cmp_lte_errors_len => |air_tag| {
172925 const un_op = air_datas[@intFromEnum(inst)].un_op;172925 const un_op = air_datas[@intFromEnum(inst)].un_op;
172926 var ops = try cg.tempsFromOperands(inst, .{un_op});172926 var ops = try cg.tempsFromOperands(inst, .{un_op});
172927 var res: [1]Temp = undefined;172927 var res: [1]Temp = undefined;