| ... | @@ -514,7 +514,8 @@ static void destroy_instruction_src(IrInstSrc *inst) { | ... | @@ -514,7 +514,8 @@ static void destroy_instruction_src(IrInstSrc *inst) { |
| 514 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResetResult *>(inst)); | 514 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcResetResult *>(inst)); |
| 515 | case IrInstSrcIdSetAlignStack: | 515 | case IrInstSrcIdSetAlignStack: |
| 516 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetAlignStack *>(inst)); | 516 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcSetAlignStack *>(inst)); |
| 517 | case IrInstSrcIdArgType: | 517 | case IrInstSrcIdArgTypeAllowVarFalse: |
| | 518 | case IrInstSrcIdArgTypeAllowVarTrue: |
| 518 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcArgType *>(inst)); | 519 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcArgType *>(inst)); |
| 519 | case IrInstSrcIdExport: | 520 | case IrInstSrcIdExport: |
| 520 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcExport *>(inst)); | 521 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcExport *>(inst)); |
| ... | @@ -1546,10 +1547,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetAlignStack *) { | ... | @@ -1546,10 +1547,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetAlignStack *) { |
| 1546 | return IrInstSrcIdSetAlignStack; | 1547 | return IrInstSrcIdSetAlignStack; |
| 1547 | } | 1548 | } |
| 1548 | | 1549 | |
| 1549 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcArgType *) { | | |
| 1550 | return IrInstSrcIdArgType; | | |
| 1551 | } | | |
| 1552 | | | |
| 1553 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcExport *) { | 1550 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcExport *) { |
| 1554 | return IrInstSrcIdExport; | 1551 | return IrInstSrcIdExport; |
| 1555 | } | 1552 | } |
| ... | @@ -4590,10 +4587,17 @@ static IrInstSrc *ir_build_set_align_stack(IrBuilderSrc *irb, Scope *scope, AstN | ... | @@ -4590,10 +4587,17 @@ static IrInstSrc *ir_build_set_align_stack(IrBuilderSrc *irb, Scope *scope, AstN |
| 4590 | static IrInstSrc *ir_build_arg_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, | 4587 | static IrInstSrc *ir_build_arg_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 4591 | IrInstSrc *fn_type, IrInstSrc *arg_index, bool allow_var) | 4588 | IrInstSrc *fn_type, IrInstSrc *arg_index, bool allow_var) |
| 4592 | { | 4589 | { |
| 4593 | IrInstSrcArgType *instruction = ir_build_instruction<IrInstSrcArgType>(irb, scope, source_node); | 4590 | IrInstSrcArgType *instruction = heap::c_allocator.create<IrInstSrcArgType>(); |
| | 4591 | instruction->base.id = allow_var ? |
| | 4592 | IrInstSrcIdArgTypeAllowVarTrue : IrInstSrcIdArgTypeAllowVarFalse; |
| | 4593 | instruction->base.base.scope = scope; |
| | 4594 | instruction->base.base.source_node = source_node; |
| | 4595 | instruction->base.base.debug_id = exec_next_debug_id(irb->exec); |
| | 4596 | instruction->base.owner_bb = irb->current_basic_block; |
| | 4597 | ir_instruction_append(irb->current_basic_block, &instruction->base); |
| | 4598 | |
| 4594 | instruction->fn_type = fn_type; | 4599 | instruction->fn_type = fn_type; |
| 4595 | instruction->arg_index = arg_index; | 4600 | instruction->arg_index = arg_index; |
| 4596 | instruction->allow_var = allow_var; | | |
| 4597 | | 4601 | |
| 4598 | ir_ref_instruction(fn_type, irb->current_basic_block); | 4602 | ir_ref_instruction(fn_type, irb->current_basic_block); |
| 4599 | ir_ref_instruction(arg_index, irb->current_basic_block); | 4603 | ir_ref_instruction(arg_index, irb->current_basic_block); |
| ... | @@ -30976,7 +30980,9 @@ static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstS | ... | @@ -30976,7 +30980,9 @@ static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstS |
| 30976 | return ir_const_void(ira, &instruction->base.base); | 30980 | return ir_const_void(ira, &instruction->base.base); |
| 30977 | } | 30981 | } |
| 30978 | | 30982 | |
| 30979 | static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgType *instruction) { | 30983 | static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgType *instruction, |
| | 30984 | bool allow_var) |
| | 30985 | { |
| 30980 | IrInstGen *fn_type_inst = instruction->fn_type->child; | 30986 | IrInstGen *fn_type_inst = instruction->fn_type->child; |
| 30981 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); | 30987 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); |
| 30982 | if (type_is_invalid(fn_type)) | 30988 | if (type_is_invalid(fn_type)) |
| ... | @@ -30998,7 +31004,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy | ... | @@ -30998,7 +31004,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy |
| 30998 | | 31004 | |
| 30999 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 31005 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| 31000 | if (arg_index >= fn_type_id->param_count) { | 31006 | if (arg_index >= fn_type_id->param_count) { |
| 31001 | if (instruction->allow_var) { | 31007 | if (allow_var) { |
| 31002 | // TODO remove this with var args | 31008 | // TODO remove this with var args |
| 31003 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype); | 31009 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype); |
| 31004 | } | 31010 | } |
| ... | @@ -31013,7 +31019,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy | ... | @@ -31013,7 +31019,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy |
| 31013 | // Args are only unresolved if our function is generic. | 31019 | // Args are only unresolved if our function is generic. |
| 31014 | ir_assert(fn_type->data.fn.is_generic, &instruction->base.base); | 31020 | ir_assert(fn_type->data.fn.is_generic, &instruction->base.base); |
| 31015 | | 31021 | |
| 31016 | if (instruction->allow_var) { | 31022 | if (allow_var) { |
| 31017 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype); | 31023 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype); |
| 31018 | } else { | 31024 | } else { |
| 31019 | ir_add_error(ira, &arg_index_inst->base, | 31025 | ir_add_error(ira, &arg_index_inst->base, |
| ... | @@ -32383,8 +32389,10 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc | ... | @@ -32383,8 +32389,10 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc |
| 32383 | return ir_analyze_instruction_reset_result(ira, (IrInstSrcResetResult *)instruction); | 32389 | return ir_analyze_instruction_reset_result(ira, (IrInstSrcResetResult *)instruction); |
| 32384 | case IrInstSrcIdSetAlignStack: | 32390 | case IrInstSrcIdSetAlignStack: |
| 32385 | return ir_analyze_instruction_set_align_stack(ira, (IrInstSrcSetAlignStack *)instruction); | 32391 | return ir_analyze_instruction_set_align_stack(ira, (IrInstSrcSetAlignStack *)instruction); |
| 32386 | case IrInstSrcIdArgType: | 32392 | case IrInstSrcIdArgTypeAllowVarFalse: |
| 32387 | return ir_analyze_instruction_arg_type(ira, (IrInstSrcArgType *)instruction); | 32393 | return ir_analyze_instruction_arg_type(ira, (IrInstSrcArgType *)instruction, false); |
| | 32394 | case IrInstSrcIdArgTypeAllowVarTrue: |
| | 32395 | return ir_analyze_instruction_arg_type(ira, (IrInstSrcArgType *)instruction, true); |
| 32388 | case IrInstSrcIdExport: | 32396 | case IrInstSrcIdExport: |
| 32389 | return ir_analyze_instruction_export(ira, (IrInstSrcExport *)instruction); | 32397 | return ir_analyze_instruction_export(ira, (IrInstSrcExport *)instruction); |
| 32390 | case IrInstSrcIdExtern: | 32398 | case IrInstSrcIdExtern: |
| ... | @@ -32826,7 +32834,8 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) { | ... | @@ -32826,7 +32834,8 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) { |
| 32826 | case IrInstSrcIdAlignCast: | 32834 | case IrInstSrcIdAlignCast: |
| 32827 | case IrInstSrcIdImplicitCast: | 32835 | case IrInstSrcIdImplicitCast: |
| 32828 | case IrInstSrcIdResolveResult: | 32836 | case IrInstSrcIdResolveResult: |
| 32829 | case IrInstSrcIdArgType: | 32837 | case IrInstSrcIdArgTypeAllowVarFalse: |
| | 32838 | case IrInstSrcIdArgTypeAllowVarTrue: |
| 32830 | case IrInstSrcIdErrorReturnTrace: | 32839 | case IrInstSrcIdErrorReturnTrace: |
| 32831 | case IrInstSrcIdErrorUnion: | 32840 | case IrInstSrcIdErrorUnion: |
| 32832 | case IrInstSrcIdFloatOp: | 32841 | case IrInstSrcIdFloatOp: |