forked from M-Labs/nac3
core: add llvm.lifetime.{start.end}
This commit is contained in:
parent
9ad7a78dbe
commit
c4d54b198b
|
@ -35,6 +35,54 @@ fn get_float_intrinsic_repr(ctx: &Context, ft: FloatType) -> &'static str {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Invokes the [`llvm.lifetime.start`](https://releases.llvm.org/14.0.0/docs/LangRef.html#llvm-lifetime-start-intrinsic)
|
||||||
|
/// intrinsic.
|
||||||
|
pub fn call_lifetime_start<'ctx>(
|
||||||
|
ctx: &CodeGenContext<'ctx, '_>,
|
||||||
|
size: IntValue<'ctx>,
|
||||||
|
ptr: PointerValue<'ctx>,
|
||||||
|
) {
|
||||||
|
const FN_NAME: &str = "llvm.lifetime.start";
|
||||||
|
// NOTE: inkwell temporary workaround, see [`call_stackrestore`] for details
|
||||||
|
let intrinsic_fn = ctx.module.get_function(FN_NAME).unwrap_or_else(|| {
|
||||||
|
let llvm_void = ctx.ctx.void_type();
|
||||||
|
let llvm_i64 = ctx.ctx.i64_type();
|
||||||
|
let llvm_p0i8 = ctx.ctx.i8_type().ptr_type(AddressSpace::default());
|
||||||
|
let fn_type = llvm_void.fn_type(&[llvm_i64.into(), llvm_p0i8.into()], false);
|
||||||
|
|
||||||
|
ctx.module.add_function(FN_NAME, fn_type, None)
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.builder
|
||||||
|
.build_call(intrinsic_fn, &[size.into(), ptr.into()], "")
|
||||||
|
.map(CallSiteValue::try_as_basic_value)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Invokes the [`llvm.lifetime.end`](https://releases.llvm.org/14.0.0/docs/LangRef.html#llvm-lifetime-end-intrinsic)
|
||||||
|
/// intrinsic.
|
||||||
|
pub fn call_lifetime_end<'ctx>(
|
||||||
|
ctx: &CodeGenContext<'ctx, '_>,
|
||||||
|
size: IntValue<'ctx>,
|
||||||
|
ptr: PointerValue<'ctx>,
|
||||||
|
) {
|
||||||
|
const FN_NAME: &str = "llvm.lifetime.end";
|
||||||
|
// NOTE: inkwell temporary workaround, see [`call_stackrestore`] for details
|
||||||
|
let intrinsic_fn = ctx.module.get_function(FN_NAME).unwrap_or_else(|| {
|
||||||
|
let llvm_void = ctx.ctx.void_type();
|
||||||
|
let llvm_i64 = ctx.ctx.i64_type();
|
||||||
|
let llvm_p0i8 = ctx.ctx.i8_type().ptr_type(AddressSpace::default());
|
||||||
|
let fn_type = llvm_void.fn_type(&[llvm_i64.into(), llvm_p0i8.into()], false);
|
||||||
|
|
||||||
|
ctx.module.add_function(FN_NAME, fn_type, None)
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.builder
|
||||||
|
.build_call(intrinsic_fn, &[size.into(), ptr.into()], "")
|
||||||
|
.map(CallSiteValue::try_as_basic_value)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
/// Invokes the [`llvm.stacksave`](https://llvm.org/docs/LangRef.html#llvm-stacksave-intrinsic)
|
/// Invokes the [`llvm.stacksave`](https://llvm.org/docs/LangRef.html#llvm-stacksave-intrinsic)
|
||||||
/// intrinsic.
|
/// intrinsic.
|
||||||
pub fn call_stacksave<'ctx>(
|
pub fn call_stacksave<'ctx>(
|
||||||
|
|
Loading…
Reference in New Issue