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_Carry (ir_node *op1, ir_node *op2, ir_mode *mode);
284 * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
285 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
286 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
287 * ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
288 * where_alloc where);
289 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
290 * ir_type *free_type, where_alloc where);
291 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
292 * ir_node *new_NoMem (void);
293 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
294 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
295 * ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
296 * ir_node *new_Raise (ir_node *store, ir_node *obj);
297 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
299 * void add_immBlock_pred (ir_node *block, ir_node *jmp);
300 * void mature_immBlock (ir_node *block);
301 * void set_cur_block (ir_node *target);
302 * ir_node *get_value (int pos, ir_mode *mode);
303 * void set_value (int pos, ir_node *value);
304 * ir_node *get_store (void);
305 * void set_store (ir_node *store);
306 * keep_alive (ir_node ka)
308 * IR_NODES AND CONSTRUCTORS FOR IR_NODES
309 * =======================================
311 * All ir_nodes are defined by a common data structure. They are distinguished
312 * by their opcode and differ in the number of their attributes.
314 * The constructor for the block node sets current_block to itself.
315 * Const nodes are always added to the start block.
316 * All other constructors add the created node to the current_block.
317 * swich_block(block) allows to set the current block to block.
319 * Watch for my inconsistent use of input and predecessor (dataflow view)
320 * and `the node points to' (implementation view).
322 * The following description of the nodes lists four properties them if these
324 * - the parameters to the constructor
325 * - the inputs of the Firm node
326 * - the outputs of the Firm node
327 * - attributes to the node
331 * ir_node *new_immBlock (void)
332 * ----------------------------
334 * Creates a new block. Sets current_block to itself. When a new block is
335 * created it cannot be known how many predecessors this block will have in the
336 * control flow graph. Therefore the list of inputs can not be fixed at
337 * creation. Predecessors can be added with add_immBlock_pred (block, control flow
338 * operation). With every added predecessor the number of inputs to Phi nodes
341 * The block can be completed by mature_immBlock(block) if all predecessors are
342 * known. If several blocks are built at once, mature_immBlock can only be called
343 * after set_value has been called for all values that are life at the end
344 * of the block. This is necessary so that Phi nodes created mature_immBlock
345 * get the right predecessors in case of cyclic dependencies. If all set_values
346 * of this block are called after maturing it and before calling get_value
347 * in some block that is control flow dependent on this block, the construction
350 * Example for faulty ir construction: (draw the graph on a paper and you'll
353 * block_before_loop = new_block();
355 * mature_immBlock(block_before_loop);
356 * before2header = new_Jmp;
358 * loop_header = new_block ();
359 * header2body - new_Jmp();
361 * loop_body = new_block ();
362 * body2header = new_Jmp();
364 * add_immBlock_pred(loop_header, before2header);
365 * add_immBlock_pred(loop_header, body2header);
366 * add_immBlock_pred(loop_body, header2body);
368 * mature_immBlock(loop_header);
369 * mature_immBlock(loop_body);
371 * get_value(loop_body, x); // gets the Phi in loop_header
372 * set_value(loop_header, x); // sets the value the above get_value should
373 * // have returned!!!
375 * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
376 * should be called as early as possible, as afterwards the generation of Phi
377 * nodes is more efficient.
380 * There is an input for each control flow predecessor of the block.
381 * The input points to an instruction producing an output of type X.
382 * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
383 * possibly causing an exception. (Often the real predecessors are Projs.)
385 * Mode BB (R), all nodes belonging to this block should consume this output.
386 * As they are strict (except Block and Phi node) it is a necessary condition
387 * that the block node executed before any other node in this block executes.
389 * block.matured Indicates whether the block is mature.
391 * This attribute contains all local values valid in this
392 * block. This is needed to build the Phi nodes and removed
393 * if the graph is complete. This field is used by the
394 * internal construction algorithm and should not be accessed
398 * ir_node *new_Block (int arity, ir_node **in)
399 * --------------------------------------------
401 * Creates a new Block with the given list of predecessors. This block
402 * is mature. As other constructors calls optimization and vrfy for the
403 * block. If one of the predecessors is Unknown (as it has to be filled in
404 * later) optimizations are skipped. This is necessary to
405 * construct Blocks in loops. Leaving Unknown in the Block after finishing
406 * the construction may have strange effects, especially for interprocedural
407 * representation and analysis.
410 * CONTROL FLOW OPERATIONS
411 * -----------------------
413 * In each block there must be exactly one of the control flow
414 * operations Start, End, Jmp, Cond, Return or Raise. The output of a
415 * control flow operation points to the block to be executed next.
417 * ir_node *new_Start (void)
418 * -------------------------
420 * Creates a start node. Not actually needed public. There is only one such
421 * node in each procedure which is automatically created by new_ir_graph.
424 * No inputs except the block it belogns to.
426 * A tuple of 4 (5, 6) distinct values. These are labeled by the following
427 * projection numbers (pn_Start):
428 * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
429 * * pn_Start_M mode M, the global store
430 * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
431 * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
432 * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
435 * ir_node *new_End (void)
436 * -----------------------
438 * Creates an end node. Not actually needed public. There is only one such
439 * node in each procedure which is automatically created by new_ir_graph.
442 * No inputs except the block it belongs to.
446 * ir_node *new_Jmp (void)
447 * -----------------------
449 * Creates a Jmp node.
452 * The block the node belongs to
454 * Control flow to the next block.
456 * ir_node *new_IJmp (ir_node *tgt)
457 * -----------------------
459 * Creates an IJmp node.
462 * The node that represents the target jump address
464 * Control flow to an unknown target, must be pinned by
467 * ir_node *new_Cond (ir_node *c)
468 * ------------------------------
470 * Creates a Cond node. There are two versions of this node.
476 * A tuple of two control flows. The first is taken if the input is
477 * false, the second if it is true.
481 * A value of mode I_u. (i)
483 * A tuple of n control flows. If the Cond's input is i, control
484 * flow will procede along output i. If the input is >= n control
485 * flow proceeds along output n.
487 * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
488 * -------------------------------------------------------------
490 * The return node has as inputs the results of the procedure. It
491 * passes the control flow to the end_block.
497 * Control flow to the end block.
501 * ir_node *new_Const (ir_mode *mode, tarval *con)
502 * -----------------------------------------------
504 * Creates a constant in the constant table and adds a Const node
505 * returning this value to the start block.
508 * *mode The mode of the constant.
509 * *con Points to an entry in the constant table.
510 * This pointer is added to the attributes of
511 * the node (self->attr.con)
513 * No inputs except the block it belogns to.
515 * The constant value.
517 * attr.con A tarval* pointer to the proper entry in the constant
520 * ir_node *new_SymConst (union symconst_symbol value, symconst_addr_ent kind)
521 * ---------------------------------------------------------------------------
523 * There are three kinds of symbolic constants:
524 * symconst_type_tag The symbolic constant represents a type tag.
525 * symconst_size The symbolic constant represents the size of a class.
526 * symconst_addr_name Information for the linker, e.g. the name of a global
528 * To represent a pointer to an entity that is represented by an entity
529 * datastructure don't use
530 * new_SymConst((type_or_id*)get_entity_ld_ident(ent), symconst_addr_name);.
531 * Use a real const instead:
532 * new_SymConst(mode_P_mach, tarval_p_from_entity(ent));
533 * This makes the Constant independent of name changes of the entity due to
537 * kind The kind of the symbolic constant: type_tag, size or link_info.
538 * *type_or_id Points to the type the tag stands for or to the type
539 * whose size is represented by the constant or to an ident
540 * representing the linkage info.
543 * No inputs except the block it belogns to.
545 * An unsigned integer (I_u) or a pointer (P).
548 * attr.i.num The symconst_addr_ent, i.e. one of
551 * - symconst_addr_name
552 * If the attr.i.num is symconst_type_tag or symconst_size, the node contains an attribute
553 * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is.
554 * if it is linkage_ptr_info it contains
555 * attr.i.*ptrinfo, an ident holding information for the linker. The mode
556 * of the node is mode_P_mach.
560 * ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel)
561 * --------------------------------------------------------------------
564 * Selects an entity from a compound type. This entity can be a field or
568 * *store The memory in which the object the entity should be selected
570 * *frame The pointer to the object.
571 * *sel The entity to select.
574 * The memory containing the object.
575 * A pointer to the object.
576 * An unsigned integer.
578 * A pointer to the selected entity.
580 * attr.sel Pointer to the entity
583 * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
584 * --------------------------------------------------------------------------
588 * Selects a field from an array type. The entity has as owner the array, as
589 * type the arrays element type. The indices to access an array element are
593 * *store The memory in which the object the entity should be selected from
595 * *frame The pointer to the object.
596 * *arity number of array indices.
597 * *in array with index inputs to the node.
598 * *sel The entity to select.
601 * The memory containing the object.
602 * A pointer to the object.
603 * As much unsigned integer as there are array expressions.
605 * A pointer to the selected entity.
607 * attr.sel Pointer to the entity
609 * The constructors new_Sel and new_simpleSel generate the same ir nodes.
610 * simpleSel just sets the arity of the index inputs to zero.
613 * ARITHMETIC OPERATIONS
614 * ---------------------
616 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
617 * ----------------------------------------------------------------------------
621 * Creates a procedure call.
624 * *store The actual store.
625 * *callee A pointer to the called procedure.
626 * arity The number of procedure parameters.
627 * **in An array with the pointers to the parameters.
628 * The constructor copies this array.
629 * *type Type information of the procedure called.
632 * The store, the callee and the parameters.
634 * A tuple containing the eventually changed store and the procedure
637 * attr.call Contains the type information for the procedure.
640 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
641 * ------------------------------------------------------------
645 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
646 * ------------------------------------------------------------
650 * ir_node *new_Minus (ir_node *op, ir_mode *mode)
651 * -----------------------------------------------
653 * Unary Minus operations on integer and floating point values.
655 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
656 * ------------------------------------------------------------
660 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2)
661 * --------------------------------------------------------------
663 * Quot performs exact division of floating point numbers. It's mode
664 * is Tuple, the mode of the result must be annotated to the Proj
665 * that extracts the result of the arithmetic operations.
668 * The store needed to model exceptions and the two operands.
670 * A tuple contaning a memory and a execution for modeling exceptions
671 * and the result of the arithmetic operation.
673 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2)
674 * ----------------------------------------------------------------
676 * Performs Div and Mod on interger values.
679 * A tuple contaning a memory and a execution for modeling exceptions
680 * and the two result of the arithmetic operations.
682 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2)
683 * -------------------------------------------------------------
687 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2)
688 * -------------------------------------------------------------
692 * ir_node *new_Abs (ir_node *op, ir_mode *mode)
693 * ---------------------------------------------
697 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
698 * ------------------------------------------------------------
702 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
703 * -----------------------------------------------------------
707 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
708 * ------------------------------------------------------------
712 * ir_node *new_Not (ir_node *op, ir_mode *mode)
713 * ---------------------------------------------
715 * This node constructs a constant where all bits are set to one
716 * and a Eor of this constant and the operator. This simulates a
719 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
720 * ---------------------------------------------------------
724 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
725 * ---------------------------------------------------------
727 * Logic shift right, i.e., zero extended.
730 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
731 * ----------------------------------------------------------
733 * Arithmetic shift right, i.e., sign extended.
735 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
736 * ---------------------------------------------------------
738 * Rotates the operand to the (right??) by k bits.
740 * ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode)
741 * ------------------------------------------------------------
743 * Calculates the Carry value for integer addition. Used only
746 * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode)
747 * ------------------------------------------------------------
749 * Calculates the Borrow value for integer substraction. Used only
752 * ir_node *new_Conv (ir_node *op, ir_mode *mode)
753 * ---------------------------------------------
755 * Mode conversion. For allowed conversions see UKA Tech Report
758 * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
759 * ---------------------------------------------
762 * The two values to be compared.
764 * A 16-tuple containing the results of the 16 different comparisons.
765 * The following is a list giving the comparisons and a projection
766 * number (pn_Cmp) to use in Proj nodes to extract the proper result.
770 * pn_Cmp_Le less or equal
772 * pn_Cmp_Ge greater of equal
773 * pn_Cmp_Lg less or greater
774 * pn_Cmp_Leg less, equal or greater = ordered
775 * pn_Cmp_Uo unordered
776 * pn_Cmp_Ue unordered or equal
777 * pn_Cmp_Ul unordered or less
778 * pn_Cmp_Ule unordered, less or equal
779 * pn_Cmp_Ug unordered or greater
780 * pn_Cmp_Uge unordered, greater or equal
781 * pn_Cmp_Ne unordered, less or greater = not equal
788 * In general, Phi nodes are automaitcally inserted. In some cases, if
789 * all predecessors of a block are known, an explicit Phi node constructor
790 * is needed. E.g., to construct a FIRM graph for a statement as
791 * a = (b==c) ? 2 : 5;
793 * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
794 * ---------------------------------------------------------
796 * Creates a Phi node. The in's order has to correspond to the order
797 * of in's of current_block. This is not checked by the library!
798 * If one of the predecessors is Unknown (as it has to be filled in
799 * later) optimizations are skipped. This is necessary to
800 * construct Phi nodes in loops. Leaving Unknown in the Phi after finishing
801 * the construction may have strange effects, especially for interprocedural
802 * representation and analysis.
805 * arity number of predecessors
806 * **in array with predecessors
807 * *mode The mode of it's inputs and output.
809 * A Phi node has as many inputs as the block it belongs to.
810 * Each input points to a definition of the same value on a
811 * different path in the control flow.
813 * The definition valid in this block.
815 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
816 * -----------------------------------------------------------------------------
818 * Creates a Mux node. This node implements the following semantic:
819 * If the sel node (which must be of mode_b) evaluates to true, its value is
820 * ir_true, else ir_false;
823 * OPERATIONS TO MANAGE MEMORY EXPLICITLY
824 * --------------------------------------
826 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode)
827 * ----------------------------------------------------------------
829 * The Load operation reads a value from memory.
832 * *store The current memory.
833 * *addr A pointer to the variable to be read in this memory.
834 * *mode The mode of the value to be loaded.
837 * The memory and a pointer to a variable in this memory.
839 * A tuple of the memory, a control flow to be taken in case of
840 * an exception and the loaded value.
842 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
843 * ----------------------------------------------------------------
845 * The Store operation writes a value to a variable in memory.
848 * The memory, a pointer to a variable in this memory and the value
849 * to write to this variable.
851 * A tuple of the changed memory and a control flow to be taken in
852 * case of an exception.
854 * ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
855 * -----------------------------------------------------------------------
859 * The Alloc node allocates a new variable. It can be specified whether the
860 * variable should be allocated to the stack or to the heap.
863 * *store The memory which shall contain the new variable.
864 * ** *size The number of bytes to allocate. Old. **
865 * *size We decided that the size easily can be derived from the type.
866 * This field is for allocating arrays, i.e., it gives the multiple
867 * of the size of alloc_type to allocate memory for.
868 * *alloc_type The type of the allocated variable.
869 * where Where to allocate the variable, either heap_alloc or stack_alloc.
872 * A memory and an unsigned integer.
874 * A tuple of the changed memory, a control flow to be taken in
875 * case of an exception and the pointer to the new variable.
877 * a.where Indicates where the variable is allocated.
878 * a.*type A pointer to the class the allocated data object
881 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
882 * -----------------------------------------------------------------------------------
886 * The Free node frees memory of the given variable.
889 * *store The memory which shall contain the new variable.
890 * *ptr The pointer to the object to free.
891 * *size The number of objects of type free_type to free in a sequence.
892 * *free_type The type of the freed variable.
893 * where Where the variable was allocated, either heap_alloc or stack_alloc.
896 * A memory, a pointer and an unsigned integer.
898 * The changed memory.
900 * f.*type A pointer to the type information of the freed data object.
904 * ir_node *new_Sync (int arity, ir_node **in)
905 * -------------------------------------------
907 * The Sync operation unifies several partial memory blocks. These blocks
908 * have to be pairwise disjunct or the values in common locations have to
909 * be identical. This operation allows to specify all operations that eventually
910 * need several partial memory blocks as input with a single entrance by
911 * unifying the memories with a preceding Sync operation.
914 * arity The number of memories to synchronize.
915 * **in An array of pointers to nodes that produce an output of
920 * The unified memory.
926 * ir_node *new_Bad (void)
927 * -----------------------
929 * Returns the unique Bad node current_ir_graph->bad.
930 * This node is used to express results of dead code elimination.
932 * ir_node *new_NoMem (void)
933 * -----------------------------------------------------------------------------------
935 * Returns the unique NoMem node current_ir_graph->no_mem.
936 * This node is used as input for operations that need a Memory, but do not
937 * change it like Div by const != 0, analyzed calls etc.
939 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
940 * ----------------------------------------------------------
942 * Selects one entry of a tuple. This is a hidden edge with attributes.
945 * *arg A node producing a tuple.
946 * *mode The mode of the value to project.
947 * proj The position of the value in the tuple.
953 * ir_node *new_Tuple (int arity, ir_node **in)
954 * --------------------------------------------
956 * Builds a Tuple from single values. This is needed to implement
957 * optimizations that remove a node that produced a tuple. The node can be
958 * replaced by the Tuple operation so that the following Proj nodes have not to
959 * be changed. (They are hard to find due to the implementation with pointers
960 * in only one direction.) The Tuple node is smaller than any other
961 * node, so that a node can be changed into a Tuple by just changing it's
962 * opcode and giving it a new in array.
965 * arity The number of tuple elements.
966 * **in An array containing pointers to the nodes producing the
969 * ir_node *new_Id (ir_node *val, ir_mode *mode)
970 * ---------------------------------------------
972 * The single output of the Id operation is it's input. Also needed
976 * HIGH LEVEL OPERATIONS
977 * ---------------------
979 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
980 * -----------------------------------------------------------------------------------
982 * Describes a high level block copy of a compound type from address src to
983 * address dst. Must be lowered to a Call to a runtime memory copy function.
986 * HIGH LEVEL OPERATIONS: Exception Support
987 * ----------------------------------------
988 * See TechReport 1999-14, chapter Exceptions.
990 * ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
991 * -----------------------------------------------------------------------------------
993 * Describes a high level type check. Must be lowered to a Call to a runtime check
996 * ir_node *new_Raise (ir_node *store, ir_node *obj)
997 * -------------------------------------------------
999 * Raises an exception. Unconditional change of control flow. Writes
1000 * an explicit Except variable to memory to pass it to the exception
1001 * handler. Must be lowered to a Call to a runtime check
1006 * A pointer to the Except variable.
1008 * A tuple of control flow and the changed memory state. The control flow
1009 * points to the exception handler if it is definied in this procedure,
1010 * else it points to the end_block.
1012 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
1013 * -----------------------------------------------------------------------------------
1015 * Describes a high level bounds check. Must be lowered to a Call to a runtime check
1019 * COPING WITH DATA OBJECTS
1020 * ========================
1022 * Two kinds of data objects have to be distinguished for generating
1023 * FIRM. First there are local variables other than arrays that are
1024 * known to be alias free. Second there are all other data objects.
1025 * For the first a common SSA representation is built, the second
1026 * are modeled by saving them to memory. The memory is treated as
1027 * a single local variable, the alias problem is hidden in the
1028 * content of this variable.
1030 * All values known in a Block are listed in the block's attribute,
1031 * block.**graph_arr which is used to automatically insert Phi nodes.
1032 * The following two funcions can be used to add a newly computed value
1033 * to the array, or to get the producer of a value, i.e., the current
1036 * inline void set_value (int pos, ir_node *value)
1037 * -----------------------------------------------
1039 * Has to be called for every assignment to a local variable. It
1040 * adds the value to the array of used values at position pos. Pos
1041 * has to be a unique identifier for an entry in the procedure's
1042 * definition table. It can be used to access the value again.
1043 * Requires current_block to be set correctly.
1045 * ir_node *get_value (int pos, ir_mode *mode)
1046 * -------------------------------------------
1048 * Returns the node defining the value referred to by pos. If the
1049 * value is not defined in this block a Phi node is generated and
1050 * all definitions reaching this Phi node are collected. It can
1051 * happen that the algorithm allocates an unnecessary Phi node,
1052 * e.g. if there is only one definition of this value, but this
1053 * definition reaches the currend block on several different
1054 * paths. This Phi node will be eliminated if optimizations are
1055 * turned on right after it's creation.
1056 * Requires current_block to be set correctly.
1058 * There are two special routines for the global store:
1060 * void set_store (ir_node *store)
1061 * -------------------------------
1063 * Adds the store to the array of known values at a reserved
1065 * Requires current_block to be set correctly.
1067 * ir_node *get_store (void)
1068 * -------------------------
1070 * Returns the node defining the actual store.
1071 * Requires current_block to be set correctly.
1074 * inline void keep_alive (ir_node *ka)
1075 * ------------------------------------
1077 * Keep this node alive because it is (might be) not in the control
1078 * flow from Start to End. Adds the node to the list in the end
1085 #include "firm_common.h"
1087 #include "dbginfo.h"
1089 /*-------------------------------------------------------------------------*/
1090 /* The raw interface */
1091 /*-------------------------------------------------------------------------*/
1093 /** Constructor for a Block node.
1095 * Constructs a mature block with the given predecessors. Use Unknown
1096 * nodes as predecessors to construct a block if the number of
1097 * predecessors is known, but not the predecessors themselves. This
1098 * constructor does not set current_block. It not be used with
1099 * automatic Phi node construction.
1101 * @param *db A Pointer for debug information.
1102 * @param irg The ir graph the block belongs to.
1103 * @param arity The number of control predecessors.
1104 * @param in[] An array of control predecessors. The length of
1105 * the array must be 'arity'. The constructor copies this array.
1107 ir_node *new_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1109 /** Constructor for a Start node.
1111 * @param *db A pointer for debug information.
1112 * @param *irg The ir graph the node belongs to.
1113 * @param *block The ir block the node belongs to.
1115 ir_node *new_rd_Start (dbg_info *db, ir_graph *irg, ir_node *block);
1117 /** Constructor for a End node.
1119 * @param *db A pointer for debug information.
1120 * @param *irg The ir graph the node belongs to.
1121 * @param *block The ir block the node belongs to.
1123 ir_node *new_rd_End (dbg_info *db, ir_graph *irg, ir_node *block);
1125 /** Constructor for a Jmp node.
1127 * Jmp represents control flow to a single control successor.
1129 * @param *db A pointer for debug information.
1130 * @param *irg The ir graph the node belongs to.
1131 * @param *block The ir block the node belongs to.
1133 ir_node *new_rd_Jmp (dbg_info *db, ir_graph *irg, ir_node *block);
1135 /** Constructor for an IJmp node.
1137 * IJmp represents control flow to a single control successor not
1138 * statically known i.e. an indirect Jmp.
1140 * @param *db A pointer for debug information.
1141 * @param *irg The ir graph the node belongs to.
1142 * @param *block The ir block the node belongs to.
1143 * @param *tgt The ir node representing the target address.
1145 ir_node *new_rd_IJmp (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *tgt);
1147 /** Constructor for a Break node.
1149 * Break represents control flow to a single control successor just as Jmp.
1150 * The blocks separated by a break may not be concatenated by an optimization.
1151 * It is used for the interprocedural representation where blocks are parted
1152 * behind Call nodes to represent the control flow to called procedures.
1154 * @param *db A pointer for debug information.
1155 * @param *irg The ir graph the node belong to.
1156 * @param *block The block the node belong to.
1158 ir_node *new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block);
1160 /** Constructor for a Cond node.
1162 * If c is mode_b represents a conditional branch (if/else). If c is
1163 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1164 * node, default Proj is 0.)
1166 * This is not consistent: Input to Cond is Is, Proj has as proj number
1169 * @param *db A pointer for debug information.
1170 * @param *irg The ir graph the node belongs to.
1171 * @param *block The ir block the node belongs to.
1172 * @param *c The conditions parameter. Can be of mode b or I_u.
1174 ir_node *new_rd_Cond (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
1176 /** Constructor for a Return node.
1178 * Returns the memory an zero or more return values. Only node that
1179 * can end regular control flow.
1181 * @param *db A pointer for debug information.
1182 * @param *irg The ir graph the node belongs to.
1183 * @param *block The ir block the node belongs to.
1184 * @param *store The state of memory.
1185 * @param arity Number of return values.
1186 * @param *in Array of length arity with return values. The constructor copies this array.
1188 ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
1189 ir_node *store, int arity, ir_node *in[]);
1191 /** Constructor for a Const_type node.
1193 * The constant represents a target value. This constructor sets high
1194 * level type information for the constant value.
1196 * @param *db A pointer for debug information.
1197 * @param *irg The ir graph the node belongs to.
1198 * @param *block The ir block the node belongs to.
1199 * @param *mode The mode of the operands and results.
1200 * @param *con Points to an entry in the constant table.
1201 * @param *tp The type of the constant.
1203 ir_node *new_rd_Const_type (dbg_info *db, ir_graph *irg, ir_node *block,
1204 ir_mode *mode, tarval *con, ir_type *tp);
1206 /** Constructor for a Const node.
1208 * Constructor for a Const node. The constant represents a target
1209 * value. Sets the type information to type_unknown. (No more
1210 * supported: If tv is entity derives a somehow useful type.)
1212 * @param *db A pointer for debug information.
1213 * @param *irg The ir graph the node belongs to.
1214 * @param *block The ir block the node belongs to.
1215 * @param *mode The mode of the operands and results.
1216 * @param *con Points to an entry in the constant table.
1218 ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block,
1219 ir_mode *mode, tarval *con);
1221 /** Constructor for a SymConst_type node.
1223 * This is the constructor for a symbolic constant.
1224 * There are four kinds of symbolic constants:
1225 * - type_tag The symbolic constant represents a type tag. The type the
1226 * tag stands for is given explicitly.
1227 * - size The symbolic constant represents the size of a type. The
1228 * type of which the constant represents the size is given
1230 * - addr_name The symbolic constant represents the address of an entity
1231 * (variable or method). The variable is indicated by a name
1232 * that is valid for linking.
1233 * - addr_ent The symbolic constant represents the address of an entity
1234 * (variable or method). The variable is given explicitly by
1237 * Inputs to the node:
1238 * No inputs except the block it belongs to.
1239 * Outputs of the node.
1240 * An unsigned integer (I_u) or a pointer (P).
1242 * Mention union in declaration so that the firmjni generator recognizes that
1243 * it can not cast the argument to an int.
1245 * @param *db A pointer for debug information.
1246 * @param *irg The ir graph the node belongs to.
1247 * @param *block The ir block the node belongs to.
1248 * @param symkind The kind of the symbolic constant: type_tag, size, addr_name or addr_ent.
1249 * @param value A type, entity or a ident depending on the SymConst kind.
1250 * @param tp The source type of the constant.
1252 ir_node *new_rd_SymConst_type (dbg_info *db, ir_graph *irg, ir_node *block, union symconst_symbol value,
1253 symconst_kind symkind, ir_type *tp);
1255 /** Constructor for a SymConst node.
1257 * Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */
1258 ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
1259 union symconst_symbol value, symconst_kind symkind);
1261 /** Constructor for a SymConst addr_ent 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_addr_ent (dbg_info *db, ir_graph *irg, entity *symbol, ir_type *tp);
1268 /** Constructor for a SymConst addr_name 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_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, ir_type *tp);
1275 /** Constructor for a SymConst type_tag node.
1277 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1278 * symconst_addr_ent.
1279 * Adds the SymConst to the start block of irg. */
1280 ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
1282 /** Constructor for a SymConst size node.
1284 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1285 * symconst_addr_ent.
1286 * Adds the SymConst to the start block of irg. */
1287 ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, ir_type *symbol, ir_type *tp);
1289 /** Constructor for a simpleSel node.
1291 * This is a shortcut for the new_rd_Sel() constructor. To be used for
1292 * Sel nodes that do not select from an array, i.e., have no index
1293 * inputs. It adds the two parameters 0, NULL.
1295 * @param *db A pointer for debug information.
1296 * @param *irg The ir graph the node belongs to.
1297 * @param *block The ir block the node belongs to.
1298 * @param *store The memory in which the object the entity should be
1299 * selected from is allocated.
1300 * @param *objptr The object from that the Sel operation selects a
1301 * single attribute out.
1302 * @param *ent The entity to select.
1304 ir_node *new_rd_simpleSel (dbg_info *db, ir_graph *irg, ir_node *block,
1305 ir_node *store, ir_node *objptr, entity *ent);
1307 /** Constructor for a Sel node.
1309 * The select node selects an entity (field or method) from an entity
1310 * with a compound type. It explicitly specifies the entity selected.
1311 * Dynamically the node may select entities that overwrite the given
1312 * entity. If the selected entity is an array element entity the Sel
1313 * node takes the required array indices as inputs.
1315 * @param *db A pointer for debug information.
1316 * @param *irg The ir graph the node belongs to.
1317 * @param *block The ir block the node belongs to.
1318 * @param *store The memory in which the object the entity should be selected
1319 * from is allocated.
1320 * @param *objptr A pointer to a compound entity the Sel operation selects a
1321 * single attribute from.
1322 * @param *n_index The number of array indices needed to select an array element entity.
1323 * @param *index[] If the compound entity is an array the indices of the selected
1324 * element entity. The constructor copies this array.
1325 * @param *ent The entity to select.
1327 ir_node *new_rd_Sel (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1328 ir_node *objptr, int n_index, ir_node *index[], entity *ent);
1330 /** Constructor for a Call node.
1332 * Represents all kinds of method and function calls.
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 *store The current memory state.
1338 * @param *callee A pointer to the called procedure.
1339 * @param arity The number of procedure parameters.
1340 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1341 * @param *tp Type information of the procedure called.
1343 ir_node *new_rd_Call (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1344 ir_node *callee, int arity, ir_node *in[], ir_type *tp);
1346 /** Constructor for a Add node.
1348 * @param *db A pointer for debug information.
1349 * @param *irg The ir graph the node belongs to.
1350 * @param *block The ir block the node belongs to.
1351 * @param *op1 The first operand.
1352 * @param *op2 The second operand.
1353 * @param *mode The mode of the operands and the result.
1355 ir_node *new_rd_Add (dbg_info *db, ir_graph *irg, ir_node *block,
1356 ir_node *op1, ir_node *op2, ir_mode *mode);
1358 /** Constructor for a Sub node.
1360 * @param *db A pointer for debug information.
1361 * @param *irg The ir graph the node belongs to.
1362 * @param *block The ir block the node belongs to.
1363 * @param *op1 The first operand.
1364 * @param *op2 The second operand.
1365 * @param *mode The mode of the operands and the result.
1367 ir_node *new_rd_Sub (dbg_info *db, ir_graph *irg, ir_node *block,
1368 ir_node *op1, ir_node *op2, ir_mode *mode);
1370 /** Constructor for a Minus node.
1372 * @param *db A pointer for debug information.
1373 * @param *irg The ir graph the node belongs to.
1374 * @param *block The ir block the node belongs to.
1375 * @param *op The operand .
1376 * @param *mode The mode of the operand and the result.
1378 ir_node *new_rd_Minus (dbg_info *db, ir_graph *irg, ir_node *block,
1379 ir_node *op, ir_mode *mode);
1381 /** Constructor for a Mul node.
1383 * @param *db A pointer for debug information.
1384 * @param *irg The ir graph the node belongs to.
1385 * @param *block The ir block the node belongs to.
1386 * @param *op1 The first operand.
1387 * @param *op2 The second operand.
1388 * @param *mode The mode of the operands and the result.
1390 ir_node *new_rd_Mul (dbg_info *db, ir_graph *irg, ir_node *block,
1391 ir_node *op1, ir_node *op2, ir_mode *mode);
1393 /** Constructor for a Quot node.
1395 * @param *db A pointer for debug information.
1396 * @param *irg The ir graph the node belongs to.
1397 * @param *block The ir block the node belongs to.
1398 * @param *memop The store needed to model exceptions
1399 * @param *op1 The first operand.
1400 * @param *op2 The second operand.
1402 ir_node *new_rd_Quot (dbg_info *db, ir_graph *irg, ir_node *block,
1403 ir_node *memop, ir_node *op1, ir_node *op2);
1405 /** Constructor for a DivMod node.
1407 * @param *db A pointer for debug information.
1408 * @param *irg The ir graph the node belongs to.
1409 * @param *block The ir block the node belongs to.
1410 * @param *memop The store needed to model exceptions
1411 * @param *op1 The first operand.
1412 * @param *op2 The second operand.
1414 ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
1415 ir_node *memop, ir_node *op1, ir_node *op2);
1417 /** Constructor for a Div node.
1419 * @param *db A pointer for debug information.
1420 * @param *irg The ir graph the node belongs to.
1421 * @param *block The ir block the node belongs to.
1422 * @param *memop The store needed to model exceptions
1423 * @param *op1 The first operand.
1424 * @param *op2 The second operand.
1426 ir_node *new_rd_Div (dbg_info *db, ir_graph *irg, ir_node *block,
1427 ir_node *memop, ir_node *op1, ir_node *op2);
1429 /** Constructor for a Mod node.
1431 * @param *db A pointer for debug information.
1432 * @param *irg The ir graph the node belongs to.
1433 * @param *block The ir block the node belongs to.
1434 * @param *memop The store needed to model exceptions
1435 * @param *op1 The first operand.
1436 * @param *op2 The second operand.
1438 ir_node *new_rd_Mod (dbg_info *db, ir_graph *irg, ir_node *block,
1439 ir_node *memop, ir_node *op1, ir_node *op2);
1441 /** Constructor for a Abs node.
1443 * @param *db A pointer for debug information.
1444 * @param *irg The ir graph the node belongs to.
1445 * @param *block The ir block the node belongs to.
1446 * @param *op The operand
1447 * @param *mode The mode of the operands and the result.
1449 ir_node *new_rd_Abs (dbg_info *db, ir_graph *irg, ir_node *block,
1450 ir_node *op, ir_mode *mode);
1452 /** Constructor for a And node.
1454 * @param *db A pointer for debug information.
1455 * @param *irg The ir graph the node belongs to.
1456 * @param *block The ir block the node belongs to.
1457 * @param *op1 The first operand.
1458 * @param *op2 The second operand.
1459 * @param *mode The mode of the operands and the result.
1461 ir_node *new_rd_And (dbg_info *db, ir_graph *irg, ir_node *block,
1462 ir_node *op1, ir_node *op2, ir_mode *mode);
1464 /** Constructor for a Or node.
1466 * @param *db A pointer for debug information.
1467 * @param *irg The ir graph the node belongs to.
1468 * @param *block The ir block the node belongs to.
1469 * @param *op1 The first operand.
1470 * @param *op2 The second operand.
1471 * @param *mode The mode of the operands and the result.
1473 ir_node *new_rd_Or (dbg_info *db, ir_graph *irg, ir_node *block,
1474 ir_node *op1, ir_node *op2, ir_mode *mode);
1476 /** Constructor for a Eor node.
1478 * @param *db A pointer for debug information.
1479 * @param *irg The ir graph the node belongs to.
1480 * @param *block The ir block the node belongs to.
1481 * @param *op1 The first operand.
1482 * @param *op2 The second operand.
1483 * @param *mode The mode of the operands and the results.
1485 ir_node *new_rd_Eor (dbg_info *db, ir_graph *irg, ir_node *block,
1486 ir_node *op1, ir_node *op2, ir_mode *mode);
1488 /** Constructor for a Not node.
1490 * @param *db A pointer for debug information.
1491 * @param *irg The ir graph the node belongs to.
1492 * @param *block The ir block the node belongs to.
1493 * @param *op The operand.
1494 * @param *mode The mode of the operand and the result.
1496 ir_node *new_rd_Not (dbg_info *db, ir_graph *irg, ir_node *block,
1497 ir_node *op, ir_mode *mode);
1499 /** Constructor for a Cmp node.
1501 * @param *db A pointer for debug information.
1502 * @param *irg The ir graph the node belongs to.
1503 * @param *block The ir block the node belongs to.
1504 * @param *op1 The first operand.
1505 * @param *op2 The second operand.
1507 ir_node *new_rd_Cmp (dbg_info *db, ir_graph *irg, ir_node *block,
1508 ir_node *op1, ir_node *op2);
1510 /** Constructor for a Shl node.
1512 * @param *db A pointer for debug information.
1513 * @param *irg The ir graph the node belongs to.
1514 * @param *block The ir block the node belongs to.
1515 * @param *op The operand.
1516 * @param *k The number of bits to shift the operand .
1517 * @param *mode The mode of the operand and the result.
1519 ir_node *new_rd_Shl (dbg_info *db, ir_graph *irg, ir_node *block,
1520 ir_node *op, ir_node *k, ir_mode *mode);
1522 /** Constructor for a Shr node.
1524 * @param *db A pointer for debug information.
1525 * @param *irg The ir graph the node belongs to.
1526 * @param *block The ir block the node belongs to.
1527 * @param *op The operand.
1528 * @param *k The number of bits to shift the operand .
1529 * @param *mode The mode of the operand and the result.
1531 ir_node *new_rd_Shr (dbg_info *db, ir_graph *irg, ir_node *block,
1532 ir_node *op, ir_node *k, ir_mode *mode);
1534 /** Constructor for a Shrs node.
1536 * @param *db A pointer for debug information.
1537 * @param *irg The ir graph the node belongs to.
1538 * @param *block The ir block the node belongs to.
1539 * @param *op The operand.
1540 * @param *k The number of bits to shift the operand.
1541 * @param *mode The mode of the operand and the result.
1543 ir_node *new_rd_Shrs (dbg_info *db, ir_graph *irg, ir_node *block,
1544 ir_node *op, ir_node *k, ir_mode *mode);
1546 /** Constructor for a Rot node.
1548 * @param *db A pointer for debug information.
1549 * @param *irg The ir graph the node belongs to.
1550 * @param *block The ir block the node belongs to.
1551 * @param *op The operand.
1552 * @param *k The number of bits to rotate the operand.
1553 * @param *mode The mode of the operand.
1555 ir_node *new_rd_Rot (dbg_info *db, ir_graph *irg, ir_node *block,
1556 ir_node *op, ir_node *k, ir_mode *mode);
1559 /** Constructor for a Conv node.
1561 * @param *db A pointer for debug information.
1562 * @param *irg The ir graph the node belongs to.
1563 * @param *block The ir block the node belongs to.
1564 * @param *op The operand.
1565 * @param *mode The mode of this the operand muss be converted .
1567 ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block,
1568 ir_node *op, ir_mode *mode);
1570 /** Constructor for a Cast node.
1572 * High level type cast.
1574 * @param *db A pointer for debug information.
1575 * @param *irg The ir graph the node belongs to.
1576 * @param *block The ir block the node belongs to.
1577 * @param *op The operand.
1578 * @param *to_tp The type of this the operand muss be casted .
1580 ir_node *new_rd_Cast (dbg_info *db, ir_graph *irg, ir_node *block,
1581 ir_node *op, ir_type *to_tp);
1583 /** Constructor for a Carry node.
1585 * @param *db A pointer for debug information.
1586 * @param *irg The ir graph the node belongs to.
1587 * @param *block The ir block the node belongs to.
1588 * @param *op1 The first operand.
1589 * @param *op2 The second operand.
1590 * @param *mode The mode of the operands and the result.
1592 ir_node *new_rd_Carry (dbg_info *db, ir_graph *irg, ir_node *block,
1593 ir_node *op1, ir_node *op2, ir_mode *mode);
1595 /** Constructor for a Borrow node.
1597 * @param *db A pointer for debug information.
1598 * @param *irg The ir graph the node belongs to.
1599 * @param *block The ir block the node belongs to.
1600 * @param *op1 The first operand.
1601 * @param *op2 The second operand.
1602 * @param *mode The mode of the operands and the result.
1604 ir_node *new_rd_Borrow (dbg_info *db, ir_graph *irg, ir_node *block,
1605 ir_node *op1, ir_node *op2, ir_mode *mode);
1607 /** Constructor for a Phi node.
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 arity The number of predecessors
1613 * @param *in[] Array with predecessors. The constructor copies this array.
1614 * @param *mode The mode of it's inputs and output.
1616 ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
1617 ir_node *in[], ir_mode *mode);
1619 /** Constructor for a Load node.
1621 * @param *db A pointer for debug information.
1622 * @param *irg The ir graph the node belongs to.
1623 * @param *block The ir block the node belongs to.
1624 * @param *store The current memory
1625 * @param *adr A pointer to the variable to be read in this memory.
1626 * @param *mode The mode of the value to be loaded.
1628 ir_node *new_rd_Load (dbg_info *db, ir_graph *irg, ir_node *block,
1629 ir_node *store, ir_node *adr, ir_mode *mode);
1631 /** Constructor for a Store node.
1633 * @param *db A pointer for debug information.
1634 * @param *irg The ir graph the node belongs to.
1635 * @param *block The ir block the node belongs to.
1636 * @param *store The current memory
1637 * @param *adr A pointer to the variable to be read in this memory.
1638 * @param *val The value to write to this variable.
1640 ir_node *new_rd_Store (dbg_info *db, ir_graph *irg, ir_node *block,
1641 ir_node *store, ir_node *adr, ir_node *val);
1643 /** Constructor for a Alloc node.
1645 * The Alloc node extends the memory by space for an entity of type alloc_type.
1647 * @param *db A pointer for debug information.
1648 * @param *irg The ir graph the node belongs to.
1649 * @param *block The ir block the node belongs to.
1650 * @param *store The memory which shall contain the new variable.
1651 * @param *size The number of bytes to allocate.
1652 * @param *alloc_type The type of the allocated variable.
1653 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
1655 ir_node *new_rd_Alloc (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1656 ir_node *size, ir_type *alloc_type, where_alloc where);
1658 /** Constructor for a Free node.
1660 * Frees the memory occupied by the entity pointed to by the pointer
1661 * arg. Type indicates the type of the entity the argument points to.
1663 * @param *db A pointer for debug information.
1664 * @param *irg The ir graph the node belongs to.
1665 * @param *block The ir block the node belongs to.
1666 * @param *store The memory which shall contain the new variable.
1667 * @param *ptr The pointer to the object to free.
1668 * @param *size The number of objects of type free_type to free in a sequence.
1669 * @param *free_type The type of the freed variable.
1670 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
1672 ir_node *new_rd_Free (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1673 ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
1675 /** Constructor for a Sync node.
1677 * Merges several memory values. The node assumes that a variable
1678 * either occurs only in one of the memories, or it contains the same
1679 * value in all memories where it occurs.
1681 * @param *db A pointer for debug information.
1682 * @param *irg The ir graph the node belongs to.
1683 * @param *block The ir block the node belongs to.
1684 * @param arity The number of memories to synchronize.
1685 * @param *in[] An array of pointers to nodes that produce an output of type
1686 * memory. The constructor copies this array.
1688 ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
1690 /** Constructor for a Proj node.
1692 * Projects a single value out of a tuple. The parameter proj gives the
1693 * position of the value within the tuple.
1695 * @param *db A pointer for debug information.
1696 * @param *irg The ir graph the node belongs to.
1697 * @param *block The ir block the node belongs to.
1698 * @param arg A node producing a tuple. The node must have mode_T.
1699 * @param *mode The mode of the value to project.
1700 * @param proj The position of the value in the tuple.
1702 ir_node *new_rd_Proj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1703 ir_mode *mode, long proj);
1705 /** Constructor for a defaultProj node.
1707 * Represents the default control flow of a Switch-Cond node.
1709 * @param *db A pointer for debug information.
1710 * @param *irg The ir graph the node belongs to.
1711 * @param *block The ir block the node belongs to.
1712 * @param arg A node producing a tuple.
1713 * @param max_proj The end position of the value in the tuple.
1715 ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1718 /** Constructor for a Tuple node.
1720 * This is an auxiliary node to replace a node that returns a tuple
1721 * without changing the corresponding Proj nodes.
1723 * @param *db A pointer for debug information.
1724 * @param *irg The ir graph the node belongs to.
1725 * @param *block The ir block the node belongs to.
1726 * @param arity The number of tuple elements.
1727 * @param *in[] An array containing pointers to the nodes producing the tuple
1728 * elements. The constructor copies this array.
1730 ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
1731 int arity, ir_node *in[]);
1733 /** Constructor for a Id node.
1735 * This is an auxiliary node to replace a node that returns a single
1738 * @param *db A pointer for debug information.
1739 * @param *irg The ir graph the node belongs to.
1740 * @param *block The ir block the node belongs to.
1741 * @param *val The value
1742 * @param *mode The mode of *val.
1744 ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
1745 ir_node *val, ir_mode *mode);
1747 /** Constructor for a Bad node.
1749 * Returns the unique Bad node of the graph. The same as
1752 * @param *irg The ir graph the node belongs to.
1754 ir_node *new_rd_Bad (ir_graph *irg);
1756 /** Constructor for a Confirm node.
1758 * Specifies constraints for a value. To support dataflow analyses.
1760 * Example: If the value never exceeds '100' this is expressed by placing a
1761 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
1763 * @param *irg The ir graph the node belong to.
1764 * @param *block The ir block the node belong to.
1765 * @param *db A pointer for debug information.
1766 * @param *val The value we express a constraint for
1767 * @param *bound The value to compare against. Must be a firm node, typically a constant.
1768 * @param cmp The compare operation.
1770 ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
1771 ir_node *val, ir_node *bound, pn_Cmp cmp);
1773 /** Constructor for an Unknown node.
1775 * Represents an arbitrary value. Places the node in the start block.
1777 * @param *irg The ir graph the node belongs to.
1778 * @param *m The mode of the unknown value.
1780 ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
1782 /** Constructor for a CallBegin node.
1784 * CallBegin represents control flow depending of the pointer value
1785 * representing the called method to the called methods. The
1786 * constructor copies the method pointer input from the passed Call
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 *callee The call node visible in the intra procedural view.
1794 ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
1796 /** Constructor for a EndReg node.
1798 * Used to represent regular procedure end in interprocedual view.
1800 * @param *db A pointer for debug information.
1801 * @param *irg The ir graph the node belong to.
1802 * @param *block The block the node belong to.
1804 ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
1806 /** Constructor for a EndExcept node.
1808 * Used to represent exceptional procedure end in interprocedural view.
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.
1814 ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
1816 /** Constructor for a Filter node.
1818 * Adds the node to the block in current_ir_block. Filter is a node
1819 * with two views used to construct the interprocedural view. In
1820 * intraprocedural view its semantics are identical to the Proj node.
1821 * In interprocedural view the Filter performs the Phi operation on
1822 * method parameters or results. Other than a Phi a Filter node may
1823 * not be removed if it has only a single input.
1825 * The constructor builds the Filter in intraprocedural view.
1827 * @param *db A pointer for debug information.
1828 * @param *irg The ir graph the node belong to.
1829 * @param *block The block the node belong to.
1830 * @param *arg The tuple value to project from.
1831 * @param *mode The mode of the projected value.
1832 * @param proj The position in the tuple to project from.
1834 ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1835 ir_mode *mode, long proj);
1837 /** Constructor for a NoMem node.
1839 * Returns the unique NoMem node of the graph. The same as
1842 * @param *irg The ir graph the node belongs to.
1844 ir_node *new_rd_NoMem (ir_graph *irg);
1846 /** Constructor for a Mux node.
1848 * @param *db A pointer for debug information.
1849 * @param *irg The ir graph the node belong to.
1850 * @param *block The block the node belong to.
1851 * @param *sel The ir_node that calculates the boolean select.
1852 * @param *ir_true The ir_node that calculates the true result.
1853 * @param *ir_false The ir_node that calculates the false result.
1854 * @param *mode The mode of the node (and it_true and ir_false).
1856 ir_node *new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block,
1857 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
1859 /** Constructor for a CopyB node.
1861 * @param *db A pointer for debug information.
1862 * @param *irg The ir graph the node belong to.
1863 * @param *block The block the node belong to.
1864 * @param *store The current memory
1865 * @param *dst The ir_node that represents the destination address.
1866 * @param *src The ir_node that represents the source address.
1867 * @param *data_type The type of the copied data
1869 ir_node *new_rd_CopyB(dbg_info *db, ir_graph *irg, ir_node *block,
1870 ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
1872 /** Constructor for a InstOf node.
1874 * A High-Level Type check.
1876 * @param *db A pointer for debug information.
1877 * @param *irg The ir graph the node belongs to.
1878 * @param *block The ir block the node belongs to.
1879 * @param *store The memory in which the object the entity should be selected
1880 * from is allocated.
1881 * @param *objptr A pointer to a object of a class type.
1882 * @param *type The type of which objptr must be.
1884 ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1885 ir_node *objptr, ir_type *type);
1887 /** Constructor for a Raise node.
1889 * A High-Level Exception throw.
1891 * @param *db A pointer for debug information.
1892 * @param *irg The ir graph the node belongs to.
1893 * @param *block The ir block the node belongs to.
1894 * @param *store The current memory.
1895 * @param *obj A pointer to the Except variable.
1897 ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
1898 ir_node *store, ir_node *obj);
1900 /** Constructor for a Bound node.
1902 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
1904 * @param *db A pointer for debug information.
1905 * @param *irg The ir graph the node belong to.
1906 * @param *block The block the node belong to.
1907 * @param *store The current memory
1908 * @param *idx The ir_node that represents an index.
1909 * @param *lower The ir_node that represents the lower bound for the index.
1910 * @param *upper The ir_node that represents the upper bound for the index.
1912 ir_node *new_rd_Bound(dbg_info *db, ir_graph *irg, ir_node *block,
1913 ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
1915 /*-------------------------------------------------------------------------*/
1916 /* The raw interface without debug support */
1917 /*-------------------------------------------------------------------------*/
1919 /** Constructor for a Block node.
1921 * Constructs a mature block with the given predecessors. Use Unknown
1922 * nodes as predecessors to construct a block if the number of
1923 * predecessors is known, but not the predecessors themselves. This
1924 * constructor does not set current_block. It not be used with
1925 * automatic Phi node construction.
1928 * @param irg The ir graph the block belongs to.
1929 * @param arity The number of control predecessors.
1930 * @param in[] An array of control predecessors. The length of
1931 * the array must be 'arity'. The constructor copies this array.
1933 ir_node *new_r_Block (ir_graph *irg, int arity, ir_node *in[]);
1935 /** Constructor for a Start node.
1937 * @param *irg The ir graph the node belongs to.
1938 * @param *block The ir block the node belongs to.
1940 ir_node *new_r_Start (ir_graph *irg, ir_node *block);
1942 /** Constructor for a End node.
1944 * @param *irg The ir graph the node belongs to.
1945 * @param *block The ir block the node belongs to.
1947 ir_node *new_r_End (ir_graph *irg, ir_node *block);
1949 /** Constructor for a Jmp node.
1951 * Jmp represents control flow to a single control successor.
1953 * @param *irg The ir graph the node belongs to.
1954 * @param *block The ir block the node belongs to.
1956 ir_node *new_r_Jmp (ir_graph *irg, ir_node *block);
1958 /** Constructor for an IJmp node.
1960 * IJmp represents control flow to a single control successor not
1961 * statically known i.e. an indirect Jmp.
1963 * @param *irg The ir graph the node belongs to.
1964 * @param *block The ir block the node belongs to.
1965 * @param *tgt The ir node representing the target address.
1967 ir_node *new_r_IJmp (ir_graph *irg, ir_node *block, ir_node *tgt);
1969 /** Constructor for a Cond node.
1971 * If c is mode_b represents a conditional branch (if/else). If c is
1972 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1973 * node, default Proj is 0.)
1975 * This is not consistent: Input to Cond is Is, Proj has as proj number
1978 * @param *irg The ir graph the node belongs to.
1979 * @param *block The ir block the node belongs to.
1980 * @param *c The conditions parameter.Can be of mode b or I_u.
1982 ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c);
1984 /** Constructor for a Return node.
1986 * Returns the memory an zero or more return values. Only node that
1987 * can end regular control flow.
1989 * @param *irg The ir graph the node belongs to.
1990 * @param *block The ir block the node belongs to.
1991 * @param *store The state of memory.
1992 * @param arity Number of array indices.
1993 * @param *in[] Array with index inputs to the node. The constructor copies this array.
1995 ir_node *new_r_Return (ir_graph *irg, ir_node *block,
1996 ir_node *store, int arity, ir_node *in[]);
1998 /** Constructor for a Const node.
2000 * Constructor for a Const node. The constant represents a target
2001 * value. Sets the type information to type_unknown. (No more
2002 * supported: If tv is entity derives a somehow useful type.)
2004 * @param *irg The ir graph the node belongs to.
2005 * @param *block The ir block the node belongs to.
2006 * @param *mode The mode of the operands and the results.
2007 * @param *con Points to an entry in the constant table.
2009 ir_node *new_r_Const (ir_graph *irg, ir_node *block,
2010 ir_mode *mode, tarval *con);
2012 /** Constructor for a Const node.
2014 * Constructor for a Const node. The constant represents a target
2015 * value. Sets the type information to type_unknown. (No more
2016 * supported: If tv is entity derives a somehow useful type.)
2018 * @param *irg The ir graph the node belongs to.
2019 * @param *block The ir block the node belongs to.
2020 * @param *mode The mode of the operands and the results.
2021 * @param value A value from which the tarval is made.
2023 ir_node *new_r_Const_long(ir_graph *irg, ir_node *block,
2024 ir_mode *mode, long value);
2026 /** Constructor for a Const_type node.
2028 * The constant represents a target value. This constructor sets high
2029 * level type information for the constant value.
2031 * @param *irg The ir graph the node belongs to.
2032 * @param *block The ir block the node belongs to.
2033 * @param *mode The mode of the operands and results.
2034 * @param *con Points to an entry in the constant table.
2035 * @param *tp The type of the constant.
2037 ir_node *new_r_Const_type(ir_graph *irg, ir_node *block,
2038 ir_mode *mode, tarval *con, ir_type *tp);
2040 /** Constructor for a SymConst node.
2042 * This is the constructor for a symbolic constant.
2043 * There are four kinds of symbolic constants:
2044 * - type_tag The symbolic constant represents a type tag. The type the
2045 * tag stands for is given explicitly.
2046 * - size The symbolic constant represents the size of a type. The
2047 * type of which the constant represents the size is given
2049 * - addr_name The symbolic constant represents the address of an entity
2050 * (variable or method). The variable is indicated by a name
2051 * that is valid for linking.
2052 * - addr_ent The symbolic constant represents the address of an entity
2053 * (variable or method). The variable is given explicitly by
2056 * Inputs to the node:
2057 * No inputs except the block it belongs to.
2058 * Outputs of the node.
2059 * An unsigned integer (I_u) or a pointer (P).
2061 * @param *irg The ir graph the node belongs to.
2062 * @param *block The ir block the node belongs to.
2063 * @param value A type, entity or a ident depending on the SymConst kind.
2064 * @param symkind The kind of the symbolic constant: type_tag, size or link_info.
2066 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
2067 union symconst_symbol value, symconst_kind symkind);
2069 /** Constructor for a simpleSel node.
2071 * This is a shortcut for the new_d_Sel() constructor. To be used for
2072 * Sel nodes that do not select from an array, i.e., have no index
2073 * inputs. It adds the two parameters 0, NULL.
2075 * @param *irg The ir graph the node belongs to.
2076 * @param *block The ir block the node belongs to.
2077 * @param *store The memory in which the object the entity should be selected
2078 * from is allocated.
2079 * @param *objptr The object from that the Sel operation selects a
2080 * single attribute out.
2081 * @param *ent The entity to select.
2083 ir_node *new_r_simpleSel(ir_graph *irg, ir_node *block, ir_node *store,
2084 ir_node *objptr, entity *ent);
2086 /** Constructor for a Sel node.
2088 * The select node selects an entity (field or method) from an entity
2089 * with a compound type. It explicitly specifies the entity selected.
2090 * Dynamically the node may select entities that overwrite the given
2091 * entity. If the selected entity is an array element entity the Sel
2092 * node takes the required array indices as inputs.
2094 * @param *irg The ir graph the node belongs to.
2095 * @param *block The ir block the node belongs to.
2096 * @param *store The memory in which the object the entity should be selected
2097 * from is allocated.
2098 * @param *objptr A pointer to a compound entity the Sel operation selects a
2099 * single attribute from.
2100 * @param *n_index The number of array indices needed to select an array element entity.
2101 * @param *index[] If the compound entity is an array the indices of the selected
2102 * element entity. The constructor copies this array.
2103 * @param *ent The entity to select.
2105 ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store,
2106 ir_node *objptr, int n_index, ir_node *index[],
2109 /** Constructor for a Call node.
2111 * Represents all kinds of method and function calls.
2113 * @param *irg The ir graph the node belongs to.
2114 * @param *block The ir block the node belongs to.
2115 * @param *store The actual store.
2116 * @param *callee A pointer to the called procedure.
2117 * @param arity The number of procedure parameters.
2118 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2119 * @param *tp Type information of the procedure called.
2121 ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
2122 ir_node *callee, int arity, ir_node *in[],
2125 /** Constructor for a Add node.
2127 * @param *irg The ir graph the node belongs to.
2128 * @param *block The ir block the node belongs to.
2129 * @param *op1 The first operand.
2130 * @param *op2 The second operand.
2131 * @param *mode The mode of the operands and the result.
2133 ir_node *new_r_Add (ir_graph *irg, ir_node *block,
2134 ir_node *op1, ir_node *op2, ir_mode *mode);
2137 * Constructor for a Sub node.
2139 * @param *irg The ir graph the node belongs to.
2140 * @param *block The ir block the node belongs to.
2141 * @param *op1 The first operand.
2142 * @param *op2 The second operand.
2143 * @param *mode The mode of the operands and the results.
2145 ir_node *new_r_Sub (ir_graph *irg, ir_node *block,
2146 ir_node *op1, ir_node *op2, ir_mode *mode);
2148 /** Constructor for a Minus node.
2150 * @param *irg The ir graph the node belongs to.
2151 * @param *block The ir block the node belongs to.
2152 * @param *op The operand.
2153 * @param *mode The mode of the operand and the result.
2155 ir_node *new_r_Minus (ir_graph *irg, ir_node *block,
2156 ir_node *op, ir_mode *mode);
2157 /** Constructor for a Mul node.
2159 * @param *irg The ir graph the node belongs to.
2160 * @param *block The ir block the node belongs to.
2161 * @param *op1 The first operand.
2162 * @param *op2 The second operand.
2163 * @param *mode The mode of the operands and the result.
2165 ir_node *new_r_Mul (ir_graph *irg, ir_node *block,
2166 ir_node *op1, ir_node *op2, ir_mode *mode);
2168 /** Constructor for a Quot node.
2170 * @param *irg The ir graph the node belongs to.
2171 * @param *block The ir block the node belongs to.
2172 * @param *memop The store needed to model exceptions
2173 * @param *op1 The first operand.
2174 * @param *op2 The second operand.
2176 ir_node *new_r_Quot (ir_graph *irg, ir_node *block,
2177 ir_node *memop, ir_node *op1, ir_node *op2);
2179 /** Constructor for a DivMod node.
2181 * @param *irg The ir graph the node belongs to.
2182 * @param *block The ir block the node belongs to.
2183 * @param *memop The store needed to model exceptions
2184 * @param *op1 The first operand.
2185 * @param *op2 The second operand.
2187 ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
2188 ir_node *memop, ir_node *op1, ir_node *op2);
2190 /** Constructor for a Div node.
2192 * @param *irg The ir graph the node belongs to.
2193 * @param *block The ir block the node belongs to.
2194 * @param *memop The store needed to model exceptions
2195 * @param *op1 The first operand.
2196 * @param *op2 The second operand.
2198 ir_node *new_r_Div (ir_graph *irg, ir_node *block,
2199 ir_node *memop, ir_node *op1, ir_node *op2);
2201 /** Constructor for a Mod node.
2203 * @param *irg The ir graph the node belongs to.
2204 * @param *block The ir block the node belongs to.
2205 * @param *memop The store needed to model exceptions
2206 * @param *op1 The first operand.
2207 * @param *op2 The second operand.
2209 ir_node *new_r_Mod (ir_graph *irg, ir_node *block,
2210 ir_node *memop, ir_node *op1, ir_node *op2);
2212 /** Constructor for a Abs node.
2214 * @param *irg The ir graph the node belongs to.
2215 * @param *block The ir block the node belongs to.
2216 * @param *op The operand
2217 * @param *mode The mode of the operands and the result.
2219 ir_node *new_r_Abs (ir_graph *irg, ir_node *block,
2220 ir_node *op, ir_mode *mode);
2222 /** Constructor for a And node.
2224 * @param *irg The ir graph the node belongs to.
2225 * @param *block The ir block the node belongs to.
2226 * @param *op1 The first operand.
2227 * @param *op2 The second operand.
2228 * @param *mode The mode of the operands and the result.
2230 ir_node *new_r_And (ir_graph *irg, ir_node *block,
2231 ir_node *op1, ir_node *op2, ir_mode *mode);
2233 /** Constructor for a Or node.
2235 * @param *irg The ir graph the node belongs to.
2236 * @param *block The ir block the node belongs to.
2237 * @param *op1 The first operand.
2238 * @param *op2 The second operand.
2239 * @param *mode The mode of the operands and the result.
2241 ir_node *new_r_Or (ir_graph *irg, ir_node *block,
2242 ir_node *op1, ir_node *op2, ir_mode *mode);
2244 /** Constructor for a Eor node.
2246 * @param *irg The ir graph the node belongs to.
2247 * @param *block The ir block the node belongs to.
2248 * @param *op1 The first operand.
2249 * @param *op2 The second operand.
2250 * @param *mode The mode of the operands and the results.
2252 ir_node *new_r_Eor (ir_graph *irg, ir_node *block,
2253 ir_node *op1, ir_node *op2, ir_mode *mode);
2255 /** Constructor for a Not node.
2257 * @param *irg The ir graph the node belongs to.
2258 * @param *block The ir block the node belongs to.
2259 * @param *op The operand.
2260 * @param *mode The mode of the operand and the result.
2262 ir_node *new_r_Not (ir_graph *irg, ir_node *block,
2263 ir_node *op, ir_mode *mode);
2265 /** Constructor for a Cmp node.
2267 * @param *irg The ir graph the node belongs to.
2268 * @param *block The ir block the node belongs to.
2269 * @param *op1 The first operand.
2270 * @param *op2 The second operand.
2272 ir_node *new_r_Cmp (ir_graph *irg, ir_node *block,
2273 ir_node *op1, ir_node *op2);
2275 /** Constructor for a Shl node.
2277 * @param *irg The ir graph the node belongs to.
2278 * @param *block The ir block the node belongs to.
2279 * @param *op The operand.
2280 * @param *k The number of bits to shift the operand .
2281 * @param *mode The mode of the operand and the result.
2283 ir_node *new_r_Shl (ir_graph *irg, ir_node *block,
2284 ir_node *op, ir_node *k, ir_mode *mode);
2286 /** Constructor for a Shr node.
2288 * @param *irg The ir graph the node belongs to.
2289 * @param *block The ir block the node belongs to.
2290 * @param *op The operand.
2291 * @param *k The number of bits to shift the operand .
2292 * @param *mode The mode of the operand and the result.
2294 ir_node *new_r_Shr (ir_graph *irg, ir_node *block,
2295 ir_node *op, ir_node *k, ir_mode *mode);
2298 * Constructor for a Shrs node.
2300 * @param *irg The ir graph the node belongs to.
2301 * @param *block The ir block the node belongs to.
2302 * @param *op The operand.
2303 * @param *k The number of bits to shift the operand.
2304 * @param *mode The mode of the operand and the result.
2306 ir_node *new_r_Shrs (ir_graph *irg, ir_node *block,
2307 ir_node *op, ir_node *k, ir_mode *mode);
2309 /** Constructor for a Rot node.
2311 * @param *irg The ir graph the node belongs to.
2312 * @param *block The ir block the node belongs to.
2313 * @param *op The operand.
2314 * @param *k The number of bits to rotate the operand.
2315 * @param *mode The mode of the operand.
2317 ir_node *new_r_Rot (ir_graph *irg, ir_node *block,
2318 ir_node *op, ir_node *k, ir_mode *mode);
2320 /** Constructor for a Conv node.
2322 * @param *irg The ir graph the node belongs to.
2323 * @param *block The ir block the node belongs to.
2324 * @param *op The operand.
2325 * @param *mode The mode of this the operand muss be converted .
2327 ir_node *new_r_Conv (ir_graph *irg, ir_node *block,
2328 ir_node *op, ir_mode *mode);
2330 /** Constructor for a Cast node.
2332 * High level type cast
2334 * @param *irg The ir graph the node belongs to.
2335 * @param *block The ir block the node belongs to.
2336 * @param *op The operand.
2337 * @param *to_tp The type of this the operand muss be casted .
2339 ir_node *new_r_Cast (ir_graph *irg, ir_node *block,
2340 ir_node *op, ir_type *to_tp);
2342 /** Constructor for a Carry node.
2344 * @param *irg The ir graph the node belongs to.
2345 * @param *block The ir block the node belongs to.
2346 * @param *op1 The first operand.
2347 * @param *op2 The second operand.
2348 * @param *mode The mode of the operands and the result.
2350 ir_node *new_r_Carry (ir_graph *irg, ir_node *block,
2351 ir_node *op1, ir_node *op2, ir_mode *mode);
2354 * Constructor for a Borrow node.
2356 * @param *irg The ir graph the node belongs to.
2357 * @param *block The ir block the node belongs to.
2358 * @param *op1 The first operand.
2359 * @param *op2 The second operand.
2360 * @param *mode The mode of the operands and the results.
2362 ir_node *new_r_Borrow (ir_graph *irg, ir_node *block,
2363 ir_node *op1, ir_node *op2, ir_mode *mode);
2365 /** Constructor for a Phi node.
2367 * @param *irg The ir graph the node belongs to.
2368 * @param *block The ir block the node belongs to.
2369 * @param arity The number of predecessors
2370 * @param *in[] Array with predecessors. The constructor copies this array.
2371 * @param *mode The mode of it's inputs and output.
2373 ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity,
2374 ir_node *in[], ir_mode *mode);
2376 /** Constructor for a Load node.
2378 * @param *irg The ir graph the node belongs to.
2379 * @param *block The ir block the node belongs to.
2380 * @param *store The current memory
2381 * @param *adr A pointer to the variable to be read in this memory.
2382 * @param *mode The mode of the value to be loaded.
2384 ir_node *new_r_Load (ir_graph *irg, ir_node *block,
2385 ir_node *store, ir_node *adr, ir_mode *mode);
2387 /** Constructor for a Store node.
2389 * @param *irg The ir graph the node belongs to.
2390 * @param *block The ir block the node belongs to.
2391 * @param *store The current memory
2392 * @param *adr A pointer to the variable to be read in this memory.
2393 * @param *val The value to write to this variable.
2395 ir_node *new_r_Store (ir_graph *irg, ir_node *block,
2396 ir_node *store, ir_node *adr, ir_node *val);
2398 /** Constructor for a Alloc node.
2400 * The Alloc node extends the memory by space for an entity of type alloc_type.
2402 * @param *irg The ir graph the node belongs to.
2403 * @param *block The ir block the node belongs to.
2404 * @param *store The memory which shall contain the new variable.
2405 * @param *size The number of bytes to allocate.
2406 * @param *alloc_type The type of the allocated variable.
2407 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2409 ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store,
2410 ir_node *size, ir_type *alloc_type, where_alloc where);
2412 /** Constructor for a Free node.
2414 * Frees the memory occupied by the entity pointed to by the pointer
2415 * arg. Type indicates the type of the entity the argument points to.
2417 * @param *irg The ir graph the node belongs to.
2418 * @param *block The ir block the node belongs to.
2419 * @param *store The memory which shall contain the new variable.
2420 * @param *ptr The pointer to the object to free.
2421 * @param *size The number of objects of type free_type to free in a sequence.
2422 * @param *free_type The type of the freed variable.
2423 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2425 ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store,
2426 ir_node *ptr, ir_node *size, ir_type *free_type, where_alloc where);
2428 /** Constructor for a Sync node.
2430 * Merges several memory values. The node assumes that a variable
2431 * either occurs only in one of the memories, or it contains the same
2432 * value in all memories where it occurs.
2434 * @param *irg The ir graph the node belongs to.
2435 * @param *block The ir block the node belongs to.
2436 * @param arity The number of memories to synchronize.
2437 * @param *in[] An array of pointers to nodes that produce an output of type memory.
2438 * The constructor copies this array.
2440 ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2442 /** Constructor for a Proj node.
2444 * Projects a single value out of a tuple. The parameter proj gives the
2445 * position of the value within the tuple.
2447 * @param *irg The ir graph the node belongs to.
2448 * @param *block The ir block the node belongs to.
2449 * @param arg A node producing a tuple.
2450 * @param *mode The mode of the value to project.
2451 * @param proj The position of the value in the tuple.
2453 ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg,
2454 ir_mode *mode, long proj);
2456 /** Constructor for a defaultProj node.
2458 * Represents the default control flow of a Switch-Cond node.
2460 * @param *irg The ir graph the node belongs to.
2461 * @param *block The ir block the node belongs to.
2462 * @param arg A node producing a tuple.
2463 * @param max_proj The end position of the value in the tuple.
2465 ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj);
2468 /** Constructor for a Tuple node.
2470 * This is an auxiliary node to replace a node that returns a tuple
2471 * without changing the corresponding Proj nodes.
2473 * @param *irg The ir graph the node belongs to.
2474 * @param *block The ir block the node belongs to.
2475 * @param arity The number of tuple elements.
2476 * @param *in[] An array containing pointers to the nodes producing the tuple elements.
2477 * The constructor copies this array.
2479 ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2481 /** Constructor for a Id node.
2483 * This is an auxiliary node to replace a node that returns a single
2486 * @param *irg The ir graph the node belongs to.
2487 * @param *block The ir block the node belongs to.
2488 * @param *val The operand to Id.
2489 * @param *mode The mode of *val.
2491 ir_node *new_r_Id (ir_graph *irg, ir_node *block,
2492 ir_node *val, ir_mode *mode);
2494 /** Constructor for a Bad node.
2496 * Returns the unique Bad node of the graph. The same as
2499 * @param *irg The ir graph the node belongs to.
2502 ir_node *new_r_Bad (ir_graph *irg);
2504 /** Constructor for a Confirm node.
2506 * Specifies constraints for a value. To support dataflow analyses.
2508 * Example: If the value never exceeds '100' this is expressed by placing a
2509 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
2511 * @param *irg The ir graph the node belong to.
2512 * @param *block The ir block the node belong to.
2513 * @param *val The value we express a constraint for
2514 * @param *bound The value to compare against. Must be a firm node, typically a constant.
2515 * @param cmp The compare operation.
2517 ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
2518 ir_node *val, ir_node *bound, pn_Cmp cmp);
2520 /** Constructor for a Unknown node.
2522 * Represents an arbitrary value. Places the node in
2525 * @param *irg The ir graph the node belongs to.
2526 * @param *m The mode of the unknown value.
2528 ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2530 /** Constructor for a CallBegin node.
2532 * CallBegin represents control flow depending of the pointer value
2533 * representing the called method to the called methods. The
2534 * constructor copies the method pointer input from the passed Call
2537 * @param *irg The ir graph the node belong to.
2538 * @param *block The block the node belong to.
2539 * @param *callee The call node visible in the intra procedural view.
2541 ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
2543 /** Constructor for a EndReg node.
2545 * Used to represent regular procedure end in interprocedual view.
2547 * @param *irg The ir graph the node belong to.
2548 * @param *block The block the node belong to.
2550 ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
2552 /** Constructor for a EndExcept node.
2554 * Used to represent exceptional procedure end in interprocedural view.
2556 * @param *irg The ir graph the node belong to.
2557 * @param *block The block the node belong to.
2559 ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
2561 /** Constructor for a Break node.
2563 * Break represents control flow to a single control successor just as Jmp.
2564 * The blocks separated by a break may not be concatenated by an optimization.
2565 * It is used for the interprocedural representation where blocks are parted
2566 * behind Call nodes to represent the control flow to called procedures.
2568 * @param *irg The ir graph the node belong to.
2569 * @param *block The block the node belong to.
2571 ir_node *new_r_Break (ir_graph *irg, ir_node *block);
2573 /** Constructor for a Filter node.
2575 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
2576 * Filter is a node with two views used to construct the interprocedural view.
2577 * In intraprocedural view its semantics are identical to the Proj node.
2578 * In interprocedural view the Filter performs the Phi operation on method
2579 * parameters or results. Other than a Phi a Filter node may not be removed
2580 * if it has only a single input.
2582 * The constructor builds the Filter in intraprocedural view.
2584 * @param *irg The ir graph the node belong to.
2585 * @param *block The block the node belong to.
2586 * @param *arg The tuple value to project from.
2587 * @param *mode The mode of the projected value.
2588 * @param proj The position in the tuple to project from.
2590 ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
2591 ir_mode *mode, long proj);
2593 /** Constructor for a NoMem node.
2595 * Returns the unique NoMem node of the graph. The same as
2598 * @param *irg The ir graph the node belongs to.
2600 ir_node *new_r_NoMem (ir_graph *irg);
2602 /** Constructor for a Mux node.
2604 * @param *irg The ir graph the node belong to.
2605 * @param *block The block the node belong to.
2606 * @param *sel The ir_node that calculates the boolean select.
2607 * @param *ir_true The ir_node that calculates the true result.
2608 * @param *ir_false The ir_node that calculates the false result.
2609 * @param *mode The mode of the node (and it_true and ir_false).
2611 ir_node *new_r_Mux (ir_graph *irg, ir_node *block,
2612 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2614 /** Constructor for a CopyB node.
2616 * @param *irg The ir graph the node belong to.
2617 * @param *block The block the node belong to.
2618 * @param *store The current memory
2619 * @param *dst The ir_node that represents the destination address.
2620 * @param *src The ir_node that represents the source address.
2621 * @param *data_type The type of the copied data
2623 ir_node *new_r_CopyB(ir_graph *irg, ir_node *block,
2624 ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
2626 /** Constructor for a InstOf node.
2628 * A High-Level Type check.
2630 * @param *irg The ir graph the node belongs to.
2631 * @param *block The ir block the node belongs to.
2632 * @param *store The memory in which the object the entity should be selected
2633 * from is allocated.
2634 * @param *objptr A pointer to a object of a class type.
2635 * @param *type The type of which objptr must be.
2637 ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *store,
2638 ir_node *objptr, ir_type *type);
2640 /** Constructor for a Raise node.
2642 * A High-Level Exception throw.
2644 * @param *irg The ir graph the node belongs to.
2645 * @param *block The ir block the node belongs to.
2646 * @param *store The current memory.
2647 * @param *obj A pointer to the Except variable.
2649 ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
2650 ir_node *store, ir_node *obj);
2652 /** Constructor for a Bound node.
2654 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
2656 * @param *irg The ir graph the node belong to.
2657 * @param *block The block the node belong to.
2658 * @param *store The current memory
2659 * @param *idx The ir_node that represents an index.
2660 * @param *lower The ir_node that represents the lower bound for the index.
2661 * @param *upper The ir_node that represents the upper bound for the index.
2663 ir_node *new_r_Bound(ir_graph *irg, ir_node *block,
2664 ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
2666 /*-----------------------------------------------------------------------*/
2667 /* The block oriented interface */
2668 /*-----------------------------------------------------------------------*/
2670 /** Sets the current block in which the following constructors place the
2671 * nodes they construct.
2673 * @param target The new current block.
2675 void set_cur_block (ir_node *target);
2677 /** Returns the current block of the current graph. */
2678 ir_node *get_cur_block(void);
2680 /** Returns the fixed nodes of the current graph. */
2681 #define get_cur_end_block() get_irg_end_block(current_ir_graph)
2682 #define get_cur_end() get_irg_end(current_ir_graph)
2683 #define get_cur_start_block() get_irg_start_block(current_ir_graph)
2684 #define get_cur_start() get_irg_start(current_ir_graph)
2686 /** Constructor for a Block node.
2688 * Adds the block to the graph in current_ir_graph. Constructs a Block
2689 * with a fixed number of predecessors. Does set current_block. Can
2690 * be used with automatic Phi node construction.
2692 * @param *db A Pointer for debug information.
2693 * @param arity The number of control predecessors.
2694 * @param in[] An array of control predecessors. The length of
2695 * the array must be 'arity'.
2697 ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
2699 /** Constructor for a Start node.
2701 * Adds the node to the block in current_ir_block.
2703 * @param *db A pointer for debug information.
2705 ir_node *new_d_Start (dbg_info *db);
2707 /** Constructor for a End node.
2709 * Adds the node to the block in current_ir_block.
2711 * @param *db A pointer for debug information.
2713 ir_node *new_d_End (dbg_info *db);
2715 /** Constructor for a Jmp node.
2717 * Adds the node to the block in current_ir_block.
2719 * Jmp represents control flow to a single control successor.
2721 * @param *db A pointer for debug information.
2723 ir_node *new_d_Jmp (dbg_info *db);
2725 /** Constructor for an IJmp node.
2727 * IJmp represents control flow to a single control successor not
2728 * statically known i.e. an indirect Jmp.
2730 * @param *db A pointer for debug information.
2731 * @param *tgt The ir node representing the target address.
2733 ir_node *new_d_IJmp (dbg_info *db, ir_node *tgt);
2735 /** Constructor for a Cond node.
2737 * Adds the node to the block in current_ir_block.
2739 * If c is mode_b represents a conditional branch (if/else). If c is
2740 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2741 * node, default Proj is 0.)
2743 * This is not consistent: Input to Cond is Is, Proj has as proj number
2746 * @param *db A pointer for debug information.
2747 * @param *c The conditions parameter.Can be of mode b or I_u.
2749 ir_node *new_d_Cond (dbg_info *db, ir_node *c);
2751 /** Constructor for a Return node.
2753 * Adds the node to the block in current_ir_block.
2755 * Returns the memory an zero or more return values. Only node that
2756 * can end regular control flow.
2758 * @param *db A pointer for debug information.
2759 * @param *store The state of memory.
2760 * @param arity Number of array indices.
2761 * @param *in Array with index inputs to the node.
2763 ir_node *new_d_Return (dbg_info *db, ir_node *store, int arity, ir_node *in[]);
2765 /** Constructor for a Const_type node.
2767 * Adds the node to the block in current_ir_block.
2769 * The constant represents a target value. This constructor sets high
2770 * level type information for the constant value.
2772 * @param *db A pointer for debug information.
2773 * @param *mode The mode of the operands and results.
2774 * @param *con Points to an entry in the constant table. This pointer is
2775 added to the attributes of the node.
2776 * @param *tp The type of the constant.
2778 ir_node *new_d_Const_type (dbg_info *db, ir_mode *mode, tarval *con, ir_type *tp);
2780 /** Constructor for a Const node.
2782 * Adds the node to the block in current_ir_block.
2784 * Constructor for a Const node. The constant represents a target
2785 * value. Sets the type information to type_unknown. (No more
2786 * supported: If tv is entity derives a somehow useful type.)
2788 * @param *db A pointer for debug information.
2789 * @param *mode The mode of the operands and results.
2790 * @param *con Points to an entry in the constant table. This pointer is added
2791 * to the attributes of the node.
2793 ir_node *new_d_Const (dbg_info *db, ir_mode *mode, tarval *con);
2795 /** Constructor for a SymConst_type node.
2797 * Adds the node to the block in current_ir_block.
2798 * This is the constructor for a symbolic constant.
2799 * There are four kinds of symbolic constants:
2800 * - type_tag The symbolic constant represents a type tag. The type the
2801 * tag stands for is given explicitly.
2802 * - size The symbolic constant represents the size of a type. The
2803 * type of which the constant represents the size is given
2805 * - addr_name The symbolic constant represents the address of an entity
2806 * (variable or method). The variable is indicated by a name
2807 * that is valid for linking.
2808 * - addr_ent The symbolic constant represents the address of an entity
2809 * (variable or method). The variable is given explicitly by
2812 * Inputs to the node:
2813 * No inputs except the block it belongs to.
2814 * Outputs of the node.
2815 * An unsigned integer (I_u) or a pointer (P).
2817 * @param *db A pointer for debug information.
2818 * @param value A type, entity or ident depending on the SymConst kind.
2819 * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_size
2820 * or symconst_addr_name.
2821 * @param tp The source type of the constant.
2823 ir_node *new_d_SymConst_type (dbg_info *db, union symconst_symbol value, symconst_kind kind, ir_type *tp);
2825 /** Constructor for a SymConst node.
2827 * Same as new_d_SymConst_type, except that it sets the type to type_unknown. */
2828 ir_node *new_d_SymConst (dbg_info *db, union symconst_symbol value, symconst_kind kind);
2830 /** Constructor for a simpleSel node.
2832 * This is a shortcut for the new_d_Sel() constructor. To be used for
2833 * Sel nodes that do not select from an array, i.e., have no index
2834 * inputs. It adds the two parameters 0, NULL.
2836 * @param *db A pointer for debug information.
2837 * @param *store The memory in which the object the entity should be
2838 * selected from is allocated.
2839 * @param *objptr The object from that the Sel operation selects a
2840 * single attribute out.
2841 * @param *ent The entity to select.
2843 ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr, entity *ent);
2845 /** Constructor for a Sel node.
2847 * The select node selects an entity (field or method) from an entity
2848 * with a compound type. It explicitly specifies the entity selected.
2849 * Dynamically the node may select entities that overwrite the given
2850 * entity. If the selected entity is an array element entity the Sel
2851 * node takes the required array indices as inputs.
2852 * Adds the node to the block in current_ir_block.
2854 * @param *db A pointer for debug information.
2855 * @param *store The memory in which the object the entity should be selected
2856 * from is allocated.
2857 * @param *objptr A pointer to a compound entity the Sel operation selects a
2858 * single attribute from.
2859 * @param arity The number of array indices needed to select an array element entity.
2860 * @param *in[] If the compound entity is an array the indices of the selected
2861 * element entity. The constructor copies this array.
2862 * @param *ent The entity to select.
2864 ir_node *new_d_Sel (dbg_info *db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
2867 /** Constructor for a Call node.
2869 * Represents all kinds of method and function calls.
2870 * Adds the node to the block in current_ir_block.
2872 * @param *db A pointer for debug information.
2873 * @param *store The actual store.
2874 * @param *callee A pointer to the called procedure.
2875 * @param arity The number of procedure parameters.
2876 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2877 * @param *tp Type information of the procedure called.
2879 ir_node *new_d_Call (dbg_info *db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
2882 /** Constructor for a Add node.
2884 * Adds the node to the block in current_ir_block.
2886 * @param *db A pointer for debug information.
2887 * @param *op1 The first operand.
2888 * @param *op2 The second operand.
2889 * @param *mode The mode of the operands and the result.
2891 ir_node *new_d_Add (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2893 /** Constructor for a Sub node.
2895 * Adds the node to the block in current_ir_block.
2897 * @param *db A pointer for debug information.
2898 * @param *op1 The first operand.
2899 * @param *op2 The second operand.
2900 * @param *mode The mode of the operands and the result.
2902 ir_node *new_d_Sub (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2904 /** Constructor for a Minus node.
2906 * Adds the node to the block in current_ir_block.
2908 * @param *db A pointer for debug information.
2909 * @param *op The operand .
2910 * @param *mode The mode of the operand and the result.
2912 ir_node *new_d_Minus (dbg_info *db, ir_node *op, ir_mode *mode);
2914 /** Constructor for a Mul node.
2916 * Adds the node to the block in current_ir_block.
2918 * @param *db A pointer for debug information.
2919 * @param *op1 The first operand.
2920 * @param *op2 The second operand.
2921 * @param *mode The mode of the operands and the result.
2923 ir_node *new_d_Mul (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2925 /** Constructor for a Quot node.
2927 * Adds the node to the block in current_ir_block.
2929 * @param *db A pointer for debug information.
2930 * @param *memop The store needed to model exceptions
2931 * @param *op1 The first operand.
2932 * @param *op2 The second operand.
2934 ir_node *new_d_Quot (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2);
2936 /** Constructor for a DivMod node.
2938 * Adds the node to the block in current_ir_block.
2940 * @param *db A pointer for debug information.
2941 * @param *memop The store needed to model exceptions
2942 * @param *op1 The first operand.
2943 * @param *op2 The second operand.
2945 ir_node *new_d_DivMod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2);
2947 /** Constructor for a Div node.
2949 * Adds the node to the block in current_ir_block.
2951 * @param *db A pointer for debug information.
2952 * @param *memop The store needed to model exceptions
2953 * @param *op1 The first operand.
2954 * @param *op2 The second operand.
2956 ir_node *new_d_Div (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2);
2958 /** Constructor for a Mod node.
2960 * Adds the node to the block in current_ir_block.
2962 * @param *db A pointer for debug information.
2963 * @param *memop The store needed to model exceptions
2964 * @param *op1 The first operand.
2965 * @param *op2 The second operand.
2967 ir_node *new_d_Mod (dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2);
2969 /** Constructor for a Abs node.
2971 * Adds the node to the block in current_ir_block.
2973 * @param *db A pointer for debug information.
2974 * @param *op The operand
2975 * @param *mode The mode of the operands and the result.
2977 ir_node *new_d_Abs (dbg_info *db, ir_node *op, ir_mode *mode);
2979 /** Constructor for a And node.
2981 * Adds the node to the block in current_ir_block.
2983 * @param *db A pointer for debug information.
2984 * @param *op1 The first operand.
2985 * @param *op2 The second operand.
2986 * @param *mode The mode of the operands and the result.
2988 ir_node *new_d_And (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
2990 /** Constructor for a Or node.
2992 * Adds the node to the block in current_ir_block.
2994 * @param *db A pointer for debug information.
2995 * @param *op1 The first operand.
2996 * @param *op2 The second operand.
2997 * @param *mode The mode of the operands and the result.
2999 ir_node *new_d_Or (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3001 /** Constructor for a Eor node.
3003 * Adds the node to the block in current_ir_block.
3005 * @param *db A pointer for debug information.
3006 * @param *op1 The first operand.
3007 * @param *op2 The second operand.
3008 * @param *mode The mode of the operands and the results.
3010 ir_node *new_d_Eor (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3012 /** Constructor for a Not node.
3014 * Adds the node to the block in current_ir_block.
3016 * @param *db A pointer for debug information.
3017 * @param *op The operand.
3018 * @param *mode The mode of the operand and the result.
3020 ir_node *new_d_Not (dbg_info *db, ir_node *op, ir_mode *mode);
3022 /** Constructor for a Shl node.
3024 * Adds the node to the block in current_ir_block.
3026 * @param *db A pointer for debug information.
3027 * @param *op The operand.
3028 * @param *k The number of bits to shift the operand .
3029 * @param *mode The mode of the operand and the result.
3031 ir_node *new_d_Shl (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
3033 /** Constructor for a Shr node.
3035 * Adds the node to the block in current_ir_block.
3037 * @param *db A pointer for debug information.
3038 * @param *op The operand.
3039 * @param *k The number of bits to shift the operand .
3040 * @param *mode The mode of the operand and the result.
3042 ir_node *new_d_Shr (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
3044 /** Constructor for a Shrs node.
3046 * Adds the node to the block in current_ir_block.
3048 * @param *db A pointer for debug information.
3049 * @param *op The operand.
3050 * @param *k The number of bits to shift the operand .
3051 * @param *mode The mode of the operand and the result.
3053 ir_node *new_d_Shrs (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
3055 /** Constructor for a Rot node.
3057 * Adds the node to the block in current_ir_block.
3059 * @param *db A pointer for debug information.
3060 * @param *op The operand.
3061 * @param *k The number of bits to rotate the operand.
3062 * @param *mode The mode of the operand.
3064 ir_node *new_d_Rot (dbg_info *db, ir_node *op, ir_node *k, ir_mode *mode);
3066 /** Constructor for a Cmp node.
3068 * Adds the node to the block in current_ir_block.
3070 * @param *db A pointer for debug information.
3071 * @param *op1 The first operand.
3072 * @param *op2 The second operand.
3074 ir_node *new_d_Cmp (dbg_info *db, ir_node *op1, ir_node *op2);
3076 /** Constructor for a Conv node.
3078 * Adds the node to the block in current_ir_block.
3080 * @param *db A pointer for debug information.
3081 * @param *op The operand.
3082 * @param *mode The mode of this the operand muss be converted .
3084 ir_node *new_d_Conv (dbg_info *db, ir_node *op, ir_mode *mode);
3086 /** Constructor for a Cast node.
3088 * High level type cast
3089 * Adds the node to the block in current_ir_block.
3091 * @param *db A pointer for debug information.
3092 * @param *op The operand.
3093 * @param *to_tp The type of this the operand muss be casted .
3095 ir_node *new_d_Cast (dbg_info *db, ir_node *op, ir_type *to_tp);
3097 /** Constructor for a Carry node.
3099 * Adds the node to the block in current_ir_block.
3101 * @param *db A pointer for debug information.
3102 * @param *op1 The first operand.
3103 * @param *op2 The second operand.
3104 * @param *mode The mode of the operands and the result.
3106 ir_node *new_d_Carry (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3108 /** Constructor for a Borrow node.
3110 * Adds the node to the block in current_ir_block.
3112 * @param *db A pointer for debug information.
3113 * @param *op1 The first operand.
3114 * @param *op2 The second operand.
3115 * @param *mode The mode of the operands and the result.
3117 ir_node *new_d_Borrow (dbg_info *db, ir_node *op1, ir_node *op2, ir_mode *mode);
3119 /** Constructor for a Phi node.
3121 * Adds the node to the block in current_ir_block.
3123 * @param *db A pointer for debug information.
3124 * @param arity The number of predecessors
3125 * @param *in Array with predecessors
3126 * @param *mode The mode of it's inputs and output.
3128 ir_node *new_d_Phi (dbg_info *db, int arity, ir_node *in[], ir_mode *mode);
3130 /** Constructor for a Load node.
3132 * Adds the node to the block in current_ir_block.
3134 * @param *db A pointer for debug information.
3135 * @param *store The current memory
3136 * @param *addr A pointer to the variable to be read in this memory.
3137 * @param *mode The mode of the value to be loaded.
3139 ir_node *new_d_Load (dbg_info *db, ir_node *store, ir_node *addr, ir_mode *mode);
3141 /** Constructor for a Store node.
3143 * Adds the node to the block in current_ir_block.
3145 * @param *db A pointer for debug information.
3146 * @param *store The current memory
3147 * @param *addr A pointer to the variable to be read in this memory.
3148 * @param *val The value to write to this variable.
3150 ir_node *new_d_Store (dbg_info *db, ir_node *store, ir_node *addr, ir_node *val);
3152 /** Constructor for a Alloc node.
3154 * The Alloc node extends the memory by space for an entity of type alloc_type.
3155 * Adds the node to the block in current_ir_block.
3157 * @param *db A pointer for debug information.
3158 * @param *store The memory which shall contain the new variable.
3159 * @param *size The number of bytes to allocate.
3160 * @param *alloc_type The type of the allocated variable.
3161 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3163 ir_node *new_d_Alloc (dbg_info *db, ir_node *store, ir_node *size, ir_type *alloc_type,
3166 /** Constructor for a Free node.
3168 * Frees the memory occupied by the entity pointed to by the pointer
3169 * arg. Type indicates the type of the entity the argument points to.
3170 * Adds the node to the block in current_ir_block.
3172 * @param *db A pointer for debug information.
3173 * @param *store The memory which shall contain the new variable.
3174 * @param *ptr The pointer to the object to free.
3175 * @param *size The number of objects of type free_type to free in a sequence.
3176 * @param *free_type The type of the freed variable.
3177 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3179 ir_node *new_d_Free (dbg_info *db, ir_node *store, ir_node *ptr, ir_node *size,
3180 ir_type *free_type, where_alloc where);
3182 /** Constructor for a Sync node.
3184 * Merges several memory values. The node assumes that a variable
3185 * either occurs only in one of the memories, or it contains the same
3186 * value in all memories where it occurs.
3187 * Adds the node to the block in current_ir_block.
3189 * @param *db A pointer for debug information.
3190 * @param arity The number of memories to synchronize.
3191 * @param **in An array of pointers to nodes that produce an output of type
3192 * memory. The constructor copies this array.
3194 ir_node *new_d_Sync (dbg_info *db, int arity, ir_node *in[]);
3196 /** Constructor for a Proj node.
3198 * Projects a single value out of a tuple. The parameter proj gives the
3199 * position of the value within the tuple.
3200 * Adds the node to the block in current_ir_block.
3202 * @param *db A pointer for deubug information.
3203 * @param arg A node producing a tuple.
3204 * @param *mode The mode of the value to project.
3205 * @param proj The position of the value in the tuple.
3207 ir_node *new_d_Proj (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3209 /** Constructor for a defaultProj node.
3211 * Represents the default control flow of a Switch-Cond node.
3212 * Adds the node to the block in current_ir_block.
3214 * @param *db A pointer for debug information.
3215 * @param arg A node producing a tuple.
3216 * @param max_proj The end position of the value in the tuple.
3218 ir_node *new_d_defaultProj (dbg_info *db, ir_node *arg, long max_proj);
3220 /** Constructor for a Tuple node.
3222 * This is an auxiliary node to replace a node that returns a tuple
3223 * without changing the corresponding Proj nodes.
3224 * Adds the node to the block in current_ir_block.
3226 * @param *db A pointer for debug information.
3227 * @param arity The number of tuple elements.
3228 * @param **in An array containing pointers to the nodes producing the tuple elements.
3230 ir_node *new_d_Tuple (dbg_info *db, int arity, ir_node *in[]);
3232 /** Constructor for a Id node.
3234 * This is an auxiliary node to replace a node that returns a single
3235 * value. Adds the node to the block in current_ir_block.
3237 * @param *db A pointer for debug information.
3238 * @param *val The operand to Id.
3239 * @param *mode The mode of *val.
3241 ir_node *new_d_Id (dbg_info *db, ir_node *val, ir_mode *mode);
3243 /** Constructor for a Bad node.
3245 * Returns the unique Bad node of the graph. The same as
3248 ir_node *new_d_Bad (void);
3250 /** Constructor for a Confirm node.
3252 * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3253 * Specifies constraints for a value. To support dataflow analyses.
3255 * Example: If the value never exceeds '100' this is expressed by placing a
3256 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3258 * @param *db A pointer for debug information.
3259 * @param *val The value we express a constraint for
3260 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3261 * @param cmp The compare operation.
3263 ir_node *new_d_Confirm (dbg_info *db, ir_node *val, ir_node *bound, pn_Cmp cmp);
3265 /** Constructor for an Unknown node.
3267 * Represents an arbitrary value. Places the node in
3270 * @param *m The mode of the unknown value.
3272 ir_node *new_d_Unknown(ir_mode *m);
3274 /** Constructor for a CallBegin node.
3276 * CallBegin represents control flow depending of the pointer value
3277 * representing the called method to the called methods. The
3278 * constructor copies the method pointer input from the passed Call
3279 * node.Adds the node to the block in current_ir_block.
3281 * @param *db A pointer for debug information.
3282 * @param *callee The call node visible in the intra procedural view.
3284 ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
3286 /** Constructor for an EndReg node.
3288 *Adds the node to the block in current_ir_block.
3290 * @param *db A pointer for debug information.
3292 ir_node *new_d_EndReg (dbg_info *db);
3294 /** Constructor for an EndExcept node.
3296 * Used to represent regular procedure end in interprocedual view.
3297 * Adds the node to the block in current_ir_block.
3299 * @param *db A pointer for debug information.
3301 ir_node *new_d_EndExcept(dbg_info *db);
3303 /** Constructor for a Break node.
3305 * Used to represent exceptional procedure end in interprocedural view.
3306 * Adds the node to the block in current_ir_block.
3308 * Break represents control flow to a single control successor just as Jmp.
3309 * The blocks separated by a break may not be concatenated by an optimization.
3310 * It is used for the interprocedural representation where blocks are parted
3311 * behind Call nodes to represent the control flow to called procedures.
3313 * @param *db A pointer for debug information.
3315 ir_node *new_d_Break (dbg_info *db);
3317 /** Constructor for a Filter node.
3319 * Constructor for a Filter node. Adds the node to the block in
3320 * current_ir_block. Filter is a node with two views used to
3321 * construct the interprocedural view. In intraprocedural view its
3322 * semantics are identical to the Proj node. In interprocedural view
3323 * the Filter performs the Phi operation on method parameters or
3324 * results. Other than a Phi a Filter node may not be removed if it
3325 * has only a single input.
3327 * The constructor builds the Filter in intraprocedural view.
3329 * @param *db A pointer for debug information.
3330 * @param *arg The tuple value to project from.
3331 * @param *mode The mode of the projected value.
3332 * @param proj The position in the tuple to project from.
3334 ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3337 /** Constructor for a NoMem node.
3339 * Returns the unique NoMem node of the graph. The same as
3342 ir_node *new_d_NoMem (void);
3344 /** Constructor for a Mux node.
3346 * @param *db A pointer for debug information.
3347 * @param *sel The ir_node that calculates the boolean select.
3348 * @param *ir_true The ir_node that calculates the true result.
3349 * @param *ir_false The ir_node that calculates the false result.
3350 * @param *mode The mode of the node (and it_true and ir_false).
3352 ir_node *new_d_Mux (dbg_info *db, ir_node *sel,
3353 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3355 /** Constructor for a CopyB node.
3357 * @param *db A pointer for debug information.
3358 * @param *store The current memory
3359 * @param *dst The ir_node that represents the destination address.
3360 * @param *src The ir_node that represents the source address.
3361 * @param *data_type The type of the copied data
3363 ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
3365 /** Constructor for a InstOf node.
3367 * A High-Level Type check.
3369 * @param *db A pointer for debug information.
3370 * @param *store The memory in which the object the entity should be selected
3371 * from is allocated.
3372 * @param *objptr A pointer to a object of a class type.
3373 * @param *type The type of which objptr must be.
3375 ir_node *new_d_InstOf (dbg_info *db, ir_node *store, ir_node *objptr, ir_type *type);
3377 /** Constructor for a Raise node.
3379 * A High-Level Exception throw.
3381 * @param *db A pointer for debug information.
3382 * @param *store The current memory.
3383 * @param *obj A pointer to the Except variable.
3385 ir_node *new_d_Raise (dbg_info *db, ir_node *store, ir_node *obj);
3387 /** Constructor for a Bound node.
3389 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
3391 * @param *db A pointer for debug information.
3392 * @param *store The current memory
3393 * @param *idx The ir_node that represents an index.
3394 * @param *lower The ir_node that represents the lower bound for the index.
3395 * @param *upper The ir_node that represents the upper bound for the index.
3397 ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
3399 /*-----------------------------------------------------------------------*/
3400 /* The block oriented interface without debug support */
3401 /*-----------------------------------------------------------------------*/
3403 /* Needed from the interface with debug support:
3404 void set_cur_block (ir_node *target); */
3406 /** Constructor for a Block node.
3408 * Constructor for a Block node. Adds the block to the graph in
3409 * current_ir_graph. Constructs a Block with a fixed number of
3410 * predecessors. Does set current_block. Can be used with automatic
3411 * Phi node construction.
3413 * @param arity The number of control predecessors.
3414 * @param in An array of control predecessors. The length of
3415 * the array must be 'arity'.
3417 ir_node *new_Block(int arity, ir_node *in[]);
3419 /** Constructor for a Start node.
3421 * Adds the node to the block in current_ir_block.
3424 ir_node *new_Start (void);
3426 /** Constructor for an End node.
3428 * Adds the node to the block in current_ir_block.
3430 ir_node *new_End (void);
3432 /** Constructor for an EndReg node.
3434 * Used to represent regular procedure end in interprocedual view.
3435 * Adds the node to the block in current_ir_block.
3437 ir_node *new_EndReg (void);
3439 /** Constructor for an EndExpcept node.
3441 * Used to represent exceptional procedure end in interprocedural view.
3442 * Adds the node to the block in current_ir_block.
3444 ir_node *new_EndExcept(void);
3446 /** Constructor for a Jump node.
3448 * Adds the node to the block in current_ir_block.
3450 * Jmp represents control flow to a single control successor.
3452 ir_node *new_Jmp (void);
3454 /** Constructor for an IJmp node.
3456 * IJmp represents control flow to a single control successor not
3457 * statically known i.e. an indirect Jmp.
3459 * @param *tgt The ir node representing the target address.
3461 ir_node *new_IJmp (ir_node *tgt);
3463 /** Constructor for a Break node.
3464 * Break represents control flow to a single control successor just as Jmp.
3465 * The blocks separated by a break may not be concatenated by an optimization.
3466 * It is used for the interprocedural representation where blocks are parted
3467 * behind Call nodes to represent the control flow to called procedures.
3468 * Adds the node to the block in current_ir_block.
3470 ir_node *new_Break (void);
3472 /** Constructor for a Cond node.
3474 * If c is mode_b represents a conditional branch (if/else). If c is
3475 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
3476 * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3478 * This is not consistent: Input to Cond is Is, Proj has as proj number
3482 * @param *c The conditions parameter.Can be of mode b or I_u.
3484 ir_node *new_Cond (ir_node *c);
3486 /** Constructor for a Return node.
3488 * Returns the memory an zero or more return values. Only node that
3489 * can end regular control flow. Adds the node to the block in current_ir_block.
3491 * @param *store The state of memory.
3492 * @param arity Number of array indices.
3493 * @param *in Array with index inputs to the node.
3495 ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
3497 /** Constructor for a Const node.
3499 * Constructor for a Const node. The constant represents a target
3500 * value. Sets the type information to type_unknown. (No more
3501 * supported: If tv is entity derives a somehow useful type.)
3502 * Adds the node to the block in current_ir_block.
3504 * @param *mode The mode of the operands and results.
3505 * @param *con Points to an entry in the constant table. This pointer is
3506 * added to the attributes of the node.
3508 ir_node *new_Const (ir_mode *mode, tarval *con);
3511 * Make a const from a long.
3512 * This is just convenience for the usual
3514 * new_Const(mode, tarval_from_long(mode, ...))
3517 * @param mode The mode for the const.
3518 * @param value The value of the constant.
3519 * @return A new const node.
3521 ir_node *new_Const_long(ir_mode *mode, long value);
3523 /** Constructor for a Const node.
3525 * Derives mode from passed type. */
3526 ir_node *new_Const_type(tarval *con, ir_type *tp);
3528 /** Constructor for a SymConst node.
3530 * Adds the node to the block in current_ir_block.
3531 * This is the constructor for a symbolic constant.
3532 * There are four kinds of symbolic constants:
3533 * -# type_tag The symbolic constant represents a type tag. The type the
3534 * tag stands for is given explicitly.
3535 * -# size The symbolic constant represents the size of a type. The
3536 * type of which the constant represents the size is given
3538 * -# addr_name The symbolic constant represents the address of an entity
3539 * (variable or method). The variable is indicated by a name
3540 * that is valid for linking.
3541 * -# addr_ent The symbolic constant represents the address of an entity
3542 * (variable or method). The variable is given explicitly by
3545 * Inputs to the node:
3546 * No inputs except the block it belongs to.
3547 * Outputs of the node.
3548 * An unsigned integer (I_u) or a pointer (P).
3550 * @param value A type or a ident depending on the SymConst kind.
3551 * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_size or symconst_addr_name.
3553 ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind);
3555 /** Constructor for a simpelSel node.
3557 * This is a shortcut for the new_Sel() constructor. To be used for
3558 * Sel nodes that do not select from an array, i.e., have no index
3559 * inputs. It adds the two parameters 0, NULL.
3561 * @param *store The memory in which the object the entity should be selected from is allocated.
3562 * @param *objptr The object from that the Sel operation selects a single attribute out.
3563 * @param *ent The entity to select.
3565 ir_node *new_simpleSel(ir_node *store, ir_node *objptr, entity *ent);
3567 /** Constructor for a Sel node.
3569 * The select node selects an entity (field or method) from an entity
3570 * with a compound type. It explicitly specifies the entity selected.
3571 * Dynamically the node may select entities that overwrite the given
3572 * entity. If the selected entity is an array element entity the Sel
3573 * node takes the required array indices as inputs.
3574 * Adds the node to the block in current_ir_block.
3576 * @param *store The memory in which the object the entity should be selected
3577 * from is allocated.
3578 * @param *objptr A pointer to a compound entity the Sel operation selects a
3579 * single attribute from.
3580 * @param arity The number of array indices needed to select an array element entity.
3581 * @param *in[] If the compound entity is an array the indices of the selected
3582 * element entity. The constructor copies this array.
3583 * @param *ent The entity to select.
3585 ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
3588 /** Constructor for a Call node.
3590 * Adds the node to the block in current_ir_block.
3591 * Represents all kinds of method and function calls.
3593 * @param *store The actual store.
3594 * @param *callee A pointer to the called procedure.
3595 * @param arity The number of procedure parameters.
3596 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3597 * @param *tp Type information of the procedure called.
3599 ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node *in[],
3602 /** Constructor for a CallBegin node.
3604 * CallBegin represents control flow depending of the pointer value
3605 * representing the called method to the called methods. The
3606 * constructor copies the method pointer input from the passed Call
3607 * node. Adds the node to the block in current_ir_block.
3609 * @param *callee A pointer to the called procedure.
3611 ir_node *new_CallBegin(ir_node *callee);
3613 /** Constructor for a Add node.
3615 * Adds the node to the block in current_ir_block.
3617 * @param *op1 The first operand.
3618 * @param *op2 The second operand.
3619 * @param *mode The mode of the operands and the result.
3621 ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
3623 /** Constructor for a Sub node.
3625 * Adds the node to the block in current_ir_block.
3627 * @param *op1 The first operand.
3628 * @param *op2 The second operand.
3629 * @param *mode The mode of the operands and the result.
3631 ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
3633 /** Constructor for a Minus node.
3635 * Adds the node to the block in current_ir_block.
3637 * @param *op The operand .
3638 * @param *mode The mode of the operand and the result.
3640 ir_node *new_Minus (ir_node *op, ir_mode *mode);
3643 * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3645 * @param *op1 The first operand.
3646 * @param *op2 The second operand.
3647 * @param *mode The mode of the operands and the result.
3649 ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
3651 /** Constructor for a Quot node.
3653 * Adds the node to the block in current_ir_block.
3655 * @param *memop The store needed to model exceptions
3656 * @param *op1 The first operand.
3657 * @param *op2 The second operand.
3659 ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
3661 /** Constructor for a DivMod node.
3663 * Adds the node to the block in current_ir_block.
3665 * @param *memop The store needed to model exceptions
3666 * @param *op1 The first operand.
3667 * @param *op2 The second operand.
3669 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
3671 /** Constructor for a Div node.
3673 * Adds the node to the block in current_ir_block.
3675 * @param *memop The store needed to model exceptions
3676 * @param *op1 The first operand.
3677 * @param *op2 The second operand.
3679 ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
3681 /** Constructor for a Mod node.
3683 * Adds the node to the block in current_ir_block.
3685 * @param *memop The store needed to model exceptions
3686 * @param *op1 The first operand.
3687 * @param *op2 The second operand.
3689 ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
3691 /** Constructor for a Abs node.
3693 * Adds the node to the block in current_ir_block.
3695 * @param *op The operand
3696 * @param *mode The mode of the operands and the result.
3698 ir_node *new_Abs (ir_node *op, ir_mode *mode);
3700 /** Constructor for a And node.
3702 * Adds the node to the block in current_ir_block.
3704 * @param *op1 The first operand.
3705 * @param *op2 The second operand.
3706 * @param *mode The mode of the operands and the result.
3708 ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
3711 * Constructor for a Or node. Adds the node to the block in current_ir_block.
3713 * @param *op1 The first operand.
3714 * @param *op2 The second operand.
3715 * @param *mode The mode of the operands and the result.
3717 ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
3720 * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3722 * @param *op1 The first operand.
3723 * @param *op2 The second operand.
3724 * @param *mode The mode of the operands and the results.
3726 ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
3728 /** Constructor for a Not node.
3730 * Adds the node to the block in current_ir_block.
3732 * @param *op The operand.
3733 * @param *mode The mode of the operand and the result.
3735 ir_node *new_Not (ir_node *op, ir_mode *mode);
3737 /** Constructor for a Shl node.
3739 * Adds the node to the block in current_ir_block.
3741 * @param *op The operand.
3742 * @param *k The number of bits to shift the operand .
3743 * @param *mode The mode of the operand and the result.
3745 ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
3748 * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3750 * @param *op The operand.
3751 * @param *k The number of bits to shift the operand .
3752 * @param *mode The mode of the operand and the result.
3754 ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
3756 /** Constructor for a Shrs node.
3758 * Adds the node to the block in current_ir_block.
3760 * @param *op The operand.
3761 * @param *k The number of bits to shift the operand .
3762 * @param *mode The mode of the operand and the result.
3764 ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
3766 /** Constructor for a Rot node.
3768 * Adds the node to the block in current_ir_block.
3770 * @param *op The operand.
3771 * @param *k The number of bits to rotate the operand.
3772 * @param *mode The mode of the operand.
3774 ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
3776 /** Constructor for a Cmp node.
3778 * Adds the node to the block in current_ir_block.
3780 * @param *op1 The first operand.
3781 * @param *op2 The second operand.
3783 ir_node *new_Cmp (ir_node *op1, ir_node *op2);
3785 /** Constructor for a Conv node.
3787 * Adds the node to the block in current_ir_block.
3789 * @param *op The operand.
3790 * @param *mode The mode of this the operand muss be converted .
3792 ir_node *new_Conv (ir_node *op, ir_mode *mode);
3794 /** Constructor for a Cast node.
3796 * Adds the node to the block in current_ir_block.
3797 * High level type cast
3799 * @param *op The operand.
3800 * @param *to_tp The type of this the operand muss be casted .
3802 ir_node *new_Cast (ir_node *op, ir_type *to_tp);
3804 /** Constructor for a Carry node.
3806 * Adds the node to the block in current_ir_block.
3808 * @param *op1 The first operand.
3809 * @param *op2 The second operand.
3810 * @param *mode The mode of the operands and the result.
3812 ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode);
3814 /** Constructor for a Borrow node.
3816 * Adds the node to the block in current_ir_block.
3818 * @param *op1 The first operand.
3819 * @param *op2 The second operand.
3820 * @param *mode The mode of the operands and the result.
3822 ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
3824 /** Constructor for a Phi node.
3826 * Adds the node to the block in current_ir_block.
3828 * @param arity The number of predecessors.
3829 * @param *in Array with predecessors.
3830 * @param *mode The mode of it's inputs and output.
3832 ir_node *new_Phi (int arity, ir_node *in[], ir_mode *mode);
3834 /** Constructor for a Load node.
3836 * @param *store The current memory.
3837 * @param *addr A pointer to the variable to be read in this memory.
3838 * @param *mode The mode of the value to be loaded.
3840 ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
3842 /** Constructor for a Store node.
3844 * @param *store The current memory.
3845 * @param *addr A pointer to the variable to be read in this memory.
3846 * @param *val The value to write to this variable.
3848 ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
3850 /** Constructor for a Alloc node.
3852 * The Alloc node extends the memory by space for an entity of type alloc_type.
3853 * Adds the node to the block in current_ir_block.
3855 * @param *store The memory which shall contain the new variable.
3856 * @param *size The number of bytes to allocate.
3857 * @param *alloc_type The type of the allocated variable.
3858 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3860 ir_node *new_Alloc (ir_node *store, ir_node *size, ir_type *alloc_type,
3863 /** Constructor for a Free node.
3865 * Frees the memory occupied by the entity pointed to by the pointer
3866 * arg. Type indicates the type of the entity the argument points to.
3867 * Adds the node to the block in current_ir_block.
3869 * @param *store The memory which shall contain the new variable.
3870 * @param *ptr The pointer to the object to free.
3871 * @param *size The number of objects of type free_type to free in a sequence.
3872 * @param *free_type The type of the freed variable.
3873 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3875 ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
3876 ir_type *free_type, where_alloc where);
3878 /** Constructor for a Sync node.
3880 * Merges several memory values. The node assumes that a variable
3881 * either occurs only in one of the memories, or it contains the same
3882 * value in all memories where it occurs.
3883 * Adds the node to the block in current_ir_block.
3885 * @param arity The number of memories to synchronize.
3886 * @param **in An array of pointers to nodes that produce an output of type
3887 * memory. The constructor copies this array.
3889 ir_node *new_Sync (int arity, ir_node *in[]);
3891 /** Constructor for a Proj node.
3893 * Projects a single value out of a tuple. The parameter proj gives the
3894 * position of the value within the tuple.
3895 * Adds the node to the block in current_ir_block.
3897 * @param arg A node producing a tuple.
3898 * @param *mode The mode of the value to project.
3899 * @param proj The position of the value in the tuple.
3901 ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
3903 /** Constructor for a Filter node.
3905 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
3906 * Filter is a node with two views used to construct the interprocedural view.
3907 * In intraprocedural view its semantics are identical to the Proj node.
3908 * In interprocedural view the Filter performs the Phi operation on method
3909 * parameters or results. Other than a Phi a Filter node may not be removed
3910 * if it has only a single input.
3912 * The constructor builds the Filter in intraprocedural view.
3914 * @param *arg The tuple value to project from.
3915 * @param *mode The mode of the projected value.
3916 * @param proj The position in the tuple to project from.
3918 ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
3920 /** Constructor for a defaultProj node.
3922 * Represents the default control flow of a Switch-Cond node.
3923 * Adds the node to the block in current_ir_block.
3925 * @param arg A node producing a tuple.
3926 * @param max_proj The end position of the value in the tuple.
3928 ir_node *new_defaultProj (ir_node *arg, long max_proj);
3930 /** Constructor for a Tuple node.
3932 * This is an auxiliary node to replace a node that returns a tuple
3933 * without changing the corresponding Proj nodes.
3934 * Adds the node to the block in current_ir_block.
3936 * @param arity The number of tuple elements.
3937 * @param **in An array containing pointers to the nodes producing the tuple elements.
3939 ir_node *new_Tuple (int arity, ir_node *in[]);
3941 /** Constructor for an Id node.
3943 * This is an auxiliary node to replace a node that returns a single
3944 * value. Adds the node to the block in current_ir_block.
3946 * @param *val The operand to Id.
3947 * @param *mode The mode of *val.
3949 ir_node *new_Id (ir_node *val, ir_mode *mode);
3951 /** Constructor for a Bad node.
3953 * Returns the unique Bad node of the graph. The same as
3956 ir_node *new_Bad (void);
3958 /** Constructor for a Confirm node.
3960 * Specifies constraints for a value. To support dataflow analyses.
3961 * Adds the node to the block in current_ir_block.
3963 * Example: If the value never exceeds '100' this is expressed by placing a
3964 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3966 * @param *val The value we express a constraint for
3967 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3968 * @param cmp The compare operation.
3970 ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
3972 /** Constructor for an Unknown node.
3974 * Represents an arbitrary value. Places the node in
3977 * @param *m The mode of the unknown value.
3979 ir_node *new_Unknown(ir_mode *m);
3981 /** Constructor for a NoMem node.
3983 * Returns the unique NoMem node of the graph. The same as
3986 ir_node *new_NoMem (void);
3988 /** Constructor for a Mux node.
3990 * Adds the node to the block in current_ir_block.
3992 * @param *sel The ir_node that calculates the boolean select.
3993 * @param *ir_true The ir_node that calculates the true result.
3994 * @param *ir_false The ir_node that calculates the false result.
3995 * @param *mode The mode of the node (and it_true and ir_false).
3997 ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3999 /** Constructor for a CopyB node.
4001 * Adds the node to the block in current_ir_block.
4003 * @param *store The current memory
4004 * @param *dst The ir_node that represents the destination address.
4005 * @param *src The ir_node that represents the source address.
4006 * @param *data_type The type of the copied data
4008 ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
4010 /** Constructor for a InstOf node.
4012 * A High-Level Type check.
4014 * @param *store The memory in which the object the entity should be selected
4015 * from is allocated.
4016 * @param *objptr A pointer to a object of a class type.
4017 * @param *type The type of which objptr must be.
4019 ir_node *new_InstOf (ir_node *store, ir_node *objptr, ir_type *type);
4021 /**Constructor for a Raise node.
4023 * A High-Level Exception throw.
4025 * @param *store The current memory.
4026 * @param *obj A pointer to the Except variable.
4028 ir_node *new_Raise (ir_node *store, ir_node *obj);
4030 /** Constructor for a Bound node.
4032 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
4034 * Adds the node to the block in current_ir_block.
4036 * @param *store The current memory
4037 * @param *idx The ir_node that represents an index.
4038 * @param *lower The ir_node that represents the lower bound for the index.
4039 * @param *upper The ir_node that represents the upper bound for the index.
4041 ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
4043 /*---------------------------------------------------------------------*/
4044 /* The comfortable interface. */
4045 /* Supports automatic Phi node construction. */
4046 /* All routines of the block oriented interface except new_Block are */
4048 /*---------------------------------------------------------------------*/
4050 /** Create an immature block.
4052 * An immature block has an unknown number of predecessors. Predecessors
4053 * can be added with add_immBlock_pred(). Once all predecessors are
4054 * added the block must be matured.
4056 * Adds the block to the graph in current_ir_graph. Does set
4057 * current_block. Can be used with automatic Phi node construction.
4058 * This constructor can only be used if the graph is in
4061 ir_node *new_d_immBlock (dbg_info *db);
4062 ir_node *new_immBlock (void);
4064 /** Add a control flow edge to an immature block. */
4065 void add_immBlock_pred (ir_node *immblock, ir_node *jmp);
4067 /** Finalize a Block node, when all control flows are known. */
4068 void mature_immBlock (ir_node *block);
4069 #define mature_cur_block() mature_immBlock(get_cur_block());
4072 /** Get the current value of a local variable.
4074 * Use this function to obtain the last definition of the local variable
4075 * associated with pos. Pos may not exceed the value passed as n_loc
4076 * to new_ir_graph. This call automatically inserts Phi nodes.
4078 * @param *db A pointer for debug information.
4079 * @param pos The position/id of the local variable.
4080 * @param *mode The mode of the value to get.
4082 ir_node *get_d_value (dbg_info *db, int pos, ir_mode *mode);
4083 ir_node *get_value (int pos, ir_mode *mode);
4085 /** Remark a new definition of a variable.
4087 * Use this function to remember a new definition of the value
4088 * associated with pos. Pos may not exceed the value passed as n_loc
4089 * to new_ir_graph. This call is needed to automatically inserts Phi
4092 * @param pos The position/id of the local variable.
4093 * @param *value The new value written to the local variable.
4095 void set_value (int pos, ir_node *value);
4097 /** Get the current memory state.
4099 * Use this function to obtain the last definition of the memory
4100 * state. This call automatically inserts Phi nodes for the memory
4103 ir_node *get_store (void);
4105 /** Remark a new definition of the memory state.
4107 * Use this function to remember a new definition of the memory state.
4108 * This call is needed to automatically inserts Phi nodes.
4110 * @param *store The new memory state.
4112 void set_store (ir_node *store);
4114 /** keep this node alive even if End is not control-reachable from it
4116 * @param ka The node to keep alive.
4118 void keep_alive (ir_node *ka);
4120 /** Returns the frame type of the current graph */
4121 ir_type *get_cur_frame_type(void);
4124 /* --- initialize and finalize ir construction --- */
4126 /** Puts the graph into state "phase_high" */
4127 void irg_finalize_cons (ir_graph *irg);
4129 /** Puts the program and all graphs into state phase_high.
4131 * This also remarks, the construction of types is finished,
4132 * e.g., that no more subtypes will be added. */
4133 void irp_finalize_cons(void);
4135 /* --- Initialization --- */
4138 * This function is called, whenever a local variable is used before definition
4140 * @param irg the IR graph on which this happens
4141 * @param mode the mode of the local var
4142 * @param pos position chosen be the frontend for this variable (n_loc)
4144 * @return a firm node of mode @p mode that initializes the var at position pos
4147 * Do not return NULL!
4148 * If this function is not set, FIRM will create a const node with tarval BAD.
4149 * Use set_irg_loc_description()/get_irg_loc_description() to assign additional
4150 * informations to local variables.
4152 typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
4154 #endif /* _IRCONS_H_ */