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