3 * File name: ir/ir/ircons.h
4 * Purpose: Various irnode constructors. Automatic construction
5 * of SSA representation.
6 * Author: Martin Trapp, Christian Schaefer
7 * Modified by: Goetz Lindenmaier, Boris Boesler
10 * Copyright: (c) 1998-2003 Universität Karlsruhe
11 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 -# Handle construction of exceptions more comfortable:
18 Add new constructors that pass the exception region (or better the
19 Phi for the memories, the ex. region can be found from there) as parameter,
20 constructor then adds all Proj nodes and returns the pointer
21 to the Proj node that selects the result of the arithmetic operation.
22 -# Maybe hide the exception region in a global variable, especially if
23 it is always unambiguous.
29 * documentation no more supported since 2001
31 * ir node construction.
33 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
35 * This file documents all datatypes and constructors needed to
36 * build a FIRM representation of a procedure. The constructors are
37 * also implemented in this file.
39 * The documentation also gives a short manual how to use the library.
41 * For extensive documentation of FIRM see UKA Techreport 1999-14.
44 * Three kinds of nodes
45 * --------------------
47 * There are three kinds of nodes known to the ir: entities,
50 * + ir_nodes are the actual nodes of the FIRM intermediate representation.
51 * They represent operations on the data of the program and control flow
54 * + entity ==> implemented in entity.h
55 * Refers to a single entity of the compiled program, e.g. a field of a
56 * class or a method. If a method or variable can not be assigned to
57 * a method or class or the like, it is a global object.
59 * + types ==> implemented in type.h
60 * With types type information is represented. There are several type
63 * Implementation of the FIRM operations: ir_node
64 * ----------------------------------------------
66 * Ir_nodes represent operations on the data of the program and control flow
67 * operations. Examples of ir_nodes: Add, Jmp, Cmp
69 * FIRM is a dataflow graph. A dataflow graph is a directed graph,
70 * so that every node has incoming and outgoing edges. A node is
71 * executable if every input at it's incoming edges is available.
72 * Execution of the dataflow graph is started at the Start node which
73 * has no incoming edges and ends when the End node executes, even if
74 * there are still executable or not executed nodes. (Is this true,
75 * or must all executable nodes be executed?) (There are exceptions
76 * to the dataflow paradigma that all inputs have to be available
77 * before a node can execute: Phi, Block. See UKA Techreport
80 * The implementation of FIRM differs from the view as a dataflow
81 * graph. To allow fast traversion of the graph edges are
82 * implemented as C-pointers. Inputs to nodes are not ambiguous, the
83 * results can be used by several other nodes. Each input can be
84 * implemented as a single pointer to a predecessor node, outputs
85 * need to be lists of pointers to successors. Therefore a node
86 * contains pointers to it's predecessor so that the implementation is a
87 * dataflow graph with reversed edges. It has to be traversed bottom
90 * All nodes of the ir have the same basic structure. They are
91 * distinguished by a field containing the opcode.
93 * The fields of an ir_node:
95 * kind A firm_kind tag containing k_ir_node. This is useful for
96 * dynamically checking the type of a node.
98 * *op This ir_op gives the opcode as a tag and a string
99 * and the number of attributes of an ir_node. There is
100 * one statically allocated struct ir_op for each opcode.
102 * *mode The ir_mode of the operation represented by this firm
103 * node. The mode of the operation is the mode of it's
104 * result. A Firm mode is a datatype as known to the target,
105 * not a type of the source language.
107 * visit A flag for traversing the ir.
109 * **in An array with pointers to the node's predecessors.
111 * *link A pointer to an ir_node. With this pointer all Phi nodes
112 * are attached to a Block, i.e., a Block points to it's
113 * first Phi node, this node points to the second Phi node
114 * in the Block and so fourth. Used in mature_immBlock
115 * to find all Phi nodes to be matured. It's also used to
116 * annotate a node with a better, optimized version of it.
118 * attr An attr struct containing the attributes of the nodes. The
119 * attributes depend on the opcode of the node. The number
120 * of these attributes is given in op.
124 * Not yet documented. See irop.h.
128 * Not yet documented. See irmode.h.
130 * GLOBAL VARIABLES -- now also fields of ir_graph.
133 * current_ir_graph Points to the current ir_graph. All constructors for
134 * nodes add nodes to this graph.
136 * ir_visited An int used as flag to traverse the ir_graph.
138 * block_visited An int used as a flag to traverse block nodes in the
141 * Others not yet documented.
145 * CONSTRUCTOR FOR IR_GRAPH --> see irgraph.h
146 * ========================
149 * PROCEDURE TO CONSTRUCT AN IR GRAPH --> see also Firm tutorial
150 * ==================================
152 * This library supplies several interfaces to construct a FIRM graph for
154 * - A "comfortable" interface generating SSA automatically. Automatically
155 * computed predecessors of nodes need not be specified in the constructors.
156 * (new_<Node> constructurs and a set of additional routines.)
157 * - A less comfortable interface where all predecessors except the block
158 * an operation belongs to need to be specified. SSA must be constructed
159 * by hand. (new_<Node> constructors and set_cur_block()). This interface
160 * is called "block oriented". It automatically calles the local optimizations
162 * - An even less comfortable interface where the block needs to be specified
163 * explicitly. This is called the "raw" interface. (new_r_<Node>
164 * constructors). These nodes are not optimized.
166 * To use the functionality of the comfortable interface correctly the Front
167 * End needs to follow certain protocols. This is explained in the following.
168 * To build a correct IR with the other interfaces study the semantics of
169 * the firm node (See tech-reprot UKA 1999-14). For the construction of
170 * types and entities see the documentation in those modules.
172 * First the Frontend needs to decide which variables and values used in
173 * a procedure can be represented by dataflow edges. These are variables
174 * that need not be saved to memory as they cause no side effects visible
175 * out of the procedure. Often these are all compiler generated
176 * variables and simple local variables of the procedure as integers,
177 * reals and pointers. The frontend has to count and number these variables.
179 * First an ir_graph needs to be constructed with new_ir_graph. The
180 * constructor gets the number of local variables. The graph is hold in the
181 * global variable irg.
183 * Now the construction of the procedure can start. Several basic blocks can
184 * be constructed in parallel, but the code within each block needs to
185 * be constructed (almost) in program order.
187 * A global variable holds the current basic block. All (non block) nodes
188 * generated are added to this block. The current block can be set with
189 * set_cur_block(block). If several blocks are constructed in parallel block
190 * switches need to be performed constantly.
192 * To generate a Block node (with the comfortable interface) it's predecessor
193 * control flow nodes need not be known. In case of cyclic control flow these
194 * can not be known when the block is constructed. With add_immBlock_pred(block,
195 * cfnode) predecessors can be added to the block. If all predecessors are
196 * added to the block mature_immBlock(b) needs to be called. Calling mature_immBlock
197 * early improves the efficiency of the Phi node construction algorithm.
198 * But if several blocks are constructed at once, mature_immBlock must only
199 * be called after performing all set_values and set_stores in the block!
200 * (See documentation of new_immBlock constructor.)
202 * The constructors of arithmetic nodes require that their predecessors
203 * are mentioned. Sometimes these are available in the Frontend as the
204 * predecessors have just been generated by the frontend. If they are local
205 * values the predecessors can be obtained from the library with a call to
206 * get_value(local_val_nr). (local_val_nr needs to be administered by
207 * the Frontend.) A call to get_value triggers the generation of Phi nodes.
208 * If an arithmetic operation produces a local value this value needs to be
209 * passed to the library by set_value(node, local_val_nr).
210 * In straight line code these two operations just remember and return the
211 * pointer to nodes producing the value. If the value passes block boundaries
212 * Phi nodes can be inserted.
213 * Similar routines exist to manage the Memory operands: set_store and
216 * Several nodes produce more than one result. An example is the Div node.
217 * Such nodes return tuples of values. From these individual values can be
218 * extracted by proj nodes.
220 * The following example illustrates the construction of a simple basic block
221 * with two predecessors stored in variables cf_pred1 and cf_pred2, containing
224 * and finally jumping to an other block. The variable a got the local_val_nr
225 * 42 by the frontend.
227 * ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
229 * this_block = new_immBlock();
230 * add_immBlock_pred(this_block, cf_pred1);
231 * add_immBlock_pred(this_block, cf_pred2);
232 * mature_immBlock(this_block);
233 * a_val = get_value(42, mode_Iu);
235 * div = new_Div(mem, a_val, a_val);
236 * mem = new_Proj(div, mode_M, 0); * for the numbers for Proj see docu *
237 * res = new_Proj(div, mode_Iu, 2);
239 * set_value(res, 42);
242 * For further information look at the documentation of the nodes and
243 * constructors and at the paragraph COPING WITH DATA OBJECTS at the
244 * end of this documentation.
246 * The comfortable interface contains the following routines further explained
249 * ir_node *new_immBlock (void);
250 * ir_node *new_Start (void);
251 * ir_node *new_End (void);
252 * ir_node *new_Jmp (void);
253 * ir_node *new_IJmp (ir_node *tgt);
254 * ir_node *new_Cond (ir_node *c);
255 * ir_node *new_Return (ir_node *store, int arity, ir_node **in);
256 * ir_node *new_Raise (ir_node *store, ir_node *obj);
257 * ir_node *new_Const (ir_mode *mode, tarval *con);
258 * ir_node *new_SymConst (symconst_symbol value, symconst_kind kind);
259 * ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
260 * ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity,
261 * ir_node **in, entity *ent);
262 * ir_node *new_InstOf (ir_node *store, ir_node obj, type *ent);
263 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity,
264 * ir_node **in, type_method *type);
265 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
266 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
267 * ir_node *new_Minus (ir_node *op, ir_mode *mode);
268 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
269 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
270 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
271 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
272 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
273 * ir_node *new_Abs (ir_node *op, ir_mode *mode);
274 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
275 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
276 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
277 * ir_node *new_Not (ir_node *op, ir_mode *mode);
278 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
279 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
280 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
281 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
282 * ir_node *new_Cmp (ir_node *op1, ir_node *op2);
283 * ir_node *new_Conv (ir_node *op, ir_mode *mode);
284 * ir_node *new_Cast (ir_node *op, type *to_tp);
285 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
286 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
287 * ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
288 * where_alloc where);
289 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
290 * type *free_type, where_alloc where);
291 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
292 * ir_node *new_NoMem (void);
293 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
294 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, type *data_type);
296 * void add_immBlock_pred (ir_node *block, ir_node *jmp);
297 * void mature_immBlock (ir_node *block);
298 * void set_cur_block (ir_node *target);
299 * ir_node *get_value (int pos, ir_mode *mode);
300 * void set_value (int pos, ir_node *value);
301 * ir_node *get_store (void);
302 * void set_store (ir_node *store);
303 * keep_alive (ir_node ka)
305 * IR_NODES AND CONSTRUCTORS FOR IR_NODES
306 * =======================================
308 * All ir_nodes are defined by a common data structure. They are distinguished
309 * by their opcode and differ in the number of their attributes.
311 * The constructor for the block node sets current_block to itself.
312 * Const nodes are always added to the start block.
313 * All other constructors add the created node to the current_block.
314 * swich_block(block) allows to set the current block to block.
316 * Watch for my inconsistent use of input and predecessor (dataflow view)
317 * and `the node points to' (implementation view).
319 * The following description of the nodes lists four properties them if these
321 * - the parameters to the constructor
322 * - the inputs of the Firm node
323 * - the outputs of the Firm node
324 * - attributes to the node
328 * ir_node *new_immBlock (void)
329 * ----------------------------
331 * Creates a new block. Sets current_block to itself. When a new block is
332 * created it cannot be known how many predecessors this block will have in the
333 * control flow graph. Therefore the list of inputs can not be fixed at
334 * creation. Predecessors can be added with add_immBlock_pred (block, control flow
335 * operation). With every added predecessor the number of inputs to Phi nodes
338 * The block can be completed by mature_immBlock(block) if all predecessors are
339 * known. If several blocks are built at once, mature_immBlock can only be called
340 * after set_value has been called for all values that are life at the end
341 * of the block. This is necessary so that Phi nodes created mature_immBlock
342 * get the right predecessors in case of cyclic dependencies. If all set_values
343 * of this block are called after maturing it and before calling get_value
344 * in some block that is control flow dependent on this block, the construction
347 * Example for faulty ir construction: (draw the graph on a paper and you'll
350 * block_before_loop = new_block();
352 * mature_immBlock(block_before_loop);
353 * before2header = new_Jmp;
355 * loop_header = new_block ();
356 * header2body - new_Jmp();
358 * loop_body = new_block ();
359 * body2header = new_Jmp();
361 * add_immBlock_pred(loop_header, before2header);
362 * add_immBlock_pred(loop_header, body2header);
363 * add_immBlock_pred(loop_body, header2body);
365 * mature_immBlock(loop_header);
366 * mature_immBlock(loop_body);
368 * get_value(loop_body, x); // gets the Phi in loop_header
369 * set_value(loop_header, x); // sets the value the above get_value should
370 * // have returned!!!
372 * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
373 * should be called as early as possible, as afterwards the generation of Phi
374 * nodes is more efficient.
377 * There is an input for each control flow predecessor of the block.
378 * The input points to an instruction producing an output of type X.
379 * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
380 * possibly causing an exception. (Often the real predecessors are Projs.)
382 * Mode BB (R), all nodes belonging to this block should consume this output.
383 * As they are strict (except Block and Phi node) it is a necessary condition
384 * that the block node executed before any other node in this block executes.
386 * block.matured Indicates whether the block is mature.
388 * This attribute contains all local values valid in this
389 * block. This is needed to build the Phi nodes and removed
390 * if the graph is complete. This field is used by the
391 * internal construction algorithm and should not be accessed
395 * ir_node *new_Block (int arity, ir_node **in)
396 * --------------------------------------------
398 * Creates a new Block with the given list of predecessors. This block
399 * is mature. As other constructors calls optimization and vrfy for the
400 * block. If one of the predecessors is Unknown (as it has to be filled in
401 * later) optimizations are skipped. This is necessary to
402 * construct Blocks in loops. Leaving Unknown in the Block after finishing
403 * the construction may have strange effects, especially for interprocedural
404 * representation and analysis.
407 * CONTROL FLOW OPERATIONS
408 * -----------------------
410 * In each block there must be exactly one of the control flow
411 * operations Start, End, Jmp, Cond, Return or Raise. The output of a
412 * control flow operation points to the block to be executed next.
414 * ir_node *new_Start (void)
415 * -------------------------
417 * Creates a start node. Not actually needed public. There is only one such
418 * node in each procedure which is automatically created by new_ir_graph.
421 * No inputs except the block it belogns to.
423 * A tuple of 4 (5, 6) distinct values. These are labeled by the following
424 * projection numbers (pn_Start):
425 * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
426 * * pn_Start_M mode M, the global store
427 * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
428 * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
429 * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
432 * ir_node *new_End (void)
433 * -----------------------
435 * Creates an end node. Not actually needed public. There is only one such
436 * node in each procedure which is automatically created by new_ir_graph.
439 * No inputs except the block it belongs to.
443 * ir_node *new_Jmp (void)
444 * -----------------------
446 * Creates a Jmp node.
449 * The block the node belongs to
451 * Control flow to the next block.
453 * ir_node *new_IJmp (ir_node *tgt)
454 * -----------------------
456 * Creates an IJmp node.
459 * The node that represents the target jump address
461 * Control flow to an unknown target, must be pinned by
464 * ir_node *new_Cond (ir_node *c)
465 * ------------------------------
467 * Creates a Cond node. There are two versions of this node.
473 * A tuple of two control flows. The first is taken if the input is
474 * false, the second if it is true.
478 * A value of mode I_u. (i)
480 * A tuple of n control flows. If the Cond's input is i, control
481 * flow will procede along output i. If the input is >= n control
482 * flow proceeds along output n.
484 * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
485 * -------------------------------------------------------------
487 * The return node has as inputs the results of the procedure. It
488 * passes the control flow to the end_block.
494 * Control flow to the end block.
496 * ir_node *new_Raise (ir_node *store, ir_node *obj)
497 * -------------------------------------------------
499 * Raises an exception. Unconditional change of control flow. Writes
500 * an explicit Except variable to memory to pass it to the exception
501 * handler. See TechReport 1999-14, chapter Exceptions.
505 * A pointer to the Except variable.
507 * A tuple of control flow and the changed memory state. The control flow
508 * points to the exception handler if it is definied in this procedure,
509 * else it points to the end_block.
514 * ir_node *new_Const (ir_mode *mode, tarval *con)
515 * -----------------------------------------------
517 * Creates a constant in the constant table and adds a Const node
518 * returning this value to the start block.
521 * *mode The mode of the constant.
522 * *con Points to an entry in the constant table.
523 * This pointer is added to the attributes of
524 * the node (self->attr.con)
526 * No inputs except the block it belogns to.
528 * The constant value.
530 * attr.con A tarval* pointer to the proper entry in the constant
533 * ir_node *new_SymConst (union symconst_symbol value, symconst_addr_ent kind)
534 * ---------------------------------------------------------------------------
536 * There are three kinds of symbolic constants:
537 * symconst_type_tag The symbolic constant represents a type tag.
538 * symconst_size The symbolic constant represents the size of a class.
539 * symconst_addr_name Information for the linker, e.g. the name of a global
541 * To represent a pointer to an entity that is represented by an entity
542 * datastructure don't use
543 * new_SymConst((type_or_id*)get_entity_ld_ident(ent), symconst_addr_name);.
544 * Use a real const instead:
545 * new_SymConst(mode_P_mach, tarval_p_from_entity(ent));
546 * This makes the Constant independent of name changes of the entity due to
550 * kind The kind of the symbolic constant: type_tag, size or link_info.
551 * *type_or_id Points to the type the tag stands for or to the type
552 * whose size is represented by the constant or to an ident
553 * representing the linkage info.
556 * No inputs except the block it belogns to.
558 * An unsigned integer (I_u) or a pointer (P).
561 * attr.i.num The symconst_addr_ent, i.e. one of
564 * - symconst_addr_name
565 * If the attr.i.num is symconst_type_tag or symconst_size, the node contains an attribute
566 * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is.
567 * if it is linkage_ptr_info it contains
568 * attr.i.*ptrinfo, an ident holding information for the linker. The mode
569 * of the node is mode_P_mach.
573 * ir_node *new_simpleSel (ir_node *store, ir_node *frame, entity *sel)
574 * --------------------------------------------------------------------
577 * Selects an entity from a compound type. This entity can be a field or
581 * *store The memory in which the object the entity should be selected
583 * *frame The pointer to the object.
584 * *sel The entity to select.
587 * The memory containing the object.
588 * A pointer to the object.
589 * An unsigned integer.
591 * A pointer to the selected entity.
593 * attr.sel Pointer to the entity
596 * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
597 * --------------------------------------------------------------------------
601 * Selects a field from an array type. The entity has as owner the array, as
602 * type the arrays element type. The indices to access an array element are
606 * *store The memory in which the object the entity should be selected from
608 * *frame The pointer to the object.
609 * *arity number of array indices.
610 * *in array with index inputs to the node.
611 * *sel The entity to select.
614 * The memory containing the object.
615 * A pointer to the object.
616 * As much unsigned integer as there are array expressions.
618 * A pointer to the selected entity.
620 * attr.sel Pointer to the entity
622 * The constructors new_Sel and new_simpleSel generate the same ir nodes.
623 * simpleSel just sets the arity of the index inputs to zero.
626 * ARITHMETIC OPERATIONS
627 * ---------------------
629 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
630 * ----------------------------------------------------------------------------
634 * Creates a procedure call.
637 * *store The actual store.
638 * *callee A pointer to the called procedure.
639 * arity The number of procedure parameters.
640 * **in An array with the pointers to the parameters.
641 * The constructor copies this array.
642 * *type Type information of the procedure called.
645 * The store, the callee and the parameters.
647 * A tuple containing the eventually changed store and the procedure
650 * attr.call Contains the type information for the procedure.
653 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
654 * ------------------------------------------------------------
658 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
659 * ------------------------------------------------------------
663 * ir_node *new_Minus (ir_node *op, ir_mode *mode)
664 * -----------------------------------------------
666 * Unary Minus operations on integer and floating point values.
668 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
669 * ------------------------------------------------------------
673 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2)
674 * --------------------------------------------------------------
676 * Quot performs exact division of floating point numbers. It's mode
677 * is Tuple, the mode of the result must be annotated to the Proj
678 * that extracts the result of the arithmetic operations.
681 * The store needed to model exceptions and the two operands.
683 * A tuple contaning a memory and a execution for modeling exceptions
684 * and the result of the arithmetic operation.
686 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2)
687 * ----------------------------------------------------------------
689 * Performs Div and Mod on interger values.
692 * A tuple contaning a memory and a execution for modeling exceptions
693 * and the two result of the arithmetic operations.
695 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2)
696 * -------------------------------------------------------------
700 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2)
701 * -------------------------------------------------------------
705 * ir_node *new_Abs (ir_node *op, ir_mode *mode)
706 * ---------------------------------------------
710 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
711 * ------------------------------------------------------------
715 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
716 * -----------------------------------------------------------
720 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
721 * ------------------------------------------------------------
725 * ir_node *new_Not (ir_node *op, ir_mode *mode)
726 * ---------------------------------------------
728 * This node constructs a constant where all bits are set to one
729 * and a Eor of this constant and the operator. This simulates a
732 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
733 * ---------------------------------------------------------
737 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
738 * ---------------------------------------------------------
740 * Logic shift right, i.e., zero extended.
743 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
744 * ----------------------------------------------------------
746 * Arithmetic shift right, i.e., sign extended.
748 * ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode)
749 * ---------------------------------------------------------
751 * Rotates the operand to the (right??) by k bits.
753 * ir_node *new_Conv (ir_node *op, ir_mode *mode)
754 * ---------------------------------------------
756 * Mode conversion. For allowed conversions see UKA Tech Report
759 * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
760 * ---------------------------------------------
763 * The two values to be compared.
765 * A 16-tuple containing the results of the 16 different comparisons.
766 * The following is a list giving the comparisons and a projection
767 * number (pn_Cmp) to use in Proj nodes to extract the proper result.
771 * pn_Cmp_Le less or equal
773 * pn_Cmp_Ge greater of equal
774 * pn_Cmp_Lg less or greater
775 * pn_Cmp_Leg less, equal or greater = ordered
776 * pn_Cmp_Uo unordered
777 * pn_Cmp_Ue unordered or equal
778 * pn_Cmp_Ul unordered or less
779 * pn_Cmp_Ule unordered, less or equal
780 * pn_Cmp_Ug unordered or greater
781 * pn_Cmp_Uge unordered, greater or equal
782 * pn_Cmp_Ne unordered, less or greater = not equal
789 * In general, Phi nodes are automaitcally inserted. In some cases, if
790 * all predecessors of a block are known, an explicit Phi node constructor
791 * is needed. E.g., to construct a FIRM graph for a statement as
792 * a = (b==c) ? 2 : 5;
794 * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
795 * ---------------------------------------------------------
797 * Creates a Phi node. The in's order has to correspond to the order
798 * of in's of current_block. This is not checked by the library!
799 * If one of the predecessors is Unknown (as it has to be filled in
800 * later) optimizations are skipped. This is necessary to
801 * construct Phi nodes in loops. Leaving Unknown in the Phi after finishing
802 * the construction may have strange effects, especially for interprocedural
803 * representation and analysis.
806 * arity number of predecessors
807 * **in array with predecessors
808 * *mode The mode of it's inputs and output.
810 * A Phi node has as many inputs as the block it belongs to.
811 * Each input points to a definition of the same value on a
812 * different path in the control flow.
814 * The definition valid in this block.
816 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
817 * -----------------------------------------------------------------------------
819 * Creates a Mux node. This node implements the following semantic:
820 * If the sel node (which must be of mode_b) evaluates to true, its value is
821 * ir_true, else ir_false;
824 * OPERATIONS TO MANAGE MEMORY EXPLICITLY
825 * --------------------------------------
827 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode)
828 * ----------------------------------------------------------------
830 * The Load operation reads a value from memory.
833 * *store The current memory.
834 * *addr A pointer to the variable to be read in this memory.
835 * *mode The mode of the value to be loaded.
838 * The memory and a pointer to a variable in this memory.
840 * A tuple of the memory, a control flow to be taken in case of
841 * an exception and the loaded value.
843 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val)
844 * ----------------------------------------------------------------
846 * The Store operation writes a value to a variable in memory.
849 * The memory, a pointer to a variable in this memory and the value
850 * to write to this variable.
852 * A tuple of the changed memory and a control flow to be taken in
853 * case of an exception.
855 * ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
856 * --------------------------------------------------------------------
860 * The Alloc node allocates a new variable. It can be specified whether the
861 * variable should be allocated to the stack or to the heap.
864 * *store The memory which shall contain the new variable.
865 * ** *size The number of bytes to allocate. Old. **
866 * *size We decided that the size easily can be derived from the type.
867 * This field is for allocating arrays, i.e., it gives the multiple
868 * of the size of alloc_type to allocate memory for.
869 * *alloc_type The type of the allocated variable.
870 * where Where to allocate the variable, either heap_alloc or stack_alloc.
873 * A memory and an unsigned integer.
875 * A tuple of the changed memory, a control flow to be taken in
876 * case of an exception and the pointer to the new variable.
878 * a.where Indicates where the variable is allocated.
879 * a.*type A pointer to the class the allocated data object
882 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, type *free_type,
883 * --------------------------------------------------------------------------------
887 * The Free node frees memory of the given variable.
890 * *store The memory which shall contain the new variable.
891 * *ptr The pointer to the object to free.
892 * *size The number of objects of type free_type to free in a sequence.
893 * *free_type The type of the freed variable.
894 * where Where the variable was allocated, either heap_alloc or stack_alloc.
897 * A memory, a pointer and an unsigned integer.
899 * The changed memory.
901 * f.*type A pointer to the type information of the freed data object.
905 * ir_node *new_Sync (int arity, ir_node **in)
906 * -------------------------------------------
908 * The Sync operation unifies several partial memory blocks. These blocks
909 * have to be pairwise disjunct or the values in common locations have to
910 * be identical. This operation allows to specify all operations that eventually
911 * need several partial memory blocks as input with a single entrance by
912 * unifying the memories with a preceding Sync operation.
915 * arity The number of memories to synchronize.
916 * **in An array of pointers to nodes that produce an output of
921 * The unified memory.
927 * ir_node *new_Bad (void)
928 * -----------------------
930 * Returns the unique Bad node current_ir_graph->bad.
931 * This node is used to express results of dead code elimination.
933 * ir_node *new_NoMem (void)
934 * -----------------------------------------------------------------------------------
936 * Returns the unique NoMem node current_ir_graph->no_mem.
937 * This node is used as input for operations that need a Memory, but do not
938 * change it like Div by const != 0, analyzed calls etc.
940 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, type *data_type)
941 * -----------------------------------------------------------------------------------
943 * Describes a high level block copy of a compound type form address src to
944 * address dst. Must be lowered to a Call to a runtime memory copy function.
946 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
947 * ----------------------------------------------------------
949 * Selects one entry of a tuple. This is a hidden `fat edge'.
952 * *arg A node producing a tuple.
953 * *mode The mode of the value to project.
954 * proj The position of the value in the tuple.
960 * ir_node *new_Tuple (int arity, ir_node **in)
961 * --------------------------------------------
963 * Builds a Tuple from single values. This is needed to implement
964 * optimizations that remove a node that produced a tuple. The node can be
965 * replaced by the Tuple operation so that the following Proj nodes have not to
966 * be changed. (They are hard to find due to the implementation with pointers
967 * in only one direction.) The Tuple node is smaller than any other
968 * node, so that a node can be changed into a Tuple by just changing it's
969 * opcode and giving it a new in array.
972 * arity The number of tuple elements.
973 * **in An array containing pointers to the nodes producing the
976 * ir_node *new_Id (ir_node *val, ir_mode *mode)
977 * ---------------------------------------------
979 * The single output of the Id operation is it's input. Also needed
983 * COPING WITH DATA OBJECTS
984 * ========================
986 * Two kinds of data objects have to be distinguished for generating
987 * FIRM. First there are local variables other than arrays that are
988 * known to be alias free. Second there are all other data objects.
989 * For the first a common SSA representation is built, the second
990 * are modeled by saving them to memory. The memory is treated as
991 * a single local variable, the alias problem is hidden in the
992 * content of this variable.
994 * All values known in a Block are listed in the block's attribute,
995 * block.**graph_arr which is used to automatically insert Phi nodes.
996 * The following two funcions can be used to add a newly computed value
997 * to the array, or to get the producer of a value, i.e., the current
1000 * inline void set_value (int pos, ir_node *value)
1001 * -----------------------------------------------
1003 * Has to be called for every assignment to a local variable. It
1004 * adds the value to the array of used values at position pos. Pos
1005 * has to be a unique identifier for an entry in the procedure's
1006 * definition table. It can be used to access the value again.
1007 * Requires current_block to be set correctly.
1009 * ir_node *get_value (int pos, ir_mode *mode)
1010 * -------------------------------------------
1012 * Returns the node defining the value referred to by pos. If the
1013 * value is not defined in this block a Phi node is generated and
1014 * all definitions reaching this Phi node are collected. It can
1015 * happen that the algorithm allocates an unnecessary Phi node,
1016 * e.g. if there is only one definition of this value, but this
1017 * definition reaches the currend block on several different
1018 * paths. This Phi node will be eliminated if optimizations are
1019 * turned on right after it's creation.
1020 * Requires current_block to be set correctly.
1022 * There are two special routines for the global store:
1024 * void set_store (ir_node *store)
1025 * -------------------------------
1027 * Adds the store to the array of known values at a reserved
1029 * Requires current_block to be set correctly.
1031 * ir_node *get_store (void)
1032 * -------------------------
1034 * Returns the node defining the actual store.
1035 * Requires current_block to be set correctly.
1038 * inline void keep_alive (ir_node *ka)
1039 * ------------------------------------
1041 * Keep this node alive because it is (might be) not in the control
1042 * flow from Start to End. Adds the node to the list in the end
1051 # include "firm_common.h"
1052 # include "irgraph.h"
1053 # include "irnode.h"
1054 # include "irmode.h"
1055 # include "entity.h"
1058 # include "dbginfo.h"
1060 /*-------------------------------------------------------------------------*/
1061 /* The raw interface */
1062 /*-------------------------------------------------------------------------*/
1064 /** Constructor for a Block node.
1066 * Constructs a mature block with the given predecessors. Use Unknown
1067 * nodes as predecessors to construct a block if the number of
1068 * predecessors is known, but not the predecessors themselves. This
1069 * constructor does not set current_block. It not be used with
1070 * automatic Phi node construction.
1072 * @param *db A Pointer for debug information.
1073 * @param irg The ir graph the block belongs to.
1074 * @param arity The number of control predecessors.
1075 * @param in[] An array of control predecessors. The length of
1076 * the array must be 'arity'. The constructor copies this array.
1078 ir_node *new_rd_Block (dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1080 /** Constructor for a Start node.
1082 * @param *db A pointer for debug information.
1083 * @param *irg The ir graph the node belongs to.
1084 * @param *block The ir block the node belongs to.
1086 ir_node *new_rd_Start (dbg_info *db, ir_graph *irg, ir_node *block);
1088 /** Constructor for a End node.
1090 * @param *db A pointer for debug information.
1091 * @param *irg The ir graph the node belongs to.
1092 * @param *block The ir block the node belongs to.
1094 ir_node *new_rd_End (dbg_info *db, ir_graph *irg, ir_node *block);
1096 /** Constructor for a Jmp node.
1098 * Jmp represents control flow to a single control successor.
1100 * @param *db A pointer for debug information.
1101 * @param *irg The ir graph the node belongs to.
1102 * @param *block The ir block the node belongs to.
1104 ir_node *new_rd_Jmp (dbg_info *db, ir_graph *irg, ir_node *block);
1106 /** Constructor for an IJmp node.
1108 * IJmp represents control flow to a single control successor not
1109 * statically known i.e. an indirect Jmp.
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.
1114 * @param *tgt The ir node representing the target address.
1116 ir_node *new_rd_IJmp (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *tgt);
1118 /** Constructor for a Break node.
1120 * Break represents control flow to a single control successor just as Jmp.
1121 * The blocks separated by a break may not be concatenated by an optimization.
1122 * It is used for the interprocedural representation where blocks are parted
1123 * behind Call nodes to represent the control flow to called procedures.
1125 * @param *db A pointer for debug information.
1126 * @param *irg The ir graph the node belong to.
1127 * @param *block The block the node belong to.
1129 ir_node *new_rd_Break (dbg_info *db, ir_graph *irg, ir_node *block);
1131 /** Constructor for a Cond node.
1133 * If c is mode_b represents a conditional branch (if/else). If c is
1134 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1135 * node, default Proj is 0.)
1137 * This is not consistent: Input to Cond is Is, Proj has as proj number
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 *c The conditions parameter. Can be of mode b or I_u.
1145 ir_node *new_rd_Cond (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c);
1147 /** Constructor for a Return node.
1149 * Returns the memory an zero or more return values. Only node that
1150 * can end regular control flow.
1152 * @param *db A pointer for debug information.
1153 * @param *irg The ir graph the node belongs to.
1154 * @param *block The ir block the node belongs to.
1155 * @param *store The state of memory.
1156 * @param arity Number of return values.
1157 * @param *in Array of length arity with return values. The constructor copies this array.
1159 ir_node *new_rd_Return (dbg_info *db, ir_graph *irg, ir_node *block,
1160 ir_node *store, int arity, ir_node *in[]);
1162 /** Constructor for a Raise node.
1164 * @param *db A pointer for debug information.
1165 * @param *irg The ir graph the node belongs to.
1166 * @param *block The ir block the node belongs to.
1167 * @param *store The current memory.
1168 * @param *obj A pointer to the Except variable.
1170 ir_node *new_rd_Raise (dbg_info *db, ir_graph *irg, ir_node *block,
1171 ir_node *store, ir_node *obj);
1173 /** Constructor for a Const_type node.
1175 * The constant represents a target value. This constructor sets high
1176 * level type information for the constant value.
1178 * @param *db A pointer for debug information.
1179 * @param *irg The ir graph the node belongs to.
1180 * @param *block The ir block the node belongs to.
1181 * @param *mode The mode of the operands and results.
1182 * @param *con Points to an entry in the constant table.
1183 * @param *tp The type of the constant.
1185 ir_node *new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block,
1186 ir_mode *mode, tarval *con, type *tp);
1188 /** Constructor for a Const node.
1190 * Constructor for a Const node. The constant represents a target
1191 * value. Sets the type information to type_unknown. (No more
1192 * supported: If tv is entity derives a somehow useful type.)
1194 * @param *db A pointer for debug information.
1195 * @param *irg The ir graph the node belongs to.
1196 * @param *block The ir block the node belongs to.
1197 * @param *mode The mode of the operands and results.
1198 * @param *con Points to an entry in the constant table.
1200 ir_node *new_rd_Const (dbg_info *db, ir_graph *irg, ir_node *block,
1201 ir_mode *mode, tarval *con);
1203 /** Constructor for a SymConst_type node.
1205 * This is the constructor for a symbolic constant.
1206 * There are four kinds of symbolic constants:
1207 * - type_tag The symbolic constant represents a type tag. The type the
1208 * tag stands for is given explicitly.
1209 * - size The symbolic constant represents the size of a type. The
1210 * type of which the constant represents the size is given
1212 * - addr_name The symbolic constant represents the address of an entity
1213 * (variable or method). The variable is indicated by a name
1214 * that is valid for linking.
1215 * - addr_ent The symbolic constant represents the address of an entity
1216 * (variable or method). The variable is given explicitly by
1219 * Inputs to the node:
1220 * No inputs except the block it belongs to.
1221 * Outputs of the node.
1222 * An unsigned integer (I_u) or a pointer (P).
1224 * Mention union in declaration so that the firmjni generator recognizes that
1225 * it can not cast the argument to an int.
1227 * @param *db A pointer for debug information.
1228 * @param *irg The ir graph the node belongs to.
1229 * @param *block The ir block the node belongs to.
1230 * @param symkind The kind of the symbolic constant: type_tag, size, addr_name or addr_ent.
1231 * @param value A type, entity or a ident depending on the SymConst kind.
1232 * @param tp The source type of the constant.
1234 ir_node *new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, union symconst_symbol value,
1235 symconst_kind symkind, type *tp);
1237 /** Constructor for a SymConst node.
1239 * Same as new_rd_SymConst_type, except that it sets the type to type_unknown. */
1240 ir_node *new_rd_SymConst (dbg_info *db, ir_graph *irg, ir_node *block,
1241 union symconst_symbol value, symconst_kind symkind);
1243 /** Constructor for a SymConst addr_ent node.
1245 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1246 * symconst_addr_ent.
1247 * Adds the SymConst to the start block of irg. */
1248 ir_node *new_rd_SymConst_addr_ent (dbg_info *db, ir_graph *irg, entity *symbol, type *tp);
1250 /** Constructor for a SymConst addr_name node.
1252 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1253 * symconst_addr_ent.
1254 * Adds the SymConst to the start block of irg. */
1255 ir_node *new_rd_SymConst_addr_name (dbg_info *db, ir_graph *irg, ident *symbol, type *tp);
1257 /** Constructor for a SymConst type_tag node.
1259 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1260 * symconst_addr_ent.
1261 * Adds the SymConst to the start block of irg. */
1262 ir_node *new_rd_SymConst_type_tag (dbg_info *db, ir_graph *irg, type *symbol, type *tp);
1264 /** Constructor for a SymConst size node.
1266 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1267 * symconst_addr_ent.
1268 * Adds the SymConst to the start block of irg. */
1269 ir_node *new_rd_SymConst_size (dbg_info *db, ir_graph *irg, type *symbol, type *tp);
1271 /** Constructor for a simpleSel node.
1273 * This is a shortcut for the new_rd_Sel() constructor. To be used for
1274 * Sel nodes that do not select from an array, i.e., have no index
1275 * inputs. It adds the two parameters 0, NULL.
1277 * @param *db A pointer for debug information.
1278 * @param *irg The ir graph the node belongs to.
1279 * @param *block The ir block the node belongs to.
1280 * @param *store The memory in which the object the entity should be
1281 * selected from is allocated.
1282 * @param *objptr The object from that the Sel operation selects a
1283 * single attribute out.
1284 * @param *ent The entity to select.
1286 ir_node *new_rd_simpleSel (dbg_info *db, ir_graph *irg, ir_node *block,
1287 ir_node *store, ir_node *objptr, entity *ent);
1289 /** Constructor for a Sel node.
1291 * The select node selects an entity (field or method) from an entity
1292 * with a compound type. It explicitly specifies the entity selected.
1293 * Dynamically the node may select entities that overwrite the given
1294 * entity. If the selected entity is an array element entity the Sel
1295 * node takes the required array indices as inputs.
1297 * @param *db A pointer for debug information.
1298 * @param *irg The ir graph the node belongs to.
1299 * @param *block The ir block the node belongs to.
1300 * @param *store The memory in which the object the entity should be selected
1301 * from is allocated.
1302 * @param *objptr A pointer to a compound entity the Sel operation selects a
1303 * single attribute from.
1304 * @param *n_index The number of array indices needed to select an array element entity.
1305 * @param *index[] If the compound entity is an array the indices of the selected
1306 * element entity. The constructor copies this array.
1307 * @param *ent The entity to select.
1309 ir_node *new_rd_Sel (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1310 ir_node *objptr, int n_index, ir_node *index[], entity *ent);
1312 /** Constructor for a InstOf node.
1314 * For translating Java. Not supported as standard firm node.
1316 * @param *db A pointer for debug information.
1317 * @param *irg The ir graph the node belongs to.
1318 * @param *block The ir block the node belongs to.
1323 ir_node *new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1324 ir_node *objptr, type *ent);
1326 /** Constructor for a Call node.
1328 * Represents all kinds of method and function calls.
1330 * @param *db A pointer for debug information.
1331 * @param *irg The ir graph the node belongs to.
1332 * @param *block The ir block the node belongs to.
1333 * @param *store The current memory state.
1334 * @param *callee A pointer to the called procedure.
1335 * @param arity The number of procedure parameters.
1336 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1337 * @param *tp Type information of the procedure called.
1339 ir_node *new_rd_Call (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1340 ir_node *callee, int arity, ir_node *in[], type *tp);
1342 /** Constructor for a Add node.
1344 * @param *db A pointer for debug information.
1345 * @param *irg The ir graph the node belongs to.
1346 * @param *block The ir block the node belongs to.
1347 * @param *op1 The first operand.
1348 * @param *op2 The second operand.
1349 * @param *mode The mode of the operands and the result.
1351 ir_node *new_rd_Add (dbg_info *db, ir_graph *irg, ir_node *block,
1352 ir_node *op1, ir_node *op2, ir_mode *mode);
1354 /** Constructor for a Sub node.
1356 * @param *db A pointer for debug information.
1357 * @param *irg The ir graph the node belongs to.
1358 * @param *block The ir block the node belongs to.
1359 * @param *op1 The first operand.
1360 * @param *op2 The second operand.
1361 * @param *mode The mode of the operands and the result.
1363 ir_node *new_rd_Sub (dbg_info *db, ir_graph *irg, ir_node *block,
1364 ir_node *op1, ir_node *op2, ir_mode *mode);
1366 /** Constructor for a Minus node.
1368 * @param *db A pointer for debug information.
1369 * @param *irg The ir graph the node belongs to.
1370 * @param *block The ir block the node belongs to.
1371 * @param *op The operand .
1372 * @param *mode The mode of the operand and the result.
1374 ir_node *new_rd_Minus (dbg_info *db, ir_graph *irg, ir_node *block,
1375 ir_node *op, ir_mode *mode);
1377 /** Constructor for a Mul node.
1379 * @param *db A pointer for debug information.
1380 * @param *irg The ir graph the node belongs to.
1381 * @param *block The ir block the node belongs to.
1382 * @param *op1 The first operand.
1383 * @param *op2 The second operand.
1384 * @param *mode The mode of the operands and the result.
1386 ir_node *new_rd_Mul (dbg_info *db, ir_graph *irg, ir_node *block,
1387 ir_node *op1, ir_node *op2, ir_mode *mode);
1389 /** Constructor for a Quot node.
1391 * @param *db A pointer for debug information.
1392 * @param *irg The ir graph the node belongs to.
1393 * @param *block The ir block the node belongs to.
1394 * @param *memop The store needed to model exceptions
1395 * @param *op1 The first operand.
1396 * @param *op2 The second operand.
1398 ir_node *new_rd_Quot (dbg_info *db, ir_graph *irg, ir_node *block,
1399 ir_node *memop, ir_node *op1, ir_node *op2);
1401 /** Constructor for a DivMod node.
1403 * @param *db A pointer for debug information.
1404 * @param *irg The ir graph the node belongs to.
1405 * @param *block The ir block the node belongs to.
1406 * @param *memop The store needed to model exceptions
1407 * @param *op1 The first operand.
1408 * @param *op2 The second operand.
1410 ir_node *new_rd_DivMod (dbg_info *db, ir_graph *irg, ir_node *block,
1411 ir_node *memop, ir_node *op1, ir_node *op2);
1413 /** Constructor for a Div node.
1415 * @param *db A pointer for debug information.
1416 * @param *irg The ir graph the node belongs to.
1417 * @param *block The ir block the node belongs to.
1418 * @param *memop The store needed to model exceptions
1419 * @param *op1 The first operand.
1420 * @param *op2 The second operand.
1422 ir_node *new_rd_Div (dbg_info *db, ir_graph *irg, ir_node *block,
1423 ir_node *memop, ir_node *op1, ir_node *op2);
1425 /** Constructor for a Mod node.
1427 * @param *db A pointer for debug information.
1428 * @param *irg The ir graph the node belongs to.
1429 * @param *block The ir block the node belongs to.
1430 * @param *memop The store needed to model exceptions
1431 * @param *op1 The first operand.
1432 * @param *op2 The second operand.
1434 ir_node *new_rd_Mod (dbg_info *db, ir_graph *irg, ir_node *block,
1435 ir_node *memop, ir_node *op1, ir_node *op2);
1437 /** Constructor for a Abs node.
1439 * @param *db A pointer for debug information.
1440 * @param *irg The ir graph the node belongs to.
1441 * @param *block The ir block the node belongs to.
1442 * @param *op The operand
1443 * @param *mode The mode of the operands and the result.
1445 ir_node *new_rd_Abs (dbg_info *db, ir_graph *irg, ir_node *block,
1446 ir_node *op, ir_mode *mode);
1448 /** Constructor for a And node.
1450 * @param *db A pointer for debug information.
1451 * @param *irg The ir graph the node belongs to.
1452 * @param *block The ir block the node belongs to.
1453 * @param *op1 The first operand.
1454 * @param *op2 The second operand.
1455 * @param *mode The mode of the operands and the result.
1457 ir_node *new_rd_And (dbg_info *db, ir_graph *irg, ir_node *block,
1458 ir_node *op1, ir_node *op2, ir_mode *mode);
1460 /** Constructor for a Or node.
1462 * @param *db A pointer for debug information.
1463 * @param *irg The ir graph the node belongs to.
1464 * @param *block The ir block the node belongs to.
1465 * @param *op1 The first operand.
1466 * @param *op2 The second operand.
1467 * @param *mode The mode of the operands and the result.
1469 ir_node *new_rd_Or (dbg_info *db, ir_graph *irg, ir_node *block,
1470 ir_node *op1, ir_node *op2, ir_mode *mode);
1472 /** Constructor for a Eor node.
1474 * @param *db A pointer for debug information.
1475 * @param *irg The ir graph the node belongs to.
1476 * @param *block The ir block the node belongs to.
1477 * @param *op1 The first operand.
1478 * @param *op2 The second operand.
1479 * @param *mode The mode of the operands and the results.
1481 ir_node *new_rd_Eor (dbg_info *db, ir_graph *irg, ir_node *block,
1482 ir_node *op1, ir_node *op2, ir_mode *mode);
1484 /** Constructor for a Not node.
1486 * @param *db A pointer for debug information.
1487 * @param *irg The ir graph the node belongs to.
1488 * @param *block The ir block the node belongs to.
1489 * @param *op The operand.
1490 * @param *mode The mode of the operand and the result.
1492 ir_node *new_rd_Not (dbg_info *db, ir_graph *irg, ir_node *block,
1493 ir_node *op, ir_mode *mode);
1495 /** Constructor for a Cmp node.
1497 * @param *db A pointer for debug information.
1498 * @param *irg The ir graph the node belongs to.
1499 * @param *block The ir block the node belongs to.
1500 * @param *op1 The first operand.
1501 * @param *op2 The second operand.
1503 ir_node *new_rd_Cmp (dbg_info *db, ir_graph *irg, ir_node *block,
1504 ir_node *op1, ir_node *op2);
1506 /** Constructor for a Shl node.
1508 * @param *db A pointer for debug information.
1509 * @param *irg The ir graph the node belongs to.
1510 * @param *block The ir block the node belongs to.
1511 * @param *op The operand.
1512 * @param *k The number of bits to shift the operand .
1513 * @param *mode The mode of the operand and the result.
1515 ir_node *new_rd_Shl (dbg_info *db, ir_graph *irg, ir_node *block,
1516 ir_node *op, ir_node *k, ir_mode *mode);
1518 /** Constructor for a Shr node.
1520 * @param *db A pointer for debug information.
1521 * @param *irg The ir graph the node belongs to.
1522 * @param *block The ir block the node belongs to.
1523 * @param *op The operand.
1524 * @param *k The number of bits to shift the operand .
1525 * @param *mode The mode of the operand and the result.
1527 ir_node *new_rd_Shr (dbg_info *db, ir_graph *irg, ir_node *block,
1528 ir_node *op, ir_node *k, ir_mode *mode);
1530 /** Constructor for a Shrs node.
1532 * @param *db A pointer for debug information.
1533 * @param *irg The ir graph the node belongs to.
1534 * @param *block The ir block the node belongs to.
1535 * @param *op The operand.
1536 * @param *k The number of bits to shift the operand.
1537 * @param *mode The mode of the operand and the result.
1539 ir_node *new_rd_Shrs (dbg_info *db, ir_graph *irg, ir_node *block,
1540 ir_node *op, ir_node *k, ir_mode *mode);
1542 /** Constructor for a Rot node.
1544 * @param *db A pointer for debug information.
1545 * @param *irg The ir graph the node belongs to.
1546 * @param *block The ir block the node belongs to.
1547 * @param *op The operand.
1548 * @param *k The number of bits to rotate the operand.
1549 * @param *mode The mode of the operand.
1551 ir_node *new_rd_Rot (dbg_info *db, ir_graph *irg, ir_node *block,
1552 ir_node *op, ir_node *k, ir_mode *mode);
1555 /** Constructor for a Conv node.
1557 * @param *db A pointer for debug information.
1558 * @param *irg The ir graph the node belongs to.
1559 * @param *block The ir block the node belongs to.
1560 * @param *op The operand.
1561 * @param *mode The mode of this the operand muss be converted .
1563 ir_node *new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block,
1564 ir_node *op, ir_mode *mode);
1566 /** Constructor for a Cast node.
1568 * High level type cast.
1570 * @param *db A pointer for debug information.
1571 * @param *irg The ir graph the node belongs to.
1572 * @param *block The ir block the node belongs to.
1573 * @param *op The operand.
1574 * @param *to_tp The type of this the operand muss be casted .
1576 ir_node *new_rd_Cast (dbg_info* db, ir_graph *irg, ir_node *block,
1577 ir_node *op, type *to_tp);
1579 /** Constructor for a Phi node.
1581 * @param *db A pointer for debug information.
1582 * @param *irg The ir graph the node belongs to.
1583 * @param *block The ir block the node belongs to.
1584 * @param arity The number of predecessors
1585 * @param *in[] Array with predecessors. The constructor copies this array.
1586 * @param *mode The mode of it's inputs and output.
1588 ir_node *new_rd_Phi (dbg_info *db, ir_graph *irg, ir_node *block, int arity,
1589 ir_node *in[], ir_mode *mode);
1591 /** Constructor for a Load node.
1593 * @param *db A pointer for debug information.
1594 * @param *irg The ir graph the node belongs to.
1595 * @param *block The ir block the node belongs to.
1596 * @param *store The current memory
1597 * @param *adr A pointer to the variable to be read in this memory.
1598 * @param *mode The mode of the value to be loaded.
1600 ir_node *new_rd_Load (dbg_info *db, ir_graph *irg, ir_node *block,
1601 ir_node *store, ir_node *adr, ir_mode *mode);
1603 /** Constructor for a Store node.
1605 * @param *db A pointer for debug information.
1606 * @param *irg The ir graph the node belongs to.
1607 * @param *block The ir block the node belongs to.
1608 * @param *store The current memory
1609 * @param *adr A pointer to the variable to be read in this memory.
1610 * @param *val The value to write to this variable.
1612 ir_node *new_rd_Store (dbg_info *db, ir_graph *irg, ir_node *block,
1613 ir_node *store, ir_node *adr, ir_node *val);
1615 /** Constructor for a Alloc node.
1617 * The Alloc node extends the memory by space for an entity of type alloc_type.
1619 * @param *db A pointer for debug information.
1620 * @param *irg The ir graph the node belongs to.
1621 * @param *block The ir block the node belongs to.
1622 * @param *store The memory which shall contain the new variable.
1623 * @param *size The number of bytes to allocate.
1624 * @param *alloc_type The type of the allocated variable.
1625 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
1627 ir_node *new_rd_Alloc (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1628 ir_node *size, type *alloc_type, where_alloc where);
1630 /** Constructor for a Free node.
1632 * Frees the memory occupied by the entity pointed to by the pointer
1633 * arg. Type indicates the type of the entity the argument points to.
1635 * @param *db A pointer for debug information.
1636 * @param *irg The ir graph the node belongs to.
1637 * @param *block The ir block the node belongs to.
1638 * @param *store The memory which shall contain the new variable.
1639 * @param *ptr The pointer to the object to free.
1640 * @param *size The number of objects of type free_type to free in a sequence.
1641 * @param *free_type The type of the freed variable.
1642 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
1644 ir_node *new_rd_Free (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
1645 ir_node *ptr, ir_node *size, type *free_type, where_alloc where);
1647 /** Constructor for a Sync node.
1649 * Merges several memory values. The node assumes that a variable
1650 * either occurs only in one of the memories, or it contains the same
1651 * value in all memories where it occurs.
1653 * @param *db A pointer for debug information.
1654 * @param *irg The ir graph the node belongs to.
1655 * @param *block The ir block the node belongs to.
1656 * @param arity The number of memories to synchronize.
1657 * @param *in[] An array of pointers to nodes that produce an output of type
1658 * memory. The constructor copies this array.
1660 ir_node *new_rd_Sync (dbg_info *db, ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
1662 /** Constructor for a Proj node.
1664 * Projects a single value out of a tuple. The parameter proj gives the
1665 * position of the value within the tuple.
1667 * @param *db A pointer for debug information.
1668 * @param *irg The ir graph the node belongs to.
1669 * @param *block The ir block the node belongs to.
1670 * @param arg A node producing a tuple. The node must have mode_T.
1671 * @param *mode The mode of the value to project.
1672 * @param proj The position of the value in the tuple.
1674 ir_node *new_rd_Proj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1675 ir_mode *mode, long proj);
1677 /** Constructor for a defaultProj node.
1679 * Represents the default control flow of a Switch-Cond node.
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 arg A node producing a tuple.
1685 * @param max_proj The end position of the value in the tuple.
1687 ir_node *new_rd_defaultProj (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1690 /** Constructor for a Tuple node.
1692 * This is an auxiliary node to replace a node that returns a tuple
1693 * without changing the corresponding Proj nodes.
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 arity The number of tuple elements.
1699 * @param *in[] An array containing pointers to the nodes producing the tuple
1700 * elements. The constructor copies this array.
1702 ir_node *new_rd_Tuple (dbg_info *db, ir_graph *irg, ir_node *block,
1703 int arity, ir_node *in[]);
1705 /** Constructor for a Id node.
1707 * This is an auxiliary node to replace a node that returns a single
1710 * @param *db A pointer for debug information.
1711 * @param *irg The ir graph the node belongs to.
1712 * @param *block The ir block the node belongs to.
1713 * @param *val The value
1714 * @param *mode The mode of *val.
1716 ir_node *new_rd_Id (dbg_info *db, ir_graph *irg, ir_node *block,
1717 ir_node *val, ir_mode *mode);
1719 /** Constructor for a Bad node.
1721 * Returns the unique Bad node of the graph. The same as
1724 * @param *irg The ir graph the node belongs to.
1726 ir_node *new_rd_Bad (ir_graph *irg);
1728 /** Constructor for a Confirm node.
1730 * Specifies constraints for a value. To support dataflow analyses.
1732 * Example: If the value never exceeds '100' this is expressed by placing a
1733 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
1735 * @param *irg The ir graph the node belong to.
1736 * @param *block The ir block the node belong to.
1737 * @param *db A pointer for debug information.
1738 * @param *val The value we express a constraint for
1739 * @param *bound The value to compare against. Must be a firm node, typically a constant.
1740 * @param cmp The compare operation.
1742 ir_node *new_rd_Confirm (dbg_info *db, ir_graph *irg, ir_node *block,
1743 ir_node *val, ir_node *bound, pn_Cmp cmp);
1745 /** Constructor for an Unknown node.
1747 * Represents an arbitrary value. Places the node in the start block.
1749 * @param *irg The ir graph the node belongs to.
1750 * @param *m The mode of the unknown value.
1752 ir_node *new_rd_Unknown(ir_graph *irg, ir_mode *m);
1754 /** Constructor for a CallBegin node.
1756 * CallBegin represents control flow depending of the pointer value
1757 * representing the called method to the called methods. The
1758 * constructor copies the method pointer input from the passed Call
1761 * @param *db A pointer for debug information.
1762 * @param *irg The ir graph the node belong to.
1763 * @param *block The block the node belong to.
1764 * @param *callee The call node visible in the intra procedural view.
1766 ir_node *new_rd_CallBegin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *callee);
1768 /** Constructor for a EndReg node.
1770 * Used to represent regular procedure end in interprocedual view.
1772 * @param *db A pointer for debug information.
1773 * @param *irg The ir graph the node belong to.
1774 * @param *block The block the node belong to.
1776 ir_node *new_rd_EndReg (dbg_info *db, ir_graph *irg, ir_node *block);
1778 /** Constructor for a EndExcept node.
1780 * Used to represent exceptional procedure end in interprocedural view.
1782 * @param *db A pointer for debug information.
1783 * @param *irg The ir graph the node belong to.
1784 * @param *block The block the node belong to.
1786 ir_node *new_rd_EndExcept(dbg_info *db, ir_graph *irg, ir_node *block);
1788 /** Constructor for a Filter node.
1790 * Adds the node to the block in current_ir_block. Filter is a node
1791 * with two views used to construct the interprocedural view. In
1792 * intraprocedural view its semantics are identical to the Proj node.
1793 * In interprocedural view the Filter performs the Phi operation on
1794 * method parameters or results. Other than a Phi a Filter node may
1795 * not be removed if it has only a single input.
1797 * The constructor builds the Filter in intraprocedural view.
1799 * @param *db A pointer for debug information.
1800 * @param *irg The ir graph the node belong to.
1801 * @param *block The block the node belong to.
1802 * @param *arg The tuple value to project from.
1803 * @param *mode The mode of the projected value.
1804 * @param proj The position in the tuple to project from.
1806 ir_node *new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg,
1807 ir_mode *mode, long proj);
1809 /** Constructor for a NoMem node.
1811 * Returns the unique NoMem node of the graph. The same as
1814 * @param *irg The ir graph the node belongs to.
1816 ir_node *new_rd_NoMem (ir_graph *irg);
1818 /** Constructor for a Mux node.
1820 * Adds the node to the block in current_ir_block.
1822 * @param *db A pointer for debug information.
1823 * @param *irg The ir graph the node belong to.
1824 * @param *block The block the node belong to.
1825 * @param *sel The ir_node that calculates the boolean select.
1826 * @param *ir_true The ir_node that calculates the true result.
1827 * @param *ir_false The ir_node that calculates the false result.
1828 * @param *mode The mode of the node (and it_true and ir_false).
1830 ir_node *new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block,
1831 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
1833 /** Constructor for a CopyB node.
1835 * Adds the node to the block in current_ir_block.
1837 * @param *db A pointer for debug information.
1838 * @param *irg The ir graph the node belong to.
1839 * @param *block The block the node belong to.
1840 * @param *store The current memory
1841 * @param *dst The ir_node that represents the destination address.
1842 * @param *src The ir_node that represents the source address.
1843 * @param *data_type The type of the copied data
1845 ir_node *new_rd_CopyB(dbg_info *db, ir_graph *irg, ir_node *block,
1846 ir_node *store, ir_node *dst, ir_node *src, type *data_type);
1848 /*-------------------------------------------------------------------------*/
1849 /* The raw interface without debug support */
1850 /*-------------------------------------------------------------------------*/
1852 /** Constructor for a Block node.
1854 * Constructs a mature block with the given predecessors. Use Unknown
1855 * nodes as predecessors to construct a block if the number of
1856 * predecessors is known, but not the predecessors themselves. This
1857 * constructor does not set current_block. It not be used with
1858 * automatic Phi node construction.
1861 * @param irg The ir graph the block belongs to.
1862 * @param arity The number of control predecessors.
1863 * @param in[] An array of control predecessors. The length of
1864 * the array must be 'arity'. The constructor copies this array.
1866 ir_node *new_r_Block (ir_graph *irg, int arity, ir_node *in[]);
1868 /** Constructor for a Start node.
1870 * @param *irg The ir graph the node belongs to.
1871 * @param *block The ir block the node belongs to.
1873 ir_node *new_r_Start (ir_graph *irg, ir_node *block);
1875 /** Constructor for a End node.
1877 * @param *irg The ir graph the node belongs to.
1878 * @param *block The ir block the node belongs to.
1880 ir_node *new_r_End (ir_graph *irg, ir_node *block);
1882 /** Constructor for a Jmp node.
1884 * Jmp represents control flow to a single control successor.
1886 * @param *irg The ir graph the node belongs to.
1887 * @param *block The ir block the node belongs to.
1889 ir_node *new_r_Jmp (ir_graph *irg, ir_node *block);
1891 /** Constructor for an IJmp node.
1893 * IJmp represents control flow to a single control successor not
1894 * statically known i.e. an indirect Jmp.
1896 * @param *irg The ir graph the node belongs to.
1897 * @param *block The ir block the node belongs to.
1898 * @param *tgt The ir node representing the target address.
1900 ir_node *new_r_IJmp (ir_graph *irg, ir_node *block, ir_node *tgt);
1902 /** Constructor for a Cond node.
1904 * If c is mode_b represents a conditional branch (if/else). If c is
1905 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1906 * node, default Proj is 0.)
1908 * This is not consistent: Input to Cond is Is, Proj has as proj number
1911 * @param *irg The ir graph the node belongs to.
1912 * @param *block The ir block the node belongs to.
1913 * @param *c The conditions parameter.Can be of mode b or I_u.
1915 ir_node *new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c);
1917 /** Constructor for a Return node.
1919 * Returns the memory an zero or more return values. Only node that
1920 * can end regular control flow.
1922 * @param *irg The ir graph the node belongs to.
1923 * @param *block The ir block the node belongs to.
1924 * @param *store The state of memory.
1925 * @param arity Number of array indices.
1926 * @param *in[] Array with index inputs to the node. The constructor copies this array.
1928 ir_node *new_r_Return (ir_graph *irg, ir_node *block,
1929 ir_node *store, int arity, ir_node *in[]);
1931 /** Constructor for a Raise node.
1933 * @param *irg The ir graph the node belongs to.
1934 * @param *block The ir block the node belongs to.
1935 * @param *store The current memory.
1936 * @param *obj A pointer to the Except variable.
1938 ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
1939 ir_node *store, ir_node *obj);
1941 /** Constructor for a Const node.
1943 * Constructor for a Const node. The constant represents a target
1944 * value. Sets the type information to type_unknown. (No more
1945 * supported: If tv is entity derives a somehow useful type.)
1947 * @param *irg The ir graph the node belongs to.
1948 * @param *block The ir block the node belongs to.
1949 * @param *mode The mode of the operands and the results.
1950 * @param *con Points to an entry in the constant table.
1952 ir_node *new_r_Const (ir_graph *irg, ir_node *block,
1953 ir_mode *mode, tarval *con);
1955 /** Constructor for a Const node.
1957 * Constructor for a Const node. The constant represents a target
1958 * value. Sets the type information to type_unknown. (No more
1959 * supported: If tv is entity derives a somehow useful type.)
1961 * @param *irg The ir graph the node belongs to.
1962 * @param *block The ir block the node belongs to.
1963 * @param *mode The mode of the operands and the results.
1964 * @param value A value from which the tarval is made.
1966 ir_node *new_r_Const_long(ir_graph *irg, ir_node *block,
1967 ir_mode *mode, long value);
1969 /** Constructor for a Const_type node.
1971 * The constant represents a target value. This constructor sets high
1972 * level type information for the constant value.
1974 * @param *irg The ir graph the node belongs to.
1975 * @param *block The ir block the node belongs to.
1976 * @param *mode The mode of the operands and results.
1977 * @param *con Points to an entry in the constant table.
1978 * @param *tp The type of the constant.
1980 ir_node *new_r_Const_type(ir_graph *irg, ir_node *block,
1981 ir_mode *mode, tarval *con, type *tp);
1983 /** Constructor for a SymConst node.
1985 * This is the constructor for a symbolic constant.
1986 * There are four kinds of symbolic constants:
1987 * - type_tag The symbolic constant represents a type tag. The type the
1988 * tag stands for is given explicitly.
1989 * - size The symbolic constant represents the size of a type. The
1990 * type of which the constant represents the size is given
1992 * - addr_name The symbolic constant represents the address of an entity
1993 * (variable or method). The variable is indicated by a name
1994 * that is valid for linking.
1995 * - addr_ent The symbolic constant represents the address of an entity
1996 * (variable or method). The variable is given explicitly by
1999 * Inputs to the node:
2000 * No inputs except the block it belongs to.
2001 * Outputs of the node.
2002 * An unsigned integer (I_u) or a pointer (P).
2004 * @param *irg The ir graph the node belongs to.
2005 * @param *block The ir block the node belongs to.
2006 * @param value A type, entity or a ident depending on the SymConst kind.
2007 * @param symkind The kind of the symbolic constant: type_tag, size or link_info.
2009 ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
2010 union symconst_symbol value, symconst_kind symkind);
2012 /** Constructor for a Sel node.
2014 * The select node selects an entity (field or method) from an entity
2015 * with a compound type. It explicitly specifies the entity selected.
2016 * Dynamically the node may select entities that overwrite the given
2017 * entity. If the selected entity is an array element entity the Sel
2018 * node takes the required array indices as inputs.
2020 * @param *irg The ir graph the node belongs to.
2021 * @param *block The ir block the node belongs to.
2022 * @param *store The memory in which the object the entity should be selected
2023 * from is allocated.
2024 * @param *objptr A pointer to a compound entity the Sel operation selects a
2025 * single attribute from.
2026 * @param *n_index The number of array indices needed to select an array element entity.
2027 * @param *index[] If the compound entity is an array the indices of the selected
2028 * element entity. The constructor copies this array.
2029 * @param *ent The entity to select.
2031 ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store,
2032 ir_node *objptr, int n_index, ir_node *index[],
2035 /** Constructor for a InstOf node.
2037 * For translating Java. Not supported as standard firm node.
2039 * @param *irg The ir graph the node belongs to.
2040 * @param *block The ir block the node belongs to.
2045 ir_node *new_r_InstOf (ir_graph *irg, ir_node *block, ir_node *x, ir_node *y, type *z);
2047 /** Constructor for a Call node.
2049 * Represents all kinds of method and function calls.
2051 * @param *irg The ir graph the node belongs to.
2052 * @param *block The ir block the node belongs to.
2053 * @param *store The actual store.
2054 * @param *callee A pointer to the called procedure.
2055 * @param arity The number of procedure parameters.
2056 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2057 * @param *tp Type information of the procedure called.
2059 ir_node *new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
2060 ir_node *callee, int arity, ir_node *in[],
2063 /** Constructor for a Add node.
2065 * @param *irg The ir graph the node belongs to.
2066 * @param *block The ir block the node belongs to.
2067 * @param *op1 The first operand.
2068 * @param *op2 The second operand.
2069 * @param *mode The mode of the operands and the result.
2071 ir_node *new_r_Add (ir_graph *irg, ir_node *block,
2072 ir_node *op1, ir_node *op2, ir_mode *mode);
2075 * Constructor for a Sub node.
2077 * @param *irg The ir graph the node belongs to.
2078 * @param *block The ir block the node belongs to.
2079 * @param *op1 The first operand.
2080 * @param *op2 The second operand.
2081 * @param *mode The mode of the operands and the results.
2083 ir_node *new_r_Sub (ir_graph *irg, ir_node *block,
2084 ir_node *op1, ir_node *op2, ir_mode *mode);
2086 /** Constructor for a Minus node.
2088 * @param *irg The ir graph the node belongs to.
2089 * @param *block The ir block the node belongs to.
2090 * @param *op The operand.
2091 * @param *mode The mode of the operand and the result.
2093 ir_node *new_r_Minus (ir_graph *irg, ir_node *block,
2094 ir_node *op, ir_mode *mode);
2095 /** Constructor for a Mul node.
2097 * @param *irg The ir graph the node belongs to.
2098 * @param *block The ir block the node belongs to.
2099 * @param *op1 The first operand.
2100 * @param *op2 The second operand.
2101 * @param *mode The mode of the operands and the result.
2103 ir_node *new_r_Mul (ir_graph *irg, ir_node *block,
2104 ir_node *op1, ir_node *op2, ir_mode *mode);
2106 /** Constructor for a Quot node.
2108 * @param *irg The ir graph the node belongs to.
2109 * @param *block The ir block the node belongs to.
2110 * @param *memop The store needed to model exceptions
2111 * @param *op1 The first operand.
2112 * @param *op2 The second operand.
2114 ir_node *new_r_Quot (ir_graph *irg, ir_node *block,
2115 ir_node *memop, ir_node *op1, ir_node *op2);
2117 /** Constructor for a DivMod node.
2119 * @param *irg The ir graph the node belongs to.
2120 * @param *block The ir block the node belongs to.
2121 * @param *memop The store needed to model exceptions
2122 * @param *op1 The first operand.
2123 * @param *op2 The second operand.
2125 ir_node *new_r_DivMod (ir_graph *irg, ir_node *block,
2126 ir_node *memop, ir_node *op1, ir_node *op2);
2128 /** Constructor for a Div node.
2130 * @param *irg The ir graph the node belongs to.
2131 * @param *block The ir block the node belongs to.
2132 * @param *memop The store needed to model exceptions
2133 * @param *op1 The first operand.
2134 * @param *op2 The second operand.
2136 ir_node *new_r_Div (ir_graph *irg, ir_node *block,
2137 ir_node *memop, ir_node *op1, ir_node *op2);
2139 /** Constructor for a Mod node.
2141 * @param *irg The ir graph the node belongs to.
2142 * @param *block The ir block the node belongs to.
2143 * @param *memop The store needed to model exceptions
2144 * @param *op1 The first operand.
2145 * @param *op2 The second operand.
2147 ir_node *new_r_Mod (ir_graph *irg, ir_node *block,
2148 ir_node *memop, ir_node *op1, ir_node *op2);
2150 /** Constructor for a Abs node.
2152 * @param *irg The ir graph the node belongs to.
2153 * @param *block The ir block the node belongs to.
2154 * @param *op The operand
2155 * @param *mode The mode of the operands and the result.
2157 ir_node *new_r_Abs (ir_graph *irg, ir_node *block,
2158 ir_node *op, ir_mode *mode);
2160 /** Constructor for a And node.
2162 * @param *irg The ir graph the node belongs to.
2163 * @param *block The ir block the node belongs to.
2164 * @param *op1 The first operand.
2165 * @param *op2 The second operand.
2166 * @param *mode The mode of the operands and the result.
2168 ir_node *new_r_And (ir_graph *irg, ir_node *block,
2169 ir_node *op1, ir_node *op2, ir_mode *mode);
2171 /** Constructor for a Or node.
2173 * @param *irg The ir graph the node belongs to.
2174 * @param *block The ir block the node belongs to.
2175 * @param *op1 The first operand.
2176 * @param *op2 The second operand.
2177 * @param *mode The mode of the operands and the result.
2179 ir_node *new_r_Or (ir_graph *irg, ir_node *block,
2180 ir_node *op1, ir_node *op2, ir_mode *mode);
2182 /** Constructor for a Eor node.
2184 * @param *irg The ir graph the node belongs to.
2185 * @param *block The ir block the node belongs to.
2186 * @param *op1 The first operand.
2187 * @param *op2 The second operand.
2188 * @param *mode The mode of the operands and the results.
2190 ir_node *new_r_Eor (ir_graph *irg, ir_node *block,
2191 ir_node *op1, ir_node *op2, ir_mode *mode);
2193 /** Constructor for a Not node.
2195 * @param *irg The ir graph the node belongs to.
2196 * @param *block The ir block the node belongs to.
2197 * @param *op The operand.
2198 * @param *mode The mode of the operand and the result.
2200 ir_node *new_r_Not (ir_graph *irg, ir_node *block,
2201 ir_node *op, ir_mode *mode);
2203 /** Constructor for a Cmp node.
2205 * @param *irg The ir graph the node belongs to.
2206 * @param *block The ir block the node belongs to.
2207 * @param *op1 The first operand.
2208 * @param *op2 The second operand.
2210 ir_node *new_r_Cmp (ir_graph *irg, ir_node *block,
2211 ir_node *op1, ir_node *op2);
2213 /** Constructor for a Shl node.
2215 * @param *irg The ir graph the node belongs to.
2216 * @param *block The ir block the node belongs to.
2217 * @param *op The operand.
2218 * @param *k The number of bits to shift the operand .
2219 * @param *mode The mode of the operand and the result.
2221 ir_node *new_r_Shl (ir_graph *irg, ir_node *block,
2222 ir_node *op, ir_node *k, ir_mode *mode);
2224 /** Constructor for a Shr node.
2226 * @param *irg The ir graph the node belongs to.
2227 * @param *block The ir block the node belongs to.
2228 * @param *op The operand.
2229 * @param *k The number of bits to shift the operand .
2230 * @param *mode The mode of the operand and the result.
2232 ir_node *new_r_Shr (ir_graph *irg, ir_node *block,
2233 ir_node *op, ir_node *k, ir_mode *mode);
2236 * Constructor for a Shrs node.
2238 * @param *irg The ir graph the node belongs to.
2239 * @param *block The ir block the node belongs to.
2240 * @param *op The operand.
2241 * @param *k The number of bits to shift the operand.
2242 * @param *mode The mode of the operand and the result.
2244 ir_node *new_r_Shrs (ir_graph *irg, ir_node *block,
2245 ir_node *op, ir_node *k, ir_mode *mode);
2247 /** Constructor for a Rot node.
2249 * @param *irg The ir graph the node belongs to.
2250 * @param *block The ir block the node belongs to.
2251 * @param *op The operand.
2252 * @param *k The number of bits to rotate the operand.
2253 * @param *mode The mode of the operand.
2255 ir_node *new_r_Rot (ir_graph *irg, ir_node *block,
2256 ir_node *op, ir_node *k, ir_mode *mode);
2258 /** Constructor for a Conv node.
2260 * @param *irg The ir graph the node belongs to.
2261 * @param *block The ir block the node belongs to.
2262 * @param *op The operand.
2263 * @param *mode The mode of this the operand muss be converted .
2265 ir_node *new_r_Conv (ir_graph *irg, ir_node *block,
2266 ir_node *op, ir_mode *mode);
2268 /** Constructor for a Cast node.
2270 * High level type cast
2272 * @param *irg The ir graph the node belongs to.
2273 * @param *block The ir block the node belongs to.
2274 * @param *op The operand.
2275 * @param *to_tp The type of this the operand muss be casted .
2277 ir_node *new_r_Cast (ir_graph *irg, ir_node *block,
2278 ir_node *op, type *to_tp);
2280 /** Constructor for a Phi node.
2282 * @param *irg The ir graph the node belongs to.
2283 * @param *block The ir block the node belongs to.
2284 * @param arity The number of predecessors
2285 * @param *in[] Array with predecessors. The constructor copies this array.
2286 * @param *mode The mode of it's inputs and output.
2288 ir_node *new_r_Phi (ir_graph *irg, ir_node *block, int arity,
2289 ir_node *in[], ir_mode *mode);
2291 /** Constructor for a Load node.
2293 * @param *irg The ir graph the node belongs to.
2294 * @param *block The ir block the node belongs to.
2295 * @param *store The current memory
2296 * @param *adr A pointer to the variable to be read in this memory.
2297 * @param *mode The mode of the value to be loaded.
2299 ir_node *new_r_Load (ir_graph *irg, ir_node *block,
2300 ir_node *store, ir_node *adr, ir_mode *mode);
2302 /** Constructor for a Store node.
2304 * @param *irg The ir graph the node belongs to.
2305 * @param *block The ir block the node belongs to.
2306 * @param *store The current memory
2307 * @param *adr A pointer to the variable to be read in this memory.
2308 * @param *val The value to write to this variable.
2310 ir_node *new_r_Store (ir_graph *irg, ir_node *block,
2311 ir_node *store, ir_node *adr, ir_node *val);
2313 /** Constructor for a Alloc node.
2315 * The Alloc node extends the memory by space for an entity of type alloc_type.
2317 * @param *irg The ir graph the node belongs to.
2318 * @param *block The ir block the node belongs to.
2319 * @param *store The memory which shall contain the new variable.
2320 * @param *size The number of bytes to allocate.
2321 * @param *alloc_type The type of the allocated variable.
2322 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2324 ir_node *new_r_Alloc (ir_graph *irg, ir_node *block, ir_node *store,
2325 ir_node *size, type *alloc_type, where_alloc where);
2327 /** Constructor for a Free node.
2329 * Frees the memory occupied by the entity pointed to by the pointer
2330 * arg. Type indicates the type of the entity the argument points to.
2332 * @param *irg The ir graph the node belongs to.
2333 * @param *block The ir block the node belongs to.
2334 * @param *store The memory which shall contain the new variable.
2335 * @param *ptr The pointer to the object to free.
2336 * @param *size The number of objects of type free_type to free in a sequence.
2337 * @param *free_type The type of the freed variable.
2338 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2340 ir_node *new_r_Free (ir_graph *irg, ir_node *block, ir_node *store,
2341 ir_node *ptr, ir_node *size, type *free_type, where_alloc where);
2343 /** Constructor for a Sync node.
2345 * Merges several memory values. The node assumes that a variable
2346 * either occurs only in one of the memories, or it contains the same
2347 * value in all memories where it occurs.
2349 * @param *irg The ir graph the node belongs to.
2350 * @param *block The ir block the node belongs to.
2351 * @param arity The number of memories to synchronize.
2352 * @param *in[] An array of pointers to nodes that produce an output of type memory.
2353 * The constructor copies this array.
2355 ir_node *new_r_Sync (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2357 /** Constructor for a Proj node.
2359 * Projects a single value out of a tuple. The parameter proj gives the
2360 * position of the value within the tuple.
2362 * @param *irg The ir graph the node belongs to.
2363 * @param *block The ir block the node belongs to.
2364 * @param arg A node producing a tuple.
2365 * @param *mode The mode of the value to project.
2366 * @param proj The position of the value in the tuple.
2368 ir_node *new_r_Proj (ir_graph *irg, ir_node *block, ir_node *arg,
2369 ir_mode *mode, long proj);
2371 /** Constructor for a defaultProj node.
2373 * Represents the default control flow of a Switch-Cond node.
2375 * @param *irg The ir graph the node belongs to.
2376 * @param *block The ir block the node belongs to.
2377 * @param arg A node producing a tuple.
2378 * @param max_proj The end position of the value in the tuple.
2380 ir_node *new_r_defaultProj (ir_graph *irg, ir_node *block, ir_node *arg, long max_proj);
2383 /** Constructor for a Tuple node.
2385 * This is an auxiliary node to replace a node that returns a tuple
2386 * without changing the corresponding Proj nodes.
2388 * @param *irg The ir graph the node belongs to.
2389 * @param *block The ir block the node belongs to.
2390 * @param arity The number of tuple elements.
2391 * @param *in[] An array containing pointers to the nodes producing the tuple elements.
2392 * The constructor copies this array.
2394 ir_node *new_r_Tuple (ir_graph *irg, ir_node *block, int arity, ir_node *in[]);
2396 /** Constructor for a Id node.
2398 * This is an auxiliary node to replace a node that returns a single
2401 * @param *irg The ir graph the node belongs to.
2402 * @param *block The ir block the node belongs to.
2403 * @param *val The operand to Id.
2404 * @param *mode The mode of *val.
2406 ir_node *new_r_Id (ir_graph *irg, ir_node *block,
2407 ir_node *val, ir_mode *mode);
2409 /** Constructor for a Bad node.
2411 * Returns the unique Bad node of the graph. The same as
2414 * @param *irg The ir graph the node belongs to.
2418 ir_node *new_r_Bad (ir_graph *irg);
2420 /** Constructor for a Confirm node.
2422 * Specifies constraints for a value. To support dataflow analyses.
2424 * Example: If the value never exceeds '100' this is expressed by placing a
2425 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
2427 * @param *irg The ir graph the node belong to.
2428 * @param *block The ir block the node belong to.
2429 * @param *val The value we express a constraint for
2430 * @param *bound The value to compare against. Must be a firm node, typically a constant.
2431 * @param cmp The compare operation.
2434 ir_node *new_r_Confirm (ir_graph *irg, ir_node *block,
2435 ir_node *val, ir_node *bound, pn_Cmp cmp);
2437 /** Constructor for a Unknown node.
2439 * Represents an arbitrary value. Places the node in
2442 * @param *irg The ir graph the node belongs to.
2443 * @param *m The mode of the unknown value.
2445 ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2447 /** Constructor for a CallBegin node.
2449 * CallBegin represents control flow depending of the pointer value
2450 * representing the called method to the called methods. The
2451 * constructor copies the method pointer input from the passed Call
2454 * @param *irg The ir graph the node belong to.
2455 * @param *block The block the node belong to.
2456 * @param *callee The call node visible in the intra procedural view.
2458 ir_node *new_r_CallBegin(ir_graph *irg, ir_node *block, ir_node *callee);
2460 /** Constructor for a EndReg node.
2462 * Used to represent regular procedure end in interprocedual view.
2464 * @param *irg The ir graph the node belong to.
2465 * @param *block The block the node belong to.
2467 ir_node *new_r_EndReg (ir_graph *irg, ir_node *block);
2469 /** Constructor for a EndExcept node.
2471 * Used to represent exceptional procedure end in interprocedural view.
2473 * @param *irg The ir graph the node belong to.
2474 * @param *block The block the node belong to.
2476 ir_node *new_r_EndExcept(ir_graph *irg, ir_node *block);
2478 /** Constructor for a Break node.
2480 * Break represents control flow to a single control successor just as Jmp.
2481 * The blocks separated by a break may not be concatenated by an optimization.
2482 * It is used for the interprocedural representation where blocks are parted
2483 * behind Call nodes to represent the control flow to called procedures.
2485 * @param *irg The ir graph the node belong to.
2486 * @param *block The block the node belong to.
2488 ir_node *new_r_Break (ir_graph *irg, ir_node *block);
2490 /** Constructor for a Filter node.
2492 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
2493 * Filter is a node with two views used to construct the interprocedural view.
2494 * In intraprocedural view its semantics are identical to the Proj node.
2495 * In interprocedural view the Filter performs the Phi operation on method
2496 * parameters or results. Other than a Phi a Filter node may not be removed
2497 * if it has only a single input.
2499 * The constructor builds the Filter in intraprocedural view.
2501 * @param *irg The ir graph the node belong to.
2502 * @param *block The block the node belong to.
2503 * @param *arg The tuple value to project from.
2504 * @param *mode The mode of the projected value.
2505 * @param proj The position in the tuple to project from.
2507 ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg,
2508 ir_mode *mode, long proj);
2510 /** Constructor for a NoMem node.
2512 * Returns the unique NoMem node of the graph. The same as
2515 * @param *irg The ir graph the node belongs to.
2517 ir_node *new_r_NoMem (ir_graph *irg);
2519 /** Constructor for a Mux node.
2521 * Adds the node to the block in current_ir_block.
2523 * @param *irg The ir graph the node belong to.
2524 * @param *block The block the node belong to.
2525 * @param *sel The ir_node that calculates the boolean select.
2526 * @param *ir_true The ir_node that calculates the true result.
2527 * @param *ir_false The ir_node that calculates the false result.
2528 * @param *mode The mode of the node (and it_true and ir_false).
2530 ir_node *new_r_Mux (ir_graph *irg, ir_node *block,
2531 ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2533 /** Constructor for a CopyB node.
2535 * Adds the node to the block in current_ir_block.
2537 * @param *irg The ir graph the node belong to.
2538 * @param *block The block the node belong to.
2539 * @param *store The current memory
2540 * @param *dst The ir_node that represents the destination address.
2541 * @param *src The ir_node that represents the source address.
2542 * @param *data_type The type of the copied data
2544 ir_node *new_r_CopyB(ir_graph *irg, ir_node *block,
2545 ir_node *store, ir_node *dst, ir_node *src, type *data_type);
2547 /*-----------------------------------------------------------------------*/
2548 /* The block oriented interface */
2549 /*-----------------------------------------------------------------------*/
2551 /** Sets the current block in which the following constructors place the
2552 * nodes they construct.
2554 * @param target The new current block.
2556 void set_cur_block (ir_node *target);
2558 /** Returns the current block of the current graph. */
2559 ir_node *get_cur_block(void);
2561 /** Returns the fixed nodes of the current graph. */
2562 #define get_cur_end_block() get_irg_end_block(current_ir_graph)
2563 #define get_cur_end() get_irg_end(current_ir_graph)
2564 #define get_cur_start_block() get_irg_start_block(current_ir_graph)
2565 #define get_cur_start() get_irg_start(current_ir_graph)
2567 /** Constructor for a Block node.
2569 * Adds the block to the graph in current_ir_graph. Constructs a Block
2570 * with a fixed number of predecessors. Does set current_block. Can
2571 * be used with automatic Phi node construction.
2573 * @param *db A Pointer for debug information.
2574 * @param arity The number of control predecessors.
2575 * @param in[] An array of control predecessors. The length of
2576 * the array must be 'arity'.
2578 ir_node *new_d_Block(dbg_info* db, int arity, ir_node *in[]);
2580 /** Constructor for a Start node.
2582 * Adds the node to the block in current_ir_block.
2584 * @param *db A pointer for debug information.
2586 ir_node *new_d_Start (dbg_info* db);
2588 /** Constructor for a End node.
2590 * Adds the node to the block in current_ir_block.
2592 * @param *db A pointer for debug information.
2594 ir_node *new_d_End (dbg_info* db);
2596 /** Constructor for a Jmp node.
2598 * Adds the node to the block in current_ir_block.
2600 * Jmp represents control flow to a single control successor.
2602 * @param *db A pointer for debug information.
2604 ir_node *new_d_Jmp (dbg_info* db);
2606 /** Constructor for an IJmp node.
2608 * IJmp represents control flow to a single control successor not
2609 * statically known i.e. an indirect Jmp.
2611 * @param *db A pointer for debug information.
2612 * @param *tgt The ir node representing the target address.
2614 ir_node *new_d_IJmp (dbg_info *db, ir_node *tgt);
2616 /** Constructor for a Cond node.
2618 * Adds the node to the block in current_ir_block.
2620 * If c is mode_b represents a conditional branch (if/else). If c is
2621 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2622 * node, default Proj is 0.)
2624 * This is not consistent: Input to Cond is Is, Proj has as proj number
2627 * @param *db A pointer for debug information.
2628 * @param *c The conditions parameter.Can be of mode b or I_u.
2631 ir_node *new_d_Cond (dbg_info* db, ir_node *c);
2633 /** Constructor for a Return node.
2635 * Adds the node to the block in current_ir_block.
2637 * Returns the memory an zero or more return values. Only node that
2638 * can end regular control flow.
2640 * @param *db A pointer for debug information.
2641 * @param *store The state of memory.
2642 * @param arity Number of array indices.
2643 * @param *in Array with index inputs to the node.
2646 ir_node *new_d_Return (dbg_info* db, ir_node *store, int arity, ir_node *in[]);
2648 /** Constructor for a Raise node.
2650 * Adds the node to the block in current_ir_block.
2652 * @param *db A pointer for debug information.
2653 * @param *store The current memory.
2654 * @param *obj A pointer to the Except variable.
2657 ir_node *new_d_Raise (dbg_info* db, ir_node *store, ir_node *obj);
2659 /** Constructor for a Const_type node.
2661 * Adds the node to the block in current_ir_block.
2663 * The constant represents a target value. This constructor sets high
2664 * level type information for the constant value.
2666 * @param *db A pointer for debug information.
2667 * @param *mode The mode of the operands and results.
2668 * @param *con Points to an entry in the constant table. This pointer is
2669 added to the attributes of the node.
2670 * @param *tp The type of the constant.
2672 ir_node *new_d_Const_type (dbg_info* db, ir_mode *mode, tarval *con, type *tp);
2674 /** Constructor for a Const node.
2676 * Adds the node to the block in current_ir_block.
2678 * Constructor for a Const node. The constant represents a target
2679 * value. Sets the type information to type_unknown. (No more
2680 * supported: If tv is entity derives a somehow useful type.)
2682 * @param *db A pointer for debug information.
2683 * @param *mode The mode of the operands and results.
2684 * @param *con Points to an entry in the constant table. This pointer is added
2685 * to the attributes of the node.
2687 ir_node *new_d_Const (dbg_info* db, ir_mode *mode, tarval *con);
2689 /** Constructor for a SymConst_type node.
2691 * Adds the node to the block in current_ir_block.
2692 * This is the constructor for a symbolic constant.
2693 * There are four kinds of symbolic constants:
2694 * - type_tag The symbolic constant represents a type tag. The type the
2695 * tag stands for is given explicitly.
2696 * - size The symbolic constant represents the size of a type. The
2697 * type of which the constant represents the size is given
2699 * - addr_name The symbolic constant represents the address of an entity
2700 * (variable or method). The variable is indicated by a name
2701 * that is valid for linking.
2702 * - addr_ent The symbolic constant represents the address of an entity
2703 * (variable or method). The variable is given explicitly by
2706 * Inputs to the node:
2707 * No inputs except the block it belongs to.
2708 * Outputs of the node.
2709 * An unsigned integer (I_u) or a pointer (P).
2711 * @param *db A pointer for debug information.
2712 * @param value A type, entity or ident depending on the SymConst kind.
2713 * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_size
2714 * or symconst_addr_name.
2715 * @param tp The source type of the constant.
2717 ir_node *new_d_SymConst_type (dbg_info* db, union symconst_symbol value, symconst_kind kind, type* tp);
2719 /** Constructor for a SymConst node.
2721 * Same as new_d_SymConst_type, except that it sets the type to type_unknown. */
2722 ir_node *new_d_SymConst (dbg_info* db, union symconst_symbol value, symconst_kind kind);
2724 /** Constructor for a simpleSel node.
2726 * This is a shortcut for the new_d_Sel() constructor. To be used for
2727 * Sel nodes that do not select from an array, i.e., have no index
2728 * inputs. It adds the two parameters 0, NULL.
2730 * @param *db A pointer for debug information.
2731 * @param *store The memory in which the object the entity should be
2732 * selected from is allocated.
2733 * @param *objptr The object from that the Sel operation selects a
2734 * single attribute out.
2735 * @param *ent The entity to select.
2737 ir_node *new_d_simpleSel(dbg_info* db, ir_node *store, ir_node *objptr, entity *ent);
2739 /** Constructor for a Sel node.
2741 * The select node selects an entity (field or method) from an entity
2742 * with a compound type. It explicitly specifies the entity selected.
2743 * Dynamically the node may select entities that overwrite the given
2744 * entity. If the selected entity is an array element entity the Sel
2745 * node takes the required array indices as inputs.
2746 * Adds the node to the block in current_ir_block.
2748 * @param *db A pointer for debug information.
2749 * @param *store The memory in which the object the entity should be selected
2750 * from is allocated.
2751 * @param *objptr A pointer to a compound entity the Sel operation selects a
2752 * single attribute from.
2753 * @param arity The number of array indices needed to select an array element entity.
2754 * @param *in[] If the compound entity is an array the indices of the selected
2755 * element entity. The constructor copies this array.
2756 * @param *ent The entity to select.
2758 ir_node *new_d_Sel (dbg_info* db, ir_node *store, ir_node *objptr, int arity, ir_node *in[],
2761 /** Constructor for a InstOf node.
2763 * Adds the node to the block in current_ir_block.
2765 * For translating Java. Not supported as standard firm node.
2767 * @param *db A pointer for debug information.
2772 ir_node *new_d_InstOf (dbg_info* db, ir_node *store, ir_node *objptr, type *ent);
2774 /** Constructor for a Call node.
2776 * Represents all kinds of method and function calls.
2777 * Adds the node to the block in current_ir_block.
2779 * @param *db A pointer for debug information.
2780 * @param *store The actual store.
2781 * @param *callee A pointer to the called procedure.
2782 * @param arity The number of procedure parameters.
2783 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2784 * @param *tp Type information of the procedure called.
2787 ir_node *new_d_Call (dbg_info* db, ir_node *store, ir_node *callee, int arity, ir_node *in[],
2790 /** Constructor for a Add node.
2792 * Adds the node to the block in current_ir_block.
2794 * @param *db A pointer for debug information.
2795 * @param *op1 The first operand.
2796 * @param *op2 The second operand.
2797 * @param *mode The mode of the operands and the result.
2799 ir_node *new_d_Add (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2801 /** Constructor for a Sub node.
2803 * Adds the node to the block in current_ir_block.
2805 * @param *db A pointer for debug information.
2806 * @param *op1 The first operand.
2807 * @param *op2 The second operand.
2808 * @param *mode The mode of the operands and the result.
2811 ir_node *new_d_Sub (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2813 /** Constructor for a Minus node.
2815 * Adds the node to the block in current_ir_block.
2817 * @param *db A pointer for debug information.
2818 * @param *op The operand .
2819 * @param *mode The mode of the operand and the result.
2821 ir_node *new_d_Minus (dbg_info* db, ir_node *op, ir_mode *mode);
2823 /** Constructor for a Mul node.
2825 * Adds the node to the block in current_ir_block.
2827 * @param *db A pointer for debug information.
2828 * @param *op1 The first operand.
2829 * @param *op2 The second operand.
2830 * @param *mode The mode of the operands and the result.
2832 ir_node *new_d_Mul (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2834 /** Constructor for a Quot node.
2836 * Adds the node to the block in current_ir_block.
2838 * @param *db A pointer for debug information.
2839 * @param *memop The store needed to model exceptions
2840 * @param *op1 The first operand.
2841 * @param *op2 The second operand.
2843 ir_node *new_d_Quot (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2845 /** Constructor for a DivMod node.
2847 * Adds the node to the block in current_ir_block.
2849 * @param *db A pointer for debug information.
2850 * @param *memop The store needed to model exceptions
2851 * @param *op1 The first operand.
2852 * @param *op2 The second operand.
2854 ir_node *new_d_DivMod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2856 /** Constructor for a Div node.
2858 * Adds the node to the block in current_ir_block.
2860 * @param *db A pointer for debug information.
2861 * @param *memop The store needed to model exceptions
2862 * @param *op1 The first operand.
2863 * @param *op2 The second operand.
2865 ir_node *new_d_Div (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2867 /** Constructor for a Mod node.
2869 * Adds the node to the block in current_ir_block.
2871 * @param *db A pointer for debug information.
2872 * @param *memop The store needed to model exceptions
2873 * @param *op1 The first operand.
2874 * @param *op2 The second operand.
2876 ir_node *new_d_Mod (dbg_info* db, ir_node *memop, ir_node *op1, ir_node *op2);
2878 /** Constructor for a Abs node.
2880 * Adds the node to the block in current_ir_block.
2882 * @param *db A pointer for debug information.
2883 * @param *op The operand
2884 * @param *mode The mode of the operands and the result.
2886 ir_node *new_d_Abs (dbg_info* db, ir_node *op, ir_mode *mode);
2888 /** Constructor for a And node.
2890 * Adds the node to the block in current_ir_block.
2892 * @param *db A pointer for debug information.
2893 * @param *op1 The first operand.
2894 * @param *op2 The second operand.
2895 * @param *mode The mode of the operands and the result.
2897 ir_node *new_d_And (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2899 /** Constructor for a Or node.
2901 * Adds the node to the block in current_ir_block.
2903 * @param *db A pointer for debug information.
2904 * @param *op1 The first operand.
2905 * @param *op2 The second operand.
2906 * @param *mode The mode of the operands and the result.
2908 ir_node *new_d_Or (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2910 /** Constructor for a Eor node.
2912 * Adds the node to the block in current_ir_block.
2914 * @param *db A pointer for debug information.
2915 * @param *op1 The first operand.
2916 * @param *op2 The second operand.
2917 * @param *mode The mode of the operands and the results.
2919 ir_node *new_d_Eor (dbg_info* db, ir_node *op1, ir_node *op2, ir_mode *mode);
2921 /** Constructor for a Not node.
2923 * Adds the node to the block in current_ir_block.
2925 * @param *db A pointer for debug information.
2926 * @param *op The operand.
2927 * @param *mode The mode of the operand and the result.
2929 ir_node *new_d_Not (dbg_info* db, ir_node *op, ir_mode *mode);
2931 /** Constructor for a Shl node.
2933 * Adds the node to the block in current_ir_block.
2935 * @param *db A pointer for debug information.
2936 * @param *op The operand.
2937 * @param *k The number of bits to shift the operand .
2938 * @param *mode The mode of the operand and the result.
2940 ir_node *new_d_Shl (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2942 /** Constructor for a Shr node.
2944 * Adds the node to the block in current_ir_block.
2946 * @param *db A pointer for debug information.
2947 * @param *op The operand.
2948 * @param *k The number of bits to shift the operand .
2949 * @param *mode The mode of the operand and the result.
2951 ir_node *new_d_Shr (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2953 /** Constructor for a Shrs node.
2955 * Adds the node to the block in current_ir_block.
2957 * @param *db A pointer for debug information.
2958 * @param *op The operand.
2959 * @param *k The number of bits to shift the operand .
2960 * @param *mode The mode of the operand and the result.
2962 ir_node *new_d_Shrs (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2964 /** Constructor for a Rot node.
2966 * Adds the node to the block in current_ir_block.
2968 * @param *db A pointer for debug information.
2969 * @param *op The operand.
2970 * @param *k The number of bits to rotate the operand.
2971 * @param *mode The mode of the operand.
2973 ir_node *new_d_Rot (dbg_info* db, ir_node *op, ir_node *k, ir_mode *mode);
2975 /** Constructor for a Cmp node.
2977 * Adds the node to the block in current_ir_block.
2979 * @param *db A pointer for debug information.
2980 * @param *op1 The first operand.
2981 * @param *op2 The second operand.
2983 ir_node *new_d_Cmp (dbg_info* db, ir_node *op1, ir_node *op2);
2985 /** Constructor for a Conv node.
2987 * Adds the node to the block in current_ir_block.
2989 * @param *db A pointer for debug information.
2990 * @param *op The operand.
2991 * @param *mode The mode of this the operand muss be converted .
2993 ir_node *new_d_Conv (dbg_info* db, ir_node *op, ir_mode *mode);
2995 /**Constructor for a Cast node.
2997 * High level type cast
2998 * Adds the node to the block in current_ir_block.
3000 * @param *db A pointer for debug information.
3001 * @param *op The operand.
3002 * @param *to_tp The type of this the operand muss be casted .
3004 ir_node *new_d_Cast (dbg_info* db, ir_node *op, type *to_tp);
3006 /**Constructor for a Phi node.
3008 * Adds the node to the block in current_ir_block.
3010 * @param *db A pointer for debug information.
3011 * @param arity The number of predecessors
3012 * @param *in Array with predecessors
3013 * @param *mode The mode of it's inputs and output.
3015 ir_node *new_d_Phi (dbg_info* db, int arity, ir_node *in[], ir_mode *mode);
3017 /** Constructor for a Load node.
3019 * Adds the node to the block in current_ir_block.
3021 * @param *db A pointer for debug information.
3022 * @param *store The current memory
3023 * @param *addr A pointer to the variable to be read in this memory.
3024 * @param *mode The mode of the value to be loaded.
3026 ir_node *new_d_Load (dbg_info* db, ir_node *store, ir_node *addr, ir_mode *mode);
3028 /** Constructor for a Store node.
3030 * Adds the node to the block in current_ir_block.
3032 * @param *db A pointer for debug information.
3033 * @param *store The current memory
3034 * @param *addr A pointer to the variable to be read in this memory.
3035 * @param *val The value to write to this variable.
3037 ir_node *new_d_Store (dbg_info* db, ir_node *store, ir_node *addr, ir_node *val);
3039 /** Constructor for a Alloc node.
3041 * The Alloc node extends the memory by space for an entity of type alloc_type.
3042 * Adds the node to the block in current_ir_block.
3044 * @param *db A pointer for debug information.
3045 * @param *store The memory which shall contain the new variable.
3046 * @param *size The number of bytes to allocate.
3047 * @param *alloc_type The type of the allocated variable.
3048 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3050 ir_node *new_d_Alloc (dbg_info* db, ir_node *store, ir_node *size, type *alloc_type,
3053 /** Constructor for a Free node.
3055 * Frees the memory occupied by the entity pointed to by the pointer
3056 * arg. Type indicates the type of the entity the argument points to.
3057 * Adds the node to the block in current_ir_block.
3059 * @param *db A pointer for debug information.
3060 * @param *store The memory which shall contain the new variable.
3061 * @param *ptr The pointer to the object to free.
3062 * @param *size The number of objects of type free_type to free in a sequence.
3063 * @param *free_type The type of the freed variable.
3064 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3066 ir_node *new_d_Free (dbg_info* db, ir_node *store, ir_node *ptr, ir_node *size,
3067 type *free_type, where_alloc where);
3069 /** Constructor for a Sync node.
3071 * Merges several memory values. The node assumes that a variable
3072 * either occurs only in one of the memories, or it contains the same
3073 * value in all memories where it occurs.
3074 * Adds the node to the block in current_ir_block.
3076 * @param *db A pointer for debug information.
3077 * @param arity The number of memories to synchronize.
3078 * @param **in An array of pointers to nodes that produce an output of type
3079 * memory. The constructor copies this array.
3081 ir_node *new_d_Sync (dbg_info* db, int arity, ir_node *in[]);
3084 /** Constructor for a Proj node.
3086 * Projects a single value out of a tuple. The parameter proj gives the
3087 * position of the value within the tuple.
3088 * Adds the node to the block in current_ir_block.
3090 * @param *db A pointer for deubug information.
3091 * @param arg A node producing a tuple.
3092 * @param *mode The mode of the value to project.
3093 * @param proj The position of the value in the tuple.
3095 ir_node *new_d_Proj (dbg_info* db, ir_node *arg, ir_mode *mode, long proj);
3098 /** Constructor for a defaultProj node.
3100 * Represents the default control flow of a Switch-Cond node.
3101 * Adds the node to the block in current_ir_block.
3103 * @param *db A pointer for debug information.
3104 * @param arg A node producing a tuple.
3105 * @param max_proj The end position of the value in the tuple.
3107 ir_node *new_d_defaultProj (dbg_info* db, ir_node *arg, long max_proj);
3109 /** Constructor for a Tuple node.
3111 * This is an auxiliary node to replace a node that returns a tuple
3112 * without changing the corresponding Proj nodes.
3113 * Adds the node to the block in current_ir_block.
3115 * @param *db A pointer for debug information.
3116 * @param arity The number of tuple elements.
3117 * @param **in An array containing pointers to the nodes producing the tuple elements.
3119 ir_node *new_d_Tuple (dbg_info* db, int arity, ir_node *in[]);
3122 /** Constructor for a Id node.
3124 * This is an auxiliary node to replace a node that returns a single
3125 * value. Adds the node to the block in current_ir_block.
3127 * @param *db A pointer for debug information.
3128 * @param *val The operand to Id.
3129 * @param *mode The mode of *val.
3131 ir_node *new_d_Id (dbg_info* db, ir_node *val, ir_mode *mode);
3133 /** Constructor for a Bad node.
3135 * Returns the unique Bad node of the graph. The same as
3138 ir_node *new_d_Bad (void);
3140 /** Constructor for a Confirm node.
3142 * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3143 * Specifies constraints for a value. To support dataflow analyses.
3145 * Example: If the value never exceeds '100' this is expressed by placing a
3146 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3148 * @param *db A pointer for debug information.
3149 * @param *val The value we express a constraint for
3150 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3151 * @param cmp The compare operation.
3153 ir_node *new_d_Confirm (dbg_info* db, ir_node *val, ir_node *bound, pn_Cmp cmp);
3156 /** Constructor for an Unknown node.
3158 * Represents an arbitrary value. Places the node in
3161 * @param *m The mode of the unknown value.
3163 ir_node *new_d_Unknown(ir_mode *m);
3165 /** Constructor for a CallBegin node.
3167 * CallBegin represents control flow depending of the pointer value
3168 * representing the called method to the called methods. The
3169 * constructor copies the method pointer input from the passed Call
3170 * node.Adds the node to the block in current_ir_block.
3172 * @param *db A pointer for debug information.
3173 * @param *callee The call node visible in the intra procedural view.
3175 ir_node *new_d_CallBegin(dbg_info *db, ir_node *callee);
3177 /** Constructor for an EndReg node.
3179 *Adds the node to the block in current_ir_block.
3181 * @param *db A pointer for debug information.
3183 ir_node *new_d_EndReg (dbg_info *db);
3185 /** Constructor for an EndExcept node.
3187 * Used to represent regular procedure end in interprocedual view.
3188 * Adds the node to the block in current_ir_block.
3190 * @param *db A pointer for debug information.
3192 ir_node *new_d_EndExcept(dbg_info *db);
3194 /** Constructor for a Break node.
3196 * Used to represent exceptional procedure end in interprocedural view.
3197 * Adds the node to the block in current_ir_block.
3199 * Break represents control flow to a single control successor just as Jmp.
3200 * The blocks separated by a break may not be concatenated by an optimization.
3201 * It is used for the interprocedural representation where blocks are parted
3202 * behind Call nodes to represent the control flow to called procedures.
3204 * @param *db A pointer for debug information.
3206 ir_node *new_d_Break (dbg_info *db);
3208 /** Constructor for a Filter node.
3210 * Constructor for a Filter node. Adds the node to the block in
3211 * current_ir_block. Filter is a node with two views used to
3212 * construct the interprocedural view. In intraprocedural view its
3213 * semantics are identical to the Proj node. In interprocedural view
3214 * the Filter performs the Phi operation on method parameters or
3215 * results. Other than a Phi a Filter node may not be removed if it
3216 * has only a single input.
3218 * The constructor builds the Filter in intraprocedural view.
3220 * @param *db A pointer for debug information.
3221 * @param *arg The tuple value to project from.
3222 * @param *mode The mode of the projected value.
3223 * @param proj The position in the tuple to project from.
3225 ir_node *new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj);
3228 /** Constructor for a NoMem node.
3230 * Returns the unique NoMem node of the graph. The same as
3233 ir_node *new_d_NoMem (void);
3235 /** Constructor for a Mux node.
3237 * Adds the node to the block in current_ir_block.
3239 * @param *db A pointer for debug information.
3240 * @param *sel The ir_node that calculates the boolean select.
3241 * @param *ir_true The ir_node that calculates the true result.
3242 * @param *ir_false The ir_node that calculates the false result.
3243 * @param *mode The mode of the node (and it_true and ir_false).
3245 ir_node *new_d_Mux (dbg_info *db, ir_node *sel,
3246 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3248 /** Constructor for a CopyB node.
3250 * Adds the node to the block in current_ir_block.
3252 * @param *db A pointer for debug information.
3253 * @param *store The current memory
3254 * @param *dst The ir_node that represents the destination address.
3255 * @param *src The ir_node that represents the source address.
3256 * @param *data_type The type of the copied data
3258 ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst, ir_node *src, type *data_type);
3260 /*-----------------------------------------------------------------------*/
3261 /* The block oriented interface without debug support */
3262 /*-----------------------------------------------------------------------*/
3264 /* Needed from the interface with debug support:
3265 void set_cur_block (ir_node *target); */
3267 /** Constructor for a Block node.
3269 * Constructor for a Block node. Adds the block to the graph in
3270 * current_ir_graph. Constructs a Block with a fixed number of
3271 * predecessors. Does set current_block. Can be used with automatic
3272 * Phi node construction.
3274 * @param arity The number of control predecessors.
3275 * @param in An array of control predecessors. The length of
3276 * the array must be 'arity'.
3278 ir_node *new_Block(int arity, ir_node *in[]);
3280 /** Constructor for a Start node.
3282 * Adds the node to the block in current_ir_block.
3285 ir_node *new_Start (void);
3287 /** Constructor for an End node.
3289 * Adds the node to the block in current_ir_block.
3291 ir_node *new_End (void);
3293 /** Constructor for an EndReg node.
3295 * Used to represent regular procedure end in interprocedual view.
3296 * Adds the node to the block in current_ir_block.
3298 ir_node *new_EndReg (void);
3300 /** Constructor for an EndExpcept node.
3302 * Used to represent exceptional procedure end in interprocedural view.
3303 * Adds the node to the block in current_ir_block.
3305 ir_node *new_EndExcept(void);
3307 /** Constructor for a Jump node.
3309 * Adds the node to the block in current_ir_block.
3311 * Jmp represents control flow to a single control successor.
3313 ir_node *new_Jmp (void);
3315 /** Constructor for an IJmp node.
3317 * IJmp represents control flow to a single control successor not
3318 * statically known i.e. an indirect Jmp.
3320 * @param *tgt The ir node representing the target address.
3322 ir_node *new_IJmp (ir_node *tgt);
3324 /** Constructor for a Break node.
3325 * Break represents control flow to a single control successor just as Jmp.
3326 * The blocks separated by a break may not be concatenated by an optimization.
3327 * It is used for the interprocedural representation where blocks are parted
3328 * behind Call nodes to represent the control flow to called procedures.
3329 * Adds the node to the block in current_ir_block.
3331 ir_node *new_Break (void);
3333 /** Constructor for a Cond node.
3335 * If c is mode_b represents a conditional branch (if/else). If c is
3336 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
3337 * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3339 * This is not consistent: Input to Cond is Is, Proj has as proj number
3343 * @param *c The conditions parameter.Can be of mode b or I_u.
3345 ir_node *new_Cond (ir_node *c);
3347 /** Constructor for a Return node.
3349 * Returns the memory an zero or more return values. Only node that
3350 * can end regular control flow. Adds the node to the block in current_ir_block.
3352 * @param *store The state of memory.
3353 * @param arity Number of array indices.
3354 * @param *in Array with index inputs to the node.
3356 ir_node *new_Return (ir_node *store, int arity, ir_node *in[]);
3358 /**Constructor for a Raise node.
3360 * Adds the node to the block in current_ir_block.
3362 * @param *store The current memory.
3363 * @param *obj A pointer to the Except variable.
3365 ir_node *new_Raise (ir_node *store, ir_node *obj);
3367 /** Constructor for a Const node.
3369 * Constructor for a Const node. The constant represents a target
3370 * value. Sets the type information to type_unknown. (No more
3371 * supported: If tv is entity derives a somehow useful type.)
3372 * Adds the node to the block in current_ir_block.
3374 * @param *mode The mode of the operands and results.
3375 * @param *con Points to an entry in the constant table. This pointer is
3376 * added to the attributes of the node.
3378 ir_node *new_Const (ir_mode *mode, tarval *con);
3381 * Make a const from a long.
3382 * This is just convenience for the usual
3384 * new_Const(mode, tarval_from_long(mode, ...))
3387 * @param mode The mode for the const.
3388 * @param value The value of the constant.
3389 * @return A new const node.
3391 ir_node *new_Const_long(ir_mode *mode, long value);
3393 /** Constructor for a Const node.
3395 * Derives mode from passed type. */
3396 ir_node *new_Const_type(tarval *con, type *tp);
3398 /** Constructor for a SymConst node.
3400 * Adds the node to the block in current_ir_block.
3401 * This is the constructor for a symbolic constant.
3402 * There are four kinds of symbolic constants:
3403 * -# type_tag The symbolic constant represents a type tag. The type the
3404 * tag stands for is given explicitly.
3405 * -# size The symbolic constant represents the size of a type. The
3406 * type of which the constant represents the size is given
3408 * -# addr_name The symbolic constant represents the address of an entity
3409 * (variable or method). The variable is indicated by a name
3410 * that is valid for linking.
3411 * -# addr_ent The symbolic constant represents the address of an entity
3412 * (variable or method). The variable is given explicitly by
3415 * Inputs to the node:
3416 * No inputs except the block it belongs to.
3417 * Outputs of the node.
3418 * An unsigned integer (I_u) or a pointer (P).
3420 * @param value A type or a ident depending on the SymConst kind.
3421 * @param kind The kind of the symbolic constant: symconst_type_tag, symconst_size or symconst_addr_name.
3423 ir_node *new_SymConst (union symconst_symbol value, symconst_kind kind);
3425 /** Constructor for a simpelSel node.
3427 * This is a shortcut for the new_Sel() constructor. To be used for
3428 * Sel nodes that do not select from an array, i.e., have no index
3429 * inputs. It adds the two parameters 0, NULL.
3431 * @param *store The memory in which the object the entity should be selected from is allocated.
3432 * @param *objptr The object from that the Sel operation selects a single attribute out.
3433 * @param *ent The entity to select.
3435 ir_node *new_simpleSel(ir_node *store, ir_node *objptr, entity *ent);
3437 /** Constructor for a Sel node.
3439 * The select node selects an entity (field or method) from an entity
3440 * with a compound type. It explicitly specifies the entity selected.
3441 * Dynamically the node may select entities that overwrite the given
3442 * entity. If the selected entity is an array element entity the Sel
3443 * node takes the required array indices as inputs.
3444 * Adds the node to the block in current_ir_block.
3446 * @param *store The memory in which the object the entity should be selected
3447 * from is allocated.
3448 * @param *objptr A pointer to a compound entity the Sel operation selects a
3449 * single attribute from.
3450 * @param arity The number of array indices needed to select an array element entity.
3451 * @param *in[] If the compound entity is an array the indices of the selected
3452 * element entity. The constructor copies this array.
3453 * @param *ent The entity to select.
3455 ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node *in[],
3458 /** Constructor for an InstOf node.
3460 * Adds the node to the block in current_ir_block.
3461 * For translating Java. Not supported as standard firm node.
3463 * @param *store The actual store.
3467 ir_node *new_InstOf (ir_node *store, ir_node *obj, type *ent);
3469 /** Constructor for a Call node.
3471 * Adds the node to the block in current_ir_block.
3472 * Represents all kinds of method and function calls.
3474 * @param *store The actual store.
3475 * @param *callee A pointer to the called procedure.
3476 * @param arity The number of procedure parameters.
3477 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3478 * @param *tp Type information of the procedure called.
3480 ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node *in[],
3483 /** Constructor for a CallBegin node.
3485 * Adds the node to the block in current_ir_block.
3487 * @param *callee A pointer to the called procedure.
3489 ir_node *new_CallBegin(ir_node *callee);
3491 /**Constructor for a Add node.
3493 * CallBegin represents control flow depending of the pointer value
3494 * representing the called method to the called methods. The
3495 * constructor copies the method pointer input from the passed Call
3496 * node.Adds the node to the block in current_ir_block.
3498 * @param *op1 The first operand.
3499 * @param *op2 The second operand.
3500 * @param *mode The mode of the operands and the result.
3502 ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
3504 /** Constructor for a Sub node.
3506 * Adds the node to the block in current_ir_block.
3508 * @param *op1 The first operand.
3509 * @param *op2 The second operand.
3510 * @param *mode The mode of the operands and the result.
3512 ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
3514 /** Constructor for a Minus node.
3516 * Adds the node to the block in current_ir_block.
3518 * @param *op The operand .
3519 * @param *mode The mode of the operand and the result.
3521 ir_node *new_Minus (ir_node *op, ir_mode *mode);
3524 * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3526 * @param *op1 The first operand.
3527 * @param *op2 The second operand.
3528 * @param *mode The mode of the operands and the result.
3530 ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
3532 /** Constructor for a Quot node.
3534 * Adds the node to the block in current_ir_block.
3536 * @param *memop The store needed to model exceptions
3537 * @param *op1 The first operand.
3538 * @param *op2 The second operand.
3540 ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2);
3542 /** Constructor for a DivMod node.
3544 * Adds the node to the block in current_ir_block.
3546 * @param *memop The store needed to model exceptions
3547 * @param *op1 The first operand.
3548 * @param *op2 The second operand.
3550 ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2);
3552 /** Constructor for a Div node.
3554 * Adds the node to the block in current_ir_block.
3556 * @param *memop The store needed to model exceptions
3557 * @param *op1 The first operand.
3558 * @param *op2 The second operand.
3560 ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2);
3562 /** Constructor for a Mod node.
3564 * Adds the node to the block in current_ir_block.
3566 * @param *memop The store needed to model exceptions
3567 * @param *op1 The first operand.
3568 * @param *op2 The second operand.
3570 ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2);
3572 /** Constructor for a Abs node.
3574 * Adds the node to the block in current_ir_block.
3576 * @param *op The operand
3577 * @param *mode The mode of the operands and the result.
3579 ir_node *new_Abs (ir_node *op, ir_mode *mode);
3581 /** Constructor for a And node.
3583 * Adds the node to the block in current_ir_block.
3585 * @param *op1 The first operand.
3586 * @param *op2 The second operand.
3587 * @param *mode The mode of the operands and the result.
3589 ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
3592 * Constructor for a Or node. Adds the node to the block in current_ir_block.
3594 * @param *op1 The first operand.
3595 * @param *op2 The second operand.
3596 * @param *mode The mode of the operands and the result.
3598 ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
3601 * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3603 * @param *op1 The first operand.
3604 * @param *op2 The second operand.
3605 * @param *mode The mode of the operands and the results.
3607 ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
3609 /** Constructor for a Not node.
3611 * Adds the node to the block in current_ir_block.
3613 * @param *op The operand.
3614 * @param *mode The mode of the operand and the result.
3616 ir_node *new_Not (ir_node *op, ir_mode *mode);
3618 /** Constructor for a Shl node.
3620 * Adds the node to the block in current_ir_block.
3622 * @param *op The operand.
3623 * @param *k The number of bits to shift the operand .
3624 * @param *mode The mode of the operand and the result.
3626 ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
3629 * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3631 * @param *op The operand.
3632 * @param *k The number of bits to shift the operand .
3633 * @param *mode The mode of the operand and the result.
3635 ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
3637 /** Constructor for a Shrs node.
3639 * Adds the node to the block in current_ir_block.
3641 * @param *op The operand.
3642 * @param *k The number of bits to shift the operand .
3643 * @param *mode The mode of the operand and the result.
3645 ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
3647 /** Constructor for a Rot node.
3649 * Adds the node to the block in current_ir_block.
3651 * @param *op The operand.
3652 * @param *k The number of bits to rotate the operand.
3653 * @param *mode The mode of the operand.
3655 ir_node *new_Rot (ir_node *op, ir_node *k, ir_mode *mode);
3657 /** Constructor for a Cmp node.
3659 * Adds the node to the block in current_ir_block.
3661 * @param *op1 The first operand.
3662 * @param *op2 The second operand.
3664 ir_node *new_Cmp (ir_node *op1, ir_node *op2);
3666 /** Constructor for a Conv node.
3668 * Adds the node to the block in current_ir_block.
3670 * @param *op The operand.
3671 * @param *mode The mode of this the operand muss be converted .
3673 ir_node *new_Conv (ir_node *op, ir_mode *mode);
3675 /**Constructor for a Cast node.
3677 * Adds the node to the block in current_ir_block.
3678 * High level type cast
3680 * @param *op The operand.
3681 * @param *to_tp The type of this the operand muss be casted .
3683 ir_node *new_Cast (ir_node *op, type *to_tp);
3685 /** Constructor for a Phi node.
3687 * Adds the node to the block in current_ir_block.
3689 * @param arity The number of predecessors.
3690 * @param *in Array with predecessors.
3691 * @param *mode The mode of it's inputs and output.
3693 ir_node *new_Phi (int arity, ir_node *in[], ir_mode *mode);
3695 /** Constructor for a Load node.
3697 * @param *store The current memory.
3698 * @param *addr A pointer to the variable to be read in this memory.
3699 * @param *mode The mode of the value to be loaded.
3701 ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode);
3703 /** Constructor for a Store node.
3705 * @param *store The current memory.
3706 * @param *addr A pointer to the variable to be read in this memory.
3707 * @param *val The value to write to this variable.
3709 ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val);
3711 /**Constructor for a Alloc node.
3713 * The Alloc node extends the memory by space for an entity of type alloc_type.
3714 * Adds the node to the block in current_ir_block.
3716 * @param *store The memory which shall contain the new variable.
3717 * @param *size The number of bytes to allocate.
3718 * @param *alloc_type The type of the allocated variable.
3719 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3721 ir_node *new_Alloc (ir_node *store, ir_node *size, type *alloc_type,
3725 /**Constructor for a Free node.
3727 * Frees the memory occupied by the entity pointed to by the pointer
3728 * arg. Type indicates the type of the entity the argument points to.
3729 * Adds the node to the block in current_ir_block.
3731 * @param *store The memory which shall contain the new variable.
3732 * @param *ptr The pointer to the object to free.
3733 * @param *size The number of objects of type free_type to free in a sequence.
3734 * @param *free_type The type of the freed variable.
3735 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3737 ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
3738 type *free_type, where_alloc where);
3740 /** Constructor for a Sync node.
3742 * Merges several memory values. The node assumes that a variable
3743 * either occurs only in one of the memories, or it contains the same
3744 * value in all memories where it occurs.
3745 * Adds the node to the block in current_ir_block.
3747 * @param arity The number of memories to synchronize.
3748 * @param **in An array of pointers to nodes that produce an output of type
3749 * memory. The constructor copies this array.
3751 ir_node *new_Sync (int arity, ir_node *in[]);
3753 /** Constructor for a Proj node.
3755 * Projects a single value out of a tuple. The parameter proj gives the
3756 * position of the value within the tuple.
3757 * Adds the node to the block in current_ir_block.
3759 * @param arg A node producing a tuple.
3760 * @param *mode The mode of the value to project.
3761 * @param proj The position of the value in the tuple.
3763 ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
3765 /** Costructor for a Filter node.
3767 * Constructor for a Filter node. Adds the node to the block in current_ir_block.
3768 * Filter is a node with two views used to construct the interprocedural view.
3769 * In intraprocedural view its semantics are identical to the Proj node.
3770 * In interprocedural view the Filter performs the Phi operation on method
3771 * parameters or results. Other than a Phi a Filter node may not be removed
3772 * if it has only a single input.
3774 * The constructor builds the Filter in intraprocedural view.
3776 * @param *arg The tuple value to project from.
3777 * @param *mode The mode of the projected value.
3778 * @param proj The position in the tuple to project from.
3780 ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
3782 /** Constructor for a defaultProj node.
3784 * Represents the default control flow of a Switch-Cond node.
3785 * Adds the node to the block in current_ir_block.
3787 * @param arg A node producing a tuple.
3788 * @param max_proj The end position of the value in the tuple.
3790 ir_node *new_defaultProj (ir_node *arg, long max_proj);
3792 /** Constructor for a Tuple node.
3794 * This is an auxiliary node to replace a node that returns a tuple
3795 * without changing the corresponding Proj nodes.
3796 * Adds the node to the block in current_ir_block.
3798 * @param arity The number of tuple elements.
3799 * @param **in An array containing pointers to the nodes producing the tuple elements.
3801 ir_node *new_Tuple (int arity, ir_node *in[]);
3803 /** Constructor for an Id node.
3805 * This is an auxiliary node to replace a node that returns a single
3806 * value. Adds the node to the block in current_ir_block.
3808 * @param *val The operand to Id.
3809 * @param *mode The mode of *val.
3811 ir_node *new_Id (ir_node *val, ir_mode *mode);
3813 /** Constructor for a Bad node.
3815 * Returns the unique Bad node of the graph. The same as
3818 ir_node *new_Bad (void);
3820 /** Constructor for a Confirm node.
3822 * Specifies constraints for a value. To support dataflow analyses.
3823 * Adds the node to the block in current_ir_block.
3825 * Example: If the value never exceeds '100' this is expressed by placing a
3826 * Confirm node val = new_d_Confirm(db, val, 100, '<') on the dataflow edge.
3828 * @param *val The value we express a constraint for
3829 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3830 * @param cmp The compare operation.
3832 ir_node *new_Confirm (ir_node *val, ir_node *bound, pn_Cmp cmp);
3834 /** Constructor for an Unknown node.
3836 * Represents an arbitrary value. Places the node in
3839 * @param *m The mode of the unknown value.
3841 ir_node *new_Unknown(ir_mode *m);
3843 /** Constructor for a NoMem node.
3845 * Returns the unique NoMem node of the graph. The same as
3848 ir_node *new_NoMem (void);
3850 /** Constructor for a Mux node.
3852 * Adds the node to the block in current_ir_block.
3854 * @param *sel The ir_node that calculates the boolean select.
3855 * @param *ir_true The ir_node that calculates the true result.
3856 * @param *ir_false The ir_node that calculates the false result.
3857 * @param *mode The mode of the node (and it_true and ir_false).
3859 ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3861 /** Constructor for a CopyB node.
3863 * Adds the node to the block in current_ir_block.
3865 * @param *store The current memory
3866 * @param *dst The ir_node that represents the destination address.
3867 * @param *src The ir_node that represents the source address.
3868 * @param *data_type The type of the copied data
3870 ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src, type *data_type);
3872 /*---------------------------------------------------------------------*/
3873 /* The comfortable interface. */
3874 /* Supports automatic Phi node construction. */
3875 /* All routines of the block oriented interface except new_Block are */
3877 /*---------------------------------------------------------------------*/
3879 /** Create an immature block.
3881 * An immature block has an unknown number of predecessors. Predecessors
3882 * can be added with add_immBlock_pred(). Once all predecessors are
3883 * added the block must be matured.
3885 * Adds the block to the graph in current_ir_graph. Does set
3886 * current_block. Can be used with automatic Phi node construction.
3887 * This constructor can only be used if the graph is in
3890 ir_node *new_d_immBlock (dbg_info* db);
3891 ir_node *new_immBlock (void);
3893 /** Add a control flow edge to an immature block. */
3894 void add_immBlock_pred (ir_node *immblock, ir_node *jmp);
3896 /** Finalize a Block node, when all control flows are known. */
3897 void mature_immBlock (ir_node *block);
3898 #define mature_cur_block() mature_immBlock(get_cur_block());
3901 /** Get the current value of a local variable.
3903 * Use this function to obtain the last definition of the local variable
3904 * associated with pos. Pos may not exceed the value passed as n_loc
3905 * to new_ir_graph. This call automatically inserts Phi nodes.
3907 * @param *db A pointer for debug information.
3908 * @param pos The position/id of the local variable.
3909 * @param *mode The mode of the value to get.
3911 ir_node *get_d_value (dbg_info *db, int pos, ir_mode *mode);
3912 ir_node *get_value (int pos, ir_mode *mode);
3914 /** Remark a new definition of a variable.
3916 * Use this function to remember a new definition of the value
3917 * associated with pos. Pos may not exceed the value passed as n_loc
3918 * to new_ir_graph. This call is needed to automatically inserts Phi
3921 * @param pos The position/id of the local variable.
3922 * @param *value The new value written to the local variable.
3924 void set_value (int pos, ir_node *value);
3926 /** Get the current memory state.
3928 * Use this function to obtain the last definition of the memory
3929 * state. This call automatically inserts Phi nodes for the memory
3932 ir_node *get_store (void);
3934 /** Remark a new definition of the memory state.
3936 * Use this function to remember a new definition of the memory state.
3937 * This call is needed to automatically inserts Phi nodes.
3939 * @param *store The new memory state.
3941 void set_store (ir_node *store);
3943 /** keep this node alive even if End is not control-reachable from it
3945 * @param ka The node to keep alive.
3947 void keep_alive (ir_node *ka);
3949 /** Returns the frame type of the current graph */
3950 type *get_cur_frame_type(void);
3953 /* --- initialize and finalize ir construction --- */
3955 /** Puts the graph into state "phase_high" */
3956 void irg_finalize_cons (ir_graph *irg);
3958 /** Puts the program and all graphs into state phase_high.
3960 * This also remarks, the construction of types is finished,
3961 * e.g., that no more subtypes will be added. */
3962 void irp_finalize_cons(void);
3964 /* --- Initialization --- */
3967 * This function is called, whenever a local variable is used before definition
3969 * @param irg the IR graph on which this happens
3970 * @param mode the mode of the local var
3971 * @param pos position chosen be the frontend for this variable (n_loc)
3973 * @return a firm node of mode @p mode that initializes the var at position pos
3976 * Do not return NULL!
3977 * If this function is not set, FIRM will create a const node with tarval BAD.
3978 * Use set_irg_loc_description()/get_irg_loc_description() to assign additional
3979 * informations to local variables.
3981 typedef ir_node *uninitialized_local_variable_func_t(ir_graph *irg, ir_mode *mode, int pos);
3983 # endif /* _IRCONS_H_ */