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