mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
Failed attempt to use target_data
This commit is contained in:
parent
eed9fb0e69
commit
6e977d96fc
@ -27,17 +27,17 @@ const PRINT_FN_VERIFICATION_OUTPUT: bool = false;
|
|||||||
|
|
||||||
type Scope<'a, 'ctx> = ImMap<Symbol, (Layout<'a>, PointerValue<'ctx>)>;
|
type Scope<'a, 'ctx> = ImMap<Symbol, (Layout<'a>, PointerValue<'ctx>)>;
|
||||||
|
|
||||||
pub struct Env<'a, 'ctx, 'env> {
|
pub struct Env<'a, 'ctx, 'env, 'td> {
|
||||||
pub arena: &'a Bump,
|
pub arena: &'a Bump,
|
||||||
pub context: &'ctx Context,
|
pub context: &'ctx Context,
|
||||||
pub builder: &'env Builder<'ctx>,
|
pub builder: &'env Builder<'ctx>,
|
||||||
pub module: &'ctx Module<'ctx>,
|
pub module: &'ctx Module<'ctx>,
|
||||||
pub interns: Interns,
|
pub interns: Interns,
|
||||||
pub target_data: &'env TargetData,
|
pub target_data: &'td TargetData,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_expr<'a, 'ctx, 'env>(
|
pub fn build_expr<'a, 'ctx, 'env, 'td>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env, 'td>,
|
||||||
scope: &Scope<'a, 'ctx>,
|
scope: &Scope<'a, 'ctx>,
|
||||||
parent: FunctionValue<'ctx>,
|
parent: FunctionValue<'ctx>,
|
||||||
expr: &Expr<'a>,
|
expr: &Expr<'a>,
|
||||||
@ -255,7 +255,6 @@ pub fn build_expr<'a, 'ctx, 'env>(
|
|||||||
|
|
||||||
let ptr_val = BasicValueEnum::PointerValue(ptr);
|
let ptr_val = BasicValueEnum::PointerValue(ptr);
|
||||||
let struct_type = collection_wrapper(ctx, ptr.get_type());
|
let struct_type = collection_wrapper(ctx, ptr.get_type());
|
||||||
let len = BasicValueEnum::IntValue(ctx.i32_type().const_int(len_u64, false));
|
|
||||||
let mut struct_val;
|
let mut struct_val;
|
||||||
|
|
||||||
// Field 0: pointer
|
// Field 0: pointer
|
||||||
@ -269,17 +268,16 @@ pub fn build_expr<'a, 'ctx, 'env>(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Field 1: length
|
// Field 1: length
|
||||||
struct_val = builder
|
|
||||||
.build_insert_value(struct_val, len, Builtin::WRAPPER_LEN, "insert_len")
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Field 2: capacity (initially set to length)
|
|
||||||
struct_val = builder
|
struct_val = builder
|
||||||
.build_insert_value(
|
.build_insert_value(
|
||||||
struct_val,
|
struct_val,
|
||||||
len,
|
BasicValueEnum::IntValue(
|
||||||
Builtin::WRAPPER_CAPACITY,
|
env.target_data
|
||||||
"insert_capacity",
|
.ptr_sized_int_type_in_context(ctx, None)
|
||||||
|
.const_int(len_u64, false),
|
||||||
|
),
|
||||||
|
Builtin::WRAPPER_LEN,
|
||||||
|
"insert_len",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -577,8 +575,8 @@ struct Branch2<'a> {
|
|||||||
ret_layout: Layout<'a>,
|
ret_layout: Layout<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_branch2<'a, 'ctx, 'env>(
|
fn build_branch2<'a, 'ctx, 'env, 'td>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env, 'td>,
|
||||||
scope: &Scope<'a, 'ctx>,
|
scope: &Scope<'a, 'ctx>,
|
||||||
parent: FunctionValue<'ctx>,
|
parent: FunctionValue<'ctx>,
|
||||||
cond: Branch2<'a>,
|
cond: Branch2<'a>,
|
||||||
@ -608,8 +606,8 @@ struct SwitchArgs<'a, 'ctx> {
|
|||||||
pub ret_type: BasicTypeEnum<'ctx>,
|
pub ret_type: BasicTypeEnum<'ctx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_switch<'a, 'ctx, 'env>(
|
fn build_switch<'a, 'ctx, 'env, 'td>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env, 'td>,
|
||||||
scope: &Scope<'a, 'ctx>,
|
scope: &Scope<'a, 'ctx>,
|
||||||
parent: FunctionValue<'ctx>,
|
parent: FunctionValue<'ctx>,
|
||||||
switch_args: SwitchArgs<'a, 'ctx>,
|
switch_args: SwitchArgs<'a, 'ctx>,
|
||||||
@ -695,8 +693,8 @@ fn build_switch<'a, 'ctx, 'env>(
|
|||||||
|
|
||||||
// TODO trim down these arguments
|
// TODO trim down these arguments
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn build_phi2<'a, 'ctx, 'env>(
|
fn build_phi2<'a, 'ctx, 'env, 'td>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env, 'td>,
|
||||||
scope: &Scope<'a, 'ctx>,
|
scope: &Scope<'a, 'ctx>,
|
||||||
parent: FunctionValue<'ctx>,
|
parent: FunctionValue<'ctx>,
|
||||||
comparison: IntValue<'ctx>,
|
comparison: IntValue<'ctx>,
|
||||||
@ -756,7 +754,7 @@ fn set_name(bv_enum: BasicValueEnum<'_>, name: &str) {
|
|||||||
|
|
||||||
/// Creates a new stack allocation instruction in the entry block of the function.
|
/// Creates a new stack allocation instruction in the entry block of the function.
|
||||||
pub fn create_entry_block_alloca<'a, 'ctx>(
|
pub fn create_entry_block_alloca<'a, 'ctx>(
|
||||||
env: &Env<'a, 'ctx, '_>,
|
env: &Env<'a, 'ctx, '_, '_>,
|
||||||
parent: FunctionValue<'_>,
|
parent: FunctionValue<'_>,
|
||||||
basic_type: BasicTypeEnum<'ctx>,
|
basic_type: BasicTypeEnum<'ctx>,
|
||||||
name: &str,
|
name: &str,
|
||||||
@ -772,8 +770,8 @@ pub fn create_entry_block_alloca<'a, 'ctx>(
|
|||||||
builder.build_alloca(basic_type, name)
|
builder.build_alloca(basic_type, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_proc_header<'a, 'ctx, 'env>(
|
pub fn build_proc_header<'a, 'ctx, 'env, 'td>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env, 'td>,
|
||||||
symbol: Symbol,
|
symbol: Symbol,
|
||||||
proc: &Proc<'a>,
|
proc: &Proc<'a>,
|
||||||
) -> (FunctionValue<'ctx>, Vec<'a, BasicTypeEnum<'ctx>>) {
|
) -> (FunctionValue<'ctx>, Vec<'a, BasicTypeEnum<'ctx>>) {
|
||||||
@ -802,8 +800,8 @@ pub fn build_proc_header<'a, 'ctx, 'env>(
|
|||||||
(fn_val, arg_basic_types)
|
(fn_val, arg_basic_types)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_proc<'a, 'ctx, 'env>(
|
pub fn build_proc<'a, 'ctx, 'env, 'td>(
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env, 'td>,
|
||||||
proc: Proc<'a>,
|
proc: Proc<'a>,
|
||||||
procs: &Procs<'a>,
|
procs: &Procs<'a>,
|
||||||
fn_val: FunctionValue<'ctx>,
|
fn_val: FunctionValue<'ctx>,
|
||||||
@ -851,10 +849,10 @@ pub fn verify_fn(fn_val: FunctionValue<'_>) {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[allow(clippy::cognitive_complexity)]
|
#[allow(clippy::cognitive_complexity)]
|
||||||
fn call_with_args<'a, 'ctx, 'env>(
|
fn call_with_args<'a, 'ctx, 'env, 'td>(
|
||||||
symbol: Symbol,
|
symbol: Symbol,
|
||||||
args: &[BasicValueEnum<'ctx>],
|
args: &[BasicValueEnum<'ctx>],
|
||||||
env: &Env<'a, 'ctx, 'env>,
|
env: &Env<'a, 'ctx, 'env, 'td>,
|
||||||
) -> BasicValueEnum<'ctx> {
|
) -> BasicValueEnum<'ctx> {
|
||||||
match symbol {
|
match symbol {
|
||||||
Symbol::INT_ADD | Symbol::NUM_ADD => {
|
Symbol::INT_ADD | Symbol::NUM_ADD => {
|
||||||
|
Loading…
Reference in New Issue
Block a user