mie: add IR data structures
This commit is contained in:
21
mie/include/mie/ir/block.h
Normal file
21
mie/include/mie/ir/block.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef MIE_IR_BLOCK_H_
|
||||||
|
#define MIE_IR_BLOCK_H_
|
||||||
|
|
||||||
|
#include <blue/core/queue.h>
|
||||||
|
#include <mie/misc.h>
|
||||||
|
#include <mie/name.h>
|
||||||
|
#include <mie/vector.h>
|
||||||
|
|
||||||
|
struct mie_op;
|
||||||
|
struct mie_register;
|
||||||
|
|
||||||
|
struct mie_block {
|
||||||
|
struct mie_name b_name;
|
||||||
|
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_register, b_params);
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_op, b_ops);
|
||||||
|
};
|
||||||
|
|
||||||
|
MIE_API struct mie_op *mie_block_add_op(struct mie_block *block);
|
||||||
|
|
||||||
|
#endif
|
||||||
21
mie/include/mie/ir/module.h
Normal file
21
mie/include/mie/ir/module.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef MIE_IR_MODULE_H_
|
||||||
|
#define MIE_IR_MODULE_H_
|
||||||
|
|
||||||
|
#include <mie/misc.h>
|
||||||
|
#include <mie/name.h>
|
||||||
|
#include <mie/vector.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
struct mie_op;
|
||||||
|
|
||||||
|
struct mie_module {
|
||||||
|
struct mie_name_map *m_names;
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_op, m_ops);
|
||||||
|
};
|
||||||
|
|
||||||
|
MIE_API struct mie_module *mie_module_create(void);
|
||||||
|
MIE_API void mie_module_destroy(struct mie_module *mod);
|
||||||
|
|
||||||
|
MIE_API struct mie_op *mie_module_add_op(struct mie_module *mod);
|
||||||
|
|
||||||
|
#endif
|
||||||
55
mie/include/mie/ir/op.h
Normal file
55
mie/include/mie/ir/op.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#ifndef MIE_IR_OP_H_
|
||||||
|
#define MIE_IR_OP_H_
|
||||||
|
|
||||||
|
#include "mie/vector.h"
|
||||||
|
|
||||||
|
#include <mie/misc.h>
|
||||||
|
#include <mie/name.h>
|
||||||
|
|
||||||
|
struct mie_type;
|
||||||
|
|
||||||
|
struct mie_value;
|
||||||
|
struct mie_block;
|
||||||
|
struct mie_region;
|
||||||
|
struct mie_register;
|
||||||
|
|
||||||
|
struct mie_dialect;
|
||||||
|
struct mie_dialect_op;
|
||||||
|
|
||||||
|
enum mie_op_flags {
|
||||||
|
MIE_OP_F_RESOLVED = 0x01u,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mie_op_successor {
|
||||||
|
struct mie_block *s_block;
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_register *, s_params);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mie_op_attribute {
|
||||||
|
char *attrib_name;
|
||||||
|
struct mie_value *attrib_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mie_op {
|
||||||
|
enum mie_op_flags op_flags;
|
||||||
|
|
||||||
|
/* these pointers are only valid if the F_RESOLVED flag is set */
|
||||||
|
const struct mie_dialect *op_dialect;
|
||||||
|
const struct mie_dialect_op *op_info;
|
||||||
|
|
||||||
|
/* this pointer is only valid if the F_RESOLVED flag is NOT set */
|
||||||
|
char *op_name;
|
||||||
|
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_region, op_regions);
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_op_successor, op_successors);
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_op_attribute, op_attrib);
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_register *, op_args);
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_register, op_result);
|
||||||
|
};
|
||||||
|
|
||||||
|
MIE_API void mie_op_destroy(struct mie_op *op);
|
||||||
|
|
||||||
|
MIE_API struct mie_region *mie_op_add_region(struct mie_op *op);
|
||||||
|
MIE_API struct mie_op_successor *mie_op_add_successor(struct mie_op *op);
|
||||||
|
|
||||||
|
#endif
|
||||||
17
mie/include/mie/ir/region.h
Normal file
17
mie/include/mie/ir/region.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef MIE_IR_REGION_H_
|
||||||
|
#define MIE_IR_REGION_H_
|
||||||
|
|
||||||
|
#include <mie/misc.h>
|
||||||
|
#include <mie/vector.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
struct mie_block;
|
||||||
|
|
||||||
|
struct mie_region {
|
||||||
|
struct mie_name_map *r_names;
|
||||||
|
MIE_VECTOR_DECLARE(struct mie_block, r_blocks);
|
||||||
|
};
|
||||||
|
|
||||||
|
MIE_API struct mie_block *mie_region_add_block(struct mie_region *region);
|
||||||
|
|
||||||
|
#endif
|
||||||
38
mie/include/mie/ir/register.h
Normal file
38
mie/include/mie/ir/register.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef MIE_IR_REGISTER_H_
|
||||||
|
#define MIE_IR_REGISTER_H_
|
||||||
|
|
||||||
|
#include <mie/name.h>
|
||||||
|
|
||||||
|
struct mie_target_register;
|
||||||
|
|
||||||
|
enum mie_register_flags {
|
||||||
|
MIE_REGISTER_F_NONE = 0,
|
||||||
|
MIE_REGISTER_F_OP_RESULT = 0x01u,
|
||||||
|
MIE_REGISTER_F_OP_PARAM = 0x02u,
|
||||||
|
MIE_REGISTER_F_BLOCK_PARAM = 0x04u,
|
||||||
|
|
||||||
|
MIE_REGISTER_F_VIRTUAL = 0x10u,
|
||||||
|
MIE_REGISTER_F_MACHINE = 0x20u,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mie_register {
|
||||||
|
enum mie_register_flags reg_flags;
|
||||||
|
struct mie_name reg_name;
|
||||||
|
/* only valid if F_MACHINE is set. */
|
||||||
|
struct mie_target_register *reg_mach;
|
||||||
|
struct mie_type *reg_value_type;
|
||||||
|
/* if this is an OP_RESULT register, this points to the block within
|
||||||
|
* which this register is defined.
|
||||||
|
* if this is an OP_PARAM register, this pointer is NULL.
|
||||||
|
* if this is a BLOCK_PARAM register, this points to the block for
|
||||||
|
* which this register is a parameter. */
|
||||||
|
struct mie_block *reg_block;
|
||||||
|
/* if this is an OP_RESULT register, this points to the operation
|
||||||
|
* that defines the register.
|
||||||
|
* if this is an OP_PARAM register, this points to the operation
|
||||||
|
* for which this register is a parameter
|
||||||
|
* if this is a BLOCK_PARAM register, this pointer is NULL */
|
||||||
|
struct mie_op *reg_op;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user