105 lines
3.0 KiB
C
105 lines
3.0 KiB
C
#ifndef MIE_SELECT_NODE_H_
|
|
#define MIE_SELECT_NODE_H_
|
|
|
|
#include <blue/core/queue.h>
|
|
#include <mie/status.h>
|
|
#include <mie/type.h>
|
|
|
|
#define MIE_SELECT_NODE_OUTPUT_MAX 4
|
|
|
|
struct mie_target;
|
|
struct mie_value;
|
|
struct mie_select_value;
|
|
|
|
enum mie_select_node_flags {
|
|
MIE_SELECT_NODE_F_IVALUE = 0x01u,
|
|
MIE_SELECT_NODE_F_PVALUE = 0x02u,
|
|
};
|
|
|
|
struct mie_select_node {
|
|
size_t n_id;
|
|
unsigned long n_opcode;
|
|
enum mie_select_node_flags n_flags;
|
|
|
|
char *n_description;
|
|
|
|
/* certain "builtin" parameters that can be used by opcodes */
|
|
struct {
|
|
struct mie_value *v;
|
|
long long i;
|
|
void *p;
|
|
} n_value;
|
|
|
|
/* queue entry, links to mie_select_graph.g_nodes */
|
|
b_queue_entry n_entry;
|
|
|
|
/* linked lists of struct mie_select_use,
|
|
* listing all the places where this node is being used as an
|
|
* operand.
|
|
* these pointers point to data in another node's n_operands,
|
|
* and the memory belongs to these other nodes, not us.
|
|
*/
|
|
b_queue n_use;
|
|
|
|
/* array of struct mie_select_use
|
|
* listing all the nodes that are being used as operands by
|
|
* this node. other nodes hold pointers to these mie_select_use array
|
|
* entries as part of their n_use queue.
|
|
*/
|
|
struct mie_select_use *n_operands;
|
|
size_t n_nr_operands;
|
|
|
|
/* array of struct mie_type pointers
|
|
* listing the types of the values that are produced as outputs by
|
|
* this node. the type pointers themselves are owned by a mie_ctx.
|
|
*/
|
|
struct mie_type **n_results;
|
|
size_t n_nr_results;
|
|
|
|
/* the target system that provides the operation described by n_opcode. */
|
|
const struct mie_target *n_target;
|
|
};
|
|
|
|
struct mie_select_node_iterator {
|
|
b_queue_entry *it_ptr;
|
|
};
|
|
|
|
static inline struct mie_select_node *mie_select_node_iterator_unbox(
|
|
struct mie_select_node_iterator *it)
|
|
{
|
|
return b_unbox(struct mie_select_node, it->it_ptr, n_entry);
|
|
}
|
|
|
|
MIE_API void mie_select_node_iterator_next(struct mie_select_node_iterator *it);
|
|
MIE_API bool mie_select_node_iterator_is_valid(
|
|
const struct mie_select_node_iterator *it);
|
|
|
|
MIE_API struct mie_select_node *mie_select_node_create(
|
|
const struct mie_target *target, unsigned int op,
|
|
struct mie_type **results, size_t nr_results);
|
|
MIE_API void mie_select_node_destroy(struct mie_select_node *node);
|
|
|
|
MIE_API enum mie_status mie_select_node_set_operands(
|
|
struct mie_select_node *node, struct mie_select_value *operands,
|
|
size_t nr_operands);
|
|
MIE_API enum mie_status mie_select_node_clear_operands(struct mie_select_node *node);
|
|
|
|
MIE_API void mie_select_node_get_users(
|
|
struct mie_select_node *node, struct mie_select_node_iterator *it);
|
|
MIE_API void mie_select_node_get_uses(
|
|
struct mie_select_node *node, struct mie_select_node_iterator *it);
|
|
|
|
MIE_API enum mie_status mie_select_node_get_value(
|
|
struct mie_select_node *node, struct mie_type *type, size_t index,
|
|
struct mie_select_value *out);
|
|
|
|
MIE_API enum mie_status mie_select_node_set_description(
|
|
struct mie_select_node *node, const char *format, ...);
|
|
|
|
MIE_API struct mie_select_node *mie_select_node_get_glued_node(
|
|
struct mie_select_node *node);
|
|
MIE_API struct mie_select_node *mie_select_node_get_glued_user(
|
|
struct mie_select_node *node);
|
|
|
|
#endif
|