| ... | ... | @@ -1640,6 +1640,17 @@ static void gen_assign_raw(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type, |
| 1640 | 1640 | return; |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | assert(ptr_type->data.pointer.vector_index != VECTOR_INDEX_RUNTIME); |
| 1644 | if (ptr_type->data.pointer.vector_index != VECTOR_INDEX_NONE) { |
| 1645 | LLVMValueRef index_val = LLVMConstInt(LLVMInt32Type(), |
| 1646 | ptr_type->data.pointer.vector_index, false); |
| 1647 | LLVMValueRef loaded_vector = gen_load(g, ptr, ptr_type, ""); |
| 1648 | LLVMValueRef new_vector = LLVMBuildInsertElement(g->builder, loaded_vector, value, |
| 1649 | index_val, ""); |
| 1650 | gen_store(g, new_vector, ptr, ptr_type); |
| 1651 | return; |
| 1652 | } |
| 1653 | |
| 1643 | 1654 | uint32_t host_int_bytes = ptr_type->data.pointer.host_int_bytes; |
| 1644 | 1655 | if (host_int_bytes == 0) { |
| 1645 | 1656 | gen_store(g, value, ptr, ptr_type); |
| ... | ... | @@ -3414,8 +3425,6 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, |
| 3414 | 3425 | ZigType *ptr_type = instruction->ptr->value.type; |
| 3415 | 3426 | assert(ptr_type->id == ZigTypeIdPointer); |
| 3416 | 3427 | |
| 3417 | | uint32_t host_int_bytes = ptr_type->data.pointer.host_int_bytes; |
| 3418 | | |
| 3419 | 3428 | ir_assert(ptr_type->data.pointer.vector_index != VECTOR_INDEX_RUNTIME, &instruction->base); |
| 3420 | 3429 | if (ptr_type->data.pointer.vector_index != VECTOR_INDEX_NONE) { |
| 3421 | 3430 | LLVMValueRef index_val = LLVMConstInt(LLVMInt32Type(), |
| ... | ... | @@ -3424,6 +3433,7 @@ static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutable *executable, |
| 3424 | 3433 | return LLVMBuildExtractElement(g->builder, loaded_vector, index_val, ""); |
| 3425 | 3434 | } |
| 3426 | 3435 | |
| 3436 | uint32_t host_int_bytes = ptr_type->data.pointer.host_int_bytes; |
| 3427 | 3437 | if (host_int_bytes == 0) |
| 3428 | 3438 | return get_handle_value(g, ptr, child_type, ptr_type); |
| 3429 | 3439 | |
| ... | ... | @@ -3660,7 +3670,6 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI |
| 3660 | 3670 | ZigType *array_ptr_type = instruction->array_ptr->value.type; |
| 3661 | 3671 | assert(array_ptr_type->id == ZigTypeIdPointer); |
| 3662 | 3672 | ZigType *array_type = array_ptr_type->data.pointer.child_type; |
| 3663 | | LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type); |
| 3664 | 3673 | LLVMValueRef subscript_value = ir_llvm_value(g, instruction->elem_index); |
| 3665 | 3674 | assert(subscript_value); |
| 3666 | 3675 | |
| ... | ... | @@ -3672,6 +3681,7 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI |
| 3672 | 3681 | if (array_type->id == ZigTypeIdArray || |
| 3673 | 3682 | (array_type->id == ZigTypeIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle)) |
| 3674 | 3683 | { |
| 3684 | LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type); |
| 3675 | 3685 | if (array_type->id == ZigTypeIdPointer) { |
| 3676 | 3686 | assert(array_type->data.pointer.child_type->id == ZigTypeIdArray); |
| 3677 | 3687 | array_type = array_type->data.pointer.child_type; |
| ... | ... | @@ -3711,12 +3721,14 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI |
| 3711 | 3721 | }; |
| 3712 | 3722 | return LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, ""); |
| 3713 | 3723 | } else if (array_type->id == ZigTypeIdPointer) { |
| 3724 | LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type); |
| 3714 | 3725 | assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind); |
| 3715 | 3726 | LLVMValueRef indices[] = { |
| 3716 | 3727 | subscript_value |
| 3717 | 3728 | }; |
| 3718 | 3729 | return LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 1, ""); |
| 3719 | 3730 | } else if (array_type->id == ZigTypeIdStruct) { |
| 3731 | LLVMValueRef array_ptr = get_handle_value(g, array_ptr_ptr, array_type, array_ptr_type); |
| 3720 | 3732 | assert(array_type->data.structure.is_slice); |
| 3721 | 3733 | |
| 3722 | 3734 | ZigType *ptr_type = instruction->base.value.type; |