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_IJmp (ir_node *tgt);
254 * ir_node *new_Cond (ir_node *c);
255 * ir_node *new_Return (ir_node *store, int arity, ir_node **in);
256 * ir_node *new_Raise (ir_node *store, ir_node *obj);
257 * ir_node *new_Const (ir_mode *mode, tarval *con);
258 * ir_node *new_SymConst (symconst_symbol value, symconst_kind kind);
259 * ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
260 * ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity,
261 * ir_node **in, entity *ent);
262 * ir_node *new_InstOf (ir_node *store, ir_node obj, type *ent);
263 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity,
264 * ir_node **in, type_method *type);
265 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
266 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
267 * ir_node *new_Minus (ir_node *op, ir_mode *mode);
268 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
269 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
270 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
271 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
272 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
273 * ir_node *new_Abs (ir_node *op, ir_mode *mode);
274 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
275 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
276 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
277 * ir_node *new_Not (ir_node *op, ir_mode *mode);
278 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
279 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
280 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
281 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
282 * ir_node *new_Cmp (ir_node *op1, ir_node *op2);
283 * ir_node *new_Conv (ir_node *op, ir_mode *mode);
284 * ir_node *new_Cast (ir_node *op, type *to_tp);
285 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
286 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
287 * ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
288 * where_alloc where);
289 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
290 * type *free_type, where_alloc where);
291 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
292 * ir_node *new_NoMem (void);
293 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
295 * void add_immBlock_pred (ir_node *block, ir_node *jmp);
296 * void mature_immBlock (ir_node *block);
297 * void set_cur_block (ir_node *target);
298 * ir_node *get_value (int pos, ir_mode *mode);
299 * void set_value (int pos, ir_node *value);
300 * ir_node *get_store (void);
301 * void set_store (ir_node *store);
302 * keep_alive (ir_node ka)
304 * IR_NODES AND CONSTRUCTORS FOR IR_NODES
305 * =======================================
307 * All ir_nodes are defined by a common data structure. They are distinguished
308 * by their opcode and differ in the number of their attributes.
310 * The constructor for the block node sets current_block to itself.
311 * Const nodes are always added to the start block.
312 * All other constructors add the created node to the current_block.
313 * swich_block(block) allows to set the current block to block.
315 * Watch for my inconsistent use of input and predecessor (dataflow view)
316 * and `the node points to' (implementation view).
318 * The following description of the nodes lists four properties them if these
320 * - the parameters to the constructor
321 * - the inputs of the Firm node
322 * - the outputs of the Firm node
323 * - attributes to the node
327 * ir_node *new_immBlock (void)
328 * ----------------------------
330 * Creates a new block. Sets current_block to itself. When a new block is
331 * created it cannot be known how many predecessors this block will have in the
332 * control flow graph. Therefore the list of inputs can not be fixed at
333 * creation. Predecessors can be added with add_immBlock_pred (block, control flow
334 * operation). With every added predecessor the number of inputs to Phi nodes
337 * The block can be completed by mature_immBlock(block) if all predecessors are
338 * known. If several blocks are built at once, mature_immBlock can only be called
339 * after set_value has been called for all values that are life at the end
340 * of the block. This is necessary so that Phi nodes created mature_immBlock
341 * get the right predecessors in case of cyclic dependencies. If all set_values
342 * of this block are called after maturing it and before calling get_value
343 * in some block that is control flow dependent on this block, the construction
346 * Example for faulty ir construction: (draw the graph on a paper and you'll
349 * block_before_loop = new_block();
351 * mature_immBlock(block_before_loop);
352 * before2header = new_Jmp;
354 * loop_header = new_block ();
355 * header2body - new_Jmp();
357 * loop_body = new_block ();
358 * body2header = new_Jmp();
360 * add_immBlock_pred(loop_header, before2header);
361 * add_immBlock_pred(loop_header, body2header);
362 * add_immBlock_pred(loop_body, header2body);
364 * mature_immBlock(loop_header);
365 * mature_immBlock(loop_body);
367 * get_value(loop_body, x); // gets the Phi in loop_header
368 * set_value(loop_header, x); // sets the value the above get_value should
369 * // have returned!!!
371 * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
372 * should be called as early as possible, as afterwards the generation of Phi
373 * nodes is more efficient.
376 * There is an input for each control flow predecessor of the block.
377 * The input points to an instruction producing an output of type X.
378 * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
379 * possibly causing an exception. (Often the real predecessors are Projs.)
381 * Mode BB (R), all nodes belonging to this block should consume this output.
382 * As they are strict (except Block and Phi node) it is a necessary condition
383 * that the block node executed before any other node in this block executes.
385 * block.matured Indicates whether the block is mature.
387 * This attribute contains all local values valid in this
388 * block. This is needed to build the Phi nodes and removed
389 * if the graph is complete. This field is used by the
390 * internal construction algorithm and should not be accessed
394 * ir_node *new_Block (int arity, ir_node **in)
395 * --------------------------------------------
397 * Creates a new Block with the given list of predecessors. This block
398 * is mature. As other constructors calls optimization and vrfy for the
399 * block. If one of the predecessors is Unknown (as it has to be filled in
400 * later) optimizations are skipped. This is necessary to
401 * construct Blocks in loops. Leaving Unknown in the Block after finishing
402 * the construction may have strange effects, especially for interprocedural
403 * representation and analysis.
406 * CONTROL FLOW OPERATIONS
407 * -----------------------
409 * In each block there must be exactly one of the control flow
410 * operations Start, End, Jmp, Cond, Return or Raise. The output of a
411 * control flow operation points to the block to be executed next.
413 * ir_node *new_Start (void)
414 * -------------------------
416 * Creates a start node. Not actually needed public. There is only one such
417 * node in each procedure which is automatically created by new_ir_graph.
420 * No inputs except the block it belogns to.
422 * A tuple of 4 (5, 6) distinct values. These are labeled by the following
423 * projection numbers (pn_Start):
424 * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
425 * * pn_Start_M mode M, the global store
426 * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
427 * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
428 * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
431 * ir_node *new_End (void)
432 * -----------------------
434 * Creates an end node. Not actually needed public. There is only one such
435 * node in each procedure which is automatically created by new_ir_graph.
438 * No inputs except the block it belongs to.
442 * ir_node *new_Jmp (void)
443 * -----------------------
445 * Creates a Jmp node.
448 * The block the node belongs to
450 * Control flow to the next block.
452 * ir_node *new_IJmp (ir_node *tgt)
453 * -----------------------
455 * Creates an IJmp node.
458 * The node that represents the target jump address
460 * Control flow to an unknown target, must be pinned by
463 * ir_node *new_Cond (ir_node *c)
464 * ------------------------------
466 * Creates a Cond node. There are two versions of this node.
472 * A tuple of two control flows. The first is taken if the input is
473 * false, the second if it is true.
477 * A value of mode I_u. (i)
479 * A tuple of n control flows. If the Cond's input is i, control
480 * flow will procede along output i. If the input is >= n control
481 * flow proceeds along output n.
483 * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
484 * -------------------------------------------------------------
486 * The return node has as inputs the results of the procedure. It
487 * passes the control flow to the end_block.
493 * Control flow to the end block.
495 * ir_node *new_Raise (ir_node *store, ir_node *obj)
496 * -------------------------------------------------
498 * Raises an exception. Unconditional change of control flow. Writes
499 * an explicit Except variable to memory to pass it to the exception
500 * handler. See TechReport 1999-14, chapter Exceptions.
504 * A pointer to the Except variable.
506 * A tuple of control flow and the changed memory state. The control flow
507 * points to the exception handler if it is definied in this procedure,
508 * else it points to the end_block.
513 * ir_node *new_Const (ir_mode *mode, tarval *con)
514 * -----------------------------------------------
516 * Creates a constant in the constant table and adds a Const node
517 * returning this value to the start block.
520 * *mode The mode of the constant.
521 * *con Points to an entry in the constant table.
522 * This pointer is added to the attributes of
523 * the node (self->attr.con)
525 * No inputs except the block it belogns to.
527 * The constant value.
529 * attr.con A tarval* pointer to the proper entry in the constant
532 * ir_node *new_SymConst (union symconst_symbol value, symconst_addr_ent kind)
533 * ---------------------------------------------------------------------------
535 * There are three kinds of symbolic constants:
536 * symconst_type_tag The symbolic constant represents a type tag.
537 * symconst_size The symbolic constant represents the size of a class.
538 * symconst_addr_name Information for the linker, e.g. the name of a global
540 * To represent a pointer to an entity that is represented by an entity
541 * datastructure don't use
542 * new_SymConst((type_or_id*)get_entity_ld_ident(ent), symconst_addr_name);.
543 * Use a real const instead:
544 * new_SymConst(mode_P_mach, tarval_p_from_entity(ent));
545 * This makes the Constant independent of name changes of the entity due to
549 * kind The kind of the symbolic constant: type_tag, size or link_info.
550 * *type_or_id Points to the type the tag stands for or to the type
551 * whose size is represented by the constant or to an ident
552 * representing the linkage info.
555 * No inputs except the block it belogns to.
557 * An unsigned integer (I_u) or a pointer (P).
560 * attr.i.num The symconst_addr_ent, i.e. one of
563 * - symconst_addr_name
564 * If the attr.i.num is symconst_type_tag or symconst_size, the node contains an attribute
565 * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is.
566 * if it is linkage_ptr_info it contains
567 * attr.i.*ptrinfo, an ident holding information for the linker. The mode
568 * of the node is mode_P_mach.
572 * ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel)
573 * --------------------------------------------------------------------
576 * Selects an entity from a compound type. This entity can be a field or
580 * *store The memory in which the object the entity should be selected
582 * *frame The pointer to the object.
583 * *sel The entity to select.
586 * The memory containing the object.
587 * A pointer to the object.
588 * An unsigned integer.
590 * A pointer to the selected entity.
592 * attr.sel Pointer to the entity
595 * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
596 * --------------------------------------------------------------------------
600 * Selects a field from an array type. The entity has as owner the array, as
601 * type the arrays element type. The indices to access an array element are
605 * *store The memory in which the object the entity should be selected from
607 * *frame The pointer to the object.
608 * *arity number of array indices.
609 * *in array with index inputs to the node.
610 * *sel The entity to select.
613 * The memory containing the object.
614 * A pointer to the object.
615 * As much unsigned integer as there are array expressions.
617 * A pointer to the selected entity.
619 * attr.sel Pointer to the entity
621 * The constructors new_Sel and new_simpleSel generate the same ir nodes.
622 * simpleSel just sets the arity of the index inputs to zero.
625 * ARITHMETIC OPERATIONS
626 * ---------------------
628 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
629 * ----------------------------------------------------------------------------
633 * Creates a procedure call.
636 * *store The actual store.
637 * *callee A pointer to the called procedure.
638 * arity The number of procedure parameters.
639 * **in An array with the pointers to the parameters.
640 * The constructor copies this array.
641 * *type Type information of the procedure called.
644 * The store, the callee and the parameters.
646 * A tuple containing the eventually changed store and the procedure
649 * attr.call Contains the type information for the procedure.
652 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
653 * ------------------------------------------------------------
657 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
658 * ------------------------------------------------------------
662 * ir_node *new_Minus (ir_node *op, ir_mode *mode)
663 * -----------------------------------------------
665 * Unary Minus operations on integer and floating point values.
667 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
668 * ------------------------------------------------------------
672 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2)
673 * --------------------------------------------------------------
675 * Quot performs exact division of floating point numbers. It's mode
676 * is Tuple, the mode of the result must be annotated to the Proj
677 * that extracts the result of the arithmetic operations.
680 * The store needed to model exceptions and the two operands.
682 * A tuple contaning a memory and a execution for modeling exceptions
683 * and the result of the arithmetic operation.
685 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2)
686 * ----------------------------------------------------------------
688 * Performs Div and Mod on interger values.
691 * A tuple contaning a memory and a execution for modeling exceptions
692 * and the two result of the arithmetic operations.
694 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2)
695 * -------------------------------------------------------------
699 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2)
700 * -------------------------------------------------------------
704 * ir_node *new_Abs (ir_node *op, ir_mode *mode)
705 * ---------------------------------------------
709 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
710 * ------------------------------------------------------------
714 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
715 * -----------------------------------------------------------
719 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
720 * ------------------------------------------------------------
724 * ir_node *new_Not (ir_node *op, ir_mode *mode)
725 * ---------------------------------------------
727 * This node constructs a constant where all bits are set to one
728 * and a Eor of this constant and the operator. This simulates a
731 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
732 * ---------------------------------------------------------
736 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
737 * ---------------------------------------------------------
739 * Logic shift right, i.e., zero extended.
742 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
743 * ----------------------------------------------------------
745 * Arithmetic shift right, i.e., sign extended.
747 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
748 * ---------------------------------------------------------
750 * Rotates the operand to the (right??) by k bits.
752 * ir_node *new_Conv (ir_node *op, ir_mode *mode)
753 * ---------------------------------------------
755 * Mode conversion. For allowed conversions see UKA Tech Report
758 * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
759 * ---------------------------------------------
762 * The two values to be compared.
764 * A 16-tuple containing the results of the 16 different comparisons.
765 * The following is a list giving the comparisons and a projection
766 * number (pn_Cmp) to use in Proj nodes to extract the proper result.
770 * pn_Cmp_Le less or equal
772 * pn_Cmp_Ge greater of equal
773 * pn_Cmp_Lg less or greater
774 * pn_Cmp_Leg less, equal or greater = ordered
775 * pn_Cmp_Uo unordered
776 * pn_Cmp_Ue unordered or equal
777 * pn_Cmp_Ul unordered or less
778 * pn_Cmp_Ule unordered, less or equal
779 * pn_Cmp_Ug unordered or greater
780 * pn_Cmp_Uge unordered, greater or equal
781 * pn_Cmp_Ne unordered, less or greater = not equal
788 * In general, Phi nodes are automaitcally inserted. In some cases, if
789 * all predecessors of a block are known, an explicit Phi node constructor
790 * is needed. E.g., to construct a FIRM graph for a statement as
791 * a = (b==c) ? 2 : 5;
793 * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
794 * ---------------------------------------------------------
796 * Creates a Phi node. The in's order has to correspond to the order
797 * of in's of current_block. This is not checked by the library!
798 * If one of the predecessors is Unknown (as it has to be filled in
799 * later) optimizations are skipped. This is necessary to
800 * construct Phi nodes in loops. Leaving Unknown in the Phi after finishing
801 * the construction may have strange effects, especially for interprocedural
802 * representation and analysis.
805 * arity number of predecessors
806 * **in array with predecessors
807 * *mode The mode of it's inputs and output.
809 * A Phi node has as many inputs as the block it belongs to.
810 * Each input points to a definition of the same value on a
811 * different path in the control flow.
813 * The definition valid in this block.
815 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
816 * -----------------------------------------------------------------------------
818 * Creates a Mux node. This node implements the following semantic:
819 * If the sel node (which must be of mode_b) evaluates to true, its value is
820 * ir_true, else ir_false;
823 * OPERATIONS TO MANAGE MEMORY EXPLICITLY
824 * --------------------------------------
826 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode)
827 * ----------------------------------------------------------------
829 * The Load operation reads a value from memory.
832 * *store The current memory.
833 * *addr A pointer to the variable to be read in this memory.
834 * *mode The mode of the value to be loaded.
837 * The memory and a pointer to a variable in this memory.
839 * A tuple of the memory, a control flow to be taken in case of
840 * an exception and the loaded value.
842 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
843 * ----------------------------------------------------------------
845 * The Store operation writes a value to a variable in memory.
848 * The memory, a pointer to a variable in this memory and the value
849 * to write to this variable.
851 * A tuple of the changed memory and a control flow to be taken in
852 * case of an exception.
854 * ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
855 * --------------------------------------------------------------------
859 * The Alloc node allocates a new variable. It can be specified whether the
860 * variable should be allocated to the stack or to the heap.
863 * *store The memory which shall contain the new variable.
864 * ** *size The number of bytes to allocate. Old. **
865 * *size We decided that the size easily can be derived from the type.
866 * This field is for allocating arrays, i.e., it gives the multiple
867 * of the size of alloc_type to allocate memory for.
868 * *alloc_type The type of the allocated variable.
869 * where Where to allocate the variable, either heap_alloc or stack_alloc.
872 * A memory and an unsigned integer.
874 * A tuple of the changed memory, a control flow to be taken in
875 * case of an exception and the pointer to the new variable.
877 * a.where Indicates where the variable is allocated.
878 * a.*type A pointer to the class the allocated data object
881 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, type *free_type,
882 * --------------------------------------------------------------------------------
886 * The Free node frees memory of the given variable.
889 * *store The memory which shall contain the new variable.
890 * *ptr The pointer to the object to free.
891 * *size The number of objects of type free_type to free in a sequence.
892 * *free_type The type of the freed variable.
893 * where Where the variable was allocated, either heap_alloc or stack_alloc.
896 * A memory, a pointer and an unsigned integer.
898 * The changed memory.
900 * f.*type A pointer to the type information of the freed data object.
904 * ir_node *new_Sync (int arity, ir_node **in)
905 * -------------------------------------------
907 * The Sync operation unifies several partial memory blocks. These blocks
908 * have to be pairwise disjunct or the values in common locations have to
909 * be identical. This operation allows to specify all operations that eventually
910 * need several partial memory blocks as input with a single entrance by
911 * unifying the memories with a preceding Sync operation.
914 * arity The number of memories to synchronize.
915 * **in An array of pointers to nodes that produce an output of
920 * The unified memory.
926 * ir_node *new_Bad (void)
927 * -----------------------
929 * Returns the unique Bad node current_ir_graph->bad.
930 * This node is used to express results of dead code elimination.
932 * ir_node *new_NoMem (void)
933 * -----------------------------------------------------------------------------------
935 * Returns the unique NoMem node current_ir_graph->no_mem.
936 * This node is used as input for operations that need a Memory, but do not
937 * change it like Div by const != 0, analyzed calls etc.
939 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
940 * ----------------------------------------------------------
942 * Selects one entry of a tuple. This is a hidden `fat edge'.
945 * *arg A node producing a tuple.
946 * *mode The mode of the value to project.
947 * proj The position of the value in the tuple.
953 * ir_node *new_Tuple (int arity, ir_node **in)
954 * --------------------------------------------
956 * Builds a Tuple from single values. This is needed to implement
957 * optimizations that remove a node that produced a tuple. The node can be
958 * replaced by the Tuple operation so that the following Proj nodes have not to
959 * be changed. (They are hard to find due to the implementation with pointers
960 * in only one direction.) The Tuple node is smaller than any other
961 * node, so that a node can be changed into a Tuple by just changing it's
962 * opcode and giving it a new in array.
965 * arity The number of tuple elements.
966 * **in An array containing pointers to the nodes producing the
969 * ir_node *new_Id (ir_node *val, ir_mode *mode)
970 * ---------------------------------------------
972 * The single output of the Id operation is it's input. Also needed
976 * COPING WITH DATA OBJECTS
977 * ========================
979 * Two kinds of data objects have to be distinguished for generating
980 * FIRM. First there are local variables other than arrays that are
981 * known to be alias free. Second there are all other data objects.
982 * For the first a common SSA representation is built, the second
983 * are modeled by saving them to memory. The memory is treated as
984 * a single local variable, the alias problem is hidden in the
985 * content of this variable.
987 * All values known in a Block are listed in the block's attribute,
988 * block.**graph_arr which is used to automatically insert Phi nodes.
989 * The following two funcions can be used to add a newly computed value
990 * to the array, or to get the producer of a value, i.e., the current
993 * inline void set_value (int pos, ir_node *value)
994 * -----------------------------------------------
996 * Has to be called for every assignment to a local variable. It
997 * adds the value to the array of used values at position pos. Pos
998 * has to be a unique identifier for an entry in the procedure's
999 * definition table. It can be used to access the value again.
1000 * Requires current_block to be set correctly.
1002 * ir_node *get_value (int pos, ir_mode *mode)
1003 * -------------------------------------------
1005 * Returns the node defining the value referred to by pos. If the
1006 * value is not defined in this block a Phi node is generated and
1007 * all definitions reaching this Phi node are collected. It can
1008 * happen that the algorithm allocates an unnecessary Phi node,
1009 * e.g. if there is only one definition of this value, but this
1010 * definition reaches the currend block on several different
1011 * paths. This Phi node will be eliminated if optimizations are
1012 * turned on right after it's creation.
1013 * Requires current_block to be set correctly.
1015 * There are two special routines for the global store:
1017 * void set_store (ir_node *store)
1018 * -------------------------------
1020 * Adds the store to the array of known values at a reserved
1022 * Requires current_block to be set correctly.
1024 * ir_node *get_store (void)
1025 * -------------------------
1027 * Returns the node defining the actual store.
1028 * Requires current_block to be set correctly.
1031 * inline void keep_alive (ir_node *ka)
1032 * ------------------------------------
1034 * Keep this node alive because it is (might be) not in the control
1035 * flow from Start to End. Adds the node to the list in the end
1044 # include "firm_common.h"
1045 # include "irgraph.h"
1046 # include "irnode.h"
1047 # include "irmode.h"
1048 # include "entity.h"
1051 # include "dbginfo.h"
1053 /*-------------------------------------------------------------------------*/
1054 /* The raw interface */
1055 /*-------------------------------------------------------------------------*/
1057 /** Constructor for a Block node.
1059 * Constructs a mature block with the given predecessors. Use Unknown
1060 * nodes as predecessors to construct a block if the number of
1061 * predecessors is known, but not the predecessors themselves. This
1062 * constructor does not set current_block. It not be used with
1063 * automatic Phi node construction.
1065 * @param *db A Pointer for debug information.
1066 * @param irg The ir graph the block belongs to.
1067 * @param arity The number of control predecessors.
1068 * @param in[] An array of control predecessors. The length of
1069 * the array must be 'arity'. The constructor copies this array.
1071 ir_node *new_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1073 /** Constructor for a Start node.
1075 * @param *db A pointer for debug information.
1076 * @param *irg The ir graph the node belongs to.
1077 * @param *block The ir block the node belongs to.
1079 ir_node *new_rd_Start (dbg_info *db, ir_graph *irg, ir_node *block);
1081 /** Constructor for a End node.
1083 * @param *db A pointer for debug information.
1084 * @param *irg The ir graph the node belongs to.
1085 * @param *block The ir block the node belongs to.
1087 ir_node *new_rd_End (dbg_info *db, ir_graph *irg, ir_node *block);
1089 /** Constructor for a Jmp node.
1091 * Jmp represents control flow to a single control successor.
1093 * @param *db A pointer for debug information.
1094 * @param *irg The ir graph the node belongs to.
1095 * @param *block The ir block the node belongs to.
1097 ir_node *new_rd_Jmp (dbg_info *db, ir_graph *irg, ir_node *block);
1099 /** Constructor for an IJmp node.
1101 * IJmp represents control flow to a single control successor not
1102 * statically known i.e. an indirect Jmp.
1104 * @param *db A pointer for debug information.
1105 * @param *irg The ir graph the node belongs to.
1106 * @param *block The ir block the node belongs to.
1107 * @param *tgt The ir node representing the target address.
1109 ir_node *new_rd_IJmp (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *tgt);
1111 /** Constructor for a Break node.
1113 * Break represents control flow to a single control successor just as Jmp.
1114 * The blocks separated by a break may not be concatenated by an optimization.
1115 * It is used for the interprocedural representation where blocks are parted
1116 * behind Call nodes to represent the control flow to called procedures.
1118 * @param *db A pointer for debug information.
1119 * @param *irg The ir graph the node belong to.
1120 * @param *block The block the node belong to.
1122 ir_node *new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block);
1124 /** Constructor for a Cond node.
1126 * If c is mode_b represents a conditional branch (if/else). If c is
1127 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1128 * node, default Proj is 0.)
1130 * This is not consistent: Input to Cond is Is, Proj has as proj number
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 *c The conditions parameter. Can be of mode b or I_u.
1138 ir_node *new_rd_Cond (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
1140 /** Constructor for a Return node.
1142 * Returns the memory an zero or more return values. Only node that
1143 * can end regular control flow.
1145 * @param *db A pointer for debug information.
1146 * @param *irg The ir graph the node belongs to.
1147 * @param *block The ir block the node belongs to.
1148 * @param *store The state of memory.
1149 * @param arity Number of return values.
1150 * @param *in Array of length arity with return values. The constructor copies this array.
1152 ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
1153 ir_node *store, int arity, ir_node *in[]);
1155 /** Constructor for a Raise node.
1157 * @param *db A pointer for debug information.
1158 * @param *irg The ir graph the node belongs to.
1159 * @param *block The ir block the node belongs to.
1160 * @param *store The current memory.
1161 * @param *obj A pointer to the Except variable.
1163 ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
1164 ir_node *store, ir_node *obj);
1166 /** Constructor for a Const_type node.
1168 * The constant represents a target value. This constructor sets high
1169 * level type information for the constant value.
1171 * @param *db A pointer for debug information.
1172 * @param *irg The ir graph the node belongs to.
1173 * @param *block The ir block the node belongs to.
1174 * @param *mode The mode of the operands and results.
1175 * @param *con Points to an entry in the constant table.
1176 * @param *tp The type of the constant.
1178 ir_node *new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block,
1179 ir_mode *mode, tarval *con, type *tp);
1181 /** Constructor for a Const node.
1183 * Constructor for a Const node. The constant represents a target
1184 * value. Sets the type information to type_unknown. (No more
1185 * supported: If tv is entity derives a somehow useful type.)
1187 * @param *db A pointer for debug information.
1188 * @param *irg The ir graph the node belongs to.
1189 * @param *block The ir block the node belongs to.
1190 * @param *mode The mode of the operands and results.
1191 * @param *con Points to an entry in the constant table.
1193 ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block,
1194 ir_mode *mode, tarval *con);
1196 /** Constructor for a SymConst_type node.
1198 * This is the constructor for a symbolic constant.
1199 * There are four kinds of symbolic constants:
1200 * - type_tag The symbolic constant represents a type tag. The type the
1201 * tag stands for is given explicitly.
1202 * - size The symbolic constant represents the size of a type. The
1203 * type of which the constant represents the size is given
1205 * - addr_name The symbolic constant represents the address of an entity
1206 * (variable or method). The variable is indicated by a name
1207 * that is valid for linking.
1208 * - addr_ent The symbolic constant represents the address of an entity
1209 * (variable or method). The variable is given explicitly by
1212 * Inputs to the node:
1213 * No inputs except the block it belongs to.
1214 * Outputs of the node.
1215 * An unsigned integer (I_u) or a pointer (P).
1217 * Mention union in declaration so that the firmjni generator recognizes that
1218 * it can not cast the argument to an int.
1220 * @param *db A pointer for debug information.
1221 * @param *irg The ir graph the node belongs to.
1222 * @param *block The ir block the node belongs to.
1223 * @param symkind The kind of the symbolic constant: type_tag, size, addr_name or addr_ent.
1224 * @param value A type, entity or a ident depending on the SymConst kind.
1225 * @param tp The source type of the constant.
1227 ir_node *new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, union symconst_symbol value,
1228 symconst_kind symkind, type *tp);
1230 /** Constructor for a SymConst node.
1232 * Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */
1233 ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
1234 union symconst_symbol value, symconst_kind symkind);
1236 /** Constructor for a SymConst addr_ent node.
1238 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1239 * symconst_addr_ent.
1240 * Adds the SymConst to the start block of irg. */
1241 ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, entity *symbol, type *tp);
1243 /** Constructor for a SymConst addr_name node.
1245 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1246 * symconst_addr_ent.
1247 * Adds the SymConst to the start block of irg. */
1248 ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, type *tp);
1250 /** Constructor for a SymConst type_tag node.
1252 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1253 * symconst_addr_ent.
1254 * Adds the SymConst to the start block of irg. */
1255 ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, type *symbol, type *tp);
1257 /** Constructor for a SymConst size node.
1259 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1260 * symconst_addr_ent.
1261 * Adds the SymConst to the start block of irg. */
1262 ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, type *symbol, type *tp);
1264 /** Constructor for a Sel node.
1266 * The select node selects an entity (field or method) from an entity
1267 * with a compound type. It explicitly specifies the entity selected.
1268 * Dynamically the node may select entities that overwrite the given
1269 * entity. If the selected entity is an array element entity the Sel
1270 * node takes the required array indices as inputs.
1272 * @param *db A pointer for debug information.
1273 * @param *irg The ir graph the node belongs to.
1274 * @param *block The ir block the node belongs to.
1275 * @param *store The memory in which the object the entity should be selected
1276 * from is allocated.
1277 * @param *objptr A pointer to a compound entity the Sel operation selects a
1278 * single attribute from.
1279 * @param *n_index The number of array indices needed to select an array element entity.
1280 * @param *index[] If the compound entity is an array the indices of the selected
1281 * element entity. The constructor copies this array.
1282 * @param *ent The entity to select.
1284 ir_node *new_rd_Sel (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1285 ir_node *objptr, int n_index, ir_node *index[], entity *ent);
1287 /** Constructor for a InstOf node.
1289 * For translating Java. Not supported as standard firm node.
1291 * @param *db A pointer for debug information.
1292 * @param *irg The ir graph the node belongs to.
1293 * @param *block The ir block the node belongs to.
1298 ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1299 ir_node *objptr, type *ent);
1301 /** Constructor for a Call node.
1303 * Represents all kinds of method and function calls.
1305 * @param *db A pointer for debug information.
1306 * @param *irg The ir graph the node belongs to.
1307 * @param *block The ir block the node belongs to.
1308 * @param *store The current memory state.
1309 * @param *callee A pointer to the called procedure.
1310 * @param arity The number of procedure parameters.
1311 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1312 * @param *tp Type information of the procedure called.
1314 ir_node *new_rd_Call (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1315 ir_node *callee, int arity, ir_node *in[], type *tp);
1317 /** Constructor for a Add 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 *op1 The operand 1.
1323 * @param *op2 The operand 2.
1324 * @param *mode The mode of the operands and the result.
1326 ir_node *new_rd_Add (dbg_info *db, ir_graph *irg, ir_node *block,
1327 ir_node *op1, ir_node *op2, ir_mode *mode);
1329 /** Constructor for a Sub node.
1331 * @param *db A pointer for debug information.
1332 * @param *irg The ir graph the node belongs to.
1333 * @param *block The ir block the node belongs to.
1334 * @param *op1 The operand 1.
1335 * @param *op2 The operand 2.
1336 * @param *mode The mode of the operands and the result.
1338 ir_node *new_rd_Sub (dbg_info *db, ir_graph *irg, ir_node *block,
1339 ir_node *op1, ir_node *op2, ir_mode *mode);
1341 /** Constructor for a Minus node.
1343 * @param *db A pointer for debug information.
1344 * @param *irg The ir graph the node belongs to.
1345 * @param *block The ir block the node belongs to.
1346 * @param *op The operand .
1347 * @param *mode The mode of the operand and the result.
1349 ir_node *new_rd_Minus (dbg_info *db, ir_graph *irg, ir_node *block,
1350 ir_node *op, ir_mode *mode);
1352 /** Constructor for a Mul 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 *op1 The operand 1.
1358 * @param *op2 The operand 2.
1359 * @param *mode The mode of the operands and the result.
1361 ir_node *new_rd_Mul (dbg_info *db, ir_graph *irg, ir_node *block,
1362 ir_node *op1, ir_node *op2, ir_mode *mode);
1364 /** Constructor for a Quot 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_Quot (dbg_info *db, ir_graph *irg, ir_node *block,
1374 ir_node *memop, ir_node *op1, ir_node *op2);
1376 /** Constructor for a DivMod 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_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
1386 ir_node *memop, ir_node *op1, ir_node *op2);
1388 /** Constructor for a Div 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 *memop The store needed to model exceptions
1394 * @param *op1 The operand 1.
1395 * @param *op2 The operand 2.
1397 ir_node *new_rd_Div (dbg_info *db, ir_graph *irg, ir_node *block,
1398 ir_node *memop, ir_node *op1, ir_node *op2);
1400 /** Constructor for a Mod node.
1402 * @param *db A pointer for debug information.
1403 * @param *irg The ir graph the node belongs to.
1404 * @param *block The ir block the node belongs to.
1405 * @param *memop The store needed to model exceptions
1406 * @param *op1 The operand 1.
1407 * @param *op2 The operand 2.
1409 ir_node *new_rd_Mod (dbg_info *db, ir_graph *irg, ir_node *block,
1410 ir_node *memop, ir_node *op1, ir_node *op2);
1412 /** Constructor for a Abs node.
1414 * @param *db A pointer for debug information.
1415 * @param *irg The ir graph the node belongs to.
1416 * @param *block The ir block the node belongs to.
1417 * @param *op The operand
1418 * @param *mode The mode of the operands and the result.
1420 ir_node *new_rd_Abs (dbg_info *db, ir_graph *irg, ir_node *block,
1421 ir_node *op, ir_mode *mode);
1423 /** Constructor for a And 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 result.
1432 ir_node *new_rd_And (dbg_info *db, ir_graph *irg, ir_node *block,
1433 ir_node *op1, ir_node *op2, ir_mode *mode);
1435 /** Constructor for a Or 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 *op1 The operand 1.
1441 * @param *op2 The operand 2.
1442 * @param *mode The mode of the operands and the result.
1444 ir_node *new_rd_Or (dbg_info *db, ir_graph *irg, ir_node *block,
1445 ir_node *op1, ir_node *op2, ir_mode *mode);
1447 /** Constructor for a Eor node.
1449 * @param *db A pointer for debug information.
1450 * @param *irg The ir graph the node belongs to.
1451 * @param *block The ir block the node belongs to.
1452 * @param *op1 The operand 1.
1453 * @param *op2 The operand 2.
1454 * @param *mode The mode of the operands and the results.
1456 ir_node *new_rd_Eor (dbg_info *db, ir_graph *irg, ir_node *block,
1457 ir_node *op1, ir_node *op2, ir_mode *mode);
1459 /** Constructor for a Not node.
1461 * @param *db A pointer for debug information.
1462 * @param *irg The ir graph the node belongs to.
1463 * @param *block The ir block the node belongs to.
1464 * @param *op The operand.
1465 * @param *mode The mode of the operand and the result.
1467 ir_node *new_rd_Not (dbg_info *db, ir_graph *irg, ir_node *block,
1468 ir_node *op, ir_mode *mode);
1470 /** Constructor for a Cmp node.
1472 * @param *db A pointer for debug information.
1473 * @param *irg The ir graph the node belongs to.
1474 * @param *block The ir block the node belongs to.
1475 * @param *op1 The operand 1.
1476 * @param *op2 The operand 2.
1478 ir_node *new_rd_Cmp (dbg_info *db, ir_graph *irg, ir_node *block,
1479 ir_node *op1, ir_node *op2);
1481 /** Constructor for a Shl 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_Shl (dbg_info *db, ir_graph *irg, ir_node *block,
1491 ir_node *op, ir_node *k, ir_mode *mode);
1493 /** Constructor for a Shr 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 shift the operand .
1500 * @param *mode The mode of the operand and the result.
1502 ir_node *new_rd_Shr (dbg_info *db, ir_graph *irg, ir_node *block,
1503 ir_node *op, ir_node *k, ir_mode *mode);
1505 /** Constructor for a Shrs node.
1507 * @param *db A pointer for debug information.
1508 * @param *irg The ir graph the node belongs to.
1509 * @param *block The ir block the node belongs to.
1510 * @param *op The operand.
1511 * @param *k The number of bits to shift the operand.
1512 * @param *mode The mode of the operand and the result.
1514 ir_node *new_rd_Shrs (dbg_info *db, ir_graph *irg, ir_node *block,
1515 ir_node *op, ir_node *k, ir_mode *mode);
1517 /** Constructor for a Rot node.
1519 * @param *db A pointer for debug information.
1520 * @param *irg The ir graph the node belongs to.
1521 * @param *block The ir block the node belongs to.
1522 * @param *op The operand.
1523 * @param *k The number of bits to rotate the operand.
1524 * @param *mode The mode of the operand.
1526 ir_node *new_rd_Rot (dbg_info *db, ir_graph *irg, ir_node *block,
1527 ir_node *op, ir_node *k, ir_mode *mode);
1530 /** Constructor for a Conv 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 *op The operand.
1536 * @param *mode The mode of this the operand muss be converted .
1538 ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block,
1539 ir_node *op, ir_mode *mode);
1541 /** Constructor for a Cast node.
1543 * High level type cast.
1545 * @param *db A pointer for debug information.
1546 * @param *irg The ir graph the node belongs to.
1547 * @param *block The ir block the node belongs to.
1548 * @param *op The operand.
1549 * @param *to_tp The type of this the operand muss be casted .
1551 ir_node *new_rd_Cast (dbg_info* db, ir_graph *irg, ir_node *block,
1552 ir_node *op, type *to_tp);
1554 /** Constructor for a Phi 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 arity The number of predecessors
1560 * @param *in[] Array with predecessors. The constructor copies this array.
1561 * @param *mode The mode of it's inputs and output.
1563 ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
1564 ir_node *in[], ir_mode *mode);
1566 /** Constructor for a Load node.
1568 * @param *db A pointer for debug information.
1569 * @param *irg The ir graph the node belongs to.
1570 * @param *block The ir block the node belongs to.
1571 * @param *store The current memory
1572 * @param *adr A pointer to the variable to be read in this memory.
1573 * @param *mode The mode of the value to be loaded.
1575 ir_node *new_rd_Load (dbg_info *db, ir_graph *irg, ir_node *block,
1576 ir_node *store, ir_node *adr, ir_mode *mode);
1578 /** Constructor for a Store node.
1580 * @param *db A pointer for debug information.
1581 * @param *irg The ir graph the node belongs to.
1582 * @param *block The ir block the node belongs to.
1583 * @param *store The current memory
1584 * @param *adr A pointer to the variable to be read in this memory.
1585 * @param *val The value to write to this variable.
1587 ir_node *new_rd_Store (dbg_info *db, ir_graph *irg, ir_node *block,
1588 ir_node *store, ir_node *adr, ir_node *val);
1590 /** Constructor for a Alloc node.
1592 * The Alloc node extends the memory by space for an entity of type alloc_type.
1594 * @param *db A pointer for debug information.
1595 * @param *irg The ir graph the node belongs to.
1596 * @param *block The ir block the node belongs to.
1597 * @param *store The memory which shall contain the new variable.
1598 * @param *size The number of bytes to allocate.
1599 * @param *alloc_type The type of the allocated variable.
1600 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
1602 ir_node *new_rd_Alloc (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1603 ir_node *size, type *alloc_type, where_alloc where);
1605 /** Constructor for a Free node.
1607 * Frees the memory occupied by the entity pointed to by the pointer
1608 * arg. Type indicates the type of the entity the argument points to.
1610 * @param *db A pointer for debug information.
1611 * @param *irg The ir graph the node belongs to.
1612 * @param *block The ir block the node belongs to.
1613 * @param *store The memory which shall contain the new variable.
1614 * @param *ptr The pointer to the object to free.
1615 * @param *size The number of objects of type free_type to free in a sequence.
1616 * @param *free_type The type of the freed variable.
1617 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
1619 ir_node *new_rd_Free (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1620 ir_node *ptr, ir_node *size, type *free_type, where_alloc where);
1622 /** Constructor for a Sync node.
1624 * Merges several memory values. The node assumes that a variable
1625 * either occurs only in one of the memories, or it contains the same
1626 * value in all memories where it occurs.
1628 * @param *db A pointer for debug information.
1629 * @param *irg The ir graph the node belongs to.
1630 * @param *block The ir block the node belongs to.
1631 * @param arity The number of memories to synchronize.
1632 * @param *in[] An array of pointers to nodes that produce an output of type
1633 * memory. The constructor copies this array.
1635 ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
1637 /** Constructor for a Proj node.
1639 * Projects a single value out of a tuple. The parameter proj gives the
1640 * position of the value within the tuple.
1642 * @param *db A pointer for debug information.
1643 * @param *irg The ir graph the node belongs to.
1644 * @param *block The ir block the node belongs to.
1645 * @param arg A node producing a tuple. The node must have mode_T.
1646 * @param *mode The mode of the value to project.
1647 * @param proj The position of the value in the tuple.
1649 ir_node *new_rd_Proj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1650 ir_mode *mode, long proj);
1652 /** Constructor for a defaultProj node.
1654 * Represents the default control flow of a Switch-Cond node.
1656 * @param *db A pointer for debug information.
1657 * @param *irg The ir graph the node belongs to.
1658 * @param *block The ir block the node belongs to.
1659 * @param arg A node producing a tuple.
1660 * @param max_proj The end position of the value in the tuple.
1662 ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1665 /** Constructor for a Tuple node.
1667 * This is an auxiliary node to replace a node that returns a tuple
1668 * without changing the corresponding Proj nodes.
1670 * @param *db A pointer for debug information.
1671 * @param *irg The ir graph the node belongs to.
1672 * @param *block The ir block the node belongs to.
1673 * @param arity The number of tuple elements.
1674 * @param *in[] An array containing pointers to the nodes producing the tuple
1675 * elements. The constructor copies this array.
1677 ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
1678 int arity, ir_node *in[]);
1680 /** Constructor for a Id node.
1682 * This is an auxiliary node to replace a node that returns a single
1685 * @param *db A pointer for debug information.
1686 * @param *irg The ir graph the node belongs to.
1687 * @param *block The ir block the node belongs to.
1688 * @param *val The value
1689 * @param *mode The mode of *val.
1691 ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
1692 ir_node *val, ir_mode *mode);
1694 /** Constructor for a Bad node.
1696 * Returns the unique Bad node of the graph. The same as
1699 * @param *irg The ir graph the node belongs to.
1701 ir_node *new_rd_Bad (ir_graph *irg);
1703 /** Constructor for a Confirm node.
1705 * Specifies constraints for a value. To support dataflow analyses.
1707 * Example: If the value never exceeds '100' this is expressed by placing a
1708 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
1710 * @param *irg The ir graph the node belong to.
1711 * @param *block The ir block the node belong to.
1712 * @param *db A pointer for debug information.
1713 * @param *val The value we express a constraint for
1714 * @param *bound The value to compare against. Must be a firm node, typically a constant.
1715 * @param cmp The compare operation.
1717 ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
1718 ir_node *val, ir_node *bound, pn_Cmp cmp);
1720 /** Constructor for an Unknown node.
1722 * Represents an arbitrary value. Places the node in the start block.
1724 * @param *irg The ir graph the node belongs to.
1725 * @param *m The mode of the unknown value.
1727 ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
1729 /** Constructor for a CallBegin node.
1731 * CallBegin represents control flow depending of the pointer value
1732 * representing the called method to the called methods. The
1733 * constructor copies the method pointer input from the passed Call
1736 * @param *db A pointer for debug information.
1737 * @param *irg The ir graph the node belong to.
1738 * @param *block The block the node belong to.
1739 * @param *callee The call node visible in the intra procedural view.
1741 ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
1743 /** Constructor for a EndReg node.
1745 * Used to represent regular procedure end in interprocedual view.
1747 * @param *db A pointer for debug information.
1748 * @param *irg The ir graph the node belong to.
1749 * @param *block The block the node belong to.
1751 ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
1753 /** Constructor for a EndExcept node.
1755 * Used to represent exceptional procedure end in interprocedural view.
1757 * @param *db A pointer for debug information.
1758 * @param *irg The ir graph the node belong to.
1759 * @param *block The block the node belong to.
1761 ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
1763 /** Constructor for a Filter node.
1765 * Adds the node to the block in current_ir_block. Filter is a node
1766 * with two views used to construct the interprocedural view. In
1767 * intraprocedural view its semantics are identical to the Proj node.
1768 * In interprocedural view the Filter performs the Phi operation on
1769 * method parameters or results. Other than a Phi a Filter node may
1770 * not be removed if it has only a single input.
1772 * The constructor builds the Filter in intraprocedural view.
1774 * @param *db A pointer for debug information.
1775 * @param *irg The ir graph the node belong to.
1776 * @param *block The block the node belong to.
1777 * @param *arg The tuple value to project from.
1778 * @param *mode The mode of the projected value.
1779 * @param proj The position in the tuple to project from.
1781 ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1782 ir_mode *mode, long proj);
1784 /** Constructor for a NoMem node.
1786 * Returns the unique NoMem node of the graph. The same as
1789 * @param *irg The ir graph the node belongs to.
1791 ir_node *new_rd_NoMem (ir_graph *irg);
1793 /** Constructor for a Mux node.
1795 * Adds the node to the block in current_ir_block.
1797 * @param *db A pointer for debug information.
1798 * @param *irg The ir graph the node belong to.
1799 * @param *block The block the node belong to.
1800 * @param *sel The ir_node that calculates the boolean select.
1801 * @param *ir_true The ir_node that calculates the true result.
1802 * @param *ir_false The ir_node that calculates the false result.
1803 * @param *mode The mode of the node (and it_true and ir_false).
1805 ir_node *new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block,
1806 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
1808 /*-------------------------------------------------------------------------*/
1809 /* The raw interface without debug support */
1810 /*-------------------------------------------------------------------------*/
1812 /** Constructor for a Block node.
1814 * Constructs a mature block with the given predecessors. Use Unknown
1815 * nodes as predecessors to construct a block if the number of
1816 * predecessors is known, but not the predecessors themselves. This
1817 * constructor does not set current_block. It not be used with
1818 * automatic Phi node construction.
1821 * @param irg The ir graph the block belongs to.
1822 * @param arity The number of control predecessors.
1823 * @param in[] An array of control predecessors. The length of
1824 * the array must be 'arity'. The constructor copies this array.
1826 ir_node *new_r_Block (ir_graph *irg, int arity, ir_node *in[]);
1828 /** Constructor for a Start node.
1830 * @param *irg The ir graph the node belongs to.
1831 * @param *block The ir block the node belongs to.
1833 ir_node *new_r_Start (ir_graph *irg, ir_node *block);
1835 /** Constructor for a End node.
1837 * @param *irg The ir graph the node belongs to.
1838 * @param *block The ir block the node belongs to.
1840 ir_node *new_r_End (ir_graph *irg, ir_node *block);
1842 /** Constructor for a Jmp node.
1844 * Jmp represents control flow to a single control successor.
1846 * @param *irg The ir graph the node belongs to.
1847 * @param *block The ir block the node belongs to.
1849 ir_node *new_r_Jmp (ir_graph *irg, ir_node *block);
1851 /** Constructor for an IJmp node.
1853 * IJmp represents control flow to a single control successor not
1854 * statically known i.e. an indirect Jmp.
1856 * @param *irg The ir graph the node belongs to.
1857 * @param *block The ir block the node belongs to.
1858 * @param *tgt The ir node representing the target address.
1860 ir_node *new_r_IJmp (ir_graph *irg, ir_node *block, ir_node *tgt);
1862 /** Constructor for a Cond node.
1864 * If c is mode_b represents a conditional branch (if/else). If c is
1865 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1866 * node, default Proj is 0.)
1868 * This is not consistent: Input to Cond is Is, Proj has as proj number
1871 * @param *irg The ir graph the node belongs to.
1872 * @param *block The ir block the node belongs to.
1873 * @param *c The conditions parameter.Can be of mode b or I_u.
1875 ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c);
1877 /** Constructor for a Return node.
1879 * Returns the memory an zero or more return values. Only node that
1880 * can end regular control flow.
1882 * @param *irg The ir graph the node belongs to.
1883 * @param *block The ir block the node belongs to.
1884 * @param *store The state of memory.
1885 * @param arity Number of array indices.
1886 * @param *in[] Array with index inputs to the node. The constructor copies this array.
1888 ir_node *new_r_Return (ir_graph *irg, ir_node *block,
1889 ir_node *store, int arity, ir_node *in[]);
1891 /** Constructor for a Raise node.
1893 * @param *irg The ir graph the node belongs to.
1894 * @param *block The ir block the node belongs to.
1895 * @param *store The current memory.
1896 * @param *obj A pointer to the Except variable.
1898 ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
1899 ir_node *store, ir_node *obj);
1901 /** Constructor for a Const node.
1903 * Constructor for a Const node. The constant represents a target
1904 * value. Sets the type information to type_unknown. (No more
1905 * supported: If tv is entity derives a somehow useful type.)
1907 * @param *irg The ir graph the node belongs to.
1908 * @param *block The ir block the node belongs to.
1909 * @param *mode The mode of the operands and the results.
1910 * @param *con Points to an entry in the constant table.
1912 ir_node *new_r_Const (ir_graph *irg, ir_node *block,
1913 ir_mode *mode, tarval *con);
1915 /** Constructor for a Const node.
1917 * Constructor for a Const node. The constant represents a target
1918 * value. Sets the type information to type_unknown. (No more
1919 * supported: If tv is entity derives a somehow useful type.)
1921 * @param *irg The ir graph the node belongs to.
1922 * @param *block The ir block the node belongs to.
1923 * @param *mode The mode of the operands and the results.
1924 * @param value A value from which the tarval is made.
1926 ir_node *new_r_Const_long(ir_graph *irg, ir_node *block,
1927 ir_mode *mode, long value);
1929 /** Constructor for a Const_type node.
1931 * The constant represents a target value. This constructor sets high
1932 * level type information for the constant value.
1934 * @param *irg The ir graph the node belongs to.
1935 * @param *block The ir block the node belongs to.
1936 * @param *mode The mode of the operands and results.
1937 * @param *con Points to an entry in the constant table.
1938 * @param *tp The type of the constant.
1940 ir_node *new_r_Const_type(ir_graph *irg, ir_node *block,
1941 ir_mode *mode, tarval *con, type *tp);
1943 /** Constructor for a SymConst node.
1945 * This is the constructor for a symbolic constant.
1946 * There are four kinds of symbolic constants:
1947 * - type_tag The symbolic constant represents a type tag. The type the
1948 * tag stands for is given explicitly.
1949 * - size The symbolic constant represents the size of a type. The
1950 * type of which the constant represents the size is given
1952 * - addr_name The symbolic constant represents the address of an entity
1953 * (variable or method). The variable is indicated by a name
1954 * that is valid for linking.
1955 * - addr_ent The symbolic constant represents the address of an entity
1956 * (variable or method). The variable is given explicitly by
1959 * Inputs to the node:
1960 * No inputs except the block it belongs to.
1961 * Outputs of the node.
1962 * An unsigned integer (I_u) or a pointer (P).
1964 * @param *irg The ir graph the node belongs to.
1965 * @param *block The ir block the node belongs to.
1966 * @param value A type, entity or a ident depending on the SymConst kind.
1967 * @param symkind The kind of the symbolic constant: type_tag, size or link_info.
1969 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
1970 union symconst_symbol value, symconst_kind symkind);
1972 /** Constructor for a Sel node.
1974 * The select node selects an entity (field or method) from an entity
1975 * with a compound type. It explicitly specifies the entity selected.
1976 * Dynamically the node may select entities that overwrite the given
1977 * entity. If the selected entity is an array element entity the Sel
1978 * node takes the required array indices as inputs.
1980 * @param *irg The ir graph the node belongs to.
1981 * @param *block The ir block the node belongs to.
1982 * @param *store The memory in which the object the entity should be selected
1983 * from is allocated.
1984 * @param *objptr A pointer to a compound entity the Sel operation selects a
1985 * single attribute from.
1986 * @param *n_index The number of array indices needed to select an array element entity.
1987 * @param *index[] If the compound entity is an array the indices of the selected
1988 * element entity. The constructor copies this array.
1989 * @param *ent The entity to select.
1991 ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store,
1992 ir_node *objptr, int n_index, ir_node *index[],
1995 /** Constructor for a InstOf node.
1997 * For translating Java. Not supported as standard firm node.
1999 * @param *irg The ir graph the node belongs to.
2000 * @param *block The ir block the node belongs to.
2005 ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *x, ir_node *y, type *z);
2007 /** Constructor for a Call node.
2009 * Represents all kinds of method and function calls.
2011 * @param *irg The ir graph the node belongs to.
2012 * @param *block The ir block the node belongs to.
2013 * @param * store The actual store.
2014 * @param *callee A pointer to the called procedure.
2015 * @param arity The number of procedure parameters.
2016 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2017 * @param *tp Type information of the procedure called.
2019 ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
2020 ir_node *callee, int arity, ir_node *in[],
2023 /** Constructor for a Add node.
2025 * @param *irg The ir graph the node belongs to.
2026 * @param *block The ir block the node belongs to.
2027 * @param *op1 The operand 1.
2028 * @param *op2 The operand 2.
2029 * @param *mode The mode of the operands and the result.
2031 ir_node *new_r_Add (ir_graph *irg, ir_node *block,
2032 ir_node *op1, ir_node *op2, ir_mode *mode);
2035 * Constructor for a Sub node.
2037 * @param *irg The ir graph the node belongs to.
2038 * @param *block The ir block the node belongs to.
2039 * @param *op1 The operand 1.
2040 * @param *op2 The operand 2.
2041 * @param *mode The mode of the operands and the results.
2043 ir_node *new_r_Sub (ir_graph *irg, ir_node *block,
2044 ir_node *op1, ir_node *op2, ir_mode *mode);
2046 /** Constructor for a Minus node.
2048 * @param *irg The ir graph the node belongs to.
2049 * @param *block The ir block the node belongs to.
2050 * @param *op The operand.
2051 * @param *mode The mode of the operand and the result.
2053 ir_node *new_r_Minus (ir_graph *irg, ir_node *block,
2054 ir_node *op, ir_mode *mode);
2055 /** Constructor for a Mul node.
2057 * @param *irg The ir graph the node belongs to.
2058 * @param *block The ir block the node belongs to.
2059 * @param *op1 The operand 1.
2060 * @param *op2 The operand 2.
2061 * @param *mode The mode of the operands and the result.
2063 ir_node *new_r_Mul (ir_graph *irg, ir_node *block,
2064 ir_node *op1, ir_node *op2, ir_mode *mode);
2066 /** Constructor for a Quot node.
2068 * @param *irg The ir graph the node belongs to.
2069 * @param *block The ir block the node belongs to.
2070 * @param *memop The store needed to model exceptions
2071 * @param *op1 The operand 1.
2072 * @param *op2 The operand 2.
2074 ir_node *new_r_Quot (ir_graph *irg, ir_node *block,
2075 ir_node *memop, ir_node *op1, ir_node *op2);
2077 /** Constructor for a DivMod node.
2079 * @param *irg The ir graph the node belongs to.
2080 * @param *block The ir block the node belongs to.
2081 * @param *memop The store needed to model exceptions
2082 * @param *op1 The operand 1.
2083 * @param *op2 The operand 2.
2085 ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
2086 ir_node *memop, ir_node *op1, ir_node *op2);
2088 /** Constructor for a Div node.
2090 * @param *irg The ir graph the node belongs to.
2091 * @param *block The ir block the node belongs to.
2092 * @param *memop The store needed to model exceptions
2093 * @param *op1 The operand 1.
2094 * @param *op2 The operand 2.
2096 ir_node *new_r_Div (ir_graph *irg, ir_node *block,
2097 ir_node *memop, ir_node *op1, ir_node *op2);
2099 /** Constructor for a Mod node.
2101 * @param *irg The ir graph the node belongs to.
2102 * @param *block The ir block the node belongs to.
2103 * @param *memop The store needed to model exceptions
2104 * @param *op1 The operand 1.
2105 * @param *op2 The operand 2.
2107 ir_node *new_r_Mod (ir_graph *irg, ir_node *block,
2108 ir_node *memop, ir_node *op1, ir_node *op2);
2110 /** Constructor for a Abs node.
2112 * @param *irg The ir graph the node belongs to.
2113 * @param *block The ir block the node belongs to.
2114 * @param *op The operand
2115 * @param *mode The mode of the operands and the result.
2117 ir_node *new_r_Abs (ir_graph *irg, ir_node *block,
2118 ir_node *op, ir_mode *mode);
2120 /** Constructor for a And node.
2122 * @param *irg The ir graph the node belongs to.
2123 * @param *block The ir block the node belongs to.
2124 * @param *op1 The operand 1.
2125 * @param *op2 The operand 2.
2126 * @param *mode The mode of the operands and the result.
2128 ir_node *new_r_And (ir_graph *irg, ir_node *block,
2129 ir_node *op1, ir_node *op2, ir_mode *mode);
2131 /** Constructor for a Or node.
2133 * @param *irg The ir graph the node belongs to.
2134 * @param *block The ir block the node belongs to.
2135 * @param *op1 The operand 1.
2136 * @param *op2 The operand 2.
2137 * @param *mode The mode of the operands and the result.
2139 ir_node *new_r_Or (ir_graph *irg, ir_node *block,
2140 ir_node *op1, ir_node *op2, ir_mode *mode);
2142 /** Constructor for a Eor node.
2144 * @param *irg The ir graph the node belongs to.
2145 * @param *block The ir block the node belongs to.
2146 * @param *op1 The operand 1.
2147 * @param *op2 The operand 2.
2148 * @param *mode The mode of the operands and the results.
2150 ir_node *new_r_Eor (ir_graph *irg, ir_node *block,
2151 ir_node *op1, ir_node *op2, ir_mode *mode);
2153 /** Constructor for a Not node.
2155 * @param *irg The ir graph the node belongs to.
2156 * @param *block The ir block the node belongs to.
2157 * @param *op The operand.
2158 * @param *mode The mode of the operand and the result.
2160 ir_node *new_r_Not (ir_graph *irg, ir_node *block,
2161 ir_node *op, ir_mode *mode);
2163 /** Constructor for a Cmp node.
2165 * @param *irg The ir graph the node belongs to.
2166 * @param *block The ir block the node belongs to.
2167 * @param *op1 The operand 1.
2168 * @param *op2 The operand 2.
2170 ir_node *new_r_Cmp (ir_graph *irg, ir_node *block,
2171 ir_node *op1, ir_node *op2);
2173 /** Constructor for a Shl node.
2175 * @param *irg The ir graph the node belongs to.
2176 * @param *block The ir block the node belongs to.
2177 * @param *op The operand.
2178 * @param *k The number of bits to shift the operand .
2179 * @param *mode The mode of the operand and the result.
2181 ir_node *new_r_Shl (ir_graph *irg, ir_node *block,
2182 ir_node *op, ir_node *k, ir_mode *mode);
2184 /** Constructor for a Shr node.
2186 * @param *irg The ir graph the node belongs to.
2187 * @param *block The ir block the node belongs to.
2188 * @param *op The operand.
2189 * @param *k The number of bits to shift the operand .
2190 * @param *mode The mode of the operand and the result.
2192 ir_node *new_r_Shr (ir_graph *irg, ir_node *block,
2193 ir_node *op, ir_node *k, ir_mode *mode);
2196 * Constructor for a Shrs node.
2198 * @param *irg The ir graph the node belongs to.
2199 * @param *block The ir block the node belongs to.
2200 * @param *op The operand.
2201 * @param *k The number of bits to shift the operand.
2202 * @param *mode The mode of the operand and the result.
2204 ir_node *new_r_Shrs (ir_graph *irg, ir_node *block,
2205 ir_node *op, ir_node *k, ir_mode *mode);
2207 /** Constructor for a Rot node.
2209 * @param *irg The ir graph the node belongs to.
2210 * @param *block The ir block the node belongs to.
2211 * @param *op The operand.
2212 * @param *k The number of bits to rotate the operand.
2213 * @param *mode The mode of the operand.
2215 ir_node *new_r_Rot (ir_graph *irg, ir_node *block,
2216 ir_node *op, ir_node *k, ir_mode *mode);
2218 /** Constructor for a Conv node.
2220 * @param *irg The ir graph the node belongs to.
2221 * @param *block The ir block the node belongs to.
2222 * @param *op The operand.
2223 * @param *mode The mode of this the operand muss be converted .
2225 ir_node *new_r_Conv (ir_graph *irg, ir_node *block,
2226 ir_node *op, ir_mode *mode);
2228 /** Constructor for a Cast node.
2230 * High level type cast
2232 * @param *irg The ir graph the node belongs to.
2233 * @param *block The ir block the node belongs to.
2234 * @param *op The operand.
2235 * @param *to_tp The type of this the operand muss be casted .
2237 ir_node *new_r_Cast (ir_graph *irg, ir_node *block,
2238 ir_node *op, type *to_tp);
2240 /** Constructor for a Phi node.
2242 * @param *irg The ir graph the node belongs to.
2243 * @param *block The ir block the node belongs to.
2244 * @param arity The number of predecessors
2245 * @param *in[] Array with predecessors. The constructor copies this array.
2246 * @param *mode The mode of it's inputs and output.
2248 ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity,
2249 ir_node *in[], ir_mode *mode);
2251 /** Constructor for a Load node.
2253 * @param *irg The ir graph the node belongs to.
2254 * @param *block The ir block the node belongs to.
2255 * @param *store The current memory
2256 * @param *adr A pointer to the variable to be read in this memory.
2257 * @param *mode The mode of the value to be loaded.
2259 ir_node *new_r_Load (ir_graph *irg, ir_node *block,
2260 ir_node *store, ir_node *adr, ir_mode *mode);
2262 /** Constructor for a Store node.
2264 * @param *irg The ir graph the node belongs to.
2265 * @param *block The ir block the node belongs to.
2266 * @param *store The current memory
2267 * @param *adr A pointer to the variable to be read in this memory.
2268 * @param *val The value to write to this variable.
2270 ir_node *new_r_Store (ir_graph *irg, ir_node *block,
2271 ir_node *store, ir_node *adr, ir_node *val);
2273 /** Constructor for a Alloc node.
2275 * The Alloc node extends the memory by space for an entity of type alloc_type.
2277 * @param *irg The ir graph the node belongs to.
2278 * @param *block The ir block the node belongs to.
2279 * @param *store The memory which shall contain the new variable.
2280 * @param *size The number of bytes to allocate.
2281 * @param *alloc_type The type of the allocated variable.
2282 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2284 ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store,
2285 ir_node *size, type *alloc_type, where_alloc where);
2287 /** Constructor for a Free node.
2289 * Frees the memory occupied by the entity pointed to by the pointer
2290 * arg. Type indicates the type of the entity the argument points to.
2292 * @param *irg The ir graph the node belongs to.
2293 * @param *block The ir block the node belongs to.
2294 * @param *store The memory which shall contain the new variable.
2295 * @param *ptr The pointer to the object to free.
2296 * @param *size The number of objects of type free_type to free in a sequence.
2297 * @param *free_type The type of the freed variable.
2298 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2300 ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store,
2301 ir_node *ptr, ir_node *size, type *free_type, where_alloc where);
2303 /** Constructor for a Sync node.
2305 * Merges several memory values. The node assumes that a variable
2306 * either occurs only in one of the memories, or it contains the same
2307 * value in all memories where it occurs.
2309 * @param *irg The ir graph the node belongs to.
2310 * @param *block The ir block the node belongs to.
2311 * @param arity The number of memories to synchronize.
2312 * @param *in[] An array of pointers to nodes that produce an output of type memory.
2313 * The constructor copies this array.
2315 ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2317 /** Constructor for a Proj node.
2319 * Projects a single value out of a tuple. The parameter proj gives the
2320 * position of the value within the tuple.
2322 * @param *irg The ir graph the node belongs to.
2323 * @param *block The ir block the node belongs to.
2324 * @param arg A node producing a tuple.
2325 * @param *mode The mode of the value to project.
2326 * @param proj The position of the value in the tuple.
2328 ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg,
2329 ir_mode *mode, long proj);
2331 /** Constructor for a defaultProj node.
2333 * Represents the default control flow of a Switch-Cond node.
2335 * @param *irg The ir graph the node belongs to.
2336 * @param *block The ir block the node belongs to.
2337 * @param arg A node producing a tuple.
2338 * @param max_ proj The end position of the value in the tuple.
2340 ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj);
2343 /** Constructor for a Tuple node.
2345 * This is an auxiliary node to replace a node that returns a tuple
2346 * without changing the corresponding Proj nodes.
2348 * @param *irg The ir graph the node belongs to.
2349 * @param *block The ir block the node belongs to.
2350 * @param arity The number of tuple elements.
2351 * @param *in[] An array containing pointers to the nodes producing the tuple elements.
2352 * The constructor copies this array.
2354 ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2356 /** Constructor for a Id node.
2358 * This is an auxiliary node to replace a node that returns a single
2361 * @param *irg The ir graph the node belongs to.
2362 * @param *block The ir block the node belongs to.
2363 * @param *val The operand to Id.
2364 * @param *mode The mode of *val.
2366 ir_node *new_r_Id (ir_graph *irg, ir_node *block,
2367 ir_node *val, ir_mode *mode);
2369 /** Constructor for a Bad node.
2371 * Returns the unique Bad node of the graph. The same as
2374 * @param *irg The ir graph the node belongs to.
2378 ir_node *new_r_Bad (ir_graph *irg);
2380 /** Constructor for a Confirm node.
2382 * Specifies constraints for a value. To support dataflow analyses.
2384 * Example: If the value never exceeds '100' this is expressed by placing a
2385 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
2387 * @param *irg The ir graph the node belong to.
2388 * @param *block The ir block the node belong to.
2389 * @param *db A pointer for debug information.
2390 * @param *val The value we express a constraint for
2391 * @param *bound The value to compare against. Must be a firm node, typically a constant.
2392 * @param cmp The compare operation.
2395 ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
2396 ir_node *val, ir_node *bound, pn_Cmp cmp);
2398 /** Constructor for a Unknown node.
2400 * Represents an arbitrary value. Places the node in
2403 * @param *irg The ir graph the node belongs to.
2404 * @param *m The mode of the unknown value.
2406 ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2408 /** Constructor for a CallBegin node.
2410 * CallBegin represents control flow depending of the pointer value
2411 * representing the called method to the called methods. The
2412 * constructor copies the method pointer input from the passed Call
2415 * @param *irg The ir graph the node belong to.
2416 * @param *block The block the node belong to.
2417 * @param *callee The call node visible in the intra procedural view.
2419 ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
2421 /** Constructor for a EndReg node.
2423 * Used to represent regular procedure end in interprocedual view.
2425 * @param *irg The ir graph the node belong to.
2426 * @param *block The block the node belong to.
2428 ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
2430 /** Constructor for a EndExcept node.
2432 * Used to represent exceptional procedure end in interprocedural view.
2434 * @param *irg The ir graph the node belong to.
2435 * @param *block The block the node belong to.
2437 ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
2439 /** Constructor for a Break node.
2441 * Break represents control flow to a single control successor just as Jmp.
2442 * The blocks separated by a break may not be concatenated by an optimization.
2443 * It is used for the interprocedural representation where blocks are parted
2444 * behind Call nodes to represent the control flow to called procedures.
2446 * @param *irg The ir graph the node belong to.
2447 * @param *block The block the node belong to.
2449 ir_node *new_r_Break (ir_graph *irg, ir_node *block);
2451 /** Constructor for a Filter node.
2453 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
2454 * Filter is a node with two views used to construct the interprocedural view.
2455 * In intraprocedural view its semantics are identical to the Proj node.
2456 * In interprocedural view the Filter performs the Phi operation on method
2457 * parameters or results. Other than a Phi a Filter node may not be removed
2458 * if it has only a single input.
2460 * The constructor builds the Filter in intraprocedural view.
2462 * @param *irg The ir graph the node belong to.
2463 * @param *block The block the node belong to.
2464 * @param *arg The tuple value to project from.
2465 * @param *mode The mode of the projected value.
2466 * @param proj The position in the tuple to project from.
2468 ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
2469 ir_mode *mode, long proj);
2471 /** Constructor for a NoMem node.
2473 * Returns the unique NoMem node of the graph. The same as
2476 * @param *irg The ir graph the node belongs to.
2478 ir_node *new_r_NoMem (ir_graph *irg);
2480 /** Constructor for a Mux node.
2482 * Adds the node to the block in current_ir_block.
2484 * @param *irg The ir graph the node belong to.
2485 * @param *block The block the node belong to.
2486 * @param *sel The ir_node that calculates the boolean select.
2487 * @param *ir_true The ir_node that calculates the true result.
2488 * @param *ir_false The ir_node that calculates the false result.
2489 * @param *mode The mode of the node (and it_true and ir_false).
2491 ir_node *new_r_Mux (ir_graph *irg, ir_node *block,
2492 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2494 /*-----------------------------------------------------------------------*/
2495 /* The block oriented interface */
2496 /*-----------------------------------------------------------------------*/
2498 /** Sets the current block in which the following constructors place the
2499 * nodes they construct.
2501 * @param target The new current block.
2503 void set_cur_block (ir_node *target);
2505 /** Returns the current block of the current graph. */
2506 ir_node *get_cur_block(void);
2508 /** Returns the fixed nodes of the current graph. */
2509 #define get_cur_end_block() get_irg_end_block(current_ir_graph)
2510 #define get_cur_end() get_irg_end(current_ir_graph)
2511 #define get_cur_start_block() get_irg_start_block(current_ir_graph)
2512 #define get_cur_start() get_irg_start(current_ir_graph)
2514 /** Constructor for a Block node.
2516 * Adds the block to the graph in current_ir_graph. Constructs a Block
2517 * with a fixed number of predecessors. Does set current_block. Can
2518 * be used with automatic Phi node construction.
2520 * @param *db A Pointer for debug information.
2521 * @param arity The number of control predecessors.
2522 * @param in[] An array of control predecessors. The length of
2523 * the array must be 'arity'.
2525 ir_node *new_d_Block(dbg_info* db, int arity, ir_node *in[]);
2527 /** Constructor for a Start node.
2529 * Adds the node to the block in current_ir_block.
2531 * @param *db A pointer for debug information.
2533 ir_node *new_d_Start (dbg_info* db);
2535 /** Constructor for a End node.
2537 * Adds the node to the block in current_ir_block.
2539 * @param *db A pointer for debug information.
2541 ir_node *new_d_End (dbg_info* db);
2543 /** Constructor for a Jmp node.
2545 * Adds the node to the block in current_ir_block.
2547 * Jmp represents control flow to a single control successor.
2549 * @param *db A pointer for debug information.
2551 ir_node *new_d_Jmp (dbg_info* db);
2553 /** Constructor for an IJmp node.
2555 * IJmp represents control flow to a single control successor not
2556 * statically known i.e. an indirect Jmp.
2558 * @param *db A pointer for debug information.
2559 * @param *tgt The ir node representing the target address.
2561 ir_node *new_d_IJmp (dbg_info *db, ir_node *tgt);
2563 /** Constructor for a Cond node.
2565 * Adds the node to the block in current_ir_block.
2567 * If c is mode_b represents a conditional branch (if/else). If c is
2568 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2569 * node, default Proj is 0.)
2571 * This is not consistent: Input to Cond is Is, Proj has as proj number
2574 * @param *db A pointer for debug information.
2575 * @param *c The conditions parameter.Can be of mode b or I_u.
2578 ir_node *new_d_Cond (dbg_info* db, ir_node *c);
2580 /** Constructor for a Return node.
2582 * Adds the node to the block in current_ir_block.
2584 * Returns the memory an zero or more return values. Only node that
2585 * can end regular control flow.
2587 * @param *db A pointer for debug information.
2588 * @param *store The state of memory.
2589 * @param arity Number of array indices.
2590 * @param *in Array with index inputs to the node.
2593 ir_node *new_d_Return (dbg_info* db, ir_node *store, int arity, ir_node *in[]);
2595 /** Constructor for a Raise node.
2597 * Adds the node to the block in current_ir_block.
2599 * @param *db A pointer for debug information.
2600 * @param *store The current memory.
2601 * @param *obj A pointer to the Except variable.
2604 ir_node *new_d_Raise (dbg_info* db, ir_node *store, ir_node *obj);
2606 /** Constructor for a Const_type node.
2608 * Adds the node to the block in current_ir_block.
2610 * The constant represents a target value. This constructor sets high
2611 * level type information for the constant value.
2613 * @param *db A pointer for debug information.
2614 * @param *mode The mode of the operands and results.
2615 * @param *con Points to an entry in the constant table. This pointer is
2616 added to the attributes of the node.
2617 * @param *tp The type of the constant.
2619 ir_node *new_d_Const_type (dbg_info* db, ir_mode *mode, tarval *con, type *tp);
2621 /** Constructor for a Const node.
2623 * Adds the node to the block in current_ir_block.
2625 * Constructor for a Const node. The constant represents a target
2626 * value. Sets the type information to type_unknown. (No more
2627 * supported: If tv is entity derives a somehow useful type.)
2629 * @param *db A pointer for debug information.
2630 * @param *mode The mode of the operands and results.
2631 * @param *con Points to an entry in the constant table. This pointer is added
2632 * to the attributes of the node.
2634 ir_node *new_d_Const (dbg_info* db, ir_mode *mode, tarval *con);
2636 /** Constructor for a SymConst_type node.
2638 * Adds the node to the block in current_ir_block.
2639 * This is the constructor for a symbolic constant.
2640 * There are four kinds of symbolic constants:
2641 * - type_tag The symbolic constant represents a type tag. The type the
2642 * tag stands for is given explicitly.
2643 * - size The symbolic constant represents the size of a type. The
2644 * type of which the constant represents the size is given
2646 * - addr_name The symbolic constant represents the address of an entity
2647 * (variable or method). The variable is indicated by a name
2648 * that is valid for linking.
2649 * - addr_ent The symbolic constant represents the address of an entity
2650 * (variable or method). The variable is given explicitly by
2653 * Inputs to the node:
2654 * No inputs except the block it belongs to.
2655 * Outputs of the node.
2656 * An unsigned integer (I_u) or a pointer (P).
2658 * @param *db A pointer for debug information.
2659 * @param value A type, entity or ident depending on the SymConst kind.
2660 * @param symkind The kind of the symbolic constant: symconst_type_tag, symconst_size
2661 * or symconst_addr_name.
2662 * @param tp The source type of the constant.
2665 ir_node *new_d_SymConst_type (dbg_info* db, union symconst_symbol value, symconst_kind kind, type* tp);
2667 /** Constructor for a SymConst node.
2669 * Same as new_d_SymConst_type, except that it sets the type to type_unknown. */
2670 ir_node *new_d_SymConst (dbg_info* db, union symconst_symbol value, symconst_kind kind);
2672 /** Constructor for a simpleSel node.
2674 * This is a shortcut for the new_d_Sel() constructor. To be used for
2675 * Sel nodes that do not select from an array, i.e., have no index
2676 * inputs. It adds the two parameters 0, NULL.
2678 * @param *db A pointer for debug information.
2679 * @param *store The memory in which the object the entity should be
2680 * selected from is allocated.
2681 * @param *objptr The object from that the Sel operation selects a
2682 * single attribute out.
2683 * @param *ent The entity to select.
2685 ir_node *new_d_simpleSel(dbg_info* db, ir_node *store, ir_node *objptr, entity *ent);
2687 /** Constructor for a Sel node.
2689 * The select node selects an entity (field or method) from an entity
2690 * with a compound type. It explicitly specifies the entity selected.
2691 * Dynamically the node may select entities that overwrite the given
2692 * entity. If the selected entity is an array element entity the Sel
2693 * node takes the required array indices as inputs.
2694 * Adds the node to the block in current_ir_block.
2696 * @param *db A pointer for debug information.
2697 * @param *store The memory in which the object the entity should be selected
2698 * from is allocated.
2699 * @param *objptr A pointer to a compound entity the Sel operation selects a
2700 * single attribute from.
2701 * @param *n_index The number of array indices needed to select an array element entity.
2702 * @param *index[] If the compound entity is an array the indices of the selected
2703 * element entity. The constructor copies this array.
2704 * @param *ent The entity to select.
2706 ir_node *new_d_Sel (dbg_info* db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
2709 /** Constructor for a InstOf node.
2711 * Adds the node to the block in current_ir_block.
2713 * For translating Java. Not supported as standard firm node.
2715 * @param *db A pointer for debug information.
2720 ir_node *new_d_InstOf (dbg_info* db, ir_node *store, ir_node *objptr, type *ent);
2722 /** Constructor for a Call node.
2724 * Represents all kinds of method and function calls.
2725 * Adds the node to the block in current_ir_block.
2727 * @param *db A pointer for debug information.
2728 * @param *store The actual store.
2729 * @param *callee A pointer to the called procedure.
2730 * @param arity The number of procedure parameters.
2731 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2732 * @param *tp Type information of the procedure called.
2735 ir_node *new_d_Call (dbg_info* db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
2738 /** Constructor for a Add node.
2740 * Adds the node to the block in current_ir_block.
2742 * @param *db A pointer for debug information.
2743 * @param *op1 The operand 1.
2744 * @param *op2 The operand 2.
2745 * @param *mode The mode of the operands and the result.
2747 ir_node *new_d_Add (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2749 /** Constructor for a Sub node.
2751 * Adds the node to the block in current_ir_block.
2753 * @param *db A pointer for debug information.
2754 * @param *op1 The operand 1.
2755 * @param *op2 The operand 2.
2756 * @param *mode The mode of the operands and the result.
2759 ir_node *new_d_Sub (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2761 /** Constructor for a Minus node.
2763 * Adds the node to the block in current_ir_block.
2765 * @param *db A pointer for debug information.
2766 * @param *op The operand .
2767 * @param *mode The mode of the operand and the result.
2769 ir_node *new_d_Minus (dbg_info* db, ir_node *op, ir_mode *mode);
2771 /** Constructor for a Mul node.
2773 * Adds the node to the block in current_ir_block.
2775 * @param *db A pointer for debug information.
2776 * @param *op1 The operand 1.
2777 * @param *op2 The operand 2.
2778 * @param *mode The mode of the operands and the result.
2780 ir_node *new_d_Mul (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2782 /** Constructor for a Quot node.
2784 * Adds the node to the block in current_ir_block.
2786 * @param *db A pointer for debug information.
2787 * @param *memop The store needed to model exceptions
2788 * @param *op1 The operand 1.
2789 * @param *op2 The operand 2.
2791 ir_node *new_d_Quot (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2793 /** Constructor for a DivMod node.
2795 * Adds the node to the block in current_ir_block.
2797 * @param *db A pointer for debug information.
2798 * @param *memop The store needed to model exceptions
2799 * @param *op1 The operand 1.
2800 * @param *op2 The operand 2.
2802 ir_node *new_d_DivMod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2804 /** Constructor for a Div node.
2806 * Adds the node to the block in current_ir_block.
2808 * @param *db A pointer for debug information.
2809 * @param *memop The store needed to model exceptions
2810 * @param *op1 The operand 1.
2811 * @param *op2 The operand 2.
2813 ir_node *new_d_Div (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2815 /** Constructor for a Mod node.
2817 * Adds the node to the block in current_ir_block.
2819 * @param *db A pointer for debug information.
2820 * @param *memop The store needed to model exceptions
2821 * @param *op1 The operand 1.
2822 * @param *op2 The operand 2.
2824 ir_node *new_d_Mod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2826 /** Constructor for a Abs node.
2828 * Adds the node to the block in current_ir_block.
2830 * @param *db A pointer for debug information.
2831 * @param *op The operand
2832 * @param *mode The mode of the operands and the result.
2834 ir_node *new_d_Abs (dbg_info* db, ir_node *op, ir_mode *mode);
2836 /** Constructor for a And node.
2838 * Adds the node to the block in current_ir_block.
2840 * @param *db A pointer for debug information.
2841 * @param *irg The ir graph the node belongs to.
2842 * @param *block The ir block the node belongs to.
2843 * @param *op1 The operand 1.
2844 * @param *op2 The operand 2.
2845 * @param *mode The mode of the operands and the result.
2847 ir_node *new_d_And (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2849 /** Constructor for a Or node.
2851 * Adds the node to the block in current_ir_block.
2853 * @param *db A pointer for debug information.
2854 * @param *op1 The operand 1.
2855 * @param *op2 The operand 2.
2856 * @param *mode The mode of the operands and the result.
2858 ir_node *new_d_Or (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2860 /** Constructor for a Eor node.
2862 * Adds the node to the block in current_ir_block.
2864 * @param *db A pointer for debug information.
2865 * @param *op1 The operand 1.
2866 * @param *op2 The operand 2.
2867 * @param *mode The mode of the operands and the results.
2869 ir_node *new_d_Eor (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2871 /** Constructor for a Not node.
2873 * Adds the node to the block in current_ir_block.
2875 * @param *db A pointer for debug information.
2876 * @param *op The operand.
2877 * @param *mode The mode of the operand and the result.
2879 ir_node *new_d_Not (dbg_info* db, ir_node *op, ir_mode *mode);
2881 /** Constructor for a Shl node.
2883 * Adds the node to the block in current_ir_block.
2885 * @param *db A pointer for debug information.
2886 * @param *op The operand.
2887 * @param *k The number of bits to shift the operand .
2888 * @param *mode The mode of the operand and the result.
2890 ir_node *new_d_Shl (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2892 /** Constructor for a Shr node.
2894 * Adds the node to the block in current_ir_block.
2896 * @param *db A pointer for debug information.
2897 * @param *op The operand.
2898 * @param *k The number of bits to shift the operand .
2899 * @param *mode The mode of the operand and the result.
2901 ir_node *new_d_Shr (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2903 /** Constructor for a Shrs node.
2905 * Adds the node to the block in current_ir_block.
2907 * @param *db A pointer for debug information.
2908 * @param *op The operand.
2909 * @param *k The number of bits to shift the operand .
2910 * @param *mode The mode of the operand and the result.
2912 ir_node *new_d_Shrs (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2914 /** Constructor for a Rot node.
2916 * Adds the node to the block in current_ir_block.
2918 * @param *db A pointer for debug information.
2919 * @param *op The operand.
2920 * @param *k The number of bits to rotate the operand.
2921 * @param *mode The mode of the operand.
2923 ir_node *new_d_Rot (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2925 /** Constructor for a Cmp node.
2927 * Adds the node to the block in current_ir_block.
2929 * @param *db A pointer for debug information.
2930 * @param *op1 The operand 1.
2931 * @param *op2 The operand 2.
2933 ir_node *new_d_Cmp (dbg_info* db, ir_node *op1, ir_node *op2);
2935 /** Constructor for a Conv node.
2937 * Adds the node to the block in current_ir_block.
2939 * @param *db A pointer for debug information.
2940 * @param *op The operand.
2941 * @param *mode The mode of this the operand muss be converted .
2943 ir_node *new_d_Conv (dbg_info* db, ir_node *op, ir_mode *mode);
2945 /**Constructor for a Cast node.
2947 * High level type cast
2948 * Adds the node to the block in current_ir_block.
2950 * @param *db A pointer for debug information.
2951 * @param *op The operand.
2952 * @param *to_tp The type of this the operand muss be casted .
2954 ir_node *new_d_Cast (dbg_info* db, ir_node *op, type *to_tp);
2956 /**Constructor for a Phi node.
2958 * Adds the node to the block in current_ir_block.
2960 * @param *db A pointer for debug information.
2961 * @param arity The number of predecessors
2962 * @param *in Array with predecessors
2963 * @param *mode The mode of it's inputs and output.
2965 ir_node *new_d_Phi (dbg_info* db, int arity, ir_node *in[], ir_mode *mode);
2967 /** Constructor for a Load node.
2969 * Adds the node to the block in current_ir_block.
2971 * @param *db A pointer for debug information.
2972 * @param *store The current memory
2973 * @param *adr A pointer to the variable to be read in this memory.
2974 * @param *mode The mode of the value to be loaded.
2976 ir_node *new_d_Load (dbg_info* db, ir_node *store, ir_node *addr, ir_mode *mode);
2978 /** Constructor for a Store node.
2980 * Adds the node to the block in current_ir_block.
2982 * @param *db A pointer for debug information.
2983 * @param *store The current memory
2984 * @param *adr A pointer to the variable to be read in this memory.
2985 * @param *val The value to write to this variable.
2987 ir_node *new_d_Store (dbg_info* db, ir_node *store, ir_node *addr, ir_node *val);
2989 /** Constructor for a Alloc node.
2991 * The Alloc node extends the memory by space for an entity of type alloc_type.
2992 * Adds the node to the block in current_ir_block.
2994 * @param *db A pointer for debug information.
2995 * @param *store The memory which shall contain the new variable.
2996 * @param *size The number of bytes to allocate.
2997 * @param *alloc_type The type of the allocated variable.
2998 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3000 ir_node *new_d_Alloc (dbg_info* db, ir_node *store, ir_node *size, type *alloc_type,
3003 /** Constructor for a Free node.
3005 * Frees the memory occupied by the entity pointed to by the pointer
3006 * arg. Type indicates the type of the entity the argument points to.
3007 * Adds the node to the block in current_ir_block.
3009 * @param *db A pointer for debug information.
3010 * @param *store The memory which shall contain the new variable.
3011 * @param *ptr The pointer to the object to free.
3012 * @param *size The number of objects of type free_type to free in a sequence.
3013 * @param *free_type The type of the freed variable.
3014 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3016 ir_node *new_d_Free (dbg_info* db, ir_node *store, ir_node *ptr, ir_node *size,
3017 type *free_type, where_alloc where);
3019 /** Constructor for a Sync node.
3021 * Merges several memory values. The node assumes that a variable
3022 * either occurs only in one of the memories, or it contains the same
3023 * value in all memories where it occurs.
3024 * Adds the node to the block in current_ir_block.
3026 * @param *db A pointer for debug information.
3027 * @param arity The number of memories to synchronize.
3028 * @param **in An array of pointers to nodes that produce an output of type
3029 * memory. The constructor copies this array.
3031 ir_node *new_d_Sync (dbg_info* db, int arity, ir_node *in[]);
3034 /** Constructor for a Proj node.
3036 * Projects a single value out of a tuple. The parameter proj gives the
3037 * position of the value within the tuple.
3038 * Adds the node to the block in current_ir_block.
3040 * @param *db A pointer for deubug information.
3041 * @param arg A node producing a tuple.
3042 * @param *mode The mode of the value to project.
3043 * @param proj The position of the value in the tuple.
3045 ir_node *new_d_Proj (dbg_info* db, ir_node *arg, ir_mode *mode, long proj);
3048 /** Constructor for a defaultProj node.
3050 * Represents the default control flow of a Switch-Cond node.
3051 * Adds the node to the block in current_ir_block.
3053 * @param *db A pointer for debug information.
3054 * @param arg A node producing a tuple.
3055 * @param max_ proj The end position of the value in the tuple.
3057 ir_node *new_d_defaultProj (dbg_info* db, ir_node *arg, long max_proj);
3059 /** Constructor for a Tuple node.
3061 * This is an auxiliary node to replace a node that returns a tuple
3062 * without changing the corresponding Proj nodes.
3063 * Adds the node to the block in current_ir_block.
3065 * @param *db A pointer for debug information.
3066 * @param arity The number of tuple elements.
3067 * @param **in An array containing pointers to the nodes producing the tuple elements.
3069 ir_node *new_d_Tuple (dbg_info* db, int arity, ir_node *in[]);
3072 /** Constructor for a Id node.
3074 * This is an auxiliary node to replace a node that returns a single
3075 * value. Adds the node to the block in current_ir_block.
3077 * @param *db A pointer for debug information.
3078 * @param *val The operand to Id.
3079 * @param *mode The mode of *val.
3081 ir_node *new_d_Id (dbg_info* db, ir_node *val, ir_mode *mode);
3083 /** Constructor for a Bad node.
3085 * Returns the unique Bad node of the graph. The same as
3088 ir_node *new_d_Bad (void);
3090 /** Constructor for a Confirm node.
3092 * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3093 * Specifies constraints for a value. To support dataflow analyses.
3095 * Example: If the value never exceeds '100' this is expressed by placing a
3096 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3098 * @param *db A pointer for debug information.
3099 * @param *val The value we express a constraint for
3100 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3101 * @param cmp The compare operation.
3103 ir_node *new_d_Confirm (dbg_info* db, ir_node *val, ir_node *bound, pn_Cmp cmp);
3106 /** Constructor for an Unknown node.
3108 * Represents an arbitrary value. Places the node in
3111 * @param *m The mode of the unknown value.
3113 ir_node *new_d_Unknown(ir_mode *m);
3115 /** Constructor for a CallBegin node.
3117 * CallBegin represents control flow depending of the pointer value
3118 * representing the called method to the called methods. The
3119 * constructor copies the method pointer input from the passed Call
3120 * node.Adds the node to the block in current_ir_block.
3122 * @param *db A pointer for debug information.
3123 * @param *callee The call node visible in the intra procedural view.
3125 ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
3127 /** Constructor for an EndReg node.
3129 *Adds the node to the block in current_ir_block.
3131 * @param *db A pointer for debug information.
3133 ir_node *new_d_EndReg (dbg_info *db);
3135 /** Constructor for an EndExcept node.
3137 * Used to represent regular procedure end in interprocedual view.
3138 * Adds the node to the block in current_ir_block.
3140 * @param *db A pointer for debug information.
3142 ir_node *new_d_EndExcept(dbg_info *db);
3144 /** Constructor for a Break node.
3146 * Used to represent exceptional procedure end in interprocedural view.
3147 * Adds the node to the block in current_ir_block.
3149 * Break represents control flow to a single control successor just as Jmp.
3150 * The blocks separated by a break may not be concatenated by an optimization.
3151 * It is used for the interprocedural representation where blocks are parted
3152 * behind Call nodes to represent the control flow to called procedures.
3154 * @param *db A pointer for debug information.
3156 ir_node *new_d_Break (dbg_info *db);
3158 /** Constructor for a Filter node.
3160 * Constructor for a Filter node. Adds the node to the block in
3161 * current_ir_block. Filter is a node with two views used to
3162 * construct the interprocedural view. In intraprocedural view its
3163 * semantics are identical to the Proj node. In interprocedural view
3164 * the Filter performs the Phi operation on method parameters or
3165 * results. Other than a Phi a Filter node may not be removed if it
3166 * has only a single input.
3168 * The constructor builds the Filter in intraprocedural view.
3170 * @param *db A pointer for debug information.
3171 * @param *arg The tuple value to project from.
3172 * @param *mode The mode of the projected value.
3173 * @param proj The position in the tuple to project from.
3175 ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3178 /** Constructor for a NoMem node.
3180 * Returns the unique NoMem node of the graph. The same as
3183 ir_node *new_d_NoMem (void);
3185 /** Constructor for a Mux node.
3187 * Adds the node to the block in current_ir_block.
3189 * @param *db A pointer for debug information.
3190 * @param *sel The ir_node that calculates the boolean select.
3191 * @param *ir_true The ir_node that calculates the true result.
3192 * @param *ir_false The ir_node that calculates the false result.
3193 * @param *mode The mode of the node (and it_true and ir_false).
3195 ir_node *new_d_Mux (dbg_info *db, ir_node *sel,
3196 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3198 /*-----------------------------------------------------------------------*/
3199 /* The block oriented interface without debug support */
3200 /*-----------------------------------------------------------------------*/
3202 /* Needed from the interface with debug support:
3203 void set_cur_block (ir_node *target); */
3205 /** Constructor for a Block node.
3207 * Constructor for a Block node. Adds the block to the graph in
3208 * current_ir_graph. Constructs a Block with a fixed number of
3209 * predecessors. Does set current_block. Can be used with automatic
3210 * Phi node construction.
3212 * @param arity The number of control predecessors.
3213 * @param in An array of control predecessors. The length of
3214 * the array must be 'arity'.
3216 ir_node *new_Block(int arity, ir_node *in[]);
3218 /** Constructor for a Start node.
3220 * Adds the node to the block in current_ir_block.
3223 ir_node *new_Start (void);
3225 /** Constructor for an End node.
3227 * Adds the node to the block in current_ir_block.
3229 ir_node *new_End (void);
3231 /** Constructor for an EndReg node.
3233 * Used to represent regular procedure end in interprocedual view.
3234 * Adds the node to the block in current_ir_block.
3236 ir_node *new_EndReg (void);
3238 /** Constructor for an EndExpcept node.
3240 * Used to represent exceptional procedure end in interprocedural view.
3241 * Adds the node to the block in current_ir_block.
3243 ir_node *new_EndExcept(void);
3245 /** Constructor for a Jump node.
3247 * Adds the node to the block in current_ir_block.
3249 * Jmp represents control flow to a single control successor.
3251 ir_node *new_Jmp (void);
3253 /** Constructor for an IJmp node.
3255 * IJmp represents control flow to a single control successor not
3256 * statically known i.e. an indirect Jmp.
3258 * @param *tgt The ir node representing the target address.
3260 ir_node *new_IJmp (ir_node *tgt);
3262 /** Constructor for a Break node.
3263 * Break represents control flow to a single control successor just as Jmp.
3264 * The blocks separated by a break may not be concatenated by an optimization.
3265 * It is used for the interprocedural representation where blocks are parted
3266 * behind Call nodes to represent the control flow to called procedures.
3267 * Adds the node to the block in current_ir_block.
3269 ir_node *new_Break (void);
3271 /** Constructor for a Cond node.
3273 * If c is mode_b represents a conditional branch (if/else). If c is
3274 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
3275 * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3277 * This is not consistent: Input to Cond is Is, Proj has as proj number
3281 * @param *c The conditions parameter.Can be of mode b or I_u.
3283 ir_node *new_Cond (ir_node *c);
3285 /** Constructor for a Return node.
3287 * Returns the memory an zero or more return values. Only node that
3288 * can end regular control flow. Adds the node to the block in current_ir_block.
3290 * @param *store The state of memory.
3291 * @param arity Number of array indices.
3292 * @param *in Array with index inputs to the node.
3294 ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
3296 /**Constructor for a Raise node.
3298 * Adds the node to the block in current_ir_block.
3300 * @param *store The current memory.
3301 * @param *obj A pointer to the Except variable.
3303 ir_node *new_Raise (ir_node *store, ir_node *obj);
3305 /** Constructor for a Const node.
3307 * Constructor for a Const node. The constant represents a target
3308 * value. Sets the type information to type_unknown. (No more
3309 * supported: If tv is entity derives a somehow useful type.)
3310 * Adds the node to the block in current_ir_block.
3312 * @param *mode The mode of the operands and results.
3313 * @param *con Points to an entry in the constant table. This pointer is
3314 * added to the attributes of the node.
3316 ir_node *new_Const (ir_mode *mode, tarval *con);
3319 * Make a const from a long.
3320 * This is just convenience for the usual
3322 * new_Const(mode, tarval_from_long(mode, ...))
3325 * @param mode The mode for the const.
3326 * @param value The value of the constant.
3327 * @return A new const node.
3329 ir_node *new_Const_long(ir_mode *mode, long value);
3331 /** Constructor for a Const node.
3333 * Derives mode from passed type. */
3334 ir_node *new_Const_type(tarval *con, type *tp);
3336 /** Constructor for a SymConst node.
3338 * Adds the node to the block in current_ir_block.
3339 * This is the constructor for a symbolic constant.
3340 * There are four kinds of symbolic constants:
3341 * - type_tag The symbolic constant represents a type tag. The type the
3342 * tag stands for is given explicitly.
3343 * - size The symbolic constant represents the size of a type. The
3344 * type of which the constant represents the size is given
3346 * - addr_name The symbolic constant represents the address of an entity
3347 * (variable or method). The variable is indicated by a name
3348 * that is valid for linking.
3349 * - addr_ent The symbolic constant represents the address of an entity
3350 * (variable or method). The variable is given explicitly by
3353 * Inputs to the node:
3354 * No inputs except the block it belongs to.
3355 * Outputs of the node.
3356 * An unsigned integer (I_u) or a pointer (P).
3358 * @param value A type or a ident depending on the SymConst kind.
3359 * @param symkind The kind of the symbolic constant: symconst_type_tag, symconst_size or symconst_addr_name.
3361 ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind);
3363 /** Constructor for a simpelSel node.
3365 * This is a shortcut for the new_Sel() constructor. To be used for
3366 * Sel nodes that do not select from an array, i.e., have no index
3367 * inputs. It adds the two parameters 0, NULL.
3369 * @param *store The memory in which the object the entity should be selected from is allocated.
3370 * @param *objptr The object from that the Sel operation selects a single attribute out.
3371 * @param *ent The entity to select.
3373 ir_node *new_simpleSel(ir_node *store, ir_node *objptr, entity *ent);
3375 /** Constructor for a Sel node.
3377 * The select node selects an entity (field or method) from an entity
3378 * with a compound type. It explicitly specifies the entity selected.
3379 * Dynamically the node may select entities that overwrite the given
3380 * entity. If the selected entity is an array element entity the Sel
3381 * node takes the required array indices as inputs.
3382 * Adds the node to the block in current_ir_block.
3384 * @param *store The memory in which the object the entity should be selected
3385 * from is allocated.
3386 * @param *objptr A pointer to a compound entity the Sel operation selects a
3387 * single attribute from.
3388 * @param *n_index The number of array indices needed to select an array element entity.
3389 * @param *index[] If the compound entity is an array the indices of the selected
3390 * element entity. The constructor copies this array.
3391 * @param *ent The entity to select.
3393 ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
3396 /** Constructor for an InstOf node.
3398 * Adds the node to the block in current_ir_block.
3399 * For translating Java. Not supported as standard firm node.
3405 ir_node *new_InstOf (ir_node *store, ir_node *obj, type *ent);
3407 /** Constructor for a Call node.
3409 * Adds the node to the block in current_ir_block.
3410 * Represents all kinds of method and function calls.
3412 * @param *store The actual store.
3413 * @param *callee A pointer to the called procedure.
3414 * @param arity The number of procedure parameters.
3415 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3416 * @param *tp Type information of the procedure called.
3418 ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node *in[],
3421 /** Constructor for a CallBegin node.
3423 * Adds the node to the block in current_ir_block.
3425 * @param *callee A pointer to the called procedure.
3427 ir_node *new_CallBegin(ir_node *callee);
3429 /**Constructor for a Add node.
3431 * CallBegin represents control flow depending of the pointer value
3432 * representing the called method to the called methods. The
3433 * constructor copies the method pointer input from the passed Call
3434 * node.Adds the node to the block in current_ir_block.
3436 * @param *op1 The operand 1.
3437 * @param *op2 The operand 2.
3438 * @param *mode The mode of the operands and the result.
3440 ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
3442 /** Constructor for a Sub node.
3444 * Adds the node to the block in current_ir_block.
3446 * @param *op1 The operand 1.
3447 * @param *op2 The operand 2.
3448 * @param *mode The mode of the operands and the result.
3450 ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
3452 /** Constructor for a Minus node.
3454 * Adds the node to the block in current_ir_block.
3456 * @param *op The operand .
3457 * @param *mode The mode of the operand and the result.
3459 ir_node *new_Minus (ir_node *op, ir_mode *mode);
3462 * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3464 * @param *op1 The operand 1.
3465 * @param *op2 The operand 2.
3466 * @param *mode The mode of the operands and the result.
3468 ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
3470 /** Constructor for a Quot node.
3472 * Adds the node to the block in current_ir_block.
3474 * @param *memop The store needed to model exceptions
3475 * @param *op1 The operand 1.
3476 * @param *op2 The operand 2.
3478 ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
3480 /** Constructor for a DivMod node.
3482 * Adds the node to the block in current_ir_block.
3484 * @param *memop The store needed to model exceptions
3485 * @param *op1 The operand 1.
3486 * @param *op2 The operand 2.
3488 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
3490 /** Constructor for a Div node.
3492 * Adds the node to the block in current_ir_block.
3494 * @param *memop The store needed to model exceptions
3495 * @param *op1 The operand 1.
3496 * @param *op2 The operand 2.
3498 ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
3500 /** Constructor for a Mod node.
3502 * Adds the node to the block in current_ir_block.
3504 * @param *memop The store needed to model exceptions
3505 * @param *op1 The operand 1.
3506 * @param *op2 The operand 2.
3508 ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
3510 /** Constructor for a Abs node.
3512 * Adds the node to the block in current_ir_block.
3514 * @param *op The operand
3515 * @param *mode The mode of the operands and the result.
3517 ir_node *new_Abs (ir_node *op, ir_mode *mode);
3519 /** Constructor for a And node.
3521 * Adds the node to the block in current_ir_block.
3523 * @param *op1 The operand 1.
3524 * @param *op2 The operand 2.
3525 * @param *mode The mode of the operands and the result.
3527 ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
3530 * Constructor for a Or node. Adds the node to the block in current_ir_block.
3532 * @param *op1 The operand 1.
3533 * @param *op2 The operand 2.
3534 * @param *mode The mode of the operands and the result.
3536 ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
3539 * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3541 * @param *op1 The operand 1.
3542 * @param *op2 The operand 2.
3543 * @param *mode The mode of the operands and the results.
3545 ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
3547 /** Constructor for a Not node.
3549 * Adds the node to the block in current_ir_block.
3551 * @param *op The operand.
3552 * @param *mode The mode of the operand and the result.
3554 ir_node *new_Not (ir_node *op, ir_mode *mode);
3556 /** Constructor for a Shl node.
3558 * Adds the node to the block in current_ir_block.
3560 * @param *op The operand.
3561 * @param *k The number of bits to shift the operand .
3562 * @param *mode The mode of the operand and the result.
3564 ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
3567 * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3569 * @param *op The operand.
3570 * @param *k The number of bits to shift the operand .
3571 * @param *mode The mode of the operand and the result.
3573 ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
3575 /** Constructor for a Shrs node.
3577 * Adds the node to the block in current_ir_block.
3579 * @param *op The operand.
3580 * @param *k The number of bits to shift the operand .
3581 * @param *mode The mode of the operand and the result.
3583 ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
3585 /** Constructor for a Rot node.
3587 * Adds the node to the block in current_ir_block.
3589 * @param *op The operand.
3590 * @param *k The number of bits to rotate the operand.
3591 * @param *mode The mode of the operand.
3593 ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
3595 /** Constructor for a Cmp node.
3597 * Adds the node to the block in current_ir_block.
3599 * @param *op1 The operand 1.
3600 * @param *op2 The operand 2.
3602 ir_node *new_Cmp (ir_node *op1, ir_node *op2);
3604 /** Constructor for a Conv node.
3606 * Adds the node to the block in current_ir_block.
3608 * @param *op The operand.
3609 * @param *mode The mode of this the operand muss be converted .
3611 ir_node *new_Conv (ir_node *op, ir_mode *mode);
3613 /**Constructor for a Cast node.
3615 * Adds the node to the block in current_ir_block.
3616 * High level type cast
3618 * @param *op The operand.
3619 * @param *to_tp The type of this the operand muss be casted .
3621 ir_node *new_Cast (ir_node *op, type *to_tp);
3623 /** Constructor for a Phi node.
3625 * Adds the node to the block in current_ir_block.
3627 * @param arity The number of predecessors.
3628 * @param *in Array with predecessors.
3629 * @param *mode The mode of it's inputs and output.
3631 ir_node *new_Phi (int arity, ir_node *in[], ir_mode *mode);
3633 /** Constructor for a Load node.
3635 * @param *store The current memory.
3636 * @param *addr A pointer to the variable to be read in this memory.
3637 * @param *mode The mode of the value to be loaded.
3639 ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
3641 /** Constructor for a Store node.
3643 * @param *store The current memory.
3644 * @param *addr A pointer to the variable to be read in this memory.
3645 * @param *val The value to write to this variable.
3647 ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
3649 /**Constructor for a Alloc node.
3651 * The Alloc node extends the memory by space for an entity of type alloc_type.
3652 * Adds the node to the block in current_ir_block.
3654 * @param *store The memory which shall contain the new variable.
3655 * @param *size The number of bytes to allocate.
3656 * @param *alloc_type The type of the allocated variable.
3657 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3659 ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
3663 /**Constructor for a Free node.
3665 * Frees the memory occupied by the entity pointed to by the pointer
3666 * arg. Type indicates the type of the entity the argument points to.
3667 * Adds the node to the block in current_ir_block.
3669 * @param *store The memory which shall contain the new variable.
3670 * @param *ptr The pointer to the object to free.
3671 * @param *size The number of objects of type free_type to free in a sequence.
3672 * @param *free_type The type of the freed variable.
3673 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3675 ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
3676 type *free_type, where_alloc where);
3678 /** Constructor for a Sync node.
3680 * Merges several memory values. The node assumes that a variable
3681 * either occurs only in one of the memories, or it contains the same
3682 * value in all memories where it occurs.
3683 * Adds the node to the block in current_ir_block.
3685 * @param arity The number of memories to synchronize.
3686 * @param **in An array of pointers to nodes that produce an output of type
3687 * memory. The constructor copies this array.
3689 ir_node *new_Sync (int arity, ir_node *in[]);
3691 /** Constructor for a Proj node.
3693 * Projects a single value out of a tuple. The parameter proj gives the
3694 * position of the value within the tuple.
3695 * Adds the node to the block in current_ir_block.
3697 * @param arg A node producing a tuple.
3698 * @param *mode The mode of the value to project.
3699 * @param proj The position of the value in the tuple.
3701 ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
3703 /** Costructor for a Filter node.
3705 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
3706 * Filter is a node with two views used to construct the interprocedural view.
3707 * In intraprocedural view its semantics are identical to the Proj node.
3708 * In interprocedural view the Filter performs the Phi operation on method
3709 * parameters or results. Other than a Phi a Filter node may not be removed
3710 * if it has only a single input.
3712 * The constructor builds the Filter in intraprocedural view.
3714 * @param *arg The tuple value to project from.
3715 * @param *mode The mode of the projected value.
3716 * @param proj The position in the tuple to project from.
3718 ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
3720 /** Constructor for a defaultProj node.
3722 * Represents the default control flow of a Switch-Cond node.
3723 * Adds the node to the block in current_ir_block.
3725 * @param arg A node producing a tuple.
3726 * @param max_ proj The end position of the value in the tuple.
3728 ir_node *new_defaultProj (ir_node *arg, long max_proj);
3730 /** Constructor for a Tuple node.
3732 * This is an auxiliary node to replace a node that returns a tuple
3733 * without changing the corresponding Proj nodes.
3734 * Adds the node to the block in current_ir_block.
3736 * @param arity The number of tuple elements.
3737 * @param **in An array containing pointers to the nodes producing the tuple elements.
3739 ir_node *new_Tuple (int arity, ir_node *in[]);
3741 /** Constructor for an Id node.
3743 * This is an auxiliary node to replace a node that returns a single
3744 * value. Adds the node to the block in current_ir_block.
3746 * @param *val The operand to Id.
3747 * @param *mode The mode of *val.
3749 ir_node *new_Id (ir_node *val, ir_mode *mode);
3751 /** Constructor for a Bad node.
3753 * Returns the unique Bad node of the graph. The same as
3756 ir_node *new_Bad (void);
3758 /** Constructor for a Confirm node.
3760 * Specifies constraints for a value. To support dataflow analyses.
3761 * Adds the node to the block in current_ir_block.
3763 * Example: If the value never exceeds '100' this is expressed by placing a
3764 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3766 * @param *val The value we express a constraint for
3767 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3768 * @param cmp The compare operation.
3770 ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
3772 /** Constructor for an Unknown node.
3774 * Represents an arbitrary value. Places the node in
3777 * @param *m The mode of the unknown value.
3779 ir_node *new_Unknown(ir_mode *m);
3781 /** Constructor for a NoMem node.
3783 * Returns the unique NoMem node of the graph. The same as
3786 ir_node *new_NoMem (void);
3788 /** Constructor for a Mux node.
3790 * Adds the node to the block in current_ir_block.
3792 * @param *sel The ir_node that calculates the boolean select.
3793 * @param *ir_true The ir_node that calculates the true result.
3794 * @param *ir_false The ir_node that calculates the false result.
3795 * @param *mode The mode of the node (and it_true and ir_false).
3797 ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3799 /*---------------------------------------------------------------------*/
3800 /* The comfortable interface. */
3801 /* Supports automatic Phi node construction. */
3802 /* All routines of the block oriented interface except new_Block are */
3804 /*---------------------------------------------------------------------*/
3806 /** Create an immature block.
3808 * An immature block has an unknown number of predecessors. Predecessors
3809 * can be added with add_immBlock_pred(). Once all predecessors are
3810 * added the block must be matured.
3812 * Adds the block to the graph in current_ir_graph. Does set
3813 * current_block. Can be used with automatic Phi node construction.
3814 * This constructor can only be used if the graph is in
3817 ir_node *new_d_immBlock (dbg_info* db);
3818 ir_node *new_immBlock (void);
3820 /** Add a control flow edge to an immature block. */
3821 void add_immBlock_pred (ir_node *immblock, ir_node *jmp);
3823 /** Fix the number of predecessors of an immature block. */
3824 void mature_immBlock (ir_node *block);
3825 #define mature_cur_block() mature_immBlock(get_cur_block());
3828 /** Get the current value of a local variable.
3830 * Use this function to obtain the last definition of the local variable
3831 * associated with pos. Pos may not exceed the value passed as n_loc
3832 * to new_ir_graph. This call automatically inserts Phi nodes.
3834 * @param *db A pointer for debug information.
3835 * @param pos The position/id of the local variable.
3836 * @param *mode The mode of the value to get.
3838 ir_node *get_d_value (dbg_info* db, int pos, ir_mode *mode);
3839 ir_node *get_value (int pos, ir_mode *mode);
3841 /** Remark a new definition of a variable.
3843 * Use this function to remember a new definition of the value
3844 * associated with pos. Pos may not exceed the value passed as n_loc
3845 * to new_ir_graph. This call is needed to automatically inserts Phi
3848 * @param pos The position/id of the local variable.
3849 * @param *value The new value written to the local variable.
3851 void set_value (int pos, ir_node *value);
3853 /** Get the current memory state.
3855 * Use this function to obtain the last definition of the memory
3856 * state. This call automatically inserts Phi nodes for the memory
3859 ir_node *get_store (void);
3861 /** Remark a new definition of the memory state.
3863 * Use this function to remember a new definition of the memory state.
3864 * This call is needed to automatically inserts Phi nodes.
3866 * @param *store The new memory state.
3868 void set_store (ir_node *store);
3870 /** keep this node alive even if End is not control-reachable from it
3872 * @param ka The node to keep alive.
3874 void keep_alive (ir_node *ka);
3876 /** Returns the frame type of the current graph */
3877 type *get_cur_frame_type(void);
3880 /* --- initialize and finalize ir construction --- */
3882 /** Puts the graph into state "phase_high" */
3883 void irg_finalize_cons (ir_graph *irg);
3885 /** Puts the program and all graphs into state phase_high.
3887 * This also remarks, the construction of types is finished,
3888 * e.g., that no more subtypes will be added. */
3889 void irp_finalize_cons(void);
3891 /* --- Initialization --- */
3894 * This function is called, whenever a local variable is used before definition
3896 * @param irg the IR graph on which this happens
3897 * @param mode the mode of the local var
3898 * @param pos position chosen be the frontend for this variable (n_loc)
3900 * @return a firm node of mode @p mode that initializes the var at position pos
3903 * Do not return NULL
3904 * If this function is not set, FIRM will create a const node with tarval BAD.
3905 * Use set_irg_loc_description()/get_irg_loc_description() to assign additional
3906 * informations to local variables.
3908 typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
3910 # endif /* _IRCONS_H_ */