mie: ir: op: remove redundant op_dialect pointer
This commit is contained in:
@@ -88,7 +88,6 @@ struct mie_op *mie_ctx_create_op(
|
|||||||
|
|
||||||
out->op_flags |= MIE_OP_F_OP_RESOLVED;
|
out->op_flags |= MIE_OP_F_OP_RESOLVED;
|
||||||
out->op_info = def;
|
out->op_info = def;
|
||||||
out->op_dialect = def->op_parent;
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -129,7 +128,6 @@ bool mie_ctx_resolve_op(const struct mie_ctx *ctx, struct mie_op *op)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
op->op_dialect = dialect;
|
|
||||||
op->op_info = op_info;
|
op->op_info = op_info;
|
||||||
|
|
||||||
free(op->op_name);
|
free(op->op_name);
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ 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_init(struct mie_op *op);
|
||||||
MIE_API void mie_op_cleanup(struct mie_op *op);
|
MIE_API void mie_op_cleanup(struct mie_op *op);
|
||||||
|
|
||||||
|
MIE_API size_t mie_op_get_name(const struct mie_op *op, char *out, size_t max);
|
||||||
|
|
||||||
MIE_API struct mie_op_arg *mie_op_add_arg(struct mie_op *op);
|
MIE_API struct mie_op_arg *mie_op_add_arg(struct mie_op *op);
|
||||||
MIE_API struct mie_register *mie_op_add_result(
|
MIE_API struct mie_register *mie_op_add_result(
|
||||||
struct mie_op *op, const struct mie_type *ty);
|
struct mie_op *op, const struct mie_type *ty);
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ struct mie_op *mie_builder_put_op(
|
|||||||
struct mie_op *op = mie_block_add_op(block);
|
struct mie_op *op = mie_block_add_op(block);
|
||||||
op->op_flags = MIE_OP_F_OP_RESOLVED;
|
op->op_flags = MIE_OP_F_OP_RESOLVED;
|
||||||
op->op_info = op_def;
|
op->op_info = op_def;
|
||||||
op->op_dialect = op_def->op_parent;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < nr_args; i++) {
|
for (size_t i = 0; i < nr_args; i++) {
|
||||||
struct mie_op_arg *arg = mie_op_add_arg(op);
|
struct mie_op_arg *arg = mie_op_add_arg(op);
|
||||||
|
|||||||
15
mie/ir/op.c
15
mie/ir/op.c
@@ -66,6 +66,17 @@ void mie_op_cleanup(struct mie_op *op)
|
|||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t mie_op_get_name(const struct mie_op *op, char *out, size_t max)
|
||||||
|
{
|
||||||
|
if (!(op->op_flags & MIE_OP_F_OP_RESOLVED)) {
|
||||||
|
return snprintf(out, max, "%s", op->op_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return snprintf(
|
||||||
|
out, max, "%s.%s", op->op_info->op_parent->d_name,
|
||||||
|
op->op_info->op_name);
|
||||||
|
}
|
||||||
|
|
||||||
struct mie_op_arg *mie_op_add_arg(struct mie_op *op)
|
struct mie_op_arg *mie_op_add_arg(struct mie_op *op)
|
||||||
{
|
{
|
||||||
return mie_vector_emplace_back(op->op_args, &op_arg_vector_ops);
|
return mie_vector_emplace_back(op->op_args, &op_arg_vector_ops);
|
||||||
@@ -139,11 +150,11 @@ struct mie_region *mie_op_add_region(struct mie_op *op)
|
|||||||
|
|
||||||
bool mie_op_is(const struct mie_op *op, const char *dialect_name, const char *op_name)
|
bool mie_op_is(const struct mie_op *op, const char *dialect_name, const char *op_name)
|
||||||
{
|
{
|
||||||
if (!op->op_info || !op->op_dialect) {
|
if (!op->op_info || !op->op_info->op_parent) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(op->op_dialect->d_name, dialect_name) != 0) {
|
if (strcmp(op->op_info->op_parent->d_name, dialect_name) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -326,7 +326,8 @@ static void print_stack(struct mie_walker *walker)
|
|||||||
case MIE_WALK_ITEM_OP:
|
case MIE_WALK_ITEM_OP:
|
||||||
printf("* %zu: op %p", item->i_depth, item->i_op);
|
printf("* %zu: op %p", item->i_depth, item->i_op);
|
||||||
if (item->i_op->op_flags & MIE_OP_F_OP_RESOLVED) {
|
if (item->i_op->op_flags & MIE_OP_F_OP_RESOLVED) {
|
||||||
printf(" %s.%s", item->i_op->op_dialect->d_name,
|
printf(" %s.%s",
|
||||||
|
item->i_op->op_info->op_parent->d_name,
|
||||||
item->i_op->op_info->op_name);
|
item->i_op->op_info->op_name);
|
||||||
} else {
|
} else {
|
||||||
printf(" %s", item->i_op->op_name);
|
printf(" %s", item->i_op->op_name);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ static enum mie_match_result if_match(const struct mie_op *op)
|
|||||||
static struct mie_rewrite_result if_rewrite(
|
static struct mie_rewrite_result if_rewrite(
|
||||||
struct mie_op *op, struct mie_rewriter *rewriter)
|
struct mie_op *op, struct mie_rewriter *rewriter)
|
||||||
{
|
{
|
||||||
printf("if: rewriting %p %s.%s\n", op, op->op_dialect->d_name,
|
printf("if: rewriting %p %s.%s\n", op, op->op_info->op_parent->d_name,
|
||||||
op->op_info->op_name);
|
op->op_info->op_name);
|
||||||
|
|
||||||
struct mie_register *cond = mie_op_get_arg(op, 0);
|
struct mie_register *cond = mie_op_get_arg(op, 0);
|
||||||
@@ -111,7 +111,7 @@ static struct mie_pass_result transform(
|
|||||||
struct mie_pass *pass, struct mie_op *op, struct mie_pass_args *args)
|
struct mie_pass *pass, struct mie_op *op, struct mie_pass_args *args)
|
||||||
{
|
{
|
||||||
printf("%s: taking a look at %p %s.%s\n", mie_pass_get_name(pass), op,
|
printf("%s: taking a look at %p %s.%s\n", mie_pass_get_name(pass), op,
|
||||||
op->op_dialect->d_name, op->op_info->op_name);
|
op->op_info->op_parent->d_name, op->op_info->op_name);
|
||||||
|
|
||||||
struct mie_convert_config *cfg = mie_convert_config_create(args->p_ctx);
|
struct mie_convert_config *cfg = mie_convert_config_create(args->p_ctx);
|
||||||
mie_convert_config_add_illegal_op(cfg, "scf", "if");
|
mie_convert_config_add_illegal_op(cfg, "scf", "if");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <mie/dialect/dialect.h>
|
#include <mie/dialect/dialect.h>
|
||||||
#include <mie/interface/interface-definition.h>
|
#include <mie/interface/interface-definition.h>
|
||||||
#include <mie/ir/block.h>
|
#include <mie/ir/block.h>
|
||||||
|
#include <mie/ir/op-definition.h>
|
||||||
#include <mie/ir/op.h>
|
#include <mie/ir/op.h>
|
||||||
#include <mie/ir/region.h>
|
#include <mie/ir/region.h>
|
||||||
#include <mie/ir/walk.h>
|
#include <mie/ir/walk.h>
|
||||||
@@ -153,7 +154,7 @@ static bool filter_check_op(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter->f_dialect && op->op_dialect != filter->f_dialect) {
|
if (filter->f_dialect && op->op_info->op_parent != filter->f_dialect) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ static void print_generic_op(struct mie_printer *printer, const struct mie_op *o
|
|||||||
if (op->op_flags & MIE_OP_F_OP_RESOLVED) {
|
if (op->op_flags & MIE_OP_F_OP_RESOLVED) {
|
||||||
b_stream_write_fmt(
|
b_stream_write_fmt(
|
||||||
printer->p_stream, NULL, "%s.%s",
|
printer->p_stream, NULL, "%s.%s",
|
||||||
op->op_dialect->d_name, op->op_info->op_name);
|
op->op_info->op_parent->d_name, op->op_info->op_name);
|
||||||
} else {
|
} else {
|
||||||
b_stream_write_string(printer->p_stream, op->op_name, NULL);
|
b_stream_write_string(printer->p_stream, op->op_name, NULL);
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ void mie_printer_print_op_name(struct mie_printer *printer, const struct mie_op
|
|||||||
if (printer->p_flags & MIE_PRINT_F_GENERIC) {
|
if (printer->p_flags & MIE_PRINT_F_GENERIC) {
|
||||||
generic = true;
|
generic = true;
|
||||||
b_stream_write_char(printer->p_stream, '~');
|
b_stream_write_char(printer->p_stream, '~');
|
||||||
} else if (!strcmp(op->op_dialect->d_name, "builtin")) {
|
} else if (!strcmp(op->op_info->op_parent->d_name, "builtin")) {
|
||||||
builtin = true;
|
builtin = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +286,8 @@ void mie_printer_print_op_name(struct mie_printer *printer, const struct mie_op
|
|||||||
|
|
||||||
if (generic || !builtin || !abbreviate) {
|
if (generic || !builtin || !abbreviate) {
|
||||||
b_stream_write_fmt(
|
b_stream_write_fmt(
|
||||||
printer->p_stream, NULL, "%s.", op->op_dialect->d_name);
|
printer->p_stream, NULL, "%s.",
|
||||||
|
op->op_info->op_parent->d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
b_stream_write_string(printer->p_stream, op->op_info->op_name, NULL);
|
b_stream_write_string(printer->p_stream, op->op_info->op_name, NULL);
|
||||||
|
|||||||
@@ -382,7 +382,6 @@ struct mie_op *mie_rewriter_put_op(
|
|||||||
|
|
||||||
op->op_flags = MIE_OP_F_OP_RESOLVED;
|
op->op_flags = MIE_OP_F_OP_RESOLVED;
|
||||||
op->op_info = op_def;
|
op->op_info = op_def;
|
||||||
op->op_dialect = op_def->op_parent;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < nr_args; i++) {
|
for (size_t i = 0; i < nr_args; i++) {
|
||||||
struct mie_op_arg *arg = mie_op_add_arg(op);
|
struct mie_op_arg *arg = mie_op_add_arg(op);
|
||||||
@@ -407,7 +406,6 @@ struct mie_op *mie_rewriter_replace_op(
|
|||||||
}
|
}
|
||||||
|
|
||||||
op->op_info = op_def;
|
op->op_info = op_def;
|
||||||
op->op_dialect = op_def->op_parent;
|
|
||||||
|
|
||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user