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