a061508e673f615806da267119f7461db16d6fce
[libfirm] / include / libfirm / ircons.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   Various irnode constructors. Automatic construction of SSA
23  *          representation.
24  * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Boris Boesler,
25  *          Michael Beck
26  * @version $Id$
27  */
28
29 /**@todo
30  Ideas for improvement:
31  -# Handle construction of exceptions more comfortable:
32     Add new constructors that pass the exception region (or better the
33     Phi for the memories, the ex. region can be found from there) as parameter,
34     constructor then adds all Proj nodes and returns the pointer
35     to the Proj node that selects the result of the arithmetic operation.
36  -# Maybe hide the exception region in a global variable, especially if
37     it is always unambiguous.
38 */
39
40 /**
41  *  @file
42  *
43  *  documentation no more supported since 2001
44  *
45  *  ir node construction.
46  *
47  *    This file documents all datatypes and constructors needed to
48  *    build a FIRM representation of a procedure.  The constructors are
49  *    also implemented in this file.
50  *
51  *    The documentation also gives a short manual how to use the library.
52  *
53  *    For extensive documentation of FIRM see UKA Techreport 1999-14.
54  *
55  *
56  *    Three kinds of nodes
57  *    --------------------
58  *
59  *      There are three kinds of nodes known to the ir:  entities,
60  *      types, and ir_nodes
61  *
62  *      + ir_nodes are the actual nodes of the FIRM intermediate representation.
63  *        They represent operations on the data of the program and control flow
64  *        operations.
65  *
66  *      + entity ==> implemented in entity.h
67  *        Refers to a single entity of the compiled program, e.g. a field of a
68  *        class or a method.  If a method or variable can not be assigned to
69  *        a method or class or the like, it is a global object.
70  *
71  *      + types ==> implemented in type.h
72  *        With types type information is represented.  There are several type
73  *       nodes.
74  *
75  *    Implementation of the FIRM operations: ir_node
76  *    ----------------------------------------------
77  *
78  *      Ir_nodes represent operations on the data of the program and control flow
79  *      operations.  Examples of ir_nodes:  Add, Jmp, Cmp
80  *
81  *      FIRM is a dataflow graph.  A dataflow graph is a directed graph,
82  *      so that every node has incoming and outgoing edges.  A node is
83  *      executable if every input at it's incoming edges is available.
84  *      Execution of the dataflow graph is started at the Start node which
85  *      has no incoming edges and ends when the End node executes, even if
86  *      there are still executable or not executed nodes.  (Is this true,
87  *      or must all executable nodes be executed?)  (There are exceptions
88  *      to the dataflow paradigma that all inputs have to be available
89  *      before a node can execute: Phi, Block.  See UKA Techreport
90  *      1999-14.)
91  *
92  *      The implementation of FIRM differs from the view as a dataflow
93  *      graph.  To allow fast traversion of the graph edges are
94  *      implemented as C-pointers.  Inputs to nodes are not ambiguous, the
95  *      results can be used by several other nodes.  Each input can be
96  *      implemented as a single pointer to a predecessor node, outputs
97  *      need to be lists of pointers to successors.  Therefore a node
98  *      contains pointers to it's predecessor so that the implementation is a
99  *      dataflow graph with reversed edges.  It has to be traversed bottom
100  *      up.
101  *
102  *      All nodes of the ir have the same basic structure.  They are
103  *      distinguished by a field containing the opcode.
104  *
105  *      The fields of an ir_node:
106  *
107  *      kind             A firm_kind tag containing k_ir_node.  This is useful for
108  *                       dynamically checking the type of a node.
109  *
110  *      *op              This ir_op gives the opcode as a tag and a string
111  *                       and the number of attributes of an ir_node.  There is
112  *                       one statically allocated struct ir_op for each opcode.
113  *
114  *      *mode            The ir_mode of the operation represented by this firm
115  *                      node.  The mode of the operation is the mode of it's
116  *                       result.  A Firm mode is a datatype as known to the target,
117  *               not a type of the source language.
118  *
119  *      visit            A flag for traversing the ir.
120  *
121  *      **in             An array with pointers to the node's predecessors.
122  *
123  *      *link            A pointer to an ir_node.  With this pointer all Phi nodes
124  *                       are attached to a Block, i.e., a Block points to it's
125  *                       first Phi node, this node points to the second Phi node
126  *                       in the Block and so fourth.  Used in mature_immBlock
127  *                       to find all Phi nodes to be matured.  It's also used to
128  *               annotate a node with a better, optimized version of it.
129  *
130  *      attr             An attr struct containing the attributes of the nodes. The
131  *                       attributes depend on the opcode of the node.  The number
132  *               of these attributes is given in op.
133  *
134  *    The struct ir_op
135  *    ----------------
136  *                       Not yet documented. See irop.h.
137  *
138  *    The struct ir_mode
139  *    ------------------
140  *                       Not yet documented. See irmode.h.
141  *
142  *    GLOBAL VARIABLES -- now also fields of ir_graph.
143  *    ================
144  *
145  *    current_ir_graph   Points to the current ir_graph.  All constructors for
146  *                      nodes add nodes to this graph.
147  *
148  *    ir_visited         An int used as flag to traverse the ir_graph.
149  *
150  *    block_visited      An int used as a flag to traverse block nodes in the
151  *                       graph.
152  *
153  *                       Others not yet documented.
154  *
155  *
156  *
157  *    CONSTRUCTOR FOR IR_GRAPH --> see irgraph.h
158  *    ========================
159  *
160  *
161  *    PROCEDURE TO CONSTRUCT AN IR GRAPH --> see also Firm tutorial
162  *    ==================================
163  *
164  *    This library supplies several interfaces to construct a FIRM graph for
165  *    a program:
166  *    - A "comfortable" interface generating SSA automatically.  Automatically
167  *      computed predecessors of nodes need not be specified in the constructors.
168  *      (new_<Node> constructurs and a set of additional routines.)
169  *    - A less comfortable interface where all predecessors except the block
170  *      an operation belongs to need to be specified.  SSA must be constructed
171  *      by hand.  (new_<Node> constructors and set_cur_block()).  This interface
172  *      is called "block oriented".  It automatically calles the local optimizations
173  *      for each new node.
174  *    - An even less comfortable interface where the block needs to be specified
175  *      explicitly.  This is called the "raw" interface. (new_r_<Node>
176  *      constructors).  These nodes are not optimized.
177  *
178  *    To use the functionality of the comfortable interface correctly the Front
179  *    End needs to follow certain protocols.  This is explained in the following.
180  *    To build a correct IR with the other interfaces study the semantics of
181  *    the firm node (See tech-reprot UKA 1999-14).  For the construction of
182  *    types and entities see the documentation in those modules.
183  *
184  *    First the Frontend needs to decide which variables and values used in
185  *    a procedure can be represented by dataflow edges.  These are variables
186  *    that need not be saved to memory as they cause no side effects visible
187  *    out of the procedure.  Often these are all compiler generated
188  *    variables and simple local variables of the procedure as integers,
189  *    reals and pointers.  The frontend has to count and number these variables.
190  *
191  *    First an ir_graph needs to be constructed with new_ir_graph.  The
192  *    constructor gets the number of local variables.  The graph is hold in the
193  *    global variable irg.
194  *
195  *    Now the construction of the procedure can start.  Several basic blocks can
196  *    be constructed in parallel, but the code within each block needs to
197  *    be constructed (almost) in program order.
198  *
199  *    A global variable holds the current basic block.  All (non block) nodes
200  *    generated are added to this block.  The current block can be set with
201  *    set_cur_block(block).  If several blocks are constructed in parallel block
202  *    switches need to be performed constantly.
203  *
204  *    To generate a Block node (with the comfortable interface) it's predecessor
205  *    control flow nodes need not be known.  In case of cyclic control flow these
206  *    can not be known when the block is constructed.  With add_immBlock_pred(block,
207  *    cfnode) predecessors can be added to the block.  If all predecessors are
208  *    added to the block mature_immBlock(b) needs to be called.  Calling mature_immBlock
209  *    early improves the efficiency of the Phi node construction algorithm.
210  *    But if several  blocks are constructed at once, mature_immBlock must only
211  *    be called after performing all set_values and set_stores in the block!
212  *    (See documentation of new_immBlock constructor.)
213  *
214  *    The constructors of arithmetic nodes require that their predecessors
215  *    are mentioned.  Sometimes these are available in the Frontend as the
216  *    predecessors have just been generated by the frontend.  If they are local
217  *    values the predecessors can be obtained from the library with a call to
218  *    get_value(local_val_nr).  (local_val_nr needs to be administered by
219  *    the Frontend.)  A call to get_value triggers the generation of Phi nodes.
220  *    If an arithmetic operation produces a local value this value needs to be
221  *    passed to the library by set_value(node, local_val_nr).
222  *    In straight line code these two operations just remember and return the
223  *    pointer to nodes producing the value.  If the value passes block boundaries
224  *    Phi nodes can be inserted.
225  *    Similar routines exist to manage the Memory operands: set_store and
226  *    get_store.
227  *
228  *    Several nodes produce more than one result.  An example is the Div node.
229  *    Such nodes return tuples of values.  From these individual values can be
230  *    extracted by proj nodes.
231  *
232  *    The following example illustrates the construction of a simple basic block
233  *    with two predecessors stored in variables cf_pred1 and cf_pred2, containing
234  *    the code
235  *      a = a div a;
236  *    and finally jumping to an other block.  The variable a got the local_val_nr
237  *    42 by the frontend.
238  *
239  *    ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
240  *
241  *    this_block = new_immBlock();
242  *    add_immBlock_pred(this_block, cf_pred1);
243  *    add_immBlock_pred(this_block, cf_pred2);
244  *    mature_immBlock(this_block);
245  *    a_val = get_value(42, mode_Iu);
246  *    mem = get_store();
247  *    div = new_Div(mem, a_val, a_val, mode_Iu);
248  *    mem = new_Proj(div, mode_M, pn_Div_M);   * for the numbers for Proj see docu *
249  *    res = new_Proj(div, mode_Iu, pn_Div_res);
250  *    set_store(mem);
251  *    set_value(res, 42);
252  *    cf_op = new_Jmp();
253  *
254  *    For further information look at the documentation of the nodes and
255  *    constructors and at the paragraph COPING WITH DATA OBJECTS at the
256  *    end of this documentation.
257  *
258  *    The comfortable interface contains the following routines further explained
259  *    below:
260  *
261  *    ir_node *new_immBlock (void);
262  *    ir_node *new_Start    (void);
263  *    ir_node *new_End      (void);
264  *    ir_node *new_Jmp      (void);
265  *    ir_node *new_IJmp     (ir_node *tgt);
266  *    ir_node *new_Cond     (ir_node *c);
267  *    ir_node *new_Return   (ir_node *store, int arity, ir_node **in);
268  *    ir_node *new_Const    (ir_mode *mode, tarval *con);
269  *    ir_node *new_SymConst (symconst_symbol value, symconst_kind kind);
270  *    ir_node *new_simpleSel (ir_node *store, ir_node *objptr, ir_entity *ent);
271  *    ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity,
272  *                         ir_node **in, ir_entity *ent);
273  *    ir_node *new_Call   (ir_node *store, ir_node *callee, int arity,
274  *                 ir_node **in, type_method *type);
275  *    ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode);
276  *    ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode);
277  *    ir_node *new_Minus  (ir_node *op,  ir_mode *mode);
278  *    ir_node *new_Mul    (ir_node *op1, ir_node *op2, ir_mode *mode);
279  *    ir_node *new_Quot   (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
280  *    ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
281  *    ir_node *new_Div    (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
282  *    ir_node *new_Mod    (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
283  *    ir_node *new_Abs    (ir_node *op,                ir_mode *mode);
284  *    ir_node *new_And    (ir_node *op1, ir_node *op2, ir_mode *mode);
285  *    ir_node *new_Or     (ir_node *op1, ir_node *op2, ir_mode *mode);
286  *    ir_node *new_Eor    (ir_node *op1, ir_node *op2, ir_mode *mode);
287  *    ir_node *new_Not    (ir_node *op,                ir_mode *mode);
288  *    ir_node *new_Shl    (ir_node *op,  ir_node *k,   ir_mode *mode);
289  *    ir_node *new_Shr    (ir_node *op,  ir_node *k,   ir_mode *mode);
290  *    ir_node *new_Shrs   (ir_node *op,  ir_node *k,   ir_mode *mode);
291  *    ir_node *new_Rot    (ir_node *op,  ir_node *k,   ir_mode *mode);
292  *    ir_node *new_Cmp    (ir_node *op1, ir_node *op2);
293  *    ir_node *new_Conv   (ir_node *op, ir_mode *mode);
294  *    ir_node *new_Cast   (ir_node *op, ir_type *to_tp);
295  *    ir_node *new_Carry  (ir_node *op1, ir_node *op2, ir_mode *mode);
296  *    ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
297  *    ir_node *new_Load   (ir_node *store, ir_node *addr, ir_mode *mode);
298  *    ir_node *new_Store  (ir_node *store, ir_node *addr, ir_node *val);
299  *    ir_node *new_Alloc  (ir_node *store, ir_node *size, ir_type *alloc_type,
300  *                         where_alloc where);
301  *    ir_node *new_Free   (ir_node *store, ir_node *ptr, ir_node *size,
302  *               ir_type *free_type, where_alloc where);
303  *    ir_node *new_Proj   (ir_node *arg, ir_mode *mode, long proj);
304  *    ir_node *new_NoMem  (void);
305  *    ir_node *new_Mux    (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
306  *    ir_node *new_Psi    (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
307  *    ir_node *new_CopyB  (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
308  *    ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
309  *    ir_node *new_Raise  (ir_node *store, ir_node *obj);
310  *    ir_node *new_Bound  (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
311  *    ir_node *new_Pin    (ir_node *node);
312  *
313  *    void add_immBlock_pred (ir_node *block, ir_node *jmp);
314  *    void mature_immBlock (ir_node *block);
315  *    void set_cur_block (ir_node *target);
316  *    ir_node *get_value (int pos, ir_mode *mode);
317  *    void set_value (int pos, ir_node *value);
318  *    ir_node *get_store (void);
319  *    void set_store (ir_node *store);
320  *    keep_alive (ir_node ka)
321  *
322  *    IR_NODES AND CONSTRUCTORS FOR IR_NODES
323  *    =======================================
324  *
325  *    All ir_nodes are defined by a common data structure.  They are distinguished
326  *    by their opcode and differ in the number of their attributes.
327  *
328  *    The constructor for the block node sets current_block to itself.
329  *    Const nodes are always added to the start block.
330  *    All other constructors add the created node to the current_block.
331  *    swich_block(block) allows to set the current block to block.
332  *
333  *    Watch for my inconsistent use of input and predecessor (dataflow view)
334  *    and `the node points to' (implementation view).
335  *
336  *    The following description of the nodes lists four properties them if these
337  *    are of interest:
338  *     - the parameters to the constructor
339  *     - the inputs of the Firm node
340  *     - the outputs of the Firm node
341  *     - attributes to the node
342  *
343  *    ------------
344  *
345  *    ir_node *new_immBlock (void)
346  *    ----------------------------
347  *
348  *    Creates a new block.  Sets current_block to itself.  When a new block is
349  *    created it cannot be known how many predecessors this block will have in the
350  *    control flow graph. Therefore the list of inputs can not be fixed at
351  *    creation.  Predecessors can be added with add_immBlock_pred (block, control flow
352  *    operation).  With every added predecessor the number of inputs to Phi nodes
353  *    also changes.
354  *
355  *    The block can be completed by mature_immBlock(block) if all predecessors are
356  *    known.  If several blocks are built at once, mature_immBlock can only be called
357  *    after set_value has been called for all values that are life at the end
358  *    of the block.  This is necessary so that Phi nodes created mature_immBlock
359  *    get the right predecessors in case of cyclic dependencies.  If all set_values
360  *    of this block are called after maturing it and before calling get_value
361  *    in some block that is control flow dependent on this block, the construction
362  *    is correct.
363  *
364  *    Example for faulty ir construction:  (draw the graph on a paper and you'll
365  *                                          get it ;-)
366  *
367  *      block_before_loop = new_block();
368  *      set_value(x);
369  *      mature_immBlock(block_before_loop);
370  *      before2header = new_Jmp;
371  *
372  *      loop_header = new_block ();
373  *      header2body - new_Jmp();
374  *
375  *      loop_body = new_block ();
376  *      body2header = new_Jmp();
377  *
378  *      add_immBlock_pred(loop_header, before2header);
379  *      add_immBlock_pred(loop_header, body2header);
380  *      add_immBlock_pred(loop_body, header2body);
381  *
382  *      mature_immBlock(loop_header);
383  *      mature_immBlock(loop_body);
384  *
385  *      get_value(loop_body, x);   //  gets the Phi in loop_header
386  *      set_value(loop_header, x); //  sets the value the above get_value should
387  *                                 //  have returned!!!
388  *
389  *    Mature_immBlock also fixes the number of inputs to the Phi nodes.  Mature_immBlock
390  *    should be called as early as possible, as afterwards the generation of Phi
391  *   nodes is more efficient.
392  *
393  *    Inputs:
394  *      There is an input for each control flow predecessor of the block.
395  *      The input points to an instruction producing an output of type X.
396  *      Possible predecessors:  Start, Jmp, Cond, Raise or Return or any node
397  *      possibly causing an exception.  (Often the real predecessors are Projs.)
398  *    Output:
399  *      Mode BB (R), all nodes belonging to this block should consume this output.
400  *      As they are strict (except Block and Phi node) it is a necessary condition
401  *      that the block node executed before any other node in this block executes.
402  *    Attributes:
403  *      block.matured  Indicates whether the block is mature.
404  *      block.**graph_arr
405  *                      This attribute contains all local values valid in this
406  *                      block. This is needed to build the Phi nodes and removed
407  *                      if the graph is complete.  This field is used by the
408  *              internal construction algorithm and should not be accessed
409  *              from outside.
410  *
411  *
412  *    ir_node *new_Block (int arity, ir_node **in)
413  *    --------------------------------------------
414  *
415  *    Creates a new Block with the given list of predecessors.  This block
416  *    is mature.  As other constructors calls optimization and vrfy for the
417  *    block.  If one of the predecessors is Unknown (as it has to be filled in
418  *    later) optimizations are skipped.  This is necessary to
419  *    construct Blocks in loops.  Leaving Unknown in the Block after finishing
420  *    the construction may have strange effects, especially for interprocedural
421  *    representation and analysis.
422  *
423  *
424  *    CONTROL FLOW OPERATIONS
425  *    -----------------------
426  *
427  *    In each block there must be exactly one of the control flow
428  *    operations Start, End, Jmp, Cond, Return or Raise.  The output of a
429  *    control flow operation points to the block to be executed next.
430  *
431  *    ir_node *new_Start (void)
432  *    -------------------------
433  *
434  *    Creates a start node.  Not actually needed public.  There is only one such
435  *   node in each procedure which is automatically created by new_ir_graph.
436  *
437  *    Inputs:
438  *      No inputs except the block it belogns to.
439  *    Output:
440  *      A tuple of 4 (5, 6) distinct values. These are labeled by the following
441  *      projection numbers (pn_Start):
442  *      * pn_Start_X_initial_exec    mode X, points to the first block to be exe *                                   cuted.
443  *      * pn_Start_M                 mode M, the global store
444  *      * pn_Start_P_frame_base      mode P, a pointer to the base of the proce  *                                   dures stack frame.
445  *      * pn_Start_P_globals         mode P, a pointer to the part of the memory *                                   containing_all_ global things.
446  *      * pn_Start_T_args            mode T, a tuple containing all arguments of *                                   the procedure.
447  *
448  *
449  *    ir_node *new_End (void)
450  *    -----------------------
451  *
452  *    Creates an end node.  Not actually needed public.  There is only one such
453  *   node in each procedure which is automatically created by new_ir_graph.
454  *
455  *    Inputs:
456  *      No inputs except the block it belongs to.
457  *    Output:
458  *      No output.
459  *
460  *    ir_node *new_Jmp (void)
461  *    -----------------------
462  *
463  *    Creates a Jmp node.
464  *
465  *    Inputs:
466  *      The block the node belongs to
467  *    Output:
468  *      Control flow to the next block.
469  *
470  *    ir_node *new_IJmp (ir_node *tgt)
471  *    -----------------------
472  *
473  *    Creates an IJmp node.
474  *
475  *    Inputs:
476  *      The node that represents the target jump address
477  *    Output:
478  *      Control flow to an unknown target, must be pinned by
479  *      the End node.
480  *
481  *    ir_node *new_Cond (ir_node *c)
482  *    ------------------------------
483  *
484  *    Creates a Cond node.  There are two versions of this node.
485  *
486  *    The Boolean Cond:
487  *    Input:
488  *      A value of mode b.
489  *    Output:
490  *      A tuple of two control flows.  The first is taken if the input is
491  *      false, the second if it is true.
492  *
493  *    The Switch Cond:
494  *    Input:
495  *      A value of mode I_u. (i)
496  *    Output:
497  *      A tuple of n control flows.  If the Cond's input is i, control
498  *      flow will procede along output i. If the input is >= n control
499  *      flow proceeds along output n.
500  *
501  *    ir_node *new_Return (ir_node *store, int arity, ir_node **in)
502  *    -------------------------------------------------------------
503  *
504  *    The return node has as inputs the results of the procedure.  It
505  *    passes the control flow to the end_block.
506  *
507  *    Inputs:
508  *      The memory state.
509  *      All results.
510  *    Output
511  *      Control flow to the end block.
512  *
513  *    ---------
514  *
515  *    ir_node *new_Const (ir_mode *mode, tarval *con)
516  *    -----------------------------------------------
517  *
518  *    Creates a constant in the constant table and adds a Const node
519  *    returning this value to the start block.
520  *
521  *    Parameters:
522  *      *mode            The mode of the constant.
523  *      *con             Points to an entry in the constant table.
524  *                       This pointer is added to the attributes of
525  *                       the node (self->attr.con)
526  *    Inputs:
527  *      No inputs except the block it belogns to.
528  *    Output:
529  *      The constant value.
530  *    Attribute:
531  *      attr.con   A tarval* pointer to the proper entry in the constant
532  *                 table.
533  *
534  *    ir_node *new_SymConst (union symconst_symbol value, symconst_addr_ent kind)
535  *    ---------------------------------------------------------------------------
536  *
537  *    There are three kinds of symbolic constants:
538  *     symconst_type_tag   The symbolic constant represents a type tag.
539  *     symconst_type_size  The symbolic constant represents the size of a type.
540  *     symconst_type_align The symbolic constant represents the alignment of a type.
541  *     symconst_addr_name  Information for the linker, e.g. the name of a global
542  *                         variable.
543  *     symconst_addr_name  The symbolic constant represents the address of an entity.
544  *
545  *    To represent a pointer to an entity that is represented by an entity
546  *    datastructure don't use
547  *      new_SymConst((type_or_id*)get_entity_ld_ident(ent), symconst_addr_name);.
548  *    Use a real const instead:
549  *      new_SymConst(ent, symconst_addr_ent);
550  *    This makes the Constant independent of name changes of the entity due to
551  *    mangling.
552  *
553  *    Parameters
554  *      kind        The kind of the symbolic constant: type_tag, size or link_info.
555  *      *type_or_id Points to the type the tag stands for or to the type
556  *                  whose size is represented by the constant or to an ident
557  *                  representing the linkage info.
558  *
559  *    Inputs:
560  *      No inputs except the block it belogns to.
561  *    Output:
562  *      An unsigned integer (I_u) or a pointer (P).
563  *
564  *    Attributes:
565  *      attr.i.num       The symconst_addr_ent, i.e. one of
566  *                        -symconst_type_tag
567  *                        -symconst_type_size
568  *                        -symconst_type_align
569  *                        -symconst_addr_name
570  *
571  *    If the attr.i.num is symconst_type_tag, symconst_type_size or symconst_type_align,
572  *    the node contains an attribute:
573  *
574  *      attr.i.*type,    a pointer to a type_class.  The mode of the node is mode_Is.
575  *        if it is linkage_ptr_info it contains
576  *      attr.i.*ptrinfo,  an ident holding information for the linker.  The mode
577  *        of the node is mode_P_mach.
578  *
579  *    ---------------
580  *
581  *    ir_node *new_simpleSel (ir_node *store, ir_node *frame, ir_entity *sel)
582  *    -----------------------------------------------------------------------
583  *
584  *
585  *    Selects an entity from a compound type. This entity can be a field or
586  *    a method.
587  *
588  *    Parameters:
589  *      *store     The memory in which the object the entity should be selected
590  *                 from is allocated.
591  *      *frame     The pointer to the object.
592  *      *sel       The entity to select.
593  *
594  *    Inputs:
595  *      The memory containing the object.
596  *      A pointer to the object.
597  *      An unsigned integer.
598  *    Output:
599  *      A pointer to the selected entity.
600  *    Attributes:
601  *      attr.sel   Pointer to the entity
602  *
603  *
604  *    ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
605  *    --------------------------------------------------------------------------
606  *                      ir_entity *sel)
607  *                      ---------------
608  *
609  *    Selects a field from an array type.  The entity has as owner the array, as
610  *    type the arrays element type.  The indices to access an array element are
611  *    given also.
612  *
613  *    Parameters:
614  *      *store     The memory in which the object the entity should be selected from
615  *                 is allocated.
616  *      *frame     The pointer to the object.
617  *      *arity     number of array indices.
618  *      *in        array with index inputs to the node.
619  *      *sel       The entity to select.
620  *
621  *    Inputs:
622  *      The memory containing the object.
623  *      A pointer to the object.
624  *      As much unsigned integer as there are array expressions.
625  *    Output:
626  *      A pointer to the selected entity.
627  *    Attributes:
628  *      attr.sel   Pointer to the entity
629  *
630  *    The constructors new_Sel and new_simpleSel generate the same ir nodes.
631  *    simpleSel just sets the arity of the index inputs to zero.
632  *
633  *
634  *    ARITHMETIC OPERATIONS
635  *    ---------------------
636  *
637  *    ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
638  *    ----------------------------------------------------------------------------
639  *                       type_method *type)
640  *                       ------------------
641  *
642  *    Creates a procedure call.
643  *
644  *    Parameters
645  *      *store           The actual store.
646  *      *callee          A pointer to the called procedure.
647  *      arity            The number of procedure parameters.
648  *      **in             An array with the pointers to the parameters.
649  *                       The constructor copies this array.
650  *      *type            Type information of the procedure called.
651  *
652  *    Inputs:
653  *      The store, the callee and the parameters.
654  *    Output:
655  *      A tuple containing the eventually changed store and the procedure
656  *      results.
657  *    Attributes:
658  *      attr.call        Contains the type information for the procedure.
659  *
660  *
661  *    ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
662  *    ------------------------------------------------------------
663  *
664  *    Trivial.
665  *
666  *    ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
667  *    ------------------------------------------------------------
668  *
669  *    Trivial.
670  *
671  *    ir_node *new_Minus (ir_node *op, ir_mode *mode)
672  *    -----------------------------------------------
673  *
674  *    Unary Minus operations on integer and floating point values.
675  *
676  *    ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
677  *    ------------------------------------------------------------
678  *
679  *    Trivial.
680  *
681  *    ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
682  *    -----------------------------------------------------------------------------
683  *
684  *    Quot performs exact division of floating point numbers.  It's mode
685  *    is Tuple, the mode of the result must match the Proj mode
686  *    that extracts the result of the arithmetic operations.
687  *
688  *    Inputs:
689  *      The store needed to model exceptions and the two operands.
690  *    Output:
691  *      A tuple containing a memory and a execution for modeling exceptions
692  *      and the result of the arithmetic operation.
693  *
694  *    ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
695  *    -------------------------------------------------------------------------------
696  *
697  *    Performs Div and Mod on integer values.
698  *
699  *    Output:
700  *      A tuple containing a memory and a execution for modeling exceptions
701  *      and the two result of the arithmetic operations.
702  *
703  *    ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
704  *    ----------------------------------------------------------------------------
705  *
706  *    Trivial.
707  *
708  *    ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode)
709  *    ----------------------------------------------------------------------------
710  *
711  *    Trivial.
712  *
713  *    ir_node *new_Abs (ir_node *op, ir_mode *mode)
714  *    ---------------------------------------------
715  *
716  *    Trivial.
717  *
718  *    ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
719  *    ------------------------------------------------------------
720  *
721  *    Trivial.
722  *
723  *    ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
724  *    -----------------------------------------------------------
725  *
726  *    Trivial.
727  *
728  *    ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
729  *    ------------------------------------------------------------
730  *
731  *    Trivial.
732  *
733  *    ir_node *new_Not (ir_node *op, ir_mode *mode)
734  *    ---------------------------------------------
735  *
736  *    This node constructs a constant where all bits are set to one
737  *    and a Eor of this constant and the operator.  This simulates a
738  *    Not operation.
739  *
740  *    ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
741  *    ---------------------------------------------------------
742  *
743  *    Trivial.
744  *
745  *    ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
746  *    ---------------------------------------------------------
747  *
748  *    Logic shift right, i.e., zero extended.
749  *
750  *
751  *    ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
752  *    ----------------------------------------------------------
753  *
754  *    Arithmetic shift right, i.e., sign extended.
755  *
756  *    ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
757  *    ---------------------------------------------------------
758  *
759  *    Rotates the operand to the (right??) by k bits.
760  *
761  *    ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode)
762  *    ------------------------------------------------------------
763  *
764  *    Calculates the Carry value for integer addition. Used only
765  *    in lowering code.
766  *
767  *    ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode)
768  *    ------------------------------------------------------------
769  *
770  *    Calculates the Borrow value for integer substraction. Used only
771  *    in lowering code.
772  *
773  *    ir_node *new_Conv (ir_node *op, ir_mode *mode)
774  *    ---------------------------------------------
775  *
776  *    Mode conversion.  For allowed conversions see UKA Tech Report
777  *    1999-14.
778  *
779  *    ir_node *new_Cmp (ir_node *op1, ir_node *op2)
780  *    ---------------------------------------------
781  *
782  *    Input:
783  *      The two values to be compared.
784  *    Output:
785  *      A 16-tuple containing the results of the 16 different comparisons.
786  *      The following is a list giving the comparisons and a projection
787  *      number (pn_Cmp) to use in Proj nodes to extract the proper result.
788  *        pn_Cmp_False false
789  *        pn_Cmp_Eq    equal
790  *        pn_Cmp_Lt    less
791  *        pn_Cmp_Le    less or equal
792  *        pn_Cmp_Gt    greater
793  *        pn_Cmp_Ge    greater of equal
794  *        pn_Cmp_Lg    less or greater
795  *        pn_Cmp_Leg   less, equal or greater = ordered
796  *        pn_Cmp_Uo    unordered
797  *        pn_Cmp_Ue    unordered or equal
798  *        pn_Cmp_Ul    unordered or less
799  *        pn_Cmp_Ule   unordered, less or equal
800  *        pn_Cmp_Ug    unordered or greater
801  *        pn_Cmp_Uge   unordered, greater or equal
802  *        pn_Cmp_Ne    unordered, less or greater = not equal
803  *        pn_Cmp_True  true
804  *
805  *
806  *
807  *    ------------
808  *
809  *    In general, Phi nodes are automaitcally inserted.  In some cases, if
810  *    all predecessors of a block are known, an explicit Phi node constructor
811  *    is needed.  E.g., to construct a FIRM graph for a statement as
812  *      a = (b==c) ? 2 : 5;
813  *
814  *    ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
815  *    ---------------------------------------------------------
816  *
817  *    Creates a Phi node. The in's order has to correspond to the order
818  *    of in's of current_block.  This is not checked by the library!
819  *    If one of the predecessors is Unknown (as it has to be filled in
820  *    later) optimizations are skipped.  This is necessary to
821  *    construct Phi nodes in loops.  Leaving Unknown in the Phi after finishing
822  *    the construction may have strange effects, especially for interprocedural
823  *    representation and analysis.
824  *
825  *    Parameter
826  *      arity            number of predecessors
827  *      **in             array with predecessors
828  *      *mode            The mode of it's inputs and output.
829  *    Inputs:
830  *      A Phi node has as many inputs as the block it belongs to.
831  *      Each input points to a definition of the same value on a
832  *      different path in the control flow.
833  *    Output
834  *      The definition valid in this block.
835  *
836  *    ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
837  *    -----------------------------------------------------------------------------
838  *
839  *    Creates a Mux node. This node implements the following semantic:
840  *    If the sel node (which must be of mode_b) evaluates to true, its value is
841  *    ir_true, else ir_false;
842  *
843  *
844  *    ir_node *new_Psi (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode)
845  *    -----------------------------------------------------------------------------
846  *
847  *    Creates a Psi node. This node implements the following semantic:
848  *    Enter it here!!!
849  *
850  *
851  *    OPERATIONS TO MANAGE MEMORY EXPLICITLY
852  *    --------------------------------------
853  *
854  *    ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode)
855  *    ----------------------------------------------------------------
856  *
857  *    The Load operation reads a value from memory.
858  *
859  *    Parameters:
860  *    *store        The current memory.
861  *    *addr         A pointer to the variable to be read in this memory.
862  *    *mode         The mode of the value to be loaded.
863  *
864  *    Inputs:
865  *      The memory and a pointer to a variable in this memory.
866  *    Output:
867  *      A tuple of the memory, a control flow to be taken in case of
868  *      an exception and the loaded value.
869  *
870  *    ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
871  *    ----------------------------------------------------------------
872  *
873  *    The Store operation writes a value to a variable in memory.
874  *
875  *    Inputs:
876  *      The memory, a pointer to a variable in this memory and the value
877  *      to write to this variable.
878  *    Output:
879  *      A tuple of the changed memory and a control flow to be taken in
880  *      case of an exception.
881  *
882  *    ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
883  *    -----------------------------------------------------------------------
884  *                        where_alloc where)
885  *                        ------------------
886  *
887  *    The Alloc node allocates a new variable.  It can be specified whether the
888  *    variable should be allocated to the stack or to the heap.
889  *
890  *    Parameters:
891  *      *store       The memory which shall contain the new variable.
892  *      **    *size        The number of bytes to allocate. Old. **
893  *      *size        We decided that the size easily can be derived from the type.
894  *                   This field is for allocating arrays, i.e., it gives the multiple
895  *           of the size of alloc_type to allocate memory for.
896  *      *alloc_type  The type of the allocated variable.
897  *      where        Where to allocate the variable, either heap_alloc or stack_alloc.
898  *
899  *    Inputs:
900  *      A memory and an unsigned integer.
901  *    Output:
902  *      A tuple of the changed memory, a control flow to be taken in
903  *      case of an exception and the pointer to the new variable.
904  *    Attributes:
905  *      a.where          Indicates where the variable is allocated.
906  *      a.*type          A pointer to the class the allocated data object
907  *                       belongs to.
908  *
909  *    ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
910  *    -----------------------------------------------------------------------------------
911  *                        where_alloc where)
912  *                        ------------------
913  *
914  *    The Free node frees memory of the given variable.
915  *
916  *    Parameters:
917  *      *store       The memory which shall contain the new variable.
918  *      *ptr         The pointer to the object to free.
919  *      *size        The number of objects of type free_type to free in a sequence.
920  *      *free_type   The type of the freed variable.
921  *      where        Where the variable was allocated, either heap_alloc or stack_alloc.
922  *
923  *    Inputs:
924  *      A memory, a pointer and an unsigned integer.
925  *    Output:
926  *      The changed memory.
927  *    Attributes:
928  *      f.*type          A pointer to the type information of the freed data object.
929  *
930  *    Not Implemented!
931  *
932  *    ir_node *new_Sync (int arity, ir_node **in)
933  *    -------------------------------------------
934  *
935  *    The Sync operation unifies several partial memory blocks.  These blocks
936  *    have to be pairwise disjunct or the values in common locations have to
937  *    be identical.  This operation allows to specify all operations that eventually
938  *    need several partial memory blocks as input with a single entrance by
939  *    unifying the memories with a preceding Sync operation.
940  *
941  *    Parameters
942  *      arity    The number of memories to synchronize.
943  *      **in     An array of pointers to nodes that produce an output of
944  *               type memory.
945  *    Inputs
946  *      Several memories.
947  *    Output
948  *      The unified memory.
949  *
950  *
951  *    SPECIAL OPERATIONS
952  *    ------------------
953  *
954  *    ir_node *new_Bad (void)
955  *    -----------------------
956  *
957  *    Returns the unique Bad node current_ir_graph->bad.
958  *    This node is used to express results of dead code elimination.
959  *
960  *    ir_node *new_NoMem (void)
961  *    -----------------------------------------------------------------------------------
962  *
963  *    Returns the unique NoMem node current_ir_graph->no_mem.
964  *    This node is used as input for operations that need a Memory, but do not
965  *    change it like Div by const != 0, analyzed calls etc.
966  *
967  *    ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
968  *    ----------------------------------------------------------
969  *
970  *    Selects one entry of a tuple.  This is a hidden edge with attributes.
971  *
972  *    Parameters
973  *      *arg      A node producing a tuple.
974  *      *mode     The mode of the value to project.
975  *      proj      The position of the value in the tuple.
976  *    Input:
977  *      The tuple.
978  *    Output:
979  *      The value.
980  *
981  *    ir_node *new_Tuple (int arity, ir_node **in)
982  *    --------------------------------------------
983  *
984  *    Builds a Tuple from single values.  This is needed to implement
985  *    optimizations that remove a node that produced a tuple.  The node can be
986  *    replaced by the Tuple operation so that the following Proj nodes have not to
987  *    be changed.  (They are hard to find due to the implementation with pointers
988  *    in only one direction.)  The Tuple node is smaller than any other
989  *    node, so that a node can be changed into a Tuple by just changing it's
990  *    opcode and giving it a new in array.
991  *
992  *    Parameters
993  *      arity    The number of tuple elements.
994  *      **in     An array containing pointers to the nodes producing the
995  *               tuple elements.
996  *
997  *    ir_node *new_Id (ir_node *val, ir_mode *mode)
998  *    ---------------------------------------------
999  *
1000  *    The single output of the Id operation is it's input.  Also needed
1001  *    for optimizations.
1002  *
1003  *
1004  *    HIGH LEVEL OPERATIONS
1005  *    ---------------------
1006  *
1007  *    ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
1008  *    -----------------------------------------------------------------------------------
1009  *
1010  *    Describes a high level block copy of a compound type from address src to
1011  *    address dst. Must be lowered to a Call to a runtime memory copy function.
1012  *
1013  *
1014  *    HIGH LEVEL OPERATIONS: Exception Support
1015  *    ----------------------------------------
1016  *    See TechReport 1999-14, chapter Exceptions.
1017  *
1018  *    ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
1019  *    -----------------------------------------------------------------------------------
1020  *
1021  *    Describes a high level type check. Must be lowered to a Call to a runtime check
1022  *    function.
1023  *
1024  *    ir_node *new_Raise (ir_node *store, ir_node *obj)
1025  *    -------------------------------------------------
1026  *
1027  *    Raises an exception.  Unconditional change of control flow.  Writes
1028  *    an explicit Except variable to memory to pass it to the exception
1029  *    handler.  Must be lowered to a Call to a runtime check
1030  *    function.
1031  *
1032  *    Inputs:
1033  *      The memory state.
1034  *      A pointer to the Except variable.
1035  *    Output:
1036  *      A tuple of control flow and the changed memory state.  The control flow
1037  *      points to the exception handler if it is definied in this procedure,
1038  *      else it points to the end_block.
1039  *
1040  *    ir_node *new_Bound  (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
1041  *    -----------------------------------------------------------------------------------
1042  *
1043  *    Describes a high level bounds check. Must be lowered to a Call to a runtime check
1044  *    function.
1045  *
1046  *    ir_node *new_Pin  (ir_node *node);
1047  *    -----------------------------------------------------------------------------------
1048  *
1049  *    Pin the value of the node node in the current block  No users of the Pin node can
1050  *    float above the Block of the Pin. The node cannot float behind this block. Often
1051  *    used to Pin the NoMem node.
1052  *
1053  *
1054  *    COPING WITH DATA OBJECTS
1055  *    ========================
1056  *
1057  *    Two kinds of data objects have to be distinguished for generating
1058  *    FIRM.  First there are local variables other than arrays that are
1059  *    known to be alias free.  Second there are all other data objects.
1060  *    For the first a common SSA representation is built, the second
1061  *    are modeled by saving them to memory.  The memory is treated as
1062  *    a single local variable, the alias problem is hidden in the
1063  *    content of this variable.
1064  *
1065  *    All values known in a Block are listed in the block's attribute,
1066  *    block.**graph_arr which is used to automatically insert Phi nodes.
1067  *    The following two functions can be used to add a newly computed value
1068  *    to the array, or to get the producer of a value, i.e., the current
1069  *    live value.
1070  *
1071  *    inline void set_value (int pos, ir_node *value)
1072  *    -----------------------------------------------
1073  *
1074  *    Has to be called for every assignment to a local variable.  It
1075  *    adds the value to the array of used values at position pos.  Pos
1076  *    has to be a unique identifier for an entry in the procedure's
1077  *    definition table.  It can be used to access the value again.
1078  *    Requires current_block to be set correctly.
1079  *
1080  *    ir_node *get_value (int pos, ir_mode *mode)
1081  *    -------------------------------------------
1082  *
1083  *    Returns the node defining the value referred to by pos. If the
1084  *    value is not defined in this block a Phi node is generated and
1085  *    all definitions reaching this Phi node are collected.  It can
1086  *    happen that the algorithm allocates an unnecessary Phi node,
1087  *    e.g. if there is only one definition of this value, but this
1088  *    definition reaches the currend block on several different
1089  *    paths.  This Phi node will be eliminated if optimizations are
1090  *    turned on right after it's creation.
1091  *    Requires current_block to be set correctly.
1092  *
1093  *    There are two special routines for the global store:
1094  *
1095  *    void set_store (ir_node *store)
1096  *    -------------------------------
1097  *
1098  *    Adds the store to the array of known values at a reserved
1099  *    position.
1100  *    Requires current_block to be set correctly.
1101  *
1102  *    ir_node *get_store (void)
1103  *    -------------------------
1104  *
1105  *    Returns the node defining the actual store.
1106  *    Requires current_block to be set correctly.
1107  *
1108  *
1109  *    inline void keep_alive (ir_node *ka)
1110  *    ------------------------------------
1111  *
1112  *    Keep this node alive because it is (might be) not in the control
1113  *    flow from Start to End.  Adds the node to the list in the end
1114  *   node.
1115  *
1116  */
1117 #ifndef FIRM_IR_IRCONS_H
1118 #define FIRM_IR_IRCONS_H
1119
1120 #include "firm_common.h"
1121 #include "irnode.h"
1122 #include "irgraph.h"
1123 #include "dbginfo.h"
1124
1125 /*-------------------------------------------------------------------------*/
1126 /* The raw interface                                                       */
1127 /*-------------------------------------------------------------------------*/
1128
1129 /** Constructor for a Block node.
1130  *
1131  * Constructs a mature block with the given predecessors.  Use Unknown
1132  * nodes as predecessors to construct a block if the number of
1133  * predecessors is known, but not the predecessors themselves.  This
1134  * constructor does not set current_block.  It not be used with
1135  * automatic Phi node construction.
1136  *
1137  * @param *db    A Pointer for  debug information.
1138  * @param irg    The ir graph the block belongs to.
1139  * @param arity  The number of control predecessors.
1140  * @param in[]   An array of control predecessors.  The length of
1141  *               the array must be 'arity'.  The constructor copies this array.
1142  */
1143 ir_node *new_rd_Block  (dbg_info *db, ir_graph *irg,  int arity, ir_node *in[]);
1144
1145 /** Constructor for a Start node.
1146  *
1147  * @param *db    A pointer for debug information.
1148  * @param *irg   The ir graph the node belongs to.
1149  * @param *block The ir block the node belongs to.
1150  */
1151 ir_node *new_rd_Start  (dbg_info *db, ir_graph *irg, ir_node *block);
1152
1153 /** Constructor for a End node.
1154  *
1155  * @param *db    A pointer for  debug information.
1156  * @param *irg   The ir graph the node  belongs to.
1157  * @param *block The ir block the node belongs to.
1158  */
1159 ir_node *new_rd_End    (dbg_info *db, ir_graph *irg, ir_node *block);
1160
1161 /** Constructor for a Jmp node.
1162  *
1163  * Jmp represents control flow to a single control successor.
1164  *
1165  * @param *db     A pointer for debug information.
1166  * @param *irg    The ir graph the node belongs to.
1167  * @param *block  The ir block the node belongs to.
1168  */
1169 ir_node *new_rd_Jmp    (dbg_info *db, ir_graph *irg, ir_node *block);
1170
1171 /** Constructor for an IJmp node.
1172  *
1173  * IJmp represents control flow to a single control successor not
1174  * statically known i.e. an indirect Jmp.
1175  *
1176  * @param *db     A pointer for debug information.
1177  * @param *irg    The ir graph the node belongs to.
1178  * @param *block  The ir block the node belongs to.
1179  * @param *tgt    The ir node representing the target address.
1180  */
1181 ir_node *new_rd_IJmp   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *tgt);
1182
1183 /** Constructor for a Break node.
1184  *
1185  * Break represents control flow to a single control successor just as Jmp.
1186  * The blocks separated by a break may not be concatenated by an optimization.
1187  * It is used for the interprocedural representation where blocks are parted
1188  * behind Call nodes to represent the control flow to called procedures.
1189  *
1190  * @param *db     A pointer for debug information.
1191  * @param *irg    The ir graph the node belong to.
1192  * @param *block  The block the node belong to.
1193  */
1194 ir_node *new_rd_Break  (dbg_info *db, ir_graph *irg, ir_node *block);
1195
1196 /** Constructor for a Cond node.
1197  *
1198  * If c is mode_b represents a conditional branch (if/else). If c is
1199  * mode_Is/mode_Iu (?) represents a switch.  (Allocates dense Cond
1200  * node, default Proj is 0.)
1201  *
1202  * This is not consistent:  Input to Cond is Is, Proj has as proj number
1203  * longs.
1204  *
1205  * @param *db    A pointer for debug information.
1206  * @param *irg   The ir graph the node  belongs to.
1207  * @param *block The ir block the node belongs to.
1208  * @param *c     The conditions parameter. Can be of mode b or I_u.
1209  */
1210 ir_node *new_rd_Cond   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
1211
1212 /** Constructor for a Return node.
1213  *
1214  * Returns the memory an zero or more return values.  Only node that
1215  * can end regular control flow.
1216  *
1217  * @param *db    A pointer for debug information.
1218  * @param *irg   The ir graph the node  belongs to.
1219  * @param *block The ir block the node belongs to.
1220  * @param *store The state of memory.
1221  * @param arity  Number of return values.
1222  * @param *in    Array of length arity with return values.  The constructor copies this array.
1223  */
1224 ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
1225                         ir_node *store, int arity, ir_node *in[]);
1226
1227 /** Constructor for a Const_type node.
1228  *
1229  * The constant represents a target value.  This constructor sets high
1230  * level type information for the constant value.
1231  *
1232  * @param *db    A pointer for debug information.
1233  * @param *irg   The ir graph the node  belongs to.
1234  * @param *block The ir block the node belongs to.
1235  * @param *mode  The mode of the operands and results.
1236  * @param *con   Points to an entry in the constant table.
1237  * @param *tp    The type of the constant.
1238  */
1239 ir_node *new_rd_Const_type (dbg_info *db, ir_graph *irg, ir_node *block,
1240                             ir_mode *mode, tarval *con, ir_type *tp);
1241
1242 /** Constructor for a Const node.
1243  *
1244  * Constructor for a Const node. The constant represents a target
1245  * value.  Sets the type information to type_unknown.  (No more
1246  * supported: If tv is entity derives a somehow useful type.)
1247  *
1248  * @param *db    A pointer for debug information.
1249  * @param *irg   The ir graph the node  belongs to.
1250  * @param *block The ir block the node belongs to.
1251  * @param *mode  The mode of the operands and results.
1252  * @param *con   Points to an entry in the constant table.
1253  */
1254 ir_node *new_rd_Const  (dbg_info *db, ir_graph *irg, ir_node *block,
1255                         ir_mode *mode, tarval *con);
1256
1257 /** Constructor for a SymConst_type node.
1258  *
1259  *  This is the constructor for a symbolic constant.
1260  *    There are four kinds of symbolic constants:
1261  *    - type_tag   The symbolic constant represents a type tag.  The type the
1262  *                 tag stands for is given explicitly.
1263  *    - type_size  The symbolic constant represents the size of a type.  The
1264  *                 type of which the constant represents the size is given
1265  *                 explicitly.
1266  *    - type_align The symbolic constant represents the alignment of a type.  The
1267  *                 type of which the constant represents the size is given
1268  *                 explicitly.
1269  *    - addr_name  The symbolic constant represents the address of an entity
1270  *                 (variable or method).  The variable is indicated by a name
1271  *                 that is valid for linking.
1272  *    - addr_ent   The symbolic constant represents the address of an entity
1273  *                 (variable or method).  The variable is given explicitly by
1274  *                 a firm entity.
1275  *
1276  *    Inputs to the node:
1277  *      No inputs except the block it belongs to.
1278  *    Outputs of the node.
1279  *      An unsigned integer (I_u) or a pointer (P).
1280  *
1281  *    Mention union in declaration so that the firmjni generator recognizes that
1282  *    it can not cast the argument to an int.
1283  *
1284  * @param *db     A pointer for debug information.
1285  * @param *irg    The ir graph the node  belongs to.
1286  * @param *block  The ir block the node belongs to.
1287  * @param symkind The kind of the symbolic constant: type_tag, size, addr_name or addr_ent.
1288  * @param value   A type, entity or a ident depending on the SymConst kind.
1289  * @param tp      The source type of the constant.
1290  */
1291 ir_node *new_rd_SymConst_type (dbg_info *db, ir_graph *irg, ir_node *block, union symconst_symbol value,
1292                                            symconst_kind symkind, ir_type *tp);
1293
1294 /** Constructor for a SymConst node.
1295  *
1296  *  Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */
1297 ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
1298                                       union symconst_symbol value, symconst_kind symkind);
1299
1300 /** Constructor for a SymConst addr_ent node.
1301  *
1302  * Same as new_rd_SymConst_type, except that the constructor is tailored for
1303  * symconst_addr_ent.
1304  * Adds the SymConst to the start block of irg. */
1305 ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, ir_entity *symbol, ir_type *tp);
1306
1307 /** Constructor for a SymConst ofs_ent node.
1308  *
1309  * Same as new_rd_SymConst_type, except that the constructor is tailored for
1310  * symconst_ofs_ent.
1311  * Adds the SymConst to the start block of irg. */
1312 ir_node *new_rd_SymConst_ofs_ent (dbg_info *db, ir_graph *irg, ir_entity *symbol, ir_type *tp);
1313
1314 /** Constructor for a SymConst addr_name node.
1315  *
1316  * Same as new_rd_SymConst_type, except that the constructor is tailored for
1317  * symconst_addr_ent.
1318  * Adds the SymConst to the start block of irg. */
1319 ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, ir_type *tp);
1320
1321 /** Constructor for a SymConst type_tag node.
1322  *
1323  * Same as new_rd_SymConst_type, except that the constructor is tailored for
1324  * symconst_addr_ent.
1325  * Adds the SymConst to the start block of irg. */
1326 ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
1327
1328 /** Constructor for a SymConst size node.
1329  *
1330  * Same as new_rd_SymConst_type, except that the constructor is tailored for
1331  * symconst_type_size.
1332  * Adds the SymConst to the start block of irg. */
1333 ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
1334
1335 /** Constructor for a SymConst size node.
1336  *
1337  * Same as new_rd_SymConst_type, except that the constructor is tailored for
1338  * symconst_type_align.
1339  * Adds the SymConst to the start block of irg. */
1340 ir_node *new_rd_SymConst_align (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
1341
1342 /** Constructor for a simpleSel node.
1343  *
1344  *  This is a shortcut for the new_rd_Sel() constructor.  To be used for
1345  *  Sel nodes that do not select from an array, i.e., have no index
1346  *  inputs.  It adds the two parameters 0, NULL.
1347  *
1348  * @param   *db        A pointer for debug information.
1349  * @param   *irg       The ir graph the node  belongs to.
1350  * @param   *block     The ir block the node belongs to.
1351  * @param   *store     The memory in which the object the entity should be
1352  *                     selected from is allocated.
1353  * @param   *objptr    The object from that the Sel operation selects a
1354  *                     single attribute out.
1355  * @param   *ent       The entity to select.
1356  */
1357 ir_node *new_rd_simpleSel (dbg_info *db, ir_graph *irg, ir_node *block,
1358                            ir_node *store, ir_node *objptr, ir_entity *ent);
1359
1360 /** Constructor for a Sel node.
1361  *
1362  * The select node selects an entity (field or method) from an entity
1363  * with a compound type.  It explicitly specifies the entity selected.
1364  * Dynamically the node may select entities that overwrite the given
1365  * entity.  If the selected entity is an array element entity the Sel
1366  * node takes the required array indices as inputs.
1367  *
1368  * @param   *db        A pointer for debug information.
1369  * @param   *irg       The ir graph the node  belongs to.
1370  * @param   *block     The ir block the node belongs to.
1371  * @param   *store     The memory in which the object the entity should be selected
1372  *                     from is allocated.
1373  * @param   *objptr    A pointer to a compound entity the Sel operation selects a
1374  *                     single attribute from.
1375  * @param   *n_index   The number of array indices needed to select an array element entity.
1376  * @param   *index[]   If the compound entity is an array the indices of the selected
1377  *                     element entity.  The constructor copies this array.
1378  * @param   *ent       The entity to select.
1379  */
1380 ir_node *new_rd_Sel    (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1381                                     ir_node *objptr, int n_index, ir_node *index[], ir_entity *ent);
1382
1383 /** Constructor for a Call node.
1384  *
1385  *  Represents all kinds of method and function calls.
1386  *
1387  * @param   *db     A pointer for debug information.
1388  * @param   *irg    The ir graph the node  belongs to.
1389  * @param   *block  The ir block the node belongs to.
1390  * @param   *store  The current memory state.
1391  * @param   *callee A pointer to the called procedure.
1392  * @param   arity   The number of procedure parameters.
1393  * @param   *in[]   An array with the procedure parameters. The constructor copies this array.
1394  * @param   *tp     Type information of the procedure called.
1395  */
1396 ir_node *new_rd_Call   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1397                                     ir_node *callee, int arity, ir_node *in[], ir_type *tp);
1398
1399 /** Constructor for a Add node.
1400  *
1401  * @param   *db    A pointer for debug information.
1402  * @param   *irg   The ir graph the node  belongs to.
1403  * @param   *block The ir block the node belongs to.
1404  * @param   *op1   The first operand.
1405  * @param   *op2   The second operand.
1406  * @param   *mode  The mode of the operands and the result.
1407  */
1408 ir_node *new_rd_Add    (dbg_info *db, ir_graph *irg, ir_node *block,
1409                                     ir_node *op1, ir_node *op2, ir_mode *mode);
1410
1411 /** Constructor for a Sub node.
1412  *
1413  * @param   *db    A pointer for debug information.
1414  * @param   *irg   The ir graph the node  belongs to.
1415  * @param   *block The ir block the node belongs to.
1416  * @param   *op1   The first operand.
1417  * @param   *op2   The second operand.
1418  * @param   *mode  The mode of the operands and the result.
1419  */
1420 ir_node *new_rd_Sub    (dbg_info *db, ir_graph *irg, ir_node *block,
1421                                     ir_node *op1, ir_node *op2, ir_mode *mode);
1422
1423 /** Constructor for a Minus node.
1424  *
1425  * @param   *db    A pointer for debug information.
1426  * @param   *irg   The ir graph the node  belongs to.
1427  * @param   *block The ir block the node belongs to.
1428  * @param   *op    The operand .
1429  * @param   *mode  The mode of the operand and the result.
1430  */
1431 ir_node *new_rd_Minus  (dbg_info *db, ir_graph *irg, ir_node *block,
1432                         ir_node *op,  ir_mode *mode);
1433
1434 /** Constructor for a Mul node.
1435  *
1436  * @param   *db    A pointer for debug information.
1437  * @param   *irg   The ir graph the node  belongs to.
1438  * @param   *block The ir block the node belongs to.
1439  * @param   *op1   The first operand.
1440  * @param   *op2   The second operand.
1441  * @param   *mode  The mode of the operands and the result.
1442  */
1443 ir_node *new_rd_Mul    (dbg_info *db, ir_graph *irg, ir_node *block,
1444                ir_node *op1, ir_node *op2, ir_mode *mode);
1445
1446 /** Constructor for a Quot node.
1447  *
1448  * @param   *db    A pointer for debug information.
1449  * @param   *irg   The ir graph the node  belongs to.
1450  * @param   *block The ir block the node belongs to.
1451  * @param   *memop The store needed to model exceptions
1452  * @param   *op1   The first operand.
1453  * @param   *op2   The second operand.
1454  * @param   *mode  The mode of the result.
1455  */
1456 ir_node *new_rd_Quot   (dbg_info *db, ir_graph *irg, ir_node *block,
1457                ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
1458
1459 /** Constructor for a DivMod node.
1460  *
1461  * @param   *db    A pointer for debug information.
1462  * @param   *irg   The ir graph the node  belongs to.
1463  * @param   *block The ir block the node belongs to.
1464  * @param   *memop The store needed to model exceptions
1465  * @param   *op1   The first operand.
1466  * @param   *op2   The second operand.
1467  * @param   *mode  The mode of the results.
1468  */
1469 ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
1470                ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
1471
1472 /** Constructor for a Div node.
1473  *
1474  * @param   *db    A pointer for debug information.
1475  * @param   *irg   The ir graph the node  belongs to.
1476  * @param   *block The ir block the node belongs to.
1477  * @param   *memop The store needed to model exceptions
1478  * @param   *op1   The first operand.
1479  * @param   *op2   The second operand.
1480  * @param   *mode  The mode of the result.
1481  */
1482 ir_node *new_rd_Div    (dbg_info *db, ir_graph *irg, ir_node *block,
1483                ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
1484
1485 /** Constructor for a Mod node.
1486  *
1487  * @param   *db    A pointer for debug information.
1488  * @param   *irg   The ir graph the node  belongs to.
1489  * @param   *block The ir block the node belongs to.
1490  * @param   *memop The store needed to model exceptions
1491  * @param   *op1   The first operand.
1492  * @param   *op2   The second operand.
1493  * @param   *mode  The mode of the result.
1494  */
1495 ir_node *new_rd_Mod    (dbg_info *db, ir_graph *irg, ir_node *block,
1496                         ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
1497
1498 /** Constructor for a Abs node.
1499  *
1500  * @param   *db    A pointer for debug information.
1501  * @param   *irg   The ir graph the node  belongs to.
1502  * @param   *block The ir block the node belongs to.
1503  * @param   *op    The operand
1504  * @param   *mode  The mode of the operands and the result.
1505  */
1506 ir_node *new_rd_Abs    (dbg_info *db, ir_graph *irg, ir_node *block,
1507                        ir_node *op, ir_mode *mode);
1508
1509 /** Constructor for a And node.
1510  *
1511  * @param   *db    A pointer for debug information.
1512  * @param   *irg   The ir graph the node  belongs to.
1513  * @param   *block The ir block the node belongs to.
1514  * @param   *op1   The first operand.
1515  * @param   *op2   The second operand.
1516  * @param   *mode  The mode of the operands and the result.
1517  */
1518 ir_node *new_rd_And    (dbg_info *db, ir_graph *irg, ir_node *block,
1519                         ir_node *op1, ir_node *op2, ir_mode *mode);
1520
1521 /** Constructor for a Or node.
1522  *
1523  * @param   *db    A pointer for debug information.
1524  * @param   *irg   The ir graph the node  belongs to.
1525  * @param   *block The ir block the node belongs to.
1526  * @param   *op1   The first operand.
1527  * @param   *op2   The second operand.
1528  * @param   *mode  The mode of the operands and the result.
1529  */
1530 ir_node *new_rd_Or     (dbg_info *db, ir_graph *irg, ir_node *block,
1531                         ir_node *op1, ir_node *op2, ir_mode *mode);
1532
1533 /** Constructor for a Eor node.
1534  *
1535  * @param   *db    A pointer for debug information.
1536  * @param   *irg   The ir graph the node  belongs to.
1537  * @param   *block The ir block the node belongs to.
1538  * @param   *op1   The first operand.
1539  * @param   *op2   The second operand.
1540  * @param   *mode  The mode of the operands and the results.
1541  */
1542 ir_node *new_rd_Eor    (dbg_info *db, ir_graph *irg, ir_node *block,
1543                         ir_node *op1, ir_node *op2, ir_mode *mode);
1544
1545 /** Constructor for a Not node.
1546  *
1547  * @param   *db    A pointer for debug information.
1548  * @param   *irg   The ir graph the node  belongs to.
1549  * @param   *block The ir block the node belongs to.
1550  * @param   *op    The operand.
1551  * @param   *mode  The mode of the operand and the result.
1552  */
1553 ir_node *new_rd_Not    (dbg_info *db, ir_graph *irg, ir_node *block,
1554                ir_node *op, ir_mode *mode);
1555
1556 /** Constructor for a Cmp node.
1557  *
1558  * @param   *db    A pointer for debug information.
1559  * @param   *irg   The ir graph the node  belongs to.
1560  * @param   *block The ir block the node belongs to.
1561  * @param   *op1   The first operand.
1562  * @param   *op2   The second operand.
1563  */
1564 ir_node *new_rd_Cmp    (dbg_info *db, ir_graph *irg, ir_node *block,
1565                ir_node *op1, ir_node *op2);
1566
1567 /** Constructor for a Shl node.
1568  *
1569  * @param   *db    A pointer for debug information.
1570  * @param   *irg   The ir graph the node  belongs to.
1571  * @param   *block The ir block the node belongs to.
1572  * @param   *op    The operand.
1573  * @param   *k     The number of bits to  shift the operand .
1574  * @param   *mode  The mode of the operand and the result.
1575  */
1576 ir_node *new_rd_Shl    (dbg_info *db, ir_graph *irg, ir_node *block,
1577                ir_node *op, ir_node *k, ir_mode *mode);
1578
1579 /** Constructor for a Shr node.
1580  *
1581  * @param   *db    A pointer for debug information.
1582  * @param   *irg   The ir graph the node  belongs to.
1583  * @param   *block The ir block the node belongs to.
1584  * @param   *op    The operand.
1585  * @param   *k     The number of bits to shift the operand .
1586  * @param   *mode  The mode of the operand and the result.
1587  */
1588 ir_node *new_rd_Shr    (dbg_info *db, ir_graph *irg, ir_node *block,
1589                ir_node *op, ir_node *k, ir_mode *mode);
1590
1591 /** Constructor for a Shrs node.
1592  *
1593  * @param   *db    A pointer for debug information.
1594  * @param   *irg   The ir graph the node  belongs to.
1595  * @param   *block The ir block the node belongs to.
1596  * @param   *op    The operand.
1597  * @param   *k     The number of bits to shift the operand.
1598  * @param   *mode  The mode of the operand and the result.
1599  */
1600 ir_node *new_rd_Shrs   (dbg_info *db, ir_graph *irg, ir_node *block,
1601                ir_node *op, ir_node *k, ir_mode *mode);
1602
1603 /** Constructor for a Rot node.
1604  *
1605  * @param   *db    A pointer for debug information.
1606  * @param   *irg   The ir graph the node  belongs to.
1607  * @param   *block The ir block the node belongs to.
1608  * @param   *op    The operand.
1609  * @param   *k     The number of bits to rotate the operand.
1610  * @param   *mode  The mode of the operand.
1611  */
1612 ir_node *new_rd_Rot    (dbg_info *db, ir_graph *irg, ir_node *block,
1613                ir_node *op, ir_node *k, ir_mode *mode);
1614
1615
1616 /** Constructor for a Conv node.
1617  *
1618  * @param   *db    A pointer for debug information.
1619  * @param   *irg   The ir graph the node  belongs to.
1620  * @param   *block The ir block the node belongs to.
1621  * @param   *op    The operand.
1622  * @param   *mode  The mode of this the operand muss be converted .
1623  */
1624 ir_node *new_rd_Conv   (dbg_info *db, ir_graph *irg, ir_node *block,
1625                ir_node *op, ir_mode *mode);
1626
1627 /** Constructor for a Cast node.
1628  *
1629  * High level type cast.
1630  *
1631  * @param   *db    A pointer for debug information.
1632  * @param   *irg   The ir graph the node  belongs to.
1633  * @param   *block The ir block the node belongs to.
1634  * @param   *op    The operand.
1635  * @param   *to_tp The type of this the operand muss be casted .
1636  */
1637 ir_node *new_rd_Cast   (dbg_info *db, ir_graph *irg, ir_node *block,
1638                         ir_node *op, ir_type *to_tp);
1639
1640 /** Constructor for a Carry node.
1641  *
1642  * @param   *db    A pointer for debug information.
1643  * @param   *irg   The ir graph the node  belongs to.
1644  * @param   *block The ir block the node belongs to.
1645  * @param   *op1   The first operand.
1646  * @param   *op2   The second operand.
1647  * @param   *mode  The mode of the operands and the result.
1648  */
1649 ir_node *new_rd_Carry  (dbg_info *db, ir_graph *irg, ir_node *block,
1650                         ir_node *op1, ir_node *op2, ir_mode *mode);
1651
1652 /** Constructor for a Borrow node.
1653  *
1654  * @param   *db    A pointer for debug information.
1655  * @param   *irg   The ir graph the node  belongs to.
1656  * @param   *block The ir block the node belongs to.
1657  * @param   *op1   The first operand.
1658  * @param   *op2   The second operand.
1659  * @param   *mode  The mode of the operands and the result.
1660  */
1661 ir_node *new_rd_Borrow (dbg_info *db, ir_graph *irg, ir_node *block,
1662                         ir_node *op1, ir_node *op2, ir_mode *mode);
1663
1664 /** Constructor for a Phi node.
1665  *
1666  * @param *db    A pointer for debug information.
1667  * @param *irg   The ir graph the node  belongs to.
1668  * @param *block The ir block the node belongs to.
1669  * @param arity  The number of predecessors
1670  * @param *in[]  Array with predecessors.  The constructor copies this array.
1671  * @param *mode  The mode of it's inputs and output.
1672  */
1673 ir_node *new_rd_Phi    (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
1674                         ir_node *in[], ir_mode *mode);
1675
1676 /** Constructor for a Load node.
1677  *
1678  * @param *db    A pointer for debug information.
1679  * @param *irg   The ir graph the node  belongs to.
1680  * @param *block The ir block the node belongs to.
1681  * @param *store The current memory
1682  * @param *adr   A pointer to the variable to be read in this memory.
1683  * @param *mode  The mode of the value to be loaded.
1684  */
1685 ir_node *new_rd_Load   (dbg_info *db, ir_graph *irg, ir_node *block,
1686                         ir_node *store, ir_node *adr, ir_mode *mode);
1687
1688 /** Constructor for a Store node.
1689  *
1690  * @param *db    A pointer for debug information.
1691  * @param *irg   The ir graph the node  belongs to.
1692  * @param *block The ir block the node belongs to.
1693  * @param *store The current memory
1694  * @param *adr   A pointer to the variable to be read in this memory.
1695  * @param *val   The value to write to this variable.
1696  */
1697 ir_node *new_rd_Store  (dbg_info *db, ir_graph *irg, ir_node *block,
1698                ir_node *store, ir_node *adr, ir_node *val);
1699
1700 /** Constructor for a Alloc node.
1701  *
1702  * The Alloc node extends the memory by space for an entity of type alloc_type.
1703  *
1704  * @param *db         A pointer for debug information.
1705  * @param *irg        The ir graph the node  belongs to.
1706  * @param *block      The ir block the node belongs to.
1707  * @param *store      The memory which shall contain the new variable.
1708  * @param *size       The number of bytes to allocate.
1709  * @param *alloc_type The type of the allocated variable.
1710  * @param where       Where to allocate the variable, either heap_alloc or stack_alloc.
1711  */
1712 ir_node *new_rd_Alloc  (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1713                ir_node *size, ir_type *alloc_type, where_alloc where);
1714
1715 /** Constructor for a Free node.
1716  *
1717  * Frees the memory occupied by the entity pointed to by the pointer
1718  * arg.  Type indicates the type of the entity the argument points to.
1719  *
1720  * @param *db         A pointer for debug information.
1721  * @param *irg        The ir graph the node  belongs to.
1722  * @param *block      The ir block the node belongs to.
1723  * @param *store      The memory which shall contain the new variable.
1724  * @param *ptr        The pointer to the object to free.
1725  * @param *size       The number of objects of type free_type to free in a sequence.
1726  * @param *free_type  The type of the freed variable.
1727  * @param where       Where the variable was allocated, either heap_alloc or stack_alloc.
1728  */
1729 ir_node *new_rd_Free   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1730                         ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
1731
1732 /** Constructor for a Sync node.
1733  *
1734  * Merges several memory values.  The node assumes that a variable
1735  * either occurs only in one of the memories, or it contains the same
1736  * value in all memories where it occurs.
1737  *
1738  * @param *db       A pointer for debug information.
1739  * @param *irg      The ir graph the node  belongs to.
1740  * @param *block    The ir block the node belongs to.
1741  * @param  arity    The number of memories to synchronize.
1742  * @param  *in[]    An array of pointers to nodes that produce an output of type
1743  *                  memory.  The constructor copies this array.
1744  */
1745 ir_node *new_rd_Sync   (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
1746
1747 /** Constructor for a Proj node.
1748  *
1749  * Projects a single value out of a tuple.  The parameter proj gives the
1750  * position of the value within the tuple.
1751  *
1752  * @param *db    A pointer for debug information.
1753  * @param *irg   The ir graph the node  belongs to.
1754  * @param *block The ir block the node belongs to.
1755  * @param arg    A node producing a tuple.  The node must have mode_T.
1756  * @param *mode  The mode of the value to project.
1757  * @param proj   The position of the value in the tuple.
1758  */
1759 ir_node *new_rd_Proj   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1760                         ir_mode *mode, long proj);
1761
1762 /** Constructor for a defaultProj node.
1763  *
1764  * Represents the default control flow of a Switch-Cond node.
1765  *
1766  * @param *db       A pointer for debug information.
1767  * @param *irg      The ir graph the node  belongs to.
1768  * @param *block    The ir block the node belongs to.
1769  * @param arg       A node producing a tuple.
1770  * @param max_proj  The end position of the value in the tuple.
1771  */
1772 ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1773                              long max_proj);
1774
1775 /** Constructor for a Tuple node.
1776  *
1777  * This is an auxiliary node to replace a node that returns a tuple
1778  * without changing the corresponding Proj nodes.
1779  *
1780  * @param *db     A pointer for debug information.
1781  * @param *irg    The ir graph the node  belongs to.
1782  * @param *block  The ir block the node belongs to.
1783  * @param arity   The number of tuple elements.
1784  * @param *in[]   An array containing pointers to the nodes producing the tuple
1785  *                elements. The constructor copies this array.
1786  */
1787 ir_node *new_rd_Tuple  (dbg_info *db, ir_graph *irg, ir_node *block,
1788                         int arity, ir_node *in[]);
1789
1790 /** Constructor for a Id node.
1791  *
1792  * This is an auxiliary node to replace a node that returns a single
1793  * value.
1794  *
1795  * @param *db     A pointer for debug information.
1796  * @param *irg    The ir graph the node  belongs to.
1797  * @param *block  The ir block the node belongs to.
1798  * @param *val    The value
1799  * @param *mode   The mode of *val.
1800  */
1801 ir_node *new_rd_Id     (dbg_info *db, ir_graph *irg, ir_node *block,
1802                         ir_node *val, ir_mode *mode);
1803
1804 /** Constructor for a Bad node.
1805  *
1806  * Returns the unique Bad node of the graph.  The same as
1807  * get_irg_bad().
1808  *
1809  * @param *irg    The ir graph the node belongs to.
1810  */
1811 ir_node *new_rd_Bad    (ir_graph *irg);
1812
1813 /** Constructor for a Confirm node.
1814  *
1815  * Specifies constraints for a value.  To support dataflow analyses.
1816  *
1817  * Example: If the value never exceeds '100' this is expressed by placing a
1818  * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
1819  *
1820  * @param *irg    The ir graph the node belong to.
1821  * @param *block  The ir block the node belong to.
1822  * @param *db     A pointer for debug information.
1823  * @param *val    The value we express a constraint for
1824  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
1825  * @param cmp     The compare operation.
1826  */
1827 ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
1828              ir_node *val, ir_node *bound, pn_Cmp cmp);
1829
1830 /** Constructor for an exception region bounded Confirm node.
1831  *
1832  * Specifies constraints for a value.  To support dataflow analyses.
1833  *
1834  * Example: If the value never exceeds '100' this is expressed by placing a
1835  * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
1836  *
1837  * @param *irg    The ir graph the node belong to.
1838  * @param *block  The ir block the node belong to.
1839  * @param *db     A pointer for debug information.
1840  * @param *val    The value we express a constraint for
1841  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
1842  * @param cmp     The compare operation.
1843  */
1844 ir_node *new_rd_bounded_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
1845              ir_node *val, ir_node *bound, pn_Cmp cmp);
1846
1847 /** Constructor for an Unknown node.
1848  *
1849  * Represents an arbitrary value.  Places the node in the start block.
1850  *
1851  * @param *irg    The ir graph the node  belongs to.
1852  * @param *m      The mode of the unknown value.
1853  */
1854 ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
1855
1856 /** Constructor for a CallBegin node.
1857  *
1858  * CallBegin represents control flow depending of the pointer value
1859  * representing the called method to the called methods.  The
1860  * constructor copies the method pointer input from the passed Call
1861  * node.
1862  *
1863  * @param *db     A pointer for debug information.
1864  * @param *irg    The ir graph the node belong to.
1865  * @param *block  The block the node belong to.
1866  * @param *callee The call node visible in the intra procedural view.
1867  */
1868 ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
1869
1870 /** Constructor for a EndReg node.
1871  *
1872  * Used to represent regular procedure end in interprocedual view.
1873  *
1874  * @param *db     A pointer for debug information.
1875  * @param *irg    The ir graph the node belong to.
1876  * @param *block  The block the node belong to.
1877  */
1878 ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
1879
1880 /** Constructor for a EndExcept node.
1881  *
1882  * Used to represent exceptional procedure end in interprocedural view.
1883  *
1884  * @param *db     A pointer for debug information.
1885  * @param *irg    The ir graph the node belong to.
1886  * @param *block  The block the node belong to.
1887  */
1888 ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
1889
1890 /** Constructor for a Filter node.
1891  *
1892  * Adds the node to the block in current_ir_block.  Filter is a node
1893  * with two views used to construct the interprocedural view.  In
1894  * intraprocedural view its semantics are identical to the Proj node.
1895  * In interprocedural view the Filter performs the Phi operation on
1896  * method parameters or results.  Other than a Phi a Filter node may
1897  * not be removed if it has only a single input.
1898  *
1899  * The constructor builds the Filter in intraprocedural view.
1900  *
1901  * @param *db     A pointer for debug information.
1902  * @param *irg    The ir graph the node belong to.
1903  * @param *block  The block the node belong to.
1904  * @param *arg  The tuple value to project from.
1905  * @param *mode The mode of the projected value.
1906  * @param proj  The position in the tuple to project from.
1907  */
1908 ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1909                         ir_mode *mode, long proj);
1910
1911 /** Constructor for a NoMem node.
1912  *
1913  * Returns the unique NoMem node of the graph.  The same as
1914  * get_irg_no_mem().
1915  *
1916  * @param *irg    The ir graph the node belongs to.
1917  */
1918 ir_node *new_rd_NoMem  (ir_graph *irg);
1919
1920 /** Constructor for a Mux node.
1921  *
1922  * @param *db       A pointer for debug information.
1923  * @param *irg      The ir graph the node belong to.
1924  * @param *block    The block the node belong to.
1925  * @param *sel      The ir_node that calculates the boolean select.
1926  * @param *ir_true  The ir_node that calculates the true result.
1927  * @param *ir_false The ir_node that calculates the false result.
1928  * @param *mode     The mode of the node (and it_true and ir_false).
1929  */
1930 ir_node *new_rd_Mux  (dbg_info *db, ir_graph *irg, ir_node *block,
1931     ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
1932
1933 /** Constructor for a Psi node.
1934  *
1935  * @param *db       A pointer for debug information.
1936  * @param *irg      The ir graph the node belong to.
1937  * @param *block    The block the node belong to.
1938  * @param *arity    The arity of the conditions
1939  * @param *conds    The array of mode_b conditions, length must be equal arity
1940  * @param *vals     The array of mode values, length must be equal arity + 1
1941  * @param *mode     The mode of the node (must be the mode of all vals).
1942  */
1943 ir_node *new_rd_Psi (dbg_info *db, ir_graph *irg, ir_node *block,
1944                      int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
1945
1946 /** Constructor for a CopyB node.
1947  *
1948  * @param *db         A pointer for debug information.
1949  * @param *irg        The ir graph the node belong to.
1950  * @param *block      The block the node belong to.
1951  * @param *store      The current memory
1952  * @param *dst        The ir_node that represents the destination address.
1953  * @param *src        The ir_node that represents the source address.
1954  * @param *data_type  The type of the copied data
1955  */
1956 ir_node *new_rd_CopyB(dbg_info *db, ir_graph *irg, ir_node *block,
1957     ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
1958
1959 /** Constructor for a InstOf node.
1960  *
1961  * A High-Level Type check.
1962  *
1963  * @param   *db        A pointer for debug information.
1964  * @param   *irg       The ir graph the node  belongs to.
1965  * @param   *block     The ir block the node belongs to.
1966  * @param   *store     The memory in which the object the entity should be selected
1967  *                     from is allocated.
1968  * @param   *objptr    A pointer to a object of a class type.
1969  * @param   *type      The type of which objptr must be.
1970  */
1971 ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1972                         ir_node *objptr, ir_type *type);
1973
1974 /** Constructor for a Raise node.
1975  *
1976  * A High-Level Exception throw.
1977  *
1978  * @param *db    A pointer for debug information.
1979  * @param *irg   The ir graph the node  belongs to.
1980  * @param *block The ir block the node belongs to.
1981  * @param *store The current memory.
1982  * @param *obj   A pointer to the Except variable.
1983  */
1984 ir_node *new_rd_Raise  (dbg_info *db, ir_graph *irg, ir_node *block,
1985                         ir_node *store, ir_node *obj);
1986
1987 /** Constructor for a Bound node.
1988  *
1989  * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
1990  *
1991  * @param *db         A pointer for debug information.
1992  * @param *irg        The ir graph the node belong to.
1993  * @param *block      The block the node belong to.
1994  * @param *store      The current memory.
1995  * @param *idx        The ir_node that represents an index.
1996  * @param *lower      The ir_node that represents the lower bound for the index.
1997  * @param *upper      The ir_node that represents the upper bound for the index.
1998  */
1999 ir_node *new_rd_Bound(dbg_info *db, ir_graph *irg, ir_node *block,
2000     ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
2001
2002 /** Constructor for a Pin node.
2003  *
2004  * @param *db         A pointer for debug information.
2005  * @param *irg        The ir graph the node belong to.
2006  * @param *block      The block the node belong to.
2007  * @param *node       The node which value should be pinned.
2008  */
2009 ir_node *new_rd_Pin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *node);
2010
2011 /** Constructor for an ASM pseudo node.
2012  *
2013  * @param *db         A pointer for debug information.
2014  * @param *irg        The ir graph the node belong to.
2015  * @param *block      The block the node belong to.
2016  * @param arity       The number of data inputs to the node.
2017  * @param *in         The array of length arity of data inputs.
2018  * @param *inputs     The array of length arity of input constraints.
2019  * @param n_outs      The number of data outputs to the node.
2020  * @param *outputs    The array of length n_outs of output constraints.
2021  * @param n_clobber   The number of clobbered registers.
2022  * @param *clobber    The array of length n_clobber of clobbered registers.
2023  * @param *asm_text   The assembler text.
2024  */
2025 ir_node *new_rd_ASM(dbg_info *db, ir_graph *irg, ir_node *block,
2026                     int arity, ir_node *in[], ir_asm_constraint *inputs,
2027                     int n_outs, ir_asm_constraint *outputs,
2028                     int n_clobber, ident *clobber[], ident *asm_text);
2029
2030 /*-------------------------------------------------------------------------*/
2031 /* The raw interface without debug support                                 */
2032 /*-------------------------------------------------------------------------*/
2033
2034 /** Constructor for a Block node.
2035  *
2036  * Constructs a mature block with the given predecessors.  Use Unknown
2037  * nodes as predecessors to construct a block if the number of
2038  * predecessors is known, but not the predecessors themselves.  This
2039  * constructor does not set current_block.  It not be used with
2040  * automatic Phi node construction.
2041  *
2042  *
2043  * @param irg    The ir graph the block belongs to.
2044  * @param arity  The number of control predecessors.
2045  * @param in[]   An array of control predecessors.  The length of
2046  *               the array must be 'arity'. The constructor copies this array.
2047  */
2048 ir_node *new_r_Block  (ir_graph *irg,  int arity, ir_node *in[]);
2049
2050 /** Constructor for a Start node.
2051  *
2052  * @param *irg   The ir graph the node belongs to.
2053  * @param *block The ir block the node belongs to.
2054  */
2055 ir_node *new_r_Start  (ir_graph *irg, ir_node *block);
2056
2057 /** Constructor for a End node.
2058  *
2059  * @param *irg   The ir graph the node  belongs to.
2060  * @param *block The ir block the node belongs to.
2061  */
2062 ir_node *new_r_End    (ir_graph *irg, ir_node *block);
2063
2064 /** Constructor for a Jmp node.
2065  *
2066  * Jmp represents control flow to a single control successor.
2067  *
2068  * @param *irg    The ir graph the node belongs to.
2069  * @param *block  The ir block the node belongs to.
2070  */
2071 ir_node *new_r_Jmp    (ir_graph *irg, ir_node *block);
2072
2073 /** Constructor for an IJmp node.
2074  *
2075  * IJmp represents control flow to a single control successor not
2076  * statically known i.e. an indirect Jmp.
2077  *
2078  * @param *irg    The ir graph the node belongs to.
2079  * @param *block  The ir block the node belongs to.
2080  * @param *tgt    The ir node representing the target address.
2081  */
2082 ir_node *new_r_IJmp   (ir_graph *irg, ir_node *block, ir_node *tgt);
2083
2084 /** Constructor for a Cond node.
2085  *
2086  * If c is mode_b represents a conditional branch (if/else). If c is
2087  * mode_Is/mode_Iu (?) represents a switch.  (Allocates dense Cond
2088  * node, default Proj is 0.)
2089  *
2090  * This is not consistent:  Input to Cond is Is, Proj has as proj number
2091  * longs.
2092  *
2093  * @param *irg   The ir graph the node  belongs to.
2094  * @param *block The ir block the node belongs to.
2095  * @param *c     The conditions parameter.Can be of mode b or I_u.
2096  */
2097 ir_node *new_r_Cond   (ir_graph *irg, ir_node *block, ir_node *c);
2098
2099 /** Constructor for a Return node.
2100  *
2101  * Returns the memory an zero or more return values.  Only node that
2102  * can end regular control flow.
2103  *
2104  * @param *irg   The ir graph the node  belongs to.
2105  * @param *block The ir block the node belongs to.
2106  * @param *store The state of memory.
2107  * @param arity  Number of array indices.
2108  * @param *in[]   Array with index inputs to the node. The constructor copies this array.
2109  */
2110 ir_node *new_r_Return (ir_graph *irg, ir_node *block,
2111                        ir_node *store, int arity, ir_node *in[]);
2112
2113 /** Constructor for a Const node.
2114  *
2115  * Constructor for a Const node. The constant represents a target
2116  * value.  Sets the type information to type_unknown.  (No more
2117  * supported: If tv is entity derives a somehow useful type.)
2118  *
2119  * @param *irg   The ir graph the node  belongs to.
2120  * @param *block The ir block the node belongs to.
2121  * @param *mode  The mode of the operands and the results.
2122  * @param *con   Points to an entry in the constant table.
2123  */
2124 ir_node *new_r_Const  (ir_graph *irg, ir_node *block,
2125                        ir_mode *mode, tarval *con);
2126
2127 /** Constructor for a Const node.
2128  *
2129  * Constructor for a Const node. The constant represents a target
2130  * value.  Sets the type information to type_unknown.  (No more
2131  * supported: If tv is entity derives a somehow useful type.)
2132  *
2133  * @param *irg   The ir graph the node  belongs to.
2134  * @param *block The ir block the node belongs to.
2135  * @param *mode  The mode of the operands and the results.
2136  * @param value  A value from which the tarval is made.
2137  */
2138 ir_node *new_r_Const_long(ir_graph *irg, ir_node *block,
2139                        ir_mode *mode, long value);
2140
2141 /** Constructor for a Const_type node.
2142  *
2143  * The constant represents a target value.  This constructor sets high
2144  * level type information for the constant value.
2145  *
2146  * @param *irg   The ir graph the node  belongs to.
2147  * @param *block The ir block the node belongs to.
2148  * @param *mode  The mode of the operands and results.
2149  * @param *con   Points to an entry in the constant table.
2150  * @param *tp    The type of the constant.
2151  */
2152 ir_node *new_r_Const_type(ir_graph *irg, ir_node *block,
2153            ir_mode *mode, tarval *con, ir_type *tp);
2154
2155 /** Constructor for a SymConst node.
2156  *
2157  *  This is the constructor for a symbolic constant.
2158  *    There are four kinds of symbolic constants:
2159  *    - type_tag  The symbolic constant represents a type tag.  The type the
2160  *                tag stands for is given explicitly.
2161  *    - size      The symbolic constant represents the size of a type.  The
2162  *                type of which the constant represents the size is given
2163  *                explicitly.
2164  *    - addr_name The symbolic constant represents the address of an entity
2165  *                (variable or method).  The variable is indicated by a name
2166  *                that is valid for linking.
2167  *    - addr_ent   The symbolic constant represents the address of an entity
2168  *                (variable or method).  The variable is given explicitly by
2169  *                a firm entity.
2170  *
2171  *    Inputs to the node:
2172  *      No inputs except the block it belongs to.
2173  *    Outputs of the node.
2174  *      An unsigned integer (I_u) or a pointer (P).
2175  *
2176  * @param *irg    The ir graph the node  belongs to.
2177  * @param *block  The ir block the node belongs to.
2178  * @param value   A type, entity or a ident depending on the SymConst kind.
2179  * @param symkind The kind of the symbolic constant: type_tag, size or link_info.
2180  */
2181 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
2182                          union symconst_symbol value, symconst_kind symkind);
2183
2184 /** Constructor for a simpleSel node.
2185  *
2186  *  This is a shortcut for the new_d_Sel() constructor.  To be used for
2187  *  Sel nodes that do not select from an array, i.e., have no index
2188  *  inputs.  It adds the two parameters 0, NULL.
2189  *
2190  * @param   *irg       The ir graph the node  belongs to.
2191  * @param   *block     The ir block the node belongs to.
2192  * @param   *store     The memory in which the object the entity should be selected
2193  *                     from is allocated.
2194  * @param   *objptr    The object from that the Sel operation selects a
2195  *                     single attribute out.
2196  * @param   *ent       The entity to select.
2197  */
2198 ir_node *new_r_simpleSel(ir_graph *irg, ir_node *block, ir_node *store,
2199                          ir_node *objptr, ir_entity *ent);
2200
2201 /** Constructor for a Sel node.
2202  *
2203  * The select node selects an entity (field or method) from an entity
2204  * with a compound type.  It explicitly specifies the entity selected.
2205  * Dynamically the node may select entities that overwrite the given
2206  * entity.  If the selected entity is an array element entity the Sel
2207  * node takes the required array indices as inputs.
2208  *
2209  * @param   *irg       The ir graph the node  belongs to.
2210  * @param   *block     The ir block the node belongs to.
2211  * @param   *store     The memory in which the object the entity should be selected
2212  *                     from is allocated.
2213  * @param   *objptr    A pointer to a compound entity the Sel operation selects a
2214  *                     single attribute from.
2215  * @param   *n_index   The number of array indices needed to select an array element entity.
2216  * @param   *index[]   If the compound entity is an array the indices of the selected
2217  *                     element entity.  The constructor copies this array.
2218  * @param   *ent       The entity to select.
2219  */
2220 ir_node *new_r_Sel    (ir_graph *irg, ir_node *block, ir_node *store,
2221                        ir_node *objptr, int n_index, ir_node *index[],
2222                ir_entity *ent);
2223
2224 /** Constructor for a Call node.
2225  *
2226  *  Represents all kinds of method and function calls.
2227  *
2228  * @param   *irg    The ir graph the node  belongs to.
2229  * @param   *block  The ir block the node belongs to.
2230  * @param   *store  The actual store.
2231  * @param   *callee A pointer to the called procedure.
2232  * @param   arity   The number of procedure parameters.
2233  * @param   *in[]   An array with the pointers to the parameters. The constructor copies this array.
2234  * @param   *tp     Type information of the procedure called.
2235  */
2236 ir_node *new_r_Call   (ir_graph *irg, ir_node *block, ir_node *store,
2237                ir_node *callee, int arity, ir_node *in[],
2238                ir_type *tp);
2239
2240 /** Constructor for a Add node.
2241  *
2242  * @param   *irg   The ir graph the node  belongs to.
2243  * @param   *block The ir block the node belongs to.
2244  * @param   *op1   The first operand.
2245  * @param   *op2   The second operand.
2246  * @param   *mode  The mode of the operands and the result.
2247  */
2248 ir_node *new_r_Add    (ir_graph *irg, ir_node *block,
2249                ir_node *op1, ir_node *op2, ir_mode *mode);
2250
2251 /**
2252  * Constructor for a Sub node.
2253  *
2254  * @param   *irg   The ir graph the node  belongs to.
2255  * @param   *block The ir block the node belongs to.
2256  * @param   *op1   The first operand.
2257  * @param   *op2   The second operand.
2258  * @param   *mode  The mode of the operands and the results.
2259  */
2260 ir_node *new_r_Sub    (ir_graph *irg, ir_node *block,
2261                ir_node *op1, ir_node *op2, ir_mode *mode);
2262
2263 /** Constructor for a Minus node.
2264  *
2265  * @param   *irg   The ir graph the node  belongs to.
2266  * @param   *block The ir block the node belongs to.
2267  * @param   *op   The operand.
2268  * @param   *mode  The mode of the operand and the result.
2269  */
2270 ir_node *new_r_Minus  (ir_graph *irg, ir_node *block,
2271                ir_node *op,  ir_mode *mode);
2272 /** Constructor for a Mul node.
2273  *
2274  * @param   *irg   The ir graph the node  belongs to.
2275  * @param   *block The ir block the node belongs to.
2276  * @param   *op1   The first operand.
2277  * @param   *op2   The second operand.
2278  * @param   *mode  The mode of the operands and the result.
2279  */
2280 ir_node *new_r_Mul    (ir_graph *irg, ir_node *block,
2281                ir_node *op1, ir_node *op2, ir_mode *mode);
2282
2283 /** Constructor for a Quot node.
2284  *
2285  * @param   *irg   The ir graph the node  belongs to.
2286  * @param   *block The ir block the node belongs to.
2287  * @param   *memop The store needed to model exceptions
2288  * @param   *op1   The first operand.
2289  * @param   *op2   The second operand.
2290  * @param   *mode  The mode of the result.
2291  */
2292 ir_node *new_r_Quot   (ir_graph *irg, ir_node *block,
2293                ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
2294
2295 /** Constructor for a DivMod node.
2296  *
2297  * @param   *irg   The ir graph the node  belongs to.
2298  * @param   *block The ir block the node belongs to.
2299  * @param   *memop The store needed to model exceptions
2300  * @param   *op1   The first operand.
2301  * @param   *op2   The second operand.
2302  * @param   *mode  The mode of the results.
2303  */
2304 ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
2305                ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
2306
2307 /** Constructor for a Div node.
2308  *
2309  * @param   *irg   The ir graph the node  belongs to.
2310  * @param   *block The ir block the node belongs to.
2311  * @param   *memop The store needed to model exceptions
2312  * @param   *op1   The first operand.
2313  * @param   *op2   The second operand.
2314  * @param   *mode  The mode of the result.
2315  */
2316 ir_node *new_r_Div    (ir_graph *irg, ir_node *block,
2317                ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
2318
2319 /** Constructor for a Mod node.
2320  *
2321  * @param   *irg   The ir graph the node  belongs to.
2322  * @param   *block The ir block the node belongs to.
2323  * @param   *memop The store needed to model exceptions
2324  * @param   *op1   The first operand.
2325  * @param   *op2   The second operand.
2326  * @param   *mode  The mode of the result.
2327  */
2328 ir_node *new_r_Mod    (ir_graph *irg, ir_node *block,
2329                ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
2330
2331 /** Constructor for a Abs node.
2332  *
2333  * @param   *irg   The ir graph the node  belongs to.
2334  * @param   *block The ir block the node belongs to.
2335  * @param   *op    The operand
2336  * @param   *mode  The mode of the operands and the result.
2337  */
2338 ir_node *new_r_Abs    (ir_graph *irg, ir_node *block,
2339                        ir_node *op, ir_mode *mode);
2340
2341 /** Constructor for a And node.
2342  *
2343  * @param   *irg   The ir graph the node  belongs to.
2344  * @param   *block The ir block the node belongs to.
2345  * @param   *op1   The first operand.
2346  * @param   *op2   The second operand.
2347  * @param   *mode  The mode of the operands and the result.
2348  */
2349 ir_node *new_r_And    (ir_graph *irg, ir_node *block,
2350                ir_node *op1, ir_node *op2, ir_mode *mode);
2351
2352 /** Constructor for a Or node.
2353  *
2354  * @param   *irg   The ir graph the node  belongs to.
2355  * @param   *block The ir block the node belongs to.
2356  * @param   *op1   The first operand.
2357  * @param   *op2   The second operand.
2358  * @param   *mode  The mode of the operands and the result.
2359  */
2360 ir_node *new_r_Or     (ir_graph *irg, ir_node *block,
2361                ir_node *op1, ir_node *op2, ir_mode *mode);
2362
2363 /** Constructor for a Eor node.
2364  *
2365  * @param   *irg   The ir graph the node  belongs to.
2366  * @param   *block The ir block the node belongs to.
2367  * @param   *op1   The first operand.
2368  * @param   *op2   The second operand.
2369  * @param   *mode  The mode of the operands and the results.
2370  */
2371 ir_node *new_r_Eor    (ir_graph *irg, ir_node *block,
2372                ir_node *op1, ir_node *op2, ir_mode *mode);
2373
2374 /** Constructor for a Not node.
2375  *
2376  * @param   *irg   The ir graph the node  belongs to.
2377  * @param   *block The ir block the node belongs to.
2378  * @param   *op    The operand.
2379  * @param   *mode  The mode of the operand and the result.
2380  */
2381 ir_node *new_r_Not    (ir_graph *irg, ir_node *block,
2382                ir_node *op, ir_mode *mode);
2383
2384 /** Constructor for a Cmp node.
2385  *
2386  * @param   *irg   The ir graph the node  belongs to.
2387  * @param   *block The ir block the node belongs to.
2388  * @param   *op1   The first operand.
2389  * @param   *op2   The second operand.
2390  */
2391 ir_node *new_r_Cmp    (ir_graph *irg, ir_node *block,
2392                ir_node *op1, ir_node *op2);
2393
2394 /** Constructor for a Shl node.
2395  *
2396  * @param   *irg   The ir graph the node  belongs to.
2397  * @param   *block The ir block the node belongs to.
2398  * @param   *op    The operand.
2399  * @param   *k     The number of bits to  shift the operand .
2400  * @param   *mode  The mode of the operand and the result.
2401  */
2402 ir_node *new_r_Shl    (ir_graph *irg, ir_node *block,
2403                ir_node *op, ir_node *k, ir_mode *mode);
2404
2405 /** Constructor for a Shr node.
2406  *
2407  * @param   *irg   The ir graph the node  belongs to.
2408  * @param   *block The ir block the node belongs to.
2409  * @param   *op    The operand.
2410  * @param   *k     The number of bits to shift the operand .
2411  * @param   *mode  The mode of the operand and the result.
2412  */
2413 ir_node *new_r_Shr    (ir_graph *irg, ir_node *block,
2414                ir_node *op, ir_node *k, ir_mode *mode);
2415
2416 /**
2417  * Constructor for a Shrs node.
2418  *
2419  * @param   *irg   The ir graph the node  belongs to.
2420  * @param   *block The ir block the node belongs to.
2421  * @param   *op    The operand.
2422  * @param   *k     The number of bits to shift the operand.
2423  * @param   *mode  The mode of the operand and the result.
2424  */
2425 ir_node *new_r_Shrs   (ir_graph *irg, ir_node *block,
2426                ir_node *op, ir_node *k, ir_mode *mode);
2427
2428 /** Constructor for a Rot node.
2429  *
2430  * @param   *irg   The ir graph the node  belongs to.
2431  * @param   *block The ir block the node belongs to.
2432  * @param   *op    The operand.
2433  * @param   *k     The number of bits to rotate the operand.
2434  * @param   *mode  The mode of the operand.
2435  */
2436 ir_node *new_r_Rot    (ir_graph *irg, ir_node *block,
2437                ir_node *op, ir_node *k, ir_mode *mode);
2438
2439 /** Constructor for a Conv node.
2440  *
2441  * @param   *irg   The ir graph the node  belongs to.
2442  * @param   *block The ir block the node belongs to.
2443  * @param   *op    The operand.
2444  * @param   *mode  The mode of this the operand muss be converted .
2445  */
2446 ir_node *new_r_Conv   (ir_graph *irg, ir_node *block,
2447                ir_node *op, ir_mode *mode);
2448
2449 /** Constructor for a Cast node.
2450  *
2451  * High level type cast
2452  *
2453  * @param   *irg   The ir graph the node  belongs to.
2454  * @param   *block The ir block the node belongs to.
2455  * @param   *op    The operand.
2456  * @param   *to_tp The type of this the operand muss be casted .
2457  */
2458 ir_node *new_r_Cast   (ir_graph *irg, ir_node *block,
2459                ir_node *op, ir_type *to_tp);
2460
2461 /** Constructor for a Carry node.
2462  *
2463  * @param   *irg   The ir graph the node  belongs to.
2464  * @param   *block The ir block the node belongs to.
2465  * @param   *op1   The first operand.
2466  * @param   *op2   The second operand.
2467  * @param   *mode  The mode of the operands and the result.
2468  */
2469 ir_node *new_r_Carry  (ir_graph *irg, ir_node *block,
2470                ir_node *op1, ir_node *op2, ir_mode *mode);
2471
2472 /**
2473  * Constructor for a Borrow node.
2474  *
2475  * @param   *irg   The ir graph the node  belongs to.
2476  * @param   *block The ir block the node belongs to.
2477  * @param   *op1   The first operand.
2478  * @param   *op2   The second operand.
2479  * @param   *mode  The mode of the operands and the results.
2480  */
2481 ir_node *new_r_Borrow (ir_graph *irg, ir_node *block,
2482                ir_node *op1, ir_node *op2, ir_mode *mode);
2483
2484 /** Constructor for a Phi node.
2485  *
2486  * @param *irg   The ir graph the node  belongs to.
2487  * @param *block The ir block the node belongs to.
2488  * @param arity  The number of predecessors
2489  * @param *in[]    Array with predecessors. The constructor copies this array.
2490  * @param *mode  The mode of it's inputs and output.
2491  */
2492 ir_node *new_r_Phi    (ir_graph *irg, ir_node *block, int arity,
2493                        ir_node *in[], ir_mode *mode);
2494
2495 /** Constructor for a Load node.
2496  *
2497  * @param *irg   The ir graph the node  belongs to.
2498  * @param *block The ir block the node belongs to.
2499  * @param *store The current memory
2500  * @param *adr   A pointer to the variable to be read in this memory.
2501  * @param *mode  The mode of the value to be loaded.
2502  */
2503 ir_node *new_r_Load   (ir_graph *irg, ir_node *block,
2504                ir_node *store, ir_node *adr, ir_mode *mode);
2505
2506 /** Constructor for a Store node.
2507  *
2508  * @param *irg   The ir graph the node  belongs to.
2509  * @param *block The ir block the node belongs to.
2510  * @param *store The current memory
2511  * @param *adr   A pointer to the variable to be read in this memory.
2512  * @param *val   The value to write to this variable.
2513  */
2514 ir_node *new_r_Store  (ir_graph *irg, ir_node *block,
2515                        ir_node *store, ir_node *adr, ir_node *val);
2516
2517 /** Constructor for a Alloc node.
2518  *
2519  * The Alloc node extends the memory by space for an entity of type alloc_type.
2520  *
2521  * @param *irg        The ir graph the node  belongs to.
2522  * @param *block      The ir block the node belongs to.
2523  * @param *store      The memory which shall contain the new variable.
2524  * @param *size       The number of bytes to allocate.
2525  * @param *alloc_type The type of the allocated variable.
2526  * @param where       Where to allocate the variable, either heap_alloc or stack_alloc.
2527  */
2528 ir_node *new_r_Alloc  (ir_graph *irg, ir_node *block, ir_node *store,
2529                ir_node *size, ir_type *alloc_type, where_alloc where);
2530
2531 /** Constructor for a Free node.
2532  *
2533  * Frees the memory occupied by the entity pointed to by the pointer
2534  * arg.  Type indicates the type of the entity the argument points to.
2535  *
2536  * @param *irg        The ir graph the node  belongs to.
2537  * @param *block      The ir block the node belongs to.
2538  * @param *store      The memory which shall contain the new variable.
2539  * @param *ptr        The pointer to the object to free.
2540  * @param *size       The number of objects of type free_type to free in a sequence.
2541  * @param *free_type  The type of the freed variable.
2542  * @param where       Where the variable was allocated, either heap_alloc or stack_alloc.
2543  */
2544 ir_node *new_r_Free   (ir_graph *irg, ir_node *block, ir_node *store,
2545                ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
2546
2547 /** Constructor for a Sync node.
2548  *
2549  * Merges several memory values.  The node assumes that a variable
2550  * either occurs only in one of the memories, or it contains the same
2551  * value in all memories where it occurs.
2552  *
2553  * @param *irg      The ir graph the node  belongs to.
2554  * @param *block    The ir block the node belongs to.
2555  * @param  arity    The number of memories to synchronize.
2556  * @param  *in[]    An array of pointers to nodes that produce an output of  type memory.
2557  *                  The constructor copies this array.
2558  */
2559 ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2560
2561 /** Constructor for a Proj node.
2562  *
2563  * Projects a single value out of a tuple.  The parameter proj gives the
2564  * position of the value within the tuple.
2565  *
2566  * @param *irg   The ir graph the node  belongs to.
2567  * @param *block The ir block the node belongs to.
2568  * @param arg    A node producing a tuple.
2569  * @param *mode  The mode of the value to project.
2570  * @param proj   The position of the value in the tuple.
2571  */
2572 ir_node *new_r_Proj   (ir_graph *irg, ir_node *block, ir_node *arg,
2573                        ir_mode *mode, long proj);
2574
2575 /** Constructor for a defaultProj node.
2576  *
2577  * Represents the default control flow of a Switch-Cond node.
2578  *
2579  * @param *irg      The ir graph the node  belongs to.
2580  * @param *block    The ir block the node belongs to.
2581  * @param arg       A node producing a tuple.
2582  * @param max_proj  The end  position of the value in the tuple.
2583  */
2584 ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj);
2585
2586
2587 /** Constructor for a Tuple node.
2588  *
2589  * This is an auxiliary node to replace a node that returns a tuple
2590  * without changing the corresponding Proj nodes.
2591  *
2592  * @param *irg    The ir graph the node  belongs to.
2593  * @param *block  The ir block the node belongs to.
2594  * @param arity   The number of tuple elements.
2595  * @param *in[]   An array containing pointers to the nodes producing the tuple elements.
2596  *                The constructor copies this array.
2597  */
2598 ir_node *new_r_Tuple  (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2599
2600 /** Constructor for a Id node.
2601  *
2602  * This is an auxiliary node to replace a node that returns a single
2603  * value.
2604  *
2605  * @param *irg    The ir graph the node  belongs to.
2606  * @param *block  The ir block the node belongs to.
2607  * @param *val    The operand to Id.
2608  * @param *mode   The mode of *val.
2609  */
2610 ir_node *new_r_Id     (ir_graph *irg, ir_node *block,
2611                ir_node *val, ir_mode *mode);
2612
2613 /** Constructor for a Bad node.
2614  *
2615  * Returns the unique Bad node of the graph.  The same as
2616  * get_irg_bad().
2617  *
2618  * @param *irg    The ir graph the node  belongs to.
2619  *
2620  */
2621 ir_node *new_r_Bad    (ir_graph *irg);
2622
2623 /** Constructor for a Confirm node.
2624  *
2625  * Specifies constraints for a value.  To support dataflow analyses.
2626  *
2627  * Example: If the value never exceeds '100' this is expressed by placing a
2628  * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
2629  *
2630  * @param *irg    The ir graph the node belong to.
2631  * @param *block  The ir block the node belong to.
2632  * @param *val    The value we express a constraint for
2633  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
2634  * @param cmp     The compare operation.
2635  */
2636 ir_node *new_r_Confirm(ir_graph *irg, ir_node *block,
2637             ir_node *val, ir_node *bound, pn_Cmp cmp);
2638
2639 /** Constructor for an exception region bounded Confirm node.
2640  *
2641  * Specifies constraints for a value.  To support dataflow analyses.
2642  *
2643  * Example: If the value never exceeds '100' this is expressed by placing a
2644  * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
2645  *
2646  * @param *irg    The ir graph the node belong to.
2647  * @param *block  The ir block the node belong to.
2648  * @param *val    The value we express a constraint for
2649  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
2650  * @param cmp     The compare operation.
2651  */
2652 ir_node *new_r_bounded_Confirm(ir_graph *irg, ir_node *block,
2653             ir_node *val, ir_node *bound, pn_Cmp cmp);
2654
2655 /** Constructor for a Unknown node.
2656  *
2657  * Represents an arbitrary value.  Places the node in
2658  * the start block.
2659  *
2660  * @param *irg    The ir graph the node  belongs to.
2661  * @param *m      The mode of the unknown value.
2662  */
2663 ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2664
2665 /** Constructor for a CallBegin node.
2666  *
2667  * CallBegin represents control flow depending of the pointer value
2668  * representing the called method to the called methods.  The
2669  * constructor copies the method pointer input from the passed Call
2670  * node.
2671  *
2672  * @param *irg    The ir graph the node belong to.
2673  * @param *block  The block the node belong to.
2674  * @param *callee The call node visible in the  intra procedural view.
2675  */
2676 ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
2677
2678 /** Constructor for a EndReg node.
2679  *
2680  * Used to represent regular procedure end in interprocedual view.
2681  *
2682  * @param *irg    The ir graph the node belong to.
2683  * @param *block  The block the node belong to.
2684  */
2685 ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
2686
2687 /** Constructor for a EndExcept node.
2688  *
2689  * Used to represent exceptional procedure end in interprocedural view.
2690  *
2691  * @param *irg    The ir graph the node belong to.
2692  * @param *block  The block the node belong to.
2693  */
2694 ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
2695
2696 /** Constructor for a Break node.
2697  *
2698  * Break represents control flow to a single control successor just as Jmp.
2699  * The blocks separated by a break may not be concatenated by an optimization.
2700  * It is used for the interprocedural representation where blocks are parted
2701  * behind Call nodes to represent the control flow to called procedures.
2702  *
2703  * @param *irg    The ir graph the node belong to.
2704  * @param *block  The block the node belong to.
2705  */
2706 ir_node *new_r_Break  (ir_graph *irg, ir_node *block);
2707
2708 /** Constructor for a Filter node.
2709  *
2710  * Constructor for a Filter node. Adds the node to the block in current_ir_block.
2711  * Filter is a node with two views used to construct the interprocedural view.
2712  * In intraprocedural view its semantics are identical to the Proj node.
2713  * In interprocedural view the Filter performs the Phi operation on method
2714  * parameters or results.  Other than a Phi a Filter node may not be removed
2715  * if it has only a single input.
2716  *
2717  * The constructor builds the Filter in intraprocedural view.
2718  *
2719  * @param *irg    The ir graph the node belong to.
2720  * @param *block  The block the node belong to.
2721  * @param *arg  The tuple value to project from.
2722  * @param *mode The mode of the projected value.
2723  * @param proj  The position in the tuple to project from.
2724  */
2725 ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
2726                ir_mode *mode, long proj);
2727
2728 /** Constructor for a NoMem node.
2729  *
2730  * Returns the unique NoMem node of the graph.  The same as
2731  * get_irg_no_mem().
2732  *
2733  * @param *irg    The ir graph the node belongs to.
2734  */
2735 ir_node *new_r_NoMem  (ir_graph *irg);
2736
2737 /** Constructor for a Mux node.
2738  *
2739  * @param *irg      The ir graph the node belong to.
2740  * @param *block    The block the node belong to.
2741  * @param *sel      The ir_node that calculates the boolean select.
2742  * @param *ir_true  The ir_node that calculates the true result.
2743  * @param *ir_false The ir_node that calculates the false result.
2744  * @param *mode     The mode of the node (and it_true and ir_false).
2745  */
2746 ir_node *new_r_Mux  (ir_graph *irg, ir_node *block,
2747     ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2748
2749 /** Constructor for a Psi node.
2750  *
2751  * @param *irg      The ir graph the node belong to.
2752  * @param *block    The block the node belong to.
2753  * @param *arity    The arity of the conditions
2754  * @param *conds    The array of mode_b conditions, length must be equal arity
2755  * @param *vals     The array of mode values, length must be equal arity + 1
2756  * @param *mode     The mode of the node (must be the mode of all vals).
2757  */
2758 ir_node *new_r_Psi (ir_graph *irg, ir_node *block,
2759                     int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
2760
2761 /** Constructor for a CopyB node.
2762  *
2763  * @param *irg        The ir graph the node belong to.
2764  * @param *block      The block the node belong to.
2765  * @param *store      The current memory
2766  * @param *dst        The ir_node that represents the destination address.
2767  * @param *src        The ir_node that represents the source address.
2768  * @param *data_type  The type of the copied data
2769  */
2770 ir_node *new_r_CopyB(ir_graph *irg, ir_node *block,
2771     ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
2772
2773 /** Constructor for a InstOf node.
2774  *
2775  * A High-Level Type check.
2776  *
2777  * @param   *irg       The ir graph the node  belongs to.
2778  * @param   *block     The ir block the node belongs to.
2779  * @param   *store     The memory in which the object the entity should be selected
2780  *                     from is allocated.
2781  * @param   *objptr    A pointer to a object of a class type.
2782  * @param   *type      The type of which objptr must be.
2783  */
2784 ir_node *new_r_InstOf(ir_graph *irg, ir_node *block, ir_node *store,
2785                       ir_node *objptr, ir_type *type);
2786
2787 /** Constructor for a Raise node.
2788  *
2789  * A High-Level Exception throw.
2790  *
2791  * @param *irg   The ir graph the node  belongs to.
2792  * @param *block The ir block the node belongs to.
2793  * @param *store The current memory.
2794  * @param *obj   A pointer to the Except variable.
2795  */
2796 ir_node *new_r_Raise(ir_graph *irg, ir_node *block,
2797                      ir_node *store, ir_node *obj);
2798
2799 /** Constructor for a Bound node.
2800  *
2801  * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
2802  *
2803  * @param *irg        The ir graph the node belong to.
2804  * @param *block      The block the node belong to.
2805  * @param *store      The current memory.
2806  * @param *idx        The ir_node that represents an index.
2807  * @param *lower      The ir_node that represents the lower bound for the index.
2808  * @param *upper      The ir_node that represents the upper bound for the index.
2809  */
2810 ir_node *new_r_Bound(ir_graph *irg, ir_node *block,
2811     ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
2812
2813 /** Constructor for a Pin node.
2814  *
2815  * @param *irg        The ir graph the node belong to.
2816  * @param *block      The block the node belong to.
2817  * @param *node       The node which value should be pinned.
2818  */
2819 ir_node *new_r_Pin(ir_graph *irg, ir_node *block, ir_node *node);
2820
2821 /** Constructor for an ASM pseudo node.
2822  *
2823  * @param *irg        The ir graph the node belong to.
2824  * @param *block      The block the node belong to.
2825  * @param arity       The number of data inputs to the node.
2826  * @param *in         The array of length arity of data inputs.
2827  * @param *inputs     The array of length arity of input constraints.
2828  * @param n_outs      The number of data outputs to the node.
2829  * @param *outputs    The array of length n_outs of output constraints.
2830  * @param n_clobber   The number of clobbered registers.
2831  * @param *clobber    The array of length n_clobber of clobbered registers.
2832  * @param *asm_text   The assembler text.
2833  */
2834 ir_node *new_r_ASM(ir_graph *irg, ir_node *block,
2835                    int arity, ir_node *in[], ir_asm_constraint *inputs,
2836                    int n_outs, ir_asm_constraint *outputs,
2837                    int n_clobber, ident *clobber[], ident *asm_text);
2838
2839 /*-----------------------------------------------------------------------*/
2840 /* The block oriented interface                                          */
2841 /*-----------------------------------------------------------------------*/
2842
2843 /** Sets the current block in which the following constructors place the
2844  *  nodes they construct.
2845  *
2846  *  @param target  The new current block.
2847  */
2848 void     set_cur_block (ir_node *target);
2849
2850 /** Returns the current block of the current graph. */
2851 ir_node *get_cur_block(void);
2852
2853 /** Returns the fixed nodes  of the current graph. */
2854 #define get_cur_end_block()   get_irg_end_block(current_ir_graph)
2855 #define get_cur_end()         get_irg_end(current_ir_graph)
2856 #define get_cur_start_block() get_irg_start_block(current_ir_graph)
2857 #define get_cur_start()       get_irg_start(current_ir_graph)
2858
2859 /** Constructor for a Block node.
2860  *
2861  * Adds the block to the graph in current_ir_graph. Constructs a Block
2862  * with a fixed number of predecessors.  Does set current_block.  Can
2863  * be used with automatic Phi node construction.
2864  *
2865  * @param *db    A Pointer for debug information.
2866  * @param arity  The number of control predecessors.
2867  * @param in[]   An array of control predecessors.  The length of
2868  *               the array must be 'arity'.
2869  */
2870 ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
2871
2872 /** Constructor for a Start node.
2873  *
2874  * Adds the node to the block in current_ir_block.
2875  *
2876  * @param *db    A pointer for debug information.
2877  */
2878 ir_node *new_d_Start  (dbg_info *db);
2879
2880 /** Constructor for a End node.
2881  *
2882  * Adds the node to the block in current_ir_block.
2883  *
2884  * @param *db     A pointer for debug information.
2885  */
2886 ir_node *new_d_End    (dbg_info *db);
2887
2888 /** Constructor for a Jmp node.
2889  *
2890  * Adds the node to the block in current_ir_block.
2891  *
2892  * Jmp represents control flow to a single control successor.
2893  *
2894  * @param *db     A pointer for debug information.
2895  */
2896 ir_node *new_d_Jmp    (dbg_info *db);
2897
2898 /** Constructor for an IJmp node.
2899  *
2900  * IJmp represents control flow to a single control successor not
2901  * statically known i.e. an indirect Jmp.
2902  *
2903  * @param *db     A pointer for debug information.
2904  * @param *tgt    The ir node representing the target address.
2905  */
2906 ir_node *new_d_IJmp   (dbg_info *db, ir_node *tgt);
2907
2908 /** Constructor for a Cond node.
2909  *
2910  * Adds the node to the block in current_ir_block.
2911  *
2912  * If c is mode_b represents a conditional branch (if/else). If c is
2913  * mode_Is/mode_Iu (?) represents a switch.  (Allocates dense Cond
2914  * node, default Proj is 0.)
2915  *
2916  * This is not consistent:  Input to Cond is Is, Proj has as proj number
2917  * longs.
2918  *
2919  * @param *db    A pointer for debug information.
2920  * @param *c     The conditions parameter.Can be of mode b or I_u.
2921  */
2922 ir_node *new_d_Cond   (dbg_info *db, ir_node *c);
2923
2924 /** Constructor for a Return node.
2925  *
2926  * Adds the node to the block in current_ir_block.
2927  *
2928  * Returns the memory an zero or more return values.  Only node that
2929  * can end regular control flow.
2930  *
2931  * @param *db    A pointer for debug information.
2932  * @param *store The state of memory.
2933  * @param arity  Number of array indices.
2934  * @param *in    Array with index inputs to the node.
2935  */
2936 ir_node *new_d_Return (dbg_info *db, ir_node *store, int arity, ir_node *in[]);
2937
2938 /** Constructor for a Const_type node.
2939  *
2940  * Adds the node to the block in current_ir_block.
2941  *
2942  * The constant represents a target value.  This constructor sets high
2943  * level type information for the constant value.
2944  *
2945  * @param *db    A pointer for debug information.
2946  * @param *mode  The mode of the operands and results.
2947  * @param *con   Points to an entry in the constant table. This pointer is
2948                  added to the attributes of the node.
2949  * @param *tp    The type of the constant.
2950  */
2951 ir_node *new_d_Const_type (dbg_info *db, ir_mode *mode, tarval *con, ir_type *tp);
2952
2953 /** Constructor for a Const node.
2954  *
2955  * Adds the node to the block in current_ir_block.
2956  *
2957  * Constructor for a Const node. The constant represents a target
2958  * value.  Sets the type information to type_unknown.  (No more
2959  * supported: If tv is entity derives a somehow useful type.)
2960  *
2961  * @param *db    A pointer for debug information.
2962  * @param *mode  The mode of the operands and results.
2963  * @param *con   Points to an entry in the constant table. This pointer is added
2964  *               to the attributes of the node.
2965  */
2966 ir_node *new_d_Const  (dbg_info *db, ir_mode *mode, tarval *con);
2967
2968 /** Constructor for a SymConst_type node.
2969  *
2970  *  Adds the node to the block in current_ir_block.
2971  *  This is the constructor for a symbolic constant.
2972  *    There are four kinds of symbolic constants:
2973  *    - type_tag  The symbolic constant represents a type tag.  The type the
2974  *                tag stands for is given explicitly.
2975  *    - size      The symbolic constant represents the size of a type.  The
2976  *                type of which the constant represents the size is given
2977  *                explicitly.
2978  *    - addr_name The symbolic constant represents the address of an entity
2979  *                (variable or method).  The variable is indicated by a name
2980  *                that is valid for linking.
2981  *    - addr_ent   The symbolic constant represents the address of an entity
2982  *                (variable or method).  The variable is given explicitly by
2983  *                a firm entity.
2984  *
2985  *    Inputs to the node:
2986  *      No inputs except the block it belongs to.
2987  *    Outputs of the node.
2988  *      An unsigned integer (I_u) or a pointer (P).
2989  *
2990  * @param *db     A pointer for debug information.
2991  * @param value   A type, entity or ident depending on the SymConst kind.
2992  * @param kind    The kind of the symbolic constant: symconst_type_tag, symconst_type_size,
2993  *                symconst_type_align, symconst_addr_name or symconst_addr_ent.
2994  * @param tp      The source type of the constant.
2995  */
2996 ir_node *new_d_SymConst_type (dbg_info *db, union symconst_symbol value, symconst_kind kind, ir_type *tp);
2997
2998 /** Constructor for a SymConst node.
2999  *
3000  *  Same as new_d_SymConst_type, except that it sets the type to type_unknown. */
3001 ir_node *new_d_SymConst (dbg_info *db, union symconst_symbol value, symconst_kind kind);
3002
3003 /** Constructor for a simpleSel node.
3004  *
3005  *  This is a shortcut for the new_d_Sel() constructor.  To be used for
3006  *  Sel nodes that do not select from an array, i.e., have no index
3007  *  inputs.  It adds the two parameters 0, NULL.
3008  *
3009  * @param   *db        A pointer for debug information.
3010  * @param   *store     The memory in which the object the entity should be
3011  *                     selected from is allocated.
3012  * @param   *objptr    The object from that the Sel operation selects a
3013  *                     single attribute out.
3014  * @param   *ent       The entity to select.
3015  */
3016 ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr, ir_entity *ent);
3017
3018 /** Constructor for a Sel node.
3019  *
3020  * The select node selects an entity (field or method) from an entity
3021  * with a compound type.  It explicitly specifies the entity selected.
3022  * Dynamically the node may select entities that overwrite the given
3023  * entity.  If the selected entity is an array element entity the Sel
3024  * node takes the required array indices as inputs.
3025  * Adds the node to the block in current_ir_block.
3026  *
3027  * @param   *db        A pointer for debug information.
3028  * @param   *store     The memory in which the object the entity should be selected
3029  *                     from is allocated.
3030  * @param   *objptr    A pointer to a compound entity the Sel operation selects a
3031  *                     single attribute from.
3032  * @param   arity      The number of array indices needed to select an array element entity.
3033  * @param   *in[]      If the compound entity is an array the indices of the selected
3034  *                     element entity.  The constructor copies this array.
3035  * @param   *ent       The entity to select.
3036  */
3037 ir_node *new_d_Sel    (dbg_info *db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
3038                        ir_entity *ent);
3039
3040 /** Constructor for a Call node.
3041  *
3042  *  Represents all kinds of method and function calls.
3043  *  Adds the node to the block in current_ir_block.
3044  *
3045  * @param   *db     A pointer for debug information.
3046  * @param   *store  The actual store.
3047  * @param   *callee A pointer to the called procedure.
3048  * @param   arity   The number of procedure parameters.
3049  * @param   *in[]   An array with the pointers to the parameters. The constructor copies this array.
3050  * @param   *tp     Type information of the procedure called.
3051  */
3052 ir_node *new_d_Call   (dbg_info *db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
3053              ir_type *tp);
3054
3055 /** Constructor for a Add node.
3056  *
3057  * Adds the node to the block in current_ir_block.
3058  *
3059  * @param   *db    A pointer for debug information.
3060  * @param   *op1   The first operand.
3061  * @param   *op2   The second operand.
3062  * @param   *mode  The mode of the operands and the result.
3063  */
3064 ir_node *new_d_Add    (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3065
3066 /** Constructor for a Sub node.
3067  *
3068  * Adds the node to the block in current_ir_block.
3069  *
3070  * @param   *db    A pointer for debug information.
3071  * @param   *op1   The first operand.
3072  * @param   *op2   The second operand.
3073  * @param   *mode  The mode of the operands and the result.
3074  */
3075 ir_node *new_d_Sub    (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3076
3077 /** Constructor for a Minus node.
3078  *
3079  * Adds the node to the block in current_ir_block.
3080  *
3081  * @param   *db    A pointer for debug information.
3082  * @param   *op    The operand .
3083  * @param   *mode  The mode of the operand and the result.
3084  */
3085 ir_node *new_d_Minus  (dbg_info *db, ir_node *op,  ir_mode *mode);
3086
3087 /** Constructor for a Mul node.
3088  *
3089  * Adds the node to the block in current_ir_block.
3090  *
3091  * @param   *db    A pointer for debug information.
3092  * @param   *op1   The first operand.
3093  * @param   *op2   The second operand.
3094  * @param   *mode  The mode of the operands and the result.
3095  */
3096 ir_node *new_d_Mul    (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3097
3098 /** Constructor for a Quot node.
3099  *
3100  * Adds the node to the block in current_ir_block.
3101  *
3102  * @param   *db    A pointer for debug information.
3103  * @param   *memop The store needed to model exceptions
3104  * @param   *op1   The first operand.
3105  * @param   *op2   The second operand.
3106  * @param   *mode  The mode of the result.
3107  */
3108 ir_node *new_d_Quot   (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
3109
3110 /** Constructor for a DivMod node.
3111  *
3112  * Adds the node to the block in current_ir_block.
3113  *
3114  * @param   *db    A pointer for debug information.
3115  * @param   *memop The store needed to model exceptions
3116  * @param   *op1   The first operand.
3117  * @param   *op2   The second operand.
3118  * @param   *mode  The mode of the results.
3119  */
3120 ir_node *new_d_DivMod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
3121
3122 /** Constructor for a Div node.
3123  *
3124  * Adds the node to the block in current_ir_block.
3125  *
3126  * @param   *db    A pointer for debug information.
3127  * @param   *memop The store needed to model exceptions
3128  * @param   *op1   The first operand.
3129  * @param   *op2   The second operand.
3130  * @param   *mode  The mode of the result.
3131  */
3132 ir_node *new_d_Div    (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
3133
3134 /** Constructor for a Mod node.
3135  *
3136  * Adds the node to the block in current_ir_block.
3137  *
3138  * @param   *db    A pointer for debug information.
3139  * @param   *memop The store needed to model exceptions
3140  * @param   *op1   The first operand.
3141  * @param   *op2   The second operand.
3142  * @param   *mode  The mode of the result.
3143  */
3144 ir_node *new_d_Mod    (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
3145
3146 /** Constructor for a Abs node.
3147  *
3148  * Adds the node to the block in current_ir_block.
3149  *
3150  * @param   *db    A pointer for debug information.
3151  * @param   *op    The operand
3152  * @param   *mode  The mode of the operands and the result.
3153  */
3154 ir_node *new_d_Abs    (dbg_info *db, ir_node *op,                ir_mode *mode);
3155
3156 /** Constructor for a And node.
3157  *
3158  * Adds the node to the block in current_ir_block.
3159  *
3160  * @param   *db    A pointer for debug information.
3161  * @param   *op1   The first operand.
3162  * @param   *op2   The second operand.
3163  * @param   *mode  The mode of the operands and the result.
3164  */
3165 ir_node *new_d_And    (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3166
3167 /** Constructor for a Or node.
3168  *
3169  * Adds the node to the block in current_ir_block.
3170  *
3171  * @param   *db    A pointer for debug information.
3172  * @param   *op1   The first operand.
3173  * @param   *op2   The second operand.
3174  * @param   *mode  The mode of the operands and the result.
3175  */
3176 ir_node *new_d_Or     (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3177
3178 /** Constructor for a Eor node.
3179  *
3180  * Adds the node to the block in current_ir_block.
3181  *
3182  * @param   *db    A pointer for debug information.
3183  * @param   *op1   The first operand.
3184  * @param   *op2   The second operand.
3185  * @param   *mode  The mode of the operands and the results.
3186  */
3187 ir_node *new_d_Eor    (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3188
3189 /** Constructor for a Not node.
3190  *
3191  * Adds the node to the block in current_ir_block.
3192  *
3193  * @param   *db    A pointer for debug information.
3194  * @param   *op    The operand.
3195  * @param   *mode  The mode of the operand and the result.
3196  */
3197 ir_node *new_d_Not    (dbg_info *db, ir_node *op,                ir_mode *mode);
3198
3199 /** Constructor for a Shl node.
3200  *
3201  * Adds the node to the block in current_ir_block.
3202  *
3203  * @param   *db    A pointer for debug information.
3204  * @param   *op    The operand.
3205  * @param   *k     The number of bits to  shift the operand .
3206  * @param   *mode  The mode of the operand and the result.
3207  */
3208 ir_node *new_d_Shl    (dbg_info *db, ir_node *op,  ir_node *k,   ir_mode *mode);
3209
3210 /** Constructor for a Shr node.
3211  *
3212  * Adds the node to the block in current_ir_block.
3213  *
3214  * @param   *db    A pointer for debug information.
3215  * @param   *op    The operand.
3216  * @param   *k     The number of bits to  shift the operand .
3217  * @param   *mode  The mode of the operand and the result.
3218  */
3219 ir_node *new_d_Shr    (dbg_info *db, ir_node *op,  ir_node *k,   ir_mode *mode);
3220
3221 /** Constructor for a Shrs node.
3222  *
3223  * Adds the node to the block in current_ir_block.
3224  *
3225  * @param   *db    A pointer for debug information.
3226  * @param   *op    The operand.
3227  * @param   *k     The number of bits to  shift the operand .
3228  * @param   *mode  The mode of the operand and the result.
3229  */
3230 ir_node *new_d_Shrs   (dbg_info *db, ir_node *op,  ir_node *k,   ir_mode *mode);
3231
3232 /** Constructor for a Rot node.
3233  *
3234  * Adds the node to the block in current_ir_block.
3235  *
3236  * @param   *db    A pointer for debug information.
3237  * @param   *op    The operand.
3238  * @param   *k     The number of bits to rotate the operand.
3239  * @param   *mode  The mode of the operand.
3240  */
3241 ir_node *new_d_Rot    (dbg_info *db, ir_node *op,  ir_node *k,   ir_mode *mode);
3242
3243 /** Constructor for a Cmp node.
3244  *
3245  * Adds the node to the block in current_ir_block.
3246  *
3247  * @param   *db    A pointer for debug information.
3248  * @param   *op1   The first operand.
3249  * @param   *op2   The second operand.
3250  */
3251 ir_node *new_d_Cmp    (dbg_info *db, ir_node *op1, ir_node *op2);
3252
3253 /** Constructor for a Conv node.
3254  *
3255  * Adds the node to the block in current_ir_block.
3256  *
3257  * @param   *db    A pointer for debug information.
3258  * @param   *op    The operand.
3259  * @param   *mode  The mode of this the operand muss be converted .
3260  */
3261 ir_node *new_d_Conv   (dbg_info *db, ir_node *op, ir_mode *mode);
3262
3263 /** Constructor for a strict Conv node.
3264  *
3265  * Adds the node to the block in current_ir_block.
3266  *
3267  * @param   *db    A pointer for debug information.
3268  * @param   *op    The operand.
3269  * @param   *mode  The mode of this the operand muss be converted .
3270  */
3271 ir_node *new_d_strictConv   (dbg_info *db, ir_node *op, ir_mode *mode);
3272
3273 /** Constructor for a Cast node.
3274  *
3275  * High level type cast
3276  * Adds the node to the block in current_ir_block.
3277  *
3278  * @param   *db    A pointer for debug information.
3279  * @param   *op    The operand.
3280  * @param   *to_tp The type of this the operand muss be casted .
3281  */
3282 ir_node *new_d_Cast   (dbg_info *db, ir_node *op, ir_type *to_tp);
3283
3284 /** Constructor for a Carry node.
3285  *
3286  * Adds the node to the block in current_ir_block.
3287  *
3288  * @param   *db    A pointer for debug information.
3289  * @param   *op1   The first operand.
3290  * @param   *op2   The second operand.
3291  * @param   *mode  The mode of the operands and the result.
3292  */
3293 ir_node *new_d_Carry  (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3294
3295 /** Constructor for a Borrow node.
3296  *
3297  * Adds the node to the block in current_ir_block.
3298  *
3299  * @param   *db    A pointer for debug information.
3300  * @param   *op1   The first operand.
3301  * @param   *op2   The second operand.
3302  * @param   *mode  The mode of the operands and the result.
3303  */
3304 ir_node *new_d_Borrow (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3305
3306 /** Constructor for a Phi node.
3307  *
3308  * Adds the node to the block in current_ir_block.
3309  *
3310  * @param *db    A pointer for debug information.
3311  * @param arity  The number of predecessors
3312  * @param *in    Array with predecessors
3313  * @param *mode  The mode of it's inputs and output.
3314  */
3315 ir_node *new_d_Phi    (dbg_info *db, int arity, ir_node *in[], ir_mode *mode);
3316
3317 /** Constructor for a Load node.
3318  *
3319  * Adds the node to the block in current_ir_block.
3320  *
3321  * @param *db    A pointer for debug information.
3322  * @param *store The current memory
3323  * @param *addr  A pointer to the variable to be read in this memory.
3324  * @param *mode  The mode of the value to be loaded.
3325  */
3326 ir_node *new_d_Load   (dbg_info *db, ir_node *store, ir_node *addr, ir_mode *mode);
3327
3328 /** Constructor for a Store node.
3329  *
3330  * Adds the node to the block in current_ir_block.
3331  *
3332  * @param *db    A pointer for debug information.
3333  * @param *store The current memory
3334  * @param *addr  A pointer to the variable to be read in this memory.
3335  * @param *val   The value to write to this variable.
3336  */
3337 ir_node *new_d_Store  (dbg_info *db, ir_node *store, ir_node *addr, ir_node *val);
3338
3339 /** Constructor for a Alloc node.
3340  *
3341  * The Alloc node extends the memory by space for an entity of type alloc_type.
3342  * Adds the node to the block in current_ir_block.
3343  *
3344  * @param *db         A pointer for debug information.
3345  * @param *store      The memory which shall contain the new variable.
3346  * @param *size       The number of bytes to allocate.
3347  * @param *alloc_type The type of the allocated variable.
3348  * @param where       Where to allocate the variable, either heap_alloc or stack_alloc.
3349  */
3350 ir_node *new_d_Alloc  (dbg_info *db, ir_node *store, ir_node *size, ir_type *alloc_type,
3351                        where_alloc where);
3352
3353  /** Constructor for a Free node.
3354  *
3355  * Frees the memory occupied by the entity pointed to by the pointer
3356  * arg.  Type indicates the type of the entity the argument points to.
3357  * Adds the node to the block in current_ir_block.
3358  *
3359  * @param *db         A pointer for debug information.
3360  * @param *store      The memory which shall contain the new variable.
3361  * @param *ptr        The pointer to the object to free.
3362  * @param *size       The number of objects of type free_type to free in a sequence.
3363  * @param *free_type  The type of the freed variable.
3364  * @param where       Where the variable was allocated, either heap_alloc or stack_alloc.
3365  */
3366 ir_node *new_d_Free   (dbg_info *db, ir_node *store, ir_node *ptr, ir_node *size,
3367              ir_type *free_type, where_alloc where);
3368
3369 /** Constructor for a Sync node.
3370  *
3371  * Merges several memory values.  The node assumes that a variable
3372  * either occurs only in one of the memories, or it contains the same
3373  * value in all memories where it occurs.
3374  * Adds the node to the block in current_ir_block.
3375  *
3376  * @param *db       A pointer for debug information.
3377  * @param  arity    The number of memories to synchronize.
3378  * @param  **in     An array of pointers to nodes that produce an output of type
3379  *                  memory.  The constructor copies this array.
3380  */
3381 ir_node *new_d_Sync   (dbg_info *db, int arity, ir_node *in[]);
3382
3383 /** Constructor for a Proj node.
3384  *
3385  * Projects a single value out of a tuple.  The parameter proj gives the
3386  * position of the value within the tuple.
3387  * Adds the node to the block in current_ir_block.
3388  *
3389  * @param *db    A pointer for deubug information.
3390  * @param arg    A node producing a tuple.
3391  * @param *mode  The mode of the value to project.
3392  * @param proj   The position of the value in the tuple.
3393  */
3394 ir_node *new_d_Proj   (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3395
3396 /** Constructor for a defaultProj node.
3397  *
3398  * Represents the default control flow of a Switch-Cond node.
3399  * Adds the node to the block in current_ir_block.
3400  *
3401  * @param *db       A pointer for debug information.
3402  * @param arg       A node producing a tuple.
3403  * @param max_proj  The end  position of the value in the tuple.
3404  */
3405 ir_node *new_d_defaultProj (dbg_info *db, ir_node *arg, long max_proj);
3406
3407 /** Constructor for a Tuple node.
3408  *
3409  * This is an auxiliary node to replace a node that returns a tuple
3410  * without changing the corresponding Proj nodes.
3411  * Adds the node to the block in current_ir_block.
3412  *
3413  * @param *db     A pointer for debug information.
3414  * @param arity   The number of tuple elements.
3415  * @param **in    An array containing pointers to the nodes producing the tuple elements.
3416  */
3417 ir_node *new_d_Tuple  (dbg_info *db, int arity, ir_node *in[]);
3418
3419 /** Constructor for a Id node.
3420  *
3421  * This is an auxiliary node to replace a node that returns a single
3422  * value. Adds the node to the block in current_ir_block.
3423  *
3424  * @param *db     A pointer for debug information.
3425  * @param *val    The operand to Id.
3426  * @param *mode   The mode of *val.
3427  */
3428 ir_node *new_d_Id     (dbg_info *db, ir_node *val, ir_mode *mode);
3429
3430 /** Constructor for a Bad node.
3431  *
3432  * Returns the unique Bad node of the graph.  The same as
3433  * get_irg_bad().
3434  */
3435 ir_node *new_d_Bad    (void);
3436
3437 /** Constructor for a Confirm node.
3438  *
3439  * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3440  * Specifies constraints for a value.  To support dataflow analyses.
3441  *
3442  * Example: If the value never exceeds '100' this is expressed by placing a
3443  * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3444  *
3445  * @param *db     A pointer for debug information.
3446  * @param *val    The value we express a constraint for
3447  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
3448  * @param cmp     The compare operation.
3449  */
3450 ir_node *new_d_Confirm (dbg_info *db, ir_node *val, ir_node *bound, pn_Cmp cmp);
3451
3452 /** Constructor for a exception region bounded Confirm node.
3453  *
3454  * Constructor for a Confirm node that is bound to a specific exceptin region.
3455  * Adds the node to the block in current_ir_block.
3456  * Specifies constraints for a value.  To support dataflow analyses.
3457  *
3458  * Example: If the value never exceeds '100' this is expressed by placing a
3459  * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3460  *
3461  * @param *db     A pointer for debug information.
3462  * @param *val    The value we express a constraint for
3463  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
3464  * @param cmp     The compare operation.
3465  */
3466 ir_node *new_d_bounded_Confirm (dbg_info *db, ir_node *val, ir_node *bound, pn_Cmp cmp);
3467
3468 /** Constructor for an Unknown node.
3469  *
3470  * Represents an arbitrary value.  Places the node in
3471  * the start block.
3472  *
3473  * @param *m      The mode of the unknown value.
3474  */
3475 ir_node *new_d_Unknown(ir_mode *m);
3476
3477 /** Constructor for a CallBegin node.
3478  *
3479  * CallBegin represents control flow depending of the pointer value
3480  * representing the called method to the called methods.  The
3481  * constructor copies the method pointer input from the passed Call
3482  * node.Adds the node to the block in current_ir_block.
3483  *
3484  * @param *db     A pointer for debug information.
3485  * @param *callee The call node visible in the  intra procedural view.
3486  */
3487 ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
3488
3489 /** Constructor for an EndReg node.
3490  *
3491  *Adds the node to the block in current_ir_block.
3492  *
3493  * @param *db     A pointer for debug information.
3494  */
3495 ir_node *new_d_EndReg (dbg_info *db);
3496
3497 /** Constructor for an EndExcept node.
3498  *
3499  * Used to represent regular procedure end in interprocedual view.
3500  * Adds the node to the block in current_ir_block.
3501  *
3502  * @param *db     A pointer for debug information.
3503  */
3504 ir_node *new_d_EndExcept(dbg_info *db);
3505
3506 /** Constructor for a Break node.
3507  *
3508  * Used to represent exceptional procedure end in interprocedural view.
3509  * Adds the node to the block in current_ir_block.
3510  *
3511  * Break represents control flow to a single control successor just as Jmp.
3512  * The blocks separated by a break may not be concatenated by an optimization.
3513  * It is used for the interprocedural representation where blocks are parted
3514  * behind Call nodes to represent the control flow to called procedures.
3515  *
3516  * @param *db     A pointer for debug information.
3517  */
3518 ir_node *new_d_Break (dbg_info *db);
3519
3520 /** Constructor for a Filter node.
3521  *
3522  * Constructor for a Filter node. Adds the node to the block in
3523  * current_ir_block.  Filter is a node with two views used to
3524  * construct the interprocedural view.  In intraprocedural view its
3525  * semantics are identical to the Proj node.  In interprocedural view
3526  * the Filter performs the Phi operation on method parameters or
3527  * results.  Other than a Phi a Filter node may not be removed if it
3528  * has only a single input.
3529  *
3530  * The constructor builds the Filter in intraprocedural view.
3531  *
3532  * @param *db   A pointer for debug information.
3533  * @param *arg  The tuple value to project from.
3534  * @param *mode The mode of the projected value.
3535  * @param proj  The position in the tuple to project from.
3536  */
3537 ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3538
3539
3540 /** Constructor for a NoMem node.
3541  *
3542  * Returns the unique NoMem node of the graph.  The same as
3543  * get_irg_no_mem().
3544  */
3545 ir_node *new_d_NoMem  (void);
3546
3547 /** Constructor for a Mux node.
3548  *
3549  * @param *db       A pointer for debug information.
3550  * @param *sel      The ir_node that calculates the boolean select.
3551  * @param *ir_true  The ir_node that calculates the true result.
3552  * @param *ir_false The ir_node that calculates the false result.
3553  * @param *mode     The mode of the node (and it_true and ir_false).
3554  */
3555 ir_node *new_d_Mux  (dbg_info *db, ir_node *sel,
3556     ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3557
3558 /** Constructor for a Psi node.
3559  *
3560  * @param *db       A pointer for debug information.
3561  * @param *arity    The arity of the conditions
3562  * @param *conds    The array of mode_b conditions, length must be equal arity
3563  * @param *vals     The array of mode values, length must be equal arity + 1
3564  * @param *mode     The mode of the node (must be the mode of all vals).
3565  */
3566 ir_node *new_d_Psi (dbg_info *db,
3567                     int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
3568
3569 /** Constructor for a CopyB node.
3570  *
3571  * @param *db         A pointer for debug information.
3572  * @param *store      The current memory
3573  * @param *dst        The ir_node that represents the destination address.
3574  * @param *src        The ir_node that represents the source address.
3575  * @param *data_type  The type of the copied data
3576  */
3577 ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
3578
3579 /** Constructor for a InstOf node.
3580  *
3581  * A High-Level Type check.
3582  *
3583  * @param   *db        A pointer for debug information.
3584  * @param   *store     The memory in which the object the entity should be selected
3585  *                     from is allocated.
3586  * @param   *objptr    A pointer to a object of a class type.
3587  * @param   *type      The type of which objptr must be.
3588  */
3589 ir_node *new_d_InstOf (dbg_info *db, ir_node *store, ir_node *objptr, ir_type *type);
3590
3591 /** Constructor for a Raise node.
3592  *
3593  * A High-Level Exception throw.
3594  *
3595  * @param *db    A pointer for debug information.
3596  * @param *store The current memory.
3597  * @param *obj   A pointer to the Except variable.
3598  */
3599 ir_node *new_d_Raise  (dbg_info *db, ir_node *store, ir_node *obj);
3600
3601 /** Constructor for a Bound node.
3602  *
3603  * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
3604  *
3605  * @param *db         A pointer for debug information.
3606  * @param *store      The current memory
3607  * @param *idx        The ir_node that represents an index.
3608  * @param *lower      The ir_node that represents the lower bound for the index.
3609  * @param *upper      The ir_node that represents the upper bound for the index.
3610  */
3611 ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
3612
3613 /** Constructor for a Pin node.
3614  *
3615  * @param *db         A pointer for debug information.
3616  * @param *node       The node which value should be pinned.
3617  */
3618 ir_node *new_d_Pin(dbg_info *db, ir_node *node);
3619
3620 /** Constructor for an ASM pseudo node.
3621  *
3622  * @param *db         A pointer for debug information.
3623  * @param arity       The number of data inputs to the node.
3624  * @param *in         The array of length arity of data inputs.
3625  * @param *inputs     The array of length arity of input constraints.
3626  * @param n_outs      The number of data outputs to the node.
3627  * @param *outputs    The array of length n_outs of output constraints.
3628  * @param n_clobber   The number of clobbered registers.
3629  * @param *clobber    The array of length n_clobber of clobbered registers.
3630  * @param *asm_text   The assembler text.
3631  */
3632 ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[], ir_asm_constraint *inputs,
3633                    int n_outs, ir_asm_constraint *outputs,
3634                    int n_clobber, ident *clobber[], ident *asm_text);
3635
3636 /*-----------------------------------------------------------------------*/
3637 /* The block oriented interface without debug support                    */
3638 /*-----------------------------------------------------------------------*/
3639
3640 /* Needed from the interface with debug support:
3641 void set_cur_block (ir_node *target);   */
3642
3643 /** Constructor for a Block node.
3644  *
3645  * Constructor for a Block node. Adds the block to the graph in
3646  * current_ir_graph.  Constructs a Block with a fixed number of
3647  * predecessors.  Does set current_block.  Can be used with automatic
3648  * Phi node construction.
3649  *
3650  * @param arity  The number of control predecessors.
3651  * @param in     An array of control predecessors.  The length of
3652  *               the array must be 'arity'.
3653  */
3654 ir_node *new_Block(int arity, ir_node *in[]);
3655
3656 /** Constructor for a Start node.
3657  *
3658  * Adds the node to the block in current_ir_block.
3659  *
3660  */
3661 ir_node *new_Start  (void);
3662
3663 /** Constructor for an End node.
3664  *
3665  * Adds the node to the block in current_ir_block.
3666  */
3667 ir_node *new_End    (void);
3668
3669 /** Constructor for an EndReg node.
3670  *
3671  * Used to represent regular procedure end in interprocedual view.
3672  * Adds the node to the block in current_ir_block.
3673  */
3674 ir_node *new_EndReg (void);
3675
3676 /** Constructor for an EndExpcept node.
3677  *
3678  *  Used to represent exceptional procedure end in interprocedural view.
3679  *  Adds the node to the block in current_ir_block.
3680  */
3681 ir_node *new_EndExcept(void);
3682
3683 /** Constructor for a Jump node.
3684  *
3685  * Adds the node to the block in current_ir_block.
3686  *
3687  * Jmp represents control flow to a single control successor.
3688  */
3689 ir_node *new_Jmp    (void);
3690
3691 /** Constructor for an IJmp node.
3692  *
3693  * IJmp represents control flow to a single control successor not
3694  * statically known i.e. an indirect Jmp.
3695  *
3696  * @param *tgt    The ir node representing the target address.
3697  */
3698 ir_node *new_IJmp   (ir_node *tgt);
3699
3700 /** Constructor for a Break node.
3701  * Break represents control flow to a single control successor just as Jmp.
3702  * The blocks separated by a break may not be concatenated by an optimization.
3703  * It is used for the interprocedural representation where blocks are parted
3704  * behind Call nodes to represent the control flow to called procedures.
3705  * Adds the node to the block in current_ir_block.
3706  */
3707 ir_node *new_Break  (void);
3708
3709 /** Constructor for a Cond node.
3710  *
3711  * If c is mode_b represents a conditional branch (if/else). If c is
3712  * mode_Is/mode_Iu (?) represents a switch.  (Allocates dense Cond
3713  * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3714  *
3715  * This is not consistent:  Input to Cond is Is, Proj has as proj number
3716  * longs.
3717  *
3718  *
3719  * @param *c     The conditions parameter.Can be of mode b or I_u.
3720  */
3721 ir_node *new_Cond   (ir_node *c);
3722
3723 /** Constructor for a Return node.
3724  *
3725  * Returns the memory an zero or more return values.  Only node that
3726  * can end regular control flow. Adds the node to the block in current_ir_block.
3727  *
3728  * @param *store The state of memory.
3729  * @param arity  Number of array indices.
3730  * @param *in    Array with index inputs to the node.
3731  */
3732 ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
3733
3734 /** Constructor for a Const node.
3735  *
3736  * Constructor for a Const node. The constant represents a target
3737  * value.  Sets the type information to type_unknown.  (No more
3738  * supported: If tv is entity derives a somehow useful type.)
3739  * Adds the node to the block in current_ir_block.
3740  *
3741  * @param *mode  The mode of the operands and results.
3742  * @param *con   Points to an entry in the constant table. This pointer is
3743  *               added to the attributes of  the node.
3744  */
3745 ir_node *new_Const  (ir_mode *mode, tarval *con);
3746
3747 /**
3748  * Make a const from a long.
3749  * This is just convenience for the usual
3750  * <code>
3751  * new_Const(mode, tarval_from_long(mode, ...))
3752  * </code>
3753  * pain.
3754  * @param mode The mode for the const.
3755  * @param value The value of the constant.
3756  * @return A new const node.
3757  */
3758 ir_node *new_Const_long(ir_mode *mode, long value);
3759
3760 /** Constructor for a Const node.
3761  *
3762  * Derives mode from passed type. */
3763 ir_node *new_Const_type(tarval *con, ir_type *tp);
3764
3765 /** Constructor for a SymConst node.
3766  *
3767  * Adds the node to the block in current_ir_block.
3768  * This is the constructor for a symbolic constant.
3769  * There are four kinds of symbolic constants:
3770  *    -# type_tag  The symbolic constant represents a type tag.  The type the
3771  *                 tag stands for is given explicitly.
3772  *    -# size      The symbolic constant represents the size of a type.  The
3773  *                 type of which the constant represents the size is given
3774  *                 explicitly.
3775  *    -# align     The symbolic constant represents the alignment of a type.  The
3776  *                 type of which the constant represents the size is given
3777  *                 explicitly.
3778  *    -# addr_name The symbolic constant represents the address of an entity
3779  *                 (variable or method).  The variable is indicated by a name
3780  *                 that is valid for linking.
3781  *    -# addr_ent  The symbolic constant represents the address of an entity
3782  *                 (variable or method).  The variable is given explicitly by
3783  *                 a firm entity.
3784  *
3785  *    Inputs to the node:
3786  *      No inputs except the block it belongs to.
3787  *    Outputs of the node.
3788  *      An unsigned integer (I_u) or a pointer (P).
3789  *
3790  * @param value   A type or a ident depending on the SymConst kind.
3791  * @param kind    The kind of the symbolic constant: symconst_type_tag, symconst_type_size
3792  *                symconst_type_align, symconst_addr_name or symconst_addr_ent.
3793  * @param tp      The source type of the constant.
3794  */
3795 ir_node *new_SymConst_type (union symconst_symbol value, symconst_kind kind, ir_type *tp);
3796
3797 /** Constructor for a SymConst node.
3798  *
3799  * Adds the node to the block in current_ir_block.
3800  * This is the constructor for a symbolic constant.
3801  * There are four kinds of symbolic constants:
3802  *    -# type_tag  The symbolic constant represents a type tag.  The type the
3803  *                 tag stands for is given explicitly.
3804  *    -# size      The symbolic constant represents the size of a type.  The
3805  *                 type of which the constant represents the size is given
3806  *                 explicitly.
3807  *    -# align     The symbolic constant represents the alignment of a type.  The
3808  *                 type of which the constant represents the size is given
3809  *                 explicitly.
3810  *    -# addr_name The symbolic constant represents the address of an entity
3811  *                 (variable or method).  The variable is indicated by a name
3812  *                 that is valid for linking.
3813  *    -# addr_ent  The symbolic constant represents the address of an entity
3814  *                 (variable or method).  The variable is given explicitly by
3815  *                 a firm entity.
3816  *
3817  *    Inputs to the node:
3818  *      No inputs except the block it belongs to.
3819  *    Outputs of the node.
3820  *      An unsigned integer (I_u) or a pointer (P).
3821  *
3822  * @param value   A type or a ident depending on the SymConst kind.
3823  * @param kind    The kind of the symbolic constant: symconst_type_tag, symconst_type_size
3824  *                symconst_type_align, symconst_addr_name or symconst_addr_ent.
3825  */
3826 ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind);
3827
3828 /** Constructor for a simpelSel node.
3829  *
3830  *  This is a shortcut for the new_Sel() constructor.  To be used for
3831  *  Sel nodes that do not select from an array, i.e., have no index
3832  *  inputs.  It adds the two parameters 0, NULL.
3833  *
3834  * @param   *store     The memory in which the object the entity should be selected from is allocated.
3835  * @param   *objptr    The object from that the Sel operation selects a single attribute out.
3836  * @param   *ent       The entity to select.
3837  */
3838 ir_node *new_simpleSel(ir_node *store, ir_node *objptr, ir_entity *ent);
3839
3840 /** Constructor for a Sel node.
3841  *
3842  * The select node selects an entity (field or method) from an entity
3843  * with a compound type.  It explicitly specifies the entity selected.
3844  * Dynamically the node may select entities that overwrite the given
3845  * entity.  If the selected entity is an array element entity the Sel
3846  * node takes the required array indices as inputs.
3847  * Adds the node to the block in current_ir_block.
3848  *
3849  * @param   *store     The memory in which the object the entity should be selected
3850  *                     from is allocated.
3851  * @param   *objptr    A pointer to a compound entity the Sel operation selects a
3852  *                     single attribute from.
3853  * @param   arity      The number of array indices needed to select an array element entity.
3854  * @param   *in[]      If the compound entity is an array the indices of the selected
3855  *                     element entity.  The constructor copies this array.
3856  * @param   *ent       The entity to select.
3857  */
3858 ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
3859                      ir_entity *ent);
3860
3861 /** Constructor for a Call node.
3862  *
3863  *  Adds the node to the block in current_ir_block.
3864  *  Represents all kinds of method and function calls.
3865  *
3866  * @param   *store  The actual store.
3867  * @param   *callee A pointer to the called procedure.
3868  * @param   arity   The number of procedure parameters.
3869  * @param   *in[]   An array with the pointers to the parameters. The constructor copies this array.
3870  * @param   *tp     Type information of the procedure called.
3871  */
3872 ir_node *new_Call   (ir_node *store, ir_node *callee, int arity, ir_node *in[],
3873                              ir_type *tp);
3874
3875 /** Constructor for a CallBegin node.
3876  *
3877  * CallBegin represents control flow depending of the pointer value
3878  * representing the called method to the called methods.  The
3879  * constructor copies the method pointer input from the passed Call
3880  * node. Adds the node to the block in current_ir_block.
3881  *
3882  * @param   *callee A pointer to the called procedure.
3883  */
3884 ir_node *new_CallBegin(ir_node *callee);
3885
3886 /** Constructor for a Add node.
3887  *
3888  * Adds the node to the block in current_ir_block.
3889  *
3890  * @param   *op1   The first operand.
3891  * @param   *op2   The second operand.
3892  * @param   *mode  The mode of the operands and the result.
3893  */
3894 ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode);
3895
3896 /** Constructor for a Sub node.
3897  *
3898  * Adds the node to the block in current_ir_block.
3899  *
3900  * @param   *op1   The first operand.
3901  * @param   *op2   The second operand.
3902  * @param   *mode  The mode of the operands and the result.
3903  */
3904 ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode);
3905
3906 /** Constructor for a Minus node.
3907  *
3908  * Adds the node to the block in current_ir_block.
3909  *
3910  * @param   *op    The operand .
3911  * @param   *mode  The mode of the operand and the result.
3912  */
3913 ir_node *new_Minus  (ir_node *op,  ir_mode *mode);
3914
3915 /**
3916  * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3917  *
3918  * @param   *op1   The first operand.
3919  * @param   *op2   The second operand.
3920  * @param   *mode  The mode of the operands and the result.
3921  */
3922 ir_node *new_Mul    (ir_node *op1, ir_node *op2, ir_mode *mode);
3923
3924 /** Constructor for a Quot node.
3925  *
3926  * Adds the node to the block in current_ir_block.
3927  *
3928  * @param   *memop The store needed to model exceptions
3929  * @param   *op1   The first operand.
3930  * @param   *op2   The second operand.
3931  * @param   *mode  The mode of the result.
3932  */
3933 ir_node *new_Quot   (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
3934
3935 /** Constructor for a DivMod node.
3936  *
3937  * Adds the node to the block in current_ir_block.
3938  *
3939  * @param   *memop The store needed to model exceptions
3940  * @param   *op1   The first operand.
3941  * @param   *op2   The second operand.
3942  * @param   *mode  The mode of the results.
3943  */
3944 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
3945
3946 /** Constructor for a Div node.
3947  *
3948  * Adds the node to the block in current_ir_block.
3949  *
3950  * @param   *memop The store needed to model exceptions
3951  * @param   *op1   The first operand.
3952  * @param   *op2   The second operand.
3953  * @param   *mode  The mode of the result.
3954  */
3955 ir_node *new_Div    (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
3956
3957 /** Constructor for a Mod node.
3958  *
3959  * Adds the node to the block in current_ir_block.
3960  *
3961  * @param   *memop The store needed to model exceptions
3962  * @param   *op1   The first operand.
3963  * @param   *op2   The second operand.
3964  * @param   *mode  The mode of the result.
3965  */
3966 ir_node *new_Mod    (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode);
3967
3968 /** Constructor for a Abs node.
3969  *
3970  * Adds the node to the block in current_ir_block.
3971  *
3972  * @param   *op    The operand
3973  * @param   *mode  The mode of the operands and the result.
3974  */
3975 ir_node *new_Abs    (ir_node *op,                ir_mode *mode);
3976
3977 /** Constructor for a And node.
3978  *
3979  * Adds the node to the block in current_ir_block.
3980  *
3981  * @param   *op1   The first operand.
3982  * @param   *op2   The second operand.
3983  * @param   *mode  The mode of the operands and the result.
3984  */
3985 ir_node *new_And    (ir_node *op1, ir_node *op2, ir_mode *mode);
3986
3987 /**
3988  * Constructor for a Or node. Adds the node to the block in current_ir_block.
3989  *
3990  * @param   *op1   The first operand.
3991  * @param   *op2   The second operand.
3992  * @param   *mode  The mode of the operands and the result.
3993  */
3994 ir_node *new_Or     (ir_node *op1, ir_node *op2, ir_mode *mode);
3995
3996 /**
3997  * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3998  *
3999  * @param   *op1   The first operand.
4000  * @param   *op2   The second operand.
4001  * @param   *mode  The mode of the operands and the results.
4002  */
4003 ir_node *new_Eor    (ir_node *op1, ir_node *op2, ir_mode *mode);
4004
4005 /** Constructor for a Not node.
4006  *
4007  * Adds the node to the block in current_ir_block.
4008  *
4009  * @param   *op    The operand.
4010  * @param   *mode  The mode of the operand and the result.
4011  */
4012 ir_node *new_Not    (ir_node *op,                ir_mode *mode);
4013
4014 /** Constructor for a Shl node.
4015  *
4016  * Adds the node to the block in current_ir_block.
4017  *
4018  * @param   *op    The operand.
4019  * @param   *k     The number of bits to  shift the operand .
4020  * @param   *mode  The mode of the operand and the result.
4021  */
4022 ir_node *new_Shl    (ir_node *op,  ir_node *k,   ir_mode *mode);
4023
4024 /**
4025  * Constructor for a Shr node. Adds the node to the block in current_ir_block.
4026  *
4027  * @param   *op    The operand.
4028  * @param   *k     The number of bits to  shift the operand .
4029  * @param   *mode  The mode of the operand and the result.
4030  */
4031 ir_node *new_Shr    (ir_node *op,  ir_node *k,   ir_mode *mode);
4032
4033 /** Constructor for a Shrs node.
4034  *
4035  * Adds the node to the block in current_ir_block.
4036  *
4037  * @param   *op    The operand.
4038  * @param   *k     The number of bits to  shift the operand .
4039  * @param   *mode  The mode of the operand and the result.
4040  */
4041 ir_node *new_Shrs   (ir_node *op,  ir_node *k,   ir_mode *mode);
4042
4043 /** Constructor for a Rot node.
4044  *
4045  * Adds the node to the block in current_ir_block.
4046  *
4047  * @param   *op    The operand.
4048  * @param   *k     The number of bits to rotate the operand.
4049  * @param   *mode  The mode of the operand.
4050  */
4051 ir_node *new_Rot    (ir_node *op,  ir_node *k,   ir_mode *mode);
4052
4053 /** Constructor for a Cmp node.
4054  *
4055  * Adds the node to the block in current_ir_block.
4056  *
4057  * @param   *op1   The first operand.
4058  * @param   *op2   The second operand.
4059  */
4060 ir_node *new_Cmp    (ir_node *op1, ir_node *op2);
4061
4062 /** Constructor for a Conv node.
4063  *
4064  * Adds the node to the block in current_ir_block.
4065  *
4066  * @param   *op          The operand.
4067  * @param   *mode        The mode of this the operand muss be converted.
4068  */
4069 ir_node *new_Conv   (ir_node *op, ir_mode *mode);
4070
4071 /** Constructor for a strict Conv node.
4072  *
4073  * Adds the node to the block in current_ir_block.
4074  *
4075  * @param   *op          The operand.
4076  * @param   *mode        The mode of this the operand muss be converted.
4077  */
4078 ir_node *new_strictConv   (ir_node *op, ir_mode *mode);
4079
4080 /** Constructor for a Cast node.
4081  *
4082  * Adds the node to the block in current_ir_block.
4083  * High level type cast
4084  *
4085  * @param   *op    The operand.
4086  * @param   *to_tp The type of this the operand muss be casted .
4087  */
4088 ir_node *new_Cast   (ir_node *op, ir_type *to_tp);
4089
4090 /** Constructor for a Carry node.
4091  *
4092  * Adds the node to the block in current_ir_block.
4093  *
4094  * @param   *op1   The first operand.
4095  * @param   *op2   The second operand.
4096  * @param   *mode  The mode of the operands and the result.
4097  */
4098 ir_node *new_Carry  (ir_node *op1, ir_node *op2, ir_mode *mode);
4099
4100 /** Constructor for a Borrow node.
4101  *
4102  * Adds the node to the block in current_ir_block.
4103  *
4104  * @param   *op1   The first operand.
4105  * @param   *op2   The second operand.
4106  * @param   *mode  The mode of the operands and the result.
4107  */
4108 ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
4109
4110 /** Constructor for a Phi node.
4111  *
4112  * Adds the node to the block in current_ir_block.
4113  *
4114  * @param arity  The number of predecessors.
4115  * @param *in    Array with predecessors.
4116  * @param *mode  The mode of it's inputs and output.
4117  */
4118 ir_node *new_Phi    (int arity, ir_node *in[], ir_mode *mode);
4119
4120 /** Constructor for a Load node.
4121  *
4122  * @param *store  The current memory.
4123  * @param *addr   A pointer to the variable to be read in this memory.
4124  * @param *mode   The mode of the value to be loaded.
4125  */
4126 ir_node *new_Load   (ir_node *store, ir_node *addr, ir_mode *mode);
4127
4128 /** Constructor for a Store node.
4129  *
4130  * @param *store  The current memory.
4131  * @param *addr   A pointer to the variable to be read in this memory.
4132  * @param *val    The value to write to this variable.
4133  */
4134 ir_node *new_Store  (ir_node *store, ir_node *addr, ir_node *val);
4135
4136 /** Constructor for a Alloc node.
4137  *
4138  * The Alloc node extends the memory by space for an entity of type alloc_type.
4139  * Adds the node to the block in current_ir_block.
4140  *
4141  * @param *store      The memory which shall contain the new variable.
4142  * @param *size       The number of bytes to allocate.
4143  * @param *alloc_type The type of the allocated variable.
4144  * @param where       Where to allocate the variable, either heap_alloc or stack_alloc.
4145  */
4146 ir_node *new_Alloc  (ir_node *store, ir_node *size, ir_type *alloc_type,
4147                      where_alloc where);
4148
4149 /** Constructor for a Free node.
4150  *
4151  * Frees the memory occupied by the entity pointed to by the pointer
4152  * arg.  Type indicates the type of the entity the argument points to.
4153  * Adds the node to the block in current_ir_block.
4154  *
4155  * @param *store      The memory which shall contain the new variable.
4156  * @param *ptr        The pointer to the object to free.
4157  * @param *size       The number of objects of type free_type to free in a sequence.
4158  * @param *free_type  The type of the freed variable.
4159  * @param where       Where the variable was allocated, either heap_alloc or stack_alloc.
4160  */
4161 ir_node *new_Free   (ir_node *store, ir_node *ptr, ir_node *size,
4162                              ir_type *free_type, where_alloc where);
4163
4164 /** Constructor for a Sync node.
4165  *
4166  * Merges several memory values.  The node assumes that a variable
4167  * either occurs only in one of the memories, or it contains the same
4168  * value in all memories where it occurs.
4169  * Adds the node to the block in current_ir_block.
4170  *
4171  * @param  arity    The number of memories to synchronize.
4172  * @param  **in     An array of pointers to nodes that produce an output of type
4173  *                  memory.  The constructor copies this array.
4174  */
4175 ir_node *new_Sync   (int arity, ir_node *in[]);
4176
4177 /** Constructor for a Proj node.
4178  *
4179  * Projects a single value out of a tuple.  The parameter proj gives the
4180  * position of the value within the tuple.
4181  * Adds the node to the block in current_ir_block.
4182  *
4183  * @param arg    A node producing a tuple.
4184  * @param *mode  The mode of the value to project.
4185  * @param proj   The position of the value in the tuple.
4186  */
4187 ir_node *new_Proj   (ir_node *arg, ir_mode *mode, long proj);
4188
4189 /** Constructor for a Filter node.
4190  *
4191  * Constructor for a Filter node. Adds the node to the block in current_ir_block.
4192  * Filter is a node with two views used to construct the interprocedural view.
4193  * In intraprocedural view its semantics are identical to the Proj node.
4194  * In interprocedural view the Filter performs the Phi operation on method
4195  * parameters or results.  Other than a Phi a Filter node may not be removed
4196  * if it has only a single input.
4197  *
4198  * The constructor builds the Filter in intraprocedural view.
4199  *
4200  * @param *arg  The tuple value to project from.
4201  * @param *mode The mode of the projected value.
4202  * @param proj  The position in the tuple to project from.
4203  */
4204 ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
4205
4206 /** Constructor for a defaultProj node.
4207  *
4208  * Represents the default control flow of a Switch-Cond node.
4209  * Adds the node to the block in current_ir_block.
4210  *
4211  * @param arg       A node producing a tuple.
4212  * @param max_proj  The end  position of the value in the tuple.
4213  */
4214 ir_node *new_defaultProj (ir_node *arg, long max_proj);
4215
4216 /** Constructor for a Tuple node.
4217  *
4218  * This is an auxiliary node to replace a node that returns a tuple
4219  * without changing the corresponding Proj nodes.
4220  * Adds the node to the block in current_ir_block.
4221  *
4222  * @param arity   The number of tuple elements.
4223  * @param **in    An array containing pointers to the nodes producing the tuple elements.
4224  */
4225 ir_node *new_Tuple  (int arity, ir_node *in[]);
4226
4227 /** Constructor for an Id node.
4228  *
4229  * This is an auxiliary node to replace a node that returns a single
4230  * value. Adds the node to the block in current_ir_block.
4231  *
4232  * @param *val    The operand to Id.
4233  * @param *mode   The mode of *val.
4234  */
4235 ir_node *new_Id     (ir_node *val, ir_mode *mode);
4236
4237 /** Constructor for a Bad node.
4238  *
4239  * Returns the unique Bad node of the graph.  The same as
4240  * get_irg_bad().
4241  */
4242 ir_node *new_Bad    (void);
4243
4244 /** Constructor for a Confirm node.
4245  *
4246  * Specifies constraints for a value.  To support dataflow analyses.
4247  * Adds the node to the block in current_ir_block.
4248  *
4249  * Example: If the value never exceeds '100' this is expressed by placing a
4250  * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
4251  *
4252  * @param *val    The value we express a constraint for
4253  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
4254  * @param cmp     The compare operation.
4255  */
4256 ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
4257
4258 /** Constructor for an exception region bounded Confirm node.
4259  *
4260  * Specifies constraints for a value.  To support dataflow analyses.
4261  * Adds the node to the block in current_ir_block.
4262  *
4263  * Example: If the value never exceeds '100' this is expressed by placing a
4264  * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
4265  *
4266  * @param *val    The value we express a constraint for
4267  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
4268  * @param cmp     The compare operation.
4269  */
4270 ir_node *new_bounded_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
4271
4272 /** Constructor for an Unknown node.
4273  *
4274  * Represents an arbitrary value.  Places the node in
4275  * the start block.
4276  *
4277  * @param *m      The mode of the unknown value.
4278  */
4279 ir_node *new_Unknown(ir_mode *m);
4280
4281 /** Constructor for a NoMem node.
4282  *
4283  * Returns the unique NoMem node of the graph.  The same as
4284  * get_irg_no_mem().
4285  */
4286 ir_node *new_NoMem  (void);
4287
4288 /** Constructor for a Mux node.
4289  *
4290  * Adds the node to the block in current_ir_block.
4291  *
4292  * @param *sel      The ir_node that calculates the boolean select.
4293  * @param *ir_true  The ir_node that calculates the true result.
4294  * @param *ir_false The ir_node that calculates the false result.
4295  * @param *mode     The mode of the node (and it_true and ir_false).
4296  */
4297 ir_node *new_Mux  (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
4298
4299 /** Constructor for a Psi node.
4300  *
4301  * @param *arity    The arity of the conditions
4302  * @param *conds    The array of mode_b conditions, length must be equal arity
4303  * @param *vals     The array of mode values, length must be equal arity + 1
4304  * @param *mode     The mode of the node (must be the mode of all vals).
4305  */
4306 ir_node *new_Psi (int arity, ir_node *conds[], ir_node *vals[], ir_mode *mode);
4307
4308 /** Constructor for a CopyB node.
4309  *
4310  * Adds the node to the block in current_ir_block.
4311  *
4312  * @param *store      The current memory
4313  * @param *dst        The ir_node that represents the destination address.
4314  * @param *src        The ir_node that represents the source address.
4315  * @param *data_type  The type of the copied data
4316  */
4317 ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
4318
4319 /** Constructor for a InstOf node.
4320  *
4321  * A High-Level Type check.
4322  *
4323  * @param   *store     The memory in which the object the entity should be selected
4324  *                     from is allocated.
4325  * @param   *objptr    A pointer to a object of a class type.
4326  * @param   *type      The type of which objptr must be.
4327  */
4328 ir_node *new_InstOf (ir_node *store, ir_node *objptr, ir_type *type);
4329
4330 /**Constructor for a Raise node.
4331  *
4332  * A High-Level Exception throw.
4333  *
4334  * @param *store The current memory.
4335  * @param *obj   A pointer to the Except variable.
4336  */
4337 ir_node *new_Raise  (ir_node *store, ir_node *obj);
4338
4339 /** Constructor for a Bound node.
4340  *
4341  * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
4342  *
4343  * Adds the node to the block in current_ir_block.
4344  *
4345  * @param *store      The current memory
4346  * @param *idx        The ir_node that represents an index.
4347  * @param *lower      The ir_node that represents the lower bound for the index.
4348  * @param *upper      The ir_node that represents the upper bound for the index.
4349  */
4350 ir_node *new_Bound  (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
4351
4352 /** Constructor for a Pin node.
4353  *
4354  * @param *node       The node which value should be pinned.
4355  */
4356 ir_node *new_Pin    (ir_node *node);
4357
4358 /** Constructor for an ASM pseudo node.
4359  *
4360  * @param arity       The number of data inputs to the node.
4361  * @param *in         The array of length arity of data inputs.
4362  * @param *inputs     The array of length arity of input constraints.
4363  * @param n_outs      The number of data outputs to the node.
4364  * @param *outputs    The array of length n_outs of output constraints.
4365  * @param n_clobber   The number of clobbered registers.
4366  * @param *clobber    The array of length n_clobber of clobbered registers.
4367  * @param *asm_text   The assembler text.
4368  */
4369 ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
4370                  int n_outs, ir_asm_constraint *outputs,
4371                  int n_clobber, ident *clobber[], ident *asm_text);
4372
4373 /*---------------------------------------------------------------------*/
4374 /* The comfortable interface.                                          */
4375 /* Supports automatic Phi node construction.                           */
4376 /* All routines of the block oriented interface except new_Block are   */
4377 /* needed also.                                                        */
4378 /*---------------------------------------------------------------------*/
4379
4380 /** Create an immature Block.
4381  *
4382  * An immature Block has an unknown number of predecessors.  Predecessors
4383  * can be added with add_immBlock_pred().  Once all predecessors are
4384  * added the block must be matured.
4385  *
4386  * Adds the block to the graph in current_ir_graph. Does set
4387  * current_block.  Can be used with automatic Phi node construction.
4388  * This constructor can only be used if the graph is in
4389  * state_building.
4390  */
4391 ir_node *new_d_immBlock(dbg_info *db);
4392 ir_node *new_immBlock(void);
4393
4394 /** Create an immature PartBlock.
4395  *
4396  * An immature block has only one Block or PartBlock predecessor.
4397  * A PartBlock forms together with one BLock and possibly other
4398  * PartBlocks a MacroBlock.
4399  *
4400  * Adds the PartBlock to the graph in current_ir_graph. Does set
4401  * current_block.  Can be used with automatic Phi node construction.
4402  * This constructor can only be used if the graph is in
4403  * state_building.
4404  */
4405 ir_node *new_d_immPartBlock(dbg_info *db, ir_node *pred_jmp);
4406 ir_node *new_immPartBlock(ir_node *pred_jmp);
4407
4408 /** Add a control flow edge to an immature block. */
4409 void add_immBlock_pred(ir_node *immblock, ir_node *jmp);
4410
4411 /** Finalize a Block node, when all control flows are known. */
4412 void mature_immBlock(ir_node *block);
4413 #define mature_cur_block() mature_immBlock(get_cur_block());
4414
4415
4416 /** Get the current value of a local variable.
4417  *
4418  * Use this function to obtain the last definition of the local variable
4419  * associated with pos.  Pos may not exceed the value passed as n_loc
4420  * to new_ir_graph.  This call automatically inserts Phi nodes.
4421  *
4422  * @param *db    A pointer for debug information.
4423  * @param  pos   The position/id of the local variable.
4424  * @param *mode  The mode of the value to get.
4425  */
4426 ir_node *get_d_value(dbg_info *db, int pos, ir_mode *mode);
4427 ir_node *get_value(int pos, ir_mode *mode);
4428
4429 /** Remark a new definition of a variable.
4430  *
4431  * Use this function to remember a new definition of the value
4432  * associated with pos. Pos may not exceed the value passed as n_loc
4433  * to new_ir_graph.  This call is needed to automatically inserts Phi
4434  * nodes.
4435  *
4436  * @param  pos   The position/id of the local variable.
4437  * @param *value The new value written to the local variable.
4438  */
4439 void set_value(int pos, ir_node *value);
4440
4441 /** Find the value number for a node in the current block.
4442  *
4443  * This function searches all values in the current block for
4444  * a given value and returns its value number if it was found, else
4445  * -1.
4446  * Note that this does not mean that the value does not exists,
4447  * it's just not equal the node (for instance behind a Phi/Confirm ...)
4448  *
4449  * @param *value The value to find.
4450  */
4451 int find_value(ir_node *value);
4452
4453 /** Get the current memory state.
4454  *
4455  * Use this function to obtain the last definition of the memory
4456  * state.  This call automatically inserts Phi nodes for the memory
4457  * state value.
4458  */
4459 ir_node *get_store(void);
4460
4461 /** Remark a new definition of the memory state.
4462  *
4463  * Use this function to remember a new definition of the memory state.
4464  * This call is needed to automatically inserts Phi nodes.
4465  *
4466  * @param *store The new memory state.
4467  */
4468 void set_store(ir_node *store);
4469
4470 /** keep this node alive even if End is not control-reachable from it
4471  *
4472  * @param ka The node to keep alive.
4473  */
4474 void keep_alive(ir_node *ka);
4475
4476 /** Returns the frame type of the current graph */
4477 ir_type *get_cur_frame_type(void);
4478
4479
4480 /* --- initialize and finalize ir construction --- */
4481
4482 /** Puts the graph into state "phase_high" */
4483 #define irg_finalize_cons(irg) set_irg_phase_state(irg, phase_high)
4484
4485 /** Puts the program and all graphs into state phase_high.
4486  *
4487  * This also remarks, the construction of types is finished,
4488  * e.g., that no more subtypes will be added.  */
4489 void irp_finalize_cons(void);
4490
4491 /* --- Initialization --- */
4492
4493 /**
4494  * This function is called, whenever a local variable is used before definition
4495  *
4496  * @param irg       the IR graph on which this happens
4497  * @param mode      the mode of the local var
4498  * @param pos       position chosen be the frontend for this variable (n_loc)
4499  *
4500  * @return a firm node of mode @p mode that initializes the var at position pos
4501  *
4502  * @note
4503  *      Do not return NULL!
4504  *      If this function is not set, FIRM will create a const node with tarval BAD.
4505  *      Use set_irg_loc_description()/get_irg_loc_description() to assign additional
4506  *      informations to local variables.
4507  */
4508 typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
4509
4510 #endif