b98030f9da30142f7e92622d451c81243d3198ae
[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    (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 (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
1131 /*-------------------------------------------------------------------------*/
1132 /* The raw interface                                                       */
1133 /*-------------------------------------------------------------------------*/
1134
1135 /** Constructor for a Block node.
1136  *
1137  * Constructs a mature block with the given predecessors.
1138  *
1139  * @param *db    A Pointer for  debug information.
1140  * @param irg    The IR graph the block belongs to.
1141  * @param arity  The number of control predecessors.
1142  * @param in[]   An array of control predecessors.  The length of
1143  *               the array must be 'arity'.  The constructor copies this array.
1144  */
1145 FIRM_API ir_node *new_rd_Block(dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1146
1147 /** Constructor for a Start node.
1148  *
1149  * @param *db    A pointer for debug information.
1150  * @param *irg   The IR graph the node belongs to.
1151  */
1152 FIRM_API ir_node *new_rd_Start(dbg_info *db, ir_graph *irg);
1153
1154 /** Constructor for a End node.
1155  *
1156  * @param *db    A pointer for  debug information.
1157  * @param *irg   The IR graph the node  belongs to.
1158  */
1159 FIRM_API ir_node *new_rd_End(dbg_info *db, ir_graph *irg);
1160
1161 /** Constructor for a Jmp node.
1162  *
1163  * Jmp represents control flow to a single control successor.
1164  *
1165  * @param *db     A pointer for debug information.
1166  * @param *block  The IR block the node belongs to.
1167  */
1168 FIRM_API ir_node *new_rd_Jmp(dbg_info *db, ir_node *block);
1169
1170 /** Constructor for an IJmp node.
1171  *
1172  * IJmp represents control flow to a single control successor not
1173  * statically known i.e. an indirect Jmp.
1174  *
1175  * @param *db     A pointer for debug information.
1176  * @param *block  The IR block the node belongs to.
1177  * @param *tgt    The IR node representing the target address.
1178  */
1179 FIRM_API ir_node *new_rd_IJmp(dbg_info *db, ir_node *block, ir_node *tgt);
1180
1181 /** Constructor for a Cond node.
1182  *
1183  * If c is mode_b represents a conditional branch (if/else). If c is
1184  * mode_Is/mode_Iu (?) represents a switch.  (Allocates dense Cond
1185  * node, default Proj is 0.)
1186  *
1187  * This is not consistent:  Input to Cond is Is, Proj has as proj number
1188  * longs.
1189  *
1190  * @param *db    A pointer for debug information.
1191  * @param *block The IR block the node belongs to.
1192  * @param *c     The conditions parameter. Can be of mode b or I_u.
1193  */
1194 FIRM_API ir_node *new_rd_Cond(dbg_info *db, ir_node *block, ir_node *c);
1195
1196 /** Constructor for a Return node.
1197  *
1198  * Returns the memory and zero or more return values.  Only node that
1199  * can end regular control flow.
1200  *
1201  * @param *db    A pointer for debug information.
1202  * @param *block The IR block the node belongs to.
1203  * @param *store The state of memory.
1204  * @param arity  Number of return values.
1205  * @param *in    Array of length arity with return values.  The constructor copies this array.
1206  */
1207 FIRM_API ir_node *new_rd_Return(dbg_info *db, ir_node *block,
1208                                 ir_node *store, int arity, ir_node *in[]);
1209
1210 /** Constructor for a Const node.
1211  *
1212  * Adds the node to the start block.
1213  *
1214  * Constructor for a Const node. The constant represents a target
1215  * value.  Sets the type information to type_unknown.  (No more
1216  * supported: If tv is entity derives a somehow useful type.)
1217  * Derives mode from passed tarval.
1218  *
1219  * @param *db    A pointer for debug information.
1220  * @param *irg   The IR graph the node  belongs to.
1221  * @param *con   Points to an entry in the constant table.
1222  */
1223 FIRM_API ir_node *new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con);
1224
1225 /**
1226  * Constructor for a Const node.
1227  *
1228  * Adds the node to the start block.
1229  *
1230  * Constructor for a Const node. The constant represents a target
1231  * value.  Sets the type information to type_unknown.  (No more
1232  * supported: If tv is entity derives a somehow useful type.)
1233  *
1234  * @param *db    A pointer for debug information.
1235  * @param *irg   The IR graph the node  belongs to.
1236  * @param *mode  The mode of the operands and results.
1237  * @param value  A value from which the tarval is made.
1238  */
1239 FIRM_API ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg,
1240                                     ir_mode *mode, long value);
1241
1242 /** Constructor for a SymConst node.
1243  *
1244  *  This is the constructor for a symbolic constant.
1245  *    There are several kinds of symbolic constants:
1246  *    - symconst_type_tag   The symbolic constant represents a type tag.  The
1247  *                          type the tag stands for is given explicitly.
1248  *    - symconst_type_size  The symbolic constant represents the size of a type.
1249  *                          The type of which the constant represents the size
1250  *                          is given explicitly.
1251  *    - symconst_type_align The symbolic constant represents the alignment of a
1252  *                          type.  The type of which the constant represents the
1253  *                          size is given explicitly.
1254  *    - symconst_addr_ent   The symbolic constant represents the address of an
1255  *                          entity (variable or method).  The variable is given
1256  *                          explicitly by a firm entity.
1257  *    - symconst_ofs_ent    The symbolic constant represents the offset of an
1258  *                          entity in its owner type.
1259  *    - symconst_enum_const The symbolic constant is a enumeration constant of
1260  *                          an enumeration type.
1261  *
1262  *    Inputs to the node:
1263  *      No inputs except the block it belongs to.
1264  *    Outputs of the node.
1265  *      An unsigned integer (I_u) or a pointer (P).
1266  *
1267  *    Mention union in declaration so that the firmjni generator recognizes that
1268  *    it can not cast the argument to an int.
1269  *
1270  * @param *db     A pointer for debug information.
1271  * @param *irg    The IR graph the node  belongs to.
1272  * @param mode    The mode for the SymConst.
1273  * @param val     A type, ident, entity or enum constant depending on the
1274  *                SymConst kind.
1275  * @param kind    The kind of the symbolic constant, see the list above
1276  */
1277 FIRM_API ir_node *new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode,
1278                                   union symconst_symbol value,
1279                                   symconst_kind kind);
1280
1281 /** Constructor for a SymConst addr_ent node.
1282  *
1283  * Same as new_rd_SymConst, except that the constructor is tailored for
1284  * symconst_addr_ent.
1285  * Adds the SymConst to the start block of irg. */
1286 FIRM_API ir_node *new_rd_SymConst_addr_ent(dbg_info *db, ir_graph *irg,
1287                                            ir_mode *mode, ir_entity *symbol);
1288
1289 /** Constructor for a SymConst ofs_ent node.
1290  *
1291  * Same as new_rd_SymConst, except that the constructor is tailored for
1292  * symconst_ofs_ent.
1293  * Adds the SymConst to the start block of irg.
1294  */
1295 FIRM_API ir_node *new_rd_SymConst_ofs_ent(dbg_info *db, ir_graph *irg,
1296                                           ir_mode *mode, ir_entity *symbol);
1297
1298 /** Constructor for a SymConst type_tag node.
1299  *
1300  * Same as new_rd_SymConst, except that the constructor is tailored for
1301  * symconst_type_tag.
1302  * Adds the SymConst to the start block of irg.
1303  */
1304 FIRM_API ir_node *new_rd_SymConst_type_tag(dbg_info *db, ir_graph *irg,
1305                                            ir_mode *mode, ir_type *symbol);
1306
1307 /** Constructor for a SymConst size node.
1308  *
1309  * Same as new_rd_SymConst, except that the constructor is tailored for
1310  * symconst_type_size.
1311  * Adds the SymConst to the start block of irg. */
1312 FIRM_API ir_node *new_rd_SymConst_size(dbg_info *db, ir_graph *irg,
1313                                        ir_mode *mode, ir_type *symbol);
1314
1315 /** Constructor for a SymConst size node.
1316  *
1317  * Same as new_rd_SymConst, except that the constructor is tailored for
1318  * symconst_type_align.
1319  * Adds the SymConst to the start block of irg.
1320  */
1321 FIRM_API ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg,
1322                                         ir_mode *mode, ir_type *symbol);
1323
1324 /** Constructor for a simpleSel node.
1325  *
1326  *  This is a shortcut for the new_rd_Sel() constructor.  To be used for
1327  *  Sel nodes that do not select from an array, i.e., have no index
1328  *  inputs.  It adds the two parameters 0, NULL.
1329  *
1330  * @param   *db        A pointer for debug information.
1331  * @param   *block     The IR block the node belongs to.
1332  * @param   *store     The memory in which the object the entity should be
1333  *                     selected from is allocated.
1334  * @param   *objptr    The object from that the Sel operation selects a
1335  *                     single attribute out.
1336  * @param   *ent       The entity to select.
1337  */
1338 FIRM_API ir_node *new_rd_simpleSel(dbg_info *db, ir_node *block, ir_node *store,
1339                                    ir_node *objptr, ir_entity *ent);
1340
1341 /** Constructor for a Sel node.
1342  *
1343  * The select node selects an entity (field or method) from an entity
1344  * with a compound type.  It explicitly specifies the entity selected.
1345  * Dynamically the node may select entities that overwrite the given
1346  * entity.  If the selected entity is an array element entity the Sel
1347  * node takes the required array indices as inputs.
1348  *
1349  * @param   *db        A pointer for debug information.
1350  * @param   *block     The IR block the node belongs to.
1351  * @param   *store     The memory in which the object the entity should be selected
1352  *                     from is allocated.
1353  * @param   *objptr    A pointer to a compound entity the Sel operation selects a
1354  *                     single attribute from.
1355  * @param   *n_index   The number of array indices needed to select an array element entity.
1356  * @param   *index[]   If the compound entity is an array the indices of the selected
1357  *                     element entity.  The constructor copies this array.
1358  * @param   *ent       The entity to select.
1359  */
1360 FIRM_API ir_node *new_rd_Sel(dbg_info *db, ir_node *block, ir_node *store,
1361                              ir_node *objptr, int n_index, ir_node *index[],
1362                              ir_entity *ent);
1363
1364 /** Constructor for a Call node.
1365  *
1366  * Represents all kinds of method and function calls.
1367  *
1368  * @param   *db     A pointer for debug information.
1369  * @param   *block  The IR block the node belongs to.
1370  * @param   *store  The current memory state.
1371  * @param   *callee A pointer to the called procedure.
1372  * @param   arity   The number of procedure parameters.
1373  * @param   *in[]   An array with the procedure parameters. The constructor copies this array.
1374  * @param   *tp     Type information of the procedure called.
1375  */
1376 FIRM_API ir_node *new_rd_Call(dbg_info *db, ir_node *block, ir_node *store,
1377                               ir_node *callee, int arity, ir_node *in[],
1378                               ir_type *tp);
1379
1380 /** Constructor for a Builtin node.
1381  *
1382  * Represents a call of a backend-specific builtin..
1383  *
1384  * @param   *db     A pointer for debug information.
1385  * @param   *block  The IR block the node belongs to.
1386  * @param   *store  The current memory state.
1387  * @param   arity   The number of procedure parameters.
1388  * @param   *in[]   An array with the procedure parameters. The constructor copies this array.
1389  * @param   kind    The kind of the called builtin.
1390  * @param   *tp     Type information of the procedure called.
1391  */
1392 FIRM_API ir_node *new_rd_Builtin(dbg_info *db, ir_node *block, ir_node *store,
1393                                  int arity, ir_node *in[], ir_builtin_kind kind,
1394                                  ir_type *tp);
1395
1396 /** Constructor for a Add node.
1397  *
1398  * @param   *db    A pointer for debug information.
1399  * @param   *block The IR block the node belongs to.
1400  * @param   *op1   The first operand.
1401  * @param   *op2   The second operand.
1402  * @param   *mode  The mode of the operands and the result.
1403  */
1404 FIRM_API ir_node *new_rd_Add(dbg_info *db, ir_node *block, ir_node *op1,
1405                              ir_node *op2, ir_mode *mode);
1406
1407 /** Constructor for a Sub node.
1408  *
1409  * @param   *db    A pointer for debug information.
1410  * @param   *block The IR block the node belongs to.
1411  * @param   *op1   The first operand.
1412  * @param   *op2   The second operand.
1413  * @param   *mode  The mode of the operands and the result.
1414  */
1415 FIRM_API ir_node *new_rd_Sub(dbg_info *db, ir_node *block,
1416                              ir_node *op1, ir_node *op2, ir_mode *mode);
1417
1418 /** Constructor for a Minus node.
1419  *
1420  * @param   *db    A pointer for debug information.
1421  * @param   *block The IR block the node belongs to.
1422  * @param   *op    The operand .
1423  * @param   *mode  The mode of the operand and the result.
1424  */
1425 FIRM_API ir_node *new_rd_Minus(dbg_info *db, ir_node *block,
1426                                ir_node *op, ir_mode *mode);
1427
1428 /** Constructor for a Mul node.
1429  *
1430  * @param   *db    A pointer for debug information.
1431  * @param   *block The IR block the node belongs to.
1432  * @param   *op1   The first operand.
1433  * @param   *op2   The second operand.
1434  * @param   *mode  The mode of the operands and the result.
1435  */
1436 FIRM_API ir_node *new_rd_Mul(dbg_info *db, ir_node *block,
1437                              ir_node *op1, ir_node *op2, ir_mode *mode);
1438
1439 /** Constructor for a Mulh node.
1440  *
1441  * @param   *db    A pointer for debug information.
1442  * @param   *block The IR block the node belongs to.
1443  * @param   *op1   The first operand.
1444  * @param   *op2   The second operand.
1445  * @param   *mode  The mode of the operands and the result.
1446  */
1447 FIRM_API ir_node *new_rd_Mulh(dbg_info *db, ir_node *block,
1448                               ir_node *op1, ir_node *op2, ir_mode *mode);
1449
1450 /** Constructor for a Quot node.
1451  *
1452  * @param   *db    A pointer for debug information.
1453  * @param   *block The IR block the node belongs to.
1454  * @param   *memop The store needed to model exceptions
1455  * @param   *op1   The first operand.
1456  * @param   *op2   The second operand.
1457  * @param   *mode  The mode of the result.
1458  * @param   state  The pinned state.
1459  */
1460 FIRM_API ir_node *new_rd_Quot(dbg_info *db, ir_node *block, ir_node *memop,
1461                               ir_node *op1, ir_node *op2, ir_mode *mode,
1462                               op_pin_state state);
1463
1464 /** Constructor for a DivMod node.
1465  *
1466  * @param   *db    A pointer for debug information.
1467  * @param   *block The IR block the node belongs to.
1468  * @param   *memop The store needed to model exceptions
1469  * @param   *op1   The first operand.
1470  * @param   *op2   The second operand.
1471  * @param   *mode  The mode of the results.
1472  * @param   state  The pinned state.
1473  */
1474 FIRM_API ir_node *new_rd_DivMod(dbg_info *db, ir_node *block, ir_node *memop,
1475                                 ir_node *op1, ir_node *op2, ir_mode *mode,
1476                                 op_pin_state state);
1477
1478 /** Constructor for a Div node.
1479  *
1480  * @param   *db    A pointer for debug information.
1481  * @param   *block The IR block the node belongs to.
1482  * @param   *memop The store needed to model exceptions
1483  * @param   *op1   The first operand.
1484  * @param   *op2   The second operand.
1485  * @param   *mode  The mode of the result.
1486  * @param   state  The pinned state.
1487  */
1488 FIRM_API ir_node *new_rd_Div(dbg_info *db, ir_node *block, ir_node *memop,
1489                              ir_node *op1, ir_node *op2, ir_mode *mode,
1490                              op_pin_state state);
1491
1492 /** Constructor for a remainderless Div node.
1493  *
1494  * @param   *db    A pointer for debug information.
1495  * @param   *block The IR block the node belongs to.
1496  * @param   *memop The store needed to model exceptions
1497  * @param   *op1   The first operand.
1498  * @param   *op2   The second operand.
1499  * @param   *mode  The mode of the result.
1500  * @param   state  The pinned state.
1501  */
1502 FIRM_API ir_node *new_rd_DivRL(dbg_info *db, ir_node *block, ir_node *memop,
1503                                ir_node *op1, ir_node *op2, ir_mode *mode,
1504                                op_pin_state state);
1505
1506 /** Constructor for a Mod node.
1507  *
1508  * @param   *db    A pointer for debug information.
1509  * @param   *block The IR block the node belongs to.
1510  * @param   *memop The store needed to model exceptions
1511  * @param   *op1   The first operand.
1512  * @param   *op2   The second operand.
1513  * @param   *mode  The mode of the result.
1514  * @param   state  The pinned state.
1515  */
1516 FIRM_API ir_node *new_rd_Mod(dbg_info *db, ir_node *block, ir_node *memop,
1517                              ir_node *op1, ir_node *op2, ir_mode *mode,
1518                              op_pin_state state);
1519
1520 /** Constructor for a And node.
1521  *
1522  * @param   *db    A pointer for debug information.
1523  * @param   *block The IR block the node belongs to.
1524  * @param   *op1   The first operand.
1525  * @param   *op2   The second operand.
1526  * @param   *mode  The mode of the operands and the result.
1527  */
1528 FIRM_API ir_node *new_rd_And(dbg_info *db, ir_node *block,
1529                              ir_node *op1, ir_node *op2, ir_mode *mode);
1530
1531 /** Constructor for a Or node.
1532  *
1533  * @param   *db    A pointer for debug information.
1534  * @param   *block The IR block the node belongs to.
1535  * @param   *op1   The first operand.
1536  * @param   *op2   The second operand.
1537  * @param   *mode  The mode of the operands and the result.
1538  */
1539 FIRM_API ir_node *new_rd_Or(dbg_info *db, ir_node *block,
1540                             ir_node *op1, ir_node *op2, ir_mode *mode);
1541
1542 /** Constructor for a Eor node.
1543  *
1544  * @param   *db    A pointer for debug information.
1545  * @param   *block The IR block the node belongs to.
1546  * @param   *op1   The first operand.
1547  * @param   *op2   The second operand.
1548  * @param   *mode  The mode of the operands and the results.
1549  */
1550 FIRM_API ir_node *new_rd_Eor(dbg_info *db, ir_node *block,
1551                              ir_node *op1, ir_node *op2, ir_mode *mode);
1552
1553 /** Constructor for a Not node.
1554  *
1555  * @param   *db    A pointer for debug information.
1556  * @param   *block The IR block the node belongs to.
1557  * @param   *op    The operand.
1558  * @param   *mode  The mode of the operand and the result.
1559  */
1560 FIRM_API ir_node *new_rd_Not(dbg_info *db, ir_node *block, ir_node *op,
1561                              ir_mode *mode);
1562
1563 /** Constructor for a Cmp node.
1564  *
1565  * @param   *db    A pointer for debug information.
1566  * @param   *block The IR block the node belongs to.
1567  * @param   *op1   The first operand.
1568  * @param   *op2   The second operand.
1569  */
1570 FIRM_API ir_node *new_rd_Cmp(dbg_info *db, ir_node *block,
1571                              ir_node *op1, ir_node *op2);
1572
1573 /** Constructor for a Shl node.
1574  *
1575  * @param   *db    A pointer for debug information.
1576  * @param   *block The IR block the node belongs to.
1577  * @param   *op    The operand.
1578  * @param   *k     The number of bits to  shift the operand .
1579  * @param   *mode  The mode of the operand and the result.
1580  */
1581 FIRM_API ir_node *new_rd_Shl(dbg_info *db, ir_node *block,
1582                              ir_node *op, ir_node *k, ir_mode *mode);
1583
1584 /** Constructor for a Shr node.
1585  *
1586  * @param   *db    A pointer for debug information.
1587  * @param   *block The IR block the node belongs to.
1588  * @param   *op    The operand.
1589  * @param   *k     The number of bits to shift the operand .
1590  * @param   *mode  The mode of the operand and the result.
1591  */
1592 FIRM_API ir_node *new_rd_Shr(dbg_info *db, ir_node *block,
1593                              ir_node *op, ir_node *k, ir_mode *mode);
1594
1595 /** Constructor for a Shrs node.
1596  *
1597  * @param   *db    A pointer for debug information.
1598  * @param   *block The IR block the node belongs to.
1599  * @param   *op    The operand.
1600  * @param   *k     The number of bits to shift the operand.
1601  * @param   *mode  The mode of the operand and the result.
1602  */
1603 FIRM_API ir_node *new_rd_Shrs(dbg_info *db, ir_node *block,
1604                               ir_node *op, ir_node *k, ir_mode *mode);
1605
1606 /** Constructor for a Rotl node.
1607  *
1608  * @param   *db    A pointer for debug information.
1609  * @param   *block The IR block the node belongs to.
1610  * @param   *op    The operand.
1611  * @param   *k     The number of bits to rotate the operand.
1612  * @param   *mode  The mode of the operand.
1613  */
1614 FIRM_API ir_node *new_rd_Rotl(dbg_info *db, ir_node *block,
1615                               ir_node *op, ir_node *k, ir_mode *mode);
1616
1617
1618 /** Constructor for a Conv node.
1619  *
1620  * @param   *db    A pointer for debug information.
1621  * @param   *block The IR block the node belongs to.
1622  * @param   *op    The operand.
1623  * @param   *mode  The mode of this the operand muss be converted .
1624  */
1625 FIRM_API ir_node *new_rd_Conv(dbg_info *db, ir_node *block, ir_node *op,
1626                               ir_mode *mode);
1627
1628 /** Constructor for a strictConv node.
1629  *
1630  * @param   *db    A pointer for debug information.
1631  * @param   *block The IR block the node belongs to.
1632  * @param   *op    The operand.
1633  * @param   *mode  The mode of this the operand muss be converted .
1634  */
1635 FIRM_API ir_node *new_rd_strictConv(dbg_info *db, ir_node *block,
1636                                     ir_node *op, ir_mode *mode);
1637
1638 /** Constructor for a Cast node.
1639  *
1640  * High level type cast.
1641  *
1642  * @param   *db    A pointer for debug information.
1643  * @param   *block The IR block the node belongs to.
1644  * @param   *op    The operand.
1645  * @param   *to_tp The type of this the operand muss be casted .
1646  */
1647 FIRM_API ir_node *new_rd_Cast(dbg_info *db, ir_node *block,
1648                               ir_node *op, ir_type *to_tp);
1649
1650 /** Constructor for a Carry node.
1651  * Note: This node is not supported by the backends! Only use for program
1652  * analysis tasks.
1653  *
1654  * @param   *db    A pointer for debug information.
1655  * @param   *block The IR block the node belongs to.
1656  * @param   *op1   The first operand.
1657  * @param   *op2   The second operand.
1658  * @param   *mode  The mode of the operands and the result.
1659  */
1660 FIRM_API ir_node *new_rd_Carry(dbg_info *db, ir_node *block,
1661                                ir_node *op1, ir_node *op2, ir_mode *mode);
1662
1663 /** Constructor for a Borrow node.
1664  * Note: This node is not supported by the backends! Only use for program
1665  * analysis tasks.
1666  *
1667  * @param   *db    A pointer for debug information.
1668  * @param   *block The IR block the node belongs to.
1669  * @param   *op1   The first operand.
1670  * @param   *op2   The second operand.
1671  * @param   *mode  The mode of the operands and the result.
1672  */
1673 FIRM_API ir_node *new_rd_Borrow(dbg_info *db, ir_node *block,
1674                                 ir_node *op1, ir_node *op2, ir_mode *mode);
1675
1676 /** Constructor for a Phi node.
1677  *
1678  * @param *db    A pointer for debug information.
1679  * @param *block The IR block the node belongs to.
1680  * @param arity  The number of predecessors
1681  * @param *in[]  Array with predecessors.  The constructor copies this array.
1682  * @param *mode  The mode of it's inputs and output.
1683  */
1684 FIRM_API ir_node *new_rd_Phi(dbg_info *db, ir_node *block, int arity,
1685                              ir_node *in[], ir_mode *mode);
1686
1687 /** Constructor for a Load node.
1688  *
1689  * @param *db    A pointer for debug information.
1690  * @param *block The IR block the node belongs to.
1691  * @param *store The current memory
1692  * @param *adr   A pointer to the variable to be read in this memory.
1693  * @param *mode  The mode of the value to be loaded.
1694  * @param  flags Additional flags for alignment, volatility and pin state.
1695  */
1696 FIRM_API ir_node *new_rd_Load(dbg_info *db, ir_node *block, ir_node *store,
1697                               ir_node *adr, ir_mode *mode, ir_cons_flags flags);
1698
1699 /** Constructor for a Store node.
1700  *
1701  * @param *db    A pointer for debug information.
1702  * @param *block The IR block the node belongs to.
1703  * @param *store The current memory
1704  * @param *adr   A pointer to the variable to be read in this memory.
1705  * @param *val   The value to write to this variable.
1706  * @param  flags Additional flags for alignment, volatility and pin state.
1707  */
1708 FIRM_API ir_node *new_rd_Store(dbg_info *db, ir_node *block, ir_node *store,
1709                                ir_node *adr, ir_node *val, ir_cons_flags flags);
1710
1711 /** Constructor for a Alloc node.
1712  *
1713  * The Alloc node extends the memory by space for an entity of type alloc_type.
1714  *
1715  * @param *db         A pointer for debug information.
1716  * @param *block      The IR block the node belongs to.
1717  * @param *store      The memory which shall contain the new variable.
1718  * @param *count      The number of objects to allocate.
1719  * @param *alloc_type The type of the allocated variable.
1720  * @param where       Where to allocate the variable, either heap_alloc or stack_alloc.
1721  */
1722 FIRM_API ir_node *new_rd_Alloc(dbg_info *db, ir_node *block, ir_node *store,
1723                                ir_node *count, ir_type *alloc_type,
1724                                ir_where_alloc where);
1725
1726 /** Constructor for a Free node.
1727  *
1728  * Frees the memory occupied by the entity pointed to by the pointer
1729  * arg.  Type indicates the type of the entity the argument points to.
1730  *
1731  * @param *db         A pointer for debug information.
1732  * @param *block      The IR block the node belongs to.
1733  * @param *store      The memory which shall contain the new variable.
1734  * @param *ptr        The pointer to the object to free.
1735  * @param *size       The number of objects of type free_type to free in a sequence.
1736  * @param *free_type  The type of the freed variable.
1737  * @param where       Where the variable was allocated, either heap_alloc or stack_alloc.
1738  */
1739 FIRM_API ir_node *new_rd_Free(dbg_info *db, ir_node *block, ir_node *store,
1740                               ir_node *ptr, ir_node *size, ir_type *free_type,
1741                               ir_where_alloc where);
1742
1743 /** Constructor for a Sync node.
1744  *
1745  * Merges several memory values.  The node assumes that a variable
1746  * either occurs only in one of the memories, or it contains the same
1747  * value in all memories where it occurs.
1748  *
1749  * @param *db       A pointer for debug information.
1750  * @param *block    The IR block the node belongs to.
1751  * @param  arity    The number of memories to synchronize.
1752  * @param  *in[]    An array of pointers to nodes that produce an output of type
1753  *                  memory.  The constructor copies this array.
1754  */
1755 FIRM_API ir_node *new_rd_Sync(dbg_info *db, ir_node *block, int arity,
1756                               ir_node *in[]);
1757
1758 /** Constructor for a Proj node.
1759  *
1760  * Projects a single value out of a tuple.  The parameter proj gives the
1761  * position of the value within the tuple.
1762  *
1763  * @param *db    A pointer for debug information.
1764  * @param arg    A node producing a tuple.  The node must have mode_T.
1765  * @param *mode  The mode of the value to project.
1766  * @param proj   The position of the value in the tuple.
1767  */
1768 FIRM_API ir_node *new_rd_Proj(dbg_info *db, ir_node *arg, ir_mode *mode,
1769                               long proj);
1770
1771 /** Constructor for a defaultProj node.
1772  *
1773  * Represents the default control flow of a Switch-Cond node.
1774  *
1775  * @param *db       A pointer for debug information.
1776  * @param arg       A node producing a tuple.
1777  * @param max_proj  The end position of the value in the tuple.
1778  */
1779 FIRM_API ir_node *new_rd_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
1780
1781 /** Constructor for a Tuple node.
1782  *
1783  * This is an auxiliary node to replace a node that returns a tuple
1784  * without changing the corresponding Proj nodes.
1785  *
1786  * @param *db     A pointer for debug information.
1787  * @param *block  The IR block the node belongs to.
1788  * @param arity   The number of tuple elements.
1789  * @param *in[]   An array containing pointers to the nodes producing the tuple
1790  *                elements. The constructor copies this array.
1791  */
1792 FIRM_API ir_node *new_rd_Tuple(dbg_info *db, ir_node *block,
1793                                int arity, ir_node *in[]);
1794
1795 /** Constructor for a Id node.
1796  *
1797  * This is an auxiliary node to replace a node that returns a single
1798  * value.
1799  *
1800  * @param *db     A pointer for debug information.
1801  * @param *block  The IR block the node belongs to.
1802  * @param *val    The value
1803  * @param *mode   The mode of *val.
1804  */
1805 FIRM_API ir_node *new_rd_Id(dbg_info *db, ir_node *block,
1806                             ir_node *val, ir_mode *mode);
1807
1808 /** Constructor for a Confirm node.
1809  *
1810  * Specifies constraints for a value.  To support dataflow analyses.
1811  *
1812  * Example: If the value never exceeds '100' this is expressed by placing a
1813  * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
1814  *
1815  * @param *db     A pointer for debug information.
1816  * @param *block  The IR block the node belong to.
1817  * @param *val    The value we express a constraint for
1818  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
1819  * @param cmp     The compare operation.
1820  */
1821 FIRM_API ir_node *new_rd_Confirm(dbg_info *db, ir_node *block,
1822                                  ir_node *val, ir_node *bound, pn_Cmp cmp);
1823
1824 /** Constructor for an Unknown node.
1825  *
1826  * Represents an arbitrary value.  Places the node in the start block.
1827  *
1828  * @param *db     A pointer for debug information.
1829  * @param *irg    The IR graph the node  belongs to.
1830  * @param *m      The mode of the unknown value.
1831  */
1832 FIRM_API ir_node *new_rd_Unknown(dbg_info *db, ir_graph *irg, ir_mode *m);
1833
1834 /** Constructor for a Mux node.
1835  *
1836  * @param *db       A pointer for debug information.
1837  * @param *block    The block the node belong to.
1838  * @param *sel      The ir_node that calculates the boolean select.
1839  * @param *ir_true  The ir_node that calculates the true result.
1840  * @param *ir_false The ir_node that calculates the false result.
1841  * @param *mode     The mode of the node (and it_true and ir_false).
1842  */
1843 FIRM_API ir_node *new_rd_Mux(dbg_info *db, ir_node *block, ir_node *sel,
1844                              ir_node *ir_false, ir_node *ir_true,
1845                              ir_mode *mode);
1846
1847 /** Constructor for a CopyB node.
1848  *
1849  * @param *db         A pointer for debug information.
1850  * @param *block      The block the node belong to.
1851  * @param *store      The current memory
1852  * @param *dst        The ir_node that represents the destination address.
1853  * @param *src        The ir_node that represents the source address.
1854  * @param *data_type  The type of the copied data
1855  */
1856 FIRM_API ir_node *new_rd_CopyB(dbg_info *db, ir_node *block, ir_node *store,
1857                                ir_node *dst, ir_node *src, ir_type *data_type);
1858
1859 /** Constructor for a InstOf node.
1860  *
1861  * A High-Level Type check.
1862  *
1863  * @param   *db        A pointer for debug information.
1864  * @param   *block     The IR block the node belongs to.
1865  * @param   *store     The memory in which the object the entity should be selected
1866  *                     from is allocated.
1867  * @param   *objptr    A pointer to a object of a class type.
1868  * @param   *type      The type of which objptr must be.
1869  */
1870 FIRM_API ir_node *new_rd_InstOf(dbg_info *db, ir_node *block, ir_node *store,
1871                                 ir_node *objptr, ir_type *type);
1872
1873 /** Constructor for a Raise node.
1874  *
1875  * A High-Level Exception throw.
1876  *
1877  * @param *db    A pointer for debug information.
1878  * @param *block The IR block the node belongs to.
1879  * @param *store The current memory.
1880  * @param *obj   A pointer to the Except variable.
1881  */
1882 FIRM_API ir_node *new_rd_Raise(dbg_info *db, ir_node *block, ir_node *store,
1883                                ir_node *obj);
1884
1885 /** Constructor for a Bound node.
1886  *
1887  * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
1888  *
1889  * @param *db         A pointer for debug information.
1890  * @param *block      The block the node belong to.
1891  * @param *store      The current memory.
1892  * @param *idx        The ir_node that represents an index.
1893  * @param *lower      The ir_node that represents the lower bound for the index.
1894  * @param *upper      The ir_node that represents the upper bound for the index.
1895  */
1896 FIRM_API ir_node *new_rd_Bound(dbg_info *db, ir_node *block,
1897                                ir_node *store, ir_node *idx, ir_node *lower,
1898                                ir_node *upper);
1899
1900 /** Constructor for a Pin node.
1901  *
1902  * @param *db         A pointer for debug information.
1903  * @param *block      The block the node belong to.
1904  * @param *node       The node which value should be pinned.
1905  */
1906 FIRM_API ir_node *new_rd_Pin(dbg_info *db, ir_node *block, ir_node *node);
1907
1908 /** Constructor for an ASM pseudo node.
1909  *
1910  * @param *db         A pointer for debug information.
1911  * @param *block      The block the node belong to.
1912  * @param arity       The number of data inputs to the node.
1913  * @param *in         The array of length arity of data inputs.
1914  * @param *inputs     The array of length arity of input constraints.
1915  * @param n_outs      The number of data outputs to the node.
1916  * @param *outputs    The array of length n_outs of output constraints.
1917  * @param n_clobber   The number of clobbered registers.
1918  * @param *clobber    The array of length n_clobber of clobbered registers.
1919  * @param *asm_text   The assembler text.
1920  */
1921 FIRM_API ir_node *new_rd_ASM(dbg_info *db, ir_node *block,
1922                             int arity, ir_node *in[], ir_asm_constraint *inputs,
1923                             int n_outs, ir_asm_constraint *outputs,
1924                             int n_clobber, ident *clobber[], ident *asm_text);
1925
1926 /*-------------------------------------------------------------------------*/
1927 /* The raw interface without debug support                                 */
1928 /*-------------------------------------------------------------------------*/
1929
1930 /** Constructor for a Block node.
1931  *
1932  * Constructs a mature block with the given predecessors.  Use Unknown
1933  * nodes as predecessors to construct a block if the number of
1934  * predecessors is known, but not the predecessors themselves.  This
1935  * constructor does not set current_block.  It not be used with
1936  * automatic Phi node construction.
1937  *
1938  *
1939  * @param irg    The IR graph the block belongs to.
1940  * @param arity  The number of control predecessors.
1941  * @param in[]   An array of control predecessors.  The length of
1942  *               the array must be 'arity'. The constructor copies this array.
1943  */
1944 FIRM_API ir_node *new_r_Block(ir_graph *irg, int arity, ir_node *in[]);
1945
1946 /** Constructor for a Start node. */
1947 FIRM_API ir_node *new_r_Start(ir_graph *irg);
1948
1949 /** Constructor for a End node. */
1950 FIRM_API ir_node *new_r_End(ir_graph *irg);
1951
1952 /** Constructor for a Jmp node.
1953  *
1954  * Jmp represents control flow to a single control successor.
1955  *
1956  * @param *block  The IR block the node belongs to.
1957  */
1958 FIRM_API ir_node *new_r_Jmp(ir_node *block);
1959
1960 /** Constructor for an IJmp node.
1961  *
1962  * IJmp represents control flow to a single control successor not
1963  * statically known i.e. an indirect Jmp.
1964  *
1965  * @param *block  The IR block the node belongs to.
1966  * @param *tgt    The IR node representing the target address.
1967  */
1968 FIRM_API ir_node *new_r_IJmp(ir_node *block, ir_node *tgt);
1969
1970 /** Constructor for a Cond node.
1971  *
1972  * If c is mode_b represents a conditional branch (if/else). If c is
1973  * mode_Is/mode_Iu (?) represents a switch.  (Allocates dense Cond
1974  * node, default Proj is 0.)
1975  *
1976  * This is not consistent:  Input to Cond is Is, Proj has as proj number
1977  * longs.
1978  *
1979  * @param *block The IR block the node belongs to.
1980  * @param *c     The conditions parameter.Can be of mode b or I_u.
1981  */
1982 FIRM_API ir_node *new_r_Cond(ir_node *block, ir_node *c);
1983
1984 /** Constructor for a Return node.
1985  *
1986  * Returns the memory and zero or more return values.  Only node that
1987  * can end regular control flow.
1988  *
1989  * @param *block The IR block the node belongs to.
1990  * @param *store The state of memory.
1991  * @param arity  Number of array indices.
1992  * @param *in[]  Array with index inputs to the node. The constructor copies this array.
1993  */
1994 FIRM_API ir_node *new_r_Return(ir_node *block, ir_node *store,
1995                                int arity, ir_node *in[]);
1996
1997 /** Constructor for a Const node.
1998  *
1999  * Adds the node to the start block.
2000  *
2001  * Constructor for a Const node. The constant represents a target
2002  * value.  Sets the type information to type_unknown.  (No more
2003  * supported: If tv is entity derives a somehow useful type.)
2004  * Derives mode from passed tarval.
2005  *
2006  * @param *irg   The IR graph the node  belongs to.
2007  * @param *con   Points to an entry in the constant table.
2008  */
2009 FIRM_API ir_node *new_r_Const(ir_graph *irg, tarval *con);
2010
2011 /** Constructor for a Const node.
2012  *
2013  * Adds the node to the start block.
2014  *
2015  * Constructor for a Const node. The constant represents a target
2016  * value.  Sets the type information to type_unknown.  (No more
2017  * supported: If tv is entity derives a somehow useful type.)
2018  *
2019  * @param *irg   The IR graph the node  belongs to.
2020  * @param *mode  The mode of the operands and the results.
2021  * @param value  A value from which the tarval is made.
2022  */
2023 FIRM_API ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value);
2024
2025 /** Constructor for a SymConst node.
2026  *
2027  *  This is the constructor for a symbolic constant.
2028  *    There are several kinds of symbolic constants:
2029  *    - symconst_type_tag   The symbolic constant represents a type tag.  The
2030  *                          type the tag stands for is given explicitly.
2031  *    - symconst_type_size  The symbolic constant represents the size of a type.
2032  *                          The type of which the constant represents the size
2033  *                          is given explicitly.
2034  *    - symconst_type_align The symbolic constant represents the alignment of a
2035  *                          type.  The type of which the constant represents the
2036  *                          size is given explicitly.
2037  *    - symconst_addr_ent   The symbolic constant represents the address of an
2038  *                          entity (variable or method).  The variable is given
2039  *                          explicitly by a firm entity.
2040  *    - symconst_ofs_ent    The symbolic constant represents the offset of an
2041  *                          entity in its owner type.
2042  *    - symconst_enum_const The symbolic constant is a enumeration constant of
2043  *                          an enumeration type.
2044  *
2045  *    Inputs to the node:
2046  *      No inputs except the block it belongs to.
2047  *    Outputs of the node.
2048  *      An unsigned integer (I_u) or a pointer (P).
2049  *
2050  *    Mention union in declaration so that the firmjni generator recognizes that
2051  *    it can not cast the argument to an int.
2052  *
2053  * @param *irg    The IR graph the node  belongs to.
2054  * @param mode    The mode for the SymConst.
2055  * @param value   A type, ident, entity or enum constant depending on the
2056  *                SymConst kind.
2057  * @param kind    The kind of the symbolic constant, see the list above
2058  */
2059 FIRM_API ir_node *new_r_SymConst(ir_graph *irg, ir_mode *mode,
2060                                  union symconst_symbol value,
2061                                  symconst_kind kind);
2062
2063 /** Constructor for a simpleSel node.
2064  *
2065  *  This is a shortcut for the new_d_Sel() constructor.  To be used for
2066  *  Sel nodes that do not select from an array, i.e., have no index
2067  *  inputs.  It adds the two parameters 0, NULL.
2068  *
2069  * @param *block     The IR block the node belongs to.
2070  * @param *store     The memory in which the object the entity should be selected
2071  *                   from is allocated.
2072  * @param *objptr    The object from that the Sel operation selects a
2073  *                   single attribute out.
2074  * @param *ent       The entity to select.
2075  */
2076 FIRM_API ir_node *new_r_simpleSel(ir_node *block, ir_node *store,
2077                                   ir_node *objptr, ir_entity *ent);
2078
2079 /** Constructor for a Sel node.
2080  *
2081  * The select node selects an entity (field or method) from an entity
2082  * with a compound type.  It explicitly specifies the entity selected.
2083  * Dynamically the node may select entities that overwrite the given
2084  * entity.  If the selected entity is an array element entity the Sel
2085  * node takes the required array indices as inputs.
2086  *
2087  * @param *block     The IR block the node belongs to.
2088  * @param *store     The memory in which the object the entity should be selected
2089  *                   from is allocated.
2090  * @param *objptr    A pointer to a compound entity the Sel operation selects a
2091  *                   single attribute from.
2092  * @param *n_index   The number of array indices needed to select an array element entity.
2093  * @param *index[]   If the compound entity is an array the indices of the selected
2094  *                   element entity.  The constructor copies this array.
2095  * @param *ent       The entity to select.
2096  */
2097 FIRM_API ir_node *new_r_Sel(ir_node *block, ir_node *store,
2098                             ir_node *objptr, int n_index, ir_node *index[],
2099                             ir_entity *ent);
2100
2101 /** Constructor for a Call node.
2102  *
2103  * Represents all kinds of method and function calls.
2104  *
2105  * @param *block  The IR block the node belongs to.
2106  * @param *store  The actual store.
2107  * @param *callee A pointer to the called procedure.
2108  * @param arity   The number of procedure parameters.
2109  * @param *in[]   An array with the pointers to the parameters. The constructor copies this array.
2110  * @param *tp     Type information of the procedure called.
2111  */
2112 FIRM_API ir_node *new_r_Call(ir_node *block, ir_node *store,
2113                              ir_node *callee, int arity, ir_node *in[],
2114                              ir_type *tp);
2115
2116 /** Constructor for a Builtin node.
2117  *
2118  * Represents a call of a backend-specific builtin..
2119  *
2120  * @param *block  The IR block the node belongs to.
2121  * @param *store  The actual store.
2122  * @param arity   The number of procedure parameters.
2123  * @param *in[]   An array with the pointers to the parameters. The constructor copies this array.
2124  * @param kind    The kind of the called builtin.
2125  * @param *tp     Type information of the procedure called.
2126  */
2127 FIRM_API ir_node *new_r_Builtin(ir_node *block, ir_node *store,
2128                                 int arity, ir_node *in[], ir_builtin_kind kind,
2129                                 ir_type *tp);
2130
2131 /** Constructor for a Add node.
2132  *
2133  * @param *block The IR block the node belongs to.
2134  * @param *op1   The first operand.
2135  * @param *op2   The second operand.
2136  * @param *mode  The mode of the operands and the result.
2137  */
2138 FIRM_API ir_node *new_r_Add(ir_node *block, ir_node *op1, ir_node *op2,
2139                             ir_mode *mode);
2140
2141 /**
2142  * Constructor for a Sub node.
2143  *
2144  * @param *block The IR block the node belongs to.
2145  * @param *op1   The first operand.
2146  * @param *op2   The second operand.
2147  * @param *mode  The mode of the operands and the results.
2148  */
2149 FIRM_API ir_node *new_r_Sub(ir_node *block, ir_node *op1, ir_node *op2,
2150                             ir_mode *mode);
2151
2152 /** Constructor for a Minus node.
2153  *
2154  * @param *block The IR block the node belongs to.
2155  * @param *op    The operand.
2156  * @param *mode  The mode of the operand and the result.
2157  */
2158 FIRM_API ir_node *new_r_Minus(ir_node *block, ir_node *op, ir_mode *mode);
2159
2160 /** Constructor for a Mul node.
2161  *
2162  * @param *block The IR block the node belongs to.
2163  * @param *op1   The first operand.
2164  * @param *op2   The second operand.
2165  * @param *mode  The mode of the operands and the result.
2166  */
2167 FIRM_API ir_node *new_r_Mul(ir_node *block, ir_node *op1, ir_node *op2,
2168                             ir_mode *mode);
2169
2170 /** Constructor for a Mulh node.
2171  *
2172  * @param *block The IR block the node belongs to.
2173  * @param *op1   The first operand.
2174  * @param *op2   The second operand.
2175  * @param *mode  The mode of the operands and the result.
2176  */
2177 FIRM_API ir_node *new_r_Mulh(ir_node *block, ir_node *op1, ir_node *op2,
2178                              ir_mode *mode);
2179
2180 /** Constructor for a Quot node.
2181  *
2182  * @param *block The IR block the node belongs to.
2183  * @param *memop The store needed to model exceptions
2184  * @param *op1   The first operand.
2185  * @param *op2   The second operand.
2186  * @param *mode  The mode of the result.
2187  * @param state  The pinned state.
2188  */
2189 FIRM_API ir_node *new_r_Quot(ir_node *block, ir_node *memop,
2190                              ir_node *op1, ir_node *op2, ir_mode *mode,
2191                              op_pin_state state);
2192
2193 /** Constructor for a DivMod node.
2194  *
2195  * @param *block The IR block the node belongs to.
2196  * @param *memop The store needed to model exceptions
2197  * @param *op1   The first operand.
2198  * @param *op2   The second operand.
2199  * @param *mode  The mode of the results.
2200  * @param state  The pinned state.
2201  */
2202 FIRM_API ir_node *new_r_DivMod(ir_node *block, ir_node *memop,
2203                                ir_node *op1, ir_node *op2, ir_mode *mode,
2204                                op_pin_state state);
2205
2206 /** Constructor for a Div node.
2207  *
2208  * @param *block The IR block the node belongs to.
2209  * @param *memop The store needed to model exceptions
2210  * @param *op1   The first operand.
2211  * @param *op2   The second operand.
2212  * @param *mode  The mode of the result.
2213  * @param state  The pinned state.
2214  */
2215 FIRM_API ir_node *new_r_Div(ir_node *block, ir_node *memop,
2216                             ir_node *op1, ir_node *op2, ir_mode *mode,
2217                             op_pin_state state);
2218
2219 /** Constructor for a remainderless Div node.
2220  *
2221  * @param *block The IR block the node belongs to.
2222  * @param *memop The store needed to model exceptions
2223  * @param *op1   The first operand.
2224  * @param *op2   The second operand.
2225  * @param *mode  The mode of the result.
2226  * @param state  The pinned state.
2227  */
2228 FIRM_API ir_node *new_r_DivRL(ir_node *block, ir_node *memop,
2229                               ir_node *op1, ir_node *op2, ir_mode *mode,
2230                               op_pin_state state);
2231
2232 /** Constructor for a Mod node.
2233  *
2234  * @param *block The IR block the node belongs to.
2235  * @param *memop The store needed to model exceptions
2236  * @param *op1   The first operand.
2237  * @param *op2   The second operand.
2238  * @param *mode  The mode of the result.
2239  * @param state  The pinned state.
2240  */
2241 FIRM_API ir_node *new_r_Mod(ir_node *block, ir_node *memop,
2242                             ir_node *op1, ir_node *op2, ir_mode *mode,
2243                             op_pin_state state);
2244
2245 /** Constructor for a And node.
2246  *
2247  * @param *block The IR block the node belongs to.
2248  * @param *op1   The first operand.
2249  * @param *op2   The second operand.
2250  * @param *mode  The mode of the operands and the result.
2251  */
2252 FIRM_API ir_node *new_r_And(ir_node *block, ir_node *op1, ir_node *op2,
2253                             ir_mode *mode);
2254
2255 /** Constructor for a Or node.
2256  *
2257  * @param *block The IR block the node belongs to.
2258  * @param *op1   The first operand.
2259  * @param *op2   The second operand.
2260  * @param *mode  The mode of the operands and the result.
2261  */
2262 FIRM_API ir_node *new_r_Or(ir_node *block, ir_node *op1, ir_node *op2,
2263                            ir_mode *mode);
2264
2265 /** Constructor for a Eor node.
2266  *
2267  * @param *block The IR block the node belongs to.
2268  * @param *op1   The first operand.
2269  * @param *op2   The second operand.
2270  * @param *mode  The mode of the operands and the results.
2271  */
2272 FIRM_API ir_node *new_r_Eor(ir_node *block, ir_node *op1, ir_node *op2,
2273                             ir_mode *mode);
2274
2275 /** Constructor for a Not node.
2276  *
2277  * @param *block The IR block the node belongs to.
2278  * @param *op    The operand.
2279  * @param *mode  The mode of the operand and the result.
2280  */
2281 FIRM_API ir_node *new_r_Not(ir_node *block, ir_node *op, ir_mode *mode);
2282
2283 /** Constructor for a Cmp node.
2284  *
2285  * @param *block The IR block the node belongs to.
2286  * @param *op1   The first operand.
2287  * @param *op2   The second operand.
2288  */
2289 FIRM_API ir_node *new_r_Cmp(ir_node *block, ir_node *op1, ir_node *op2);
2290
2291 /** Constructor for a Shl node.
2292  *
2293  * @param   *block The IR block the node belongs to.
2294  * @param   *op    The operand.
2295  * @param   *k     The number of bits to  shift the operand .
2296  * @param   *mode  The mode of the operand and the result.
2297  */
2298 FIRM_API ir_node *new_r_Shl(ir_node *block, ir_node *op, ir_node *k,
2299                             ir_mode *mode);
2300
2301 /** Constructor for a Shr node.
2302  *
2303  * @param *block The IR block the node belongs to.
2304  * @param *op    The operand.
2305  * @param *k     The number of bits to shift the operand .
2306  * @param *mode  The mode of the operand and the result.
2307  */
2308 FIRM_API ir_node *new_r_Shr(ir_node *block, ir_node *op, ir_node *k,
2309                             ir_mode *mode);
2310
2311 /**
2312  * Constructor for a Shrs node.
2313  *
2314  * @param  *block The IR block the node belongs to.
2315  * @param  *op    The operand.
2316  * @param  *k     The number of bits to shift the operand.
2317  * @param  *mode  The mode of the operand and the result.
2318  */
2319 FIRM_API ir_node *new_r_Shrs(ir_node *block, ir_node *op, ir_node *k,
2320                              ir_mode *mode);
2321
2322 /** Constructor for a Rotl node.
2323  *
2324  * @param *block The IR block the node belongs to.
2325  * @param *op    The operand.
2326  * @param *k     The number of bits to rotate the operand.
2327  * @param *mode  The mode of the operand.
2328  */
2329 FIRM_API ir_node *new_r_Rotl(ir_node *block, ir_node *op, ir_node *k,
2330                              ir_mode *mode);
2331
2332 /** Constructor for a Conv node.
2333  *
2334  * @param *block The IR block the node belongs to.
2335  * @param *op    The operand.
2336  * @param *mode  The mode of this the operand muss be converted .
2337  */
2338 FIRM_API ir_node *new_r_Conv(ir_node *block, ir_node *op, ir_mode *mode);
2339
2340 /** Constructor for a strict Conv node.
2341  *
2342  * @param *block The IR block the node belongs to.
2343  * @param *op    The operand.
2344  * @param *mode  The mode of this the operand muss be converted .
2345  */
2346 FIRM_API ir_node *new_r_strictConv(ir_node *block, ir_node *op, ir_mode *mode);
2347
2348 /** Constructor for a Cast node.
2349  *
2350  * High level type cast
2351  *
2352  * @param *block The IR block the node belongs to.
2353  * @param *op    The operand.
2354  * @param *to_tp The type of this the operand muss be casted .
2355  */
2356 FIRM_API ir_node *new_r_Cast(ir_node *block, ir_node *op, ir_type *to_tp);
2357
2358 /** Constructor for a Carry node.
2359  *
2360  * @param *block The IR block the node belongs to.
2361  * @param *op1   The first operand.
2362  * @param *op2   The second operand.
2363  * @param *mode  The mode of the operands and the result.
2364  */
2365 FIRM_API ir_node *new_r_Carry(ir_node *block, ir_node *op1, ir_node *op2,
2366                               ir_mode *mode);
2367
2368 /**
2369  * Constructor for a Borrow node.
2370  *
2371  * @param *block The IR block the node belongs to.
2372  * @param *op1   The first operand.
2373  * @param *op2   The second operand.
2374  * @param *mode  The mode of the operands and the results.
2375  */
2376 FIRM_API ir_node *new_r_Borrow(ir_node *block, ir_node *op1, ir_node *op2,
2377                                ir_mode *mode);
2378
2379 /** Constructor for a Phi node.
2380  *
2381  * @param *block The IR block the node belongs to.
2382  * @param arity  The number of predecessors
2383  * @param *in[]  Array with predecessors. The constructor copies this array.
2384  * @param *mode  The mode of it's inputs and output.
2385  */
2386 FIRM_API ir_node *new_r_Phi(ir_node *block, int arity, ir_node *in[],
2387                             ir_mode *mode);
2388
2389 /** Constructor for a Load node.
2390  *
2391  * @param *block The IR block the node belongs to.
2392  * @param *store The current memory
2393  * @param *adr   A pointer to the variable to be read in this memory.
2394  * @param *mode  The mode of the value to be loaded.
2395  * @param  flags Additional flags for alignment, volatility and pin state.
2396  */
2397 FIRM_API ir_node *new_r_Load(ir_node *block, ir_node *store,
2398                              ir_node *adr, ir_mode *mode, ir_cons_flags flags);
2399
2400 /** Constructor for a Store node.
2401  *
2402  * @param *block The IR block the node belongs to.
2403  * @param *store The current memory
2404  * @param *adr   A pointer to the variable to be read in this memory.
2405  * @param *val   The value to write to this variable.
2406  * @param  flags Additional flags for alignment, volatility and pin state.
2407  */
2408 FIRM_API ir_node *new_r_Store(ir_node *block, ir_node *store,
2409                               ir_node *adr, ir_node *val, ir_cons_flags flags);
2410
2411 /** Constructor for a Alloc node.
2412  *
2413  * The Alloc node extends the memory by space for an entity of type alloc_type.
2414  *
2415  * @param *block      The IR block the node belongs to.
2416  * @param *store      The memory which shall contain the new variable.
2417  * @param *count      The number of objects to allocate.
2418  * @param *alloc_type The type of the allocated variable.
2419  * @param where       Where to allocate the variable, either heap_alloc or stack_alloc.
2420  */
2421 FIRM_API ir_node *new_r_Alloc(ir_node *block, ir_node *store,
2422                               ir_node *count, ir_type *alloc_type,
2423                               ir_where_alloc where);
2424
2425 /** Constructor for a Free node.
2426  *
2427  * Frees the memory occupied by the entity pointed to by the pointer
2428  * arg.  Type indicates the type of the entity the argument points to.
2429  *
2430  * @param *block      The IR block the node belongs to.
2431  * @param *store      The memory which shall contain the new variable.
2432  * @param *ptr        The pointer to the object to free.
2433  * @param *size       The number of objects of type free_type to free in a sequence.
2434  * @param *free_type  The type of the freed variable.
2435  * @param where       Where the variable was allocated, either heap_alloc or stack_alloc.
2436  */
2437 FIRM_API ir_node *new_r_Free(ir_node *block, ir_node *store, ir_node *ptr,
2438                              ir_node *size, ir_type *free_type,
2439                              ir_where_alloc where);
2440
2441 /** Constructor for a Sync node.
2442  *
2443  * Merges several memory values.  The node assumes that a variable
2444  * either occurs only in one of the memories, or it contains the same
2445  * value in all memories where it occurs.
2446  *
2447  * @param *block   The IR block the node belongs to.
2448  * @param arity    The number of memories to synchronize.
2449  * @param *in[]    An array of pointers to nodes that produce an output of  type memory.
2450  *                 The constructor copies this array.
2451  */
2452 FIRM_API ir_node *new_r_Sync(ir_node *block, int arity, ir_node *in[]);
2453
2454 /** Constructor for a Proj node.
2455  *
2456  * Projects a single value out of a tuple.  The parameter proj gives the
2457  * position of the value within the tuple.
2458  *
2459  * @param arg    A node producing a tuple.
2460  * @param mode   The mode of the value to project.
2461  * @param proj   The position of the value in the tuple.
2462  */
2463 FIRM_API ir_node *new_r_Proj(ir_node *arg, ir_mode *mode, long proj);
2464
2465 /** Constructor for a defaultProj node.
2466  *
2467  * Represents the default control flow of a Switch-Cond node.
2468  *
2469  * @param arg       A node producing a tuple.
2470  * @param max_proj  The end  position of the value in the tuple.
2471  */
2472 FIRM_API ir_node *new_r_defaultProj(ir_node *arg, long max_proj);
2473
2474
2475 /** Constructor for a Tuple node.
2476  *
2477  * This is an auxiliary node to replace a node that returns a tuple
2478  * without changing the corresponding Proj nodes.
2479  *
2480  * @param *block  The IR block the node belongs to.
2481  * @param arity   The number of tuple elements.
2482  * @param *in[]   An array containing pointers to the nodes producing the tuple elements.
2483  *                The constructor copies this array.
2484  */
2485 FIRM_API ir_node *new_r_Tuple(ir_node *block, int arity, ir_node *in[]);
2486
2487 /** Constructor for a Id node.
2488  *
2489  * This is an auxiliary node to replace a node that returns a single
2490  * value.
2491  *
2492  * @param *block  The IR block the node belongs to.
2493  * @param *val    The operand to Id.
2494  * @param *mode   The mode of *val.
2495  */
2496 FIRM_API ir_node *new_r_Id(ir_node *block, ir_node *val, ir_mode *mode);
2497
2498 /** Constructor for a Bad node.
2499  *
2500  * Returns the unique Bad node of the graph.  The same as
2501  * get_irg_bad().
2502  *
2503  * @param *irg    The IR graph the node  belongs to.
2504  */
2505 FIRM_API ir_node *new_r_Bad(ir_graph *irg);
2506
2507 /** Constructor for a Confirm node.
2508  *
2509  * Specifies constraints for a value.  To support dataflow analyses.
2510  *
2511  * Example: If the value never exceeds '100' this is expressed by placing a
2512  * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
2513  *
2514  * @param *block  The IR block the node belong to.
2515  * @param *val    The value we express a constraint for
2516  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
2517  * @param cmp     The compare operation.
2518  */
2519 FIRM_API ir_node *new_r_Confirm(ir_node *block, ir_node *val, ir_node *bound,
2520                                 pn_Cmp cmp);
2521
2522 /** Constructor for a Unknown node.
2523  *
2524  * Represents an arbitrary value.  Places the node in
2525  * the start block.
2526  *
2527  * @param *irg    The IR graph the node  belongs to.
2528  * @param *m      The mode of the unknown value.
2529  */
2530 FIRM_API ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2531
2532 /** Constructor for a NoMem node.
2533  *
2534  * Returns the unique NoMem node of the graph.  The same as
2535  * get_irg_no_mem().
2536  *
2537  * @param *irg    The IR graph the node belongs to.
2538  */
2539 FIRM_API ir_node *new_r_NoMem(ir_graph *irg);
2540
2541 /** Constructor for a Mux node.
2542  *
2543  * @param *block    The block the node belong to.
2544  * @param *sel      The ir_node that calculates the boolean select.
2545  * @param *ir_true  The ir_node that calculates the true result.
2546  * @param *ir_false The ir_node that calculates the false result.
2547  * @param *mode     The mode of the node (and it_true and ir_false).
2548  */
2549 FIRM_API ir_node *new_r_Mux(ir_node *block, ir_node *sel,
2550                             ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2551
2552 /** Constructor for a CopyB node.
2553  *
2554  * @param *block      The block the node belong to.
2555  * @param *store      The current memory
2556  * @param *dst        The ir_node that represents the destination address.
2557  * @param *src        The ir_node that represents the source address.
2558  * @param *data_type  The type of the copied data
2559  */
2560 FIRM_API ir_node *new_r_CopyB(ir_node *block, ir_node *store,
2561                               ir_node *dst, ir_node *src, ir_type *data_type);
2562
2563 /** Constructor for a InstOf node.
2564  *
2565  * A High-Level Type check.
2566  *
2567  * @param *block     The block the node belong to.
2568  * @param *store     The memory in which the object the entity should be selected
2569  *                   from is allocated.
2570  * @param *objptr    A pointer to a object of a class type.
2571  * @param *type      The type of which objptr must be.
2572  */
2573 FIRM_API ir_node *new_r_InstOf(ir_node *block, ir_node *store,
2574                                ir_node *objptr, ir_type *type);
2575
2576 /** Constructor for a Raise node.
2577  *
2578  * A High-Level Exception throw.
2579  *
2580  * @param *block The IR block the node belongs to.
2581  * @param *store The current memory.
2582  * @param *obj   A pointer to the Except variable.
2583  */
2584 FIRM_API ir_node *new_r_Raise(ir_node *block, ir_node *store, ir_node *obj);
2585
2586 /** Constructor for a Bound node.
2587  *
2588  * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
2589  *
2590  * @param *block      The block the node belong to.
2591  * @param *store      The current memory.
2592  * @param *idx        The ir_node that represents an index.
2593  * @param *lower      The ir_node that represents the lower bound for the index.
2594  * @param *upper      The ir_node that represents the upper bound for the index.
2595  */
2596 FIRM_API ir_node *new_r_Bound(ir_node *block, ir_node *store,
2597                               ir_node *idx, ir_node *lower, ir_node *upper);
2598
2599 /** Constructor for a Pin node.
2600  *
2601  * @param *block      The block the node belong to.
2602  * @param *node       The node which value should be pinned.
2603  */
2604 FIRM_API ir_node *new_r_Pin(ir_node *block, ir_node *node);
2605
2606 /** Constructor for an ASM pseudo node.
2607  *
2608  * @param *block      The block the node belong to.
2609  * @param arity       The number of data inputs to the node.
2610  * @param *in         The array of length arity of data inputs.
2611  * @param *inputs     The array of length arity of input constraints.
2612  * @param n_outs      The number of data outputs to the node.
2613  * @param *outputs    The array of length n_outs of output constraints.
2614  * @param n_clobber   The number of clobbered registers.
2615  * @param *clobber    The array of length n_clobber of clobbered registers.
2616  * @param *asm_text   The assembler text.
2617  */
2618 FIRM_API ir_node *new_r_ASM(ir_node *block,
2619                             int arity, ir_node *in[], ir_asm_constraint *inputs,
2620                             int n_outs, ir_asm_constraint *outputs,
2621                             int n_clobber, ident *clobber[], ident *asm_text);
2622
2623 /*-----------------------------------------------------------------------*/
2624 /* The block oriented interface                                          */
2625 /*-----------------------------------------------------------------------*/
2626
2627 /** Sets the current block in which the following constructors place the
2628  *  nodes they construct.
2629  *
2630  *  @param target  The new current block.
2631  */
2632 FIRM_API void set_cur_block(ir_node *target);
2633 FIRM_API void set_r_cur_block(ir_graph *irg, ir_node *target);
2634
2635 /** Returns the current block of the current graph. */
2636 FIRM_API ir_node *get_cur_block(void);
2637 FIRM_API ir_node *get_r_cur_block(ir_graph *irg);
2638
2639 /** Constructor for a Block node.
2640  *
2641  * Adds the block to the graph in current_ir_graph. Constructs a Block
2642  * with a fixed number of predecessors.
2643  *
2644  * @param *db    A Pointer for debug information.
2645  * @param arity  The number of control predecessors.
2646  * @param in[]   An array of control predecessors.  The length of
2647  *               the array must be 'arity'.
2648  */
2649 FIRM_API ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
2650
2651 /** Constructor for a Start node.
2652  *
2653  * Adds the node to the block in current_ir_block.
2654  *
2655  * @param *db    A pointer for debug information.
2656  */
2657 FIRM_API ir_node *new_d_Start(dbg_info *db);
2658
2659 /** Constructor for a End node.
2660  *
2661  * Adds the node to the block in current_ir_block.
2662  *
2663  * @param *db     A pointer for debug information.
2664  */
2665 FIRM_API ir_node *new_d_End(dbg_info *db);
2666
2667 /** Constructor for a Jmp node.
2668  *
2669  * Adds the node to the block in current_ir_block.
2670  *
2671  * Jmp represents control flow to a single control successor.
2672  *
2673  * @param *db     A pointer for debug information.
2674  */
2675 FIRM_API ir_node *new_d_Jmp(dbg_info *db);
2676
2677 /** Constructor for an IJmp node.
2678  *
2679  * IJmp represents control flow to a single control successor not
2680  * statically known i.e. an indirect Jmp.
2681  *
2682  * @param *db     A pointer for debug information.
2683  * @param *tgt    The IR node representing the target address.
2684  */
2685 FIRM_API ir_node *new_d_IJmp(dbg_info *db, ir_node *tgt);
2686
2687 /** Constructor for a Cond node.
2688  *
2689  * Adds the node to the block in current_ir_block.
2690  *
2691  * If c is mode_b represents a conditional branch (if/else). If c is
2692  * mode_Is/mode_Iu (?) represents a switch.  (Allocates dense Cond
2693  * node, default Proj is 0.)
2694  *
2695  * This is not consistent:  Input to Cond is Is, Proj has as proj number
2696  * longs.
2697  *
2698  * @param *db    A pointer for debug information.
2699  * @param *c     The conditions parameter.Can be of mode b or I_u.
2700  */
2701 FIRM_API ir_node *new_d_Cond(dbg_info *db, ir_node *c);
2702
2703 /** Constructor for a Return node.
2704  *
2705  * Adds the node to the block in current_ir_block.
2706  *
2707  * Returns the memory and zero or more return values.  Only node that
2708  * can end regular control flow.
2709  *
2710  * @param *db    A pointer for debug information.
2711  * @param *store The state of memory.
2712  * @param arity  Number of array indices.
2713  * @param *in    Array with index inputs to the node.
2714  */
2715 FIRM_API ir_node *new_d_Return(dbg_info *db, ir_node *store,
2716                                int arity, ir_node *in[]);
2717
2718 /** Constructor for a Const node.
2719  *
2720  * Adds the node to the block in current_ir_block.
2721  *
2722  * Constructor for a Const node. The constant represents a target
2723  * value.  Sets the type information to type_unknown.  (No more
2724  * supported: If tv is entity derives a somehow useful type.)
2725  * Derives mode from passed tarval.
2726  *
2727  * @param *db    A pointer for debug information.
2728  * @param *con   Points to an entry in the constant table. This pointer is added
2729  *               to the attributes of the node.
2730  */
2731 FIRM_API ir_node *new_d_Const(dbg_info *db, tarval *con);
2732
2733 /**
2734  * @see new_rd_Const_long()
2735  *
2736  * @param *db    A pointer for debug information.
2737  * @param *mode  The mode of the operands and results.
2738  * @param value  A value from which the tarval is made.
2739  */
2740 FIRM_API ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value);
2741
2742 /** Constructor for a SymConst node.
2743  *
2744  *  This is the constructor for a symbolic constant.
2745  *    There are several kinds of symbolic constants:
2746  *    - symconst_type_tag   The symbolic constant represents a type tag.  The
2747  *                          type the tag stands for is given explicitly.
2748  *    - symconst_type_size  The symbolic constant represents the size of a type.
2749  *                          The type of which the constant represents the size
2750  *                          is given explicitly.
2751  *    - symconst_type_align The symbolic constant represents the alignment of a
2752  *                          type.  The type of which the constant represents the
2753  *                          size is given explicitly.
2754  *    - symconst_addr_ent   The symbolic constant represents the address of an
2755  *                          entity (variable or method).  The variable is given
2756  *                          explicitly by a firm entity.
2757  *    - symconst_ofs_ent    The symbolic constant represents the offset of an
2758  *                          entity in its owner type.
2759  *    - symconst_enum_const The symbolic constant is a enumeration constant of
2760  *                          an enumeration type.
2761  *
2762  *    Inputs to the node:
2763  *      No inputs except the block it belongs to.
2764  *    Outputs of the node.
2765  *      An unsigned integer (I_u) or a pointer (P).
2766  *
2767  *    Mention union in declaration so that the firmjni generator recognizes that
2768  *    it can not cast the argument to an int.
2769  *
2770  * @param *db     A pointer for debug information.
2771  * @param mode    The mode for the SymConst.
2772  * @param value   A type, ident, entity or enum constant depending on the
2773  *                SymConst kind.
2774  * @param kind    The kind of the symbolic constant, see the list above
2775  */
2776 FIRM_API ir_node *new_d_SymConst(dbg_info *db, ir_mode *mode,
2777                                  union symconst_symbol value,
2778                                  symconst_kind kind);
2779
2780 /** Constructor for a simpleSel node.
2781  *
2782  *  This is a shortcut for the new_d_Sel() constructor.  To be used for
2783  *  Sel nodes that do not select from an array, i.e., have no index
2784  *  inputs.  It adds the two parameters 0, NULL.
2785  *
2786  * @param   *db        A pointer for debug information.
2787  * @param   *store     The memory in which the object the entity should be
2788  *                     selected from is allocated.
2789  * @param   *objptr    The object from that the Sel operation selects a
2790  *                     single attribute out.
2791  * @param   *ent       The entity to select.
2792  */
2793 FIRM_API ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr,
2794                                   ir_entity *ent);
2795
2796 /** Constructor for a Sel node.
2797  *
2798  * The select node selects an entity (field or method) from an entity
2799  * with a compound type.  It explicitly specifies the entity selected.
2800  * Dynamically the node may select entities that overwrite the given
2801  * entity.  If the selected entity is an array element entity the Sel
2802  * node takes the required array indices as inputs.
2803  * Adds the node to the block in current_ir_block.
2804  *
2805  * @param   *db        A pointer for debug information.
2806  * @param   *store     The memory in which the object the entity should be selected
2807  *                     from is allocated.
2808  * @param   *objptr    A pointer to a compound entity the Sel operation selects a
2809  *                     single attribute from.
2810  * @param   arity      The number of array indices needed to select an array element entity.
2811  * @param   *in[]      If the compound entity is an array the indices of the selected
2812  *                     element entity.  The constructor copies this array.
2813  * @param   *ent       The entity to select.
2814  */
2815 FIRM_API ir_node *new_d_Sel(dbg_info *db, ir_node *store, ir_node *objptr,
2816                             int arity, ir_node *in[], ir_entity *ent);
2817
2818 /** Constructor for a Call node.
2819  *
2820  * Represents all kinds of method and function calls.
2821  * Adds the node to the block in current_ir_block.
2822  *
2823  * @param   *db     A pointer for debug information.
2824  * @param   *store  The actual store.
2825  * @param   *callee A pointer to the called procedure.
2826  * @param   arity   The number of procedure parameters.
2827  * @param   *in[]   An array with the pointers to the parameters. The constructor copies this array.
2828  * @param   *tp     Type information of the procedure called.
2829  */
2830 FIRM_API ir_node *new_d_Call(dbg_info *db, ir_node *store, ir_node *callee,
2831                              int arity, ir_node *in[], ir_type *tp);
2832
2833 /** Constructor for a Builtin node.
2834  *
2835  * Represents a call of a backend-specific builtin..
2836  * Adds the node to the block in current_ir_block.
2837  *
2838  * @param   *db     A pointer for debug information.
2839  * @param   *store  The actual store.
2840  * @param   arity   The number of procedure parameters.
2841  * @param   *in[]   An array with the pointers to the parameters. The constructor copies this array.
2842  * @param   kind    The kind of the called builtin.
2843  * @param   *tp     Type information of the procedure called.
2844  */
2845 FIRM_API ir_node *new_d_Builtin(dbg_info *db, ir_node *store,
2846                                 int arity, ir_node *in[],
2847                                 ir_builtin_kind kind, ir_type *tp);
2848
2849 /** Constructor for a Add node.
2850  *
2851  * Adds the node to the block in current_ir_block.
2852  *
2853  * @param   *db    A pointer for debug information.
2854  * @param   *op1   The first operand.
2855  * @param   *op2   The second operand.
2856  * @param   *mode  The mode of the operands and the result.
2857  */
2858 FIRM_API ir_node *new_d_Add(dbg_info *db, ir_node *op1, ir_node *op2,
2859                             ir_mode *mode);
2860
2861 /** Constructor for a Sub node.
2862  *
2863  * Adds the node to the block in current_ir_block.
2864  *
2865  * @param   *db    A pointer for debug information.
2866  * @param   *op1   The first operand.
2867  * @param   *op2   The second operand.
2868  * @param   *mode  The mode of the operands and the result.
2869  */
2870 FIRM_API ir_node *new_d_Sub(dbg_info *db, ir_node *op1, ir_node *op2,
2871                             ir_mode *mode);
2872
2873 /** Constructor for a Minus node.
2874  *
2875  * Adds the node to the block in current_ir_block.
2876  *
2877  * @param   *db    A pointer for debug information.
2878  * @param   *op    The operand .
2879  * @param   *mode  The mode of the operand and the result.
2880  */
2881 FIRM_API ir_node *new_d_Minus(dbg_info *db, ir_node *op,  ir_mode *mode);
2882
2883 /** Constructor for a Mul node.
2884  *
2885  * Adds the node to the block in current_ir_block.
2886  *
2887  * @param   *db    A pointer for debug information.
2888  * @param   *op1   The first operand.
2889  * @param   *op2   The second operand.
2890  * @param   *mode  The mode of the operands and the result.
2891  */
2892 FIRM_API ir_node *new_d_Mul(dbg_info *db, ir_node *op1, ir_node *op2,
2893                             ir_mode *mode);
2894
2895 /** Constructor for a Mulh node.
2896  *
2897  * Adds the node to the block in current_ir_block.
2898  *
2899  * @param   *db    A pointer for debug information.
2900  * @param   *op1   The first operand.
2901  * @param   *op2   The second operand.
2902  * @param   *mode  The mode of the operands and the result.
2903  */
2904 FIRM_API ir_node *new_d_Mulh(dbg_info *db, ir_node *op1, ir_node *op2,
2905                              ir_mode *mode);
2906
2907 /** Constructor for a Quot node.
2908  *
2909  * Adds the node to the block in current_ir_block.
2910  *
2911  * @param   *db    A pointer for debug information.
2912  * @param   *memop The store needed to model exceptions
2913  * @param   *op1   The first operand.
2914  * @param   *op2   The second operand.
2915  * @param   *mode  The mode of the result.
2916  * @param   state  The pinned state.
2917  */
2918 FIRM_API ir_node *new_d_Quot(dbg_info *db, ir_node *memop,
2919                              ir_node *op1, ir_node *op2, ir_mode *mode,
2920                              op_pin_state state);
2921
2922 /** Constructor for a DivMod node.
2923  *
2924  * Adds the node to the block in current_ir_block.
2925  *
2926  * @param   *db    A pointer for debug information.
2927  * @param   *memop The store needed to model exceptions
2928  * @param   *op1   The first operand.
2929  * @param   *op2   The second operand.
2930  * @param   *mode  The mode of the results.
2931  * @param   state  The pinned state.
2932  */
2933 FIRM_API ir_node *new_d_DivMod(dbg_info *db, ir_node *memop, ir_node *op1,
2934                                ir_node *op2, ir_mode *mode, op_pin_state state);
2935
2936 /** Constructor for a Div node.
2937  *
2938  * Adds the node to the block in current_ir_block.
2939  *
2940  * @param   *db    A pointer for debug information.
2941  * @param   *memop The store needed to model exceptions
2942  * @param   *op1   The first operand.
2943  * @param   *op2   The second operand.
2944  * @param   *mode  The mode of the result.
2945  * @param   state  The pinned state.
2946  */
2947 FIRM_API ir_node *new_d_Div(dbg_info *db, ir_node *memop, ir_node *op1,
2948                             ir_node *op2, ir_mode *mode, op_pin_state state);
2949
2950 /** Constructor for a remainderless Div node.
2951  *
2952  * Adds the node to the block in current_ir_block.
2953  *
2954  * @param   *db    A pointer for debug information.
2955  * @param   *memop The store needed to model exceptions
2956  * @param   *op1   The first operand.
2957  * @param   *op2   The second operand.
2958  * @param   *mode  The mode of the result.
2959  * @param   state  The pinned state.
2960  */
2961 FIRM_API ir_node *new_d_DivRL(dbg_info *db, ir_node *memop,
2962                               ir_node *op1, ir_node *op2, ir_mode *mode,
2963                               op_pin_state state);
2964
2965 /** Constructor for a Mod node.
2966  *
2967  * Adds the node to the block in current_ir_block.
2968  *
2969  * @param   *db    A pointer for debug information.
2970  * @param   *memop The store needed to model exceptions
2971  * @param   *op1   The first operand.
2972  * @param   *op2   The second operand.
2973  * @param   *mode  The mode of the result.
2974  * @param   state  The pinned state.
2975  */
2976 FIRM_API ir_node *new_d_Mod(dbg_info *db, ir_node *memop,
2977                             ir_node *op1, ir_node *op2, ir_mode *mode,
2978                             op_pin_state state);
2979
2980 /** Constructor for a And node.
2981  *
2982  * Adds the node to the block in current_ir_block.
2983  *
2984  * @param   *db    A pointer for debug information.
2985  * @param   *op1   The first operand.
2986  * @param   *op2   The second operand.
2987  * @param   *mode  The mode of the operands and the result.
2988  */
2989 FIRM_API ir_node *new_d_And(dbg_info *db, ir_node *op1, ir_node *op2,
2990                             ir_mode *mode);
2991
2992 /** Constructor for a Or node.
2993  *
2994  * Adds the node to the block in current_ir_block.
2995  *
2996  * @param   *db    A pointer for debug information.
2997  * @param   *op1   The first operand.
2998  * @param   *op2   The second operand.
2999  * @param   *mode  The mode of the operands and the result.
3000  */
3001 FIRM_API ir_node *new_d_Or(dbg_info *db, ir_node *op1, ir_node *op2,
3002                            ir_mode *mode);
3003
3004 /** Constructor for a Eor node.
3005  *
3006  * Adds the node to the block in current_ir_block.
3007  *
3008  * @param   *db    A pointer for debug information.
3009  * @param   *op1   The first operand.
3010  * @param   *op2   The second operand.
3011  * @param   *mode  The mode of the operands and the results.
3012  */
3013 FIRM_API ir_node *new_d_Eor(dbg_info *db, ir_node *op1, ir_node *op2,
3014                             ir_mode *mode);
3015
3016 /** Constructor for a Not node.
3017  *
3018  * Adds the node to the block in current_ir_block.
3019  *
3020  * @param   *db    A pointer for debug information.
3021  * @param   *op    The operand.
3022  * @param   *mode  The mode of the operand and the result.
3023  */
3024 FIRM_API ir_node *new_d_Not(dbg_info *db, ir_node *op, ir_mode *mode);
3025
3026 /** Constructor for a Shl node.
3027  *
3028  * Adds the node to the block in current_ir_block.
3029  *
3030  * @param   *db    A pointer for debug information.
3031  * @param   *op    The operand.
3032  * @param   *k     The number of bits to  shift the operand .
3033  * @param   *mode  The mode of the operand and the result.
3034  */
3035 FIRM_API ir_node *new_d_Shl(dbg_info *db, ir_node *op, ir_node *k,
3036                             ir_mode *mode);
3037
3038 /** Constructor for a Shr node.
3039  *
3040  * Adds the node to the block in current_ir_block.
3041  *
3042  * @param   *db    A pointer for debug information.
3043  * @param   *op    The operand.
3044  * @param   *k     The number of bits to  shift the operand .
3045  * @param   *mode  The mode of the operand and the result.
3046  */
3047 FIRM_API ir_node *new_d_Shr(dbg_info *db, ir_node *op, ir_node *k,
3048                             ir_mode *mode);
3049
3050 /** Constructor for a Shrs node.
3051  *
3052  * Adds the node to the block in current_ir_block.
3053  *
3054  * @param   *db    A pointer for debug information.
3055  * @param   *op    The operand.
3056  * @param   *k     The number of bits to  shift the operand .
3057  * @param   *mode  The mode of the operand and the result.
3058  */
3059 FIRM_API ir_node *new_d_Shrs(dbg_info *db, ir_node *op, ir_node *k,
3060                              ir_mode *mode);
3061
3062 /** Constructor for a Rotl node.
3063  *
3064  * Adds the node to the block in current_ir_block.
3065  *
3066  * @param   *db    A pointer for debug information.
3067  * @param   *op    The operand.
3068  * @param   *k     The number of bits to rotate the operand.
3069  * @param   *mode  The mode of the operand.
3070  */
3071 FIRM_API ir_node *new_d_Rotl(dbg_info *db, ir_node *op, ir_node *k,
3072                              ir_mode *mode);
3073
3074 /** Constructor for a Cmp node.
3075  *
3076  * Adds the node to the block in current_ir_block.
3077  *
3078  * @param   *db    A pointer for debug information.
3079  * @param   *op1   The first operand.
3080  * @param   *op2   The second operand.
3081  */
3082 FIRM_API ir_node *new_d_Cmp(dbg_info *db, ir_node *op1, ir_node *op2);
3083
3084 /** Constructor for a Conv node.
3085  *
3086  * Adds the node to the block in current_ir_block.
3087  *
3088  * @param   *db    A pointer for debug information.
3089  * @param   *op    The operand.
3090  * @param   *mode  The mode of this the operand muss be converted .
3091  */
3092 FIRM_API ir_node *new_d_Conv(dbg_info *db, ir_node *op, ir_mode *mode);
3093
3094 /** Constructor for a strict Conv node.
3095  *
3096  * Adds the node to the block in current_ir_block.
3097  *
3098  * @param   *db    A pointer for debug information.
3099  * @param   *op    The operand.
3100  * @param   *mode  The mode of this the operand muss be converted .
3101  */
3102 FIRM_API ir_node *new_d_strictConv(dbg_info *db, ir_node *op, ir_mode *mode);
3103
3104 /** Constructor for a Cast node.
3105  *
3106  * High level type cast
3107  * Adds the node to the block in current_ir_block.
3108  *
3109  * @param   *db    A pointer for debug information.
3110  * @param   *op    The operand.
3111  * @param   *to_tp The type of this the operand muss be casted .
3112  */
3113 FIRM_API ir_node *new_d_Cast(dbg_info *db, ir_node *op, ir_type *to_tp);
3114
3115 /** Constructor for a Carry node.
3116  *
3117  * Adds the node to the block in current_ir_block.
3118  *
3119  * @param   *db    A pointer for debug information.
3120  * @param   *op1   The first operand.
3121  * @param   *op2   The second operand.
3122  * @param   *mode  The mode of the operands and the result.
3123  */
3124 FIRM_API ir_node *new_d_Carry(dbg_info *db, ir_node *op1, ir_node *op2,
3125                               ir_mode *mode);
3126
3127 /** Constructor for a Borrow node.
3128  *
3129  * Adds the node to the block in current_ir_block.
3130  *
3131  * @param   *db    A pointer for debug information.
3132  * @param   *op1   The first operand.
3133  * @param   *op2   The second operand.
3134  * @param   *mode  The mode of the operands and the result.
3135  */
3136 FIRM_API ir_node *new_d_Borrow(dbg_info *db, ir_node *op1, ir_node *op2,
3137                                ir_mode *mode);
3138
3139 /** Constructor for a Phi node.
3140  *
3141  * Adds the node to the block in current_ir_block.
3142  *
3143  * @param *db    A pointer for debug information.
3144  * @param arity  The number of predecessors
3145  * @param *in    Array with predecessors
3146  * @param *mode  The mode of it's inputs and output.
3147  */
3148 FIRM_API ir_node *new_d_Phi(dbg_info *db, int arity, ir_node *in[],
3149                             ir_mode *mode);
3150
3151 /** Constructor for a Load node.
3152  *
3153  * Adds the node to the block in current_ir_block.
3154  *
3155  * @param *db    A pointer for debug information.
3156  * @param *store The current memory
3157  * @param *addr  A pointer to the variable to be read in this memory.
3158  * @param *mode  The mode of the value to be loaded.
3159  * @param  flags Additional flags for alignment, volatility and pin state.
3160  */
3161 FIRM_API ir_node *new_d_Load(dbg_info *db, ir_node *store, ir_node *addr,
3162                              ir_mode *mode, ir_cons_flags flags);
3163
3164 /** Constructor for a Store node.
3165  *
3166  * Adds the node to the block in current_ir_block.
3167  *
3168  * @param *db    A pointer for debug information.
3169  * @param *store The current memory
3170  * @param *addr  A pointer to the variable to be read in this memory.
3171  * @param *val   The value to write to this variable.
3172  * @param  flags Additional flags for alignment, volatility and pin state.
3173  */
3174 FIRM_API ir_node *new_d_Store(dbg_info *db, ir_node *store, ir_node *addr,
3175                               ir_node *val, ir_cons_flags flags);
3176
3177 /** Constructor for a Alloc node.
3178  *
3179  * The Alloc node extends the memory by space for an entity of type alloc_type.
3180  * Adds the node to the block in current_ir_block.
3181  *
3182  * @param *db         A pointer for debug information.
3183  * @param *store      The memory which shall contain the new variable.
3184  * @param *count      The number of objects to allocate.
3185  * @param *alloc_type The type of the allocated variable.
3186  * @param where       Where to allocate the variable, either heap_alloc or stack_alloc.
3187  */
3188 FIRM_API ir_node *new_d_Alloc(dbg_info *db, ir_node *store, ir_node *count,
3189                               ir_type *alloc_type, ir_where_alloc where);
3190
3191  /** Constructor for a Free node.
3192  *
3193  * Frees the memory occupied by the entity pointed to by the pointer
3194  * arg.  Type indicates the type of the entity the argument points to.
3195  * Adds the node to the block in current_ir_block.
3196  *
3197  * @param *db         A pointer for debug information.
3198  * @param *store      The memory which shall contain the new variable.
3199  * @param *ptr        The pointer to the object to free.
3200  * @param *size       The number of objects of type free_type to free in a sequence.
3201  * @param *free_type  The type of the freed variable.
3202  * @param where       Where the variable was allocated, either heap_alloc or stack_alloc.
3203  */
3204 FIRM_API ir_node *new_d_Free(dbg_info *db, ir_node *store, ir_node *ptr,
3205                              ir_node *size, ir_type *free_type,
3206                              ir_where_alloc where);
3207
3208 /** Constructor for a Sync node.
3209  *
3210  * Merges several memory values.  The node assumes that a variable
3211  * either occurs only in one of the memories, or it contains the same
3212  * value in all memories where it occurs.
3213  * Adds the node to the block in current_ir_block.
3214  *
3215  * @param *db       A pointer for debug information.
3216  * @param  arity    The number of memories to synchronize.
3217  * @param  **in     An array of pointers to nodes that produce an output of type
3218  *                  memory.  The constructor copies this array.
3219  */
3220 FIRM_API ir_node *new_d_Sync(dbg_info *db, int arity, ir_node *in[]);
3221
3222 /** Constructor for a Proj node.
3223  *
3224  * Projects a single value out of a tuple.  The parameter proj gives the
3225  * position of the value within the tuple.
3226  * Adds the node to the block in current_ir_block.
3227  *
3228  * @param *db    A pointer for deubug information.
3229  * @param arg    A node producing a tuple.
3230  * @param *mode  The mode of the value to project.
3231  * @param proj   The position of the value in the tuple.
3232  */
3233 FIRM_API ir_node *new_d_Proj(dbg_info *db, ir_node *arg, ir_mode *mode,
3234                              long proj);
3235
3236 /** Constructor for a defaultProj node.
3237  *
3238  * Represents the default control flow of a Switch-Cond node.
3239  * Adds the node to the block in current_ir_block.
3240  *
3241  * @param *db       A pointer for debug information.
3242  * @param arg       A node producing a tuple.
3243  * @param max_proj  The end  position of the value in the tuple.
3244  */
3245 FIRM_API ir_node *new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
3246
3247 /** Constructor for a Tuple node.
3248  *
3249  * This is an auxiliary node to replace a node that returns a tuple
3250  * without changing the corresponding Proj nodes.
3251  * Adds the node to the block in current_ir_block.
3252  *
3253  * @param *db     A pointer for debug information.
3254  * @param arity   The number of tuple elements.
3255  * @param **in    An array containing pointers to the nodes producing the tuple elements.
3256  */
3257 FIRM_API ir_node *new_d_Tuple(dbg_info *db, int arity, ir_node *in[]);
3258
3259 /** Constructor for a Id node.
3260  *
3261  * This is an auxiliary node to replace a node that returns a single
3262  * value. Adds the node to the block in current_ir_block.
3263  *
3264  * @param *db     A pointer for debug information.
3265  * @param *val    The operand to Id.
3266  * @param *mode   The mode of *val.
3267  */
3268 FIRM_API ir_node *new_d_Id(dbg_info *db, ir_node *val, ir_mode *mode);
3269
3270 /** Constructor for a Confirm node.
3271  *
3272  * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3273  * Specifies constraints for a value.  To support dataflow analyses.
3274  *
3275  * Example: If the value never exceeds '100' this is expressed by placing a
3276  * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
3277  *
3278  * @param *db     A pointer for debug information.
3279  * @param *val    The value we express a constraint for
3280  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
3281  * @param cmp     The compare operation.
3282  */
3283 FIRM_API ir_node *new_d_Confirm(dbg_info *db, ir_node *val, ir_node *bound,
3284                                 pn_Cmp cmp);
3285
3286 /** Constructor for an Unknown node.
3287  *
3288  * Represents an arbitrary value.  Places the node in
3289  * the start block.
3290  *
3291  * @param *db     A pointer for debug information.
3292  * @param *m      The mode of the unknown value.
3293  */
3294 FIRM_API ir_node *new_d_Unknown(dbg_info *db, ir_mode *m);
3295
3296 /** Constructor for a Mux node.
3297  *
3298  * @param *db       A pointer for debug information.
3299  * @param *sel      The ir_node that calculates the boolean select.
3300  * @param *ir_true  The ir_node that calculates the true result.
3301  * @param *ir_false The ir_node that calculates the false result.
3302  * @param *mode     The mode of the node (and it_true and ir_false).
3303  */
3304 FIRM_API ir_node *new_d_Mux(dbg_info *db, ir_node *sel,
3305                             ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3306
3307 /** Constructor for a CopyB node.
3308  *
3309  * @param *db         A pointer for debug information.
3310  * @param *store      The current memory
3311  * @param *dst        The ir_node that represents the destination address.
3312  * @param *src        The ir_node that represents the source address.
3313  * @param *data_type  The type of the copied data
3314  */
3315 FIRM_API ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst,
3316                               ir_node *src, ir_type *data_type);
3317
3318 /** Constructor for a InstOf node.
3319  *
3320  * A High-Level Type check.
3321  *
3322  * @param   *db        A pointer for debug information.
3323  * @param   *store     The memory in which the object the entity should be selected
3324  *                     from is allocated.
3325  * @param   *objptr    A pointer to a object of a class type.
3326  * @param   *type      The type of which objptr must be.
3327  */
3328 FIRM_API ir_node *new_d_InstOf(dbg_info *db, ir_node *store, ir_node *objptr,
3329                                ir_type *type);
3330
3331 /** Constructor for a Raise node.
3332  *
3333  * A High-Level Exception throw.
3334  *
3335  * @param *db    A pointer for debug information.
3336  * @param *store The current memory.
3337  * @param *obj   A pointer to the Except variable.
3338  */
3339 FIRM_API ir_node *new_d_Raise(dbg_info *db, ir_node *store, ir_node *obj);
3340
3341 /** Constructor for a Bound node.
3342  *
3343  * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
3344  *
3345  * @param *db         A pointer for debug information.
3346  * @param *store      The current memory
3347  * @param *idx        The ir_node that represents an index.
3348  * @param *lower      The ir_node that represents the lower bound for the index.
3349  * @param *upper      The ir_node that represents the upper bound for the index.
3350  */
3351 FIRM_API ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx,
3352                               ir_node *lower, ir_node *upper);
3353
3354 /** Constructor for a Pin node.
3355  *
3356  * @param *db         A pointer for debug information.
3357  * @param *node       The node which value should be pinned.
3358  */
3359 FIRM_API ir_node *new_d_Pin(dbg_info *db, ir_node *node);
3360
3361 /** Constructor for an ASM pseudo node.
3362  *
3363  * @param *db         A pointer for debug information.
3364  * @param arity       The number of data inputs to the node.
3365  * @param *in         The array of length arity of data inputs.
3366  * @param *inputs     The array of length arity of input constraints.
3367  * @param n_outs      The number of data outputs to the node.
3368  * @param *outputs    The array of length n_outs of output constraints.
3369  * @param n_clobber   The number of clobbered registers.
3370  * @param *clobber    The array of length n_clobber of clobbered registers.
3371  * @param *asm_text   The assembler text.
3372  */
3373 FIRM_API ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[],
3374                             ir_asm_constraint *inputs,
3375                             int n_outs, ir_asm_constraint *outputs,
3376                             int n_clobber, ident *clobber[], ident *asm_text);
3377
3378 /*-----------------------------------------------------------------------*/
3379 /* The block oriented interface without debug support                    */
3380 /*-----------------------------------------------------------------------*/
3381
3382 /** Constructor for a Block node.
3383  *
3384  * Constructor for a Block node. Adds the block to the graph in
3385  * current_ir_graph. Constructs a Block with a fixed number of predecessors.
3386  *
3387  * @param arity  The number of control predecessors.
3388  * @param in     An array of control predecessors.  The length of
3389  *               the array must be 'arity'.
3390  */
3391 FIRM_API ir_node *new_Block(int arity, ir_node *in[]);
3392
3393 /** Constructor for a Start node.
3394  *
3395  * Adds the node to the block in current_ir_block.
3396  *
3397  */
3398 FIRM_API ir_node *new_Start(void);
3399
3400 /** Constructor for an End node.
3401  *
3402  * Adds the node to the block in current_ir_block.
3403  */
3404 FIRM_API ir_node *new_End(void);
3405
3406 /** Constructor for a Jump node.
3407  *
3408  * Adds the node to the block in current_ir_block.
3409  *
3410  * Jmp represents control flow to a single control successor.
3411  */
3412 FIRM_API ir_node *new_Jmp(void);
3413
3414 /** Constructor for an IJmp node.
3415  *
3416  * IJmp represents control flow to a single control successor not
3417  * statically known i.e. an indirect Jmp.
3418  *
3419  * @param *tgt    The IR node representing the target address.
3420  */
3421 FIRM_API ir_node *new_IJmp(ir_node *tgt);
3422
3423 /** Constructor for a Cond node.
3424  *
3425  * If c is mode_b represents a conditional branch (if/else). If c is
3426  * mode_Is/mode_Iu (?) represents a switch.  (Allocates dense Cond
3427  * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3428  *
3429  * This is not consistent:  Input to Cond is Is, Proj has as proj number
3430  * longs.
3431  *
3432  *
3433  * @param *c     The conditions parameter.Can be of mode b or I_u.
3434  */
3435 FIRM_API ir_node *new_Cond(ir_node *c);
3436
3437 /** Constructor for a Return node.
3438  *
3439  * Returns the memory and zero or more return values.  Only node that
3440  * can end regular control flow. Adds the node to the block in current_ir_block.
3441  *
3442  * @param *store The state of memory.
3443  * @param arity  Number of array indices.
3444  * @param *in    Array with index inputs to the node.
3445  */
3446 FIRM_API ir_node *new_Return(ir_node *store, int arity, ir_node *in[]);
3447
3448 /** Constructor for a Const node.
3449  *
3450  * Constructor for a Const node. The constant represents a target
3451  * value.  Sets the type information to type_unknown.  (No more
3452  * supported: If tv is entity derives a somehow useful type.)
3453  * Adds the node to the block in current_ir_block.
3454  * Derives mode from passed tarval.
3455  *
3456  * @param *con   Points to an entry in the constant table. This pointer is
3457  *               added to the attributes of  the node.
3458  */
3459 FIRM_API ir_node *new_Const(tarval *con);
3460
3461 /**
3462  * Make a const from a long.
3463  * This is just convenience for the usual
3464  * <code>
3465  * new_Const(mode, tarval_from_long(mode, ...))
3466  * </code>
3467  * pain.
3468  * @param mode The mode for the const.
3469  * @param value The value of the constant.
3470  * @return A new const node.
3471  */
3472 FIRM_API ir_node *new_Const_long(ir_mode *mode, long value);
3473
3474 /** Constructor for a SymConst node.
3475  *
3476  *  This is the constructor for a symbolic constant.
3477  *    There are several kinds of symbolic constants:
3478  *    - symconst_type_tag   The symbolic constant represents a type tag.  The
3479  *                          type the tag stands for is given explicitly.
3480  *    - symconst_type_size  The symbolic constant represents the size of a type.
3481  *                          The type of which the constant represents the size
3482  *                          is given explicitly.
3483  *    - symconst_type_align The symbolic constant represents the alignment of a
3484  *                          type.  The type of which the constant represents the
3485  *                          size is given explicitly.
3486  *    - symconst_addr_ent   The symbolic constant represents the address of an
3487  *                          entity (variable or method).  The variable is given
3488  *                          explicitly by a firm entity.
3489  *    - symconst_ofs_ent    The symbolic constant represents the offset of an
3490  *                          entity in its owner type.
3491  *    - symconst_enum_const The symbolic constant is a enumeration constant of
3492  *                          an enumeration type.
3493  *
3494  *    Inputs to the node:
3495  *      No inputs except the block it belongs to.
3496  *    Outputs of the node.
3497  *      An unsigned integer (I_u) or a pointer (P).
3498  *
3499  *    Mention union in declaration so that the firmjni generator recognizes that
3500  *    it can not cast the argument to an int.
3501  *
3502  * @param mode    The mode for the SymConst.
3503  * @param value   A type, ident, entity or enum constant depending on the
3504  *                SymConst kind.
3505  * @param kind    The kind of the symbolic constant, see the list above
3506  */
3507 FIRM_API ir_node *new_SymConst(ir_mode *mode, union symconst_symbol value,
3508                                symconst_kind kind);
3509
3510 /** Constructor for a simpelSel node.
3511  *
3512  *  This is a shortcut for the new_Sel() constructor.  To be used for
3513  *  Sel nodes that do not select from an array, i.e., have no index
3514  *  inputs.  It adds the two parameters 0, NULL.
3515  *
3516  * @param   *store     The memory in which the object the entity should be selected from is allocated.
3517  * @param   *objptr    The object from that the Sel operation selects a single attribute out.
3518  * @param   *ent       The entity to select.
3519  */
3520 FIRM_API ir_node *new_simpleSel(ir_node *store, ir_node *objptr,
3521                                 ir_entity *ent);
3522
3523 /** Constructor for a Sel node.
3524  *
3525  * The select node selects an entity (field or method) from an entity
3526  * with a compound type.  It explicitly specifies the entity selected.
3527  * Dynamically the node may select entities that overwrite the given
3528  * entity.  If the selected entity is an array element entity the Sel
3529  * node takes the required array indices as inputs.
3530  * Adds the node to the block in current_ir_block.
3531  *
3532  * @param   *store     The memory in which the object the entity should be selected
3533  *                     from is allocated.
3534  * @param   *objptr    A pointer to a compound entity the Sel operation selects a
3535  *                     single attribute from.
3536  * @param   arity      The number of array indices needed to select an array element entity.
3537  * @param   *in[]      If the compound entity is an array the indices of the selected
3538  *                     element entity.  The constructor copies this array.
3539  * @param   *ent       The entity to select.
3540  */
3541 FIRM_API ir_node *new_Sel(ir_node *store, ir_node *objptr,
3542                           int arity, ir_node *in[], ir_entity *ent);
3543
3544 /** Constructor for a Call node.
3545  *
3546  * Adds the node to the block in current_ir_block.
3547  * Represents all kinds of method and function calls.
3548  *
3549  * @param   *store  The actual store.
3550  * @param   *callee A pointer to the called procedure.
3551  * @param   arity   The number of procedure parameters.
3552  * @param   *in[]   An array with the pointers to the parameters. The constructor copies this array.
3553  * @param   *tp     Type information of the procedure called.
3554  */
3555 FIRM_API ir_node *new_Call(ir_node *store, ir_node *callee,
3556                            int arity, ir_node *in[], ir_type *tp);
3557
3558 /** Constructor for a Builtin node.
3559  *
3560  * Represents a call of a backend-specific builtin..
3561  * Represents all kinds of method and function calls.
3562  *
3563  * @param   *store  The actual store.
3564  * @param   kind    The kind of the called builtin.
3565  * @param   arity   The number of procedure parameters.
3566  * @param   *in[]   An array with the pointers to the parameters. The constructor copies this array.
3567  * @param   *tp     Type information of the procedure called.
3568  */
3569 FIRM_API ir_node *new_Builtin(ir_node *store, int arity, ir_node *in[],
3570                               ir_builtin_kind kind, ir_type *tp);
3571
3572 /** Constructor for a Add node.
3573  *
3574  * Adds the node to the block in current_ir_block.
3575  *
3576  * @param   *op1   The first operand.
3577  * @param   *op2   The second operand.
3578  * @param   *mode  The mode of the operands and the result.
3579  */
3580 FIRM_API ir_node *new_Add(ir_node *op1, ir_node *op2, ir_mode *mode);
3581
3582 /** Constructor for a Sub node.
3583  *
3584  * Adds the node to the block in current_ir_block.
3585  *
3586  * @param   *op1   The first operand.
3587  * @param   *op2   The second operand.
3588  * @param   *mode  The mode of the operands and the result.
3589  */
3590 FIRM_API ir_node *new_Sub(ir_node *op1, ir_node *op2, ir_mode *mode);
3591
3592 /** Constructor for a Minus node.
3593  *
3594  * Adds the node to the block in current_ir_block.
3595  *
3596  * @param   *op    The operand .
3597  * @param   *mode  The mode of the operand and the result.
3598  */
3599 FIRM_API ir_node *new_Minus(ir_node *op,  ir_mode *mode);
3600
3601 /**
3602  * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3603  *
3604  * @param   *op1   The first operand.
3605  * @param   *op2   The second operand.
3606  * @param   *mode  The mode of the operands and the result.
3607  */
3608 FIRM_API ir_node *new_Mul(ir_node *op1, ir_node *op2, ir_mode *mode);
3609
3610 /**
3611  * Constructor for a Mulh node. Adds the node to the block in current_ir_block.
3612  *
3613  * @param   *op1   The first operand.
3614  * @param   *op2   The second operand.
3615  * @param   *mode  The mode of the operands and the result.
3616  */
3617 FIRM_API ir_node *new_Mulh(ir_node *op1, ir_node *op2, ir_mode *mode);
3618
3619 /** Constructor for a Quot node.
3620  *
3621  * Adds the node to the block in current_ir_block.
3622  *
3623  * @param   *memop The store needed to model exceptions
3624  * @param   *op1   The first operand.
3625  * @param   *op2   The second operand.
3626  * @param   *mode  The mode of the result.
3627  * @param   state  The pinned state.
3628  */
3629 FIRM_API ir_node *new_Quot(ir_node *memop, ir_node *op1, ir_node *op2,
3630                            ir_mode *mode, op_pin_state state);
3631
3632 /** Constructor for a DivMod node.
3633  *
3634  * Adds the node to the block in current_ir_block.
3635  *
3636  * @param   *memop The store needed to model exceptions
3637  * @param   *op1   The first operand.
3638  * @param   *op2   The second operand.
3639  * @param   *mode  The mode of the results.
3640  * @param   state  The pinned state.
3641  */
3642 FIRM_API ir_node *new_DivMod(ir_node *memop, ir_node *op1, ir_node *op2,
3643                              ir_mode *mode, op_pin_state state);
3644
3645 /** Constructor for a Div node.
3646  *
3647  * Adds the node to the block in current_ir_block.
3648  *
3649  * @param   *memop The store needed to model exceptions
3650  * @param   *op1   The first operand.
3651  * @param   *op2   The second operand.
3652  * @param   *mode  The mode of the result.
3653  * @param   state  The pinned state.
3654  */
3655 FIRM_API ir_node *new_Div(ir_node *memop, ir_node *op1, ir_node *op2,
3656                           ir_mode *mode, op_pin_state state);
3657
3658 /** Constructor for a remainderless Div node.
3659  *
3660  * Adds the node to the block in current_ir_block.
3661  *
3662  * @param   *memop The store needed to model exceptions
3663  * @param   *op1   The first operand.
3664  * @param   *op2   The second operand.
3665  * @param   *mode  The mode of the result.
3666  * @param   state  The pinned state.
3667  */
3668 FIRM_API ir_node *new_DivRL(ir_node *memop, ir_node *op1, ir_node *op2,
3669                             ir_mode *mode, op_pin_state state);
3670
3671 /** Constructor for a Mod node.
3672  *
3673  * Adds the node to the block in current_ir_block.
3674  *
3675  * @param   *memop The store needed to model exceptions
3676  * @param   *op1   The first operand.
3677  * @param   *op2   The second operand.
3678  * @param   *mode  The mode of the result.
3679  * @param   state  The pinned state.
3680  */
3681 FIRM_API ir_node *new_Mod(ir_node *memop, ir_node *op1, ir_node *op2,
3682                           ir_mode *mode, op_pin_state state);
3683
3684 /** Constructor for a And node.
3685  *
3686  * Adds the node to the block in current_ir_block.
3687  *
3688  * @param   *op1   The first operand.
3689  * @param   *op2   The second operand.
3690  * @param   *mode  The mode of the operands and the result.
3691  */
3692 FIRM_API ir_node *new_And(ir_node *op1, ir_node *op2, ir_mode *mode);
3693
3694 /**
3695  * Constructor for a Or node. Adds the node to the block in current_ir_block.
3696  *
3697  * @param   *op1   The first operand.
3698  * @param   *op2   The second operand.
3699  * @param   *mode  The mode of the operands and the result.
3700  */
3701 FIRM_API ir_node *new_Or(ir_node *op1, ir_node *op2, ir_mode *mode);
3702
3703 /**
3704  * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3705  *
3706  * @param   *op1   The first operand.
3707  * @param   *op2   The second operand.
3708  * @param   *mode  The mode of the operands and the results.
3709  */
3710 FIRM_API ir_node *new_Eor(ir_node *op1, ir_node *op2, ir_mode *mode);
3711
3712 /** Constructor for a Not node.
3713  *
3714  * Adds the node to the block in current_ir_block.
3715  *
3716  * @param   *op    The operand.
3717  * @param   *mode  The mode of the operand and the result.
3718  */
3719 FIRM_API ir_node *new_Not(ir_node *op, ir_mode *mode);
3720
3721 /** Constructor for a Shl node.
3722  *
3723  * Adds the node to the block in current_ir_block.
3724  *
3725  * @param   *op    The operand.
3726  * @param   *k     The number of bits to  shift the operand .
3727  * @param   *mode  The mode of the operand and the result.
3728  */
3729 FIRM_API ir_node *new_Shl(ir_node *op, ir_node *k, ir_mode *mode);
3730
3731 /**
3732  * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3733  *
3734  * @param   *op    The operand.
3735  * @param   *k     The number of bits to  shift the operand .
3736  * @param   *mode  The mode of the operand and the result.
3737  */
3738 FIRM_API ir_node *new_Shr(ir_node *op, ir_node *k, ir_mode *mode);
3739
3740 /** Constructor for a Shrs node.
3741  *
3742  * Adds the node to the block in current_ir_block.
3743  *
3744  * @param   *op    The operand.
3745  * @param   *k     The number of bits to  shift the operand .
3746  * @param   *mode  The mode of the operand and the result.
3747  */
3748 FIRM_API ir_node *new_Shrs(ir_node *op, ir_node *k, ir_mode *mode);
3749
3750 /** Constructor for a Rotl node.
3751  *
3752  * Adds the node to the block in current_ir_block.
3753  *
3754  * @param   *op    The operand.
3755  * @param   *k     The number of bits to rotate the operand.
3756  * @param   *mode  The mode of the operand.
3757  */
3758 FIRM_API ir_node *new_Rotl(ir_node *op, ir_node *k, ir_mode *mode);
3759
3760 /** Constructor for a Cmp node.
3761  *
3762  * Adds the node to the block in current_ir_block.
3763  *
3764  * @param   *op1   The first operand.
3765  * @param   *op2   The second operand.
3766  */
3767 FIRM_API ir_node *new_Cmp(ir_node *op1, ir_node *op2);
3768
3769 /** Constructor for a Conv node.
3770  *
3771  * Adds the node to the block in current_ir_block.
3772  *
3773  * @param   *op          The operand.
3774  * @param   *mode        The mode of this the operand muss be converted.
3775  */
3776 FIRM_API ir_node *new_Conv(ir_node *op, ir_mode *mode);
3777
3778 /** Constructor for a strict Conv node.
3779  *
3780  * Adds the node to the block in current_ir_block.
3781  *
3782  * @param   *op          The operand.
3783  * @param   *mode        The mode of this the operand muss be converted.
3784  */
3785 FIRM_API ir_node *new_strictConv(ir_node *op, ir_mode *mode);
3786
3787 /** Constructor for a Cast node.
3788  *
3789  * Adds the node to the block in current_ir_block.
3790  * High level type cast
3791  *
3792  * @param   *op    The operand.
3793  * @param   *to_tp The type of this the operand muss be casted .
3794  */
3795 FIRM_API ir_node *new_Cast(ir_node *op, ir_type *to_tp);
3796
3797 /** Constructor for a Carry node.
3798  *
3799  * Adds the node to the block in current_ir_block.
3800  *
3801  * @param   *op1   The first operand.
3802  * @param   *op2   The second operand.
3803  * @param   *mode  The mode of the operands and the result.
3804  */
3805 FIRM_API ir_node *new_Carry(ir_node *op1, ir_node *op2, ir_mode *mode);
3806
3807 /** Constructor for a Borrow node.
3808  *
3809  * Adds the node to the block in current_ir_block.
3810  *
3811  * @param   *op1   The first operand.
3812  * @param   *op2   The second operand.
3813  * @param   *mode  The mode of the operands and the result.
3814  */
3815 FIRM_API ir_node *new_Borrow(ir_node *op1, ir_node *op2, ir_mode *mode);
3816
3817 /** Constructor for a Phi node.
3818  *
3819  * Adds the node to the block in current_ir_block.
3820  *
3821  * @param arity  The number of predecessors.
3822  * @param *in    Array with predecessors.
3823  * @param *mode  The mode of it's inputs and output.
3824  */
3825 FIRM_API ir_node *new_Phi(int arity, ir_node *in[], ir_mode *mode);
3826
3827 /** Constructor for a Load node.
3828  *
3829  * @param *store  The current memory.
3830  * @param *addr   A pointer to the variable to be read in this memory.
3831  * @param *mode   The mode of the value to be loaded.
3832  * @param  flags  Additional flags for alignment, volatility and pin state.
3833  */
3834 FIRM_API ir_node *new_Load(ir_node *store, ir_node *addr, ir_mode *mode,
3835                            ir_cons_flags flags);
3836
3837 /** Constructor for a Store node.
3838  *
3839  * @param *store  The current memory.
3840  * @param *addr   A pointer to the variable to be read in this memory.
3841  * @param *val    The value to write to this variable.
3842  * @param  flags  Additional flags for alignment, volatility and pin state.
3843  */
3844 FIRM_API ir_node *new_Store(ir_node *store, ir_node *addr, ir_node *val,
3845                             ir_cons_flags flags);
3846
3847 /** Constructor for a Alloc node.
3848  *
3849  * The Alloc node extends the memory by space for an entity of type alloc_type.
3850  * Adds the node to the block in current_ir_block.
3851  *
3852  * @param *store      The memory which shall contain the new variable.
3853  * @param *count      The number of objects to allocate.
3854  * @param *alloc_type The type of the allocated variable.
3855  * @param where       Where to allocate the variable, either heap_alloc or stack_alloc.
3856  */
3857 FIRM_API ir_node *new_Alloc(ir_node *store, ir_node *count, ir_type *alloc_type,
3858                             ir_where_alloc where);
3859
3860 /** Constructor for a Free node.
3861  *
3862  * Frees the memory occupied by the entity pointed to by the pointer
3863  * arg.  Type indicates the type of the entity the argument points to.
3864  * Adds the node to the block in current_ir_block.
3865  *
3866  * @param *store      The memory which shall contain the new variable.
3867  * @param *ptr        The pointer to the object to free.
3868  * @param *size       The number of objects of type free_type to free in a sequence.
3869  * @param *free_type  The type of the freed variable.
3870  * @param where       Where the variable was allocated, either heap_alloc or stack_alloc.
3871  */
3872 FIRM_API ir_node *new_Free(ir_node *store, ir_node *ptr, ir_node *size,
3873                            ir_type *free_type, ir_where_alloc where);
3874
3875 /** Constructor for a Sync node.
3876  *
3877  * Merges several memory values.  The node assumes that a variable
3878  * either occurs only in one of the memories, or it contains the same
3879  * value in all memories where it occurs.
3880  * Adds the node to the block in current_ir_block.
3881  *
3882  * @param  arity    The number of memories to synchronize.
3883  * @param  **in     An array of pointers to nodes that produce an output of type
3884  *                  memory.  The constructor copies this array.
3885  */
3886 FIRM_API ir_node *new_Sync(int arity, ir_node *in[]);
3887
3888 /** Constructor for a Proj node.
3889  *
3890  * Projects a single value out of a tuple.  The parameter proj gives the
3891  * position of the value within the tuple.
3892  * Adds the node to the block in current_ir_block.
3893  *
3894  * @param arg    A node producing a tuple.
3895  * @param *mode  The mode of the value to project.
3896  * @param proj   The position of the value in the tuple.
3897  */
3898 FIRM_API ir_node *new_Proj(ir_node *arg, ir_mode *mode, long proj);
3899
3900 /** Constructor for a defaultProj node.
3901  *
3902  * Represents the default control flow of a Switch-Cond node.
3903  * Adds the node to the block in current_ir_block.
3904  *
3905  * @param arg       A node producing a tuple.
3906  * @param max_proj  The end  position of the value in the tuple.
3907  */
3908 FIRM_API ir_node *new_defaultProj(ir_node *arg, long max_proj);
3909
3910 /** Constructor for a Tuple node.
3911  *
3912  * This is an auxiliary node to replace a node that returns a tuple
3913  * without changing the corresponding Proj nodes.
3914  * Adds the node to the block in current_ir_block.
3915  *
3916  * @param arity   The number of tuple elements.
3917  * @param **in    An array containing pointers to the nodes producing the tuple elements.
3918  */
3919 FIRM_API ir_node *new_Tuple(int arity, ir_node *in[]);
3920
3921 /** Constructor for an Id node.
3922  *
3923  * This is an auxiliary node to replace a node that returns a single
3924  * value. Adds the node to the block in current_ir_block.
3925  *
3926  * @param *val    The operand to Id.
3927  * @param *mode   The mode of *val.
3928  */
3929 FIRM_API ir_node *new_Id(ir_node *val, ir_mode *mode);
3930
3931 /** Constructor for a Bad node.
3932  *
3933  * Returns the unique Bad node of the graph.  The same as
3934  * get_irg_bad().
3935  */
3936 FIRM_API ir_node *new_Bad(void);
3937
3938 /** Constructor for a Confirm node.
3939  *
3940  * Specifies constraints for a value.  To support dataflow analyses.
3941  * Adds the node to the block in current_ir_block.
3942  *
3943  * Example: If the value never exceeds '100' this is expressed by placing a
3944  * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
3945  *
3946  * @param *val    The value we express a constraint for
3947  * @param *bound  The value to compare against. Must be a firm node, typically a constant.
3948  * @param cmp     The compare operation.
3949  */
3950 FIRM_API ir_node *new_Confirm(ir_node *val, ir_node *bound, pn_Cmp cmp);
3951
3952 /** Constructor for an Unknown node.
3953  *
3954  * Represents an arbitrary value.  Places the node in
3955  * the start block.
3956  *
3957  * @param *m      The mode of the unknown value.
3958  */
3959 FIRM_API ir_node *new_Unknown(ir_mode *m);
3960
3961 /** Constructor for a NoMem node.
3962  *
3963  * Returns the unique NoMem node of the graph.  The same as
3964  * get_irg_no_mem().
3965  */
3966 FIRM_API ir_node *new_NoMem(void);
3967
3968 /** Constructor for a Mux node.
3969  *
3970  * Adds the node to the block in current_ir_block.
3971  *
3972  * @param *sel      The ir_node that calculates the boolean select.
3973  * @param *ir_true  The ir_node that calculates the true result.
3974  * @param *ir_false The ir_node that calculates the false result.
3975  * @param *mode     The mode of the node (and it_true and ir_false).
3976  */
3977 FIRM_API ir_node *new_Mux(ir_node *sel, ir_node *ir_false, ir_node *ir_true,
3978                           ir_mode *mode);
3979
3980 /** Constructor for a CopyB node.
3981  *
3982  * Adds the node to the block in current_ir_block.
3983  *
3984  * @param *store      The current memory
3985  * @param *dst        The ir_node that represents the destination address.
3986  * @param *src        The ir_node that represents the source address.
3987  * @param *data_type  The type of the copied data
3988  */
3989 FIRM_API ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src,
3990                             ir_type *data_type);
3991
3992 /** Constructor for a InstOf node.
3993  *
3994  * A High-Level Type check.
3995  *
3996  * @param   *store     The memory in which the object the entity should be selected
3997  *                     from is allocated.
3998  * @param   *objptr    A pointer to a object of a class type.
3999  * @param   *type      The type of which objptr must be.
4000  */
4001 FIRM_API ir_node *new_InstOf(ir_node *store, ir_node *objptr, ir_type *type);
4002
4003 /**Constructor for a Raise node.
4004  *
4005  * A High-Level Exception throw.
4006  *
4007  * @param *store The current memory.
4008  * @param *obj   A pointer to the Except variable.
4009  */
4010 FIRM_API ir_node *new_Raise(ir_node *store, ir_node *obj);
4011
4012 /** Constructor for a Bound node.
4013  *
4014  * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
4015  *
4016  * Adds the node to the block in current_ir_block.
4017  *
4018  * @param *store      The current memory
4019  * @param *idx        The ir_node that represents an index.
4020  * @param *lower      The ir_node that represents the lower bound for the index.
4021  * @param *upper      The ir_node that represents the upper bound for the index.
4022  */
4023 FIRM_API ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower,
4024                             ir_node *upper);
4025
4026 /** Constructor for a Pin node.
4027  *
4028  * @param *node       The node which value should be pinned.
4029  */
4030 FIRM_API ir_node *new_Pin(ir_node *node);
4031
4032 /** Constructor for an ASM pseudo node.
4033  *
4034  * @param arity       The number of data inputs to the node.
4035  * @param *in         The array of length arity of data inputs.
4036  * @param *inputs     The array of length arity of input constraints.
4037  * @param n_outs      The number of data outputs to the node.
4038  * @param *outputs    The array of length n_outs of output constraints.
4039  * @param n_clobber   The number of clobbered registers.
4040  * @param *clobber    The array of length n_clobber of clobbered registers.
4041  * @param *asm_text   The assembler text.
4042  */
4043 FIRM_API ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
4044                           int n_outs, ir_asm_constraint *outputs,
4045                           int n_clobber, ident *clobber[], ident *asm_text);
4046
4047 /**
4048  * @brief Constructor for a Dummy node.
4049  *
4050  * @param *db       debug info for the node
4051  * @param *mode     The mode of the node.
4052  * @param *irg      the graph to put the node into
4053  * @returns         the newly created note
4054  */
4055 FIRM_API ir_node *new_rd_Dummy(dbg_info *db, ir_graph *irg, ir_mode *mode);
4056
4057 /**
4058  * @copybrief new_rd_Dummy()
4059  *
4060  * @param *mode     The mode of the node.
4061  * @param *irg      the graph to put the node into
4062  * @returns         the newly created note
4063  */
4064 FIRM_API ir_node *new_r_Dummy(ir_graph *irg, ir_mode *mode);
4065
4066 /**
4067  * @copybrief new_rd_Dummy()
4068  *
4069  * @param *db       debug info for the node
4070  * @param *mode     The mode of the node.
4071  * @returns         the newly created note
4072  */
4073 FIRM_API ir_node *new_d_Dummy(dbg_info *db, ir_mode *mode);
4074
4075 /**
4076  * @copybrief new_rd_Dummy()
4077  *
4078  * @param *mode     The mode of the node.
4079  * @returns         the newly created note
4080  */
4081 FIRM_API ir_node *new_Dummy(ir_mode *mode);
4082
4083 /*---------------------------------------------------------------------*/
4084 /* The comfortable interface.                                          */
4085 /* Supports automatic Phi node construction.                           */
4086 /* All routines of the block oriented interface except new_Block are   */
4087 /* needed also.                                                        */
4088 /*---------------------------------------------------------------------*/
4089
4090 /** Create an immature Block.
4091  *
4092  * An immature Block has an unknown number of predecessors.  Predecessors
4093  * can be added with add_immBlock_pred().  Once all predecessors are
4094  * added the block must be matured.
4095  *
4096  * Adds the block to the graph in current_ir_graph. Can be used with automatic
4097  * Phi node construction.
4098  * This constructor can only be used if the graph is in state_building.
4099  */
4100 FIRM_API ir_node *new_d_immBlock(dbg_info *db);
4101 FIRM_API ir_node *new_immBlock(void);
4102 FIRM_API ir_node *new_r_immBlock(ir_graph *irg);
4103 FIRM_API ir_node *new_rd_immBlock(dbg_info *db, ir_graph *irg);
4104
4105 /** Add a control flow edge to an immature block. */
4106 FIRM_API void add_immBlock_pred(ir_node *immblock, ir_node *jmp);
4107
4108 /** Finalize a Block node, when all control flows are known. */
4109 FIRM_API void mature_immBlock(ir_node *block);
4110
4111 /** Get the current value of a local variable.
4112  *
4113  * Use this function to obtain the last definition of the local variable
4114  * associated with pos.  Pos may not exceed the value passed as n_loc
4115  * to new_ir_graph.  This call automatically inserts Phi nodes.
4116  *
4117  * @param *db    A pointer for debug information.
4118  * @param  pos   The position/id of the local variable.
4119  * @param *mode  The mode of the value to get.
4120  */
4121 FIRM_API ir_node *get_value(int pos, ir_mode *mode);
4122 FIRM_API ir_node *get_r_value(ir_graph *irg, int pos, ir_mode *mode);
4123
4124 /**
4125  * Try to guess the mode of a local variable.
4126  * This is done by recursively going up the control flow graph until
4127  * we find a definition for the variable. The mode of the first found
4128  * definition is returned. NULL in case no definition is found.
4129  *
4130  * @param  pos   The position/id of the local variable.
4131  */
4132 FIRM_API ir_mode *ir_guess_mode(int pos);
4133
4134 /** Remark a new definition of a variable.
4135  *
4136  * Use this function to remember a new definition of the value
4137  * associated with pos. Pos may not exceed the value passed as n_loc
4138  * to new_ir_graph.  This call is needed to automatically inserts Phi
4139  * nodes.
4140  *
4141  * @param  pos   The position/id of the local variable.
4142  * @param *value The new value written to the local variable.
4143  */
4144 FIRM_API void set_value(int pos, ir_node *value);
4145 FIRM_API void set_r_value(ir_graph *irg, int pos, ir_node *value);
4146
4147 /**
4148  * Find the value number for a node in the current block.
4149  *
4150  * @param value  the searched value
4151  *
4152  * @return the value number of the value or -1 if this value has
4153  * no value number in the current block.
4154  */
4155 FIRM_API int find_value(ir_node *value);
4156
4157 /** Get the current memory state.
4158  *
4159  * Use this function to obtain the last definition of the memory
4160  * state.  This call automatically inserts Phi nodes for the memory
4161  * state value.
4162  */
4163 FIRM_API ir_node *get_store(void);
4164 FIRM_API ir_node *get_r_store(ir_graph *irg);
4165
4166 /** Remark a new definition of the memory state.
4167  *
4168  * Use this function to remember a new definition of the memory state.
4169  * This call is needed to automatically inserts Phi nodes.
4170  *
4171  * @param *store The new memory state.
4172  */
4173 FIRM_API void set_store(ir_node *store);
4174 FIRM_API void set_r_store(ir_graph *irg, ir_node *store);
4175
4176 /** keep this node alive even if End is not control-reachable from it
4177  *
4178  * @param ka The node to keep alive.
4179  */
4180 FIRM_API void keep_alive(ir_node *ka);
4181
4182 /* --- initialize and finalize IR construction --- */
4183
4184 /** Puts the graph into state "phase_high" */
4185 FIRM_API void irg_finalize_cons(ir_graph *irg);
4186
4187 /** Puts the program and all graphs into state phase_high.
4188  *
4189  * This also remarks, the construction of types is finished,
4190  * e.g., that no more subtypes will be added.  */
4191 FIRM_API void irp_finalize_cons(void);
4192
4193 FIRM_API void ir_set_uninitialized_local_variable_func(
4194                 uninitialized_local_variable_func_t *func);
4195
4196 #include "end.h"
4197
4198 #endif