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