mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
fix warnings from deprecated llvm ptr type
This commit is contained in:
parent
8090e99e75
commit
1519e5f833
11 changed files with 109 additions and 218 deletions
|
@ -243,7 +243,7 @@ fn build_transform_caller_help<'a, 'ctx>(
|
||||||
let block = env.builder.get_insert_block().expect("to be in a function");
|
let block = env.builder.get_insert_block().expect("to be in a function");
|
||||||
let di_location = env.builder.get_current_debug_location().unwrap();
|
let di_location = env.builder.get_current_debug_location().unwrap();
|
||||||
|
|
||||||
let arg_type = env.context.i8_type().ptr_type(AddressSpace::default());
|
let arg_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
|
@ -280,9 +280,7 @@ fn build_transform_caller_help<'a, 'ctx>(
|
||||||
bumpalo::collections::Vec::with_capacity_in(arguments.len(), env.arena);
|
bumpalo::collections::Vec::with_capacity_in(arguments.len(), env.arena);
|
||||||
|
|
||||||
for (argument_ptr, layout) in arguments.iter().zip(argument_layouts) {
|
for (argument_ptr, layout) in arguments.iter().zip(argument_layouts) {
|
||||||
let basic_type =
|
let basic_type = env.context.ptr_type(AddressSpace::default());
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(*layout))
|
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let cast_ptr = env.builder.new_build_pointer_cast(
|
let cast_ptr = env.builder.new_build_pointer_cast(
|
||||||
argument_ptr.into_pointer_value(),
|
argument_ptr.into_pointer_value(),
|
||||||
|
@ -311,9 +309,7 @@ fn build_transform_caller_help<'a, 'ctx>(
|
||||||
// the function doesn't expect a closure argument, nothing to add
|
// the function doesn't expect a closure argument, nothing to add
|
||||||
}
|
}
|
||||||
(true, layout) => {
|
(true, layout) => {
|
||||||
let closure_type =
|
let closure_type = env.context.ptr_type(AddressSpace::default());
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout))
|
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let closure_cast = env.builder.new_build_pointer_cast(
|
let closure_cast = env.builder.new_build_pointer_cast(
|
||||||
closure_ptr,
|
closure_ptr,
|
||||||
|
@ -420,7 +416,7 @@ fn build_rc_wrapper<'a, 'ctx>(
|
||||||
let function_value = match env.module.get_function(fn_name.as_str()) {
|
let function_value = match env.module.get_function(fn_name.as_str()) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let arg_type = env.context.i8_type().ptr_type(AddressSpace::default());
|
let arg_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let function_value = match rc_operation {
|
let function_value = match rc_operation {
|
||||||
Mode::Inc | Mode::Dec => crate::llvm::refcounting::build_header_help(
|
Mode::Inc | Mode::Dec => crate::llvm::refcounting::build_header_help(
|
||||||
|
@ -457,7 +453,7 @@ fn build_rc_wrapper<'a, 'ctx>(
|
||||||
|
|
||||||
let value_type =
|
let value_type =
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout));
|
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout));
|
||||||
let value_ptr_type = value_type.ptr_type(AddressSpace::default());
|
let value_ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
let value_ptr = env.builder.new_build_pointer_cast(
|
let value_ptr = env.builder.new_build_pointer_cast(
|
||||||
generic_value_ptr,
|
generic_value_ptr,
|
||||||
value_ptr_type,
|
value_ptr_type,
|
||||||
|
@ -519,7 +515,7 @@ pub fn build_eq_wrapper<'a, 'ctx>(
|
||||||
let function_value = match env.module.get_function(fn_name.as_str()) {
|
let function_value = match env.module.get_function(fn_name.as_str()) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let arg_type = env.context.i8_type().ptr_type(AddressSpace::default());
|
let arg_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
|
@ -548,9 +544,7 @@ pub fn build_eq_wrapper<'a, 'ctx>(
|
||||||
value_ptr1.set_name(Symbol::ARG_1.as_str(&env.interns));
|
value_ptr1.set_name(Symbol::ARG_1.as_str(&env.interns));
|
||||||
value_ptr2.set_name(Symbol::ARG_2.as_str(&env.interns));
|
value_ptr2.set_name(Symbol::ARG_2.as_str(&env.interns));
|
||||||
|
|
||||||
let value_type =
|
let value_type = env.context.ptr_type(AddressSpace::default());
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout))
|
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let value_cast1 =
|
let value_cast1 =
|
||||||
env.builder
|
env.builder
|
||||||
|
@ -617,7 +611,7 @@ pub fn build_compare_wrapper<'a, 'ctx>(
|
||||||
let function_value = match env.module.get_function(fn_name) {
|
let function_value = match env.module.get_function(fn_name) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let arg_type = env.context.i8_type().ptr_type(AddressSpace::default());
|
let arg_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
|
@ -651,9 +645,7 @@ pub fn build_compare_wrapper<'a, 'ctx>(
|
||||||
value_ptr1.set_name(Symbol::ARG_2.as_str(&env.interns));
|
value_ptr1.set_name(Symbol::ARG_2.as_str(&env.interns));
|
||||||
value_ptr2.set_name(Symbol::ARG_3.as_str(&env.interns));
|
value_ptr2.set_name(Symbol::ARG_3.as_str(&env.interns));
|
||||||
|
|
||||||
let value_type =
|
let value_ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout));
|
|
||||||
let value_ptr_type = value_type.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let value_cast1 =
|
let value_cast1 =
|
||||||
env.builder
|
env.builder
|
||||||
|
@ -696,7 +688,7 @@ pub fn build_compare_wrapper<'a, 'ctx>(
|
||||||
layout_interner,
|
layout_interner,
|
||||||
layout_interner.get_repr(closure_data_repr),
|
layout_interner.get_repr(closure_data_repr),
|
||||||
);
|
);
|
||||||
let closure_ptr_type = closure_type.ptr_type(AddressSpace::default());
|
let closure_ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let closure_cast = env.builder.new_build_pointer_cast(
|
let closure_cast = env.builder.new_build_pointer_cast(
|
||||||
closure_ptr,
|
closure_ptr,
|
||||||
|
@ -754,7 +746,7 @@ pub fn build_copy_wrapper<'a, 'ctx>(
|
||||||
let function_value = match env.module.get_function(fn_name.as_str()) {
|
let function_value = match env.module.get_function(fn_name.as_str()) {
|
||||||
Some(function_value) => function_value,
|
Some(function_value) => function_value,
|
||||||
None => {
|
None => {
|
||||||
let arg_type = env.context.i8_type().ptr_type(AddressSpace::default());
|
let arg_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let function_value = crate::llvm::refcounting::build_header_help(
|
let function_value = crate::llvm::refcounting::build_header_help(
|
||||||
env,
|
env,
|
||||||
|
@ -784,8 +776,7 @@ pub fn build_copy_wrapper<'a, 'ctx>(
|
||||||
src_ptr.set_name(Symbol::ARG_2.as_str(&env.interns));
|
src_ptr.set_name(Symbol::ARG_2.as_str(&env.interns));
|
||||||
|
|
||||||
let repr = layout_interner.get_repr(layout);
|
let repr = layout_interner.get_repr(layout);
|
||||||
let value_type = basic_type_from_layout(env, layout_interner, repr)
|
let value_type = env.context.ptr_type(AddressSpace::default());
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let dst_cast = env
|
let dst_cast = env
|
||||||
.builder
|
.builder
|
||||||
|
@ -959,7 +950,7 @@ fn ptr_len_cap<'ctx>(
|
||||||
|
|
||||||
let ptr = env.builder.new_build_int_to_ptr(
|
let ptr = env.builder.new_build_int_to_ptr(
|
||||||
lower_word,
|
lower_word,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"list_ptr",
|
"list_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ use inkwell::values::{
|
||||||
FunctionValue, InstructionOpcode, InstructionValue, IntMathValue, IntValue, PhiValue,
|
FunctionValue, InstructionOpcode, InstructionValue, IntMathValue, IntValue, PhiValue,
|
||||||
PointerMathValue, PointerValue, StructValue,
|
PointerMathValue, PointerValue, StructValue,
|
||||||
};
|
};
|
||||||
|
use inkwell::FloatPredicate;
|
||||||
use inkwell::{AddressSpace, IntPredicate};
|
use inkwell::{AddressSpace, IntPredicate};
|
||||||
use inkwell::{FloatPredicate, OptimizationLevel};
|
|
||||||
use morphic_lib::{
|
use morphic_lib::{
|
||||||
CalleeSpecVar, FuncName, FuncSpec, FuncSpecSolutions, ModSolutions, UpdateMode, UpdateModeVar,
|
CalleeSpecVar, FuncName, FuncSpec, FuncSpecSolutions, ModSolutions, UpdateMode, UpdateModeVar,
|
||||||
};
|
};
|
||||||
|
@ -1173,8 +1173,8 @@ fn promote_to_wasm_test_wrapper<'a, 'ctx>(
|
||||||
let roc_main_fn = function_value_by_func_spec(env, FuncBorrowSpec::Some(*func_spec), symbol);
|
let roc_main_fn = function_value_by_func_spec(env, FuncBorrowSpec::Some(*func_spec), symbol);
|
||||||
|
|
||||||
let output_type = match roc_main_fn.get_type().get_return_type() {
|
let output_type = match roc_main_fn.get_type().get_return_type() {
|
||||||
Some(return_type) => {
|
Some(..) => {
|
||||||
let output_type = return_type.ptr_type(AddressSpace::default());
|
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||||
output_type.into()
|
output_type.into()
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
@ -1367,7 +1367,7 @@ fn small_str_ptr_width_8<'ctx>(env: &Env<'_, 'ctx, '_>, str_literal: &str) -> Po
|
||||||
let cap = env.ptr_int().const_int(word3, false);
|
let cap = env.ptr_int().const_int(word3, false);
|
||||||
|
|
||||||
let address_space = AddressSpace::default();
|
let address_space = AddressSpace::default();
|
||||||
let ptr_type = env.context.i8_type().ptr_type(address_space);
|
let ptr_type = env.context.ptr_type(address_space);
|
||||||
let ptr = env.builder.new_build_int_to_ptr(ptr, ptr_type, "to_u8_ptr");
|
let ptr = env.builder.new_build_int_to_ptr(ptr, ptr_type, "to_u8_ptr");
|
||||||
|
|
||||||
const_str_alloca_ptr(env, ptr, len, cap)
|
const_str_alloca_ptr(env, ptr, len, cap)
|
||||||
|
@ -1391,7 +1391,7 @@ fn small_str_ptr_width_4<'ctx>(env: &Env<'_, 'ctx, '_>, str_literal: &str) -> St
|
||||||
let cap = env.ptr_int().const_int(word3 as u64, false);
|
let cap = env.ptr_int().const_int(word3 as u64, false);
|
||||||
|
|
||||||
let address_space = AddressSpace::default();
|
let address_space = AddressSpace::default();
|
||||||
let ptr_type = env.context.i8_type().ptr_type(address_space);
|
let ptr_type = env.context.ptr_type(address_space);
|
||||||
let ptr = env.builder.new_build_int_to_ptr(ptr, ptr_type, "to_u8_ptr");
|
let ptr = env.builder.new_build_int_to_ptr(ptr, ptr_type, "to_u8_ptr");
|
||||||
|
|
||||||
struct_from_fields(
|
struct_from_fields(
|
||||||
|
@ -1530,7 +1530,7 @@ fn struct_pointer_from_fields<'a, 'ctx, 'env, I>(
|
||||||
.builder
|
.builder
|
||||||
.new_build_bitcast(
|
.new_build_bitcast(
|
||||||
input_pointer,
|
input_pointer,
|
||||||
struct_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"struct_ptr",
|
"struct_ptr",
|
||||||
)
|
)
|
||||||
.into_pointer_value();
|
.into_pointer_value();
|
||||||
|
@ -1868,7 +1868,7 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
||||||
|
|
||||||
let data_ptr = env.builder.new_build_pointer_cast(
|
let data_ptr = env.builder.new_build_pointer_cast(
|
||||||
opaque_data_ptr,
|
opaque_data_ptr,
|
||||||
struct_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_data_pointer",
|
"to_data_pointer",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2222,7 +2222,7 @@ fn build_tag_field_value<'a, 'ctx>(
|
||||||
env.builder
|
env.builder
|
||||||
.new_build_pointer_cast(
|
.new_build_pointer_cast(
|
||||||
value.into_pointer_value(),
|
value.into_pointer_value(),
|
||||||
env.context.i64_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_recursive_pointer",
|
"cast_recursive_pointer",
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
|
@ -2395,7 +2395,7 @@ fn build_tag<'a, 'ctx>(
|
||||||
RocUnion::untagged_from_slices(layout_interner, env.context, &[other_fields]);
|
RocUnion::untagged_from_slices(layout_interner, env.context, &[other_fields]);
|
||||||
|
|
||||||
if tag_id == *nullable_id as u16 {
|
if tag_id == *nullable_id as u16 {
|
||||||
let output_type = roc_union.struct_type().ptr_type(AddressSpace::default());
|
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
return output_type.const_null().into();
|
return output_type.const_null().into();
|
||||||
}
|
}
|
||||||
|
@ -2445,7 +2445,7 @@ fn tag_pointer_set_tag_id<'ctx>(
|
||||||
|
|
||||||
let cast_pointer = env.builder.new_build_pointer_cast(
|
let cast_pointer = env.builder.new_build_pointer_cast(
|
||||||
pointer,
|
pointer,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_to_i8_ptr",
|
"cast_to_i8_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2504,7 +2504,7 @@ pub fn tag_pointer_clear_tag_id<'ctx>(
|
||||||
|
|
||||||
let cast_pointer = env.builder.new_build_pointer_cast(
|
let cast_pointer = env.builder.new_build_pointer_cast(
|
||||||
pointer,
|
pointer,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_to_i8_ptr",
|
"cast_to_i8_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2718,7 +2718,7 @@ fn union_field_ptr_at_index_help<'a, 'ctx>(
|
||||||
|
|
||||||
let data_ptr = env.builder.new_build_pointer_cast(
|
let data_ptr = env.builder.new_build_pointer_cast(
|
||||||
value,
|
value,
|
||||||
struct_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_lookup_at_index_ptr",
|
"cast_lookup_at_index_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2769,17 +2769,11 @@ fn reserve_with_refcount_union_as_block_of_memory<'a, 'ctx>(
|
||||||
RocUnion::untagged_from_slices(layout_interner, env.context, fields)
|
RocUnion::untagged_from_slices(layout_interner, env.context, fields)
|
||||||
};
|
};
|
||||||
|
|
||||||
reserve_union_with_refcount_help(
|
reserve_union_with_refcount_help(env, roc_union.tag_width(), roc_union.tag_alignment())
|
||||||
env,
|
|
||||||
roc_union.struct_type(),
|
|
||||||
roc_union.tag_width(),
|
|
||||||
roc_union.tag_alignment(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reserve_union_with_refcount_help<'a, 'ctx, 'env>(
|
fn reserve_union_with_refcount_help<'ctx>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'_, 'ctx, '_>,
|
||||||
basic_type: impl BasicType<'ctx>,
|
|
||||||
stack_size: u32,
|
stack_size: u32,
|
||||||
alignment_bytes: u32,
|
alignment_bytes: u32,
|
||||||
) -> PointerValue<'ctx> {
|
) -> PointerValue<'ctx> {
|
||||||
|
@ -2789,18 +2783,11 @@ fn reserve_union_with_refcount_help<'a, 'ctx, 'env>(
|
||||||
|
|
||||||
// elem_refcounted does not apply to unions, only lists.
|
// elem_refcounted does not apply to unions, only lists.
|
||||||
let elem_refcounted = env.context.bool_type().const_zero().into();
|
let elem_refcounted = env.context.bool_type().const_zero().into();
|
||||||
allocate_with_refcount_help(
|
allocate_with_refcount_help(env, alignment_bytes, value_bytes_intvalue, elem_refcounted)
|
||||||
env,
|
|
||||||
basic_type,
|
|
||||||
alignment_bytes,
|
|
||||||
value_bytes_intvalue,
|
|
||||||
elem_refcounted,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn allocate_with_refcount_help<'a, 'ctx, 'env>(
|
pub fn allocate_with_refcount_help<'ctx>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'_, 'ctx, '_>,
|
||||||
value_type: impl BasicType<'ctx>,
|
|
||||||
alignment_bytes: u32,
|
alignment_bytes: u32,
|
||||||
number_of_data_bytes: IntValue<'ctx>,
|
number_of_data_bytes: IntValue<'ctx>,
|
||||||
elem_refcounted: BasicValueEnum<'ctx>,
|
elem_refcounted: BasicValueEnum<'ctx>,
|
||||||
|
@ -2816,7 +2803,7 @@ pub fn allocate_with_refcount_help<'a, 'ctx, 'env>(
|
||||||
)
|
)
|
||||||
.into_pointer_value();
|
.into_pointer_value();
|
||||||
|
|
||||||
let ptr_type = value_type.ptr_type(AddressSpace::default());
|
let ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
env.builder
|
env.builder
|
||||||
.new_build_pointer_cast(ptr, ptr_type, "alloc_cast_to_desired")
|
.new_build_pointer_cast(ptr, ptr_type, "alloc_cast_to_desired")
|
||||||
|
@ -3043,9 +3030,7 @@ pub fn store_roc_value_opaque<'a, 'ctx>(
|
||||||
opaque_destination: PointerValue<'ctx>,
|
opaque_destination: PointerValue<'ctx>,
|
||||||
value: BasicValueEnum<'ctx>,
|
value: BasicValueEnum<'ctx>,
|
||||||
) {
|
) {
|
||||||
let target_type =
|
let target_type = env.context.ptr_type(AddressSpace::default());
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout))
|
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
let destination = env.builder.new_build_pointer_cast(
|
let destination = env.builder.new_build_pointer_cast(
|
||||||
opaque_destination,
|
opaque_destination,
|
||||||
target_type,
|
target_type,
|
||||||
|
@ -3929,7 +3914,7 @@ fn complex_bitcast_from_bigger_than_to<'ctx>(
|
||||||
// then read it back as a different type
|
// then read it back as a different type
|
||||||
let to_type_pointer = builder.new_build_pointer_cast(
|
let to_type_pointer = builder.new_build_pointer_cast(
|
||||||
argument_pointer,
|
argument_pointer,
|
||||||
to_type.ptr_type(inkwell::AddressSpace::default()),
|
env.context.ptr_type(inkwell::AddressSpace::default()),
|
||||||
name,
|
name,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -3951,9 +3936,7 @@ fn complex_bitcast_to_bigger_than_from<'ctx>(
|
||||||
// then cast the pointer to our desired type
|
// then cast the pointer to our desired type
|
||||||
let from_type_pointer = builder.new_build_pointer_cast(
|
let from_type_pointer = builder.new_build_pointer_cast(
|
||||||
storage,
|
storage,
|
||||||
from_value
|
env.context.ptr_type(inkwell::AddressSpace::default()),
|
||||||
.get_type()
|
|
||||||
.ptr_type(inkwell::AddressSpace::default()),
|
|
||||||
name,
|
name,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4320,8 +4303,8 @@ fn expose_function_to_host_help_c_abi_generic<'a, 'ctx>(
|
||||||
let output_type = roc_function.get_type().get_param_types().pop().unwrap();
|
let output_type = roc_function.get_type().get_param_types().pop().unwrap();
|
||||||
argument_types.insert(0, output_type);
|
argument_types.insert(0, output_type);
|
||||||
}
|
}
|
||||||
Some(return_type) => {
|
Some(..) => {
|
||||||
let output_type = return_type.ptr_type(AddressSpace::default());
|
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||||
argument_types.insert(0, output_type.into());
|
argument_types.insert(0, output_type.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4373,7 +4356,7 @@ fn expose_function_to_host_help_c_abi_generic<'a, 'ctx>(
|
||||||
// bitcast the ptr
|
// bitcast the ptr
|
||||||
let fastcc_ptr = env.builder.new_build_pointer_cast(
|
let fastcc_ptr = env.builder.new_build_pointer_cast(
|
||||||
arg.into_pointer_value(),
|
arg.into_pointer_value(),
|
||||||
fastcc_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"bitcast_arg",
|
"bitcast_arg",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4514,7 +4497,7 @@ fn expose_function_to_host_help_c_abi_gen_test<'a, 'ctx>(
|
||||||
let return_type = wrapper_return_type;
|
let return_type = wrapper_return_type;
|
||||||
|
|
||||||
let c_function_spec = {
|
let c_function_spec = {
|
||||||
let output_type = return_type.ptr_type(AddressSpace::default());
|
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||||
argument_types.push(output_type.into());
|
argument_types.push(output_type.into());
|
||||||
FunctionSpec::cconv(env, CCReturn::Void, None, &argument_types)
|
FunctionSpec::cconv(env, CCReturn::Void, None, &argument_types)
|
||||||
};
|
};
|
||||||
|
@ -4690,10 +4673,7 @@ fn expose_function_to_host_help_c_abi_v2<'a, 'ctx>(
|
||||||
|
|
||||||
let c_abi_roc_str_type = env.context.struct_type(
|
let c_abi_roc_str_type = env.context.struct_type(
|
||||||
&[
|
&[
|
||||||
env.context
|
env.context.ptr_type(AddressSpace::default()).into(),
|
||||||
.i8_type()
|
|
||||||
.ptr_type(AddressSpace::default())
|
|
||||||
.into(),
|
|
||||||
env.ptr_int().into(),
|
env.ptr_int().into(),
|
||||||
env.ptr_int().into(),
|
env.ptr_int().into(),
|
||||||
],
|
],
|
||||||
|
@ -4834,7 +4814,7 @@ fn expose_function_to_host_help_c_abi_v2<'a, 'ctx>(
|
||||||
// bitcast the ptr
|
// bitcast the ptr
|
||||||
let fastcc_ptr = env.builder.new_build_pointer_cast(
|
let fastcc_ptr = env.builder.new_build_pointer_cast(
|
||||||
arg.into_pointer_value(),
|
arg.into_pointer_value(),
|
||||||
fastcc_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"bitcast_arg",
|
"bitcast_arg",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -5024,7 +5004,7 @@ pub fn get_sjlj_buffer<'ctx>(env: &Env<'_, 'ctx, '_>) -> PointerValue<'ctx> {
|
||||||
|
|
||||||
env.builder.new_build_pointer_cast(
|
env.builder.new_build_pointer_cast(
|
||||||
global.as_pointer_value(),
|
global.as_pointer_value(),
|
||||||
env.context.i32_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_sjlj_buffer",
|
"cast_sjlj_buffer",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -5041,15 +5021,11 @@ pub fn build_setjmp_call<'ctx>(env: &Env<'_, 'ctx, '_>) -> BasicValueEnum<'ctx>
|
||||||
// Anywhere else, use the LLVM intrinsic.
|
// Anywhere else, use the LLVM intrinsic.
|
||||||
// https://llvm.org/docs/ExceptionHandling.html#llvm-eh-sjlj-setjmp
|
// https://llvm.org/docs/ExceptionHandling.html#llvm-eh-sjlj-setjmp
|
||||||
|
|
||||||
let buf_type = env
|
let buf_type = env.context.ptr_type(AddressSpace::default()).array_type(5);
|
||||||
.context
|
|
||||||
.i8_type()
|
|
||||||
.ptr_type(AddressSpace::default())
|
|
||||||
.array_type(5);
|
|
||||||
|
|
||||||
let jmp_buf_i8p_arr = env.builder.new_build_pointer_cast(
|
let jmp_buf_i8p_arr = env.builder.new_build_pointer_cast(
|
||||||
jmp_buf,
|
jmp_buf,
|
||||||
buf_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"jmp_buf [5 x i8*]",
|
"jmp_buf [5 x i8*]",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -5090,7 +5066,7 @@ pub fn build_setjmp_call<'ctx>(env: &Env<'_, 'ctx, '_>) -> BasicValueEnum<'ctx>
|
||||||
.builder
|
.builder
|
||||||
.new_build_pointer_cast(
|
.new_build_pointer_cast(
|
||||||
jmp_buf,
|
jmp_buf,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"jmp_buf i8*",
|
"jmp_buf i8*",
|
||||||
)
|
)
|
||||||
.into();
|
.into();
|
||||||
|
@ -5262,7 +5238,7 @@ fn roc_call_result_type<'ctx>(
|
||||||
env.context.struct_type(
|
env.context.struct_type(
|
||||||
&[
|
&[
|
||||||
env.context.i64_type().into(),
|
env.context.i64_type().into(),
|
||||||
zig_str_type(env).ptr_type(AddressSpace::default()).into(),
|
env.context.ptr_type(AddressSpace::default()).into(),
|
||||||
return_type,
|
return_type,
|
||||||
],
|
],
|
||||||
false,
|
false,
|
||||||
|
@ -5990,23 +5966,11 @@ fn build_closure_caller<'a, 'ctx>(
|
||||||
) {
|
) {
|
||||||
let mut argument_types = Vec::with_capacity_in(arguments.len() + 3, env.arena);
|
let mut argument_types = Vec::with_capacity_in(arguments.len() + 3, env.arena);
|
||||||
|
|
||||||
for layout in arguments {
|
for _ in arguments {
|
||||||
let arg_type =
|
argument_types.push(env.context.ptr_type(AddressSpace::default()).into());
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(*layout));
|
|
||||||
let arg_ptr_type = arg_type.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
argument_types.push(arg_ptr_type.into());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let closure_argument_type = {
|
let closure_argument_type = env.context.ptr_type(AddressSpace::default());
|
||||||
let basic_type = basic_type_from_layout(
|
|
||||||
env,
|
|
||||||
layout_interner,
|
|
||||||
layout_interner.get_repr(lambda_set.runtime_representation()),
|
|
||||||
);
|
|
||||||
|
|
||||||
basic_type.ptr_type(AddressSpace::default())
|
|
||||||
};
|
|
||||||
argument_types.push(closure_argument_type.into());
|
argument_types.push(closure_argument_type.into());
|
||||||
|
|
||||||
let context = &env.context;
|
let context = &env.context;
|
||||||
|
@ -6015,7 +5979,7 @@ fn build_closure_caller<'a, 'ctx>(
|
||||||
let result_type =
|
let result_type =
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(result));
|
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(result));
|
||||||
|
|
||||||
let output_type = { result_type.ptr_type(AddressSpace::default()) };
|
let output_type = { env.context.ptr_type(AddressSpace::default()) };
|
||||||
argument_types.push(output_type.into());
|
argument_types.push(output_type.into());
|
||||||
|
|
||||||
// STEP 1: build function header
|
// STEP 1: build function header
|
||||||
|
@ -6264,7 +6228,7 @@ fn roc_call_erased_with_args<'a, 'ctx>(
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
let function_type =
|
let function_type =
|
||||||
fn_ptr::function_type(env, layout_interner, argument_layouts, result_layout);
|
fn_ptr::function_type(env, layout_interner, argument_layouts, result_layout);
|
||||||
let function_ptr_type = function_type.ptr_type(AddressSpace::default());
|
let function_ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let function_pointer = fn_ptr::cast_to_function_ptr_type(env, pointer, function_ptr_type);
|
let function_pointer = fn_ptr::cast_to_function_ptr_type(env, pointer, function_ptr_type);
|
||||||
|
|
||||||
|
@ -6486,7 +6450,7 @@ fn to_cc_type<'a, 'ctx>(
|
||||||
let stack_type = basic_type_from_layout(env, layout_interner, layout_repr);
|
let stack_type = basic_type_from_layout(env, layout_interner, layout_repr);
|
||||||
|
|
||||||
if layout_repr.is_passed_by_reference(layout_interner) {
|
if layout_repr.is_passed_by_reference(layout_interner) {
|
||||||
stack_type.ptr_type(AddressSpace::default()).into()
|
env.context.ptr_type(AddressSpace::default()).into()
|
||||||
} else {
|
} else {
|
||||||
stack_type
|
stack_type
|
||||||
}
|
}
|
||||||
|
@ -6506,18 +6470,7 @@ fn to_cc_type_builtin<'a, 'ctx>(
|
||||||
Builtin::Int(_) | Builtin::Float(_) | Builtin::Bool | Builtin::Decimal => {
|
Builtin::Int(_) | Builtin::Float(_) | Builtin::Bool | Builtin::Decimal => {
|
||||||
basic_type_from_builtin(env, builtin)
|
basic_type_from_builtin(env, builtin)
|
||||||
}
|
}
|
||||||
Builtin::Str | Builtin::List(_) => {
|
Builtin::Str | Builtin::List(_) => env.context.ptr_type(AddressSpace::default()).into(),
|
||||||
let address_space = AddressSpace::default();
|
|
||||||
let field_types: [BasicTypeEnum; 3] = [
|
|
||||||
env.context.i8_type().ptr_type(address_space).into(),
|
|
||||||
env.ptr_int().into(),
|
|
||||||
env.ptr_int().into(),
|
|
||||||
];
|
|
||||||
|
|
||||||
let struct_type = env.context.struct_type(&field_types, false);
|
|
||||||
|
|
||||||
struct_type.ptr_type(address_space).into()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6597,7 +6550,7 @@ impl<'ctx> FunctionSpec<'ctx> {
|
||||||
let (typ, opt_sret_parameter) = match cc_return {
|
let (typ, opt_sret_parameter) = match cc_return {
|
||||||
CCReturn::ByPointer => {
|
CCReturn::ByPointer => {
|
||||||
// turn the output type into a pointer type. Make it the first argument to the function
|
// turn the output type into a pointer type. Make it the first argument to the function
|
||||||
let output_type = return_type.unwrap().ptr_type(AddressSpace::default());
|
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let mut arguments: Vec<'_, BasicTypeEnum> =
|
let mut arguments: Vec<'_, BasicTypeEnum> =
|
||||||
bumpalo::vec![in env.arena; output_type.into()];
|
bumpalo::vec![in env.arena; output_type.into()];
|
||||||
|
@ -6641,7 +6594,7 @@ impl<'ctx> FunctionSpec<'ctx> {
|
||||||
return_type.fn_type(&function_arguments(env, &argument_types), false)
|
return_type.fn_type(&function_arguments(env, &argument_types), false)
|
||||||
}
|
}
|
||||||
RocReturn::ByPointer => {
|
RocReturn::ByPointer => {
|
||||||
argument_types.push(return_type.ptr_type(AddressSpace::default()).into());
|
argument_types.push(env.context.ptr_type(AddressSpace::default()).into());
|
||||||
env.context
|
env.context
|
||||||
.void_type()
|
.void_type()
|
||||||
.fn_type(&function_arguments(env, &argument_types), false)
|
.fn_type(&function_arguments(env, &argument_types), false)
|
||||||
|
@ -6901,7 +6854,7 @@ fn define_global_str_literal_ptr<'ctx>(
|
||||||
|
|
||||||
let ptr = env.builder.new_build_pointer_cast(
|
let ptr = env.builder.new_build_pointer_cast(
|
||||||
global.as_pointer_value(),
|
global.as_pointer_value(),
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_opaque",
|
"to_opaque",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::llvm::bitcode::build_dec_wrapper;
|
||||||
use crate::llvm::build::{allocate_with_refcount_help, cast_basic_basic, Env, RocFunctionCall};
|
use crate::llvm::build::{allocate_with_refcount_help, cast_basic_basic, Env, RocFunctionCall};
|
||||||
use crate::llvm::convert::basic_type_from_layout;
|
use crate::llvm::convert::basic_type_from_layout;
|
||||||
use inkwell::builder::Builder;
|
use inkwell::builder::Builder;
|
||||||
use inkwell::types::{BasicType, PointerType};
|
use inkwell::types::PointerType;
|
||||||
use inkwell::values::{BasicValueEnum, FunctionValue, IntValue, PointerValue, StructValue};
|
use inkwell::values::{BasicValueEnum, FunctionValue, IntValue, PointerValue, StructValue};
|
||||||
use inkwell::{AddressSpace, IntPredicate};
|
use inkwell::{AddressSpace, IntPredicate};
|
||||||
use morphic_lib::UpdateMode;
|
use morphic_lib::UpdateMode;
|
||||||
|
@ -73,7 +73,7 @@ fn pass_element_as_opaque<'a, 'ctx>(
|
||||||
env.builder
|
env.builder
|
||||||
.new_build_pointer_cast(
|
.new_build_pointer_cast(
|
||||||
element_ptr,
|
element_ptr,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"pass_element_as_opaque",
|
"pass_element_as_opaque",
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
|
@ -110,7 +110,7 @@ pub(crate) fn pass_as_opaque<'ctx>(
|
||||||
env.builder
|
env.builder
|
||||||
.new_build_pointer_cast(
|
.new_build_pointer_cast(
|
||||||
ptr,
|
ptr,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"pass_as_opaque",
|
"pass_as_opaque",
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
|
@ -155,7 +155,7 @@ pub(crate) fn list_get_unsafe<'a, 'ctx>(
|
||||||
);
|
);
|
||||||
// listGetUnsafe takes a U64, but we need to convert that to usize for index calculation.
|
// listGetUnsafe takes a U64, but we need to convert that to usize for index calculation.
|
||||||
let elem_index = builder.new_build_int_cast(elem_index, env.ptr_int(), "u64_to_usize");
|
let elem_index = builder.new_build_int_cast(elem_index, env.ptr_int(), "u64_to_usize");
|
||||||
let ptr_type = elem_type.ptr_type(AddressSpace::default());
|
let ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
// Load the pointer to the array data
|
// Load the pointer to the array data
|
||||||
let array_data_ptr = load_list_ptr(env, wrapper_struct, ptr_type);
|
let array_data_ptr = load_list_ptr(env, wrapper_struct, ptr_type);
|
||||||
|
|
||||||
|
@ -728,18 +728,9 @@ pub(crate) fn allocate_list<'a, 'ctx>(
|
||||||
let bytes_per_element = len_type.const_int(elem_bytes, false);
|
let bytes_per_element = len_type.const_int(elem_bytes, false);
|
||||||
let number_of_data_bytes =
|
let number_of_data_bytes =
|
||||||
builder.new_build_int_mul(bytes_per_element, number_of_elements, "data_length");
|
builder.new_build_int_mul(bytes_per_element, number_of_elements, "data_length");
|
||||||
|
|
||||||
let basic_type =
|
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(elem_layout));
|
|
||||||
let alignment_bytes = layout_interner.alignment_bytes(elem_layout);
|
let alignment_bytes = layout_interner.alignment_bytes(elem_layout);
|
||||||
let elem_refcounted = layout_refcounted(env, layout_interner, elem_layout);
|
let elem_refcounted = layout_refcounted(env, layout_interner, elem_layout);
|
||||||
allocate_with_refcount_help(
|
allocate_with_refcount_help(env, alignment_bytes, number_of_data_bytes, elem_refcounted)
|
||||||
env,
|
|
||||||
basic_type,
|
|
||||||
alignment_bytes,
|
|
||||||
number_of_data_bytes,
|
|
||||||
elem_refcounted,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn store_list<'ctx>(
|
pub(crate) fn store_list<'ctx>(
|
||||||
|
|
|
@ -3,7 +3,6 @@ use crate::llvm::build_list::{list_len_usize, load_list_ptr};
|
||||||
use crate::llvm::build_str::str_equal;
|
use crate::llvm::build_str::str_equal;
|
||||||
use crate::llvm::convert::basic_type_from_layout;
|
use crate::llvm::convert::basic_type_from_layout;
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use inkwell::types::BasicType;
|
|
||||||
use inkwell::values::{BasicValueEnum, FunctionValue, IntValue, PointerValue, StructValue};
|
use inkwell::values::{BasicValueEnum, FunctionValue, IntValue, PointerValue, StructValue};
|
||||||
use inkwell::{AddressSpace, FloatPredicate, IntPredicate};
|
use inkwell::{AddressSpace, FloatPredicate, IntPredicate};
|
||||||
use roc_builtins::bitcode;
|
use roc_builtins::bitcode;
|
||||||
|
@ -528,7 +527,7 @@ fn build_list_eq_help<'a, 'ctx>(
|
||||||
|
|
||||||
let builder = env.builder;
|
let builder = env.builder;
|
||||||
let element_type = basic_type_from_layout(env, layout_interner, element_layout);
|
let element_type = basic_type_from_layout(env, layout_interner, element_layout);
|
||||||
let ptr_type = element_type.ptr_type(AddressSpace::default());
|
let ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
let ptr1 = load_list_ptr(env, list1, ptr_type);
|
let ptr1 = load_list_ptr(env, list1, ptr_type);
|
||||||
let ptr2 = load_list_ptr(env, list2, ptr_type);
|
let ptr2 = load_list_ptr(env, list2, ptr_type);
|
||||||
|
|
||||||
|
@ -1286,13 +1285,13 @@ fn eq_ptr_to_struct<'a, 'ctx>(
|
||||||
// cast the opaque pointer to a pointer of the correct shape
|
// cast the opaque pointer to a pointer of the correct shape
|
||||||
let struct1_ptr = env.builder.new_build_pointer_cast(
|
let struct1_ptr = env.builder.new_build_pointer_cast(
|
||||||
tag1,
|
tag1,
|
||||||
wrapper_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"opaque_to_correct",
|
"opaque_to_correct",
|
||||||
);
|
);
|
||||||
|
|
||||||
let struct2_ptr = env.builder.new_build_pointer_cast(
|
let struct2_ptr = env.builder.new_build_pointer_cast(
|
||||||
tag2,
|
tag2,
|
||||||
wrapper_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"opaque_to_correct",
|
"opaque_to_correct",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::llvm::build::{BuilderExt, Env, FunctionSpec, RocReturn};
|
use crate::llvm::build::{BuilderExt, Env};
|
||||||
use crate::llvm::erased;
|
use crate::llvm::erased;
|
||||||
use crate::llvm::memcpy::build_memcpy;
|
use crate::llvm::memcpy::build_memcpy;
|
||||||
use bumpalo::collections::{CollectIn, Vec as AVec};
|
use bumpalo::collections::Vec as AVec;
|
||||||
use inkwell::context::Context;
|
use inkwell::context::Context;
|
||||||
use inkwell::types::{BasicType, BasicTypeEnum, FloatType, IntType, StructType};
|
use inkwell::types::{BasicType, BasicTypeEnum, FloatType, IntType, StructType};
|
||||||
use inkwell::values::PointerValue;
|
use inkwell::values::PointerValue;
|
||||||
|
@ -32,37 +32,18 @@ pub fn basic_type_from_layout<'a, 'ctx>(
|
||||||
layout_interner.get_repr(lambda_set.runtime_representation()),
|
layout_interner.get_repr(lambda_set.runtime_representation()),
|
||||||
),
|
),
|
||||||
|
|
||||||
Ptr(inner_layout) => {
|
Ptr(..) => env.context.ptr_type(AddressSpace::default()).into(),
|
||||||
let inner_type = basic_type_from_layout(
|
|
||||||
env,
|
|
||||||
layout_interner,
|
|
||||||
layout_interner.get_repr(inner_layout),
|
|
||||||
);
|
|
||||||
|
|
||||||
inner_type.ptr_type(AddressSpace::default()).into()
|
|
||||||
}
|
|
||||||
Union(union_layout) => basic_type_from_union_layout(env, layout_interner, &union_layout),
|
Union(union_layout) => basic_type_from_union_layout(env, layout_interner, &union_layout),
|
||||||
|
|
||||||
RecursivePointer(_) => env
|
RecursivePointer(_) => env
|
||||||
.context
|
.context
|
||||||
.i64_type()
|
|
||||||
.ptr_type(AddressSpace::default())
|
.ptr_type(AddressSpace::default())
|
||||||
.as_basic_type_enum(),
|
.as_basic_type_enum(),
|
||||||
|
|
||||||
FunctionPointer(self::FunctionPointer { args, ret }) => {
|
FunctionPointer(self::FunctionPointer { .. }) => {
|
||||||
let args = args.iter().map(|arg| {
|
env.context.ptr_type(AddressSpace::default()).into()
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(*arg))
|
|
||||||
});
|
|
||||||
|
|
||||||
let ret_repr = layout_interner.get_repr(ret);
|
|
||||||
let ret = basic_type_from_layout(env, layout_interner, ret_repr);
|
|
||||||
|
|
||||||
let roc_return = RocReturn::from_layout(layout_interner, ret_repr);
|
|
||||||
|
|
||||||
let fn_spec = FunctionSpec::fastcc(env, roc_return, ret, args.collect_in(env.arena));
|
|
||||||
|
|
||||||
fn_spec.typ.ptr_type(AddressSpace::default()).into()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Erased(_) => erased::basic_type(env).into(),
|
Erased(_) => erased::basic_type(env).into(),
|
||||||
|
|
||||||
Builtin(builtin) => basic_type_from_builtin(env, &builtin),
|
Builtin(builtin) => basic_type_from_builtin(env, &builtin),
|
||||||
|
@ -136,7 +117,7 @@ fn basic_type_from_union_layout<'a, 'ctx>(
|
||||||
Recursive(_)
|
Recursive(_)
|
||||||
| NonNullableUnwrapped(_)
|
| NonNullableUnwrapped(_)
|
||||||
| NullableWrapped { .. }
|
| NullableWrapped { .. }
|
||||||
| NullableUnwrapped { .. } => struct_type.ptr_type(AddressSpace::default()).into(),
|
| NullableUnwrapped { .. } => env.context.ptr_type(AddressSpace::default()).into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +169,7 @@ pub fn argument_type_from_layout<'a, 'ctx>(
|
||||||
let base = basic_type_from_layout(env, layout_interner, layout);
|
let base = basic_type_from_layout(env, layout_interner, layout);
|
||||||
|
|
||||||
if layout.is_passed_by_reference(layout_interner) {
|
if layout.is_passed_by_reference(layout_interner) {
|
||||||
base.ptr_type(AddressSpace::default()).into()
|
env.context.ptr_type(AddressSpace::default()).into()
|
||||||
} else {
|
} else {
|
||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
@ -208,7 +189,7 @@ fn argument_type_from_struct_layout<'a, 'ctx>(
|
||||||
let stack_type = basic_type_from_layout(env, layout_interner, struct_layout);
|
let stack_type = basic_type_from_layout(env, layout_interner, struct_layout);
|
||||||
|
|
||||||
if struct_layout.is_passed_by_reference(layout_interner) {
|
if struct_layout.is_passed_by_reference(layout_interner) {
|
||||||
stack_type.ptr_type(AddressSpace::default()).into()
|
env.context.ptr_type(AddressSpace::default()).into()
|
||||||
} else {
|
} else {
|
||||||
stack_type
|
stack_type
|
||||||
}
|
}
|
||||||
|
@ -223,7 +204,7 @@ pub fn argument_type_from_union_layout<'a, 'ctx>(
|
||||||
let heap_type = basic_type_from_union_layout(env, layout_interner, union_layout);
|
let heap_type = basic_type_from_union_layout(env, layout_interner, union_layout);
|
||||||
|
|
||||||
if let UnionLayout::NonRecursive(_) = union_layout {
|
if let UnionLayout::NonRecursive(_) = union_layout {
|
||||||
heap_type.ptr_type(AddressSpace::default()).into()
|
env.context.ptr_type(AddressSpace::default()).into()
|
||||||
} else {
|
} else {
|
||||||
heap_type
|
heap_type
|
||||||
}
|
}
|
||||||
|
@ -442,7 +423,7 @@ impl<'ctx> RocUnion<'ctx> {
|
||||||
RocStruct::ByValue(value) => {
|
RocStruct::ByValue(value) => {
|
||||||
let cast_pointer = env.builder.new_build_pointer_cast(
|
let cast_pointer = env.builder.new_build_pointer_cast(
|
||||||
data_buffer,
|
data_buffer,
|
||||||
value.get_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_data_ptr",
|
"to_data_ptr",
|
||||||
);
|
);
|
||||||
env.builder.new_build_store(cast_pointer, value);
|
env.builder.new_build_store(cast_pointer, value);
|
||||||
|
@ -509,7 +490,7 @@ pub fn zig_dec_type<'ctx>(env: &Env<'_, 'ctx, '_>) -> StructType<'ctx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn zig_has_tag_id_type<'ctx>(env: &Env<'_, 'ctx, '_>) -> StructType<'ctx> {
|
pub fn zig_has_tag_id_type<'ctx>(env: &Env<'_, 'ctx, '_>) -> StructType<'ctx> {
|
||||||
let u8_ptr_t = env.context.i8_type().ptr_type(AddressSpace::default());
|
let u8_ptr_t = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
env.context
|
env.context
|
||||||
.struct_type(&[env.context.bool_type().into(), u8_ptr_t.into()], false)
|
.struct_type(&[env.context.bool_type().into(), u8_ptr_t.into()], false)
|
||||||
|
|
|
@ -8,7 +8,7 @@ use roc_mono::ir::ErasedField;
|
||||||
use super::build::{BuilderExt, Env};
|
use super::build::{BuilderExt, Env};
|
||||||
|
|
||||||
pub fn opaque_ptr_type<'ctx>(env: &Env<'_, 'ctx, '_>) -> PointerType<'ctx> {
|
pub fn opaque_ptr_type<'ctx>(env: &Env<'_, 'ctx, '_>) -> PointerType<'ctx> {
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default())
|
env.context.ptr_type(AddressSpace::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn refcounter_type<'ctx>(env: &Env<'_, 'ctx, '_>) -> PointerType<'ctx> {
|
fn refcounter_type<'ctx>(env: &Env<'_, 'ctx, '_>) -> PointerType<'ctx> {
|
||||||
|
|
|
@ -100,7 +100,7 @@ fn read_state<'ctx>(
|
||||||
env: &Env<'_, 'ctx, '_>,
|
env: &Env<'_, 'ctx, '_>,
|
||||||
ptr: PointerValue<'ctx>,
|
ptr: PointerValue<'ctx>,
|
||||||
) -> (IntValue<'ctx>, IntValue<'ctx>) {
|
) -> (IntValue<'ctx>, IntValue<'ctx>) {
|
||||||
let ptr_type = env.ptr_int().ptr_type(AddressSpace::default());
|
let ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
let ptr = env.builder.new_build_pointer_cast(ptr, ptr_type, "");
|
let ptr = env.builder.new_build_pointer_cast(ptr, ptr_type, "");
|
||||||
|
|
||||||
let one = env.ptr_int().const_int(1, false);
|
let one = env.ptr_int().const_int(1, false);
|
||||||
|
@ -120,7 +120,7 @@ fn write_state<'ctx>(
|
||||||
count: IntValue<'ctx>,
|
count: IntValue<'ctx>,
|
||||||
offset: IntValue<'ctx>,
|
offset: IntValue<'ctx>,
|
||||||
) {
|
) {
|
||||||
let ptr_type = env.ptr_int().ptr_type(AddressSpace::default());
|
let ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
let ptr = env.builder.new_build_pointer_cast(ptr, ptr_type, "");
|
let ptr = env.builder.new_build_pointer_cast(ptr, ptr_type, "");
|
||||||
|
|
||||||
let one = env.ptr_int().const_int(1, false);
|
let one = env.ptr_int().const_int(1, false);
|
||||||
|
@ -249,7 +249,7 @@ pub(crate) fn clone_to_shared_memory<'a, 'ctx>(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let u32_ptr = env.context.i32_type().ptr_type(AddressSpace::default());
|
let u32_ptr = env.context.ptr_type(AddressSpace::default());
|
||||||
let ptr = env
|
let ptr = env
|
||||||
.builder
|
.builder
|
||||||
.new_build_pointer_cast(ptr, u32_ptr, "cast_ptr_type");
|
.new_build_pointer_cast(ptr, u32_ptr, "cast_ptr_type");
|
||||||
|
@ -321,7 +321,7 @@ fn build_clone<'a, 'ctx>(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let ptr_type = value.get_type().ptr_type(AddressSpace::default());
|
let ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
let ptr = env
|
let ptr = env
|
||||||
.builder
|
.builder
|
||||||
.new_build_pointer_cast(ptr, ptr_type, "cast_ptr_type");
|
.new_build_pointer_cast(ptr, ptr_type, "cast_ptr_type");
|
||||||
|
@ -446,10 +446,7 @@ fn build_clone_tag<'a, 'ctx>(
|
||||||
|
|
||||||
let function_type = env.ptr_int().fn_type(
|
let function_type = env.ptr_int().fn_type(
|
||||||
&[
|
&[
|
||||||
env.context
|
env.context.ptr_type(AddressSpace::default()).into(),
|
||||||
.i8_type()
|
|
||||||
.ptr_type(AddressSpace::default())
|
|
||||||
.into(),
|
|
||||||
env.ptr_int().into(),
|
env.ptr_int().into(),
|
||||||
env.ptr_int().into(),
|
env.ptr_int().into(),
|
||||||
BasicMetadataTypeEnum::from(value.get_type()),
|
BasicMetadataTypeEnum::from(value.get_type()),
|
||||||
|
@ -523,7 +520,7 @@ fn load_tag_data<'a, 'ctx>(
|
||||||
|
|
||||||
let data_ptr = env.builder.new_build_pointer_cast(
|
let data_ptr = env.builder.new_build_pointer_cast(
|
||||||
raw_data_ptr,
|
raw_data_ptr,
|
||||||
tag_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"data_ptr",
|
"data_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -545,7 +542,7 @@ fn clone_tag_payload_and_id<'a, 'ctx>(
|
||||||
|
|
||||||
let payload_ptr = env.builder.new_build_pointer_cast(
|
let payload_ptr = env.builder.new_build_pointer_cast(
|
||||||
opaque_payload_ptr,
|
opaque_payload_ptr,
|
||||||
payload_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_payload_ptr",
|
"cast_payload_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -948,7 +945,7 @@ fn build_copy<'ctx>(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let ptr_type = value.get_type().ptr_type(AddressSpace::default());
|
let ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
let ptr = env
|
let ptr = env
|
||||||
.builder
|
.builder
|
||||||
.new_build_pointer_cast(ptr, ptr_type, "cast_ptr_type");
|
.new_build_pointer_cast(ptr, ptr_type, "cast_ptr_type");
|
||||||
|
@ -1016,18 +1013,16 @@ fn build_clone_builtin<'a, 'ctx>(
|
||||||
let dest = pointer_at_offset(bd, env.context.i8_type(), ptr, elements_start_offset);
|
let dest = pointer_at_offset(bd, env.context.i8_type(), ptr, elements_start_offset);
|
||||||
let src = bd.new_build_pointer_cast(
|
let src = bd.new_build_pointer_cast(
|
||||||
elements,
|
elements,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_bytes_pointer",
|
"to_bytes_pointer",
|
||||||
);
|
);
|
||||||
bd.build_memcpy(dest, 1, src, 1, elements_width).unwrap();
|
bd.build_memcpy(dest, 1, src, 1, elements_width).unwrap();
|
||||||
|
|
||||||
bd.new_build_int_add(elements_start_offset, elements_width, "new_offset")
|
bd.new_build_int_add(elements_start_offset, elements_width, "new_offset")
|
||||||
} else {
|
} else {
|
||||||
let element_type =
|
|
||||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(elem));
|
|
||||||
let elements = bd.new_build_pointer_cast(
|
let elements = bd.new_build_pointer_cast(
|
||||||
elements,
|
elements,
|
||||||
element_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"elements",
|
"elements",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub fn add_default_roc_externs(env: &Env<'_, '_, '_>) {
|
||||||
let builder = env.builder;
|
let builder = env.builder;
|
||||||
|
|
||||||
let usize_type = env.ptr_int();
|
let usize_type = env.ptr_int();
|
||||||
let i8_ptr_type = ctx.i8_type().ptr_type(AddressSpace::default());
|
let i8_ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
match env.mode {
|
match env.mode {
|
||||||
super::build::LlvmBackendMode::CliTest => {
|
super::build::LlvmBackendMode::CliTest => {
|
||||||
|
@ -331,7 +331,7 @@ pub fn build_longjmp_call(env: &Env) {
|
||||||
// Call the LLVM-intrinsic longjmp: `void @llvm.eh.sjlj.longjmp(i8* %setjmp_buf)`
|
// Call the LLVM-intrinsic longjmp: `void @llvm.eh.sjlj.longjmp(i8* %setjmp_buf)`
|
||||||
let jmp_buf_i8p = env.builder.new_build_pointer_cast(
|
let jmp_buf_i8p = env.builder.new_build_pointer_cast(
|
||||||
jmp_buf,
|
jmp_buf,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"jmp_buf i8*",
|
"jmp_buf i8*",
|
||||||
);
|
);
|
||||||
let _call = env.build_intrinsic_call(LLVM_LONGJMP, &[jmp_buf_i8p.into()]);
|
let _call = env.build_intrinsic_call(LLVM_LONGJMP, &[jmp_buf_i8p.into()]);
|
||||||
|
|
|
@ -75,8 +75,7 @@ pub(crate) fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>) {
|
||||||
//
|
//
|
||||||
// https://releases.llvm.org/10.0.0/docs/LangRef.html#standard-c-library-intrinsics
|
// https://releases.llvm.org/10.0.0/docs/LangRef.html#standard-c-library-intrinsics
|
||||||
let i1_type = ctx.bool_type();
|
let i1_type = ctx.bool_type();
|
||||||
let i8_type = ctx.i8_type();
|
let i8_ptr_type = ctx.ptr_type(AddressSpace::default());
|
||||||
let i8_ptr_type = i8_type.ptr_type(AddressSpace::default());
|
|
||||||
let i32_type = ctx.i32_type();
|
let i32_type = ctx.i32_type();
|
||||||
let void_type = ctx.void_type();
|
let void_type = ctx.void_type();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use inkwell::{
|
use inkwell::{
|
||||||
attributes::{Attribute, AttributeLoc},
|
attributes::{Attribute, AttributeLoc},
|
||||||
module::Linkage,
|
module::Linkage,
|
||||||
types::{BasicType, IntType},
|
types::IntType,
|
||||||
values::{
|
values::{
|
||||||
BasicValue, BasicValueEnum, FloatValue, FunctionValue, InstructionOpcode, IntValue,
|
BasicValue, BasicValueEnum, FloatValue, FunctionValue, InstructionOpcode, IntValue,
|
||||||
StructValue,
|
StructValue,
|
||||||
|
@ -237,12 +237,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
||||||
intrinsic,
|
intrinsic,
|
||||||
);
|
);
|
||||||
|
|
||||||
let roc_return_type = basic_type_from_layout(
|
let roc_return_type = env.context.ptr_type(AddressSpace::default());
|
||||||
env,
|
|
||||||
layout_interner,
|
|
||||||
layout_interner.get_repr(layout),
|
|
||||||
)
|
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let roc_return_alloca = env.builder.new_build_pointer_cast(
|
let roc_return_alloca = env.builder.new_build_pointer_cast(
|
||||||
zig_return_alloca,
|
zig_return_alloca,
|
||||||
|
@ -331,12 +326,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
||||||
intrinsic,
|
intrinsic,
|
||||||
);
|
);
|
||||||
|
|
||||||
let roc_return_type = basic_type_from_layout(
|
let roc_return_type = env.context.ptr_type(AddressSpace::default());
|
||||||
env,
|
|
||||||
layout_interner,
|
|
||||||
layout_interner.get_repr(layout),
|
|
||||||
)
|
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let roc_return_alloca = env.builder.new_build_pointer_cast(
|
let roc_return_alloca = env.builder.new_build_pointer_cast(
|
||||||
zig_return_alloca,
|
zig_return_alloca,
|
||||||
|
@ -1363,7 +1353,7 @@ pub(crate) fn run_low_level<'a, 'ctx>(
|
||||||
|
|
||||||
let ptr = env.builder.new_build_pointer_cast(
|
let ptr = env.builder.new_build_pointer_cast(
|
||||||
data_ptr.into_pointer_value(),
|
data_ptr.into_pointer_value(),
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_to_i8_ptr",
|
"cast_to_i8_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1979,7 +1969,7 @@ fn dec_alloca<'ctx>(env: &Env<'_, 'ctx, '_>, value: IntValue<'ctx>) -> BasicValu
|
||||||
|
|
||||||
let ptr = env.builder.new_build_pointer_cast(
|
let ptr = env.builder.new_build_pointer_cast(
|
||||||
alloca,
|
alloca,
|
||||||
value.get_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_to_i128_ptr",
|
"cast_to_i128_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2000,7 +1990,7 @@ fn dec_alloca<'ctx>(env: &Env<'_, 'ctx, '_>, value: IntValue<'ctx>) -> BasicValu
|
||||||
instruction.set_alignment(16).unwrap();
|
instruction.set_alignment(16).unwrap();
|
||||||
let ptr = env.builder.new_build_pointer_cast(
|
let ptr = env.builder.new_build_pointer_cast(
|
||||||
alloca,
|
alloca,
|
||||||
value.get_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_to_i128_ptr",
|
"cast_to_i128_ptr",
|
||||||
);
|
);
|
||||||
env.builder.new_build_store(ptr, value);
|
env.builder.new_build_store(ptr, value);
|
||||||
|
@ -2480,12 +2470,7 @@ fn build_int_unary_op<'a, 'ctx, 'env>(
|
||||||
intrinsic,
|
intrinsic,
|
||||||
);
|
);
|
||||||
|
|
||||||
let roc_return_type = basic_type_from_layout(
|
let roc_return_type = env.context.ptr_type(AddressSpace::default());
|
||||||
env,
|
|
||||||
layout_interner,
|
|
||||||
layout_interner.get_repr(return_layout),
|
|
||||||
)
|
|
||||||
.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let roc_return_alloca = env.builder.new_build_pointer_cast(
|
let roc_return_alloca = env.builder.new_build_pointer_cast(
|
||||||
zig_return_alloca,
|
zig_return_alloca,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::llvm::struct_::RocStruct;
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use inkwell::basic_block::BasicBlock;
|
use inkwell::basic_block::BasicBlock;
|
||||||
use inkwell::module::Linkage;
|
use inkwell::module::Linkage;
|
||||||
use inkwell::types::{AnyTypeEnum, BasicMetadataTypeEnum, BasicType, BasicTypeEnum};
|
use inkwell::types::{AnyTypeEnum, BasicMetadataTypeEnum, BasicTypeEnum};
|
||||||
use inkwell::values::{BasicValueEnum, FunctionValue, InstructionValue, IntValue, PointerValue};
|
use inkwell::values::{BasicValueEnum, FunctionValue, InstructionValue, IntValue, PointerValue};
|
||||||
use inkwell::{AddressSpace, IntPredicate};
|
use inkwell::{AddressSpace, IntPredicate};
|
||||||
use roc_builtins::bitcode;
|
use roc_builtins::bitcode;
|
||||||
|
@ -37,12 +37,9 @@ impl<'ctx> PointerToRefcount<'ctx> {
|
||||||
/// not the data, and only is the start of the allocated buffer if the
|
/// not the data, and only is the start of the allocated buffer if the
|
||||||
/// alignment works out that way.
|
/// alignment works out that way.
|
||||||
pub unsafe fn from_ptr<'a, 'env>(env: &Env<'a, 'ctx, 'env>, ptr: PointerValue<'ctx>) -> Self {
|
pub unsafe fn from_ptr<'a, 'env>(env: &Env<'a, 'ctx, 'env>, ptr: PointerValue<'ctx>) -> Self {
|
||||||
// must make sure it's a pointer to usize
|
|
||||||
let refcount_type = env.ptr_int();
|
|
||||||
|
|
||||||
let value = env.builder.new_build_pointer_cast(
|
let value = env.builder.new_build_pointer_cast(
|
||||||
ptr,
|
ptr,
|
||||||
refcount_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_refcount_ptr",
|
"to_refcount_ptr",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -56,7 +53,7 @@ impl<'ctx> PointerToRefcount<'ctx> {
|
||||||
let builder = env.builder;
|
let builder = env.builder;
|
||||||
// pointer to usize
|
// pointer to usize
|
||||||
let refcount_type = env.ptr_int();
|
let refcount_type = env.ptr_int();
|
||||||
let refcount_ptr_type = refcount_type.ptr_type(AddressSpace::default());
|
let refcount_ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||||
|
|
||||||
let ptr_as_usize_ptr =
|
let ptr_as_usize_ptr =
|
||||||
builder.new_build_pointer_cast(data_ptr, refcount_ptr_type, "as_usize_ptr");
|
builder.new_build_pointer_cast(data_ptr, refcount_ptr_type, "as_usize_ptr");
|
||||||
|
@ -145,7 +142,7 @@ impl<'ctx> PointerToRefcount<'ctx> {
|
||||||
None => {
|
None => {
|
||||||
// inc and dec return void
|
// inc and dec return void
|
||||||
let fn_type = context.void_type().fn_type(
|
let fn_type = context.void_type().fn_type(
|
||||||
&[env.ptr_int().ptr_type(AddressSpace::default()).into()],
|
&[env.context.ptr_type(AddressSpace::default()).into()],
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -231,7 +228,7 @@ fn incref_pointer<'ctx>(
|
||||||
env.builder
|
env.builder
|
||||||
.new_build_pointer_cast(
|
.new_build_pointer_cast(
|
||||||
pointer,
|
pointer,
|
||||||
env.ptr_int().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_isize_ptr",
|
"to_isize_ptr",
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
|
@ -255,7 +252,7 @@ fn free_pointer<'ctx>(
|
||||||
env.builder
|
env.builder
|
||||||
.new_build_pointer_cast(
|
.new_build_pointer_cast(
|
||||||
pointer,
|
pointer,
|
||||||
env.ptr_int().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_isize_ptr",
|
"to_isize_ptr",
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
|
@ -280,7 +277,7 @@ fn decref_pointer<'ctx>(
|
||||||
env.builder
|
env.builder
|
||||||
.new_build_pointer_cast(
|
.new_build_pointer_cast(
|
||||||
pointer,
|
pointer,
|
||||||
env.ptr_int().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_isize_ptr",
|
"to_isize_ptr",
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
|
@ -306,7 +303,7 @@ pub fn decref_pointer_check_null<'ctx>(
|
||||||
env.builder
|
env.builder
|
||||||
.new_build_pointer_cast(
|
.new_build_pointer_cast(
|
||||||
pointer,
|
pointer,
|
||||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"to_i8_ptr",
|
"to_i8_ptr",
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
|
@ -1320,7 +1317,7 @@ fn build_rec_union_recursive_decrement<'a, 'ctx>(
|
||||||
// cast the opaque pointer to a pointer of the correct shape
|
// cast the opaque pointer to a pointer of the correct shape
|
||||||
let struct_ptr = env.builder.new_build_pointer_cast(
|
let struct_ptr = env.builder.new_build_pointer_cast(
|
||||||
value_ptr,
|
value_ptr,
|
||||||
wrapper_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"opaque_to_correct_recursive_decrement",
|
"opaque_to_correct_recursive_decrement",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1340,7 +1337,7 @@ fn build_rec_union_recursive_decrement<'a, 'ctx>(
|
||||||
);
|
);
|
||||||
|
|
||||||
let ptr_as_i64_ptr = env.builder.new_build_load(
|
let ptr_as_i64_ptr = env.builder.new_build_load(
|
||||||
env.context.i64_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
elem_pointer,
|
elem_pointer,
|
||||||
"load_recursive_pointer",
|
"load_recursive_pointer",
|
||||||
);
|
);
|
||||||
|
@ -1792,7 +1789,7 @@ fn modify_refcount_nonrecursive_help<'a, 'ctx>(
|
||||||
|
|
||||||
let cast_tag_data_pointer = env.builder.new_build_pointer_cast(
|
let cast_tag_data_pointer = env.builder.new_build_pointer_cast(
|
||||||
opaque_tag_data_ptr,
|
opaque_tag_data_ptr,
|
||||||
data_struct_type.ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
"cast_to_concrete_tag",
|
"cast_to_concrete_tag",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1810,7 +1807,7 @@ fn modify_refcount_nonrecursive_help<'a, 'ctx>(
|
||||||
|
|
||||||
// This is the actual pointer to the recursive data.
|
// This is the actual pointer to the recursive data.
|
||||||
let field_value = env.builder.new_build_load(
|
let field_value = env.builder.new_build_load(
|
||||||
env.context.i64_type().ptr_type(AddressSpace::default()),
|
env.context.ptr_type(AddressSpace::default()),
|
||||||
field_ptr,
|
field_ptr,
|
||||||
"load_recursive_pointer",
|
"load_recursive_pointer",
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue