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