mie: pass: support filtering passes to any op of a given dialect
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
struct mie_op;
|
||||
struct mie_ctx;
|
||||
struct mie_pass;
|
||||
struct mie_dialect;
|
||||
struct mie_op_definition;
|
||||
struct mie_trait_definition;
|
||||
struct mie_interface_definition;
|
||||
@@ -40,6 +41,7 @@ struct mie_pass_args {
|
||||
};
|
||||
|
||||
struct mie_pass_filter {
|
||||
const struct mie_dialect *f_dialect;
|
||||
const struct mie_op_definition *f_op;
|
||||
const struct mie_trait_definition *f_trait;
|
||||
const struct mie_interface_definition *f_iface;
|
||||
|
||||
@@ -87,18 +87,19 @@ enum mie_status mie_pass_manager_filter_op(
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
if (!dialect_name || !op_name) {
|
||||
if (!dialect_name) {
|
||||
return MIE_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
const struct mie_op_definition *op
|
||||
= mie_ctx_get_op_definition(pm->pm_ctx, dialect_name, op_name);
|
||||
if (!op) {
|
||||
return MIE_ERR_NO_ENTRY;
|
||||
if (!op_name) {
|
||||
pm->pm_filter.f_dialect
|
||||
= mie_ctx_get_dialect(pm->pm_ctx, dialect_name);
|
||||
return pm->pm_filter.f_dialect ? MIE_SUCCESS : MIE_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
pm->pm_filter.f_op = op;
|
||||
return MIE_SUCCESS;
|
||||
pm->pm_filter.f_op
|
||||
= mie_ctx_get_op_definition(pm->pm_ctx, dialect_name, op_name);
|
||||
return pm->pm_filter.f_op ? MIE_SUCCESS : MIE_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
enum mie_status mie_pass_manager_filter_trait(
|
||||
@@ -152,6 +153,10 @@ static bool filter_check_op(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filter->f_dialect && op->op_dialect != filter->f_dialect) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filter->f_trait
|
||||
&& !mie_op_has_trait(
|
||||
op, filter->f_trait->tr_parent->d_name,
|
||||
@@ -203,7 +208,7 @@ static void schedule_passes(
|
||||
while (mie_walker_step(walker) == MIE_SUCCESS) {
|
||||
for (size_t i = 0; i < MIE_VECTOR_COUNT(pm->pm_nested); i++) {
|
||||
struct mie_pass_manager *nested = pm->pm_nested.items[i];
|
||||
struct mie_walker_item *item = mie_walker_get(walker);
|
||||
struct mie_walk_item *item = mie_walker_get(walker);
|
||||
schedule_passes(nested, schedule, item->i_op, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user