mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
llvm types for erasure, function pointer
This commit is contained in:
parent
2c826ea898
commit
74d0f8d2e5
4 changed files with 44 additions and 8 deletions
|
@ -1,15 +1,15 @@
|
|||
use crate::llvm::build::{BuilderExt, Env};
|
||||
use crate::llvm::build::{BuilderExt, Env, FunctionSpec, RocReturn};
|
||||
use crate::llvm::erased;
|
||||
use crate::llvm::memcpy::build_memcpy;
|
||||
use bumpalo::collections::Vec as AVec;
|
||||
use bumpalo::collections::{CollectIn, Vec as AVec};
|
||||
use inkwell::context::Context;
|
||||
use inkwell::types::{BasicType, BasicTypeEnum, FloatType, IntType, StructType};
|
||||
use inkwell::values::PointerValue;
|
||||
use inkwell::AddressSpace;
|
||||
use roc_builtins::bitcode::{FloatWidth, IntWidth};
|
||||
use roc_error_macros::todo_lambda_erasure;
|
||||
use roc_mono::layout::{
|
||||
round_up_to_alignment, Builtin, InLayout, Layout, LayoutInterner, LayoutRepr, STLayoutInterner,
|
||||
UnionLayout,
|
||||
round_up_to_alignment, Builtin, FunctionPointer, InLayout, Layout, LayoutInterner, LayoutRepr,
|
||||
STLayoutInterner, UnionLayout,
|
||||
};
|
||||
use roc_target::TargetInfo;
|
||||
|
||||
|
@ -49,8 +49,21 @@ pub fn basic_type_from_layout<'a, 'ctx>(
|
|||
.ptr_type(AddressSpace::default())
|
||||
.as_basic_type_enum(),
|
||||
|
||||
FunctionPointer(_) => todo_lambda_erasure!(),
|
||||
Erased(_) => todo_lambda_erasure!(),
|
||||
FunctionPointer(self::FunctionPointer { args, ret }) => {
|
||||
let args = args.iter().map(|arg| {
|
||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(*arg))
|
||||
});
|
||||
|
||||
let ret_repr = layout_interner.get_repr(ret);
|
||||
let ret = basic_type_from_layout(env, layout_interner, ret_repr);
|
||||
|
||||
let roc_return = RocReturn::from_layout(layout_interner, ret_repr);
|
||||
|
||||
let fn_spec = FunctionSpec::fastcc(env, roc_return, ret, args.collect_in(env.arena));
|
||||
|
||||
fn_spec.typ.ptr_type(AddressSpace::default()).into()
|
||||
}
|
||||
Erased(_) => erased::basic_type(env).into(),
|
||||
|
||||
Builtin(builtin) => basic_type_from_builtin(env, &builtin),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue