Fixed 'inline' lossage --flo
[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 pocedure.  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  *
45  *    The struct ir_graph
46  *    -------------------
47  *
48  *      This struct contains all information about a procedure.
49  *      It's allocated directly to memory.
50  *
51  *      The fields of ir_graph:
52  *
53  *      *ent             The entity describing this procedure.
54  *
55  *      The beginning and end of a graph:
56  *
57  *      *start_block     This ir_node is the block that contains the unique
58  *                       start node of the procedure.  With it it contains
59  *                       the Proj's on starts results.
60  *                       Further all Const nodes are placed in the start block.
61  *      *start           This ir_node is the unique start node of the procedure.
62  *
63  *      *end_block       This ir_node is the block that contains the unique
64  *                       end node of the procedure.  This block contains no
65  *                       further nodes.
66  *      *end             This ir_node is the unique end node of the procedure.
67  *
68  *      The following nodes are Projs from the start node, held in ir_graph for
69  *      simple access:
70  *
71  *      *frame           The ir_node producing the pointer to the stack frame of
72  *                       the procedure as output.  This is the Proj node on the
73  *                       third output of the start node.  This output of the start
74  *                       node is tagged as pns_frame_base.  In FIRM most lokal
75  *                       variables are modeled as data flow edges.  Static
76  *                       allocated arrays can not be represented as dataflow
77  *                       edges. Therefore FIRM has to represent them in the stack
78  *                       frame.
79  *
80  *      *globals         This models a pointer to a space in the memory where
81  *               _all_ global things are held.  Select from this pointer
82  *               with a Sel node the pointer to a global variable /
83  *               procedure / compiler known function... .
84  *
85  *      *args        The ir_node that produces the arguments of the method as
86  *               it's result.  This is a Proj node on the fourth output of
87  *               the start node.  This output is tagged as pns_args.
88  *
89  *      *bad             The bad node is an auxiliary node. It is needed only once,
90  *                       so there is this globally reachable node.
91  *
92  *      Datastructures that are private to a graph:
93  *
94  *      *obst            An obstack that contains all nodes.
95  *
96  *      *current_block   A pointer to the current block.  Any node created with
97  *                       one of the node constructors (new_<opcode>) are assigned
98  *                       to this block.  It can be set with switch_block(block).
99  *                       Only needed for ir construction.
100  *
101  *      params/n_loc     An int giving the number of local variables in this
102  *               procedure.  This is neede for ir construction. Name will
103  *               be changed.
104  *
105  *      *value_table     This hash table (pset) is used for global value numbering
106  *               for optimizing use in iropt.c.
107  *
108  *      *Phi_in_stack;   a stack needed for automatic Phi construction, needed only
109  *               during ir construction.
110  *
111  *      visited          A int used as flag to traverse the ir_graph.
112  *
113  *      block_visited    A int used as a flag to traverse block nodes in the graph.
114  *
115  *    Three kinds of nodes
116  *    --------------------
117  *
118  *      There are three kinds of nodes known to the ir:  entities,
119  *      types, and ir_nodes
120  *
121  *      + ir_nodes are the actual nodes of the FIRM intermediate representation.
122  *        They represent operations on the data of the program and control flow
123  *        operations.
124  *
125  *      + entity ==> implemented in entity.h
126  *        Refers to a single entity of the compiled program, e.g. a field of a
127  *        class or a method.  If a method or variable can not be assigned to
128  *        a method or class or the like, it is a global object.
129  *
130  *      + types ==> implemented in type.h
131  *        With types type information is represented.  There are several type
132  *        nodes.
133  *
134  *    Implementation of the FIRM operations: ir_node
135  *    ----------------------------------------------
136  *
137  *      Ir_nodes represent operations on the data of the program and control flow
138  *      operations.  Examples of ir_nodes:  Add, Jmp, Cmp
139  *
140  *      FIRM is a dataflow graph.  A dataflow graph is a directed graph,
141  *      so that every node has incoming and outgoing edges.  A node is
142  *      executable if every input at it's incoming edges is available.
143  *      Execution of the dataflow graph is started at the Start node which
144  *      has no incoming edges and ends when the End node executes, even if
145  *      there are still executable or not executed nodes.  (Is this true,
146  *      or must all executable nodes be executed?)  (There are exceptions
147  *      to the dataflow paradigma that all inputs have to be available
148  *      before a node can execute: Phi, Block.  See UKA Techreport
149  *      1999-14.)
150  *
151  *      The implementation of FIRM differs from the view as a dataflow
152  *      graph.  To allow fast traversion of the graph edges are
153  *      implemented as C-pointers.  Inputs to nodes are not ambiguous, the
154  *      results can be used by several other nodes.  Each input can be
155  *      implemented as a single pointer to a predecessor node, outputs
156  *      need to be lists of pointers to successors.  Therefore a node
157  *      contains pointers to it's predecessor so that the implementation is a
158  *      dataflow graph with reversed edges.  It has to be traversed bottom
159  *      up.
160  *
161  *      All nodes of the ir have the same basic structure.  They are
162  *      distinguished by a field containing the opcode.
163  *
164  *      The fields of an ir_node:
165  *
166  *      kind             A firm_kind tag containing k_ir_node.  This is useful for
167  *                       dynamically checking the type of a node.
168  *
169  *      *op              This ir_op gives the opcode as a tag and a string
170  *                       and the number of attributes of an ir_node.  There is
171  *                       one statically allocated struct ir_op for each opcode.
172  *
173  *      *mode            The ir_mode of the operation represented by this firm
174  *                       node.  The mode of the operation is the mode of it's
175  *                       result.  A Firm mode is a datatype as known to the target,
176  *               not a type of the source language.
177  *
178  *      visit            A flag for traversing the ir.
179  *
180  *      **in             An array with pointers to the node's predecessors.
181  *
182  *      *link            A pointer to an ir_node.  With this pointer all Phi nodes
183  *                       are attached to a Block, i.e., a Block points to it's
184  *                       first Phi node, this node points to the second Phi node
185  *                       in the Block and so fourth.  Used in mature_block
186  *                       to find all Phi nodes to be matured.  It's also used to
187  *               annotate a node with a better, optimized version of it.
188  *
189  *      attr             An attr struct containing the attributes of the nodes. The
190  *                       attributes depend on the opcode of the node.  The number
191  *               of these attributes is given in op.
192  *
193  *    The struct ir_op
194  *    ----------------
195  *                       Not yet documented. See irop.h.
196  *
197  *    The struct ir_mode
198  *    ------------------
199  *                       Not yet documented. See irmode.h.
200  *
201  *    GLOBAL VARIABLES -- now also fields of ir_graph.
202  *    ================
203  *
204  *    current_ir_graph   Points to the current ir_graph.  All constructors for
205  *                       nodes add nodes to this graph.
206  *
207  *    ir_visited         An int used as flag to traverse the ir_graph.
208  *
209  *    block_visited      An int used as a flag to traverse block nodes in the
210  *                       graph.
211  *
212  *                       Others not yet documented.
213  *
214  *
215  *
216  *    CONSTRUCTOR FOR IR_GRAPH --> see irgraph.h
217  *    ========================
218  *
219  *
220  *    PROCEDURE TO CONSTRUCT AN IR GRAPH --> see also Firm tutorial
221  *    ==================================
222  *
223  *    This library supplies several interfaces to construct a FIRM graph for
224  *    a program:
225  *    * A "comfortable" interface generating SSA automatically.  Automatically
226  *      computed predecessors of nodes need not be specified in the constructors.
227  *      (new_<Node> constructurs and a set of additional routines.)
228  *    * A less comfortable interface where all predecessors except the block
229  *      an operation belongs to need to be specified.  SSA must be constructed
230  *      by hand.  (new_<Node> constructors and switch_block()).  This interface
231  *      is called "block oriented".  It automatically calles the local optimizations
232  *      for each new node.
233  *    * An even less comfortable interface where the block needs to be specified
234  *      explicitly.  This is called the "raw" interface. (new_r_<Node>
235  *      constructors).  These nodes are not optimized.
236  *
237  *    To use the functionality of the comfortable interface correctly the Front
238  *    End needs to follow certain protocols.  This is explained in the following.
239  *    To build a correct IR with the other interfaces study the semantics of
240  *    the firm node (See tech-reprot UKA 1999-14).  For the construction of
241  *    types and entities see the documentation in those modules.
242  *
243  *    First the Frontend needs to decide which variables and values used in
244  *    a procedure can be represented by dataflow edges.  These are variables
245  *    that need not be saved to memory as they cause no side effects visible
246  *    out of the procedure.  Often these are all compiler generated
247  *    variables and simple local variables of the procedure as integers,
248  *    reals and pointers.  The frontend has to count and number these variables.
249  *
250  *    First an ir_graph needs to be constructed with new_ir_graph.  The
251  *    constructor gets the number of local variables.  The graph is hold in the
252  *    global variable irg.
253  *
254  *    Now the construction of the procedure can start.  Several basic blocks can
255  *    be constructed in parallel, but the code within each block needs to
256  *    be constructed (almost) in program order.
257  *
258  *    A global variable holds the current basic block.  All (non block) nodes
259  *    generated are added to this block.  The current block can be set with
260  *    switch_block(block).  If several blocks are constructed in parallel block
261  *    switches need to be performed constantly.
262  *
263  *    To generate a Block node (with the comfortable interface) it's predecessor
264  *    control flow nodes need not be known.  In case of cyclic control flow these
265  *    can not be known when the block is constructed.  With add_in_edge(block,
266  *    cfnode) predecessors can be added to the block.  If all predecessors are
267  *    added to the block mature_block(b) needs to be called.  Calling mature_block
268  *    early improves the efficiency of the Phi node construction algorithm.
269  *    But if several  blocks are constructed at once, mature_block must only
270  *    be called after performing all set_values and set_stores in the block!
271  *    (See documentation of new_immBlock constructor.)
272  *
273  *    The constructors of arithmetic nodes require that their predecessors
274  *    are mentioned.  Sometimes these are available in the Frontend as the
275  *    predecessors have just been generated by the frontend.  If they are local
276  *    values the predecessors can be obtained from the library with a call to
277  *    get_value(local_val_nr).  (local_val_nr needs to be administered by
278  *    the Frontend.)  A call to get_value triggers the generation of Phi nodes.
279  *    If an arithmetic operation produces a local value this value needs to be
280  *    passed to the library by set_value(node, local_val_nr).
281  *    In straight line code these two operations just remember and return the
282  *    pointer to nodes producing the value.  If the value passes block boundaries
283  *    Phi nodes can be inserted.
284  *    Similar routines exist to manage the Memory operands: set_store and
285  *    get_store.
286  *
287  *    Several nodes produce more than one result.  An example is the Div node.
288  *    Such nodes return tuples of values.  From these individual values can be
289  *    extracted by proj nodes.
290  *
291  *    The following example illustrates the construction of a simple basic block
292  *    with two predecessors stored in variables cf_pred1 and cf_pred2, containing
293  *    the code
294  *      a = a div a;
295  *    and finally jumping to an other block.  The variable a got the local_val_nr
296  *    42 by the frontend.
297  *
298  *    ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
299  *
300  *    this_block = new_immBlock();
301  *    add_in_edge(this_block, cf_pred1);
302  *    add_in_edge(this_block, cf_pred2);
303  *    mature_block(this_block);
304  *    a_val = get_value(42, mode_Iu);
305  *    mem = get_store();
306  *    div = new_Div(mem, a_val, a_val);
307  *    mem = new_Proj(div, mode_M, 0);   * for the numbers for Proj see docu *
308  *    res = new_Proj(div, mode_Iu, 2);
309  *    set_store(mem);
310  *    set_value(res, 42);
311  *    cf_op = new_Jmp();
312  *
313  *    For further information look at the documentation of the nodes and
314  *    constructors and at the paragraph COPING WITH DATA OBJECTS at the
315  *    end of this documentation.
316  *
317  *    The comfortable interface contains the following routines further explained
318  *    below:
319  *
320  *    ir_node *new_immBlock (void);
321  *    ir_node *new_Start    (void);
322  *    ir_node *new_End      (void);
323  *    ir_node *new_Jmp      (void);
324  *    ir_node *new_Cond     (ir_node *c);
325  *    ir_node *new_Return   (ir_node *store, int arity, ir_node **in);
326  *    ir_node *new_Raise    (ir_node *store, ir_node *obj);
327  *    ir_node *new_Const    (ir_mode *mode, tarval *con);
328  *    ir_node *new_SymConst (type_or_id *value, symconst_kind kind);
329 <<<<<<< ircons.h
330  *    ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
331  *    ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity,
332  *                         ir_node **in, entity *ent);
333  *    ir_node *new_InstOf (ir_node *store, ir_node obj, type *ent);
334  *    ir_node *new_Call   (ir_node *store, ir_node *callee, int arity,
335  *                 ir_node **in, type_method *type);
336  *    ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode);
337  *    ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode);
338  *    ir_node *new_Minus  (ir_node *op,  ir_mode *mode);
339  *    ir_node *new_Mul    (ir_node *op1, ir_node *op2, ir_mode *mode);
340  *    ir_node *new_Quot   (ir_node *memop, ir_node *op1, ir_node *op2);
341  *    ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
342  *    ir_node *new_Div    (ir_node *memop, ir_node *op1, ir_node *op2);
343  *    ir_node *new_Mod    (ir_node *memop, ir_node *op1, ir_node *op2);
344  *    ir_node *new_Abs    (ir_node *op,                ir_mode *mode);
345  *    ir_node *new_And    (ir_node *op1, ir_node *op2, ir_mode *mode);
346  *    ir_node *new_Or     (ir_node *op1, ir_node *op2, ir_mode *mode);
347  *    ir_node *new_Eor    (ir_node *op1, ir_node *op2, ir_mode *mode);
348  *    ir_node *new_Not    (ir_node *op,                ir_mode *mode);
349  *    ir_node *new_Shl    (ir_node *op,  ir_node *k,   ir_mode *mode);
350  *    ir_node *new_Shr    (ir_node *op,  ir_node *k,   ir_mode *mode);
351  *    ir_node *new_Shrs   (ir_node *op,  ir_node *k,   ir_mode *mode);
352  *    ir_node *new_Rot    (ir_node *op,  ir_node *k,   ir_mode *mode);
353  *    ir_node *new_Cmp    (ir_node *op1, ir_node *op2);
354  *    ir_node *new_Conv   (ir_node *op, ir_mode *mode);
355  *    ir_node *new_Cast   (ir_node *op, type *to_tp);
356  *    ir_node *new_Load   (ir_node *store, ir_node *addr);
357  *    ir_node *new_Store  (ir_node *store, ir_node *addr, ir_node *val);
358  *    ir_node *new_Alloc  (ir_node *store, ir_node *size, type *alloc_type,
359  *                         where_alloc where);
360  *    ir_node *new_Free   (ir_node *store, ir_node *ptr, ir_node *size,
361  *               type *free_type);
362  *    ir_node *new_Proj   (ir_node *arg, ir_mode *mode, long proj);
363 =======
364  *    ir_node *new_simpleSel(ir_node *store, ir_node *objptr, entity *ent);
365  *    ir_node *new_Sel      (ir_node *store, ir_node *objptr, int arity,
366  *                           ir_node **in, entity *ent);
367  *    ir_node *new_Call     (ir_node *store, ir_node *callee, int arity,
368  *                       ir_node **in, type_method *type);
369  *    ir_node *new_Add      (ir_node *op1, ir_node *op2, ir_mode *mode);
370  *    ir_node *new_Sub      (ir_node *op1, ir_node *op2, ir_mode *mode);
371  *    ir_node *new_Minus    (ir_node *op,  ir_mode *mode);
372  *    ir_node *new_Mul      (ir_node *op1, ir_node *op2, ir_mode *mode);
373  *    ir_node *new_Quot     (ir_node *memop, ir_node *op1, ir_node *op2);
374  *    ir_node *new_DivMod   (ir_node *memop, ir_node *op1, ir_node *op2);
375  *    ir_node *new_Div      (ir_node *memop, ir_node *op1, ir_node *op2);
376  *    ir_node *new_Mod      (ir_node *memop, ir_node *op1, ir_node *op2);
377  *    ir_node *new_Abs      (ir_node *op,                ir_mode *mode);
378  *    ir_node *new_And      (ir_node *op1, ir_node *op2, ir_mode *mode);
379  *    ir_node *new_Or       (ir_node *op1, ir_node *op2, ir_mode *mode);
380  *    ir_node *new_Eor      (ir_node *op1, ir_node *op2, ir_mode *mode);
381  *    ir_node *new_Not      (ir_node *op,                ir_mode *mode);
382  *    ir_node *new_Shl      (ir_node *op,  ir_node *k,   ir_mode *mode);
383  *    ir_node *new_Shr      (ir_node *op,  ir_node *k,   ir_mode *mode);
384  *    ir_node *new_Shrs     (ir_node *op,  ir_node *k,   ir_mode *mode);
385  *    ir_node *new_Rot      (ir_node *op,  ir_node *k,   ir_mode *mode);
386  *    ir_node *new_Cmp      (ir_node *op1, ir_node *op2);
387  *    ir_node *new_Conv     (ir_node *op, ir_mode *mode);
388  *    ir_node *new_Cast     (ir_node *op, type *to_tp);
389  *    ir_node *new_Load     (ir_node *store, ir_node *addr);
390  *    ir_node *new_Store    (ir_node *store, ir_node *addr, ir_node *val);
391  *    ir_node *new_Alloc    (ir_node *store, ir_node *size, type *alloc_type,
392  *                           where_alloc where);
393  *    ir_node *new_Free     (ir_node *store, ir_node *ptr, ir_node *size,
394  *                       type *free_type);
395  *    ir_node *new_Proj     (ir_node *arg, ir_mode *mode, long proj);
396  *    ir_node *new_FuncCall (ir_node *store, ir_node *callee, int arity,
397  *                       ir_node **in, type_method *type);
398  *
399  *    void add_in_edge (ir_node *block, ir_node *jmp);
400  *    void mature_block (ir_node *block);
401  *    void switch_block (ir_node *target);
402  *    ir_node *get_value (int pos, ir_mode *mode);
403  *    void set_value (int pos, ir_node *value);
404  *    ir_node *get_store (void);
405  *    void set_store (ir_node *store);
406  *    keep_alive (ir_node ka)
407  *
408  *    IR_NODES AND CONSTRUCTORS FOR IR_NODES
409  *    =======================================
410  *
411  *    All ir_nodes are defined by a common data structure.  They are distinguished
412  *    by their opcode and differ in the number of their attributes.
413  *
414  *    The constructor for the block node sets current_block to itself.
415  *    Const nodes are always added to the start block.
416  *    All other constructors add the created node to the current_block.
417  *    swich_block(block) allows to set the current block to block.
418  *
419  *    Watch for my inconsistent use of input and predecessor (dataflow view)
420  *    and `the node points to' (implementation view).
421  *
422  *    The following description of the nodes lists four properties them if these
423  *    are of interest:
424  *     - the parameters to the constructor
425  *     - the inputs of the Firm node
426  *     - the outputs of the Firm node
427  *     - attributes to the node
428  *
429  *    ------------
430  *
431  *    ir_node *new_immBlock (void)
432  *    ----------------------------
433  *
434  *    Creates a new block.  Sets current_block to itself.  When a new block is
435  *    created it cannot be known how many predecessors this block will have in the
436  *    control flow graph. Therefore the list of inputs can not be fixed at
437  *    creation.  Predecessors can be added with add_in_edge (block, control flow
438  *    operation).  With every added predecessor the number of inputs to Phi nodes
439  *    also changes.
440  *
441  *    The block can be completed by mature_block(block) if all predecessors are
442  *    known.  If several blocks are built at once, mature_block can only be called
443  *    after set_value has been called for all values that are life at the end
444  *    of the block.  This is necessary so that Phi nodes created by mature_block
445  *    get the right predecessors in case of cyclic dependencies.  If all set_values
446  *    of this block are called after maturing it and before calling get_value
447  *    in some block that is control flow dependent on this block, the construction
448  *    is correct.
449  *
450  *    Example for faulty ir construction:  (draw the graph on a paper and you'll
451  *                                          get it ;-)
452  *
453  *      block_before_loop = new_block();
454  *      set_value(x);
455  *      mature_block(block_before_loop);
456  *      before2header = new_Jmp;
457  *
458  *      loop_header = new_block ();
459  *      header2body - new_Jmp();
460  *
461  *      loop_body = new_block ();
462  *      body2header = new_Jmp();
463  *
464  *      add_in_edge(loop_header, before2header);
465  *      add_in_edge(loop_header, body2header);
466  *      add_in_edge(loop_body, header2body);
467  *
468  *      mature_block(loop_header);
469  *      mature_block(loop_body);
470  *
471  *      get_value(loop_body, x);   // gets the Phi in loop_header
472  *      set_value(loop_header, x); // sets the value the above get_value should
473  *                                 // have returned!!!
474  *
475  *    Mature_block also fixes the number of inputs to the Phi nodes.  Mature_block
476  *    should be called as early as possible, as afterwards the generation of Phi
477  *    nodes is more efficient.
478  *
479  *    Inputs:
480  *      There is an input for each control flow predecessor of the block.
481  *      The input points to an instruction producing an output of type X.
482  *      Possible predecessors:  Start, Jmp, Cond, Raise or Return or any node
483  *      possibly causing an exception.  (Often the real predecessors are Projs.)
484  *    Output:
485  *      Mode BB (R), all nodes belonging to this block should consume this output.
486  *      As they are strict (except Block and Phi node) it is a necessary condition
487  *      that the block node executed before any other node in this block executes.
488  *    Attributes:
489  *      block.matured  Indicates whether the block is mature.
490  *      block.**graph_arr
491  *                      This attribute contains all local values valid in this
492  *                      block. This is needed to build the Phi nodes and removed
493  *                      if the graph is complete.  This field is used by the
494  *              internal construction algorithm and should not be accessed
495  *              from outside.
496  *
497  *
498  *    ir_node *new_Block (int arity, ir_node **in)
499  *    --------------------------------------------
500  *
501  *    Creates a new Block with the given list of predecessors.  This block
502  *    is mature.  As other constructors calls optimization and vrfy for the
503  *    block.  If one of the predecessors is Unknown (as it has to be filled in
504  *    later) optimizations are skipped.  This is necessary to
505  *    construct Blocks in loops.  Leaving Unknown in the Block after finishing
506  *    the construction may have strange effects, especially for interprocedural
507  *    representation and analyses.
508  *
509  *
510  *    CONTROL FLOW OPERATIONS
511  *    -----------------------
512  *
513  *    In each block there must be exactly one of the control flow
514  *    operations Start, End, Jmp, Cond, Return or Raise.  The output of a
515  *    control flow operation points to the block to be executed next.
516  *
517  *    ir_node *new_Start (void)
518  *    -------------------------
519  *
520  *    Creates a start node.  Not actually needed public.  There is only one such
521  *    node in each procedure which is automatically created by new_ir_graph.
522  *
523  *    Inputs:
524  *      No inputs except the block it belogns to.
525  *    Output:
526  *      A tuple of 4 (5, 6) distinct values. These are labeled by the following
527  *      projection numbers (pns_number):
528  *      * pns_initial_exec
529  *                       mode X, points to the first block to be executed.
530  *      * pns_global_store
531  *                       mode M, the global store
532  *      * pns_frame_base mode P, a pointer to the base of the procedures
533  *                       stack frame.
534  *      * pns_globals    mode P, a pointer to the part of the memory containing
535  *                               _all_ global things.
536  *      * pns_args       mode T, a tuple containing all arguments of the procedure.
537  *
538  *
539  *    ir_node *new_End (void)
540  *    -----------------------
541  *
542  *    Creates an end node.  Not actually needed public.  There is only one such
543  *    node in each procedure which is automatically created by new_ir_graph.
544  *
545  *    Inputs:
546  *      No inputs except the block it belongs to.
547  *    Output:
548  *      No output.
549  *
550  *    ir_node *new_Jmp (void)
551  *    -----------------------
552  *
553  *    Creates a Jmp node.
554  *
555  *    Inputs:
556  *      The block the node belongs to
557  *    Output:
558  *      Control flow to the next block.
559  *
560  *    ir_node *new_Cond (ir_node *c)
561  *    ------------------------------
562  *
563  *    Creates a Cond node.  There are two versions of this node.
564  *
565  *    The Boolean Cond:
566  *    Input:
567  *      A value of mode b.
568  *    Output:
569  *      A tuple of two control flows.  The first is taken if the input is
570  *      false, the second if it is true.
571  *
572  *    The Switch Cond:
573  *    Input:
574  *      A value of mode I_u. (i)
575  *    Output:
576  *      A tuple of n control flows.  If the Cond's input is i, control
577  *      flow will procede along output i. If the input is >= n control
578  *      flow proceeds along output n.
579  *
580  *    ir_node *new_Return (in_node *store, int arity, ir_node **in)
581  *    -------------------------------------------------------------
582  *
583  *    The return node has as inputs the results of the procedure.  It
584  *    passes the control flow to the end_block.
585  *
586  *    Inputs:
587  *      The memory state.
588  *      All results.
589  *    Output
590  *      Control flow to the end block.
591  *
592  *    ir_node *new_Raise (ir_node *store, ir_node *obj)
593  *    -------------------------------------------------
594  *
595  *    Raises an exception.  Unconditional change of control flow.  Writes
596  *    an explicit Except variable to memory to pass it to the exception
597  *    handler.  See TechReport 1999-14, chapter Exceptions.
598  *
599  *    Inputs:
600  *      The memory state.
601  *      A pointer to the Except variable.
602  *    Output:
603  *      A tuple of control flow and the changed memory state.  The control flow
604  *      points to the exception handler if it is definied in this procedure,
605  *      else it points to the end_block.
606  *
607  *
608  *    ---------
609  *
610  *    ir_node *new_Const (ir_mode *mode, tarval *con)
611  *    -----------------------------------------------
612  *
613  *    Creates a constant in the constant table and adds a Const node
614  *    returning this value to the start block.
615  *
616  *    Parameters:
617  *      *mode            The mode of the constant.
618  *      *con             Points to an entry in the constant table.
619  *                       This pointer is added to the attributes of
620  *                       the node (self->attr.con)
621  *    Inputs:
622  *      No inputs except the block it belogns to.
623  *    Output:
624  *      The constant value.
625  *    Attribute:
626  *      attr.con   A tarval* pointer to the proper entry in the constant
627  *                 table.
628  *
629  *    ir_node *new_SymConst (type *tp, symconst_kind kind)
630  *    ------------------------------------------------------------
631  *
632  *    There are three kinds of symbolic constants:
633  *      type_tag  The symbolic constant represents a type tag.
634  *      size      The symbolic constant represents the size of a class.
635  *      link_info Information for the linker, e.g. the name of a global
636  *                variable.
637  *    To represent a pointer to an entity that is represented by an entity
638  *    datastructure don't use
639  *      new_SymConst((type_or_id*)get_entity_ld_ident(ent), linkage_ptr_info);.
640  *    Use a real const instead:
641  *      new_Const(mode_P_mach, tarval_p_from_entity(ent));
642  *    This makes the Constant independent of name changes of the entity due to
643  *    mangling.
644  *
645  *    Parameters
646  *      kind        The kind of the symbolic constant: type_tag, size or link_info.
647  *      *type_or_id Points to the type the tag stands for or to the type
648  *                  whose size is represented by the constant or to an ident
649  *                  representing the linkage info.
650  *
651  *    Inputs:
652  *      No inputs except the block it belogns to.
653  *    Output:
654  *      An unsigned integer (I_u) or a pointer (P).
655  *
656  *    Attributes:
657  *      attr.i.num       The symconst_kind, i.e. one of
658  *                        - type_tag
659  *                        - size
660  *                - linkage_ptr_info
661  *        If the attr.i.num is type_tag or size, the node contains an attribute
662  *      attr.i.*type,    a pointer to a type_class.  The mode of the node is mode_Is.
663  *        if it is linkage_ptr_info it contains
664  *      attr.i.*ptrinfo,  an ident holding information for the linker.  The mode
665  *        of the node is mode_P_mach.
666  *
667  *    ---------------
668  *
669  *    ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel)
670  *    --------------------------------------------------------------------
671  *
672  *
673  *    Selects an entity from a compound type. This entity can be a field or
674  *    a method.
675  *
676  *    Parameters:
677  *      *store     The memory in which the object the entity should be selected
678  *                 from is allocated.
679  *      *frame     The pointer to the object.
680  *      *sel       The entity to select.
681  *
682  *    Inputs:
683  *      The memory containing the object.
684  *      A pointer to the object.
685  *      An unsigned integer.
686  *    Output:
687  *      A pointer to the selected entity.
688  *    Attributes:
689  *      attr.sel   Pointer to the entity
690  *
691  *
692  *    ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
693  *    --------------------------------------------------------------------------
694  *                      entity *sel)
695  *                      ------------
696  *
697  *    Selects a field from an array type.  The entity has as owner the array, as
698  *    type the arrays element type.  The indexes to access an array element are
699  *    given also.
700  *
701  *    Parameters:
702  *      *store     The memory in which the object the entity should be selected from
703  *                 is allocated.
704  *      *frame     The pointer to the object.
705  *      *arity     number of array indexes.
706  *      *in        array with index inputs to the node.
707  *      *sel       The entity to select.
708  *
709  *    Inputs:
710  *      The memory containing the object.
711  *      A pointer to the object.
712  *      As much unsigned integer as there are array expressions.
713  *    Output:
714  *      A pointer to the selected entity.
715  *    Attributes:
716  *      attr.sel   Pointer to the entity
717  *
718  *    The constructors new_Sel and new_simpleSel generate the same ir nodes.
719  *    simpleSel just sets the arity of the index inputs to zero.
720  *
721  *
722  *    ARITHMETIC OPERATIONS
723  *    ---------------------
724  *
725  *    ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
726  *    ----------------------------------------------------------------------------
727  *                       type_method *type)
728  *                       ------------------
729  *
730  *    Creates a procedure call.
731  *
732  *    Parameters
733  *      *store           The actual store.
734  *      *callee          A pointer to the called procedure.
735  *      arity            The number of procedure parameters.
736  *      **in             An array with the pointers to the parameters.
737  *                       The constructor copies this array.
738  *      *type            Type information of the procedure called.
739  *
740  *    Inputs:
741  *      The store, the callee and the parameters.
742  *    Output:
743  *      A tuple containing the eventually changed store and the procedure
744  *      results.
745  *    Attributes:
746  *      attr.call        Contains the type information for the procedure.
747  *
748  *    ir_node *new_FuncCall (ir_node *callee, int arity, ir_node **in, type_method *type)
749  *    -----------------------------------------------------------------------------------
750  *
751  *    Creates a procedure call to a function WITHOUT memory side effects.
752  *    Nodes of this kind are floating in contrast to Call nodes.
753  *    Further, a procedure call with FuncCall cannot raise an exception!
754  *
755  *    Parameters
756  *      *callee          A pointer to the called procedure.
757  *      arity            The number of procedure parameters.
758  *      **in             An array with the pointers to the parameters.
759  *                       The constructor copies this array.
760  *      *type            Type information of the procedure called.
761  *
762  *    Inputs:
763  *      The callee and the parameters.
764  *    Output:
765  *      A tuple containing the procedure results.
766  *    Attributes:
767  *      attr.call        Contains the type information for the procedure.
768  *
769  *    ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
770  *    ------------------------------------------------------------
771  *
772  *    Trivial.
773  *
774  *    ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
775  *    ------------------------------------------------------------
776  *
777  *    Trivial.
778  *
779  *    ir_node *new_Minus (ir_node *op, ir_mode *mode)
780  *    -----------------------------------------------
781  *
782  *    Unary Minus operations on floating point values.
783  *
784  *    ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
785  *    ------------------------------------------------------------
786  *
787  *    Trivial.
788  *
789  *    ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2)
790  *    --------------------------------------------------------------
791  *
792  *    Quot performs exact division of floating point numbers.  It's mode
793  *    is Tuple, the mode of the result must be annotated to the Proj
794  *    that extracts the result of the arithmetic operations.
795  *
796  *    Inputs:
797  *      The store needed to model exceptions and the two operands.
798  *    Output:
799  *      A tuple contaning a memory and a execution for modeling exceptions
800  *      and the result of the arithmetic operation.
801  *
802  *    ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2)
803  *    ----------------------------------------------------------------
804  *
805  *    Performs Div and Mod on interger values.
806  *
807  *    Output:
808  *      A tuple contaning a memory and a execution for modeling exceptions
809  *      and the two result of the arithmetic operations.
810  *
811  *    ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2)
812  *    -------------------------------------------------------------
813  *
814  *    Trivial.
815  *
816  *    ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2)
817  *    -------------------------------------------------------------
818  *
819  *    Trivial.
820  *
821  *    ir_node *new_Abs (ir_node *op, ir_mode *mode)
822  *    ---------------------------------------------
823  *
824  *    Trivial.
825  *
826  *    ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
827  *    ------------------------------------------------------------
828  *
829  *    Trivial.
830  *
831  *    ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
832  *    -----------------------------------------------------------
833  *
834  *    Trivial.
835  *
836  *    ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
837  *    ------------------------------------------------------------
838  *
839  *    Trivial.
840  *
841  *    ir_node *new_Not (ir_node *op, ir_mode *mode)
842  *    ---------------------------------------------
843  *
844  *    This node constructs a constant where all bits are set to one
845  *    and a Eor of this constant and the operator.  This simulates a
846  *    Not operation.
847  *
848  *    ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
849  *    ---------------------------------------------------------
850  *
851  *    Trivial.
852  *
853  *    ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
854  *    ---------------------------------------------------------
855  *
856  *    Logic shift right, i.e., zero extended.
857  *
858  *
859  *    ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
860  *    ----------------------------------------------------------
861  *
862  *    Arithmetic shift right, i.e., sign extended.
863  *
864  *    ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
865  *    ---------------------------------------------------------
866  *
867  *    Rotates the operand to the (right??) by k bits.
868  *
869  *    ir_node *new_Conv (ir_node *op, ir_mode *mode)
870  *    ---------------------------------------------
871  *
872  *    Mode conversion.  For allowed conversions see UKA Tech Report
873  *    1999-14.
874  *
875  *    ir_node *new_Cmp (ir_node *op1, ir_node *op2)
876  *    ---------------------------------------------
877  *
878  *    Input:
879  *      The two values to be compared.
880  *    Output:
881  *      A 16-tuple containing the results of the 16 different comparisons.
882  *      The following is a list giving the comparisons and a projection
883  *      number (pnc_number) to use in Proj nodes to extract the proper result.
884  *        False     false
885  *        Eq        equal
886  *        Lt    less
887  *        Le    less or equal
888  *        Gt    greater
889  *        Ge    greater of equal
890  *        Lg    less or greater
891  *        Leg   less, equal or greater = ordered
892  *        Uo    unordered
893  *        Ue    unordered or equal
894  *        Ul    unordered or less
895  *        Ule   unordered, less or equal
896  *        Ug    unordered or greater
897  *        Uge   unordered, greater or equal
898  *        Ne    unordered, less or greater = not equal
899  *        True  true
900  *
901  *
902  *
903  *    ------------
904  *
905  *    In general, Phi nodes are automaitcally inserted.  In some cases, if
906  *    all predecessors of a block are known, an explicit Phi node constructor
907  *    is needed.  E.g., to construct a FIRM graph for a statement as
908  *      a = (b==c) ? 2 : 5;
909  *
910  *    ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
911  *    ---------------------------------------------------------
912  *
913  *    Creates a Phi node. The in's order has to correspond to the order
914  *    of in's of current_block.  This is not checked by the library!
915  *    If one of the predecessors is Unknown (as it has to be filled in
916  *    later) optimizations are skipped.  This is necessary to
917  *    construct Phi nodes in loops.  Leaving Unknown in the Phi after finishing
918  *    the construction may have strange effects, especially for interprocedural
919  *    representation and analyses.
920  *
921  *    Parameter
922  *      arity            number of predecessors
923  *      **in             array with predecessors
924  *      *mode            The mode of it's inputs and output.
925  *    Inputs:
926  *      A Phi node has as many inputs as the block it belongs to.
927  *      Each input points to a definition of the same value on a
928  *      different path in the control flow.
929  *    Output
930  *      The definition valid in this block.
931  *
932  *
933  *    OPERATIONS TO MANAGE MEMORY EXPLICITLY
934  *    --------------------------------------
935  *
936  *    ir_node *new_Load (ir_node *store, ir_node *addr)
937  *    ----------------------------------------------------------------
938  *
939  *    The Load operation reads a value from memory.
940  *
941  *    Parameters:
942  *    *store        The current memory.
943  *    *addr         A pointer to the variable to be read in this memory.
944  *
945  *    Inputs:
946  *      The memory and a pointer to a variable in this memory.
947  *    Output:
948  *      A tuple of the memory, a control flow to be taken in case of
949  *      an exception and the loaded value.
950  *
951  *    ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
952  *    ----------------------------------------------------------------
953  *
954  *    The Store operation writes a value to a variable in memory.
955  *
956  *    Inputs:
957  *      The memory, a pointer to a variable in this memory and the value
958  *      to write to this variable.
959  *    Output:
960  *      A tuple of the changed memory and a control flow to be taken in
961  *      case of an exception.
962  *
963  *    ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
964  *    --------------------------------------------------------------------
965  *                        where_alloc where)
966  *                        ------------------
967  *
968  *    The Alloc node allocates a new variable.  It can be specified whether the
969  *    variable should be allocated to the stack or to the heap.
970  *
971  *    Parameters:
972  *      *store       The memory which shall contain the new variable.
973  *      **    *size        The number of bytes to allocate. Old. **
974  *      *size        We decided that the size easily can be derived from the type.
975  *                   This field is for allocating arrays, i.e., it gives the multiple
976  *           of the size of alloc_type to allocate memory for.
977  *      *alloc_type  The type of the allocated variable.
978  *      where        Where to allocate the variable, either heap_alloc or stack_alloc.
979  *
980  *    Inputs:
981  *      A memory and an unsigned integer.
982  *    Output:
983  *      A tuple of the changed memory, a control flow to be taken in
984  *      case of an exception and the pointer to the new variable.
985  *    Attributes:
986  *      a.where          Indicates where the variable is allocated.
987  *      a.*type          A pointer to the class the allocated data object
988  *                       belongs to.
989  *
990  *    ir_node *new_Free (ir_node *store, ir_node *ptr, type *free_type)
991  *    ------------------------------------------------------------------
992  *
993  *    The Free node frees memory of the given variable.
994  *
995  *    Parameters:
996  *      *store       The memory which shall contain the new variable.
997  *      *ptr         The pointer to the object to free.
998  *      *size        The number of objects of type free_type to free in a sequence.
999  *      *free_type   The type of the freed variable.
1000  *
1001  *    Inputs:
1002  *      A memory, a pointer and an unsigned integer.
1003  *    Output:
1004  *      The changed memory.
1005  *    Attributes:
1006  *      f.*type          A pointer to the type information of the freed data object.
1007  *
1008  *    Not Implemented!
1009  *
1010  *    ir_node *new_Sync (int arity, ir_node **in)
1011  *    -------------------------------------------
1012  *
1013  *    The Sync operation unifies several partial memory blocks.  These blocks
1014  *    have to be pairwise disjunct or the values in common locations have to
1015  *    be identical.  This operation allows to specify all operations that eventually
1016  *    need several partial memory blocks as input with a single entrance by
1017  *    unifying the memories with a preceding Sync operation.
1018  *
1019  *    Parameters
1020  *      arity    The number of memories to syncronize.
1021  *      **in     An array of pointers to nodes that produce an output of
1022  *               type memory.
1023  *    Inputs
1024  *      Several memories.
1025  *    Output
1026  *      The unified memory.
1027  *
1028  *
1029  *    SPECIAL OPERATIONS
1030  *    ------------------
1031  *
1032  *    ir_node *new_Bad (void)
1033  *    -----------------------
1034  *
1035  *    Returns the unique Bad node current_ir_graph->bad.
1036  *    This node is used to express results of dead code elimination.
1037  *
1038  *    ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
1039  *    ----------------------------------------------------------
1040  *
1041  *    Selects one entry of a tuple.  This is a hidden `fat edge'.
1042  *
1043  *    Parameters
1044  *      *arg      A node producing a tuple.
1045  *      *mode     The mode of the value to project.
1046  *      proj      The position of the value in the tuple.
1047  *    Input:
1048  *      The tuple.
1049  *    Output:
1050  *      The value.
1051  *
1052  *    ir_node *new_Tuple (int arity, ir_node **in)
1053  *    --------------------------------------------
1054  *
1055  *    Builds a Tuple from single values.  This is needed to implement
1056  *    optimizations that remove a node that produced a tuple.  The node can be
1057  *    replaced by the Tuple operation so that the following Proj nodes have not to
1058  *    be changed.  (They are hard to find due to the implementation with pointers
1059  *    in only one direction.)  The Tuple node is smaller than any other
1060  *    node, so that a node can be changed into a Tuple by just changing it's
1061  *    opcode and giving it a new in array.
1062  *
1063  *    Parameters
1064  *      arity    The number of tuple elements.
1065  *      **in     An array containing pointers to the nodes producing the
1066  *               tuple elements.
1067  *
1068  *    ir_node *new_Id (ir_node *val, ir_mode *mode)
1069  *    ---------------------------------------------
1070  *
1071  *    The single output of the Id operation is it's input.  Also needed
1072  *    for optimizations.
1073  *
1074  *
1075  *    COPING WITH DATA OBJECTS
1076  *    ========================
1077  *
1078  *    Two kinds of data objects have to be distinguished for generating
1079  *    FIRM.  First there are local variables other than arrays that are
1080  *    known to be alias free.  Second there are all other data objects.
1081  *    For the first a common SSA representation is built, the second
1082  *    are modeled by saving them to memory.  The memory is treated as
1083  *    a single local variable, the alias problem is hidden in the
1084  *    content of this variable.
1085  *
1086  *    All values known in a Block are listed in the block's attribute,
1087  *    block.**graph_arr which is used to automatically insert Phi nodes.
1088  *    The following two funcions can be used to add a newly computed value
1089  *    to the array, or to get the producer of a value, i.e., the current
1090  *    live value.
1091  *
1092  *    inline void set_value (int pos, ir_node *value)
1093  *    -----------------------------------------------
1094  *
1095  *    Has to be called for every assignment to a local variable.  It
1096  *    adds the value to the array of used values at position pos.  Pos
1097  *    has to be a unique identifier for an entry in the procedure's
1098  *    definition table.  It can be used to access the value again.
1099  *    Requires current_block to be set correctly.
1100  *
1101  *    ir_node *get_value (int pos, ir_mode *mode)
1102  *    -------------------------------------------
1103  *
1104  *    Returns the node defining the value referred to by pos. If the
1105  *    value is not defined in this block a Phi node is generated and
1106  *    all definitions reaching this Phi node are collected.  It can
1107  *    happen that the algorithm allocates an unnecessary Phi node,
1108  *    e.g. if there is only one definition of this value, but this
1109  *    definition reaches the currend block on several different
1110  *    paths.  This Phi node will be eliminated if optimizations are
1111  *    turned on right after it's creation.
1112  *    Requires current_block to be set correctly.
1113  *
1114  *    There are two special routines for the global store:
1115  *
1116  *    inline void set_store (ir_node *store)
1117  *    --------------------------------------
1118  *
1119  *    Adds the store to the array of known values at a reserved
1120  *    position.
1121  *    Requires current_block to be set correctly.
1122  *
1123  *    inline ir_node *get_store (void)
1124  *    --------------------------------
1125  *
1126  *    Returns the node defining the actual store.
1127  *    Requires current_block to be set correctly.
1128  *
1129  *
1130  *    inline void keep_alive (ir_node *ka)
1131  *    ------------------------------------
1132  *
1133  *    Keep this node alive because it is (might be) not in the control
1134  *    flow from Start to End.  Adds the node to the list in the end
1135  *    node.
1136  *
1137  */
1138
1139
1140 # ifndef _IRCONS_H_
1141 # define _IRCONS_H_
1142
1143 # include "firm_common.h"
1144 # include "irgraph.h"
1145 # include "irnode.h"
1146 # include "irmode.h"
1147 # include "entity.h"
1148 # include "tv.h"
1149 # include "type.h"
1150 # include "dbginfo.h"
1151
1152 /*-------------------------------------------------------------------------*/
1153 /* The raw interface                                                       */
1154 /*-------------------------------------------------------------------------*/
1155
1156 /* Constructs a Block with a fixed number of predecessors.
1157    Does not set current_block.  Can not be used with automatic
1158    Phi node construction. */
1159 ir_node *new_rd_Block  (dbg_info *db, ir_graph *irg,  int arity, ir_node *in[]);
1160 ir_node *new_rd_Start  (dbg_info *db, ir_graph *irg, ir_node *block);
1161 ir_node *new_rd_End    (dbg_info *db, ir_graph *irg, ir_node *block);
1162 ir_node *new_rd_Jmp    (dbg_info *db, ir_graph *irg, ir_node *block);
1163 ir_node *new_rd_Cond   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
1164 ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
1165                ir_node *store, int arity, ir_node *in[]);
1166 ir_node *new_rd_Raise  (dbg_info *db, ir_graph *irg, ir_node *block,
1167                ir_node *store, ir_node *obj);
1168 ir_node *new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block,
1169                 ir_mode *mode, tarval *con, type *tp);
1170 ir_node *new_rd_Const  (dbg_info *db, ir_graph *irg, ir_node *block,
1171                ir_mode *mode, tarval *con);
1172 ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
1173                        type_or_id_p value, symconst_kind symkind);
1174 ir_node *new_rd_Sel    (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1175                        ir_node *objptr, int n_index, ir_node *index[],
1176                entity *ent);
1177 ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr, type *ent);
1178 ir_node *new_rd_Call   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1179                ir_node *callee, int arity, ir_node *in[],
1180                type *tp);
1181 ir_node *new_rd_Add    (dbg_info *db, ir_graph *irg, ir_node *block,
1182                ir_node *op1, ir_node *op2, ir_mode *mode);
1183 ir_node *new_rd_Sub    (dbg_info *db, ir_graph *irg, ir_node *block,
1184                ir_node *op1, ir_node *op2, ir_mode *mode);
1185 ir_node *new_rd_Minus  (dbg_info *db, ir_graph *irg, ir_node *block,
1186                ir_node *op,  ir_mode *mode);
1187 ir_node *new_rd_Mul    (dbg_info *db, ir_graph *irg, ir_node *block,
1188                ir_node *op1, ir_node *op2, ir_mode *mode);
1189 ir_node *new_rd_Quot   (dbg_info *db, ir_graph *irg, ir_node *block,
1190                ir_node *memop, ir_node *op1, ir_node *op2);
1191 ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
1192                ir_node *memop, ir_node *op1, ir_node *op2);
1193 ir_node *new_rd_Div    (dbg_info *db, ir_graph *irg, ir_node *block,
1194                ir_node *memop, ir_node *op1, ir_node *op2);
1195 ir_node *new_rd_Mod    (dbg_info *db, ir_graph *irg, ir_node *block,
1196                ir_node *memop, ir_node *op1, ir_node *op2);
1197 ir_node *new_rd_Abs    (dbg_info *db, ir_graph *irg, ir_node *block,
1198                        ir_node *op, ir_mode *mode);
1199 ir_node *new_rd_And    (dbg_info *db, ir_graph *irg, ir_node *block,
1200                ir_node *op1, ir_node *op2, ir_mode *mode);
1201 ir_node *new_rd_Or     (dbg_info *db, ir_graph *irg, ir_node *block,
1202                ir_node *op1, ir_node *op2, ir_mode *mode);
1203 ir_node *new_rd_Eor    (dbg_info *db, ir_graph *irg, ir_node *block,
1204                ir_node *op1, ir_node *op2, ir_mode *mode);
1205 ir_node *new_rd_Not    (dbg_info *db, ir_graph *irg, ir_node *block,
1206                ir_node *op, ir_mode *mode);
1207 ir_node *new_rd_Cmp    (dbg_info *db, ir_graph *irg, ir_node *block,
1208                ir_node *op1, ir_node *op2);
1209 ir_node *new_rd_Shl    (dbg_info *db, ir_graph *irg, ir_node *block,
1210                ir_node *op, ir_node *k, ir_mode *mode);
1211 ir_node *new_rd_Shr    (dbg_info *db, ir_graph *irg, ir_node *block,
1212                ir_node *op, ir_node *k, ir_mode *mode);
1213 ir_node *new_rd_Shrs   (dbg_info *db, ir_graph *irg, ir_node *block,
1214                ir_node *op, ir_node *k, ir_mode *mode);
1215 ir_node *new_rd_Rot    (dbg_info *db, ir_graph *irg, ir_node *block,
1216                ir_node *op, ir_node *k, ir_mode *mode);
1217 ir_node *new_rd_Conv   (dbg_info *db, ir_graph *irg, ir_node *block,
1218                ir_node *op, ir_mode *mode);
1219 ir_node *new_rd_Cast   (dbg_info* db, ir_graph *irg, ir_node *block,
1220                ir_node *op, type *to_tp);
1221 ir_node *new_rd_Phi    (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
1222                ir_node *in[], ir_mode *mode);
1223 ir_node *new_rd_Load   (dbg_info *db, ir_graph *irg, ir_node *block,
1224                ir_node *store, ir_node *adr);
1225 ir_node *new_rd_Store  (dbg_info *db, ir_graph *irg, ir_node *block,
1226                ir_node *store, ir_node *adr, ir_node *val);
1227 ir_node *new_rd_Alloc  (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1228                ir_node *size, type *alloc_type, where_alloc where);
1229 ir_node *new_rd_Free   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1230                ir_node *ptr, ir_node *size, type *free_type);
1231 ir_node *new_rd_Sync   (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
1232 ir_node *new_rd_Proj   (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1233                ir_mode *mode, long proj);
1234 ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1235                 long max_proj);
1236 ir_node *new_rd_Tuple  (dbg_info *db, ir_graph *irg, ir_node *block,
1237                int arity, ir_node *in[]);
1238 ir_node *new_rd_Id     (dbg_info *db, ir_graph *irg, ir_node *block,
1239                ir_node *val, ir_mode *mode);
1240 ir_node *new_rd_Bad    (ir_graph *irg);
1241 ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
1242              ir_node *val, ir_node *bound, pn_Cmp cmp);
1243 ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
1244 ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
1245 ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
1246 ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
1247 ir_node *new_rd_Break  (dbg_info *db, ir_graph *irg, ir_node *block);
1248 ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1249                ir_mode *mode, long proj);
1250 ir_node *new_rd_FuncCall (dbg_info *db, ir_graph *irg, ir_node *block,
1251                ir_node *callee, int arity, ir_node *in[],
1252                type *tp);
1253
1254 /*-------------------------------------------------------------------------*/
1255 /* The raw interface without debug support                                 */
1256 /*-------------------------------------------------------------------------*/
1257
1258 /* Constructs a Block with a fixed number of predecessors.
1259    Does not set current_block.  Can not be used with automatic
1260    Phi node costruction. */
1261 ir_node *new_r_Block  (ir_graph *irg,  int arity, ir_node *in[]);
1262 ir_node *new_r_Start  (ir_graph *irg, ir_node *block);
1263 ir_node *new_r_End    (ir_graph *irg, ir_node *block);
1264 ir_node *new_r_Jmp    (ir_graph *irg, ir_node *block);
1265 ir_node *new_r_Cond   (ir_graph *irg, ir_node *block, ir_node *c);
1266 ir_node *new_r_Return (ir_graph *irg, ir_node *block,
1267                ir_node *store, int arity, ir_node *in[]);
1268 ir_node *new_r_Raise  (ir_graph *irg, ir_node *block,
1269                ir_node *store, ir_node *obj);
1270 ir_node *new_r_Const  (ir_graph *irg, ir_node *block,
1271                ir_mode *mode, tarval *con);
1272 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
1273                        type_or_id_p value, symconst_kind symkind);
1274 ir_node *new_r_Sel    (ir_graph *irg, ir_node *block, ir_node *store,
1275                        ir_node *objptr, int n_index, ir_node *index[],
1276                entity *ent);
1277 ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *x, ir_node *y, type *z);
1278 ir_node *new_r_Call   (ir_graph *irg, ir_node *block, ir_node *store,
1279                ir_node *callee, int arity, ir_node *in[],
1280                type *tp);
1281 ir_node *new_r_Add    (ir_graph *irg, ir_node *block,
1282                ir_node *op1, ir_node *op2, ir_mode *mode);
1283 ir_node *new_r_Sub    (ir_graph *irg, ir_node *block,
1284                ir_node *op1, ir_node *op2, ir_mode *mode);
1285 ir_node *new_r_Minus  (ir_graph *irg, ir_node *block,
1286                ir_node *op,  ir_mode *mode);
1287 ir_node *new_r_Mul    (ir_graph *irg, ir_node *block,
1288                ir_node *op1, ir_node *op2, ir_mode *mode);
1289 ir_node *new_r_Quot   (ir_graph *irg, ir_node *block,
1290                ir_node *memop, ir_node *op1, ir_node *op2);
1291 ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
1292                ir_node *memop, ir_node *op1, ir_node *op2);
1293 ir_node *new_r_Div    (ir_graph *irg, ir_node *block,
1294                ir_node *memop, ir_node *op1, ir_node *op2);
1295 ir_node *new_r_Mod    (ir_graph *irg, ir_node *block,
1296                ir_node *memop, ir_node *op1, ir_node *op2);
1297 ir_node *new_r_Abs    (ir_graph *irg, ir_node *block,
1298                        ir_node *op, ir_mode *mode);
1299 ir_node *new_r_And    (ir_graph *irg, ir_node *block,
1300                ir_node *op1, ir_node *op2, ir_mode *mode);
1301 ir_node *new_r_Or     (ir_graph *irg, ir_node *block,
1302                ir_node *op1, ir_node *op2, ir_mode *mode);
1303 ir_node *new_r_Eor    (ir_graph *irg, ir_node *block,
1304                ir_node *op1, ir_node *op2, ir_mode *mode);
1305 ir_node *new_r_Not    (ir_graph *irg, ir_node *block,
1306                ir_node *op, ir_mode *mode);
1307 ir_node *new_r_Cmp    (ir_graph *irg, ir_node *block,
1308                ir_node *op1, ir_node *op2);
1309 ir_node *new_r_Shl    (ir_graph *irg, ir_node *block,
1310                ir_node *op, ir_node *k, ir_mode *mode);
1311 ir_node *new_r_Shr    (ir_graph *irg, ir_node *block,
1312                ir_node *op, ir_node *k, ir_mode *mode);
1313 ir_node *new_r_Shrs   (ir_graph *irg, ir_node *block,
1314                ir_node *op, ir_node *k, ir_mode *mode);
1315 ir_node *new_r_Rot    (ir_graph *irg, ir_node *block,
1316                ir_node *op, ir_node *k, ir_mode *mode);
1317 ir_node *new_r_Conv   (ir_graph *irg, ir_node *block,
1318                ir_node *op, ir_mode *mode);
1319 ir_node *new_r_Cast   (ir_graph *irg, ir_node *block,
1320                ir_node *op, type *to_tp);
1321 ir_node *new_r_Phi    (ir_graph *irg, ir_node *block, int arity,
1322                ir_node *in[], ir_mode *mode);
1323 ir_node *new_r_Load   (ir_graph *irg, ir_node *block,
1324                ir_node *store, ir_node *adr);
1325 ir_node *new_r_Store  (ir_graph *irg, ir_node *block,
1326                ir_node *store, ir_node *adr, ir_node *val);
1327 ir_node *new_r_Alloc  (ir_graph *irg, ir_node *block, ir_node *store,
1328                ir_node *size, type *alloc_type, where_alloc where);
1329 ir_node *new_r_Free   (ir_graph *irg, ir_node *block, ir_node *store,
1330                ir_node *ptr, ir_node *size, type *free_type);
1331 ir_node *new_r_Sync   (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
1332 ir_node *new_r_Proj   (ir_graph *irg, ir_node *block, ir_node *arg,
1333                ir_mode *mode, long proj);
1334 ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg,
1335                 long max_proj);
1336 ir_node *new_r_Tuple  (ir_graph *irg, ir_node *block,
1337                int arity, ir_node *in[]);
1338 ir_node *new_r_Id     (ir_graph *irg, ir_node *block,
1339                ir_node *val, ir_mode *mode);
1340 ir_node *new_r_Bad    (ir_graph *irg);
1341 ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
1342             ir_node *val, ir_node *bound, pn_Cmp cmp);
1343 ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
1344 ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
1345 ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
1346 ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
1347 ir_node *new_r_Break  (ir_graph *irg, ir_node *block);
1348 ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
1349                ir_mode *mode, long proj);
1350 ir_node *new_r_FuncCall (ir_graph *irg, ir_node *block,
1351                ir_node *callee, int arity, ir_node *in[],
1352                type *tp);
1353
1354 /*-----------------------------------------------------------------------*/
1355 /* The block oriented interface                                          */
1356 /*-----------------------------------------------------------------------*/
1357
1358 /** Sets the current block in which the following constructors place the
1359    nodes they construct. */
1360 void switch_block (ir_node *target);
1361
1362 /* Constructs a Block with a fixed number of predecessors.
1363    Does set current_block.  Can be used with automatic Phi
1364    node construction. */
1365
1366
1367 ir_node *new_d_Block(dbg_info* db, int arity, ir_node *in[]);
1368 ir_node *new_d_Start  (dbg_info* db);
1369 ir_node *new_d_End    (dbg_info* db);
1370 ir_node *new_d_Jmp    (dbg_info* db);
1371 ir_node *new_d_Cond   (dbg_info* db, ir_node *c);
1372 ir_node *new_d_Return (dbg_info* db, ir_node *store, int arity, ir_node *in[]);
1373 ir_node *new_d_Raise  (dbg_info* db, ir_node *store, ir_node *obj);
1374 ir_node *new_d_Const_type (dbg_info* db, ir_mode *mode, tarval *con, type *tp);
1375 ir_node *new_d_Const  (dbg_info* db, ir_mode *mode, tarval *con);
1376 ir_node *new_d_SymConst (dbg_info* db, type_or_id_p value, symconst_kind kind);
1377 ir_node *new_d_simpleSel(dbg_info* db, ir_node *store, ir_node *objptr, entity *ent);
1378 ir_node *new_d_Sel    (dbg_info* db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
1379                      entity *ent);
1380 ir_node *new_d_InstOf (dbg_info* db, ir_node *store, ir_node *objptr, type *ent);
1381 ir_node *new_d_Call   (dbg_info* db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
1382              type *tp);
1383 ir_node *new_d_Add    (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
1384 ir_node *new_d_Sub    (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
1385 ir_node *new_d_Minus  (dbg_info* db, ir_node *op,  ir_mode *mode);
1386 ir_node *new_d_Mul    (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
1387 ir_node *new_d_Quot   (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
1388 ir_node *new_d_DivMod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
1389 ir_node *new_d_Div    (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
1390 ir_node *new_d_Mod    (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
1391 ir_node *new_d_Abs    (dbg_info* db, ir_node *op,                ir_mode *mode);
1392 ir_node *new_d_And    (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
1393 ir_node *new_d_Or     (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
1394 ir_node *new_d_Eor    (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
1395 ir_node *new_d_Not    (dbg_info* db, ir_node *op,                ir_mode *mode);
1396 ir_node *new_d_Shl    (dbg_info* db, ir_node *op,  ir_node *k,   ir_mode *mode);
1397 ir_node *new_d_Shr    (dbg_info* db, ir_node *op,  ir_node *k,   ir_mode *mode);
1398 ir_node *new_d_Shrs   (dbg_info* db, ir_node *op,  ir_node *k,   ir_mode *mode);
1399 ir_node *new_d_Rot    (dbg_info* db, ir_node *op,  ir_node *k,   ir_mode *mode);
1400 ir_node *new_d_Cmp    (dbg_info* db, ir_node *op1, ir_node *op2);
1401 ir_node *new_d_Conv   (dbg_info* db, ir_node *op, ir_mode *mode);
1402 ir_node *new_d_Cast   (dbg_info* db, ir_node *op, type *to_tp);
1403 ir_node *new_d_Phi    (dbg_info* db, int arity, ir_node *in[], ir_mode *mode);
1404 ir_node *new_d_Load   (dbg_info* db, ir_node *store, ir_node *addr);
1405 ir_node *new_d_Store  (dbg_info* db, ir_node *store, ir_node *addr, ir_node *val);
1406 ir_node *new_d_Alloc  (dbg_info* db, ir_node *store, ir_node *size, type *alloc_type,
1407                      where_alloc where);
1408 ir_node *new_d_Free   (dbg_info* db, ir_node *store, ir_node *ptr, ir_node *size,
1409              type *free_type);
1410 ir_node *new_d_Sync   (dbg_info* db, int arity, ir_node *in[]);
1411 ir_node *new_d_Proj   (dbg_info* db, ir_node *arg, ir_mode *mode, long proj);
1412 ir_node *new_d_defaultProj (dbg_info* db, ir_node *arg, long max_proj);
1413 ir_node *new_d_Tuple  (dbg_info* db, int arity, ir_node *in[]);
1414 ir_node *new_d_Id     (dbg_info* db, ir_node *val, ir_mode *mode);
1415 ir_node *new_d_Bad    (void);
1416 ir_node *new_d_Confirm (dbg_info* db, ir_node *val, ir_node *bound, pn_Cmp cmp);
1417 ir_node *new_d_Unknown(ir_mode *m);
1418 ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
1419 ir_node *new_d_EndReg (dbg_info *db);
1420 ir_node *new_d_EndExcept(dbg_info *db);
1421 ir_node *new_d_Break (dbg_info *db);
1422 ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
1423 ir_node *new_d_FuncCall (dbg_info* db, ir_node *callee, int arity, ir_node *in[],
1424              type *tp);
1425
1426 /*-----------------------------------------------------------------------*/
1427 /* The block oriented interface without debug support                    */
1428 /*-----------------------------------------------------------------------*/
1429
1430 /* Needed from the interfase with debug support:
1431 void switch_block (ir_node *target);   */
1432
1433 /* Constructs a Block with a fixed number of predecessors.
1434    Does set current_block.  Can be used with automatic Phi
1435    node construction. */
1436 ir_node *new_Block(int arity, ir_node *in[]);
1437 ir_node *new_Start  (void);
1438 ir_node *new_End    (void);
1439 ir_node *new_EndReg (void);
1440 ir_node *new_EndExcept(void);
1441 ir_node *new_Jmp    (void);
1442 ir_node *new_Break  (void);
1443 ir_node *new_Cond   (ir_node *c);
1444 ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
1445 ir_node *new_Raise  (ir_node *store, ir_node *obj);
1446 ir_node *new_Const  (ir_mode *mode, tarval *con);
1447 ir_node *new_SymConst (type_or_id_p value, symconst_kind kind);
1448 ir_node *new_simpleSel(ir_node *store, ir_node *objptr, entity *ent);
1449 ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
1450                      entity *ent);
1451 ir_node *new_InstOf (ir_node *store, ir_node *obj,  type *ent);
1452 ir_node *new_Call   (ir_node *store, ir_node *callee, int arity, ir_node *in[],
1453              type *tp);
1454 ir_node *new_CallBegin(ir_node *callee);
1455 ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode);
1456 ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode);
1457 ir_node *new_Minus  (ir_node *op,  ir_mode *mode);
1458 ir_node *new_Mul    (ir_node *op1, ir_node *op2, ir_mode *mode);
1459 ir_node *new_Quot   (ir_node *memop, ir_node *op1, ir_node *op2);
1460 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
1461 ir_node *new_Div    (ir_node *memop, ir_node *op1, ir_node *op2);
1462 ir_node *new_Mod    (ir_node *memop, ir_node *op1, ir_node *op2);
1463 ir_node *new_Abs    (ir_node *op,                ir_mode *mode);
1464 ir_node *new_And    (ir_node *op1, ir_node *op2, ir_mode *mode);
1465 ir_node *new_Or     (ir_node *op1, ir_node *op2, ir_mode *mode);
1466 ir_node *new_Eor    (ir_node *op1, ir_node *op2, ir_mode *mode);
1467 ir_node *new_Not    (ir_node *op,                ir_mode *mode);
1468 ir_node *new_Shl    (ir_node *op,  ir_node *k,   ir_mode *mode);
1469 ir_node *new_Shr    (ir_node *op,  ir_node *k,   ir_mode *mode);
1470 ir_node *new_Shrs   (ir_node *op,  ir_node *k,   ir_mode *mode);
1471 ir_node *new_Rot    (ir_node *op,  ir_node *k,   ir_mode *mode);
1472 ir_node *new_Cmp    (ir_node *op1, ir_node *op2);
1473 ir_node *new_Conv   (ir_node *op, ir_mode *mode);
1474 ir_node *new_Cast   (ir_node *op, type *to_tp);
1475 ir_node *new_Phi    (int arity, ir_node *in[], ir_mode *mode);
1476 ir_node *new_Load   (ir_node *store, ir_node *addr);
1477 ir_node *new_Store  (ir_node *store, ir_node *addr, ir_node *val);
1478 ir_node *new_Alloc  (ir_node *store, ir_node *size, type *alloc_type,
1479                      where_alloc where);
1480 ir_node *new_Free   (ir_node *store, ir_node *ptr, ir_node *size,
1481              type *free_type);
1482 ir_node *new_Sync   (int arity, ir_node *in[]);
1483 ir_node *new_Proj   (ir_node *arg, ir_mode *mode, long proj);
1484 ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
1485 ir_node *new_defaultProj (ir_node *arg, long max_proj);
1486 ir_node *new_Tuple  (int arity, ir_node *in[]);
1487 ir_node *new_Id     (ir_node *val, ir_mode *mode);
1488 ir_node *new_Bad    (void);
1489 ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
1490 ir_node *new_Unknown(ir_mode *m);
1491 ir_node *new_FuncCall (ir_node *callee, int arity, ir_node *in[],
1492              type *tp);
1493
1494 /*---------------------------------------------------------------------*/
1495 /* The comfortable interface.                                          */
1496 /* Supports automatic Phi node construction.                           */
1497 /* All routines of the block oriented interface except new_Block are   */
1498 /* needed also.                                                        */
1499 /*---------------------------------------------------------------------*/
1500
1501 /* --- Block construction --- */
1502 /* immature Block without predecessors */
1503 ir_node *new_d_immBlock (dbg_info* db);
1504 ir_node *new_immBlock (void);
1505
1506 /** Add a control flow edge to an immature block. */
1507 void add_in_edge (ir_node *immblock, ir_node *jmp);
1508
1509 /** fixes the number of predecessors of a block. */
1510 void mature_block (ir_node *block);
1511
1512 /* --- Parameter administration --- */
1513 /* Read a value from the array with the local variables.  Use this
1514    function to obtain the last definition of the value associated with
1515    pos.  Pos may not exceed the value passed as n_loc to new_ir_graph. */
1516 ir_node *get_d_value (dbg_info* db, int pos, ir_mode *mode);
1517 ir_node *get_value (int pos, ir_mode *mode);
1518
1519 /** Write a value in the array with the local variables. Use this function
1520    to remember a new definition of the value associated with pos. Pos may
1521    not exceed the value passed as n_loc to new_ir_graph. */
1522 void set_value (int pos, ir_node *value);
1523
1524 /** Read a store.
1525    Use this function to get the most recent version of the store (type M).
1526    Internally it does the same as get_value. */
1527 ir_node *get_store (void);
1528
1529 /** Write a store. */
1530 void set_store (ir_node *store);
1531
1532 /** keep this node alive even if End is not control-reachable from it */
1533 void keep_alive (ir_node *ka);
1534
1535 /* --- Useful access routines --- */
1536 /** Returns the current block of the current graph.  To set the current
1537    block use switch_block(). */
1538 ir_node *get_cur_block(void);
1539
1540 /** Returns the frame type of the current graph */
1541 type *get_cur_frame_type(void);
1542
1543
1544 /* --- initialize and finalize ir construction --- */
1545
1546 /** Puts the graph into state "phase_high" */
1547 void finalize_cons (ir_graph *irg);
1548
1549 /* --- Initialization --- */
1550
1551 /**
1552  * This function is called, whenever a local variable is used before definition
1553  *
1554  * @parameter mode      the mode of the local var
1555  * @pos                 position choosen be the frontend for this var
1556  *
1557  * @return a firm node of mode @p mode that initialises the var at position pos
1558  *
1559  * @note
1560  *      Do not return NULL
1561  *      If this function is not set, FIRM will create a const node with tarval BAD
1562  */
1563 typedef ir_node *default_initialize_local_variable_func_t(ir_mode *mode, int pos);
1564
1565 /**
1566  * Initializes the graph construction.
1567  *
1568  * @param func  @see default_initialize_local_variable_func_t
1569  */
1570 void init_cons (default_initialize_local_variable_func_t *func);
1571
1572 # endif /* _IRCONS_H_ */