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