Skip to content

Commit

Permalink
Implement ExecutionEngine::lookup() proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
azteca1998 committed Dec 19, 2023
1 parent 816e3c9 commit bb3348c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion melior/src/execution_engine.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{ir::Module, logical_result::LogicalResult, string_ref::StringRef, Error};
use mlir_sys::{
mlirExecutionEngineCreate, mlirExecutionEngineDestroy, mlirExecutionEngineDumpToObjectFile,
mlirExecutionEngineInvokePacked, mlirExecutionEngineRegisterSymbol, MlirExecutionEngine,
mlirExecutionEngineInvokePacked, mlirExecutionEngineLookup, mlirExecutionEngineRegisterSymbol,
MlirExecutionEngine,
};

/// An execution engine.
Expand Down Expand Up @@ -34,6 +35,17 @@ impl ExecutionEngine {
}
}

/// Searches a symbol in a module and returns a pointer to it.
///
/// # Safety
///
/// This function modifies memory locations pointed by the `arguments`
/// argument. If those pointers are invalid or misaligned, calling this
/// function might result in undefined behavior.
pub fn lookup(&self, name: &str) -> *mut () {
unsafe { mlirExecutionEngineLookup(self.raw, StringRef::new(name).to_raw()) as *mut () }
}

/// Invokes a function in a module. The `arguments` argument includes
/// pointers to results of the function as well as arguments.
///
Expand Down

0 comments on commit bb3348c

Please sign in to comment.