Don't now what changed...
[libfirm] / ir / ir / ircons.h
1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
3 **
4 ** Authors: Martin Trapp, Christian Schaefer,
5 **          Goetz Lindenmaier
6 **
7 ** ircons.h ir node construction
8 */
9
10
11 /** !!!
12 *** Ideas for imrovement:
13 ***
14  Handle construction of exceptions more comfortable:
15  Add new constructors that pass the exception region (or better the
16  Phi for the memories, the ex. region can be found from there) as parameter,
17  constructor then adds all Proj nodes and returns the pointer
18  to the Proj node that selects the result of the arithmetic operation.
19
20  Maybe hide the exception region in a global variable, especially if
21  it is always unambiguous.
22 **/
23
24 /****h* libfirm/ircons
25  *
26  * NAME
27  *   file ircons.h
28  *
29  * NOTES
30  *    This file documents all datatypes and constructors needed to
31  *    build a FIRM representation of a pocedure.  The constructors are
32  *    also implemented in this file.
33  *
34  *    The documentation also gives a short manual how to use the library.
35  *
36  *    For extensive documentation of FIRM see UKA Techreport 1999-14.
37  *
38  *    DATATYPES
39  *    =========
40  *
41  *    The struct ir_graph
42  *    -------------------
43  *
44  *      This struct contains all information about a procedure.
45  *      It's allocated directly to memory.
46  *
47  *      The fields of ir_graph:
48  *
49  *      *ent             The entity describing this procedure.
50  *
51  *      The beginning and end of a graph:
52  *
53  *      *start_block     This ir_node is the block that contains the unique
54  *                       start node of the procedure.  With it it contains
55  *                       the Proj's on starts results.
56  *                       Further all Const nodes are placed in the start block.
57  *      *start           This ir_node is the unique start node of the procedure.
58  *
59  *      *end_block       This ir_node is the block that contains the unique
60  *                       end node of the procedure.  This block contains no
61  *                       further nodes.
62  *      *end             This ir_node is the unique end node of the procedure.
63  *
64  *      The following nodes are Projs from the start node, held in ir_graph for
65  *      simple access:
66  *
67  *      *frame           The ir_node producing the pointer to the stack frame of
68  *                       the procedure as output.  This is the Proj node on the
69  *                       third output of the start node.  This output of the start
70  *                       node is tagged as pns_frame_base.  In FIRM most lokal
71  *                       variables are modeled as data flow edges.  Static
72  *                       allocated arrays can not be represented as dataflow
73  *                       edges. Therefore FIRM has to represent them in the stack
74  *                       frame.
75  *
76  *      *globals             This models a pointer to a space in the memory where
77  *                   _all_ global things are held.  Select from this pointer
78  *                   with a Sel node the pointer to a global variable /
79  *                   procedure / compiler known function... .
80  *
81  *      *args        The ir_node that produces the arguments of the method as
82  *                   it's result.  This is a Proj node on the fourth output of
83  *                   the start node.  This output is tagged as pns_args.
84  *
85  *      *bad             The bad node is an auxiliary node. It is needed only once,
86  *                       so there is this globally reachable node.
87  *
88  *      Datastructures that are private to a graph:
89  *
90  *      *obst            An obstack that contains all nodes.
91  *
92  *      *current_block   A pointer to the current block.  Any node created with
93  *                       one of the node constructors (new_<opcode>) are assigned
94  *                       to this block.  It can be set with switch_block(block).
95  *                       Only needed for ir construction.
96  *
97  *      params/n_loc     An int giving the number of local variables in this
98  *                   procedure.  This is neede for ir construction. Name will
99  *                   be changed.
100  *
101  *      *value_table     This hash table (pset) is used for global value numbering
102  *                   for optimizing use in iropt.c.
103  *
104  *      *Phi_in_stack;   a stack needed for automatic Phi construction, needed only
105  *                   during ir construction.
106  *
107  *      visited          A int used as flag to traverse the ir_graph.
108  *
109  *      block_visited    A int used as a flag to traverse block nodes in the graph.
110  *
111  *    Three kinds of nodes
112  *    --------------------
113  *
114  *      There are three kinds of nodes known to the ir:  entities,
115  *      types, and ir_nodes
116  *
117  *      + ir_nodes are the actual nodes of the FIRM intermediate representation.
118  *        They represent operations on the data of the program and control flow
119  *        operations.
120  *
121  *      + entity ==> implemented in entity.h
122  *        Refers to a single entity of the compiled program, e.g. a field of a
123  *        class or a method.  If a method or variable can not be assigned to
124  *        a method or class or the like, it is a global object.
125  *
126  *      + types ==> implemented in type.h
127  *        With types type information is represented.  There are several type
128  *        nodes.
129  *
130  *    Implementation of the FIRM operations: ir_node
131  *    ----------------------------------------------
132  *
133  *      Ir_nodes represent operations on the data of the program and control flow
134  *      operations.  Examples of ir_nodes:  Add, Jmp, Cmp
135  *
136  *      FIRM is a dataflow graph.  A dataflow graph is a directed graph,
137  *      so that every node has incoming and outgoing edges.  A node is
138  *      executable if every input at it's incoming edges is available.
139  *      Execution of the dataflow graph is started at the Start node which
140  *      has no incoming edges and ends when the End node executes, even if
141  *      there are still executable or not executed nodes.  (Is this true,
142  *      or must all executable nodes be executed?)  (There are exceptions
143  *      to the dataflow paradigma that all inputs have to be available
144  *      before a node can execute: Phi, Block.  See UKA Techreport
145  *      1999-14.)
146  *
147  *      The implementation of FIRM differs from the view as a dataflow
148  *      graph.  To allow fast traversion of the graph edges are
149  *      implemented as C-pointers.  Inputs to nodes are not ambiguous, the
150  *      results can be used by several other nodes.  Each input can be
151  *      implemented as a single pointer to a predecessor node, outputs
152  *      need to be lists of pointers to successors.  Therefore a node
153  *      contains pointers to it's predecessor so that the implementation is a
154  *      dataflow graph with reversed edges.  It has to be traversed bottom
155  *      up.
156  *
157  *      All nodes of the ir have the same basic structure.  They are
158  *      distinguished by a field containing the opcode.
159  *
160  *      The fields of an ir_node:
161  *
162  *      kind             A firm_kind tag containing k_ir_node.  This is useful for
163  *                       dynamically checking the type of a node.
164  *
165  *      *op              This ir_op gives the opcode as a tag and a string
166  *                       and the number of attributes of an ir_node.  There is
167  *                       one statically allocated struct ir_op for each opcode.
168  *
169  *      *mode            The ir_mode of the operation represented by this firm
170  *                       node.  The mode of the operation is the mode of it's
171  *                       result.  A Firm mode is a datatype as known to the target,
172  *                   not a type of the source language.
173  *
174  *      visit            A flag for traversing the ir.
175  *
176  *      **in             An array with pointers to the node's predecessors.
177  *
178  *      *link            A pointer to an ir_node.  With this pointer all Phi nodes
179  *                       are attached to a Block, i.e., a Block points to it's
180  *                       first Phi node, this node points to the second Phi node
181  *                       in the Block and so fourth.  Used in mature_block
182  *                       to find all Phi nodes to be matured.  It's also used to
183  *                   annotate a node with a better, optimized version of it.
184  *
185  *      attr             An attr struct containing the attributes of the nodes. The
186  *                       attributes depend on the opcode of the node.  The number
187  *                   of these attributes is given in op.
188  *
189  *    The struct ir_op
190  *    ----------------
191  *                       Not yet documented. See irop.h.
192  *
193  *    The struct ir_mode
194  *    ------------------
195  *                       Not yet documented. See irmode.h.
196  *
197  *    GLOBAL VARIABLES
198  *    ================
199  *
200  *    current_ir_graph   Points to the current ir_graph.  All constructors for
201  *                       nodes add nodes to this graph.
202  *
203  *    ir_visited         An int used as flag to traverse the ir_graph.
204  *
205  *    block_visited      An int used as a flag to traverse block nodes in the
206  *                       graph.
207  *
208  *                       Others not yet documented.
209  *
210  *
211  *
212  *    CONSTRUCTOR FOR IR_GRAPH
213  *    ========================
214  *
215  *    ir_graph *new_ir_graph (entity *ent, int params);
216  *    -------------------------------------------------
217  *
218  *    This constructor generates the basic infrastructure needed to
219  *    represent a procedure in FIRM.
220  *
221  *    The parameters of new_ir_graph are:
222  *
223  *      *ent             A pointer to an entity representing the procedure.
224  *
225  *      params           An integer giving the number of local variables in the
226  *                       procedure.
227  *
228  *    It allocates an ir_graph and sets current_ir_graph to point to this
229  *    graph.  Further it allocates the following nodes needed for every
230  *    procedure:
231  *
232  *    * The start block containing a start node and Proj nodes for it's
233  *      five results (X, M, P, P, T).
234  *    * The end block containing an end node. This block is not matured
235  *      after executing new_ir_graph as predecessors need to be added to it.
236  *      (Maturing a block means fixing it's number of predecessors.)
237  *    * The current block, which is empty and also not matured.
238  *
239  *    Further it enters the global store into the datastructure of the start
240  *    block that contanis all valid values in this block (set_store()).  This
241  *    datastructure is used to build the Phi nodes and removed after completion
242  *    of the graph.
243  *    There is no path from end to start in the graph after calling ir_graph.
244  *
245  *
246  *    PROCEDURE TO CONSTRUCT AN IR GRAPH
247  *    ==================================
248  *
249  *    This library supplies several interfaces to construct a FIRM graph for
250  *    a program:
251  *    * A "comfortable" interface generating SSA automatically.  Automatically
252  *      computed predecessors of nodes need not be specified in the constructors.
253  *      (new_<Node> constructurs and a set of additional routines.)
254  *    * A less comfortable interface where all predecessors except the block
255  *      an operation belongs to need to be specified.  SSA must be constructed
256  *      by hand.  (new_<Node> constructors and switch_block()).  This interface
257  *      is called "block oriented".  It automatically calles the local optimizations
258  *      for each new node.
259  *    * An even less comfortable interface where the block needs to be specified
260  *      explicitly.  This is called the "raw" interface. (new_r_<Node>
261  *      constructors).  These nodes are not optimized.
262  *
263  *    To use the functionality of the comfortable interface correctly the Front
264  *    End needs to follow certain protocols.  This is explained in the following.
265  *    To build a correct IR with the other interfaces study the semantics of
266  *    the firm node (See tech-reprot UKA 1999-14).  For the construction of
267  *    types and entities see the documentation in those modules.
268  *
269  *    First the Frontend needs to decide which variables and values used in
270  *    a procedure can be represented by dataflow edges.  These are variables
271  *    that need not be saved to memory as they cause no side effects visible
272  *    out of the procedure.  In general these are all compiler generated
273  *    variables and simple local variables of the procedure as integers,
274  *    reals and pointers.  The frontend has to count and number these variables.
275  *
276  *    First an ir_graph needs to be constructed with new_ir_graph.  The
277  *    constructor gets the number of local variables.  The graph is hold in the
278  *    global variable irg.
279  *
280  *    Now the construction of the procedure can start.  Several basic blocks can
281  *    be constructed in parallel, but the code within each block needs to
282  *    be constructed (almost) in program order.
283  *
284  *    A global variable holds the current basic block.  All (non block) nodes
285  *    generated are added to this block.  The current block can be set with
286  *    switch_block(block).  If several blocks are constructed in parallel block
287  *    switches need to be performed constantly.
288  *
289  *    To generate a Block node (with the comfortable interface) it's predecessor
290  *    control flow nodes need not be known.  In case of cyclic control flow these
291  *    can not be known when the block is constructed.  With add_in_edge(block,
292  *    cfnode) predecessors can be added to the block.  If all predecessors are
293  *    added to the block mature_block(b) needs to be called.  Calling mature_block
294  *    early improves the efficiency of the Phi node construction algorithm.
295  *    But if several  blocks are constructed at once, mature_block must only
296  *    be called after performing all set_values and set_stores in the block!
297  *    (See documentation of new_immBlock constructor.)
298  *
299  *    The constructors of arithmetic nodes require that their predecessors
300  *    are mentioned.  Sometimes these are available in the Frontend as the
301  *    predecessors have just been generated by the frontend.  If they are local
302  *    values the predecessors can be obtained from the library with a call to
303  *    get_value(local_val_nr).  (local_val_nr needs to be administered by
304  *    the Frontend.)  A call to get_value triggers the generation of Phi nodes.
305  *    If an arithmetic operation produces a local value this value needs to be
306  *    passed to the library by set_value(node, local_val_nr).
307  *    In straight line code these two operations just remember and return the
308  *    pointer to nodes producing the value.  If the value passes block boundaries
309  *    Phi nodes can be inserted.
310  *    Similar routines exist to manage the Memory operands: set_store and
311  *    get_store.
312  *
313  *    Several nodes produce more than one result.  An example is the Div node.
314  *    Such nodes return tuples of values.  From these individual values can be
315  *    extracted by proj nodes.
316  *
317  *    The following example illustrates the construction of a simple basic block
318  *    with two predecessors stored in variables cf_pred1 and cf_pred2, containing
319  *    the code
320  *      a = a div a;
321  *    and finally jumping to an other block.  The variable a got the local_val_nr
322  *    42 by the frontend.
323  *
324  *    ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
325  *
326  *    this_block = new_immBlock();
327  *    add_in_edge(this_block, cf_pred1);
328  *    add_in_edge(this_block, cf_pred2);
329  *    mature_block(this_block);
330  *    a_val = get_value(42, mode_I);
331  *    mem = get_store();
332  *    div = new_Div(mem, a_val, a_val);
333  *    mem = new_Proj(div, mode_M, 0);   * for the numbers for Proj see docu *
334  *    res = new_Proj(div, mode_I, 2);
335  *    set_store(mem);
336  *    set_value(res, 42);
337  *    cf_op = new_Jmp();
338  *
339  *    For further information look at the documentation of the nodes and
340  *    constructors and at the paragraph COPING WITH DATA OBJECTS at the
341  *    end of this documentation.
342  *
343  *    The comfortable interface contains the following routines further explained
344  *    below:
345  *
346  *    ir_node *new_immBlock  (void);
347  *    ir_node *new_Start  (void);
348  *    ir_node *new_End    (void);
349  *    ir_node *new_Jmp    (void);
350  *    ir_node *new_Cond   (ir_node *c);
351  *    ir_node *new_Return (ir_node *store, int arity, ir_node **in);
352  *    ir_node *new_Raise  (ir_node *store, ir_node *obj);
353  *    ir_node *new_Const  (ir_mode *mode, tarval *con);
354  *    ir_node *new_SymConst (type_or_id *value, symconst_kind kind);
355  *    ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
356  *    ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity,
357  *                         ir_node **in, entity *ent);
358  *    ir_node *new_Call   (ir_node *store, ir_node *callee, int arity,
359  *                     ir_node **in, type_method *type);
360  *    ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode);
361  *    ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode);
362  *    ir_node *new_Minus  (ir_node *op,  ir_mode *mode);
363  *    ir_node *new_Mul    (ir_node *op1, ir_node *op2, ir_mode *mode);
364  *    ir_node *new_Quot   (ir_node *memop, ir_node *op1, ir_node *op2);
365  *    ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
366  *    ir_node *new_Div    (ir_node *memop, ir_node *op1, ir_node *op2);
367  *    ir_node *new_Mod    (ir_node *memop, ir_node *op1, ir_node *op2);
368  *    ir_node *new_Abs    (ir_node *op,                ir_mode *mode);
369  *    ir_node *new_And    (ir_node *op1, ir_node *op2, ir_mode *mode);
370  *    ir_node *new_Or     (ir_node *op1, ir_node *op2, ir_mode *mode);
371  *    ir_node *new_Eor    (ir_node *op1, ir_node *op2, ir_mode *mode);
372  *    ir_node *new_Not    (ir_node *op,                ir_mode *mode);
373  *    ir_node *new_Shl    (ir_node *op,  ir_node *k,   ir_mode *mode);
374  *    ir_node *new_Shr    (ir_node *op,  ir_node *k,   ir_mode *mode);
375  *    ir_node *new_Shrs   (ir_node *op,  ir_node *k,   ir_mode *mode);
376  *    ir_node *new_Rot    (ir_node *op,  ir_node *k,   ir_mode *mode);
377  *    ir_node *new_Cmp    (ir_node *op1, ir_node *op2);
378  *    ir_node *new_Conv   (ir_node *op, ir_mode *mode);
379  *    ir_node *new_Load   (ir_node *store, ir_node *addr);
380  *    ir_node *new_Store  (ir_node *store, ir_node *addr, ir_node *val);
381  *    ir_node *new_Alloc  (ir_node *store, ir_node *size, type *alloc_type,
382  *                         where_alloc where);
383  *    ir_node *new_Free   (ir_node *store, ir_node *ptr, ir_node *size,
384  *                   type *free_type);
385  *    ir_node *new_Proj   (ir_node *arg, ir_mode *mode, long proj);
386  *
387  *    void add_in_edge (ir_node *block, ir_node *jmp);
388  *    void     mature_block (ir_node *block);
389  *    void switch_block (ir_node *target);
390  *    ir_node *get_value (int pos, ir_mode *mode);
391  *    void set_value (int pos, ir_node *value);
392  *    ir_node *get_store (void);
393  *    void set_store (ir_node *store);
394  *
395  *
396  *    IR_NODES AND CONSTRUCTORS FOR IR_NODES
397  *    =======================================
398  *
399  *    All ir_nodes are defined by a common data structure.  They are distinguished
400  *    by their opcode and differ in the number of their attributes.
401  *
402  *    The constructor for the block node sets current_block to itself.
403  *    Const nodes are always added to the start block.
404  *    All other constructors add the created node to the current_block.
405  *    swich_block(block) allows to set the current block to block.
406  *
407  *    Watch for my inconsistent use of input and predecessor (dataflow view)
408  *    and `the node points to' (implementation view).
409  *
410  *    The following description of the nodes lists four properties them if these
411  *    are of interest:
412  *     - the parameters to the constructor
413  *     - the inputs of the Firm node
414  *     - the outputs of the Firm node
415  *     - attributes to the node
416  *
417  *    BASIC BLOCKS
418  *    ------------
419  *
420  *    ir_node *new_immBlock (void)
421  *    ----------------------------
422  *
423  *    Creates a new block.  Sets current_block to itself.  When a new block is
424  *    created it cannot be known how many predecessors this block will have in the
425  *    control flow graph. Therefore the list of inputs can not be fixed at
426  *    creation.  Predecessors can be added with add_in_edge (block, control flow
427  *    operation).  With every added predecessor the number of inputs to Phi nodes
428  *    also changes.
429  *
430  *    The block can be completed by mature_block(block) if all predecessors are
431  *    known.  If several blocks are built at once, mature_block can only be called
432  *    after set_value has been called for all values that are life at the end
433  *    of the block.  This is necessary so that Phi nodes created by mature_block
434  *    get the right predecessors in case of cyclic dependencies.  If all set_values
435  *    of this block are called after maturing it and before calling get_value
436  *    in some block that is control flow dependent on this block, the construction
437  *    is correct.
438  *
439  *    Example for faulty ir construction:  (draw the graph on a paper and you'll
440  *                                          get it ;-)
441  *
442  *      block_before_loop = new_block();
443  *      set_value(x);
444  *      mature_block(block_before_loop);
445  *      before2header = new_Jmp;
446  *
447  *      loop_header = new_block ();
448  *      header2body - new_Jmp();
449  *
450  *      loop_body = new_block ();
451  *      body2header = new_Jmp();
452  *
453  *      add_in_edge(loop_header, before2header);
454  *      add_in_edge(loop_header, body2header);
455  *      add_in_edge(loop_body, header2body);
456  *
457  *      mature_block(loop_header);
458  *      mature_block(loop_body);
459  *
460  *      get_value(loop_body, x);   // gets the Phi in loop_header
461  *      set_value(loop_header, x); // sets the value the above get_value should
462  *      // have returned!!!
463  *
464  *    Mature_block also fixes the number of inputs to the Phi nodes.  Mature_block
465  *    should be called as early as possible, as afterwards the generation of Phi
466  *    nodes is more efficient.
467  *
468  *    Inputs:
469  *      There is an input for each control flow predecessor of the block.
470  *      The input points to an instruction producing an output of type X.
471  *      Possible predecessors:  Start, Jmp, Cond, Raise or Return or any node
472  *      possibly causing an exception.  (Often the real predecessors are Projs.)
473  *    Output:
474  *      Mode BB (R), all nodes belonging to this block should consume this output.
475  *      As they are strict (except Block and Phi node) it is a necessary condition
476  *      that the block node executed before any other node in this block executes.
477  *    Attributes:
478  *      block.matured  Indicates whether the block is mature.
479  *      block.**graph_arr
480  *                      This attribute contains all local values valid in this
481  *                      block. This is needed to build the Phi nodes and removed
482  *                      if the graph is complete.  This field is used by the
483  *                  internal construction algorithm and should not be accessed
484  *                  from outside.
485  *
486  *
487  *    ir_node *new_Block (int arity, ir_node **in)
488  *    --------------------------------------------
489  *
490  *    Creates a new Block with the given list of predecessors.  This block
491  *    is mature.
492  *
493  *
494  *    CONTROL FLOW OPERATIONS
495  *    -----------------------
496  *
497  *    In each block there must be exactly one of the control flow
498  *    operations Start, End, Jmp, Cond, Return or Raise.  The output of a
499  *    control flow operation points to the block to be executed next.
500  *
501  *    ir_node *new_Start (void)
502  *    -------------------------
503  *
504  *    Creates a start node.  Not actually needed public.  There is only one such
505  *    node in each procedure which is automatically created by new_ir_graph.
506  *
507  *    Inputs:
508  *      No inputs except the block it belogns to.
509  *    Output:
510  *      A tuple of 4 (5, 6) distinct values. These are labeled by the following
511  *      projection numbers (pns_number):
512  *      * pns_initial_exec
513  *                       mode X, points to the first block to be executed.
514  *      * pns_global_store
515  *                       mode M, the global store
516  *      * pns_frame_base mode P, a pointer to the base of the procedures
517  *                           stack frame.
518  *      * pns_globals    mode P, a pointer to the part of the memory containing
519  *                               _all_ global things.
520  *      * pns_args       mode T, a tuple containing all arguments of the procedure.
521  *
522  *
523  *    ir_node *new_End (void)
524  *    -----------------------
525  *
526  *    Creates an end node.  Not actually needed public.  There is only one such
527  *    node in each procedure which is automatically created by new_ir_graph.
528  *
529  *    Inputs:
530  *      No inputs except the block it belongs to.
531  *    Output:
532  *      No output.
533  *
534  *    ir_node *new_Jmp (void)
535  *    -----------------------
536  *
537  *    Creates a Jmp node.
538  *
539  *    Inputs:
540  *      The block the node belongs to
541  *    Output:
542  *      Control flow to the next block.
543  *
544  *    ir_node *new_Cond (ir_node *c)
545  *    ------------------------------
546  *
547  *    Creates a Cond node.  There are two versions of this node.
548  *
549  *    The Boolean Cond:
550  *    Input:
551  *      A value of mode b.
552  *    Output:
553  *      A tuple of two control flows.  The first is taken if the input is
554  *      false, the second if it is true.
555  *
556  *    The Switch Cond:
557  *    Input:
558  *      A value of mode I_u. (i)
559  *    Output:
560  *      A tuple of n control flows.  If the Cond's input is i, control
561  *      flow will procede along output i. If the input is >= n control
562  *      flow proceeds along output n.
563  *
564  *    ir_node *new_Return (in_node *store, int arity, ir_node **in)
565  *    -------------------------------------------------------------
566  *
567  *    The return node has as inputs the results of the procedure.  It
568  *    passes the control flow to the end_block.
569  *
570  *    Inputs:
571  *      The memory state.
572  *      All results.
573  *    Output
574  *      Control flow to the end block.
575  *
576  *    ir_node *new_Raise (ir_node *store, ir_node *obj)
577  *    -------------------------------------------------
578  *
579  *    Raises an exception.  Unconditional change of control flow.  Writes
580  *    an explicit Except variable to memory to pass it to the exception
581  *    handler.  See TechReport 1999-14, chapter Exceptions.
582  *
583  *    Inputs:
584  *      The memory state.
585  *      A pointer to the Except variable.
586  *    Output:
587  *      A tuple of control flow and the changed memory state.  The control flow
588  *      points to the exception handler if it is definied in this procedure,
589  *      else it points to the end_block.
590  *
591  *
592  *    CONSTANTS
593  *    ---------
594  *
595  *    ir_node *new_Const (ir_mode *mode, tarval *con)
596  *    -----------------------------------------------
597  *
598  *    Creates a constant in the constant table and adds a Const node
599  *    returning this value to the start block.
600  *
601  *    Parameters:
602  *      *mode            The mode of the constant.
603  *      *con             Points to an entry in the constant table.
604  *                       This pointer is added to the attributes of
605  *                       the node (self->attr.con)
606  *    Inputs:
607  *      No inputs except the block it belogns to.
608  *    Output:
609  *      The constant value.
610  *    Attribute:
611  *      attr.con   A tarval* pointer to the proper entry in the constant
612  *                 table.
613  *
614  *    ir_node *new_SymConst (type *type, symconst_kind kind)
615  *    ------------------------------------------------------------
616  *
617  *    There are three kinds of symbolic constants:
618  *      type_tag  The symbolic constant represents a type tag.
619  *      size      The symbolic constant represents the size of a class.
620  *      link_info Information for the linker, e.g. the name of a global
621  *                variable.
622  *
623  *    Parameters
624  *      kind        The kind of the symbolic constant: type_tag, size or link_info.
625  *      *type_or_id Points to the type the tag stands for or to the type
626  *                  whose size is represented by the constant or to an ident
627  *                  representing the linkage info.
628  *
629  *    Inputs:
630  *      No inputs except the block it belogns to.
631  *    Output:
632  *      An unsigned integer (I_u) or a pointer (P).
633  *
634  *    Attributes:
635  *      attr.i.num       The symconst_kind, i.e. one of
636  *                        - type_tag
637  *                        - size
638  *                    - linkage_ptr_info
639  *        If the attr.i.num is type_tag or size, the node contains an attribute
640  *      attr.i.*type,    a pointer to a type_class.  The mode of the node is mode_i.
641  *        if it is linkage_ptr_info it contains
642  *      attr.i.*ptrinfo,  an ident holding information for the linker.  The mode
643  *        of the node is mode_p.
644  *
645  *    THE SELECT NODE
646  *    ---------------
647  *
648  *    ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel)
649  *    --------------------------------------------------------------------
650  *
651  *
652  *    Selects an entity from a compound type. This entity can be a field or
653  *    a method.
654  *
655  *    Parameters:
656  *      *store     The memory in which the object the entity should be selected
657  *                 from is allocated.
658  *      *frame     The pointer to the object.
659  *      *sel       The entity to select.
660  *
661  *    Inputs:
662  *      The memory containing the object.
663  *      A pointer to the object.
664  *      An unsigned integer.
665  *    Output:
666  *      A pointer to the selected entity.
667  *    Attributes:
668  *      attr.sel   Pointer to the entity
669  *
670  *
671  *    ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
672  *    --------------------------------------------------------------------------
673  *                      entity *sel)
674  *                      ------------
675  *
676  *    Selects a field from an array type.  The entity has as owner the array, as
677  *    type the arrays element type.  The indexes to access an array element are
678  *    given also.
679  *
680  *    Parameters:
681  *      *store     The memory in which the object the entity should be selected from
682  *                 is allocated.
683  *      *frame     The pointer to the object.
684  *      *arity     number of array indexes.
685  *      *in        array with index inputs to the node.
686  *      *sel       The entity to select.
687  *
688  *    Inputs:
689  *      The memory containing the object.
690  *      A pointer to the object.
691  *      As much unsigned integer as there are array expressions.
692  *    Output:
693  *      A pointer to the selected entity.
694  *    Attributes:
695  *      attr.sel   Pointer to the entity
696  *
697  *    The constructors new_Sel and new_simpleSel generate the same ir nodes.
698  *    simpleSel just sets the arity of the index inputs to zero.
699  *
700  *
701  *    ARITHMETIC OPERATIONS
702  *    ---------------------
703  *
704  *    ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
705  *    ----------------------------------------------------------------------------
706  *                       type_method *type)
707  *                       ------------------
708  *
709  *    Creates a procedure call.
710  *
711  *    Parameters
712  *      *store           The actual store.
713  *      *callee          A pointer to the called procedure.
714  *      arity            The number of procedure parameters.
715  *      **in             An array with the pointers to the parameters.
716  *                       The constructor copies this array.
717  *      *type            Type information of the procedure called.
718  *
719  *    Inputs:
720  *      The store, the callee and the parameters.
721  *    Output:
722  *      A tuple containing the eventually changed store and the procedure
723  *      results.
724  *    Attributes:
725  *      attr.call        Contains the type information for the procedure.
726  *
727  *    ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
728  *    ------------------------------------------------------------
729  *
730  *    Trivial.
731  *
732  *    ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
733  *    ------------------------------------------------------------
734  *
735  *    Trivial.
736  *
737  *    ir_node *new_Minus (ir_node *op, ir_mode *mode)
738  *    -----------------------------------------------
739  *
740  *    This constructor is for unary Minus operations on floating point
741  *    values.  Such a Minus can trap if it is implemented as a Sub from
742  *    zero due to rounding errors.
743  *
744  *    ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
745  *    ------------------------------------------------------------
746  *
747  *    Trivial.
748  *
749  *    ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2)
750  *    --------------------------------------------------------------
751  *
752  *    Quot performs exact division of floating point numbers.  It's mode
753  *    is Tuple, the mode of the result must be annotated to the Proj
754  *    that extracts the result of the arithmetic operations.
755  *
756  *    Inputs:
757  *      The store needed to model exceptions and the two operands.
758  *    Output:
759  *      A tuple contaning a memory and a execution for modeling exceptions
760  *      and the result of the arithmetic operation.
761  *
762  *    ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2)
763  *    ----------------------------------------------------------------
764  *
765  *    Performs Div and Mod on interger values.
766  *
767  *    Output:
768  *      A tuple contaning a memory and a execution for modeling exceptions
769  *      and the two result of the arithmetic operations.
770  *
771  *    ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2)
772  *    -------------------------------------------------------------
773  *
774  *    Trivial.
775  *
776  *    ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2)
777  *    -------------------------------------------------------------
778  *
779  *    Trivial.
780  *
781  *    ir_node *new_Abs (ir_node *op, ir_mode *mode)
782  *    ---------------------------------------------
783  *
784  *    Trivial.
785  *
786  *    ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
787  *    ------------------------------------------------------------
788  *
789  *    Trivial.
790  *
791  *    ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
792  *    -----------------------------------------------------------
793  *
794  *    Trivial.
795  *
796  *    ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
797  *    ------------------------------------------------------------
798  *
799  *    Trivial.
800  *
801  *    ir_node *new_Not (ir_node *op, ir_mode *mode)
802  *    ---------------------------------------------
803  *
804  *    This node constructs a constant where all bits are set to one
805  *    and a Eor of this constant and the operator.  This simulates a
806  *    Not operation.
807  *
808  *    ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
809  *    ---------------------------------------------------------
810  *
811  *    Trivial.
812  *
813  *    ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
814  *    ---------------------------------------------------------
815  *
816  *    Logic shift right, i.e., zero extended.
817  *
818  *
819  *    ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
820  *    ----------------------------------------------------------
821  *
822  *    Arithmetic shift right, i.e., sign extended.
823  *
824  *    ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
825  *    ---------------------------------------------------------
826  *
827  *    Rotates the operand to the (right??) by k bits.
828  *
829  *    ir_node *new_Conv (ir_node *op, ir_mode *mode)
830  *    ---------------------------------------------
831  *
832  *    Mode conversion.  For allowed conversions see UKA Tech Report
833  *    1999-14.
834  *
835  *    ir_node *new_Cmp (ir_node *op1, ir_node *op2)
836  *    ---------------------------------------------
837  *
838  *    Input:
839  *      The two values to be compared.
840  *    Output:
841  *      A 16-tuple containing the results of the 16 different comparisons.
842  *      The following is a list giving the comparisons and a projection
843  *      number (pnc_number) to use in Proj nodes to extract the proper result.
844  *        False     false
845  *        Eq        equal
846  *        Lt    less
847  *        Le    less or equal
848  *        Gt    greater
849  *        Ge    greater of equal
850  *        Lg    less or greater
851  *        Leg   less, equal or greater = ordered
852  *        Uo    unordered
853  *        Ue    unordered or equal
854  *        Ul    unordered or less
855  *        Ule   unordered, less or equal
856  *        Ug    unordered or greater
857  *        Uge   unordered, greater or equal
858  *        Ne    unordered, less or greater = not equal
859  *        True  true
860  *
861  *
862  *
863  *    THE PHI NODE
864  *    ------------
865  *
866  *    In general, Phi nodes are automaitcally inserted.  In some cases, if
867  *    all predecessors of a block are known, an explicit Phi node constructor
868  *    is needed.  E.g., to construct a FIRM graph for a statement as
869  *      a = (b==c) ? 2 : 5;
870  *
871  *    ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
872  *    ---------------------------------------------------------
873  *
874  *    Creates a Phi node. The in's order has to correspond to the order
875  *    of in's of current_block.  This is not checked by the library!
876  *
877  *    Parameter
878  *      arity            number of predecessors
879  *      **in             array with predecessors
880  *      *mode            The mode of it's inputs and output.
881  *    Inputs:
882  *      A Phi node has as many inputs as the block it belongs to.
883  *      Each input points to a definition of the same value on a
884  *      different path in the control flow.
885  *    Output
886  *      The definition valid in this block.
887  *
888  *
889  *    OPERATIONS TO MANAGE MEMORY EXPLICITLY
890  *    --------------------------------------
891  *
892  *    ir_node *new_Load (ir_node *store, ir_node *addr)
893  *    ----------------------------------------------------------------
894  *
895  *    The Load operation reads a value from memory.
896  *
897  *    Parameters:
898  *    *store        The current memory.
899  *    *addr         A pointer to the variable to be read in this memory.
900  *
901  *    Inputs:
902  *      The memory and a pointer to a variable in this memory.
903  *    Output:
904  *      A tuple of the memory, a control flow to be taken in case of
905  *      an exception and the loaded value.
906  *
907  *    ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
908  *    ----------------------------------------------------------------
909  *
910  *    The Store operation writes a value to a variable in memory.
911  *
912  *    Inputs:
913  *      The memory, a pointer to a variable in this memory and the value
914  *      to write to this variable.
915  *    Output:
916  *      A tuple of the changed memory and a control flow to be taken in
917  *      case of an exception.
918  *
919  *    ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
920  *    --------------------------------------------------------------------
921  *                        where_alloc where)
922  *                        ------------------
923  *
924  *    The Alloc node allocates a new variable.  It can be specified whether the
925  *    variable should be allocated to the stack or to the heap.
926  *
927  *    Parameters:
928  *      *store       The memory which shall contain the new variable.
929  *      **    *size        The number of bytes to allocate. Old. **
930  *      *size        We decided that the size easily can be derived from the type.
931  *                   This field is for allocating arrays, i.e., it gives the multiple
932  *               of the size of alloc_type to allocate memory for.
933  *      *alloc_type  The type of the allocated variable.
934  *      where        Where to allocate the variable, either heap_alloc or stack_alloc.
935  *
936  *    Inputs:
937  *      A memory and an unsigned integer.
938  *    Output:
939  *      A tuple of the changed memory, a control flow to be taken in
940  *      case of an exception and the pointer to the new variable.
941  *    Attributes:
942  *      a.where          Indicates where the variable is allocated.
943  *      a.*type          A pointer to the class the allocated data object
944  *                       belongs to.
945  *
946  *    ir_node *new_Free (ir_node *store, ir_node *ptr, type *free_type)
947  *    ------------------------------------------------------------------
948  *
949  *    The Free node frees memory of the given variable.
950  *
951  *    Parameters:
952  *      *store       The memory which shall contain the new variable.
953  *      *ptr         The pointer to the object to free.
954  *      *size        The number of objects of type free_type to free in a sequence.
955  *      *free_type   The type of the freed variable.
956  *
957  *    Inputs:
958  *      A memory, a pointer and an unsigned integer.
959  *    Output:
960  *      The changed memory.
961  *    Attributes:
962  *      f.*type          A pointer to the type information of the freed data object.
963  *
964  *    Not Implemented!
965  *
966  *    ir_node *new_Sync (int arity, ir_node **in)
967  *    -------------------------------------------
968  *
969  *    The Sync operation unifies several partial memory blocks.  These blocks
970  *    have to be pairwise disjunct or the values in common locations have to
971  *    be identical.  This operation allows to specify all operations that eventually
972  *    need several partial memory blocks as input with a single entrance by
973  *    unifying the memories with a preceding Sync operation.
974  *
975  *    Parameters
976  *      arity    The number of memories to syncronize.
977  *      **in     An array of pointers to nodes that produce an output of
978  *               type memory.
979  *    Inputs
980  *      Several memories.
981  *    Output
982  *      The unified memory.
983  *
984  *
985  *    SPECIAL OPERATIONS
986  *    ------------------
987  *
988  *    ir_node *new_Bad (void)
989  *    -----------------------
990  *
991  *    Returns the unique Bad node current_ir_graph->bad.
992  *    This node is used to express results of dead code elimination.
993  *
994  *    ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
995  *    ----------------------------------------------------------
996  *
997  *    Selects one entry of a tuple.  This is a hidden `fat edge'.
998  *
999  *    Parameters
1000  *      *arg      A node producing a tuple.
1001  *      *mode     The mode of the value to project.
1002  *      proj      The position of the value in the tuple.
1003  *    Input:
1004  *      The tuple.
1005  *    Output:
1006  *      The value.
1007  *
1008  *    ir_node *new_Tuple (int arity, ir_node **in)
1009  *    --------------------------------------------
1010  *
1011  *    Builds a Tuple from single values.  This is needed to implement
1012  *    optimizations that remove a node that produced a tuple.  The node can be
1013  *    replaced by the Tuple operation so that the following Proj nodes have not to
1014  *    be changed.  (They are hard to find due to the implementation with pointers
1015  *    in only one direction.)  The Tuple node is smaller than any other
1016  *    node, so that a node can be changed into a Tuple by just changing it's
1017  *    opcode and giving it a new in array.
1018  *
1019  *    Parameters
1020  *      arity    The number of tuple elements.
1021  *      **in     An array containing pointers to the nodes producing the
1022  *               tuple elements.
1023  *
1024  *    ir_node *new_Id (ir_node *val, ir_mode *mode)
1025  *    ---------------------------------------------
1026  *
1027  *    The single output of the Id operation is it's input.  Also needed
1028  *    for optimizations.
1029  *
1030  *
1031  *    COPING WITH DATA OBJECTS
1032  *    ========================
1033  *
1034  *    Two kinds of data objects have to be distinguished for generating
1035  *    FIRM.  First there are local variables other than arrays that are
1036  *    known to be alias free.  Second there are all other data objects.
1037  *    For the first a common SSA representation is built, the second
1038  *    are modeled by saving them to memory.  The memory is treated as
1039  *    a single local variable, the alias problem is hidden in the
1040  *    content of this variable.
1041  *
1042  *    All values known in a Block are listed in the block's attribute,
1043  *    block.**graph_arr which is used to automatically insert Phi nodes.
1044  *    The following two funcions can be used to add a newly computed value
1045  *    to the array, or to get the producer of a value, i.e., the current
1046  *    live value.
1047  *
1048  *    inline void set_value (int pos, ir_node *value)
1049  *    -----------------------------------------------
1050  *
1051  *    Has to be called for every assignment to a local variable.  It
1052  *    adds the value to the array of used values at position pos.  Pos
1053  *    has to be a unique identifier for an entry in the procedure's
1054  *    definition table.  It can be used to access the value again.
1055  *
1056  *    ir_node *get_value (int pos, ir_mode *mode)
1057  *    -------------------------------------------
1058  *
1059  *    Returns the node defining the value referred to by pos. If the
1060  *    value is not defined in this block a Phi node is generated and
1061  *    all definitions reaching this Phi node are collected.  It can
1062  *    happen that the algorithm allocates an unnecessary Phi node,
1063  *    e.g. if there is only one definition of this value, but this
1064  *    definition reaches the currend block on several different
1065  *    paths.  This Phi node will be eliminated if optimizations are
1066  *    turned on right after it's creation.
1067  *
1068  *
1069  *    There are two special routines for the global store:
1070  *
1071  *    inline void set_store (ir_node *store)
1072  *    --------------------------------------
1073  *
1074  *    Adds the store to the array of known values at a reserved
1075  *    position.
1076  *
1077  *    inline ir_node *get_store (void)
1078  *    --------------------------------
1079  *
1080  *    Returns the node defining the actual store.
1081  *****
1082  */
1083
1084
1085 # ifndef _IRCONS_H_
1086 # define _IRCONS_H_
1087
1088 # include "common.h"
1089 # include "irgraph.h"
1090 # include "irnode.h"
1091 # include "irmode.h"
1092 # include "entity.h"
1093 # include "tv.h"
1094 # include "type.h"
1095
1096 /***************************************************************************/
1097 /* The raw interface                                                       */
1098 /***************************************************************************/
1099
1100 /* Constructs a Block with a fixed number of predecessors.
1101    Does not set current_block.  Can not be used with automatic
1102    Phi node construction. */
1103 ir_node *new_r_Block  (ir_graph *irg,  int arity, ir_node **in);
1104 ir_node *new_r_Start  (ir_graph *irg, ir_node *block);
1105 ir_node *new_r_End    (ir_graph *irg, ir_node *block);
1106 ir_node *new_r_Jmp    (ir_graph *irg, ir_node *block);
1107 ir_node *new_r_Cond   (ir_graph *irg, ir_node *block, ir_node *c);
1108 ir_node *new_r_Return (ir_graph *irg, ir_node *block,
1109                        ir_node *store, int arity, ir_node **in);
1110 ir_node *new_r_Raise  (ir_graph *irg, ir_node *block,
1111                        ir_node *store, ir_node *obj);
1112 ir_node *new_r_Const  (ir_graph *irg, ir_node *block,
1113                        ir_mode *mode, tarval *con);
1114 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
1115                        type_or_id_p value, symconst_kind symkind);
1116 ir_node *new_r_Sel    (ir_graph *irg, ir_node *block, ir_node *store,
1117                        ir_node *objptr, int n_index, ir_node **index,
1118                        entity *ent);
1119 ir_node *new_r_Call   (ir_graph *irg, ir_node *block, ir_node *store,
1120                        ir_node *callee, int arity, ir_node **in,
1121                        type *type);
1122 ir_node *new_r_Add    (ir_graph *irg, ir_node *block,
1123                        ir_node *op1, ir_node *op2, ir_mode *mode);
1124 ir_node *new_r_Sub    (ir_graph *irg, ir_node *block,
1125                        ir_node *op1, ir_node *op2, ir_mode *mode);
1126 ir_node *new_r_Minus  (ir_graph *irg, ir_node *block,
1127                        ir_node *op,  ir_mode *mode);
1128 ir_node *new_r_Mul    (ir_graph *irg, ir_node *block,
1129                        ir_node *op1, ir_node *op2, ir_mode *mode);
1130 ir_node *new_r_Quot   (ir_graph *irg, ir_node *block,
1131                        ir_node *memop, ir_node *op1, ir_node *op2);
1132 ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
1133                        ir_node *memop, ir_node *op1, ir_node *op2);
1134 ir_node *new_r_Div    (ir_graph *irg, ir_node *block,
1135                        ir_node *memop, ir_node *op1, ir_node *op2);
1136 ir_node *new_r_Mod    (ir_graph *irg, ir_node *block,
1137                        ir_node *memop, ir_node *op1, ir_node *op2);
1138 ir_node *new_r_Abs    (ir_graph *irg, ir_node *block,
1139                        ir_node *op, ir_mode *mode);
1140 ir_node *new_r_And    (ir_graph *irg, ir_node *block,
1141                        ir_node *op1, ir_node *op2, ir_mode *mode);
1142 ir_node *new_r_Or     (ir_graph *irg, ir_node *block,
1143                        ir_node *op1, ir_node *op2, ir_mode *mode);
1144 ir_node *new_r_Eor    (ir_graph *irg, ir_node *block,
1145                        ir_node *op1, ir_node *op2, ir_mode *mode);
1146 ir_node *new_r_Not    (ir_graph *irg, ir_node *block,
1147                        ir_node *op, ir_mode *mode);
1148 ir_node *new_r_Cmp    (ir_graph *irg, ir_node *block,
1149                        ir_node *op1, ir_node *op2);
1150 ir_node *new_r_Shl    (ir_graph *irg, ir_node *block,
1151                        ir_node *op, ir_node *k, ir_mode *mode);
1152 ir_node *new_r_Shr    (ir_graph *irg, ir_node *block,
1153                        ir_node *op, ir_node *k, ir_mode *mode);
1154 ir_node *new_r_Shrs   (ir_graph *irg, ir_node *block,
1155                        ir_node *op, ir_node *k, ir_mode *mode);
1156 ir_node *new_r_Rot    (ir_graph *irg, ir_node *block,
1157                        ir_node *op, ir_node *k, ir_mode *mode);
1158 ir_node *new_r_Conv   (ir_graph *irg, ir_node *block,
1159                        ir_node *op, ir_mode *mode);
1160 ir_node *new_r_Phi    (ir_graph *irg, ir_node *block, int arity,
1161                        ir_node **in, ir_mode *mode);
1162 ir_node *new_r_Load   (ir_graph *irg, ir_node *block,
1163                        ir_node *store, ir_node *adr);
1164 ir_node *new_r_Store  (ir_graph *irg, ir_node *block,
1165                        ir_node *store, ir_node *adr, ir_node *val);
1166 ir_node *new_r_Alloc  (ir_graph *irg, ir_node *block, ir_node *store,
1167                        ir_node *size, type *alloc_type, where_alloc where);
1168 ir_node *new_r_Free   (ir_graph *irg, ir_node *block, ir_node *store,
1169                        ir_node *ptr, ir_node *size, type *free_type);
1170 ir_node *new_r_Sync   (ir_graph *irg, ir_node *block, int arity, ir_node **in);
1171 ir_node *new_r_Proj   (ir_graph *irg, ir_node *block, ir_node *arg,
1172                        ir_mode *mode, long proj);
1173 ir_node *new_r_Tuple  (ir_graph *irg, ir_node *block,
1174                        int arity, ir_node **in);
1175 ir_node *new_r_Id     (ir_graph *irg, ir_node *block,
1176                        ir_node *val, ir_mode *mode);
1177 ir_node *new_r_Bad    ();
1178
1179
1180 /*************************************************************************/
1181 /* The block oriented interface                                          */
1182 /*************************************************************************/
1183
1184 /* Sets the current block in which the following constructors place the
1185    nodes they construct. */
1186 void switch_block (ir_node *target);
1187
1188 /* Constructs a Block with a fixed number of predecessors.
1189    Does set current_block.  Can be used with automatic Phi
1190    node construction. */
1191 ir_node *new_Block(int arity, ir_node **in);
1192 ir_node *new_Start  (void);
1193 ir_node *new_End    (void);
1194 ir_node *new_Jmp    (void);
1195 ir_node *new_Cond   (ir_node *c);
1196 ir_node *new_Return (ir_node *store, int arity, ir_node **in);
1197 ir_node *new_Raise  (ir_node *store, ir_node *obj);
1198 ir_node *new_Const  (ir_mode *mode, tarval *con);
1199 ir_node *new_SymConst (type_or_id_p value, symconst_kind kind);
1200 ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
1201 ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity, ir_node **in,
1202                      entity *ent);
1203 ir_node *new_Call   (ir_node *store, ir_node *callee, int arity, ir_node **in,
1204                      type *type);
1205 ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode);
1206 ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode);
1207 ir_node *new_Minus  (ir_node *op,  ir_mode *mode);
1208 ir_node *new_Mul    (ir_node *op1, ir_node *op2, ir_mode *mode);
1209 ir_node *new_Quot   (ir_node *memop, ir_node *op1, ir_node *op2);
1210 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
1211 ir_node *new_Div    (ir_node *memop, ir_node *op1, ir_node *op2);
1212 ir_node *new_Mod    (ir_node *memop, ir_node *op1, ir_node *op2);
1213 ir_node *new_Abs    (ir_node *op,                ir_mode *mode);
1214 ir_node *new_And    (ir_node *op1, ir_node *op2, ir_mode *mode);
1215 ir_node *new_Or     (ir_node *op1, ir_node *op2, ir_mode *mode);
1216 ir_node *new_Eor    (ir_node *op1, ir_node *op2, ir_mode *mode);
1217 ir_node *new_Not    (ir_node *op,                ir_mode *mode);
1218 ir_node *new_Shl    (ir_node *op,  ir_node *k,   ir_mode *mode);
1219 ir_node *new_Shr    (ir_node *op,  ir_node *k,   ir_mode *mode);
1220 ir_node *new_Shrs   (ir_node *op,  ir_node *k,   ir_mode *mode);
1221 ir_node *new_Rot    (ir_node *op,  ir_node *k,   ir_mode *mode);
1222 ir_node *new_Cmp    (ir_node *op1, ir_node *op2);
1223 ir_node *new_Conv   (ir_node *op, ir_mode *mode);
1224 ir_node *new_Phi    (int arity, ir_node **in, ir_mode *mode);
1225 ir_node *new_Load   (ir_node *store, ir_node *addr);
1226 ir_node *new_Store  (ir_node *store, ir_node *addr, ir_node *val);
1227 ir_node *new_Alloc  (ir_node *store, ir_node *size, type *alloc_type,
1228                      where_alloc where);
1229 ir_node *new_Free   (ir_node *store, ir_node *ptr, ir_node *size,
1230                      type *free_type);
1231 ir_node *new_Sync   (int arity, ir_node **in);
1232 ir_node *new_Proj   (ir_node *arg, ir_mode *mode, long proj);
1233 ir_node *new_Tuple  (int arity, ir_node **in);
1234 ir_node *new_Id     (ir_node *val, ir_mode *mode);
1235 ir_node *new_Bad    (void);
1236
1237 /***********************************************************************/
1238 /* The comfortable interface.                                          */
1239 /* Supports automatic Phi node construction.                           */
1240 /* All routines of the block oriented interface except new_Block are   */
1241 /* needed also.                                                        */
1242 /***********************************************************************/
1243
1244 /** Block construction **/
1245 /* immature Block without predecessors */
1246 ir_node *new_immBlock (void);
1247
1248 /* Add a control flow edge to an immature block. */
1249 void add_in_edge (ir_node *immblock, ir_node *jmp);
1250
1251 /* fixes the number of predecessors of a block. */
1252 void mature_block (ir_node *block);
1253
1254 /** Parameter administration **/
1255 /* Read a value from the array with the local variables.  Use this
1256    function to obtain the last definition of the value associated with
1257    pos.  Pos may not exceed the value passed as n_loc to new_ir_graph. */
1258 ir_node *get_value (int pos, ir_mode *mode);
1259
1260 /* Write a value in the array with the local variables. Use this function
1261    to remember a new definition of the value associated with pos. Pos may
1262    not exceed the value passed as n_loc to new_ir_graph. */
1263 void set_value (int pos, ir_node *value);
1264
1265 /* Read a store.
1266    Use this function to get the most recent version of the store (type M).
1267    Internally it does the same as get_value. */
1268 ir_node *get_store (void);
1269
1270 /* Write a store. */
1271 void set_store (ir_node *store);
1272
1273 /***********************************************************************/
1274 /* initialize ir construction                                          */
1275 /***********************************************************************/
1276 void init_cons (void);
1277
1278
1279 # endif /* _IRCONS_H_ */