Revert "implement @expect builtin (#19658)"

This reverts commit a7de02e052.

This did not implement the accepted proposal, and I did not sign off
on the changes. I would like a chance to review this, please.
This commit is contained in:
Andrew Kelley
2024-05-22 09:57:43 -07:00
parent a7de02e052
commit 9be8a9000f
25 changed files with 1 additions and 202 deletions

View File

@@ -3343,8 +3343,6 @@ fn genBodyInner(f: *Function, body: []const Air.Inst.Index) error{ AnalysisFail,
.@"try" => try airTry(f, inst),
.try_ptr => try airTryPtr(f, inst),
.expect => try airExpect(f, inst),
.dbg_stmt => try airDbgStmt(f, inst),
.dbg_inline_block => try airDbgInlineBlock(f, inst),
@@ -4706,27 +4704,6 @@ fn airTryPtr(f: *Function, inst: Air.Inst.Index) !CValue {
return lowerTry(f, inst, extra.data.ptr, body, err_union_ty, true);
}
fn airExpect(f: *Function, inst: Air.Inst.Index) !CValue {
const bin_op = f.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
const operand = try f.resolveInst(bin_op.lhs);
const expected = try f.resolveInst(bin_op.rhs);
const writer = f.object.writer();
const local = try f.allocLocal(inst, Type.bool);
const a = try Assignment.start(f, writer, CType.bool);
try f.writeCValue(writer, local, .Other);
try a.assign(f, writer);
try writer.writeAll("zig_expect(");
try f.writeCValue(writer, operand, .FunctionArgument);
try writer.writeAll(", ");
try f.writeCValue(writer, expected, .FunctionArgument);
try writer.writeAll(")");
try a.end(f, writer);
return local;
}
fn lowerTry(
f: *Function,
inst: Air.Inst.Index,

View File

@@ -5038,8 +5038,6 @@ pub const FuncGen = struct {
.slice_ptr => try self.airSliceField(inst, 0),
.slice_len => try self.airSliceField(inst, 1),
.expect => try self.airExpect(inst),
.call => try self.airCall(inst, .auto),
.call_always_tail => try self.airCall(inst, .always_tail),
.call_never_tail => try self.airCall(inst, .never_tail),
@@ -6367,26 +6365,6 @@ pub const FuncGen = struct {
return result;
}
// Note that the LowerExpectPass only runs in Release modes
fn airExpect(self: *FuncGen, inst: Air.Inst.Index) !Builder.Value {
const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
const operand = try self.resolveInst(bin_op.lhs);
const expected = try self.resolveInst(bin_op.rhs);
return try self.wip.callIntrinsic(
.normal,
.none,
.expect,
&.{operand.typeOfWip(&self.wip)},
&.{
operand,
expected,
},
"",
);
}
fn sliceOrArrayPtr(fg: *FuncGen, ptr: Builder.Value, ty: Type) Allocator.Error!Builder.Value {
const o = fg.dg.object;
const mod = o.module;