3 * File name: ir/ir/ircons.h
4 * Purpose: Various irnode constructors. Automatic construction
5 * of SSA representation.
6 * Author: Martin Trapp, Christian Schaefer
7 * Modified by: Goetz Lindenmaier, Boris Boesler
10 * Copyright: (c) 1998-2003 Universität Karlsruhe
11 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 -# Handle construction of exceptions more comfortable:
18 Add new constructors that pass the exception region (or better the
19 Phi for the memories, the ex. region can be found from there) as parameter,
20 constructor then adds all Proj nodes and returns the pointer
21 to the Proj node that selects the result of the arithmetic operation.
22 -# Maybe hide the exception region in a global variable, especially if
23 it is always unambiguous.
29 * documentation no more supported since 2001
31 * ir node construction.
33 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
35 * This file documents all datatypes and constructors needed to
36 * build a FIRM representation of a procedure. The constructors are
37 * also implemented in this file.
39 * The documentation also gives a short manual how to use the library.
41 * For extensive documentation of FIRM see UKA Techreport 1999-14.
44 * Three kinds of nodes
45 * --------------------
47 * There are three kinds of nodes known to the ir: entities,
50 * + ir_nodes are the actual nodes of the FIRM intermediate representation.
51 * They represent operations on the data of the program and control flow
54 * + entity ==> implemented in entity.h
55 * Refers to a single entity of the compiled program, e.g. a field of a
56 * class or a method. If a method or variable can not be assigned to
57 * a method or class or the like, it is a global object.
59 * + types ==> implemented in type.h
60 * With types type information is represented. There are several type
63 * Implementation of the FIRM operations: ir_node
64 * ----------------------------------------------
66 * Ir_nodes represent operations on the data of the program and control flow
67 * operations. Examples of ir_nodes: Add, Jmp, Cmp
69 * FIRM is a dataflow graph. A dataflow graph is a directed graph,
70 * so that every node has incoming and outgoing edges. A node is
71 * executable if every input at it's incoming edges is available.
72 * Execution of the dataflow graph is started at the Start node which
73 * has no incoming edges and ends when the End node executes, even if
74 * there are still executable or not executed nodes. (Is this true,
75 * or must all executable nodes be executed?) (There are exceptions
76 * to the dataflow paradigma that all inputs have to be available
77 * before a node can execute: Phi, Block. See UKA Techreport
80 * The implementation of FIRM differs from the view as a dataflow
81 * graph. To allow fast traversion of the graph edges are
82 * implemented as C-pointers. Inputs to nodes are not ambiguous, the
83 * results can be used by several other nodes. Each input can be
84 * implemented as a single pointer to a predecessor node, outputs
85 * need to be lists of pointers to successors. Therefore a node
86 * contains pointers to it's predecessor so that the implementation is a
87 * dataflow graph with reversed edges. It has to be traversed bottom
90 * All nodes of the ir have the same basic structure. They are
91 * distinguished by a field containing the opcode.
93 * The fields of an ir_node:
95 * kind A firm_kind tag containing k_ir_node. This is useful for
96 * dynamically checking the type of a node.
98 * *op This ir_op gives the opcode as a tag and a string
99 * and the number of attributes of an ir_node. There is
100 * one statically allocated struct ir_op for each opcode.
102 * *mode The ir_mode of the operation represented by this firm
103 * node. The mode of the operation is the mode of it's
104 * result. A Firm mode is a datatype as known to the target,
105 * not a type of the source language.
107 * visit A flag for traversing the ir.
109 * **in An array with pointers to the node's predecessors.
111 * *link A pointer to an ir_node. With this pointer all Phi nodes
112 * are attached to a Block, i.e., a Block points to it's
113 * first Phi node, this node points to the second Phi node
114 * in the Block and so fourth. Used in mature_immBlock
115 * to find all Phi nodes to be matured. It's also used to
116 * annotate a node with a better, optimized version of it.
118 * attr An attr struct containing the attributes of the nodes. The
119 * attributes depend on the opcode of the node. The number
120 * of these attributes is given in op.
124 * Not yet documented. See irop.h.
128 * Not yet documented. See irmode.h.
130 * GLOBAL VARIABLES -- now also fields of ir_graph.
133 * current_ir_graph Points to the current ir_graph. All constructors for
134 * nodes add nodes to this graph.
136 * ir_visited An int used as flag to traverse the ir_graph.
138 * block_visited An int used as a flag to traverse block nodes in the
141 * Others not yet documented.
145 * CONSTRUCTOR FOR IR_GRAPH --> see irgraph.h
146 * ========================
149 * PROCEDURE TO CONSTRUCT AN IR GRAPH --> see also Firm tutorial
150 * ==================================
152 * This library supplies several interfaces to construct a FIRM graph for
154 * - A "comfortable" interface generating SSA automatically. Automatically
155 * computed predecessors of nodes need not be specified in the constructors.
156 * (new_<Node> constructurs and a set of additional routines.)
157 * - A less comfortable interface where all predecessors except the block
158 * an operation belongs to need to be specified. SSA must be constructed
159 * by hand. (new_<Node> constructors and set_cur_block()). This interface
160 * is called "block oriented". It automatically calles the local optimizations
162 * - An even less comfortable interface where the block needs to be specified
163 * explicitly. This is called the "raw" interface. (new_r_<Node>
164 * constructors). These nodes are not optimized.
166 * To use the functionality of the comfortable interface correctly the Front
167 * End needs to follow certain protocols. This is explained in the following.
168 * To build a correct IR with the other interfaces study the semantics of
169 * the firm node (See tech-reprot UKA 1999-14). For the construction of
170 * types and entities see the documentation in those modules.
172 * First the Frontend needs to decide which variables and values used in
173 * a procedure can be represented by dataflow edges. These are variables
174 * that need not be saved to memory as they cause no side effects visible
175 * out of the procedure. Often these are all compiler generated
176 * variables and simple local variables of the procedure as integers,
177 * reals and pointers. The frontend has to count and number these variables.
179 * First an ir_graph needs to be constructed with new_ir_graph. The
180 * constructor gets the number of local variables. The graph is hold in the
181 * global variable irg.
183 * Now the construction of the procedure can start. Several basic blocks can
184 * be constructed in parallel, but the code within each block needs to
185 * be constructed (almost) in program order.
187 * A global variable holds the current basic block. All (non block) nodes
188 * generated are added to this block. The current block can be set with
189 * set_cur_block(block). If several blocks are constructed in parallel block
190 * switches need to be performed constantly.
192 * To generate a Block node (with the comfortable interface) it's predecessor
193 * control flow nodes need not be known. In case of cyclic control flow these
194 * can not be known when the block is constructed. With add_immBlock_pred(block,
195 * cfnode) predecessors can be added to the block. If all predecessors are
196 * added to the block mature_immBlock(b) needs to be called. Calling mature_immBlock
197 * early improves the efficiency of the Phi node construction algorithm.
198 * But if several blocks are constructed at once, mature_immBlock must only
199 * be called after performing all set_values and set_stores in the block!
200 * (See documentation of new_immBlock constructor.)
202 * The constructors of arithmetic nodes require that their predecessors
203 * are mentioned. Sometimes these are available in the Frontend as the
204 * predecessors have just been generated by the frontend. If they are local
205 * values the predecessors can be obtained from the library with a call to
206 * get_value(local_val_nr). (local_val_nr needs to be administered by
207 * the Frontend.) A call to get_value triggers the generation of Phi nodes.
208 * If an arithmetic operation produces a local value this value needs to be
209 * passed to the library by set_value(node, local_val_nr).
210 * In straight line code these two operations just remember and return the
211 * pointer to nodes producing the value. If the value passes block boundaries
212 * Phi nodes can be inserted.
213 * Similar routines exist to manage the Memory operands: set_store and
216 * Several nodes produce more than one result. An example is the Div node.
217 * Such nodes return tuples of values. From these individual values can be
218 * extracted by proj nodes.
220 * The following example illustrates the construction of a simple basic block
221 * with two predecessors stored in variables cf_pred1 and cf_pred2, containing
224 * and finally jumping to an other block. The variable a got the local_val_nr
225 * 42 by the frontend.
227 * ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
229 * this_block = new_immBlock();
230 * add_immBlock_pred(this_block, cf_pred1);
231 * add_immBlock_pred(this_block, cf_pred2);
232 * mature_immBlock(this_block);
233 * a_val = get_value(42, mode_Iu);
235 * div = new_Div(mem, a_val, a_val);
236 * mem = new_Proj(div, mode_M, 0); * for the numbers for Proj see docu *
237 * res = new_Proj(div, mode_Iu, 2);
239 * set_value(res, 42);
242 * For further information look at the documentation of the nodes and
243 * constructors and at the paragraph COPING WITH DATA OBJECTS at the
244 * end of this documentation.
246 * The comfortable interface contains the following routines further explained
249 * ir_node *new_immBlock (void);
250 * ir_node *new_Start (void);
251 * ir_node *new_End (void);
252 * ir_node *new_Jmp (void);
253 * ir_node *new_Cond (ir_node *c);
254 * ir_node *new_Return (ir_node *store, int arity, ir_node **in);
255 * ir_node *new_Raise (ir_node *store, ir_node *obj);
256 * ir_node *new_Const (ir_mode *mode, tarval *con);
257 * ir_node *new_SymConst (symconst_symbol value, symconst_kind kind);
258 * ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
259 * ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity,
260 * ir_node **in, entity *ent);
261 * ir_node *new_InstOf (ir_node *store, ir_node obj, type *ent);
262 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity,
263 * ir_node **in, type_method *type);
264 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
265 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
266 * ir_node *new_Minus (ir_node *op, ir_mode *mode);
267 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
268 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
269 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
270 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
271 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
272 * ir_node *new_Abs (ir_node *op, ir_mode *mode);
273 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
274 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
275 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
276 * ir_node *new_Not (ir_node *op, ir_mode *mode);
277 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
278 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
279 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
280 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
281 * ir_node *new_Cmp (ir_node *op1, ir_node *op2);
282 * ir_node *new_Conv (ir_node *op, ir_mode *mode);
283 * ir_node *new_Cast (ir_node *op, type *to_tp);
284 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
285 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
286 * ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
287 * where_alloc where);
288 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
289 * type *free_type, where_alloc where);
290 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
291 * ir_node *new_NoMem (void);
292 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
294 * void add_immBlock_pred (ir_node *block, ir_node *jmp);
295 * void mature_immBlock (ir_node *block);
296 * void set_cur_block (ir_node *target);
297 * ir_node *get_value (int pos, ir_mode *mode);
298 * void set_value (int pos, ir_node *value);
299 * ir_node *get_store (void);
300 * void set_store (ir_node *store);
301 * keep_alive (ir_node ka)
303 * IR_NODES AND CONSTRUCTORS FOR IR_NODES
304 * =======================================
306 * All ir_nodes are defined by a common data structure. They are distinguished
307 * by their opcode and differ in the number of their attributes.
309 * The constructor for the block node sets current_block to itself.
310 * Const nodes are always added to the start block.
311 * All other constructors add the created node to the current_block.
312 * swich_block(block) allows to set the current block to block.
314 * Watch for my inconsistent use of input and predecessor (dataflow view)
315 * and `the node points to' (implementation view).
317 * The following description of the nodes lists four properties them if these
319 * - the parameters to the constructor
320 * - the inputs of the Firm node
321 * - the outputs of the Firm node
322 * - attributes to the node
326 * ir_node *new_immBlock (void)
327 * ----------------------------
329 * Creates a new block. Sets current_block to itself. When a new block is
330 * created it cannot be known how many predecessors this block will have in the
331 * control flow graph. Therefore the list of inputs can not be fixed at
332 * creation. Predecessors can be added with add_immBlock_pred (block, control flow
333 * operation). With every added predecessor the number of inputs to Phi nodes
336 * The block can be completed by mature_immBlock(block) if all predecessors are
337 * known. If several blocks are built at once, mature_immBlock can only be called
338 * after set_value has been called for all values that are life at the end
339 * of the block. This is necessary so that Phi nodes created mature_immBlock
340 * get the right predecessors in case of cyclic dependencies. If all set_values
341 * of this block are called after maturing it and before calling get_value
342 * in some block that is control flow dependent on this block, the construction
345 * Example for faulty ir construction: (draw the graph on a paper and you'll
348 * block_before_loop = new_block();
350 * mature_immBlock(block_before_loop);
351 * before2header = new_Jmp;
353 * loop_header = new_block ();
354 * header2body - new_Jmp();
356 * loop_body = new_block ();
357 * body2header = new_Jmp();
359 * add_immBlock_pred(loop_header, before2header);
360 * add_immBlock_pred(loop_header, body2header);
361 * add_immBlock_pred(loop_body, header2body);
363 * mature_immBlock(loop_header);
364 * mature_immBlock(loop_body);
366 * get_value(loop_body, x); // gets the Phi in loop_header
367 * set_value(loop_header, x); // sets the value the above get_value should
368 * // have returned!!!
370 * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
371 * should be called as early as possible, as afterwards the generation of Phi
372 * nodes is more efficient.
375 * There is an input for each control flow predecessor of the block.
376 * The input points to an instruction producing an output of type X.
377 * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
378 * possibly causing an exception. (Often the real predecessors are Projs.)
380 * Mode BB (R), all nodes belonging to this block should consume this output.
381 * As they are strict (except Block and Phi node) it is a necessary condition
382 * that the block node executed before any other node in this block executes.
384 * block.matured Indicates whether the block is mature.
386 * This attribute contains all local values valid in this
387 * block. This is needed to build the Phi nodes and removed
388 * if the graph is complete. This field is used by the
389 * internal construction algorithm and should not be accessed
393 * ir_node *new_Block (int arity, ir_node **in)
394 * --------------------------------------------
396 * Creates a new Block with the given list of predecessors. This block
397 * is mature. As other constructors calls optimization and vrfy for the
398 * block. If one of the predecessors is Unknown (as it has to be filled in
399 * later) optimizations are skipped. This is necessary to
400 * construct Blocks in loops. Leaving Unknown in the Block after finishing
401 * the construction may have strange effects, especially for interprocedural
402 * representation and analysis.
405 * CONTROL FLOW OPERATIONS
406 * -----------------------
408 * In each block there must be exactly one of the control flow
409 * operations Start, End, Jmp, Cond, Return or Raise. The output of a
410 * control flow operation points to the block to be executed next.
412 * ir_node *new_Start (void)
413 * -------------------------
415 * Creates a start node. Not actually needed public. There is only one such
416 * node in each procedure which is automatically created by new_ir_graph.
419 * No inputs except the block it belogns to.
421 * A tuple of 4 (5, 6) distinct values. These are labeled by the following
422 * projection numbers (pn_Start):
423 * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
424 * * pn_Start_M mode M, the global store
425 * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
426 * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
427 * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
430 * ir_node *new_End (void)
431 * -----------------------
433 * Creates an end node. Not actually needed public. There is only one such
434 * node in each procedure which is automatically created by new_ir_graph.
437 * No inputs except the block it belongs to.
441 * ir_node *new_Jmp (void)
442 * -----------------------
444 * Creates a Jmp node.
447 * The block the node belongs to
449 * Control flow to the next block.
451 * ir_node *new_Cond (ir_node *c)
452 * ------------------------------
454 * Creates a Cond node. There are two versions of this node.
460 * A tuple of two control flows. The first is taken if the input is
461 * false, the second if it is true.
465 * A value of mode I_u. (i)
467 * A tuple of n control flows. If the Cond's input is i, control
468 * flow will procede along output i. If the input is >= n control
469 * flow proceeds along output n.
471 * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
472 * -------------------------------------------------------------
474 * The return node has as inputs the results of the procedure. It
475 * passes the control flow to the end_block.
481 * Control flow to the end block.
483 * ir_node *new_Raise (ir_node *store, ir_node *obj)
484 * -------------------------------------------------
486 * Raises an exception. Unconditional change of control flow. Writes
487 * an explicit Except variable to memory to pass it to the exception
488 * handler. See TechReport 1999-14, chapter Exceptions.
492 * A pointer to the Except variable.
494 * A tuple of control flow and the changed memory state. The control flow
495 * points to the exception handler if it is definied in this procedure,
496 * else it points to the end_block.
501 * ir_node *new_Const (ir_mode *mode, tarval *con)
502 * -----------------------------------------------
504 * Creates a constant in the constant table and adds a Const node
505 * returning this value to the start block.
508 * *mode The mode of the constant.
509 * *con Points to an entry in the constant table.
510 * This pointer is added to the attributes of
511 * the node (self->attr.con)
513 * No inputs except the block it belogns to.
515 * The constant value.
517 * attr.con A tarval* pointer to the proper entry in the constant
520 * ir_node *new_SymConst (union symconst_symbol value, symconst_addr_ent kind)
521 * ---------------------------------------------------------------------------
523 * There are three kinds of symbolic constants:
524 * symconst_type_tag The symbolic constant represents a type tag.
525 * symconst_size The symbolic constant represents the size of a class.
526 * symconst_addr_name Information for the linker, e.g. the name of a global
528 * To represent a pointer to an entity that is represented by an entity
529 * datastructure don't use
530 * new_SymConst((type_or_id*)get_entity_ld_ident(ent), symconst_addr_name);.
531 * Use a real const instead:
532 * new_SymConst(mode_P_mach, tarval_p_from_entity(ent));
533 * This makes the Constant independent of name changes of the entity due to
537 * kind The kind of the symbolic constant: type_tag, size or link_info.
538 * *type_or_id Points to the type the tag stands for or to the type
539 * whose size is represented by the constant or to an ident
540 * representing the linkage info.
543 * No inputs except the block it belogns to.
545 * An unsigned integer (I_u) or a pointer (P).
548 * attr.i.num The symconst_addr_ent, i.e. one of
551 * - symconst_addr_name
552 * If the attr.i.num is symconst_type_tag or symconst_size, the node contains an attribute
553 * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is.
554 * if it is linkage_ptr_info it contains
555 * attr.i.*ptrinfo, an ident holding information for the linker. The mode
556 * of the node is mode_P_mach.
560 * ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel)
561 * --------------------------------------------------------------------
564 * Selects an entity from a compound type. This entity can be a field or
568 * *store The memory in which the object the entity should be selected
570 * *frame The pointer to the object.
571 * *sel The entity to select.
574 * The memory containing the object.
575 * A pointer to the object.
576 * An unsigned integer.
578 * A pointer to the selected entity.
580 * attr.sel Pointer to the entity
583 * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
584 * --------------------------------------------------------------------------
588 * Selects a field from an array type. The entity has as owner the array, as
589 * type the arrays element type. The indices to access an array element are
593 * *store The memory in which the object the entity should be selected from
595 * *frame The pointer to the object.
596 * *arity number of array indices.
597 * *in array with index inputs to the node.
598 * *sel The entity to select.
601 * The memory containing the object.
602 * A pointer to the object.
603 * As much unsigned integer as there are array expressions.
605 * A pointer to the selected entity.
607 * attr.sel Pointer to the entity
609 * The constructors new_Sel and new_simpleSel generate the same ir nodes.
610 * simpleSel just sets the arity of the index inputs to zero.
613 * ARITHMETIC OPERATIONS
614 * ---------------------
616 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
617 * ----------------------------------------------------------------------------
621 * Creates a procedure call.
624 * *store The actual store.
625 * *callee A pointer to the called procedure.
626 * arity The number of procedure parameters.
627 * **in An array with the pointers to the parameters.
628 * The constructor copies this array.
629 * *type Type information of the procedure called.
632 * The store, the callee and the parameters.
634 * A tuple containing the eventually changed store and the procedure
637 * attr.call Contains the type information for the procedure.
640 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
641 * ------------------------------------------------------------
645 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
646 * ------------------------------------------------------------
650 * ir_node *new_Minus (ir_node *op, ir_mode *mode)
651 * -----------------------------------------------
653 * Unary Minus operations on integer and floating point values.
655 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
656 * ------------------------------------------------------------
660 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2)
661 * --------------------------------------------------------------
663 * Quot performs exact division of floating point numbers. It's mode
664 * is Tuple, the mode of the result must be annotated to the Proj
665 * that extracts the result of the arithmetic operations.
668 * The store needed to model exceptions and the two operands.
670 * A tuple contaning a memory and a execution for modeling exceptions
671 * and the result of the arithmetic operation.
673 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2)
674 * ----------------------------------------------------------------
676 * Performs Div and Mod on interger values.
679 * A tuple contaning a memory and a execution for modeling exceptions
680 * and the two result of the arithmetic operations.
682 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2)
683 * -------------------------------------------------------------
687 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2)
688 * -------------------------------------------------------------
692 * ir_node *new_Abs (ir_node *op, ir_mode *mode)
693 * ---------------------------------------------
697 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
698 * ------------------------------------------------------------
702 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
703 * -----------------------------------------------------------
707 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
708 * ------------------------------------------------------------
712 * ir_node *new_Not (ir_node *op, ir_mode *mode)
713 * ---------------------------------------------
715 * This node constructs a constant where all bits are set to one
716 * and a Eor of this constant and the operator. This simulates a
719 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
720 * ---------------------------------------------------------
724 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
725 * ---------------------------------------------------------
727 * Logic shift right, i.e., zero extended.
730 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
731 * ----------------------------------------------------------
733 * Arithmetic shift right, i.e., sign extended.
735 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
736 * ---------------------------------------------------------
738 * Rotates the operand to the (right??) by k bits.
740 * ir_node *new_Conv (ir_node *op, ir_mode *mode)
741 * ---------------------------------------------
743 * Mode conversion. For allowed conversions see UKA Tech Report
746 * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
747 * ---------------------------------------------
750 * The two values to be compared.
752 * A 16-tuple containing the results of the 16 different comparisons.
753 * The following is a list giving the comparisons and a projection
754 * number (pn_Cmp) to use in Proj nodes to extract the proper result.
758 * pn_Cmp_Le less or equal
760 * pn_Cmp_Ge greater of equal
761 * pn_Cmp_Lg less or greater
762 * pn_Cmp_Leg less, equal or greater = ordered
763 * pn_Cmp_Uo unordered
764 * pn_Cmp_Ue unordered or equal
765 * pn_Cmp_Ul unordered or less
766 * pn_Cmp_Ule unordered, less or equal
767 * pn_Cmp_Ug unordered or greater
768 * pn_Cmp_Uge unordered, greater or equal
769 * pn_Cmp_Ne unordered, less or greater = not equal
776 * In general, Phi nodes are automaitcally inserted. In some cases, if
777 * all predecessors of a block are known, an explicit Phi node constructor
778 * is needed. E.g., to construct a FIRM graph for a statement as
779 * a = (b==c) ? 2 : 5;
781 * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
782 * ---------------------------------------------------------
784 * Creates a Phi node. The in's order has to correspond to the order
785 * of in's of current_block. This is not checked by the library!
786 * If one of the predecessors is Unknown (as it has to be filled in
787 * later) optimizations are skipped. This is necessary to
788 * construct Phi nodes in loops. Leaving Unknown in the Phi after finishing
789 * the construction may have strange effects, especially for interprocedural
790 * representation and analysis.
793 * arity number of predecessors
794 * **in array with predecessors
795 * *mode The mode of it's inputs and output.
797 * A Phi node has as many inputs as the block it belongs to.
798 * Each input points to a definition of the same value on a
799 * different path in the control flow.
801 * The definition valid in this block.
803 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
804 * -----------------------------------------------------------------------------
806 * Creates a Mux node. This node implements the following semantic:
807 * If the sel node (which must be of mode_b) evaluates to true, its value is
808 * ir_true, else ir_false;
811 * OPERATIONS TO MANAGE MEMORY EXPLICITLY
812 * --------------------------------------
814 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode)
815 * ----------------------------------------------------------------
817 * The Load operation reads a value from memory.
820 * *store The current memory.
821 * *addr A pointer to the variable to be read in this memory.
822 * *mode The mode of the value to be loaded.
825 * The memory and a pointer to a variable in this memory.
827 * A tuple of the memory, a control flow to be taken in case of
828 * an exception and the loaded value.
830 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
831 * ----------------------------------------------------------------
833 * The Store operation writes a value to a variable in memory.
836 * The memory, a pointer to a variable in this memory and the value
837 * to write to this variable.
839 * A tuple of the changed memory and a control flow to be taken in
840 * case of an exception.
842 * ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
843 * --------------------------------------------------------------------
847 * The Alloc node allocates a new variable. It can be specified whether the
848 * variable should be allocated to the stack or to the heap.
851 * *store The memory which shall contain the new variable.
852 * ** *size The number of bytes to allocate. Old. **
853 * *size We decided that the size easily can be derived from the type.
854 * This field is for allocating arrays, i.e., it gives the multiple
855 * of the size of alloc_type to allocate memory for.
856 * *alloc_type The type of the allocated variable.
857 * where Where to allocate the variable, either heap_alloc or stack_alloc.
860 * A memory and an unsigned integer.
862 * A tuple of the changed memory, a control flow to be taken in
863 * case of an exception and the pointer to the new variable.
865 * a.where Indicates where the variable is allocated.
866 * a.*type A pointer to the class the allocated data object
869 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, type *free_type,
870 * --------------------------------------------------------------------------------
874 * The Free node frees memory of the given variable.
877 * *store The memory which shall contain the new variable.
878 * *ptr The pointer to the object to free.
879 * *size The number of objects of type free_type to free in a sequence.
880 * *free_type The type of the freed variable.
881 * where Where the variable was allocated, either heap_alloc or stack_alloc.
884 * A memory, a pointer and an unsigned integer.
886 * The changed memory.
888 * f.*type A pointer to the type information of the freed data object.
892 * ir_node *new_Sync (int arity, ir_node **in)
893 * -------------------------------------------
895 * The Sync operation unifies several partial memory blocks. These blocks
896 * have to be pairwise disjunct or the values in common locations have to
897 * be identical. This operation allows to specify all operations that eventually
898 * need several partial memory blocks as input with a single entrance by
899 * unifying the memories with a preceding Sync operation.
902 * arity The number of memories to synchronize.
903 * **in An array of pointers to nodes that produce an output of
908 * The unified memory.
914 * ir_node *new_Bad (void)
915 * -----------------------
917 * Returns the unique Bad node current_ir_graph->bad.
918 * This node is used to express results of dead code elimination.
920 * ir_node *new_NoMem (void)
921 * -----------------------------------------------------------------------------------
923 * Returns the unique NoMem node current_ir_graph->no_mem.
924 * This node is used as input for operations that need a Memory, but do not
925 * change it like Div by const != 0, analyzed calls etc.
927 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
928 * ----------------------------------------------------------
930 * Selects one entry of a tuple. This is a hidden `fat edge'.
933 * *arg A node producing a tuple.
934 * *mode The mode of the value to project.
935 * proj The position of the value in the tuple.
941 * ir_node *new_Tuple (int arity, ir_node **in)
942 * --------------------------------------------
944 * Builds a Tuple from single values. This is needed to implement
945 * optimizations that remove a node that produced a tuple. The node can be
946 * replaced by the Tuple operation so that the following Proj nodes have not to
947 * be changed. (They are hard to find due to the implementation with pointers
948 * in only one direction.) The Tuple node is smaller than any other
949 * node, so that a node can be changed into a Tuple by just changing it's
950 * opcode and giving it a new in array.
953 * arity The number of tuple elements.
954 * **in An array containing pointers to the nodes producing the
957 * ir_node *new_Id (ir_node *val, ir_mode *mode)
958 * ---------------------------------------------
960 * The single output of the Id operation is it's input. Also needed
964 * COPING WITH DATA OBJECTS
965 * ========================
967 * Two kinds of data objects have to be distinguished for generating
968 * FIRM. First there are local variables other than arrays that are
969 * known to be alias free. Second there are all other data objects.
970 * For the first a common SSA representation is built, the second
971 * are modeled by saving them to memory. The memory is treated as
972 * a single local variable, the alias problem is hidden in the
973 * content of this variable.
975 * All values known in a Block are listed in the block's attribute,
976 * block.**graph_arr which is used to automatically insert Phi nodes.
977 * The following two funcions can be used to add a newly computed value
978 * to the array, or to get the producer of a value, i.e., the current
981 * inline void set_value (int pos, ir_node *value)
982 * -----------------------------------------------
984 * Has to be called for every assignment to a local variable. It
985 * adds the value to the array of used values at position pos. Pos
986 * has to be a unique identifier for an entry in the procedure's
987 * definition table. It can be used to access the value again.
988 * Requires current_block to be set correctly.
990 * ir_node *get_value (int pos, ir_mode *mode)
991 * -------------------------------------------
993 * Returns the node defining the value referred to by pos. If the
994 * value is not defined in this block a Phi node is generated and
995 * all definitions reaching this Phi node are collected. It can
996 * happen that the algorithm allocates an unnecessary Phi node,
997 * e.g. if there is only one definition of this value, but this
998 * definition reaches the currend block on several different
999 * paths. This Phi node will be eliminated if optimizations are
1000 * turned on right after it's creation.
1001 * Requires current_block to be set correctly.
1003 * There are two special routines for the global store:
1005 * void set_store (ir_node *store)
1006 * -------------------------------
1008 * Adds the store to the array of known values at a reserved
1010 * Requires current_block to be set correctly.
1012 * ir_node *get_store (void)
1013 * -------------------------
1015 * Returns the node defining the actual store.
1016 * Requires current_block to be set correctly.
1019 * inline void keep_alive (ir_node *ka)
1020 * ------------------------------------
1022 * Keep this node alive because it is (might be) not in the control
1023 * flow from Start to End. Adds the node to the list in the end
1032 # include "firm_common.h"
1033 # include "irgraph.h"
1034 # include "irnode.h"
1035 # include "irmode.h"
1036 # include "entity.h"
1039 # include "dbginfo.h"
1041 /*-------------------------------------------------------------------------*/
1042 /* The raw interface */
1043 /*-------------------------------------------------------------------------*/
1045 /** Constructor for a Block node.
1047 * Constructs a mature block with the given predecessors. Use Unknown
1048 * nodes as predecessors to construct a block if the number of
1049 * predecessors is known, but not the predecessors themselves. This
1050 * constructor does not set current_block. It not be used with
1051 * automatic Phi node construction.
1053 * @param *db A Pointer for debug information.
1054 * @param irg The ir graph the block belongs to.
1055 * @param arity The number of control predecessors.
1056 * @param in[] An array of control predecessors. The length of
1057 * the array must be 'arity'. The constructor copies this array.
1059 ir_node *new_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1061 /** Constructor for a Start node.
1063 * @param *db A pointer for debug information.
1064 * @param *irg The ir graph the node belongs to.
1065 * @param *block The ir block the node belongs to.
1067 ir_node *new_rd_Start (dbg_info *db, ir_graph *irg, ir_node *block);
1069 /** Constructor for a End node.
1071 * @param *db A pointer for debug information.
1072 * @param *irg The ir graph the node belongs to.
1073 * @param *block The ir block the node belongs to.
1075 ir_node *new_rd_End (dbg_info *db, ir_graph *irg, ir_node *block);
1077 /** Constructor for a Jmp node.
1079 * Jmp represents control flow to a single control successor.
1081 * @param *db A pointer for debug information.
1082 * @param *irg The ir graph the node belongs to.
1083 * @param *block The ir block the node belongs to.
1085 ir_node *new_rd_Jmp (dbg_info *db, ir_graph *irg, ir_node *block);
1087 /** Constructor for a Break node.
1089 * Break represents control flow to a single control successor just as Jmp.
1090 * The blocks separated by a break may not be concatenated by an optimization.
1091 * It is used for the interprocedural representation where blocks are parted
1092 * behind Call nodes to represent the control flow to called procedures.
1094 * @param *db A pointer for debug information.
1095 * @param *irg The ir graph the node belong to.
1096 * @param *block The block the node belong to.
1098 ir_node *new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block);
1100 /** Constructor for a Cond node.
1102 * If c is mode_b represents a conditional branch (if/else). If c is
1103 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1104 * node, default Proj is 0.)
1106 * This is not consistent: Input to Cond is Is, Proj has as proj number
1109 * @param *db A pointer for debug information.
1110 * @param *irg The ir graph the node belongs to.
1111 * @param *block The ir block the node belongs to.
1112 * @param *c The conditions parameter. Can be of mode b or I_u.
1114 ir_node *new_rd_Cond (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
1116 /** Constructor for a Return node.
1118 * Returns the memory an zero or more return values. Only node that
1119 * can end regular control flow.
1121 * @param *db A pointer for debug information.
1122 * @param *irg The ir graph the node belongs to.
1123 * @param *block The ir block the node belongs to.
1124 * @param *store The state of memory.
1125 * @param arity Number of return values.
1126 * @param *in Array of length arity with return values. The constructor copies this array.
1128 ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
1129 ir_node *store, int arity, ir_node *in[]);
1131 /** Constructor for a Raise node.
1133 * @param *db A pointer for debug information.
1134 * @param *irg The ir graph the node belongs to.
1135 * @param *block The ir block the node belongs to.
1136 * @param *store The current memory.
1137 * @param *obj A pointer to the Except variable.
1139 ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
1140 ir_node *store, ir_node *obj);
1142 /** Constructor for a Const_type node.
1144 * The constant represents a target value. This constructor sets high
1145 * level type information for the constant value.
1147 * @param *db A pointer for debug information.
1148 * @param *irg The ir graph the node belongs to.
1149 * @param *block The ir block the node belongs to.
1150 * @param *mode The mode of the operands and results.
1151 * @param *con Points to an entry in the constant table.
1152 * @param *tp The type of the constant.
1154 ir_node *new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block,
1155 ir_mode *mode, tarval *con, type *tp);
1157 /** Constructor for a Const node.
1159 * Constructor for a Const node. The constant represents a target
1160 * value. Sets the type information to type_unknown. (No more
1161 * supported: If tv is entity derives a somehow useful type.)
1163 * @param *db A pointer for debug information.
1164 * @param *irg The ir graph the node belongs to.
1165 * @param *block The ir block the node belongs to.
1166 * @param *mode The mode of the operands and results.
1167 * @param *con Points to an entry in the constant table.
1169 ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block,
1170 ir_mode *mode, tarval *con);
1172 /** Constructor for a SymConst_type node.
1174 * This is the constructor for a symbolic constant.
1175 * There are four kinds of symbolic constants:
1176 * - type_tag The symbolic constant represents a type tag. The type the
1177 * tag stands for is given explicitly.
1178 * - size The symbolic constant represents the size of a type. The
1179 * type of which the constant represents the size is given
1181 * - addr_name The symbolic constant represents the address of an entity
1182 * (variable or method). The variable is indicated by a name
1183 * that is valid for linking.
1184 * - addr_ent The symbolic constant represents the address of an entity
1185 * (variable or method). The variable is given explicitly by
1188 * Inputs to the node:
1189 * No inputs except the block it belongs to.
1190 * Outputs of the node.
1191 * An unsigned integer (I_u) or a pointer (P).
1193 * Mention union in declaration so that the firmjni generator recognizes that
1194 * it can not cast the argument to an int.
1196 * @param *db A pointer for debug information.
1197 * @param *irg The ir graph the node belongs to.
1198 * @param *block The ir block the node belongs to.
1199 * @param symkind The kind of the symbolic constant: type_tag, size, addr_name or addr_ent.
1200 * @param value A type, entity or a ident depending on the SymConst kind.
1201 * @param tp The source type of the constant.
1203 ir_node *new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, union symconst_symbol value,
1204 symconst_kind symkind, type *tp);
1206 /** Constructor for a SymConst node.
1208 * Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */
1209 ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
1210 union symconst_symbol value, symconst_kind symkind);
1212 /** Constructor for a SymConst addr_ent node.
1214 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1215 * symconst_addr_ent.
1216 * Adds the SymConst to the start block of irg. */
1217 ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, entity *symbol, type *tp);
1219 /** Constructor for a SymConst addr_name node.
1221 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1222 * symconst_addr_ent.
1223 * Adds the SymConst to the start block of irg. */
1224 ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, type *tp);
1226 /** Constructor for a SymConst type_tag node.
1228 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1229 * symconst_addr_ent.
1230 * Adds the SymConst to the start block of irg. */
1231 ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, type *symbol, type *tp);
1233 /** Constructor for a SymConst size node.
1235 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1236 * symconst_addr_ent.
1237 * Adds the SymConst to the start block of irg. */
1238 ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, type *symbol, type *tp);
1240 /** Constructor for a Sel node.
1242 * The select node selects an entity (field or method) from an entity
1243 * with a compound type. It explicitly specifies the entity selected.
1244 * Dynamically the node may select entities that overwrite the given
1245 * entity. If the selected entity is an array element entity the Sel
1246 * node takes the required array indices as inputs.
1248 * @param *db A pointer for debug information.
1249 * @param *irg The ir graph the node belongs to.
1250 * @param *block The ir block the node belongs to.
1251 * @param *store The memory in which the object the entity should be selected
1252 * from is allocated.
1253 * @param *objptr A pointer to a compound entity the Sel operation selects a
1254 * single attribute from.
1255 * @param *n_index The number of array indices needed to select an array element entity.
1256 * @param *index[] If the compound entity is an array the indices of the selected
1257 * element entity. The constructor copies this array.
1258 * @param *ent The entity to select.
1260 ir_node *new_rd_Sel (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1261 ir_node *objptr, int n_index, ir_node *index[], entity *ent);
1263 /** Constructor for a InstOf node.
1265 * For translating Java. Not supported as standard firm node.
1267 * @param *db A pointer for debug information.
1268 * @param *irg The ir graph the node belongs to.
1269 * @param *block The ir block the node belongs to.
1274 ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1275 ir_node *objptr, type *ent);
1277 /** Constructor for a Call node.
1279 * Represents all kinds of method and function calls.
1281 * @param *db A pointer for debug information.
1282 * @param *irg The ir graph the node belongs to.
1283 * @param *block The ir block the node belongs to.
1284 * @param *store The current memory state.
1285 * @param *callee A pointer to the called procedure.
1286 * @param arity The number of procedure parameters.
1287 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1288 * @param *tp Type information of the procedure called.
1290 ir_node *new_rd_Call (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1291 ir_node *callee, int arity, ir_node *in[], type *tp);
1293 /** Constructor for a Add node.
1295 * @param *db A pointer for debug information.
1296 * @param *irg The ir graph the node belongs to.
1297 * @param *block The ir block the node belongs to.
1298 * @param *op1 The operand 1.
1299 * @param *op2 The operand 2.
1300 * @param *mode The mode of the operands and the result.
1302 ir_node *new_rd_Add (dbg_info *db, ir_graph *irg, ir_node *block,
1303 ir_node *op1, ir_node *op2, ir_mode *mode);
1305 /** Constructor for a Sub node.
1307 * @param *db A pointer for debug information.
1308 * @param *irg The ir graph the node belongs to.
1309 * @param *block The ir block the node belongs to.
1310 * @param *op1 The operand 1.
1311 * @param *op2 The operand 2.
1312 * @param *mode The mode of the operands and the result.
1314 ir_node *new_rd_Sub (dbg_info *db, ir_graph *irg, ir_node *block,
1315 ir_node *op1, ir_node *op2, ir_mode *mode);
1317 /** Constructor for a Minus node.
1319 * @param *db A pointer for debug information.
1320 * @param *irg The ir graph the node belongs to.
1321 * @param *block The ir block the node belongs to.
1322 * @param *op The operand .
1323 * @param *mode The mode of the operand and the result.
1325 ir_node *new_rd_Minus (dbg_info *db, ir_graph *irg, ir_node *block,
1326 ir_node *op, ir_mode *mode);
1328 /** Constructor for a Mul node.
1330 * @param *db A pointer for debug information.
1331 * @param *irg The ir graph the node belongs to.
1332 * @param *block The ir block the node belongs to.
1333 * @param *op1 The operand 1.
1334 * @param *op2 The operand 2.
1335 * @param *mode The mode of the operands and the result.
1337 ir_node *new_rd_Mul (dbg_info *db, ir_graph *irg, ir_node *block,
1338 ir_node *op1, ir_node *op2, ir_mode *mode);
1340 /** Constructor for a Quot node.
1342 * @param *db A pointer for debug information.
1343 * @param *irg The ir graph the node belongs to.
1344 * @param *block The ir block the node belongs to.
1345 * @param *memop The store needed to model exceptions
1346 * @param *op1 The operand 1.
1347 * @param *op2 The operand 2.
1349 ir_node *new_rd_Quot (dbg_info *db, ir_graph *irg, ir_node *block,
1350 ir_node *memop, ir_node *op1, ir_node *op2);
1352 /** Constructor for a DivMod node.
1354 * @param *db A pointer for debug information.
1355 * @param *irg The ir graph the node belongs to.
1356 * @param *block The ir block the node belongs to.
1357 * @param *memop The store needed to model exceptions
1358 * @param *op1 The operand 1.
1359 * @param *op2 The operand 2.
1361 ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
1362 ir_node *memop, ir_node *op1, ir_node *op2);
1364 /** Constructor for a Div node.
1366 * @param *db A pointer for debug information.
1367 * @param *irg The ir graph the node belongs to.
1368 * @param *block The ir block the node belongs to.
1369 * @param *memop The store needed to model exceptions
1370 * @param *op1 The operand 1.
1371 * @param *op2 The operand 2.
1373 ir_node *new_rd_Div (dbg_info *db, ir_graph *irg, ir_node *block,
1374 ir_node *memop, ir_node *op1, ir_node *op2);
1376 /** Constructor for a Mod node.
1378 * @param *db A pointer for debug information.
1379 * @param *irg The ir graph the node belongs to.
1380 * @param *block The ir block the node belongs to.
1381 * @param *memop The store needed to model exceptions
1382 * @param *op1 The operand 1.
1383 * @param *op2 The operand 2.
1385 ir_node *new_rd_Mod (dbg_info *db, ir_graph *irg, ir_node *block,
1386 ir_node *memop, ir_node *op1, ir_node *op2);
1388 /** Constructor for a Abs node.
1390 * @param *db A pointer for debug information.
1391 * @param *irg The ir graph the node belongs to.
1392 * @param *block The ir block the node belongs to.
1393 * @param *op The operand
1394 * @param *mode The mode of the operands and the result.
1396 ir_node *new_rd_Abs (dbg_info *db, ir_graph *irg, ir_node *block,
1397 ir_node *op, ir_mode *mode);
1399 /** Constructor for a And node.
1401 * @param *db A pointer for debug information.
1402 * @param *irg The ir graph the node belongs to.
1403 * @param *block The ir block the node belongs to.
1404 * @param *op1 The operand 1.
1405 * @param *op2 The operand 2.
1406 * @param *mode The mode of the operands and the result.
1408 ir_node *new_rd_And (dbg_info *db, ir_graph *irg, ir_node *block,
1409 ir_node *op1, ir_node *op2, ir_mode *mode);
1411 /** Constructor for a Or node.
1413 * @param *db A pointer for debug information.
1414 * @param *irg The ir graph the node belongs to.
1415 * @param *block The ir block the node belongs to.
1416 * @param *op1 The operand 1.
1417 * @param *op2 The operand 2.
1418 * @param *mode The mode of the operands and the result.
1420 ir_node *new_rd_Or (dbg_info *db, ir_graph *irg, ir_node *block,
1421 ir_node *op1, ir_node *op2, ir_mode *mode);
1423 /** Constructor for a Eor node.
1425 * @param *db A pointer for debug information.
1426 * @param *irg The ir graph the node belongs to.
1427 * @param *block The ir block the node belongs to.
1428 * @param *op1 The operand 1.
1429 * @param *op2 The operand 2.
1430 * @param *mode The mode of the operands and the results.
1432 ir_node *new_rd_Eor (dbg_info *db, ir_graph *irg, ir_node *block,
1433 ir_node *op1, ir_node *op2, ir_mode *mode);
1435 /** Constructor for a Not node.
1437 * @param *db A pointer for debug information.
1438 * @param *irg The ir graph the node belongs to.
1439 * @param *block The ir block the node belongs to.
1440 * @param *op The operand.
1441 * @param *mode The mode of the operand and the result.
1443 ir_node *new_rd_Not (dbg_info *db, ir_graph *irg, ir_node *block,
1444 ir_node *op, ir_mode *mode);
1446 /** Constructor for a Cmp node.
1448 * @param *db A pointer for debug information.
1449 * @param *irg The ir graph the node belongs to.
1450 * @param *block The ir block the node belongs to.
1451 * @param *op1 The operand 1.
1452 * @param *op2 The operand 2.
1454 ir_node *new_rd_Cmp (dbg_info *db, ir_graph *irg, ir_node *block,
1455 ir_node *op1, ir_node *op2);
1457 /** Constructor for a Shl node.
1459 * @param *db A pointer for debug information.
1460 * @param *irg The ir graph the node belongs to.
1461 * @param *block The ir block the node belongs to.
1462 * @param *op The operand.
1463 * @param *k The number of bits to shift the operand .
1464 * @param *mode The mode of the operand and the result.
1466 ir_node *new_rd_Shl (dbg_info *db, ir_graph *irg, ir_node *block,
1467 ir_node *op, ir_node *k, ir_mode *mode);
1469 /** Constructor for a Shr node.
1471 * @param *db A pointer for debug information.
1472 * @param *irg The ir graph the node belongs to.
1473 * @param *block The ir block the node belongs to.
1474 * @param *op The operand.
1475 * @param *k The number of bits to shift the operand .
1476 * @param *mode The mode of the operand and the result.
1478 ir_node *new_rd_Shr (dbg_info *db, ir_graph *irg, ir_node *block,
1479 ir_node *op, ir_node *k, ir_mode *mode);
1481 /** Constructor for a Shrs node.
1483 * @param *db A pointer for debug information.
1484 * @param *irg The ir graph the node belongs to.
1485 * @param *block The ir block the node belongs to.
1486 * @param *op The operand.
1487 * @param *k The number of bits to shift the operand.
1488 * @param *mode The mode of the operand and the result.
1490 ir_node *new_rd_Shrs (dbg_info *db, ir_graph *irg, ir_node *block,
1491 ir_node *op, ir_node *k, ir_mode *mode);
1493 /** Constructor for a Rot node.
1495 * @param *db A pointer for debug information.
1496 * @param *irg The ir graph the node belongs to.
1497 * @param *block The ir block the node belongs to.
1498 * @param *op The operand.
1499 * @param *k The number of bits to rotate the operand.
1500 * @param *mode The mode of the operand.
1502 ir_node *new_rd_Rot (dbg_info *db, ir_graph *irg, ir_node *block,
1503 ir_node *op, ir_node *k, ir_mode *mode);
1506 /** Constructor for a Conv node.
1508 * @param *db A pointer for debug information.
1509 * @param *irg The ir graph the node belongs to.
1510 * @param *block The ir block the node belongs to.
1511 * @param *op The operand.
1512 * @param *mode The mode of this the operand muss be converted .
1514 ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block,
1515 ir_node *op, ir_mode *mode);
1517 /** Constructor for a Cast node.
1519 * High level type cast.
1521 * @param *db A pointer for debug information.
1522 * @param *irg The ir graph the node belongs to.
1523 * @param *block The ir block the node belongs to.
1524 * @param *op The operand.
1525 * @param *to_tp The type of this the operand muss be casted .
1527 ir_node *new_rd_Cast (dbg_info* db, ir_graph *irg, ir_node *block,
1528 ir_node *op, type *to_tp);
1530 /** Constructor for a Phi node.
1532 * @param *db A pointer for debug information.
1533 * @param *irg The ir graph the node belongs to.
1534 * @param *block The ir block the node belongs to.
1535 * @param arity The number of predecessors
1536 * @param *in[] Array with predecessors. The constructor copies this array.
1537 * @param *mode The mode of it's inputs and output.
1539 ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
1540 ir_node *in[], ir_mode *mode);
1542 /** Constructor for a Load node.
1544 * @param *db A pointer for debug information.
1545 * @param *irg The ir graph the node belongs to.
1546 * @param *block The ir block the node belongs to.
1547 * @param *store The current memory
1548 * @param *adr A pointer to the variable to be read in this memory.
1549 * @param *mode The mode of the value to be loaded.
1551 ir_node *new_rd_Load (dbg_info *db, ir_graph *irg, ir_node *block,
1552 ir_node *store, ir_node *adr, ir_mode *mode);
1554 /** Constructor for a Store node.
1556 * @param *db A pointer for debug information.
1557 * @param *irg The ir graph the node belongs to.
1558 * @param *block The ir block the node belongs to.
1559 * @param *store The current memory
1560 * @param *adr A pointer to the variable to be read in this memory.
1561 * @param *val The value to write to this variable.
1563 ir_node *new_rd_Store (dbg_info *db, ir_graph *irg, ir_node *block,
1564 ir_node *store, ir_node *adr, ir_node *val);
1566 /** Constructor for a Alloc node.
1568 * The Alloc node extends the memory by space for an entity of type alloc_type.
1570 * @param *db A pointer for debug information.
1571 * @param *irg The ir graph the node belongs to.
1572 * @param *block The ir block the node belongs to.
1573 * @param *store The memory which shall contain the new variable.
1574 * @param *size The number of bytes to allocate.
1575 * @param *alloc_type The type of the allocated variable.
1576 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
1578 ir_node *new_rd_Alloc (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1579 ir_node *size, type *alloc_type, where_alloc where);
1581 /** Constructor for a Free node.
1583 * Frees the memory occupied by the entity pointed to by the pointer
1584 * arg. Type indicates the type of the entity the argument points to.
1586 * @param *db A pointer for debug information.
1587 * @param *irg The ir graph the node belongs to.
1588 * @param *block The ir block the node belongs to.
1589 * @param *store The memory which shall contain the new variable.
1590 * @param *ptr The pointer to the object to free.
1591 * @param *size The number of objects of type free_type to free in a sequence.
1592 * @param *free_type The type of the freed variable.
1593 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
1595 ir_node *new_rd_Free (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1596 ir_node *ptr, ir_node *size, type *free_type, where_alloc where);
1598 /** Constructor for a Sync node.
1600 * Merges several memory values. The node assumes that a variable
1601 * either occurs only in one of the memories, or it contains the same
1602 * value in all memories where it occurs.
1604 * @param *db A pointer for debug information.
1605 * @param *irg The ir graph the node belongs to.
1606 * @param *block The ir block the node belongs to.
1607 * @param arity The number of memories to synchronize.
1608 * @param *in[] An array of pointers to nodes that produce an output of type
1609 * memory. The constructor copies this array.
1611 ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
1613 /** Constructor for a Proj node.
1615 * Projects a single value out of a tuple. The parameter proj gives the
1616 * position of the value within the tuple.
1618 * @param *db A pointer for debug information.
1619 * @param *irg The ir graph the node belongs to.
1620 * @param *block The ir block the node belongs to.
1621 * @param arg A node producing a tuple. The node must have mode_T.
1622 * @param *mode The mode of the value to project.
1623 * @param proj The position of the value in the tuple.
1625 ir_node *new_rd_Proj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1626 ir_mode *mode, long proj);
1628 /** Constructor for a defaultProj node.
1630 * Represents the default control flow of a Switch-Cond node.
1632 * @param *db A pointer for debug information.
1633 * @param *irg The ir graph the node belongs to.
1634 * @param *block The ir block the node belongs to.
1635 * @param arg A node producing a tuple.
1636 * @param max_proj The end position of the value in the tuple.
1638 ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1641 /** Constructor for a Tuple node.
1643 * This is an auxiliary node to replace a node that returns a tuple
1644 * without changing the corresponding Proj nodes.
1646 * @param *db A pointer for debug information.
1647 * @param *irg The ir graph the node belongs to.
1648 * @param *block The ir block the node belongs to.
1649 * @param arity The number of tuple elements.
1650 * @param *in[] An array containing pointers to the nodes producing the tuple
1651 * elements. The constructor copies this array.
1653 ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
1654 int arity, ir_node *in[]);
1656 /** Constructor for a Id node.
1658 * This is an auxiliary node to replace a node that returns a single
1661 * @param *db A pointer for debug information.
1662 * @param *irg The ir graph the node belongs to.
1663 * @param *block The ir block the node belongs to.
1664 * @param *val The value
1665 * @param *mode The mode of *val.
1667 ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
1668 ir_node *val, ir_mode *mode);
1670 /** Constructor for a Bad node.
1672 * Returns the unique Bad node of the graph. The same as
1675 * @param *irg The ir graph the node belongs to.
1677 ir_node *new_rd_Bad (ir_graph *irg);
1679 /** Constructor for a Confirm node.
1681 * Specifies constraints for a value. To support dataflow analyses.
1683 * Example: If the value never exceeds '100' this is expressed by placing a
1684 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
1686 * @param *irg The ir graph the node belong to.
1687 * @param *block The ir block the node belong to.
1688 * @param *db A pointer for debug information.
1689 * @param *val The value we express a constraint for
1690 * @param *bound The value to compare against. Must be a firm node, typically a constant.
1691 * @param cmp The compare operation.
1693 ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
1694 ir_node *val, ir_node *bound, pn_Cmp cmp);
1696 /** Constructor for an Unknown node.
1698 * Represents an arbitrary value. Places the node in the start block.
1700 * @param *irg The ir graph the node belongs to.
1701 * @param *m The mode of the unknown value.
1703 ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
1705 /** Constructor for a CallBegin node.
1707 * CallBegin represents control flow depending of the pointer value
1708 * representing the called method to the called methods. The
1709 * constructor copies the method pointer input from the passed Call
1712 * @param *db A pointer for debug information.
1713 * @param *irg The ir graph the node belong to.
1714 * @param *block The block the node belong to.
1715 * @param *callee The call node visible in the intra procedural view.
1717 ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
1719 /** Constructor for a EndReg node.
1721 * Used to represent regular procedure end in interprocedual view.
1723 * @param *db A pointer for debug information.
1724 * @param *irg The ir graph the node belong to.
1725 * @param *block The block the node belong to.
1727 ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
1729 /** Constructor for a EndExcept node.
1731 * Used to represent exceptional procedure end in interprocedural view.
1733 * @param *db A pointer for debug information.
1734 * @param *irg The ir graph the node belong to.
1735 * @param *block The block the node belong to.
1737 ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
1739 /** Constructor for a Filter node.
1741 * Adds the node to the block in current_ir_block. Filter is a node
1742 * with two views used to construct the interprocedural view. In
1743 * intraprocedural view its semantics are identical to the Proj node.
1744 * In interprocedural view the Filter performs the Phi operation on
1745 * method parameters or results. Other than a Phi a Filter node may
1746 * not be removed if it has only a single input.
1748 * The constructor builds the Filter in intraprocedural view.
1750 * @param *db A pointer for debug information.
1751 * @param *irg The ir graph the node belong to.
1752 * @param *block The block the node belong to.
1753 * @param *arg The tuple value to project from.
1754 * @param *mode The mode of the projected value.
1755 * @param proj The position in the tuple to project from.
1757 ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1758 ir_mode *mode, long proj);
1760 /** Constructor for a NoMem node.
1762 * Returns the unique NoMem node of the graph. The same as
1765 * @param *irg The ir graph the node belongs to.
1767 ir_node *new_rd_NoMem (ir_graph *irg);
1769 /** Constructor for a Mux node.
1771 * Adds the node to the block in current_ir_block.
1773 * @param *db A pointer for debug information.
1774 * @param *irg The ir graph the node belong to.
1775 * @param *block The block the node belong to.
1776 * @param *sel The ir_node that calculates the boolean select.
1777 * @param *ir_true The ir_node that calculates the true result.
1778 * @param *ir_false The ir_node that calculates the false result.
1779 * @param *mode The mode of the node (and it_true and ir_false).
1781 ir_node *new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block,
1782 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
1784 /*-------------------------------------------------------------------------*/
1785 /* The raw interface without debug support */
1786 /*-------------------------------------------------------------------------*/
1788 /** Constructor for a Block node.
1790 * Constructs a mature block with the given predecessors. Use Unknown
1791 * nodes as predecessors to construct a block if the number of
1792 * predecessors is known, but not the predecessors themselves. This
1793 * constructor does not set current_block. It not be used with
1794 * automatic Phi node construction.
1797 * @param irg The ir graph the block belongs to.
1798 * @param arity The number of control predecessors.
1799 * @param in[] An array of control predecessors. The length of
1800 * the array must be 'arity'. The constructor copies this array.
1802 ir_node *new_r_Block (ir_graph *irg, int arity, ir_node *in[]);
1804 /** Constructor for a Start node.
1806 * @param *irg The ir graph the node belongs to.
1807 * @param *block The ir block the node belongs to.
1809 ir_node *new_r_Start (ir_graph *irg, ir_node *block);
1811 /** Constructor for a End node.
1813 * @param *irg The ir graph the node belongs to.
1814 * @param *block The ir block the node belongs to.
1816 ir_node *new_r_End (ir_graph *irg, ir_node *block);
1818 /** Constructor for a Jmp node.
1820 * Jmp represents control flow to a single control successor.
1822 * @param *irg The ir graph the node belongs to.
1823 * @param *block The ir block the node belongs to.
1825 ir_node *new_r_Jmp (ir_graph *irg, ir_node *block);
1827 /** Constructor for a Cond node.
1829 * If c is mode_b represents a conditional branch (if/else). If c is
1830 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1831 * node, default Proj is 0.)
1833 * This is not consistent: Input to Cond is Is, Proj has as proj number
1836 * @param *irg The ir graph the node belongs to.
1837 * @param *block The ir block the node belongs to.
1838 * @param *c The conditions parameter.Can be of mode b or I_u.
1840 ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c);
1842 /** Constructor for a Return node.
1844 * Returns the memory an zero or more return values. Only node that
1845 * can end regular control flow.
1847 * @param *irg The ir graph the node belongs to.
1848 * @param *block The ir block the node belongs to.
1849 * @param *store The state of memory.
1850 * @param arity Number of array indices.
1851 * @param *in[] Array with index inputs to the node. The constructor copies this array.
1853 ir_node *new_r_Return (ir_graph *irg, ir_node *block,
1854 ir_node *store, int arity, ir_node *in[]);
1856 /** Constructor for a Raise node.
1858 * @param *irg The ir graph the node belongs to.
1859 * @param *block The ir block the node belongs to.
1860 * @param *store The current memory.
1861 * @param *obj A pointer to the Except variable.
1863 ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
1864 ir_node *store, ir_node *obj);
1866 /** Constructor for a Const node.
1868 * Constructor for a Const node. The constant represents a target
1869 * value. Sets the type information to type_unknown. (No more
1870 * supported: If tv is entity derives a somehow useful type.)
1872 * @param *irg The ir graph the node belongs to.
1873 * @param *block The ir block the node belongs to.
1874 * @param *mode The mode of the operands and the results.
1875 * @param *con Points to an entry in the constant table.
1877 ir_node *new_r_Const (ir_graph *irg, ir_node *block,
1878 ir_mode *mode, tarval *con);
1880 /** Constructor for a Const node.
1882 * Constructor for a Const node. The constant represents a target
1883 * value. Sets the type information to type_unknown. (No more
1884 * supported: If tv is entity derives a somehow useful type.)
1886 * @param *irg The ir graph the node belongs to.
1887 * @param *block The ir block the node belongs to.
1888 * @param *mode The mode of the operands and the results.
1889 * @param value A value from which the tarval is made.
1891 ir_node *new_r_Const_long(ir_graph *irg, ir_node *block,
1892 ir_mode *mode, long value);
1894 /** Constructor for a SymConst node.
1896 * This is the constructor for a symbolic constant.
1897 * There are four kinds of symbolic constants:
1898 * - type_tag The symbolic constant represents a type tag. The type the
1899 * tag stands for is given explicitly.
1900 * - size The symbolic constant represents the size of a type. The
1901 * type of which the constant represents the size is given
1903 * - addr_name The symbolic constant represents the address of an entity
1904 * (variable or method). The variable is indicated by a name
1905 * that is valid for linking.
1906 * - addr_ent The symbolic constant represents the address of an entity
1907 * (variable or method). The variable is given explicitly by
1910 * Inputs to the node:
1911 * No inputs except the block it belongs to.
1912 * Outputs of the node.
1913 * An unsigned integer (I_u) or a pointer (P).
1915 * @param *irg The ir graph the node belongs to.
1916 * @param *block The ir block the node belongs to.
1917 * @param value A type, entity or a ident depending on the SymConst kind.
1918 * @param symkind The kind of the symbolic constant: type_tag, size or link_info.
1920 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
1921 union symconst_symbol value, symconst_kind symkind);
1923 /** Constructor for a Sel node.
1925 * The select node selects an entity (field or method) from an entity
1926 * with a compound type. It explicitly specifies the entity selected.
1927 * Dynamically the node may select entities that overwrite the given
1928 * entity. If the selected entity is an array element entity the Sel
1929 * node takes the required array indices as inputs.
1931 * @param *irg The ir graph the node belongs to.
1932 * @param *block The ir block the node belongs to.
1933 * @param *store The memory in which the object the entity should be selected
1934 * from is allocated.
1935 * @param *objptr A pointer to a compound entity the Sel operation selects a
1936 * single attribute from.
1937 * @param *n_index The number of array indices needed to select an array element entity.
1938 * @param *index[] If the compound entity is an array the indices of the selected
1939 * element entity. The constructor copies this array.
1940 * @param *ent The entity to select.
1942 ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store,
1943 ir_node *objptr, int n_index, ir_node *index[],
1946 /** Constructor for a InstOf node.
1948 * For translating Java. Not supported as standard firm node.
1950 * @param *irg The ir graph the node belongs to.
1951 * @param *block The ir block the node belongs to.
1956 ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *x, ir_node *y, type *z);
1958 /** Constructor for a Call node.
1960 * Represents all kinds of method and function calls.
1962 * @param *irg The ir graph the node belongs to.
1963 * @param *block The ir block the node belongs to.
1964 * @param * store The actual store.
1965 * @param *callee A pointer to the called procedure.
1966 * @param arity The number of procedure parameters.
1967 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
1968 * @param *tp Type information of the procedure called.
1970 ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
1971 ir_node *callee, int arity, ir_node *in[],
1974 /** Constructor for a Add node.
1976 * @param *irg The ir graph the node belongs to.
1977 * @param *block The ir block the node belongs to.
1978 * @param *op1 The operand 1.
1979 * @param *op2 The operand 2.
1980 * @param *mode The mode of the operands and the result.
1982 ir_node *new_r_Add (ir_graph *irg, ir_node *block,
1983 ir_node *op1, ir_node *op2, ir_mode *mode);
1986 * Constructor for a Sub node.
1988 * @param *irg The ir graph the node belongs to.
1989 * @param *block The ir block the node belongs to.
1990 * @param *op1 The operand 1.
1991 * @param *op2 The operand 2.
1992 * @param *mode The mode of the operands and the results.
1994 ir_node *new_r_Sub (ir_graph *irg, ir_node *block,
1995 ir_node *op1, ir_node *op2, ir_mode *mode);
1997 /** Constructor for a Minus node.
1999 * @param *irg The ir graph the node belongs to.
2000 * @param *block The ir block the node belongs to.
2001 * @param *op The operand.
2002 * @param *mode The mode of the operand and the result.
2004 ir_node *new_r_Minus (ir_graph *irg, ir_node *block,
2005 ir_node *op, ir_mode *mode);
2006 /** Constructor for a Mul node.
2008 * @param *irg The ir graph the node belongs to.
2009 * @param *block The ir block the node belongs to.
2010 * @param *op1 The operand 1.
2011 * @param *op2 The operand 2.
2012 * @param *mode The mode of the operands and the result.
2014 ir_node *new_r_Mul (ir_graph *irg, ir_node *block,
2015 ir_node *op1, ir_node *op2, ir_mode *mode);
2017 /** Constructor for a Quot node.
2019 * @param *irg The ir graph the node belongs to.
2020 * @param *block The ir block the node belongs to.
2021 * @param *memop The store needed to model exceptions
2022 * @param *op1 The operand 1.
2023 * @param *op2 The operand 2.
2025 ir_node *new_r_Quot (ir_graph *irg, ir_node *block,
2026 ir_node *memop, ir_node *op1, ir_node *op2);
2028 /** Constructor for a DivMod node.
2030 * @param *irg The ir graph the node belongs to.
2031 * @param *block The ir block the node belongs to.
2032 * @param *memop The store needed to model exceptions
2033 * @param *op1 The operand 1.
2034 * @param *op2 The operand 2.
2036 ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
2037 ir_node *memop, ir_node *op1, ir_node *op2);
2039 /** Constructor for a Div node.
2041 * @param *irg The ir graph the node belongs to.
2042 * @param *block The ir block the node belongs to.
2043 * @param *memop The store needed to model exceptions
2044 * @param *op1 The operand 1.
2045 * @param *op2 The operand 2.
2047 ir_node *new_r_Div (ir_graph *irg, ir_node *block,
2048 ir_node *memop, ir_node *op1, ir_node *op2);
2050 /** Constructor for a Mod node.
2052 * @param *irg The ir graph the node belongs to.
2053 * @param *block The ir block the node belongs to.
2054 * @param *memop The store needed to model exceptions
2055 * @param *op1 The operand 1.
2056 * @param *op2 The operand 2.
2058 ir_node *new_r_Mod (ir_graph *irg, ir_node *block,
2059 ir_node *memop, ir_node *op1, ir_node *op2);
2061 /** Constructor for a Abs node.
2063 * @param *irg The ir graph the node belongs to.
2064 * @param *block The ir block the node belongs to.
2065 * @param *op The operand
2066 * @param *mode The mode of the operands and the result.
2068 ir_node *new_r_Abs (ir_graph *irg, ir_node *block,
2069 ir_node *op, ir_mode *mode);
2071 /** Constructor for a And node.
2073 * @param *irg The ir graph the node belongs to.
2074 * @param *block The ir block the node belongs to.
2075 * @param *op1 The operand 1.
2076 * @param *op2 The operand 2.
2077 * @param *mode The mode of the operands and the result.
2079 ir_node *new_r_And (ir_graph *irg, ir_node *block,
2080 ir_node *op1, ir_node *op2, ir_mode *mode);
2082 /** Constructor for a Or node.
2084 * @param *irg The ir graph the node belongs to.
2085 * @param *block The ir block the node belongs to.
2086 * @param *op1 The operand 1.
2087 * @param *op2 The operand 2.
2088 * @param *mode The mode of the operands and the result.
2090 ir_node *new_r_Or (ir_graph *irg, ir_node *block,
2091 ir_node *op1, ir_node *op2, ir_mode *mode);
2093 /** Constructor for a Eor node.
2095 * @param *irg The ir graph the node belongs to.
2096 * @param *block The ir block the node belongs to.
2097 * @param *op1 The operand 1.
2098 * @param *op2 The operand 2.
2099 * @param *mode The mode of the operands and the results.
2101 ir_node *new_r_Eor (ir_graph *irg, ir_node *block,
2102 ir_node *op1, ir_node *op2, ir_mode *mode);
2104 /** Constructor for a Not node.
2106 * @param *irg The ir graph the node belongs to.
2107 * @param *block The ir block the node belongs to.
2108 * @param *op The operand.
2109 * @param *mode The mode of the operand and the result.
2111 ir_node *new_r_Not (ir_graph *irg, ir_node *block,
2112 ir_node *op, ir_mode *mode);
2114 /** Constructor for a Cmp node.
2116 * @param *irg The ir graph the node belongs to.
2117 * @param *block The ir block the node belongs to.
2118 * @param *op1 The operand 1.
2119 * @param *op2 The operand 2.
2121 ir_node *new_r_Cmp (ir_graph *irg, ir_node *block,
2122 ir_node *op1, ir_node *op2);
2124 /** Constructor for a Shl node.
2126 * @param *irg The ir graph the node belongs to.
2127 * @param *block The ir block the node belongs to.
2128 * @param *op The operand.
2129 * @param *k The number of bits to shift the operand .
2130 * @param *mode The mode of the operand and the result.
2132 ir_node *new_r_Shl (ir_graph *irg, ir_node *block,
2133 ir_node *op, ir_node *k, ir_mode *mode);
2135 /** Constructor for a Shr node.
2137 * @param *irg The ir graph the node belongs to.
2138 * @param *block The ir block the node belongs to.
2139 * @param *op The operand.
2140 * @param *k The number of bits to shift the operand .
2141 * @param *mode The mode of the operand and the result.
2143 ir_node *new_r_Shr (ir_graph *irg, ir_node *block,
2144 ir_node *op, ir_node *k, ir_mode *mode);
2147 * Constructor for a Shrs node.
2149 * @param *irg The ir graph the node belongs to.
2150 * @param *block The ir block the node belongs to.
2151 * @param *op The operand.
2152 * @param *k The number of bits to shift the operand.
2153 * @param *mode The mode of the operand and the result.
2155 ir_node *new_r_Shrs (ir_graph *irg, ir_node *block,
2156 ir_node *op, ir_node *k, ir_mode *mode);
2158 /** Constructor for a Rot node.
2160 * @param *irg The ir graph the node belongs to.
2161 * @param *block The ir block the node belongs to.
2162 * @param *op The operand.
2163 * @param *k The number of bits to rotate the operand.
2164 * @param *mode The mode of the operand.
2166 ir_node *new_r_Rot (ir_graph *irg, ir_node *block,
2167 ir_node *op, ir_node *k, ir_mode *mode);
2169 /** Constructor for a Conv node.
2171 * @param *irg The ir graph the node belongs to.
2172 * @param *block The ir block the node belongs to.
2173 * @param *op The operand.
2174 * @param *mode The mode of this the operand muss be converted .
2176 ir_node *new_r_Conv (ir_graph *irg, ir_node *block,
2177 ir_node *op, ir_mode *mode);
2179 /** Constructor for a Cast node.
2181 * High level type cast
2183 * @param *irg The ir graph the node belongs to.
2184 * @param *block The ir block the node belongs to.
2185 * @param *op The operand.
2186 * @param *to_tp The type of this the operand muss be casted .
2188 ir_node *new_r_Cast (ir_graph *irg, ir_node *block,
2189 ir_node *op, type *to_tp);
2191 /** Constructor for a Phi node.
2193 * @param *irg The ir graph the node belongs to.
2194 * @param *block The ir block the node belongs to.
2195 * @param arity The number of predecessors
2196 * @param *in[] Array with predecessors. The constructor copies this array.
2197 * @param *mode The mode of it's inputs and output.
2199 ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity,
2200 ir_node *in[], ir_mode *mode);
2202 /** Constructor for a Load node.
2204 * @param *irg The ir graph the node belongs to.
2205 * @param *block The ir block the node belongs to.
2206 * @param *store The current memory
2207 * @param *adr A pointer to the variable to be read in this memory.
2208 * @param *mode The mode of the value to be loaded.
2210 ir_node *new_r_Load (ir_graph *irg, ir_node *block,
2211 ir_node *store, ir_node *adr, ir_mode *mode);
2213 /** Constructor for a Store node.
2215 * @param *irg The ir graph the node belongs to.
2216 * @param *block The ir block the node belongs to.
2217 * @param *store The current memory
2218 * @param *adr A pointer to the variable to be read in this memory.
2219 * @param *val The value to write to this variable.
2221 ir_node *new_r_Store (ir_graph *irg, ir_node *block,
2222 ir_node *store, ir_node *adr, ir_node *val);
2224 /** Constructor for a Alloc node.
2226 * The Alloc node extends the memory by space for an entity of type alloc_type.
2228 * @param *irg The ir graph the node belongs to.
2229 * @param *block The ir block the node belongs to.
2230 * @param *store The memory which shall contain the new variable.
2231 * @param *size The number of bytes to allocate.
2232 * @param *alloc_type The type of the allocated variable.
2233 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2235 ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store,
2236 ir_node *size, type *alloc_type, where_alloc where);
2238 /** Constructor for a Free node.
2240 * Frees the memory occupied by the entity pointed to by the pointer
2241 * arg. Type indicates the type of the entity the argument points to.
2243 * @param *irg The ir graph the node belongs to.
2244 * @param *block The ir block the node belongs to.
2245 * @param *store The memory which shall contain the new variable.
2246 * @param *ptr The pointer to the object to free.
2247 * @param *size The number of objects of type free_type to free in a sequence.
2248 * @param *free_type The type of the freed variable.
2249 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2251 ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store,
2252 ir_node *ptr, ir_node *size, type *free_type, where_alloc where);
2254 /** Constructor for a Sync node.
2256 * Merges several memory values. The node assumes that a variable
2257 * either occurs only in one of the memories, or it contains the same
2258 * value in all memories where it occurs.
2260 * @param *irg The ir graph the node belongs to.
2261 * @param *block The ir block the node belongs to.
2262 * @param arity The number of memories to synchronize.
2263 * @param *in[] An array of pointers to nodes that produce an output of type memory.
2264 * The constructor copies this array.
2266 ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2268 /** Constructor for a Proj node.
2270 * Projects a single value out of a tuple. The parameter proj gives the
2271 * position of the value within the tuple.
2273 * @param *irg The ir graph the node belongs to.
2274 * @param *block The ir block the node belongs to.
2275 * @param arg A node producing a tuple.
2276 * @param *mode The mode of the value to project.
2277 * @param proj The position of the value in the tuple.
2279 ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg,
2280 ir_mode *mode, long proj);
2282 /** Constructor for a defaultProj node.
2284 * Represents the default control flow of a Switch-Cond node.
2286 * @param *irg The ir graph the node belongs to.
2287 * @param *block The ir block the node belongs to.
2288 * @param arg A node producing a tuple.
2289 * @param max_ proj The end position of the value in the tuple.
2291 ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj);
2294 /** Constructor for a Tuple node.
2296 * This is an auxiliary node to replace a node that returns a tuple
2297 * without changing the corresponding Proj nodes.
2299 * @param *irg The ir graph the node belongs to.
2300 * @param *block The ir block the node belongs to.
2301 * @param arity The number of tuple elements.
2302 * @param *in[] An array containing pointers to the nodes producing the tuple elements.
2303 * The constructor copies this array.
2305 ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2307 /** Constructor for a Id node.
2309 * This is an auxiliary node to replace a node that returns a single
2312 * @param *irg The ir graph the node belongs to.
2313 * @param *block The ir block the node belongs to.
2314 * @param *val The operand to Id.
2315 * @param *mode The mode of *val.
2317 ir_node *new_r_Id (ir_graph *irg, ir_node *block,
2318 ir_node *val, ir_mode *mode);
2320 /** Constructor for a Bad node.
2322 * Returns the unique Bad node of the graph. The same as
2325 * @param *irg The ir graph the node belongs to.
2329 ir_node *new_r_Bad (ir_graph *irg);
2331 /** Constructor for a Confirm node.
2333 * Specifies constraints for a value. To support dataflow analyses.
2335 * Example: If the value never exceeds '100' this is expressed by placing a
2336 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
2338 * @param *irg The ir graph the node belong to.
2339 * @param *block The ir block the node belong to.
2340 * @param *db A pointer for debug information.
2341 * @param *val The value we express a constraint for
2342 * @param *bound The value to compare against. Must be a firm node, typically a constant.
2343 * @param cmp The compare operation.
2346 ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
2347 ir_node *val, ir_node *bound, pn_Cmp cmp);
2349 /** Constructor for a Unknown node.
2351 * Represents an arbitrary value. Places the node in
2354 * @param *irg The ir graph the node belongs to.
2355 * @param *m The mode of the unknown value.
2357 ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2359 /** Constructor for a CallBegin node.
2361 * CallBegin represents control flow depending of the pointer value
2362 * representing the called method to the called methods. The
2363 * constructor copies the method pointer input from the passed Call
2366 * @param *irg The ir graph the node belong to.
2367 * @param *block The block the node belong to.
2368 * @param *callee The call node visible in the intra procedural view.
2370 ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
2372 /** Constructor for a EndReg node.
2374 * Used to represent regular procedure end in interprocedual view.
2376 * @param *irg The ir graph the node belong to.
2377 * @param *block The block the node belong to.
2379 ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
2381 /** Constructor for a EndExcept node.
2383 * Used to represent exceptional procedure end in interprocedural view.
2385 * @param *irg The ir graph the node belong to.
2386 * @param *block The block the node belong to.
2388 ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
2390 /** Constructor for a Break node.
2392 * Break represents control flow to a single control successor just as Jmp.
2393 * The blocks separated by a break may not be concatenated by an optimization.
2394 * It is used for the interprocedural representation where blocks are parted
2395 * behind Call nodes to represent the control flow to called procedures.
2397 * @param *irg The ir graph the node belong to.
2398 * @param *block The block the node belong to.
2400 ir_node *new_r_Break (ir_graph *irg, ir_node *block);
2402 /** Constructor for a Filter node.
2404 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
2405 * Filter is a node with two views used to construct the interprocedural view.
2406 * In intraprocedural view its semantics are identical to the Proj node.
2407 * In interprocedural view the Filter performs the Phi operation on method
2408 * parameters or results. Other than a Phi a Filter node may not be removed
2409 * if it has only a single input.
2411 * The constructor builds the Filter in intraprocedural view.
2413 * @param *irg The ir graph the node belong to.
2414 * @param *block The block the node belong to.
2415 * @param *arg The tuple value to project from.
2416 * @param *mode The mode of the projected value.
2417 * @param proj The position in the tuple to project from.
2419 ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
2420 ir_mode *mode, long proj);
2422 /** Constructor for a NoMem node.
2424 * Returns the unique NoMem node of the graph. The same as
2427 * @param *irg The ir graph the node belongs to.
2429 ir_node *new_r_NoMem (ir_graph *irg);
2431 /** Constructor for a Mux node.
2433 * Adds the node to the block in current_ir_block.
2435 * @param *irg The ir graph the node belong to.
2436 * @param *block The block the node belong to.
2437 * @param *sel The ir_node that calculates the boolean select.
2438 * @param *ir_true The ir_node that calculates the true result.
2439 * @param *ir_false The ir_node that calculates the false result.
2440 * @param *mode The mode of the node (and it_true and ir_false).
2442 ir_node *new_r_Mux (ir_graph *irg, ir_node *block,
2443 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2445 /*-----------------------------------------------------------------------*/
2446 /* The block oriented interface */
2447 /*-----------------------------------------------------------------------*/
2449 /** Sets the current block in which the following constructors place the
2450 * nodes they construct.
2452 * @param target The new current block.
2454 void set_cur_block (ir_node *target);
2456 /** Returns the current block of the current graph. */
2457 ir_node *get_cur_block(void);
2459 /** Returns the fixed nodes of the current graph. */
2460 #define get_cur_end_block() get_irg_end_block(current_ir_graph)
2461 #define get_cur_end() get_irg_end(current_ir_graph)
2462 #define get_cur_start_block() get_irg_start_block(current_ir_graph)
2463 #define get_cur_start() get_irg_start(current_ir_graph)
2465 /** Constructor for a Block node.
2467 * Adds the block to the graph in current_ir_graph. Constructs a Block
2468 * with a fixed number of predecessors. Does set current_block. Can
2469 * be used with automatic Phi node construction.
2471 * @param *db A Pointer for debug information.
2472 * @param arity The number of control predecessors.
2473 * @param in[] An array of control predecessors. The length of
2474 * the array must be 'arity'.
2476 ir_node *new_d_Block(dbg_info* db, int arity, ir_node *in[]);
2478 /** Constructor for a Start node.
2480 * Adds the node to the block in current_ir_block.
2482 * @param *db A pointer for debug information.
2484 ir_node *new_d_Start (dbg_info* db);
2486 /** Constructor for a End node.
2488 * Adds the node to the block in current_ir_block.
2490 * @param *db A pointer for debug information.
2492 ir_node *new_d_End (dbg_info* db);
2494 /** Constructor for a Jmp node.
2496 * Adds the node to the block in current_ir_block.
2498 * Jmp represents control flow to a single control successor.
2500 * @param *db A pointer for debug information.
2503 ir_node *new_d_Jmp (dbg_info* db);
2505 /** Constructor for a Cond node.
2507 * Adds the node to the block in current_ir_block.
2509 * If c is mode_b represents a conditional branch (if/else). If c is
2510 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2511 * node, default Proj is 0.)
2513 * This is not consistent: Input to Cond is Is, Proj has as proj number
2516 * @param *db A pointer for debug information.
2517 * @param *c The conditions parameter.Can be of mode b or I_u.
2520 ir_node *new_d_Cond (dbg_info* db, ir_node *c);
2522 /** Constructor for a Return node.
2524 * Adds the node to the block in current_ir_block.
2526 * Returns the memory an zero or more return values. Only node that
2527 * can end regular control flow.
2529 * @param *db A pointer for debug information.
2530 * @param *store The state of memory.
2531 * @param arity Number of array indices.
2532 * @param *in Array with index inputs to the node.
2535 ir_node *new_d_Return (dbg_info* db, ir_node *store, int arity, ir_node *in[]);
2537 /** Constructor for a Raise node.
2539 * Adds the node to the block in current_ir_block.
2541 * @param *db A pointer for debug information.
2542 * @param *store The current memory.
2543 * @param *obj A pointer to the Except variable.
2546 ir_node *new_d_Raise (dbg_info* db, ir_node *store, ir_node *obj);
2548 /** Constructor for a Const_type node.
2550 * Adds the node to the block in current_ir_block.
2552 * The constant represents a target value. This constructor sets high
2553 * level type information for the constant value.
2555 * @param *db A pointer for debug information.
2556 * @param *mode The mode of the operands and results.
2557 * @param *con Points to an entry in the constant table. This pointer is
2558 added to the attributes of the node.
2559 * @param *tp The type of the constant.
2561 ir_node *new_d_Const_type (dbg_info* db, ir_mode *mode, tarval *con, type *tp);
2563 /** Constructor for a Const node.
2565 * Adds the node to the block in current_ir_block.
2567 * Constructor for a Const node. The constant represents a target
2568 * value. Sets the type information to type_unknown. (No more
2569 * supported: If tv is entity derives a somehow useful type.)
2571 * @param *db A pointer for debug information.
2572 * @param *mode The mode of the operands and results.
2573 * @param *con Points to an entry in the constant table. This pointer is added
2574 * to the attributes of the node.
2576 ir_node *new_d_Const (dbg_info* db, ir_mode *mode, tarval *con);
2578 /** Constructor for a SymConst_type node.
2580 * Adds the node to the block in current_ir_block.
2581 * This is the constructor for a symbolic constant.
2582 * There are four kinds of symbolic constants:
2583 * - type_tag The symbolic constant represents a type tag. The type the
2584 * tag stands for is given explicitly.
2585 * - size The symbolic constant represents the size of a type. The
2586 * type of which the constant represents the size is given
2588 * - addr_name The symbolic constant represents the address of an entity
2589 * (variable or method). The variable is indicated by a name
2590 * that is valid for linking.
2591 * - addr_ent The symbolic constant represents the address of an entity
2592 * (variable or method). The variable is given explicitly by
2595 * Inputs to the node:
2596 * No inputs except the block it belongs to.
2597 * Outputs of the node.
2598 * An unsigned integer (I_u) or a pointer (P).
2600 * @param *db A pointer for debug information.
2601 * @param value A type, entity or ident depending on the SymConst kind.
2602 * @param symkind The kind of the symbolic constant: symconst_type_tag, symconst_size
2603 * or symconst_addr_name.
2604 * @param tp The source type of the constant.
2607 ir_node *new_d_SymConst_type (dbg_info* db, union symconst_symbol value, symconst_kind kind, type* tp);
2609 /** Constructor for a SymConst node.
2611 * Same as new_d_SymConst_type, except that it sets the type to type_unknown. */
2612 ir_node *new_d_SymConst (dbg_info* db, union symconst_symbol value, symconst_kind kind);
2614 /** Constructor for a simpleSel node.
2616 * This is a shortcut for the new_d_Sel() constructor. To be used for
2617 * Sel nodes that do not select from an array, i.e., have no index
2618 * inputs. It adds the two parameters 0, NULL.
2620 * @param *db A pointer for debug information.
2621 * @param *store The memory in which the object the entity should be
2622 * selected from is allocated.
2623 * @param *objptr The object from that the Sel operation selects a
2624 * single attribute out.
2625 * @param *ent The entity to select.
2627 ir_node *new_d_simpleSel(dbg_info* db, ir_node *store, ir_node *objptr, entity *ent);
2629 /** Constructor for a Sel node.
2631 * The select node selects an entity (field or method) from an entity
2632 * with a compound type. It explicitly specifies the entity selected.
2633 * Dynamically the node may select entities that overwrite the given
2634 * entity. If the selected entity is an array element entity the Sel
2635 * node takes the required array indices as inputs.
2636 * Adds the node to the block in current_ir_block.
2638 * @param *db A pointer for debug information.
2639 * @param *store The memory in which the object the entity should be selected
2640 * from is allocated.
2641 * @param *objptr A pointer to a compound entity the Sel operation selects a
2642 * single attribute from.
2643 * @param *n_index The number of array indices needed to select an array element entity.
2644 * @param *index[] If the compound entity is an array the indices of the selected
2645 * element entity. The constructor copies this array.
2646 * @param *ent The entity to select.
2648 ir_node *new_d_Sel (dbg_info* db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
2651 /** Constructor for a InstOf node.
2653 * Adds the node to the block in current_ir_block.
2655 * For translating Java. Not supported as standard firm node.
2657 * @param *db A pointer for debug information.
2662 ir_node *new_d_InstOf (dbg_info* db, ir_node *store, ir_node *objptr, type *ent);
2664 /** Constructor for a Call node.
2666 * Represents all kinds of method and function calls.
2667 * Adds the node to the block in current_ir_block.
2669 * @param *db A pointer for debug information.
2670 * @param *store The actual store.
2671 * @param *callee A pointer to the called procedure.
2672 * @param arity The number of procedure parameters.
2673 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2674 * @param *tp Type information of the procedure called.
2677 ir_node *new_d_Call (dbg_info* db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
2680 /** Constructor for a Add node.
2682 * Adds the node to the block in current_ir_block.
2684 * @param *db A pointer for debug information.
2685 * @param *op1 The operand 1.
2686 * @param *op2 The operand 2.
2687 * @param *mode The mode of the operands and the result.
2689 ir_node *new_d_Add (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2691 /** Constructor for a Sub node.
2693 * Adds the node to the block in current_ir_block.
2695 * @param *db A pointer for debug information.
2696 * @param *op1 The operand 1.
2697 * @param *op2 The operand 2.
2698 * @param *mode The mode of the operands and the result.
2701 ir_node *new_d_Sub (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2703 /** Constructor for a Minus node.
2705 * Adds the node to the block in current_ir_block.
2707 * @param *db A pointer for debug information.
2708 * @param *op The operand .
2709 * @param *mode The mode of the operand and the result.
2711 ir_node *new_d_Minus (dbg_info* db, ir_node *op, ir_mode *mode);
2713 /** Constructor for a Mul node.
2715 * Adds the node to the block in current_ir_block.
2717 * @param *db A pointer for debug information.
2718 * @param *op1 The operand 1.
2719 * @param *op2 The operand 2.
2720 * @param *mode The mode of the operands and the result.
2722 ir_node *new_d_Mul (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2724 /** Constructor for a Quot node.
2726 * Adds the node to the block in current_ir_block.
2728 * @param *db A pointer for debug information.
2729 * @param *memop The store needed to model exceptions
2730 * @param *op1 The operand 1.
2731 * @param *op2 The operand 2.
2733 ir_node *new_d_Quot (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2735 /** Constructor for a DivMod node.
2737 * Adds the node to the block in current_ir_block.
2739 * @param *db A pointer for debug information.
2740 * @param *memop The store needed to model exceptions
2741 * @param *op1 The operand 1.
2742 * @param *op2 The operand 2.
2744 ir_node *new_d_DivMod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2746 /** Constructor for a Div node.
2748 * Adds the node to the block in current_ir_block.
2750 * @param *db A pointer for debug information.
2751 * @param *memop The store needed to model exceptions
2752 * @param *op1 The operand 1.
2753 * @param *op2 The operand 2.
2755 ir_node *new_d_Div (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2757 /** Constructor for a Mod node.
2759 * Adds the node to the block in current_ir_block.
2761 * @param *db A pointer for debug information.
2762 * @param *memop The store needed to model exceptions
2763 * @param *op1 The operand 1.
2764 * @param *op2 The operand 2.
2766 ir_node *new_d_Mod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2768 /** Constructor for a Abs node.
2770 * Adds the node to the block in current_ir_block.
2772 * @param *db A pointer for debug information.
2773 * @param *op The operand
2774 * @param *mode The mode of the operands and the result.
2776 ir_node *new_d_Abs (dbg_info* db, ir_node *op, ir_mode *mode);
2778 /** Constructor for a And node.
2780 * Adds the node to the block in current_ir_block.
2782 * @param *db A pointer for debug information.
2783 * @param *irg The ir graph the node belongs to.
2784 * @param *block The ir block the node belongs to.
2785 * @param *op1 The operand 1.
2786 * @param *op2 The operand 2.
2787 * @param *mode The mode of the operands and the result.
2789 ir_node *new_d_And (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2791 /** Constructor for a Or node.
2793 * Adds the node to the block in current_ir_block.
2795 * @param *db A pointer for debug information.
2796 * @param *op1 The operand 1.
2797 * @param *op2 The operand 2.
2798 * @param *mode The mode of the operands and the result.
2800 ir_node *new_d_Or (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2802 /** Constructor for a Eor node.
2804 * Adds the node to the block in current_ir_block.
2806 * @param *db A pointer for debug information.
2807 * @param *op1 The operand 1.
2808 * @param *op2 The operand 2.
2809 * @param *mode The mode of the operands and the results.
2811 ir_node *new_d_Eor (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2813 /** Constructor for a Not node.
2815 * Adds the node to the block in current_ir_block.
2817 * @param *db A pointer for debug information.
2818 * @param *op The operand.
2819 * @param *mode The mode of the operand and the result.
2821 ir_node *new_d_Not (dbg_info* db, ir_node *op, ir_mode *mode);
2823 /** Constructor for a Shl node.
2825 * Adds the node to the block in current_ir_block.
2827 * @param *db A pointer for debug information.
2828 * @param *op The operand.
2829 * @param *k The number of bits to shift the operand .
2830 * @param *mode The mode of the operand and the result.
2832 ir_node *new_d_Shl (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2834 /** Constructor for a Shr node.
2836 * Adds the node to the block in current_ir_block.
2838 * @param *db A pointer for debug information.
2839 * @param *op The operand.
2840 * @param *k The number of bits to shift the operand .
2841 * @param *mode The mode of the operand and the result.
2843 ir_node *new_d_Shr (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2845 /** Constructor for a Shrs node.
2847 * Adds the node to the block in current_ir_block.
2849 * @param *db A pointer for debug information.
2850 * @param *op The operand.
2851 * @param *k The number of bits to shift the operand .
2852 * @param *mode The mode of the operand and the result.
2854 ir_node *new_d_Shrs (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2856 /** Constructor for a Rot node.
2858 * Adds the node to the block in current_ir_block.
2860 * @param *db A pointer for debug information.
2861 * @param *op The operand.
2862 * @param *k The number of bits to rotate the operand.
2863 * @param *mode The mode of the operand.
2865 ir_node *new_d_Rot (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2867 /** Constructor for a Cmp node.
2869 * Adds the node to the block in current_ir_block.
2871 * @param *db A pointer for debug information.
2872 * @param *op1 The operand 1.
2873 * @param *op2 The operand 2.
2875 ir_node *new_d_Cmp (dbg_info* db, ir_node *op1, ir_node *op2);
2877 /** Constructor for a Conv node.
2879 * Adds the node to the block in current_ir_block.
2881 * @param *db A pointer for debug information.
2882 * @param *op The operand.
2883 * @param *mode The mode of this the operand muss be converted .
2885 ir_node *new_d_Conv (dbg_info* db, ir_node *op, ir_mode *mode);
2887 /**Constructor for a Cast node.
2889 * High level type cast
2890 * Adds the node to the block in current_ir_block.
2892 * @param *db A pointer for debug information.
2893 * @param *op The operand.
2894 * @param *to_tp The type of this the operand muss be casted .
2896 ir_node *new_d_Cast (dbg_info* db, ir_node *op, type *to_tp);
2898 /**Constructor for a Phi node.
2900 * Adds the node to the block in current_ir_block.
2902 * @param *db A pointer for debug information.
2903 * @param arity The number of predecessors
2904 * @param *in Array with predecessors
2905 * @param *mode The mode of it's inputs and output.
2907 ir_node *new_d_Phi (dbg_info* db, int arity, ir_node *in[], ir_mode *mode);
2909 /** Constructor for a Load node.
2911 * Adds the node to the block in current_ir_block.
2913 * @param *db A pointer for debug information.
2914 * @param *store The current memory
2915 * @param *adr A pointer to the variable to be read in this memory.
2916 * @param *mode The mode of the value to be loaded.
2918 ir_node *new_d_Load (dbg_info* db, ir_node *store, ir_node *addr, ir_mode *mode);
2920 /** Constructor for a Store node.
2922 * Adds the node to the block in current_ir_block.
2924 * @param *db A pointer for debug information.
2925 * @param *store The current memory
2926 * @param *adr A pointer to the variable to be read in this memory.
2927 * @param *val The value to write to this variable.
2929 ir_node *new_d_Store (dbg_info* db, ir_node *store, ir_node *addr, ir_node *val);
2931 /** Constructor for a Alloc node.
2933 * The Alloc node extends the memory by space for an entity of type alloc_type.
2934 * Adds the node to the block in current_ir_block.
2936 * @param *db A pointer for debug information.
2937 * @param *store The memory which shall contain the new variable.
2938 * @param *size The number of bytes to allocate.
2939 * @param *alloc_type The type of the allocated variable.
2940 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2942 ir_node *new_d_Alloc (dbg_info* db, ir_node *store, ir_node *size, type *alloc_type,
2945 /** Constructor for a Free node.
2947 * Frees the memory occupied by the entity pointed to by the pointer
2948 * arg. Type indicates the type of the entity the argument points to.
2949 * Adds the node to the block in current_ir_block.
2951 * @param *db A pointer for debug information.
2952 * @param *store The memory which shall contain the new variable.
2953 * @param *ptr The pointer to the object to free.
2954 * @param *size The number of objects of type free_type to free in a sequence.
2955 * @param *free_type The type of the freed variable.
2956 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2958 ir_node *new_d_Free (dbg_info* db, ir_node *store, ir_node *ptr, ir_node *size,
2959 type *free_type, where_alloc where);
2961 /** Constructor for a Sync node.
2963 * Merges several memory values. The node assumes that a variable
2964 * either occurs only in one of the memories, or it contains the same
2965 * value in all memories where it occurs.
2966 * Adds the node to the block in current_ir_block.
2968 * @param *db A pointer for debug information.
2969 * @param arity The number of memories to synchronize.
2970 * @param **in An array of pointers to nodes that produce an output of type
2971 * memory. The constructor copies this array.
2973 ir_node *new_d_Sync (dbg_info* db, int arity, ir_node *in[]);
2976 /** Constructor for a Proj node.
2978 * Projects a single value out of a tuple. The parameter proj gives the
2979 * position of the value within the tuple.
2980 * Adds the node to the block in current_ir_block.
2982 * @param *db A pointer for deubug information.
2983 * @param arg A node producing a tuple.
2984 * @param *mode The mode of the value to project.
2985 * @param proj The position of the value in the tuple.
2987 ir_node *new_d_Proj (dbg_info* db, ir_node *arg, ir_mode *mode, long proj);
2990 /** Constructor for a defaultProj node.
2992 * Represents the default control flow of a Switch-Cond node.
2993 * Adds the node to the block in current_ir_block.
2995 * @param *db A pointer for debug information.
2996 * @param arg A node producing a tuple.
2997 * @param max_ proj The end position of the value in the tuple.
2999 ir_node *new_d_defaultProj (dbg_info* db, ir_node *arg, long max_proj);
3001 /** Constructor for a Tuple node.
3003 * This is an auxiliary node to replace a node that returns a tuple
3004 * without changing the corresponding Proj nodes.
3005 * Adds the node to the block in current_ir_block.
3007 * @param *db A pointer for debug information.
3008 * @param arity The number of tuple elements.
3009 * @param **in An array containing pointers to the nodes producing the tuple elements.
3011 ir_node *new_d_Tuple (dbg_info* db, int arity, ir_node *in[]);
3014 /** Constructor for a Id node.
3016 * This is an auxiliary node to replace a node that returns a single
3017 * value. Adds the node to the block in current_ir_block.
3019 * @param *db A pointer for debug information.
3020 * @param *val The operand to Id.
3021 * @param *mode The mode of *val.
3023 ir_node *new_d_Id (dbg_info* db, ir_node *val, ir_mode *mode);
3025 /** Constructor for a Bad node.
3027 * Returns the unique Bad node of the graph. The same as
3030 ir_node *new_d_Bad (void);
3032 /** Constructor for a Confirm node.
3034 * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3035 * Specifies constraints for a value. To support dataflow analyses.
3037 * Example: If the value never exceeds '100' this is expressed by placing a
3038 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3040 * @param *db A pointer for debug information.
3041 * @param *val The value we express a constraint for
3042 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3043 * @param cmp The compare operation.
3045 ir_node *new_d_Confirm (dbg_info* db, ir_node *val, ir_node *bound, pn_Cmp cmp);
3048 /** Constructor for an Unknown node.
3050 * Represents an arbitrary value. Places the node in
3053 * @param *m The mode of the unknown value.
3055 ir_node *new_d_Unknown(ir_mode *m);
3057 /** Constructor for a CallBegin node.
3059 * CallBegin represents control flow depending of the pointer value
3060 * representing the called method to the called methods. The
3061 * constructor copies the method pointer input from the passed Call
3062 * node.Adds the node to the block in current_ir_block.
3064 * @param *db A pointer for debug information.
3065 * @param *callee The call node visible in the intra procedural view.
3067 ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
3069 /** Constructor for an EndReg node.
3071 *Adds the node to the block in current_ir_block.
3073 * @param *db A pointer for debug information.
3075 ir_node *new_d_EndReg (dbg_info *db);
3077 /** Constructor for an EndExcept node.
3079 * Used to represent regular procedure end in interprocedual view.
3080 * Adds the node to the block in current_ir_block.
3082 * @param *db A pointer for debug information.
3084 ir_node *new_d_EndExcept(dbg_info *db);
3086 /** Constructor for a Break node.
3088 * Used to represent exceptional procedure end in interprocedural view.
3089 * Adds the node to the block in current_ir_block.
3091 * Break represents control flow to a single control successor just as Jmp.
3092 * The blocks separated by a break may not be concatenated by an optimization.
3093 * It is used for the interprocedural representation where blocks are parted
3094 * behind Call nodes to represent the control flow to called procedures.
3096 * @param *db A pointer for debug information.
3098 ir_node *new_d_Break (dbg_info *db);
3100 /** Constructor for a Filter node.
3102 * Constructor for a Filter node. Adds the node to the block in
3103 * current_ir_block. Filter is a node with two views used to
3104 * construct the interprocedural view. In intraprocedural view its
3105 * semantics are identical to the Proj node. In interprocedural view
3106 * the Filter performs the Phi operation on method parameters or
3107 * results. Other than a Phi a Filter node may not be removed if it
3108 * has only a single input.
3110 * The constructor builds the Filter in intraprocedural view.
3112 * @param *db A pointer for debug information.
3113 * @param *arg The tuple value to project from.
3114 * @param *mode The mode of the projected value.
3115 * @param proj The position in the tuple to project from.
3117 ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3120 /** Constructor for a NoMem node.
3122 * Returns the unique NoMem node of the graph. The same as
3125 ir_node *new_d_NoMem (void);
3127 /** Constructor for a Mux node.
3129 * Adds the node to the block in current_ir_block.
3131 * @param *db A pointer for debug information.
3132 * @param *sel The ir_node that calculates the boolean select.
3133 * @param *ir_true The ir_node that calculates the true result.
3134 * @param *ir_false The ir_node that calculates the false result.
3135 * @param *mode The mode of the node (and it_true and ir_false).
3137 ir_node *new_d_Mux (dbg_info *db, ir_node *sel,
3138 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3140 /*-----------------------------------------------------------------------*/
3141 /* The block oriented interface without debug support */
3142 /*-----------------------------------------------------------------------*/
3144 /* Needed from the interface with debug support:
3145 void set_cur_block (ir_node *target); */
3147 /** Constructor for a Block node.
3149 * Constructor for a Block node. Adds the block to the graph in
3150 * current_ir_graph. Constructs a Block with a fixed number of
3151 * predecessors. Does set current_block. Can be used with automatic
3152 * Phi node construction.
3154 * @param arity The number of control predecessors.
3155 * @param in An array of control predecessors. The length of
3156 * the array must be 'arity'.
3158 ir_node *new_Block(int arity, ir_node *in[]);
3160 /** Constructor for a Start node.
3162 * Adds the node to the block in current_ir_block.
3165 ir_node *new_Start (void);
3167 /** Constructor for an End node.
3169 * Adds the node to the block in current_ir_block.
3171 ir_node *new_End (void);
3173 /** Constructor for an EndReg node.
3175 * Used to represent regular procedure end in interprocedual view.
3176 * Adds the node to the block in current_ir_block.
3178 ir_node *new_EndReg (void);
3180 /** Constructor for an EndExpcept node.
3182 * Used to represent exceptional procedure end in interprocedural view.
3183 * Adds the node to the block in current_ir_block.
3185 ir_node *new_EndExcept(void);
3187 /** Constructor for a Jump node.
3189 * Adds the node to the block in current_ir_block.
3191 * Jmp represents control flow to a single control successor.
3193 ir_node *new_Jmp (void);
3195 /** Constructor for a Break node.
3196 * Break represents control flow to a single control successor just as Jmp.
3197 * The blocks separated by a break may not be concatenated by an optimization.
3198 * It is used for the interprocedural representation where blocks are parted
3199 * behind Call nodes to represent the control flow to called procedures.
3200 * Adds the node to the block in current_ir_block.
3202 ir_node *new_Break (void);
3204 /** Constructor for a Cond node.
3206 * If c is mode_b represents a conditional branch (if/else). If c is
3207 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
3208 * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3210 * This is not consistent: Input to Cond is Is, Proj has as proj number
3214 * @param *c The conditions parameter.Can be of mode b or I_u.
3216 ir_node *new_Cond (ir_node *c);
3218 /** Constructor for a Return node.
3220 * Returns the memory an zero or more return values. Only node that
3221 * can end regular control flow. Adds the node to the block in current_ir_block.
3223 * @param *store The state of memory.
3224 * @param arity Number of array indices.
3225 * @param *in Array with index inputs to the node.
3227 ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
3229 /**Constructor for a Raise node.
3231 * Adds the node to the block in current_ir_block.
3233 * @param *store The current memory.
3234 * @param *obj A pointer to the Except variable.
3236 ir_node *new_Raise (ir_node *store, ir_node *obj);
3238 /** Constructor for a Const node.
3240 * Constructor for a Const node. The constant represents a target
3241 * value. Sets the type information to type_unknown. (No more
3242 * supported: If tv is entity derives a somehow useful type.)
3243 * Adds the node to the block in current_ir_block.
3245 * @param *mode The mode of the operands and results.
3246 * @param *con Points to an entry in the constant table. This pointer is
3247 * added to the attributes of the node.
3249 ir_node *new_Const (ir_mode *mode, tarval *con);
3252 * Make a const from a long.
3253 * This is just convenience for the usual
3255 * new_Const(mode, tarval_from_long(mode, ...))
3258 * @param mode The mode for the const.
3259 * @param value The value of the constant.
3260 * @return A new const node.
3262 ir_node *new_Const_long(ir_mode *mode, long value);
3264 /** Constructor for a Const node.
3266 * Derives mode from passed type. */
3267 ir_node *new_Const_type(tarval *con, type *tp);
3269 /** Constructor for a SymConst node.
3271 * Adds the node to the block in current_ir_block.
3272 * This is the constructor for a symbolic constant.
3273 * There are four kinds of symbolic constants:
3274 * - type_tag The symbolic constant represents a type tag. The type the
3275 * tag stands for is given explicitly.
3276 * - size The symbolic constant represents the size of a type. The
3277 * type of which the constant represents the size is given
3279 * - addr_name The symbolic constant represents the address of an entity
3280 * (variable or method). The variable is indicated by a name
3281 * that is valid for linking.
3282 * - addr_ent The symbolic constant represents the address of an entity
3283 * (variable or method). The variable is given explicitly by
3286 * Inputs to the node:
3287 * No inputs except the block it belongs to.
3288 * Outputs of the node.
3289 * An unsigned integer (I_u) or a pointer (P).
3291 * @param value A type or a ident depending on the SymConst kind.
3292 * @param symkind The kind of the symbolic constant: symconst_type_tag, symconst_size or symconst_addr_name.
3294 ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind);
3296 /** Constructor for a simpelSel node.
3298 * This is a shortcut for the new_Sel() constructor. To be used for
3299 * Sel nodes that do not select from an array, i.e., have no index
3300 * inputs. It adds the two parameters 0, NULL.
3302 * @param *store The memory in which the object the entity should be selected from is allocated.
3303 * @param *objptr The object from that the Sel operation selects a single attribute out.
3304 * @param *ent The entity to select.
3306 ir_node *new_simpleSel(ir_node *store, ir_node *objptr, entity *ent);
3308 /** Constructor for a Sel node.
3310 * The select node selects an entity (field or method) from an entity
3311 * with a compound type. It explicitly specifies the entity selected.
3312 * Dynamically the node may select entities that overwrite the given
3313 * entity. If the selected entity is an array element entity the Sel
3314 * node takes the required array indices as inputs.
3315 * Adds the node to the block in current_ir_block.
3317 * @param *store The memory in which the object the entity should be selected
3318 * from is allocated.
3319 * @param *objptr A pointer to a compound entity the Sel operation selects a
3320 * single attribute from.
3321 * @param *n_index The number of array indices needed to select an array element entity.
3322 * @param *index[] If the compound entity is an array the indices of the selected
3323 * element entity. The constructor copies this array.
3324 * @param *ent The entity to select.
3326 ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
3329 /** Constructor for an InstOf node.
3331 * Adds the node to the block in current_ir_block.
3332 * For translating Java. Not supported as standard firm node.
3338 ir_node *new_InstOf (ir_node *store, ir_node *obj, type *ent);
3340 /** Constructor for a Call node.
3342 * Adds the node to the block in current_ir_block.
3343 * Represents all kinds of method and function calls.
3345 * @param *store The actual store.
3346 * @param *callee A pointer to the called procedure.
3347 * @param arity The number of procedure parameters.
3348 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3349 * @param *tp Type information of the procedure called.
3351 ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node *in[],
3354 /** Constructor for a CallBegin node.
3356 * Adds the node to the block in current_ir_block.
3358 * @param *callee A pointer to the called procedure.
3360 ir_node *new_CallBegin(ir_node *callee);
3362 /**Constructor for a Add node.
3364 * CallBegin represents control flow depending of the pointer value
3365 * representing the called method to the called methods. The
3366 * constructor copies the method pointer input from the passed Call
3367 * node.Adds the node to the block in current_ir_block.
3369 * @param *op1 The operand 1.
3370 * @param *op2 The operand 2.
3371 * @param *mode The mode of the operands and the result.
3373 ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
3375 /** Constructor for a Sub node.
3377 * Adds the node to the block in current_ir_block.
3379 * @param *op1 The operand 1.
3380 * @param *op2 The operand 2.
3381 * @param *mode The mode of the operands and the result.
3383 ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
3385 /** Constructor for a Minus node.
3387 * Adds the node to the block in current_ir_block.
3389 * @param *op The operand .
3390 * @param *mode The mode of the operand and the result.
3392 ir_node *new_Minus (ir_node *op, ir_mode *mode);
3395 * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3397 * @param *op1 The operand 1.
3398 * @param *op2 The operand 2.
3399 * @param *mode The mode of the operands and the result.
3401 ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
3403 /** Constructor for a Quot node.
3405 * Adds the node to the block in current_ir_block.
3407 * @param *memop The store needed to model exceptions
3408 * @param *op1 The operand 1.
3409 * @param *op2 The operand 2.
3411 ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
3413 /** Constructor for a DivMod node.
3415 * Adds the node to the block in current_ir_block.
3417 * @param *memop The store needed to model exceptions
3418 * @param *op1 The operand 1.
3419 * @param *op2 The operand 2.
3421 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
3423 /** Constructor for a Div node.
3425 * Adds the node to the block in current_ir_block.
3427 * @param *memop The store needed to model exceptions
3428 * @param *op1 The operand 1.
3429 * @param *op2 The operand 2.
3431 ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
3433 /** Constructor for a Mod node.
3435 * Adds the node to the block in current_ir_block.
3437 * @param *memop The store needed to model exceptions
3438 * @param *op1 The operand 1.
3439 * @param *op2 The operand 2.
3441 ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
3443 /** Constructor for a Abs node.
3445 * Adds the node to the block in current_ir_block.
3447 * @param *op The operand
3448 * @param *mode The mode of the operands and the result.
3450 ir_node *new_Abs (ir_node *op, ir_mode *mode);
3452 /** Constructor for a And node.
3454 * Adds the node to the block in current_ir_block.
3456 * @param *op1 The operand 1.
3457 * @param *op2 The operand 2.
3458 * @param *mode The mode of the operands and the result.
3460 ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
3463 * Constructor for a Or node. Adds the node to the block in current_ir_block.
3465 * @param *op1 The operand 1.
3466 * @param *op2 The operand 2.
3467 * @param *mode The mode of the operands and the result.
3469 ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
3472 * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3474 * @param *op1 The operand 1.
3475 * @param *op2 The operand 2.
3476 * @param *mode The mode of the operands and the results.
3478 ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
3480 /** Constructor for a Not node.
3482 * Adds the node to the block in current_ir_block.
3484 * @param *op The operand.
3485 * @param *mode The mode of the operand and the result.
3487 ir_node *new_Not (ir_node *op, ir_mode *mode);
3489 /** Constructor for a Shl node.
3491 * Adds the node to the block in current_ir_block.
3493 * @param *op The operand.
3494 * @param *k The number of bits to shift the operand .
3495 * @param *mode The mode of the operand and the result.
3497 ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
3500 * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3502 * @param *op The operand.
3503 * @param *k The number of bits to shift the operand .
3504 * @param *mode The mode of the operand and the result.
3506 ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
3508 /** Constructor for a Shrs node.
3510 * Adds the node to the block in current_ir_block.
3512 * @param *op The operand.
3513 * @param *k The number of bits to shift the operand .
3514 * @param *mode The mode of the operand and the result.
3516 ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
3518 /** Constructor for a Rot node.
3520 * Adds the node to the block in current_ir_block.
3522 * @param *op The operand.
3523 * @param *k The number of bits to rotate the operand.
3524 * @param *mode The mode of the operand.
3526 ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
3528 /** Constructor for a Cmp node.
3530 * Adds the node to the block in current_ir_block.
3532 * @param *op1 The operand 1.
3533 * @param *op2 The operand 2.
3535 ir_node *new_Cmp (ir_node *op1, ir_node *op2);
3537 /** Constructor for a Conv node.
3539 * Adds the node to the block in current_ir_block.
3541 * @param *op The operand.
3542 * @param *mode The mode of this the operand muss be converted .
3544 ir_node *new_Conv (ir_node *op, ir_mode *mode);
3546 /**Constructor for a Cast node.
3548 * Adds the node to the block in current_ir_block.
3549 * High level type cast
3551 * @param *op The operand.
3552 * @param *to_tp The type of this the operand muss be casted .
3554 ir_node *new_Cast (ir_node *op, type *to_tp);
3556 /** Constructor for a Phi node.
3558 * Adds the node to the block in current_ir_block.
3560 * @param arity The number of predecessors.
3561 * @param *in Array with predecessors.
3562 * @param *mode The mode of it's inputs and output.
3564 ir_node *new_Phi (int arity, ir_node *in[], ir_mode *mode);
3566 /** Constructor for a Load node.
3568 * @param *store The current memory.
3569 * @param *addr A pointer to the variable to be read in this memory.
3570 * @param *mode The mode of the value to be loaded.
3572 ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
3574 /** Constructor for a Store node.
3576 * @param *store The current memory.
3577 * @param *addr A pointer to the variable to be read in this memory.
3578 * @param *val The value to write to this variable.
3580 ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
3582 /**Constructor for a Alloc node.
3584 * The Alloc node extends the memory by space for an entity of type alloc_type.
3585 * Adds the node to the block in current_ir_block.
3587 * @param *store The memory which shall contain the new variable.
3588 * @param *size The number of bytes to allocate.
3589 * @param *alloc_type The type of the allocated variable.
3590 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3592 ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
3596 /**Constructor for a Free node.
3598 * Frees the memory occupied by the entity pointed to by the pointer
3599 * arg. Type indicates the type of the entity the argument points to.
3600 * Adds the node to the block in current_ir_block.
3602 * @param *store The memory which shall contain the new variable.
3603 * @param *ptr The pointer to the object to free.
3604 * @param *size The number of objects of type free_type to free in a sequence.
3605 * @param *free_type The type of the freed variable.
3606 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3608 ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
3609 type *free_type, where_alloc where);
3611 /** Constructor for a Sync node.
3613 * Merges several memory values. The node assumes that a variable
3614 * either occurs only in one of the memories, or it contains the same
3615 * value in all memories where it occurs.
3616 * Adds the node to the block in current_ir_block.
3618 * @param arity The number of memories to synchronize.
3619 * @param **in An array of pointers to nodes that produce an output of type
3620 * memory. The constructor copies this array.
3622 ir_node *new_Sync (int arity, ir_node *in[]);
3624 /** Constructor for a Proj node.
3626 * Projects a single value out of a tuple. The parameter proj gives the
3627 * position of the value within the tuple.
3628 * Adds the node to the block in current_ir_block.
3630 * @param arg A node producing a tuple.
3631 * @param *mode The mode of the value to project.
3632 * @param proj The position of the value in the tuple.
3634 ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
3636 /** Costructor for a Filter node.
3638 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
3639 * Filter is a node with two views used to construct the interprocedural view.
3640 * In intraprocedural view its semantics are identical to the Proj node.
3641 * In interprocedural view the Filter performs the Phi operation on method
3642 * parameters or results. Other than a Phi a Filter node may not be removed
3643 * if it has only a single input.
3645 * The constructor builds the Filter in intraprocedural view.
3647 * @param *arg The tuple value to project from.
3648 * @param *mode The mode of the projected value.
3649 * @param proj The position in the tuple to project from.
3651 ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
3653 /** Constructor for a defaultProj node.
3655 * Represents the default control flow of a Switch-Cond node.
3656 * Adds the node to the block in current_ir_block.
3658 * @param arg A node producing a tuple.
3659 * @param max_ proj The end position of the value in the tuple.
3661 ir_node *new_defaultProj (ir_node *arg, long max_proj);
3663 /** Constructor for a Tuple node.
3665 * This is an auxiliary node to replace a node that returns a tuple
3666 * without changing the corresponding Proj nodes.
3667 * Adds the node to the block in current_ir_block.
3669 * @param arity The number of tuple elements.
3670 * @param **in An array containing pointers to the nodes producing the tuple elements.
3672 ir_node *new_Tuple (int arity, ir_node *in[]);
3674 /** Constructor for an Id node.
3676 * This is an auxiliary node to replace a node that returns a single
3677 * value. Adds the node to the block in current_ir_block.
3679 * @param *val The operand to Id.
3680 * @param *mode The mode of *val.
3682 ir_node *new_Id (ir_node *val, ir_mode *mode);
3684 /** Constructor for a Bad node.
3686 * Returns the unique Bad node of the graph. The same as
3689 ir_node *new_Bad (void);
3691 /** Constructor for a Confirm node.
3693 * Specifies constraints for a value. To support dataflow analyses.
3694 * Adds the node to the block in current_ir_block.
3696 * Example: If the value never exceeds '100' this is expressed by placing a
3697 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3699 * @param *val The value we express a constraint for
3700 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3701 * @param cmp The compare operation.
3703 ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
3705 /** Constructor for an Unknown node.
3707 * Represents an arbitrary value. Places the node in
3710 * @param *m The mode of the unknown value.
3712 ir_node *new_Unknown(ir_mode *m);
3714 /** Constructor for a NoMem node.
3716 * Returns the unique NoMem node of the graph. The same as
3719 ir_node *new_NoMem (void);
3721 /** Constructor for a Mux node.
3723 * Adds the node to the block in current_ir_block.
3725 * @param *sel The ir_node that calculates the boolean select.
3726 * @param *ir_true The ir_node that calculates the true result.
3727 * @param *ir_false The ir_node that calculates the false result.
3728 * @param *mode The mode of the node (and it_true and ir_false).
3730 ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3732 /*---------------------------------------------------------------------*/
3733 /* The comfortable interface. */
3734 /* Supports automatic Phi node construction. */
3735 /* All routines of the block oriented interface except new_Block are */
3737 /*---------------------------------------------------------------------*/
3739 /** Create an immature block.
3741 * An immature block has an unknown number of predecessors. Predecessors
3742 * can be added with add_immBlock_pred(). Once all predecessors are
3743 * added the block must be matured.
3745 * Adds the block to the graph in current_ir_graph. Does set
3746 * current_block. Can be used with automatic Phi node construction.
3747 * This constructor can only be used if the graph is in
3750 ir_node *new_d_immBlock (dbg_info* db);
3751 ir_node *new_immBlock (void);
3753 /** Add a control flow edge to an immature block. */
3754 void add_immBlock_pred (ir_node *immblock, ir_node *jmp);
3756 /** Fix the number of predecessors of an immature block. */
3757 void mature_immBlock (ir_node *block);
3758 #define mature_cur_block() mature_immBlock(get_cur_block());
3761 /** Get the current value of a local variable.
3763 * Use this function to obtain the last definition of the local variable
3764 * associated with pos. Pos may not exceed the value passed as n_loc
3765 * to new_ir_graph. This call automatically inserts Phi nodes.
3767 * @param *db A pointer for debug information.
3768 * @param pos The position/id of the local variable.
3769 * @param *mode The mode of the value to get.
3771 ir_node *get_d_value (dbg_info* db, int pos, ir_mode *mode);
3772 ir_node *get_value (int pos, ir_mode *mode);
3774 /** Remark a new definition of a variable.
3776 * Use this function to remember a new definition of the value
3777 * associated with pos. Pos may not exceed the value passed as n_loc
3778 * to new_ir_graph. This call is needed to automatically inserts Phi
3781 * @param pos The position/id of the local variable.
3782 * @param *value The new value written to the local variable.
3784 void set_value (int pos, ir_node *value);
3786 /** Get the current memory state.
3788 * Use this function to obtain the last definition of the memory
3789 * state. This call automatically inserts Phi nodes for the memory
3792 ir_node *get_store (void);
3794 /** Remark a new definition of the memory state.
3796 * Use this function to remember a new definition of the memory state.
3797 * This call is needed to automatically inserts Phi nodes.
3799 * @param *store The new memory state.
3801 void set_store (ir_node *store);
3803 /** keep this node alive even if End is not control-reachable from it
3805 * @param ka The node to keep alive.
3807 void keep_alive (ir_node *ka);
3809 /** Returns the frame type of the current graph */
3810 type *get_cur_frame_type(void);
3813 /* --- initialize and finalize ir construction --- */
3815 /** Puts the graph into state "phase_high" */
3816 void irg_finalize_cons (ir_graph *irg);
3818 /** Puts the program and all graphs into state phase_high.
3820 * This also remarks, the construction of types is finished,
3821 * e.g., that no more subtypes will be added. */
3822 void irp_finalize_cons(void);
3824 /* --- Initialization --- */
3827 * This function is called, whenever a local variable is used before definition
3829 * @param irg the IR graph on which this happens
3830 * @param mode the mode of the local var
3831 * @param pos position chosen be the frontend for this variable (n_loc)
3833 * @return a firm node of mode @p mode that initializes the var at position pos
3836 * Do not return NULL
3837 * If this function is not set, FIRM will create a const node with tarval BAD.
3838 * Use set_irg_loc_description()/get_irg_loc_description() to assign additional
3839 * informations to local variables.
3841 typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
3843 # endif /* _IRCONS_H_ */