mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +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
22
crates/compiler/gen_llvm/src/llvm/erased.rs
Normal file
22
crates/compiler/gen_llvm/src/llvm/erased.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use inkwell::{
|
||||
types::{BasicTypeEnum, StructType},
|
||||
AddressSpace,
|
||||
};
|
||||
|
||||
use super::build::Env;
|
||||
|
||||
/// Erased is laid out like
|
||||
///
|
||||
/// ```text
|
||||
/// struct Erased {
|
||||
/// value: void*,
|
||||
/// callee: void*,
|
||||
/// refcounter: void*,
|
||||
/// }
|
||||
/// ```
|
||||
pub fn basic_type<'a, 'ctx>(env: &Env<'a, 'ctx, '_>) -> StructType<'ctx> {
|
||||
let ptr_ty = env.context.i8_type().ptr_type(AddressSpace::default());
|
||||
|
||||
env.context
|
||||
.struct_type(&[ptr_ty.into(), ptr_ty.into(), ptr_ty.into()], false)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue