unified mein file comments
[libfirm] / ir / be / bemachnode.h
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
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.
10  *
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.
14  *
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
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Support for machine nodes with machine operands.
23  * @author      Michael Beck
24  * @version     $Id$
25  */
26 #ifndef FIRM_BE_BEMACHNODES_H
27 #define FIRM_BE_BEMACHNODES_H
28
29 #include "irnode.h"
30
31 /*
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.
36  *
37  * The arity of a machine node is the number of leafs
38  * that are NOT machine operands.
39  *
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.
42  *
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 :-)
48  *
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.
52  *
53  * Moreover machine handles must be destroyed yet...
54  *
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 ...
58  */
59
60 /**
61  * The machine handle. A cache to access and set
62  * the predecessors (leafs) of a machine node.
63  */
64 typedef ir_node *** mirn_handle;
65
66 /**
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
70  * consecutive.
71  */
72 mirn_handle get_mirn_in(ir_node *n);
73
74 /** Frees a machine handle. */
75 void free_mirn_in(mirn_handle h);
76
77 /** Get the pos-th predecessor of a machine node represented by it's
78     handle.. */
79 ir_node *get_mirn_n(mirn_handle h, int pos);
80
81 /** Convenience: Get the pos-th predecessor of a machine node. */
82 ir_node *_get_mirn_n(ir_node *n, int pos);
83
84 /** Set the n-th predecessor of a machine node represented by it's
85     handle.. */
86 void set_mirn_n(mirn_handle h, int pos, ir_node *n);
87
88 /* Convenience: Set the pos-th predecessor of a machine node. */
89 void _set_mirn_n(ir_node *irn, int pos, ir_node *n);
90
91 /** Returns the arity (in terms of inputs) of a machine node represented by it's
92     handle. */
93 int get_mirn_arity(mirn_handle h);
94
95 /* Convenience: Returns the arity of a machine node. */
96 int _get_mirn_arity(ir_node *n);
97
98 #endif /* FIRM_BE_BEMACHNODES_H */