implement packed struct equality (#21679)

This commit is contained in:
David Rubin
2024-10-12 20:59:12 -07:00
committed by GitHub
parent ba1331090c
commit e131a2c8e2
7 changed files with 93 additions and 1 deletions

View File

@@ -6032,6 +6032,7 @@ pub const FuncGen = struct {
const o = self.ng.object;
const pt = o.pt;
const zcu = pt.zcu;
const ip = &zcu.intern_pool;
const scalar_ty = operand_ty.scalarType(zcu);
const int_ty = switch (scalar_ty.zigTypeTag(zcu)) {
.@"enum" => scalar_ty.intTagType(zcu),
@@ -6110,6 +6111,12 @@ pub const FuncGen = struct {
return phi.toValue();
},
.float => return self.buildFloatCmp(fast, op, operand_ty, .{ lhs, rhs }),
.@"struct" => blk: {
const struct_obj = ip.loadStructType(scalar_ty.toIntern());
assert(struct_obj.layout == .@"packed");
const backing_index = struct_obj.backingIntTypeUnordered(ip);
break :blk Type.fromInterned(backing_index);
},
else => unreachable,
};
const is_signed = int_ty.isSignedInt(zcu);