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_Const (ir_mode *mode, tarval *con);
257 * ir_node *new_SymConst (symconst_symbol value, symconst_kind kind);
258 * ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
259 * ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity,
260 * ir_node **in, entity *ent);
261 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity,
262 * ir_node **in, type_method *type);
263 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
264 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
265 * ir_node *new_Minus (ir_node *op, ir_mode *mode);
266 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
267 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
268 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
269 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
270 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
271 * ir_node *new_Abs (ir_node *op, ir_mode *mode);
272 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
273 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
274 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
275 * ir_node *new_Not (ir_node *op, ir_mode *mode);
276 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
277 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
278 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
279 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
280 * ir_node *new_Cmp (ir_node *op1, ir_node *op2);
281 * ir_node *new_Conv (ir_node *op, ir_mode *mode);
282 * ir_node *new_Cast (ir_node *op, ir_type *to_tp);
283 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
284 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
285 * ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
286 * where_alloc where);
287 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
288 * ir_type *free_type, where_alloc where);
289 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
290 * ir_node *new_NoMem (void);
291 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
292 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
293 * ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
294 * ir_node *new_Raise (ir_node *store, ir_node *obj);
295 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
297 * void add_immBlock_pred (ir_node *block, ir_node *jmp);
298 * void mature_immBlock (ir_node *block);
299 * void set_cur_block (ir_node *target);
300 * ir_node *get_value (int pos, ir_mode *mode);
301 * void set_value (int pos, ir_node *value);
302 * ir_node *get_store (void);
303 * void set_store (ir_node *store);
304 * keep_alive (ir_node ka)
306 * IR_NODES AND CONSTRUCTORS FOR IR_NODES
307 * =======================================
309 * All ir_nodes are defined by a common data structure. They are distinguished
310 * by their opcode and differ in the number of their attributes.
312 * The constructor for the block node sets current_block to itself.
313 * Const nodes are always added to the start block.
314 * All other constructors add the created node to the current_block.
315 * swich_block(block) allows to set the current block to block.
317 * Watch for my inconsistent use of input and predecessor (dataflow view)
318 * and `the node points to' (implementation view).
320 * The following description of the nodes lists four properties them if these
322 * - the parameters to the constructor
323 * - the inputs of the Firm node
324 * - the outputs of the Firm node
325 * - attributes to the node
329 * ir_node *new_immBlock (void)
330 * ----------------------------
332 * Creates a new block. Sets current_block to itself. When a new block is
333 * created it cannot be known how many predecessors this block will have in the
334 * control flow graph. Therefore the list of inputs can not be fixed at
335 * creation. Predecessors can be added with add_immBlock_pred (block, control flow
336 * operation). With every added predecessor the number of inputs to Phi nodes
339 * The block can be completed by mature_immBlock(block) if all predecessors are
340 * known. If several blocks are built at once, mature_immBlock can only be called
341 * after set_value has been called for all values that are life at the end
342 * of the block. This is necessary so that Phi nodes created mature_immBlock
343 * get the right predecessors in case of cyclic dependencies. If all set_values
344 * of this block are called after maturing it and before calling get_value
345 * in some block that is control flow dependent on this block, the construction
348 * Example for faulty ir construction: (draw the graph on a paper and you'll
351 * block_before_loop = new_block();
353 * mature_immBlock(block_before_loop);
354 * before2header = new_Jmp;
356 * loop_header = new_block ();
357 * header2body - new_Jmp();
359 * loop_body = new_block ();
360 * body2header = new_Jmp();
362 * add_immBlock_pred(loop_header, before2header);
363 * add_immBlock_pred(loop_header, body2header);
364 * add_immBlock_pred(loop_body, header2body);
366 * mature_immBlock(loop_header);
367 * mature_immBlock(loop_body);
369 * get_value(loop_body, x); // gets the Phi in loop_header
370 * set_value(loop_header, x); // sets the value the above get_value should
371 * // have returned!!!
373 * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
374 * should be called as early as possible, as afterwards the generation of Phi
375 * nodes is more efficient.
378 * There is an input for each control flow predecessor of the block.
379 * The input points to an instruction producing an output of type X.
380 * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
381 * possibly causing an exception. (Often the real predecessors are Projs.)
383 * Mode BB (R), all nodes belonging to this block should consume this output.
384 * As they are strict (except Block and Phi node) it is a necessary condition
385 * that the block node executed before any other node in this block executes.
387 * block.matured Indicates whether the block is mature.
389 * This attribute contains all local values valid in this
390 * block. This is needed to build the Phi nodes and removed
391 * if the graph is complete. This field is used by the
392 * internal construction algorithm and should not be accessed
396 * ir_node *new_Block (int arity, ir_node **in)
397 * --------------------------------------------
399 * Creates a new Block with the given list of predecessors. This block
400 * is mature. As other constructors calls optimization and vrfy for the
401 * block. If one of the predecessors is Unknown (as it has to be filled in
402 * later) optimizations are skipped. This is necessary to
403 * construct Blocks in loops. Leaving Unknown in the Block after finishing
404 * the construction may have strange effects, especially for interprocedural
405 * representation and analysis.
408 * CONTROL FLOW OPERATIONS
409 * -----------------------
411 * In each block there must be exactly one of the control flow
412 * operations Start, End, Jmp, Cond, Return or Raise. The output of a
413 * control flow operation points to the block to be executed next.
415 * ir_node *new_Start (void)
416 * -------------------------
418 * Creates a start node. Not actually needed public. There is only one such
419 * node in each procedure which is automatically created by new_ir_graph.
422 * No inputs except the block it belogns to.
424 * A tuple of 4 (5, 6) distinct values. These are labeled by the following
425 * projection numbers (pn_Start):
426 * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
427 * * pn_Start_M mode M, the global store
428 * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
429 * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
430 * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
433 * ir_node *new_End (void)
434 * -----------------------
436 * Creates an end node. Not actually needed public. There is only one such
437 * node in each procedure which is automatically created by new_ir_graph.
440 * No inputs except the block it belongs to.
444 * ir_node *new_Jmp (void)
445 * -----------------------
447 * Creates a Jmp node.
450 * The block the node belongs to
452 * Control flow to the next block.
454 * ir_node *new_IJmp (ir_node *tgt)
455 * -----------------------
457 * Creates an IJmp node.
460 * The node that represents the target jump address
462 * Control flow to an unknown target, must be pinned by
465 * ir_node *new_Cond (ir_node *c)
466 * ------------------------------
468 * Creates a Cond node. There are two versions of this node.
474 * A tuple of two control flows. The first is taken if the input is
475 * false, the second if it is true.
479 * A value of mode I_u. (i)
481 * A tuple of n control flows. If the Cond's input is i, control
482 * flow will procede along output i. If the input is >= n control
483 * flow proceeds along output n.
485 * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
486 * -------------------------------------------------------------
488 * The return node has as inputs the results of the procedure. It
489 * passes the control flow to the end_block.
495 * Control flow to the end block.
499 * ir_node *new_Const (ir_mode *mode, tarval *con)
500 * -----------------------------------------------
502 * Creates a constant in the constant table and adds a Const node
503 * returning this value to the start block.
506 * *mode The mode of the constant.
507 * *con Points to an entry in the constant table.
508 * This pointer is added to the attributes of
509 * the node (self->attr.con)
511 * No inputs except the block it belogns to.
513 * The constant value.
515 * attr.con A tarval* pointer to the proper entry in the constant
518 * ir_node *new_SymConst (union symconst_symbol value, symconst_addr_ent kind)
519 * ---------------------------------------------------------------------------
521 * There are three kinds of symbolic constants:
522 * symconst_type_tag The symbolic constant represents a type tag.
523 * symconst_size The symbolic constant represents the size of a class.
524 * symconst_addr_name Information for the linker, e.g. the name of a global
526 * To represent a pointer to an entity that is represented by an entity
527 * datastructure don't use
528 * new_SymConst((type_or_id*)get_entity_ld_ident(ent), symconst_addr_name);.
529 * Use a real const instead:
530 * new_SymConst(mode_P_mach, tarval_p_from_entity(ent));
531 * This makes the Constant independent of name changes of the entity due to
535 * kind The kind of the symbolic constant: type_tag, size or link_info.
536 * *type_or_id Points to the type the tag stands for or to the type
537 * whose size is represented by the constant or to an ident
538 * representing the linkage info.
541 * No inputs except the block it belogns to.
543 * An unsigned integer (I_u) or a pointer (P).
546 * attr.i.num The symconst_addr_ent, i.e. one of
549 * - symconst_addr_name
550 * If the attr.i.num is symconst_type_tag or symconst_size, the node contains an attribute
551 * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is.
552 * if it is linkage_ptr_info it contains
553 * attr.i.*ptrinfo, an ident holding information for the linker. The mode
554 * of the node is mode_P_mach.
558 * ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel)
559 * --------------------------------------------------------------------
562 * Selects an entity from a compound type. This entity can be a field or
566 * *store The memory in which the object the entity should be selected
568 * *frame The pointer to the object.
569 * *sel The entity to select.
572 * The memory containing the object.
573 * A pointer to the object.
574 * An unsigned integer.
576 * A pointer to the selected entity.
578 * attr.sel Pointer to the entity
581 * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
582 * --------------------------------------------------------------------------
586 * Selects a field from an array type. The entity has as owner the array, as
587 * type the arrays element type. The indices to access an array element are
591 * *store The memory in which the object the entity should be selected from
593 * *frame The pointer to the object.
594 * *arity number of array indices.
595 * *in array with index inputs to the node.
596 * *sel The entity to select.
599 * The memory containing the object.
600 * A pointer to the object.
601 * As much unsigned integer as there are array expressions.
603 * A pointer to the selected entity.
605 * attr.sel Pointer to the entity
607 * The constructors new_Sel and new_simpleSel generate the same ir nodes.
608 * simpleSel just sets the arity of the index inputs to zero.
611 * ARITHMETIC OPERATIONS
612 * ---------------------
614 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
615 * ----------------------------------------------------------------------------
619 * Creates a procedure call.
622 * *store The actual store.
623 * *callee A pointer to the called procedure.
624 * arity The number of procedure parameters.
625 * **in An array with the pointers to the parameters.
626 * The constructor copies this array.
627 * *type Type information of the procedure called.
630 * The store, the callee and the parameters.
632 * A tuple containing the eventually changed store and the procedure
635 * attr.call Contains the type information for the procedure.
638 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
639 * ------------------------------------------------------------
643 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
644 * ------------------------------------------------------------
648 * ir_node *new_Minus (ir_node *op, ir_mode *mode)
649 * -----------------------------------------------
651 * Unary Minus operations on integer and floating point values.
653 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
654 * ------------------------------------------------------------
658 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2)
659 * --------------------------------------------------------------
661 * Quot performs exact division of floating point numbers. It's mode
662 * is Tuple, the mode of the result must be annotated to the Proj
663 * that extracts the result of the arithmetic operations.
666 * The store needed to model exceptions and the two operands.
668 * A tuple contaning a memory and a execution for modeling exceptions
669 * and the result of the arithmetic operation.
671 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2)
672 * ----------------------------------------------------------------
674 * Performs Div and Mod on interger values.
677 * A tuple contaning a memory and a execution for modeling exceptions
678 * and the two result of the arithmetic operations.
680 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2)
681 * -------------------------------------------------------------
685 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2)
686 * -------------------------------------------------------------
690 * ir_node *new_Abs (ir_node *op, ir_mode *mode)
691 * ---------------------------------------------
695 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
696 * ------------------------------------------------------------
700 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
701 * -----------------------------------------------------------
705 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
706 * ------------------------------------------------------------
710 * ir_node *new_Not (ir_node *op, ir_mode *mode)
711 * ---------------------------------------------
713 * This node constructs a constant where all bits are set to one
714 * and a Eor of this constant and the operator. This simulates a
717 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
718 * ---------------------------------------------------------
722 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
723 * ---------------------------------------------------------
725 * Logic shift right, i.e., zero extended.
728 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
729 * ----------------------------------------------------------
731 * Arithmetic shift right, i.e., sign extended.
733 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
734 * ---------------------------------------------------------
736 * Rotates the operand to the (right??) by k bits.
738 * ir_node *new_Conv (ir_node *op, ir_mode *mode)
739 * ---------------------------------------------
741 * Mode conversion. For allowed conversions see UKA Tech Report
744 * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
745 * ---------------------------------------------
748 * The two values to be compared.
750 * A 16-tuple containing the results of the 16 different comparisons.
751 * The following is a list giving the comparisons and a projection
752 * number (pn_Cmp) to use in Proj nodes to extract the proper result.
756 * pn_Cmp_Le less or equal
758 * pn_Cmp_Ge greater of equal
759 * pn_Cmp_Lg less or greater
760 * pn_Cmp_Leg less, equal or greater = ordered
761 * pn_Cmp_Uo unordered
762 * pn_Cmp_Ue unordered or equal
763 * pn_Cmp_Ul unordered or less
764 * pn_Cmp_Ule unordered, less or equal
765 * pn_Cmp_Ug unordered or greater
766 * pn_Cmp_Uge unordered, greater or equal
767 * pn_Cmp_Ne unordered, less or greater = not equal
774 * In general, Phi nodes are automaitcally inserted. In some cases, if
775 * all predecessors of a block are known, an explicit Phi node constructor
776 * is needed. E.g., to construct a FIRM graph for a statement as
777 * a = (b==c) ? 2 : 5;
779 * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
780 * ---------------------------------------------------------
782 * Creates a Phi node. The in's order has to correspond to the order
783 * of in's of current_block. This is not checked by the library!
784 * If one of the predecessors is Unknown (as it has to be filled in
785 * later) optimizations are skipped. This is necessary to
786 * construct Phi nodes in loops. Leaving Unknown in the Phi after finishing
787 * the construction may have strange effects, especially for interprocedural
788 * representation and analysis.
791 * arity number of predecessors
792 * **in array with predecessors
793 * *mode The mode of it's inputs and output.
795 * A Phi node has as many inputs as the block it belongs to.
796 * Each input points to a definition of the same value on a
797 * different path in the control flow.
799 * The definition valid in this block.
801 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
802 * -----------------------------------------------------------------------------
804 * Creates a Mux node. This node implements the following semantic:
805 * If the sel node (which must be of mode_b) evaluates to true, its value is
806 * ir_true, else ir_false;
809 * OPERATIONS TO MANAGE MEMORY EXPLICITLY
810 * --------------------------------------
812 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode)
813 * ----------------------------------------------------------------
815 * The Load operation reads a value from memory.
818 * *store The current memory.
819 * *addr A pointer to the variable to be read in this memory.
820 * *mode The mode of the value to be loaded.
823 * The memory and a pointer to a variable in this memory.
825 * A tuple of the memory, a control flow to be taken in case of
826 * an exception and the loaded value.
828 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
829 * ----------------------------------------------------------------
831 * The Store operation writes a value to a variable in memory.
834 * The memory, a pointer to a variable in this memory and the value
835 * to write to this variable.
837 * A tuple of the changed memory and a control flow to be taken in
838 * case of an exception.
840 * ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
841 * -----------------------------------------------------------------------
845 * The Alloc node allocates a new variable. It can be specified whether the
846 * variable should be allocated to the stack or to the heap.
849 * *store The memory which shall contain the new variable.
850 * ** *size The number of bytes to allocate. Old. **
851 * *size We decided that the size easily can be derived from the type.
852 * This field is for allocating arrays, i.e., it gives the multiple
853 * of the size of alloc_type to allocate memory for.
854 * *alloc_type The type of the allocated variable.
855 * where Where to allocate the variable, either heap_alloc or stack_alloc.
858 * A memory and an unsigned integer.
860 * A tuple of the changed memory, a control flow to be taken in
861 * case of an exception and the pointer to the new variable.
863 * a.where Indicates where the variable is allocated.
864 * a.*type A pointer to the class the allocated data object
867 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
868 * -----------------------------------------------------------------------------------
872 * The Free node frees memory of the given variable.
875 * *store The memory which shall contain the new variable.
876 * *ptr The pointer to the object to free.
877 * *size The number of objects of type free_type to free in a sequence.
878 * *free_type The type of the freed variable.
879 * where Where the variable was allocated, either heap_alloc or stack_alloc.
882 * A memory, a pointer and an unsigned integer.
884 * The changed memory.
886 * f.*type A pointer to the type information of the freed data object.
890 * ir_node *new_Sync (int arity, ir_node **in)
891 * -------------------------------------------
893 * The Sync operation unifies several partial memory blocks. These blocks
894 * have to be pairwise disjunct or the values in common locations have to
895 * be identical. This operation allows to specify all operations that eventually
896 * need several partial memory blocks as input with a single entrance by
897 * unifying the memories with a preceding Sync operation.
900 * arity The number of memories to synchronize.
901 * **in An array of pointers to nodes that produce an output of
906 * The unified memory.
912 * ir_node *new_Bad (void)
913 * -----------------------
915 * Returns the unique Bad node current_ir_graph->bad.
916 * This node is used to express results of dead code elimination.
918 * ir_node *new_NoMem (void)
919 * -----------------------------------------------------------------------------------
921 * Returns the unique NoMem node current_ir_graph->no_mem.
922 * This node is used as input for operations that need a Memory, but do not
923 * change it like Div by const != 0, analyzed calls etc.
925 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
926 * ----------------------------------------------------------
928 * Selects one entry of a tuple. This is a hidden edge with attributes.
931 * *arg A node producing a tuple.
932 * *mode The mode of the value to project.
933 * proj The position of the value in the tuple.
939 * ir_node *new_Tuple (int arity, ir_node **in)
940 * --------------------------------------------
942 * Builds a Tuple from single values. This is needed to implement
943 * optimizations that remove a node that produced a tuple. The node can be
944 * replaced by the Tuple operation so that the following Proj nodes have not to
945 * be changed. (They are hard to find due to the implementation with pointers
946 * in only one direction.) The Tuple node is smaller than any other
947 * node, so that a node can be changed into a Tuple by just changing it's
948 * opcode and giving it a new in array.
951 * arity The number of tuple elements.
952 * **in An array containing pointers to the nodes producing the
955 * ir_node *new_Id (ir_node *val, ir_mode *mode)
956 * ---------------------------------------------
958 * The single output of the Id operation is it's input. Also needed
962 * HIGH LEVEL OPERATIONS
963 * ---------------------
965 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
966 * -----------------------------------------------------------------------------------
968 * Describes a high level block copy of a compound type from address src to
969 * address dst. Must be lowered to a Call to a runtime memory copy function.
972 * HIGH LEVEL OPERATIONS: Exception Support
973 * ----------------------------------------
974 * See TechReport 1999-14, chapter Exceptions.
976 * ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
977 * -----------------------------------------------------------------------------------
979 * Describes a high level type check. Must be lowered to a Call to a runtime check
982 * ir_node *new_Raise (ir_node *store, ir_node *obj)
983 * -------------------------------------------------
985 * Raises an exception. Unconditional change of control flow. Writes
986 * an explicit Except variable to memory to pass it to the exception
987 * handler. Must be lowered to a Call to a runtime check
992 * A pointer to the Except variable.
994 * A tuple of control flow and the changed memory state. The control flow
995 * points to the exception handler if it is definied in this procedure,
996 * else it points to the end_block.
998 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
999 * -----------------------------------------------------------------------------------
1001 * Describes a high level bounds check. Must be lowered to a Call to a runtime check
1005 * COPING WITH DATA OBJECTS
1006 * ========================
1008 * Two kinds of data objects have to be distinguished for generating
1009 * FIRM. First there are local variables other than arrays that are
1010 * known to be alias free. Second there are all other data objects.
1011 * For the first a common SSA representation is built, the second
1012 * are modeled by saving them to memory. The memory is treated as
1013 * a single local variable, the alias problem is hidden in the
1014 * content of this variable.
1016 * All values known in a Block are listed in the block's attribute,
1017 * block.**graph_arr which is used to automatically insert Phi nodes.
1018 * The following two funcions can be used to add a newly computed value
1019 * to the array, or to get the producer of a value, i.e., the current
1022 * inline void set_value (int pos, ir_node *value)
1023 * -----------------------------------------------
1025 * Has to be called for every assignment to a local variable. It
1026 * adds the value to the array of used values at position pos. Pos
1027 * has to be a unique identifier for an entry in the procedure's
1028 * definition table. It can be used to access the value again.
1029 * Requires current_block to be set correctly.
1031 * ir_node *get_value (int pos, ir_mode *mode)
1032 * -------------------------------------------
1034 * Returns the node defining the value referred to by pos. If the
1035 * value is not defined in this block a Phi node is generated and
1036 * all definitions reaching this Phi node are collected. It can
1037 * happen that the algorithm allocates an unnecessary Phi node,
1038 * e.g. if there is only one definition of this value, but this
1039 * definition reaches the currend block on several different
1040 * paths. This Phi node will be eliminated if optimizations are
1041 * turned on right after it's creation.
1042 * Requires current_block to be set correctly.
1044 * There are two special routines for the global store:
1046 * void set_store (ir_node *store)
1047 * -------------------------------
1049 * Adds the store to the array of known values at a reserved
1051 * Requires current_block to be set correctly.
1053 * ir_node *get_store (void)
1054 * -------------------------
1056 * Returns the node defining the actual store.
1057 * Requires current_block to be set correctly.
1060 * inline void keep_alive (ir_node *ka)
1061 * ------------------------------------
1063 * Keep this node alive because it is (might be) not in the control
1064 * flow from Start to End. Adds the node to the list in the end
1071 #include "firm_common.h"
1073 #include "dbginfo.h"
1075 /*-------------------------------------------------------------------------*/
1076 /* The raw interface */
1077 /*-------------------------------------------------------------------------*/
1079 /** Constructor for a Block node.
1081 * Constructs a mature block with the given predecessors. Use Unknown
1082 * nodes as predecessors to construct a block if the number of
1083 * predecessors is known, but not the predecessors themselves. This
1084 * constructor does not set current_block. It not be used with
1085 * automatic Phi node construction.
1087 * @param *db A Pointer for debug information.
1088 * @param irg The ir graph the block belongs to.
1089 * @param arity The number of control predecessors.
1090 * @param in[] An array of control predecessors. The length of
1091 * the array must be 'arity'. The constructor copies this array.
1093 ir_node *new_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1095 /** Constructor for a Start node.
1097 * @param *db A pointer for debug information.
1098 * @param *irg The ir graph the node belongs to.
1099 * @param *block The ir block the node belongs to.
1101 ir_node *new_rd_Start (dbg_info *db, ir_graph *irg, ir_node *block);
1103 /** Constructor for a End node.
1105 * @param *db A pointer for debug information.
1106 * @param *irg The ir graph the node belongs to.
1107 * @param *block The ir block the node belongs to.
1109 ir_node *new_rd_End (dbg_info *db, ir_graph *irg, ir_node *block);
1111 /** Constructor for a Jmp node.
1113 * Jmp represents control flow to a single control successor.
1115 * @param *db A pointer for debug information.
1116 * @param *irg The ir graph the node belongs to.
1117 * @param *block The ir block the node belongs to.
1119 ir_node *new_rd_Jmp (dbg_info *db, ir_graph *irg, ir_node *block);
1121 /** Constructor for an IJmp node.
1123 * IJmp represents control flow to a single control successor not
1124 * statically known i.e. an indirect Jmp.
1126 * @param *db A pointer for debug information.
1127 * @param *irg The ir graph the node belongs to.
1128 * @param *block The ir block the node belongs to.
1129 * @param *tgt The ir node representing the target address.
1131 ir_node *new_rd_IJmp (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *tgt);
1133 /** Constructor for a Break node.
1135 * Break represents control flow to a single control successor just as Jmp.
1136 * The blocks separated by a break may not be concatenated by an optimization.
1137 * It is used for the interprocedural representation where blocks are parted
1138 * behind Call nodes to represent the control flow to called procedures.
1140 * @param *db A pointer for debug information.
1141 * @param *irg The ir graph the node belong to.
1142 * @param *block The block the node belong to.
1144 ir_node *new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block);
1146 /** Constructor for a Cond node.
1148 * If c is mode_b represents a conditional branch (if/else). If c is
1149 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1150 * node, default Proj is 0.)
1152 * This is not consistent: Input to Cond is Is, Proj has as proj number
1155 * @param *db A pointer for debug information.
1156 * @param *irg The ir graph the node belongs to.
1157 * @param *block The ir block the node belongs to.
1158 * @param *c The conditions parameter. Can be of mode b or I_u.
1160 ir_node *new_rd_Cond (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
1162 /** Constructor for a Return node.
1164 * Returns the memory an zero or more return values. Only node that
1165 * can end regular control flow.
1167 * @param *db A pointer for debug information.
1168 * @param *irg The ir graph the node belongs to.
1169 * @param *block The ir block the node belongs to.
1170 * @param *store The state of memory.
1171 * @param arity Number of return values.
1172 * @param *in Array of length arity with return values. The constructor copies this array.
1174 ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
1175 ir_node *store, int arity, ir_node *in[]);
1177 /** Constructor for a Const_type node.
1179 * The constant represents a target value. This constructor sets high
1180 * level type information for the constant value.
1182 * @param *db A pointer for debug information.
1183 * @param *irg The ir graph the node belongs to.
1184 * @param *block The ir block the node belongs to.
1185 * @param *mode The mode of the operands and results.
1186 * @param *con Points to an entry in the constant table.
1187 * @param *tp The type of the constant.
1189 ir_node *new_rd_Const_type (dbg_info *db, ir_graph *irg, ir_node *block,
1190 ir_mode *mode, tarval *con, ir_type *tp);
1192 /** Constructor for a Const node.
1194 * Constructor for a Const node. The constant represents a target
1195 * value. Sets the type information to type_unknown. (No more
1196 * supported: If tv is entity derives a somehow useful type.)
1198 * @param *db A pointer for debug information.
1199 * @param *irg The ir graph the node belongs to.
1200 * @param *block The ir block the node belongs to.
1201 * @param *mode The mode of the operands and results.
1202 * @param *con Points to an entry in the constant table.
1204 ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block,
1205 ir_mode *mode, tarval *con);
1207 /** Constructor for a SymConst_type node.
1209 * This is the constructor for a symbolic constant.
1210 * There are four kinds of symbolic constants:
1211 * - type_tag The symbolic constant represents a type tag. The type the
1212 * tag stands for is given explicitly.
1213 * - size The symbolic constant represents the size of a type. The
1214 * type of which the constant represents the size is given
1216 * - addr_name The symbolic constant represents the address of an entity
1217 * (variable or method). The variable is indicated by a name
1218 * that is valid for linking.
1219 * - addr_ent The symbolic constant represents the address of an entity
1220 * (variable or method). The variable is given explicitly by
1223 * Inputs to the node:
1224 * No inputs except the block it belongs to.
1225 * Outputs of the node.
1226 * An unsigned integer (I_u) or a pointer (P).
1228 * Mention union in declaration so that the firmjni generator recognizes that
1229 * it can not cast the argument to an int.
1231 * @param *db A pointer for debug information.
1232 * @param *irg The ir graph the node belongs to.
1233 * @param *block The ir block the node belongs to.
1234 * @param symkind The kind of the symbolic constant: type_tag, size, addr_name or addr_ent.
1235 * @param value A type, entity or a ident depending on the SymConst kind.
1236 * @param tp The source type of the constant.
1238 ir_node *new_rd_SymConst_type (dbg_info *db, ir_graph *irg, ir_node *block, union symconst_symbol value,
1239 symconst_kind symkind, ir_type *tp);
1241 /** Constructor for a SymConst node.
1243 * Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */
1244 ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
1245 union symconst_symbol value, symconst_kind symkind);
1247 /** Constructor for a SymConst addr_ent node.
1249 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1250 * symconst_addr_ent.
1251 * Adds the SymConst to the start block of irg. */
1252 ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, entity *symbol, ir_type *tp);
1254 /** Constructor for a SymConst addr_name node.
1256 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1257 * symconst_addr_ent.
1258 * Adds the SymConst to the start block of irg. */
1259 ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, ir_type *tp);
1261 /** Constructor for a SymConst type_tag node.
1263 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1264 * symconst_addr_ent.
1265 * Adds the SymConst to the start block of irg. */
1266 ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
1268 /** Constructor for a SymConst size node.
1270 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1271 * symconst_addr_ent.
1272 * Adds the SymConst to the start block of irg. */
1273 ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
1275 /** Constructor for a simpleSel node.
1277 * This is a shortcut for the new_rd_Sel() constructor. To be used for
1278 * Sel nodes that do not select from an array, i.e., have no index
1279 * inputs. It adds the two parameters 0, NULL.
1281 * @param *db A pointer for debug information.
1282 * @param *irg The ir graph the node belongs to.
1283 * @param *block The ir block the node belongs to.
1284 * @param *store The memory in which the object the entity should be
1285 * selected from is allocated.
1286 * @param *objptr The object from that the Sel operation selects a
1287 * single attribute out.
1288 * @param *ent The entity to select.
1290 ir_node *new_rd_simpleSel (dbg_info *db, ir_graph *irg, ir_node *block,
1291 ir_node *store, ir_node *objptr, entity *ent);
1293 /** Constructor for a Sel node.
1295 * The select node selects an entity (field or method) from an entity
1296 * with a compound type. It explicitly specifies the entity selected.
1297 * Dynamically the node may select entities that overwrite the given
1298 * entity. If the selected entity is an array element entity the Sel
1299 * node takes the required array indices as inputs.
1301 * @param *db A pointer for debug information.
1302 * @param *irg The ir graph the node belongs to.
1303 * @param *block The ir block the node belongs to.
1304 * @param *store The memory in which the object the entity should be selected
1305 * from is allocated.
1306 * @param *objptr A pointer to a compound entity the Sel operation selects a
1307 * single attribute from.
1308 * @param *n_index The number of array indices needed to select an array element entity.
1309 * @param *index[] If the compound entity is an array the indices of the selected
1310 * element entity. The constructor copies this array.
1311 * @param *ent The entity to select.
1313 ir_node *new_rd_Sel (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1314 ir_node *objptr, int n_index, ir_node *index[], entity *ent);
1316 /** Constructor for a Call node.
1318 * Represents all kinds of method and function calls.
1320 * @param *db A pointer for debug information.
1321 * @param *irg The ir graph the node belongs to.
1322 * @param *block The ir block the node belongs to.
1323 * @param *store The current memory state.
1324 * @param *callee A pointer to the called procedure.
1325 * @param arity The number of procedure parameters.
1326 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1327 * @param *tp Type information of the procedure called.
1329 ir_node *new_rd_Call (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1330 ir_node *callee, int arity, ir_node *in[], ir_type *tp);
1332 /** Constructor for a Add node.
1334 * @param *db A pointer for debug information.
1335 * @param *irg The ir graph the node belongs to.
1336 * @param *block The ir block the node belongs to.
1337 * @param *op1 The first operand.
1338 * @param *op2 The second operand.
1339 * @param *mode The mode of the operands and the result.
1341 ir_node *new_rd_Add (dbg_info *db, ir_graph *irg, ir_node *block,
1342 ir_node *op1, ir_node *op2, ir_mode *mode);
1344 /** Constructor for a Sub node.
1346 * @param *db A pointer for debug information.
1347 * @param *irg The ir graph the node belongs to.
1348 * @param *block The ir block the node belongs to.
1349 * @param *op1 The first operand.
1350 * @param *op2 The second operand.
1351 * @param *mode The mode of the operands and the result.
1353 ir_node *new_rd_Sub (dbg_info *db, ir_graph *irg, ir_node *block,
1354 ir_node *op1, ir_node *op2, ir_mode *mode);
1356 /** Constructor for a Minus node.
1358 * @param *db A pointer for debug information.
1359 * @param *irg The ir graph the node belongs to.
1360 * @param *block The ir block the node belongs to.
1361 * @param *op The operand .
1362 * @param *mode The mode of the operand and the result.
1364 ir_node *new_rd_Minus (dbg_info *db, ir_graph *irg, ir_node *block,
1365 ir_node *op, ir_mode *mode);
1367 /** Constructor for a Mul node.
1369 * @param *db A pointer for debug information.
1370 * @param *irg The ir graph the node belongs to.
1371 * @param *block The ir block the node belongs to.
1372 * @param *op1 The first operand.
1373 * @param *op2 The second operand.
1374 * @param *mode The mode of the operands and the result.
1376 ir_node *new_rd_Mul (dbg_info *db, ir_graph *irg, ir_node *block,
1377 ir_node *op1, ir_node *op2, ir_mode *mode);
1379 /** Constructor for a Quot node.
1381 * @param *db A pointer for debug information.
1382 * @param *irg The ir graph the node belongs to.
1383 * @param *block The ir block the node belongs to.
1384 * @param *memop The store needed to model exceptions
1385 * @param *op1 The first operand.
1386 * @param *op2 The second operand.
1388 ir_node *new_rd_Quot (dbg_info *db, ir_graph *irg, ir_node *block,
1389 ir_node *memop, ir_node *op1, ir_node *op2);
1391 /** Constructor for a DivMod node.
1393 * @param *db A pointer for debug information.
1394 * @param *irg The ir graph the node belongs to.
1395 * @param *block The ir block the node belongs to.
1396 * @param *memop The store needed to model exceptions
1397 * @param *op1 The first operand.
1398 * @param *op2 The second operand.
1400 ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
1401 ir_node *memop, ir_node *op1, ir_node *op2);
1403 /** Constructor for a Div node.
1405 * @param *db A pointer for debug information.
1406 * @param *irg The ir graph the node belongs to.
1407 * @param *block The ir block the node belongs to.
1408 * @param *memop The store needed to model exceptions
1409 * @param *op1 The first operand.
1410 * @param *op2 The second operand.
1412 ir_node *new_rd_Div (dbg_info *db, ir_graph *irg, ir_node *block,
1413 ir_node *memop, ir_node *op1, ir_node *op2);
1415 /** Constructor for a Mod node.
1417 * @param *db A pointer for debug information.
1418 * @param *irg The ir graph the node belongs to.
1419 * @param *block The ir block the node belongs to.
1420 * @param *memop The store needed to model exceptions
1421 * @param *op1 The first operand.
1422 * @param *op2 The second operand.
1424 ir_node *new_rd_Mod (dbg_info *db, ir_graph *irg, ir_node *block,
1425 ir_node *memop, ir_node *op1, ir_node *op2);
1427 /** Constructor for a Abs node.
1429 * @param *db A pointer for debug information.
1430 * @param *irg The ir graph the node belongs to.
1431 * @param *block The ir block the node belongs to.
1432 * @param *op The operand
1433 * @param *mode The mode of the operands and the result.
1435 ir_node *new_rd_Abs (dbg_info *db, ir_graph *irg, ir_node *block,
1436 ir_node *op, ir_mode *mode);
1438 /** Constructor for a And node.
1440 * @param *db A pointer for debug information.
1441 * @param *irg The ir graph the node belongs to.
1442 * @param *block The ir block the node belongs to.
1443 * @param *op1 The first operand.
1444 * @param *op2 The second operand.
1445 * @param *mode The mode of the operands and the result.
1447 ir_node *new_rd_And (dbg_info *db, ir_graph *irg, ir_node *block,
1448 ir_node *op1, ir_node *op2, ir_mode *mode);
1450 /** Constructor for a Or node.
1452 * @param *db A pointer for debug information.
1453 * @param *irg The ir graph the node belongs to.
1454 * @param *block The ir block the node belongs to.
1455 * @param *op1 The first operand.
1456 * @param *op2 The second operand.
1457 * @param *mode The mode of the operands and the result.
1459 ir_node *new_rd_Or (dbg_info *db, ir_graph *irg, ir_node *block,
1460 ir_node *op1, ir_node *op2, ir_mode *mode);
1462 /** Constructor for a Eor node.
1464 * @param *db A pointer for debug information.
1465 * @param *irg The ir graph the node belongs to.
1466 * @param *block The ir block the node belongs to.
1467 * @param *op1 The first operand.
1468 * @param *op2 The second operand.
1469 * @param *mode The mode of the operands and the results.
1471 ir_node *new_rd_Eor (dbg_info *db, ir_graph *irg, ir_node *block,
1472 ir_node *op1, ir_node *op2, ir_mode *mode);
1474 /** Constructor for a Not node.
1476 * @param *db A pointer for debug information.
1477 * @param *irg The ir graph the node belongs to.
1478 * @param *block The ir block the node belongs to.
1479 * @param *op The operand.
1480 * @param *mode The mode of the operand and the result.
1482 ir_node *new_rd_Not (dbg_info *db, ir_graph *irg, ir_node *block,
1483 ir_node *op, ir_mode *mode);
1485 /** Constructor for a Cmp node.
1487 * @param *db A pointer for debug information.
1488 * @param *irg The ir graph the node belongs to.
1489 * @param *block The ir block the node belongs to.
1490 * @param *op1 The first operand.
1491 * @param *op2 The second operand.
1493 ir_node *new_rd_Cmp (dbg_info *db, ir_graph *irg, ir_node *block,
1494 ir_node *op1, ir_node *op2);
1496 /** Constructor for a Shl node.
1498 * @param *db A pointer for debug information.
1499 * @param *irg The ir graph the node belongs to.
1500 * @param *block The ir block the node belongs to.
1501 * @param *op The operand.
1502 * @param *k The number of bits to shift the operand .
1503 * @param *mode The mode of the operand and the result.
1505 ir_node *new_rd_Shl (dbg_info *db, ir_graph *irg, ir_node *block,
1506 ir_node *op, ir_node *k, ir_mode *mode);
1508 /** Constructor for a Shr node.
1510 * @param *db A pointer for debug information.
1511 * @param *irg The ir graph the node belongs to.
1512 * @param *block The ir block the node belongs to.
1513 * @param *op The operand.
1514 * @param *k The number of bits to shift the operand .
1515 * @param *mode The mode of the operand and the result.
1517 ir_node *new_rd_Shr (dbg_info *db, ir_graph *irg, ir_node *block,
1518 ir_node *op, ir_node *k, ir_mode *mode);
1520 /** Constructor for a Shrs node.
1522 * @param *db A pointer for debug information.
1523 * @param *irg The ir graph the node belongs to.
1524 * @param *block The ir block the node belongs to.
1525 * @param *op The operand.
1526 * @param *k The number of bits to shift the operand.
1527 * @param *mode The mode of the operand and the result.
1529 ir_node *new_rd_Shrs (dbg_info *db, ir_graph *irg, ir_node *block,
1530 ir_node *op, ir_node *k, ir_mode *mode);
1532 /** Constructor for a Rot node.
1534 * @param *db A pointer for debug information.
1535 * @param *irg The ir graph the node belongs to.
1536 * @param *block The ir block the node belongs to.
1537 * @param *op The operand.
1538 * @param *k The number of bits to rotate the operand.
1539 * @param *mode The mode of the operand.
1541 ir_node *new_rd_Rot (dbg_info *db, ir_graph *irg, ir_node *block,
1542 ir_node *op, ir_node *k, ir_mode *mode);
1545 /** Constructor for a Conv node.
1547 * @param *db A pointer for debug information.
1548 * @param *irg The ir graph the node belongs to.
1549 * @param *block The ir block the node belongs to.
1550 * @param *op The operand.
1551 * @param *mode The mode of this the operand muss be converted .
1553 ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block,
1554 ir_node *op, ir_mode *mode);
1556 /** Constructor for a Cast node.
1558 * High level type cast.
1560 * @param *db A pointer for debug information.
1561 * @param *irg The ir graph the node belongs to.
1562 * @param *block The ir block the node belongs to.
1563 * @param *op The operand.
1564 * @param *to_tp The type of this the operand muss be casted .
1566 ir_node *new_rd_Cast (dbg_info *db, ir_graph *irg, ir_node *block,
1567 ir_node *op, ir_type *to_tp);
1569 /** Constructor for a Phi node.
1571 * @param *db A pointer for debug information.
1572 * @param *irg The ir graph the node belongs to.
1573 * @param *block The ir block the node belongs to.
1574 * @param arity The number of predecessors
1575 * @param *in[] Array with predecessors. The constructor copies this array.
1576 * @param *mode The mode of it's inputs and output.
1578 ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
1579 ir_node *in[], ir_mode *mode);
1581 /** Constructor for a Load node.
1583 * @param *db A pointer for debug information.
1584 * @param *irg The ir graph the node belongs to.
1585 * @param *block The ir block the node belongs to.
1586 * @param *store The current memory
1587 * @param *adr A pointer to the variable to be read in this memory.
1588 * @param *mode The mode of the value to be loaded.
1590 ir_node *new_rd_Load (dbg_info *db, ir_graph *irg, ir_node *block,
1591 ir_node *store, ir_node *adr, ir_mode *mode);
1593 /** Constructor for a Store node.
1595 * @param *db A pointer for debug information.
1596 * @param *irg The ir graph the node belongs to.
1597 * @param *block The ir block the node belongs to.
1598 * @param *store The current memory
1599 * @param *adr A pointer to the variable to be read in this memory.
1600 * @param *val The value to write to this variable.
1602 ir_node *new_rd_Store (dbg_info *db, ir_graph *irg, ir_node *block,
1603 ir_node *store, ir_node *adr, ir_node *val);
1605 /** Constructor for a Alloc node.
1607 * The Alloc node extends the memory by space for an entity of type alloc_type.
1609 * @param *db A pointer for debug information.
1610 * @param *irg The ir graph the node belongs to.
1611 * @param *block The ir block the node belongs to.
1612 * @param *store The memory which shall contain the new variable.
1613 * @param *size The number of bytes to allocate.
1614 * @param *alloc_type The type of the allocated variable.
1615 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
1617 ir_node *new_rd_Alloc (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1618 ir_node *size, ir_type *alloc_type, where_alloc where);
1620 /** Constructor for a Free node.
1622 * Frees the memory occupied by the entity pointed to by the pointer
1623 * arg. Type indicates the type of the entity the argument points to.
1625 * @param *db A pointer for debug information.
1626 * @param *irg The ir graph the node belongs to.
1627 * @param *block The ir block the node belongs to.
1628 * @param *store The memory which shall contain the new variable.
1629 * @param *ptr The pointer to the object to free.
1630 * @param *size The number of objects of type free_type to free in a sequence.
1631 * @param *free_type The type of the freed variable.
1632 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
1634 ir_node *new_rd_Free (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1635 ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
1637 /** Constructor for a Sync node.
1639 * Merges several memory values. The node assumes that a variable
1640 * either occurs only in one of the memories, or it contains the same
1641 * value in all memories where it occurs.
1643 * @param *db A pointer for debug information.
1644 * @param *irg The ir graph the node belongs to.
1645 * @param *block The ir block the node belongs to.
1646 * @param arity The number of memories to synchronize.
1647 * @param *in[] An array of pointers to nodes that produce an output of type
1648 * memory. The constructor copies this array.
1650 ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
1652 /** Constructor for a Proj node.
1654 * Projects a single value out of a tuple. The parameter proj gives the
1655 * position of the value within the tuple.
1657 * @param *db A pointer for debug information.
1658 * @param *irg The ir graph the node belongs to.
1659 * @param *block The ir block the node belongs to.
1660 * @param arg A node producing a tuple. The node must have mode_T.
1661 * @param *mode The mode of the value to project.
1662 * @param proj The position of the value in the tuple.
1664 ir_node *new_rd_Proj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1665 ir_mode *mode, long proj);
1667 /** Constructor for a defaultProj node.
1669 * Represents the default control flow of a Switch-Cond node.
1671 * @param *db A pointer for debug information.
1672 * @param *irg The ir graph the node belongs to.
1673 * @param *block The ir block the node belongs to.
1674 * @param arg A node producing a tuple.
1675 * @param max_proj The end position of the value in the tuple.
1677 ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1680 /** Constructor for a Tuple node.
1682 * This is an auxiliary node to replace a node that returns a tuple
1683 * without changing the corresponding Proj nodes.
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 arity The number of tuple elements.
1689 * @param *in[] An array containing pointers to the nodes producing the tuple
1690 * elements. The constructor copies this array.
1692 ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
1693 int arity, ir_node *in[]);
1695 /** Constructor for a Id node.
1697 * This is an auxiliary node to replace a node that returns a single
1700 * @param *db A pointer for debug information.
1701 * @param *irg The ir graph the node belongs to.
1702 * @param *block The ir block the node belongs to.
1703 * @param *val The value
1704 * @param *mode The mode of *val.
1706 ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
1707 ir_node *val, ir_mode *mode);
1709 /** Constructor for a Bad node.
1711 * Returns the unique Bad node of the graph. The same as
1714 * @param *irg The ir graph the node belongs to.
1716 ir_node *new_rd_Bad (ir_graph *irg);
1718 /** Constructor for a Confirm node.
1720 * Specifies constraints for a value. To support dataflow analyses.
1722 * Example: If the value never exceeds '100' this is expressed by placing a
1723 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
1725 * @param *irg The ir graph the node belong to.
1726 * @param *block The ir block the node belong to.
1727 * @param *db A pointer for debug information.
1728 * @param *val The value we express a constraint for
1729 * @param *bound The value to compare against. Must be a firm node, typically a constant.
1730 * @param cmp The compare operation.
1732 ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
1733 ir_node *val, ir_node *bound, pn_Cmp cmp);
1735 /** Constructor for an Unknown node.
1737 * Represents an arbitrary value. Places the node in the start block.
1739 * @param *irg The ir graph the node belongs to.
1740 * @param *m The mode of the unknown value.
1742 ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
1744 /** Constructor for a CallBegin node.
1746 * CallBegin represents control flow depending of the pointer value
1747 * representing the called method to the called methods. The
1748 * constructor copies the method pointer input from the passed Call
1751 * @param *db A pointer for debug information.
1752 * @param *irg The ir graph the node belong to.
1753 * @param *block The block the node belong to.
1754 * @param *callee The call node visible in the intra procedural view.
1756 ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
1758 /** Constructor for a EndReg node.
1760 * Used to represent regular procedure end in interprocedual view.
1762 * @param *db A pointer for debug information.
1763 * @param *irg The ir graph the node belong to.
1764 * @param *block The block the node belong to.
1766 ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
1768 /** Constructor for a EndExcept node.
1770 * Used to represent exceptional procedure end in interprocedural view.
1772 * @param *db A pointer for debug information.
1773 * @param *irg The ir graph the node belong to.
1774 * @param *block The block the node belong to.
1776 ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
1778 /** Constructor for a Filter node.
1780 * Adds the node to the block in current_ir_block. Filter is a node
1781 * with two views used to construct the interprocedural view. In
1782 * intraprocedural view its semantics are identical to the Proj node.
1783 * In interprocedural view the Filter performs the Phi operation on
1784 * method parameters or results. Other than a Phi a Filter node may
1785 * not be removed if it has only a single input.
1787 * The constructor builds the Filter in intraprocedural view.
1789 * @param *db A pointer for debug information.
1790 * @param *irg The ir graph the node belong to.
1791 * @param *block The block the node belong to.
1792 * @param *arg The tuple value to project from.
1793 * @param *mode The mode of the projected value.
1794 * @param proj The position in the tuple to project from.
1796 ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1797 ir_mode *mode, long proj);
1799 /** Constructor for a NoMem node.
1801 * Returns the unique NoMem node of the graph. The same as
1804 * @param *irg The ir graph the node belongs to.
1806 ir_node *new_rd_NoMem (ir_graph *irg);
1808 /** Constructor for a Mux node.
1810 * @param *db A pointer for debug information.
1811 * @param *irg The ir graph the node belong to.
1812 * @param *block The block the node belong to.
1813 * @param *sel The ir_node that calculates the boolean select.
1814 * @param *ir_true The ir_node that calculates the true result.
1815 * @param *ir_false The ir_node that calculates the false result.
1816 * @param *mode The mode of the node (and it_true and ir_false).
1818 ir_node *new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block,
1819 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
1821 /** Constructor for a CopyB node.
1823 * @param *db A pointer for debug information.
1824 * @param *irg The ir graph the node belong to.
1825 * @param *block The block the node belong to.
1826 * @param *store The current memory
1827 * @param *dst The ir_node that represents the destination address.
1828 * @param *src The ir_node that represents the source address.
1829 * @param *data_type The type of the copied data
1831 ir_node *new_rd_CopyB(dbg_info *db, ir_graph *irg, ir_node *block,
1832 ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
1834 /** Constructor for a InstOf node.
1836 * A High-Level Type check.
1838 * @param *db A pointer for debug information.
1839 * @param *irg The ir graph the node belongs to.
1840 * @param *block The ir block the node belongs to.
1841 * @param *store The memory in which the object the entity should be selected
1842 * from is allocated.
1843 * @param *objptr A pointer to a object of a class type.
1844 * @param *type The type of which objptr must be.
1846 ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1847 ir_node *objptr, ir_type *type);
1849 /** Constructor for a Raise node.
1851 * A High-Level Exception throw.
1853 * @param *db A pointer for debug information.
1854 * @param *irg The ir graph the node belongs to.
1855 * @param *block The ir block the node belongs to.
1856 * @param *store The current memory.
1857 * @param *obj A pointer to the Except variable.
1859 ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
1860 ir_node *store, ir_node *obj);
1862 /** Constructor for a Bound node.
1864 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
1866 * @param *db A pointer for debug information.
1867 * @param *irg The ir graph the node belong to.
1868 * @param *block The block the node belong to.
1869 * @param *store The current memory
1870 * @param *idx The ir_node that represents an index.
1871 * @param *lower The ir_node that represents the lower bound for the index.
1872 * @param *upper The ir_node that represents the upper bound for the index.
1874 ir_node *new_rd_Bound(dbg_info *db, ir_graph *irg, ir_node *block,
1875 ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
1877 /*-------------------------------------------------------------------------*/
1878 /* The raw interface without debug support */
1879 /*-------------------------------------------------------------------------*/
1881 /** Constructor for a Block node.
1883 * Constructs a mature block with the given predecessors. Use Unknown
1884 * nodes as predecessors to construct a block if the number of
1885 * predecessors is known, but not the predecessors themselves. This
1886 * constructor does not set current_block. It not be used with
1887 * automatic Phi node construction.
1890 * @param irg The ir graph the block belongs to.
1891 * @param arity The number of control predecessors.
1892 * @param in[] An array of control predecessors. The length of
1893 * the array must be 'arity'. The constructor copies this array.
1895 ir_node *new_r_Block (ir_graph *irg, int arity, ir_node *in[]);
1897 /** Constructor for a Start node.
1899 * @param *irg The ir graph the node belongs to.
1900 * @param *block The ir block the node belongs to.
1902 ir_node *new_r_Start (ir_graph *irg, ir_node *block);
1904 /** Constructor for a End node.
1906 * @param *irg The ir graph the node belongs to.
1907 * @param *block The ir block the node belongs to.
1909 ir_node *new_r_End (ir_graph *irg, ir_node *block);
1911 /** Constructor for a Jmp node.
1913 * Jmp represents control flow to a single control successor.
1915 * @param *irg The ir graph the node belongs to.
1916 * @param *block The ir block the node belongs to.
1918 ir_node *new_r_Jmp (ir_graph *irg, ir_node *block);
1920 /** Constructor for an IJmp node.
1922 * IJmp represents control flow to a single control successor not
1923 * statically known i.e. an indirect Jmp.
1925 * @param *irg The ir graph the node belongs to.
1926 * @param *block The ir block the node belongs to.
1927 * @param *tgt The ir node representing the target address.
1929 ir_node *new_r_IJmp (ir_graph *irg, ir_node *block, ir_node *tgt);
1931 /** Constructor for a Cond node.
1933 * If c is mode_b represents a conditional branch (if/else). If c is
1934 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1935 * node, default Proj is 0.)
1937 * This is not consistent: Input to Cond is Is, Proj has as proj number
1940 * @param *irg The ir graph the node belongs to.
1941 * @param *block The ir block the node belongs to.
1942 * @param *c The conditions parameter.Can be of mode b or I_u.
1944 ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c);
1946 /** Constructor for a Return node.
1948 * Returns the memory an zero or more return values. Only node that
1949 * can end regular control flow.
1951 * @param *irg The ir graph the node belongs to.
1952 * @param *block The ir block the node belongs to.
1953 * @param *store The state of memory.
1954 * @param arity Number of array indices.
1955 * @param *in[] Array with index inputs to the node. The constructor copies this array.
1957 ir_node *new_r_Return (ir_graph *irg, ir_node *block,
1958 ir_node *store, int arity, ir_node *in[]);
1960 /** Constructor for a Const node.
1962 * Constructor for a Const node. The constant represents a target
1963 * value. Sets the type information to type_unknown. (No more
1964 * supported: If tv is entity derives a somehow useful type.)
1966 * @param *irg The ir graph the node belongs to.
1967 * @param *block The ir block the node belongs to.
1968 * @param *mode The mode of the operands and the results.
1969 * @param *con Points to an entry in the constant table.
1971 ir_node *new_r_Const (ir_graph *irg, ir_node *block,
1972 ir_mode *mode, tarval *con);
1974 /** Constructor for a Const node.
1976 * Constructor for a Const node. The constant represents a target
1977 * value. Sets the type information to type_unknown. (No more
1978 * supported: If tv is entity derives a somehow useful type.)
1980 * @param *irg The ir graph the node belongs to.
1981 * @param *block The ir block the node belongs to.
1982 * @param *mode The mode of the operands and the results.
1983 * @param value A value from which the tarval is made.
1985 ir_node *new_r_Const_long(ir_graph *irg, ir_node *block,
1986 ir_mode *mode, long value);
1988 /** Constructor for a Const_type node.
1990 * The constant represents a target value. This constructor sets high
1991 * level type information for the constant value.
1993 * @param *irg The ir graph the node belongs to.
1994 * @param *block The ir block the node belongs to.
1995 * @param *mode The mode of the operands and results.
1996 * @param *con Points to an entry in the constant table.
1997 * @param *tp The type of the constant.
1999 ir_node *new_r_Const_type(ir_graph *irg, ir_node *block,
2000 ir_mode *mode, tarval *con, ir_type *tp);
2002 /** Constructor for a SymConst node.
2004 * This is the constructor for a symbolic constant.
2005 * There are four kinds of symbolic constants:
2006 * - type_tag The symbolic constant represents a type tag. The type the
2007 * tag stands for is given explicitly.
2008 * - size The symbolic constant represents the size of a type. The
2009 * type of which the constant represents the size is given
2011 * - addr_name The symbolic constant represents the address of an entity
2012 * (variable or method). The variable is indicated by a name
2013 * that is valid for linking.
2014 * - addr_ent The symbolic constant represents the address of an entity
2015 * (variable or method). The variable is given explicitly by
2018 * Inputs to the node:
2019 * No inputs except the block it belongs to.
2020 * Outputs of the node.
2021 * An unsigned integer (I_u) or a pointer (P).
2023 * @param *irg The ir graph the node belongs to.
2024 * @param *block The ir block the node belongs to.
2025 * @param value A type, entity or a ident depending on the SymConst kind.
2026 * @param symkind The kind of the symbolic constant: type_tag, size or link_info.
2028 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
2029 union symconst_symbol value, symconst_kind symkind);
2031 /** Constructor for a simpleSel node.
2033 * This is a shortcut for the new_d_Sel() constructor. To be used for
2034 * Sel nodes that do not select from an array, i.e., have no index
2035 * inputs. It adds the two parameters 0, NULL.
2037 * @param *irg The ir graph the node belongs to.
2038 * @param *block The ir block the node belongs to.
2039 * @param *store The memory in which the object the entity should be selected
2040 * from is allocated.
2041 * @param *objptr The object from that the Sel operation selects a
2042 * single attribute out.
2043 * @param *ent The entity to select.
2045 ir_node *new_r_simpleSel(ir_graph *irg, ir_node *block, ir_node *store,
2046 ir_node *objptr, entity *ent);
2048 /** Constructor for a Sel node.
2050 * The select node selects an entity (field or method) from an entity
2051 * with a compound type. It explicitly specifies the entity selected.
2052 * Dynamically the node may select entities that overwrite the given
2053 * entity. If the selected entity is an array element entity the Sel
2054 * node takes the required array indices as inputs.
2056 * @param *irg The ir graph the node belongs to.
2057 * @param *block The ir block the node belongs to.
2058 * @param *store The memory in which the object the entity should be selected
2059 * from is allocated.
2060 * @param *objptr A pointer to a compound entity the Sel operation selects a
2061 * single attribute from.
2062 * @param *n_index The number of array indices needed to select an array element entity.
2063 * @param *index[] If the compound entity is an array the indices of the selected
2064 * element entity. The constructor copies this array.
2065 * @param *ent The entity to select.
2067 ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store,
2068 ir_node *objptr, int n_index, ir_node *index[],
2071 /** Constructor for a Call node.
2073 * Represents all kinds of method and function calls.
2075 * @param *irg The ir graph the node belongs to.
2076 * @param *block The ir block the node belongs to.
2077 * @param *store The actual store.
2078 * @param *callee A pointer to the called procedure.
2079 * @param arity The number of procedure parameters.
2080 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2081 * @param *tp Type information of the procedure called.
2083 ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
2084 ir_node *callee, int arity, ir_node *in[],
2087 /** Constructor for a Add node.
2089 * @param *irg The ir graph the node belongs to.
2090 * @param *block The ir block the node belongs to.
2091 * @param *op1 The first operand.
2092 * @param *op2 The second operand.
2093 * @param *mode The mode of the operands and the result.
2095 ir_node *new_r_Add (ir_graph *irg, ir_node *block,
2096 ir_node *op1, ir_node *op2, ir_mode *mode);
2099 * Constructor for a Sub node.
2101 * @param *irg The ir graph the node belongs to.
2102 * @param *block The ir block the node belongs to.
2103 * @param *op1 The first operand.
2104 * @param *op2 The second operand.
2105 * @param *mode The mode of the operands and the results.
2107 ir_node *new_r_Sub (ir_graph *irg, ir_node *block,
2108 ir_node *op1, ir_node *op2, ir_mode *mode);
2110 /** Constructor for a Minus 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 operand and the result.
2117 ir_node *new_r_Minus (ir_graph *irg, ir_node *block,
2118 ir_node *op, ir_mode *mode);
2119 /** Constructor for a Mul node.
2121 * @param *irg The ir graph the node belongs to.
2122 * @param *block The ir block the node belongs to.
2123 * @param *op1 The first operand.
2124 * @param *op2 The second operand.
2125 * @param *mode The mode of the operands and the result.
2127 ir_node *new_r_Mul (ir_graph *irg, ir_node *block,
2128 ir_node *op1, ir_node *op2, ir_mode *mode);
2130 /** Constructor for a Quot node.
2132 * @param *irg The ir graph the node belongs to.
2133 * @param *block The ir block the node belongs to.
2134 * @param *memop The store needed to model exceptions
2135 * @param *op1 The first operand.
2136 * @param *op2 The second operand.
2138 ir_node *new_r_Quot (ir_graph *irg, ir_node *block,
2139 ir_node *memop, ir_node *op1, ir_node *op2);
2141 /** Constructor for a DivMod node.
2143 * @param *irg The ir graph the node belongs to.
2144 * @param *block The ir block the node belongs to.
2145 * @param *memop The store needed to model exceptions
2146 * @param *op1 The first operand.
2147 * @param *op2 The second operand.
2149 ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
2150 ir_node *memop, ir_node *op1, ir_node *op2);
2152 /** Constructor for a Div node.
2154 * @param *irg The ir graph the node belongs to.
2155 * @param *block The ir block the node belongs to.
2156 * @param *memop The store needed to model exceptions
2157 * @param *op1 The first operand.
2158 * @param *op2 The second operand.
2160 ir_node *new_r_Div (ir_graph *irg, ir_node *block,
2161 ir_node *memop, ir_node *op1, ir_node *op2);
2163 /** Constructor for a Mod node.
2165 * @param *irg The ir graph the node belongs to.
2166 * @param *block The ir block the node belongs to.
2167 * @param *memop The store needed to model exceptions
2168 * @param *op1 The first operand.
2169 * @param *op2 The second operand.
2171 ir_node *new_r_Mod (ir_graph *irg, ir_node *block,
2172 ir_node *memop, ir_node *op1, ir_node *op2);
2174 /** Constructor for a Abs node.
2176 * @param *irg The ir graph the node belongs to.
2177 * @param *block The ir block the node belongs to.
2178 * @param *op The operand
2179 * @param *mode The mode of the operands and the result.
2181 ir_node *new_r_Abs (ir_graph *irg, ir_node *block,
2182 ir_node *op, ir_mode *mode);
2184 /** Constructor for a And node.
2186 * @param *irg The ir graph the node belongs to.
2187 * @param *block The ir block the node belongs to.
2188 * @param *op1 The first operand.
2189 * @param *op2 The second operand.
2190 * @param *mode The mode of the operands and the result.
2192 ir_node *new_r_And (ir_graph *irg, ir_node *block,
2193 ir_node *op1, ir_node *op2, ir_mode *mode);
2195 /** Constructor for a Or node.
2197 * @param *irg The ir graph the node belongs to.
2198 * @param *block The ir block the node belongs to.
2199 * @param *op1 The first operand.
2200 * @param *op2 The second operand.
2201 * @param *mode The mode of the operands and the result.
2203 ir_node *new_r_Or (ir_graph *irg, ir_node *block,
2204 ir_node *op1, ir_node *op2, ir_mode *mode);
2206 /** Constructor for a Eor node.
2208 * @param *irg The ir graph the node belongs to.
2209 * @param *block The ir block the node belongs to.
2210 * @param *op1 The first operand.
2211 * @param *op2 The second operand.
2212 * @param *mode The mode of the operands and the results.
2214 ir_node *new_r_Eor (ir_graph *irg, ir_node *block,
2215 ir_node *op1, ir_node *op2, ir_mode *mode);
2217 /** Constructor for a Not node.
2219 * @param *irg The ir graph the node belongs to.
2220 * @param *block The ir block the node belongs to.
2221 * @param *op The operand.
2222 * @param *mode The mode of the operand and the result.
2224 ir_node *new_r_Not (ir_graph *irg, ir_node *block,
2225 ir_node *op, ir_mode *mode);
2227 /** Constructor for a Cmp node.
2229 * @param *irg The ir graph the node belongs to.
2230 * @param *block The ir block the node belongs to.
2231 * @param *op1 The first operand.
2232 * @param *op2 The second operand.
2234 ir_node *new_r_Cmp (ir_graph *irg, ir_node *block,
2235 ir_node *op1, ir_node *op2);
2237 /** Constructor for a Shl node.
2239 * @param *irg The ir graph the node belongs to.
2240 * @param *block The ir block the node belongs to.
2241 * @param *op The operand.
2242 * @param *k The number of bits to shift the operand .
2243 * @param *mode The mode of the operand and the result.
2245 ir_node *new_r_Shl (ir_graph *irg, ir_node *block,
2246 ir_node *op, ir_node *k, ir_mode *mode);
2248 /** Constructor for a Shr node.
2250 * @param *irg The ir graph the node belongs to.
2251 * @param *block The ir block the node belongs to.
2252 * @param *op The operand.
2253 * @param *k The number of bits to shift the operand .
2254 * @param *mode The mode of the operand and the result.
2256 ir_node *new_r_Shr (ir_graph *irg, ir_node *block,
2257 ir_node *op, ir_node *k, ir_mode *mode);
2260 * Constructor for a Shrs node.
2262 * @param *irg The ir graph the node belongs to.
2263 * @param *block The ir block the node belongs to.
2264 * @param *op The operand.
2265 * @param *k The number of bits to shift the operand.
2266 * @param *mode The mode of the operand and the result.
2268 ir_node *new_r_Shrs (ir_graph *irg, ir_node *block,
2269 ir_node *op, ir_node *k, ir_mode *mode);
2271 /** Constructor for a Rot node.
2273 * @param *irg The ir graph the node belongs to.
2274 * @param *block The ir block the node belongs to.
2275 * @param *op The operand.
2276 * @param *k The number of bits to rotate the operand.
2277 * @param *mode The mode of the operand.
2279 ir_node *new_r_Rot (ir_graph *irg, ir_node *block,
2280 ir_node *op, ir_node *k, ir_mode *mode);
2282 /** Constructor for a Conv node.
2284 * @param *irg The ir graph the node belongs to.
2285 * @param *block The ir block the node belongs to.
2286 * @param *op The operand.
2287 * @param *mode The mode of this the operand muss be converted .
2289 ir_node *new_r_Conv (ir_graph *irg, ir_node *block,
2290 ir_node *op, ir_mode *mode);
2292 /** Constructor for a Cast node.
2294 * High level type cast
2296 * @param *irg The ir graph the node belongs to.
2297 * @param *block The ir block the node belongs to.
2298 * @param *op The operand.
2299 * @param *to_tp The type of this the operand muss be casted .
2301 ir_node *new_r_Cast (ir_graph *irg, ir_node *block,
2302 ir_node *op, ir_type *to_tp);
2304 /** Constructor for a Phi node.
2306 * @param *irg The ir graph the node belongs to.
2307 * @param *block The ir block the node belongs to.
2308 * @param arity The number of predecessors
2309 * @param *in[] Array with predecessors. The constructor copies this array.
2310 * @param *mode The mode of it's inputs and output.
2312 ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity,
2313 ir_node *in[], ir_mode *mode);
2315 /** Constructor for a Load node.
2317 * @param *irg The ir graph the node belongs to.
2318 * @param *block The ir block the node belongs to.
2319 * @param *store The current memory
2320 * @param *adr A pointer to the variable to be read in this memory.
2321 * @param *mode The mode of the value to be loaded.
2323 ir_node *new_r_Load (ir_graph *irg, ir_node *block,
2324 ir_node *store, ir_node *adr, ir_mode *mode);
2326 /** Constructor for a Store node.
2328 * @param *irg The ir graph the node belongs to.
2329 * @param *block The ir block the node belongs to.
2330 * @param *store The current memory
2331 * @param *adr A pointer to the variable to be read in this memory.
2332 * @param *val The value to write to this variable.
2334 ir_node *new_r_Store (ir_graph *irg, ir_node *block,
2335 ir_node *store, ir_node *adr, ir_node *val);
2337 /** Constructor for a Alloc node.
2339 * The Alloc node extends the memory by space for an entity of type alloc_type.
2341 * @param *irg The ir graph the node belongs to.
2342 * @param *block The ir block the node belongs to.
2343 * @param *store The memory which shall contain the new variable.
2344 * @param *size The number of bytes to allocate.
2345 * @param *alloc_type The type of the allocated variable.
2346 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2348 ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store,
2349 ir_node *size, ir_type *alloc_type, where_alloc where);
2351 /** Constructor for a Free node.
2353 * Frees the memory occupied by the entity pointed to by the pointer
2354 * arg. Type indicates the type of the entity the argument points to.
2356 * @param *irg The ir graph the node belongs to.
2357 * @param *block The ir block the node belongs to.
2358 * @param *store The memory which shall contain the new variable.
2359 * @param *ptr The pointer to the object to free.
2360 * @param *size The number of objects of type free_type to free in a sequence.
2361 * @param *free_type The type of the freed variable.
2362 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2364 ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store,
2365 ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
2367 /** Constructor for a Sync node.
2369 * Merges several memory values. The node assumes that a variable
2370 * either occurs only in one of the memories, or it contains the same
2371 * value in all memories where it occurs.
2373 * @param *irg The ir graph the node belongs to.
2374 * @param *block The ir block the node belongs to.
2375 * @param arity The number of memories to synchronize.
2376 * @param *in[] An array of pointers to nodes that produce an output of type memory.
2377 * The constructor copies this array.
2379 ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2381 /** Constructor for a Proj node.
2383 * Projects a single value out of a tuple. The parameter proj gives the
2384 * position of the value within the tuple.
2386 * @param *irg The ir graph the node belongs to.
2387 * @param *block The ir block the node belongs to.
2388 * @param arg A node producing a tuple.
2389 * @param *mode The mode of the value to project.
2390 * @param proj The position of the value in the tuple.
2392 ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg,
2393 ir_mode *mode, long proj);
2395 /** Constructor for a defaultProj node.
2397 * Represents the default control flow of a Switch-Cond node.
2399 * @param *irg The ir graph the node belongs to.
2400 * @param *block The ir block the node belongs to.
2401 * @param arg A node producing a tuple.
2402 * @param max_proj The end position of the value in the tuple.
2404 ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj);
2407 /** Constructor for a Tuple node.
2409 * This is an auxiliary node to replace a node that returns a tuple
2410 * without changing the corresponding Proj nodes.
2412 * @param *irg The ir graph the node belongs to.
2413 * @param *block The ir block the node belongs to.
2414 * @param arity The number of tuple elements.
2415 * @param *in[] An array containing pointers to the nodes producing the tuple elements.
2416 * The constructor copies this array.
2418 ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2420 /** Constructor for a Id node.
2422 * This is an auxiliary node to replace a node that returns a single
2425 * @param *irg The ir graph the node belongs to.
2426 * @param *block The ir block the node belongs to.
2427 * @param *val The operand to Id.
2428 * @param *mode The mode of *val.
2430 ir_node *new_r_Id (ir_graph *irg, ir_node *block,
2431 ir_node *val, ir_mode *mode);
2433 /** Constructor for a Bad node.
2435 * Returns the unique Bad node of the graph. The same as
2438 * @param *irg The ir graph the node belongs to.
2441 ir_node *new_r_Bad (ir_graph *irg);
2443 /** Constructor for a Confirm node.
2445 * Specifies constraints for a value. To support dataflow analyses.
2447 * Example: If the value never exceeds '100' this is expressed by placing a
2448 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
2450 * @param *irg The ir graph the node belong to.
2451 * @param *block The ir block the node belong to.
2452 * @param *val The value we express a constraint for
2453 * @param *bound The value to compare against. Must be a firm node, typically a constant.
2454 * @param cmp The compare operation.
2456 ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
2457 ir_node *val, ir_node *bound, pn_Cmp cmp);
2459 /** Constructor for a Unknown node.
2461 * Represents an arbitrary value. Places the node in
2464 * @param *irg The ir graph the node belongs to.
2465 * @param *m The mode of the unknown value.
2467 ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2469 /** Constructor for a CallBegin node.
2471 * CallBegin represents control flow depending of the pointer value
2472 * representing the called method to the called methods. The
2473 * constructor copies the method pointer input from the passed Call
2476 * @param *irg The ir graph the node belong to.
2477 * @param *block The block the node belong to.
2478 * @param *callee The call node visible in the intra procedural view.
2480 ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
2482 /** Constructor for a EndReg node.
2484 * Used to represent regular procedure end in interprocedual view.
2486 * @param *irg The ir graph the node belong to.
2487 * @param *block The block the node belong to.
2489 ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
2491 /** Constructor for a EndExcept node.
2493 * Used to represent exceptional procedure end in interprocedural view.
2495 * @param *irg The ir graph the node belong to.
2496 * @param *block The block the node belong to.
2498 ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
2500 /** Constructor for a Break node.
2502 * Break represents control flow to a single control successor just as Jmp.
2503 * The blocks separated by a break may not be concatenated by an optimization.
2504 * It is used for the interprocedural representation where blocks are parted
2505 * behind Call nodes to represent the control flow to called procedures.
2507 * @param *irg The ir graph the node belong to.
2508 * @param *block The block the node belong to.
2510 ir_node *new_r_Break (ir_graph *irg, ir_node *block);
2512 /** Constructor for a Filter node.
2514 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
2515 * Filter is a node with two views used to construct the interprocedural view.
2516 * In intraprocedural view its semantics are identical to the Proj node.
2517 * In interprocedural view the Filter performs the Phi operation on method
2518 * parameters or results. Other than a Phi a Filter node may not be removed
2519 * if it has only a single input.
2521 * The constructor builds the Filter in intraprocedural view.
2523 * @param *irg The ir graph the node belong to.
2524 * @param *block The block the node belong to.
2525 * @param *arg The tuple value to project from.
2526 * @param *mode The mode of the projected value.
2527 * @param proj The position in the tuple to project from.
2529 ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
2530 ir_mode *mode, long proj);
2532 /** Constructor for a NoMem node.
2534 * Returns the unique NoMem node of the graph. The same as
2537 * @param *irg The ir graph the node belongs to.
2539 ir_node *new_r_NoMem (ir_graph *irg);
2541 /** Constructor for a Mux node.
2543 * @param *irg The ir graph the node belong to.
2544 * @param *block The block the node belong to.
2545 * @param *sel The ir_node that calculates the boolean select.
2546 * @param *ir_true The ir_node that calculates the true result.
2547 * @param *ir_false The ir_node that calculates the false result.
2548 * @param *mode The mode of the node (and it_true and ir_false).
2550 ir_node *new_r_Mux (ir_graph *irg, ir_node *block,
2551 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2553 /** Constructor for a CopyB node.
2555 * @param *irg The ir graph the node belong to.
2556 * @param *block The block the node belong to.
2557 * @param *store The current memory
2558 * @param *dst The ir_node that represents the destination address.
2559 * @param *src The ir_node that represents the source address.
2560 * @param *data_type The type of the copied data
2562 ir_node *new_r_CopyB(ir_graph *irg, ir_node *block,
2563 ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
2565 /** Constructor for a InstOf node.
2567 * A High-Level Type check.
2569 * @param *irg The ir graph the node belongs to.
2570 * @param *block The ir block the node belongs to.
2571 * @param *store The memory in which the object the entity should be selected
2572 * from is allocated.
2573 * @param *objptr A pointer to a object of a class type.
2574 * @param *type The type of which objptr must be.
2576 ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *store,
2577 ir_node *objptr, ir_type *type);
2579 /** Constructor for a Raise node.
2581 * A High-Level Exception throw.
2583 * @param *irg The ir graph the node belongs to.
2584 * @param *block The ir block the node belongs to.
2585 * @param *store The current memory.
2586 * @param *obj A pointer to the Except variable.
2588 ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
2589 ir_node *store, ir_node *obj);
2591 /** Constructor for a Bound node.
2593 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
2595 * @param *irg The ir graph the node belong to.
2596 * @param *block The block the node belong to.
2597 * @param *store The current memory
2598 * @param *idx The ir_node that represents an index.
2599 * @param *lower The ir_node that represents the lower bound for the index.
2600 * @param *upper The ir_node that represents the upper bound for the index.
2602 ir_node *new_r_Bound(ir_graph *irg, ir_node *block,
2603 ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
2605 /*-----------------------------------------------------------------------*/
2606 /* The block oriented interface */
2607 /*-----------------------------------------------------------------------*/
2609 /** Sets the current block in which the following constructors place the
2610 * nodes they construct.
2612 * @param target The new current block.
2614 void set_cur_block (ir_node *target);
2616 /** Returns the current block of the current graph. */
2617 ir_node *get_cur_block(void);
2619 /** Returns the fixed nodes of the current graph. */
2620 #define get_cur_end_block() get_irg_end_block(current_ir_graph)
2621 #define get_cur_end() get_irg_end(current_ir_graph)
2622 #define get_cur_start_block() get_irg_start_block(current_ir_graph)
2623 #define get_cur_start() get_irg_start(current_ir_graph)
2625 /** Constructor for a Block node.
2627 * Adds the block to the graph in current_ir_graph. Constructs a Block
2628 * with a fixed number of predecessors. Does set current_block. Can
2629 * be used with automatic Phi node construction.
2631 * @param *db A Pointer for debug information.
2632 * @param arity The number of control predecessors.
2633 * @param in[] An array of control predecessors. The length of
2634 * the array must be 'arity'.
2636 ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
2638 /** Constructor for a Start node.
2640 * Adds the node to the block in current_ir_block.
2642 * @param *db A pointer for debug information.
2644 ir_node *new_d_Start (dbg_info *db);
2646 /** Constructor for a End node.
2648 * Adds the node to the block in current_ir_block.
2650 * @param *db A pointer for debug information.
2652 ir_node *new_d_End (dbg_info *db);
2654 /** Constructor for a Jmp node.
2656 * Adds the node to the block in current_ir_block.
2658 * Jmp represents control flow to a single control successor.
2660 * @param *db A pointer for debug information.
2662 ir_node *new_d_Jmp (dbg_info *db);
2664 /** Constructor for an IJmp node.
2666 * IJmp represents control flow to a single control successor not
2667 * statically known i.e. an indirect Jmp.
2669 * @param *db A pointer for debug information.
2670 * @param *tgt The ir node representing the target address.
2672 ir_node *new_d_IJmp (dbg_info *db, ir_node *tgt);
2674 /** Constructor for a Cond node.
2676 * Adds the node to the block in current_ir_block.
2678 * If c is mode_b represents a conditional branch (if/else). If c is
2679 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2680 * node, default Proj is 0.)
2682 * This is not consistent: Input to Cond is Is, Proj has as proj number
2685 * @param *db A pointer for debug information.
2686 * @param *c The conditions parameter.Can be of mode b or I_u.
2688 ir_node *new_d_Cond (dbg_info *db, ir_node *c);
2690 /** Constructor for a Return node.
2692 * Adds the node to the block in current_ir_block.
2694 * Returns the memory an zero or more return values. Only node that
2695 * can end regular control flow.
2697 * @param *db A pointer for debug information.
2698 * @param *store The state of memory.
2699 * @param arity Number of array indices.
2700 * @param *in Array with index inputs to the node.
2702 ir_node *new_d_Return (dbg_info *db, ir_node *store, int arity, ir_node *in[]);
2704 /** Constructor for a Const_type node.
2706 * Adds the node to the block in current_ir_block.
2708 * The constant represents a target value. This constructor sets high
2709 * level type information for the constant value.
2711 * @param *db A pointer for debug information.
2712 * @param *mode The mode of the operands and results.
2713 * @param *con Points to an entry in the constant table. This pointer is
2714 added to the attributes of the node.
2715 * @param *tp The type of the constant.
2717 ir_node *new_d_Const_type (dbg_info *db, ir_mode *mode, tarval *con, ir_type *tp);
2719 /** Constructor for a Const node.
2721 * Adds the node to the block in current_ir_block.
2723 * Constructor for a Const node. The constant represents a target
2724 * value. Sets the type information to type_unknown. (No more
2725 * supported: If tv is entity derives a somehow useful type.)
2727 * @param *db A pointer for debug information.
2728 * @param *mode The mode of the operands and results.
2729 * @param *con Points to an entry in the constant table. This pointer is added
2730 * to the attributes of the node.
2732 ir_node *new_d_Const (dbg_info *db, ir_mode *mode, tarval *con);
2734 /** Constructor for a SymConst_type node.
2736 * Adds the node to the block in current_ir_block.
2737 * This is the constructor for a symbolic constant.
2738 * There are four kinds of symbolic constants:
2739 * - type_tag The symbolic constant represents a type tag. The type the
2740 * tag stands for is given explicitly.
2741 * - size The symbolic constant represents the size of a type. The
2742 * type of which the constant represents the size is given
2744 * - addr_name The symbolic constant represents the address of an entity
2745 * (variable or method). The variable is indicated by a name
2746 * that is valid for linking.
2747 * - addr_ent The symbolic constant represents the address of an entity
2748 * (variable or method). The variable is given explicitly by
2751 * Inputs to the node:
2752 * No inputs except the block it belongs to.
2753 * Outputs of the node.
2754 * An unsigned integer (I_u) or a pointer (P).
2756 * @param *db A pointer for debug information.
2757 * @param value A type, entity or ident depending on the SymConst kind.
2758 * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_size
2759 * or symconst_addr_name.
2760 * @param tp The source type of the constant.
2762 ir_node *new_d_SymConst_type (dbg_info *db, union symconst_symbol value, symconst_kind kind, ir_type *tp);
2764 /** Constructor for a SymConst node.
2766 * Same as new_d_SymConst_type, except that it sets the type to type_unknown. */
2767 ir_node *new_d_SymConst (dbg_info *db, union symconst_symbol value, symconst_kind kind);
2769 /** Constructor for a simpleSel node.
2771 * This is a shortcut for the new_d_Sel() constructor. To be used for
2772 * Sel nodes that do not select from an array, i.e., have no index
2773 * inputs. It adds the two parameters 0, NULL.
2775 * @param *db A pointer for debug information.
2776 * @param *store The memory in which the object the entity should be
2777 * selected from is allocated.
2778 * @param *objptr The object from that the Sel operation selects a
2779 * single attribute out.
2780 * @param *ent The entity to select.
2782 ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr, entity *ent);
2784 /** Constructor for a Sel node.
2786 * The select node selects an entity (field or method) from an entity
2787 * with a compound type. It explicitly specifies the entity selected.
2788 * Dynamically the node may select entities that overwrite the given
2789 * entity. If the selected entity is an array element entity the Sel
2790 * node takes the required array indices as inputs.
2791 * Adds the node to the block in current_ir_block.
2793 * @param *db A pointer for debug information.
2794 * @param *store The memory in which the object the entity should be selected
2795 * from is allocated.
2796 * @param *objptr A pointer to a compound entity the Sel operation selects a
2797 * single attribute from.
2798 * @param arity The number of array indices needed to select an array element entity.
2799 * @param *in[] If the compound entity is an array the indices of the selected
2800 * element entity. The constructor copies this array.
2801 * @param *ent The entity to select.
2803 ir_node *new_d_Sel (dbg_info *db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
2806 /** Constructor for a Call node.
2808 * Represents all kinds of method and function calls.
2809 * Adds the node to the block in current_ir_block.
2811 * @param *db A pointer for debug information.
2812 * @param *store The actual store.
2813 * @param *callee A pointer to the called procedure.
2814 * @param arity The number of procedure parameters.
2815 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2816 * @param *tp Type information of the procedure called.
2818 ir_node *new_d_Call (dbg_info *db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
2821 /** Constructor for a Add node.
2823 * Adds the node to the block in current_ir_block.
2825 * @param *db A pointer for debug information.
2826 * @param *op1 The first operand.
2827 * @param *op2 The second operand.
2828 * @param *mode The mode of the operands and the result.
2830 ir_node *new_d_Add (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2832 /** Constructor for a Sub node.
2834 * Adds the node to the block in current_ir_block.
2836 * @param *db A pointer for debug information.
2837 * @param *op1 The first operand.
2838 * @param *op2 The second operand.
2839 * @param *mode The mode of the operands and the result.
2841 ir_node *new_d_Sub (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2843 /** Constructor for a Minus node.
2845 * Adds the node to the block in current_ir_block.
2847 * @param *db A pointer for debug information.
2848 * @param *op The operand .
2849 * @param *mode The mode of the operand and the result.
2851 ir_node *new_d_Minus (dbg_info *db, ir_node *op, ir_mode *mode);
2853 /** Constructor for a Mul node.
2855 * Adds the node to the block in current_ir_block.
2857 * @param *db A pointer for debug information.
2858 * @param *op1 The first operand.
2859 * @param *op2 The second operand.
2860 * @param *mode The mode of the operands and the result.
2862 ir_node *new_d_Mul (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2864 /** Constructor for a Quot node.
2866 * Adds the node to the block in current_ir_block.
2868 * @param *db A pointer for debug information.
2869 * @param *memop The store needed to model exceptions
2870 * @param *op1 The first operand.
2871 * @param *op2 The second operand.
2873 ir_node *new_d_Quot (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2);
2875 /** Constructor for a DivMod node.
2877 * Adds the node to the block in current_ir_block.
2879 * @param *db A pointer for debug information.
2880 * @param *memop The store needed to model exceptions
2881 * @param *op1 The first operand.
2882 * @param *op2 The second operand.
2884 ir_node *new_d_DivMod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2);
2886 /** Constructor for a Div node.
2888 * Adds the node to the block in current_ir_block.
2890 * @param *db A pointer for debug information.
2891 * @param *memop The store needed to model exceptions
2892 * @param *op1 The first operand.
2893 * @param *op2 The second operand.
2895 ir_node *new_d_Div (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2);
2897 /** Constructor for a Mod node.
2899 * Adds the node to the block in current_ir_block.
2901 * @param *db A pointer for debug information.
2902 * @param *memop The store needed to model exceptions
2903 * @param *op1 The first operand.
2904 * @param *op2 The second operand.
2906 ir_node *new_d_Mod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2);
2908 /** Constructor for a Abs node.
2910 * Adds the node to the block in current_ir_block.
2912 * @param *db A pointer for debug information.
2913 * @param *op The operand
2914 * @param *mode The mode of the operands and the result.
2916 ir_node *new_d_Abs (dbg_info *db, ir_node *op, ir_mode *mode);
2918 /** Constructor for a And node.
2920 * Adds the node to the block in current_ir_block.
2922 * @param *db A pointer for debug information.
2923 * @param *op1 The first operand.
2924 * @param *op2 The second operand.
2925 * @param *mode The mode of the operands and the result.
2927 ir_node *new_d_And (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2929 /** Constructor for a Or node.
2931 * Adds the node to the block in current_ir_block.
2933 * @param *db A pointer for debug information.
2934 * @param *op1 The first operand.
2935 * @param *op2 The second operand.
2936 * @param *mode The mode of the operands and the result.
2938 ir_node *new_d_Or (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2940 /** Constructor for a Eor node.
2942 * Adds the node to the block in current_ir_block.
2944 * @param *db A pointer for debug information.
2945 * @param *op1 The first operand.
2946 * @param *op2 The second operand.
2947 * @param *mode The mode of the operands and the results.
2949 ir_node *new_d_Eor (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2951 /** Constructor for a Not node.
2953 * Adds the node to the block in current_ir_block.
2955 * @param *db A pointer for debug information.
2956 * @param *op The operand.
2957 * @param *mode The mode of the operand and the result.
2959 ir_node *new_d_Not (dbg_info *db, ir_node *op, ir_mode *mode);
2961 /** Constructor for a Shl node.
2963 * Adds the node to the block in current_ir_block.
2965 * @param *db A pointer for debug information.
2966 * @param *op The operand.
2967 * @param *k The number of bits to shift the operand .
2968 * @param *mode The mode of the operand and the result.
2970 ir_node *new_d_Shl (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
2972 /** Constructor for a Shr node.
2974 * Adds the node to the block in current_ir_block.
2976 * @param *db A pointer for debug information.
2977 * @param *op The operand.
2978 * @param *k The number of bits to shift the operand .
2979 * @param *mode The mode of the operand and the result.
2981 ir_node *new_d_Shr (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
2983 /** Constructor for a Shrs node.
2985 * Adds the node to the block in current_ir_block.
2987 * @param *db A pointer for debug information.
2988 * @param *op The operand.
2989 * @param *k The number of bits to shift the operand .
2990 * @param *mode The mode of the operand and the result.
2992 ir_node *new_d_Shrs (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
2994 /** Constructor for a Rot node.
2996 * Adds the node to the block in current_ir_block.
2998 * @param *db A pointer for debug information.
2999 * @param *op The operand.
3000 * @param *k The number of bits to rotate the operand.
3001 * @param *mode The mode of the operand.
3003 ir_node *new_d_Rot (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
3005 /** Constructor for a Cmp node.
3007 * Adds the node to the block in current_ir_block.
3009 * @param *db A pointer for debug information.
3010 * @param *op1 The first operand.
3011 * @param *op2 The second operand.
3013 ir_node *new_d_Cmp (dbg_info *db, ir_node *op1, ir_node *op2);
3015 /** Constructor for a Conv node.
3017 * Adds the node to the block in current_ir_block.
3019 * @param *db A pointer for debug information.
3020 * @param *op The operand.
3021 * @param *mode The mode of this the operand muss be converted .
3023 ir_node *new_d_Conv (dbg_info *db, ir_node *op, ir_mode *mode);
3025 /**Constructor for a Cast node.
3027 * High level type cast
3028 * Adds the node to the block in current_ir_block.
3030 * @param *db A pointer for debug information.
3031 * @param *op The operand.
3032 * @param *to_tp The type of this the operand muss be casted .
3034 ir_node *new_d_Cast (dbg_info *db, ir_node *op, ir_type *to_tp);
3036 /**Constructor for a Phi node.
3038 * Adds the node to the block in current_ir_block.
3040 * @param *db A pointer for debug information.
3041 * @param arity The number of predecessors
3042 * @param *in Array with predecessors
3043 * @param *mode The mode of it's inputs and output.
3045 ir_node *new_d_Phi (dbg_info *db, int arity, ir_node *in[], ir_mode *mode);
3047 /** Constructor for a Load node.
3049 * Adds the node to the block in current_ir_block.
3051 * @param *db A pointer for debug information.
3052 * @param *store The current memory
3053 * @param *addr A pointer to the variable to be read in this memory.
3054 * @param *mode The mode of the value to be loaded.
3056 ir_node *new_d_Load (dbg_info *db, ir_node *store, ir_node *addr, ir_mode *mode);
3058 /** Constructor for a Store node.
3060 * Adds the node to the block in current_ir_block.
3062 * @param *db A pointer for debug information.
3063 * @param *store The current memory
3064 * @param *addr A pointer to the variable to be read in this memory.
3065 * @param *val The value to write to this variable.
3067 ir_node *new_d_Store (dbg_info *db, ir_node *store, ir_node *addr, ir_node *val);
3069 /** Constructor for a Alloc node.
3071 * The Alloc node extends the memory by space for an entity of type alloc_type.
3072 * Adds the node to the block in current_ir_block.
3074 * @param *db A pointer for debug information.
3075 * @param *store The memory which shall contain the new variable.
3076 * @param *size The number of bytes to allocate.
3077 * @param *alloc_type The type of the allocated variable.
3078 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3080 ir_node *new_d_Alloc (dbg_info *db, ir_node *store, ir_node *size, ir_type *alloc_type,
3083 /** Constructor for a Free node.
3085 * Frees the memory occupied by the entity pointed to by the pointer
3086 * arg. Type indicates the type of the entity the argument points to.
3087 * Adds the node to the block in current_ir_block.
3089 * @param *db A pointer for debug information.
3090 * @param *store The memory which shall contain the new variable.
3091 * @param *ptr The pointer to the object to free.
3092 * @param *size The number of objects of type free_type to free in a sequence.
3093 * @param *free_type The type of the freed variable.
3094 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3096 ir_node *new_d_Free (dbg_info *db, ir_node *store, ir_node *ptr, ir_node *size,
3097 ir_type *free_type, where_alloc where);
3099 /** Constructor for a Sync node.
3101 * Merges several memory values. The node assumes that a variable
3102 * either occurs only in one of the memories, or it contains the same
3103 * value in all memories where it occurs.
3104 * Adds the node to the block in current_ir_block.
3106 * @param *db A pointer for debug information.
3107 * @param arity The number of memories to synchronize.
3108 * @param **in An array of pointers to nodes that produce an output of type
3109 * memory. The constructor copies this array.
3111 ir_node *new_d_Sync (dbg_info *db, int arity, ir_node *in[]);
3113 /** Constructor for a Proj node.
3115 * Projects a single value out of a tuple. The parameter proj gives the
3116 * position of the value within the tuple.
3117 * Adds the node to the block in current_ir_block.
3119 * @param *db A pointer for deubug information.
3120 * @param arg A node producing a tuple.
3121 * @param *mode The mode of the value to project.
3122 * @param proj The position of the value in the tuple.
3124 ir_node *new_d_Proj (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3126 /** Constructor for a defaultProj node.
3128 * Represents the default control flow of a Switch-Cond node.
3129 * Adds the node to the block in current_ir_block.
3131 * @param *db A pointer for debug information.
3132 * @param arg A node producing a tuple.
3133 * @param max_proj The end position of the value in the tuple.
3135 ir_node *new_d_defaultProj (dbg_info *db, ir_node *arg, long max_proj);
3137 /** Constructor for a Tuple node.
3139 * This is an auxiliary node to replace a node that returns a tuple
3140 * without changing the corresponding Proj nodes.
3141 * Adds the node to the block in current_ir_block.
3143 * @param *db A pointer for debug information.
3144 * @param arity The number of tuple elements.
3145 * @param **in An array containing pointers to the nodes producing the tuple elements.
3147 ir_node *new_d_Tuple (dbg_info *db, int arity, ir_node *in[]);
3149 /** Constructor for a Id node.
3151 * This is an auxiliary node to replace a node that returns a single
3152 * value. Adds the node to the block in current_ir_block.
3154 * @param *db A pointer for debug information.
3155 * @param *val The operand to Id.
3156 * @param *mode The mode of *val.
3158 ir_node *new_d_Id (dbg_info *db, ir_node *val, ir_mode *mode);
3160 /** Constructor for a Bad node.
3162 * Returns the unique Bad node of the graph. The same as
3165 ir_node *new_d_Bad (void);
3167 /** Constructor for a Confirm node.
3169 * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3170 * Specifies constraints for a value. To support dataflow analyses.
3172 * Example: If the value never exceeds '100' this is expressed by placing a
3173 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3175 * @param *db A pointer for debug information.
3176 * @param *val The value we express a constraint for
3177 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3178 * @param cmp The compare operation.
3180 ir_node *new_d_Confirm (dbg_info *db, ir_node *val, ir_node *bound, pn_Cmp cmp);
3182 /** Constructor for an Unknown node.
3184 * Represents an arbitrary value. Places the node in
3187 * @param *m The mode of the unknown value.
3189 ir_node *new_d_Unknown(ir_mode *m);
3191 /** Constructor for a CallBegin node.
3193 * CallBegin represents control flow depending of the pointer value
3194 * representing the called method to the called methods. The
3195 * constructor copies the method pointer input from the passed Call
3196 * node.Adds the node to the block in current_ir_block.
3198 * @param *db A pointer for debug information.
3199 * @param *callee The call node visible in the intra procedural view.
3201 ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
3203 /** Constructor for an EndReg node.
3205 *Adds the node to the block in current_ir_block.
3207 * @param *db A pointer for debug information.
3209 ir_node *new_d_EndReg (dbg_info *db);
3211 /** Constructor for an EndExcept node.
3213 * Used to represent regular procedure end in interprocedual view.
3214 * Adds the node to the block in current_ir_block.
3216 * @param *db A pointer for debug information.
3218 ir_node *new_d_EndExcept(dbg_info *db);
3220 /** Constructor for a Break node.
3222 * Used to represent exceptional procedure end in interprocedural view.
3223 * Adds the node to the block in current_ir_block.
3225 * Break represents control flow to a single control successor just as Jmp.
3226 * The blocks separated by a break may not be concatenated by an optimization.
3227 * It is used for the interprocedural representation where blocks are parted
3228 * behind Call nodes to represent the control flow to called procedures.
3230 * @param *db A pointer for debug information.
3232 ir_node *new_d_Break (dbg_info *db);
3234 /** Constructor for a Filter node.
3236 * Constructor for a Filter node. Adds the node to the block in
3237 * current_ir_block. Filter is a node with two views used to
3238 * construct the interprocedural view. In intraprocedural view its
3239 * semantics are identical to the Proj node. In interprocedural view
3240 * the Filter performs the Phi operation on method parameters or
3241 * results. Other than a Phi a Filter node may not be removed if it
3242 * has only a single input.
3244 * The constructor builds the Filter in intraprocedural view.
3246 * @param *db A pointer for debug information.
3247 * @param *arg The tuple value to project from.
3248 * @param *mode The mode of the projected value.
3249 * @param proj The position in the tuple to project from.
3251 ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3254 /** Constructor for a NoMem node.
3256 * Returns the unique NoMem node of the graph. The same as
3259 ir_node *new_d_NoMem (void);
3261 /** Constructor for a Mux node.
3263 * @param *db A pointer for debug information.
3264 * @param *sel The ir_node that calculates the boolean select.
3265 * @param *ir_true The ir_node that calculates the true result.
3266 * @param *ir_false The ir_node that calculates the false result.
3267 * @param *mode The mode of the node (and it_true and ir_false).
3269 ir_node *new_d_Mux (dbg_info *db, ir_node *sel,
3270 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3272 /** Constructor for a CopyB node.
3274 * @param *db A pointer for debug information.
3275 * @param *store The current memory
3276 * @param *dst The ir_node that represents the destination address.
3277 * @param *src The ir_node that represents the source address.
3278 * @param *data_type The type of the copied data
3280 ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
3282 /** Constructor for a InstOf node.
3284 * A High-Level Type check.
3286 * @param *db A pointer for debug information.
3287 * @param *store The memory in which the object the entity should be selected
3288 * from is allocated.
3289 * @param *objptr A pointer to a object of a class type.
3290 * @param *type The type of which objptr must be.
3292 ir_node *new_d_InstOf (dbg_info *db, ir_node *store, ir_node *objptr, ir_type *type);
3294 /** Constructor for a Raise node.
3296 * A High-Level Exception throw.
3298 * @param *db A pointer for debug information.
3299 * @param *store The current memory.
3300 * @param *obj A pointer to the Except variable.
3302 ir_node *new_d_Raise (dbg_info *db, ir_node *store, ir_node *obj);
3304 /** Constructor for a Bound node.
3306 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
3308 * @param *db A pointer for debug information.
3309 * @param *store The current memory
3310 * @param *idx The ir_node that represents an index.
3311 * @param *lower The ir_node that represents the lower bound for the index.
3312 * @param *upper The ir_node that represents the upper bound for the index.
3314 ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
3316 /*-----------------------------------------------------------------------*/
3317 /* The block oriented interface without debug support */
3318 /*-----------------------------------------------------------------------*/
3320 /* Needed from the interface with debug support:
3321 void set_cur_block (ir_node *target); */
3323 /** Constructor for a Block node.
3325 * Constructor for a Block node. Adds the block to the graph in
3326 * current_ir_graph. Constructs a Block with a fixed number of
3327 * predecessors. Does set current_block. Can be used with automatic
3328 * Phi node construction.
3330 * @param arity The number of control predecessors.
3331 * @param in An array of control predecessors. The length of
3332 * the array must be 'arity'.
3334 ir_node *new_Block(int arity, ir_node *in[]);
3336 /** Constructor for a Start node.
3338 * Adds the node to the block in current_ir_block.
3341 ir_node *new_Start (void);
3343 /** Constructor for an End node.
3345 * Adds the node to the block in current_ir_block.
3347 ir_node *new_End (void);
3349 /** Constructor for an EndReg node.
3351 * Used to represent regular procedure end in interprocedual view.
3352 * Adds the node to the block in current_ir_block.
3354 ir_node *new_EndReg (void);
3356 /** Constructor for an EndExpcept node.
3358 * Used to represent exceptional procedure end in interprocedural view.
3359 * Adds the node to the block in current_ir_block.
3361 ir_node *new_EndExcept(void);
3363 /** Constructor for a Jump node.
3365 * Adds the node to the block in current_ir_block.
3367 * Jmp represents control flow to a single control successor.
3369 ir_node *new_Jmp (void);
3371 /** Constructor for an IJmp node.
3373 * IJmp represents control flow to a single control successor not
3374 * statically known i.e. an indirect Jmp.
3376 * @param *tgt The ir node representing the target address.
3378 ir_node *new_IJmp (ir_node *tgt);
3380 /** Constructor for a Break node.
3381 * Break represents control flow to a single control successor just as Jmp.
3382 * The blocks separated by a break may not be concatenated by an optimization.
3383 * It is used for the interprocedural representation where blocks are parted
3384 * behind Call nodes to represent the control flow to called procedures.
3385 * Adds the node to the block in current_ir_block.
3387 ir_node *new_Break (void);
3389 /** Constructor for a Cond node.
3391 * If c is mode_b represents a conditional branch (if/else). If c is
3392 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
3393 * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3395 * This is not consistent: Input to Cond is Is, Proj has as proj number
3399 * @param *c The conditions parameter.Can be of mode b or I_u.
3401 ir_node *new_Cond (ir_node *c);
3403 /** Constructor for a Return node.
3405 * Returns the memory an zero or more return values. Only node that
3406 * can end regular control flow. Adds the node to the block in current_ir_block.
3408 * @param *store The state of memory.
3409 * @param arity Number of array indices.
3410 * @param *in Array with index inputs to the node.
3412 ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
3414 /** Constructor for a Const node.
3416 * Constructor for a Const node. The constant represents a target
3417 * value. Sets the type information to type_unknown. (No more
3418 * supported: If tv is entity derives a somehow useful type.)
3419 * Adds the node to the block in current_ir_block.
3421 * @param *mode The mode of the operands and results.
3422 * @param *con Points to an entry in the constant table. This pointer is
3423 * added to the attributes of the node.
3425 ir_node *new_Const (ir_mode *mode, tarval *con);
3428 * Make a const from a long.
3429 * This is just convenience for the usual
3431 * new_Const(mode, tarval_from_long(mode, ...))
3434 * @param mode The mode for the const.
3435 * @param value The value of the constant.
3436 * @return A new const node.
3438 ir_node *new_Const_long(ir_mode *mode, long value);
3440 /** Constructor for a Const node.
3442 * Derives mode from passed type. */
3443 ir_node *new_Const_type(tarval *con, ir_type *tp);
3445 /** Constructor for a SymConst node.
3447 * Adds the node to the block in current_ir_block.
3448 * This is the constructor for a symbolic constant.
3449 * There are four kinds of symbolic constants:
3450 * -# type_tag The symbolic constant represents a type tag. The type the
3451 * tag stands for is given explicitly.
3452 * -# size The symbolic constant represents the size of a type. The
3453 * type of which the constant represents the size is given
3455 * -# addr_name The symbolic constant represents the address of an entity
3456 * (variable or method). The variable is indicated by a name
3457 * that is valid for linking.
3458 * -# addr_ent The symbolic constant represents the address of an entity
3459 * (variable or method). The variable is given explicitly by
3462 * Inputs to the node:
3463 * No inputs except the block it belongs to.
3464 * Outputs of the node.
3465 * An unsigned integer (I_u) or a pointer (P).
3467 * @param value A type or a ident depending on the SymConst kind.
3468 * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_size or symconst_addr_name.
3470 ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind);
3472 /** Constructor for a simpelSel node.
3474 * This is a shortcut for the new_Sel() constructor. To be used for
3475 * Sel nodes that do not select from an array, i.e., have no index
3476 * inputs. It adds the two parameters 0, NULL.
3478 * @param *store The memory in which the object the entity should be selected from is allocated.
3479 * @param *objptr The object from that the Sel operation selects a single attribute out.
3480 * @param *ent The entity to select.
3482 ir_node *new_simpleSel(ir_node *store, ir_node *objptr, entity *ent);
3484 /** Constructor for a Sel node.
3486 * The select node selects an entity (field or method) from an entity
3487 * with a compound type. It explicitly specifies the entity selected.
3488 * Dynamically the node may select entities that overwrite the given
3489 * entity. If the selected entity is an array element entity the Sel
3490 * node takes the required array indices as inputs.
3491 * Adds the node to the block in current_ir_block.
3493 * @param *store The memory in which the object the entity should be selected
3494 * from is allocated.
3495 * @param *objptr A pointer to a compound entity the Sel operation selects a
3496 * single attribute from.
3497 * @param arity The number of array indices needed to select an array element entity.
3498 * @param *in[] If the compound entity is an array the indices of the selected
3499 * element entity. The constructor copies this array.
3500 * @param *ent The entity to select.
3502 ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
3505 /** Constructor for a Call node.
3507 * Adds the node to the block in current_ir_block.
3508 * Represents all kinds of method and function calls.
3510 * @param *store The actual store.
3511 * @param *callee A pointer to the called procedure.
3512 * @param arity The number of procedure parameters.
3513 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3514 * @param *tp Type information of the procedure called.
3516 ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node *in[],
3519 /** Constructor for a CallBegin node.
3521 * Adds the node to the block in current_ir_block.
3523 * @param *callee A pointer to the called procedure.
3525 ir_node *new_CallBegin(ir_node *callee);
3527 /**Constructor for a Add node.
3529 * CallBegin represents control flow depending of the pointer value
3530 * representing the called method to the called methods. The
3531 * constructor copies the method pointer input from the passed Call
3532 * node.Adds the node to the block in current_ir_block.
3534 * @param *op1 The first operand.
3535 * @param *op2 The second operand.
3536 * @param *mode The mode of the operands and the result.
3538 ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
3540 /** Constructor for a Sub node.
3542 * Adds the node to the block in current_ir_block.
3544 * @param *op1 The first operand.
3545 * @param *op2 The second operand.
3546 * @param *mode The mode of the operands and the result.
3548 ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
3550 /** Constructor for a Minus node.
3552 * Adds the node to the block in current_ir_block.
3554 * @param *op The operand .
3555 * @param *mode The mode of the operand and the result.
3557 ir_node *new_Minus (ir_node *op, ir_mode *mode);
3560 * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3562 * @param *op1 The first operand.
3563 * @param *op2 The second operand.
3564 * @param *mode The mode of the operands and the result.
3566 ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
3568 /** Constructor for a Quot node.
3570 * Adds the node to the block in current_ir_block.
3572 * @param *memop The store needed to model exceptions
3573 * @param *op1 The first operand.
3574 * @param *op2 The second operand.
3576 ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
3578 /** Constructor for a DivMod node.
3580 * Adds the node to the block in current_ir_block.
3582 * @param *memop The store needed to model exceptions
3583 * @param *op1 The first operand.
3584 * @param *op2 The second operand.
3586 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
3588 /** Constructor for a Div node.
3590 * Adds the node to the block in current_ir_block.
3592 * @param *memop The store needed to model exceptions
3593 * @param *op1 The first operand.
3594 * @param *op2 The second operand.
3596 ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
3598 /** Constructor for a Mod node.
3600 * Adds the node to the block in current_ir_block.
3602 * @param *memop The store needed to model exceptions
3603 * @param *op1 The first operand.
3604 * @param *op2 The second operand.
3606 ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
3608 /** Constructor for a Abs node.
3610 * Adds the node to the block in current_ir_block.
3612 * @param *op The operand
3613 * @param *mode The mode of the operands and the result.
3615 ir_node *new_Abs (ir_node *op, ir_mode *mode);
3617 /** Constructor for a And node.
3619 * Adds the node to the block in current_ir_block.
3621 * @param *op1 The first operand.
3622 * @param *op2 The second operand.
3623 * @param *mode The mode of the operands and the result.
3625 ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
3628 * Constructor for a Or node. Adds the node to the block in current_ir_block.
3630 * @param *op1 The first operand.
3631 * @param *op2 The second operand.
3632 * @param *mode The mode of the operands and the result.
3634 ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
3637 * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3639 * @param *op1 The first operand.
3640 * @param *op2 The second operand.
3641 * @param *mode The mode of the operands and the results.
3643 ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
3645 /** Constructor for a Not node.
3647 * Adds the node to the block in current_ir_block.
3649 * @param *op The operand.
3650 * @param *mode The mode of the operand and the result.
3652 ir_node *new_Not (ir_node *op, ir_mode *mode);
3654 /** Constructor for a Shl node.
3656 * Adds the node to the block in current_ir_block.
3658 * @param *op The operand.
3659 * @param *k The number of bits to shift the operand .
3660 * @param *mode The mode of the operand and the result.
3662 ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
3665 * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3667 * @param *op The operand.
3668 * @param *k The number of bits to shift the operand .
3669 * @param *mode The mode of the operand and the result.
3671 ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
3673 /** Constructor for a Shrs node.
3675 * Adds the node to the block in current_ir_block.
3677 * @param *op The operand.
3678 * @param *k The number of bits to shift the operand .
3679 * @param *mode The mode of the operand and the result.
3681 ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
3683 /** Constructor for a Rot node.
3685 * Adds the node to the block in current_ir_block.
3687 * @param *op The operand.
3688 * @param *k The number of bits to rotate the operand.
3689 * @param *mode The mode of the operand.
3691 ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
3693 /** Constructor for a Cmp node.
3695 * Adds the node to the block in current_ir_block.
3697 * @param *op1 The first operand.
3698 * @param *op2 The second operand.
3700 ir_node *new_Cmp (ir_node *op1, ir_node *op2);
3702 /** Constructor for a Conv node.
3704 * Adds the node to the block in current_ir_block.
3706 * @param *op The operand.
3707 * @param *mode The mode of this the operand muss be converted .
3709 ir_node *new_Conv (ir_node *op, ir_mode *mode);
3711 /**Constructor for a Cast node.
3713 * Adds the node to the block in current_ir_block.
3714 * High level type cast
3716 * @param *op The operand.
3717 * @param *to_tp The type of this the operand muss be casted .
3719 ir_node *new_Cast (ir_node *op, ir_type *to_tp);
3721 /** Constructor for a Phi node.
3723 * Adds the node to the block in current_ir_block.
3725 * @param arity The number of predecessors.
3726 * @param *in Array with predecessors.
3727 * @param *mode The mode of it's inputs and output.
3729 ir_node *new_Phi (int arity, ir_node *in[], ir_mode *mode);
3731 /** Constructor for a Load node.
3733 * @param *store The current memory.
3734 * @param *addr A pointer to the variable to be read in this memory.
3735 * @param *mode The mode of the value to be loaded.
3737 ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
3739 /** Constructor for a Store node.
3741 * @param *store The current memory.
3742 * @param *addr A pointer to the variable to be read in this memory.
3743 * @param *val The value to write to this variable.
3745 ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
3747 /** Constructor for a Alloc node.
3749 * The Alloc node extends the memory by space for an entity of type alloc_type.
3750 * Adds the node to the block in current_ir_block.
3752 * @param *store The memory which shall contain the new variable.
3753 * @param *size The number of bytes to allocate.
3754 * @param *alloc_type The type of the allocated variable.
3755 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3757 ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
3760 /** Constructor for a Free node.
3762 * Frees the memory occupied by the entity pointed to by the pointer
3763 * arg. Type indicates the type of the entity the argument points to.
3764 * Adds the node to the block in current_ir_block.
3766 * @param *store The memory which shall contain the new variable.
3767 * @param *ptr The pointer to the object to free.
3768 * @param *size The number of objects of type free_type to free in a sequence.
3769 * @param *free_type The type of the freed variable.
3770 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3772 ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
3773 ir_type *free_type, where_alloc where);
3775 /** Constructor for a Sync node.
3777 * Merges several memory values. The node assumes that a variable
3778 * either occurs only in one of the memories, or it contains the same
3779 * value in all memories where it occurs.
3780 * Adds the node to the block in current_ir_block.
3782 * @param arity The number of memories to synchronize.
3783 * @param **in An array of pointers to nodes that produce an output of type
3784 * memory. The constructor copies this array.
3786 ir_node *new_Sync (int arity, ir_node *in[]);
3788 /** Constructor for a Proj node.
3790 * Projects a single value out of a tuple. The parameter proj gives the
3791 * position of the value within the tuple.
3792 * Adds the node to the block in current_ir_block.
3794 * @param arg A node producing a tuple.
3795 * @param *mode The mode of the value to project.
3796 * @param proj The position of the value in the tuple.
3798 ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
3800 /** Constructor for a Filter node.
3802 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
3803 * Filter is a node with two views used to construct the interprocedural view.
3804 * In intraprocedural view its semantics are identical to the Proj node.
3805 * In interprocedural view the Filter performs the Phi operation on method
3806 * parameters or results. Other than a Phi a Filter node may not be removed
3807 * if it has only a single input.
3809 * The constructor builds the Filter in intraprocedural view.
3811 * @param *arg The tuple value to project from.
3812 * @param *mode The mode of the projected value.
3813 * @param proj The position in the tuple to project from.
3815 ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
3817 /** Constructor for a defaultProj node.
3819 * Represents the default control flow of a Switch-Cond node.
3820 * Adds the node to the block in current_ir_block.
3822 * @param arg A node producing a tuple.
3823 * @param max_proj The end position of the value in the tuple.
3825 ir_node *new_defaultProj (ir_node *arg, long max_proj);
3827 /** Constructor for a Tuple node.
3829 * This is an auxiliary node to replace a node that returns a tuple
3830 * without changing the corresponding Proj nodes.
3831 * Adds the node to the block in current_ir_block.
3833 * @param arity The number of tuple elements.
3834 * @param **in An array containing pointers to the nodes producing the tuple elements.
3836 ir_node *new_Tuple (int arity, ir_node *in[]);
3838 /** Constructor for an Id node.
3840 * This is an auxiliary node to replace a node that returns a single
3841 * value. Adds the node to the block in current_ir_block.
3843 * @param *val The operand to Id.
3844 * @param *mode The mode of *val.
3846 ir_node *new_Id (ir_node *val, ir_mode *mode);
3848 /** Constructor for a Bad node.
3850 * Returns the unique Bad node of the graph. The same as
3853 ir_node *new_Bad (void);
3855 /** Constructor for a Confirm node.
3857 * Specifies constraints for a value. To support dataflow analyses.
3858 * Adds the node to the block in current_ir_block.
3860 * Example: If the value never exceeds '100' this is expressed by placing a
3861 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3863 * @param *val The value we express a constraint for
3864 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3865 * @param cmp The compare operation.
3867 ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
3869 /** Constructor for an Unknown node.
3871 * Represents an arbitrary value. Places the node in
3874 * @param *m The mode of the unknown value.
3876 ir_node *new_Unknown(ir_mode *m);
3878 /** Constructor for a NoMem node.
3880 * Returns the unique NoMem node of the graph. The same as
3883 ir_node *new_NoMem (void);
3885 /** Constructor for a Mux node.
3887 * Adds the node to the block in current_ir_block.
3889 * @param *sel The ir_node that calculates the boolean select.
3890 * @param *ir_true The ir_node that calculates the true result.
3891 * @param *ir_false The ir_node that calculates the false result.
3892 * @param *mode The mode of the node (and it_true and ir_false).
3894 ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3896 /** Constructor for a CopyB node.
3898 * Adds the node to the block in current_ir_block.
3900 * @param *store The current memory
3901 * @param *dst The ir_node that represents the destination address.
3902 * @param *src The ir_node that represents the source address.
3903 * @param *data_type The type of the copied data
3905 ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
3907 /** Constructor for a InstOf node.
3909 * A High-Level Type check.
3911 * @param *store The memory in which the object the entity should be selected
3912 * from is allocated.
3913 * @param *objptr A pointer to a object of a class type.
3914 * @param *type The type of which objptr must be.
3916 ir_node *new_InstOf (ir_node *store, ir_node *objptr, ir_type *type);
3918 /**Constructor for a Raise node.
3920 * A High-Level Exception throw.
3922 * @param *store The current memory.
3923 * @param *obj A pointer to the Except variable.
3925 ir_node *new_Raise (ir_node *store, ir_node *obj);
3927 /** Constructor for a Bound node.
3929 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
3931 * Adds the node to the block in current_ir_block.
3933 * @param *store The current memory
3934 * @param *idx The ir_node that represents an index.
3935 * @param *lower The ir_node that represents the lower bound for the index.
3936 * @param *upper The ir_node that represents the upper bound for the index.
3938 ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
3940 /*---------------------------------------------------------------------*/
3941 /* The comfortable interface. */
3942 /* Supports automatic Phi node construction. */
3943 /* All routines of the block oriented interface except new_Block are */
3945 /*---------------------------------------------------------------------*/
3947 /** Create an immature block.
3949 * An immature block has an unknown number of predecessors. Predecessors
3950 * can be added with add_immBlock_pred(). Once all predecessors are
3951 * added the block must be matured.
3953 * Adds the block to the graph in current_ir_graph. Does set
3954 * current_block. Can be used with automatic Phi node construction.
3955 * This constructor can only be used if the graph is in
3958 ir_node *new_d_immBlock (dbg_info *db);
3959 ir_node *new_immBlock (void);
3961 /** Add a control flow edge to an immature block. */
3962 void add_immBlock_pred (ir_node *immblock, ir_node *jmp);
3964 /** Finalize a Block node, when all control flows are known. */
3965 void mature_immBlock (ir_node *block);
3966 #define mature_cur_block() mature_immBlock(get_cur_block());
3969 /** Get the current value of a local variable.
3971 * Use this function to obtain the last definition of the local variable
3972 * associated with pos. Pos may not exceed the value passed as n_loc
3973 * to new_ir_graph. This call automatically inserts Phi nodes.
3975 * @param *db A pointer for debug information.
3976 * @param pos The position/id of the local variable.
3977 * @param *mode The mode of the value to get.
3979 ir_node *get_d_value (dbg_info *db, int pos, ir_mode *mode);
3980 ir_node *get_value (int pos, ir_mode *mode);
3982 /** Remark a new definition of a variable.
3984 * Use this function to remember a new definition of the value
3985 * associated with pos. Pos may not exceed the value passed as n_loc
3986 * to new_ir_graph. This call is needed to automatically inserts Phi
3989 * @param pos The position/id of the local variable.
3990 * @param *value The new value written to the local variable.
3992 void set_value (int pos, ir_node *value);
3994 /** Get the current memory state.
3996 * Use this function to obtain the last definition of the memory
3997 * state. This call automatically inserts Phi nodes for the memory
4000 ir_node *get_store (void);
4002 /** Remark a new definition of the memory state.
4004 * Use this function to remember a new definition of the memory state.
4005 * This call is needed to automatically inserts Phi nodes.
4007 * @param *store The new memory state.
4009 void set_store (ir_node *store);
4011 /** keep this node alive even if End is not control-reachable from it
4013 * @param ka The node to keep alive.
4015 void keep_alive (ir_node *ka);
4017 /** Returns the frame type of the current graph */
4018 ir_type *get_cur_frame_type(void);
4021 /* --- initialize and finalize ir construction --- */
4023 /** Puts the graph into state "phase_high" */
4024 void irg_finalize_cons (ir_graph *irg);
4026 /** Puts the program and all graphs into state phase_high.
4028 * This also remarks, the construction of types is finished,
4029 * e.g., that no more subtypes will be added. */
4030 void irp_finalize_cons(void);
4032 /* --- Initialization --- */
4035 * This function is called, whenever a local variable is used before definition
4037 * @param irg the IR graph on which this happens
4038 * @param mode the mode of the local var
4039 * @param pos position chosen be the frontend for this variable (n_loc)
4041 * @return a firm node of mode @p mode that initializes the var at position pos
4044 * Do not return NULL!
4045 * If this function is not set, FIRM will create a const node with tarval BAD.
4046 * Use set_irg_loc_description()/get_irg_loc_description() to assign additional
4047 * informations to local variables.
4049 typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
4051 #endif /* _IRCONS_H_ */