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