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