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
22 * @brief Support for machine nodes with machine operands.
23 * @author Michael Beck
26 #ifndef FIRM_BE_BEMACHNODES_H
27 #define FIRM_BE_BEMACHNODES_H
29 #include "firm_types.h"
32 * Machine nodes can have machine operands as inputs.
33 * Machine operands are trees of other machine operands.
34 * The leafs of machine operands are normal Firm nodes
35 * or a machine operand with arity 0.
37 * The arity of a machine node is the number of leafs
38 * that are NOT machine operands.
40 * For instance Add(x, Const) have the arity 1 if Const is a
41 * machine operand, Add(x, ADR(b, i)) have arity 3.
43 * We simulate the the normal concept of get_irn_n/set_irn_n.
44 * Instead of the node machine handle are used which are just
45 * caches for the leaf positions of a machine node.
46 * This means, it is only possible to manipulate the leafs!
47 * Do not mix _mirn_ and _irn_ calls or terrible things can happen :-)
49 * Note further that currently the number of ins for a machine
50 * instruction is limited to 8 + arity of Firm node which means
51 * up to 8 registers can be added due to machine operands.
53 * Moreover machine handles must be destroyed yet...
55 * The convenience functions create the handle and drop it at the end.
56 * as operands are seldom, they have a complexity of O(#predecessors)
57 * which is near to O(1) for most node but use them seldom ...
61 * The machine handle. A cache to access and set
62 * the predecessors (leafs) of a machine node.
64 typedef ir_node *** mirn_handle;
67 * Returns the machine handle for a machine node with machine operands.
68 * The order of the predecessors in this handle is not guaranteed, except that
69 * lists of operands as predecessors of Block or arguments of a Call are
72 mirn_handle get_mirn_in(ir_node *n);
74 /** Frees a machine handle. */
75 void free_mirn_in(mirn_handle h);
77 /** Get the pos-th predecessor of a machine node represented by it's
79 ir_node *get_mirn_n(mirn_handle h, int pos);
81 /** Convenience: Get the pos-th predecessor of a machine node. */
82 ir_node *_get_mirn_n(ir_node *n, int pos);
84 /** Set the n-th predecessor of a machine node represented by it's
86 void set_mirn_n(mirn_handle h, int pos, ir_node *n);
88 /* Convenience: Set the pos-th predecessor of a machine node. */
89 void _set_mirn_n(ir_node *irn, int pos, ir_node *n);
91 /** Returns the arity (in terms of inputs) of a machine node represented by it's
93 int get_mirn_arity(mirn_handle h);
95 /* Convenience: Returns the arity of a machine node. */
96 int _get_mirn_arity(ir_node *n);
98 #endif /* FIRM_BE_BEMACHNODES_H */