0f20b935966b435c78ce3927a9851731c91eb8a1
[libfirm] / include / libfirm / ircons.h
1 /*
2  * Copyright (C) 1995-2010 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Various irnode constructors. Automatic construction of SSA
23  *          representation.
24  * @author  Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Boris Boesler,
25  *          Michael Beck
26  * @version $Id$
27  */
28
29 /**
30  *  @file
31  *
32  *  documentation no more supported since 2001
33  *
34  *  IR node construction.
35  *
36  *    This file documents all datatypes and constructors needed to
37  *    build a FIRM representation of a procedure.  The constructors are
38  *    also implemented in this file.
39  *
40  *    The documentation also gives a short manual how to use the library.
41  *
42  *    For extensive documentation of FIRM see UKA Techreport 1999-14.
43  *
44  *
45  *    Three kinds of nodes
46  *    --------------------
47  *
48  *      There are three kinds of nodes known to the IR:  entities,
49  *      types, and ir_nodes
50  *
51  *      + ir_nodes are the actual nodes of the FIRM intermediate representation.
52  *        They represent operations on the data of the program and control flow
53  *        operations.
54  *
55  *      + entity ==> implemented in entity.h
56  *        Refers to a single entity of the compiled program, e.g. a field of a
57  *        class or a method.  If a method or variable can not be assigned to
58  *        a method or class or the like, it is a global object.
59  *
60  *      + types ==> implemented in type.h
61  *        With types type information is represented.  There are several type
62  *       nodes.
63  *
64  *    Implementation of the FIRM operations: ir_node
65  *    ----------------------------------------------
66  *
67  *      Ir_nodes represent operations on the data of the program and control flow
68  *      operations.  Examples of ir_nodes:  Add, Jmp, Cmp
69  *
70  *      FIRM is a dataflow graph.  A dataflow graph is a directed graph,
71  *      so that every node has incoming and outgoing edges.  A node is
72  *      executable if every input at its incoming edges is available.
73  *      Execution of the dataflow graph is started at the Start node which
74  *      has no incoming edges and ends when the End node executes, even if
75  *      there are still executable or not executed nodes.  (Is this true,
76  *      or must all executable nodes be executed?)  (There are exceptions
77  *      to the dataflow paradigma that all inputs have to be available
78  *      before a node can execute: Phi, Block.  See UKA Techreport
79  *      1999-14.)
80  *
81  *      The implementation of FIRM differs from the view as a dataflow
82  *      graph.  To allow fast traversion of the graph edges are
83  *      implemented as C-pointers.  Inputs to nodes are not ambiguous, the
84  *      results can be used by several other nodes.  Each input can be
85  *      implemented as a single pointer to a predecessor node, outputs
86  *      need to be lists of pointers to successors.  Therefore a node
87  *      contains pointers to its predecessors so that the implementation is a
88  *      dataflow graph with reversed edges.  It has to be traversed bottom
89  *      up.
90  *
91  *      All nodes of the IR have the same basic structure.  They are
92  *      distinguished by a field containing the opcode.
93  *
94  *      The fields of an ir_node:
95  *
96  *      kind             A firm_kind tag containing k_ir_node.  This is useful for
97  *                       dynamically checking the type of a node.
98  *
99  *      *op              This ir_op gives the opcode as a tag and a string
100  *                       and the number of attributes of an ir_node.  There is
101  *                       one statically allocated struct ir_op for each opcode.
102  *
103  *      *mode            The ir_mode of the operation represented by this firm
104  *                       node.  The mode of the operation is the mode of its
105  *                       result.  A Firm mode is a datatype as known to the
106  *                       target, not a type of the source language.
107  *
108  *      visit            A flag for traversing the IR.
109  *
110  *      **in             An array with pointers to the node's predecessors.
111  *
112  *      *link            A pointer to an ir_node.  With this pointer all Phi nodes
113  *                       are attached to a Block, i.e. a Block points to its
114  *                       first Phi node, this node points to the second Phi node
115  *                       in the Block and so forth.  Used in mature_immBlock
116  *                       to find all Phi nodes to be matured.  It's also used to
117  *                       annotate a node with a better, optimized version of it.
118  *
119  *      attr             An attr struct containing the attributes of the nodes. The
120  *                       attributes depend on the opcode of the node.  The number
121  *                       of these attributes is given in op.
122  *
123  *    The struct ir_op
124  *    ----------------
125  *                       Not yet documented. See irop.h.
126  *
127  *    The struct ir_mode
128  *    ------------------
129  *                       Not yet documented. See irmode.h.
130  *
131  *    GLOBAL VARIABLES -- now also fields of ir_graph.
132  *    ================
133  *
134  *    current_ir_graph   Points to the current ir_graph.  All constructors for
135  *                       nodes add nodes to this graph.
136  *
137  *    ir_visited         An int used as flag to traverse the ir_graph.
138  *
139  *    block_visited      An int used as a flag to traverse block nodes in the
140  *                       graph.
141  *
142  *                       Others not yet documented.
143  *
144  *
145  *
146  *    CONSTRUCTOR FOR IR_GRAPH --> see irgraph.h
147  *    ========================
148  *
149  *
150  *    PROCEDURE TO CONSTRUCT AN IR GRAPH --> see also Firm tutorial
151  *    ==================================
152  *
153  *    This library supplies several interfaces to construct a FIRM graph for
154  *    a program:
155  *    - A "comfortable" interface generating SSA automatically.  Automatically
156  *      computed predecessors of nodes need not be specified in the constructors.
157  *      (new_<Node> constructurs and a set of additional routines.)
158  *    - A less comfortable interface where all predecessors except the block
159  *      an operation belongs to need to be specified.  SSA must be constructed
160  *      by hand.  (new_<Node> constructors and set_cur_block()).  This interface
161  *      is called "block oriented".  It automatically calles the local optimizations
162  *      for each new node.
163  *    - An even less comfortable interface where the block needs to be specified
164  *      explicitly.  This is called the "raw" interface. (new_r_<Node>
165  *      constructors).  These nodes are not optimized.
166  *
167  *    To use the functionality of the comfortable interface correctly the Front
168  *    End needs to follow certain protocols.  This is explained in the following.
169  *    To build a correct IR with the other interfaces study the semantics of
170  *    the firm node (See tech-reprot UKA 1999-14).  For the construction of
171  *    types and entities see the documentation in those modules.
172  *
173  *    First the Frontend needs to decide which variables and values used in
174  *    a procedure can be represented by dataflow edges.  These are variables
175  *    that need not be saved to memory as they cause no side effects visible
176  *    out of the procedure.  Often these are all compiler generated
177  *    variables and simple local variables of the procedure as integers,
178  *    reals and pointers.  The frontend has to count and number these variables.
179  *
180  *    First an ir_graph needs to be constructed with new_ir_graph.  The
181  *    constructor gets the number of local variables.  The graph is held in the
182  *    global variable irg.
183  *
184  *    Now the construction of the procedure can start.  Several basic blocks can
185  *    be constructed in parallel, but the code within each block needs to
186  *    be constructed (almost) in program order.
187  *
188  *    A global variable holds the current basic block.  All (non block) nodes
189  *    generated are added to this block.  The current block can be set with
190  *    set_cur_block(block).  If several blocks are constructed in parallel block
191  *    switches need to be performed constantly.
192  *
193  *    To generate a Block node (with the comfortable interface), its predecessor
194  *    control flow nodes need not be known.  In case of cyclic control flow these
195  *    can not be known when the block is constructed.  With add_immBlock_pred(block,
196  *    cfnode) predecessors can be added to the block.  If all predecessors are
197  *    added to the block mature_immBlock(b) needs to be called.  Calling mature_immBlock
198  *    early improves the efficiency of the Phi node construction algorithm.
199  *    But if several  blocks are constructed at once, mature_immBlock must only
200  *    be called after performing all set_values and set_stores in the block!
201  *    (See documentation of new_immBlock constructor.)
202  *
203  *    The constructors of arithmetic nodes require that their predecessors
204  *    are mentioned.  Sometimes these are available in the Frontend as the
205  *    predecessors have just been generated by the frontend.  If they are local
206  *    values, the predecessors can be obtained from the library with a call to
207  *    get_value(local_val_nr).  (local_val_nr needs to be administered by
208  *    the Frontend.)  A call to get_value triggers the generation of Phi nodes.
209  *    If an arithmetic operation produces a local value, this value needs to be
210  *    passed to the library by set_value(node, local_val_nr).
211  *    In straight line code these two operations just remember and return the
212  *    pointer to nodes producing the value.  If the value passes block boundaries
213  *    Phi nodes can be inserted.
214  *    Similar routines exist to manage the Memory operands: set_store and
215  *    get_store.
216  *
217  *    Several nodes produce more than one result.  An example is the Div node.
218  *    Such nodes return tuples of values.  From these individual values can be
219  *    extracted by proj nodes.
220  *
221  *    The following example illustrates the construction of a simple basic block
222  *    with two predecessors stored in variables cf_pred1 and cf_pred2, containing
223  *    the code
224  *      a = a div a;
225  *    and finally jumping to an other block.  The variable a got the local_val_nr
226  *    42 by the frontend.
227  *
228  *    ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
229  *
230  *    this_block = new_immBlock();
231  *    add_immBlock_pred(this_block, cf_pred1);
232  *    add_immBlock_pred(this_block, cf_pred2);
233  *    mature_immBlock(this_block);
234  *    a_val = get_value(42, mode_Iu);
235  *    mem = get_store();
236  *    div = new_Div(mem, a_val, a_val, mode_Iu);
237  *    mem = new_Proj(div, mode_M, pn_Div_M);   * for the numbers for Proj see docu *
238  *    res = new_Proj(div, mode_Iu, pn_Div_res);
239  *    set_store(mem);
240  *    set_value(res, 42);
241  *    cf_op = new_Jmp();
242  *
243  *    For further information look at the documentation of the nodes and
244  *    constructors and at the paragraph COPING WITH DATA OBJECTS at the
245  *    end of this documentation.
246  *
247  *    The comfortable interface contains the following routines further explained
248  *    below:
249  *
250  *    ir_node *new_immBlock (void);
251  *    ir_node *new_Start    (void);
252  *    ir_node *new_End      (void);
253  *    ir_node *new_Jmp      (void);
254  *    ir_node *new_IJmp     (ir_node *tgt);
255  *    ir_node *new_Cond     (ir_node *c);
256  *    ir_node *new_Return   (ir_node *store, int arity, ir_node **in);
257  *    ir_node *new_Const    (ir_tarval *con);
258  *    ir_node *new_SymConst (ir_mode *mode, symconst_symbol value, symconst_kind kind);
259  *    ir_node *new_simpleSel (ir_node *store, ir_node *objptr, ir_entity *ent);
260  *    ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity,
261  *                         ir_node **in, ir_entity *ent);
262  *    ir_node *new_Call   (ir_node *store, ir_node *callee, int arity,
263  *                         ir_node **in, type_method *type);
264  *    ir_node *new_Builtin(ir_node *store, ir_builtin_kind kind, int arity,
265  *                         ir_node **in, type_method *type);
266  *    ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode);
267  *    ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode);
268  *    ir_node *new_Minus  (ir_node *op,  ir_mode *mode);
269  *    ir_node *new_Mul    (ir_node *op1, ir_node *op2, ir_mode *mode);
270  *    ir_node *new_Mulh   (ir_node *op1, ir_node *op2, ir_mode *mode);
271  *    ir_node *new_Quot   (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state);
272  *    ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state);
273  *    ir_node *new_Div    (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state);
274  *    ir_node *new_Mod    (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state;
275  *    ir_node *new_And    (ir_node *op1, ir_node *op2, ir_mode *mode);
276  *    ir_node *new_Or     (ir_node *op1, ir_node *op2, ir_mode *mode);
277  *    ir_node *new_Eor    (ir_node *op1, ir_node *op2, ir_mode *mode);
278  *    ir_node *new_Not    (ir_node *op,                ir_mode *mode);
279  *    ir_node *new_Shl    (ir_node *op,  ir_node *k,   ir_mode *mode);
280  *    ir_node *new_Shr    (ir_node *op,  ir_node *k,   ir_mode *mode);
281  *    ir_node *new_Shrs   (ir_node *op,  ir_node *k,   ir_mode *mode);
282  *    ir_node *new_Rotl   (ir_node *op,  ir_node *k,   ir_mode *mode);
283  *    ir_node *new_Cmp    (ir_node *op1, ir_node *op2);
284  *    ir_node *new_Conv   (ir_node *op, ir_mode *mode);
285  *    ir_node *new_Cast   (ir_node *op, ir_type *to_tp);
286  *    ir_node *new_Carry  (ir_node *op1, ir_node *op2, ir_mode *mode);
287  *    ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
288  *    ir_node *new_Load   (ir_node *store, ir_node *addr, ir_mode *mode, ir_cons_flags flags);
289  *    ir_node *new_Store  (ir_node *store, ir_node *addr, ir_node *val, ir_cons_flags flags);
290  *    ir_node *new_Alloc  (ir_node *store, ir_node *count, ir_type *alloc_type,
291  *                         where_alloc where);
292  *    ir_node *new_Free   (ir_node *store, ir_node *ptr, ir_node *size,
293  *               ir_type *free_type, where_alloc where);
294  *    ir_node *new_Proj   (ir_node *arg, ir_mode *mode, long proj);
295  *    ir_node *new_NoMem  (void);
296  *    ir_node *new_Mux    (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
297  *    ir_node *new_CopyB  (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
298  *    ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
299  *    ir_node *new_Raise  (ir_node *store, ir_node *obj);
300  *    ir_node *new_Bound  (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
301  *    ir_node *new_Pin    (ir_node *node);
302  *
303  *    void add_immBlock_pred (ir_node *block, ir_node *jmp);
304  *    void mature_immBlock (ir_node *block);
305  *    void set_cur_block (ir_node *target);
306  *    ir_node *get_value (int pos, ir_mode *mode);
307  *    void set_value (int pos, ir_node *value);
308  *    ir_node *get_store (void);
309  *    void set_store (ir_node *store);
310  *    keep_alive (ir_node ka)
311  *
312  *    IR_NODES AND CONSTRUCTORS FOR IR_NODES
313  *    =======================================
314  *
315  *    All ir_nodes are defined by a common data structure.  They are distinguished
316  *    by their opcode and differ in the number of their attributes.
317  *
318  *    Const nodes are always added to the start block.
319  *    All other constructors add the created node to the current_block.
320  *    swich_block(block) allows to set the current block to block.
321  *
322  *    Watch for my inconsistent use of input and predecessor (dataflow view)
323  *    and `the node points to' (implementation view).
324  *
325  *    The following description of the nodes lists four properties them if these
326  *    are of interest:
327  *     - the parameters to the constructor
328  *     - the inputs of the Firm node
329  *     - the outputs of the Firm node
330  *     - attributes to the node
331  *
332  *    ------------
333  *
334  *    ir_node *new_immBlock (void)
335  *    ----------------------------
336  *
337  *    Creates a new block. When a new block is created it cannot be known how
338  *    many predecessors this block will have in the control flow graph.
339  *    Therefore the list of inputs can not be fixed at creation.  Predecessors
340  *    can be added with add_immBlock_pred (block, control flow operation).
341  *    With every added predecessor the number of inputs to Phi nodes also
342  *    changes.
343  *
344  *    The block can be completed by mature_immBlock(block) if all predecessors are
345  *    known.  If several blocks are built at once, mature_immBlock can only be called
346  *    after set_value has been called for all values that are life at the end
347  *    of the block.  This is necessary so that Phi nodes created mature_immBlock
348  *    get the right predecessors in case of cyclic dependencies.  If all set_values
349  *    of this block are called after maturing it and before calling get_value
350  *    in some block that is control flow dependent on this block, the construction
351  *    is correct.
352  *
353  *    Example for faulty IR construction:  (draw the graph on a paper and you'll
354  *                                          get it ;-)
355  *
356  *      block_before_loop = new_immBlock();
357  *      set_cur_block(block_before_loop);
358  *      set_value(x);
359  *      mature_immBlock(block_before_loop);
360  *      before2header = new_Jmp;
361  *
362  *      loop_header = new_immBlock ();
363  *      set_cur_block(loop_header);
364  *      header2body - new_Jmp();
365  *
366  *      loop_body = new_immBlock ();
367  *      set_cur_block(loop_body);
368  *      body2header = new_Jmp();
369  *
370  *      add_immBlock_pred(loop_header, before2header);
371  *      add_immBlock_pred(loop_header, body2header);
372  *      add_immBlock_pred(loop_body, header2body);
373  *
374  *      mature_immBlock(loop_header);
375  *      mature_immBlock(loop_body);
376  *
377  *      get_value(loop_body, x);   //  gets the Phi in loop_header
378  *      set_value(loop_header, x); //  sets the value the above get_value should
379  *                                 //  have returned!!!
380  *
381  *    Mature_immBlock also fixes the number of inputs to the Phi nodes.  Mature_immBlock
382  *    should be called as early as possible, as afterwards the generation of Phi
383  *    nodes is more efficient.
384  *
385  *    Inputs:
386  *      There is an input for each control flow predecessor of the block.
387  *      The input points to an instruction producing an output of type X.
388  *      Possible predecessors:  Start, Jmp, Cond, Raise or Return or any node
389  *      possibly causing an exception.  (Often the real predecessors are Projs.)
390  *    Output:
391  *      Mode BB (R), all nodes belonging to this block should consume this output.
392  *      As they are strict (except Block and Phi node) it is a necessary condition
393  *      that the block node executed before any other node in this block executes.
394  *    Attributes:
395  *      block.matured  Indicates whether the block is mature.
396  *      block.**graph_arr
397  *                      This attribute contains all local values valid in this
398  *                      block. This is needed to build the Phi nodes and removed
399  *                      if the graph is complete.  This field is used by the
400  *              internal construction algorithm and should not be accessed
401  *              from outside.
402  *
403  *
404  *    ir_node *new_Block (int arity, ir_node **in)
405  *    --------------------------------------------
406  *
407  *    Creates a new Block with the given list of predecessors.  This block
408  *    is mature.  As other constructors calls optimization and verify for the
409  *    block.  If one of the predecessors is Unknown (as it has to be filled in
410  *    later) optimizations are skipped.  This is necessary to
411  *    construct Blocks in loops.
412  *
413  *
414  *    CONTROL FLOW OPERATIONS
415  *    -----------------------
416  *
417  *    In each block there must be exactly one of the control flow
418  *    operations Start, End, Jmp, Cond, Return or Raise.  The output of a
419  *    control flow operation points to the block to be executed next.
420  *
421  *    ir_node *new_Start (void)
422  *    -------------------------
423  *
424  *    Creates a start node.  Not actually needed public.  There is only one such
425  *   node in each procedure which is automatically created by new_ir_graph.
426  *
427  *    Inputs:
428  *      No inputs except the block it belongs to.
429  *    Output:
430  *      A tuple of 4 (5, 6) distinct values. These are labeled by the following
431  *      projection numbers (pn_Start):
432  *      * pn_Start_X_initial_exec    mode X, points to the first block to be exe *                                   cuted.
433  *      * pn_Start_M                 mode M, the global store
434  *      * pn_Start_P_frame_base      mode P, a pointer to the base of the proce  *                                   dures stack frame.
435  *      * pn_Start_P_globals         mode P, a pointer to the part of the memory *                                   containing_all_ global things.
436  *      * pn_Start_T_args            mode T, a tuple containing all arguments of *                                   the procedure.
437  *
438  *
439  *    ir_node *new_End (void)
440  *    -----------------------
441  *
442  *    Creates an end node.  Not actually needed public.  There is only one such
443  *   node in each procedure which is automatically created by new_ir_graph.
444  *
445  *    Inputs:
446  *      No inputs except the block it belongs to.
447  *    Output:
448  *      No output.
449  *
450  *    ir_node *new_Jmp (void)
451  *    -----------------------
452  *
453  *    Creates a Jmp node.
454  *
455  *    Inputs:
456  *      The block the node belongs to
457  *    Output:
458  *      Control flow to the next block.
459  *
460  *    ir_node *new_IJmp (ir_node *tgt)
461  *    -----------------------
462  *
463  *    Creates an IJmp node.
464  *
465  *    Inputs:
466  *      The node that represents the target jump address
467  *    Output:
468  *      Control flow to an unknown target, must be pinned by
469  *      the End node.
470  *
471  *    ir_node *new_Cond (ir_node *c)
472  *    ------------------------------
473  *
474  *    Creates a Cond node.  There are two versions of this node.
475  *
476  *    The Boolean Cond:
477  *    Input:
478  *      A value of mode b.
479  *    Output:
480  *      A tuple of two control flows.  The first is taken if the input is
481  *      false, the second if it is true.
482  *
483  *    The Switch Cond:
484  *    Input:
485  *      A value of mode I_u. (i)
486  *    Output:
487  *      A tuple of n control flows.  If the Cond's input is i, control
488  *      flow will proceed along output i. If the input is >= n control
489  *      flow proceeds along output n.
490  *
491  *    ir_node *new_Return (ir_node *store, int arity, ir_node **in)
492  *    -------------------------------------------------------------
493  *
494  *    The Return node has as inputs the results of the procedure.  It
495  *    passes the control flow to the end_block.
496  *
497  *    Inputs:
498  *      The memory state.
499  *      All results.
500  *    Output
501  *      Control flow to the end block.
502  *
503  *
504  *    ir_node *new_Const (ir_tarval *con)
505  *    -----------------------------------------------
506  *
507  *    Creates a constant in the constant table and adds a Const node
508  *    returning this value to the start block. The mode is derived
509  *    from the tarval.
510  *
511  *    Parameters:
512  *      *con             Points to an entry in the constant table.
513  *                       This pointer is added to the attributes of
514  *                       the node (self->attr.con)
515  *    Inputs:
516  *      No inputs except the block it belogns to.
517  *    Output:
518  *      The constant value.
519  *    Attribute:
520  *      attr.con   A tarval* pointer to the proper entry in the constant
521  *                 table.
522  *
523  *    ir_node *new_SymConst (ir_mode *mode, union symconst_symbol value, symconst_addr_ent kind)
524  *    -----------------------------------------------------------------------------------------
525  *
526  *    There are several symbolic constants:
527  *     symconst_type_tag   The symbolic constant represents a type tag.
528  *     symconst_type_size  The symbolic constant represents the size of a type.
529  *     symconst_type_align The symbolic constant represents the alignment of a type.
530  *     symconst_addr_ent   The symbolic constant represents the address of an entity.
531  *     symconst_ofs_ent    The symbolic constant represents the offset of an
532  *                         entity in its owner type.
533  *     symconst_enum_const The symbolic constant is a enumeration constant of an
534  *                         enumeration type.
535  *
536  *    Parameters
537  *      mode        P for SymConsts representing addresses, Iu otherwise.
538  *      value       The type, ident, entity or enum constant, depending on the
539  *                  kind
540  *      kind        The kind of the symbolic constant, see the list above.
541  *
542  *    Inputs:
543  *      No inputs except the block it belongs to.
544  *    Output:
545  *      A symbolic constant.
546  *
547  *    Attributes:
548  *      attr.i.num       The symconst_addr_ent, i.e. one of
549  *                        -symconst_type_tag
550  *                        -symconst_type_size
551  *                        -symconst_type_align
552  *                        -symconst_addr_ent
553  *
554  *    If the attr.i.num is symconst_type_tag, symconst_type_size or symconst_type_align,
555  *    the node contains an attribute:
556  *
557  *      attr.i.*type,    a pointer to a type_class.
558  *        if it is linkage_ptr_info it contains
559  *      attr.i.*ptrinfo,  an ident holding information for the linker.
560  *
561  *    ---------------
562  *
563  *    ir_node *new_simpleSel (ir_node *store, ir_node *frame, ir_entity *sel)
564  *    -----------------------------------------------------------------------
565  *
566  *
567  *    Selects an entity from a compound type. This entity can be a field or
568  *    a method.
569  *
570  *    Parameters:
571  *      *store     The memory in which the object the entity should be selected
572  *                 from is allocated.
573  *      *frame     The pointer to the object.
574  *      *sel       The entity to select.
575  *
576  *    Inputs:
577  *      The memory containing the object.
578  *      A pointer to the object.
579  *      An unsigned integer.
580  *    Output:
581  *      A pointer to the selected entity.
582  *    Attributes:
583  *      attr.sel   Pointer to the entity
584  *
585  *
586  *    ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
587  *    --------------------------------------------------------------------------
588  *                      ir_entity *sel)
589  *                      ---------------
590  *
591  *    Selects a field from an array type.  The entity has as owner the array, as
592  *    type the arrays element type.  The indices to access an array element are
593  *    given also.
594  *
595  *    Parameters:
596  *      *store     The memory in which the object the entity should be selected from
597  *                 is allocated.
598  *      *frame     The pointer to the object.
599  *      *arity     number of array indices.
600  *      *in        array with index inputs to the node.
601  *      *sel       The entity to select.
602  *
603  *    Inputs:
604  *      The memory containing the object.
605  *      A pointer to the object.
606  *      As much unsigned integer as there are array expressions.
607  *    Output:
608  *      A pointer to the selected entity.
609  *    Attributes:
610  *      attr.sel   Pointer to the entity
611  *
612  *    The constructors new_Sel and new_simpleSel generate the same IR nodes.
613  *    simpleSel just sets the arity of the index inputs to zero.
614  *
615  *
616  *    ARITHMETIC OPERATIONS
617  *    ---------------------
618  *
619  *    ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
620  *    ----------------------------------------------------------------------------
621  *                       type_method *type)
622  *                       ------------------
623  *
624  *    Creates a procedure call.
625  *
626  *    Parameters
627  *      *store           The actual store.
628  *      *callee          A pointer to the called procedure.
629  *      arity            The number of procedure parameters.
630  *      **in             An array with the pointers to the parameters.
631  *                       The constructor copies this array.
632  *      *type            Type information of the procedure called.
633  *
634  *    Inputs:
635  *      The store, the callee and the parameters.
636  *    Output:
637  *      A tuple containing the eventually changed store and the procedure
638  *      results.
639  *    Attributes:
640  *      attr.call        Contains the attributes for the procedure.
641  *
642  *    ir_node *new_Builtin(ir_node *store, ir_builtin_kind kind, int arity, ir_node **in,
643  *    -----------------------------------------------------------------------------------
644  *                       type_method *type)
645  *                       ------------------
646  *
647  *    Creates a builtin call.
648  *
649  *    Parameters
650  *      *store           The actual store.
651  *      kind             Describes the called builtin.
652  *      arity            The number of procedure parameters.
653  *      **in             An array with the pointers to the parameters.
654  *                       The constructor copies this array.
655  *      *type            Type information of the procedure called.
656  *
657  *    Inputs:
658  *      The store, the kind and the parameters.
659  *    Output:
660  *      A tuple containing the eventually changed store and the procedure
661  *      results.
662  *    Attributes:
663  *      attr.builtin     Contains the attributes for the called builtin.
664  *
665  *    ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
666  *    ------------------------------------------------------------
667  *
668  *    Trivial.
669  *
670  *    ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
671  *    ------------------------------------------------------------
672  *
673  *    Trivial.
674  *
675  *    ir_node *new_Minus (ir_node *op, ir_mode *mode)
676  *    -----------------------------------------------
677  *
678  *    Unary Minus operations on integer and floating point values.
679  *
680  *    ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
681  *    ------------------------------------------------------------
682  *
683  *    Trivial.
684  *
685  *    ir_node *new_Mulh (ir_node *op1, ir_node *op2, ir_mode *mode)
686  *    ------------------------------------------------------------
687  *
688  *    Returns the high order bits of a n*n=2n multiplication.
689  *
690  *    ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
691  *    -------------------------------------------------------------------------------------------------
692  *
693  *    Quot performs exact division of floating point numbers.  It's mode
694  *    is Tuple, the mode of the result must match the Proj mode
695  *    that extracts the result of the arithmetic operations.
696  *
697  *    Inputs:
698  *      The store needed to model exceptions and the two operands.
699  *    Output:
700  *      A tuple containing a memory and a execution for modeling exceptions
701  *      and the result of the arithmetic operation.
702  *
703  *    ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
704  *    ---------------------------------------------------------------------------------------------------
705  *
706  *    Performs Div and Mod on integer values.
707  *
708  *    Output:
709  *      A tuple containing a memory and a execution for modeling exceptions
710  *      and the two result of the arithmetic operations.
711  *
712  *    ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
713  *    ------------------------------------------------------------------------------------------------
714  *
715  *    Trivial.
716  *
717  *    ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
718  *    ------------------------------------------------------------------------------------------------
719  *
720  *    Trivial.
721  *
722  *    ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
723  *    ------------------------------------------------------------
724  *
725  *    Trivial.
726  *
727  *    ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
728  *    -----------------------------------------------------------
729  *
730  *    Trivial.
731  *
732  *    ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
733  *    ------------------------------------------------------------
734  *
735  *    Trivial.
736  *
737  *    ir_node *new_Not (ir_node *op, ir_mode *mode)
738  *    ---------------------------------------------
739  *
740  *    This node constructs a constant where all bits are set to one
741  *    and a Eor of this constant and the operator.  This simulates a
742  *    Not operation.
743  *
744  *    ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
745  *    ---------------------------------------------------------
746  *
747  *    Trivial.
748  *
749  *    ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
750  *    ---------------------------------------------------------
751  *
752  *    Logic shift right, i.e., zero extended.
753  *
754  *
755  *    ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
756  *    ----------------------------------------------------------
757  *
758  *    Arithmetic shift right, i.e., sign extended.
759  *
760  *    ir_node *new_Rotl (ir_node *op, ir_node *k, ir_mode *mode)
761  *    ---------------------------------------------------------
762  *
763  *    Rotates the operand to the left by k bits.
764  *
765  *    ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode)
766  *    ------------------------------------------------------------
767  *
768  *    Calculates the Carry value for integer addition. Used only
769  *    in lowering code.
770  *
771  *    ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode)
772  *    ------------------------------------------------------------
773  *
774  *    Calculates the Borrow value for integer substraction. Used only
775  *    in lowering code.
776  *
777  *    ir_node *new_Conv (ir_node *op, ir_mode *mode)
778  *    ---------------------------------------------
779  *
780  *    Mode conversion.  For allowed conversions see UKA Tech Report
781  *    1999-14.
782  *
783  *    ir_node *new_Cmp (ir_node *op1, ir_node *op2)
784  *    ---------------------------------------------
785  *
786  *    Input:
787  *      The two values to be compared.
788  *    Output:
789  *      A 16-tuple containing the results of the 16 different comparisons.
790  *      The following is a list giving the comparisons and a projection
791  *      number (pn_Cmp) to use in Proj nodes to extract the proper result.
792  *        pn_Cmp_False false
793  *        pn_Cmp_Eq    equal
794  *        pn_Cmp_Lt    less
795  *        pn_Cmp_Le    less or equal
796  *        pn_Cmp_Gt    greater
797  *        pn_Cmp_Ge    greater of equal
798  *        pn_Cmp_Lg    less or greater
799  *        pn_Cmp_Leg   less, equal or greater = ordered
800  *        pn_Cmp_Uo    unordered
801  *        pn_Cmp_Ue    unordered or equal
802  *        pn_Cmp_Ul    unordered or less
803  *        pn_Cmp_Ule   unordered, less or equal
804  *        pn_Cmp_Ug    unordered or greater
805  *        pn_Cmp_Uge   unordered, greater or equal
806  *        pn_Cmp_Ne    unordered, less or greater = not equal
807  *        pn_Cmp_True  true
808  *
809  *
810  *
811  *    ------------
812  *
813  *    In general, Phi nodes are automaitcally inserted.  In some cases, if
814  *    all predecessors of a block are known, an explicit Phi node constructor
815  *    is needed.  E.g., to construct a FIRM graph for a statement as
816  *      a = (b==c) ? 2 : 5;
817  *
818  *    ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
819  *    ---------------------------------------------------------
820  *
821  *    Creates a Phi node. The in's order has to correspond to the order
822  *    of in's of current_block.  This is not checked by the library!
823  *    If one of the predecessors is Unknown (as it has to be filled in
824  *    later) optimizations are skipped.  This is necessary to
825  *    construct Phi nodes in loops.
826  *
827  *    Parameter
828  *      arity            number of predecessors
829  *      **in             array with predecessors
830  *      *mode            The mode of it's inputs and output.
831  *    Inputs:
832  *      A Phi node has as many inputs as the block it belongs to.
833  *      Each input points to a definition of the same value on a
834  *      different path in the control flow.
835  *    Output
836  *      The definition valid in this block.
837  *
838  *    ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
839  *    -----------------------------------------------------------------------------------
840  *
841  *    Creates a Mux node. This node implements the following semantic:
842  *    If the sel node (which must be of mode_b) evaluates to true, its value is
843  *    ir_true, else ir_false;
844  *
845  *
846  *
847  *    OPERATIONS TO MANAGE MEMORY EXPLICITLY
848  *    --------------------------------------
849  *
850  *    ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode, ir_cons_flags flags)
851  *    -------------------------------------------------------------------------------------
852  *
853  *    The Load operation reads a value from memory.
854  *
855  *    Parameters:
856  *    *store        The current memory.
857  *    *addr         A pointer to the variable to be read in this memory.
858  *    *mode         The mode of the value to be loaded.
859  *     flags        Additional flags for alignment, volatility and pin state.
860  *
861  *    Inputs:
862  *      The memory and a pointer to a variable in this memory.
863  *    Output:
864  *      A tuple of the memory, a control flow to be taken in case of
865  *      an exception and the loaded value.
866  *
867  *    ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val, ir_cons_flags flags)
868  *    -------------------------------------------------------------------------------------
869  *
870  *    The Store operation writes a value to a variable in memory.
871  *
872  *    Inputs:
873  *      The memory, a pointer to a variable in this memory and the value
874  *      to write to this variable.
875  *    Output:
876  *      A tuple of the changed memory and a control flow to be taken in
877  *      case of an exception.
878  *
879  *    ir_node *new_Alloc (ir_node *store, ir_node *count, ir_type *alloc_type,
880  *    -----------------------------------------------------------------------
881  *                        where_alloc where)
882  *                        ------------------
883  *
884  *    The Alloc node allocates a new variable.  It can be specified whether the
885  *    variable should be allocated to the stack or to the heap.
886  *
887  *    Parameters:
888  *      *store       The memory which shall contain the new variable.
889  *      *count       This field is for allocating arrays, it specifies how
890  *                   many array elements are to be allocated.
891  *      *alloc_type  The type of the allocated variable. In case of allocating
892  *                   arrays this has to be the array type, not the type of the
893  *                   array elements.
894  *      where        Where to allocate the variable, either heap_alloc or stack_alloc.
895  *
896  *    Inputs:
897  *      A memory and an unsigned integer.
898  *    Output:
899  *      A tuple of the changed memory, a control flow to be taken in
900  *      case of an exception and the pointer to the new variable.
901  *    Attributes:
902  *      a.where          Indicates where the variable is allocated.
903  *      a.*type          A pointer to the class the allocated data object
904  *                       belongs to.
905  *
906  *    ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
907  *    -----------------------------------------------------------------------------------
908  *                        where_alloc where)
909  *                        ------------------
910  *
911  *    The Free node frees memory of the given variable.
912  *
913  *    Parameters:
914  *      *store       The memory which shall contain the new variable.
915  *      *ptr         The pointer to the object to free.
916  *      *size        The number of objects of type free_type to free in a sequence.
917  *      *free_type   The type of the freed variable.
918  *      where        Where the variable was allocated, either heap_alloc or stack_alloc.
919  *
920  *    Inputs:
921  *      A memory, a pointer and an unsigned integer.
922  *    Output:
923  *      The changed memory.
924  *    Attributes:
925  *      f.*type          A pointer to the type information of the freed data object.
926  *
927  *    Not Implemented!
928  *
929  *    ir_node *new_Sync (int arity, ir_node **in)
930  *    -------------------------------------------
931  *
932  *    The Sync operation unifies several partial memory blocks.  These blocks
933  *    have to be pairwise disjunct or the values in common locations have to
934  *    be identical.  This operation allows to specify all operations that eventually
935  *    need several partial memory blocks as input with a single entrance by
936  *    unifying the memories with a preceding Sync operation.
937  *
938  *    Parameters
939  *      arity    The number of memories to synchronize.
940  *      **in     An array of pointers to nodes that produce an output of
941  *               type memory.
942  *    Inputs
943  *      Several memories.
944  *    Output
945  *      The unified memory.
946  *
947  *
948  *    SPECIAL OPERATIONS
949  *    ------------------
950  *
951  *    ir_node *new_Bad (void)
952  *    -----------------------
953  *
954  *    Returns the unique Bad node current_ir_graph->bad.
955  *    This node is used to express results of dead code elimination.
956  *
957  *    ir_node *new_NoMem (void)
958  *    -----------------------------------------------------------------------------------
959  *
960  *    Returns the unique NoMem node current_ir_graph->no_mem.
961  *    This node is used as input for operations that need a Memory, but do not
962  *    change it like Div by const != 0, analyzed calls etc.
963  *
964  *    ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
965  *    ----------------------------------------------------------
966  *
967  *    Selects one entry of a tuple.  This is a hidden edge with attributes.
968  *
969  *    Parameters
970  *      *arg      A node producing a tuple.
971  *      *mode     The mode of the value to project.
972  *      proj      The position of the value in the tuple.
973  *    Input:
974  *      The tuple.
975  *    Output:
976  *      The value.
977  *
978  *    ir_node *new_Tuple (int arity, ir_node **in)
979  *    --------------------------------------------
980  *
981  *    Builds a Tuple from single values.  This is needed to implement
982  *    optimizations that remove a node that produced a tuple.  The node can be
983  *    replaced by the Tuple operation so that the following Proj nodes have not to
984  *    be changed.  (They are hard to find due to the implementation with pointers
985  *    in only one direction.)  The Tuple node is smaller than any other
986  *    node, so that a node can be changed into a Tuple by just changing it's
987  *    opcode and giving it a new in array.
988  *
989  *    Parameters
990  *      arity    The number of tuple elements.
991  *      **in     An array containing pointers to the nodes producing the
992  *               tuple elements.
993  *
994  *    ir_node *new_Id (ir_node *val, ir_mode *mode)
995  *    ---------------------------------------------
996  *
997  *    The single output of the Id operation is it's input.  Also needed
998  *    for optimizations.
999  *
1000  *
1001  *    HIGH LEVEL OPERATIONS
1002  *    ---------------------
1003  *
1004  *    ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
1005  *    -----------------------------------------------------------------------------------
1006  *
1007  *    Describes a high level block copy of a compound type from address src to
1008  *    address dst. Must be lowered to a Call to a runtime memory copy function.
1009  *
1010  *
1011  *    HIGH LEVEL OPERATIONS: Exception Support
1012  *    ----------------------------------------
1013  *    See TechReport 1999-14, chapter Exceptions.
1014  *
1015  *    ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
1016  *    -----------------------------------------------------------------------------------
1017  *
1018  *    Describes a high level type check. Must be lowered to a Call to a runtime check
1019  *    function.
1020  *
1021  *    ir_node *new_Raise (ir_node *store, ir_node *obj)
1022  *    -------------------------------------------------
1023  *
1024  *    Raises an exception.  Unconditional change of control flow.  Writes
1025  *    an explicit Except variable to memory to pass it to the exception
1026  *    handler.  Must be lowered to a Call to a runtime check
1027  *    function.
1028  *
1029  *    Inputs:
1030  *      The memory state.
1031  *      A pointer to the Except variable.
1032  *    Output:
1033  *      A tuple of control flow and the changed memory state.  The control flow
1034  *      points to the exception handler if it is definied in this procedure,
1035  *      else it points to the end_block.
1036  *
1037  *    ir_node *new_Bound  (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
1038  *    -----------------------------------------------------------------------------------
1039  *
1040  *    Describes a high level bounds check. Must be lowered to a Call to a runtime check
1041  *    function.
1042  *
1043  *    ir_node *new_Pin  (ir_node *node);
1044  *    -----------------------------------------------------------------------------------
1045  *
1046  *    Pin the value of the node node in the current block  No users of the Pin node can
1047  *    float above the Block of the Pin. The node cannot float behind this block. Often
1048  *    used to Pin the NoMem node.
1049  *
1050  *
1051  *    COPING WITH DATA OBJECTS
1052  *    ========================
1053  *
1054  *    Two kinds of data objects have to be distinguished for generating
1055  *    FIRM.  First there are local variables other than arrays that are
1056  *    known to be alias free.  Second there are all other data objects.
1057  *    For the first a common SSA representation is built, the second
1058  *    are modeled by saving them to memory.  The memory is treated as
1059  *    a single local variable, the alias problem is hidden in the
1060  *    content of this variable.
1061  *
1062  *    All values known in a Block are listed in the block's attribute,
1063  *    block.**graph_arr which is used to automatically insert Phi nodes.
1064  *    The following two functions can be used to add a newly computed value
1065  *    to the array, or to get the producer of a value, i.e., the current
1066  *    live value.
1067  *
1068  *    inline void set_value (int pos, ir_node *value)
1069  *    -----------------------------------------------
1070  *
1071  *    Has to be called for every assignment to a local variable.  It
1072  *    adds the value to the array of used values at position pos.  Pos
1073  *    has to be a unique identifier for an entry in the procedure's
1074  *    definition table.  It can be used to access the value again.
1075  *    Requires current_block to be set correctly.
1076  *
1077  *    ir_node *get_value (int pos, ir_mode *mode)
1078  *    -------------------------------------------
1079  *
1080  *    Returns the node defining the value referred to by pos. If the
1081  *    value is not defined in this block a Phi node is generated and
1082  *    all definitions reaching this Phi node are collected.  It can
1083  *    happen that the algorithm allocates an unnecessary Phi node,
1084  *    e.g. if there is only one definition of this value, but this
1085  *    definition reaches the currend block on several different
1086  *    paths.  This Phi node will be eliminated if optimizations are
1087  *    turned on right after it's creation.
1088  *    Requires current_block to be set correctly.
1089  *
1090  *    There are two special routines for the global store:
1091  *
1092  *    void set_store (ir_node *store)
1093  *    -------------------------------
1094  *
1095  *    Adds the store to the array of known values at a reserved
1096  *    position.
1097  *    Requires current_block to be set correctly.
1098  *
1099  *    ir_node *get_store (void)
1100  *    -------------------------
1101  *
1102  *    Returns the node defining the actual store.
1103  *    Requires current_block to be set correctly.
1104  *
1105  *
1106  *    inline void keep_alive (ir_node *ka)
1107  *    ------------------------------------
1108  *
1109  *    Keep this node alive because it is (might be) not in the control
1110  *    flow from Start to End.  Adds the node to the list in the end
1111  *   node.
1112  *
1113  */
1114 #ifndef FIRM_IR_IRCONS_H
1115 #define FIRM_IR_IRCONS_H
1116
1117 #include "firm_types.h"
1118 #include "begin.h"
1119 #include "irnode.h"
1120
1121 /*-------------------------------------------------------------------------*/
1122 /* The raw interface                                                       */
1123 /*-------------------------------------------------------------------------*/
1124
1125 /**
1126  * Constructor for a Const node.
1127  *
1128  * Adds the node to the start block.
1129  *
1130  * Constructor for a Const node. The constant represents a target
1131  * value.  Sets the type information to type_unknown.  (No more
1132  * supported: If tv is entity derives a somehow useful type.)
1133  *
1134  * @param *db    A pointer for debug information.
1135  * @param *irg   The IR graph the node  belongs to.
1136  * @param *mode  The mode of the operands and results.
1137  * @param value  A value from which the tarval is made.
1138  */
1139 FIRM_API ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg,
1140                                     ir_mode *mode, long value);
1141
1142 /** Constructor for a SymConst node.
1143  *
1144  *  This is the constructor for a symbolic constant.
1145  *    There are several kinds of symbolic constants:
1146  *    - symconst_type_tag   The symbolic constant represents a type tag.  The
1147  *                          type the tag stands for is given explicitly.
1148  *    - symconst_type_size  The symbolic constant represents the size of a type.
1149  *                          The type of which the constant represents the size
1150  *                          is given explicitly.
1151  *    - symconst_type_align The symbolic constant represents the alignment of a
1152  *                          type.  The type of which the constant represents the
1153  *                          size is given explicitly.
1154  *    - symconst_addr_ent   The symbolic constant represents the address of an
1155  *                          entity (variable or method).  The variable is given
1156  *                          explicitly by a firm entity.
1157  *    - symconst_ofs_ent    The symbolic constant represents the offset of an
1158  *                          entity in its owner type.
1159  *    - symconst_enum_const The symbolic constant is a enumeration constant of
1160  *                          an enumeration type.
1161  *
1162  *    Inputs to the node:
1163  *      No inputs except the block it belongs to.
1164  *    Outputs of the node.
1165  *      An unsigned integer (I_u) or a pointer (P).
1166  *
1167  *    Mention union in declaration so that the firmjni generator recognizes that
1168  *    it can not cast the argument to an int.
1169  *
1170  * @param *db     A pointer for debug information.
1171  * @param *irg    The IR graph the node  belongs to.
1172  * @param mode    The mode for the SymConst.
1173  * @param val     A type, ident, entity or enum constant depending on the
1174  *                SymConst kind.
1175  * @param kind    The kind of the symbolic constant, see the list above
1176  */
1177 FIRM_API ir_node *new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode,
1178                                   union symconst_symbol value,
1179                                   symconst_kind kind);
1180
1181 /** Constructor for a SymConst addr_ent node.
1182  *
1183  * Same as new_rd_SymConst, except that the constructor is tailored for
1184  * symconst_addr_ent.
1185  * Adds the SymConst to the start block of irg. */
1186 FIRM_API ir_node *new_rd_SymConst_addr_ent(dbg_info *db, ir_graph *irg,
1187                                            ir_mode *mode, ir_entity *symbol);
1188
1189 /** Constructor for a SymConst ofs_ent node.
1190  *
1191  * Same as new_rd_SymConst, except that the constructor is tailored for
1192  * symconst_ofs_ent.
1193  * Adds the SymConst to the start block of irg.
1194  */
1195 FIRM_API ir_node *new_rd_SymConst_ofs_ent(dbg_info *db, ir_graph *irg,
1196                                           ir_mode *mode, ir_entity *symbol);
1197
1198 /** Constructor for a SymConst type_tag node.
1199  *
1200  * Same as new_rd_SymConst, except that the constructor is tailored for
1201  * symconst_type_tag.
1202  * Adds the SymConst to the start block of irg.
1203  */
1204 FIRM_API ir_node *new_rd_SymConst_type_tag(dbg_info *db, ir_graph *irg,
1205                                            ir_mode *mode, ir_type *symbol);
1206
1207 /** Constructor for a SymConst size node.
1208  *
1209  * Same as new_rd_SymConst, except that the constructor is tailored for
1210  * symconst_type_size.
1211  * Adds the SymConst to the start block of irg. */
1212 FIRM_API ir_node *new_rd_SymConst_size(dbg_info *db, ir_graph *irg,
1213                                        ir_mode *mode, ir_type *symbol);
1214
1215 /** Constructor for a SymConst size node.
1216  *
1217  * Same as new_rd_SymConst, except that the constructor is tailored for
1218  * symconst_type_align.
1219  * Adds the SymConst to the start block of irg.
1220  */
1221 FIRM_API ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg,
1222                                         ir_mode *mode, ir_type *symbol);
1223
1224 /** Constructor for a simpleSel node.
1225  *
1226  *  This is a shortcut for the new_rd_Sel() constructor.  To be used for
1227  *  Sel nodes that do not select from an array, i.e., have no index
1228  *  inputs.  It adds the two parameters 0, NULL.
1229  *
1230  * @param   *db        A pointer for debug information.
1231  * @param   *block     The IR block the node belongs to.
1232  * @param   *store     The memory in which the object the entity should be
1233  *                     selected from is allocated.
1234  * @param   *objptr    The object from that the Sel operation selects a
1235  *                     single attribute out.
1236  * @param   *ent       The entity to select.
1237  */
1238 FIRM_API ir_node *new_rd_simpleSel(dbg_info *db, ir_node *block, ir_node *store,
1239                                    ir_node *objptr, ir_entity *ent);
1240
1241 /** Constructor for a remainderless Div node.
1242  *
1243  * @param   *db    A pointer for debug information.
1244  * @param   *block The IR block the node belongs to.
1245  * @param   *memop The store needed to model exceptions
1246  * @param   *op1   The first operand.
1247  * @param   *op2   The second operand.
1248  * @param   *mode  The mode of the result.
1249  * @param   state  The pinned state.
1250  */
1251 FIRM_API ir_node *new_rd_DivRL(dbg_info *db, ir_node *block, ir_node *memop,
1252                                ir_node *op1, ir_node *op2, ir_mode *mode,
1253                                op_pin_state state);
1254
1255 /** Constructor for a strictConv node.
1256  *
1257  * @param   *db    A pointer for debug information.
1258  * @param   *block The IR block the node belongs to.
1259  * @param   *op    The operand.
1260  * @param   *mode  The mode of this the operand muss be converted .
1261  */
1262 FIRM_API ir_node *new_rd_strictConv(dbg_info *db, ir_node *block,
1263                                     ir_node *op, ir_mode *mode);
1264
1265 /** Constructor for a defaultProj node.
1266  *
1267  * Represents the default control flow of a Switch-Cond node.
1268  *
1269  * @param *db       A pointer for debug information.
1270  * @param arg       A node producing a tuple.
1271  * @param max_proj  The end position of the value in the tuple.
1272  */
1273 FIRM_API ir_node *new_rd_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
1274
1275 /** Constructor for an ASM pseudo node.
1276  *
1277  * @param *db         A pointer for debug information.
1278  * @param *block      The block the node belong to.
1279  * @param arity       The number of data inputs to the node.
1280  * @param *in         The array of length arity of data inputs.
1281  * @param *inputs     The array of length arity of input constraints.
1282  * @param n_outs      The number of data outputs to the node.
1283  * @param *outputs    The array of length n_outs of output constraints.
1284  * @param n_clobber   The number of clobbered registers.
1285  * @param *clobber    The array of length n_clobber of clobbered registers.
1286  * @param *asm_text   The assembler text.
1287  */
1288 FIRM_API ir_node *new_rd_ASM(dbg_info *db, ir_node *block,
1289                             int arity, ir_node *in[], ir_asm_constraint *inputs,
1290                             int n_outs, ir_asm_constraint *outputs,
1291                             int n_clobber, ident *clobber[], ident *asm_text);
1292
1293 /*-------------------------------------------------------------------------*/
1294 /* The raw interface without debug support                                 */
1295 /*-------------------------------------------------------------------------*/
1296
1297 /** Constructor for a Const node.
1298  *
1299  * Adds the node to the start block.
1300  *
1301  * Constructor for a Const node. The constant represents a target
1302  * value.  Sets the type information to type_unknown.  (No more
1303  * supported: If tv is entity derives a somehow useful type.)
1304  *
1305  * @param *irg   The IR graph the node  belongs to.
1306  * @param *mode  The mode of the operands and the results.
1307  * @param value  A value from which the tarval is made.
1308  */
1309 FIRM_API ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value);
1310
1311 /** Constructor for a SymConst node.
1312  *
1313  *  This is the constructor for a symbolic constant.
1314  *    There are several kinds of symbolic constants:
1315  *    - symconst_type_tag   The symbolic constant represents a type tag.  The
1316  *                          type the tag stands for is given explicitly.
1317  *    - symconst_type_size  The symbolic constant represents the size of a type.
1318  *                          The type of which the constant represents the size
1319  *                          is given explicitly.
1320  *    - symconst_type_align The symbolic constant represents the alignment of a
1321  *                          type.  The type of which the constant represents the
1322  *                          size is given explicitly.
1323  *    - symconst_addr_ent   The symbolic constant represents the address of an
1324  *                          entity (variable or method).  The variable is given
1325  *                          explicitly by a firm entity.
1326  *    - symconst_ofs_ent    The symbolic constant represents the offset of an
1327  *                          entity in its owner type.
1328  *    - symconst_enum_const The symbolic constant is a enumeration constant of
1329  *                          an enumeration type.
1330  *
1331  *    Inputs to the node:
1332  *      No inputs except the block it belongs to.
1333  *    Outputs of the node.
1334  *      An unsigned integer (I_u) or a pointer (P).
1335  *
1336  *    Mention union in declaration so that the firmjni generator recognizes that
1337  *    it can not cast the argument to an int.
1338  *
1339  * @param *irg    The IR graph the node  belongs to.
1340  * @param mode    The mode for the SymConst.
1341  * @param value   A type, ident, entity or enum constant depending on the
1342  *                SymConst kind.
1343  * @param kind    The kind of the symbolic constant, see the list above
1344  */
1345 FIRM_API ir_node *new_r_SymConst(ir_graph *irg, ir_mode *mode,
1346                                  union symconst_symbol value,
1347                                  symconst_kind kind);
1348
1349 /** Constructor for a simpleSel node.
1350  *
1351  *  This is a shortcut for the new_d_Sel() constructor.  To be used for
1352  *  Sel nodes that do not select from an array, i.e., have no index
1353  *  inputs.  It adds the two parameters 0, NULL.
1354  *
1355  * @param *block     The IR block the node belongs to.
1356  * @param *store     The memory in which the object the entity should be selected
1357  *                   from is allocated.
1358  * @param *objptr    The object from that the Sel operation selects a
1359  *                   single attribute out.
1360  * @param *ent       The entity to select.
1361  */
1362 FIRM_API ir_node *new_r_simpleSel(ir_node *block, ir_node *store,
1363                                   ir_node *objptr, ir_entity *ent);
1364
1365 /** Constructor for a remainderless Div node.
1366  *
1367  * @param *block The IR block the node belongs to.
1368  * @param *memop The store needed to model exceptions
1369  * @param *op1   The first operand.
1370  * @param *op2   The second operand.
1371  * @param *mode  The mode of the result.
1372  * @param state  The pinned state.
1373  */
1374 FIRM_API ir_node *new_r_DivRL(ir_node *block, ir_node *memop,
1375                               ir_node *op1, ir_node *op2, ir_mode *mode,
1376                               op_pin_state state);
1377 /** Constructor for a strict Conv node.
1378  *
1379  * @param *block The IR block the node belongs to.
1380  * @param *op    The operand.
1381  * @param *mode  The mode of this the operand muss be converted .
1382  */
1383 FIRM_API ir_node *new_r_strictConv(ir_node *block, ir_node *op, ir_mode *mode);
1384
1385 /** Constructor for a defaultProj node.
1386  *
1387  * Represents the default control flow of a Switch-Cond node.
1388  *
1389  * @param arg       A node producing a tuple.
1390  * @param max_proj  The end  position of the value in the tuple.
1391  */
1392 FIRM_API ir_node *new_r_defaultProj(ir_node *arg, long max_proj);
1393
1394 /** Constructor for an ASM pseudo node.
1395  *
1396  * @param *block      The block the node belong to.
1397  * @param arity       The number of data inputs to the node.
1398  * @param *in         The array of length arity of data inputs.
1399  * @param *inputs     The array of length arity of input constraints.
1400  * @param n_outs      The number of data outputs to the node.
1401  * @param *outputs    The array of length n_outs of output constraints.
1402  * @param n_clobber   The number of clobbered registers.
1403  * @param *clobber    The array of length n_clobber of clobbered registers.
1404  * @param *asm_text   The assembler text.
1405  */
1406 FIRM_API ir_node *new_r_ASM(ir_node *block,
1407                             int arity, ir_node *in[], ir_asm_constraint *inputs,
1408                             int n_outs, ir_asm_constraint *outputs,
1409                             int n_clobber, ident *clobber[], ident *asm_text);
1410
1411 /*-----------------------------------------------------------------------*/
1412 /* The block oriented interface                                          */
1413 /*-----------------------------------------------------------------------*/
1414
1415 /** Sets the current block in which the following constructors place the
1416  *  nodes they construct.
1417  *
1418  *  @param target  The new current block.
1419  */
1420 FIRM_API void set_cur_block(ir_node *target);
1421 FIRM_API void set_r_cur_block(ir_graph *irg, ir_node *target);
1422
1423 /** Returns the current block of the current graph. */
1424 FIRM_API ir_node *get_cur_block(void);
1425 FIRM_API ir_node *get_r_cur_block(ir_graph *irg);
1426
1427 /**
1428  * @see new_rd_Const_long()
1429  *
1430  * @param *db    A pointer for debug information.
1431  * @param *mode  The mode of the operands and results.
1432  * @param value  A value from which the tarval is made.
1433  */
1434 FIRM_API ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value);
1435
1436 /** Constructor for a SymConst node.
1437  *
1438  *  This is the constructor for a symbolic constant.
1439  *    There are several kinds of symbolic constants:
1440  *    - symconst_type_tag   The symbolic constant represents a type tag.  The
1441  *                          type the tag stands for is given explicitly.
1442  *    - symconst_type_size  The symbolic constant represents the size of a type.
1443  *                          The type of which the constant represents the size
1444  *                          is given explicitly.
1445  *    - symconst_type_align The symbolic constant represents the alignment of a
1446  *                          type.  The type of which the constant represents the
1447  *                          size is given explicitly.
1448  *    - symconst_addr_ent   The symbolic constant represents the address of an
1449  *                          entity (variable or method).  The variable is given
1450  *                          explicitly by a firm entity.
1451  *    - symconst_ofs_ent    The symbolic constant represents the offset of an
1452  *                          entity in its owner type.
1453  *    - symconst_enum_const The symbolic constant is a enumeration constant of
1454  *                          an enumeration type.
1455  *
1456  *    Inputs to the node:
1457  *      No inputs except the block it belongs to.
1458  *    Outputs of the node.
1459  *      An unsigned integer (I_u) or a pointer (P).
1460  *
1461  *    Mention union in declaration so that the firmjni generator recognizes that
1462  *    it can not cast the argument to an int.
1463  *
1464  * @param *db     A pointer for debug information.
1465  * @param mode    The mode for the SymConst.
1466  * @param value   A type, ident, entity or enum constant depending on the
1467  *                SymConst kind.
1468  * @param kind    The kind of the symbolic constant, see the list above
1469  */
1470 FIRM_API ir_node *new_d_SymConst(dbg_info *db, ir_mode *mode,
1471                                  union symconst_symbol value,
1472                                  symconst_kind kind);
1473
1474 /** Constructor for a simpleSel node.
1475  *
1476  *  This is a shortcut for the new_d_Sel() constructor.  To be used for
1477  *  Sel nodes that do not select from an array, i.e., have no index
1478  *  inputs.  It adds the two parameters 0, NULL.
1479  *
1480  * @param   *db        A pointer for debug information.
1481  * @param   *store     The memory in which the object the entity should be
1482  *                     selected from is allocated.
1483  * @param   *objptr    The object from that the Sel operation selects a
1484  *                     single attribute out.
1485  * @param   *ent       The entity to select.
1486  */
1487 FIRM_API ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr,
1488                                   ir_entity *ent);
1489 /** Constructor for a remainderless Div node.
1490  *
1491  * Adds the node to the block in current_ir_block.
1492  *
1493  * @param   *db    A pointer for debug information.
1494  * @param   *memop The store needed to model exceptions
1495  * @param   *op1   The first operand.
1496  * @param   *op2   The second operand.
1497  * @param   *mode  The mode of the result.
1498  * @param   state  The pinned state.
1499  */
1500 FIRM_API ir_node *new_d_DivRL(dbg_info *db, ir_node *memop,
1501                               ir_node *op1, ir_node *op2, ir_mode *mode,
1502                               op_pin_state state);
1503 /** Constructor for a strict Conv node.
1504  *
1505  * Adds the node to the block in current_ir_block.
1506  *
1507  * @param   *db    A pointer for debug information.
1508  * @param   *op    The operand.
1509  * @param   *mode  The mode of this the operand muss be converted .
1510  */
1511 FIRM_API ir_node *new_d_strictConv(dbg_info *db, ir_node *op, ir_mode *mode);
1512
1513 /** Constructor for a defaultProj node.
1514  *
1515  * Represents the default control flow of a Switch-Cond node.
1516  * Adds the node to the block in current_ir_block.
1517  *
1518  * @param *db       A pointer for debug information.
1519  * @param arg       A node producing a tuple.
1520  * @param max_proj  The end  position of the value in the tuple.
1521  */
1522 FIRM_API ir_node *new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
1523
1524 /** Constructor for an ASM pseudo node.
1525  *
1526  * @param *db         A pointer for debug information.
1527  * @param arity       The number of data inputs to the node.
1528  * @param *in         The array of length arity of data inputs.
1529  * @param *inputs     The array of length arity of input constraints.
1530  * @param n_outs      The number of data outputs to the node.
1531  * @param *outputs    The array of length n_outs of output constraints.
1532  * @param n_clobber   The number of clobbered registers.
1533  * @param *clobber    The array of length n_clobber of clobbered registers.
1534  * @param *asm_text   The assembler text.
1535  */
1536 FIRM_API ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[],
1537                             ir_asm_constraint *inputs,
1538                             int n_outs, ir_asm_constraint *outputs,
1539                             int n_clobber, ident *clobber[], ident *asm_text);
1540
1541 /*-----------------------------------------------------------------------*/
1542 /* The block oriented interface without debug support                    */
1543 /*-----------------------------------------------------------------------*/
1544
1545 /**
1546  * Make a const from a long.
1547  * This is just convenience for the usual
1548  * <code>
1549  * new_Const(mode, tarval_from_long(mode, ...))
1550  * </code>
1551  * pain.
1552  * @param mode The mode for the const.
1553  * @param value The value of the constant.
1554  * @return A new const node.
1555  */
1556 FIRM_API ir_node *new_Const_long(ir_mode *mode, long value);
1557
1558 /** Constructor for a SymConst node.
1559  *
1560  *  This is the constructor for a symbolic constant.
1561  *    There are several kinds of symbolic constants:
1562  *    - symconst_type_tag   The symbolic constant represents a type tag.  The
1563  *                          type the tag stands for is given explicitly.
1564  *    - symconst_type_size  The symbolic constant represents the size of a type.
1565  *                          The type of which the constant represents the size
1566  *                          is given explicitly.
1567  *    - symconst_type_align The symbolic constant represents the alignment of a
1568  *                          type.  The type of which the constant represents the
1569  *                          size is given explicitly.
1570  *    - symconst_addr_ent   The symbolic constant represents the address of an
1571  *                          entity (variable or method).  The variable is given
1572  *                          explicitly by a firm entity.
1573  *    - symconst_ofs_ent    The symbolic constant represents the offset of an
1574  *                          entity in its owner type.
1575  *    - symconst_enum_const The symbolic constant is a enumeration constant of
1576  *                          an enumeration type.
1577  *
1578  *    Inputs to the node:
1579  *      No inputs except the block it belongs to.
1580  *    Outputs of the node.
1581  *      An unsigned integer (I_u) or a pointer (P).
1582  *
1583  *    Mention union in declaration so that the firmjni generator recognizes that
1584  *    it can not cast the argument to an int.
1585  *
1586  * @param mode    The mode for the SymConst.
1587  * @param value   A type, ident, entity or enum constant depending on the
1588  *                SymConst kind.
1589  * @param kind    The kind of the symbolic constant, see the list above
1590  */
1591 FIRM_API ir_node *new_SymConst(ir_mode *mode, union symconst_symbol value,
1592                                symconst_kind kind);
1593
1594 /** Constructor for a simpelSel node.
1595  *
1596  *  This is a shortcut for the new_Sel() constructor.  To be used for
1597  *  Sel nodes that do not select from an array, i.e., have no index
1598  *  inputs.  It adds the two parameters 0, NULL.
1599  *
1600  * @param   *store     The memory in which the object the entity should be selected from is allocated.
1601  * @param   *objptr    The object from that the Sel operation selects a single attribute out.
1602  * @param   *ent       The entity to select.
1603  */
1604 FIRM_API ir_node *new_simpleSel(ir_node *store, ir_node *objptr,
1605                                 ir_entity *ent);
1606
1607 /** Constructor for a remainderless Div node.
1608  *
1609  * Adds the node to the block in current_ir_block.
1610  *
1611  * @param   *memop The store needed to model exceptions
1612  * @param   *op1   The first operand.
1613  * @param   *op2   The second operand.
1614  * @param   *mode  The mode of the result.
1615  * @param   state  The pinned state.
1616  */
1617 FIRM_API ir_node *new_DivRL(ir_node *memop, ir_node *op1, ir_node *op2,
1618                             ir_mode *mode, op_pin_state state);
1619
1620 /** Constructor for a strict Conv node.
1621  *
1622  * Adds the node to the block in current_ir_block.
1623  *
1624  * @param   *op          The operand.
1625  * @param   *mode        The mode of this the operand muss be converted.
1626  */
1627 FIRM_API ir_node *new_strictConv(ir_node *op, ir_mode *mode);
1628
1629 /** Constructor for a defaultProj node.
1630  *
1631  * Represents the default control flow of a Switch-Cond node.
1632  * Adds the node to the block in current_ir_block.
1633  *
1634  * @param arg       A node producing a tuple.
1635  * @param max_proj  The end  position of the value in the tuple.
1636  */
1637 FIRM_API ir_node *new_defaultProj(ir_node *arg, long max_proj);
1638
1639 /** Constructor for an ASM pseudo node.
1640  *
1641  * @param arity       The number of data inputs to the node.
1642  * @param *in         The array of length arity of data inputs.
1643  * @param *inputs     The array of length arity of input constraints.
1644  * @param n_outs      The number of data outputs to the node.
1645  * @param *outputs    The array of length n_outs of output constraints.
1646  * @param n_clobber   The number of clobbered registers.
1647  * @param *clobber    The array of length n_clobber of clobbered registers.
1648  * @param *asm_text   The assembler text.
1649  */
1650 FIRM_API ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
1651                           int n_outs, ir_asm_constraint *outputs,
1652                           int n_clobber, ident *clobber[], ident *asm_text);
1653
1654 /*---------------------------------------------------------------------*/
1655 /* The comfortable interface.                                          */
1656 /* Supports automatic Phi node construction.                           */
1657 /* All routines of the block oriented interface except new_Block are   */
1658 /* needed also.                                                        */
1659 /*---------------------------------------------------------------------*/
1660
1661 /** Create an immature Block.
1662  *
1663  * An immature Block has an unknown number of predecessors.  Predecessors
1664  * can be added with add_immBlock_pred().  Once all predecessors are
1665  * added the block must be matured.
1666  *
1667  * Adds the block to the graph in current_ir_graph. Can be used with automatic
1668  * Phi node construction.
1669  * This constructor can only be used if the graph is in state_building.
1670  */
1671 FIRM_API ir_node *new_d_immBlock(dbg_info *db);
1672 FIRM_API ir_node *new_immBlock(void);
1673 FIRM_API ir_node *new_r_immBlock(ir_graph *irg);
1674 FIRM_API ir_node *new_rd_immBlock(dbg_info *db, ir_graph *irg);
1675
1676 /** Add a control flow edge to an immature block. */
1677 FIRM_API void add_immBlock_pred(ir_node *immblock, ir_node *jmp);
1678
1679 /** Finalize a Block node, when all control flows are known. */
1680 FIRM_API void mature_immBlock(ir_node *block);
1681
1682 /** Get the current value of a local variable.
1683  *
1684  * Use this function to obtain the last definition of the local variable
1685  * associated with pos.  Pos may not exceed the value passed as n_loc
1686  * to new_ir_graph.  This call automatically inserts Phi nodes.
1687  *
1688  * @param *db    A pointer for debug information.
1689  * @param  pos   The position/id of the local variable.
1690  * @param *mode  The mode of the value to get.
1691  */
1692 FIRM_API ir_node *get_value(int pos, ir_mode *mode);
1693 FIRM_API ir_node *get_r_value(ir_graph *irg, int pos, ir_mode *mode);
1694
1695 /**
1696  * Try to guess the mode of a local variable.
1697  * This is done by recursively going up the control flow graph until
1698  * we find a definition for the variable. The mode of the first found
1699  * definition is returned. NULL in case no definition is found.
1700  *
1701  * @param  pos   The position/id of the local variable.
1702  */
1703 FIRM_API ir_mode *ir_guess_mode(int pos);
1704 FIRM_API ir_mode *ir_r_guess_mode(ir_graph *irg, int pos);
1705
1706 /** Remark a new definition of a variable.
1707  *
1708  * Use this function to remember a new definition of the value
1709  * associated with pos. Pos may not exceed the value passed as n_loc
1710  * to new_ir_graph.  This call is needed to automatically inserts Phi
1711  * nodes.
1712  *
1713  * @param  pos   The position/id of the local variable.
1714  * @param *value The new value written to the local variable.
1715  */
1716 FIRM_API void set_value(int pos, ir_node *value);
1717 FIRM_API void set_r_value(ir_graph *irg, int pos, ir_node *value);
1718
1719 /**
1720  * Find the value number for a node in the current block.
1721  *
1722  * @param value  the searched value
1723  *
1724  * @return the value number of the value or -1 if this value has
1725  * no value number in the current block.
1726  */
1727 FIRM_API int find_value(ir_node *value);
1728 FIRM_API int r_find_value(ir_graph *irg, ir_node *value);
1729
1730 /** Get the current memory state.
1731  *
1732  * Use this function to obtain the last definition of the memory
1733  * state.  This call automatically inserts Phi nodes for the memory
1734  * state value.
1735  */
1736 FIRM_API ir_node *get_store(void);
1737 FIRM_API ir_node *get_r_store(ir_graph *irg);
1738
1739 /** Remark a new definition of the memory state.
1740  *
1741  * Use this function to remember a new definition of the memory state.
1742  * This call is needed to automatically inserts Phi nodes.
1743  *
1744  * @param *store The new memory state.
1745  */
1746 FIRM_API void set_store(ir_node *store);
1747 FIRM_API void set_r_store(ir_graph *irg, ir_node *store);
1748
1749 /** keep this node alive even if End is not control-reachable from it
1750  *
1751  * @param ka The node to keep alive.
1752  */
1753 FIRM_API void keep_alive(ir_node *ka);
1754 FIRM_API void r_keep_alive(ir_graph *irg, ir_node *ka);
1755
1756 /* --- initialize and finalize IR construction --- */
1757
1758 /** Puts the graph into state "phase_high" */
1759 FIRM_API void irg_finalize_cons(ir_graph *irg);
1760
1761 /** Puts the program and all graphs into state phase_high.
1762  *
1763  * This also remarks, the construction of types is finished,
1764  * e.g., that no more subtypes will be added.  */
1765 FIRM_API void irp_finalize_cons(void);
1766
1767 FIRM_API void ir_set_uninitialized_local_variable_func(
1768                 uninitialized_local_variable_func_t *func);
1769
1770 #include "end.h"
1771
1772 #endif