mie: add select dialect
This commit is contained in:
21
mie/dialect/select/graph-only.c
Normal file
21
mie/dialect/select/graph-only.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/macros.h>
|
||||
#include <mie/trait/trait-definition.h>
|
||||
#include <mie/trait/trait.h>
|
||||
|
||||
static enum mie_status validate(
|
||||
const struct mie_trait_definition *trait_def,
|
||||
const struct mie_trait *trait, const struct mie_trait_target *target)
|
||||
{
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
/* select.graph-only trait:
|
||||
* this is a graph-only op. references to it by name must be prefixed with +
|
||||
* and the op can only be used within graph regions.
|
||||
* a graph op can have the same name as a regular or non-graph op. */
|
||||
MIE_TRAIT_DEFINITION_BEGIN(mie_select_graph_only, "graph-only")
|
||||
MIE_TRAIT_DEFINITION_TARGETS(MIE_TRAIT_TARGET_OP | MIE_TRAIT_TARGET_TYPE);
|
||||
MIE_TRAIT_DEFINITION_STRUCT(struct mie_trait);
|
||||
MIE_TRAIT_DEFINITION_VALIDATE(validate);
|
||||
MIE_TRAIT_DEFINITION_END()
|
||||
21
mie/dialect/select/graph-op.c
Normal file
21
mie/dialect/select/graph-op.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/macros.h>
|
||||
#include <mie/trait/trait-definition.h>
|
||||
#include <mie/trait/trait.h>
|
||||
|
||||
static enum mie_status validate(
|
||||
const struct mie_trait_definition *trait_def,
|
||||
const struct mie_trait *trait, const struct mie_trait_target *target)
|
||||
{
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
/* select.graph-op trait:
|
||||
* ops with this trait can be used within graph regions. by default, ops cannot
|
||||
* be used in graph regions unless they have the graph-op or graph-only traits.
|
||||
*/
|
||||
MIE_TRAIT_DEFINITION_BEGIN(mie_select_graph_op, "graph-op")
|
||||
MIE_TRAIT_DEFINITION_TARGETS(MIE_TRAIT_TARGET_OP | MIE_TRAIT_TARGET_TYPE);
|
||||
MIE_TRAIT_DEFINITION_STRUCT(struct mie_trait);
|
||||
MIE_TRAIT_DEFINITION_VALIDATE(validate);
|
||||
MIE_TRAIT_DEFINITION_END()
|
||||
21
mie/dialect/select/graph-scope.c
Normal file
21
mie/dialect/select/graph-scope.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/macros.h>
|
||||
#include <mie/trait/trait-definition.h>
|
||||
#include <mie/trait/trait.h>
|
||||
|
||||
static enum mie_status validate(
|
||||
const struct mie_trait_definition *trait_def,
|
||||
const struct mie_trait *trait, const struct mie_trait_target *target)
|
||||
{
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
/* select.graph-scope trait:
|
||||
* regions of an op that has this trait are graph regions. graph regions
|
||||
* cannot have more than one block, and the entry block must be unnamed
|
||||
* with no parameters. However, graph ops can be used. */
|
||||
MIE_TRAIT_DEFINITION_BEGIN(mie_select_graph_scope, "graph-scope")
|
||||
MIE_TRAIT_DEFINITION_TARGETS(MIE_TRAIT_TARGET_OP | MIE_TRAIT_TARGET_TYPE);
|
||||
MIE_TRAIT_DEFINITION_STRUCT(struct mie_trait);
|
||||
MIE_TRAIT_DEFINITION_VALIDATE(validate);
|
||||
MIE_TRAIT_DEFINITION_END()
|
||||
21
mie/dialect/select/graph.c
Normal file
21
mie/dialect/select/graph.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/ir/op-definition.h>
|
||||
#include <mie/macros.h>
|
||||
#include <mie/trait/trait.h>
|
||||
|
||||
static enum mie_status print(const struct mie_op *op, b_stream *out)
|
||||
{
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
static enum mie_status parse(struct mie_parser *parser, struct mie_op *out)
|
||||
{
|
||||
return MIE_SUCCESS;
|
||||
}
|
||||
|
||||
MIE_OP_DEFINITION_BEGIN(mie_select_graph, "graph")
|
||||
MIE_OP_DEFINITION_PRINT(print);
|
||||
MIE_OP_DEFINITION_PARSE(parse);
|
||||
MIE_OP_DEFINITION_TRAIT("select", "graph-scope");
|
||||
MIE_OP_DEFINITION_END()
|
||||
9
mie/dialect/select/select.c
Normal file
9
mie/dialect/select/select.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <mie/dialect/dialect.h>
|
||||
#include <mie/macros.h>
|
||||
|
||||
MIE_DIALECT_BEGIN(mie_select, "select")
|
||||
MIE_DIALECT_ADD_TRAIT(mie_select_graph_only);
|
||||
MIE_DIALECT_ADD_TRAIT(mie_select_graph_op);
|
||||
MIE_DIALECT_ADD_TRAIT(mie_select_graph_scope);
|
||||
MIE_DIALECT_ADD_OP(mie_select_graph);
|
||||
MIE_DIALECT_END()
|
||||
11
mie/include/mie/dialect/select.h
Normal file
11
mie/include/mie/dialect/select.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef MIE_DIALECT_SELECT_H_
|
||||
#define MIE_DIALECT_SELECT_H_
|
||||
|
||||
#include <mie/misc.h>
|
||||
|
||||
struct mie_ctx;
|
||||
struct mie_dialect;
|
||||
|
||||
MIE_API struct mie_dialect *mie_select_dialect_create(struct mie_ctx *ctx);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user