| ... | ... | @@ -145,18 +145,6 @@ pub const Inst = struct { |
| 145 | 145 | /// Twos complement wrapping integer addition. |
| 146 | 146 | /// Uses the `pl_node` union field. Payload is `Bin`. |
| 147 | 147 | addwrap, |
| 148 | | /// Allocates stack local memory. |
| 149 | | /// Uses the `un_node` union field. The operand is the type of the allocated object. |
| 150 | | /// The node source location points to a var decl node. |
| 151 | | /// Indicates the beginning of a new statement in debug info. |
| 152 | | alloc, |
| 153 | | /// Same as `alloc` except mutable. |
| 154 | | alloc_mut, |
| 155 | | /// Same as `alloc` except the type is inferred. |
| 156 | | /// Uses the `node` union field. |
| 157 | | alloc_inferred, |
| 158 | | /// Same as `alloc_inferred` except mutable. |
| 159 | | alloc_inferred_mut, |
| 160 | 148 | /// Array concatenation. `a ++ b` |
| 161 | 149 | /// Uses the `pl_node` union field. Payload is `Bin`. |
| 162 | 150 | array_cat, |
| ... | ... | @@ -483,12 +471,6 @@ pub const Inst = struct { |
| 483 | 471 | /// Create a pointer type which can have a sentinel, alignment, and/or bit range. |
| 484 | 472 | /// Uses the `ptr_type` union field. |
| 485 | 473 | ptr_type, |
| 486 | | /// Each `store_to_inferred_ptr` puts the type of the stored value into a set, |
| 487 | | /// and then `resolve_inferred_alloc` triggers peer type resolution on the set. |
| 488 | | /// The operand is a `alloc_inferred` or `alloc_inferred_mut` instruction, which |
| 489 | | /// is the allocation that needs to have its type inferred. |
| 490 | | /// Uses the `un_node` field. The AST node is the var decl. |
| 491 | | resolve_inferred_alloc, |
| 492 | 474 | /// Slice operation `lhs[rhs..]`. No sentinel and no end offset. |
| 493 | 475 | /// Uses the `pl_node` field. AST node is the slice syntax. Payload is `SliceStart`. |
| 494 | 476 | slice_start, |
| ... | ... | @@ -613,37 +595,40 @@ pub const Inst = struct { |
| 613 | 595 | ensure_err_payload_void, |
| 614 | 596 | /// An enum literal. Uses the `str_tok` union field. |
| 615 | 597 | enum_literal, |
| 616 | | /// An enum literal 8 or fewer bytes. No source location. |
| 617 | | /// Uses the `small_str` field. |
| 618 | | enum_literal_small, |
| 619 | 598 | /// A switch expression. Uses the `pl_node` union field. |
| 620 | 599 | /// AST node is the switch, payload is `SwitchBlock`. |
| 621 | 600 | /// All prongs of target handled. |
| 622 | 601 | switch_block, |
| 623 | 602 | /// Same as switch_block, except one or more prongs have multiple items. |
| 603 | /// Payload is `SwitchBlockMulti` |
| 624 | 604 | switch_block_multi, |
| 625 | 605 | /// Same as switch_block, except has an else prong. |
| 626 | 606 | switch_block_else, |
| 627 | 607 | /// Same as switch_block_else, except one or more prongs have multiple items. |
| 608 | /// Payload is `SwitchBlockMulti` |
| 628 | 609 | switch_block_else_multi, |
| 629 | 610 | /// Same as switch_block, except has an underscore prong. |
| 630 | 611 | switch_block_under, |
| 631 | 612 | /// Same as switch_block, except one or more prongs have multiple items. |
| 613 | /// Payload is `SwitchBlockMulti` |
| 632 | 614 | switch_block_under_multi, |
| 633 | 615 | /// Same as `switch_block` but the target is a pointer to the value being switched on. |
| 634 | 616 | switch_block_ref, |
| 635 | 617 | /// Same as `switch_block_multi` but the target is a pointer to the value being switched on. |
| 618 | /// Payload is `SwitchBlockMulti` |
| 636 | 619 | switch_block_ref_multi, |
| 637 | 620 | /// Same as `switch_block_else` but the target is a pointer to the value being switched on. |
| 638 | 621 | switch_block_ref_else, |
| 639 | 622 | /// Same as `switch_block_else_multi` but the target is a pointer to the |
| 640 | 623 | /// value being switched on. |
| 624 | /// Payload is `SwitchBlockMulti` |
| 641 | 625 | switch_block_ref_else_multi, |
| 642 | 626 | /// Same as `switch_block_under` but the target is a pointer to the value |
| 643 | 627 | /// being switched on. |
| 644 | 628 | switch_block_ref_under, |
| 645 | 629 | /// Same as `switch_block_under_multi` but the target is a pointer to |
| 646 | 630 | /// the value being switched on. |
| 631 | /// Payload is `SwitchBlockMulti` |
| 647 | 632 | switch_block_ref_under_multi, |
| 648 | 633 | /// Produces the capture value for a switch prong. |
| 649 | 634 | /// Uses the `switch_capture` field. |
| ... | ... | @@ -937,6 +922,32 @@ pub const Inst = struct { |
| 937 | 922 | /// Implements the `@cImport` builtin. |
| 938 | 923 | /// Uses the `pl_node` union field with payload `Block`. |
| 939 | 924 | c_import, |
| 925 | |
| 926 | /// Allocates stack local memory. |
| 927 | /// Uses the `un_node` union field. The operand is the type of the allocated object. |
| 928 | /// The node source location points to a var decl node. |
| 929 | /// Indicates the beginning of a new statement in debug info. |
| 930 | alloc, |
| 931 | /// Same as `alloc` except mutable. |
| 932 | alloc_mut, |
| 933 | /// Allocates comptime-mutable memory. |
| 934 | /// Uses the `un_node` union field. The operand is the type of the allocated object. |
| 935 | /// The node source location points to a var decl node. |
| 936 | alloc_comptime, |
| 937 | /// Same as `alloc` except the type is inferred. |
| 938 | /// Uses the `node` union field. |
| 939 | alloc_inferred, |
| 940 | /// Same as `alloc_inferred` except mutable. |
| 941 | alloc_inferred_mut, |
| 942 | /// Same as `alloc_comptime` except the type is inferred. |
| 943 | alloc_inferred_comptime, |
| 944 | /// Each `store_to_inferred_ptr` puts the type of the stored value into a set, |
| 945 | /// and then `resolve_inferred_alloc` triggers peer type resolution on the set. |
| 946 | /// The operand is a `alloc_inferred` or `alloc_inferred_mut` instruction, which |
| 947 | /// is the allocation that needs to have its type inferred. |
| 948 | /// Uses the `un_node` field. The AST node is the var decl. |
| 949 | resolve_inferred_alloc, |
| 950 | |
| 940 | 951 | /// The ZIR instruction tag is one of the `Extended` ones. |
| 941 | 952 | /// Uses the `extended` union field. |
| 942 | 953 | extended, |
| ... | ... | @@ -949,8 +960,10 @@ pub const Inst = struct { |
| 949 | 960 | .addwrap, |
| 950 | 961 | .alloc, |
| 951 | 962 | .alloc_mut, |
| 963 | .alloc_comptime, |
| 952 | 964 | .alloc_inferred, |
| 953 | 965 | .alloc_inferred_mut, |
| 966 | .alloc_inferred_comptime, |
| 954 | 967 | .array_cat, |
| 955 | 968 | .array_mul, |
| 956 | 969 | .array_type, |
| ... | ... | @@ -1066,7 +1079,6 @@ pub const Inst = struct { |
| 1066 | 1079 | .ptr_type_simple, |
| 1067 | 1080 | .ensure_err_payload_void, |
| 1068 | 1081 | .enum_literal, |
| 1069 | | .enum_literal_small, |
| 1070 | 1082 | .merge_error_sets, |
| 1071 | 1083 | .error_union_type, |
| 1072 | 1084 | .bit_not, |
| ... | ... | @@ -2251,6 +2263,7 @@ const Writer = struct { |
| 2251 | 2263 | |
| 2252 | 2264 | .alloc, |
| 2253 | 2265 | .alloc_mut, |
| 2266 | .alloc_comptime, |
| 2254 | 2267 | .indexable_ptr_len, |
| 2255 | 2268 | .bit_not, |
| 2256 | 2269 | .bool_not, |
| ... | ... | @@ -2516,6 +2529,7 @@ const Writer = struct { |
| 2516 | 2529 | .repeat_inline, |
| 2517 | 2530 | .alloc_inferred, |
| 2518 | 2531 | .alloc_inferred_mut, |
| 2532 | .alloc_inferred_comptime, |
| 2519 | 2533 | => try self.writeNode(stream, inst), |
| 2520 | 2534 | |
| 2521 | 2535 | .error_value, |
| ... | ... | @@ -2530,8 +2544,6 @@ const Writer = struct { |
| 2530 | 2544 | |
| 2531 | 2545 | .@"unreachable" => try self.writeUnreachable(stream, inst), |
| 2532 | 2546 | |
| 2533 | | .enum_literal_small => try self.writeSmallStr(stream, inst), |
| 2534 | | |
| 2535 | 2547 | .switch_capture, |
| 2536 | 2548 | .switch_capture_ref, |
| 2537 | 2549 | .switch_capture_multi, |
| ... | ... | @@ -3442,15 +3454,6 @@ const Writer = struct { |
| 3442 | 3454 | try self.writeSrc(stream, src); |
| 3443 | 3455 | } |
| 3444 | 3456 | |
| 3445 | | fn writeSmallStr( |
| 3446 | | self: *Writer, |
| 3447 | | stream: anytype, |
| 3448 | | inst: Inst.Index, |
| 3449 | | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { |
| 3450 | | const str = self.code.instructions.items(.data)[inst].small_str.get(); |
| 3451 | | try stream.print("\"{}\")", .{std.zig.fmtEscapes(str)}); |
| 3452 | | } |
| 3453 | | |
| 3454 | 3457 | fn writeSwitchCapture(self: *Writer, stream: anytype, inst: Inst.Index) !void { |
| 3455 | 3458 | const inst_data = self.code.instructions.items(.data)[inst].switch_capture; |
| 3456 | 3459 | try self.writeInstIndex(stream, inst_data.switch_inst); |