Skip to content

Commit

Permalink
Merge branch 'main' into fix-aarch64-linux-build
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe committed Jun 15, 2024
2 parents d4a2926 + cb869a1 commit 637aef7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion melior/src/ir/operation/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'c> OperationBuilder<'c> {
mlirOperationStateAddOwnedRegions(
&mut self.raw,
regions.len() as isize,
transmute::<_, Vec<ManuallyDrop<Region>>>(regions).as_ptr() as *const _,
transmute::<Vec<Region>, Vec<ManuallyDrop<Region>>>(regions).as_ptr() as *const _,
)
}

Expand Down
25 changes: 19 additions & 6 deletions melior/src/pass/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use mlir_sys::{
mlirCreateExternalPass, mlirExternalPassSignalFailure, MlirContext, MlirExternalPass,
MlirExternalPassCallbacks, MlirLogicalResult, MlirOperation,
};
use std::{marker::PhantomData, mem::transmute, ptr::drop_in_place};
use std::{ffi::c_void, marker::PhantomData, mem::transmute, ptr::drop_in_place};

#[derive(Clone, Copy, Debug)]
pub struct ExternalPass<'a> {
Expand Down Expand Up @@ -185,11 +185,24 @@ pub fn create_external<'c, T: RunExternalPass<'c>>(
dependent_dialects.len() as isize,
dependent_dialects.as_ptr() as _,
MlirExternalPassCallbacks {
construct: Some(transmute(callback_construct::<T> as *const ())),
destruct: Some(transmute(callback_destruct::<T> as *const ())),
initialize: Some(transmute(callback_initialize::<T> as *const ())),
run: Some(transmute(callback_run::<T> as *const ())),
clone: Some(transmute(callback_clone::<T> as *const ())),
construct: Some(transmute::<*const (), unsafe extern "C" fn(*mut c_void)>(
callback_construct::<T> as *const (),
)),
destruct: Some(transmute::<*const (), unsafe extern "C" fn(*mut c_void)>(
callback_destruct::<T> as *const (),
)),
initialize: Some(transmute::<
*const (),
unsafe extern "C" fn(MlirContext, *mut c_void) -> MlirLogicalResult,
>(callback_initialize::<T> as *const ())),
run: Some(transmute::<
*const (),
unsafe extern "C" fn(MlirOperation, MlirExternalPass, *mut c_void),
>(callback_run::<T> as *const ())),
clone: Some(transmute::<
*const (),
unsafe extern "C" fn(*mut c_void) -> *mut c_void,
>(callback_clone::<T> as *const ())),
},
Box::into_raw(Box::new(pass)) as _,
))
Expand Down

0 comments on commit 637aef7

Please sign in to comment.