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