| ... | @@ -675,6 +675,8 @@ const DocData = struct { | ... | @@ -675,6 +675,8 @@ const DocData = struct { |
| 675 | string: []const u8, // direct value | 675 | string: []const u8, // direct value |
| 676 | sliceIndex: usize, | 676 | sliceIndex: usize, |
| 677 | slice: Slice, | 677 | slice: Slice, |
| | 678 | cmpxchgIndex: usize, |
| | 679 | cmpxchg: Cmpxchg, |
| 678 | builtin: Builtin, | 680 | builtin: Builtin, |
| 679 | builtinIndex: usize, | 681 | builtinIndex: usize, |
| 680 | builtinBin: BuiltinBin, | 682 | builtinBin: BuiltinBin, |
| ... | @@ -709,6 +711,7 @@ const DocData = struct { | ... | @@ -709,6 +711,7 @@ const DocData = struct { |
| 709 | end: ?usize = null, | 711 | end: ?usize = null, |
| 710 | sentinel: ?usize = null, // index in `exprs` | 712 | sentinel: ?usize = null, // index in `exprs` |
| 711 | }; | 713 | }; |
| | 714 | const Cmpxchg = struct { name: []const u8, type: usize, ptr: usize, expected_value: usize, new_value: usize, success_order: usize, failure_order: usize }; |
| 712 | const As = struct { | 715 | const As = struct { |
| 713 | typeRefArg: ?usize, // index in `exprs` | 716 | typeRefArg: ?usize, // index in `exprs` |
| 714 | exprArg: usize, // index in `exprs` | 717 | exprArg: usize, // index in `exprs` |
| ... | @@ -814,6 +817,16 @@ const DocData = struct { | ... | @@ -814,6 +817,16 @@ const DocData = struct { |
| 814 | options, | 817 | options, |
| 815 | w, | 818 | w, |
| 816 | ), | 819 | ), |
| | 820 | .cmpxchg => |v| try std.json.stringify( |
| | 821 | struct { cmpxchg: Cmpxchg }{ .cmpxchg = v }, |
| | 822 | options, |
| | 823 | w, |
| | 824 | ), |
| | 825 | .cmpxchgIndex => |v| try std.json.stringify( |
| | 826 | struct { cmpxchgIndex: usize }{ .cmpxchgIndex = v }, |
| | 827 | options, |
| | 828 | w, |
| | 829 | ), |
| 817 | .binOp => |v| try std.json.stringify( | 830 | .binOp => |v| try std.json.stringify( |
| 818 | struct { binOp: BinOp }{ .binOp = v }, | 831 | struct { binOp: BinOp }{ .binOp = v }, |
| 819 | options, | 832 | options, |
| ... | @@ -990,6 +1003,67 @@ fn walkInstruction( | ... | @@ -990,6 +1003,67 @@ fn walkInstruction( |
| 990 | need_type, | 1003 | need_type, |
| 991 | ); | 1004 | ); |
| 992 | }, | 1005 | }, |
| | 1006 | .cmpxchg_strong, .cmpxchg_weak => { |
| | 1007 | const pl_node = data[inst_index].pl_node; |
| | 1008 | const extra = file.zir.extraData(Zir.Inst.Cmpxchg, pl_node.payload_index); |
| | 1009 | |
| | 1010 | const last_type_index = self.exprs.items.len; |
| | 1011 | const last_type = self.exprs.items[last_type_index - 1]; |
| | 1012 | const type_index = self.exprs.items.len; |
| | 1013 | try self.exprs.append(self.arena, last_type); |
| | 1014 | |
| | 1015 | const ptr_index = self.exprs.items.len; |
| | 1016 | var ptr: DocData.WalkResult = try self.walkRef( |
| | 1017 | file, |
| | 1018 | parent_scope, |
| | 1019 | extra.data.ptr, |
| | 1020 | false, |
| | 1021 | ); |
| | 1022 | try self.exprs.append(self.arena, ptr.expr); |
| | 1023 | |
| | 1024 | const expected_value_index = self.exprs.items.len; |
| | 1025 | var expected_value: DocData.WalkResult = try self.walkRef( |
| | 1026 | file, |
| | 1027 | parent_scope, |
| | 1028 | extra.data.expected_value, |
| | 1029 | false, |
| | 1030 | ); |
| | 1031 | try self.exprs.append(self.arena, expected_value.expr); |
| | 1032 | |
| | 1033 | const new_value_index = self.exprs.items.len; |
| | 1034 | var new_value: DocData.WalkResult = try self.walkRef( |
| | 1035 | file, |
| | 1036 | parent_scope, |
| | 1037 | extra.data.new_value, |
| | 1038 | false, |
| | 1039 | ); |
| | 1040 | try self.exprs.append(self.arena, new_value.expr); |
| | 1041 | |
| | 1042 | const success_order_index = self.exprs.items.len; |
| | 1043 | var success_order: DocData.WalkResult = try self.walkRef( |
| | 1044 | file, |
| | 1045 | parent_scope, |
| | 1046 | extra.data.success_order, |
| | 1047 | false, |
| | 1048 | ); |
| | 1049 | try self.exprs.append(self.arena, success_order.expr); |
| | 1050 | |
| | 1051 | const failure_order_index = self.exprs.items.len; |
| | 1052 | var failure_order: DocData.WalkResult = try self.walkRef( |
| | 1053 | file, |
| | 1054 | parent_scope, |
| | 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 | }, |
| 993 | .str => { | 1067 | .str => { |
| 994 | const str = data[inst_index].str.get(file.zir); | 1068 | const str = data[inst_index].str.get(file.zir); |
| 995 | | 1069 | |