diff --git a/mie/include/mie/ir/op.h b/mie/include/mie/ir/op.h index 9241679..997a43b 100644 --- a/mie/include/mie/ir/op.h +++ b/mie/include/mie/ir/op.h @@ -72,6 +72,11 @@ MIE_API void mie_op_destroy(struct mie_op *op); MIE_API void mie_op_init(struct mie_op *op); MIE_API void mie_op_cleanup(struct mie_op *op); +MIE_API bool mie_op_has_trait( + const struct mie_op *op, const char *dialect_name, const char *trait_name); +MIE_API bool mie_op_has_interface( + const struct mie_op *op, const char *dialect_name, const char *iface_name); + MIE_API const struct mie_type *mie_op_arg_get_type(const struct mie_op_arg *arg); #endif diff --git a/mie/ir/op.c b/mie/ir/op.c index b008957..f50f8b5 100644 --- a/mie/ir/op.c +++ b/mie/ir/op.c @@ -1,3 +1,4 @@ +#include #include #include @@ -30,3 +31,34 @@ void mie_op_cleanup(struct mie_op *op) { /* TODO */ } + +bool mie_op_has_trait( + const struct mie_op *op, const char *dialect_name, const char *trait_name) +{ + if (!op->op_info) { + return false; + } + + if (mie_trait_table_get_unique( + &op->op_info->op_traits, dialect_name, trait_name)) { + return true; + } + + struct mie_trait_table_iterator it; + enum mie_status status = mie_trait_table_get_generic( + &op->op_info->op_traits, dialect_name, trait_name, &it); + + return (status == MIE_SUCCESS); +} + +bool mie_op_has_interface( + const struct mie_op *op, const char *dialect_name, const char *iface_name) +{ + if (!op->op_info) { + return false; + } + + const struct mie_interface *p = mie_interface_map_get( + &op->op_info->op_iface, dialect_name, iface_name); + return p != NULL; +}