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