Add a compiler-llvm CompilerFunctionKind for the whole module which can occur with the experimental API for engine-native.

Since it's no longer per-function, rename CompilerFunctionKind to CompilerKind.
This commit is contained in:
Nick Lewycky
2020-08-20 23:28:07 -07:00
parent 91414df670
commit 5d40787856
6 changed files with 29 additions and 35 deletions

View File

@@ -19,24 +19,22 @@ pub type InkwellMemoryBuffer = inkwell::memory_buffer::MemoryBuffer;
/// The compiled function kind, used for debugging in the `LLVMCallbacks`.
#[derive(Debug, Clone)]
pub enum CompiledFunctionKind {
// A locally-defined function in the Wasm file
pub enum CompiledKind {
// A locally-defined function in the Wasm file.
Local(LocalFunctionIndex),
// A function call trampoline for a given signature
// A function call trampoline for a given signature.
FunctionCallTrampoline(FunctionType),
// A dynamic function trampoline for a given signature
// A dynamic function trampoline for a given signature.
DynamicFunctionTrampoline(FunctionType),
// An entire Wasm module.
Module,
}
/// Callbacks to the different LLVM compilation phases.
pub trait LLVMCallbacks: Debug + Send + Sync {
fn preopt_ir(&self, function: &CompiledFunctionKind, module: &InkwellModule);
fn postopt_ir(&self, function: &CompiledFunctionKind, module: &InkwellModule);
fn obj_memory_buffer(
&self,
function: &CompiledFunctionKind,
memory_buffer: &InkwellMemoryBuffer,
);
fn preopt_ir(&self, function: &CompiledKind, module: &InkwellModule);
fn postopt_ir(&self, function: &CompiledKind, module: &InkwellModule);
fn obj_memory_buffer(&self, function: &CompiledKind, memory_buffer: &InkwellMemoryBuffer);
}
#[derive(Debug, Clone)]