From b40a8efb9a72e69cd7e9061fc4c08d5e705b0fbd Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 23 Apr 2021 18:28:46 -0700 Subject: stage2: implement `anyframe`, `anyframe->T` and fix assembly * AstGen: implement `anyframe_literal` and `anyframe_type`. * Introduce `makeSubBlock` to avoid redundant AstGen code for GenZir scopes. Allows adding/removing a field without possibility of accidentally introducing a bug of forgetting to set the new field. * Add to GenZir `nosuspend_node` and `suspend_node` in preparation for implementing `suspend` blocks and `nosuspend` blocks. * AstGen: fix assembly to support clobbers, multiple outputs, and outputs without `->` syntax. - `asm` and `asm_volatile` move to `Extended` enum with `small` being repurposed for a few things. This frees up 2 ZIR tags, 1 of which is used in this commit and 1 is leftover. * AstGen: fix `simple_types` incorrectly having multiple conflicting values for "undefined" and "null". - Also add "anyframe" to `simple_types`. * Add `anyframe_type` to type.zig, value.zig and `Zir.Inst.Ref`. - Also add i128 and u128 types to `Zir.Inst.Ref` and `simple_types`. * Sema/Zir: Fix incorrect math causing the function body to be messed up for Extended-encoded functions. * Zir: support `i32` fields for "extra" payloads. --- src/value.zig | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/value.zig') diff --git a/src/value.zig b/src/value.zig index e1ca79332c..d2d7be3007 100644 --- a/src/value.zig +++ b/src/value.zig @@ -55,17 +55,10 @@ pub const Value = extern union { comptime_int_type, comptime_float_type, noreturn_type, + anyframe_type, null_type, undefined_type, - fn_noreturn_no_args_type, - fn_void_no_args_type, - fn_naked_noreturn_no_args_type, - fn_ccc_void_no_args_type, - single_const_pointer_to_comptime_int_type, - const_slice_u8_type, enum_literal_type, - manyptr_u8_type, - manyptr_const_u8_type, atomic_ordering_type, atomic_rmw_op_type, calling_convention_type, @@ -74,6 +67,14 @@ pub const Value = extern union { call_options_type, export_options_type, extern_options_type, + manyptr_u8_type, + manyptr_const_u8_type, + fn_noreturn_no_args_type, + fn_void_no_args_type, + fn_naked_noreturn_no_args_type, + fn_ccc_void_no_args_type, + single_const_pointer_to_comptime_int_type, + const_slice_u8_type, undef, zero, @@ -166,6 +167,7 @@ pub const Value = extern union { .fn_naked_noreturn_no_args_type, .fn_ccc_void_no_args_type, .single_const_pointer_to_comptime_int_type, + .anyframe_type, .const_slice_u8_type, .enum_literal_type, .undef, @@ -334,6 +336,7 @@ pub const Value = extern union { .fn_naked_noreturn_no_args_type, .fn_ccc_void_no_args_type, .single_const_pointer_to_comptime_int_type, + .anyframe_type, .const_slice_u8_type, .enum_literal_type, .undef, @@ -502,6 +505,7 @@ pub const Value = extern union { .fn_naked_noreturn_no_args_type => return out_stream.writeAll("fn() callconv(.Naked) noreturn"), .fn_ccc_void_no_args_type => return out_stream.writeAll("fn() callconv(.C) void"), .single_const_pointer_to_comptime_int_type => return out_stream.writeAll("*const comptime_int"), + .anyframe_type => return out_stream.writeAll("anyframe"), .const_slice_u8_type => return out_stream.writeAll("[]const u8"), .enum_literal_type => return out_stream.writeAll("@Type(.EnumLiteral)"), .manyptr_u8_type => return out_stream.writeAll("[*]u8"), @@ -633,6 +637,7 @@ pub const Value = extern union { .fn_naked_noreturn_no_args_type => Type.initTag(.fn_naked_noreturn_no_args), .fn_ccc_void_no_args_type => Type.initTag(.fn_ccc_void_no_args), .single_const_pointer_to_comptime_int_type => Type.initTag(.single_const_pointer_to_comptime_int), + .anyframe_type => Type.initTag(.@"anyframe"), .const_slice_u8_type => Type.initTag(.const_slice_u8), .enum_literal_type => Type.initTag(.enum_literal), .manyptr_u8_type => Type.initTag(.manyptr_u8), @@ -1070,6 +1075,7 @@ pub const Value = extern union { .fn_naked_noreturn_no_args_type, .fn_ccc_void_no_args_type, .single_const_pointer_to_comptime_int_type, + .anyframe_type, .const_slice_u8_type, .enum_literal_type, .ty, @@ -1338,6 +1344,7 @@ pub const Value = extern union { .fn_naked_noreturn_no_args_type, .fn_ccc_void_no_args_type, .single_const_pointer_to_comptime_int_type, + .anyframe_type, .const_slice_u8_type, .enum_literal_type, .manyptr_u8_type, -- cgit v1.2.3