| author | |
| committer | |
| log | 85e32043440f3f555419af2a5964618df79cfdce |
| tree | 07261572d548eb2ba7afc03fb5bc7e2a9037259c |
| parent | 902f6db67b2d25f238fb13e458a12e06df62dadb |
cmpxchg_weak and cmpxchg_strong are not very common; demote them to
extended operations to make some headroom.
This commit does not change any behavior, only memory layout of the
compiler.5 files changed, 111 insertions(+), 104 deletions(-)
src/AstGen.zig+12-8| ... | @@ -2439,8 +2439,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As | ... | @@ -2439,8 +2439,6 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As |
| 2439 | .shr_exact, | 2439 | .shr_exact, |
| 2440 | .bit_offset_of, | 2440 | .bit_offset_of, |
| 2441 | .offset_of, | 2441 | .offset_of, |
| 2442 | .cmpxchg_strong, | ||
| 2443 | .cmpxchg_weak, | ||
| 2444 | .splat, | 2442 | .splat, |
| 2445 | .reduce, | 2443 | .reduce, |
| 2446 | .shuffle, | 2444 | .shuffle, |
| ... | @@ -7753,8 +7751,8 @@ fn builtinCall( | ... | @@ -7753,8 +7751,8 @@ fn builtinCall( |
| 7753 | .c_undef => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_undef), | 7751 | .c_undef => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_undef), |
| 7754 | .c_include => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_include), | 7752 | .c_include => return simpleCBuiltin(gz, scope, rl, node, params[0], .c_include), |
| 7755 | 7753 | ||
| 7756 | .cmpxchg_strong => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_strong), | 7754 | .cmpxchg_strong => return cmpxchg(gz, scope, rl, node, params, 1), |
| 7757 | .cmpxchg_weak => return cmpxchg(gz, scope, rl, node, params, .cmpxchg_weak), | 7755 | .cmpxchg_weak => return cmpxchg(gz, scope, rl, node, params, 0), |
| 7758 | // zig fmt: on | 7756 | // zig fmt: on |
| 7759 | 7757 | ||
| 7760 | .wasm_memory_size => { | 7758 | .wasm_memory_size => { |
| ... | @@ -8080,11 +8078,12 @@ fn cmpxchg( | ... | @@ -8080,11 +8078,12 @@ fn cmpxchg( |
| 8080 | rl: ResultLoc, | 8078 | rl: ResultLoc, |
| 8081 | node: Ast.Node.Index, | 8079 | node: Ast.Node.Index, |
| 8082 | params: []const Ast.Node.Index, | 8080 | params: []const Ast.Node.Index, |
| 8083 | tag: Zir.Inst.Tag, | 8081 | small: u16, |
| 8084 | ) InnerError!Zir.Inst.Ref { | 8082 | ) InnerError!Zir.Inst.Ref { |
| 8085 | const int_type = try typeExpr(gz, scope, params[0]); | 8083 | const int_type = try typeExpr(gz, scope, params[0]); |
| 8086 | const result = try gz.addPlNode(tag, node, Zir.Inst.Cmpxchg{ | 8084 | const result = try gz.addExtendedPayloadSmall(.cmpxchg, small, Zir.Inst.Cmpxchg{ |
| 8087 | // zig fmt: off | 8085 | // zig fmt: off |
| 8086 | .node = gz.nodeIndexToRelative(node), | ||
| 8088 | .ptr = try expr(gz, scope, .none, params[1]), | 8087 | .ptr = try expr(gz, scope, .none, params[1]), |
| 8089 | .expected_value = try expr(gz, scope, .{ .ty = int_type }, params[2]), | 8088 | .expected_value = try expr(gz, scope, .{ .ty = int_type }, params[2]), |
| 8090 | .new_value = try expr(gz, scope, .{ .coerced_ty = int_type }, params[3]), | 8089 | .new_value = try expr(gz, scope, .{ .coerced_ty = int_type }, params[3]), |
| ... | @@ -10904,9 +10903,14 @@ const GenZir = struct { | ... | @@ -10904,9 +10903,14 @@ const GenZir = struct { |
| 10904 | return new_index; | 10903 | return new_index; |
| 10905 | } | 10904 | } |
| 10906 | 10905 | ||
| 10907 | fn addExtendedPayload( | 10906 | fn addExtendedPayload(gz: *GenZir, opcode: Zir.Inst.Extended, extra: anytype) !Zir.Inst.Ref { |
| 10907 | return addExtendedPayloadSmall(gz, opcode, undefined, extra); | ||
| 10908 | } | ||
| 10909 | |||
| 10910 | fn addExtendedPayloadSmall( | ||
| 10908 | gz: *GenZir, | 10911 | gz: *GenZir, |
| 10909 | opcode: Zir.Inst.Extended, | 10912 | opcode: Zir.Inst.Extended, |
| 10913 | small: u16, | ||
| 10910 | extra: anytype, | 10914 | extra: anytype, |
| 10911 | ) !Zir.Inst.Ref { | 10915 | ) !Zir.Inst.Ref { |
| 10912 | const gpa = gz.astgen.gpa; | 10916 | const gpa = gz.astgen.gpa; |
| ... | @@ -10920,7 +10924,7 @@ const GenZir = struct { | ... | @@ -10920,7 +10924,7 @@ const GenZir = struct { |
| 10920 | .tag = .extended, | 10924 | .tag = .extended, |
| 10921 | .data = .{ .extended = .{ | 10925 | .data = .{ .extended = .{ |
| 10922 | .opcode = opcode, | 10926 | .opcode = opcode, |
| 10923 | .small = undefined, | 10927 | .small = small, |
| 10924 | .operand = payload_index, | 10928 | .operand = payload_index, |
| 10925 | } }, | 10929 | } }, |
| 10926 | }); | 10930 | }); |
src/Autodoc.zig+73-66| ... | @@ -998,72 +998,6 @@ fn walkInstruction( | ... | @@ -998,72 +998,6 @@ fn walkInstruction( |
| 998 | const un_tok = data[inst_index].un_tok; | 998 | const un_tok = data[inst_index].un_tok; |
| 999 | return try self.walkRef(file, parent_scope, parent_src, un_tok.operand, need_type); | 999 | return try self.walkRef(file, parent_scope, parent_src, un_tok.operand, need_type); |
| 1000 | }, | 1000 | }, |
| 1001 | .cmpxchg_strong, .cmpxchg_weak => { | ||
| 1002 | const pl_node = data[inst_index].pl_node; | ||
| 1003 | const extra = file.zir.extraData(Zir.Inst.Cmpxchg, pl_node.payload_index); | ||
| 1004 | |||
| 1005 | const last_type_index = self.exprs.items.len; | ||
| 1006 | const last_type = self.exprs.items[last_type_index - 1]; | ||
| 1007 | const type_index = self.exprs.items.len; | ||
| 1008 | try self.exprs.append(self.arena, last_type); | ||
| 1009 | |||
| 1010 | const ptr_index = self.exprs.items.len; | ||
| 1011 | var ptr: DocData.WalkResult = try self.walkRef( | ||
| 1012 | file, | ||
| 1013 | parent_scope, | ||
| 1014 | parent_src, | ||
| 1015 | extra.data.ptr, | ||
| 1016 | false, | ||
| 1017 | ); | ||
| 1018 | try self.exprs.append(self.arena, ptr.expr); | ||
| 1019 | |||
| 1020 | const expected_value_index = self.exprs.items.len; | ||
| 1021 | var expected_value: DocData.WalkResult = try self.walkRef( | ||
| 1022 | file, | ||
| 1023 | parent_scope, | ||
| 1024 | parent_src, | ||
| 1025 | extra.data.expected_value, | ||
| 1026 | false, | ||
| 1027 | ); | ||
| 1028 | try self.exprs.append(self.arena, expected_value.expr); | ||
| 1029 | |||
| 1030 | const new_value_index = self.exprs.items.len; | ||
| 1031 | var new_value: DocData.WalkResult = try self.walkRef( | ||
| 1032 | file, | ||
| 1033 | parent_scope, | ||
| 1034 | parent_src, | ||
| 1035 | extra.data.new_value, | ||
| 1036 | false, | ||
| 1037 | ); | ||
| 1038 | try self.exprs.append(self.arena, new_value.expr); | ||
| 1039 | |||
| 1040 | const success_order_index = self.exprs.items.len; | ||
| 1041 | var success_order: DocData.WalkResult = try self.walkRef( | ||
| 1042 | file, | ||
| 1043 | parent_scope, | ||
| 1044 | parent_src, | ||
| 1045 | extra.data.success_order, | ||
| 1046 | false, | ||
| 1047 | ); | ||
| 1048 | try self.exprs.append(self.arena, success_order.expr); | ||
| 1049 | |||
| 1050 | const failure_order_index = self.exprs.items.len; | ||
| 1051 | var failure_order: DocData.WalkResult = try self.walkRef( | ||
| 1052 | file, | ||
| 1053 | parent_scope, | ||
| 1054 | parent_src, | ||
| 1055 | extra.data.failure_order, | ||
| 1056 | false, | ||
| 1057 | ); | ||
| 1058 | try self.exprs.append(self.arena, failure_order.expr); | ||
| 1059 | |||
| 1060 | const cmpxchg_index = self.exprs.items.len; | ||
| 1061 | try self.exprs.append(self.arena, .{ .cmpxchg = .{ .name = @tagName(tags[inst_index]), .type = type_index, .ptr = ptr_index, .expected_value = expected_value_index, .new_value = new_value_index, .success_order = success_order_index, .failure_order = failure_order_index } }); | ||
| 1062 | return DocData.WalkResult{ | ||
| 1063 | .typeRef = .{ .type = @enumToInt(Ref.type_type) }, | ||
| 1064 | .expr = .{ .cmpxchgIndex = cmpxchg_index }, | ||
| 1065 | }; | ||
| 1066 | }, | ||
| 1067 | .str => { | 1001 | .str => { |
| 1068 | const str = data[inst_index].str.get(file.zir); | 1002 | const str = data[inst_index].str.get(file.zir); |
| 1069 | 1003 | ||
| ... | @@ -3047,6 +2981,79 @@ fn walkInstruction( | ... | @@ -3047,6 +2981,79 @@ fn walkInstruction( |
| 3047 | .expr = .{ .builtinIndex = bin_index }, | 2981 | .expr = .{ .builtinIndex = bin_index }, |
| 3048 | }; | 2982 | }; |
| 3049 | }, | 2983 | }, |
| 2984 | .cmpxchg => { | ||
| 2985 | const extra = file.zir.extraData(Zir.Inst.Cmpxchg, extended.operand).data; | ||
| 2986 | |||
| 2987 | const last_type_index = self.exprs.items.len; | ||
| 2988 | const last_type = self.exprs.items[last_type_index - 1]; | ||
| 2989 | const type_index = self.exprs.items.len; | ||
| 2990 | try self.exprs.append(self.arena, last_type); | ||
| 2991 | |||
| 2992 | const ptr_index = self.exprs.items.len; | ||
| 2993 | var ptr: DocData.WalkResult = try self.walkRef( | ||
| 2994 | file, | ||
| 2995 | parent_scope, | ||
| 2996 | parent_src, | ||
| 2997 | extra.ptr, | ||
| 2998 | false, | ||
| 2999 | ); | ||
| 3000 | try self.exprs.append(self.arena, ptr.expr); | ||
| 3001 | |||
| 3002 | const expected_value_index = self.exprs.items.len; | ||
| 3003 | var expected_value: DocData.WalkResult = try self.walkRef( | ||
| 3004 | file, | ||
| 3005 | parent_scope, | ||
| 3006 | parent_src, | ||
| 3007 | extra.expected_value, | ||
| 3008 | false, | ||
| 3009 | ); | ||
| 3010 | try self.exprs.append(self.arena, expected_value.expr); | ||
| 3011 | |||
| 3012 | const new_value_index = self.exprs.items.len; | ||
| 3013 | var new_value: DocData.WalkResult = try self.walkRef( | ||
| 3014 | file, | ||
| 3015 | parent_scope, | ||
| 3016 | parent_src, | ||
| 3017 | extra.new_value, | ||
| 3018 | false, | ||
| 3019 | ); | ||
| 3020 | try self.exprs.append(self.arena, new_value.expr); | ||
| 3021 | |||
| 3022 | const success_order_index = self.exprs.items.len; | ||
| 3023 | var success_order: DocData.WalkResult = try self.walkRef( | ||
| 3024 | file, | ||
| 3025 | parent_scope, | ||
| 3026 | parent_src, | ||
| 3027 | extra.success_order, | ||
| 3028 | false, | ||
| 3029 | ); | ||
| 3030 | try self.exprs.append(self.arena, success_order.expr); | ||
| 3031 | |||
| 3032 | const failure_order_index = self.exprs.items.len; | ||
| 3033 | var failure_order: DocData.WalkResult = try self.walkRef( | ||
| 3034 | file, | ||
| 3035 | parent_scope, | ||
| 3036 | parent_src, | ||
| 3037 | extra.failure_order, | ||
| 3038 | false, | ||
| 3039 | ); | ||
| 3040 | try self.exprs.append(self.arena, failure_order.expr); | ||
| 3041 | |||
| 3042 | const cmpxchg_index = self.exprs.items.len; | ||
| 3043 | try self.exprs.append(self.arena, .{ .cmpxchg = .{ | ||
| 3044 | .name = @tagName(tags[inst_index]), | ||
| 3045 | .type = type_index, | ||
| 3046 | .ptr = ptr_index, | ||
| 3047 | .expected_value = expected_value_index, | ||
| 3048 | .new_value = new_value_index, | ||
| 3049 | .success_order = success_order_index, | ||
| 3050 | .failure_order = failure_order_index, | ||
| 3051 | } }); | ||
| 3052 | return DocData.WalkResult{ | ||
| 3053 | .typeRef = .{ .type = @enumToInt(Ref.type_type) }, | ||
| 3054 | .expr = .{ .cmpxchgIndex = cmpxchg_index }, | ||
| 3055 | }; | ||
| 3056 | }, | ||
| 3050 | } | 3057 | } |
| 3051 | }, | 3058 | }, |
| 3052 | } | 3059 | } |
src/Sema.zig+16-13| ... | @@ -839,8 +839,6 @@ fn analyzeBodyInner( | ... | @@ -839,8 +839,6 @@ fn analyzeBodyInner( |
| 839 | .bit_reverse => try sema.zirBitReverse(block, inst), | 839 | .bit_reverse => try sema.zirBitReverse(block, inst), |
| 840 | .bit_offset_of => try sema.zirBitOffsetOf(block, inst), | 840 | .bit_offset_of => try sema.zirBitOffsetOf(block, inst), |
| 841 | .offset_of => try sema.zirOffsetOf(block, inst), | 841 | .offset_of => try sema.zirOffsetOf(block, inst), |
| 842 | .cmpxchg_strong => try sema.zirCmpxchg(block, inst, .cmpxchg_strong), | ||
| 843 | .cmpxchg_weak => try sema.zirCmpxchg(block, inst, .cmpxchg_weak), | ||
| 844 | .splat => try sema.zirSplat(block, inst), | 842 | .splat => try sema.zirSplat(block, inst), |
| 845 | .reduce => try sema.zirReduce(block, inst), | 843 | .reduce => try sema.zirReduce(block, inst), |
| 846 | .shuffle => try sema.zirShuffle(block, inst), | 844 | .shuffle => try sema.zirShuffle(block, inst), |
| ... | @@ -957,6 +955,8 @@ fn analyzeBodyInner( | ... | @@ -957,6 +955,8 @@ fn analyzeBodyInner( |
| 957 | .int_to_error => try sema.zirIntToError( block, extended), | 955 | .int_to_error => try sema.zirIntToError( block, extended), |
| 958 | .reify => try sema.zirReify( block, extended, inst), | 956 | .reify => try sema.zirReify( block, extended, inst), |
| 959 | .builtin_async_call => try sema.zirBuiltinAsyncCall( block, extended), | 957 | .builtin_async_call => try sema.zirBuiltinAsyncCall( block, extended), |
| 958 | .cmpxchg => try sema.zirCmpxchg( block, extended), | ||
| 959 | |||
| 960 | // zig fmt: on | 960 | // zig fmt: on |
| 961 | .fence => { | 961 | .fence => { |
| 962 | try sema.zirFence(block, extended); | 962 | try sema.zirFence(block, extended); |
| ... | @@ -18891,19 +18891,22 @@ fn resolveAtomicRmwOp( | ... | @@ -18891,19 +18891,22 @@ fn resolveAtomicRmwOp( |
| 18891 | fn zirCmpxchg( | 18891 | fn zirCmpxchg( |
| 18892 | sema: *Sema, | 18892 | sema: *Sema, |
| 18893 | block: *Block, | 18893 | block: *Block, |
| 18894 | inst: Zir.Inst.Index, | 18894 | extended: Zir.Inst.Extended.InstData, |
| 18895 | air_tag: Air.Inst.Tag, | ||
| 18896 | ) CompileError!Air.Inst.Ref { | 18895 | ) CompileError!Air.Inst.Ref { |
| 18897 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 18896 | const extra = sema.code.extraData(Zir.Inst.Cmpxchg, extended.operand).data; |
| 18898 | const extra = sema.code.extraData(Zir.Inst.Cmpxchg, inst_data.payload_index).data; | 18897 | const air_tag: Air.Inst.Tag = switch (extended.small) { |
| 18899 | const src = inst_data.src(); | 18898 | 0 => .cmpxchg_weak, |
| 18899 | 1 => .cmpxchg_strong, | ||
| 18900 | else => unreachable, | ||
| 18901 | }; | ||
| 18902 | const src = LazySrcLoc.nodeOffset(extra.node); | ||
| 18900 | // zig fmt: off | 18903 | // zig fmt: off |
| 18901 | const elem_ty_src : LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 18904 | const elem_ty_src : LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; |
| 18902 | const ptr_src : LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 18905 | const ptr_src : LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 18903 | const expected_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; | 18906 | const expected_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = extra.node }; |
| 18904 | const new_value_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; | 18907 | const new_value_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = extra.node }; |
| 18905 | const success_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node }; | 18908 | const success_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg4 = extra.node }; |
| 18906 | const failure_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg5 = inst_data.src_node }; | 18909 | const failure_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg5 = extra.node }; |
| 18907 | // zig fmt: on | 18910 | // zig fmt: on |
| 18908 | const expected_value = try sema.resolveInst(extra.expected_value); | 18911 | const expected_value = try sema.resolveInst(extra.expected_value); |
| 18909 | const elem_ty = sema.typeOf(expected_value); | 18912 | const elem_ty = sema.typeOf(expected_value); |
src/Zir.zig+5-12| ... | @@ -890,12 +890,6 @@ pub const Inst = struct { | ... | @@ -890,12 +890,6 @@ pub const Inst = struct { |
| 890 | /// Implements the `@offsetOf` builtin. | 890 | /// Implements the `@offsetOf` builtin. |
| 891 | /// Uses the `pl_node` union field with payload `Bin`. | 891 | /// Uses the `pl_node` union field with payload `Bin`. |
| 892 | offset_of, | 892 | offset_of, |
| 893 | /// Implements the `@cmpxchgStrong` builtin. | ||
| 894 | /// Uses the `pl_node` union field with payload `Cmpxchg`. | ||
| 895 | cmpxchg_strong, | ||
| 896 | /// Implements the `@cmpxchgWeak` builtin. | ||
| 897 | /// Uses the `pl_node` union field with payload `Cmpxchg`. | ||
| 898 | cmpxchg_weak, | ||
| 899 | /// Implements the `@splat` builtin. | 893 | /// Implements the `@splat` builtin. |
| 900 | /// Uses the `pl_node` union field with payload `Bin`. | 894 | /// Uses the `pl_node` union field with payload `Bin`. |
| 901 | splat, | 895 | splat, |
| ... | @@ -1211,8 +1205,6 @@ pub const Inst = struct { | ... | @@ -1211,8 +1205,6 @@ pub const Inst = struct { |
| 1211 | .shr_exact, | 1205 | .shr_exact, |
| 1212 | .bit_offset_of, | 1206 | .bit_offset_of, |
| 1213 | .offset_of, | 1207 | .offset_of, |
| 1214 | .cmpxchg_strong, | ||
| 1215 | .cmpxchg_weak, | ||
| 1216 | .splat, | 1208 | .splat, |
| 1217 | .reduce, | 1209 | .reduce, |
| 1218 | .shuffle, | 1210 | .shuffle, |
| ... | @@ -1498,8 +1490,6 @@ pub const Inst = struct { | ... | @@ -1498,8 +1490,6 @@ pub const Inst = struct { |
| 1498 | .shr_exact, | 1490 | .shr_exact, |
| 1499 | .bit_offset_of, | 1491 | .bit_offset_of, |
| 1500 | .offset_of, | 1492 | .offset_of, |
| 1501 | .cmpxchg_strong, | ||
| 1502 | .cmpxchg_weak, | ||
| 1503 | .splat, | 1493 | .splat, |
| 1504 | .reduce, | 1494 | .reduce, |
| 1505 | .shuffle, | 1495 | .shuffle, |
| ... | @@ -1781,8 +1771,6 @@ pub const Inst = struct { | ... | @@ -1781,8 +1771,6 @@ pub const Inst = struct { |
| 1781 | 1771 | ||
| 1782 | .bit_offset_of = .pl_node, | 1772 | .bit_offset_of = .pl_node, |
| 1783 | .offset_of = .pl_node, | 1773 | .offset_of = .pl_node, |
| 1784 | .cmpxchg_strong = .pl_node, | ||
| 1785 | .cmpxchg_weak = .pl_node, | ||
| 1786 | .splat = .pl_node, | 1774 | .splat = .pl_node, |
| 1787 | .reduce = .pl_node, | 1775 | .reduce = .pl_node, |
| 1788 | .shuffle = .pl_node, | 1776 | .shuffle = .pl_node, |
| ... | @@ -1972,6 +1960,10 @@ pub const Inst = struct { | ... | @@ -1972,6 +1960,10 @@ pub const Inst = struct { |
| 1972 | /// Implements the `@asyncCall` builtin. | 1960 | /// Implements the `@asyncCall` builtin. |
| 1973 | /// `operand` is payload index to `AsyncCall`. | 1961 | /// `operand` is payload index to `AsyncCall`. |
| 1974 | builtin_async_call, | 1962 | builtin_async_call, |
| 1963 | /// Implements the `@cmpxchgStrong` and `@cmpxchgWeak` builtins. | ||
| 1964 | /// `small` 0=>weak 1=>strong | ||
| 1965 | /// `operand` is payload index to `Cmpxchg`. | ||
| 1966 | cmpxchg, | ||
| 1975 | 1967 | ||
| 1976 | pub const InstData = struct { | 1968 | pub const InstData = struct { |
| 1977 | opcode: Extended, | 1969 | opcode: Extended, |
| ... | @@ -3392,6 +3384,7 @@ pub const Inst = struct { | ... | @@ -3392,6 +3384,7 @@ pub const Inst = struct { |
| 3392 | }; | 3384 | }; |
| 3393 | 3385 | ||
| 3394 | pub const Cmpxchg = struct { | 3386 | pub const Cmpxchg = struct { |
| 3387 | node: i32, | ||
| 3395 | ptr: Ref, | 3388 | ptr: Ref, |
| 3396 | expected_value: Ref, | 3389 | expected_value: Ref, |
| 3397 | new_value: Ref, | 3390 | new_value: Ref, |
src/print_zir.zig+5-5| ... | @@ -272,7 +272,6 @@ const Writer = struct { | ... | @@ -272,7 +272,6 @@ const Writer = struct { |
| 272 | .struct_init_ref, | 272 | .struct_init_ref, |
| 273 | => try self.writeStructInit(stream, inst), | 273 | => try self.writeStructInit(stream, inst), |
| 274 | 274 | ||
| 275 | .cmpxchg_strong, .cmpxchg_weak => try self.writeCmpxchg(stream, inst), | ||
| 276 | .atomic_load => try self.writeAtomicLoad(stream, inst), | 275 | .atomic_load => try self.writeAtomicLoad(stream, inst), |
| 277 | .atomic_store => try self.writeAtomicStore(stream, inst), | 276 | .atomic_store => try self.writeAtomicStore(stream, inst), |
| 278 | .atomic_rmw => try self.writeAtomicRmw(stream, inst), | 277 | .atomic_rmw => try self.writeAtomicRmw(stream, inst), |
| ... | @@ -532,6 +531,7 @@ const Writer = struct { | ... | @@ -532,6 +531,7 @@ const Writer = struct { |
| 532 | try self.writeSrc(stream, src); | 531 | try self.writeSrc(stream, src); |
| 533 | }, | 532 | }, |
| 534 | .builtin_async_call => try self.writeBuiltinAsyncCall(stream, extended), | 533 | .builtin_async_call => try self.writeBuiltinAsyncCall(stream, extended), |
| 534 | .cmpxchg => try self.writeCmpxchg(stream, extended), | ||
| 535 | } | 535 | } |
| 536 | } | 536 | } |
| 537 | 537 | ||
| ... | @@ -912,9 +912,9 @@ const Writer = struct { | ... | @@ -912,9 +912,9 @@ const Writer = struct { |
| 912 | try self.writeSrc(stream, inst_data.src()); | 912 | try self.writeSrc(stream, inst_data.src()); |
| 913 | } | 913 | } |
| 914 | 914 | ||
| 915 | fn writeCmpxchg(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 915 | fn writeCmpxchg(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { |
| 916 | const inst_data = self.code.instructions.items(.data)[inst].pl_node; | 916 | const extra = self.code.extraData(Zir.Inst.Cmpxchg, extended.operand).data; |
| 917 | const extra = self.code.extraData(Zir.Inst.Cmpxchg, inst_data.payload_index).data; | 917 | const src = LazySrcLoc.nodeOffset(extra.node); |
| 918 | 918 | ||
| 919 | try self.writeInstRef(stream, extra.ptr); | 919 | try self.writeInstRef(stream, extra.ptr); |
| 920 | try stream.writeAll(", "); | 920 | try stream.writeAll(", "); |
| ... | @@ -926,7 +926,7 @@ const Writer = struct { | ... | @@ -926,7 +926,7 @@ const Writer = struct { |
| 926 | try stream.writeAll(", "); | 926 | try stream.writeAll(", "); |
| 927 | try self.writeInstRef(stream, extra.failure_order); | 927 | try self.writeInstRef(stream, extra.failure_order); |
| 928 | try stream.writeAll(") "); | 928 | try stream.writeAll(") "); |
| 929 | try self.writeSrc(stream, inst_data.src()); | 929 | try self.writeSrc(stream, src); |
| 930 | } | 930 | } |
| 931 | 931 | ||
| 932 | fn writeAtomicLoad(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 932 | fn writeAtomicLoad(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { |