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