| ... | @@ -218,7 +218,8 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst *source_instr, IrInstGen * | ... | @@ -218,7 +218,8 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst *source_instr, IrInstGen * |
| 218 | ResultLoc *result_loc); | 218 | ResultLoc *result_loc); |
| 219 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutableSrc *exec, AstNode *source_node, Buf *msg); | 219 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutableSrc *exec, AstNode *source_node, Buf *msg); |
| 220 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | 220 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 221 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type, bool initializing); | 221 | IrInst* source_instr, IrInstGen *container_ptr, IrInst *container_ptr_src, |
| | 222 | ZigType *container_type, bool initializing); |
| 222 | static void ir_assert(bool ok, IrInst* source_instruction); | 223 | static void ir_assert(bool ok, IrInst* source_instruction); |
| 223 | static void ir_assert_gen(bool ok, IrInstGen *source_instruction); | 224 | static void ir_assert_gen(bool ok, IrInstGen *source_instruction); |
| 224 | static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, IrInst *source_instr, ZigVar *var); | 225 | static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, IrInst *source_instr, ZigVar *var); |
| ... | @@ -13040,10 +13041,13 @@ static IrInstGen *ir_const_fn(IrAnalyze *ira, IrInst *source_instr, ZigFn *fn_en | ... | @@ -13040,10 +13041,13 @@ static IrInstGen *ir_const_fn(IrAnalyze *ira, IrInst *source_instr, ZigFn *fn_en |
| 13040 | return result; | 13041 | return result; |
| 13041 | } | 13042 | } |
| 13042 | | 13043 | |
| 13043 | static IrInstGen *ir_const_bound_fn(IrAnalyze *ira, IrInst *src_inst, ZigFn *fn_entry, IrInstGen *first_arg) { | 13044 | static IrInstGen *ir_const_bound_fn(IrAnalyze *ira, IrInst *src_inst, ZigFn *fn_entry, IrInstGen *first_arg, |
| | 13045 | IrInst *first_arg_src) |
| | 13046 | { |
| 13044 | IrInstGen *result = ir_const(ira, src_inst, get_bound_fn_type(ira->codegen, fn_entry)); | 13047 | IrInstGen *result = ir_const(ira, src_inst, get_bound_fn_type(ira->codegen, fn_entry)); |
| 13045 | result->value->data.x_bound_fn.fn = fn_entry; | 13048 | result->value->data.x_bound_fn.fn = fn_entry; |
| 13046 | result->value->data.x_bound_fn.first_arg = first_arg; | 13049 | result->value->data.x_bound_fn.first_arg = first_arg; |
| | 13050 | result->value->data.x_bound_fn.first_arg_src = first_arg_src; |
| 13047 | return result; | 13051 | return result; |
| 13048 | } | 13052 | } |
| 13049 | | 13053 | |
| ... | @@ -15481,7 +15485,7 @@ static IrInstGen *ir_analyze_instruction_return(IrAnalyze *ira, IrInstSrcReturn | ... | @@ -15481,7 +15485,7 @@ static IrInstGen *ir_analyze_instruction_return(IrAnalyze *ira, IrInstSrcReturn |
| 15481 | casted_operand->value->type->id == ZigTypeIdPointer && | 15485 | casted_operand->value->type->id == ZigTypeIdPointer && |
| 15482 | casted_operand->value->data.rh_ptr == RuntimeHintPtrStack) | 15486 | casted_operand->value->data.rh_ptr == RuntimeHintPtrStack) |
| 15483 | { | 15487 | { |
| 15484 | ir_add_error(ira, &casted_operand->base, buf_sprintf("function returns address of local variable")); | 15488 | ir_add_error(ira, &instruction->operand->base, buf_sprintf("function returns address of local variable")); |
| 15485 | return ir_unreach_error(ira); | 15489 | return ir_unreach_error(ira); |
| 15486 | } | 15490 | } |
| 15487 | | 15491 | |
| ... | @@ -18895,7 +18899,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node | ... | @@ -18895,7 +18899,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 18895 | } | 18899 | } |
| 18896 | | 18900 | |
| 18897 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, | 18901 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 18898 | IrInstGen *arg, Scope **child_scope, size_t *next_proto_i, | 18902 | IrInstGen *arg, IrInst *arg_src, Scope **child_scope, size_t *next_proto_i, |
| 18899 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstGen **casted_args, | 18903 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstGen **casted_args, |
| 18900 | ZigFn *impl_fn) | 18904 | ZigFn *impl_fn) |
| 18901 | { | 18905 | { |
| ... | @@ -18914,7 +18918,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -18914,7 +18918,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 18914 | if (type_is_invalid(param_type)) | 18918 | if (type_is_invalid(param_type)) |
| 18915 | return false; | 18919 | return false; |
| 18916 | | 18920 | |
| 18917 | casted_arg = ir_implicit_cast(ira, arg, param_type); | 18921 | casted_arg = ir_implicit_cast2(ira, arg_src, arg, param_type); |
| 18918 | if (type_is_invalid(casted_arg->value->type)) | 18922 | if (type_is_invalid(casted_arg->value->type)) |
| 18919 | return false; | 18923 | return false; |
| 18920 | } else { | 18924 | } else { |
| ... | @@ -19201,7 +19205,7 @@ static IrInstGen *analyze_casted_new_stack(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19201,7 +19205,7 @@ static IrInstGen *analyze_casted_new_stack(IrAnalyze *ira, IrInst* source_instr, |
| 19201 | | 19205 | |
| 19202 | static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | 19206 | static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19203 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, | 19207 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, |
| 19204 | IrInstGen *first_arg_ptr, CallModifier modifier, | 19208 | IrInstGen *first_arg_ptr, IrInst *first_arg_ptr_src, CallModifier modifier, |
| 19205 | IrInstGen *new_stack, IrInst *new_stack_src, bool is_async_call_builtin, | 19209 | IrInstGen *new_stack, IrInst *new_stack_src, bool is_async_call_builtin, |
| 19206 | IrInstGen **args_ptr, size_t args_len, IrInstGen *ret_ptr, ResultLoc *call_result_loc) | 19210 | IrInstGen **args_ptr, size_t args_len, IrInstGen *ret_ptr, ResultLoc *call_result_loc) |
| 19207 | { | 19211 | { |
| ... | @@ -19416,8 +19420,8 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19416,8 +19420,8 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19416 | return ira->codegen->invalid_inst_gen; | 19420 | return ira->codegen->invalid_inst_gen; |
| 19417 | } | 19421 | } |
| 19418 | | 19422 | |
| 19419 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, first_arg, &impl_fn->child_scope, | 19423 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, first_arg, first_arg_ptr_src, |
| 19420 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) | 19424 | &impl_fn->child_scope, &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) |
| 19421 | { | 19425 | { |
| 19422 | return ira->codegen->invalid_inst_gen; | 19426 | return ira->codegen->invalid_inst_gen; |
| 19423 | } | 19427 | } |
| ... | @@ -19431,7 +19435,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19431,7 +19435,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19431 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); | 19435 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); |
| 19432 | assert(param_decl_node->type == NodeTypeParamDecl); | 19436 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 19433 | | 19437 | |
| 19434 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg, &impl_fn->child_scope, | 19438 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg, &arg->base, &impl_fn->child_scope, |
| 19435 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) | 19439 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) |
| 19436 | { | 19440 | { |
| 19437 | return ira->codegen->invalid_inst_gen; | 19441 | return ira->codegen->invalid_inst_gen; |
| ... | @@ -19479,7 +19483,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19479,7 +19483,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19479 | case ReqCompTimeYes: | 19483 | case ReqCompTimeYes: |
| 19480 | // Throw out our work and call the function as if it were comptime. | 19484 | // Throw out our work and call the function as if it were comptime. |
| 19481 | return ir_analyze_fn_call(ira, source_instr, fn_entry, fn_type, fn_ref, first_arg_ptr, | 19485 | return ir_analyze_fn_call(ira, source_instr, fn_entry, fn_type, fn_ref, first_arg_ptr, |
| 19482 | CallModifierCompileTime, new_stack, new_stack_src, is_async_call_builtin, | 19486 | first_arg_ptr_src, CallModifierCompileTime, new_stack, new_stack_src, is_async_call_builtin, |
| 19483 | args_ptr, args_len, ret_ptr, call_result_loc); | 19487 | args_ptr, args_len, ret_ptr, call_result_loc); |
| 19484 | case ReqCompTimeInvalid: | 19488 | case ReqCompTimeInvalid: |
| 19485 | return ira->codegen->invalid_inst_gen; | 19489 | return ira->codegen->invalid_inst_gen; |
| ... | @@ -19600,7 +19604,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19600,7 +19604,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19600 | return ira->codegen->invalid_inst_gen; | 19604 | return ira->codegen->invalid_inst_gen; |
| 19601 | } | 19605 | } |
| 19602 | | 19606 | |
| 19603 | IrInstGen *casted_arg = ir_implicit_cast(ira, first_arg, param_type); | 19607 | IrInstGen *casted_arg = ir_implicit_cast2(ira, first_arg_ptr_src, first_arg, param_type); |
| 19604 | if (type_is_invalid(casted_arg->value->type)) | 19608 | if (type_is_invalid(casted_arg->value->type)) |
| 19605 | return ira->codegen->invalid_inst_gen; | 19609 | return ira->codegen->invalid_inst_gen; |
| 19606 | | 19610 | |
| ... | @@ -19696,7 +19700,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19696,7 +19700,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 19696 | | 19700 | |
| 19697 | static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_instruction, | 19701 | static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_instruction, |
| 19698 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, | 19702 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, |
| 19699 | IrInstGen *first_arg_ptr, CallModifier modifier) | 19703 | IrInstGen *first_arg_ptr, IrInst *first_arg_ptr_src, CallModifier modifier) |
| 19700 | { | 19704 | { |
| 19701 | IrInstGen *new_stack = nullptr; | 19705 | IrInstGen *new_stack = nullptr; |
| 19702 | IrInst *new_stack_src = nullptr; | 19706 | IrInst *new_stack_src = nullptr; |
| ... | @@ -19719,8 +19723,9 @@ static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_ins | ... | @@ -19719,8 +19723,9 @@ static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_ins |
| 19719 | return ira->codegen->invalid_inst_gen; | 19723 | return ira->codegen->invalid_inst_gen; |
| 19720 | } | 19724 | } |
| 19721 | IrInstGen *result = ir_analyze_fn_call(ira, &call_instruction->base.base, fn_entry, fn_type, fn_ref, | 19725 | IrInstGen *result = ir_analyze_fn_call(ira, &call_instruction->base.base, fn_entry, fn_type, fn_ref, |
| 19722 | first_arg_ptr, modifier, new_stack, new_stack_src, call_instruction->is_async_call_builtin, | 19726 | first_arg_ptr, first_arg_ptr_src, modifier, new_stack, new_stack_src, |
| 19723 | args_ptr, call_instruction->arg_count, ret_ptr, call_instruction->result_loc); | 19727 | call_instruction->is_async_call_builtin, args_ptr, call_instruction->arg_count, ret_ptr, |
| | 19728 | call_instruction->result_loc); |
| 19724 | deallocate(args_ptr, call_instruction->arg_count, "IrInstGen *"); | 19729 | deallocate(args_ptr, call_instruction->arg_count, "IrInstGen *"); |
| 19725 | return result; | 19730 | return result; |
| 19726 | } | 19731 | } |
| ... | @@ -19771,12 +19776,14 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19771,12 +19776,14 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr, |
| 19771 | } | 19776 | } |
| 19772 | | 19777 | |
| 19773 | IrInstGen *first_arg_ptr = nullptr; | 19778 | IrInstGen *first_arg_ptr = nullptr; |
| | 19779 | IrInst *first_arg_ptr_src = nullptr; |
| 19774 | ZigFn *fn = nullptr; | 19780 | ZigFn *fn = nullptr; |
| 19775 | if (instr_is_comptime(fn_ref)) { | 19781 | if (instr_is_comptime(fn_ref)) { |
| 19776 | if (fn_ref->value->type->id == ZigTypeIdBoundFn) { | 19782 | if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 19777 | assert(fn_ref->value->special == ConstValSpecialStatic); | 19783 | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 19778 | fn = fn_ref->value->data.x_bound_fn.fn; | 19784 | fn = fn_ref->value->data.x_bound_fn.fn; |
| 19779 | first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; | 19785 | first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| | 19786 | first_arg_ptr_src = fn_ref->value->data.x_bound_fn.first_arg_src; |
| 19780 | if (type_is_invalid(first_arg_ptr->value->type)) | 19787 | if (type_is_invalid(first_arg_ptr->value->type)) |
| 19781 | return ira->codegen->invalid_inst_gen; | 19788 | return ira->codegen->invalid_inst_gen; |
| 19782 | } else { | 19789 | } else { |
| ... | @@ -19818,7 +19825,7 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -19818,7 +19825,7 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr, |
| 19818 | return ira->codegen->invalid_inst_gen; | 19825 | return ira->codegen->invalid_inst_gen; |
| 19819 | } | 19826 | } |
| 19820 | | 19827 | |
| 19821 | return ir_analyze_fn_call(ira, source_instr, fn, fn_type, fn_ref, first_arg_ptr, | 19828 | return ir_analyze_fn_call(ira, source_instr, fn, fn_type, fn_ref, first_arg_ptr, first_arg_ptr_src, |
| 19822 | modifier, stack, &stack->base, false, args_ptr, args_len, nullptr, result_loc); | 19829 | modifier, stack, &stack->base, false, args_ptr, args_len, nullptr, result_loc); |
| 19823 | } | 19830 | } |
| 19824 | | 19831 | |
| ... | @@ -19894,14 +19901,15 @@ static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *cal | ... | @@ -19894,14 +19901,15 @@ static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *cal |
| 19894 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type; | 19901 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type; |
| 19895 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; | 19902 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; |
| 19896 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_type, | 19903 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_type, |
| 19897 | fn_ref, nullptr, modifier); | 19904 | fn_ref, nullptr, nullptr, modifier); |
| 19898 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { | 19905 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 19899 | assert(fn_ref->value->special == ConstValSpecialStatic); | 19906 | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 19900 | ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn; | 19907 | ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn; |
| 19901 | IrInstGen *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; | 19908 | IrInstGen *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| | 19909 | IrInst *first_arg_ptr_src = fn_ref->value->data.x_bound_fn.first_arg_src; |
| 19902 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; | 19910 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; |
| 19903 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, | 19911 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| 19904 | fn_ref, first_arg_ptr, modifier); | 19912 | fn_ref, first_arg_ptr, first_arg_ptr_src, modifier); |
| 19905 | } else { | 19913 | } else { |
| 19906 | ir_add_error(ira, &fn_ref->base, | 19914 | ir_add_error(ira, &fn_ref->base, |
| 19907 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); | 19915 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| ... | @@ -19911,7 +19919,7 @@ static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *cal | ... | @@ -19911,7 +19919,7 @@ static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *cal |
| 19911 | | 19919 | |
| 19912 | if (fn_ref->value->type->id == ZigTypeIdFn) { | 19920 | if (fn_ref->value->type->id == ZigTypeIdFn) { |
| 19913 | return ir_analyze_fn_call_src(ira, call_instruction, nullptr, fn_ref->value->type, | 19921 | return ir_analyze_fn_call_src(ira, call_instruction, nullptr, fn_ref->value->type, |
| 19914 | fn_ref, nullptr, modifier); | 19922 | fn_ref, nullptr, nullptr, modifier); |
| 19915 | } else { | 19923 | } else { |
| 19916 | ir_add_error(ira, &fn_ref->base, | 19924 | ir_add_error(ira, &fn_ref->base, |
| 19917 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); | 19925 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| ... | @@ -21009,7 +21017,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP | ... | @@ -21009,7 +21017,7 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP |
| 21009 | | 21017 | |
| 21010 | static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, | 21018 | static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 21011 | ZigType *bare_struct_type, Buf *field_name, IrInst* source_instr, | 21019 | ZigType *bare_struct_type, Buf *field_name, IrInst* source_instr, |
| 21012 | IrInstGen *container_ptr, ZigType *container_type) | 21020 | IrInstGen *container_ptr, IrInst *container_ptr_src, ZigType *container_type) |
| 21013 | { | 21021 | { |
| 21014 | if (!is_slice(bare_struct_type)) { | 21022 | if (!is_slice(bare_struct_type)) { |
| 21015 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); | 21023 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); |
| ... | @@ -21030,7 +21038,8 @@ static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -21030,7 +21038,8 @@ static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 21030 | if (type_is_invalid(fn_entry->type_entry)) | 21038 | if (type_is_invalid(fn_entry->type_entry)) |
| 21031 | return ira->codegen->invalid_inst_gen; | 21039 | return ira->codegen->invalid_inst_gen; |
| 21032 | | 21040 | |
| 21033 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, source_instr, fn_entry, container_ptr); | 21041 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, source_instr, fn_entry, container_ptr, |
| | 21042 | container_ptr_src); |
| 21034 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); | 21043 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); |
| 21035 | } else if (tld->id == TldIdVar) { | 21044 | } else if (tld->id == TldIdVar) { |
| 21036 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); | 21045 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); |
| ... | @@ -21049,7 +21058,8 @@ static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -21049,7 +21058,8 @@ static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 21049 | if (var->const_value->type->id == ZigTypeIdFn) { | 21058 | if (var->const_value->type->id == ZigTypeIdFn) { |
| 21050 | ir_assert(var->const_value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr); | 21059 | ir_assert(var->const_value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr); |
| 21051 | ZigFn *fn = var->const_value->data.x_ptr.data.fn.fn_entry; | 21060 | ZigFn *fn = var->const_value->data.x_ptr.data.fn.fn_entry; |
| 21052 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, source_instr, fn, container_ptr); | 21061 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, source_instr, fn, container_ptr, |
| | 21062 | container_ptr_src); |
| 21053 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); | 21063 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); |
| 21054 | } | 21064 | } |
| 21055 | } | 21065 | } |
| ... | @@ -21213,7 +21223,8 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | ... | @@ -21213,7 +21223,8 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 21213 | } | 21223 | } |
| 21214 | | 21224 | |
| 21215 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | 21225 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 21216 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type, bool initializing) | 21226 | IrInst* source_instr, IrInstGen *container_ptr, IrInst *container_ptr_src, |
| | 21227 | ZigType *container_type, bool initializing) |
| 21217 | { | 21228 | { |
| 21218 | Error err; | 21229 | Error err; |
| 21219 | | 21230 | |
| ... | @@ -21235,13 +21246,13 @@ static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name | ... | @@ -21235,13 +21246,13 @@ static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name |
| 21235 | return ir_analyze_struct_field_ptr(ira, source_instr, field, container_ptr, bare_type, initializing); | 21246 | return ir_analyze_struct_field_ptr(ira, source_instr, field, container_ptr, bare_type, initializing); |
| 21236 | } else { | 21247 | } else { |
| 21237 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, | 21248 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, |
| 21238 | source_instr, container_ptr, container_type); | 21249 | source_instr, container_ptr, container_ptr_src, container_type); |
| 21239 | } | 21250 | } |
| 21240 | } | 21251 | } |
| 21241 | | 21252 | |
| 21242 | if (bare_type->id == ZigTypeIdEnum) { | 21253 | if (bare_type->id == ZigTypeIdEnum) { |
| 21243 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, | 21254 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, |
| 21244 | source_instr, container_ptr, container_type); | 21255 | source_instr, container_ptr, container_ptr_src, container_type); |
| 21245 | } | 21256 | } |
| 21246 | | 21257 | |
| 21247 | if (bare_type->id == ZigTypeIdUnion) { | 21258 | if (bare_type->id == ZigTypeIdUnion) { |
| ... | @@ -21251,7 +21262,7 @@ static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name | ... | @@ -21251,7 +21262,7 @@ static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name |
| 21251 | TypeUnionField *field = find_union_type_field(bare_type, field_name); | 21262 | TypeUnionField *field = find_union_type_field(bare_type, field_name); |
| 21252 | if (field == nullptr) { | 21263 | if (field == nullptr) { |
| 21253 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, | 21264 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, |
| 21254 | source_instr, container_ptr, container_type); | 21265 | source_instr, container_ptr, container_ptr_src, container_type); |
| 21255 | } | 21266 | } |
| 21256 | | 21267 | |
| 21257 | ZigType *field_type = resolve_union_field_type(ira->codegen, field); | 21268 | ZigType *field_type = resolve_union_field_type(ira->codegen, field); |
| ... | @@ -21445,10 +21456,14 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel | ... | @@ -21445,10 +21456,14 @@ static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFiel |
| 21445 | if (container_type->id == ZigTypeIdPointer) { | 21456 | if (container_type->id == ZigTypeIdPointer) { |
| 21446 | ZigType *bare_type = container_ref_type(container_type); | 21457 | ZigType *bare_type = container_ref_type(container_type); |
| 21447 | IrInstGen *container_child = ir_get_deref(ira, &field_ptr_instruction->base.base, container_ptr, nullptr); | 21458 | IrInstGen *container_child = ir_get_deref(ira, &field_ptr_instruction->base.base, container_ptr, nullptr); |
| 21448 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base.base, container_child, bare_type, field_ptr_instruction->initializing); | 21459 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base.base, |
| | 21460 | container_child, &field_ptr_instruction->container_ptr->base, bare_type, |
| | 21461 | field_ptr_instruction->initializing); |
| 21449 | return result; | 21462 | return result; |
| 21450 | } else { | 21463 | } else { |
| 21451 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base.base, container_ptr, container_type, field_ptr_instruction->initializing); | 21464 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base.base, |
| | 21465 | container_ptr, &field_ptr_instruction->container_ptr->base, container_type, |
| | 21466 | field_ptr_instruction->initializing); |
| 21452 | return result; | 21467 | return result; |
| 21453 | } | 21468 | } |
| 21454 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { | 21469 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { |
| ... | @@ -25096,7 +25111,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch | ... | @@ -25096,7 +25111,7 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 25096 | | 25111 | |
| 25097 | // TODO let this be volatile | 25112 | // TODO let this be volatile |
| 25098 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 25113 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 25099 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); | 25114 | IrInstGen *casted_ptr = ir_implicit_cast2(ira, &instruction->ptr->base, ptr, ptr_type); |
| 25100 | if (type_is_invalid(casted_ptr->value->type)) | 25115 | if (type_is_invalid(casted_ptr->value->type)) |
| 25101 | return ira->codegen->invalid_inst_gen; | 25116 | return ira->codegen->invalid_inst_gen; |
| 25102 | | 25117 | |
| ... | @@ -25124,11 +25139,11 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch | ... | @@ -25124,11 +25139,11 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch |
| 25124 | if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order)) | 25139 | if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order)) |
| 25125 | return ira->codegen->invalid_inst_gen; | 25140 | return ira->codegen->invalid_inst_gen; |
| 25126 | | 25141 | |
| 25127 | IrInstGen *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); | 25142 | IrInstGen *casted_cmp_value = ir_implicit_cast2(ira, &instruction->cmp_value->base, cmp_value, operand_type); |
| 25128 | if (type_is_invalid(casted_cmp_value->value->type)) | 25143 | if (type_is_invalid(casted_cmp_value->value->type)) |
| 25129 | return ira->codegen->invalid_inst_gen; | 25144 | return ira->codegen->invalid_inst_gen; |
| 25130 | | 25145 | |
| 25131 | IrInstGen *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); | 25146 | IrInstGen *casted_new_value = ir_implicit_cast2(ira, &instruction->new_value->base, new_value, operand_type); |
| 25132 | if (type_is_invalid(casted_new_value->value->type)) | 25147 | if (type_is_invalid(casted_new_value->value->type)) |
| 25133 | return ira->codegen->invalid_inst_gen; | 25148 | return ira->codegen->invalid_inst_gen; |
| 25134 | | 25149 | |
| ... | @@ -25219,7 +25234,7 @@ static IrInstGen *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstSrcTrunc | ... | @@ -25219,7 +25234,7 @@ static IrInstGen *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstSrcTrunc |
| 25219 | } | 25234 | } |
| 25220 | | 25235 | |
| 25221 | if (dest_type->id == ZigTypeIdComptimeInt) { | 25236 | if (dest_type->id == ZigTypeIdComptimeInt) { |
| 25222 | return ir_implicit_cast(ira, target, dest_type); | 25237 | return ir_implicit_cast2(ira, &instruction->target->base, target, dest_type); |
| 25223 | } | 25238 | } |
| 25224 | | 25239 | |
| 25225 | if (instr_is_comptime(target)) { | 25240 | if (instr_is_comptime(target)) { |
| ... | @@ -25273,7 +25288,7 @@ static IrInstGen *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstSrcIntCa | ... | @@ -25273,7 +25288,7 @@ static IrInstGen *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstSrcIntCa |
| 25273 | } | 25288 | } |
| 25274 | | 25289 | |
| 25275 | if (instr_is_comptime(target)) { | 25290 | if (instr_is_comptime(target)) { |
| 25276 | return ir_implicit_cast(ira, target, dest_type); | 25291 | return ir_implicit_cast2(ira, &instruction->target->base, target, dest_type); |
| 25277 | } | 25292 | } |
| 25278 | | 25293 | |
| 25279 | if (dest_type->id == ZigTypeIdComptimeInt) { | 25294 | if (dest_type->id == ZigTypeIdComptimeInt) { |
| ... | @@ -25401,7 +25416,7 @@ static IrInstGen *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstSrcFro | ... | @@ -25401,7 +25416,7 @@ static IrInstGen *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstSrcFro |
| 25401 | src_ptr_align, 0, 0, false); | 25416 | src_ptr_align, 0, 0, false); |
| 25402 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); | 25417 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 25403 | | 25418 | |
| 25404 | IrInstGen *casted_value = ir_implicit_cast(ira, target, u8_slice); | 25419 | IrInstGen *casted_value = ir_implicit_cast2(ira, &instruction->target->base, target, u8_slice); |
| 25405 | if (type_is_invalid(casted_value->value->type)) | 25420 | if (type_is_invalid(casted_value->value->type)) |
| 25406 | return ira->codegen->invalid_inst_gen; | 25421 | return ira->codegen->invalid_inst_gen; |
| 25407 | | 25422 | |