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