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