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