From 7b978bf1e05727f15fc83ae7d2455c08833cc439 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Wed, 5 Oct 2022 05:34:52 -0700 Subject: stage2: Rename `Value.compare` to `compareAll`, etc. These functions have a very error-prone API. They are essentially `all(cmp(op, ...))` but that's not reflected in the name. This renames these functions to `compareAllAgainstZero...` etc. for clarity and fixes >20 locations where the predicate was incorrect. In the future, the scalar `compare` should probably be split off from the vector comparison. Rank-polymorphic programming is great, but a proper implementation in Zig would decouple comparison and reduction, which then needs a way to fuse ops at comptime. --- src/type.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/type.zig') diff --git a/src/type.zig b/src/type.zig index 12c969eaec..f24c89ef6f 100644 --- a/src/type.zig +++ b/src/type.zig @@ -5463,13 +5463,13 @@ pub const Type = extern union { } const S = struct { fn fieldWithRange(int_ty: Type, int_val: Value, end: usize, m: *Module) ?usize { - if (int_val.compareWithZero(.lt)) return null; + if (int_val.compareAllWithZero(.lt)) return null; var end_payload: Value.Payload.U64 = .{ .base = .{ .tag = .int_u64 }, .data = end, }; const end_val = Value.initPayload(&end_payload.base); - if (int_val.compare(.gte, end_val, int_ty, m)) return null; + if (int_val.compareAll(.gte, end_val, int_ty, m)) return null; return @intCast(usize, int_val.toUnsignedInt(m.getTarget())); } }; @@ -6455,12 +6455,12 @@ pub const Type = extern union { if (!d.mutable and d.pointee_type.eql(Type.u8, mod)) { switch (d.size) { .Slice => { - if (sent.compareWithZero(.eq)) { + if (sent.compareAllWithZero(.eq)) { return Type.initTag(.const_slice_u8_sentinel_0); } }, .Many => { - if (sent.compareWithZero(.eq)) { + if (sent.compareAllWithZero(.eq)) { return Type.initTag(.manyptr_const_u8_sentinel_0); } }, -- cgit v1.2.3