llvm types for erasure, function pointer

This commit is contained in:
Ayaz Hafiz 2023-07-04 16:56:39 -05:00
parent 2c826ea898
commit 74d0f8d2e5
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 44 additions and 8 deletions

View 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)
}