| author | |
| committer | |
| log | fb224178aaeeb5d8e37392f5c168afca771147ca |
| tree | 0c69accaff106cf7801feba1ea6905a221ac6d37 |
| parent | c0f3a238314315a1e4a578b23cc66237eac90689 |
| signature |
13 files changed, 24 insertions(+), 26 deletions(-)
src/Air.zig+3-4| ... | ... | @@ -874,7 +874,6 @@ pub const Inst = struct { |
| 874 | 874 | /// size as the error integer type, is less than *or equal to* the total |
| 875 | 875 | /// number of errors in the Zcu. The "or equal to" is a consequence of |
| 876 | 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 | 878 | /// This instruction exists (as opposed to just using `cmp_lte` against |
| 880 | 879 | /// a constant) because the number of errors in the Zcu is not known |
| ... | ... | @@ -884,7 +883,7 @@ pub const Inst = struct { |
| 884 | 883 | /// Result type is always `bool`. |
| 885 | 884 | /// |
| 886 | 885 | /// Uses the `un_op` field. |
| 887 | cmp_lt_errors_len, | |
| 886 | cmp_lte_errors_len, | |
| 888 | 887 | |
| 889 | 888 | /// Returns pointer to current error return trace. |
| 890 | 889 | err_return_trace, |
| ... | ... | @@ -1623,7 +1622,7 @@ pub fn typeOfIndex(air: *const Air, inst: Air.Inst.Index, ip: *const InternPool) |
| 1623 | 1622 | .cmp_gte_optimized, |
| 1624 | 1623 | .cmp_gt_optimized, |
| 1625 | 1624 | .cmp_neq_optimized, |
| 1626 | .cmp_lt_errors_len, | |
| 1625 | .cmp_lte_errors_len, | |
| 1627 | 1626 | .is_null, |
| 1628 | 1627 | .is_non_null, |
| 1629 | 1628 | .is_null_ptr, |
| ... | ... | @@ -2059,7 +2058,7 @@ pub fn mustLower(air: Air, inst: Air.Inst.Index, ip: *const InternPool) bool { |
| 2059 | 2058 | .mul_add, |
| 2060 | 2059 | .field_parent_ptr, |
| 2061 | 2060 | .wasm_memory_size, |
| 2062 | .cmp_lt_errors_len, | |
| 2061 | .cmp_lte_errors_len, | |
| 2063 | 2062 | .err_return_trace, |
| 2064 | 2063 | .addrspace_cast, |
| 2065 | 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 | 884 | .field_parent_ptr, |
| 885 | 885 | .wasm_memory_size, |
| 886 | 886 | .wasm_memory_grow, |
| 887 | .cmp_lt_errors_len, | |
| 887 | .cmp_lte_errors_len, | |
| 888 | 888 | .err_return_trace, |
| 889 | 889 | .set_err_return_trace, |
| 890 | 890 | .addrspace_cast, |
src/Air/Liveness.zig+1-1| ... | ... | @@ -565,7 +565,7 @@ fn analyzeInst( |
| 565 | 565 | .trunc_float, |
| 566 | 566 | .neg, |
| 567 | 567 | .neg_optimized, |
| 568 | .cmp_lt_errors_len, | |
| 568 | .cmp_lte_errors_len, | |
| 569 | 569 | .set_err_return_trace, |
| 570 | 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 | 152 | .trunc_float, |
| 153 | 153 | .neg, |
| 154 | 154 | .neg_optimized, |
| 155 | .cmp_lt_errors_len, | |
| 155 | .cmp_lte_errors_len, | |
| 156 | 156 | .set_err_return_trace, |
| 157 | 157 | .c_va_end, |
| 158 | 158 | => { |
src/Air/print.zig+1-1| ... | ... | @@ -211,7 +211,7 @@ const Writer = struct { |
| 211 | 211 | .trunc_float, |
| 212 | 212 | .neg, |
| 213 | 213 | .neg_optimized, |
| 214 | .cmp_lt_errors_len, | |
| 214 | .cmp_lte_errors_len, | |
| 215 | 215 | .set_err_return_trace, |
| 216 | 216 | .c_va_end, |
| 217 | 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 | 7832 | } |
| 7833 | 7833 | try sema.requireRuntimeBlock(block, src, operand_src); |
| 7834 | 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 | 7836 | const zero_val = Air.internedToRef((try pt.intValue(err_int_ty, 0)).toIntern()); |
| 7837 | 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 | 7839 | try sema.addSafetyCheck(block, src, ok, .invalid_error_code); |
| 7840 | 7840 | } |
| 7841 | 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 | 522 | .is_named_enum_value, |
| 523 | 523 | .tag_name, |
| 524 | 524 | .error_name, |
| 525 | .cmp_lt_errors_len, | |
| 525 | .cmp_lte_errors_len, | |
| 526 | 526 | => { |
| 527 | 527 | const un_op = air_data[@intFromEnum(air_inst_index)].un_op; |
| 528 | 528 | |
| ... | ... | @@ -7175,7 +7175,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory, |
| 7175 | 7175 | if (air.next()) |next_air_tag| continue :air_tag next_air_tag; |
| 7176 | 7176 | }, |
| 7177 | 7177 | .wasm_memory_size, .wasm_memory_grow => unreachable, |
| 7178 | .cmp_lt_errors_len => { | |
| 7178 | .cmp_lte_errors_len => { | |
| 7179 | 7179 | if (isel.live_values.fetchRemove(air.inst_index)) |is_vi| unused: { |
| 7180 | 7180 | defer is_vi.value.deref(isel); |
| 7181 | 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 | 2722 | const extra = f.air.extraData(Air.VectorCmp, ty_pl.payload).data; |
| 2723 | 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), | |
| 2726 | 2726 | |
| 2727 | 2727 | // bool_and and bool_or are non-short-circuit operations |
| 2728 | 2728 | .bool_and, .bit_and => try airBinOp(f, inst, "&", "and", .none), |
| ... | ... | @@ -3728,7 +3728,7 @@ fn airEquality( |
| 3728 | 3728 | return local; |
| 3729 | 3729 | } |
| 3730 | 3730 | |
| 3731 | fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue { | |
| 3731 | fn airCmpLteErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue { | |
| 3732 | 3732 | const un_op = f.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 3733 | 3733 | |
| 3734 | 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 | 302 | |
| 303 | 303 | .cmp_vector => try self.airCmpVector(inst, .normal), |
| 304 | 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), | |
| 306 | 306 | |
| 307 | 307 | .is_non_null => try self.airIsNonNull(inst, false, .ne), |
| 308 | 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 | 1105 | return self.cmp(fast, cmp_op, vec_ty, lhs, rhs); |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { | |
| 1108 | fn airCmpLteErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { | |
| 1109 | 1109 | const o = self.object; |
| 1110 | 1110 | const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 1111 | 1111 | const operand = try self.resolveInst(un_op); |
| ... | ... | @@ -1117,7 +1117,6 @@ fn airCmpLtErrorsLen(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Build |
| 1117 | 1117 | Type.errorAbiAlignment(o.zcu).toLlvm(), |
| 1118 | 1118 | "", |
| 1119 | 1119 | ); |
| 1120 | // Despite the name, this instruction is actually lte. MLUGG TODO RENAME | |
| 1121 | 1120 | return self.wip.icmp(.ule, operand, errors_len_val, ""); |
| 1122 | 1121 | } |
| 1123 | 1122 |
src/codegen/riscv64/CodeGen.zig+3-3| ... | ... | @@ -1477,7 +1477,7 @@ fn genBody(func: *Func, body: []const Air.Inst.Index) InnerError!void { |
| 1477 | 1477 | => try func.airCmp(inst, tag), |
| 1478 | 1478 | |
| 1479 | 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), | |
| 1481 | 1481 | |
| 1482 | 1482 | .slice => try func.airSlice(inst), |
| 1483 | 1483 | .array_to_slice => try func.airArrayToSlice(inst), |
| ... | ... | @@ -5186,11 +5186,11 @@ fn airCmpVector(func: *Func, inst: Air.Inst.Index) !void { |
| 5186 | 5186 | return func.fail("TODO implement airCmpVector for {}", .{func.target.cpu.arch}); |
| 5187 | 5187 | } |
| 5188 | 5188 | |
| 5189 | fn airCmpLtErrorsLen(func: *Func, inst: Air.Inst.Index) !void { | |
| 5189 | fn airCmpLteErrorsLen(func: *Func, inst: Air.Inst.Index) !void { | |
| 5190 | 5190 | const un_op = func.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 5191 | 5191 | const operand = try func.resolveInst(un_op); |
| 5192 | 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 | 5194 | return func.finishAir(inst, result, .{ un_op, .none, .none }); |
| 5195 | 5195 | } |
| 5196 | 5196 |
src/codegen/sparc64/CodeGen.zig+3-3| ... | ... | @@ -545,7 +545,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 545 | 545 | .cmp_gt => try self.airCmp(inst, .gt), |
| 546 | 546 | .cmp_neq => try self.airCmp(inst, .neq), |
| 547 | 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), | |
| 549 | 549 | |
| 550 | 550 | .alloc => try self.airAlloc(inst), |
| 551 | 551 | .ret_ptr => try self.airRetPtr(inst), |
| ... | ... | @@ -1425,11 +1425,11 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void { |
| 1425 | 1425 | return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none }); |
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | fn airCmpLtErrorsLen(self: *Self, inst: Air.Inst.Index) !void { | |
| 1428 | fn airCmpLteErrorsLen(self: *Self, inst: Air.Inst.Index) !void { | |
| 1429 | 1429 | const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 1430 | 1430 | const operand = try self.resolveInst(un_op); |
| 1431 | 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 | 1433 | return self.finishAir(inst, result, .{ un_op, .none, .none }); |
| 1434 | 1434 | } |
| 1435 | 1435 |
src/codegen/wasm/CodeGen.zig+2-2| ... | ... | @@ -1718,7 +1718,7 @@ fn genInst(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 1718 | 1718 | .cmp_neq => cg.airCmp(inst, .neq), |
| 1719 | 1719 | |
| 1720 | 1720 | .cmp_vector => cg.airCmpVector(inst), |
| 1721 | .cmp_lt_errors_len => cg.airCmpLtErrorsLen(inst), | |
| 1721 | .cmp_lte_errors_len => cg.airCmpLteErrorsLen(inst), | |
| 1722 | 1722 | |
| 1723 | 1723 | .array_elem_val => cg.airArrayElemVal(inst), |
| 1724 | 1724 | .array_to_slice => cg.airArrayToSlice(inst), |
| ... | ... | @@ -4841,7 +4841,7 @@ fn airCmpVector(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4841 | 4841 | return cg.fail("TODO implement airCmpVector for wasm", .{}); |
| 4842 | 4842 | } |
| 4843 | 4843 | |
| 4844 | fn airCmpLtErrorsLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | |
| 4844 | fn airCmpLteErrorsLen(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | |
| 4845 | 4845 | const un_op = cg.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 4846 | 4846 | const operand = try cg.resolveInst(un_op); |
| 4847 | 4847 |
src/codegen/x86_64/CodeGen.zig+1-1| ... | ... | @@ -172921,7 +172921,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 172921 | 172921 | try ops[0].finish(inst, &.{field_parent_ptr.field_ptr}, &ops, cg); |
| 172922 | 172922 | }, |
| 172923 | 172923 | .wasm_memory_size, .wasm_memory_grow => unreachable, |
| 172924 | .cmp_lt_errors_len => |air_tag| { | |
| 172924 | .cmp_lte_errors_len => |air_tag| { | |
| 172925 | 172925 | const un_op = air_datas[@intFromEnum(inst)].un_op; |
| 172926 | 172926 | var ops = try cg.tempsFromOperands(inst, .{un_op}); |
| 172927 | 172927 | var res: [1]Temp = undefined; |