mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Push mutable layout interner through llvm backend
This commit is contained in:
parent
e4b5252e51
commit
512a1721ae
8 changed files with 1289 additions and 555 deletions
|
@ -14,7 +14,7 @@ use roc_builtins::bitcode;
|
|||
use roc_builtins::bitcode::{FloatWidth, IntWidth};
|
||||
use roc_intern::Interner;
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_mono::layout::{Builtin, InLayout, Layout, LayoutIds, UnionLayout};
|
||||
use roc_mono::layout::{Builtin, InLayout, Layout, LayoutIds, STLayoutInterner, UnionLayout};
|
||||
|
||||
use super::build::{load_roc_value, use_roc_value, BuilderExt};
|
||||
use super::convert::argument_type_from_union_layout;
|
||||
|
@ -22,6 +22,7 @@ use super::lowlevel::dec_binop_with_unchecked;
|
|||
|
||||
pub fn generic_eq<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
lhs_val: BasicValueEnum<'ctx>,
|
||||
rhs_val: BasicValueEnum<'ctx>,
|
||||
|
@ -30,6 +31,7 @@ pub fn generic_eq<'a, 'ctx, 'env>(
|
|||
) -> BasicValueEnum<'ctx> {
|
||||
build_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
|
@ -41,6 +43,7 @@ pub fn generic_eq<'a, 'ctx, 'env>(
|
|||
|
||||
pub fn generic_neq<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
lhs_val: BasicValueEnum<'ctx>,
|
||||
rhs_val: BasicValueEnum<'ctx>,
|
||||
|
@ -49,6 +52,7 @@ pub fn generic_neq<'a, 'ctx, 'env>(
|
|||
) -> BasicValueEnum<'ctx> {
|
||||
build_neq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
|
@ -60,6 +64,7 @@ pub fn generic_neq<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_eq_builtin<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
lhs_val: BasicValueEnum<'ctx>,
|
||||
rhs_val: BasicValueEnum<'ctx>,
|
||||
|
@ -125,6 +130,7 @@ fn build_eq_builtin<'a, 'ctx, 'env>(
|
|||
Builtin::Str => str_equal(env, lhs_val, rhs_val),
|
||||
Builtin::List(elem) => build_list_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
&Layout::Builtin(*builtin),
|
||||
*elem,
|
||||
|
@ -137,6 +143,7 @@ fn build_eq_builtin<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_eq<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
lhs_val: BasicValueEnum<'ctx>,
|
||||
rhs_val: BasicValueEnum<'ctx>,
|
||||
|
@ -144,8 +151,8 @@ fn build_eq<'a, 'ctx, 'env>(
|
|||
rhs_layout: &Layout<'a>,
|
||||
when_recursive: WhenRecursive<'a>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
let lhs_layout = &lhs_layout.runtime_representation(env.layout_interner);
|
||||
let rhs_layout = &rhs_layout.runtime_representation(env.layout_interner);
|
||||
let lhs_layout = &lhs_layout.runtime_representation(layout_interner);
|
||||
let rhs_layout = &rhs_layout.runtime_representation(layout_interner);
|
||||
if lhs_layout != rhs_layout {
|
||||
panic!(
|
||||
"Equality of different layouts; did you have a type mismatch?\n{:?} == {:?}",
|
||||
|
@ -154,12 +161,19 @@ fn build_eq<'a, 'ctx, 'env>(
|
|||
}
|
||||
|
||||
match lhs_layout {
|
||||
Layout::Builtin(builtin) => {
|
||||
build_eq_builtin(env, layout_ids, lhs_val, rhs_val, builtin, when_recursive)
|
||||
}
|
||||
Layout::Builtin(builtin) => build_eq_builtin(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
builtin,
|
||||
when_recursive,
|
||||
),
|
||||
|
||||
Layout::Struct { field_layouts, .. } => build_struct_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
field_layouts,
|
||||
when_recursive,
|
||||
|
@ -171,6 +185,7 @@ fn build_eq<'a, 'ctx, 'env>(
|
|||
|
||||
Layout::Union(union_layout) => build_tag_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
when_recursive,
|
||||
union_layout,
|
||||
|
@ -180,6 +195,7 @@ fn build_eq<'a, 'ctx, 'env>(
|
|||
|
||||
Layout::Boxed(inner_layout) => build_box_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
when_recursive,
|
||||
lhs_layout,
|
||||
|
@ -196,7 +212,7 @@ fn build_eq<'a, 'ctx, 'env>(
|
|||
WhenRecursive::Loop(union_layout) => {
|
||||
let layout = Layout::Union(union_layout);
|
||||
|
||||
let bt = basic_type_from_layout(env, &layout);
|
||||
let bt = basic_type_from_layout(env, layout_interner, &layout);
|
||||
|
||||
// cast the i64 pointer to a pointer to block of memory
|
||||
let field1_cast = env.builder.build_pointer_cast(
|
||||
|
@ -213,6 +229,7 @@ fn build_eq<'a, 'ctx, 'env>(
|
|||
|
||||
build_tag_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
WhenRecursive::Loop(union_layout),
|
||||
&union_layout,
|
||||
|
@ -226,6 +243,7 @@ fn build_eq<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_neq_builtin<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
lhs_val: BasicValueEnum<'ctx>,
|
||||
rhs_val: BasicValueEnum<'ctx>,
|
||||
|
@ -297,6 +315,7 @@ fn build_neq_builtin<'a, 'ctx, 'env>(
|
|||
Builtin::List(elem) => {
|
||||
let is_equal = build_list_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
&Layout::Builtin(*builtin),
|
||||
*elem,
|
||||
|
@ -315,6 +334,7 @@ fn build_neq_builtin<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_neq<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
lhs_val: BasicValueEnum<'ctx>,
|
||||
rhs_val: BasicValueEnum<'ctx>,
|
||||
|
@ -330,13 +350,20 @@ fn build_neq<'a, 'ctx, 'env>(
|
|||
}
|
||||
|
||||
match lhs_layout {
|
||||
Layout::Builtin(builtin) => {
|
||||
build_neq_builtin(env, layout_ids, lhs_val, rhs_val, builtin, when_recursive)
|
||||
}
|
||||
Layout::Builtin(builtin) => build_neq_builtin(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
lhs_val,
|
||||
rhs_val,
|
||||
builtin,
|
||||
when_recursive,
|
||||
),
|
||||
|
||||
Layout::Struct { field_layouts, .. } => {
|
||||
let is_equal = build_struct_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
field_layouts,
|
||||
when_recursive,
|
||||
|
@ -353,6 +380,7 @@ fn build_neq<'a, 'ctx, 'env>(
|
|||
Layout::Union(union_layout) => {
|
||||
let is_equal = build_tag_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
when_recursive,
|
||||
union_layout,
|
||||
|
@ -369,6 +397,7 @@ fn build_neq<'a, 'ctx, 'env>(
|
|||
Layout::Boxed(inner_layout) => {
|
||||
let is_equal = build_box_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
when_recursive,
|
||||
lhs_layout,
|
||||
|
@ -392,6 +421,7 @@ fn build_neq<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_list_eq<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
list_layout: &Layout<'a>,
|
||||
element_layout: InLayout<'a>,
|
||||
|
@ -403,7 +433,7 @@ fn build_list_eq<'a, 'ctx, 'env>(
|
|||
let di_location = env.builder.get_current_debug_location().unwrap();
|
||||
|
||||
let symbol = Symbol::LIST_EQ;
|
||||
let element_layout = env.layout_interner.get(element_layout);
|
||||
let element_layout = layout_interner.get(element_layout);
|
||||
let element_layout = when_recursive.unwrap_recursive_pointer(*element_layout);
|
||||
let fn_name = layout_ids
|
||||
.get(symbol, &element_layout)
|
||||
|
@ -412,7 +442,7 @@ fn build_list_eq<'a, 'ctx, 'env>(
|
|||
let function = match env.module.get_function(fn_name.as_str()) {
|
||||
Some(function_value) => function_value,
|
||||
None => {
|
||||
let arg_type = basic_type_from_layout(env, list_layout);
|
||||
let arg_type = basic_type_from_layout(env, layout_interner, list_layout);
|
||||
|
||||
let function_value = crate::llvm::refcounting::build_header_help(
|
||||
env,
|
||||
|
@ -423,6 +453,7 @@ fn build_list_eq<'a, 'ctx, 'env>(
|
|||
|
||||
build_list_eq_help(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
when_recursive,
|
||||
function_value,
|
||||
|
@ -447,6 +478,7 @@ fn build_list_eq<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_list_eq_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
when_recursive: WhenRecursive<'a>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
|
@ -509,7 +541,7 @@ fn build_list_eq_help<'a, 'ctx, 'env>(
|
|||
env.builder.position_at_end(then_block);
|
||||
|
||||
let builder = env.builder;
|
||||
let element_type = basic_type_from_layout(env, element_layout);
|
||||
let element_type = basic_type_from_layout(env, layout_interner, element_layout);
|
||||
let ptr_type = element_type.ptr_type(AddressSpace::Generic);
|
||||
let ptr1 = load_list_ptr(env.builder, list1, ptr_type);
|
||||
let ptr2 = load_list_ptr(env.builder, list2, ptr_type);
|
||||
|
@ -549,18 +581,19 @@ fn build_list_eq_help<'a, 'ctx, 'env>(
|
|||
let elem_ptr = unsafe {
|
||||
builder.new_build_in_bounds_gep(element_type, ptr1, &[curr_index], "load_index")
|
||||
};
|
||||
load_roc_value(env, *element_layout, elem_ptr, "get_elem")
|
||||
load_roc_value(env, layout_interner, *element_layout, elem_ptr, "get_elem")
|
||||
};
|
||||
|
||||
let elem2 = {
|
||||
let elem_ptr = unsafe {
|
||||
builder.new_build_in_bounds_gep(element_type, ptr2, &[curr_index], "load_index")
|
||||
};
|
||||
load_roc_value(env, *element_layout, elem_ptr, "get_elem")
|
||||
load_roc_value(env, layout_interner, *element_layout, elem_ptr, "get_elem")
|
||||
};
|
||||
|
||||
let are_equal = build_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
elem1,
|
||||
elem2,
|
||||
|
@ -605,6 +638,7 @@ fn build_list_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_struct_eq<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
field_layouts: &'a [Layout<'a>],
|
||||
when_recursive: WhenRecursive<'a>,
|
||||
|
@ -624,7 +658,7 @@ fn build_struct_eq<'a, 'ctx, 'env>(
|
|||
let function = match env.module.get_function(fn_name.as_str()) {
|
||||
Some(function_value) => function_value,
|
||||
None => {
|
||||
let arg_type = basic_type_from_layout(env, &struct_layout);
|
||||
let arg_type = basic_type_from_layout(env, layout_interner, &struct_layout);
|
||||
|
||||
let function_value = crate::llvm::refcounting::build_header_help(
|
||||
env,
|
||||
|
@ -635,6 +669,7 @@ fn build_struct_eq<'a, 'ctx, 'env>(
|
|||
|
||||
build_struct_eq_help(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
function_value,
|
||||
when_recursive,
|
||||
|
@ -659,6 +694,7 @@ fn build_struct_eq<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_struct_eq_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
when_recursive: WhenRecursive<'a>,
|
||||
|
@ -727,7 +763,7 @@ fn build_struct_eq_help<'a, 'ctx, 'env>(
|
|||
WhenRecursive::Loop(union_layout) => {
|
||||
let field_layout = Layout::Union(*union_layout);
|
||||
|
||||
let bt = basic_type_from_layout(env, &field_layout);
|
||||
let bt = basic_type_from_layout(env, layout_interner, &field_layout);
|
||||
|
||||
// cast the i64 pointer to a pointer to block of memory
|
||||
let field1_cast = env.builder.build_pointer_cast(
|
||||
|
@ -744,6 +780,7 @@ fn build_struct_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
build_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
field1_cast.into(),
|
||||
field2_cast.into(),
|
||||
|
@ -755,11 +792,14 @@ fn build_struct_eq_help<'a, 'ctx, 'env>(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
let lhs = use_roc_value(env, layout_interner, *field_layout, field1, "field1");
|
||||
let rhs = use_roc_value(env, layout_interner, *field_layout, field2, "field2");
|
||||
build_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
use_roc_value(env, *field_layout, field1, "field1"),
|
||||
use_roc_value(env, *field_layout, field2, "field2"),
|
||||
lhs,
|
||||
rhs,
|
||||
field_layout,
|
||||
field_layout,
|
||||
when_recursive,
|
||||
|
@ -791,6 +831,7 @@ fn build_struct_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_tag_eq<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
when_recursive: WhenRecursive<'a>,
|
||||
union_layout: &UnionLayout<'a>,
|
||||
|
@ -809,7 +850,7 @@ fn build_tag_eq<'a, 'ctx, 'env>(
|
|||
let function = match env.module.get_function(fn_name.as_str()) {
|
||||
Some(function_value) => function_value,
|
||||
None => {
|
||||
let arg_type = argument_type_from_union_layout(env, union_layout);
|
||||
let arg_type = argument_type_from_union_layout(env, layout_interner, union_layout);
|
||||
|
||||
let function_value = crate::llvm::refcounting::build_header_help(
|
||||
env,
|
||||
|
@ -820,6 +861,7 @@ fn build_tag_eq<'a, 'ctx, 'env>(
|
|||
|
||||
build_tag_eq_help(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
when_recursive,
|
||||
function_value,
|
||||
|
@ -844,6 +886,7 @@ fn build_tag_eq<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_tag_eq_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
when_recursive: WhenRecursive<'a>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
|
@ -924,8 +967,8 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
env.builder.position_at_end(compare_tag_ids);
|
||||
|
||||
let id1 = get_tag_id(env, parent, union_layout, tag1);
|
||||
let id2 = get_tag_id(env, parent, union_layout, tag2);
|
||||
let id1 = get_tag_id(env, layout_interner, parent, union_layout, tag1);
|
||||
let id2 = get_tag_id(env, layout_interner, parent, union_layout, tag2);
|
||||
|
||||
// clear the tag_id so we get a pointer to the actual data
|
||||
let tag1 = tag1.into_pointer_value();
|
||||
|
@ -952,6 +995,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
union_layout,
|
||||
Some(when_recursive),
|
||||
|
@ -994,8 +1038,8 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
env.builder.position_at_end(compare_tag_ids);
|
||||
|
||||
let id1 = get_tag_id(env, parent, union_layout, tag1);
|
||||
let id2 = get_tag_id(env, parent, union_layout, tag2);
|
||||
let id1 = get_tag_id(env, layout_interner, parent, union_layout, tag1);
|
||||
let id2 = get_tag_id(env, layout_interner, parent, union_layout, tag2);
|
||||
|
||||
// clear the tag_id so we get a pointer to the actual data
|
||||
let tag1 = tag_pointer_clear_tag_id(env, tag1.into_pointer_value());
|
||||
|
@ -1022,6 +1066,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
union_layout,
|
||||
None,
|
||||
|
@ -1082,6 +1127,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
union_layout,
|
||||
None,
|
||||
|
@ -1150,8 +1196,8 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
env.builder.position_at_end(compare_other);
|
||||
|
||||
let id1 = get_tag_id(env, parent, union_layout, tag1);
|
||||
let id2 = get_tag_id(env, parent, union_layout, tag2);
|
||||
let id1 = get_tag_id(env, layout_interner, parent, union_layout, tag1);
|
||||
let id2 = get_tag_id(env, layout_interner, parent, union_layout, tag2);
|
||||
|
||||
// clear the tag_id so we get a pointer to the actual data
|
||||
let tag1 = tag_pointer_clear_tag_id(env, tag1.into_pointer_value());
|
||||
|
@ -1179,6 +1225,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
union_layout,
|
||||
None,
|
||||
|
@ -1217,6 +1264,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
let answer = eq_ptr_to_struct(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
union_layout,
|
||||
None,
|
||||
|
@ -1232,6 +1280,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
|
|||
|
||||
fn eq_ptr_to_struct<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
union_layout: &UnionLayout<'a>,
|
||||
opt_when_recursive: Option<WhenRecursive<'a>>,
|
||||
|
@ -1241,7 +1290,7 @@ fn eq_ptr_to_struct<'a, 'ctx, 'env>(
|
|||
) -> IntValue<'ctx> {
|
||||
let struct_layout = Layout::struct_no_name_order(field_layouts);
|
||||
|
||||
let wrapper_type = basic_type_from_layout(env, &struct_layout);
|
||||
let wrapper_type = basic_type_from_layout(env, layout_interner, &struct_layout);
|
||||
debug_assert!(wrapper_type.is_struct_type());
|
||||
|
||||
// cast the opaque pointer to a pointer of the correct shape
|
||||
|
@ -1269,6 +1318,7 @@ fn eq_ptr_to_struct<'a, 'ctx, 'env>(
|
|||
|
||||
build_struct_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
field_layouts,
|
||||
opt_when_recursive.unwrap_or(WhenRecursive::Loop(*union_layout)),
|
||||
|
@ -1282,6 +1332,7 @@ fn eq_ptr_to_struct<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_box_eq<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
when_recursive: WhenRecursive<'a>,
|
||||
box_layout: &Layout<'a>,
|
||||
|
@ -1300,7 +1351,7 @@ fn build_box_eq<'a, 'ctx, 'env>(
|
|||
let function = match env.module.get_function(fn_name.as_str()) {
|
||||
Some(function_value) => function_value,
|
||||
None => {
|
||||
let arg_type = basic_type_from_layout(env, box_layout);
|
||||
let arg_type = basic_type_from_layout(env, layout_interner, box_layout);
|
||||
|
||||
let function_value = crate::llvm::refcounting::build_header_help(
|
||||
env,
|
||||
|
@ -1311,6 +1362,7 @@ fn build_box_eq<'a, 'ctx, 'env>(
|
|||
|
||||
build_box_eq_help(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
when_recursive,
|
||||
function_value,
|
||||
|
@ -1335,6 +1387,7 @@ fn build_box_eq<'a, 'ctx, 'env>(
|
|||
|
||||
fn build_box_eq_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
layout_interner: &mut STLayoutInterner<'a>,
|
||||
layout_ids: &mut LayoutIds<'a>,
|
||||
when_recursive: WhenRecursive<'a>,
|
||||
parent: FunctionValue<'ctx>,
|
||||
|
@ -1402,13 +1455,14 @@ fn build_box_eq_help<'a, 'ctx, 'env>(
|
|||
let box1 = box1.into_pointer_value();
|
||||
let box2 = box2.into_pointer_value();
|
||||
|
||||
let inner_layout = env.layout_interner.get(inner_layout);
|
||||
let inner_layout = layout_interner.get(inner_layout);
|
||||
|
||||
let value1 = load_roc_value(env, *inner_layout, box1, "load_box1");
|
||||
let value2 = load_roc_value(env, *inner_layout, box2, "load_box2");
|
||||
let value1 = load_roc_value(env, layout_interner, *inner_layout, box1, "load_box1");
|
||||
let value2 = load_roc_value(env, layout_interner, *inner_layout, box2, "load_box2");
|
||||
|
||||
let is_equal = build_eq(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_ids,
|
||||
value1,
|
||||
value2,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue