diff --git a/mie/dialect/select/graph-only.c b/mie/dialect/select/graph-only.c new file mode 100644 index 0000000..c045900 --- /dev/null +++ b/mie/dialect/select/graph-only.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +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() diff --git a/mie/dialect/select/graph-op.c b/mie/dialect/select/graph-op.c new file mode 100644 index 0000000..59e2852 --- /dev/null +++ b/mie/dialect/select/graph-op.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +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() diff --git a/mie/dialect/select/graph-scope.c b/mie/dialect/select/graph-scope.c new file mode 100644 index 0000000..3232ce7 --- /dev/null +++ b/mie/dialect/select/graph-scope.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +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() diff --git a/mie/dialect/select/graph.c b/mie/dialect/select/graph.c new file mode 100644 index 0000000..0767a5b --- /dev/null +++ b/mie/dialect/select/graph.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include +#include + +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() diff --git a/mie/dialect/select/select.c b/mie/dialect/select/select.c new file mode 100644 index 0000000..90a4266 --- /dev/null +++ b/mie/dialect/select/select.c @@ -0,0 +1,9 @@ +#include +#include + +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() diff --git a/mie/include/mie/dialect/select.h b/mie/include/mie/dialect/select.h new file mode 100644 index 0000000..a0ac752 --- /dev/null +++ b/mie/include/mie/dialect/select.h @@ -0,0 +1,11 @@ +#ifndef MIE_DIALECT_SELECT_H_ +#define MIE_DIALECT_SELECT_H_ + +#include + +struct mie_ctx; +struct mie_dialect; + +MIE_API struct mie_dialect *mie_select_dialect_create(struct mie_ctx *ctx); + +#endif