Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed May 5, 2023
1 parent a1efd0d commit 180aea5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ pub struct ExecutionEngine {

impl ExecutionEngine {
/// Creates an execution engine.
pub fn new(module: &Module, optimization_level: usize, shared_library_paths: &[&str]) -> Self {
pub fn new(
module: &Module,
optimization_level: usize,
shared_library_paths: &[&str],
enable_object_dump: bool,
) -> Self {
Self {
raw: unsafe {
mlirExecutionEngineCreate(
Expand All @@ -24,6 +29,7 @@ impl ExecutionEngine {
.map(|&string| StringRef::from(string).to_raw())
.collect::<Vec<_>>()
.as_ptr(),
enable_object_dump,
)
},
}
Expand Down
11 changes: 3 additions & 8 deletions src/ir/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use mlir_sys::{
mlirAttributeIsABool, mlirAttributeIsADenseElements, mlirAttributeIsADenseFPElements,
mlirAttributeIsADenseIntElements, mlirAttributeIsADictionary, mlirAttributeIsAElements,
mlirAttributeIsAFloat, mlirAttributeIsAInteger, mlirAttributeIsAIntegerSet,
mlirAttributeIsAOpaque, mlirAttributeIsAOpaqueElements, mlirAttributeIsASparseElements,
mlirAttributeIsAString, mlirAttributeIsASymbolRef, mlirAttributeIsAType, mlirAttributeIsAUnit,
mlirAttributeParseGet, mlirAttributePrint, MlirAttribute,
mlirAttributeIsAOpaque, mlirAttributeIsASparseElements, mlirAttributeIsAString,
mlirAttributeIsASymbolRef, mlirAttributeIsAType, mlirAttributeIsAUnit, mlirAttributeParseGet,
mlirAttributePrint, MlirAttribute,
};
use std::{
ffi::c_void,
Expand Down Expand Up @@ -127,11 +127,6 @@ impl<'c> Attribute<'c> {
!self.is_null() && unsafe { mlirAttributeIsAOpaque(self.raw) }
}

/// Returns `true` if an attribute is opaque elements.
pub fn is_opaque_elements(&self) -> bool {
!self.is_null() && unsafe { mlirAttributeIsAOpaqueElements(self.raw) }
}

/// Returns `true` if an attribute is sparse elements.
pub fn is_sparse_elements(&self) -> bool {
!self.is_null() && unsafe { mlirAttributeIsASparseElements(self.raw) }
Expand Down
4 changes: 2 additions & 2 deletions src/pass/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

use super::Pass;
use mlir_sys::{
mlirCreateConversionConvertArithmeticToLLVM, mlirCreateConversionConvertControlFlowToLLVM,
mlirCreateConversionArithToLLVMConversionPass, mlirCreateConversionConvertControlFlowToLLVM,
mlirCreateConversionConvertControlFlowToSPIRV, mlirCreateConversionConvertFuncToLLVM,
mlirCreateConversionConvertMathToLLVM, mlirCreateConversionConvertMathToLibm,
mlirCreateConversionConvertMathToSPIRV,
};

/// Creates a pass to convert the `arith` dialect to the `llvm` dialect.
pub fn convert_arithmetic_to_llvm() -> Pass {
Pass::from_raw_fn(mlirCreateConversionConvertArithmeticToLLVM)
Pass::from_raw_fn(mlirCreateConversionArithToLLVMConversionPass)
}

/// Creates a pass to convert the `cf` dialect to the `llvm` dialect.
Expand Down
9 changes: 8 additions & 1 deletion src/utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use mlir_sys::{
use std::{
ffi::c_void,
fmt::{self, Formatter},
ptr::null_mut,
sync::Once,
};

Expand All @@ -33,8 +34,14 @@ pub fn register_all_passes() {

/// Parses a pass pipeline.
pub fn parse_pass_pipeline(manager: pass::OperationManager, source: &str) -> Result<(), Error> {
// TODO Handle parse errors.
let result = LogicalResult::from_raw(unsafe {
mlirParsePassPipeline(manager.to_raw(), StringRef::from(source).to_raw())
mlirParsePassPipeline(
manager.to_raw(),
StringRef::from(source).to_raw(),
None,
null_mut(),
)
});

if result.is_success() {
Expand Down

0 comments on commit 180aea5

Please sign in to comment.