This commit is contained in:
Folkert 2022-01-26 14:30:37 +01:00
parent 7e90812332
commit 74932a4cab
13 changed files with 93 additions and 91 deletions

View File

@ -181,7 +181,7 @@ pub fn gen_and_eval<'a>(
context: &context,
interns,
module,
ptr_bytes,
target_info: ptr_bytes,
is_gen_test: true, // so roc_panic is generated
// important! we don't want any procedures to get the C calling convention
exposed_to_host: MutSet::default(),

View File

@ -286,7 +286,7 @@ pub fn gen_from_mono_module_llvm(
context: &context,
interns: loaded.interns,
module,
ptr_bytes,
target_info: ptr_bytes,
// in gen_tests, the compiler provides roc_panic
// and sets up the setjump/longjump exception handling
is_gen_test: false,

View File

@ -105,15 +105,15 @@ pub fn dict_insert<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let result_ptr = builder.build_alloca(zig_dict_type(env), "result_ptr");
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let hash_fn = build_hash_wrapper(env, layout_ids, key_layout);
@ -162,15 +162,15 @@ pub fn dict_remove<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let result_ptr = builder.build_alloca(zig_dict_type(env), "result_ptr");
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let hash_fn = build_hash_wrapper(env, layout_ids, key_layout);
@ -218,13 +218,13 @@ pub fn dict_contains<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let hash_fn = build_hash_wrapper(env, layout_ids, key_layout);
@ -264,13 +264,13 @@ pub fn dict_get<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let hash_fn = build_hash_wrapper(env, layout_ids, key_layout);
@ -366,13 +366,13 @@ pub fn dict_elements_rc<'a, 'ctx, 'env>(
) {
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let (key_fn, value_fn) = match rc_operation {
@ -412,13 +412,13 @@ pub fn dict_keys<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let inc_key_fn = build_inc_wrapper(env, layout_ids, key_layout);
@ -454,7 +454,7 @@ fn pass_dict_c_abi<'a, 'ctx, 'env>(
env: &Env<'a, 'ctx, 'env>,
dict: BasicValueEnum<'ctx>,
) -> BasicValueEnum<'ctx> {
match env.ptr_bytes {
match env.target_info {
4 => {
let target_type = env.context.custom_width_int_type(96).into();
@ -483,13 +483,13 @@ pub fn dict_union<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let hash_fn = build_hash_wrapper(env, layout_ids, key_layout);
@ -576,13 +576,13 @@ fn dict_intersect_or_difference<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let hash_fn = build_hash_wrapper(env, layout_ids, key_layout);
@ -631,7 +631,7 @@ pub fn dict_walk<'a, 'ctx, 'env>(
let accum_ptr = builder.build_alloca(accum_bt, "accum_ptr");
env.builder.build_store(accum_ptr, accum);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let output_ptr = builder.build_alloca(accum_bt, "output_ptr");
@ -671,13 +671,13 @@ pub fn dict_values<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env
.ptr_int()
.const_int(value_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(value_layout.stack_size(env.target_info) as u64, false);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.ptr_bytes);
let alignment = Alignment::from_key_value_layout(key_layout, value_layout, env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let inc_value_fn = build_inc_wrapper(env, layout_ids, value_layout);
@ -729,14 +729,14 @@ pub fn set_from_list<'a, 'ctx, 'env>(
let key_width = env
.ptr_int()
.const_int(key_layout.stack_size(env.ptr_bytes) as u64, false);
.const_int(key_layout.stack_size(env.target_info) as u64, false);
let value_width = env.ptr_int().const_zero();
let result_alloca = builder.build_alloca(zig_dict_type(env), "result_alloca");
let alignment =
Alignment::from_key_value_layout(key_layout, &Layout::Struct(&[]), env.ptr_bytes);
Alignment::from_key_value_layout(key_layout, &Layout::Struct(&[]), env.target_info);
let alignment_iv = alignment.as_int_value(env.context);
let hash_fn = build_hash_wrapper(env, layout_ids, key_layout);

View File

@ -120,7 +120,7 @@ fn hash_builtin<'a, 'ctx, 'env>(
builtin: &Builtin<'a>,
when_recursive: WhenRecursive<'a>,
) -> IntValue<'ctx> {
let ptr_bytes = env.ptr_bytes;
let ptr_bytes = env.target_info;
match builtin {
Builtin::Int(_) | Builtin::Float(_) | Builtin::Bool | Builtin::Decimal => {
@ -246,7 +246,7 @@ fn hash_struct<'a, 'ctx, 'env>(
when_recursive: WhenRecursive<'a>,
field_layouts: &[Layout<'a>],
) -> IntValue<'ctx> {
let ptr_bytes = env.ptr_bytes;
let ptr_bytes = env.target_info;
let layout = Layout::Struct(field_layouts);
@ -423,7 +423,7 @@ fn hash_tag<'a, 'ctx, 'env>(
env,
seed,
hash_bytes,
tag_id_layout.stack_size(env.ptr_bytes),
tag_id_layout.stack_size(env.target_info),
);
// hash the tag data
@ -474,7 +474,7 @@ fn hash_tag<'a, 'ctx, 'env>(
env,
seed,
hash_bytes,
tag_id_layout.stack_size(env.ptr_bytes),
tag_id_layout.stack_size(env.target_info),
);
// hash the tag data
@ -574,7 +574,7 @@ fn hash_tag<'a, 'ctx, 'env>(
env,
seed,
hash_bytes,
tag_id_layout.stack_size(env.ptr_bytes),
tag_id_layout.stack_size(env.target_info),
);
// hash tag data

View File

@ -87,7 +87,7 @@ pub fn layout_width<'a, 'ctx, 'env>(
layout: &Layout<'a>,
) -> BasicValueEnum<'ctx> {
env.ptr_int()
.const_int(layout.stack_size(env.ptr_bytes) as u64, false)
.const_int(layout.stack_size(env.target_info) as u64, false)
.into()
}
@ -1254,17 +1254,17 @@ pub fn allocate_list<'a, 'ctx, 'env>(
let ctx = env.context;
let len_type = env.ptr_int();
let elem_bytes = elem_layout.stack_size(env.ptr_bytes) as u64;
let elem_bytes = elem_layout.stack_size(env.target_info) as u64;
let bytes_per_element = len_type.const_int(elem_bytes, false);
let number_of_data_bytes =
builder.build_int_mul(bytes_per_element, number_of_elements, "data_length");
// the refcount of a new list is initially 1
// we assume that the list is indeed used (dead variables are eliminated)
let rc1 = crate::llvm::refcounting::refcount_1(ctx, env.ptr_bytes);
let rc1 = crate::llvm::refcounting::refcount_1(ctx, env.target_info);
let basic_type = basic_type_from_layout(env, elem_layout);
let alignment_bytes = elem_layout.alignment_bytes(env.ptr_bytes);
let alignment_bytes = elem_layout.alignment_bytes(env.target_info);
allocate_with_refcount_help(env, basic_type, alignment_bytes, number_of_data_bytes, rc1)
}

