Legalize: implement scalarization of binary operations
This commit is contained in:
@@ -4579,10 +4579,11 @@ pub const Index = enum(u32) {
|
||||
undefined_type,
|
||||
enum_literal_type,
|
||||
|
||||
ptr_usize_type,
|
||||
ptr_const_comptime_int_type,
|
||||
manyptr_u8_type,
|
||||
manyptr_const_u8_type,
|
||||
manyptr_const_u8_sentinel_0_type,
|
||||
single_const_pointer_to_comptime_int_type,
|
||||
slice_const_u8_type,
|
||||
slice_const_u8_sentinel_0_type,
|
||||
|
||||
@@ -4649,19 +4650,29 @@ pub const Index = enum(u32) {
|
||||
|
||||
/// `undefined` (untyped)
|
||||
undef,
|
||||
/// `@as(bool, undefined)`
|
||||
undef_bool,
|
||||
/// `@as(usize, undefined)`
|
||||
undef_usize,
|
||||
/// `@as(u1, undefined)`
|
||||
undef_u1,
|
||||
/// `0` (comptime_int)
|
||||
zero,
|
||||
/// `0` (usize)
|
||||
/// `@as(usize, 0)`
|
||||
zero_usize,
|
||||
/// `0` (u8)
|
||||
/// `@as(u1, 0)`
|
||||
zero_u1,
|
||||
/// `@as(u8, 0)`
|
||||
zero_u8,
|
||||
/// `1` (comptime_int)
|
||||
one,
|
||||
/// `1` (usize)
|
||||
/// `@as(usize, 1)`
|
||||
one_usize,
|
||||
/// `1` (u8)
|
||||
/// `@as(u1, 1)`
|
||||
one_u1,
|
||||
/// `@as(u8, 1)`
|
||||
one_u8,
|
||||
/// `4` (u8)
|
||||
/// `@as(u8, 4)`
|
||||
four_u8,
|
||||
/// `-1` (comptime_int)
|
||||
negative_one,
|
||||
@@ -5074,6 +5085,20 @@ pub const static_keys: [static_len]Key = .{
|
||||
.{ .simple_type = .undefined },
|
||||
.{ .simple_type = .enum_literal },
|
||||
|
||||
// *usize
|
||||
.{ .ptr_type = .{
|
||||
.child = .usize_type,
|
||||
.flags = .{},
|
||||
} },
|
||||
|
||||
// *const comptime_int
|
||||
.{ .ptr_type = .{
|
||||
.child = .comptime_int_type,
|
||||
.flags = .{
|
||||
.is_const = true,
|
||||
},
|
||||
} },
|
||||
|
||||
// [*]u8
|
||||
.{ .ptr_type = .{
|
||||
.child = .u8_type,
|
||||
@@ -5101,15 +5126,6 @@ pub const static_keys: [static_len]Key = .{
|
||||
},
|
||||
} },
|
||||
|
||||
// *const comptime_int
|
||||
.{ .ptr_type = .{
|
||||
.child = .comptime_int_type,
|
||||
.flags = .{
|
||||
.size = .one,
|
||||
.is_const = true,
|
||||
},
|
||||
} },
|
||||
|
||||
// []const u8
|
||||
.{ .ptr_type = .{
|
||||
.child = .u8_type,
|
||||
@@ -5245,6 +5261,9 @@ pub const static_keys: [static_len]Key = .{
|
||||
} },
|
||||
|
||||
.{ .simple_value = .undefined },
|
||||
.{ .undef = .bool_type },
|
||||
.{ .undef = .usize_type },
|
||||
.{ .undef = .u1_type },
|
||||
|
||||
.{ .int = .{
|
||||
.ty = .comptime_int_type,
|
||||
@@ -5256,6 +5275,11 @@ pub const static_keys: [static_len]Key = .{
|
||||
.storage = .{ .u64 = 0 },
|
||||
} },
|
||||
|
||||
.{ .int = .{
|
||||
.ty = .u1_type,
|
||||
.storage = .{ .u64 = 0 },
|
||||
} },
|
||||
|
||||
.{ .int = .{
|
||||
.ty = .u8_type,
|
||||
.storage = .{ .u64 = 0 },
|
||||
@@ -5271,17 +5295,21 @@ pub const static_keys: [static_len]Key = .{
|
||||
.storage = .{ .u64 = 1 },
|
||||
} },
|
||||
|
||||
// one_u8
|
||||
.{ .int = .{
|
||||
.ty = .u1_type,
|
||||
.storage = .{ .u64 = 1 },
|
||||
} },
|
||||
|
||||
.{ .int = .{
|
||||
.ty = .u8_type,
|
||||
.storage = .{ .u64 = 1 },
|
||||
} },
|
||||
// four_u8
|
||||
|
||||
.{ .int = .{
|
||||
.ty = .u8_type,
|
||||
.storage = .{ .u64 = 4 },
|
||||
} },
|
||||
// negative_one
|
||||
|
||||
.{ .int = .{
|
||||
.ty = .comptime_int_type,
|
||||
.storage = .{ .i64 = -1 },
|
||||
@@ -10482,7 +10510,7 @@ pub fn getCoerced(
|
||||
.base_addr = .int,
|
||||
.byte_offset = 0,
|
||||
} }),
|
||||
.len = try ip.get(gpa, tid, .{ .undef = .usize_type }),
|
||||
.len = .undef_usize,
|
||||
} }),
|
||||
};
|
||||
},
|
||||
@@ -10601,7 +10629,7 @@ pub fn getCoerced(
|
||||
.base_addr = .int,
|
||||
.byte_offset = 0,
|
||||
} }),
|
||||
.len = try ip.get(gpa, tid, .{ .undef = .usize_type }),
|
||||
.len = .undef_usize,
|
||||
} }),
|
||||
},
|
||||
else => |payload| try ip.getCoerced(gpa, tid, payload, new_ty),
|
||||
@@ -11847,10 +11875,11 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
|
||||
.null_type,
|
||||
.undefined_type,
|
||||
.enum_literal_type,
|
||||
.ptr_usize_type,
|
||||
.ptr_const_comptime_int_type,
|
||||
.manyptr_u8_type,
|
||||
.manyptr_const_u8_type,
|
||||
.manyptr_const_u8_sentinel_0_type,
|
||||
.single_const_pointer_to_comptime_int_type,
|
||||
.slice_const_u8_type,
|
||||
.slice_const_u8_sentinel_0_type,
|
||||
.vector_8_i8_type,
|
||||
@@ -11909,12 +11938,13 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
|
||||
|
||||
.undef => .undefined_type,
|
||||
.zero, .one, .negative_one => .comptime_int_type,
|
||||
.zero_usize, .one_usize => .usize_type,
|
||||
.undef_usize, .zero_usize, .one_usize => .usize_type,
|
||||
.undef_u1, .zero_u1, .one_u1 => .u1_type,
|
||||
.zero_u8, .one_u8, .four_u8 => .u8_type,
|
||||
.void_value => .void_type,
|
||||
.unreachable_value => .noreturn_type,
|
||||
.null_value => .null_type,
|
||||
.bool_true, .bool_false => .bool_type,
|
||||
.undef_bool, .bool_true, .bool_false => .bool_type,
|
||||
.empty_tuple => .empty_tuple_type,
|
||||
|
||||
// This optimization on tags is needed so that indexToKey can call
|
||||
@@ -12186,10 +12216,11 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
|
||||
.undefined_type => .undefined,
|
||||
.enum_literal_type => .enum_literal,
|
||||
|
||||
.ptr_usize_type,
|
||||
.ptr_const_comptime_int_type,
|
||||
.manyptr_u8_type,
|
||||
.manyptr_const_u8_type,
|
||||
.manyptr_const_u8_sentinel_0_type,
|
||||
.single_const_pointer_to_comptime_int_type,
|
||||
.slice_const_u8_type,
|
||||
.slice_const_u8_sentinel_0_type,
|
||||
=> .pointer,
|
||||
@@ -12251,11 +12282,16 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
|
||||
|
||||
// values, not types
|
||||
.undef => unreachable,
|
||||
.undef_bool => unreachable,
|
||||
.undef_usize => unreachable,
|
||||
.undef_u1 => unreachable,
|
||||
.zero => unreachable,
|
||||
.zero_usize => unreachable,
|
||||
.zero_u1 => unreachable,
|
||||
.zero_u8 => unreachable,
|
||||
.one => unreachable,
|
||||
.one_usize => unreachable,
|
||||
.one_u1 => unreachable,
|
||||
.one_u8 => unreachable,
|
||||
.four_u8 => unreachable,
|
||||
.negative_one => unreachable,
|
||||
|
||||
Reference in New Issue
Block a user