| ... | ... | @@ -1007,7 +1007,7 @@ pub const Scope = struct { |
| 1007 | 1007 | return gz.zir_code.decl.tokSrcLoc(token_index); |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | | pub fn addFnTypeCc(gz: *GenZir, args: struct { |
| 1010 | pub fn addFnTypeCc(gz: *GenZir, tag: zir.Inst.Tag, args: struct { |
| 1011 | 1011 | param_types: []const zir.Inst.Ref, |
| 1012 | 1012 | ret_ty: zir.Inst.Ref, |
| 1013 | 1013 | cc: zir.Inst.Ref, |
| ... | ... | @@ -1026,24 +1026,24 @@ pub const Scope = struct { |
| 1026 | 1026 | }) catch unreachable; // Capacity is ensured above. |
| 1027 | 1027 | gz.zir_code.extra.appendSliceAssumeCapacity(args.param_types); |
| 1028 | 1028 | |
| 1029 | | const new_index = gz.zir_code.instructions.len; |
| 1029 | const new_index = @intCast(zir.Inst.Index, gz.zir_code.instructions.len); |
| 1030 | 1030 | gz.zir_code.instructions.appendAssumeCapacity(.{ |
| 1031 | | .tag = .fn_type_cc, |
| 1031 | .tag = tag, |
| 1032 | 1032 | .data = .{ .fn_type = .{ |
| 1033 | 1033 | .return_type = args.ret_ty, |
| 1034 | 1034 | .payload_index = payload_index, |
| 1035 | 1035 | } }, |
| 1036 | 1036 | }); |
| 1037 | | const result = @intCast(zir.Inst.Ref, new_index + gz.zir_code.ref_start_index); |
| 1038 | | gz.instructions.appendAssumeCapacity(result); |
| 1039 | | return result; |
| 1037 | gz.instructions.appendAssumeCapacity(new_index); |
| 1038 | return new_index + gz.zir_code.ref_start_index; |
| 1040 | 1039 | } |
| 1041 | 1040 | |
| 1042 | 1041 | pub fn addFnType( |
| 1043 | 1042 | gz: *GenZir, |
| 1043 | tag: zir.Inst.Tag, |
| 1044 | 1044 | ret_ty: zir.Inst.Ref, |
| 1045 | 1045 | param_types: []const zir.Inst.Ref, |
| 1046 | | ) !zir.Inst.Index { |
| 1046 | ) !zir.Inst.Ref { |
| 1047 | 1047 | assert(ret_ty != 0); |
| 1048 | 1048 | const gpa = gz.zir_code.gpa; |
| 1049 | 1049 | try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1); |
| ... | ... | @@ -1056,20 +1056,19 @@ pub const Scope = struct { |
| 1056 | 1056 | }) catch unreachable; // Capacity is ensured above. |
| 1057 | 1057 | gz.zir_code.extra.appendSliceAssumeCapacity(param_types); |
| 1058 | 1058 | |
| 1059 | | const new_index = gz.zir_code.instructions.len; |
| 1059 | const new_index = @intCast(zir.Inst.Index, gz.zir_code.instructions.len); |
| 1060 | 1060 | gz.zir_code.instructions.appendAssumeCapacity(.{ |
| 1061 | | .tag = .fn_type_cc, |
| 1061 | .tag = tag, |
| 1062 | 1062 | .data = .{ .fn_type = .{ |
| 1063 | 1063 | .return_type = ret_ty, |
| 1064 | 1064 | .payload_index = payload_index, |
| 1065 | 1065 | } }, |
| 1066 | 1066 | }); |
| 1067 | | const result = @intCast(zir.Inst.Ref, new_index + gz.zir_code.ref_start_index); |
| 1068 | | gz.instructions.appendAssumeCapacity(result); |
| 1069 | | return result; |
| 1067 | gz.instructions.appendAssumeCapacity(new_index); |
| 1068 | return new_index + gz.zir_code.ref_start_index; |
| 1070 | 1069 | } |
| 1071 | 1070 | |
| 1072 | | pub fn addInt(gz: *GenZir, integer: u64) !zir.Inst.Index { |
| 1071 | pub fn addInt(gz: *GenZir, integer: u64) !zir.Inst.Ref { |
| 1073 | 1072 | return gz.add(.{ |
| 1074 | 1073 | .tag = .int, |
| 1075 | 1074 | .data = .{ .int = integer }, |
| ... | ... | @@ -1171,11 +1170,10 @@ pub const Scope = struct { |
| 1171 | 1170 | try gz.instructions.ensureCapacity(gpa, gz.instructions.items.len + 1); |
| 1172 | 1171 | try gz.zir_code.instructions.ensureCapacity(gpa, gz.zir_code.instructions.len + 1); |
| 1173 | 1172 | |
| 1174 | | const new_index = gz.zir_code.instructions.len; |
| 1173 | const new_index = @intCast(zir.Inst.Index, gz.zir_code.instructions.len); |
| 1175 | 1174 | gz.zir_code.instructions.appendAssumeCapacity(inst); |
| 1176 | | const result = @intCast(zir.Inst.Ref, new_index + gz.zir_code.ref_start_index); |
| 1177 | | gz.instructions.appendAssumeCapacity(result); |
| 1178 | | return result; |
| 1175 | gz.instructions.appendAssumeCapacity(new_index); |
| 1176 | return new_index + gz.zir_code.ref_start_index; |
| 1179 | 1177 | } |
| 1180 | 1178 | }; |
| 1181 | 1179 | |
| ... | ... | @@ -1232,7 +1230,7 @@ pub const WipZirCode = struct { |
| 1232 | 1230 | extra: std.ArrayListUnmanaged(u32) = .{}, |
| 1233 | 1231 | /// The end of special indexes. `zir.Inst.Ref` subtracts against this number to convert |
| 1234 | 1232 | /// to `zir.Inst.Index`. The default here is correct if there are 0 parameters. |
| 1235 | | ref_start_index: usize = zir.const_inst_list.len, |
| 1233 | ref_start_index: u32 = zir.const_inst_list.len, |
| 1236 | 1234 | decl: *Decl, |
| 1237 | 1235 | gpa: *Allocator, |
| 1238 | 1236 | arena: *Allocator, |
| ... | ... | @@ -2034,14 +2032,14 @@ fn astgenAndSemaFn( |
| 2034 | 2032 | |
| 2035 | 2033 | const fn_type_inst: zir.Inst.Ref = if (cc != 0) fn_type: { |
| 2036 | 2034 | const tag: zir.Inst.Tag = if (is_var_args) .fn_type_cc_var_args else .fn_type_cc; |
| 2037 | | break :fn_type try fn_type_scope.addFnTypeCc(.{ |
| 2035 | break :fn_type try fn_type_scope.addFnTypeCc(tag, .{ |
| 2038 | 2036 | .ret_ty = return_type_inst, |
| 2039 | 2037 | .param_types = param_types, |
| 2040 | 2038 | .cc = cc, |
| 2041 | 2039 | }); |
| 2042 | 2040 | } else fn_type: { |
| 2043 | 2041 | const tag: zir.Inst.Tag = if (is_var_args) .fn_type_var_args else .fn_type; |
| 2044 | | break :fn_type try fn_type_scope.addFnType(return_type_inst, param_types); |
| 2042 | break :fn_type try fn_type_scope.addFnType(tag, return_type_inst, param_types); |
| 2045 | 2043 | }; |
| 2046 | 2044 | |
| 2047 | 2045 | // We need the memory for the Type to go into the arena for the Decl |