| ... | @@ -111,6 +111,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -111,6 +111,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 111 | static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | 111 | static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 112 | VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr); | 112 | VariableTableEntry *var, bool is_const_ptr, bool is_volatile_ptr); |
| 113 | static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op); | 113 | static TypeTableEntry *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op); |
| | 114 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval); |
| 114 | | 115 | |
| 115 | ConstExprValue *const_ptr_pointee(CodeGen *g, ConstExprValue *const_val) { | 116 | ConstExprValue *const_ptr_pointee(CodeGen *g, ConstExprValue *const_val) { |
| 116 | assert(const_val->type->id == TypeTableEntryIdPointer); | 117 | assert(const_val->type->id == TypeTableEntryIdPointer); |
| ... | @@ -1033,11 +1034,12 @@ static IrInstruction *ir_build_elem_ptr_from(IrBuilder *irb, IrInstruction *old_ | ... | @@ -1033,11 +1034,12 @@ static IrInstruction *ir_build_elem_ptr_from(IrBuilder *irb, IrInstruction *old_ |
| 1033 | return new_instruction; | 1034 | return new_instruction; |
| 1034 | } | 1035 | } |
| 1035 | | 1036 | |
| 1036 | static IrInstruction *ir_build_field_ptr_inner(IrBuilder *irb, Scope *scope, AstNode *source_node, | 1037 | static IrInstruction *ir_build_field_ptr_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 1037 | IrInstruction *container_ptr, IrInstruction *field_name_expr) | 1038 | IrInstruction *container_ptr, IrInstruction *field_name_expr) |
| 1038 | { | 1039 | { |
| 1039 | IrInstructionFieldPtr *instruction = ir_build_instruction<IrInstructionFieldPtr>(irb, scope, source_node); | 1040 | IrInstructionFieldPtr *instruction = ir_build_instruction<IrInstructionFieldPtr>(irb, scope, source_node); |
| 1040 | instruction->container_ptr = container_ptr; | 1041 | instruction->container_ptr = container_ptr; |
| | 1042 | instruction->field_name_buffer = nullptr; |
| 1041 | instruction->field_name_expr = field_name_expr; | 1043 | instruction->field_name_expr = field_name_expr; |
| 1042 | | 1044 | |
| 1043 | ir_ref_instruction(container_ptr, irb->current_basic_block); | 1045 | ir_ref_instruction(container_ptr, irb->current_basic_block); |
| ... | @@ -1049,8 +1051,14 @@ static IrInstruction *ir_build_field_ptr_inner(IrBuilder *irb, Scope *scope, Ast | ... | @@ -1049,8 +1051,14 @@ static IrInstruction *ir_build_field_ptr_inner(IrBuilder *irb, Scope *scope, Ast |
| 1049 | static IrInstruction *ir_build_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 1051 | static IrInstruction *ir_build_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 1050 | IrInstruction *container_ptr, Buf *field_name) | 1052 | IrInstruction *container_ptr, Buf *field_name) |
| 1051 | { | 1053 | { |
| 1052 | IrInstruction *field_name_expr = ir_build_const_str_lit(irb, scope, source_node, field_name); | 1054 | IrInstructionFieldPtr *instruction = ir_build_instruction<IrInstructionFieldPtr>(irb, scope, source_node); |
| 1053 | return ir_build_field_ptr_inner(irb, scope, source_node, container_ptr, field_name_expr); | 1055 | instruction->container_ptr = container_ptr; |
| | 1056 | instruction->field_name_buffer = field_name; |
| | 1057 | instruction->field_name_expr = nullptr; |
| | 1058 | |
| | 1059 | ir_ref_instruction(container_ptr, irb->current_basic_block); |
| | 1060 | |
| | 1061 | return &instruction->base; |
| 1054 | } | 1062 | } |
| 1055 | | 1063 | |
| 1056 | static IrInstruction *ir_build_struct_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 1064 | static IrInstruction *ir_build_struct_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| ... | @@ -3532,7 +3540,7 @@ static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3532,7 +3540,7 @@ static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode |
| 3532 | return ir_build_load_ptr(irb, scope, node, ptr_instruction); | 3540 | return ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 3533 | } | 3541 | } |
| 3534 | | 3542 | |
| 3535 | static IrInstruction *ir_gen_field_access(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { | 3543 | static IrInstruction *ir_gen_field_access(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 3536 | assert(node->type == NodeTypeFieldAccessExpr); | 3544 | assert(node->type == NodeTypeFieldAccessExpr); |
| 3537 | | 3545 | |
| 3538 | AstNode *container_ref_node = node->data.field_access_expr.struct_expr; | 3546 | AstNode *container_ref_node = node->data.field_access_expr.struct_expr; |
| ... | @@ -3542,11 +3550,7 @@ static IrInstruction *ir_gen_field_access(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3542,11 +3550,7 @@ static IrInstruction *ir_gen_field_access(IrBuilder *irb, Scope *scope, AstNode |
| 3542 | if (container_ref_instruction == irb->codegen->invalid_instruction) | 3550 | if (container_ref_instruction == irb->codegen->invalid_instruction) |
| 3543 | return container_ref_instruction; | 3551 | return container_ref_instruction; |
| 3544 | | 3552 | |
| 3545 | IrInstruction *ptr_instruction = ir_build_field_ptr(irb, scope, node, container_ref_instruction, field_name); | 3553 | return ir_build_field_ptr(irb, scope, node, container_ref_instruction, field_name); |
| 3546 | if (lval.is_ptr) | | |
| 3547 | return ptr_instruction; | | |
| 3548 | | | |
| 3549 | return ir_build_load_ptr(irb, scope, node, ptr_instruction); | | |
| 3550 | } | 3554 | } |
| 3551 | | 3555 | |
| 3552 | static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode *node, IrOverflowOp op) { | 3556 | static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode *node, IrOverflowOp op) { |
| ... | @@ -3577,7 +3581,7 @@ static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -3577,7 +3581,7 @@ static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode * |
| 3577 | return ir_build_overflow_op(irb, scope, node, op, type_value, op1, op2, result_ptr, nullptr); | 3581 | return ir_build_overflow_op(irb, scope, node, op, type_value, op1, op2, result_ptr, nullptr); |
| 3578 | } | 3582 | } |
| 3579 | | 3583 | |
| 3580 | static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNode *node) { | 3584 | static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { |
| 3581 | assert(node->type == NodeTypeFnCallExpr); | 3585 | assert(node->type == NodeTypeFnCallExpr); |
| 3582 | | 3586 | |
| 3583 | AstNode *fn_ref_expr = node->data.fn_call_expr.fn_ref_expr; | 3587 | AstNode *fn_ref_expr = node->data.fn_call_expr.fn_ref_expr; |
| ... | @@ -3609,7 +3613,9 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3609,7 +3613,9 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3609 | IrInstruction *arg = ir_gen_node(irb, arg_node, scope); | 3613 | IrInstruction *arg = ir_gen_node(irb, arg_node, scope); |
| 3610 | if (arg == irb->codegen->invalid_instruction) | 3614 | if (arg == irb->codegen->invalid_instruction) |
| 3611 | return arg; | 3615 | return arg; |
| 3612 | return ir_build_typeof(irb, scope, node, arg); | 3616 | |
| | 3617 | IrInstruction *type_of = ir_build_typeof(irb, scope, node, arg); |
| | 3618 | return ir_lval_wrap(irb, scope, type_of, lval); |
| 3613 | } | 3619 | } |
| 3614 | case BuiltinFnIdSetCold: | 3620 | case BuiltinFnIdSetCold: |
| 3615 | { | 3621 | { |
| ... | @@ -3618,7 +3624,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3618,7 +3624,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3618 | if (arg0_value == irb->codegen->invalid_instruction) | 3624 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3619 | return arg0_value; | 3625 | return arg0_value; |
| 3620 | | 3626 | |
| 3621 | return ir_build_set_cold(irb, scope, node, arg0_value); | 3627 | IrInstruction *set_cold = ir_build_set_cold(irb, scope, node, arg0_value); |
| | 3628 | return ir_lval_wrap(irb, scope, set_cold, lval); |
| 3622 | } | 3629 | } |
| 3623 | case BuiltinFnIdSetRuntimeSafety: | 3630 | case BuiltinFnIdSetRuntimeSafety: |
| 3624 | { | 3631 | { |
| ... | @@ -3627,7 +3634,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3627,7 +3634,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3627 | if (arg0_value == irb->codegen->invalid_instruction) | 3634 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3628 | return arg0_value; | 3635 | return arg0_value; |
| 3629 | | 3636 | |
| 3630 | return ir_build_set_runtime_safety(irb, scope, node, arg0_value); | 3637 | IrInstruction *set_safety = ir_build_set_runtime_safety(irb, scope, node, arg0_value); |
| | 3638 | return ir_lval_wrap(irb, scope, set_safety, lval); |
| 3631 | } | 3639 | } |
| 3632 | case BuiltinFnIdSetFloatMode: | 3640 | case BuiltinFnIdSetFloatMode: |
| 3633 | { | 3641 | { |
| ... | @@ -3641,7 +3649,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3641,7 +3649,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3641 | if (arg1_value == irb->codegen->invalid_instruction) | 3649 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3642 | return arg1_value; | 3650 | return arg1_value; |
| 3643 | | 3651 | |
| 3644 | return ir_build_set_float_mode(irb, scope, node, arg0_value, arg1_value); | 3652 | IrInstruction *set_float_mode = ir_build_set_float_mode(irb, scope, node, arg0_value, arg1_value); |
| | 3653 | return ir_lval_wrap(irb, scope, set_float_mode, lval); |
| 3645 | } | 3654 | } |
| 3646 | case BuiltinFnIdSizeof: | 3655 | case BuiltinFnIdSizeof: |
| 3647 | { | 3656 | { |
| ... | @@ -3650,7 +3659,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3650,7 +3659,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3650 | if (arg0_value == irb->codegen->invalid_instruction) | 3659 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3651 | return arg0_value; | 3660 | return arg0_value; |
| 3652 | | 3661 | |
| 3653 | return ir_build_size_of(irb, scope, node, arg0_value); | 3662 | IrInstruction *size_of = ir_build_size_of(irb, scope, node, arg0_value); |
| | 3663 | return ir_lval_wrap(irb, scope, size_of, lval); |
| 3654 | } | 3664 | } |
| 3655 | case BuiltinFnIdCtz: | 3665 | case BuiltinFnIdCtz: |
| 3656 | { | 3666 | { |
| ... | @@ -3659,7 +3669,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3659,7 +3669,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3659 | if (arg0_value == irb->codegen->invalid_instruction) | 3669 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3660 | return arg0_value; | 3670 | return arg0_value; |
| 3661 | | 3671 | |
| 3662 | return ir_build_ctz(irb, scope, node, arg0_value); | 3672 | IrInstruction *ctz = ir_build_ctz(irb, scope, node, arg0_value); |
| | 3673 | return ir_lval_wrap(irb, scope, ctz, lval); |
| 3663 | } | 3674 | } |
| 3664 | case BuiltinFnIdClz: | 3675 | case BuiltinFnIdClz: |
| 3665 | { | 3676 | { |
| ... | @@ -3668,7 +3679,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3668,7 +3679,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3668 | if (arg0_value == irb->codegen->invalid_instruction) | 3679 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3669 | return arg0_value; | 3680 | return arg0_value; |
| 3670 | | 3681 | |
| 3671 | return ir_build_clz(irb, scope, node, arg0_value); | 3682 | IrInstruction *clz = ir_build_clz(irb, scope, node, arg0_value); |
| | 3683 | return ir_lval_wrap(irb, scope, clz, lval); |
| 3672 | } | 3684 | } |
| 3673 | case BuiltinFnIdImport: | 3685 | case BuiltinFnIdImport: |
| 3674 | { | 3686 | { |
| ... | @@ -3677,11 +3689,13 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3677,11 +3689,13 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3677 | if (arg0_value == irb->codegen->invalid_instruction) | 3689 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3678 | return arg0_value; | 3690 | return arg0_value; |
| 3679 | | 3691 | |
| 3680 | return ir_build_import(irb, scope, node, arg0_value); | 3692 | IrInstruction *import = ir_build_import(irb, scope, node, arg0_value); |
| | 3693 | return ir_lval_wrap(irb, scope, import, lval); |
| 3681 | } | 3694 | } |
| 3682 | case BuiltinFnIdCImport: | 3695 | case BuiltinFnIdCImport: |
| 3683 | { | 3696 | { |
| 3684 | return ir_build_c_import(irb, scope, node); | 3697 | IrInstruction *c_import = ir_build_c_import(irb, scope, node); |
| | 3698 | return ir_lval_wrap(irb, scope, c_import, lval); |
| 3685 | } | 3699 | } |
| 3686 | case BuiltinFnIdCInclude: | 3700 | case BuiltinFnIdCInclude: |
| 3687 | { | 3701 | { |
| ... | @@ -3695,7 +3709,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3695,7 +3709,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3695 | return irb->codegen->invalid_instruction; | 3709 | return irb->codegen->invalid_instruction; |
| 3696 | } | 3710 | } |
| 3697 | | 3711 | |
| 3698 | return ir_build_c_include(irb, scope, node, arg0_value); | 3712 | IrInstruction *c_include = ir_build_c_include(irb, scope, node, arg0_value); |
| | 3713 | return ir_lval_wrap(irb, scope, c_include, lval); |
| 3699 | } | 3714 | } |
| 3700 | case BuiltinFnIdCDefine: | 3715 | case BuiltinFnIdCDefine: |
| 3701 | { | 3716 | { |
| ... | @@ -3714,7 +3729,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3714,7 +3729,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3714 | return irb->codegen->invalid_instruction; | 3729 | return irb->codegen->invalid_instruction; |
| 3715 | } | 3730 | } |
| 3716 | | 3731 | |
| 3717 | return ir_build_c_define(irb, scope, node, arg0_value, arg1_value); | 3732 | IrInstruction *c_define = ir_build_c_define(irb, scope, node, arg0_value, arg1_value); |
| | 3733 | return ir_lval_wrap(irb, scope, c_define, lval); |
| 3718 | } | 3734 | } |
| 3719 | case BuiltinFnIdCUndef: | 3735 | case BuiltinFnIdCUndef: |
| 3720 | { | 3736 | { |
| ... | @@ -3728,7 +3744,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3728,7 +3744,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3728 | return irb->codegen->invalid_instruction; | 3744 | return irb->codegen->invalid_instruction; |
| 3729 | } | 3745 | } |
| 3730 | | 3746 | |
| 3731 | return ir_build_c_undef(irb, scope, node, arg0_value); | 3747 | IrInstruction *c_undef = ir_build_c_undef(irb, scope, node, arg0_value); |
| | 3748 | return ir_lval_wrap(irb, scope, c_undef, lval); |
| 3732 | } | 3749 | } |
| 3733 | case BuiltinFnIdMaxValue: | 3750 | case BuiltinFnIdMaxValue: |
| 3734 | { | 3751 | { |
| ... | @@ -3737,7 +3754,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3737,7 +3754,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3737 | if (arg0_value == irb->codegen->invalid_instruction) | 3754 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3738 | return arg0_value; | 3755 | return arg0_value; |
| 3739 | | 3756 | |
| 3740 | return ir_build_max_value(irb, scope, node, arg0_value); | 3757 | IrInstruction *max_value = ir_build_max_value(irb, scope, node, arg0_value); |
| | 3758 | return ir_lval_wrap(irb, scope, max_value, lval); |
| 3741 | } | 3759 | } |
| 3742 | case BuiltinFnIdMinValue: | 3760 | case BuiltinFnIdMinValue: |
| 3743 | { | 3761 | { |
| ... | @@ -3746,7 +3764,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3746,7 +3764,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3746 | if (arg0_value == irb->codegen->invalid_instruction) | 3764 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3747 | return arg0_value; | 3765 | return arg0_value; |
| 3748 | | 3766 | |
| 3749 | return ir_build_min_value(irb, scope, node, arg0_value); | 3767 | IrInstruction *min_value = ir_build_min_value(irb, scope, node, arg0_value); |
| | 3768 | return ir_lval_wrap(irb, scope, min_value, lval); |
| 3750 | } | 3769 | } |
| 3751 | case BuiltinFnIdCompileErr: | 3770 | case BuiltinFnIdCompileErr: |
| 3752 | { | 3771 | { |
| ... | @@ -3755,7 +3774,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3755,7 +3774,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3755 | if (arg0_value == irb->codegen->invalid_instruction) | 3774 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3756 | return arg0_value; | 3775 | return arg0_value; |
| 3757 | | 3776 | |
| 3758 | return ir_build_compile_err(irb, scope, node, arg0_value); | 3777 | IrInstruction *compile_err = ir_build_compile_err(irb, scope, node, arg0_value); |
| | 3778 | return ir_lval_wrap(irb, scope, compile_err, lval); |
| 3759 | } | 3779 | } |
| 3760 | case BuiltinFnIdCompileLog: | 3780 | case BuiltinFnIdCompileLog: |
| 3761 | { | 3781 | { |
| ... | @@ -3768,7 +3788,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3768,7 +3788,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3768 | return irb->codegen->invalid_instruction; | 3788 | return irb->codegen->invalid_instruction; |
| 3769 | } | 3789 | } |
| 3770 | | 3790 | |
| 3771 | return ir_build_compile_log(irb, scope, node, actual_param_count, args); | 3791 | IrInstruction *compile_log = ir_build_compile_log(irb, scope, node, actual_param_count, args); |
| | 3792 | return ir_lval_wrap(irb, scope, compile_log, lval); |
| 3772 | } | 3793 | } |
| 3773 | case BuiltinFnIdErrName: | 3794 | case BuiltinFnIdErrName: |
| 3774 | { | 3795 | { |
| ... | @@ -3777,7 +3798,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3777,7 +3798,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3777 | if (arg0_value == irb->codegen->invalid_instruction) | 3798 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3778 | return arg0_value; | 3799 | return arg0_value; |
| 3779 | | 3800 | |
| 3780 | return ir_build_err_name(irb, scope, node, arg0_value); | 3801 | IrInstruction *err_name = ir_build_err_name(irb, scope, node, arg0_value); |
| | 3802 | return ir_lval_wrap(irb, scope, err_name, lval); |
| 3781 | } | 3803 | } |
| 3782 | case BuiltinFnIdEmbedFile: | 3804 | case BuiltinFnIdEmbedFile: |
| 3783 | { | 3805 | { |
| ... | @@ -3786,7 +3808,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3786,7 +3808,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3786 | if (arg0_value == irb->codegen->invalid_instruction) | 3808 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3787 | return arg0_value; | 3809 | return arg0_value; |
| 3788 | | 3810 | |
| 3789 | return ir_build_embed_file(irb, scope, node, arg0_value); | 3811 | IrInstruction *embed_file = ir_build_embed_file(irb, scope, node, arg0_value); |
| | 3812 | return ir_lval_wrap(irb, scope, embed_file, lval); |
| 3790 | } | 3813 | } |
| 3791 | case BuiltinFnIdCmpxchgWeak: | 3814 | case BuiltinFnIdCmpxchgWeak: |
| 3792 | case BuiltinFnIdCmpxchgStrong: | 3815 | case BuiltinFnIdCmpxchgStrong: |
| ... | @@ -3821,9 +3844,10 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3821,9 +3844,10 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3821 | if (arg5_value == irb->codegen->invalid_instruction) | 3844 | if (arg5_value == irb->codegen->invalid_instruction) |
| 3822 | return arg5_value; | 3845 | return arg5_value; |
| 3823 | | 3846 | |
| 3824 | return ir_build_cmpxchg(irb, scope, node, arg0_value, arg1_value, | 3847 | IrInstruction *cmpxchg = ir_build_cmpxchg(irb, scope, node, arg0_value, arg1_value, |
| 3825 | arg2_value, arg3_value, arg4_value, arg5_value, (builtin_fn->id == BuiltinFnIdCmpxchgWeak), | 3848 | arg2_value, arg3_value, arg4_value, arg5_value, (builtin_fn->id == BuiltinFnIdCmpxchgWeak), |
| 3826 | nullptr, AtomicOrderUnordered, AtomicOrderUnordered); | 3849 | nullptr, AtomicOrderUnordered, AtomicOrderUnordered); |
| | 3850 | return ir_lval_wrap(irb, scope, cmpxchg, lval); |
| 3827 | } | 3851 | } |
| 3828 | case BuiltinFnIdFence: | 3852 | case BuiltinFnIdFence: |
| 3829 | { | 3853 | { |
| ... | @@ -3832,7 +3856,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3832,7 +3856,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3832 | if (arg0_value == irb->codegen->invalid_instruction) | 3856 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3833 | return arg0_value; | 3857 | return arg0_value; |
| 3834 | | 3858 | |
| 3835 | return ir_build_fence(irb, scope, node, arg0_value, AtomicOrderUnordered); | 3859 | IrInstruction *fence = ir_build_fence(irb, scope, node, arg0_value, AtomicOrderUnordered); |
| | 3860 | return ir_lval_wrap(irb, scope, fence, lval); |
| 3836 | } | 3861 | } |
| 3837 | case BuiltinFnIdDivExact: | 3862 | case BuiltinFnIdDivExact: |
| 3838 | { | 3863 | { |
| ... | @@ -3846,7 +3871,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3846,7 +3871,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3846 | if (arg1_value == irb->codegen->invalid_instruction) | 3871 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3847 | return arg1_value; | 3872 | return arg1_value; |
| 3848 | | 3873 | |
| 3849 | return ir_build_bin_op(irb, scope, node, IrBinOpDivExact, arg0_value, arg1_value, true); | 3874 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivExact, arg0_value, arg1_value, true); |
| | 3875 | return ir_lval_wrap(irb, scope, bin_op, lval); |
| 3850 | } | 3876 | } |
| 3851 | case BuiltinFnIdDivTrunc: | 3877 | case BuiltinFnIdDivTrunc: |
| 3852 | { | 3878 | { |
| ... | @@ -3860,7 +3886,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3860,7 +3886,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3860 | if (arg1_value == irb->codegen->invalid_instruction) | 3886 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3861 | return arg1_value; | 3887 | return arg1_value; |
| 3862 | | 3888 | |
| 3863 | return ir_build_bin_op(irb, scope, node, IrBinOpDivTrunc, arg0_value, arg1_value, true); | 3889 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivTrunc, arg0_value, arg1_value, true); |
| | 3890 | return ir_lval_wrap(irb, scope, bin_op, lval); |
| 3864 | } | 3891 | } |
| 3865 | case BuiltinFnIdDivFloor: | 3892 | case BuiltinFnIdDivFloor: |
| 3866 | { | 3893 | { |
| ... | @@ -3874,7 +3901,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3874,7 +3901,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3874 | if (arg1_value == irb->codegen->invalid_instruction) | 3901 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3875 | return arg1_value; | 3902 | return arg1_value; |
| 3876 | | 3903 | |
| 3877 | return ir_build_bin_op(irb, scope, node, IrBinOpDivFloor, arg0_value, arg1_value, true); | 3904 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivFloor, arg0_value, arg1_value, true); |
| | 3905 | return ir_lval_wrap(irb, scope, bin_op, lval); |
| 3878 | } | 3906 | } |
| 3879 | case BuiltinFnIdRem: | 3907 | case BuiltinFnIdRem: |
| 3880 | { | 3908 | { |
| ... | @@ -3888,7 +3916,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3888,7 +3916,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3888 | if (arg1_value == irb->codegen->invalid_instruction) | 3916 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3889 | return arg1_value; | 3917 | return arg1_value; |
| 3890 | | 3918 | |
| 3891 | return ir_build_bin_op(irb, scope, node, IrBinOpRemRem, arg0_value, arg1_value, true); | 3919 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemRem, arg0_value, arg1_value, true); |
| | 3920 | return ir_lval_wrap(irb, scope, bin_op, lval); |
| 3892 | } | 3921 | } |
| 3893 | case BuiltinFnIdMod: | 3922 | case BuiltinFnIdMod: |
| 3894 | { | 3923 | { |
| ... | @@ -3902,7 +3931,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3902,7 +3931,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3902 | if (arg1_value == irb->codegen->invalid_instruction) | 3931 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3903 | return arg1_value; | 3932 | return arg1_value; |
| 3904 | | 3933 | |
| 3905 | return ir_build_bin_op(irb, scope, node, IrBinOpRemMod, arg0_value, arg1_value, true); | 3934 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemMod, arg0_value, arg1_value, true); |
| | 3935 | return ir_lval_wrap(irb, scope, bin_op, lval); |
| 3906 | } | 3936 | } |
| 3907 | case BuiltinFnIdSqrt: | 3937 | case BuiltinFnIdSqrt: |
| 3908 | { | 3938 | { |
| ... | @@ -3916,7 +3946,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3916,7 +3946,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3916 | if (arg1_value == irb->codegen->invalid_instruction) | 3946 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3917 | return arg1_value; | 3947 | return arg1_value; |
| 3918 | | 3948 | |
| 3919 | return ir_build_sqrt(irb, scope, node, arg0_value, arg1_value); | 3949 | IrInstruction *ir_sqrt = ir_build_sqrt(irb, scope, node, arg0_value, arg1_value); |
| | 3950 | return ir_lval_wrap(irb, scope, ir_sqrt, lval); |
| 3920 | } | 3951 | } |
| 3921 | case BuiltinFnIdTruncate: | 3952 | case BuiltinFnIdTruncate: |
| 3922 | { | 3953 | { |
| ... | @@ -3930,7 +3961,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3930,7 +3961,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3930 | if (arg1_value == irb->codegen->invalid_instruction) | 3961 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3931 | return arg1_value; | 3962 | return arg1_value; |
| 3932 | | 3963 | |
| 3933 | return ir_build_truncate(irb, scope, node, arg0_value, arg1_value); | 3964 | IrInstruction *truncate = ir_build_truncate(irb, scope, node, arg0_value, arg1_value); |
| | 3965 | return ir_lval_wrap(irb, scope, truncate, lval); |
| 3934 | } | 3966 | } |
| 3935 | case BuiltinFnIdIntType: | 3967 | case BuiltinFnIdIntType: |
| 3936 | { | 3968 | { |
| ... | @@ -3944,7 +3976,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3944,7 +3976,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3944 | if (arg1_value == irb->codegen->invalid_instruction) | 3976 | if (arg1_value == irb->codegen->invalid_instruction) |
| 3945 | return arg1_value; | 3977 | return arg1_value; |
| 3946 | | 3978 | |
| 3947 | return ir_build_int_type(irb, scope, node, arg0_value, arg1_value); | 3979 | IrInstruction *int_type = ir_build_int_type(irb, scope, node, arg0_value, arg1_value); |
| | 3980 | return ir_lval_wrap(irb, scope, int_type, lval); |
| 3948 | } | 3981 | } |
| 3949 | case BuiltinFnIdMemcpy: | 3982 | case BuiltinFnIdMemcpy: |
| 3950 | { | 3983 | { |
| ... | @@ -3963,7 +3996,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3963,7 +3996,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3963 | if (arg2_value == irb->codegen->invalid_instruction) | 3996 | if (arg2_value == irb->codegen->invalid_instruction) |
| 3964 | return arg2_value; | 3997 | return arg2_value; |
| 3965 | | 3998 | |
| 3966 | return ir_build_memcpy(irb, scope, node, arg0_value, arg1_value, arg2_value); | 3999 | IrInstruction *ir_memcpy = ir_build_memcpy(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| | 4000 | return ir_lval_wrap(irb, scope, ir_memcpy, lval); |
| 3967 | } | 4001 | } |
| 3968 | case BuiltinFnIdMemset: | 4002 | case BuiltinFnIdMemset: |
| 3969 | { | 4003 | { |
| ... | @@ -3982,7 +4016,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3982,7 +4016,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3982 | if (arg2_value == irb->codegen->invalid_instruction) | 4016 | if (arg2_value == irb->codegen->invalid_instruction) |
| 3983 | return arg2_value; | 4017 | return arg2_value; |
| 3984 | | 4018 | |
| 3985 | return ir_build_memset(irb, scope, node, arg0_value, arg1_value, arg2_value); | 4019 | IrInstruction *ir_memset = ir_build_memset(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| | 4020 | return ir_lval_wrap(irb, scope, ir_memset, lval); |
| 3986 | } | 4021 | } |
| 3987 | case BuiltinFnIdMemberCount: | 4022 | case BuiltinFnIdMemberCount: |
| 3988 | { | 4023 | { |
| ... | @@ -3991,7 +4026,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3991,7 +4026,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3991 | if (arg0_value == irb->codegen->invalid_instruction) | 4026 | if (arg0_value == irb->codegen->invalid_instruction) |
| 3992 | return arg0_value; | 4027 | return arg0_value; |
| 3993 | | 4028 | |
| 3994 | return ir_build_member_count(irb, scope, node, arg0_value); | 4029 | IrInstruction *member_count = ir_build_member_count(irb, scope, node, arg0_value); |
| | 4030 | return ir_lval_wrap(irb, scope, member_count, lval); |
| 3995 | } | 4031 | } |
| 3996 | case BuiltinFnIdMemberType: | 4032 | case BuiltinFnIdMemberType: |
| 3997 | { | 4033 | { |
| ... | @@ -4006,7 +4042,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4006,7 +4042,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4006 | return arg1_value; | 4042 | return arg1_value; |
| 4007 | | 4043 | |
| 4008 | | 4044 | |
| 4009 | return ir_build_member_type(irb, scope, node, arg0_value, arg1_value); | 4045 | IrInstruction *member_type = ir_build_member_type(irb, scope, node, arg0_value, arg1_value); |
| | 4046 | return ir_lval_wrap(irb, scope, member_type, lval); |
| 4010 | } | 4047 | } |
| 4011 | case BuiltinFnIdMemberName: | 4048 | case BuiltinFnIdMemberName: |
| 4012 | { | 4049 | { |
| ... | @@ -4021,7 +4058,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4021,7 +4058,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4021 | return arg1_value; | 4058 | return arg1_value; |
| 4022 | | 4059 | |
| 4023 | | 4060 | |
| 4024 | return ir_build_member_name(irb, scope, node, arg0_value, arg1_value); | 4061 | IrInstruction *member_name = ir_build_member_name(irb, scope, node, arg0_value, arg1_value); |
| | 4062 | return ir_lval_wrap(irb, scope, member_name, lval); |
| 4025 | } | 4063 | } |
| 4026 | case BuiltinFnIdField: | 4064 | case BuiltinFnIdField: |
| 4027 | { | 4065 | { |
| ... | @@ -4035,18 +4073,19 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4035,18 +4073,19 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4035 | if (arg1_value == irb->codegen->invalid_instruction) | 4073 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4036 | return arg1_value; | 4074 | return arg1_value; |
| 4037 | | 4075 | |
| 4038 | IrInstruction *ptr_instruction = ir_build_field_ptr_inner(irb, scope, node, arg0_value, arg1_value); | 4076 | IrInstruction *ptr_instruction = ir_build_field_ptr_instruction(irb, scope, node, arg0_value, arg1_value); |
| 4039 | //if (lval.is_ptr) | 4077 | |
| 4040 | // return ptr_instruction; | 4078 | if (lval.is_ptr) |
| | 4079 | return ptr_instruction; |
| 4041 | | 4080 | |
| 4042 | return ir_build_load_ptr(irb, scope, node, ptr_instruction); | 4081 | return ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 4043 | } | 4082 | } |
| 4044 | case BuiltinFnIdBreakpoint: | 4083 | case BuiltinFnIdBreakpoint: |
| 4045 | return ir_build_breakpoint(irb, scope, node); | 4084 | return ir_lval_wrap(irb, scope, ir_build_breakpoint(irb, scope, node), lval); |
| 4046 | case BuiltinFnIdReturnAddress: | 4085 | case BuiltinFnIdReturnAddress: |
| 4047 | return ir_build_return_address(irb, scope, node); | 4086 | return ir_lval_wrap(irb, scope, ir_build_return_address(irb, scope, node), lval); |
| 4048 | case BuiltinFnIdFrameAddress: | 4087 | case BuiltinFnIdFrameAddress: |
| 4049 | return ir_build_frame_address(irb, scope, node); | 4088 | return ir_lval_wrap(irb, scope, ir_build_frame_address(irb, scope, node), lval); |
| 4050 | case BuiltinFnIdAlignOf: | 4089 | case BuiltinFnIdAlignOf: |
| 4051 | { | 4090 | { |
| 4052 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 4091 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| ... | @@ -4054,16 +4093,17 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4054,16 +4093,17 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4054 | if (arg0_value == irb->codegen->invalid_instruction) | 4093 | if (arg0_value == irb->codegen->invalid_instruction) |
| 4055 | return arg0_value; | 4094 | return arg0_value; |
| 4056 | | 4095 | |
| 4057 | return ir_build_align_of(irb, scope, node, arg0_value); | 4096 | IrInstruction *align_of = ir_build_align_of(irb, scope, node, arg0_value); |
| | 4097 | return ir_lval_wrap(irb, scope, align_of, lval); |
| 4058 | } | 4098 | } |
| 4059 | case BuiltinFnIdAddWithOverflow: | 4099 | case BuiltinFnIdAddWithOverflow: |
| 4060 | return ir_gen_overflow_op(irb, scope, node, IrOverflowOpAdd); | 4100 | return ir_lval_wrap(irb, scope, ir_gen_overflow_op(irb, scope, node, IrOverflowOpAdd), lval); |
| 4061 | case BuiltinFnIdSubWithOverflow: | 4101 | case BuiltinFnIdSubWithOverflow: |
| 4062 | return ir_gen_overflow_op(irb, scope, node, IrOverflowOpSub); | 4102 | return ir_lval_wrap(irb, scope, ir_gen_overflow_op(irb, scope, node, IrOverflowOpSub), lval); |
| 4063 | case BuiltinFnIdMulWithOverflow: | 4103 | case BuiltinFnIdMulWithOverflow: |
| 4064 | return ir_gen_overflow_op(irb, scope, node, IrOverflowOpMul); | 4104 | return ir_lval_wrap(irb, scope, ir_gen_overflow_op(irb, scope, node, IrOverflowOpMul), lval); |
| 4065 | case BuiltinFnIdShlWithOverflow: | 4105 | case BuiltinFnIdShlWithOverflow: |
| 4066 | return ir_gen_overflow_op(irb, scope, node, IrOverflowOpShl); | 4106 | return ir_lval_wrap(irb, scope, ir_gen_overflow_op(irb, scope, node, IrOverflowOpShl), lval); |
| 4067 | case BuiltinFnIdTypeName: | 4107 | case BuiltinFnIdTypeName: |
| 4068 | { | 4108 | { |
| 4069 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 4109 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| ... | @@ -4071,7 +4111,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4071,7 +4111,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4071 | if (arg0_value == irb->codegen->invalid_instruction) | 4111 | if (arg0_value == irb->codegen->invalid_instruction) |
| 4072 | return arg0_value; | 4112 | return arg0_value; |
| 4073 | | 4113 | |
| 4074 | return ir_build_type_name(irb, scope, node, arg0_value); | 4114 | IrInstruction *type_name = ir_build_type_name(irb, scope, node, arg0_value); |
| | 4115 | return ir_lval_wrap(irb, scope, type_name, lval); |
| 4075 | } | 4116 | } |
| 4076 | case BuiltinFnIdCanImplicitCast: | 4117 | case BuiltinFnIdCanImplicitCast: |
| 4077 | { | 4118 | { |
| ... | @@ -4085,7 +4126,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4085,7 +4126,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4085 | if (arg1_value == irb->codegen->invalid_instruction) | 4126 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4086 | return arg1_value; | 4127 | return arg1_value; |
| 4087 | | 4128 | |
| 4088 | return ir_build_can_implicit_cast(irb, scope, node, arg0_value, arg1_value); | 4129 | IrInstruction *can_implicit_cast = ir_build_can_implicit_cast(irb, scope, node, arg0_value, arg1_value); |
| | 4130 | return ir_lval_wrap(irb, scope, can_implicit_cast, lval); |
| 4089 | } | 4131 | } |
| 4090 | case BuiltinFnIdPanic: | 4132 | case BuiltinFnIdPanic: |
| 4091 | { | 4133 | { |
| ... | @@ -4094,7 +4136,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4094,7 +4136,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4094 | if (arg0_value == irb->codegen->invalid_instruction) | 4136 | if (arg0_value == irb->codegen->invalid_instruction) |
| 4095 | return arg0_value; | 4137 | return arg0_value; |
| 4096 | | 4138 | |
| 4097 | return ir_build_panic(irb, scope, node, arg0_value); | 4139 | IrInstruction *panic = ir_build_panic(irb, scope, node, arg0_value); |
| | 4140 | return ir_lval_wrap(irb, scope, panic, lval); |
| 4098 | } | 4141 | } |
| 4099 | case BuiltinFnIdPtrCast: | 4142 | case BuiltinFnIdPtrCast: |
| 4100 | { | 4143 | { |
| ... | @@ -4108,7 +4151,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4108,7 +4151,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4108 | if (arg1_value == irb->codegen->invalid_instruction) | 4151 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4109 | return arg1_value; | 4152 | return arg1_value; |
| 4110 | | 4153 | |
| 4111 | return ir_build_ptr_cast(irb, scope, node, arg0_value, arg1_value); | 4154 | IrInstruction *ptr_cast = ir_build_ptr_cast(irb, scope, node, arg0_value, arg1_value); |
| | 4155 | return ir_lval_wrap(irb, scope, ptr_cast, lval); |
| 4112 | } | 4156 | } |
| 4113 | case BuiltinFnIdBitCast: | 4157 | case BuiltinFnIdBitCast: |
| 4114 | { | 4158 | { |
| ... | @@ -4122,7 +4166,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4122,7 +4166,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4122 | if (arg1_value == irb->codegen->invalid_instruction) | 4166 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4123 | return arg1_value; | 4167 | return arg1_value; |
| 4124 | | 4168 | |
| 4125 | return ir_build_bit_cast(irb, scope, node, arg0_value, arg1_value); | 4169 | IrInstruction *bit_cast = ir_build_bit_cast(irb, scope, node, arg0_value, arg1_value); |
| | 4170 | return ir_lval_wrap(irb, scope, bit_cast, lval); |
| 4126 | } | 4171 | } |
| 4127 | case BuiltinFnIdIntToPtr: | 4172 | case BuiltinFnIdIntToPtr: |
| 4128 | { | 4173 | { |
| ... | @@ -4136,7 +4181,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4136,7 +4181,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4136 | if (arg1_value == irb->codegen->invalid_instruction) | 4181 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4137 | return arg1_value; | 4182 | return arg1_value; |
| 4138 | | 4183 | |
| 4139 | return ir_build_int_to_ptr(irb, scope, node, arg0_value, arg1_value); | 4184 | IrInstruction *int_to_ptr = ir_build_int_to_ptr(irb, scope, node, arg0_value, arg1_value); |
| | 4185 | return ir_lval_wrap(irb, scope, int_to_ptr, lval); |
| 4140 | } | 4186 | } |
| 4141 | case BuiltinFnIdPtrToInt: | 4187 | case BuiltinFnIdPtrToInt: |
| 4142 | { | 4188 | { |
| ... | @@ -4145,7 +4191,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4145,7 +4191,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4145 | if (arg0_value == irb->codegen->invalid_instruction) | 4191 | if (arg0_value == irb->codegen->invalid_instruction) |
| 4146 | return arg0_value; | 4192 | return arg0_value; |
| 4147 | | 4193 | |
| 4148 | return ir_build_ptr_to_int(irb, scope, node, arg0_value); | 4194 | IrInstruction *ptr_to_int = ir_build_ptr_to_int(irb, scope, node, arg0_value); |
| | 4195 | return ir_lval_wrap(irb, scope, ptr_to_int, lval); |
| 4149 | } | 4196 | } |
| 4150 | case BuiltinFnIdTagName: | 4197 | case BuiltinFnIdTagName: |
| 4151 | { | 4198 | { |
| ... | @@ -4155,7 +4202,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4155,7 +4202,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4155 | return arg0_value; | 4202 | return arg0_value; |
| 4156 | | 4203 | |
| 4157 | IrInstruction *actual_tag = ir_build_union_tag(irb, scope, node, arg0_value); | 4204 | IrInstruction *actual_tag = ir_build_union_tag(irb, scope, node, arg0_value); |
| 4158 | return ir_build_tag_name(irb, scope, node, actual_tag); | 4205 | IrInstruction *tag_name = ir_build_tag_name(irb, scope, node, actual_tag); |
| | 4206 | return ir_lval_wrap(irb, scope, tag_name, lval); |
| 4159 | } | 4207 | } |
| 4160 | case BuiltinFnIdTagType: | 4208 | case BuiltinFnIdTagType: |
| 4161 | { | 4209 | { |
| ... | @@ -4164,7 +4212,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4164,7 +4212,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4164 | if (arg0_value == irb->codegen->invalid_instruction) | 4212 | if (arg0_value == irb->codegen->invalid_instruction) |
| 4165 | return arg0_value; | 4213 | return arg0_value; |
| 4166 | | 4214 | |
| 4167 | return ir_build_tag_type(irb, scope, node, arg0_value); | 4215 | IrInstruction *tag_type = ir_build_tag_type(irb, scope, node, arg0_value); |
| | 4216 | return ir_lval_wrap(irb, scope, tag_type, lval); |
| 4168 | } | 4217 | } |
| 4169 | case BuiltinFnIdFieldParentPtr: | 4218 | case BuiltinFnIdFieldParentPtr: |
| 4170 | { | 4219 | { |
| ... | @@ -4183,7 +4232,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4183,7 +4232,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4183 | if (arg2_value == irb->codegen->invalid_instruction) | 4232 | if (arg2_value == irb->codegen->invalid_instruction) |
| 4184 | return arg2_value; | 4233 | return arg2_value; |
| 4185 | | 4234 | |
| 4186 | return ir_build_field_parent_ptr(irb, scope, node, arg0_value, arg1_value, arg2_value, nullptr); | 4235 | IrInstruction *field_parent_ptr = ir_build_field_parent_ptr(irb, scope, node, arg0_value, arg1_value, arg2_value, nullptr); |
| | 4236 | return ir_lval_wrap(irb, scope, field_parent_ptr, lval); |
| 4187 | } | 4237 | } |
| 4188 | case BuiltinFnIdOffsetOf: | 4238 | case BuiltinFnIdOffsetOf: |
| 4189 | { | 4239 | { |
| ... | @@ -4197,7 +4247,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4197,7 +4247,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4197 | if (arg1_value == irb->codegen->invalid_instruction) | 4247 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4198 | return arg1_value; | 4248 | return arg1_value; |
| 4199 | | 4249 | |
| 4200 | return ir_build_offset_of(irb, scope, node, arg0_value, arg1_value); | 4250 | IrInstruction *offset_of = ir_build_offset_of(irb, scope, node, arg0_value, arg1_value); |
| | 4251 | return ir_lval_wrap(irb, scope, offset_of, lval); |
| 4201 | } | 4252 | } |
| 4202 | case BuiltinFnIdInlineCall: | 4253 | case BuiltinFnIdInlineCall: |
| 4203 | case BuiltinFnIdNoInlineCall: | 4254 | case BuiltinFnIdNoInlineCall: |
| ... | @@ -4223,7 +4274,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4223,7 +4274,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4223 | } | 4274 | } |
| 4224 | FnInline fn_inline = (builtin_fn->id == BuiltinFnIdInlineCall) ? FnInlineAlways : FnInlineNever; | 4275 | FnInline fn_inline = (builtin_fn->id == BuiltinFnIdInlineCall) ? FnInlineAlways : FnInlineNever; |
| 4225 | | 4276 | |
| 4226 | return ir_build_call(irb, scope, node, nullptr, fn_ref, arg_count, args, false, fn_inline, false, nullptr); | 4277 | IrInstruction *call = ir_build_call(irb, scope, node, nullptr, fn_ref, arg_count, args, false, fn_inline, false, nullptr); |
| | 4278 | return ir_lval_wrap(irb, scope, call, lval); |
| 4227 | } | 4279 | } |
| 4228 | case BuiltinFnIdTypeId: | 4280 | case BuiltinFnIdTypeId: |
| 4229 | { | 4281 | { |
| ... | @@ -4232,7 +4284,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4232,7 +4284,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4232 | if (arg0_value == irb->codegen->invalid_instruction) | 4284 | if (arg0_value == irb->codegen->invalid_instruction) |
| 4233 | return arg0_value; | 4285 | return arg0_value; |
| 4234 | | 4286 | |
| 4235 | return ir_build_type_id(irb, scope, node, arg0_value); | 4287 | IrInstruction *type_id = ir_build_type_id(irb, scope, node, arg0_value); |
| | 4288 | return ir_lval_wrap(irb, scope, type_id, lval); |
| 4236 | } | 4289 | } |
| 4237 | case BuiltinFnIdShlExact: | 4290 | case BuiltinFnIdShlExact: |
| 4238 | { | 4291 | { |
| ... | @@ -4246,7 +4299,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4246,7 +4299,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4246 | if (arg1_value == irb->codegen->invalid_instruction) | 4299 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4247 | return arg1_value; | 4300 | return arg1_value; |
| 4248 | | 4301 | |
| 4249 | return ir_build_bin_op(irb, scope, node, IrBinOpBitShiftLeftExact, arg0_value, arg1_value, true); | 4302 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftLeftExact, arg0_value, arg1_value, true); |
| | 4303 | return ir_lval_wrap(irb, scope, bin_op, lval); |
| 4250 | } | 4304 | } |
| 4251 | case BuiltinFnIdShrExact: | 4305 | case BuiltinFnIdShrExact: |
| 4252 | { | 4306 | { |
| ... | @@ -4260,7 +4314,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4260,7 +4314,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4260 | if (arg1_value == irb->codegen->invalid_instruction) | 4314 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4261 | return arg1_value; | 4315 | return arg1_value; |
| 4262 | | 4316 | |
| 4263 | return ir_build_bin_op(irb, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); | 4317 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); |
| | 4318 | return ir_lval_wrap(irb, scope, bin_op, lval); |
| 4264 | } | 4319 | } |
| 4265 | case BuiltinFnIdSetEvalBranchQuota: | 4320 | case BuiltinFnIdSetEvalBranchQuota: |
| 4266 | { | 4321 | { |
| ... | @@ -4269,7 +4324,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4269,7 +4324,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4269 | if (arg0_value == irb->codegen->invalid_instruction) | 4324 | if (arg0_value == irb->codegen->invalid_instruction) |
| 4270 | return arg0_value; | 4325 | return arg0_value; |
| 4271 | | 4326 | |
| 4272 | return ir_build_set_eval_branch_quota(irb, scope, node, arg0_value); | 4327 | IrInstruction *set_eval_branch_quota = ir_build_set_eval_branch_quota(irb, scope, node, arg0_value); |
| | 4328 | return ir_lval_wrap(irb, scope, set_eval_branch_quota, lval); |
| 4273 | } | 4329 | } |
| 4274 | case BuiltinFnIdAlignCast: | 4330 | case BuiltinFnIdAlignCast: |
| 4275 | { | 4331 | { |
| ... | @@ -4283,10 +4339,14 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4283,10 +4339,14 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4283 | if (arg1_value == irb->codegen->invalid_instruction) | 4339 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4284 | return arg1_value; | 4340 | return arg1_value; |
| 4285 | | 4341 | |
| 4286 | return ir_build_align_cast(irb, scope, node, arg0_value, arg1_value); | 4342 | IrInstruction *align_cast = ir_build_align_cast(irb, scope, node, arg0_value, arg1_value); |
| | 4343 | return ir_lval_wrap(irb, scope, align_cast, lval); |
| 4287 | } | 4344 | } |
| 4288 | case BuiltinFnIdOpaqueType: | 4345 | case BuiltinFnIdOpaqueType: |
| 4289 | return ir_build_opaque_type(irb, scope, node); | 4346 | { |
| | 4347 | IrInstruction *opaque_type = ir_build_opaque_type(irb, scope, node); |
| | 4348 | return ir_lval_wrap(irb, scope, opaque_type, lval); |
| | 4349 | } |
| 4290 | case BuiltinFnIdSetAlignStack: | 4350 | case BuiltinFnIdSetAlignStack: |
| 4291 | { | 4351 | { |
| 4292 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 4352 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| ... | @@ -4294,7 +4354,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4294,7 +4354,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4294 | if (arg0_value == irb->codegen->invalid_instruction) | 4354 | if (arg0_value == irb->codegen->invalid_instruction) |
| 4295 | return arg0_value; | 4355 | return arg0_value; |
| 4296 | | 4356 | |
| 4297 | return ir_build_set_align_stack(irb, scope, node, arg0_value); | 4357 | IrInstruction *set_align_stack = ir_build_set_align_stack(irb, scope, node, arg0_value); |
| | 4358 | return ir_lval_wrap(irb, scope, set_align_stack, lval); |
| 4298 | } | 4359 | } |
| 4299 | case BuiltinFnIdArgType: | 4360 | case BuiltinFnIdArgType: |
| 4300 | { | 4361 | { |
| ... | @@ -4308,7 +4369,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4308,7 +4369,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4308 | if (arg1_value == irb->codegen->invalid_instruction) | 4369 | if (arg1_value == irb->codegen->invalid_instruction) |
| 4309 | return arg1_value; | 4370 | return arg1_value; |
| 4310 | | 4371 | |
| 4311 | return ir_build_arg_type(irb, scope, node, arg0_value, arg1_value); | 4372 | IrInstruction *arg_type = ir_build_arg_type(irb, scope, node, arg0_value, arg1_value); |
| | 4373 | return ir_lval_wrap(irb, scope, arg_type, lval); |
| 4312 | } | 4374 | } |
| 4313 | case BuiltinFnIdExport: | 4375 | case BuiltinFnIdExport: |
| 4314 | { | 4376 | { |
| ... | @@ -4327,11 +4389,13 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4327,11 +4389,13 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4327 | if (arg2_value == irb->codegen->invalid_instruction) | 4389 | if (arg2_value == irb->codegen->invalid_instruction) |
| 4328 | return arg2_value; | 4390 | return arg2_value; |
| 4329 | | 4391 | |
| 4330 | return ir_build_export(irb, scope, node, arg0_value, arg1_value, arg2_value); | 4392 | IrInstruction *ir_export = ir_build_export(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| | 4393 | return ir_lval_wrap(irb, scope, ir_export, lval); |
| 4331 | } | 4394 | } |
| 4332 | case BuiltinFnIdErrorReturnTrace: | 4395 | case BuiltinFnIdErrorReturnTrace: |
| 4333 | { | 4396 | { |
| 4334 | return ir_build_error_return_trace(irb, scope, node, IrInstructionErrorReturnTrace::Null); | 4397 | IrInstruction *error_return_trace = ir_build_error_return_trace(irb, scope, node, IrInstructionErrorReturnTrace::Null); |
| | 4398 | return ir_lval_wrap(irb, scope, error_return_trace, lval); |
| 4335 | } | 4399 | } |
| 4336 | case BuiltinFnIdAtomicRmw: | 4400 | case BuiltinFnIdAtomicRmw: |
| 4337 | { | 4401 | { |
| ... | @@ -4390,11 +4454,11 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -4390,11 +4454,11 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4390 | zig_unreachable(); | 4454 | zig_unreachable(); |
| 4391 | } | 4455 | } |
| 4392 | | 4456 | |
| 4393 | static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node) { | 4457 | static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { |
| 4394 | assert(node->type == NodeTypeFnCallExpr); | 4458 | assert(node->type == NodeTypeFnCallExpr); |
| 4395 | | 4459 | |
| 4396 | if (node->data.fn_call_expr.is_builtin) | 4460 | if (node->data.fn_call_expr.is_builtin) |
| 4397 | return ir_gen_builtin_fn_call(irb, scope, node); | 4461 | return ir_gen_builtin_fn_call(irb, scope, node, lval); |
| 4398 | | 4462 | |
| 4399 | AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr; | 4463 | AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr; |
| 4400 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 4464 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| ... | @@ -4420,7 +4484,8 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -4420,7 +4484,8 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node |
| 4420 | } | 4484 | } |
| 4421 | } | 4485 | } |
| 4422 | | 4486 | |
| 4423 | return ir_build_call(irb, scope, node, nullptr, fn_ref, arg_count, args, false, FnInlineAuto, is_async, async_allocator); | 4487 | IrInstruction *fn_call = ir_build_call(irb, scope, node, nullptr, fn_ref, arg_count, args, false, FnInlineAuto, is_async, async_allocator); |
| | 4488 | return ir_lval_wrap(irb, scope, fn_call, lval); |
| 4424 | } | 4489 | } |
| 4425 | | 4490 | |
| 4426 | static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode *node) { | 4491 | static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode *node) { |
| ... | @@ -6436,7 +6501,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -6436,7 +6501,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 6436 | case NodeTypeSymbol: | 6501 | case NodeTypeSymbol: |
| 6437 | return ir_gen_symbol(irb, scope, node, lval); | 6502 | return ir_gen_symbol(irb, scope, node, lval); |
| 6438 | case NodeTypeFnCallExpr: | 6503 | case NodeTypeFnCallExpr: |
| 6439 | return ir_lval_wrap(irb, scope, ir_gen_fn_call(irb, scope, node), lval); | 6504 | return ir_gen_fn_call(irb, scope, node, lval); |
| 6440 | case NodeTypeIfBoolExpr: | 6505 | case NodeTypeIfBoolExpr: |
| 6441 | return ir_lval_wrap(irb, scope, ir_gen_if_bool_expr(irb, scope, node), lval); | 6506 | return ir_lval_wrap(irb, scope, ir_gen_if_bool_expr(irb, scope, node), lval); |
| 6442 | case NodeTypePrefixOpExpr: | 6507 | case NodeTypePrefixOpExpr: |
| ... | @@ -6456,7 +6521,13 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -6456,7 +6521,13 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 6456 | case NodeTypeReturnExpr: | 6521 | case NodeTypeReturnExpr: |
| 6457 | return ir_gen_return(irb, scope, node, lval); | 6522 | return ir_gen_return(irb, scope, node, lval); |
| 6458 | case NodeTypeFieldAccessExpr: | 6523 | case NodeTypeFieldAccessExpr: |
| 6459 | return ir_gen_field_access(irb, scope, node, lval); | 6524 | { |
| | 6525 | IrInstruction *ptr_instruction = ir_gen_field_access(irb, scope, node); |
| | 6526 | if (lval.is_ptr) |
| | 6527 | return ptr_instruction; |
| | 6528 | |
| | 6529 | return ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| | 6530 | } |
| 6460 | case NodeTypeThisLiteral: | 6531 | case NodeTypeThisLiteral: |
| 6461 | return ir_lval_wrap(irb, scope, ir_gen_this_literal(irb, scope, node), lval); | 6532 | return ir_lval_wrap(irb, scope, ir_gen_this_literal(irb, scope, node), lval); |
| 6462 | case NodeTypeBoolLiteral: | 6533 | case NodeTypeBoolLiteral: |
| ... | @@ -13484,10 +13555,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru | ... | @@ -13484,10 +13555,14 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 13484 | zig_unreachable(); | 13555 | zig_unreachable(); |
| 13485 | } | 13556 | } |
| 13486 | | 13557 | |
| 13487 | IrInstruction *field_name_expr = field_ptr_instruction->field_name_expr->other; | 13558 | Buf *field_name = field_ptr_instruction->field_name_buffer; |
| 13488 | Buf *field_name = ir_resolve_str(ira, field_name_expr); | 13559 | if (!field_name) { |
| 13489 | if (!field_name) | 13560 | IrInstruction *field_name_expr = field_ptr_instruction->field_name_expr->other; |
| 13490 | return ira->codegen->builtin_types.entry_invalid; | 13561 | field_name = ir_resolve_str(ira, field_name_expr); |
| | 13562 | if (!field_name) |
| | 13563 | return ira->codegen->builtin_types.entry_invalid; |
| | 13564 | } |
| | 13565 | |
| 13491 | | 13566 | |
| 13492 | AstNode *source_node = field_ptr_instruction->base.source_node; | 13567 | AstNode *source_node = field_ptr_instruction->base.source_node; |
| 13493 | | 13568 | |