View File

@ -79,7 +79,7 @@ fn str_symbol_to_c_abi<'a, 'ctx, 'env>(
) -> IntValue<'ctx> {
let string = load_symbol(scope, &symbol);
let target_type = match env.ptr_bytes {
let target_type = match env.target_info {
8 => env.context.i128_type().into(),
4 => env.context.i64_type().into(),
_ => unreachable!(),
@ -96,7 +96,7 @@ pub fn str_to_c_abi<'a, 'ctx, 'env>(
env.builder.build_store(cell, value);
let target_type = match env.ptr_bytes {
let target_type = match env.target_info {
8 => env.context.i128_type(),
4 => env.context.i64_type(),
_ => unreachable!(),
@ -310,7 +310,7 @@ fn decode_from_utf8_result<'a, 'ctx, 'env>(
let builder = env.builder;
let ctx = env.context;
let fields = match env.ptr_bytes {
let fields = match env.target_info {
8 | 4 => [
env.ptr_int().into(),
super::convert::zig_str_type(env).into(),
@ -322,7 +322,7 @@ fn decode_from_utf8_result<'a, 'ctx, 'env>(
let record_type = env.context.struct_type(&fields, false);
match env.ptr_bytes {
match env.target_info {
8 | 4 => {
let result_ptr_cast = env
.builder

View File

@ -36,7 +36,7 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
match union_layout {
NonRecursive(tags) => {
let data = block_of_memory_slices(env.context, tags, env.ptr_bytes);
let data = block_of_memory_slices(env.context, tags, env.target_info);
env.context.struct_type(&[data, tag_id_type], false).into()
}
@ -44,9 +44,9 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
| NullableWrapped {
other_tags: tags, ..
} => {
let data = block_of_memory_slices(env.context, tags, env.ptr_bytes);
let data = block_of_memory_slices(env.context, tags, env.target_info);
if union_layout.stores_tag_id_as_data(env.ptr_bytes) {
if union_layout.stores_tag_id_as_data(env.target_info) {
env.context
.struct_type(&[data, tag_id_type], false)
.ptr_type(AddressSpace::Generic)
@ -56,11 +56,12 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
}
}
NullableUnwrapped { other_fields, .. } => {
let block = block_of_memory_slices(env.context, &[other_fields], env.ptr_bytes);
let block =
block_of_memory_slices(env.context, &[other_fields], env.target_info);
block.ptr_type(AddressSpace::Generic).into()
}
NonNullableUnwrapped(fields) => {
let block = block_of_memory_slices(env.context, &[fields], env.ptr_bytes);
let block = block_of_memory_slices(env.context, &[fields], env.target_info);
block.ptr_type(AddressSpace::Generic).into()
}
}
@ -95,7 +96,7 @@ pub fn basic_type_from_layout_1<'a, 'ctx, 'env>(
match union_layout {
NonRecursive(tags) => {
let data = block_of_memory_slices(env.context, tags, env.ptr_bytes);
let data = block_of_memory_slices(env.context, tags, env.target_info);
let struct_type = env.context.struct_type(&[data, tag_id_type], false);
struct_type.ptr_type(AddressSpace::Generic).into()
@ -104,9 +105,9 @@ pub fn basic_type_from_layout_1<'a, 'ctx, 'env>(
| NullableWrapped {
other_tags: tags, ..
} => {
let data = block_of_memory_slices(env.context, tags, env.ptr_bytes);
let data = block_of_memory_slices(env.context, tags, env.target_info);
if union_layout.stores_tag_id_as_data(env.ptr_bytes) {
if union_layout.stores_tag_id_as_data(env.target_info) {
env.context
.struct_type(&[data, tag_id_type], false)
.ptr_type(AddressSpace::Generic)
@ -116,11 +117,12 @@ pub fn basic_type_from_layout_1<'a, 'ctx, 'env>(
}
}
NullableUnwrapped { other_fields, .. } => {
let block = block_of_memory_slices(env.context, &[other_fields], env.ptr_bytes);
let block =
block_of_memory_slices(env.context, &[other_fields], env.target_info);
block.ptr_type(AddressSpace::Generic).into()
}
NonNullableUnwrapped(fields) => {
let block = block_of_memory_slices(env.context, &[fields], env.ptr_bytes);
let block = block_of_memory_slices(env.context, &[fields], env.target_info);
block.ptr_type(AddressSpace::Generic).into()
}
}

View File

@ -175,7 +175,7 @@ pub fn add_sjlj_roc_panic(env: &Env<'_, '_, '_>) {
let buffer = crate::llvm::build::get_sjlj_buffer(env);
// write our error message pointer
let index = env.ptr_int().const_int(3 * env.ptr_bytes as u64, false);
let index = env.ptr_int().const_int(3 * env.target_info as u64, false);
let message_buffer_raw =
unsafe { builder.build_gep(buffer, &[index], "raw_msg_buffer_ptr") };
let message_buffer = builder.build_bitcast(

View File

@ -98,7 +98,7 @@ impl<'ctx> PointerToRefcount<'ctx> {
pub fn is_1<'a, 'env>(&self, env: &Env<'a, 'ctx, 'env>) -> IntValue<'ctx> {
let current = self.get_refcount(env);
let one = refcount_1(env.context, env.ptr_bytes);
let one = refcount_1(env.context, env.target_info);
env.builder
.build_int_compare(IntPredicate::EQ, current, one, "is_one")
@ -163,8 +163,8 @@ impl<'ctx> PointerToRefcount<'ctx> {
pub fn decrement<'a, 'env>(&self, env: &Env<'a, 'ctx, 'env>, layout: &Layout<'a>) {
let alignment = layout
.allocation_alignment_bytes(env.ptr_bytes)
.max(env.ptr_bytes);
.allocation_alignment_bytes(env.target_info)
.max(env.target_info);
let context = env.context;
let block = env.builder.get_insert_block().expect("to be in a function");
@ -1192,7 +1192,7 @@ fn build_rec_union_help<'a, 'ctx, 'env>(
debug_assert!(arg_val.is_pointer_value());
let current_tag_id = get_tag_id(env, fn_val, &union_layout, arg_val);
let value_ptr = if union_layout.stores_tag_id_in_pointer(env.ptr_bytes) {
let value_ptr = if union_layout.stores_tag_id_in_pointer(env.target_info) {
tag_pointer_clear_tag_id(env, arg_val.into_pointer_value())
} else {
arg_val.into_pointer_value()

View File

@ -3824,7 +3824,7 @@ fn make_specializations<'a>(
subs: &mut subs,
home,
ident_ids: &mut ident_ids,
ptr_bytes,
target_info: ptr_bytes,
update_mode_ids: &mut update_mode_ids,
// call_specialization_counter=0 is reserved
call_specialization_counter: 1,
@ -3920,7 +3920,7 @@ fn build_pending_specializations<'a>(
subs: &mut subs,
home,
ident_ids: &mut ident_ids,
ptr_bytes,
target_info: ptr_bytes,
update_mode_ids: &mut update_mode_ids,
// call_specialization_counter=0 is reserved
call_specialization_counter: 1,

View File

@ -1071,7 +1071,7 @@ pub struct Env<'a, 'i> {
pub problems: &'i mut std::vec::Vec<MonoProblem>,
pub home: ModuleId,
pub ident_ids: &'i mut IdentIds,
pub ptr_bytes: u32,
pub target_info: u32,
pub update_mode_ids: &'i mut UpdateModeIds,
pub call_specialization_counter: u32,
}
@ -2471,7 +2471,7 @@ fn specialize_external<'a>(
env.arena,
);
let ptr_bytes = env.ptr_bytes;
let ptr_bytes = env.target_info;
combined.sort_by(|(_, layout1), (_, layout2)| {
let size1 = layout1.alignment_bytes(ptr_bytes);
@ -2504,7 +2504,7 @@ fn specialize_external<'a>(
env.arena,
);
let ptr_bytes = env.ptr_bytes;
let ptr_bytes = env.target_info;
combined.sort_by(|(_, layout1), (_, layout2)| {
let size1 = layout1.alignment_bytes(ptr_bytes);
@ -3009,14 +3009,14 @@ fn try_make_literal<'a>(
match can_expr {
Int(_, precision, _, int) => {
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, *precision, false) {
match num_argument_to_int_or_float(env.subs, env.target_info, *precision, false) {
IntOrFloat::Int(_) => Some(Literal::Int(*int)),
_ => unreachable!("unexpected float precision for integer"),
}
}
Float(_, precision, float_str, float) => {
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, *precision, true) {
match num_argument_to_int_or_float(env.subs, env.target_info, *precision, true) {
IntOrFloat::Float(_) => Some(Literal::Float(*float)),
IntOrFloat::DecimalFloatType => {
let dec = match RocDec::from_str(float_str) {
@ -3037,7 +3037,7 @@ fn try_make_literal<'a>(
// Str(string) => Some(Literal::Str(env.arena.alloc(string))),
Num(var, num_str, num) => {
// first figure out what kind of number this is
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, *var, false) {
match num_argument_to_int_or_float(env.subs, env.target_info, *var, false) {
IntOrFloat::Int(_) => Some(Literal::Int((*num).into())),
IntOrFloat::Float(_) => Some(Literal::Float(*num as f64)),
IntOrFloat::DecimalFloatType => {
@ -3072,7 +3072,7 @@ pub fn with_hole<'a>(
match can_expr {
Int(_, precision, _, int) => {
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, precision, false) {
match num_argument_to_int_or_float(env.subs, env.target_info, precision, false) {
IntOrFloat::Int(precision) => Stmt::Let(
assigned,
Expr::Literal(Literal::Int(int)),
@ -3084,7 +3084,7 @@ pub fn with_hole<'a>(
}
Float(_, precision, float_str, float) => {
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, precision, true) {
match num_argument_to_int_or_float(env.subs, env.target_info, precision, true) {
IntOrFloat::Float(precision) => Stmt::Let(
assigned,
Expr::Literal(Literal::Float(float)),
@ -3116,7 +3116,7 @@ pub fn with_hole<'a>(
Num(var, num_str, num) => {
// first figure out what kind of number this is
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, var, false) {
match num_argument_to_int_or_float(env.subs, env.target_info, var, false) {
IntOrFloat::Int(precision) => Stmt::Let(
assigned,
Expr::Literal(Literal::Int(num.into())),
@ -3393,7 +3393,7 @@ pub fn with_hole<'a>(
env.arena,
record_var,
env.subs,
env.ptr_bytes,
env.target_info,
) {
Ok(fields) => fields,
Err(_) => return Stmt::RuntimeError("Can't create record with improper layout"),
@ -3754,7 +3754,7 @@ pub fn with_hole<'a>(
env.arena,
record_var,
env.subs,
env.ptr_bytes,
env.target_info,
) {
Ok(fields) => fields,
Err(_) => return Stmt::RuntimeError("Can't access record with improper layout"),
@ -3911,7 +3911,7 @@ pub fn with_hole<'a>(
env.arena,
record_var,
env.subs,
env.ptr_bytes,
env.target_info,
) {
Ok(fields) => fields,
Err(_) => return Stmt::RuntimeError("Can't update record with improper layout"),
@ -4586,7 +4586,7 @@ fn construct_closure_data<'a>(
env.arena,
);
let ptr_bytes = env.ptr_bytes;
let ptr_bytes = env.target_info;
combined.sort_by(|(_, layout1), (_, layout2)| {
let size1 = layout1.alignment_bytes(ptr_bytes);
@ -4617,7 +4617,7 @@ fn construct_closure_data<'a>(
env.arena,
);
let ptr_bytes = env.ptr_bytes;
let ptr_bytes = env.target_info;
combined.sort_by(|(_, layout1), (_, layout2)| {
let size1 = layout1.alignment_bytes(ptr_bytes);
@ -4692,7 +4692,7 @@ fn convert_tag_union<'a>(
) -> Stmt<'a> {
use crate::layout::UnionVariant::*;
let res_variant =
crate::layout::union_sorted_tags(env.arena, variant_var, env.subs, env.ptr_bytes);
crate::layout::union_sorted_tags(env.arena, variant_var, env.subs, env.target_info);
let variant = match res_variant {
Ok(cached) => cached,
Err(LayoutProblem::UnresolvedTypeVar(_)) => {
@ -5035,7 +5035,7 @@ fn sorted_field_symbols<'a>(
}
};
let alignment = layout.alignment_bytes(env.ptr_bytes);
let alignment = layout.alignment_bytes(env.target_info);
let symbol = possible_reuse_symbol(env, procs, &arg.value);
field_symbols_temp.push((alignment, symbol, ((var, arg), &*env.arena.alloc(symbol))));
@ -5120,7 +5120,7 @@ fn register_capturing_closure<'a>(
let captured_symbols = match *env.subs.get_content_without_compacting(function_type) {
Content::Structure(FlatType::Func(_, closure_var, _)) => {
match LambdaSet::from_var(env.arena, env.subs, closure_var, env.ptr_bytes) {
match LambdaSet::from_var(env.arena, env.subs, closure_var, env.target_info) {
Ok(lambda_set) => {
if let Layout::Struct(&[]) = lambda_set.runtime_representation() {
CapturedSymbols::None
@ -7621,7 +7621,7 @@ fn from_can_pattern_help<'a>(
Underscore => Ok(Pattern::Underscore),
Identifier(symbol) => Ok(Pattern::Identifier(*symbol)),
IntLiteral(var, _, int) => {
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, *var, false) {
match num_argument_to_int_or_float(env.subs, env.target_info, *var, false) {
IntOrFloat::Int(precision) => Ok(Pattern::IntLiteral(*int as i128, precision)),
other => {
panic!(
@ -7633,7 +7633,7 @@ fn from_can_pattern_help<'a>(
}
FloatLiteral(var, float_str, float) => {
// TODO: Can I reuse num_argument_to_int_or_float here if I pass in true?
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, *var, true) {
match num_argument_to_int_or_float(env.subs, env.target_info, *var, true) {
IntOrFloat::Int(_) => {
panic!("Invalid precision for float pattern {:?}", var)
}
@ -7663,7 +7663,7 @@ fn from_can_pattern_help<'a>(
Err(RuntimeError::UnsupportedPattern(*region))
}
NumLiteral(var, num_str, num) => {
match num_argument_to_int_or_float(env.subs, env.ptr_bytes, *var, false) {
match num_argument_to_int_or_float(env.subs, env.target_info, *var, false) {
IntOrFloat::Int(precision) => Ok(Pattern::IntLiteral(*num as i128, precision)),
IntOrFloat::Float(precision) => Ok(Pattern::FloatLiteral(*num as u64, precision)),
IntOrFloat::DecimalFloatType => {
@ -7686,7 +7686,7 @@ fn from_can_pattern_help<'a>(
use crate::layout::UnionVariant::*;
let res_variant =
crate::layout::union_sorted_tags(env.arena, *whole_var, env.subs, env.ptr_bytes)
crate::layout::union_sorted_tags(env.arena, *whole_var, env.subs, env.target_info)
.map_err(Into::into);
let variant = match res_variant {
@ -7768,12 +7768,12 @@ fn from_can_pattern_help<'a>(
arguments.sort_by(|arg1, arg2| {
let size1 = layout_cache
.from_var(env.arena, arg1.0, env.subs)
.map(|x| x.alignment_bytes(env.ptr_bytes))
.map(|x| x.alignment_bytes(env.target_info))
.unwrap_or(0);
let size2 = layout_cache
.from_var(env.arena, arg2.0, env.subs)
.map(|x| x.alignment_bytes(env.ptr_bytes))
.map(|x| x.alignment_bytes(env.target_info))
.unwrap_or(0);
size2.cmp(&size1)
@ -7806,8 +7806,8 @@ fn from_can_pattern_help<'a>(
let layout2 =
layout_cache.from_var(env.arena, arg2.0, env.subs).unwrap();
let size1 = layout1.alignment_bytes(env.ptr_bytes);
let size2 = layout2.alignment_bytes(env.ptr_bytes);
let size1 = layout1.alignment_bytes(env.target_info);
let size2 = layout2.alignment_bytes(env.target_info);
size2.cmp(&size1)
});
@ -8107,7 +8107,7 @@ fn from_can_pattern_help<'a>(
} => {
// sorted fields based on the type
let sorted_fields =
crate::layout::sort_record_fields(env.arena, *whole_var, env.subs, env.ptr_bytes)
crate::layout::sort_record_fields(env.arena, *whole_var, env.subs, env.target_info)
.map_err(RuntimeError::from)?;
// sorted fields based on the destruct

View File

@ -213,7 +213,7 @@ fn create_llvm_module<'a>(
context,
interns,
module,
ptr_bytes,
target_info: ptr_bytes,
is_gen_test,
// important! we don't want any procedures to get the C calling convention
exposed_to_host: MutSet::default(),

View File

@ -105,7 +105,7 @@ mod test_reporting {
home,
ident_ids: &mut ident_ids,
update_mode_ids: &mut update_mode_ids,
ptr_bytes,
target_info: ptr_bytes,
// call_specialization_counter=0 is reserved
call_specialization_counter: 1,
};