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