2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * Support for machine nodes with machine operands.
23 * @author Michael Beck
25 #ifndef _BEMACHNODES_H
26 #define _BEMACHNODES_H
28 #include "firm_types.h"
31 * Machine nodes can have machine operands as inputs.
32 * Machine operands are trees of other machine operands.
33 * The leafs of machine operands are normal Firm nodes
34 * or a machine operand with arity 0.
36 * The arity of a machine node is the number of leafs
37 * that are NOT machine operands.
39 * For instance Add(x, Const) have the arity 1 if Const is a
40 * machine operand, Add(x, ADR(b, i)) have arity 3.
42 * We simulate the the normal concept of get_irn_n/set_irn_n.
43 * Instead of the node machine handle are used which are just
44 * caches for the leaf positions of a machine node.
45 * This means, it is only possible to manipulate the leafs!
46 * Do not mix _mirn_ and _irn_ calls or terrible things can happen :-)
48 * Note further that currently the number of ins for a machine
49 * instruction is limited to 8 + arity of Firm node which means
50 * up to 8 registers can be added due to machine operands.
52 * Moreover machine handles must be destroyed yet...
54 * The convenience functions create the handle and drop it at the end.
55 * as operands are seldom, they have a complexity of O(#predecessors)
56 * which is near to O(1) for most node but use them seldom ...
60 * The machine handle. A cache to access and set
61 * the predecessors (leafs) of a machine node.
63 typedef ir_node *** mirn_handle;
66 * Returns the machine handle for a machine node with machine operands.
67 * The order of the predecessors in this handle is not guaranteed, except that
68 * lists of operands as predecessors of Block or arguments of a Call are
71 mirn_handle get_mirn_in(ir_node *n);
73 /** Frees a machine handle. */
74 void free_mirn_in(mirn_handle h);
76 /** Get the pos-th predecessor of a machine node represented by it's
78 ir_node *get_mirn_n(mirn_handle h, int pos);
80 /** Convenience: Get the pos-th predecessor of a machine node. */
81 ir_node *_get_mirn_n(ir_node *n, int pos);
83 /** Set the n-th predecessor of a machine node represented by it's
85 void set_mirn_n(mirn_handle h, int pos, ir_node *n);
87 /* Convenience: Set the pos-th predecessor of a machine node. */
88 void _set_mirn_n(ir_node *irn, int pos, ir_node *n);
90 /** Returns the arity (in terms of inputs) of a machine node represented by it's
92 int get_mirn_arity(mirn_handle h);
94 /* Convenience: Returns the arity of a machine node. */
95 int _get_mirn_arity(ir_node *n);
97 #endif /* _BEMACHNODES_H */