aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-20 15:50:56 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:47:53 -0700
commitdfb3521160eb4397b7482de68796d370230a8d11 (patch)
treef40c8351fec5f2a71e76d402a4d37fdc57f5858e /src
parent115c08956278b79c848e04c2f4eefca40e6cd8a3 (diff)
downloadzig-dfb3521160eb4397b7482de68796d370230a8d11.tar.gz
zig-dfb3521160eb4397b7482de68796d370230a8d11.zip
compiler: remove var_args_param_type from SimpleType
This is now represented instead by a special `InternPool.Index.Tag` that has no corresponding type/value.
Diffstat (limited to 'src')
-rw-r--r--src/Air.zig4
-rw-r--r--src/InternPool.zig7
-rw-r--r--src/Sema.zig7
-rw-r--r--src/Zir.zig4
-rw-r--r--src/type.zig10
5 files changed, 10 insertions, 22 deletions
diff --git a/src/Air.zig b/src/Air.zig
index 6673a37fb6..9c1b499763 100644
--- a/src/Air.zig
+++ b/src/Air.zig
@@ -905,7 +905,6 @@ pub const Inst = struct {
const_slice_u8_sentinel_0_type = @enumToInt(InternPool.Index.const_slice_u8_sentinel_0_type),
anyerror_void_error_union_type = @enumToInt(InternPool.Index.anyerror_void_error_union_type),
generic_poison_type = @enumToInt(InternPool.Index.generic_poison_type),
- var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
empty_struct_type = @enumToInt(InternPool.Index.empty_struct_type),
undef = @enumToInt(InternPool.Index.undef),
zero = @enumToInt(InternPool.Index.zero),
@@ -927,6 +926,9 @@ pub const Inst = struct {
generic_poison = @enumToInt(InternPool.Index.generic_poison),
/// This Ref does not correspond to any AIR instruction or constant
+ /// value. It is used to handle argument types of var args functions.
+ var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
+ /// This Ref does not correspond to any AIR instruction or constant
/// value and may instead be used as a sentinel to indicate null.
none = @enumToInt(InternPool.Index.none),
_,
diff --git a/src/InternPool.zig b/src/InternPool.zig
index 8b826458a8..130bcc1cad 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -959,7 +959,6 @@ pub const Index = enum(u32) {
const_slice_u8_sentinel_0_type,
anyerror_void_error_union_type,
generic_poison_type,
- var_args_param_type,
/// `@TypeOf(.{})`
empty_struct_type,
@@ -1002,6 +1001,8 @@ pub const Index = enum(u32) {
/// is not known until generic function instantiation.
generic_poison,
+ /// Used by Air/Sema only.
+ var_args_param_type = std.math.maxInt(u32) - 1,
none = std.math.maxInt(u32),
_,
@@ -1195,9 +1196,6 @@ pub const static_keys = [_]Key{
// generic_poison_type
.{ .simple_type = .generic_poison },
- // var_args_param_type
- .{ .simple_type = .var_args_param },
-
// empty_struct_type
.{ .anon_struct_type = .{
.types = &.{},
@@ -1570,7 +1568,6 @@ pub const SimpleType = enum(u32) {
type_info,
generic_poison,
- var_args_param,
};
pub const SimpleValue = enum(u32) {
diff --git a/src/Sema.zig b/src/Sema.zig
index c98c61ddc4..4f0bfd7120 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -31657,7 +31657,6 @@ pub fn resolveTypeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
.anyerror,
.noreturn,
.generic_poison,
- .var_args_param,
.atomic_order,
.atomic_rmw_op,
.calling_convention,
@@ -31856,6 +31855,8 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
const mod = sema.mod;
switch (ty.ip_index) {
+ .var_args_param_type => unreachable,
+
// TODO: After the InternPool transition is complete, change this to `unreachable`.
.none => return ty,
@@ -31909,7 +31910,6 @@ pub fn resolveTypeFields(sema: *Sema, ty: Type) CompileError!Type {
.const_slice_u8_sentinel_0_type,
.anyerror_void_error_union_type,
.generic_poison_type,
- .var_args_param_type,
.empty_struct_type,
=> return ty,
@@ -33123,7 +33123,6 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
.undefined => Value.undef,
.generic_poison => return error.GenericPoison,
- .var_args_param => unreachable,
},
.struct_type => |struct_type| {
const resolved_ty = try sema.resolveTypeFields(ty);
@@ -33678,8 +33677,6 @@ pub fn typeRequiresComptime(sema: *Sema, ty: Type) CompileError!bool {
.enum_literal,
.type_info,
=> true,
-
- .var_args_param => unreachable,
},
.struct_type => |struct_type| {
const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse return false;
diff --git a/src/Zir.zig b/src/Zir.zig
index ec3288620c..7af779c1aa 100644
--- a/src/Zir.zig
+++ b/src/Zir.zig
@@ -2112,7 +2112,6 @@ pub const Inst = struct {
const_slice_u8_sentinel_0_type = @enumToInt(InternPool.Index.const_slice_u8_sentinel_0_type),
anyerror_void_error_union_type = @enumToInt(InternPool.Index.anyerror_void_error_union_type),
generic_poison_type = @enumToInt(InternPool.Index.generic_poison_type),
- var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
empty_struct_type = @enumToInt(InternPool.Index.empty_struct_type),
undef = @enumToInt(InternPool.Index.undef),
zero = @enumToInt(InternPool.Index.zero),
@@ -2133,6 +2132,9 @@ pub const Inst = struct {
empty_struct = @enumToInt(InternPool.Index.empty_struct),
generic_poison = @enumToInt(InternPool.Index.generic_poison),
+ /// This tag is here to match Air and InternPool, however it is unused
+ /// for ZIR purposes.
+ var_args_param_type = @enumToInt(InternPool.Index.var_args_param_type),
/// This Ref does not correspond to any ZIR instruction or constant
/// value and may instead be used as a sentinel to indicate null.
none = @enumToInt(InternPool.Index.none),
diff --git a/src/type.zig b/src/type.zig
index d0cf054845..d1ee185be5 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -105,7 +105,6 @@ pub const Type = struct {
.type_info => .Union,
.generic_poison => return error.GenericPoison,
- .var_args_param => unreachable,
},
// values, not types
@@ -803,7 +802,6 @@ pub const Type = struct {
=> false,
.generic_poison => unreachable,
- .var_args_param => unreachable,
},
.struct_type => |struct_type| {
const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse {
@@ -952,8 +950,6 @@ pub const Type = struct {
.type_info,
.generic_poison,
=> false,
-
- .var_args_param => unreachable,
},
.struct_type => |struct_type| {
const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse {
@@ -1198,7 +1194,6 @@ pub const Type = struct {
.noreturn => unreachable,
.generic_poison => unreachable,
- .var_args_param => unreachable,
},
.struct_type => |struct_type| {
const struct_obj = mod.structPtrUnwrap(struct_type.index) orelse
@@ -1610,7 +1605,6 @@ pub const Type = struct {
.type_info => unreachable,
.noreturn => unreachable,
.generic_poison => unreachable,
- .var_args_param => unreachable,
},
.struct_type => |struct_type| switch (ty.containerLayout(mod)) {
.Packed => {
@@ -1841,7 +1835,6 @@ pub const Type = struct {
.undefined => unreachable,
.enum_literal => unreachable,
.generic_poison => unreachable,
- .var_args_param => unreachable,
.atomic_order => unreachable, // missing call to resolveTypeFields
.atomic_rmw_op => unreachable, // missing call to resolveTypeFields
@@ -2717,7 +2710,6 @@ pub const Type = struct {
.undefined => return Value.undef,
.generic_poison => unreachable,
- .var_args_param => unreachable,
},
.struct_type => |struct_type| {
if (mod.structPtrUnwrap(struct_type.index)) |s| {
@@ -2896,8 +2888,6 @@ pub const Type = struct {
.enum_literal,
.type_info,
=> true,
-
- .var_args_param => unreachable,
},
.struct_type => |struct_type| {
// A struct with no fields is not comptime-only.