mie: builtin: initial implementation of a symbol system
the symbol system will allow ops to reference each other via symbolic names, rather than just via their SSA output registers. this will allow for links between ops that are less strict than SSA. the two parts of the system are: - the symbol-table trait. ops with this trait can contain symbol ops. - the symbol interface. ops with this interface have the necessary attributes to be treated as symbols.
This commit is contained in:
@@ -92,4 +92,6 @@ MIE_DIALECT_BEGIN(mie_builtin, struct builtin_dialect, "builtin")
|
||||
MIE_DIALECT_ADD_ATTRIBUTE(mie_builtin_int);
|
||||
MIE_DIALECT_ADD_ATTRIBUTE(mie_builtin_float);
|
||||
MIE_DIALECT_ADD_TRAIT(mie_builtin_isolated_from_above);
|
||||
MIE_DIALECT_ADD_TRAIT(mie_builtin_symbol_table);
|
||||
MIE_DIALECT_ADD_INTERFACE(mie_builtin_symbol);
|
||||
MIE_DIALECT_END()
|
||||
|
||||
7
mie/dialect/builtin/interface/symbol.c
Normal file
7
mie/dialect/builtin/interface/symbol.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <mie/dialect/builtin.h>
|
||||
#include <mie/interface/interface-definition.h>
|
||||
#include <mie/macros.h>
|
||||
|
||||
MIE_INTERFACE_DEFINITION_BEGIN(mie_builtin_symbol, "symbol")
|
||||
MIE_INTERFACE_DEFINITION_STRUCT(struct mie_symbol);
|
||||
MIE_INTERFACE_DEFINITION_END()
|
||||
21
mie/dialect/builtin/trait/symbol-table.c
Normal file
21
mie/dialect/builtin/trait/symbol-table.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <mie/dialect/builtin.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
/* builtin.isolated-from-above trait:
|
||||
* regions of an op that has this trait cannot capture or reference
|
||||
* values defined in the enclosing scope. */
|
||||
MIE_TRAIT_DEFINITION_BEGIN(mie_builtin_symbol_table, "symbol-table")
|
||||
MIE_TRAIT_DEFINITION_TARGETS(MIE_TRAIT_TARGET_OP | MIE_TRAIT_TARGET_TYPE);
|
||||
MIE_TRAIT_DEFINITION_STRUCT(struct mie_symbol_table);
|
||||
MIE_TRAIT_DEFINITION_VALIDATE(validate);
|
||||
MIE_TRAIT_DEFINITION_END()
|
||||
@@ -3,11 +3,14 @@
|
||||
|
||||
#include <blue/ds/string.h>
|
||||
#include <mie/attribute/attribute.h>
|
||||
#include <mie/interface/interface.h>
|
||||
#include <mie/misc.h>
|
||||
#include <mie/trait/trait.h>
|
||||
|
||||
struct mie_dialect;
|
||||
|
||||
struct mie_ctx;
|
||||
struct mie_op;
|
||||
struct mie_int_type;
|
||||
struct mie_float_type;
|
||||
|
||||
@@ -51,6 +54,15 @@ struct mie_index {
|
||||
size_t i_value;
|
||||
};
|
||||
|
||||
struct mie_symbol {
|
||||
struct mie_interface sym_base;
|
||||
const char *(*sym_get_name)(const struct mie_op *);
|
||||
};
|
||||
|
||||
struct mie_symbol_table {
|
||||
struct mie_trait tab_base;
|
||||
};
|
||||
|
||||
struct mie_int_cache;
|
||||
struct mie_float_cache;
|
||||
struct mie_string_cache;
|
||||
|
||||
Reference in New Issue
Block a user