xo-jit: fnptr -> closures for primitives+lambdas throughout

This commit is contained in:
Roland Conybeare 2024-07-10 16:05:00 -04:00
commit 09f5c141df
6 changed files with 295 additions and 124 deletions

View file

@ -68,6 +68,17 @@ namespace xo {
llvm::Type * llvm_type_ = nullptr;
};
inline std::ostream &
operator<<(std::ostream & os, const runtime_binding_detail & x) {
os << "<runtime_binding_detail"
<< xtag("i_argno", x.i_argno_)
<< xtag("llvm_addr", (void*)x.llvm_addr_)
<< xtag("llvm_type", (void*)x.llvm_type_)
<< ">";
return os;
}
/**
* 1. pattern for a stack frame associated with a user-defined function (some Lambda lm)
*

View file

@ -38,9 +38,23 @@ namespace xo {
* to either {primitive functions, functions-requiring-closures},
* with choice deferred until runtime
**/
static llvm::FunctionType * function_td_to_llvm_type(xo::ref::brw<LlvmContext> llvm_cx,
TypeDescr fn_td,
bool wrapper_flag = false);
static llvm::FunctionType * function_td_to_lvtype(xo::ref::brw<LlvmContext> llvm_cx,
TypeDescr fn_td,
bool wrapper_flag = false);
/** establish llvm representation for a function-pointer type
* described by @p fn_td
*
* @param wrapper_flag If true, create function type for a wrapper
* to be associated with a closure.
* The wrapper accepts (and ignores) an envapi pointer as first argument.
* Necessary to (for example) support function pointers that may refer
* to either {primitive functions, functions-requiring-closures},
* with choice deferred until runtime
**/
static llvm::PointerType * function_td_to_llvm_fnptr_type(xo::ref::brw<LlvmContext> llvm_cx,
TypeDescr fn_td,
bool wrapper_flag);
/** establish llvm concrete representation for a closure.
*
@ -171,19 +185,6 @@ namespace xo {
llvm::PointerType * hint_envptr_llvm_type = nullptr);
private:
/** establish llvm representation for a function-pointer type
* described by @p fn_td
*
* @param wrapper_flag If true, create function type for a wrapper
* to be associated with a closure.
* The wrapper accepts (and ignores) an envapi pointer as first argument.
* Necessary to (for example) support function pointers that may refer
* to either {primitive functions, functions-requiring-closures},
* with choice deferred until runtime
**/
static llvm::PointerType * function_td_to_llvm_fnptr_type(xo::ref::brw<LlvmContext> llvm_cx,
TypeDescr fn_td,
bool wrapper_flag);
/** establish llvm representation for a struct type described by @p struct_td
**/