diff --git a/src/Air.zig b/src/Air.zig index a3de9c84c867cc0e4ca158087b0e60c7efc6e1c2..275857214ebb3638bedc3e785620cd18939f031d 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -874,7 +874,6 @@ pub const Inst = struct { /// size as the error integer type, is less than *or equal to* the total /// number of errors in the Zcu. The "or equal to" is a consequence of /// value 0 being reserved for the "non-error" status in error unions. - /// MLUGG TODO: rename this instruction to `cmp_lte_errors_len` /// /// This instruction exists (as opposed to just using `cmp_lte` against /// a constant) because the number of errors in the Zcu is not known @@ -884,7 +883,7 @@ pub const Inst = struct { /// Result type is always `bool`. /// /// Uses the `un_op` field. - cmp_lt_errors_len, + cmp_lte_errors_len, /// Returns pointer to current error return trace. err_return_trace, @@ -1623,7 +1622,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool) .cmp_gte_optimized, .cmp_gt_optimized, .cmp_neq_optimized, - .cmp_lt_errors_len, + .cmp_lte_errors_len, .is_null, .is_non_null, .is_null_ptr, @@ -2059,7 +2058,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool { .mul_add, .field_parent_ptr, .wasm_memory_size, - .cmp_lt_errors_len, + .cmp_lte_errors_len, .err_return_trace, .addrspace_cast, .save_err_return_trace_index, diff --git a/src/Air/Legalize.zig b/src/Air/Legalize.zig index 3dcab2043581cefc7c79871e40d7717936747c88..01f4c53482b97eb9b2b620b5c967f748ff3d7b9b 100644 --- a/src/Air/Legalize.zig +++ b/src/Air/Legalize.zig @@ -884,7 +884,7 @@ fn legalizeBody(l: *Legalize, body_start: usize, body_len: usize) Error!void { .field_parent_ptr, .wasm_memory_size, .wasm_memory_grow, - .cmp_lt_errors_len, + .cmp_lte_errors_len, .err_return_trace, .set_err_return_trace, .addrspace_cast, diff --git a/src/Air/Liveness.zig b/src/Air/Liveness.zig index 384a056988b40b6a59fc4f9a582c7869bf994d3e..402873227a738953ee6ce9546115e39b75c0331a 100644 --- a/src/Air/Liveness.zig +++ b/src/Air/Liveness.zig @@ -565,7 +565,7 @@ fn analyzeInst( .trunc_float, .neg, .neg_optimized, - .cmp_lt_errors_len, + .cmp_lte_errors_len, .set_err_return_trace, .c_va_end, => { diff --git a/src/Air/Liveness/Verify.zig b/src/Air/Liveness/Verify.zig index 7f820e65981b1d4247b363c061269c8d893ce239..fd8f735741bf905ce80d5dbbf69e54425b1e2e63 100644 --- a/src/Air/Liveness/Verify.zig +++ b/src/Air/Liveness/Verify.zig @@ -152,7 +152,7 @@ fn verifyBody(self: *Verify, body: []const Air.Inst.Index) Error!void { .trunc_float, .neg, .neg_optimized, - .cmp_lt_errors_len, + .cmp_lte_errors_len, .set_err_return_trace, .c_va_end, => { diff --git a/src/Air/print.zig b/src/Air/print.zig index f6c0f5a03b8f1c957b0129978358888977690de7..b1114b39c3dfc154705b9e5c8324b200514a6a91 100644 --- a/src/Air/print.zig +++ b/src/Air/print.zig @@ -211,7 +211,7 @@ const Writer = struct { .trunc_float, .neg, .neg_optimized, - .cmp_lt_errors_len, + .cmp_lte_errors_len, .set_err_return_trace, .c_va_end, => try w.writeUnOp(s, inst), diff --git a/src/Sema.zig b/src/Sema.zig index 0629e827a97a3acd68dc811714020b600616e341..ab7e8b4c155fe804c09a17e6020c7955c2f86d5f 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -7832,10 +7832,10 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD } try sema.requireRuntimeBlock(block, src, operand_src); if (block.wantSafety()) { - const is_lt_len = try block.addUnOp(.cmp_lt_errors_len, operand); + const is_lte_len = try block.addUnOp(.cmp_lte_errors_len, operand); const zero_val = Air.internedToRef((try pt.intValue(err_int_ty, 0)).toIntern()); const is_non_zero = try block.addBinOp(.cmp_neq, operand, zero_val); - const ok = try block.addBinOp(.bool_and, is_lt_len, is_non_zero); + const ok = try block.addBinOp(.bool_and, is_lte_len, is_non_zero); try sema.addSafetyCheck(block, src, ok, .invalid_error_code); } return block.addInst(.{ diff --git a/src/codegen/aarch64/Select.zig b/src/codegen/aarch64/Select.zig index c8a9f41cb3d6c2906e7011373ede8fca90a031a3..2bfb3c4a552c2d453a7612ea07ada56eae490308 100644 --- a/src/codegen/aarch64/Select.zig +++ b/src/codegen/aarch64/Select.zig @@ -522,7 +522,7 @@ pub fn analyze(isel: *Select, air_body: []const Air.Inst.Index) !void { .is_named_enum_value, .tag_name, .error_name, - .cmp_lt_errors_len, + .cmp_lte_errors_len, => { const un_op = air_data[@intFromEnum(air_inst_index)].un_op; @@ -7175,7 +7175,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, if (air.next()) |next_air_tag| continue :air_tag next_air_tag; }, .wasm_memory_size, .wasm_memory_grow => unreachable, - .cmp_lt_errors_len => { + .cmp_lte_errors_len => { if (isel.live_values.fetchRemove(air.inst_index)) |is_vi| unused: { defer is_vi.value.deref(isel); const is_ra = try is_vi.value.defReg(isel) orelse break :unused; diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 1b72c8759907bb004e0c31850bc1e53ccde57dea..99f15a902659004788477a58fa12004ef956b828 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -2722,7 +2722,7 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) Error!void { const extra = f.air.extraData(Air.VectorCmp, ty_pl.payload).data; break :blk try airCmpOp(f, inst, extra, extra.compareOperator()); }, - .cmp_lt_errors_len => try airCmpLtErrorsLen(f, inst), + .cmp_lte_errors_len => try airCmpLteErrorsLen(f, inst), // bool_and and bool_or are non-short-circuit operations .bool_and, .bit_and => try airBinOp(f, inst, "&", "and", .none), @@ -3728,7 +3728,7 @@ fn airEquality( return local; } -fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue { +fn airCmpLteErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue { const un_op = f.air.instructions.items(.data)[@intFromEnum(inst)].un_op; const operand = try f.resolveInst(un_op); diff --git a/src/codegen/llvm/FuncGen.zig b/src/codegen/llvm/FuncGen.zig index ec8e0b1d0577dadd8a299bf0cb274be8723a76e9..2b4bef2bc76013936396c674bf1414a508b5824e 100644 --- a/src/codegen/llvm/FuncGen.zig +++ b/src/codegen/llvm/FuncGen.zig @@ -302,7 +302,7 @@ pub fn genBody(self: *FuncGen, body: []const Air.Inst.Index, coverage_point: Air .cmp_vector => try self.airCmpVector(inst, .normal), .cmp_vector_optimized => try self.airCmpVector(inst, .fast), - .cmp_lt_errors_len => try self.airCmpLtErrorsLen(inst), + .cmp_lte_errors_len => try self.airCmpLteErrorsLen(inst), .is_non_null => try self.airIsNonNull(inst, false, .ne), .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 return self.cmp(fast, cmp_op, vec_ty, lhs, rhs); } -fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { +fn airCmpLteErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { const o = self.object; const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; const operand = try self.resolveInst(un_op); @@ -1117,7 +1117,6 @@ fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build Type.errorAbiAlignment(o.zcu).toLlvm(), "", ); - // Despite the name, this instruction is actually lte. MLUGG TODO RENAME return self.wip.icmp(.ule, operand, errors_len_val, ""); } diff --git a/src/codegen/riscv64/CodeGen.zig b/src/codegen/riscv64/CodeGen.zig index d50f6a71254877ca7cad6b0c82af9b79381d7a7b..5ab8bebed44c45d8eeb7aa071fe2d803c1f43839 100644 --- a/src/codegen/riscv64/CodeGen.zig +++ b/src/codegen/riscv64/CodeGen.zig @@ -1477,7 +1477,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void { => try func.airCmp(inst, tag), .cmp_vector => try func.airCmpVector(inst), - .cmp_lt_errors_len => try func.airCmpLtErrorsLen(inst), + .cmp_lte_errors_len => try func.airCmpLteErrorsLen(inst), .slice => try func.airSlice(inst), .array_to_slice => try func.airArrayToSlice(inst), @@ -5186,11 +5186,11 @@ fn airCmpVector(func: *Func, inst: Air.Inst.Index) !void { return func.fail("TODO implement airCmpVector for {}", .{func.target.cpu.arch}); } -fn airCmpLtErrorsLen(func: *Func, inst: Air.Inst.Index) !void { +fn airCmpLteErrorsLen(func: *Func, inst: Air.Inst.Index) !void { const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op; const operand = try func.resolveInst(un_op); _ = operand; - const result: MCValue = if (func.liveness.isUnused(inst)) .unreach else return func.fail("TODO implement airCmpLtErrorsLen for {}", .{func.target.cpu.arch}); + const result: MCValue = if (func.liveness.isUnused(inst)) .unreach else return func.fail("TODO implement airCmpLteErrorsLen for {}", .{func.target.cpu.arch}); return func.finishAir(inst, result, .{ un_op, .none, .none }); } diff --git a/src/codegen/sparc64/CodeGen.zig b/src/codegen/sparc64/CodeGen.zig index d4744e0fd0921de6aac44c859c9f9363ef37d677..c34e91bd96b0390cb063cf9bcd22261a364f2df1 100644 --- a/src/codegen/sparc64/CodeGen.zig +++ b/src/codegen/sparc64/CodeGen.zig @@ -545,7 +545,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { .cmp_gt => try self.airCmp(inst, .gt), .cmp_neq => try self.airCmp(inst, .neq), .cmp_vector => @panic("TODO try self.airCmpVector(inst)"), - .cmp_lt_errors_len => try self.airCmpLtErrorsLen(inst), + .cmp_lte_errors_len => try self.airCmpLteErrorsLen(inst), .alloc => try self.airAlloc(inst), .ret_ptr => try self.airRetPtr(inst), @@ -1425,11 +1425,11 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void { return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none }); } -fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void { +fn airCmpLteErrorsLen(self: *Self, inst: Air.Inst.Index) !void { const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; const operand = try self.resolveInst(un_op); _ = operand; - const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airCmpLtErrorsLen for {}", .{self.target.cpu.arch}); + const result: MCValue = if (self.liveness.isUnused(inst)) .dead else return self.fail("TODO implement airCmpLteErrorsLen for {}", .{self.target.cpu.arch}); return self.finishAir(inst, result, .{ un_op, .none, .none }); } diff --git a/src/codegen/wasm/CodeGen.zig b/src/codegen/wasm/CodeGen.zig index 83049921ef7f6d4dca1cef1208266fb3f578118d..c968cbf322978d098059f0ae5863166597ff26bd 100644 --- a/src/codegen/wasm/CodeGen.zig +++ b/src/codegen/wasm/CodeGen.zig @@ -1718,7 +1718,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { .cmp_neq => cg.airCmp(inst, .neq), .cmp_vector => cg.airCmpVector(inst), - .cmp_lt_errors_len => cg.airCmpLtErrorsLen(inst), + .cmp_lte_errors_len => cg.airCmpLteErrorsLen(inst), .array_elem_val => cg.airArrayElemVal(inst), .array_to_slice => cg.airArrayToSlice(inst), @@ -4841,7 +4841,7 @@ fn airCmpVector(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { return cg.fail("TODO implement airCmpVector for wasm", .{}); } -fn airCmpLtErrorsLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { +fn airCmpLteErrorsLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op; const operand = try cg.resolveInst(un_op); diff --git a/src/codegen/x86_64/CodeGen.zig b/src/codegen/x86_64/CodeGen.zig index 69e6a94f08684905a47417c66a6518d544cdbbe7..48101500be89eab157b802c326970a99ca43ef7a 100644 --- a/src/codegen/x86_64/CodeGen.zig +++ b/src/codegen/x86_64/CodeGen.zig @@ -172921,7 +172921,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { try ops[0].finish(inst, &.{field_parent_ptr.field_ptr}, &ops, cg); }, .wasm_memory_size, .wasm_memory_grow => unreachable, - .cmp_lt_errors_len => |air_tag| { + .cmp_lte_errors_len => |air_tag| { const un_op = air_datas[@intFromEnum(inst)].un_op; var ops = try cg.tempsFromOperands(inst, .{un_op}); var res: [1]Temp = undefined;