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