diff --git a/melior/src/dialect/llvm.rs b/melior/src/dialect/llvm.rs index 5b93de7398..b91f37e440 100644 --- a/melior/src/dialect/llvm.rs +++ b/melior/src/dialect/llvm.rs @@ -8,7 +8,8 @@ use crate::{ }, operation::OperationBuilder, r#type::IntegerType, - Attribute, Identifier, Location, Operation, Region, Type, Value, + Attribute, AttributeLike, Identifier, Location, Operation, Region, Type, TypeLike, Value, + ValueLike, }, Context, }; @@ -21,8 +22,21 @@ mod load_store_options; pub mod r#type; macro_rules! assert_operation { - ($context:expr, $name:expr) => { + ($context:expr, $name:expr, [$($x:expr),+]) => { assert!($context.is_registered_operation($name)); + assert_context!($context, $($x),+); + + }; +} + +macro_rules! assert_context { + ($context:expr) => {}; + ($context:expr, $x:expr) => { + assert!($context == &$x.context()); + }; + ($context:expr, $x:expr, $($y:expr),+) => { + assert!($context == &$x.context()); + assert_context!($context, $($y),+); }; } @@ -38,7 +52,11 @@ pub fn extract_value<'c>( ) -> Operation<'c> { const NAME: &str = "llvm.extractvalue"; - assert_operation!(context, NAME); + assert_operation!( + context, + NAME, + [container.r#type(), position, result_type, location] + ); OperationBuilder::new(NAME, location) .add_attributes(&[(Identifier::new(context, "position"), position.into())])