fix extra ampersands

This commit is contained in:
Folkert 2021-07-29 17:32:08 +02:00
parent b6116eeb98
commit 899cbeabd7
79 changed files with 372 additions and 376 deletions

View file

@ -78,7 +78,7 @@ pub fn build_has_tag_id<'a, 'ctx, 'env>(
match env.module.get_function(fn_name) {
Some(function_value) => function_value,
None => build_has_tag_id_help(env, union_layout, &fn_name),
None => build_has_tag_id_help(env, union_layout, fn_name),
}
}
@ -97,9 +97,9 @@ fn build_has_tag_id_help<'a, 'ctx, 'env>(
let function_value = crate::llvm::refcounting::build_header_help(
env,
&fn_name,
fn_name,
output_type.into(),
&argument_types,
argument_types,
);
// called from zig, must use C calling convention
@ -204,7 +204,7 @@ pub fn build_transform_caller<'a, 'ctx, 'env>(
function,
closure_data_layout,
argument_layouts,
&fn_name,
fn_name,
),
}
}
@ -225,7 +225,7 @@ fn build_transform_caller_help<'a, 'ctx, 'env>(
let function_value = crate::llvm::refcounting::build_header_help(
env,
&fn_name,
fn_name,
env.context.void_type().into(),
&(bumpalo::vec![ in env.arena; BasicTypeEnum::PointerType(arg_type); argument_layouts.len() + 2 ]),
);
@ -394,7 +394,7 @@ fn build_rc_wrapper<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_RC_REF;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let fn_name = match rc_operation {
@ -489,7 +489,7 @@ pub fn build_eq_wrapper<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_EQ_REF;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let function_value = match env.module.get_function(fn_name.as_str()) {
@ -576,7 +576,7 @@ pub fn build_compare_wrapper<'a, 'ctx, 'env>(
let function_value = crate::llvm::refcounting::build_header_help(
env,
&fn_name,
fn_name,
env.context.i8_type().into(),
&[arg_type.into(), arg_type.into(), arg_type.into()],
);

View file

@ -347,7 +347,7 @@ pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Modu
// we compile the builtins into LLVM bitcode
let bitcode_bytes: &[u8] = include_bytes!("../../../builtins/bitcode/builtins.bc");
let memory_buffer = MemoryBuffer::create_from_memory_range(&bitcode_bytes, module_name);
let memory_buffer = MemoryBuffer::create_from_memory_range(bitcode_bytes, module_name);
let module = Module::parse_bitcode_from_buffer(&memory_buffer, ctx)
.unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err));
@ -632,7 +632,7 @@ pub fn float_with_precision<'a, 'ctx, 'env>(
Builtin::Decimal => call_bitcode_fn(
env,
&[env.context.f64_type().const_float(value).into()],
&bitcode::DEC_FROM_F64,
bitcode::DEC_FROM_F64,
),
Builtin::Float64 => env.context.f64_type().const_float(value).into(),
Builtin::Float32 => env.context.f32_type().const_float(value).into(),
@ -976,7 +976,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
// The layout of the struct expects them to be dropped!
let (field_expr, field_layout) = load_symbol_and_layout(scope, symbol);
if !field_layout.is_dropped_because_empty() {
field_types.push(basic_type_from_layout(env, &field_layout));
field_types.push(basic_type_from_layout(env, field_layout));
field_vals.push(field_expr);
}
@ -1187,7 +1187,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
)
}
UnionLayout::NonNullableUnwrapped(field_layouts) => {
let struct_layout = Layout::Struct(&field_layouts);
let struct_layout = Layout::Struct(field_layouts);
let struct_type = basic_type_from_layout(env, &struct_layout);
@ -1260,7 +1260,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
// cast the argument bytes into the desired shape for this tag
let (argument, _structure_layout) = load_symbol_and_layout(scope, structure);
get_tag_id(env, parent, &union_layout, argument).into()
get_tag_id(env, parent, union_layout, argument).into()
}
}
}
@ -1459,7 +1459,7 @@ pub fn build_tag<'a, 'ctx, 'env>(
union_layout,
tag_id,
arguments,
&tag_field_layouts,
tag_field_layouts,
tags,
reuse_allocation,
parent,
@ -1491,7 +1491,7 @@ pub fn build_tag<'a, 'ctx, 'env>(
union_layout,
tag_id,
arguments,
&tag_field_layouts,
tag_field_layouts,
tags,
reuse_allocation,
parent,
@ -2269,7 +2269,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
scope,
parent,
layout,
&expr,
expr,
);
// Make a new scope which includes the binding we just encountered.
@ -2399,7 +2399,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
cond_layout,
cond_symbol,
} => {
let ret_type = basic_type_from_layout(env, &ret_layout);
let ret_type = basic_type_from_layout(env, ret_layout);
let switch_args = SwitchArgsIr {
cond_layout: *cond_layout,
@ -2477,7 +2477,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
);
// remove this join point again
scope.join_points.remove(&id);
scope.join_points.remove(id);
cont_block.move_after(phi_block).unwrap();
@ -3121,7 +3121,7 @@ where
let call_result = {
let call = builder.build_invoke(
function,
&arguments,
arguments,
then_block,
catch_block,
"call_roc_function",
@ -3291,7 +3291,7 @@ fn make_exception_catching_wrapper<'a, 'ctx, 'env>(
// Add main to the module.
let wrapper_function = add_func(
env.module,
&wrapper_function_name,
wrapper_function_name,
wrapper_function_type,
Linkage::External,
C_CALL_CONV,
@ -3414,7 +3414,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
// Add all the Proc headers to the module.
// We have to do this in a separate pass first,
// because their bodies may reference each other.
let headers = build_proc_headers(env, &mod_solutions, procedures, &mut scope);
let headers = build_proc_headers(env, mod_solutions, procedures, &mut scope);
let (_, function_pass) = construct_optimization_passes(env.module, opt_level);
@ -3428,7 +3428,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
current_scope.retain_top_level_thunks_for_module(home);
build_proc(
&env,
env,
mod_solutions,
&mut layout_ids,
func_spec_solutions,
@ -3441,7 +3441,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
env.dibuilder.finalize();
if fn_val.verify(true) {
function_pass.run_on(&fn_val);
function_pass.run_on(fn_val);
} else {
let mode = "NON-OPTIMIZED";
@ -3511,7 +3511,7 @@ fn build_proc_header<'a, 'ctx, 'env>(
let mut arg_basic_types = Vec::with_capacity_in(args.len(), arena);
for (layout, _) in args.iter() {
let arg_type = basic_type_from_layout(env, &layout);
let arg_type = basic_type_from_layout(env, layout);
arg_basic_types.push(arg_type);
}
@ -5426,7 +5426,7 @@ fn build_int_binop<'a, 'ctx, 'env>(
}
}
NumDivUnchecked => bd.build_int_signed_div(lhs, rhs, "div_int").into(),
NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], &bitcode::NUM_POW_INT),
NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], bitcode::NUM_POW_INT),
NumBitwiseAnd => bd.build_and(lhs, rhs, "int_bitwise_and").into(),
NumBitwiseXor => bd.build_xor(lhs, rhs, "int_bitwise_xor").into(),
NumBitwiseOr => bd.build_or(lhs, rhs, "int_bitwise_or").into(),
@ -5523,7 +5523,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_add(lhs, rhs, "add_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let then_block = context.append_basic_block(parent, "then_block");
let throw_block = context.append_basic_block(parent, "throw_block");
@ -5544,7 +5544,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_add(lhs, rhs, "add_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let is_infinite = bd.build_not(is_finite, "negate");
let struct_type = context.struct_type(
@ -5572,7 +5572,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_sub(lhs, rhs, "sub_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let then_block = context.append_basic_block(parent, "then_block");
let throw_block = context.append_basic_block(parent, "throw_block");
@ -5593,7 +5593,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_sub(lhs, rhs, "sub_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let is_infinite = bd.build_not(is_finite, "negate");
let struct_type = context.struct_type(
@ -5621,7 +5621,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_mul(lhs, rhs, "mul_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let then_block = context.append_basic_block(parent, "then_block");
let throw_block = context.append_basic_block(parent, "throw_block");
@ -5642,7 +5642,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_mul(lhs, rhs, "mul_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let is_infinite = bd.build_not(is_finite, "negate");
let struct_type = context.struct_type(
@ -5688,9 +5688,9 @@ fn build_dec_binop<'a, 'ctx, 'env>(
use roc_module::low_level::LowLevel::*;
match op {
NumAddChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_ADD_WITH_OVERFLOW),
NumSubChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_SUB_WITH_OVERFLOW),
NumMulChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_MUL_WITH_OVERFLOW),
NumAddChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_ADD_WITH_OVERFLOW),
NumSubChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_SUB_WITH_OVERFLOW),
NumMulChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_MUL_WITH_OVERFLOW),
NumAdd => build_dec_binop_throw_on_overflow(
env,
parent,
@ -5715,7 +5715,7 @@ fn build_dec_binop<'a, 'ctx, 'env>(
rhs,
"decimal multiplication overflowed",
),
NumDivUnchecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_DIV),
NumDivUnchecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_DIV),
_ => {
unreachable!("Unrecognized int binary operation: {:?}", op);
}
@ -5938,10 +5938,10 @@ fn build_float_unary_op<'a, 'ctx, 'env>(
env.context.i64_type(),
"num_floor",
),
NumIsFinite => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_IS_FINITE),
NumAtan => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ATAN),
NumAcos => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ACOS),
NumAsin => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ASIN),
NumIsFinite => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_IS_FINITE),
NumAtan => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ATAN),
NumAcos => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ACOS),
NumAsin => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ASIN),
_ => {
unreachable!("Unrecognized int unary operation: {:?}", op);
}
@ -6107,7 +6107,7 @@ fn cxa_allocate_exception<'a, 'ctx, 'env>(
let context = env.context;
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
let function = match module.get_function(&name) {
let function = match module.get_function(name) {
Some(gvalue) => gvalue,
None => {
// void *__cxa_allocate_exception(size_t thrown_size);
@ -6141,7 +6141,7 @@ fn cxa_throw_exception<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>, info: BasicVal
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
let function = match module.get_function(&name) {
let function = match module.get_function(name) {
Some(value) => value,
None => {
// void __cxa_throw (void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) );
@ -6207,7 +6207,7 @@ fn get_gxx_personality_v0<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> Function
let module = env.module;
let context = env.context;
match module.get_function(&name) {
match module.get_function(name) {
Some(gvalue) => gvalue,
None => {
let personality_func = add_func(
@ -6229,7 +6229,7 @@ fn cxa_end_catch(env: &Env<'_, '_, '_>) {
let module = env.module;
let context = env.context;
let function = match module.get_function(&name) {
let function = match module.get_function(name) {
Some(gvalue) => gvalue,
None => {
let cxa_end_catch = add_func(
@ -6257,7 +6257,7 @@ fn cxa_begin_catch<'a, 'ctx, 'env>(
let module = env.module;
let context = env.context;
let function = match module.get_function(&name) {
let function = match module.get_function(name) {
Some(gvalue) => gvalue,
None => {
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);

View file

@ -64,7 +64,7 @@ pub fn dict_len<'a, 'ctx, 'env>(
.build_alloca(dict_as_zig_dict.get_type(), "dict_ptr");
env.builder.build_store(dict_ptr, dict_as_zig_dict);
call_bitcode_fn(env, &[dict_ptr.into()], &bitcode::DICT_LEN)
call_bitcode_fn(env, &[dict_ptr.into()], bitcode::DICT_LEN)
}
Layout::Builtin(Builtin::EmptyDict) => ctx.i64_type().const_zero().into(),
_ => unreachable!("Invalid layout given to Dict.len : {:?}", dict_layout),
@ -78,7 +78,7 @@ pub fn dict_empty<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> BasicValueEnum<'
// we must give a pointer for the bitcode function to write the result into
let result_alloc = env.builder.build_alloca(roc_dict_type, "dict_empty");
call_void_bitcode_fn(env, &[result_alloc.into()], &bitcode::DICT_EMPTY);
call_void_bitcode_fn(env, &[result_alloc.into()], bitcode::DICT_EMPTY);
env.builder.build_load(result_alloc, "load_result")
}
@ -140,7 +140,7 @@ pub fn dict_insert<'a, 'ctx, 'env>(
dec_value_fn.as_global_value().as_pointer_value().into(),
result_ptr.into(),
],
&bitcode::DICT_INSERT,
bitcode::DICT_INSERT,
);
env.builder.build_load(result_ptr, "load_result")
@ -199,7 +199,7 @@ pub fn dict_remove<'a, 'ctx, 'env>(
dec_value_fn.as_global_value().as_pointer_value().into(),
result_ptr.into(),
],
&bitcode::DICT_REMOVE,
bitcode::DICT_REMOVE,
);
env.builder.build_load(result_ptr, "load_result")
@ -250,7 +250,7 @@ pub fn dict_contains<'a, 'ctx, 'env>(
hash_fn.as_global_value().as_pointer_value().into(),
eq_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::DICT_CONTAINS,
bitcode::DICT_CONTAINS,
)
}
@ -303,7 +303,7 @@ pub fn dict_get<'a, 'ctx, 'env>(
eq_fn.as_global_value().as_pointer_value().into(),
inc_value_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::DICT_GET,
bitcode::DICT_GET,
)
.into_struct_value();
@ -415,7 +415,7 @@ pub fn dict_elements_rc<'a, 'ctx, 'env>(
key_fn.as_global_value().as_pointer_value().into(),
value_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::DICT_ELEMENTS_RC,
bitcode::DICT_ELEMENTS_RC,
);
}
@ -460,7 +460,7 @@ pub fn dict_keys<'a, 'ctx, 'env>(
inc_key_fn.as_global_value().as_pointer_value().into(),
list_ptr.into(),
],
&bitcode::DICT_KEYS,
bitcode::DICT_KEYS,
);
let list_ptr = env
@ -527,7 +527,7 @@ pub fn dict_union<'a, 'ctx, 'env>(
inc_value_fn.as_global_value().as_pointer_value().into(),
output_ptr.into(),
],
&bitcode::DICT_UNION,
bitcode::DICT_UNION,
);
env.builder.build_load(output_ptr, "load_output_ptr")
@ -549,7 +549,7 @@ pub fn dict_difference<'a, 'ctx, 'env>(
dict2,
key_layout,
value_layout,
&bitcode::DICT_DIFFERENCE,
bitcode::DICT_DIFFERENCE,
)
}
@ -569,7 +569,7 @@ pub fn dict_intersection<'a, 'ctx, 'env>(
dict2,
key_layout,
value_layout,
&bitcode::DICT_INTERSECTION,
bitcode::DICT_INTERSECTION,
)
}
@ -674,7 +674,7 @@ pub fn dict_walk<'a, 'ctx, 'env>(
layout_width(env, accum_layout),
env.builder.build_bitcast(output_ptr, u8_ptr, "to_opaque"),
],
&bitcode::DICT_WALK,
bitcode::DICT_WALK,
);
env.builder.build_load(output_ptr, "load_output_ptr")
@ -721,7 +721,7 @@ pub fn dict_values<'a, 'ctx, 'env>(
inc_value_fn.as_global_value().as_pointer_value().into(),
list_ptr.into(),
],
&bitcode::DICT_VALUES,
bitcode::DICT_VALUES,
);
let list_ptr = env
@ -784,7 +784,7 @@ pub fn set_from_list<'a, 'ctx, 'env>(
dec_key_fn.as_global_value().as_pointer_value().into(),
result_alloca.into(),
],
&bitcode::SET_FROM_LIST,
bitcode::SET_FROM_LIST,
);
env.builder.build_load(result_alloca, "load_result")
@ -800,7 +800,7 @@ fn build_hash_wrapper<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_HASH_REF;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let function_value = match env.module.get_function(fn_name.as_str()) {
@ -867,7 +867,7 @@ fn dict_symbol_to_zig_dict<'a, 'ctx, 'env>(
let zig_dict_type = env.module.get_struct_type("dict.RocDict").unwrap();
complex_bitcast(&env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict")
complex_bitcast(env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict")
.into_struct_value()
}

View file

@ -130,7 +130,7 @@ fn hash_builtin<'a, 'ctx, 'env>(
| Builtin::Float16
| Builtin::Decimal
| Builtin::Usize => {
let hash_bytes = store_and_use_as_u8_ptr(env, val, &layout);
let hash_bytes = store_and_use_as_u8_ptr(env, val, layout);
hash_bitcode_fn(env, seed, hash_bytes, layout.stack_size(ptr_bytes))
}
Builtin::Str => {
@ -138,7 +138,7 @@ fn hash_builtin<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[seed.into(), build_str::str_to_i128(env, val).into()],
&bitcode::DICT_HASH_STR,
bitcode::DICT_HASH_STR,
)
.into_int_value()
}
@ -327,7 +327,7 @@ fn build_hash_tag<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_HASH;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let function = match env.module.get_function(fn_name.as_str()) {
@ -335,7 +335,7 @@ fn build_hash_tag<'a, 'ctx, 'env>(
None => {
let seed_type = env.context.i64_type();
let arg_type = basic_type_from_layout(env, &layout);
let arg_type = basic_type_from_layout(env, layout);
let function_value = crate::llvm::refcounting::build_header_help(
env,
@ -659,7 +659,7 @@ fn build_hash_list<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_HASH;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let function = match env.module.get_function(fn_name.as_str()) {
@ -667,7 +667,7 @@ fn build_hash_list<'a, 'ctx, 'env>(
None => {
let seed_type = env.context.i64_type();
let arg_type = basic_type_from_layout(env, &layout);
let arg_type = basic_type_from_layout(env, layout);
let function_value = crate::llvm::refcounting::build_header_help(
env,
@ -870,7 +870,7 @@ fn store_and_use_as_u8_ptr<'a, 'ctx, 'env>(
value: BasicValueEnum<'ctx>,
layout: &Layout<'a>,
) -> PointerValue<'ctx> {
let basic_type = basic_type_from_layout(env, &layout);
let basic_type = basic_type_from_layout(env, layout);
let alloc = env.builder.build_alloca(basic_type, "store");
env.builder.build_store(alloc, value);
@ -895,7 +895,7 @@ fn hash_bitcode_fn<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[seed.into(), buffer.into(), num_bytes.into()],
&bitcode::DICT_HASH,
bitcode::DICT_HASH,
)
.into_int_value()
}

View file

@ -94,7 +94,7 @@ pub fn list_single<'a, 'ctx, 'env>(
pass_element_as_opaque(env, element),
layout_width(env, element_layout),
],
&bitcode::LIST_SINGLE,
bitcode::LIST_SINGLE,
)
}
@ -206,7 +206,7 @@ pub fn list_join<'a, 'ctx, 'env>(
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
],
&bitcode::LIST_JOIN,
bitcode::LIST_JOIN,
)
}
_ => {
@ -239,7 +239,7 @@ pub fn list_reverse<'a, 'ctx, 'env>(
env.alignment_intvalue(&element_layout),
layout_width(env, &element_layout),
],
&bitcode::LIST_REVERSE,
bitcode::LIST_REVERSE,
)
}
@ -291,11 +291,11 @@ pub fn list_append<'a, 'ctx, 'env>(
env,
&[
pass_list_as_i128(env, original_wrapper.into()),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
pass_element_as_opaque(env, element),
layout_width(env, element_layout),
],
&bitcode::LIST_APPEND,
bitcode::LIST_APPEND,
)
}
@ -311,12 +311,12 @@ pub fn list_swap<'a, 'ctx, 'env>(
env,
&[
pass_list_as_i128(env, original_wrapper.into()),
env.alignment_intvalue(&element_layout),
layout_width(env, &element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
index_1.into(),
index_2.into(),
],
&bitcode::LIST_SWAP,
bitcode::LIST_SWAP,
)
}
@ -328,17 +328,17 @@ pub fn list_drop<'a, 'ctx, 'env>(
count: IntValue<'ctx>,
element_layout: &Layout<'a>,
) -> BasicValueEnum<'ctx> {
let dec_element_fn = build_dec_wrapper(env, layout_ids, &element_layout);
let dec_element_fn = build_dec_wrapper(env, layout_ids, element_layout);
call_bitcode_fn_returns_list(
env,
&[
pass_list_as_i128(env, original_wrapper.into()),
env.alignment_intvalue(&element_layout),
layout_width(env, &element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
count.into(),
dec_element_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::LIST_DROP,
bitcode::LIST_DROP,
)
}
@ -377,7 +377,7 @@ pub fn list_set<'a, 'ctx, 'env>(
&[
bytes.into(),
length.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
index.into(),
pass_element_as_opaque(env, element),
layout_width(env, element_layout),
@ -456,7 +456,7 @@ pub fn list_walk_generic<'a, 'ctx, 'env>(
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
pass_as_opaque(env, default_ptr),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
layout_width(env, default_layout),
pass_as_opaque(env, result_ptr),
@ -487,7 +487,7 @@ pub fn list_walk_generic<'a, 'ctx, 'env>(
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
pass_as_opaque(env, default_ptr),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
layout_width(env, function_call_return_layout),
layout_width(env, default_layout),
@ -563,7 +563,7 @@ pub fn list_range<'a, 'ctx, 'env>(
pass_as_opaque(env, low_ptr),
pass_as_opaque(env, high_ptr),
],
&bitcode::LIST_RANGE,
bitcode::LIST_RANGE,
)
}
@ -611,12 +611,12 @@ pub fn list_keep_if<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
inc_element_fn.as_global_value().as_pointer_value().into(),
dec_element_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::LIST_KEEP_IF,
bitcode::LIST_KEEP_IF,
)
}
@ -653,7 +653,7 @@ pub fn list_keep_oks<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&before_layout),
env.alignment_intvalue(before_layout),
layout_width(env, before_layout),
layout_width(env, result_layout),
layout_width(env, after_layout),
@ -697,7 +697,7 @@ pub fn list_keep_errs<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&before_layout),
env.alignment_intvalue(before_layout),
layout_width(env, before_layout),
layout_width(env, result_layout),
layout_width(env, after_layout),
@ -724,7 +724,7 @@ pub fn list_sort_with<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
],
bitcode::LIST_SORT_WITH,
@ -747,7 +747,7 @@ pub fn list_map_with_index<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
layout_width(env, return_layout),
],
@ -771,7 +771,7 @@ pub fn list_map<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
layout_width(env, return_layout),
],
@ -873,7 +873,7 @@ pub fn list_concat<'a, 'ctx, 'env>(
env.alignment_intvalue(elem_layout),
layout_width(env, elem_layout),
],
&bitcode::LIST_CONCAT,
bitcode::LIST_CONCAT,
),
_ => {
unreachable!("Invalid List layout for List.concat {:?}", list_layout);

View file

@ -27,7 +27,7 @@ pub fn str_split<'a, 'ctx, 'env>(
let segment_count = call_bitcode_fn(
env,
&[str_i128.into(), delim_i128.into()],
&bitcode::STR_COUNT_SEGMENTS,
bitcode::STR_COUNT_SEGMENTS,
)
.into_int_value();
@ -47,7 +47,7 @@ pub fn str_split<'a, 'ctx, 'env>(
call_void_bitcode_fn(
env,
&[ret_list_ptr_zig_rocstr, str_i128.into(), delim_i128.into()],
&bitcode::STR_STR_SPLIT_IN_PLACE,
bitcode::STR_STR_SPLIT_IN_PLACE,
);
store_list(env, ret_list_ptr, segment_count)
@ -62,7 +62,7 @@ fn str_symbol_to_i128<'a, 'ctx, 'env>(
let i128_type = env.context.i128_type().into();
complex_bitcast(&env.builder, string, i128_type, "str_to_i128").into_int_value()
complex_bitcast(env.builder, string, i128_type, "str_to_i128").into_int_value()
}
pub fn str_to_i128<'a, 'ctx, 'env>(
@ -119,7 +119,7 @@ pub fn str_concat<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str1_i128.into(), str2_i128.into()],
&bitcode::STR_CONCAT,
bitcode::STR_CONCAT,
)
}
@ -138,7 +138,7 @@ pub fn str_join_with<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[list_i128.into(), str_i128.into()],
&bitcode::STR_JOIN_WITH,
bitcode::STR_JOIN_WITH,
)
}
@ -151,7 +151,7 @@ pub fn str_number_of_bytes<'a, 'ctx, 'env>(
// the builtin will always return an u64
let length =
call_bitcode_fn(env, &[str_i128.into()], &bitcode::STR_NUMBER_OF_BYTES).into_int_value();
call_bitcode_fn(env, &[str_i128.into()], bitcode::STR_NUMBER_OF_BYTES).into_int_value();
// cast to the appropriate usize of the current build
env.builder
@ -171,7 +171,7 @@ pub fn str_starts_with<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str_i128.into(), prefix_i128.into()],
&bitcode::STR_STARTS_WITH,
bitcode::STR_STARTS_WITH,
)
}
@ -188,7 +188,7 @@ pub fn str_starts_with_code_point<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str_i128.into(), prefix],
&bitcode::STR_STARTS_WITH_CODE_POINT,
bitcode::STR_STARTS_WITH_CODE_POINT,
)
}
@ -205,7 +205,7 @@ pub fn str_ends_with<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str_i128.into(), prefix_i128.into()],
&bitcode::STR_ENDS_WITH,
bitcode::STR_ENDS_WITH,
)
}
@ -220,7 +220,7 @@ pub fn str_count_graphemes<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str_i128.into()],
&bitcode::STR_COUNT_GRAPEHEME_CLUSTERS,
bitcode::STR_COUNT_GRAPEHEME_CLUSTERS,
)
}
@ -232,7 +232,7 @@ pub fn str_from_int<'a, 'ctx, 'env>(
) -> BasicValueEnum<'ctx> {
let int = load_symbol(scope, &int_symbol);
call_bitcode_fn(env, &[int], &bitcode::STR_FROM_INT)
call_bitcode_fn(env, &[int], bitcode::STR_FROM_INT)
}
/// Str.toBytes : Str -> List U8
@ -247,7 +247,7 @@ pub fn str_to_bytes<'a, 'ctx, 'env>(
"to_bytes",
);
call_bitcode_fn_returns_list(env, &[string], &bitcode::STR_TO_BYTES)
call_bitcode_fn_returns_list(env, &[string], bitcode::STR_TO_BYTES)
}
/// Str.fromUtf8 : List U8 -> { a : Bool, b : Str, c : Nat, d : I8 }
@ -273,7 +273,7 @@ pub fn str_from_utf8<'a, 'ctx, 'env>(
),
result_ptr.into(),
],
&bitcode::STR_FROM_UTF8,
bitcode::STR_FROM_UTF8,
);
let record_type = env.context.struct_type(
@ -306,7 +306,7 @@ pub fn str_from_float<'a, 'ctx, 'env>(
) -> BasicValueEnum<'ctx> {
let float = load_symbol(scope, &int_symbol);
call_bitcode_fn(env, &[float], &bitcode::STR_FROM_FLOAT)
call_bitcode_fn(env, &[float], bitcode::STR_FROM_FLOAT)
}
/// Str.equal : Str, Str -> Bool
@ -321,7 +321,7 @@ pub fn str_equal<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str1_i128.into(), str2_i128.into()],
&bitcode::STR_EQUAL,
bitcode::STR_EQUAL,
)
}

