| ... | @@ -16190,14 +16190,13 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp | ... | @@ -16190,14 +16190,13 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp |
| 16190 | result->value.special = ConstValSpecialLazy; | 16190 | result->value.special = ConstValSpecialLazy; |
| 16191 | | 16191 | |
| 16192 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1); | 16192 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1); |
| | 16193 | lazy_opt_type->ira = ira; |
| 16193 | result->value.data.x_lazy = &lazy_opt_type->base; | 16194 | result->value.data.x_lazy = &lazy_opt_type->base; |
| 16194 | lazy_opt_type->base.id = LazyValueIdOptType; | 16195 | lazy_opt_type->base.id = LazyValueIdOptType; |
| 16195 | lazy_opt_type->base.exec = ira->new_irb.exec; | | |
| 16196 | | 16196 | |
| 16197 | lazy_opt_type->payload_type_val = ir_resolve_type_lazy(ira, instruction->value->child); | 16197 | lazy_opt_type->payload_type = instruction->value->child; |
| 16198 | if (lazy_opt_type->payload_type_val == nullptr) | 16198 | if (ir_resolve_type_lazy(ira, lazy_opt_type->payload_type) == nullptr) |
| 16199 | return ira->codegen->invalid_instruction; | 16199 | return ira->codegen->invalid_instruction; |
| 16200 | lazy_opt_type->payload_type_src_node = instruction->value->source_node; | | |
| 16201 | | 16200 | |
| 16202 | return result; | 16201 | return result; |
| 16203 | } | 16202 | } |
| ... | @@ -17936,13 +17935,13 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -17936,13 +17935,13 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 17936 | result->value.special = ConstValSpecialLazy; | 17935 | result->value.special = ConstValSpecialLazy; |
| 17937 | | 17936 | |
| 17938 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1); | 17937 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1); |
| | 17938 | lazy_slice_type->ira = ira; |
| 17939 | result->value.data.x_lazy = &lazy_slice_type->base; | 17939 | result->value.data.x_lazy = &lazy_slice_type->base; |
| 17940 | lazy_slice_type->base.id = LazyValueIdSliceType; | 17940 | lazy_slice_type->base.id = LazyValueIdSliceType; |
| 17941 | lazy_slice_type->base.exec = ira->new_irb.exec; | | |
| 17942 | | 17941 | |
| 17943 | if (slice_type_instruction->align_value != nullptr) { | 17942 | if (slice_type_instruction->align_value != nullptr) { |
| 17944 | lazy_slice_type->align_val = ir_resolve_const(ira, slice_type_instruction->align_value->child, LazyOk); | 17943 | lazy_slice_type->align_inst = slice_type_instruction->align_value->child; |
| 17945 | if (lazy_slice_type->align_val == nullptr) | 17944 | if (ir_resolve_const(ira, lazy_slice_type->align_inst, LazyOk) == nullptr) |
| 17946 | return ira->codegen->invalid_instruction; | 17945 | return ira->codegen->invalid_instruction; |
| 17947 | } | 17946 | } |
| 17948 | | 17947 | |
| ... | @@ -22371,14 +22370,13 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct | ... | @@ -22371,14 +22370,13 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct |
| 22371 | result->value.special = ConstValSpecialLazy; | 22370 | result->value.special = ConstValSpecialLazy; |
| 22372 | | 22371 | |
| 22373 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1); | 22372 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1); |
| | 22373 | lazy_align_of->ira = ira; |
| 22374 | result->value.data.x_lazy = &lazy_align_of->base; | 22374 | result->value.data.x_lazy = &lazy_align_of->base; |
| 22375 | lazy_align_of->base.id = LazyValueIdAlignOf; | 22375 | lazy_align_of->base.id = LazyValueIdAlignOf; |
| 22376 | lazy_align_of->base.exec = ira->new_irb.exec; | | |
| 22377 | | 22376 | |
| 22378 | lazy_align_of->target_type_val = ir_resolve_type_lazy(ira, instruction->type_value->child); | 22377 | lazy_align_of->target_type = instruction->type_value->child; |
| 22379 | if (lazy_align_of->target_type_val == nullptr) | 22378 | if (ir_resolve_type_lazy(ira, lazy_align_of->target_type) == nullptr) |
| 22380 | return ira->codegen->invalid_instruction; | 22379 | return ira->codegen->invalid_instruction; |
| 22381 | lazy_align_of->target_type_src_node = instruction->type_value->source_node; | | |
| 22382 | | 22380 | |
| 22383 | return result; | 22381 | return result; |
| 22384 | } | 22382 | } |
| ... | @@ -22856,9 +22854,9 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -22856,9 +22854,9 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 22856 | result->value.special = ConstValSpecialLazy; | 22854 | result->value.special = ConstValSpecialLazy; |
| 22857 | | 22855 | |
| 22858 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1); | 22856 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1); |
| | 22857 | lazy_fn_type->ira = ira; |
| 22859 | result->value.data.x_lazy = &lazy_fn_type->base; | 22858 | result->value.data.x_lazy = &lazy_fn_type->base; |
| 22860 | lazy_fn_type->base.id = LazyValueIdFnType; | 22859 | lazy_fn_type->base.id = LazyValueIdFnType; |
| 22861 | lazy_fn_type->base.exec = ira->new_irb.exec; | | |
| 22862 | | 22860 | |
| 22863 | if (proto_node->data.fn_proto.auto_err_set) { | 22861 | if (proto_node->data.fn_proto.auto_err_set) { |
| 22864 | ir_add_error(ira, &instruction->base, | 22862 | ir_add_error(ira, &instruction->base, |
| ... | @@ -22868,8 +22866,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -22868,8 +22866,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 22868 | | 22866 | |
| 22869 | size_t param_count = proto_node->data.fn_proto.params.length; | 22867 | size_t param_count = proto_node->data.fn_proto.params.length; |
| 22870 | lazy_fn_type->proto_node = proto_node; | 22868 | lazy_fn_type->proto_node = proto_node; |
| 22871 | lazy_fn_type->param_types = allocate<ConstExprValue *>(param_count); | 22869 | lazy_fn_type->param_types = allocate<IrInstruction *>(param_count); |
| 22872 | lazy_fn_type->param_type_src_nodes = allocate<AstNode *>(param_count); | | |
| 22873 | | 22870 | |
| 22874 | for (size_t param_index = 0; param_index < param_count; param_index += 1) { | 22871 | for (size_t param_index = 0; param_index < param_count; param_index += 1) { |
| 22875 | AstNode *param_node = proto_node->data.fn_proto.params.at(param_index); | 22872 | AstNode *param_node = proto_node->data.fn_proto.params.at(param_index); |
| ... | @@ -22895,23 +22892,20 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -22895,23 +22892,20 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 22895 | IrInstruction *param_type_value = instruction->param_types[param_index]->child; | 22892 | IrInstruction *param_type_value = instruction->param_types[param_index]->child; |
| 22896 | if (type_is_invalid(param_type_value->value.type)) | 22893 | if (type_is_invalid(param_type_value->value.type)) |
| 22897 | return ira->codegen->invalid_instruction; | 22894 | return ira->codegen->invalid_instruction; |
| 22898 | ConstExprValue *param_type_val = ir_resolve_const(ira, param_type_value, LazyOk); | 22895 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) |
| 22899 | if (param_type_val == nullptr) | | |
| 22900 | return ira->codegen->invalid_instruction; | 22896 | return ira->codegen->invalid_instruction; |
| 22901 | lazy_fn_type->param_types[param_index] = param_type_val; | 22897 | lazy_fn_type->param_types[param_index] = param_type_value; |
| 22902 | lazy_fn_type->param_type_src_nodes[param_index] = instruction->param_types[param_index]->source_node; | | |
| 22903 | } | 22898 | } |
| 22904 | | 22899 | |
| 22905 | if (instruction->align_value != nullptr) { | 22900 | if (instruction->align_value != nullptr) { |
| 22906 | lazy_fn_type->align_val = ir_resolve_const(ira, instruction->align_value->child, LazyOk); | 22901 | lazy_fn_type->align_inst = instruction->align_value->child; |
| 22907 | if (lazy_fn_type->align_val == nullptr) | 22902 | if (ir_resolve_const(ira, lazy_fn_type->align_inst, LazyOk) == nullptr) |
| 22908 | return ira->codegen->invalid_instruction; | 22903 | return ira->codegen->invalid_instruction; |
| 22909 | } | 22904 | } |
| 22910 | | 22905 | |
| 22911 | lazy_fn_type->return_type = ir_resolve_const(ira, instruction->return_type->child, LazyOk); | 22906 | lazy_fn_type->return_type = instruction->return_type->child; |
| 22912 | if (lazy_fn_type->return_type == nullptr) | 22907 | if (ir_resolve_const(ira, lazy_fn_type->return_type, LazyOk) == nullptr) |
| 22913 | return ira->codegen->invalid_instruction; | 22908 | return ira->codegen->invalid_instruction; |
| 22914 | lazy_fn_type->return_type_src_node = instruction->return_type->source_node; | | |
| 22915 | | 22909 | |
| 22916 | return result; | 22910 | return result; |
| 22917 | } | 22911 | } |
| ... | @@ -23890,18 +23884,17 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct | ... | @@ -23890,18 +23884,17 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct |
| 23890 | result->value.special = ConstValSpecialLazy; | 23884 | result->value.special = ConstValSpecialLazy; |
| 23891 | | 23885 | |
| 23892 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1); | 23886 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1); |
| | 23887 | lazy_ptr_type->ira = ira; |
| 23893 | result->value.data.x_lazy = &lazy_ptr_type->base; | 23888 | result->value.data.x_lazy = &lazy_ptr_type->base; |
| 23894 | lazy_ptr_type->base.id = LazyValueIdPtrType; | 23889 | lazy_ptr_type->base.id = LazyValueIdPtrType; |
| 23895 | lazy_ptr_type->base.exec = ira->new_irb.exec; | | |
| 23896 | | 23890 | |
| 23897 | lazy_ptr_type->elem_type_val = ir_resolve_type_lazy(ira, instruction->child_type->child); | 23891 | lazy_ptr_type->elem_type = instruction->child_type->child; |
| 23898 | if (lazy_ptr_type->elem_type_val == nullptr) | 23892 | if (ir_resolve_type_lazy(ira, lazy_ptr_type->elem_type) == nullptr) |
| 23899 | return ira->codegen->invalid_instruction; | 23893 | return ira->codegen->invalid_instruction; |
| 23900 | lazy_ptr_type->elem_type_src_node = instruction->child_type->source_node; | | |
| 23901 | | 23894 | |
| 23902 | if (instruction->align_value != nullptr) { | 23895 | if (instruction->align_value != nullptr) { |
| 23903 | lazy_ptr_type->align_val = ir_resolve_const(ira, instruction->align_value->child, LazyOk); | 23896 | lazy_ptr_type->align_inst = instruction->align_value->child; |
| 23904 | if (lazy_ptr_type->align_val == nullptr) | 23897 | if (ir_resolve_const(ira, lazy_ptr_type->align_inst, LazyOk) == nullptr) |
| 23905 | return ira->codegen->invalid_instruction; | 23898 | return ira->codegen->invalid_instruction; |
| 23906 | } | 23899 | } |
| 23907 | | 23900 | |
| ... | @@ -25446,9 +25439,7 @@ bool ir_has_side_effects(IrInstruction *instruction) { | ... | @@ -25446,9 +25439,7 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 25446 | zig_unreachable(); | 25439 | zig_unreachable(); |
| 25447 | } | 25440 | } |
| 25448 | | 25441 | |
| 25449 | static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 25442 | static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, LazyValueFnType *lazy_fn_type) { |
| 25450 | LazyValueFnType *lazy_fn_type) | | |
| 25451 | { | | |
| 25452 | Error err; | 25443 | Error err; |
| 25453 | AstNode *proto_node = lazy_fn_type->proto_node; | 25444 | AstNode *proto_node = lazy_fn_type->proto_node; |
| 25454 | | 25445 | |
| ... | @@ -25465,7 +25456,7 @@ static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, As | ... | @@ -25465,7 +25456,7 @@ static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, As |
| 25465 | fn_type_id.param_count = fn_type_id.next_param_index; | 25456 | fn_type_id.param_count = fn_type_id.next_param_index; |
| 25466 | continue; | 25457 | continue; |
| 25467 | } else if (fn_type_id.cc == CallingConventionUnspecified) { | 25458 | } else if (fn_type_id.cc == CallingConventionUnspecified) { |
| 25468 | return get_generic_fn_type(codegen, &fn_type_id); | 25459 | return get_generic_fn_type(ira->codegen, &fn_type_id); |
| 25469 | } else { | 25460 | } else { |
| 25470 | zig_unreachable(); | 25461 | zig_unreachable(); |
| 25471 | } | 25462 | } |
| ... | @@ -25475,34 +25466,33 @@ static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, As | ... | @@ -25475,34 +25466,33 @@ static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, As |
| 25475 | | 25466 | |
| 25476 | if (lazy_fn_type->param_types[fn_type_id.next_param_index] == nullptr) { | 25467 | if (lazy_fn_type->param_types[fn_type_id.next_param_index] == nullptr) { |
| 25477 | param_info->type = nullptr; | 25468 | param_info->type = nullptr; |
| 25478 | return get_generic_fn_type(codegen, &fn_type_id); | 25469 | return get_generic_fn_type(ira->codegen, &fn_type_id); |
| 25479 | } else { | 25470 | } else { |
| 25480 | AstNode *param_src_node = lazy_fn_type->param_type_src_nodes[fn_type_id.next_param_index]; | 25471 | IrInstruction *param_type_inst = lazy_fn_type->param_types[fn_type_id.next_param_index]; |
| 25481 | ZigType *param_type = ir_resolve_const_type(codegen, exec, param_src_node, | 25472 | ZigType *param_type = ir_resolve_type(ira, param_type_inst); |
| 25482 | lazy_fn_type->param_types[fn_type_id.next_param_index]); | | |
| 25483 | if (type_is_invalid(param_type)) | 25473 | if (type_is_invalid(param_type)) |
| 25484 | return nullptr; | 25474 | return nullptr; |
| 25485 | switch (type_requires_comptime(codegen, param_type)) { | 25475 | switch (type_requires_comptime(ira->codegen, param_type)) { |
| 25486 | case ReqCompTimeYes: | 25476 | case ReqCompTimeYes: |
| 25487 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 25477 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 25488 | exec_add_error_node(codegen, exec, param_src_node, | 25478 | ir_add_error(ira, param_type_inst, |
| 25489 | buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'", | 25479 | buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'", |
| 25490 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); | 25480 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); |
| 25491 | return nullptr; | 25481 | return nullptr; |
| 25492 | } | 25482 | } |
| 25493 | param_info->type = param_type; | 25483 | param_info->type = param_type; |
| 25494 | fn_type_id.next_param_index += 1; | 25484 | fn_type_id.next_param_index += 1; |
| 25495 | return get_generic_fn_type(codegen, &fn_type_id); | 25485 | return get_generic_fn_type(ira->codegen, &fn_type_id); |
| 25496 | case ReqCompTimeInvalid: | 25486 | case ReqCompTimeInvalid: |
| 25497 | return nullptr; | 25487 | return nullptr; |
| 25498 | case ReqCompTimeNo: | 25488 | case ReqCompTimeNo: |
| 25499 | break; | 25489 | break; |
| 25500 | } | 25490 | } |
| 25501 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 25491 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 25502 | if ((err = type_resolve(codegen, param_type, ResolveStatusZeroBitsKnown))) | 25492 | if ((err = type_resolve(ira->codegen, param_type, ResolveStatusZeroBitsKnown))) |
| 25503 | return nullptr; | 25493 | return nullptr; |
| 25504 | if (!type_has_bits(param_type)) { | 25494 | if (!type_has_bits(param_type)) { |
| 25505 | exec_add_error_node(codegen, exec, param_src_node, | 25495 | ir_add_error(ira, param_type_inst, |
| 25506 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", | 25496 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", |
| 25507 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); | 25497 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); |
| 25508 | return nullptr; | 25498 | return nullptr; |
| ... | @@ -25512,37 +25502,35 @@ static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, As | ... | @@ -25512,37 +25502,35 @@ static ZigType *ir_resolve_lazy_fn_type(CodeGen *codegen, IrExecutable *exec, As |
| 25512 | } | 25502 | } |
| 25513 | } | 25503 | } |
| 25514 | | 25504 | |
| 25515 | if (lazy_fn_type->align_val != nullptr) { | 25505 | if (lazy_fn_type->align_inst != nullptr) { |
| 25516 | if (!ir_resolve_const_align(codegen, exec, source_node, lazy_fn_type->align_val, &fn_type_id.alignment)) | 25506 | if (!ir_resolve_align(ira, lazy_fn_type->align_inst, &fn_type_id.alignment)) |
| 25517 | return nullptr; | 25507 | return nullptr; |
| 25518 | } | 25508 | } |
| 25519 | | 25509 | |
| 25520 | fn_type_id.return_type = ir_resolve_const_type(codegen, exec, lazy_fn_type->return_type_src_node, | 25510 | fn_type_id.return_type = ir_resolve_type(ira, lazy_fn_type->return_type); |
| 25521 | lazy_fn_type->return_type); | | |
| 25522 | if (type_is_invalid(fn_type_id.return_type)) | 25511 | if (type_is_invalid(fn_type_id.return_type)) |
| 25523 | return nullptr; | 25512 | return nullptr; |
| 25524 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { | 25513 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { |
| 25525 | exec_add_error_node(codegen, exec, lazy_fn_type->return_type_src_node, | 25514 | ir_add_error(ira, lazy_fn_type->return_type, buf_create_from_str("return type cannot be opaque")); |
| 25526 | buf_create_from_str("return type cannot be opaque")); | | |
| 25527 | return nullptr; | 25515 | return nullptr; |
| 25528 | } | 25516 | } |
| 25529 | | 25517 | |
| 25530 | return get_fn_type(codegen, &fn_type_id); | 25518 | return get_fn_type(ira->codegen, &fn_type_id); |
| 25531 | } | 25519 | } |
| 25532 | | 25520 | |
| 25533 | static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstExprValue *val) { | 25521 | static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 25534 | Error err; | 25522 | Error err; |
| 25535 | if (val->special != ConstValSpecialLazy) | 25523 | if (val->special != ConstValSpecialLazy) |
| 25536 | return ErrorNone; | 25524 | return ErrorNone; |
| 25537 | IrExecutable *exec = val->data.x_lazy->exec; | | |
| 25538 | switch (val->data.x_lazy->id) { | 25525 | switch (val->data.x_lazy->id) { |
| 25539 | case LazyValueIdInvalid: | 25526 | case LazyValueIdInvalid: |
| 25540 | zig_unreachable(); | 25527 | zig_unreachable(); |
| 25541 | case LazyValueIdAlignOf: { | 25528 | case LazyValueIdAlignOf: { |
| 25542 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(val->data.x_lazy); | 25529 | LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(val->data.x_lazy); |
| | 25530 | IrAnalyze *ira = lazy_align_of->ira; |
| 25543 | | 25531 | |
| 25544 | if (lazy_align_of->target_type_val->special == ConstValSpecialStatic) { | 25532 | if (lazy_align_of->target_type->value.special == ConstValSpecialStatic) { |
| 25545 | switch (lazy_align_of->target_type_val->data.x_type->id) { | 25533 | switch (lazy_align_of->target_type->value.data.x_type->id) { |
| 25546 | case ZigTypeIdInvalid: | 25534 | case ZigTypeIdInvalid: |
| 25547 | zig_unreachable(); | 25535 | zig_unreachable(); |
| 25548 | case ZigTypeIdMetaType: | 25536 | case ZigTypeIdMetaType: |
| ... | @@ -25556,9 +25544,9 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx | ... | @@ -25556,9 +25544,9 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx |
| 25556 | case ZigTypeIdArgTuple: | 25544 | case ZigTypeIdArgTuple: |
| 25557 | case ZigTypeIdVoid: | 25545 | case ZigTypeIdVoid: |
| 25558 | case ZigTypeIdOpaque: | 25546 | case ZigTypeIdOpaque: |
| 25559 | exec_add_error_node(codegen, exec, lazy_align_of->target_type_src_node, | 25547 | ir_add_error(ira, lazy_align_of->target_type, |
| 25560 | buf_sprintf("no align available for type '%s'", | 25548 | buf_sprintf("no align available for type '%s'", |
| 25561 | buf_ptr(&lazy_align_of->target_type_val->data.x_type->name))); | 25549 | buf_ptr(&lazy_align_of->target_type->value.data.x_type->name))); |
| 25562 | return ErrorSemanticAnalyzeFail; | 25550 | return ErrorSemanticAnalyzeFail; |
| 25563 | case ZigTypeIdBool: | 25551 | case ZigTypeIdBool: |
| 25564 | case ZigTypeIdInt: | 25552 | case ZigTypeIdInt: |
| ... | @@ -25580,8 +25568,11 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx | ... | @@ -25580,8 +25568,11 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx |
| 25580 | } | 25568 | } |
| 25581 | | 25569 | |
| 25582 | uint32_t align_in_bytes; | 25570 | uint32_t align_in_bytes; |
| 25583 | if ((err = type_val_resolve_abi_align(codegen, lazy_align_of->target_type_val, &align_in_bytes))) | 25571 | if ((err = type_val_resolve_abi_align(ira->codegen, &lazy_align_of->target_type->value, |
| | 25572 | &align_in_bytes))) |
| | 25573 | { |
| 25584 | return err; | 25574 | return err; |
| | 25575 | } |
| 25585 | | 25576 | |
| 25586 | val->special = ConstValSpecialStatic; | 25577 | val->special = ConstValSpecialStatic; |
| 25587 | assert(val->type->id == ZigTypeIdComptimeInt); | 25578 | assert(val->type->id == ZigTypeIdComptimeInt); |
| ... | @@ -25590,69 +25581,72 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx | ... | @@ -25590,69 +25581,72 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx |
| 25590 | } | 25581 | } |
| 25591 | case LazyValueIdSliceType: { | 25582 | case LazyValueIdSliceType: { |
| 25592 | LazyValueSliceType *lazy_slice_type = reinterpret_cast<LazyValueSliceType *>(val->data.x_lazy); | 25583 | LazyValueSliceType *lazy_slice_type = reinterpret_cast<LazyValueSliceType *>(val->data.x_lazy); |
| | 25584 | IrAnalyze *ira = lazy_slice_type->ira; |
| | 25585 | |
| 25593 | uint32_t align_bytes = 0; | 25586 | uint32_t align_bytes = 0; |
| 25594 | if (lazy_slice_type->align_val != nullptr) { | 25587 | if (lazy_slice_type->align_inst != nullptr) { |
| 25595 | if (!ir_resolve_const_align(codegen, exec, source_node, lazy_slice_type->align_val, &align_bytes)) | 25588 | if (!ir_resolve_align(ira, lazy_slice_type->align_inst, &align_bytes)) |
| 25596 | return ErrorSemanticAnalyzeFail; | 25589 | return ErrorSemanticAnalyzeFail; |
| 25597 | } | 25590 | } |
| 25598 | ResolveStatus needed_status = (align_bytes == 0) ? | 25591 | ResolveStatus needed_status = (align_bytes == 0) ? |
| 25599 | ResolveStatusZeroBitsKnown : ResolveStatusAlignmentKnown; | 25592 | ResolveStatusZeroBitsKnown : ResolveStatusAlignmentKnown; |
| 25600 | if ((err = type_resolve(codegen, lazy_slice_type->elem_type, needed_status))) | 25593 | if ((err = type_resolve(ira->codegen, lazy_slice_type->elem_type, needed_status))) |
| 25601 | return err; | 25594 | return err; |
| 25602 | ZigType *slice_ptr_type = get_pointer_to_type_extra(codegen, lazy_slice_type->elem_type, | 25595 | ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, lazy_slice_type->elem_type, |
| 25603 | lazy_slice_type->is_const, lazy_slice_type->is_volatile, PtrLenUnknown, align_bytes, | 25596 | lazy_slice_type->is_const, lazy_slice_type->is_volatile, PtrLenUnknown, align_bytes, |
| 25604 | 0, 0, lazy_slice_type->is_allowzero); | 25597 | 0, 0, lazy_slice_type->is_allowzero); |
| 25605 | val->special = ConstValSpecialStatic; | 25598 | val->special = ConstValSpecialStatic; |
| 25606 | assert(val->type->id == ZigTypeIdMetaType); | 25599 | assert(val->type->id == ZigTypeIdMetaType); |
| 25607 | val->data.x_type = get_slice_type(codegen, slice_ptr_type); | 25600 | val->data.x_type = get_slice_type(ira->codegen, slice_ptr_type); |
| 25608 | return ErrorNone; | 25601 | return ErrorNone; |
| 25609 | } | 25602 | } |
| 25610 | case LazyValueIdPtrType: { | 25603 | case LazyValueIdPtrType: { |
| 25611 | LazyValuePtrType *lazy_ptr_type = reinterpret_cast<LazyValuePtrType *>(val->data.x_lazy); | 25604 | LazyValuePtrType *lazy_ptr_type = reinterpret_cast<LazyValuePtrType *>(val->data.x_lazy); |
| | 25605 | IrAnalyze *ira = lazy_ptr_type->ira; |
| | 25606 | |
| 25612 | uint32_t align_bytes = 0; | 25607 | uint32_t align_bytes = 0; |
| 25613 | if (lazy_ptr_type->align_val != nullptr) { | 25608 | if (lazy_ptr_type->align_inst != nullptr) { |
| 25614 | if (!ir_resolve_const_align(codegen, exec, source_node, lazy_ptr_type->align_val, &align_bytes)) | 25609 | if (!ir_resolve_align(ira, lazy_ptr_type->align_inst, &align_bytes)) |
| 25615 | return ErrorSemanticAnalyzeFail; | 25610 | return ErrorSemanticAnalyzeFail; |
| 25616 | } | 25611 | } |
| 25617 | ZigType *elem_type = ir_resolve_const_type(codegen, exec, lazy_ptr_type->elem_type_src_node, | 25612 | ZigType *elem_type = ir_resolve_type(ira, lazy_ptr_type->elem_type); |
| 25618 | lazy_ptr_type->elem_type_val); | | |
| 25619 | if (type_is_invalid(elem_type)) | 25613 | if (type_is_invalid(elem_type)) |
| 25620 | return ErrorSemanticAnalyzeFail; | 25614 | return ErrorSemanticAnalyzeFail; |
| 25621 | | 25615 | |
| 25622 | if (elem_type->id == ZigTypeIdUnreachable) { | 25616 | if (elem_type->id == ZigTypeIdUnreachable) { |
| 25623 | exec_add_error_node(codegen, exec, lazy_ptr_type->elem_type_src_node, | 25617 | ir_add_error(ira, lazy_ptr_type->elem_type, |
| 25624 | buf_create_from_str("pointer to noreturn not allowed")); | 25618 | buf_create_from_str("pointer to noreturn not allowed")); |
| 25625 | return ErrorSemanticAnalyzeFail; | 25619 | return ErrorSemanticAnalyzeFail; |
| 25626 | } else if (elem_type->id == ZigTypeIdOpaque && lazy_ptr_type->ptr_len == PtrLenUnknown) { | 25620 | } else if (elem_type->id == ZigTypeIdOpaque && lazy_ptr_type->ptr_len == PtrLenUnknown) { |
| 25627 | exec_add_error_node(codegen, exec, lazy_ptr_type->elem_type_src_node, | 25621 | ir_add_error(ira, lazy_ptr_type->elem_type, |
| 25628 | buf_create_from_str("unknown-length pointer to opaque")); | 25622 | buf_create_from_str("unknown-length pointer to opaque")); |
| 25629 | return ErrorSemanticAnalyzeFail; | 25623 | return ErrorSemanticAnalyzeFail; |
| 25630 | } else if (lazy_ptr_type->ptr_len == PtrLenC) { | 25624 | } else if (lazy_ptr_type->ptr_len == PtrLenC) { |
| 25631 | if (!type_allowed_in_extern(codegen, elem_type)) { | 25625 | if (!type_allowed_in_extern(ira->codegen, elem_type)) { |
| 25632 | exec_add_error_node(codegen, exec, lazy_ptr_type->elem_type_src_node, | 25626 | ir_add_error(ira, lazy_ptr_type->elem_type, |
| 25633 | buf_sprintf("C pointers cannot point to non-C-ABI-compatible type '%s'", | 25627 | buf_sprintf("C pointers cannot point to non-C-ABI-compatible type '%s'", |
| 25634 | buf_ptr(&elem_type->name))); | 25628 | buf_ptr(&elem_type->name))); |
| 25635 | return ErrorSemanticAnalyzeFail; | 25629 | return ErrorSemanticAnalyzeFail; |
| 25636 | } else if (elem_type->id == ZigTypeIdOpaque) { | 25630 | } else if (elem_type->id == ZigTypeIdOpaque) { |
| 25637 | exec_add_error_node(codegen, exec, lazy_ptr_type->elem_type_src_node, | 25631 | ir_add_error(ira, lazy_ptr_type->elem_type, |
| 25638 | buf_sprintf("C pointers cannot point opaque types")); | 25632 | buf_sprintf("C pointers cannot point opaque types")); |
| 25639 | return ErrorSemanticAnalyzeFail; | 25633 | return ErrorSemanticAnalyzeFail; |
| 25640 | } else if (lazy_ptr_type->is_allowzero) { | 25634 | } else if (lazy_ptr_type->is_allowzero) { |
| 25641 | exec_add_error_node(codegen, exec, lazy_ptr_type->elem_type_src_node, | 25635 | ir_add_error(ira, lazy_ptr_type->elem_type, |
| 25642 | buf_sprintf("C pointers always allow address zero")); | 25636 | buf_sprintf("C pointers always allow address zero")); |
| 25643 | return ErrorSemanticAnalyzeFail; | 25637 | return ErrorSemanticAnalyzeFail; |
| 25644 | } | 25638 | } |
| 25645 | } | 25639 | } |
| 25646 | | 25640 | |
| 25647 | if (align_bytes != 0) { | 25641 | if (align_bytes != 0) { |
| 25648 | if ((err = type_resolve(codegen, elem_type, ResolveStatusAlignmentKnown))) | 25642 | if ((err = type_resolve(ira->codegen, elem_type, ResolveStatusAlignmentKnown))) |
| 25649 | return err; | 25643 | return err; |
| 25650 | if (!type_has_bits(elem_type)) | 25644 | if (!type_has_bits(elem_type)) |
| 25651 | align_bytes = 0; | 25645 | align_bytes = 0; |
| 25652 | } | 25646 | } |
| 25653 | bool allow_zero = lazy_ptr_type->is_allowzero || lazy_ptr_type->ptr_len == PtrLenC; | 25647 | bool allow_zero = lazy_ptr_type->is_allowzero || lazy_ptr_type->ptr_len == PtrLenC; |
| 25654 | assert(val->type->id == ZigTypeIdMetaType); | 25648 | assert(val->type->id == ZigTypeIdMetaType); |
| 25655 | val->data.x_type = get_pointer_to_type_extra(codegen, elem_type, | 25649 | val->data.x_type = get_pointer_to_type_extra(ira->codegen, elem_type, |
| 25656 | lazy_ptr_type->is_const, lazy_ptr_type->is_volatile, lazy_ptr_type->ptr_len, align_bytes, | 25650 | lazy_ptr_type->is_const, lazy_ptr_type->is_volatile, lazy_ptr_type->ptr_len, align_bytes, |
| 25657 | lazy_ptr_type->bit_offset_in_host, lazy_ptr_type->host_int_bytes, | 25651 | lazy_ptr_type->bit_offset_in_host, lazy_ptr_type->host_int_bytes, |
| 25658 | allow_zero); | 25652 | allow_zero); |
| ... | @@ -25661,29 +25655,29 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx | ... | @@ -25661,29 +25655,29 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx |
| 25661 | } | 25655 | } |
| 25662 | case LazyValueIdOptType: { | 25656 | case LazyValueIdOptType: { |
| 25663 | LazyValueOptType *lazy_opt_type = reinterpret_cast<LazyValueOptType *>(val->data.x_lazy); | 25657 | LazyValueOptType *lazy_opt_type = reinterpret_cast<LazyValueOptType *>(val->data.x_lazy); |
| | 25658 | IrAnalyze *ira = lazy_opt_type->ira; |
| 25664 | | 25659 | |
| 25665 | ZigType *payload_type = ir_resolve_const_type(codegen, exec, lazy_opt_type->payload_type_src_node, | 25660 | ZigType *payload_type = ir_resolve_type(ira, lazy_opt_type->payload_type); |
| 25666 | lazy_opt_type->payload_type_val); | | |
| 25667 | if (type_is_invalid(payload_type)) | 25661 | if (type_is_invalid(payload_type)) |
| 25668 | return ErrorSemanticAnalyzeFail; | 25662 | return ErrorSemanticAnalyzeFail; |
| 25669 | | 25663 | |
| 25670 | if (payload_type->id == ZigTypeIdOpaque || payload_type->id == ZigTypeIdUnreachable) { | 25664 | if (payload_type->id == ZigTypeIdOpaque || payload_type->id == ZigTypeIdUnreachable) { |
| 25671 | exec_add_error_node(codegen, exec, lazy_opt_type->payload_type_src_node, | 25665 | ir_add_error(ira, lazy_opt_type->payload_type, |
| 25672 | buf_sprintf("type '%s' cannot be optional", buf_ptr(&payload_type->name))); | 25666 | buf_sprintf("type '%s' cannot be optional", buf_ptr(&payload_type->name))); |
| 25673 | return ErrorSemanticAnalyzeFail; | 25667 | return ErrorSemanticAnalyzeFail; |
| 25674 | } | 25668 | } |
| 25675 | | 25669 | |
| 25676 | if ((err = type_resolve(codegen, payload_type, ResolveStatusSizeKnown))) | 25670 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) |
| 25677 | return err; | 25671 | return err; |
| 25678 | | 25672 | |
| 25679 | assert(val->type->id == ZigTypeIdMetaType); | 25673 | assert(val->type->id == ZigTypeIdMetaType); |
| 25680 | val->data.x_type = get_optional_type(codegen, payload_type); | 25674 | val->data.x_type = get_optional_type(ira->codegen, payload_type); |
| 25681 | val->special = ConstValSpecialStatic; | 25675 | val->special = ConstValSpecialStatic; |
| 25682 | return ErrorNone; | 25676 | return ErrorNone; |
| 25683 | } | 25677 | } |
| 25684 | case LazyValueIdFnType: { | 25678 | case LazyValueIdFnType: { |
| 25685 | ZigType *fn_type = ir_resolve_lazy_fn_type(codegen, exec, source_node, | 25679 | LazyValueFnType *lazy_fn_type = reinterpret_cast<LazyValueFnType *>(val->data.x_lazy); |
| 25686 | reinterpret_cast<LazyValueFnType *>(val->data.x_lazy)); | 25680 | ZigType *fn_type = ir_resolve_lazy_fn_type(lazy_fn_type->ira, source_node, lazy_fn_type); |
| 25687 | if (fn_type == nullptr) | 25681 | if (fn_type == nullptr) |
| 25688 | return ErrorSemanticAnalyzeFail; | 25682 | return ErrorSemanticAnalyzeFail; |
| 25689 | val->special = ConstValSpecialStatic; | 25683 | val->special = ConstValSpecialStatic; |
| ... | @@ -25697,7 +25691,7 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx | ... | @@ -25697,7 +25691,7 @@ static Error ir_resolve_lazy_raw(CodeGen *codegen, AstNode *source_node, ConstEx |
| 25697 | | 25691 | |
| 25698 | Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ConstExprValue *val) { | 25692 | Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ConstExprValue *val) { |
| 25699 | Error err; | 25693 | Error err; |
| 25700 | if ((err = ir_resolve_lazy_raw(codegen, source_node, val))) { | 25694 | if ((err = ir_resolve_lazy_raw(source_node, val))) { |
| 25701 | if (codegen->trace_err != nullptr && !source_node->already_traced_this_node) { | 25695 | if (codegen->trace_err != nullptr && !source_node->already_traced_this_node) { |
| 25702 | source_node->already_traced_this_node = true; | 25696 | source_node->already_traced_this_node = true; |
| 25703 | codegen->trace_err = add_error_note(codegen, codegen->trace_err, source_node, | 25697 | codegen->trace_err = add_error_note(codegen, codegen->trace_err, source_node, |