2 * Support for machine nodes with machine operands.
9 #include "firm_types.h"
12 * Machine nodes can have machine operands as inputs.
13 * Machine operands are trees of other machine operands.
14 * The leafs of machine operands are normal Firm nodes
15 * or a machine operand with arity 0.
17 * The arity of a machine node is the number of leafs
18 * that are NOT machine operands.
20 * For instance Add(x, Const) have the arity 1 if Const is a
21 * machine operand, Add(x, ADR(b, i)) have arity 3.
23 * We simulate the the normal concept of get_irn_n/set_irn_n.
24 * Instead of the node machine handle are used which are just
25 * caches for the leaf positions of a machine node.
26 * This means, it is only possible to manipulate the leafs!
27 * Do not mix _mirn_ and _irn_ calls or terrible things can happen :-)
29 * Note further that currently the number of ins for a machine
30 * instruction is limited to 8 + arity of Firm node which means
31 * up to 8 registers can be added due to machine operands.
33 * Moreover machine handles must be destroyed yet...
35 * The convenience functions create the handle and drop it at the end.
36 * as operands are seldom, they have a complexity of O(#predecessors)
37 * which is near to O(1) for most node but use them seldom ...
41 * The machine handle. A cache to access and set
42 * the predecessors (leafs) of a machine node.
44 typedef ir_node *** mirn_handle;
47 * Returns the machine handle for a machine node with machine operands.
48 * The order of the predecessors in this handle is not guaranteed, except that
49 * lists of operands as predecessors of Block or arguments of a Call are
52 mirn_handle get_mirn_in(ir_node *n);
54 /** Frees a machine handle. */
55 void free_mirn_in(mirn_handle h);
57 /** Get the pos-th predecessor of a machine node represented by it's
59 ir_node *get_mirn_n(mirn_handle h, int pos);
61 /** Convenience: Get the pos-th predecessor of a machine node. */
62 ir_node *_get_mirn_n(ir_node *n, int pos);
64 /** Set the n-th predecessor of a machine node represented by it's
66 void set_mirn_n(mirn_handle h, int pos, ir_node *n);
68 /* Convenience: Set the pos-th predecessor of a machine node. */
69 void _set_mirn_n(ir_node *irn, int pos, ir_node *n);
71 /** Returns the arity (in terms of inputs) of a machine node represented by it's
73 int get_mirn_arity(mirn_handle h);
75 /* Convenience: Returns the arity of a machine node. */
76 int _get_mirn_arity(ir_node *n);
78 #endif /* _BEMACHNODES_H */