View file

@ -99,7 +99,7 @@ fn build_eq_builtin<'a, 'ctx, 'env>(
Builtin::Usize => int_cmp(IntPredicate::EQ, "eq_usize"),
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], &bitcode::DEC_EQ),
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], bitcode::DEC_EQ),
Builtin::Float128 => float_cmp(FloatPredicate::OEQ, "eq_f128"),
Builtin::Float64 => float_cmp(FloatPredicate::OEQ, "eq_f64"),
Builtin::Float32 => float_cmp(FloatPredicate::OEQ, "eq_f32"),
@ -245,7 +245,7 @@ fn build_neq_builtin<'a, 'ctx, 'env>(
Builtin::Usize => int_cmp(IntPredicate::NE, "neq_usize"),
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], &bitcode::DEC_NEQ),
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], bitcode::DEC_NEQ),
Builtin::Float128 => float_cmp(FloatPredicate::ONE, "neq_f128"),
Builtin::Float64 => float_cmp(FloatPredicate::ONE, "neq_f64"),
Builtin::Float32 => float_cmp(FloatPredicate::ONE, "neq_f32"),
@ -361,13 +361,13 @@ fn build_list_eq<'a, 'ctx, 'env>(
let symbol = Symbol::LIST_EQ;
let fn_name = layout_ids
.get(symbol, &element_layout)
.get(symbol, element_layout)
.to_symbol_string(symbol, &env.interns);
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, list_layout);
let function_value = crate::llvm::refcounting::build_header_help(
env,
@ -428,7 +428,7 @@ fn build_list_eq_help<'a, 'ctx, 'env>(
/* current_scope */ lexical_block.as_debug_info_scope(),
/* inlined_at */ None,
);
builder.set_current_debug_location(&ctx, loc);
builder.set_current_debug_location(ctx, loc);
}
// Add args to scope
@ -636,7 +636,7 @@ fn build_struct_eq_help<'a, 'ctx, 'env>(
/* current_scope */ lexical_block.as_debug_info_scope(),
/* inlined_at */ None,
);
builder.set_current_debug_location(&ctx, loc);
builder.set_current_debug_location(ctx, loc);
}
// Add args to scope
@ -752,13 +752,13 @@ fn build_tag_eq<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_EQ;
let fn_name = layout_ids
.get(symbol, &tag_layout)
.get(symbol, tag_layout)
.to_symbol_string(symbol, &env.interns);
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, &tag_layout);
let arg_type = basic_type_from_layout(env, tag_layout);
let function_value = crate::llvm::refcounting::build_header_help(
env,
@ -817,7 +817,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
/* current_scope */ lexical_block.as_debug_info_scope(),
/* inlined_at */ None,
);
builder.set_current_debug_location(&ctx, loc);
builder.set_current_debug_location(ctx, loc);
}
// Add args to scope

