right now, the group only contains a single pass: prefix-func-with-underscore. this is a test pass that visits instances of func.func and prepends an underscore to the func's symbol name.
36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
#include <mie/ctx.h>
|
|
#include <mie/dialect/builtin.h>
|
|
#include <mie/ir/op.h>
|
|
#include <mie/macros.h>
|
|
#include <mie/pass/pass-definition.h>
|
|
#include <mie/pass/pass.h>
|
|
|
|
static struct mie_pass_result transform(
|
|
struct mie_pass *pass, struct mie_op *op, struct mie_pass_args *args)
|
|
{
|
|
const struct mie_attribute *sym_name_attr
|
|
= mie_attribute_map_get(&op->op_attrib, "sym_name");
|
|
const char *sym_name = mie_string_get_cstr(sym_name_attr);
|
|
|
|
char tmp[256];
|
|
snprintf(tmp, sizeof tmp, "_%s", sym_name);
|
|
const struct mie_attribute *new_name
|
|
= mie_ctx_get_string(args->p_ctx, tmp);
|
|
|
|
mie_attribute_map_put(
|
|
&op->op_attrib, "sym_name", new_name, MIE_ATTRMAP_F_REPLACE);
|
|
|
|
printf("%s: taking a look at @%s\n", mie_pass_get_name(pass), sym_name);
|
|
|
|
return MIE_PASS_CONTINUE;
|
|
}
|
|
|
|
MIE_PASS_DEFINITION_BEGIN(prefix_func_with_underscore)
|
|
MIE_PASS_NAME("prefix-func-with-underscore");
|
|
MIE_PASS_DESCRIPTION(
|
|
"Test pass that prefixes the identifier of every function with "
|
|
"an underscore.");
|
|
MIE_PASS_TRANSFORM(transform);
|
|
MIE_PASS_FILTER_OP("func", "func");
|
|
MIE_PASS_DEFINITION_END()
|