| ... | @@ -687,15 +687,6 @@ pub const Inst = struct { | ... | @@ -687,15 +687,6 @@ pub const Inst = struct { |
| 687 | /// If the `prong_index` field is max int, it means this is the capture | 687 | /// If the `prong_index` field is max int, it means this is the capture |
| 688 | /// for the else/`_` prong. | 688 | /// for the else/`_` prong. |
| 689 | switch_capture_ref, | 689 | switch_capture_ref, |
| 690 | /// Produces the capture value for a switch prong. | | |
| 691 | /// The prong is one of the multi cases. | | |
| 692 | /// Uses the `switch_capture` field. | | |
| 693 | switch_capture_multi, | | |
| 694 | /// Produces the capture value for a switch prong. | | |
| 695 | /// The prong is one of the multi cases. | | |
| 696 | /// Result is a pointer to the value. | | |
| 697 | /// Uses the `switch_capture` field. | | |
| 698 | switch_capture_multi_ref, | | |
| 699 | /// Produces the capture value for an inline switch prong tag capture. | 690 | /// Produces the capture value for an inline switch prong tag capture. |
| 700 | /// Uses the `un_tok` field. | 691 | /// Uses the `un_tok` field. |
| 701 | switch_capture_tag, | 692 | switch_capture_tag, |
| ... | @@ -1146,8 +1137,6 @@ pub const Inst = struct { | ... | @@ -1146,8 +1137,6 @@ pub const Inst = struct { |
| 1146 | .set_eval_branch_quota, | 1137 | .set_eval_branch_quota, |
| 1147 | .switch_capture, | 1138 | .switch_capture, |
| 1148 | .switch_capture_ref, | 1139 | .switch_capture_ref, |
| 1149 | .switch_capture_multi, | | |
| 1150 | .switch_capture_multi_ref, | | |
| 1151 | .switch_capture_tag, | 1140 | .switch_capture_tag, |
| 1152 | .switch_block, | 1141 | .switch_block, |
| 1153 | .switch_cond, | 1142 | .switch_cond, |
| ... | @@ -1440,8 +1429,6 @@ pub const Inst = struct { | ... | @@ -1440,8 +1429,6 @@ pub const Inst = struct { |
| 1440 | .typeof_log2_int_type, | 1429 | .typeof_log2_int_type, |
| 1441 | .switch_capture, | 1430 | .switch_capture, |
| 1442 | .switch_capture_ref, | 1431 | .switch_capture_ref, |
| 1443 | .switch_capture_multi, | | |
| 1444 | .switch_capture_multi_ref, | | |
| 1445 | .switch_capture_tag, | 1432 | .switch_capture_tag, |
| 1446 | .switch_block, | 1433 | .switch_block, |
| 1447 | .switch_cond, | 1434 | .switch_cond, |
| ... | @@ -1700,8 +1687,6 @@ pub const Inst = struct { | ... | @@ -1700,8 +1687,6 @@ pub const Inst = struct { |
| 1700 | .switch_cond_ref = .un_node, | 1687 | .switch_cond_ref = .un_node, |
| 1701 | .switch_capture = .switch_capture, | 1688 | .switch_capture = .switch_capture, |
| 1702 | .switch_capture_ref = .switch_capture, | 1689 | .switch_capture_ref = .switch_capture, |
| 1703 | .switch_capture_multi = .switch_capture, | | |
| 1704 | .switch_capture_multi_ref = .switch_capture, | | |
| 1705 | .switch_capture_tag = .un_tok, | 1690 | .switch_capture_tag = .un_tok, |
| 1706 | .array_base_ptr = .un_node, | 1691 | .array_base_ptr = .un_node, |
| 1707 | .field_base_ptr = .un_node, | 1692 | .field_base_ptr = .un_node, |
| ... | @@ -2735,8 +2720,8 @@ pub const Inst = struct { | ... | @@ -2735,8 +2720,8 @@ pub const Inst = struct { |
| 2735 | } | 2720 | } |
| 2736 | }; | 2721 | }; |
| 2737 | | 2722 | |
| 2738 | pub const ScalarProng = struct { | 2723 | pub const MultiProng = struct { |
| 2739 | item: Ref, | 2724 | items: []const Ref, |
| 2740 | body: []const Index, | 2725 | body: []const Index, |
| 2741 | }; | 2726 | }; |
| 2742 | | 2727 | |
| ... | @@ -2744,56 +2729,13 @@ pub const Inst = struct { | ... | @@ -2744,56 +2729,13 @@ pub const Inst = struct { |
| 2744 | /// change the definition of switch_capture instruction to store extra_index | 2729 | /// change the definition of switch_capture instruction to store extra_index |
| 2745 | /// instead of prong_index. This way, Sema won't be doing O(N^2) iterations | 2730 | /// instead of prong_index. This way, Sema won't be doing O(N^2) iterations |
| 2746 | /// over the switch prongs. | 2731 | /// over the switch prongs. |
| 2747 | pub fn getScalarProng( | 2732 | pub fn getProng( |
| 2748 | self: SwitchBlock, | | |
| 2749 | zir: Zir, | | |
| 2750 | extra_end: usize, | | |
| 2751 | prong_index: usize, | | |
| 2752 | ) ScalarProng { | | |
| 2753 | var extra_index: usize = extra_end; | | |
| 2754 | | | |
| 2755 | if (self.bits.has_multi_cases) { | | |
| 2756 | extra_index += 1; | | |
| 2757 | } | | |
| 2758 | | | |
| 2759 | if (self.bits.specialProng() != .none) { | | |
| 2760 | const body_len = @truncate(u31, zir.extra[extra_index]); | | |
| 2761 | extra_index += 1; | | |
| 2762 | const body = zir.extra[extra_index..][0..body_len]; | | |
| 2763 | extra_index += body.len; | | |
| 2764 | } | | |
| 2765 | | | |
| 2766 | var scalar_i: usize = 0; | | |
| 2767 | while (true) : (scalar_i += 1) { | | |
| 2768 | const item = @intToEnum(Ref, zir.extra[extra_index]); | | |
| 2769 | extra_index += 1; | | |
| 2770 | const body_len = @truncate(u31, zir.extra[extra_index]); | | |
| 2771 | extra_index += 1; | | |
| 2772 | const body = zir.extra[extra_index..][0..body_len]; | | |
| 2773 | extra_index += body.len; | | |
| 2774 | | | |
| 2775 | if (scalar_i < prong_index) continue; | | |
| 2776 | | | |
| 2777 | return .{ | | |
| 2778 | .item = item, | | |
| 2779 | .body = body, | | |
| 2780 | }; | | |
| 2781 | } | | |
| 2782 | } | | |
| 2783 | | | |
| 2784 | pub const MultiProng = struct { | | |
| 2785 | items: []const Ref, | | |
| 2786 | body: []const Index, | | |
| 2787 | }; | | |
| 2788 | | | |
| 2789 | pub fn getMultiProng( | | |
| 2790 | self: SwitchBlock, | 2733 | self: SwitchBlock, |
| 2791 | zir: Zir, | 2734 | zir: Zir, |
| 2792 | extra_end: usize, | 2735 | extra_end: usize, |
| 2793 | prong_index: usize, | 2736 | prong_index: usize, |
| 2794 | ) MultiProng { | 2737 | ) MultiProng { |
| 2795 | // +1 for self.bits.has_multi_cases == true | 2738 | var extra_index: usize = extra_end + @boolToInt(self.bits.has_multi_cases); |
| 2796 | var extra_index: usize = extra_end + 1; | | |
| 2797 | | 2739 | |
| 2798 | if (self.bits.specialProng() != .none) { | 2740 | if (self.bits.specialProng() != .none) { |
| 2799 | const body_len = @truncate(u31, zir.extra[extra_index]); | 2741 | const body_len = @truncate(u31, zir.extra[extra_index]); |
| ... | @@ -2802,15 +2744,22 @@ pub const Inst = struct { | ... | @@ -2802,15 +2744,22 @@ pub const Inst = struct { |
| 2802 | extra_index += body.len; | 2744 | extra_index += body.len; |
| 2803 | } | 2745 | } |
| 2804 | | 2746 | |
| 2805 | var scalar_i: usize = 0; | 2747 | var cur_idx: usize = 0; |
| 2806 | while (scalar_i < self.bits.scalar_cases_len) : (scalar_i += 1) { | 2748 | while (cur_idx < self.bits.scalar_cases_len) : (cur_idx += 1) { |
| | 2749 | const items = zir.refSlice(extra_index, 1); |
| 2807 | extra_index += 1; | 2750 | extra_index += 1; |
| 2808 | const body_len = @truncate(u31, zir.extra[extra_index]); | 2751 | const body_len = @truncate(u31, zir.extra[extra_index]); |
| 2809 | extra_index += 1; | 2752 | extra_index += 1; |
| | 2753 | const body = zir.extra[extra_index..][0..body_len]; |
| 2810 | extra_index += body_len; | 2754 | extra_index += body_len; |
| | 2755 | if (cur_idx == prong_index) { |
| | 2756 | return .{ |
| | 2757 | .items = items, |
| | 2758 | .body = body, |
| | 2759 | }; |
| | 2760 | } |
| 2811 | } | 2761 | } |
| 2812 | var multi_i: u32 = 0; | 2762 | while (true) : (cur_idx += 1) { |
| 2813 | while (true) : (multi_i += 1) { | | |
| 2814 | const items_len = zir.extra[extra_index]; | 2763 | const items_len = zir.extra[extra_index]; |
| 2815 | extra_index += 1; | 2764 | extra_index += 1; |
| 2816 | const ranges_len = zir.extra[extra_index]; | 2765 | const ranges_len = zir.extra[extra_index]; |
| ... | @@ -2825,11 +2774,12 @@ pub const Inst = struct { | ... | @@ -2825,11 +2774,12 @@ pub const Inst = struct { |
| 2825 | const body = zir.extra[extra_index..][0..body_len]; | 2774 | const body = zir.extra[extra_index..][0..body_len]; |
| 2826 | extra_index += body_len; | 2775 | extra_index += body_len; |
| 2827 | | 2776 | |
| 2828 | if (multi_i < prong_index) continue; | 2777 | if (cur_idx == prong_index) { |
| 2829 | return .{ | 2778 | return .{ |
| 2830 | .items = items, | 2779 | .items = items, |
| 2831 | .body = body, | 2780 | .body = body, |
| 2832 | }; | 2781 | }; |
| | 2782 | } |
| 2833 | } | 2783 | } |
| 2834 | } | 2784 | } |
| 2835 | }; | 2785 | }; |