View file

@ -59,7 +59,7 @@ 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);
block_of_memory_slices(env.context, &[other_fields], env.ptr_bytes);
block.ptr_type(AddressSpace::Generic).into()
}
NonNullableUnwrapped(fields) => {

View file

@ -720,14 +720,14 @@ fn modify_refcount_list<'a, 'ctx, 'env>(
&env.interns,
"increment_list",
"decrement_list",
&layout,
layout,
mode,
);
let function = match env.module.get_function(fn_name.as_str()) {
Some(function_value) => function_value,
None => {
let basic_type = basic_type_from_layout(env, &layout);
let basic_type = basic_type_from_layout(env, layout);
let function_value = build_header(env, basic_type, mode, &fn_name);
modify_refcount_list_help(
@ -857,14 +857,14 @@ fn modify_refcount_str<'a, 'ctx, 'env>(
&env.interns,
"increment_str",
"decrement_str",
&layout,
layout,
mode,
);
let function = match env.module.get_function(fn_name.as_str()) {
Some(function_value) => function_value,
None => {
let basic_type = basic_type_from_layout(env, &layout);
let basic_type = basic_type_from_layout(env, layout);
let function_value = build_header(env, basic_type, mode, &fn_name);
modify_refcount_str_help(env, mode, layout, function_value);
@ -956,14 +956,14 @@ fn modify_refcount_dict<'a, 'ctx, 'env>(
&env.interns,
"increment_dict",
"decrement_dict",
&layout,
layout,
mode,
);
let function = match env.module.get_function(fn_name.as_str()) {
Some(function_value) => function_value,
None => {
let basic_type = basic_type_from_layout(env, &layout);
let basic_type = basic_type_from_layout(env, layout);
let function_value = build_header(env, basic_type, mode, &fn_name);
modify_refcount_dict_help(
@ -1118,7 +1118,7 @@ pub fn build_header_help<'a, 'ctx, 'env>(
FAST_CALL_CONV, // Because it's an internal-only function, it should use the fast calling convention.
);
let subprogram = env.new_subprogram(&fn_name);
let subprogram = env.new_subprogram(fn_name);
fn_val.set_subprogram(subprogram);
env.dibuilder.finalize();