mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
setup before zig work
This commit is contained in:
parent
8e36b5797b
commit
ac001598e8
6 changed files with 116 additions and 30 deletions
|
@ -1,7 +1,7 @@
|
|||
#![allow(clippy::too_many_arguments)]
|
||||
use crate::llvm::bitcode::{
|
||||
build_dec_wrapper, build_eq_wrapper, build_inc_wrapper, build_transform_caller,
|
||||
call_bitcode_fn, call_void_bitcode_fn,
|
||||
build_compare_wrapper, build_dec_wrapper, build_eq_wrapper, build_inc_wrapper,
|
||||
build_transform_caller, call_bitcode_fn, call_void_bitcode_fn,
|
||||
};
|
||||
use crate::llvm::build::{
|
||||
allocate_with_refcount_help, cast_basic_basic, complex_bitcast, Env, InPlace,
|
||||
|
@ -1141,40 +1141,23 @@ pub fn list_sort_with<'a, 'ctx, 'env>(
|
|||
list: BasicValueEnum<'ctx>,
|
||||
element_layout: &Layout<'a>,
|
||||
) -> BasicValueEnum<'ctx> {
|
||||
// TODO: decide between returning void pointer or u8 from function passed in.
|
||||
// TODO: implement soriting in zig
|
||||
let builder = env.builder;
|
||||
|
||||
let return_layout = match transform_layout {
|
||||
Layout::FunctionPointer(_, ret) => ret,
|
||||
Layout::Closure(_, _, ret) => ret,
|
||||
_ => unreachable!("not a callable layout"),
|
||||
};
|
||||
|
||||
let u8_ptr = env.context.i8_type().ptr_type(AddressSpace::Generic);
|
||||
let u9_ptr = env.context.i8_type().ptr_type(AddressSpace::Generic);
|
||||
|
||||
let list_i128 = complex_bitcast(env.builder, list, env.context.i128_type().into(), "to_i128");
|
||||
|
||||
let transform_ptr = builder.build_alloca(transform.get_type(), "transform_ptr");
|
||||
env.builder.build_store(transform_ptr, transform);
|
||||
|
||||
let stepper_caller = build_transform_caller(
|
||||
env,
|
||||
layout_ids,
|
||||
transform_layout,
|
||||
&[*element_layout, *element_layout],
|
||||
)
|
||||
.as_global_value()
|
||||
.as_pointer_value();
|
||||
let compare_wrapper = build_compare_wrapper(env, layout_ids, element_layout)
|
||||
.as_global_value()
|
||||
.as_pointer_value();
|
||||
|
||||
let old_element_width = env
|
||||
let element_width = env
|
||||
.ptr_int()
|
||||
.const_int(element_layout.stack_size(env.ptr_bytes) as u64, false);
|
||||
|
||||
let new_element_width = env
|
||||
.ptr_int()
|
||||
.const_int(return_layout.stack_size(env.ptr_bytes) as u64, false);
|
||||
|
||||
let alignment = element_layout.alignment_bytes(env.ptr_bytes);
|
||||
let alignment_iv = env.ptr_int().const_int(alignment as u64, false);
|
||||
|
||||
|
@ -1184,10 +1167,9 @@ pub fn list_sort_with<'a, 'ctx, 'env>(
|
|||
list_i128,
|
||||
env.builder
|
||||
.build_bitcast(transform_ptr, u8_ptr, "to_opaque"),
|
||||
stepper_caller.into(),
|
||||
compare_wrapper.into(),
|
||||
alignment_iv.into(),
|
||||
old_element_width.into(),
|
||||
new_element_width.into(),
|
||||
element_width.into(),
|
||||
],
|
||||
bitcode::LIST_SORT_WITH,
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue