| ... | @@ -2443,7 +2443,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) { | ... | @@ -2443,7 +2443,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) { |
| 2443 | return fn_val; | 2443 | return fn_val; |
| 2444 | | 2444 | |
| 2445 | } | 2445 | } |
| 2446 | static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, IrExecutableGen *executable, | 2446 | static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, Stage1Air *executable, |
| 2447 | IrInstGenSaveErrRetAddr *save_err_ret_addr_instruction) | 2447 | IrInstGenSaveErrRetAddr *save_err_ret_addr_instruction) |
| 2448 | { | 2448 | { |
| 2449 | assert(g->have_err_ret_tracing); | 2449 | assert(g->have_err_ret_tracing); |
| ... | @@ -2636,7 +2636,7 @@ static void gen_async_return(CodeGen *g, IrInstGenReturn *instruction) { | ... | @@ -2636,7 +2636,7 @@ static void gen_async_return(CodeGen *g, IrInstGenReturn *instruction) { |
| 2636 | LLVMBuildRetVoid(g->builder); | 2636 | LLVMBuildRetVoid(g->builder); |
| 2637 | } | 2637 | } |
| 2638 | | 2638 | |
| 2639 | static LLVMValueRef ir_render_return(CodeGen *g, IrExecutableGen *executable, IrInstGenReturn *instruction) { | 2639 | static LLVMValueRef ir_render_return(CodeGen *g, Stage1Air *executable, IrInstGenReturn *instruction) { |
| 2640 | if (fn_is_async(g->cur_fn)) { | 2640 | if (fn_is_async(g->cur_fn)) { |
| 2641 | gen_async_return(g, instruction); | 2641 | gen_async_return(g, instruction); |
| 2642 | return nullptr; | 2642 | return nullptr; |
| ... | @@ -3061,7 +3061,7 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type | ... | @@ -3061,7 +3061,7 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type |
| 3061 | } | 3061 | } |
| 3062 | } | 3062 | } |
| 3063 | | 3063 | |
| 3064 | static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable, | 3064 | static LLVMValueRef ir_render_bin_op(CodeGen *g, Stage1Air *executable, |
| 3065 | IrInstGenBinOp *bin_op_instruction) | 3065 | IrInstGenBinOp *bin_op_instruction) |
| 3066 | { | 3066 | { |
| 3067 | IrBinOp op_id = bin_op_instruction->op_id; | 3067 | IrBinOp op_id = bin_op_instruction->op_id; |
| ... | @@ -3283,7 +3283,7 @@ static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *in | ... | @@ -3283,7 +3283,7 @@ static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *in |
| 3283 | } | 3283 | } |
| 3284 | } | 3284 | } |
| 3285 | | 3285 | |
| 3286 | static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutableGen *executable, | 3286 | static LLVMValueRef ir_render_cast(CodeGen *g, Stage1Air *executable, |
| 3287 | IrInstGenCast *cast_instruction) | 3287 | IrInstGenCast *cast_instruction) |
| 3288 | { | 3288 | { |
| 3289 | Error err; | 3289 | Error err; |
| ... | @@ -3367,7 +3367,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutableGen *executable, | ... | @@ -3367,7 +3367,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutableGen *executable, |
| 3367 | zig_unreachable(); | 3367 | zig_unreachable(); |
| 3368 | } | 3368 | } |
| 3369 | | 3369 | |
| 3370 | static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutableGen *executable, | 3370 | static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, Stage1Air *executable, |
| 3371 | IrInstGenPtrOfArrayToSlice *instruction) | 3371 | IrInstGenPtrOfArrayToSlice *instruction) |
| 3372 | { | 3372 | { |
| 3373 | ZigType *actual_type = instruction->operand->value->type; | 3373 | ZigType *actual_type = instruction->operand->value->type; |
| ... | @@ -3404,7 +3404,7 @@ static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutableGen | ... | @@ -3404,7 +3404,7 @@ static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutableGen |
| 3404 | return result_loc; | 3404 | return result_loc; |
| 3405 | } | 3405 | } |
| 3406 | | 3406 | |
| 3407 | static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutableGen *executable, | 3407 | static LLVMValueRef ir_render_ptr_cast(CodeGen *g, Stage1Air *executable, |
| 3408 | IrInstGenPtrCast *instruction) | 3408 | IrInstGenPtrCast *instruction) |
| 3409 | { | 3409 | { |
| 3410 | ZigType *wanted_type = instruction->base.value->type; | 3410 | ZigType *wanted_type = instruction->base.value->type; |
| ... | @@ -3430,7 +3430,7 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutableGen *executable, | ... | @@ -3430,7 +3430,7 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutableGen *executable, |
| 3430 | return result_ptr; | 3430 | return result_ptr; |
| 3431 | } | 3431 | } |
| 3432 | | 3432 | |
| 3433 | static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutableGen *executable, | 3433 | static LLVMValueRef ir_render_bit_cast(CodeGen *g, Stage1Air *executable, |
| 3434 | IrInstGenBitCast *instruction) | 3434 | IrInstGenBitCast *instruction) |
| 3435 | { | 3435 | { |
| 3436 | ZigType *wanted_type = instruction->base.value->type; | 3436 | ZigType *wanted_type = instruction->base.value->type; |
| ... | @@ -3458,7 +3458,7 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutableGen *executable, | ... | @@ -3458,7 +3458,7 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutableGen *executable, |
| 3458 | } | 3458 | } |
| 3459 | } | 3459 | } |
| 3460 | | 3460 | |
| 3461 | static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutableGen *executable, | 3461 | static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, Stage1Air *executable, |
| 3462 | IrInstGenWidenOrShorten *instruction) | 3462 | IrInstGenWidenOrShorten *instruction) |
| 3463 | { | 3463 | { |
| 3464 | ZigType *actual_type = instruction->target->value->type; | 3464 | ZigType *actual_type = instruction->target->value->type; |
| ... | @@ -3475,7 +3475,7 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutableGen *exec | ... | @@ -3475,7 +3475,7 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutableGen *exec |
| 3475 | instruction->base.value->type, target_val); | 3475 | instruction->base.value->type, target_val); |
| 3476 | } | 3476 | } |
| 3477 | | 3477 | |
| 3478 | static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenIntToPtr *instruction) { | 3478 | static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, Stage1Air *executable, IrInstGenIntToPtr *instruction) { |
| 3479 | ZigType *wanted_type = instruction->base.value->type; | 3479 | ZigType *wanted_type = instruction->base.value->type; |
| 3480 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); | 3480 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 3481 | const uint32_t align_bytes = get_ptr_align(g, wanted_type); | 3481 | const uint32_t align_bytes = get_ptr_align(g, wanted_type); |
| ... | @@ -3513,13 +3513,13 @@ static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable | ... | @@ -3513,13 +3513,13 @@ static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable |
| 3513 | return LLVMBuildIntToPtr(g->builder, target_val, get_llvm_type(g, wanted_type), ""); | 3513 | return LLVMBuildIntToPtr(g->builder, target_val, get_llvm_type(g, wanted_type), ""); |
| 3514 | } | 3514 | } |
| 3515 | | 3515 | |
| 3516 | static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, IrExecutableGen *executable, IrInstGenPtrToInt *instruction) { | 3516 | static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, Stage1Air *executable, IrInstGenPtrToInt *instruction) { |
| 3517 | ZigType *wanted_type = instruction->base.value->type; | 3517 | ZigType *wanted_type = instruction->base.value->type; |
| 3518 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); | 3518 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 3519 | return LLVMBuildPtrToInt(g->builder, target_val, get_llvm_type(g, wanted_type), ""); | 3519 | return LLVMBuildPtrToInt(g->builder, target_val, get_llvm_type(g, wanted_type), ""); |
| 3520 | } | 3520 | } |
| 3521 | | 3521 | |
| 3522 | static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutableGen *executable, IrInstGenIntToEnum *instruction) { | 3522 | static LLVMValueRef ir_render_int_to_enum(CodeGen *g, Stage1Air *executable, IrInstGenIntToEnum *instruction) { |
| 3523 | ZigType *wanted_type = instruction->base.value->type; | 3523 | ZigType *wanted_type = instruction->base.value->type; |
| 3524 | assert(wanted_type->id == ZigTypeIdEnum); | 3524 | assert(wanted_type->id == ZigTypeIdEnum); |
| 3525 | ZigType *tag_int_type = wanted_type->data.enumeration.tag_int_type; | 3525 | ZigType *tag_int_type = wanted_type->data.enumeration.tag_int_type; |
| ... | @@ -3559,7 +3559,7 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutableGen *executabl | ... | @@ -3559,7 +3559,7 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutableGen *executabl |
| 3559 | return tag_int_value; | 3559 | return tag_int_value; |
| 3560 | } | 3560 | } |
| 3561 | | 3561 | |
| 3562 | static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutableGen *executable, IrInstGenIntToErr *instruction) { | 3562 | static LLVMValueRef ir_render_int_to_err(CodeGen *g, Stage1Air *executable, IrInstGenIntToErr *instruction) { |
| 3563 | ZigType *wanted_type = instruction->base.value->type; | 3563 | ZigType *wanted_type = instruction->base.value->type; |
| 3564 | assert(wanted_type->id == ZigTypeIdErrorSet); | 3564 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 3565 | | 3565 | |
| ... | @@ -3576,7 +3576,7 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutableGen *executable | ... | @@ -3576,7 +3576,7 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutableGen *executable |
| 3576 | return gen_widen_or_shorten(g, false, actual_type, g->err_tag_type, target_val); | 3576 | return gen_widen_or_shorten(g, false, actual_type, g->err_tag_type, target_val); |
| 3577 | } | 3577 | } |
| 3578 | | 3578 | |
| 3579 | static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutableGen *executable, IrInstGenErrToInt *instruction) { | 3579 | static LLVMValueRef ir_render_err_to_int(CodeGen *g, Stage1Air *executable, IrInstGenErrToInt *instruction) { |
| 3580 | ZigType *wanted_type = instruction->base.value->type; | 3580 | ZigType *wanted_type = instruction->base.value->type; |
| 3581 | assert(wanted_type->id == ZigTypeIdInt); | 3581 | assert(wanted_type->id == ZigTypeIdInt); |
| 3582 | assert(!wanted_type->data.integral.is_signed); | 3582 | assert(!wanted_type->data.integral.is_signed); |
| ... | @@ -3602,7 +3602,7 @@ static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutableGen *executable | ... | @@ -3602,7 +3602,7 @@ static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutableGen *executable |
| 3602 | } | 3602 | } |
| 3603 | } | 3603 | } |
| 3604 | | 3604 | |
| 3605 | static LLVMValueRef ir_render_unreachable(CodeGen *g, IrExecutableGen *executable, | 3605 | static LLVMValueRef ir_render_unreachable(CodeGen *g, Stage1Air *executable, |
| 3606 | IrInstGenUnreachable *unreachable_instruction) | 3606 | IrInstGenUnreachable *unreachable_instruction) |
| 3607 | { | 3607 | { |
| 3608 | if (ir_want_runtime_safety(g, &unreachable_instruction->base)) { | 3608 | if (ir_want_runtime_safety(g, &unreachable_instruction->base)) { |
| ... | @@ -3613,7 +3613,7 @@ static LLVMValueRef ir_render_unreachable(CodeGen *g, IrExecutableGen *executabl | ... | @@ -3613,7 +3613,7 @@ static LLVMValueRef ir_render_unreachable(CodeGen *g, IrExecutableGen *executabl |
| 3613 | return nullptr; | 3613 | return nullptr; |
| 3614 | } | 3614 | } |
| 3615 | | 3615 | |
| 3616 | static LLVMValueRef ir_render_cond_br(CodeGen *g, IrExecutableGen *executable, | 3616 | static LLVMValueRef ir_render_cond_br(CodeGen *g, Stage1Air *executable, |
| 3617 | IrInstGenCondBr *cond_br_instruction) | 3617 | IrInstGenCondBr *cond_br_instruction) |
| 3618 | { | 3618 | { |
| 3619 | LLVMBuildCondBr(g->builder, | 3619 | LLVMBuildCondBr(g->builder, |
| ... | @@ -3623,12 +3623,12 @@ static LLVMValueRef ir_render_cond_br(CodeGen *g, IrExecutableGen *executable, | ... | @@ -3623,12 +3623,12 @@ static LLVMValueRef ir_render_cond_br(CodeGen *g, IrExecutableGen *executable, |
| 3623 | return nullptr; | 3623 | return nullptr; |
| 3624 | } | 3624 | } |
| 3625 | | 3625 | |
| 3626 | static LLVMValueRef ir_render_br(CodeGen *g, IrExecutableGen *executable, IrInstGenBr *br_instruction) { | 3626 | static LLVMValueRef ir_render_br(CodeGen *g, Stage1Air *executable, IrInstGenBr *br_instruction) { |
| 3627 | LLVMBuildBr(g->builder, br_instruction->dest_block->llvm_block); | 3627 | LLVMBuildBr(g->builder, br_instruction->dest_block->llvm_block); |
| 3628 | return nullptr; | 3628 | return nullptr; |
| 3629 | } | 3629 | } |
| 3630 | | 3630 | |
| 3631 | static LLVMValueRef ir_render_binary_not(CodeGen *g, IrExecutableGen *executable, | 3631 | static LLVMValueRef ir_render_binary_not(CodeGen *g, Stage1Air *executable, |
| 3632 | IrInstGenBinaryNot *inst) | 3632 | IrInstGenBinaryNot *inst) |
| 3633 | { | 3633 | { |
| 3634 | LLVMValueRef operand = ir_llvm_value(g, inst->operand); | 3634 | LLVMValueRef operand = ir_llvm_value(g, inst->operand); |
| ... | @@ -3660,13 +3660,13 @@ static LLVMValueRef ir_gen_negation(CodeGen *g, IrInstGen *inst, IrInstGen *oper | ... | @@ -3660,13 +3660,13 @@ static LLVMValueRef ir_gen_negation(CodeGen *g, IrInstGen *inst, IrInstGen *oper |
| 3660 | } | 3660 | } |
| 3661 | } | 3661 | } |
| 3662 | | 3662 | |
| 3663 | static LLVMValueRef ir_render_negation(CodeGen *g, IrExecutableGen *executable, | 3663 | static LLVMValueRef ir_render_negation(CodeGen *g, Stage1Air *executable, |
| 3664 | IrInstGenNegation *inst) | 3664 | IrInstGenNegation *inst) |
| 3665 | { | 3665 | { |
| 3666 | return ir_gen_negation(g, &inst->base, inst->operand, inst->wrapping); | 3666 | return ir_gen_negation(g, &inst->base, inst->operand, inst->wrapping); |
| 3667 | } | 3667 | } |
| 3668 | | 3668 | |
| 3669 | static LLVMValueRef ir_render_bool_not(CodeGen *g, IrExecutableGen *executable, IrInstGenBoolNot *instruction) { | 3669 | static LLVMValueRef ir_render_bool_not(CodeGen *g, Stage1Air *executable, IrInstGenBoolNot *instruction) { |
| 3670 | LLVMValueRef value = ir_llvm_value(g, instruction->value); | 3670 | LLVMValueRef value = ir_llvm_value(g, instruction->value); |
| 3671 | LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(value)); | 3671 | LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(value)); |
| 3672 | return LLVMBuildICmp(g->builder, LLVMIntEQ, value, zero, ""); | 3672 | return LLVMBuildICmp(g->builder, LLVMIntEQ, value, zero, ""); |
| ... | @@ -3680,14 +3680,14 @@ static void render_decl_var(CodeGen *g, ZigVar *var) { | ... | @@ -3680,14 +3680,14 @@ static void render_decl_var(CodeGen *g, ZigVar *var) { |
| 3680 | gen_var_debug_decl(g, var); | 3680 | gen_var_debug_decl(g, var); |
| 3681 | } | 3681 | } |
| 3682 | | 3682 | |
| 3683 | static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutableGen *executable, IrInstGenDeclVar *instruction) { | 3683 | static LLVMValueRef ir_render_decl_var(CodeGen *g, Stage1Air *executable, IrInstGenDeclVar *instruction) { |
| 3684 | instruction->var->ptr_instruction = instruction->var_ptr; | 3684 | instruction->var->ptr_instruction = instruction->var_ptr; |
| 3685 | instruction->var->did_the_decl_codegen = true; | 3685 | instruction->var->did_the_decl_codegen = true; |
| 3686 | render_decl_var(g, instruction->var); | 3686 | render_decl_var(g, instruction->var); |
| 3687 | return nullptr; | 3687 | return nullptr; |
| 3688 | } | 3688 | } |
| 3689 | | 3689 | |
| 3690 | static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutableGen *executable, | 3690 | static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable, |
| 3691 | IrInstGenLoadPtr *instruction) | 3691 | IrInstGenLoadPtr *instruction) |
| 3692 | { | 3692 | { |
| 3693 | ZigType *child_type = instruction->base.value->type; | 3693 | ZigType *child_type = instruction->base.value->type; |
| ... | @@ -3889,7 +3889,7 @@ static void gen_undef_init(CodeGen *g, ZigType *ptr_type, ZigType *value_type, L | ... | @@ -3889,7 +3889,7 @@ static void gen_undef_init(CodeGen *g, ZigType *ptr_type, ZigType *value_type, L |
| 3889 | gen_assign_raw(g, ptr, ptr_type, zero); | 3889 | gen_assign_raw(g, ptr, ptr_type, zero); |
| 3890 | } | 3890 | } |
| 3891 | | 3891 | |
| 3892 | static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenStorePtr *instruction) { | 3892 | static LLVMValueRef ir_render_store_ptr(CodeGen *g, Stage1Air *executable, IrInstGenStorePtr *instruction) { |
| 3893 | Error err; | 3893 | Error err; |
| 3894 | | 3894 | |
| 3895 | ZigType *ptr_type = instruction->ptr->value->type; | 3895 | ZigType *ptr_type = instruction->ptr->value->type; |
| ... | @@ -3921,7 +3921,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutableGen *executable, | ... | @@ -3921,7 +3921,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutableGen *executable, |
| 3921 | return nullptr; | 3921 | return nullptr; |
| 3922 | } | 3922 | } |
| 3923 | | 3923 | |
| 3924 | static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutableGen *executable, | 3924 | static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, Stage1Air *executable, |
| 3925 | IrInstGenVectorStoreElem *instruction) | 3925 | IrInstGenVectorStoreElem *instruction) |
| 3926 | { | 3926 | { |
| 3927 | LLVMValueRef vector_ptr = ir_llvm_value(g, instruction->vector_ptr); | 3927 | LLVMValueRef vector_ptr = ir_llvm_value(g, instruction->vector_ptr); |
| ... | @@ -3934,7 +3934,7 @@ static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutableGen *exe | ... | @@ -3934,7 +3934,7 @@ static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutableGen *exe |
| 3934 | return nullptr; | 3934 | return nullptr; |
| 3935 | } | 3935 | } |
| 3936 | | 3936 | |
| 3937 | static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenVarPtr *instruction) { | 3937 | static LLVMValueRef ir_render_var_ptr(CodeGen *g, Stage1Air *executable, IrInstGenVarPtr *instruction) { |
| 3938 | Error err; | 3938 | Error err; |
| 3939 | | 3939 | |
| 3940 | ZigType *ptr_type = instruction->base.value->type; | 3940 | ZigType *ptr_type = instruction->base.value->type; |
| ... | @@ -3961,7 +3961,7 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutableGen *executable, I | ... | @@ -3961,7 +3961,7 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutableGen *executable, I |
| 3961 | get_llvm_type(g, ptr_type), ""); | 3961 | get_llvm_type(g, ptr_type), ""); |
| 3962 | } | 3962 | } |
| 3963 | | 3963 | |
| 3964 | static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutableGen *executable, | 3964 | static LLVMValueRef ir_render_return_ptr(CodeGen *g, Stage1Air *executable, |
| 3965 | IrInstGenReturnPtr *instruction) | 3965 | IrInstGenReturnPtr *instruction) |
| 3966 | { | 3966 | { |
| 3967 | if (!type_has_bits(g, instruction->base.value->type)) | 3967 | if (!type_has_bits(g, instruction->base.value->type)) |
| ... | @@ -3970,7 +3970,7 @@ static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutableGen *executable | ... | @@ -3970,7 +3970,7 @@ static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutableGen *executable |
| 3970 | return g->cur_ret_ptr; | 3970 | return g->cur_ret_ptr; |
| 3971 | } | 3971 | } |
| 3972 | | 3972 | |
| 3973 | static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenElemPtr *instruction) { | 3973 | static LLVMValueRef ir_render_elem_ptr(CodeGen *g, Stage1Air *executable, IrInstGenElemPtr *instruction) { |
| 3974 | LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr); | 3974 | LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr); |
| 3975 | ZigType *array_ptr_type = instruction->array_ptr->value->type; | 3975 | ZigType *array_ptr_type = instruction->array_ptr->value->type; |
| 3976 | assert(array_ptr_type->id == ZigTypeIdPointer); | 3976 | assert(array_ptr_type->id == ZigTypeIdPointer); |
| ... | @@ -4222,7 +4222,7 @@ static void gen_init_stack_trace(CodeGen *g, LLVMValueRef trace_field_ptr, LLVMV | ... | @@ -4222,7 +4222,7 @@ static void gen_init_stack_trace(CodeGen *g, LLVMValueRef trace_field_ptr, LLVMV |
| 4222 | LLVMBuildStore(g->builder, LLVMConstInt(usize_type_ref, stack_trace_ptr_count, false), addrs_len_ptr); | 4222 | LLVMBuildStore(g->builder, LLVMConstInt(usize_type_ref, stack_trace_ptr_count, false), addrs_len_ptr); |
| 4223 | } | 4223 | } |
| 4224 | | 4224 | |
| 4225 | static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrInstGenCall *instruction) { | 4225 | static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, IrInstGenCall *instruction) { |
| 4226 | Error err; | 4226 | Error err; |
| 4227 | | 4227 | |
| 4228 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; | 4228 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; |
| ... | @@ -4642,7 +4642,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn | ... | @@ -4642,7 +4642,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn |
| 4642 | } | 4642 | } |
| 4643 | } | 4643 | } |
| 4644 | | 4644 | |
| 4645 | static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutableGen *executable, | 4645 | static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, Stage1Air *executable, |
| 4646 | IrInstGenStructFieldPtr *instruction) | 4646 | IrInstGenStructFieldPtr *instruction) |
| 4647 | { | 4647 | { |
| 4648 | Error err; | 4648 | Error err; |
| ... | @@ -4693,7 +4693,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutableGen *exec | ... | @@ -4693,7 +4693,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutableGen *exec |
| 4693 | return field_ptr_val; | 4693 | return field_ptr_val; |
| 4694 | } | 4694 | } |
| 4695 | | 4695 | |
| 4696 | static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutableGen *executable, | 4696 | static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, Stage1Air *executable, |
| 4697 | IrInstGenUnionFieldPtr *instruction) | 4697 | IrInstGenUnionFieldPtr *instruction) |
| 4698 | { | 4698 | { |
| 4699 | if (instruction->base.value->special != ConstValSpecialRuntime) | 4699 | if (instruction->base.value->special != ConstValSpecialRuntime) |
| ... | @@ -4793,7 +4793,7 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_ | ... | @@ -4793,7 +4793,7 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_ |
| 4793 | return SIZE_MAX; | 4793 | return SIZE_MAX; |
| 4794 | } | 4794 | } |
| 4795 | | 4795 | |
| 4796 | static LLVMValueRef ir_render_asm_gen(CodeGen *g, IrExecutableGen *executable, IrInstGenAsm *instruction) { | 4796 | static LLVMValueRef ir_render_asm_gen(CodeGen *g, Stage1Air *executable, IrInstGenAsm *instruction) { |
| 4797 | AstNode *asm_node = instruction->base.base.source_node; | 4797 | AstNode *asm_node = instruction->base.base.source_node; |
| 4798 | assert(asm_node->type == NodeTypeAsmExpr); | 4798 | assert(asm_node->type == NodeTypeAsmExpr); |
| 4799 | AstNodeAsmExpr *asm_expr = &asm_node->data.asm_expr; | 4799 | AstNodeAsmExpr *asm_expr = &asm_node->data.asm_expr; |
| ... | @@ -4970,13 +4970,13 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueR | ... | @@ -4970,13 +4970,13 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueR |
| 4970 | return gen_load_untyped(g, maybe_field_ptr, 0, false, ""); | 4970 | return gen_load_untyped(g, maybe_field_ptr, 0, false, ""); |
| 4971 | } | 4971 | } |
| 4972 | | 4972 | |
| 4973 | static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutableGen *executable, | 4973 | static LLVMValueRef ir_render_test_non_null(CodeGen *g, Stage1Air *executable, |
| 4974 | IrInstGenTestNonNull *instruction) | 4974 | IrInstGenTestNonNull *instruction) |
| 4975 | { | 4975 | { |
| 4976 | return gen_non_null_bit(g, instruction->value->value->type, ir_llvm_value(g, instruction->value)); | 4976 | return gen_non_null_bit(g, instruction->value->value->type, ir_llvm_value(g, instruction->value)); |
| 4977 | } | 4977 | } |
| 4978 | | 4978 | |
| 4979 | static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutableGen *executable, | 4979 | static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, Stage1Air *executable, |
| 4980 | IrInstGenOptionalUnwrapPtr *instruction) | 4980 | IrInstGenOptionalUnwrapPtr *instruction) |
| 4981 | { | 4981 | { |
| 4982 | if (instruction->base.value->special != ConstValSpecialRuntime) | 4982 | if (instruction->base.value->special != ConstValSpecialRuntime) |
| ... | @@ -5083,7 +5083,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *expr_type, BuiltinFn | ... | @@ -5083,7 +5083,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *expr_type, BuiltinFn |
| 5083 | return fn_val; | 5083 | return fn_val; |
| 5084 | } | 5084 | } |
| 5085 | | 5085 | |
| 5086 | static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutableGen *executable, IrInstGenClz *instruction) { | 5086 | static LLVMValueRef ir_render_clz(CodeGen *g, Stage1Air *executable, IrInstGenClz *instruction) { |
| 5087 | ZigType *int_type = instruction->op->value->type; | 5087 | ZigType *int_type = instruction->op->value->type; |
| 5088 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz); | 5088 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz); |
| 5089 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); | 5089 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); |
| ... | @@ -5095,7 +5095,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutableGen *executable, IrIns | ... | @@ -5095,7 +5095,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutableGen *executable, IrIns |
| 5095 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); | 5095 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); |
| 5096 | } | 5096 | } |
| 5097 | | 5097 | |
| 5098 | static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutableGen *executable, IrInstGenCtz *instruction) { | 5098 | static LLVMValueRef ir_render_ctz(CodeGen *g, Stage1Air *executable, IrInstGenCtz *instruction) { |
| 5099 | ZigType *int_type = instruction->op->value->type; | 5099 | ZigType *int_type = instruction->op->value->type; |
| 5100 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz); | 5100 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz); |
| 5101 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); | 5101 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); |
| ... | @@ -5107,7 +5107,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutableGen *executable, IrIns | ... | @@ -5107,7 +5107,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutableGen *executable, IrIns |
| 5107 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); | 5107 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); |
| 5108 | } | 5108 | } |
| 5109 | | 5109 | |
| 5110 | static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutableGen *executable, IrInstGenShuffleVector *instruction) { | 5110 | static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, Stage1Air *executable, IrInstGenShuffleVector *instruction) { |
| 5111 | uint64_t len_a = instruction->a->value->type->data.vector.len; | 5111 | uint64_t len_a = instruction->a->value->type->data.vector.len; |
| 5112 | uint64_t len_mask = instruction->mask->value->type->data.vector.len; | 5112 | uint64_t len_mask = instruction->mask->value->type->data.vector.len; |
| 5113 | | 5113 | |
| ... | @@ -5137,7 +5137,7 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutableGen *execut | ... | @@ -5137,7 +5137,7 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutableGen *execut |
| 5137 | llvm_mask_value, ""); | 5137 | llvm_mask_value, ""); |
| 5138 | } | 5138 | } |
| 5139 | | 5139 | |
| 5140 | static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutableGen *executable, IrInstGenSplat *instruction) { | 5140 | static LLVMValueRef ir_render_splat(CodeGen *g, Stage1Air *executable, IrInstGenSplat *instruction) { |
| 5141 | ZigType *result_type = instruction->base.value->type; | 5141 | ZigType *result_type = instruction->base.value->type; |
| 5142 | ir_assert(result_type->id == ZigTypeIdVector, &instruction->base); | 5142 | ir_assert(result_type->id == ZigTypeIdVector, &instruction->base); |
| 5143 | uint32_t len = result_type->data.vector.len; | 5143 | uint32_t len = result_type->data.vector.len; |
| ... | @@ -5149,7 +5149,7 @@ static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutableGen *executable, IrI | ... | @@ -5149,7 +5149,7 @@ static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutableGen *executable, IrI |
| 5149 | return LLVMBuildShuffleVector(g->builder, op_vector, undef_vector, LLVMConstNull(mask_llvm_type), ""); | 5149 | return LLVMBuildShuffleVector(g->builder, op_vector, undef_vector, LLVMConstNull(mask_llvm_type), ""); |
| 5150 | } | 5150 | } |
| 5151 | | 5151 | |
| 5152 | static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutableGen *executable, IrInstGenPopCount *instruction) { | 5152 | static LLVMValueRef ir_render_pop_count(CodeGen *g, Stage1Air *executable, IrInstGenPopCount *instruction) { |
| 5153 | ZigType *int_type = instruction->op->value->type; | 5153 | ZigType *int_type = instruction->op->value->type; |
| 5154 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount); | 5154 | LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount); |
| 5155 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); | 5155 | LLVMValueRef operand = ir_llvm_value(g, instruction->op); |
| ... | @@ -5157,7 +5157,7 @@ static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutableGen *executable, | ... | @@ -5157,7 +5157,7 @@ static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutableGen *executable, |
| 5157 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); | 5157 | return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int); |
| 5158 | } | 5158 | } |
| 5159 | | 5159 | |
| 5160 | static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutableGen *executable, IrInstGenSwitchBr *instruction) { | 5160 | static LLVMValueRef ir_render_switch_br(CodeGen *g, Stage1Air *executable, IrInstGenSwitchBr *instruction) { |
| 5161 | ZigType *target_type = instruction->target_value->value->type; | 5161 | ZigType *target_type = instruction->target_value->value->type; |
| 5162 | LLVMBasicBlockRef else_block = instruction->else_block->llvm_block; | 5162 | LLVMBasicBlockRef else_block = instruction->else_block->llvm_block; |
| 5163 | | 5163 | |
| ... | @@ -5185,7 +5185,7 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutableGen *executable, | ... | @@ -5185,7 +5185,7 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutableGen *executable, |
| 5185 | return nullptr; | 5185 | return nullptr; |
| 5186 | } | 5186 | } |
| 5187 | | 5187 | |
| 5188 | static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutableGen *executable, IrInstGenPhi *instruction) { | 5188 | static LLVMValueRef ir_render_phi(CodeGen *g, Stage1Air *executable, IrInstGenPhi *instruction) { |
| 5189 | if (!type_has_bits(g, instruction->base.value->type)) | 5189 | if (!type_has_bits(g, instruction->base.value->type)) |
| 5190 | return nullptr; | 5190 | return nullptr; |
| 5191 | | 5191 | |
| ... | @@ -5209,7 +5209,7 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutableGen *executable, IrIns | ... | @@ -5209,7 +5209,7 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutableGen *executable, IrIns |
| 5209 | return phi; | 5209 | return phi; |
| 5210 | } | 5210 | } |
| 5211 | | 5211 | |
| 5212 | static LLVMValueRef ir_render_ref(CodeGen *g, IrExecutableGen *executable, IrInstGenRef *instruction) { | 5212 | static LLVMValueRef ir_render_ref(CodeGen *g, Stage1Air *executable, IrInstGenRef *instruction) { |
| 5213 | if (!type_has_bits(g, instruction->base.value->type)) { | 5213 | if (!type_has_bits(g, instruction->base.value->type)) { |
| 5214 | return nullptr; | 5214 | return nullptr; |
| 5215 | } | 5215 | } |
| ... | @@ -5229,7 +5229,7 @@ static LLVMValueRef ir_render_ref(CodeGen *g, IrExecutableGen *executable, IrIns | ... | @@ -5229,7 +5229,7 @@ static LLVMValueRef ir_render_ref(CodeGen *g, IrExecutableGen *executable, IrIns |
| 5229 | } | 5229 | } |
| 5230 | } | 5230 | } |
| 5231 | | 5231 | |
| 5232 | static LLVMValueRef ir_render_err_name(CodeGen *g, IrExecutableGen *executable, IrInstGenErrName *instruction) { | 5232 | static LLVMValueRef ir_render_err_name(CodeGen *g, Stage1Air *executable, IrInstGenErrName *instruction) { |
| 5233 | assert(g->generate_error_name_table); | 5233 | assert(g->generate_error_name_table); |
| 5234 | assert(g->errors_by_index.length > 0); | 5234 | assert(g->errors_by_index.length > 0); |
| 5235 | | 5235 | |
| ... | @@ -5356,7 +5356,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) { | ... | @@ -5356,7 +5356,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) { |
| 5356 | return fn_val; | 5356 | return fn_val; |
| 5357 | } | 5357 | } |
| 5358 | | 5358 | |
| 5359 | static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutableGen *executable, | 5359 | static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, Stage1Air *executable, |
| 5360 | IrInstGenTagName *instruction) | 5360 | IrInstGenTagName *instruction) |
| 5361 | { | 5361 | { |
| 5362 | ZigType *enum_type = instruction->target->value->type; | 5362 | ZigType *enum_type = instruction->target->value->type; |
| ... | @@ -5369,7 +5369,7 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutableGen *executa | ... | @@ -5369,7 +5369,7 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutableGen *executa |
| 5369 | get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, ""); | 5369 | get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, ""); |
| 5370 | } | 5370 | } |
| 5371 | | 5371 | |
| 5372 | static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutableGen *executable, | 5372 | static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, Stage1Air *executable, |
| 5373 | IrInstGenFieldParentPtr *instruction) | 5373 | IrInstGenFieldParentPtr *instruction) |
| 5374 | { | 5374 | { |
| 5375 | ZigType *container_ptr_type = instruction->base.value->type; | 5375 | ZigType *container_ptr_type = instruction->base.value->type; |
| ... | @@ -5396,7 +5396,7 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutableGen *exec | ... | @@ -5396,7 +5396,7 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutableGen *exec |
| 5396 | } | 5396 | } |
| 5397 | } | 5397 | } |
| 5398 | | 5398 | |
| 5399 | static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutableGen *executable, IrInstGenAlignCast *instruction) { | 5399 | static LLVMValueRef ir_render_align_cast(CodeGen *g, Stage1Air *executable, IrInstGenAlignCast *instruction) { |
| 5400 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); | 5400 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 5401 | assert(target_val); | 5401 | assert(target_val); |
| 5402 | | 5402 | |
| ... | @@ -5459,7 +5459,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutableGen *executable | ... | @@ -5459,7 +5459,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutableGen *executable |
| 5459 | return target_val; | 5459 | return target_val; |
| 5460 | } | 5460 | } |
| 5461 | | 5461 | |
| 5462 | static LLVMValueRef ir_render_error_return_trace(CodeGen *g, IrExecutableGen *executable, | 5462 | static LLVMValueRef ir_render_error_return_trace(CodeGen *g, Stage1Air *executable, |
| 5463 | IrInstGenErrorReturnTrace *instruction) | 5463 | IrInstGenErrorReturnTrace *instruction) |
| 5464 | { | 5464 | { |
| 5465 | bool is_llvm_alloca; | 5465 | bool is_llvm_alloca; |
| ... | @@ -5530,7 +5530,7 @@ static LLVMTypeRef get_atomic_abi_type(CodeGen *g, IrInstGen *instruction) { | ... | @@ -5530,7 +5530,7 @@ static LLVMTypeRef get_atomic_abi_type(CodeGen *g, IrInstGen *instruction) { |
| 5530 | } | 5530 | } |
| 5531 | } | 5531 | } |
| 5532 | | 5532 | |
| 5533 | static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutableGen *executable, IrInstGenCmpxchg *instruction) { | 5533 | static LLVMValueRef ir_render_cmpxchg(CodeGen *g, Stage1Air *executable, IrInstGenCmpxchg *instruction) { |
| 5534 | LLVMValueRef ptr_val = ir_llvm_value(g, instruction->ptr); | 5534 | LLVMValueRef ptr_val = ir_llvm_value(g, instruction->ptr); |
| 5535 | LLVMValueRef cmp_val = ir_llvm_value(g, instruction->cmp_value); | 5535 | LLVMValueRef cmp_val = ir_llvm_value(g, instruction->cmp_value); |
| 5536 | LLVMValueRef new_val = ir_llvm_value(g, instruction->new_value); | 5536 | LLVMValueRef new_val = ir_llvm_value(g, instruction->new_value); |
| ... | @@ -5592,7 +5592,7 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutableGen *executable, I | ... | @@ -5592,7 +5592,7 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutableGen *executable, I |
| 5592 | return result_loc; | 5592 | return result_loc; |
| 5593 | } | 5593 | } |
| 5594 | | 5594 | |
| 5595 | static LLVMValueRef ir_render_reduce(CodeGen *g, IrExecutableGen *executable, IrInstGenReduce *instruction) { | 5595 | static LLVMValueRef ir_render_reduce(CodeGen *g, Stage1Air *executable, IrInstGenReduce *instruction) { |
| 5596 | LLVMValueRef value = ir_llvm_value(g, instruction->value); | 5596 | LLVMValueRef value = ir_llvm_value(g, instruction->value); |
| 5597 | | 5597 | |
| 5598 | ZigType *value_type = instruction->value->value->type; | 5598 | ZigType *value_type = instruction->value->value->type; |
| ... | @@ -5656,13 +5656,13 @@ static LLVMValueRef ir_render_reduce(CodeGen *g, IrExecutableGen *executable, Ir | ... | @@ -5656,13 +5656,13 @@ static LLVMValueRef ir_render_reduce(CodeGen *g, IrExecutableGen *executable, Ir |
| 5656 | return result_val; | 5656 | return result_val; |
| 5657 | } | 5657 | } |
| 5658 | | 5658 | |
| 5659 | static LLVMValueRef ir_render_fence(CodeGen *g, IrExecutableGen *executable, IrInstGenFence *instruction) { | 5659 | static LLVMValueRef ir_render_fence(CodeGen *g, Stage1Air *executable, IrInstGenFence *instruction) { |
| 5660 | LLVMAtomicOrdering atomic_order = to_LLVMAtomicOrdering(instruction->order); | 5660 | LLVMAtomicOrdering atomic_order = to_LLVMAtomicOrdering(instruction->order); |
| 5661 | LLVMBuildFence(g->builder, atomic_order, false, ""); | 5661 | LLVMBuildFence(g->builder, atomic_order, false, ""); |
| 5662 | return nullptr; | 5662 | return nullptr; |
| 5663 | } | 5663 | } |
| 5664 | | 5664 | |
| 5665 | static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutableGen *executable, IrInstGenTruncate *instruction) { | 5665 | static LLVMValueRef ir_render_truncate(CodeGen *g, Stage1Air *executable, IrInstGenTruncate *instruction) { |
| 5666 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); | 5666 | LLVMValueRef target_val = ir_llvm_value(g, instruction->target); |
| 5667 | ZigType *dest_type = instruction->base.value->type; | 5667 | ZigType *dest_type = instruction->base.value->type; |
| 5668 | ZigType *src_type = instruction->target->value->type; | 5668 | ZigType *src_type = instruction->target->value->type; |
| ... | @@ -5677,7 +5677,7 @@ static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutableGen *executable, | ... | @@ -5677,7 +5677,7 @@ static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutableGen *executable, |
| 5677 | } | 5677 | } |
| 5678 | } | 5678 | } |
| 5679 | | 5679 | |
| 5680 | static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutableGen *executable, IrInstGenMemset *instruction) { | 5680 | static LLVMValueRef ir_render_memset(CodeGen *g, Stage1Air *executable, IrInstGenMemset *instruction) { |
| 5681 | LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr); | 5681 | LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr); |
| 5682 | LLVMValueRef len_val = ir_llvm_value(g, instruction->count); | 5682 | LLVMValueRef len_val = ir_llvm_value(g, instruction->count); |
| 5683 | | 5683 | |
| ... | @@ -5707,7 +5707,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutableGen *executable, Ir | ... | @@ -5707,7 +5707,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutableGen *executable, Ir |
| 5707 | return nullptr; | 5707 | return nullptr; |
| 5708 | } | 5708 | } |
| 5709 | | 5709 | |
| 5710 | static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, IrInstGenMemcpy *instruction) { | 5710 | static LLVMValueRef ir_render_memcpy(CodeGen *g, Stage1Air *executable, IrInstGenMemcpy *instruction) { |
| 5711 | LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr); | 5711 | LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr); |
| 5712 | LLVMValueRef src_ptr = ir_llvm_value(g, instruction->src_ptr); | 5712 | LLVMValueRef src_ptr = ir_llvm_value(g, instruction->src_ptr); |
| 5713 | LLVMValueRef len_val = ir_llvm_value(g, instruction->count); | 5713 | LLVMValueRef len_val = ir_llvm_value(g, instruction->count); |
| ... | @@ -5729,14 +5729,14 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, Ir | ... | @@ -5729,14 +5729,14 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, Ir |
| 5729 | return nullptr; | 5729 | return nullptr; |
| 5730 | } | 5730 | } |
| 5731 | | 5731 | |
| 5732 | static LLVMValueRef ir_render_wasm_memory_size(CodeGen *g, IrExecutableGen *executable, IrInstGenWasmMemorySize *instruction) { | 5732 | static LLVMValueRef ir_render_wasm_memory_size(CodeGen *g, Stage1Air *executable, IrInstGenWasmMemorySize *instruction) { |
| 5733 | // TODO adjust for wasm64 | 5733 | // TODO adjust for wasm64 |
| 5734 | LLVMValueRef param = ir_llvm_value(g, instruction->index); | 5734 | LLVMValueRef param = ir_llvm_value(g, instruction->index); |
| 5735 | LLVMValueRef val = LLVMBuildCall(g->builder, gen_wasm_memory_size(g), &param, 1, ""); | 5735 | LLVMValueRef val = LLVMBuildCall(g->builder, gen_wasm_memory_size(g), &param, 1, ""); |
| 5736 | return val; | 5736 | return val; |
| 5737 | } | 5737 | } |
| 5738 | | 5738 | |
| 5739 | static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, IrExecutableGen *executable, IrInstGenWasmMemoryGrow *instruction) { | 5739 | static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, Stage1Air *executable, IrInstGenWasmMemoryGrow *instruction) { |
| 5740 | // TODO adjust for wasm64 | 5740 | // TODO adjust for wasm64 |
| 5741 | LLVMValueRef params[] = { | 5741 | LLVMValueRef params[] = { |
| 5742 | ir_llvm_value(g, instruction->index), | 5742 | ir_llvm_value(g, instruction->index), |
| ... | @@ -5746,7 +5746,7 @@ static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, IrExecutableGen *exec | ... | @@ -5746,7 +5746,7 @@ static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, IrExecutableGen *exec |
| 5746 | return val; | 5746 | return val; |
| 5747 | } | 5747 | } |
| 5748 | | 5748 | |
| 5749 | static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrInstGenSlice *instruction) { | 5749 | static LLVMValueRef ir_render_slice(CodeGen *g, Stage1Air *executable, IrInstGenSlice *instruction) { |
| 5750 | Error err; | 5750 | Error err; |
| 5751 | | 5751 | |
| 5752 | LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr); | 5752 | LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr); |
| ... | @@ -5983,12 +5983,12 @@ static LLVMValueRef get_trap_fn_val(CodeGen *g) { | ... | @@ -5983,12 +5983,12 @@ static LLVMValueRef get_trap_fn_val(CodeGen *g) { |
| 5983 | } | 5983 | } |
| 5984 | | 5984 | |
| 5985 | | 5985 | |
| 5986 | static LLVMValueRef ir_render_breakpoint(CodeGen *g, IrExecutableGen *executable, IrInstGenBreakpoint *instruction) { | 5986 | static LLVMValueRef ir_render_breakpoint(CodeGen *g, Stage1Air *executable, IrInstGenBreakpoint *instruction) { |
| 5987 | LLVMBuildCall(g->builder, get_trap_fn_val(g), nullptr, 0, ""); | 5987 | LLVMBuildCall(g->builder, get_trap_fn_val(g), nullptr, 0, ""); |
| 5988 | return nullptr; | 5988 | return nullptr; |
| 5989 | } | 5989 | } |
| 5990 | | 5990 | |
| 5991 | static LLVMValueRef ir_render_return_address(CodeGen *g, IrExecutableGen *executable, | 5991 | static LLVMValueRef ir_render_return_address(CodeGen *g, Stage1Air *executable, |
| 5992 | IrInstGenReturnAddress *instruction) | 5992 | IrInstGenReturnAddress *instruction) |
| 5993 | { | 5993 | { |
| 5994 | if (target_is_wasm(g->zig_target) && g->zig_target->os != OsEmscripten) { | 5994 | if (target_is_wasm(g->zig_target) && g->zig_target->os != OsEmscripten) { |
| ... | @@ -6016,7 +6016,7 @@ static LLVMValueRef get_frame_address_fn_val(CodeGen *g) { | ... | @@ -6016,7 +6016,7 @@ static LLVMValueRef get_frame_address_fn_val(CodeGen *g) { |
| 6016 | return g->frame_address_fn_val; | 6016 | return g->frame_address_fn_val; |
| 6017 | } | 6017 | } |
| 6018 | | 6018 | |
| 6019 | static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutableGen *executable, | 6019 | static LLVMValueRef ir_render_frame_address(CodeGen *g, Stage1Air *executable, |
| 6020 | IrInstGenFrameAddress *instruction) | 6020 | IrInstGenFrameAddress *instruction) |
| 6021 | { | 6021 | { |
| 6022 | LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_i32->llvm_type); | 6022 | LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_i32->llvm_type); |
| ... | @@ -6024,7 +6024,7 @@ static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutableGen *executa | ... | @@ -6024,7 +6024,7 @@ static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutableGen *executa |
| 6024 | return LLVMBuildPtrToInt(g->builder, ptr_val, g->builtin_types.entry_usize->llvm_type, ""); | 6024 | return LLVMBuildPtrToInt(g->builder, ptr_val, g->builtin_types.entry_usize->llvm_type, ""); |
| 6025 | } | 6025 | } |
| 6026 | | 6026 | |
| 6027 | static LLVMValueRef ir_render_handle(CodeGen *g, IrExecutableGen *executable, IrInstGenFrameHandle *instruction) { | 6027 | static LLVMValueRef ir_render_handle(CodeGen *g, Stage1Air *executable, IrInstGenFrameHandle *instruction) { |
| 6028 | return g->cur_frame_ptr; | 6028 | return g->cur_frame_ptr; |
| 6029 | } | 6029 | } |
| 6030 | | 6030 | |
| ... | @@ -6053,7 +6053,7 @@ static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstGenOverflowOp *in | ... | @@ -6053,7 +6053,7 @@ static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstGenOverflowOp *in |
| 6053 | return overflow_bit; | 6053 | return overflow_bit; |
| 6054 | } | 6054 | } |
| 6055 | | 6055 | |
| 6056 | static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutableGen *executable, IrInstGenOverflowOp *instruction) { | 6056 | static LLVMValueRef ir_render_overflow_op(CodeGen *g, Stage1Air *executable, IrInstGenOverflowOp *instruction) { |
| 6057 | AddSubMul add_sub_mul; | 6057 | AddSubMul add_sub_mul; |
| 6058 | switch (instruction->op) { | 6058 | switch (instruction->op) { |
| 6059 | case IrOverflowOpAdd: | 6059 | case IrOverflowOpAdd: |
| ... | @@ -6091,7 +6091,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutableGen *executabl | ... | @@ -6091,7 +6091,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutableGen *executabl |
| 6091 | return overflow_bit; | 6091 | return overflow_bit; |
| 6092 | } | 6092 | } |
| 6093 | | 6093 | |
| 6094 | static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutableGen *executable, IrInstGenTestErr *instruction) { | 6094 | static LLVMValueRef ir_render_test_err(CodeGen *g, Stage1Air *executable, IrInstGenTestErr *instruction) { |
| 6095 | ZigType *err_union_type = instruction->err_union->value->type; | 6095 | ZigType *err_union_type = instruction->err_union->value->type; |
| 6096 | ZigType *payload_type = err_union_type->data.error_union.payload_type; | 6096 | ZigType *payload_type = err_union_type->data.error_union.payload_type; |
| 6097 | LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->err_union); | 6097 | LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->err_union); |
| ... | @@ -6108,7 +6108,7 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutableGen *executable, | ... | @@ -6108,7 +6108,7 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutableGen *executable, |
| 6108 | return LLVMBuildICmp(g->builder, LLVMIntNE, err_val, zero, ""); | 6108 | return LLVMBuildICmp(g->builder, LLVMIntNE, err_val, zero, ""); |
| 6109 | } | 6109 | } |
| 6110 | | 6110 | |
| 6111 | static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutableGen *executable, | 6111 | static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, Stage1Air *executable, |
| 6112 | IrInstGenUnwrapErrCode *instruction) | 6112 | IrInstGenUnwrapErrCode *instruction) |
| 6113 | { | 6113 | { |
| 6114 | if (instruction->base.value->special != ConstValSpecialRuntime) | 6114 | if (instruction->base.value->special != ConstValSpecialRuntime) |
| ... | @@ -6128,7 +6128,7 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutableGen *execu | ... | @@ -6128,7 +6128,7 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutableGen *execu |
| 6128 | } | 6128 | } |
| 6129 | } | 6129 | } |
| 6130 | | 6130 | |
| 6131 | static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutableGen *executable, | 6131 | static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, Stage1Air *executable, |
| 6132 | IrInstGenUnwrapErrPayload *instruction) | 6132 | IrInstGenUnwrapErrPayload *instruction) |
| 6133 | { | 6133 | { |
| 6134 | Error err; | 6134 | Error err; |
| ... | @@ -6197,7 +6197,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutableGen *ex | ... | @@ -6197,7 +6197,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutableGen *ex |
| 6197 | } | 6197 | } |
| 6198 | } | 6198 | } |
| 6199 | | 6199 | |
| 6200 | static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutableGen *executable, IrInstGenOptionalWrap *instruction) { | 6200 | static LLVMValueRef ir_render_optional_wrap(CodeGen *g, Stage1Air *executable, IrInstGenOptionalWrap *instruction) { |
| 6201 | ZigType *wanted_type = instruction->base.value->type; | 6201 | ZigType *wanted_type = instruction->base.value->type; |
| 6202 | | 6202 | |
| 6203 | assert(wanted_type->id == ZigTypeIdOptional); | 6203 | assert(wanted_type->id == ZigTypeIdOptional); |
| ... | @@ -6233,7 +6233,7 @@ static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutableGen *executa | ... | @@ -6233,7 +6233,7 @@ static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutableGen *executa |
| 6233 | return result_loc; | 6233 | return result_loc; |
| 6234 | } | 6234 | } |
| 6235 | | 6235 | |
| 6236 | static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutableGen *executable, IrInstGenErrWrapCode *instruction) { | 6236 | static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, Stage1Air *executable, IrInstGenErrWrapCode *instruction) { |
| 6237 | ZigType *wanted_type = instruction->base.value->type; | 6237 | ZigType *wanted_type = instruction->base.value->type; |
| 6238 | | 6238 | |
| 6239 | assert(wanted_type->id == ZigTypeIdErrorUnion); | 6239 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| ... | @@ -6253,7 +6253,7 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutableGen *executa | ... | @@ -6253,7 +6253,7 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutableGen *executa |
| 6253 | return result_loc; | 6253 | return result_loc; |
| 6254 | } | 6254 | } |
| 6255 | | 6255 | |
| 6256 | static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutableGen *executable, IrInstGenErrWrapPayload *instruction) { | 6256 | static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, Stage1Air *executable, IrInstGenErrWrapPayload *instruction) { |
| 6257 | ZigType *wanted_type = instruction->base.value->type; | 6257 | ZigType *wanted_type = instruction->base.value->type; |
| 6258 | | 6258 | |
| 6259 | assert(wanted_type->id == ZigTypeIdErrorUnion); | 6259 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| ... | @@ -6284,7 +6284,7 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutableGen *exec | ... | @@ -6284,7 +6284,7 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutableGen *exec |
| 6284 | return result_loc; | 6284 | return result_loc; |
| 6285 | } | 6285 | } |
| 6286 | | 6286 | |
| 6287 | static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutableGen *executable, IrInstGenUnionTag *instruction) { | 6287 | static LLVMValueRef ir_render_union_tag(CodeGen *g, Stage1Air *executable, IrInstGenUnionTag *instruction) { |
| 6288 | ZigType *union_type = instruction->value->value->type; | 6288 | ZigType *union_type = instruction->value->value->type; |
| 6289 | | 6289 | |
| 6290 | ZigType *tag_type = union_type->data.unionation.tag_type; | 6290 | ZigType *tag_type = union_type->data.unionation.tag_type; |
| ... | @@ -6302,14 +6302,14 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutableGen *executable, | ... | @@ -6302,14 +6302,14 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutableGen *executable, |
| 6302 | return get_handle_value(g, tag_field_ptr, tag_type, ptr_type); | 6302 | return get_handle_value(g, tag_field_ptr, tag_type, ptr_type); |
| 6303 | } | 6303 | } |
| 6304 | | 6304 | |
| 6305 | static LLVMValueRef ir_render_panic(CodeGen *g, IrExecutableGen *executable, IrInstGenPanic *instruction) { | 6305 | static LLVMValueRef ir_render_panic(CodeGen *g, Stage1Air *executable, IrInstGenPanic *instruction) { |
| 6306 | bool is_llvm_alloca; | 6306 | bool is_llvm_alloca; |
| 6307 | LLVMValueRef err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.base.scope, &is_llvm_alloca); | 6307 | LLVMValueRef err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.base.scope, &is_llvm_alloca); |
| 6308 | gen_panic(g, ir_llvm_value(g, instruction->msg), err_ret_trace_val, is_llvm_alloca); | 6308 | gen_panic(g, ir_llvm_value(g, instruction->msg), err_ret_trace_val, is_llvm_alloca); |
| 6309 | return nullptr; | 6309 | return nullptr; |
| 6310 | } | 6310 | } |
| 6311 | | 6311 | |
| 6312 | static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutableGen *executable, | 6312 | static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, Stage1Air *executable, |
| 6313 | IrInstGenAtomicRmw *instruction) | 6313 | IrInstGenAtomicRmw *instruction) |
| 6314 | { | 6314 | { |
| 6315 | bool is_signed; | 6315 | bool is_signed; |
| ... | @@ -6354,7 +6354,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutableGen *executable | ... | @@ -6354,7 +6354,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutableGen *executable |
| 6354 | return LLVMBuildIntToPtr(g->builder, uncasted_result, get_llvm_type(g, operand_type), ""); | 6354 | return LLVMBuildIntToPtr(g->builder, uncasted_result, get_llvm_type(g, operand_type), ""); |
| 6355 | } | 6355 | } |
| 6356 | | 6356 | |
| 6357 | static LLVMValueRef ir_render_atomic_load(CodeGen *g, IrExecutableGen *executable, | 6357 | static LLVMValueRef ir_render_atomic_load(CodeGen *g, Stage1Air *executable, |
| 6358 | IrInstGenAtomicLoad *instruction) | 6358 | IrInstGenAtomicLoad *instruction) |
| 6359 | { | 6359 | { |
| 6360 | LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering); | 6360 | LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering); |
| ... | @@ -6375,7 +6375,7 @@ static LLVMValueRef ir_render_atomic_load(CodeGen *g, IrExecutableGen *executabl | ... | @@ -6375,7 +6375,7 @@ static LLVMValueRef ir_render_atomic_load(CodeGen *g, IrExecutableGen *executabl |
| 6375 | return load_inst; | 6375 | return load_inst; |
| 6376 | } | 6376 | } |
| 6377 | | 6377 | |
| 6378 | static LLVMValueRef ir_render_atomic_store(CodeGen *g, IrExecutableGen *executable, | 6378 | static LLVMValueRef ir_render_atomic_store(CodeGen *g, Stage1Air *executable, |
| 6379 | IrInstGenAtomicStore *instruction) | 6379 | IrInstGenAtomicStore *instruction) |
| 6380 | { | 6380 | { |
| 6381 | LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering); | 6381 | LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering); |
| ... | @@ -6398,13 +6398,13 @@ static LLVMValueRef ir_render_atomic_store(CodeGen *g, IrExecutableGen *executab | ... | @@ -6398,13 +6398,13 @@ static LLVMValueRef ir_render_atomic_store(CodeGen *g, IrExecutableGen *executab |
| 6398 | return nullptr; | 6398 | return nullptr; |
| 6399 | } | 6399 | } |
| 6400 | | 6400 | |
| 6401 | static LLVMValueRef ir_render_float_op(CodeGen *g, IrExecutableGen *executable, IrInstGenFloatOp *instruction) { | 6401 | static LLVMValueRef ir_render_float_op(CodeGen *g, Stage1Air *executable, IrInstGenFloatOp *instruction) { |
| 6402 | LLVMValueRef operand = ir_llvm_value(g, instruction->operand); | 6402 | LLVMValueRef operand = ir_llvm_value(g, instruction->operand); |
| 6403 | LLVMValueRef fn_val = get_float_fn(g, instruction->base.value->type, ZigLLVMFnIdFloatOp, instruction->fn_id); | 6403 | LLVMValueRef fn_val = get_float_fn(g, instruction->base.value->type, ZigLLVMFnIdFloatOp, instruction->fn_id); |
| 6404 | return LLVMBuildCall(g->builder, fn_val, &operand, 1, ""); | 6404 | return LLVMBuildCall(g->builder, fn_val, &operand, 1, ""); |
| 6405 | } | 6405 | } |
| 6406 | | 6406 | |
| 6407 | static LLVMValueRef ir_render_mul_add(CodeGen *g, IrExecutableGen *executable, IrInstGenMulAdd *instruction) { | 6407 | static LLVMValueRef ir_render_mul_add(CodeGen *g, Stage1Air *executable, IrInstGenMulAdd *instruction) { |
| 6408 | LLVMValueRef op1 = ir_llvm_value(g, instruction->op1); | 6408 | LLVMValueRef op1 = ir_llvm_value(g, instruction->op1); |
| 6409 | LLVMValueRef op2 = ir_llvm_value(g, instruction->op2); | 6409 | LLVMValueRef op2 = ir_llvm_value(g, instruction->op2); |
| 6410 | LLVMValueRef op3 = ir_llvm_value(g, instruction->op3); | 6410 | LLVMValueRef op3 = ir_llvm_value(g, instruction->op3); |
| ... | @@ -6419,7 +6419,7 @@ static LLVMValueRef ir_render_mul_add(CodeGen *g, IrExecutableGen *executable, I | ... | @@ -6419,7 +6419,7 @@ static LLVMValueRef ir_render_mul_add(CodeGen *g, IrExecutableGen *executable, I |
| 6419 | return LLVMBuildCall(g->builder, fn_val, args, 3, ""); | 6419 | return LLVMBuildCall(g->builder, fn_val, args, 3, ""); |
| 6420 | } | 6420 | } |
| 6421 | | 6421 | |
| 6422 | static LLVMValueRef ir_render_bswap(CodeGen *g, IrExecutableGen *executable, IrInstGenBswap *instruction) { | 6422 | static LLVMValueRef ir_render_bswap(CodeGen *g, Stage1Air *executable, IrInstGenBswap *instruction) { |
| 6423 | LLVMValueRef op = ir_llvm_value(g, instruction->op); | 6423 | LLVMValueRef op = ir_llvm_value(g, instruction->op); |
| 6424 | ZigType *expr_type = instruction->base.value->type; | 6424 | ZigType *expr_type = instruction->base.value->type; |
| 6425 | bool is_vector = expr_type->id == ZigTypeIdVector; | 6425 | bool is_vector = expr_type->id == ZigTypeIdVector; |
| ... | @@ -6453,7 +6453,7 @@ static LLVMValueRef ir_render_bswap(CodeGen *g, IrExecutableGen *executable, IrI | ... | @@ -6453,7 +6453,7 @@ static LLVMValueRef ir_render_bswap(CodeGen *g, IrExecutableGen *executable, IrI |
| 6453 | return LLVMBuildTrunc(g->builder, shifted, get_llvm_type(g, expr_type), ""); | 6453 | return LLVMBuildTrunc(g->builder, shifted, get_llvm_type(g, expr_type), ""); |
| 6454 | } | 6454 | } |
| 6455 | | 6455 | |
| 6456 | static LLVMValueRef ir_render_extern(CodeGen *g, IrExecutableGen *executable, | 6456 | static LLVMValueRef ir_render_extern(CodeGen *g, Stage1Air *executable, |
| 6457 | IrInstGenExtern *instruction) | 6457 | IrInstGenExtern *instruction) |
| 6458 | { | 6458 | { |
| 6459 | ZigType *expr_type = instruction->base.value->type; | 6459 | ZigType *expr_type = instruction->base.value->type; |
| ... | @@ -6477,7 +6477,7 @@ static LLVMValueRef ir_render_extern(CodeGen *g, IrExecutableGen *executable, | ... | @@ -6477,7 +6477,7 @@ static LLVMValueRef ir_render_extern(CodeGen *g, IrExecutableGen *executable, |
| 6477 | return LLVMBuildBitCast(g->builder, global_value, get_llvm_type(g, expr_type), ""); | 6477 | return LLVMBuildBitCast(g->builder, global_value, get_llvm_type(g, expr_type), ""); |
| 6478 | } | 6478 | } |
| 6479 | | 6479 | |
| 6480 | static LLVMValueRef ir_render_bit_reverse(CodeGen *g, IrExecutableGen *executable, IrInstGenBitReverse *instruction) { | 6480 | static LLVMValueRef ir_render_bit_reverse(CodeGen *g, Stage1Air *executable, IrInstGenBitReverse *instruction) { |
| 6481 | LLVMValueRef op = ir_llvm_value(g, instruction->op); | 6481 | LLVMValueRef op = ir_llvm_value(g, instruction->op); |
| 6482 | ZigType *int_type = instruction->base.value->type; | 6482 | ZigType *int_type = instruction->base.value->type; |
| 6483 | assert(int_type->id == ZigTypeIdInt); | 6483 | assert(int_type->id == ZigTypeIdInt); |
| ... | @@ -6485,7 +6485,7 @@ static LLVMValueRef ir_render_bit_reverse(CodeGen *g, IrExecutableGen *executabl | ... | @@ -6485,7 +6485,7 @@ static LLVMValueRef ir_render_bit_reverse(CodeGen *g, IrExecutableGen *executabl |
| 6485 | return LLVMBuildCall(g->builder, fn_val, &op, 1, ""); | 6485 | return LLVMBuildCall(g->builder, fn_val, &op, 1, ""); |
| 6486 | } | 6486 | } |
| 6487 | | 6487 | |
| 6488 | static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutableGen *executable, | 6488 | static LLVMValueRef ir_render_vector_to_array(CodeGen *g, Stage1Air *executable, |
| 6489 | IrInstGenVectorToArray *instruction) | 6489 | IrInstGenVectorToArray *instruction) |
| 6490 | { | 6490 | { |
| 6491 | ZigType *array_type = instruction->base.value->type; | 6491 | ZigType *array_type = instruction->base.value->type; |
| ... | @@ -6519,7 +6519,7 @@ static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutableGen *execu | ... | @@ -6519,7 +6519,7 @@ static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutableGen *execu |
| 6519 | return result_loc; | 6519 | return result_loc; |
| 6520 | } | 6520 | } |
| 6521 | | 6521 | |
| 6522 | static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutableGen *executable, | 6522 | static LLVMValueRef ir_render_array_to_vector(CodeGen *g, Stage1Air *executable, |
| 6523 | IrInstGenArrayToVector *instruction) | 6523 | IrInstGenArrayToVector *instruction) |
| 6524 | { | 6524 | { |
| 6525 | ZigType *vector_type = instruction->base.value->type; | 6525 | ZigType *vector_type = instruction->base.value->type; |
| ... | @@ -6556,7 +6556,7 @@ static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutableGen *execu | ... | @@ -6556,7 +6556,7 @@ static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutableGen *execu |
| 6556 | } | 6556 | } |
| 6557 | } | 6557 | } |
| 6558 | | 6558 | |
| 6559 | static LLVMValueRef ir_render_assert_zero(CodeGen *g, IrExecutableGen *executable, | 6559 | static LLVMValueRef ir_render_assert_zero(CodeGen *g, Stage1Air *executable, |
| 6560 | IrInstGenAssertZero *instruction) | 6560 | IrInstGenAssertZero *instruction) |
| 6561 | { | 6561 | { |
| 6562 | LLVMValueRef target = ir_llvm_value(g, instruction->target); | 6562 | LLVMValueRef target = ir_llvm_value(g, instruction->target); |
| ... | @@ -6567,7 +6567,7 @@ static LLVMValueRef ir_render_assert_zero(CodeGen *g, IrExecutableGen *executabl | ... | @@ -6567,7 +6567,7 @@ static LLVMValueRef ir_render_assert_zero(CodeGen *g, IrExecutableGen *executabl |
| 6567 | return nullptr; | 6567 | return nullptr; |
| 6568 | } | 6568 | } |
| 6569 | | 6569 | |
| 6570 | static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutableGen *executable, | 6570 | static LLVMValueRef ir_render_assert_non_null(CodeGen *g, Stage1Air *executable, |
| 6571 | IrInstGenAssertNonNull *instruction) | 6571 | IrInstGenAssertNonNull *instruction) |
| 6572 | { | 6572 | { |
| 6573 | LLVMValueRef target = ir_llvm_value(g, instruction->target); | 6573 | LLVMValueRef target = ir_llvm_value(g, instruction->target); |
| ... | @@ -6592,7 +6592,7 @@ static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutableGen *execu | ... | @@ -6592,7 +6592,7 @@ static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutableGen *execu |
| 6592 | return nullptr; | 6592 | return nullptr; |
| 6593 | } | 6593 | } |
| 6594 | | 6594 | |
| 6595 | static LLVMValueRef ir_render_suspend_begin(CodeGen *g, IrExecutableGen *executable, | 6595 | static LLVMValueRef ir_render_suspend_begin(CodeGen *g, Stage1Air *executable, |
| 6596 | IrInstGenSuspendBegin *instruction) | 6596 | IrInstGenSuspendBegin *instruction) |
| 6597 | { | 6597 | { |
| 6598 | if (fn_is_async(g->cur_fn)) { | 6598 | if (fn_is_async(g->cur_fn)) { |
| ... | @@ -6601,7 +6601,7 @@ static LLVMValueRef ir_render_suspend_begin(CodeGen *g, IrExecutableGen *executa | ... | @@ -6601,7 +6601,7 @@ static LLVMValueRef ir_render_suspend_begin(CodeGen *g, IrExecutableGen *executa |
| 6601 | return nullptr; | 6601 | return nullptr; |
| 6602 | } | 6602 | } |
| 6603 | | 6603 | |
| 6604 | static LLVMValueRef ir_render_suspend_finish(CodeGen *g, IrExecutableGen *executable, | 6604 | static LLVMValueRef ir_render_suspend_finish(CodeGen *g, Stage1Air *executable, |
| 6605 | IrInstGenSuspendFinish *instruction) | 6605 | IrInstGenSuspendFinish *instruction) |
| 6606 | { | 6606 | { |
| 6607 | LLVMBuildRetVoid(g->builder); | 6607 | LLVMBuildRetVoid(g->builder); |
| ... | @@ -6653,7 +6653,7 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr, | ... | @@ -6653,7 +6653,7 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr, |
| 6653 | } | 6653 | } |
| 6654 | } | 6654 | } |
| 6655 | | 6655 | |
| 6656 | static LLVMValueRef ir_render_await(CodeGen *g, IrExecutableGen *executable, IrInstGenAwait *instruction) { | 6656 | static LLVMValueRef ir_render_await(CodeGen *g, Stage1Air *executable, IrInstGenAwait *instruction) { |
| 6657 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; | 6657 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; |
| 6658 | LLVMValueRef zero = LLVMConstNull(usize_type_ref); | 6658 | LLVMValueRef zero = LLVMConstNull(usize_type_ref); |
| 6659 | LLVMValueRef target_frame_ptr = ir_llvm_value(g, instruction->frame); | 6659 | LLVMValueRef target_frame_ptr = ir_llvm_value(g, instruction->frame); |
| ... | @@ -6740,7 +6740,7 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutableGen *executable, IrI | ... | @@ -6740,7 +6740,7 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutableGen *executable, IrI |
| 6740 | return nullptr; | 6740 | return nullptr; |
| 6741 | } | 6741 | } |
| 6742 | | 6742 | |
| 6743 | static LLVMValueRef ir_render_resume(CodeGen *g, IrExecutableGen *executable, IrInstGenResume *instruction) { | 6743 | static LLVMValueRef ir_render_resume(CodeGen *g, Stage1Air *executable, IrInstGenResume *instruction) { |
| 6744 | LLVMValueRef frame = ir_llvm_value(g, instruction->frame); | 6744 | LLVMValueRef frame = ir_llvm_value(g, instruction->frame); |
| 6745 | ZigType *frame_type = instruction->frame->value->type; | 6745 | ZigType *frame_type = instruction->frame->value->type; |
| 6746 | assert(frame_type->id == ZigTypeIdAnyFrame); | 6746 | assert(frame_type->id == ZigTypeIdAnyFrame); |
| ... | @@ -6749,14 +6749,14 @@ static LLVMValueRef ir_render_resume(CodeGen *g, IrExecutableGen *executable, Ir | ... | @@ -6749,14 +6749,14 @@ static LLVMValueRef ir_render_resume(CodeGen *g, IrExecutableGen *executable, Ir |
| 6749 | return nullptr; | 6749 | return nullptr; |
| 6750 | } | 6750 | } |
| 6751 | | 6751 | |
| 6752 | static LLVMValueRef ir_render_frame_size(CodeGen *g, IrExecutableGen *executable, | 6752 | static LLVMValueRef ir_render_frame_size(CodeGen *g, Stage1Air *executable, |
| 6753 | IrInstGenFrameSize *instruction) | 6753 | IrInstGenFrameSize *instruction) |
| 6754 | { | 6754 | { |
| 6755 | LLVMValueRef fn_val = ir_llvm_value(g, instruction->fn); | 6755 | LLVMValueRef fn_val = ir_llvm_value(g, instruction->fn); |
| 6756 | return gen_frame_size(g, fn_val); | 6756 | return gen_frame_size(g, fn_val); |
| 6757 | } | 6757 | } |
| 6758 | | 6758 | |
| 6759 | static LLVMValueRef ir_render_spill_begin(CodeGen *g, IrExecutableGen *executable, | 6759 | static LLVMValueRef ir_render_spill_begin(CodeGen *g, Stage1Air *executable, |
| 6760 | IrInstGenSpillBegin *instruction) | 6760 | IrInstGenSpillBegin *instruction) |
| 6761 | { | 6761 | { |
| 6762 | if (!fn_is_async(g->cur_fn)) | 6762 | if (!fn_is_async(g->cur_fn)) |
| ... | @@ -6776,7 +6776,7 @@ static LLVMValueRef ir_render_spill_begin(CodeGen *g, IrExecutableGen *executabl | ... | @@ -6776,7 +6776,7 @@ static LLVMValueRef ir_render_spill_begin(CodeGen *g, IrExecutableGen *executabl |
| 6776 | zig_unreachable(); | 6776 | zig_unreachable(); |
| 6777 | } | 6777 | } |
| 6778 | | 6778 | |
| 6779 | static LLVMValueRef ir_render_spill_end(CodeGen *g, IrExecutableGen *executable, IrInstGenSpillEnd *instruction) { | 6779 | static LLVMValueRef ir_render_spill_end(CodeGen *g, Stage1Air *executable, IrInstGenSpillEnd *instruction) { |
| 6780 | if (!fn_is_async(g->cur_fn)) | 6780 | if (!fn_is_async(g->cur_fn)) |
| 6781 | return ir_llvm_value(g, instruction->begin->operand); | 6781 | return ir_llvm_value(g, instruction->begin->operand); |
| 6782 | | 6782 | |
| ... | @@ -6792,7 +6792,7 @@ static LLVMValueRef ir_render_spill_end(CodeGen *g, IrExecutableGen *executable, | ... | @@ -6792,7 +6792,7 @@ static LLVMValueRef ir_render_spill_end(CodeGen *g, IrExecutableGen *executable, |
| 6792 | zig_unreachable(); | 6792 | zig_unreachable(); |
| 6793 | } | 6793 | } |
| 6794 | | 6794 | |
| 6795 | static LLVMValueRef ir_render_vector_extract_elem(CodeGen *g, IrExecutableGen *executable, | 6795 | static LLVMValueRef ir_render_vector_extract_elem(CodeGen *g, Stage1Air *executable, |
| 6796 | IrInstGenVectorExtractElem *instruction) | 6796 | IrInstGenVectorExtractElem *instruction) |
| 6797 | { | 6797 | { |
| 6798 | LLVMValueRef vector = ir_llvm_value(g, instruction->vector); | 6798 | LLVMValueRef vector = ir_llvm_value(g, instruction->vector); |
| ... | @@ -6811,7 +6811,7 @@ static void set_debug_location(CodeGen *g, IrInstGen *instruction) { | ... | @@ -6811,7 +6811,7 @@ static void set_debug_location(CodeGen *g, IrInstGen *instruction) { |
| 6811 | node_column_onebased(source_node), get_di_scope(g, scope)); | 6811 | node_column_onebased(source_node), get_di_scope(g, scope)); |
| 6812 | } | 6812 | } |
| 6813 | | 6813 | |
| 6814 | static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutableGen *executable, IrInstGen *instruction) { | 6814 | static LLVMValueRef ir_render_instruction(CodeGen *g, Stage1Air *executable, IrInstGen *instruction) { |
| 6815 | switch (instruction->id) { | 6815 | switch (instruction->id) { |
| 6816 | case IrInstGenIdInvalid: | 6816 | case IrInstGenIdInvalid: |
| 6817 | case IrInstGenIdConst: | 6817 | case IrInstGenIdConst: |
| ... | @@ -6999,7 +6999,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutableGen *executabl | ... | @@ -6999,7 +6999,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutableGen *executabl |
| 6999 | static void ir_render(CodeGen *g, ZigFn *fn_entry) { | 6999 | static void ir_render(CodeGen *g, ZigFn *fn_entry) { |
| 7000 | assert(fn_entry); | 7000 | assert(fn_entry); |
| 7001 | | 7001 | |
| 7002 | IrExecutableGen *executable = &fn_entry->analyzed_executable; | 7002 | Stage1Air *executable = &fn_entry->analyzed_executable; |
| 7003 | assert(executable->basic_block_list.length > 0); | 7003 | assert(executable->basic_block_list.length > 0); |
| 7004 | | 7004 | |
| 7005 | for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) { | 7005 | for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) { |
| ... | @@ -7997,7 +7997,7 @@ static void generate_error_name_table(CodeGen *g) { | ... | @@ -7997,7 +7997,7 @@ static void generate_error_name_table(CodeGen *g) { |
| 7997 | } | 7997 | } |
| 7998 | | 7998 | |
| 7999 | static void build_all_basic_blocks(CodeGen *g, ZigFn *fn) { | 7999 | static void build_all_basic_blocks(CodeGen *g, ZigFn *fn) { |
| 8000 | IrExecutableGen *executable = &fn->analyzed_executable; | 8000 | Stage1Air *executable = &fn->analyzed_executable; |
| 8001 | assert(executable->basic_block_list.length > 0); | 8001 | assert(executable->basic_block_list.length > 0); |
| 8002 | LLVMValueRef fn_val = fn_llvm_value(g, fn); | 8002 | LLVMValueRef fn_val = fn_llvm_value(g, fn); |
| 8003 | LLVMBasicBlockRef first_bb = nullptr; | 8003 | LLVMBasicBlockRef first_bb = nullptr; |
| ... | @@ -8380,7 +8380,7 @@ static void do_code_gen(CodeGen *g) { | ... | @@ -8380,7 +8380,7 @@ static void do_code_gen(CodeGen *g) { |
| 8380 | node_line_onebased(source_node), node_column_onebased(source_node), | 8380 | node_line_onebased(source_node), node_column_onebased(source_node), |
| 8381 | get_di_scope(g, fn_table_entry->child_scope)); | 8381 | get_di_scope(g, fn_table_entry->child_scope)); |
| 8382 | } | 8382 | } |
| 8383 | IrExecutableGen *executable = &fn_table_entry->analyzed_executable; | 8383 | Stage1Air *executable = &fn_table_entry->analyzed_executable; |
| 8384 | LLVMBasicBlockRef bad_resume_block = LLVMAppendBasicBlock(g->cur_fn_val, "BadResume"); | 8384 | LLVMBasicBlockRef bad_resume_block = LLVMAppendBasicBlock(g->cur_fn_val, "BadResume"); |
| 8385 | LLVMPositionBuilderAtEnd(g->builder, bad_resume_block); | 8385 | LLVMPositionBuilderAtEnd(g->builder, bad_resume_block); |
| 8386 | gen_assertion_scope(g, PanicMsgIdBadResume, fn_table_entry->child_scope); | 8386 | gen_assertion_scope(g, PanicMsgIdBadResume, fn_table_entry->child_scope); |