2 * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Various irnode constructors. Automatic construction of SSA
24 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Boris Boesler,
32 * documentation no more supported since 2001
34 * IR node construction.
36 * This file documents all datatypes and constructors needed to
37 * build a FIRM representation of a procedure. The constructors are
38 * also implemented in this file.
40 * The documentation also gives a short manual how to use the library.
42 * For extensive documentation of FIRM see UKA Techreport 1999-14.
45 * Three kinds of nodes
46 * --------------------
48 * There are three kinds of nodes known to the IR: entities,
51 * + ir_nodes are the actual nodes of the FIRM intermediate representation.
52 * They represent operations on the data of the program and control flow
55 * + entity ==> implemented in entity.h
56 * Refers to a single entity of the compiled program, e.g. a field of a
57 * class or a method. If a method or variable can not be assigned to
58 * a method or class or the like, it is a global object.
60 * + types ==> implemented in type.h
61 * With types type information is represented. There are several type
64 * Implementation of the FIRM operations: ir_node
65 * ----------------------------------------------
67 * Ir_nodes represent operations on the data of the program and control flow
68 * operations. Examples of ir_nodes: Add, Jmp, Cmp
70 * FIRM is a dataflow graph. A dataflow graph is a directed graph,
71 * so that every node has incoming and outgoing edges. A node is
72 * executable if every input at its incoming edges is available.
73 * Execution of the dataflow graph is started at the Start node which
74 * has no incoming edges and ends when the End node executes, even if
75 * there are still executable or not executed nodes. (Is this true,
76 * or must all executable nodes be executed?) (There are exceptions
77 * to the dataflow paradigma that all inputs have to be available
78 * before a node can execute: Phi, Block. See UKA Techreport
81 * The implementation of FIRM differs from the view as a dataflow
82 * graph. To allow fast traversion of the graph edges are
83 * implemented as C-pointers. Inputs to nodes are not ambiguous, the
84 * results can be used by several other nodes. Each input can be
85 * implemented as a single pointer to a predecessor node, outputs
86 * need to be lists of pointers to successors. Therefore a node
87 * contains pointers to its predecessors so that the implementation is a
88 * dataflow graph with reversed edges. It has to be traversed bottom
91 * All nodes of the IR have the same basic structure. They are
92 * distinguished by a field containing the opcode.
94 * The fields of an ir_node:
96 * kind A firm_kind tag containing k_ir_node. This is useful for
97 * dynamically checking the type of a node.
99 * *op This ir_op gives the opcode as a tag and a string
100 * and the number of attributes of an ir_node. There is
101 * one statically allocated struct ir_op for each opcode.
103 * *mode The ir_mode of the operation represented by this firm
104 * node. The mode of the operation is the mode of its
105 * result. A Firm mode is a datatype as known to the
106 * target, not a type of the source language.
108 * visit A flag for traversing the IR.
110 * **in An array with pointers to the node's predecessors.
112 * *link A pointer to an ir_node. With this pointer all Phi nodes
113 * are attached to a Block, i.e. a Block points to its
114 * first Phi node, this node points to the second Phi node
115 * in the Block and so forth. Used in mature_immBlock
116 * to find all Phi nodes to be matured. It's also used to
117 * annotate a node with a better, optimized version of it.
119 * attr An attr struct containing the attributes of the nodes. The
120 * attributes depend on the opcode of the node. The number
121 * of these attributes is given in op.
125 * Not yet documented. See irop.h.
129 * Not yet documented. See irmode.h.
131 * GLOBAL VARIABLES -- now also fields of ir_graph.
134 * current_ir_graph Points to the current ir_graph. All constructors for
135 * nodes add nodes to this graph.
137 * ir_visited An int used as flag to traverse the ir_graph.
139 * block_visited An int used as a flag to traverse block nodes in the
142 * Others not yet documented.
146 * CONSTRUCTOR FOR IR_GRAPH --> see irgraph.h
147 * ========================
150 * PROCEDURE TO CONSTRUCT AN IR GRAPH --> see also Firm tutorial
151 * ==================================
153 * This library supplies several interfaces to construct a FIRM graph for
155 * - A "comfortable" interface generating SSA automatically. Automatically
156 * computed predecessors of nodes need not be specified in the constructors.
157 * (new_<Node> constructurs and a set of additional routines.)
158 * - A less comfortable interface where all predecessors except the block
159 * an operation belongs to need to be specified. SSA must be constructed
160 * by hand. (new_<Node> constructors and set_cur_block()). This interface
161 * is called "block oriented". It automatically calles the local optimizations
163 * - An even less comfortable interface where the block needs to be specified
164 * explicitly. This is called the "raw" interface. (new_r_<Node>
165 * constructors). These nodes are not optimized.
167 * To use the functionality of the comfortable interface correctly the Front
168 * End needs to follow certain protocols. This is explained in the following.
169 * To build a correct IR with the other interfaces study the semantics of
170 * the firm node (See tech-reprot UKA 1999-14). For the construction of
171 * types and entities see the documentation in those modules.
173 * First the Frontend needs to decide which variables and values used in
174 * a procedure can be represented by dataflow edges. These are variables
175 * that need not be saved to memory as they cause no side effects visible
176 * out of the procedure. Often these are all compiler generated
177 * variables and simple local variables of the procedure as integers,
178 * reals and pointers. The frontend has to count and number these variables.
180 * First an ir_graph needs to be constructed with new_ir_graph. The
181 * constructor gets the number of local variables. The graph is held in the
182 * global variable irg.
184 * Now the construction of the procedure can start. Several basic blocks can
185 * be constructed in parallel, but the code within each block needs to
186 * be constructed (almost) in program order.
188 * A global variable holds the current basic block. All (non block) nodes
189 * generated are added to this block. The current block can be set with
190 * set_cur_block(block). If several blocks are constructed in parallel block
191 * switches need to be performed constantly.
193 * To generate a Block node (with the comfortable interface), its predecessor
194 * control flow nodes need not be known. In case of cyclic control flow these
195 * can not be known when the block is constructed. With add_immBlock_pred(block,
196 * cfnode) predecessors can be added to the block. If all predecessors are
197 * added to the block mature_immBlock(b) needs to be called. Calling mature_immBlock
198 * early improves the efficiency of the Phi node construction algorithm.
199 * But if several blocks are constructed at once, mature_immBlock must only
200 * be called after performing all set_values and set_stores in the block!
201 * (See documentation of new_immBlock constructor.)
203 * The constructors of arithmetic nodes require that their predecessors
204 * are mentioned. Sometimes these are available in the Frontend as the
205 * predecessors have just been generated by the frontend. If they are local
206 * values, the predecessors can be obtained from the library with a call to
207 * get_value(local_val_nr). (local_val_nr needs to be administered by
208 * the Frontend.) A call to get_value triggers the generation of Phi nodes.
209 * If an arithmetic operation produces a local value, this value needs to be
210 * passed to the library by set_value(node, local_val_nr).
211 * In straight line code these two operations just remember and return the
212 * pointer to nodes producing the value. If the value passes block boundaries
213 * Phi nodes can be inserted.
214 * Similar routines exist to manage the Memory operands: set_store and
217 * Several nodes produce more than one result. An example is the Div node.
218 * Such nodes return tuples of values. From these individual values can be
219 * extracted by proj nodes.
221 * The following example illustrates the construction of a simple basic block
222 * with two predecessors stored in variables cf_pred1 and cf_pred2, containing
225 * and finally jumping to an other block. The variable a got the local_val_nr
226 * 42 by the frontend.
228 * ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
230 * this_block = new_immBlock();
231 * add_immBlock_pred(this_block, cf_pred1);
232 * add_immBlock_pred(this_block, cf_pred2);
233 * mature_immBlock(this_block);
234 * a_val = get_value(42, mode_Iu);
236 * div = new_Div(mem, a_val, a_val, mode_Iu);
237 * mem = new_Proj(div, mode_M, pn_Div_M); * for the numbers for Proj see docu *
238 * res = new_Proj(div, mode_Iu, pn_Div_res);
240 * set_value(res, 42);
243 * For further information look at the documentation of the nodes and
244 * constructors and at the paragraph COPING WITH DATA OBJECTS at the
245 * end of this documentation.
247 * The comfortable interface contains the following routines further explained
250 * ir_node *new_immBlock (void);
251 * ir_node *new_Start (void);
252 * ir_node *new_End (void);
253 * ir_node *new_Jmp (void);
254 * ir_node *new_IJmp (ir_node *tgt);
255 * ir_node *new_Cond (ir_node *c);
256 * ir_node *new_Return (ir_node *store, int arity, ir_node **in);
257 * ir_node *new_Const (tarval *con);
258 * ir_node *new_SymConst (ir_mode *mode, symconst_symbol value, symconst_kind kind);
259 * ir_node *new_simpleSel (ir_node *store, ir_node *objptr, ir_entity *ent);
260 * ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity,
261 * ir_node **in, ir_entity *ent);
262 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity,
263 * ir_node **in, type_method *type);
264 * ir_node *new_Builtin(ir_node *store, ir_builtin_kind kind, int arity,
265 * ir_node **in, type_method *type);
266 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
267 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
268 * ir_node *new_Minus (ir_node *op, ir_mode *mode);
269 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode);
270 * ir_node *new_Mulh (ir_node *op1, ir_node *op2, ir_mode *mode);
271 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state);
272 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state);
273 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state);
274 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state;
275 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
276 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
277 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
278 * ir_node *new_Not (ir_node *op, ir_mode *mode);
279 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
280 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
281 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
282 * ir_node *new_Rotl (ir_node *op, ir_node *k, ir_mode *mode);
283 * ir_node *new_Cmp (ir_node *op1, ir_node *op2);
284 * ir_node *new_Conv (ir_node *op, ir_mode *mode);
285 * ir_node *new_Cast (ir_node *op, ir_type *to_tp);
286 * ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode);
287 * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
288 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode, ir_cons_flags flags);
289 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val, ir_cons_flags flags);
290 * ir_node *new_Alloc (ir_node *store, ir_node *count, ir_type *alloc_type,
291 * where_alloc where);
292 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
293 * ir_type *free_type, where_alloc where);
294 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
295 * ir_node *new_NoMem (void);
296 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
297 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
298 * ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
299 * ir_node *new_Raise (ir_node *store, ir_node *obj);
300 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
301 * ir_node *new_Pin (ir_node *node);
303 * void add_immBlock_pred (ir_node *block, ir_node *jmp);
304 * void mature_immBlock (ir_node *block);
305 * void set_cur_block (ir_node *target);
306 * ir_node *get_value (int pos, ir_mode *mode);
307 * void set_value (int pos, ir_node *value);
308 * ir_node *get_store (void);
309 * void set_store (ir_node *store);
310 * keep_alive (ir_node ka)
312 * IR_NODES AND CONSTRUCTORS FOR IR_NODES
313 * =======================================
315 * All ir_nodes are defined by a common data structure. They are distinguished
316 * by their opcode and differ in the number of their attributes.
318 * Const nodes are always added to the start block.
319 * All other constructors add the created node to the current_block.
320 * swich_block(block) allows to set the current block to block.
322 * Watch for my inconsistent use of input and predecessor (dataflow view)
323 * and `the node points to' (implementation view).
325 * The following description of the nodes lists four properties them if these
327 * - the parameters to the constructor
328 * - the inputs of the Firm node
329 * - the outputs of the Firm node
330 * - attributes to the node
334 * ir_node *new_immBlock (void)
335 * ----------------------------
337 * Creates a new block. When a new block is created it cannot be known how
338 * many predecessors this block will have in the control flow graph.
339 * Therefore the list of inputs can not be fixed at creation. Predecessors
340 * can be added with add_immBlock_pred (block, control flow operation).
341 * With every added predecessor the number of inputs to Phi nodes also
344 * The block can be completed by mature_immBlock(block) if all predecessors are
345 * known. If several blocks are built at once, mature_immBlock can only be called
346 * after set_value has been called for all values that are life at the end
347 * of the block. This is necessary so that Phi nodes created mature_immBlock
348 * get the right predecessors in case of cyclic dependencies. If all set_values
349 * of this block are called after maturing it and before calling get_value
350 * in some block that is control flow dependent on this block, the construction
353 * Example for faulty IR construction: (draw the graph on a paper and you'll
356 * block_before_loop = new_immBlock();
357 * set_cur_block(block_before_loop);
359 * mature_immBlock(block_before_loop);
360 * before2header = new_Jmp;
362 * loop_header = new_immBlock ();
363 * set_cur_block(loop_header);
364 * header2body - new_Jmp();
366 * loop_body = new_immBlock ();
367 * set_cur_block(loop_body);
368 * body2header = new_Jmp();
370 * add_immBlock_pred(loop_header, before2header);
371 * add_immBlock_pred(loop_header, body2header);
372 * add_immBlock_pred(loop_body, header2body);
374 * mature_immBlock(loop_header);
375 * mature_immBlock(loop_body);
377 * get_value(loop_body, x); // gets the Phi in loop_header
378 * set_value(loop_header, x); // sets the value the above get_value should
379 * // have returned!!!
381 * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
382 * should be called as early as possible, as afterwards the generation of Phi
383 * nodes is more efficient.
386 * There is an input for each control flow predecessor of the block.
387 * The input points to an instruction producing an output of type X.
388 * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
389 * possibly causing an exception. (Often the real predecessors are Projs.)
391 * Mode BB (R), all nodes belonging to this block should consume this output.
392 * As they are strict (except Block and Phi node) it is a necessary condition
393 * that the block node executed before any other node in this block executes.
395 * block.matured Indicates whether the block is mature.
397 * This attribute contains all local values valid in this
398 * block. This is needed to build the Phi nodes and removed
399 * if the graph is complete. This field is used by the
400 * internal construction algorithm and should not be accessed
404 * ir_node *new_Block (int arity, ir_node **in)
405 * --------------------------------------------
407 * Creates a new Block with the given list of predecessors. This block
408 * is mature. As other constructors calls optimization and verify for the
409 * block. If one of the predecessors is Unknown (as it has to be filled in
410 * later) optimizations are skipped. This is necessary to
411 * construct Blocks in loops.
414 * CONTROL FLOW OPERATIONS
415 * -----------------------
417 * In each block there must be exactly one of the control flow
418 * operations Start, End, Jmp, Cond, Return or Raise. The output of a
419 * control flow operation points to the block to be executed next.
421 * ir_node *new_Start (void)
422 * -------------------------
424 * Creates a start node. Not actually needed public. There is only one such
425 * node in each procedure which is automatically created by new_ir_graph.
428 * No inputs except the block it belongs to.
430 * A tuple of 4 (5, 6) distinct values. These are labeled by the following
431 * projection numbers (pn_Start):
432 * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
433 * * pn_Start_M mode M, the global store
434 * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
435 * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
436 * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
439 * ir_node *new_End (void)
440 * -----------------------
442 * Creates an end node. Not actually needed public. There is only one such
443 * node in each procedure which is automatically created by new_ir_graph.
446 * No inputs except the block it belongs to.
450 * ir_node *new_Jmp (void)
451 * -----------------------
453 * Creates a Jmp node.
456 * The block the node belongs to
458 * Control flow to the next block.
460 * ir_node *new_IJmp (ir_node *tgt)
461 * -----------------------
463 * Creates an IJmp node.
466 * The node that represents the target jump address
468 * Control flow to an unknown target, must be pinned by
471 * ir_node *new_Cond (ir_node *c)
472 * ------------------------------
474 * Creates a Cond node. There are two versions of this node.
480 * A tuple of two control flows. The first is taken if the input is
481 * false, the second if it is true.
485 * A value of mode I_u. (i)
487 * A tuple of n control flows. If the Cond's input is i, control
488 * flow will proceed along output i. If the input is >= n control
489 * flow proceeds along output n.
491 * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
492 * -------------------------------------------------------------
494 * The Return node has as inputs the results of the procedure. It
495 * passes the control flow to the end_block.
501 * Control flow to the end block.
504 * ir_node *new_Const (tarval *con)
505 * -----------------------------------------------
507 * Creates a constant in the constant table and adds a Const node
508 * returning this value to the start block. The mode is derived
512 * *con Points to an entry in the constant table.
513 * This pointer is added to the attributes of
514 * the node (self->attr.con)
516 * No inputs except the block it belogns to.
518 * The constant value.
520 * attr.con A tarval* pointer to the proper entry in the constant
523 * ir_node *new_SymConst (ir_mode *mode, union symconst_symbol value, symconst_addr_ent kind)
524 * -----------------------------------------------------------------------------------------
526 * There are several symbolic constants:
527 * symconst_type_tag The symbolic constant represents a type tag.
528 * symconst_type_size The symbolic constant represents the size of a type.
529 * symconst_type_align The symbolic constant represents the alignment of a type.
530 * symconst_addr_ent The symbolic constant represents the address of an entity.
531 * symconst_ofs_ent The symbolic constant represents the offset of an
532 * entity in its owner type.
533 * symconst_enum_const The symbolic constant is a enumeration constant of an
537 * mode P for SymConsts representing addresses, Iu otherwise.
538 * value The type, ident, entity or enum constant, depending on the
540 * kind The kind of the symbolic constant, see the list above.
543 * No inputs except the block it belongs to.
545 * A symbolic constant.
548 * attr.i.num The symconst_addr_ent, i.e. one of
550 * -symconst_type_size
551 * -symconst_type_align
554 * If the attr.i.num is symconst_type_tag, symconst_type_size or symconst_type_align,
555 * the node contains an attribute:
557 * attr.i.*type, a pointer to a type_class.
558 * if it is linkage_ptr_info it contains
559 * attr.i.*ptrinfo, an ident holding information for the linker.
563 * ir_node *new_simpleSel (ir_node *store, ir_node *frame, ir_entity *sel)
564 * -----------------------------------------------------------------------
567 * Selects an entity from a compound type. This entity can be a field or
571 * *store The memory in which the object the entity should be selected
573 * *frame The pointer to the object.
574 * *sel The entity to select.
577 * The memory containing the object.
578 * A pointer to the object.
579 * An unsigned integer.
581 * A pointer to the selected entity.
583 * attr.sel Pointer to the entity
586 * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
587 * --------------------------------------------------------------------------
591 * Selects a field from an array type. The entity has as owner the array, as
592 * type the arrays element type. The indices to access an array element are
596 * *store The memory in which the object the entity should be selected from
598 * *frame The pointer to the object.
599 * *arity number of array indices.
600 * *in array with index inputs to the node.
601 * *sel The entity to select.
604 * The memory containing the object.
605 * A pointer to the object.
606 * As much unsigned integer as there are array expressions.
608 * A pointer to the selected entity.
610 * attr.sel Pointer to the entity
612 * The constructors new_Sel and new_simpleSel generate the same IR nodes.
613 * simpleSel just sets the arity of the index inputs to zero.
616 * ARITHMETIC OPERATIONS
617 * ---------------------
619 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
620 * ----------------------------------------------------------------------------
624 * Creates a procedure call.
627 * *store The actual store.
628 * *callee A pointer to the called procedure.
629 * arity The number of procedure parameters.
630 * **in An array with the pointers to the parameters.
631 * The constructor copies this array.
632 * *type Type information of the procedure called.
635 * The store, the callee and the parameters.
637 * A tuple containing the eventually changed store and the procedure
640 * attr.call Contains the attributes for the procedure.
642 * ir_node *new_Builtin(ir_node *store, ir_builtin_kind kind, int arity, ir_node **in,
643 * -----------------------------------------------------------------------------------
647 * Creates a builtin call.
650 * *store The actual store.
651 * kind Describes the called builtin.
652 * arity The number of procedure parameters.
653 * **in An array with the pointers to the parameters.
654 * The constructor copies this array.
655 * *type Type information of the procedure called.
658 * The store, the kind and the parameters.
660 * A tuple containing the eventually changed store and the procedure
663 * attr.builtin Contains the attributes for the called builtin.
665 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
666 * ------------------------------------------------------------
670 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
671 * ------------------------------------------------------------
675 * ir_node *new_Minus (ir_node *op, ir_mode *mode)
676 * -----------------------------------------------
678 * Unary Minus operations on integer and floating point values.
680 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
681 * ------------------------------------------------------------
685 * ir_node *new_Mulh (ir_node *op1, ir_node *op2, ir_mode *mode)
686 * ------------------------------------------------------------
688 * Returns the high order bits of a n*n=2n multiplication.
690 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
691 * -------------------------------------------------------------------------------------------------
693 * Quot performs exact division of floating point numbers. It's mode
694 * is Tuple, the mode of the result must match the Proj mode
695 * that extracts the result of the arithmetic operations.
698 * The store needed to model exceptions and the two operands.
700 * A tuple containing a memory and a execution for modeling exceptions
701 * and the result of the arithmetic operation.
703 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
704 * ---------------------------------------------------------------------------------------------------
706 * Performs Div and Mod on integer values.
709 * A tuple containing a memory and a execution for modeling exceptions
710 * and the two result of the arithmetic operations.
712 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
713 * ------------------------------------------------------------------------------------------------
717 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
718 * ------------------------------------------------------------------------------------------------
722 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
723 * ------------------------------------------------------------
727 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
728 * -----------------------------------------------------------
732 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
733 * ------------------------------------------------------------
737 * ir_node *new_Not (ir_node *op, ir_mode *mode)
738 * ---------------------------------------------
740 * This node constructs a constant where all bits are set to one
741 * and a Eor of this constant and the operator. This simulates a
744 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
745 * ---------------------------------------------------------
749 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
750 * ---------------------------------------------------------
752 * Logic shift right, i.e., zero extended.
755 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
756 * ----------------------------------------------------------
758 * Arithmetic shift right, i.e., sign extended.
760 * ir_node *new_Rotl (ir_node *op, ir_node *k, ir_mode *mode)
761 * ---------------------------------------------------------
763 * Rotates the operand to the left by k bits.
765 * ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode)
766 * ------------------------------------------------------------
768 * Calculates the Carry value for integer addition. Used only
771 * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode)
772 * ------------------------------------------------------------
774 * Calculates the Borrow value for integer substraction. Used only
777 * ir_node *new_Conv (ir_node *op, ir_mode *mode)
778 * ---------------------------------------------
780 * Mode conversion. For allowed conversions see UKA Tech Report
783 * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
784 * ---------------------------------------------
787 * The two values to be compared.
789 * A 16-tuple containing the results of the 16 different comparisons.
790 * The following is a list giving the comparisons and a projection
791 * number (pn_Cmp) to use in Proj nodes to extract the proper result.
795 * pn_Cmp_Le less or equal
797 * pn_Cmp_Ge greater of equal
798 * pn_Cmp_Lg less or greater
799 * pn_Cmp_Leg less, equal or greater = ordered
800 * pn_Cmp_Uo unordered
801 * pn_Cmp_Ue unordered or equal
802 * pn_Cmp_Ul unordered or less
803 * pn_Cmp_Ule unordered, less or equal
804 * pn_Cmp_Ug unordered or greater
805 * pn_Cmp_Uge unordered, greater or equal
806 * pn_Cmp_Ne unordered, less or greater = not equal
813 * In general, Phi nodes are automaitcally inserted. In some cases, if
814 * all predecessors of a block are known, an explicit Phi node constructor
815 * is needed. E.g., to construct a FIRM graph for a statement as
816 * a = (b==c) ? 2 : 5;
818 * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
819 * ---------------------------------------------------------
821 * Creates a Phi node. The in's order has to correspond to the order
822 * of in's of current_block. This is not checked by the library!
823 * If one of the predecessors is Unknown (as it has to be filled in
824 * later) optimizations are skipped. This is necessary to
825 * construct Phi nodes in loops.
828 * arity number of predecessors
829 * **in array with predecessors
830 * *mode The mode of it's inputs and output.
832 * A Phi node has as many inputs as the block it belongs to.
833 * Each input points to a definition of the same value on a
834 * different path in the control flow.
836 * The definition valid in this block.
838 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
839 * -----------------------------------------------------------------------------------
841 * Creates a Mux node. This node implements the following semantic:
842 * If the sel node (which must be of mode_b) evaluates to true, its value is
843 * ir_true, else ir_false;
847 * OPERATIONS TO MANAGE MEMORY EXPLICITLY
848 * --------------------------------------
850 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode, ir_cons_flags flags)
851 * -------------------------------------------------------------------------------------
853 * The Load operation reads a value from memory.
856 * *store The current memory.
857 * *addr A pointer to the variable to be read in this memory.
858 * *mode The mode of the value to be loaded.
859 * flags Additional flags for alignment, volatility and pin state.
862 * The memory and a pointer to a variable in this memory.
864 * A tuple of the memory, a control flow to be taken in case of
865 * an exception and the loaded value.
867 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val, ir_cons_flags flags)
868 * -------------------------------------------------------------------------------------
870 * The Store operation writes a value to a variable in memory.
873 * The memory, a pointer to a variable in this memory and the value
874 * to write to this variable.
876 * A tuple of the changed memory and a control flow to be taken in
877 * case of an exception.
879 * ir_node *new_Alloc (ir_node *store, ir_node *count, ir_type *alloc_type,
880 * -----------------------------------------------------------------------
884 * The Alloc node allocates a new variable. It can be specified whether the
885 * variable should be allocated to the stack or to the heap.
888 * *store The memory which shall contain the new variable.
889 * *count This field is for allocating arrays, it specifies how
890 * many array elements are to be allocated.
891 * *alloc_type The type of the allocated variable. In case of allocating
892 * arrays this has to be the array type, not the type of the
894 * where Where to allocate the variable, either heap_alloc or stack_alloc.
897 * A memory and an unsigned integer.
899 * A tuple of the changed memory, a control flow to be taken in
900 * case of an exception and the pointer to the new variable.
902 * a.where Indicates where the variable is allocated.
903 * a.*type A pointer to the class the allocated data object
906 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
907 * -----------------------------------------------------------------------------------
911 * The Free node frees memory of the given variable.
914 * *store The memory which shall contain the new variable.
915 * *ptr The pointer to the object to free.
916 * *size The number of objects of type free_type to free in a sequence.
917 * *free_type The type of the freed variable.
918 * where Where the variable was allocated, either heap_alloc or stack_alloc.
921 * A memory, a pointer and an unsigned integer.
923 * The changed memory.
925 * f.*type A pointer to the type information of the freed data object.
929 * ir_node *new_Sync (int arity, ir_node **in)
930 * -------------------------------------------
932 * The Sync operation unifies several partial memory blocks. These blocks
933 * have to be pairwise disjunct or the values in common locations have to
934 * be identical. This operation allows to specify all operations that eventually
935 * need several partial memory blocks as input with a single entrance by
936 * unifying the memories with a preceding Sync operation.
939 * arity The number of memories to synchronize.
940 * **in An array of pointers to nodes that produce an output of
945 * The unified memory.
951 * ir_node *new_Bad (void)
952 * -----------------------
954 * Returns the unique Bad node current_ir_graph->bad.
955 * This node is used to express results of dead code elimination.
957 * ir_node *new_NoMem (void)
958 * -----------------------------------------------------------------------------------
960 * Returns the unique NoMem node current_ir_graph->no_mem.
961 * This node is used as input for operations that need a Memory, but do not
962 * change it like Div by const != 0, analyzed calls etc.
964 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
965 * ----------------------------------------------------------
967 * Selects one entry of a tuple. This is a hidden edge with attributes.
970 * *arg A node producing a tuple.
971 * *mode The mode of the value to project.
972 * proj The position of the value in the tuple.
978 * ir_node *new_Tuple (int arity, ir_node **in)
979 * --------------------------------------------
981 * Builds a Tuple from single values. This is needed to implement
982 * optimizations that remove a node that produced a tuple. The node can be
983 * replaced by the Tuple operation so that the following Proj nodes have not to
984 * be changed. (They are hard to find due to the implementation with pointers
985 * in only one direction.) The Tuple node is smaller than any other
986 * node, so that a node can be changed into a Tuple by just changing it's
987 * opcode and giving it a new in array.
990 * arity The number of tuple elements.
991 * **in An array containing pointers to the nodes producing the
994 * ir_node *new_Id (ir_node *val, ir_mode *mode)
995 * ---------------------------------------------
997 * The single output of the Id operation is it's input. Also needed
1001 * HIGH LEVEL OPERATIONS
1002 * ---------------------
1004 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
1005 * -----------------------------------------------------------------------------------
1007 * Describes a high level block copy of a compound type from address src to
1008 * address dst. Must be lowered to a Call to a runtime memory copy function.
1011 * HIGH LEVEL OPERATIONS: Exception Support
1012 * ----------------------------------------
1013 * See TechReport 1999-14, chapter Exceptions.
1015 * ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
1016 * -----------------------------------------------------------------------------------
1018 * Describes a high level type check. Must be lowered to a Call to a runtime check
1021 * ir_node *new_Raise (ir_node *store, ir_node *obj)
1022 * -------------------------------------------------
1024 * Raises an exception. Unconditional change of control flow. Writes
1025 * an explicit Except variable to memory to pass it to the exception
1026 * handler. Must be lowered to a Call to a runtime check
1031 * A pointer to the Except variable.
1033 * A tuple of control flow and the changed memory state. The control flow
1034 * points to the exception handler if it is definied in this procedure,
1035 * else it points to the end_block.
1037 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
1038 * -----------------------------------------------------------------------------------
1040 * Describes a high level bounds check. Must be lowered to a Call to a runtime check
1043 * ir_node *new_Pin (ir_node *node);
1044 * -----------------------------------------------------------------------------------
1046 * Pin the value of the node node in the current block No users of the Pin node can
1047 * float above the Block of the Pin. The node cannot float behind this block. Often
1048 * used to Pin the NoMem node.
1051 * COPING WITH DATA OBJECTS
1052 * ========================
1054 * Two kinds of data objects have to be distinguished for generating
1055 * FIRM. First there are local variables other than arrays that are
1056 * known to be alias free. Second there are all other data objects.
1057 * For the first a common SSA representation is built, the second
1058 * are modeled by saving them to memory. The memory is treated as
1059 * a single local variable, the alias problem is hidden in the
1060 * content of this variable.
1062 * All values known in a Block are listed in the block's attribute,
1063 * block.**graph_arr which is used to automatically insert Phi nodes.
1064 * The following two functions can be used to add a newly computed value
1065 * to the array, or to get the producer of a value, i.e., the current
1068 * inline void set_value (int pos, ir_node *value)
1069 * -----------------------------------------------
1071 * Has to be called for every assignment to a local variable. It
1072 * adds the value to the array of used values at position pos. Pos
1073 * has to be a unique identifier for an entry in the procedure's
1074 * definition table. It can be used to access the value again.
1075 * Requires current_block to be set correctly.
1077 * ir_node *get_value (int pos, ir_mode *mode)
1078 * -------------------------------------------
1080 * Returns the node defining the value referred to by pos. If the
1081 * value is not defined in this block a Phi node is generated and
1082 * all definitions reaching this Phi node are collected. It can
1083 * happen that the algorithm allocates an unnecessary Phi node,
1084 * e.g. if there is only one definition of this value, but this
1085 * definition reaches the currend block on several different
1086 * paths. This Phi node will be eliminated if optimizations are
1087 * turned on right after it's creation.
1088 * Requires current_block to be set correctly.
1090 * There are two special routines for the global store:
1092 * void set_store (ir_node *store)
1093 * -------------------------------
1095 * Adds the store to the array of known values at a reserved
1097 * Requires current_block to be set correctly.
1099 * ir_node *get_store (void)
1100 * -------------------------
1102 * Returns the node defining the actual store.
1103 * Requires current_block to be set correctly.
1106 * inline void keep_alive (ir_node *ka)
1107 * ------------------------------------
1109 * Keep this node alive because it is (might be) not in the control
1110 * flow from Start to End. Adds the node to the list in the end
1114 #ifndef FIRM_IR_IRCONS_H
1115 #define FIRM_IR_IRCONS_H
1117 #include "firm_types.h"
1122 * constrained flags for memory operations.
1124 typedef enum ir_cons_flags {
1125 cons_none = 0, /**< No constrains. */
1126 cons_volatile = 1U << 0, /**< Memory operation is volatile. */
1127 cons_unaligned = 1U << 1, /**< Memory operation is unaligned. */
1128 cons_floats = 1U << 2 /**< Memory operation can float. */
1131 /*-------------------------------------------------------------------------*/
1132 /* The raw interface */
1133 /*-------------------------------------------------------------------------*/
1135 /** Constructor for a Block node.
1137 * Constructs a mature block with the given predecessors.
1139 * @param *db A Pointer for debug information.
1140 * @param irg The IR graph the block belongs to.
1141 * @param arity The number of control predecessors.
1142 * @param in[] An array of control predecessors. The length of
1143 * the array must be 'arity'. The constructor copies this array.
1145 FIRM_API ir_node *new_rd_Block(dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1147 /** Constructor for a Start node.
1149 * @param *db A pointer for debug information.
1150 * @param *irg The IR graph the node belongs to.
1151 * @param *block The IR block the node belongs to.
1153 FIRM_API ir_node *new_rd_Start(dbg_info *db, ir_node *block);
1155 /** Constructor for a End node.
1157 * @param *db A pointer for debug information.
1158 * @param *irg The IR graph the node belongs to.
1159 * @param *block The IR block the node belongs to.
1161 FIRM_API ir_node *new_rd_End(dbg_info *db, ir_node *block);
1163 /** Constructor for a Jmp node.
1165 * Jmp represents control flow to a single control successor.
1167 * @param *db A pointer for debug information.
1168 * @param *block The IR block the node belongs to.
1170 FIRM_API ir_node *new_rd_Jmp(dbg_info *db, ir_node *block);
1172 /** Constructor for an IJmp node.
1174 * IJmp represents control flow to a single control successor not
1175 * statically known i.e. an indirect Jmp.
1177 * @param *db A pointer for debug information.
1178 * @param *block The IR block the node belongs to.
1179 * @param *tgt The IR node representing the target address.
1181 FIRM_API ir_node *new_rd_IJmp(dbg_info *db, ir_node *block, ir_node *tgt);
1183 /** Constructor for a Cond node.
1185 * If c is mode_b represents a conditional branch (if/else). If c is
1186 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1187 * node, default Proj is 0.)
1189 * This is not consistent: Input to Cond is Is, Proj has as proj number
1192 * @param *db A pointer for debug information.
1193 * @param *block The IR block the node belongs to.
1194 * @param *c The conditions parameter. Can be of mode b or I_u.
1196 FIRM_API ir_node *new_rd_Cond(dbg_info *db, ir_node *block, ir_node *c);
1198 /** Constructor for a Return node.
1200 * Returns the memory and zero or more return values. Only node that
1201 * can end regular control flow.
1203 * @param *db A pointer for debug information.
1204 * @param *block The IR block the node belongs to.
1205 * @param *store The state of memory.
1206 * @param arity Number of return values.
1207 * @param *in Array of length arity with return values. The constructor copies this array.
1209 FIRM_API ir_node *new_rd_Return(dbg_info *db, ir_node *block,
1210 ir_node *store, int arity, ir_node *in[]);
1212 /** Constructor for a Const_type node.
1214 * Adds the node to the start block.
1216 * The constant represents a target value. This constructor sets high
1217 * level type information for the constant value.
1218 * Derives mode from passed tarval.
1220 * @param *db A pointer for debug information.
1221 * @param *irg The IR graph the node belongs to.
1222 * @param *con Points to an entry in the constant table.
1223 * @param *tp The type of the constant.
1225 FIRM_API ir_node *new_rd_Const_type(dbg_info *db, ir_graph *irg,
1226 tarval *con, ir_type *tp);
1228 /** Constructor for a Const node.
1230 * Adds the node to the start block.
1232 * Constructor for a Const node. The constant represents a target
1233 * value. Sets the type information to type_unknown. (No more
1234 * supported: If tv is entity derives a somehow useful type.)
1235 * Derives mode from passed tarval.
1237 * @param *db A pointer for debug information.
1238 * @param *irg The IR graph the node belongs to.
1239 * @param *con Points to an entry in the constant table.
1241 FIRM_API ir_node *new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con);
1244 * Constructor for a Const node.
1246 * Adds the node to the start block.
1248 * Constructor for a Const node. The constant represents a target
1249 * value. Sets the type information to type_unknown. (No more
1250 * supported: If tv is entity derives a somehow useful type.)
1252 * @param *db A pointer for debug information.
1253 * @param *irg The IR graph the node belongs to.
1254 * @param *mode The mode of the operands and results.
1255 * @param value A value from which the tarval is made.
1257 FIRM_API ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg,
1258 ir_mode *mode, long value);
1260 /** Constructor for a SymConst_type node.
1262 * This is the constructor for a symbolic constant.
1263 * There are several kinds of symbolic constants:
1264 * - symconst_type_tag The symbolic constant represents a type tag. The
1265 * type the tag stands for is given explicitly.
1266 * - symconst_type_size The symbolic constant represents the size of a type.
1267 * The type of which the constant represents the size
1268 * is given explicitly.
1269 * - symconst_type_align The symbolic constant represents the alignment of a
1270 * type. The type of which the constant represents the
1271 * size is given explicitly.
1272 * - symconst_addr_ent The symbolic constant represents the address of an
1273 * entity (variable or method). The variable is given
1274 * explicitly by a firm entity.
1275 * - symconst_ofs_ent The symbolic constant represents the offset of an
1276 * entity in its owner type.
1277 * - symconst_enum_const The symbolic constant is a enumeration constant of
1278 * an enumeration type.
1280 * Inputs to the node:
1281 * No inputs except the block it belongs to.
1282 * Outputs of the node.
1283 * An unsigned integer (I_u) or a pointer (P).
1285 * Mention union in declaration so that the firmjni generator recognizes that
1286 * it can not cast the argument to an int.
1288 * @param *db A pointer for debug information.
1289 * @param *irg The IR graph the node belongs to.
1290 * @param mode The mode for the SymConst.
1291 * @param val A type, ident, entity or enum constant depending on the
1293 * @param kind The kind of the symbolic constant, see the list above
1294 * @param tp The source type of the constant.
1296 FIRM_API ir_node *new_rd_SymConst_type(dbg_info *db, ir_graph *irg,
1297 ir_mode *mode, union symconst_symbol val,
1298 symconst_kind kind, ir_type *tp);
1300 /** Constructor for a SymConst node.
1302 * Same as new_rd_SymConst_type, except that it sets the type to type_unknown.
1304 FIRM_API ir_node *new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode,
1305 union symconst_symbol value,
1306 symconst_kind kind);
1308 /** Constructor for a SymConst addr_ent node.
1310 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1311 * symconst_addr_ent.
1312 * Adds the SymConst to the start block of irg. */
1313 FIRM_API ir_node *new_rd_SymConst_addr_ent(dbg_info *db, ir_graph *irg,
1314 ir_mode *mode, ir_entity *symbol,
1317 /** Constructor for a SymConst ofs_ent node.
1319 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1321 * Adds the SymConst to the start block of irg.
1323 FIRM_API ir_node *new_rd_SymConst_ofs_ent(dbg_info *db, ir_graph *irg,
1324 ir_mode *mode, ir_entity *symbol,
1327 /** Constructor for a SymConst type_tag node.
1329 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1330 * symconst_type_tag.
1331 * Adds the SymConst to the start block of irg.
1333 FIRM_API ir_node *new_rd_SymConst_type_tag(dbg_info *db, ir_graph *irg,
1334 ir_mode *mode, ir_type *symbol,
1337 /** Constructor for a SymConst size node.
1339 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1340 * symconst_type_size.
1341 * Adds the SymConst to the start block of irg. */
1342 FIRM_API ir_node *new_rd_SymConst_size(dbg_info *db, ir_graph *irg,
1343 ir_mode *mode, ir_type *symbol,
1346 /** Constructor for a SymConst size node.
1348 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1349 * symconst_type_align.
1350 * Adds the SymConst to the start block of irg.
1352 FIRM_API ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg,
1353 ir_mode *mode, ir_type *symbol,
1356 /** Constructor for a simpleSel node.
1358 * This is a shortcut for the new_rd_Sel() constructor. To be used for
1359 * Sel nodes that do not select from an array, i.e., have no index
1360 * inputs. It adds the two parameters 0, NULL.
1362 * @param *db A pointer for debug information.
1363 * @param *block The IR block the node belongs to.
1364 * @param *store The memory in which the object the entity should be
1365 * selected from is allocated.
1366 * @param *objptr The object from that the Sel operation selects a
1367 * single attribute out.
1368 * @param *ent The entity to select.
1370 FIRM_API ir_node *new_rd_simpleSel(dbg_info *db, ir_node *block, ir_node *store,
1371 ir_node *objptr, ir_entity *ent);
1373 /** Constructor for a Sel node.
1375 * The select node selects an entity (field or method) from an entity
1376 * with a compound type. It explicitly specifies the entity selected.
1377 * Dynamically the node may select entities that overwrite the given
1378 * entity. If the selected entity is an array element entity the Sel
1379 * node takes the required array indices as inputs.
1381 * @param *db A pointer for debug information.
1382 * @param *block The IR block the node belongs to.
1383 * @param *store The memory in which the object the entity should be selected
1384 * from is allocated.
1385 * @param *objptr A pointer to a compound entity the Sel operation selects a
1386 * single attribute from.
1387 * @param *n_index The number of array indices needed to select an array element entity.
1388 * @param *index[] If the compound entity is an array the indices of the selected
1389 * element entity. The constructor copies this array.
1390 * @param *ent The entity to select.
1392 FIRM_API ir_node *new_rd_Sel(dbg_info *db, ir_node *block, ir_node *store,
1393 ir_node *objptr, int n_index, ir_node *index[],
1396 /** Constructor for a Call node.
1398 * Represents all kinds of method and function calls.
1400 * @param *db A pointer for debug information.
1401 * @param *block The IR block the node belongs to.
1402 * @param *store The current memory state.
1403 * @param *callee A pointer to the called procedure.
1404 * @param arity The number of procedure parameters.
1405 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1406 * @param *tp Type information of the procedure called.
1408 FIRM_API ir_node *new_rd_Call(dbg_info *db, ir_node *block, ir_node *store,
1409 ir_node *callee, int arity, ir_node *in[],
1412 /** Constructor for a Builtin node.
1414 * Represents a call of a backend-specific builtin..
1416 * @param *db A pointer for debug information.
1417 * @param *block The IR block the node belongs to.
1418 * @param *store The current memory state.
1419 * @param arity The number of procedure parameters.
1420 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1421 * @param kind The kind of the called builtin.
1422 * @param *tp Type information of the procedure called.
1424 FIRM_API ir_node *new_rd_Builtin(dbg_info *db, ir_node *block, ir_node *store,
1425 int arity, ir_node *in[], ir_builtin_kind kind,
1428 /** Constructor for a Add node.
1430 * @param *db A pointer for debug information.
1431 * @param *block The IR block the node belongs to.
1432 * @param *op1 The first operand.
1433 * @param *op2 The second operand.
1434 * @param *mode The mode of the operands and the result.
1436 FIRM_API ir_node *new_rd_Add(dbg_info *db, ir_node *block, ir_node *op1,
1437 ir_node *op2, ir_mode *mode);
1439 /** Constructor for a Sub node.
1441 * @param *db A pointer for debug information.
1442 * @param *block The IR block the node belongs to.
1443 * @param *op1 The first operand.
1444 * @param *op2 The second operand.
1445 * @param *mode The mode of the operands and the result.
1447 FIRM_API ir_node *new_rd_Sub(dbg_info *db, ir_node *block,
1448 ir_node *op1, ir_node *op2, ir_mode *mode);
1450 /** Constructor for a Minus node.
1452 * @param *db A pointer for debug information.
1453 * @param *block The IR block the node belongs to.
1454 * @param *op The operand .
1455 * @param *mode The mode of the operand and the result.
1457 FIRM_API ir_node *new_rd_Minus(dbg_info *db, ir_node *block,
1458 ir_node *op, ir_mode *mode);
1460 /** Constructor for a Mul node.
1462 * @param *db A pointer for debug information.
1463 * @param *block The IR block the node belongs to.
1464 * @param *op1 The first operand.
1465 * @param *op2 The second operand.
1466 * @param *mode The mode of the operands and the result.
1468 FIRM_API ir_node *new_rd_Mul(dbg_info *db, ir_node *block,
1469 ir_node *op1, ir_node *op2, ir_mode *mode);
1471 /** Constructor for a Mulh node.
1473 * @param *db A pointer for debug information.
1474 * @param *block The IR block the node belongs to.
1475 * @param *op1 The first operand.
1476 * @param *op2 The second operand.
1477 * @param *mode The mode of the operands and the result.
1479 FIRM_API ir_node *new_rd_Mulh(dbg_info *db, ir_node *block,
1480 ir_node *op1, ir_node *op2, ir_mode *mode);
1482 /** Constructor for a Quot node.
1484 * @param *db A pointer for debug information.
1485 * @param *block The IR block the node belongs to.
1486 * @param *memop The store needed to model exceptions
1487 * @param *op1 The first operand.
1488 * @param *op2 The second operand.
1489 * @param *mode The mode of the result.
1490 * @param state The pinned state.
1492 FIRM_API ir_node *new_rd_Quot(dbg_info *db, ir_node *block, ir_node *memop,
1493 ir_node *op1, ir_node *op2, ir_mode *mode,
1494 op_pin_state state);
1496 /** Constructor for a DivMod node.
1498 * @param *db A pointer for debug information.
1499 * @param *block The IR block the node belongs to.
1500 * @param *memop The store needed to model exceptions
1501 * @param *op1 The first operand.
1502 * @param *op2 The second operand.
1503 * @param *mode The mode of the results.
1504 * @param state The pinned state.
1506 FIRM_API ir_node *new_rd_DivMod(dbg_info *db, ir_node *block, ir_node *memop,
1507 ir_node *op1, ir_node *op2, ir_mode *mode,
1508 op_pin_state state);
1510 /** Constructor for a Div node.
1512 * @param *db A pointer for debug information.
1513 * @param *block The IR block the node belongs to.
1514 * @param *memop The store needed to model exceptions
1515 * @param *op1 The first operand.
1516 * @param *op2 The second operand.
1517 * @param *mode The mode of the result.
1518 * @param state The pinned state.
1520 FIRM_API ir_node *new_rd_Div(dbg_info *db, ir_node *block, ir_node *memop,
1521 ir_node *op1, ir_node *op2, ir_mode *mode,
1522 op_pin_state state);
1524 /** Constructor for a remainderless Div node.
1526 * @param *db A pointer for debug information.
1527 * @param *block The IR block the node belongs to.
1528 * @param *memop The store needed to model exceptions
1529 * @param *op1 The first operand.
1530 * @param *op2 The second operand.
1531 * @param *mode The mode of the result.
1532 * @param state The pinned state.
1534 FIRM_API ir_node *new_rd_DivRL(dbg_info *db, ir_node *block, ir_node *memop,
1535 ir_node *op1, ir_node *op2, ir_mode *mode,
1536 op_pin_state state);
1538 /** Constructor for a Mod node.
1540 * @param *db A pointer for debug information.
1541 * @param *block The IR block the node belongs to.
1542 * @param *memop The store needed to model exceptions
1543 * @param *op1 The first operand.
1544 * @param *op2 The second operand.
1545 * @param *mode The mode of the result.
1546 * @param state The pinned state.
1548 FIRM_API ir_node *new_rd_Mod(dbg_info *db, ir_node *block, ir_node *memop,
1549 ir_node *op1, ir_node *op2, ir_mode *mode,
1550 op_pin_state state);
1552 /** Constructor for a And node.
1554 * @param *db A pointer for debug information.
1555 * @param *block The IR block the node belongs to.
1556 * @param *op1 The first operand.
1557 * @param *op2 The second operand.
1558 * @param *mode The mode of the operands and the result.
1560 FIRM_API ir_node *new_rd_And(dbg_info *db, ir_node *block,
1561 ir_node *op1, ir_node *op2, ir_mode *mode);
1563 /** Constructor for a Or node.
1565 * @param *db A pointer for debug information.
1566 * @param *block The IR block the node belongs to.
1567 * @param *op1 The first operand.
1568 * @param *op2 The second operand.
1569 * @param *mode The mode of the operands and the result.
1571 FIRM_API ir_node *new_rd_Or(dbg_info *db, ir_node *block,
1572 ir_node *op1, ir_node *op2, ir_mode *mode);
1574 /** Constructor for a Eor node.
1576 * @param *db A pointer for debug information.
1577 * @param *block The IR block the node belongs to.
1578 * @param *op1 The first operand.
1579 * @param *op2 The second operand.
1580 * @param *mode The mode of the operands and the results.
1582 FIRM_API ir_node *new_rd_Eor(dbg_info *db, ir_node *block,
1583 ir_node *op1, ir_node *op2, ir_mode *mode);
1585 /** Constructor for a Not node.
1587 * @param *db A pointer for debug information.
1588 * @param *block The IR block the node belongs to.
1589 * @param *op The operand.
1590 * @param *mode The mode of the operand and the result.
1592 FIRM_API ir_node *new_rd_Not(dbg_info *db, ir_node *block, ir_node *op,
1595 /** Constructor for a Cmp node.
1597 * @param *db A pointer for debug information.
1598 * @param *block The IR block the node belongs to.
1599 * @param *op1 The first operand.
1600 * @param *op2 The second operand.
1602 FIRM_API ir_node *new_rd_Cmp(dbg_info *db, ir_node *block,
1603 ir_node *op1, ir_node *op2);
1605 /** Constructor for a Shl node.
1607 * @param *db A pointer for debug information.
1608 * @param *block The IR block the node belongs to.
1609 * @param *op The operand.
1610 * @param *k The number of bits to shift the operand .
1611 * @param *mode The mode of the operand and the result.
1613 FIRM_API ir_node *new_rd_Shl(dbg_info *db, ir_node *block,
1614 ir_node *op, ir_node *k, ir_mode *mode);
1616 /** Constructor for a Shr node.
1618 * @param *db A pointer for debug information.
1619 * @param *block The IR block the node belongs to.
1620 * @param *op The operand.
1621 * @param *k The number of bits to shift the operand .
1622 * @param *mode The mode of the operand and the result.
1624 FIRM_API ir_node *new_rd_Shr(dbg_info *db, ir_node *block,
1625 ir_node *op, ir_node *k, ir_mode *mode);
1627 /** Constructor for a Shrs node.
1629 * @param *db A pointer for debug information.
1630 * @param *block The IR block the node belongs to.
1631 * @param *op The operand.
1632 * @param *k The number of bits to shift the operand.
1633 * @param *mode The mode of the operand and the result.
1635 FIRM_API ir_node *new_rd_Shrs(dbg_info *db, ir_node *block,
1636 ir_node *op, ir_node *k, ir_mode *mode);
1638 /** Constructor for a Rotl node.
1640 * @param *db A pointer for debug information.
1641 * @param *block The IR block the node belongs to.
1642 * @param *op The operand.
1643 * @param *k The number of bits to rotate the operand.
1644 * @param *mode The mode of the operand.
1646 FIRM_API ir_node *new_rd_Rotl(dbg_info *db, ir_node *block,
1647 ir_node *op, ir_node *k, ir_mode *mode);
1650 /** Constructor for a Conv node.
1652 * @param *db A pointer for debug information.
1653 * @param *block The IR block the node belongs to.
1654 * @param *op The operand.
1655 * @param *mode The mode of this the operand muss be converted .
1657 FIRM_API ir_node *new_rd_Conv(dbg_info *db, ir_node *block, ir_node *op,
1660 /** Constructor for a strictConv node.
1662 * @param *db A pointer for debug information.
1663 * @param *block The IR block the node belongs to.
1664 * @param *op The operand.
1665 * @param *mode The mode of this the operand muss be converted .
1667 FIRM_API ir_node *new_rd_strictConv(dbg_info *db, ir_node *block,
1668 ir_node *op, ir_mode *mode);
1670 /** Constructor for a Cast node.
1672 * High level type cast.
1674 * @param *db A pointer for debug information.
1675 * @param *block The IR block the node belongs to.
1676 * @param *op The operand.
1677 * @param *to_tp The type of this the operand muss be casted .
1679 FIRM_API ir_node *new_rd_Cast(dbg_info *db, ir_node *block,
1680 ir_node *op, ir_type *to_tp);
1682 /** Constructor for a Carry node.
1683 * Note: This node is not supported by the backends! Only use for program
1686 * @param *db A pointer for debug information.
1687 * @param *block The IR block the node belongs to.
1688 * @param *op1 The first operand.
1689 * @param *op2 The second operand.
1690 * @param *mode The mode of the operands and the result.
1692 FIRM_API ir_node *new_rd_Carry(dbg_info *db, ir_node *block,
1693 ir_node *op1, ir_node *op2, ir_mode *mode);
1695 /** Constructor for a Borrow node.
1696 * Note: This node is not supported by the backends! Only use for program
1699 * @param *db A pointer for debug information.
1700 * @param *block The IR block the node belongs to.
1701 * @param *op1 The first operand.
1702 * @param *op2 The second operand.
1703 * @param *mode The mode of the operands and the result.
1705 FIRM_API ir_node *new_rd_Borrow(dbg_info *db, ir_node *block,
1706 ir_node *op1, ir_node *op2, ir_mode *mode);
1708 /** Constructor for a Phi node.
1710 * @param *db A pointer for debug information.
1711 * @param *block The IR block the node belongs to.
1712 * @param arity The number of predecessors
1713 * @param *in[] Array with predecessors. The constructor copies this array.
1714 * @param *mode The mode of it's inputs and output.
1716 FIRM_API ir_node *new_rd_Phi(dbg_info *db, ir_node *block, int arity,
1717 ir_node *in[], ir_mode *mode);
1719 /** Constructor for a Load node.
1721 * @param *db A pointer for debug information.
1722 * @param *block The IR block the node belongs to.
1723 * @param *store The current memory
1724 * @param *adr A pointer to the variable to be read in this memory.
1725 * @param *mode The mode of the value to be loaded.
1726 * @param flags Additional flags for alignment, volatility and pin state.
1728 FIRM_API ir_node *new_rd_Load(dbg_info *db, ir_node *block, ir_node *store,
1729 ir_node *adr, ir_mode *mode, ir_cons_flags flags);
1731 /** Constructor for a Store node.
1733 * @param *db A pointer for debug information.
1734 * @param *block The IR block the node belongs to.
1735 * @param *store The current memory
1736 * @param *adr A pointer to the variable to be read in this memory.
1737 * @param *val The value to write to this variable.
1738 * @param flags Additional flags for alignment, volatility and pin state.
1740 FIRM_API ir_node *new_rd_Store(dbg_info *db, ir_node *block, ir_node *store,
1741 ir_node *adr, ir_node *val, ir_cons_flags flags);
1743 /** Constructor for a Alloc node.
1745 * The Alloc node extends the memory by space for an entity of type alloc_type.
1747 * @param *db A pointer for debug information.
1748 * @param *block The IR block the node belongs to.
1749 * @param *store The memory which shall contain the new variable.
1750 * @param *count The number of objects to allocate.
1751 * @param *alloc_type The type of the allocated variable.
1752 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
1754 FIRM_API ir_node *new_rd_Alloc(dbg_info *db, ir_node *block, ir_node *store,
1755 ir_node *count, ir_type *alloc_type,
1756 ir_where_alloc where);
1758 /** Constructor for a Free node.
1760 * Frees the memory occupied by the entity pointed to by the pointer
1761 * arg. Type indicates the type of the entity the argument points to.
1763 * @param *db A pointer for debug information.
1764 * @param *block The IR block the node belongs to.
1765 * @param *store The memory which shall contain the new variable.
1766 * @param *ptr The pointer to the object to free.
1767 * @param *size The number of objects of type free_type to free in a sequence.
1768 * @param *free_type The type of the freed variable.
1769 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
1771 FIRM_API ir_node *new_rd_Free(dbg_info *db, ir_node *block, ir_node *store,
1772 ir_node *ptr, ir_node *size, ir_type *free_type,
1773 ir_where_alloc where);
1775 /** Constructor for a Sync node.
1777 * Merges several memory values. The node assumes that a variable
1778 * either occurs only in one of the memories, or it contains the same
1779 * value in all memories where it occurs.
1781 * @param *db A pointer for debug information.
1782 * @param *block The IR block the node belongs to.
1783 * @param arity The number of memories to synchronize.
1784 * @param *in[] An array of pointers to nodes that produce an output of type
1785 * memory. The constructor copies this array.
1787 FIRM_API ir_node *new_rd_Sync(dbg_info *db, ir_node *block, int arity,
1790 /** Constructor for a Proj node.
1792 * Projects a single value out of a tuple. The parameter proj gives the
1793 * position of the value within the tuple.
1795 * @param *db A pointer for debug information.
1796 * @param arg A node producing a tuple. The node must have mode_T.
1797 * @param *mode The mode of the value to project.
1798 * @param proj The position of the value in the tuple.
1800 FIRM_API ir_node *new_rd_Proj(dbg_info *db, ir_node *arg, ir_mode *mode,
1803 /** Constructor for a defaultProj node.
1805 * Represents the default control flow of a Switch-Cond node.
1807 * @param *db A pointer for debug information.
1808 * @param arg A node producing a tuple.
1809 * @param max_proj The end position of the value in the tuple.
1811 FIRM_API ir_node *new_rd_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
1813 /** Constructor for a Tuple node.
1815 * This is an auxiliary node to replace a node that returns a tuple
1816 * without changing the corresponding Proj nodes.
1818 * @param *db A pointer for debug information.
1819 * @param *block The IR block the node belongs to.
1820 * @param arity The number of tuple elements.
1821 * @param *in[] An array containing pointers to the nodes producing the tuple
1822 * elements. The constructor copies this array.
1824 FIRM_API ir_node *new_rd_Tuple(dbg_info *db, ir_node *block,
1825 int arity, ir_node *in[]);
1827 /** Constructor for a Id node.
1829 * This is an auxiliary node to replace a node that returns a single
1832 * @param *db A pointer for debug information.
1833 * @param *block The IR block the node belongs to.
1834 * @param *val The value
1835 * @param *mode The mode of *val.
1837 FIRM_API ir_node *new_rd_Id(dbg_info *db, ir_node *block,
1838 ir_node *val, ir_mode *mode);
1840 /** Constructor for a Confirm node.
1842 * Specifies constraints for a value. To support dataflow analyses.
1844 * Example: If the value never exceeds '100' this is expressed by placing a
1845 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
1847 * @param *db A pointer for debug information.
1848 * @param *block The IR block the node belong to.
1849 * @param *val The value we express a constraint for
1850 * @param *bound The value to compare against. Must be a firm node, typically a constant.
1851 * @param cmp The compare operation.
1853 FIRM_API ir_node *new_rd_Confirm(dbg_info *db, ir_node *block,
1854 ir_node *val, ir_node *bound, pn_Cmp cmp);
1856 /** Constructor for an Unknown node.
1858 * Represents an arbitrary value. Places the node in the start block.
1860 * @param *db A pointer for debug information.
1861 * @param *irg The IR graph the node belongs to.
1862 * @param *m The mode of the unknown value.
1864 FIRM_API ir_node *new_rd_Unknown(dbg_info *db, ir_graph *irg, ir_mode *m);
1866 /** Constructor for a Mux node.
1868 * @param *db A pointer for debug information.
1869 * @param *block The block the node belong to.
1870 * @param *sel The ir_node that calculates the boolean select.
1871 * @param *ir_true The ir_node that calculates the true result.
1872 * @param *ir_false The ir_node that calculates the false result.
1873 * @param *mode The mode of the node (and it_true and ir_false).
1875 FIRM_API ir_node *new_rd_Mux(dbg_info *db, ir_node *block, ir_node *sel,
1876 ir_node *ir_false, ir_node *ir_true,
1879 /** Constructor for a CopyB node.
1881 * @param *db A pointer for debug information.
1882 * @param *block The block the node belong to.
1883 * @param *store The current memory
1884 * @param *dst The ir_node that represents the destination address.
1885 * @param *src The ir_node that represents the source address.
1886 * @param *data_type The type of the copied data
1888 FIRM_API ir_node *new_rd_CopyB(dbg_info *db, ir_node *block, ir_node *store,
1889 ir_node *dst, ir_node *src, ir_type *data_type);
1891 /** Constructor for a InstOf node.
1893 * A High-Level Type check.
1895 * @param *db A pointer for debug information.
1896 * @param *block The IR block the node belongs to.
1897 * @param *store The memory in which the object the entity should be selected
1898 * from is allocated.
1899 * @param *objptr A pointer to a object of a class type.
1900 * @param *type The type of which objptr must be.
1902 FIRM_API ir_node *new_rd_InstOf(dbg_info *db, ir_node *block, ir_node *store,
1903 ir_node *objptr, ir_type *type);
1905 /** Constructor for a Raise node.
1907 * A High-Level Exception throw.
1909 * @param *db A pointer for debug information.
1910 * @param *block The IR block the node belongs to.
1911 * @param *store The current memory.
1912 * @param *obj A pointer to the Except variable.
1914 FIRM_API ir_node *new_rd_Raise(dbg_info *db, ir_node *block, ir_node *store,
1917 /** Constructor for a Bound node.
1919 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
1921 * @param *db A pointer for debug information.
1922 * @param *block The block the node belong to.
1923 * @param *store The current memory.
1924 * @param *idx The ir_node that represents an index.
1925 * @param *lower The ir_node that represents the lower bound for the index.
1926 * @param *upper The ir_node that represents the upper bound for the index.
1928 FIRM_API ir_node *new_rd_Bound(dbg_info *db, ir_node *block,
1929 ir_node *store, ir_node *idx, ir_node *lower,
1932 /** Constructor for a Pin node.
1934 * @param *db A pointer for debug information.
1935 * @param *block The block the node belong to.
1936 * @param *node The node which value should be pinned.
1938 FIRM_API ir_node *new_rd_Pin(dbg_info *db, ir_node *block, ir_node *node);
1940 /** Constructor for an ASM pseudo node.
1942 * @param *db A pointer for debug information.
1943 * @param *block The block the node belong to.
1944 * @param arity The number of data inputs to the node.
1945 * @param *in The array of length arity of data inputs.
1946 * @param *inputs The array of length arity of input constraints.
1947 * @param n_outs The number of data outputs to the node.
1948 * @param *outputs The array of length n_outs of output constraints.
1949 * @param n_clobber The number of clobbered registers.
1950 * @param *clobber The array of length n_clobber of clobbered registers.
1951 * @param *asm_text The assembler text.
1953 FIRM_API ir_node *new_rd_ASM(dbg_info *db, ir_node *block,
1954 int arity, ir_node *in[], ir_asm_constraint *inputs,
1955 int n_outs, ir_asm_constraint *outputs,
1956 int n_clobber, ident *clobber[], ident *asm_text);
1958 /*-------------------------------------------------------------------------*/
1959 /* The raw interface without debug support */
1960 /*-------------------------------------------------------------------------*/
1962 /** Constructor for a Block node.
1964 * Constructs a mature block with the given predecessors. Use Unknown
1965 * nodes as predecessors to construct a block if the number of
1966 * predecessors is known, but not the predecessors themselves. This
1967 * constructor does not set current_block. It not be used with
1968 * automatic Phi node construction.
1971 * @param irg The IR graph the block belongs to.
1972 * @param arity The number of control predecessors.
1973 * @param in[] An array of control predecessors. The length of
1974 * the array must be 'arity'. The constructor copies this array.
1976 FIRM_API ir_node *new_r_Block(ir_graph *irg, int arity, ir_node *in[]);
1978 /** Constructor for a Start node.
1980 * @param *block The IR block the node belongs to.
1982 FIRM_API ir_node *new_r_Start(ir_node *block);
1984 /** Constructor for a End node.
1986 * @param *block The IR block the node belongs to.
1988 FIRM_API ir_node *new_r_End(ir_node *block);
1990 /** Constructor for a Jmp node.
1992 * Jmp represents control flow to a single control successor.
1994 * @param *block The IR block the node belongs to.
1996 FIRM_API ir_node *new_r_Jmp(ir_node *block);
1998 /** Constructor for an IJmp node.
2000 * IJmp represents control flow to a single control successor not
2001 * statically known i.e. an indirect Jmp.
2003 * @param *block The IR block the node belongs to.
2004 * @param *tgt The IR node representing the target address.
2006 FIRM_API ir_node *new_r_IJmp(ir_node *block, ir_node *tgt);
2008 /** Constructor for a Cond node.
2010 * If c is mode_b represents a conditional branch (if/else). If c is
2011 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2012 * node, default Proj is 0.)
2014 * This is not consistent: Input to Cond is Is, Proj has as proj number
2017 * @param *block The IR block the node belongs to.
2018 * @param *c The conditions parameter.Can be of mode b or I_u.
2020 FIRM_API ir_node *new_r_Cond(ir_node *block, ir_node *c);
2022 /** Constructor for a Return node.
2024 * Returns the memory and zero or more return values. Only node that
2025 * can end regular control flow.
2027 * @param *block The IR block the node belongs to.
2028 * @param *store The state of memory.
2029 * @param arity Number of array indices.
2030 * @param *in[] Array with index inputs to the node. The constructor copies this array.
2032 FIRM_API ir_node *new_r_Return(ir_node *block, ir_node *store,
2033 int arity, ir_node *in[]);
2035 /** Constructor for a Const node.
2037 * Adds the node to the start block.
2039 * Constructor for a Const node. The constant represents a target
2040 * value. Sets the type information to type_unknown. (No more
2041 * supported: If tv is entity derives a somehow useful type.)
2042 * Derives mode from passed tarval.
2044 * @param *irg The IR graph the node belongs to.
2045 * @param *con Points to an entry in the constant table.
2047 FIRM_API ir_node *new_r_Const(ir_graph *irg, tarval *con);
2049 /** Constructor for a Const node.
2051 * Adds the node to the start block.
2053 * Constructor for a Const node. The constant represents a target
2054 * value. Sets the type information to type_unknown. (No more
2055 * supported: If tv is entity derives a somehow useful type.)
2057 * @param *irg The IR graph the node belongs to.
2058 * @param *mode The mode of the operands and the results.
2059 * @param value A value from which the tarval is made.
2061 FIRM_API ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value);
2063 /** Constructor for a Const_type node.
2065 * Adds the node to the start block.
2067 * The constant represents a target value. This constructor sets high
2068 * level type information for the constant value.
2069 * Derives mode from passed tarval.
2071 * @param *irg The IR graph the node belongs to.
2072 * @param *con Points to an entry in the constant table.
2073 * @param *tp The type of the constant.
2075 FIRM_API ir_node *new_r_Const_type(ir_graph *irg, tarval *con, ir_type *tp);
2077 /** Constructor for a SymConst node.
2079 * This is the constructor for a symbolic constant.
2080 * There are several kinds of symbolic constants:
2081 * - symconst_type_tag The symbolic constant represents a type tag. The
2082 * type the tag stands for is given explicitly.
2083 * - symconst_type_size The symbolic constant represents the size of a type.
2084 * The type of which the constant represents the size
2085 * is given explicitly.
2086 * - symconst_type_align The symbolic constant represents the alignment of a
2087 * type. The type of which the constant represents the
2088 * size is given explicitly.
2089 * - symconst_addr_ent The symbolic constant represents the address of an
2090 * entity (variable or method). The variable is given
2091 * explicitly by a firm entity.
2092 * - symconst_ofs_ent The symbolic constant represents the offset of an
2093 * entity in its owner type.
2094 * - symconst_enum_const The symbolic constant is a enumeration constant of
2095 * an enumeration type.
2097 * Inputs to the node:
2098 * No inputs except the block it belongs to.
2099 * Outputs of the node.
2100 * An unsigned integer (I_u) or a pointer (P).
2102 * Mention union in declaration so that the firmjni generator recognizes that
2103 * it can not cast the argument to an int.
2105 * @param *irg The IR graph the node belongs to.
2106 * @param mode The mode for the SymConst.
2107 * @param value A type, ident, entity or enum constant depending on the
2109 * @param kind The kind of the symbolic constant, see the list above
2111 FIRM_API ir_node *new_r_SymConst(ir_graph *irg, ir_mode *mode,
2112 union symconst_symbol value,
2113 symconst_kind kind);
2115 /** Constructor for a simpleSel node.
2117 * This is a shortcut for the new_d_Sel() constructor. To be used for
2118 * Sel nodes that do not select from an array, i.e., have no index
2119 * inputs. It adds the two parameters 0, NULL.
2121 * @param *block The IR block the node belongs to.
2122 * @param *store The memory in which the object the entity should be selected
2123 * from is allocated.
2124 * @param *objptr The object from that the Sel operation selects a
2125 * single attribute out.
2126 * @param *ent The entity to select.
2128 FIRM_API ir_node *new_r_simpleSel(ir_node *block, ir_node *store,
2129 ir_node *objptr, ir_entity *ent);
2131 /** Constructor for a Sel node.
2133 * The select node selects an entity (field or method) from an entity
2134 * with a compound type. It explicitly specifies the entity selected.
2135 * Dynamically the node may select entities that overwrite the given
2136 * entity. If the selected entity is an array element entity the Sel
2137 * node takes the required array indices as inputs.
2139 * @param *block The IR block the node belongs to.
2140 * @param *store The memory in which the object the entity should be selected
2141 * from is allocated.
2142 * @param *objptr A pointer to a compound entity the Sel operation selects a
2143 * single attribute from.
2144 * @param *n_index The number of array indices needed to select an array element entity.
2145 * @param *index[] If the compound entity is an array the indices of the selected
2146 * element entity. The constructor copies this array.
2147 * @param *ent The entity to select.
2149 FIRM_API ir_node *new_r_Sel(ir_node *block, ir_node *store,
2150 ir_node *objptr, int n_index, ir_node *index[],
2153 /** Constructor for a Call node.
2155 * Represents all kinds of method and function calls.
2157 * @param *block The IR block the node belongs to.
2158 * @param *store The actual store.
2159 * @param *callee A pointer to the called procedure.
2160 * @param arity The number of procedure parameters.
2161 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2162 * @param *tp Type information of the procedure called.
2164 FIRM_API ir_node *new_r_Call(ir_node *block, ir_node *store,
2165 ir_node *callee, int arity, ir_node *in[],
2168 /** Constructor for a Builtin node.
2170 * Represents a call of a backend-specific builtin..
2172 * @param *block The IR block the node belongs to.
2173 * @param *store The actual store.
2174 * @param arity The number of procedure parameters.
2175 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2176 * @param kind The kind of the called builtin.
2177 * @param *tp Type information of the procedure called.
2179 FIRM_API ir_node *new_r_Builtin(ir_node *block, ir_node *store,
2180 int arity, ir_node *in[], ir_builtin_kind kind,
2183 /** Constructor for a Add node.
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 result.
2190 FIRM_API ir_node *new_r_Add(ir_node *block, ir_node *op1, ir_node *op2,
2194 * Constructor for a Sub node.
2196 * @param *block The IR block the node belongs to.
2197 * @param *op1 The first operand.
2198 * @param *op2 The second operand.
2199 * @param *mode The mode of the operands and the results.
2201 FIRM_API ir_node *new_r_Sub(ir_node *block, ir_node *op1, ir_node *op2,
2204 /** Constructor for a Minus node.
2206 * @param *block The IR block the node belongs to.
2207 * @param *op The operand.
2208 * @param *mode The mode of the operand and the result.
2210 FIRM_API ir_node *new_r_Minus(ir_node *block, ir_node *op, ir_mode *mode);
2212 /** Constructor for a Mul node.
2214 * @param *block The IR block the node belongs to.
2215 * @param *op1 The first operand.
2216 * @param *op2 The second operand.
2217 * @param *mode The mode of the operands and the result.
2219 FIRM_API ir_node *new_r_Mul(ir_node *block, ir_node *op1, ir_node *op2,
2222 /** Constructor for a Mulh node.
2224 * @param *block The IR block the node belongs to.
2225 * @param *op1 The first operand.
2226 * @param *op2 The second operand.
2227 * @param *mode The mode of the operands and the result.
2229 FIRM_API ir_node *new_r_Mulh(ir_node *block, ir_node *op1, ir_node *op2,
2232 /** Constructor for a Quot node.
2234 * @param *block The IR block the node belongs to.
2235 * @param *memop The store needed to model exceptions
2236 * @param *op1 The first operand.
2237 * @param *op2 The second operand.
2238 * @param *mode The mode of the result.
2239 * @param state The pinned state.
2241 FIRM_API ir_node *new_r_Quot(ir_node *block, ir_node *memop,
2242 ir_node *op1, ir_node *op2, ir_mode *mode,
2243 op_pin_state state);
2245 /** Constructor for a DivMod node.
2247 * @param *block The IR block the node belongs to.
2248 * @param *memop The store needed to model exceptions
2249 * @param *op1 The first operand.
2250 * @param *op2 The second operand.
2251 * @param *mode The mode of the results.
2252 * @param state The pinned state.
2254 FIRM_API ir_node *new_r_DivMod(ir_node *block, ir_node *memop,
2255 ir_node *op1, ir_node *op2, ir_mode *mode,
2256 op_pin_state state);
2258 /** Constructor for a Div node.
2260 * @param *block The IR block the node belongs to.
2261 * @param *memop The store needed to model exceptions
2262 * @param *op1 The first operand.
2263 * @param *op2 The second operand.
2264 * @param *mode The mode of the result.
2265 * @param state The pinned state.
2267 FIRM_API ir_node *new_r_Div(ir_node *block, ir_node *memop,
2268 ir_node *op1, ir_node *op2, ir_mode *mode,
2269 op_pin_state state);
2271 /** Constructor for a remainderless Div node.
2273 * @param *block The IR block the node belongs to.
2274 * @param *memop The store needed to model exceptions
2275 * @param *op1 The first operand.
2276 * @param *op2 The second operand.
2277 * @param *mode The mode of the result.
2278 * @param state The pinned state.
2280 FIRM_API ir_node *new_r_DivRL(ir_node *block, ir_node *memop,
2281 ir_node *op1, ir_node *op2, ir_mode *mode,
2282 op_pin_state state);
2284 /** Constructor for a Mod node.
2286 * @param *block The IR block the node belongs to.
2287 * @param *memop The store needed to model exceptions
2288 * @param *op1 The first operand.
2289 * @param *op2 The second operand.
2290 * @param *mode The mode of the result.
2291 * @param state The pinned state.
2293 FIRM_API ir_node *new_r_Mod(ir_node *block, ir_node *memop,
2294 ir_node *op1, ir_node *op2, ir_mode *mode,
2295 op_pin_state state);
2297 /** Constructor for a And node.
2299 * @param *block The IR block the node belongs to.
2300 * @param *op1 The first operand.
2301 * @param *op2 The second operand.
2302 * @param *mode The mode of the operands and the result.
2304 FIRM_API ir_node *new_r_And(ir_node *block, ir_node *op1, ir_node *op2,
2307 /** Constructor for a Or node.
2309 * @param *block The IR block the node belongs to.
2310 * @param *op1 The first operand.
2311 * @param *op2 The second operand.
2312 * @param *mode The mode of the operands and the result.
2314 FIRM_API ir_node *new_r_Or(ir_node *block, ir_node *op1, ir_node *op2,
2317 /** Constructor for a Eor node.
2319 * @param *block The IR block the node belongs to.
2320 * @param *op1 The first operand.
2321 * @param *op2 The second operand.
2322 * @param *mode The mode of the operands and the results.
2324 FIRM_API ir_node *new_r_Eor(ir_node *block, ir_node *op1, ir_node *op2,
2327 /** Constructor for a Not node.
2329 * @param *block The IR block the node belongs to.
2330 * @param *op The operand.
2331 * @param *mode The mode of the operand and the result.
2333 FIRM_API ir_node *new_r_Not(ir_node *block, ir_node *op, ir_mode *mode);
2335 /** Constructor for a Cmp node.
2337 * @param *block The IR block the node belongs to.
2338 * @param *op1 The first operand.
2339 * @param *op2 The second operand.
2341 FIRM_API ir_node *new_r_Cmp(ir_node *block, ir_node *op1, ir_node *op2);
2343 /** Constructor for a Shl node.
2345 * @param *block The IR block the node belongs to.
2346 * @param *op The operand.
2347 * @param *k The number of bits to shift the operand .
2348 * @param *mode The mode of the operand and the result.
2350 FIRM_API ir_node *new_r_Shl(ir_node *block, ir_node *op, ir_node *k,
2353 /** Constructor for a Shr node.
2355 * @param *block The IR block the node belongs to.
2356 * @param *op The operand.
2357 * @param *k The number of bits to shift the operand .
2358 * @param *mode The mode of the operand and the result.
2360 FIRM_API ir_node *new_r_Shr(ir_node *block, ir_node *op, ir_node *k,
2364 * Constructor for a Shrs node.
2366 * @param *block The IR block the node belongs to.
2367 * @param *op The operand.
2368 * @param *k The number of bits to shift the operand.
2369 * @param *mode The mode of the operand and the result.
2371 FIRM_API ir_node *new_r_Shrs(ir_node *block, ir_node *op, ir_node *k,
2374 /** Constructor for a Rotl node.
2376 * @param *block The IR block the node belongs to.
2377 * @param *op The operand.
2378 * @param *k The number of bits to rotate the operand.
2379 * @param *mode The mode of the operand.
2381 FIRM_API ir_node *new_r_Rotl(ir_node *block, ir_node *op, ir_node *k,
2384 /** Constructor for a Conv node.
2386 * @param *block The IR block the node belongs to.
2387 * @param *op The operand.
2388 * @param *mode The mode of this the operand muss be converted .
2390 FIRM_API ir_node *new_r_Conv(ir_node *block, ir_node *op, ir_mode *mode);
2392 /** Constructor for a strict Conv node.
2394 * @param *block The IR block the node belongs to.
2395 * @param *op The operand.
2396 * @param *mode The mode of this the operand muss be converted .
2398 FIRM_API ir_node *new_r_strictConv(ir_node *block, ir_node *op, ir_mode *mode);
2400 /** Constructor for a Cast node.
2402 * High level type cast
2404 * @param *block The IR block the node belongs to.
2405 * @param *op The operand.
2406 * @param *to_tp The type of this the operand muss be casted .
2408 FIRM_API ir_node *new_r_Cast(ir_node *block, ir_node *op, ir_type *to_tp);
2410 /** Constructor for a Carry node.
2412 * @param *block The IR block the node belongs to.
2413 * @param *op1 The first operand.
2414 * @param *op2 The second operand.
2415 * @param *mode The mode of the operands and the result.
2417 FIRM_API ir_node *new_r_Carry(ir_node *block, ir_node *op1, ir_node *op2,
2421 * Constructor for a Borrow node.
2423 * @param *block The IR block the node belongs to.
2424 * @param *op1 The first operand.
2425 * @param *op2 The second operand.
2426 * @param *mode The mode of the operands and the results.
2428 FIRM_API ir_node *new_r_Borrow(ir_node *block, ir_node *op1, ir_node *op2,
2431 /** Constructor for a Phi node.
2433 * @param *block The IR block the node belongs to.
2434 * @param arity The number of predecessors
2435 * @param *in[] Array with predecessors. The constructor copies this array.
2436 * @param *mode The mode of it's inputs and output.
2438 FIRM_API ir_node *new_r_Phi(ir_node *block, int arity, ir_node *in[],
2441 /** Constructor for a Load node.
2443 * @param *block The IR block the node belongs to.
2444 * @param *store The current memory
2445 * @param *adr A pointer to the variable to be read in this memory.
2446 * @param *mode The mode of the value to be loaded.
2447 * @param flags Additional flags for alignment, volatility and pin state.
2449 FIRM_API ir_node *new_r_Load(ir_node *block, ir_node *store,
2450 ir_node *adr, ir_mode *mode, ir_cons_flags flags);
2452 /** Constructor for a Store node.
2454 * @param *block The IR block the node belongs to.
2455 * @param *store The current memory
2456 * @param *adr A pointer to the variable to be read in this memory.
2457 * @param *val The value to write to this variable.
2458 * @param flags Additional flags for alignment, volatility and pin state.
2460 FIRM_API ir_node *new_r_Store(ir_node *block, ir_node *store,
2461 ir_node *adr, ir_node *val, ir_cons_flags flags);
2463 /** Constructor for a Alloc node.
2465 * The Alloc node extends the memory by space for an entity of type alloc_type.
2467 * @param *block The IR block the node belongs to.
2468 * @param *store The memory which shall contain the new variable.
2469 * @param *count The number of objects to allocate.
2470 * @param *alloc_type The type of the allocated variable.
2471 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2473 FIRM_API ir_node *new_r_Alloc(ir_node *block, ir_node *store,
2474 ir_node *count, ir_type *alloc_type,
2475 ir_where_alloc where);
2477 /** Constructor for a Free node.
2479 * Frees the memory occupied by the entity pointed to by the pointer
2480 * arg. Type indicates the type of the entity the argument points to.
2482 * @param *block The IR block the node belongs to.
2483 * @param *store The memory which shall contain the new variable.
2484 * @param *ptr The pointer to the object to free.
2485 * @param *size The number of objects of type free_type to free in a sequence.
2486 * @param *free_type The type of the freed variable.
2487 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2489 FIRM_API ir_node *new_r_Free(ir_node *block, ir_node *store, ir_node *ptr,
2490 ir_node *size, ir_type *free_type,
2491 ir_where_alloc where);
2493 /** Constructor for a Sync node.
2495 * Merges several memory values. The node assumes that a variable
2496 * either occurs only in one of the memories, or it contains the same
2497 * value in all memories where it occurs.
2499 * @param *block The IR block the node belongs to.
2500 * @param arity The number of memories to synchronize.
2501 * @param *in[] An array of pointers to nodes that produce an output of type memory.
2502 * The constructor copies this array.
2504 FIRM_API ir_node *new_r_Sync(ir_node *block, int arity, ir_node *in[]);
2506 /** Constructor for a Proj node.
2508 * Projects a single value out of a tuple. The parameter proj gives the
2509 * position of the value within the tuple.
2511 * @param arg A node producing a tuple.
2512 * @param mode The mode of the value to project.
2513 * @param proj The position of the value in the tuple.
2515 FIRM_API ir_node *new_r_Proj(ir_node *arg, ir_mode *mode, long proj);
2517 /** Constructor for a defaultProj node.
2519 * Represents the default control flow of a Switch-Cond node.
2521 * @param arg A node producing a tuple.
2522 * @param max_proj The end position of the value in the tuple.
2524 FIRM_API ir_node *new_r_defaultProj(ir_node *arg, long max_proj);
2527 /** Constructor for a Tuple node.
2529 * This is an auxiliary node to replace a node that returns a tuple
2530 * without changing the corresponding Proj nodes.
2532 * @param *block The IR block the node belongs to.
2533 * @param arity The number of tuple elements.
2534 * @param *in[] An array containing pointers to the nodes producing the tuple elements.
2535 * The constructor copies this array.
2537 FIRM_API ir_node *new_r_Tuple(ir_node *block, int arity, ir_node *in[]);
2539 /** Constructor for a Id node.
2541 * This is an auxiliary node to replace a node that returns a single
2544 * @param *block The IR block the node belongs to.
2545 * @param *val The operand to Id.
2546 * @param *mode The mode of *val.
2548 FIRM_API ir_node *new_r_Id(ir_node *block, ir_node *val, ir_mode *mode);
2550 /** Constructor for a Bad node.
2552 * Returns the unique Bad node of the graph. The same as
2555 * @param *irg The IR graph the node belongs to.
2557 FIRM_API ir_node *new_r_Bad(ir_graph *irg);
2559 /** Constructor for a Confirm node.
2561 * Specifies constraints for a value. To support dataflow analyses.
2563 * Example: If the value never exceeds '100' this is expressed by placing a
2564 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
2566 * @param *block The IR block the node belong to.
2567 * @param *val The value we express a constraint for
2568 * @param *bound The value to compare against. Must be a firm node, typically a constant.
2569 * @param cmp The compare operation.
2571 FIRM_API ir_node *new_r_Confirm(ir_node *block, ir_node *val, ir_node *bound,
2574 /** Constructor for a Unknown node.
2576 * Represents an arbitrary value. Places the node in
2579 * @param *irg The IR graph the node belongs to.
2580 * @param *m The mode of the unknown value.
2582 FIRM_API ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2584 /** Constructor for a NoMem node.
2586 * Returns the unique NoMem node of the graph. The same as
2589 * @param *irg The IR graph the node belongs to.
2591 FIRM_API ir_node *new_r_NoMem(ir_graph *irg);
2593 /** Constructor for a Mux node.
2595 * @param *block The block the node belong to.
2596 * @param *sel The ir_node that calculates the boolean select.
2597 * @param *ir_true The ir_node that calculates the true result.
2598 * @param *ir_false The ir_node that calculates the false result.
2599 * @param *mode The mode of the node (and it_true and ir_false).
2601 FIRM_API ir_node *new_r_Mux(ir_node *block, ir_node *sel,
2602 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2604 /** Constructor for a CopyB node.
2606 * @param *block The block the node belong to.
2607 * @param *store The current memory
2608 * @param *dst The ir_node that represents the destination address.
2609 * @param *src The ir_node that represents the source address.
2610 * @param *data_type The type of the copied data
2612 FIRM_API ir_node *new_r_CopyB(ir_node *block, ir_node *store,
2613 ir_node *dst, ir_node *src, ir_type *data_type);
2615 /** Constructor for a InstOf node.
2617 * A High-Level Type check.
2619 * @param *block The block the node belong to.
2620 * @param *store The memory in which the object the entity should be selected
2621 * from is allocated.
2622 * @param *objptr A pointer to a object of a class type.
2623 * @param *type The type of which objptr must be.
2625 FIRM_API ir_node *new_r_InstOf(ir_node *block, ir_node *store,
2626 ir_node *objptr, ir_type *type);
2628 /** Constructor for a Raise node.
2630 * A High-Level Exception throw.
2632 * @param *block The IR block the node belongs to.
2633 * @param *store The current memory.
2634 * @param *obj A pointer to the Except variable.
2636 FIRM_API ir_node *new_r_Raise(ir_node *block, ir_node *store, ir_node *obj);
2638 /** Constructor for a Bound node.
2640 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
2642 * @param *block The block the node belong to.
2643 * @param *store The current memory.
2644 * @param *idx The ir_node that represents an index.
2645 * @param *lower The ir_node that represents the lower bound for the index.
2646 * @param *upper The ir_node that represents the upper bound for the index.
2648 FIRM_API ir_node *new_r_Bound(ir_node *block, ir_node *store,
2649 ir_node *idx, ir_node *lower, ir_node *upper);
2651 /** Constructor for a Pin node.
2653 * @param *block The block the node belong to.
2654 * @param *node The node which value should be pinned.
2656 FIRM_API ir_node *new_r_Pin(ir_node *block, ir_node *node);
2658 /** Constructor for an ASM pseudo node.
2660 * @param *block The block the node belong to.
2661 * @param arity The number of data inputs to the node.
2662 * @param *in The array of length arity of data inputs.
2663 * @param *inputs The array of length arity of input constraints.
2664 * @param n_outs The number of data outputs to the node.
2665 * @param *outputs The array of length n_outs of output constraints.
2666 * @param n_clobber The number of clobbered registers.
2667 * @param *clobber The array of length n_clobber of clobbered registers.
2668 * @param *asm_text The assembler text.
2670 FIRM_API ir_node *new_r_ASM(ir_node *block,
2671 int arity, ir_node *in[], ir_asm_constraint *inputs,
2672 int n_outs, ir_asm_constraint *outputs,
2673 int n_clobber, ident *clobber[], ident *asm_text);
2675 /*-----------------------------------------------------------------------*/
2676 /* The block oriented interface */
2677 /*-----------------------------------------------------------------------*/
2679 /** Sets the current block in which the following constructors place the
2680 * nodes they construct.
2682 * @param target The new current block.
2684 FIRM_API void set_cur_block(ir_node *target);
2686 /** Returns the current block of the current graph. */
2687 FIRM_API ir_node *get_cur_block(void);
2689 /** Constructor for a Block node.
2691 * Adds the block to the graph in current_ir_graph. Constructs a Block
2692 * with a fixed number of predecessors.
2694 * @param *db A Pointer for debug information.
2695 * @param arity The number of control predecessors.
2696 * @param in[] An array of control predecessors. The length of
2697 * the array must be 'arity'.
2699 FIRM_API ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
2701 /** Constructor for a Start node.
2703 * Adds the node to the block in current_ir_block.
2705 * @param *db A pointer for debug information.
2707 FIRM_API ir_node *new_d_Start(dbg_info *db);
2709 /** Constructor for a End node.
2711 * Adds the node to the block in current_ir_block.
2713 * @param *db A pointer for debug information.
2715 FIRM_API ir_node *new_d_End(dbg_info *db);
2717 /** Constructor for a Jmp node.
2719 * Adds the node to the block in current_ir_block.
2721 * Jmp represents control flow to a single control successor.
2723 * @param *db A pointer for debug information.
2725 FIRM_API ir_node *new_d_Jmp(dbg_info *db);
2727 /** Constructor for an IJmp node.
2729 * IJmp represents control flow to a single control successor not
2730 * statically known i.e. an indirect Jmp.
2732 * @param *db A pointer for debug information.
2733 * @param *tgt The IR node representing the target address.
2735 FIRM_API ir_node *new_d_IJmp(dbg_info *db, ir_node *tgt);
2737 /** Constructor for a Cond node.
2739 * Adds the node to the block in current_ir_block.
2741 * If c is mode_b represents a conditional branch (if/else). If c is
2742 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2743 * node, default Proj is 0.)
2745 * This is not consistent: Input to Cond is Is, Proj has as proj number
2748 * @param *db A pointer for debug information.
2749 * @param *c The conditions parameter.Can be of mode b or I_u.
2751 FIRM_API ir_node *new_d_Cond(dbg_info *db, ir_node *c);
2753 /** Constructor for a Return node.
2755 * Adds the node to the block in current_ir_block.
2757 * Returns the memory and zero or more return values. Only node that
2758 * can end regular control flow.
2760 * @param *db A pointer for debug information.
2761 * @param *store The state of memory.
2762 * @param arity Number of array indices.
2763 * @param *in Array with index inputs to the node.
2765 FIRM_API ir_node *new_d_Return(dbg_info *db, ir_node *store,
2766 int arity, ir_node *in[]);
2768 /** Constructor for a Const_type node.
2770 * Adds the node to the start block.
2772 * The constant represents a target value. This constructor sets high
2773 * level type information for the constant value.
2774 * Derives mode from passed tarval.
2776 * @param *db A pointer for debug information.
2777 * @param *con Points to an entry in the constant table. This pointer is
2778 added to the attributes of the node.
2779 * @param *tp The type of the constant.
2781 FIRM_API ir_node *new_d_Const_type(dbg_info *db, tarval *con, ir_type *tp);
2783 /** Constructor for a Const node.
2785 * Adds the node to the block in current_ir_block.
2787 * Constructor for a Const node. The constant represents a target
2788 * value. Sets the type information to type_unknown. (No more
2789 * supported: If tv is entity derives a somehow useful type.)
2790 * Derives mode from passed tarval.
2792 * @param *db A pointer for debug information.
2793 * @param *con Points to an entry in the constant table. This pointer is added
2794 * to the attributes of the node.
2796 FIRM_API ir_node *new_d_Const(dbg_info *db, tarval *con);
2799 * @see new_rd_Const_long()
2801 * @param *db A pointer for debug information.
2802 * @param *mode The mode of the operands and results.
2803 * @param value A value from which the tarval is made.
2805 FIRM_API ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value);
2807 /** Constructor for a SymConst_type node.
2809 * This is the constructor for a symbolic constant.
2810 * There are several kinds of symbolic constants:
2811 * - symconst_type_tag The symbolic constant represents a type tag. The
2812 * type the tag stands for is given explicitly.
2813 * - symconst_type_size The symbolic constant represents the size of a type.
2814 * The type of which the constant represents the size
2815 * is given explicitly.
2816 * - symconst_type_align The symbolic constant represents the alignment of a
2817 * type. The type of which the constant represents the
2818 * size is given explicitly.
2819 * - symconst_addr_ent The symbolic constant represents the address of an
2820 * entity (variable or method). The variable is given
2821 * explicitly by a firm entity.
2822 * - symconst_ofs_ent The symbolic constant represents the offset of an
2823 * entity in its owner type.
2824 * - symconst_enum_const The symbolic constant is a enumeration constant of
2825 * an enumeration type.
2827 * Inputs to the node:
2828 * No inputs except the block it belongs to.
2829 * Outputs of the node.
2830 * An unsigned integer (I_u) or a pointer (P).
2832 * Mention union in declaration so that the firmjni generator recognizes that
2833 * it can not cast the argument to an int.
2835 * @param *db A pointer for debug information.
2836 * @param mode The mode for the SymConst.
2837 * @param value A type, ident, entity or enum constant depending on the
2839 * @param kind The kind of the symbolic constant, see the list above
2840 * @param tp The source type of the constant.
2842 FIRM_API ir_node *new_d_SymConst_type(dbg_info *db, ir_mode *mode,
2843 union symconst_symbol value,
2844 symconst_kind kind, ir_type *tp);
2846 /** Constructor for a SymConst node.
2848 * Same as new_d_SymConst_type, except that it sets the type to type_unknown.
2850 FIRM_API ir_node *new_d_SymConst(dbg_info *db, ir_mode *mode,
2851 union symconst_symbol value,
2852 symconst_kind kind);
2854 /** Constructor for a simpleSel node.
2856 * This is a shortcut for the new_d_Sel() constructor. To be used for
2857 * Sel nodes that do not select from an array, i.e., have no index
2858 * inputs. It adds the two parameters 0, NULL.
2860 * @param *db A pointer for debug information.
2861 * @param *store The memory in which the object the entity should be
2862 * selected from is allocated.
2863 * @param *objptr The object from that the Sel operation selects a
2864 * single attribute out.
2865 * @param *ent The entity to select.
2867 FIRM_API ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr,
2870 /** Constructor for a Sel node.
2872 * The select node selects an entity (field or method) from an entity
2873 * with a compound type. It explicitly specifies the entity selected.
2874 * Dynamically the node may select entities that overwrite the given
2875 * entity. If the selected entity is an array element entity the Sel
2876 * node takes the required array indices as inputs.
2877 * Adds the node to the block in current_ir_block.
2879 * @param *db A pointer for debug information.
2880 * @param *store The memory in which the object the entity should be selected
2881 * from is allocated.
2882 * @param *objptr A pointer to a compound entity the Sel operation selects a
2883 * single attribute from.
2884 * @param arity The number of array indices needed to select an array element entity.
2885 * @param *in[] If the compound entity is an array the indices of the selected
2886 * element entity. The constructor copies this array.
2887 * @param *ent The entity to select.
2889 FIRM_API ir_node *new_d_Sel(dbg_info *db, ir_node *store, ir_node *objptr,
2890 int arity, ir_node *in[], ir_entity *ent);
2892 /** Constructor for a Call node.
2894 * Represents all kinds of method and function calls.
2895 * Adds the node to the block in current_ir_block.
2897 * @param *db A pointer for debug information.
2898 * @param *store The actual store.
2899 * @param *callee A pointer to the called procedure.
2900 * @param arity The number of procedure parameters.
2901 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2902 * @param *tp Type information of the procedure called.
2904 FIRM_API ir_node *new_d_Call(dbg_info *db, ir_node *store, ir_node *callee,
2905 int arity, ir_node *in[], ir_type *tp);
2907 /** Constructor for a Builtin node.
2909 * Represents a call of a backend-specific builtin..
2910 * Adds the node to the block in current_ir_block.
2912 * @param *db A pointer for debug information.
2913 * @param *store The actual store.
2914 * @param arity The number of procedure parameters.
2915 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2916 * @param kind The kind of the called builtin.
2917 * @param *tp Type information of the procedure called.
2919 FIRM_API ir_node *new_d_Builtin(dbg_info *db, ir_node *store,
2920 int arity, ir_node *in[],
2921 ir_builtin_kind kind, ir_type *tp);
2923 /** Constructor for a Add node.
2925 * Adds the node to the block in current_ir_block.
2927 * @param *db A pointer for debug information.
2928 * @param *op1 The first operand.
2929 * @param *op2 The second operand.
2930 * @param *mode The mode of the operands and the result.
2932 FIRM_API ir_node *new_d_Add(dbg_info *db, ir_node *op1, ir_node *op2,
2935 /** Constructor for a Sub node.
2937 * Adds the node to the block in current_ir_block.
2939 * @param *db A pointer for debug information.
2940 * @param *op1 The first operand.
2941 * @param *op2 The second operand.
2942 * @param *mode The mode of the operands and the result.
2944 FIRM_API ir_node *new_d_Sub(dbg_info *db, ir_node *op1, ir_node *op2,
2947 /** Constructor for a Minus node.
2949 * Adds the node to the block in current_ir_block.
2951 * @param *db A pointer for debug information.
2952 * @param *op The operand .
2953 * @param *mode The mode of the operand and the result.
2955 FIRM_API ir_node *new_d_Minus(dbg_info *db, ir_node *op, ir_mode *mode);
2957 /** Constructor for a Mul node.
2959 * Adds the node to the block in current_ir_block.
2961 * @param *db A pointer for debug information.
2962 * @param *op1 The first operand.
2963 * @param *op2 The second operand.
2964 * @param *mode The mode of the operands and the result.
2966 FIRM_API ir_node *new_d_Mul(dbg_info *db, ir_node *op1, ir_node *op2,
2969 /** Constructor for a Mulh node.
2971 * Adds the node to the block in current_ir_block.
2973 * @param *db A pointer for debug information.
2974 * @param *op1 The first operand.
2975 * @param *op2 The second operand.
2976 * @param *mode The mode of the operands and the result.
2978 FIRM_API ir_node *new_d_Mulh(dbg_info *db, ir_node *op1, ir_node *op2,
2981 /** Constructor for a Quot node.
2983 * Adds the node to the block in current_ir_block.
2985 * @param *db A pointer for debug information.
2986 * @param *memop The store needed to model exceptions
2987 * @param *op1 The first operand.
2988 * @param *op2 The second operand.
2989 * @param *mode The mode of the result.
2990 * @param state The pinned state.
2992 FIRM_API ir_node *new_d_Quot(dbg_info *db, ir_node *memop,
2993 ir_node *op1, ir_node *op2, ir_mode *mode,
2994 op_pin_state state);
2996 /** Constructor for a DivMod node.
2998 * Adds the node to the block in current_ir_block.
3000 * @param *db A pointer for debug information.
3001 * @param *memop The store needed to model exceptions
3002 * @param *op1 The first operand.
3003 * @param *op2 The second operand.
3004 * @param *mode The mode of the results.
3005 * @param state The pinned state.
3007 FIRM_API ir_node *new_d_DivMod(dbg_info *db, ir_node *memop, ir_node *op1,
3008 ir_node *op2, ir_mode *mode, op_pin_state state);
3010 /** Constructor for a Div node.
3012 * Adds the node to the block in current_ir_block.
3014 * @param *db A pointer for debug information.
3015 * @param *memop The store needed to model exceptions
3016 * @param *op1 The first operand.
3017 * @param *op2 The second operand.
3018 * @param *mode The mode of the result.
3019 * @param state The pinned state.
3021 FIRM_API ir_node *new_d_Div(dbg_info *db, ir_node *memop, ir_node *op1,
3022 ir_node *op2, ir_mode *mode, op_pin_state state);
3024 /** Constructor for a remainderless Div node.
3026 * Adds the node to the block in current_ir_block.
3028 * @param *db A pointer for debug information.
3029 * @param *memop The store needed to model exceptions
3030 * @param *op1 The first operand.
3031 * @param *op2 The second operand.
3032 * @param *mode The mode of the result.
3033 * @param state The pinned state.
3035 FIRM_API ir_node *new_d_DivRL(dbg_info *db, ir_node *memop,
3036 ir_node *op1, ir_node *op2, ir_mode *mode,
3037 op_pin_state state);
3039 /** Constructor for a Mod node.
3041 * Adds the node to the block in current_ir_block.
3043 * @param *db A pointer for debug information.
3044 * @param *memop The store needed to model exceptions
3045 * @param *op1 The first operand.
3046 * @param *op2 The second operand.
3047 * @param *mode The mode of the result.
3048 * @param state The pinned state.
3050 FIRM_API ir_node *new_d_Mod(dbg_info *db, ir_node *memop,
3051 ir_node *op1, ir_node *op2, ir_mode *mode,
3052 op_pin_state state);
3054 /** Constructor for a And node.
3056 * Adds the node to the block in current_ir_block.
3058 * @param *db A pointer for debug information.
3059 * @param *op1 The first operand.
3060 * @param *op2 The second operand.
3061 * @param *mode The mode of the operands and the result.
3063 FIRM_API ir_node *new_d_And(dbg_info *db, ir_node *op1, ir_node *op2,
3066 /** Constructor for a Or node.
3068 * Adds the node to the block in current_ir_block.
3070 * @param *db A pointer for debug information.
3071 * @param *op1 The first operand.
3072 * @param *op2 The second operand.
3073 * @param *mode The mode of the operands and the result.
3075 FIRM_API ir_node *new_d_Or(dbg_info *db, ir_node *op1, ir_node *op2,
3078 /** Constructor for a Eor node.
3080 * Adds the node to the block in current_ir_block.
3082 * @param *db A pointer for debug information.
3083 * @param *op1 The first operand.
3084 * @param *op2 The second operand.
3085 * @param *mode The mode of the operands and the results.
3087 FIRM_API ir_node *new_d_Eor(dbg_info *db, ir_node *op1, ir_node *op2,
3090 /** Constructor for a Not node.
3092 * Adds the node to the block in current_ir_block.
3094 * @param *db A pointer for debug information.
3095 * @param *op The operand.
3096 * @param *mode The mode of the operand and the result.
3098 FIRM_API ir_node *new_d_Not(dbg_info *db, ir_node *op, ir_mode *mode);
3100 /** Constructor for a Shl node.
3102 * Adds the node to the block in current_ir_block.
3104 * @param *db A pointer for debug information.
3105 * @param *op The operand.
3106 * @param *k The number of bits to shift the operand .
3107 * @param *mode The mode of the operand and the result.
3109 FIRM_API ir_node *new_d_Shl(dbg_info *db, ir_node *op, ir_node *k,
3112 /** Constructor for a Shr node.
3114 * Adds the node to the block in current_ir_block.
3116 * @param *db A pointer for debug information.
3117 * @param *op The operand.
3118 * @param *k The number of bits to shift the operand .
3119 * @param *mode The mode of the operand and the result.
3121 FIRM_API ir_node *new_d_Shr(dbg_info *db, ir_node *op, ir_node *k,
3124 /** Constructor for a Shrs node.
3126 * Adds the node to the block in current_ir_block.
3128 * @param *db A pointer for debug information.
3129 * @param *op The operand.
3130 * @param *k The number of bits to shift the operand .
3131 * @param *mode The mode of the operand and the result.
3133 FIRM_API ir_node *new_d_Shrs(dbg_info *db, ir_node *op, ir_node *k,
3136 /** Constructor for a Rotl node.
3138 * Adds the node to the block in current_ir_block.
3140 * @param *db A pointer for debug information.
3141 * @param *op The operand.
3142 * @param *k The number of bits to rotate the operand.
3143 * @param *mode The mode of the operand.
3145 FIRM_API ir_node *new_d_Rotl(dbg_info *db, ir_node *op, ir_node *k,
3148 /** Constructor for a Cmp node.
3150 * Adds the node to the block in current_ir_block.
3152 * @param *db A pointer for debug information.
3153 * @param *op1 The first operand.
3154 * @param *op2 The second operand.
3156 FIRM_API ir_node *new_d_Cmp(dbg_info *db, ir_node *op1, ir_node *op2);
3158 /** Constructor for a Conv node.
3160 * Adds the node to the block in current_ir_block.
3162 * @param *db A pointer for debug information.
3163 * @param *op The operand.
3164 * @param *mode The mode of this the operand muss be converted .
3166 FIRM_API ir_node *new_d_Conv(dbg_info *db, ir_node *op, ir_mode *mode);
3168 /** Constructor for a strict Conv node.
3170 * Adds the node to the block in current_ir_block.
3172 * @param *db A pointer for debug information.
3173 * @param *op The operand.
3174 * @param *mode The mode of this the operand muss be converted .
3176 FIRM_API ir_node *new_d_strictConv(dbg_info *db, ir_node *op, ir_mode *mode);
3178 /** Constructor for a Cast node.
3180 * High level type cast
3181 * Adds the node to the block in current_ir_block.
3183 * @param *db A pointer for debug information.
3184 * @param *op The operand.
3185 * @param *to_tp The type of this the operand muss be casted .
3187 FIRM_API ir_node *new_d_Cast(dbg_info *db, ir_node *op, ir_type *to_tp);
3189 /** Constructor for a Carry node.
3191 * Adds the node to the block in current_ir_block.
3193 * @param *db A pointer for debug information.
3194 * @param *op1 The first operand.
3195 * @param *op2 The second operand.
3196 * @param *mode The mode of the operands and the result.
3198 FIRM_API ir_node *new_d_Carry(dbg_info *db, ir_node *op1, ir_node *op2,
3201 /** Constructor for a Borrow node.
3203 * Adds the node to the block in current_ir_block.
3205 * @param *db A pointer for debug information.
3206 * @param *op1 The first operand.
3207 * @param *op2 The second operand.
3208 * @param *mode The mode of the operands and the result.
3210 FIRM_API ir_node *new_d_Borrow(dbg_info *db, ir_node *op1, ir_node *op2,
3213 /** Constructor for a Phi node.
3215 * Adds the node to the block in current_ir_block.
3217 * @param *db A pointer for debug information.
3218 * @param arity The number of predecessors
3219 * @param *in Array with predecessors
3220 * @param *mode The mode of it's inputs and output.
3222 FIRM_API ir_node *new_d_Phi(dbg_info *db, int arity, ir_node *in[],
3225 /** Constructor for a Load node.
3227 * Adds the node to the block in current_ir_block.
3229 * @param *db A pointer for debug information.
3230 * @param *store The current memory
3231 * @param *addr A pointer to the variable to be read in this memory.
3232 * @param *mode The mode of the value to be loaded.
3233 * @param flags Additional flags for alignment, volatility and pin state.
3235 FIRM_API ir_node *new_d_Load(dbg_info *db, ir_node *store, ir_node *addr,
3236 ir_mode *mode, ir_cons_flags flags);
3238 /** Constructor for a Store node.
3240 * Adds the node to the block in current_ir_block.
3242 * @param *db A pointer for debug information.
3243 * @param *store The current memory
3244 * @param *addr A pointer to the variable to be read in this memory.
3245 * @param *val The value to write to this variable.
3246 * @param flags Additional flags for alignment, volatility and pin state.
3248 FIRM_API ir_node *new_d_Store(dbg_info *db, ir_node *store, ir_node *addr,
3249 ir_node *val, ir_cons_flags flags);
3251 /** Constructor for a Alloc node.
3253 * The Alloc node extends the memory by space for an entity of type alloc_type.
3254 * Adds the node to the block in current_ir_block.
3256 * @param *db A pointer for debug information.
3257 * @param *store The memory which shall contain the new variable.
3258 * @param *count The number of objects to allocate.
3259 * @param *alloc_type The type of the allocated variable.
3260 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3262 FIRM_API ir_node *new_d_Alloc(dbg_info *db, ir_node *store, ir_node *count,
3263 ir_type *alloc_type, ir_where_alloc where);
3265 /** Constructor for a Free node.
3267 * Frees the memory occupied by the entity pointed to by the pointer
3268 * arg. Type indicates the type of the entity the argument points to.
3269 * Adds the node to the block in current_ir_block.
3271 * @param *db A pointer for debug information.
3272 * @param *store The memory which shall contain the new variable.
3273 * @param *ptr The pointer to the object to free.
3274 * @param *size The number of objects of type free_type to free in a sequence.
3275 * @param *free_type The type of the freed variable.
3276 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3278 FIRM_API ir_node *new_d_Free(dbg_info *db, ir_node *store, ir_node *ptr,
3279 ir_node *size, ir_type *free_type,
3280 ir_where_alloc where);
3282 /** Constructor for a Sync node.
3284 * Merges several memory values. The node assumes that a variable
3285 * either occurs only in one of the memories, or it contains the same
3286 * value in all memories where it occurs.
3287 * Adds the node to the block in current_ir_block.
3289 * @param *db A pointer for debug information.
3290 * @param arity The number of memories to synchronize.
3291 * @param **in An array of pointers to nodes that produce an output of type
3292 * memory. The constructor copies this array.
3294 FIRM_API ir_node *new_d_Sync(dbg_info *db, int arity, ir_node *in[]);
3296 /** Constructor for a Proj node.
3298 * Projects a single value out of a tuple. The parameter proj gives the
3299 * position of the value within the tuple.
3300 * Adds the node to the block in current_ir_block.
3302 * @param *db A pointer for deubug information.
3303 * @param arg A node producing a tuple.
3304 * @param *mode The mode of the value to project.
3305 * @param proj The position of the value in the tuple.
3307 FIRM_API ir_node *new_d_Proj(dbg_info *db, ir_node *arg, ir_mode *mode,
3310 /** Constructor for a defaultProj node.
3312 * Represents the default control flow of a Switch-Cond node.
3313 * Adds the node to the block in current_ir_block.
3315 * @param *db A pointer for debug information.
3316 * @param arg A node producing a tuple.
3317 * @param max_proj The end position of the value in the tuple.
3319 FIRM_API ir_node *new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
3321 /** Constructor for a Tuple node.
3323 * This is an auxiliary node to replace a node that returns a tuple
3324 * without changing the corresponding Proj nodes.
3325 * Adds the node to the block in current_ir_block.
3327 * @param *db A pointer for debug information.
3328 * @param arity The number of tuple elements.
3329 * @param **in An array containing pointers to the nodes producing the tuple elements.
3331 FIRM_API ir_node *new_d_Tuple(dbg_info *db, int arity, ir_node *in[]);
3333 /** Constructor for a Id node.
3335 * This is an auxiliary node to replace a node that returns a single
3336 * value. Adds the node to the block in current_ir_block.
3338 * @param *db A pointer for debug information.
3339 * @param *val The operand to Id.
3340 * @param *mode The mode of *val.
3342 FIRM_API ir_node *new_d_Id(dbg_info *db, ir_node *val, ir_mode *mode);
3344 /** Constructor for a Confirm node.
3346 * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3347 * Specifies constraints for a value. To support dataflow analyses.
3349 * Example: If the value never exceeds '100' this is expressed by placing a
3350 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
3352 * @param *db A pointer for debug information.
3353 * @param *val The value we express a constraint for
3354 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3355 * @param cmp The compare operation.
3357 FIRM_API ir_node *new_d_Confirm(dbg_info *db, ir_node *val, ir_node *bound,
3360 /** Constructor for an Unknown node.
3362 * Represents an arbitrary value. Places the node in
3365 * @param *db A pointer for debug information.
3366 * @param *m The mode of the unknown value.
3368 FIRM_API ir_node *new_d_Unknown(dbg_info *db, ir_mode *m);
3370 /** Constructor for a Mux node.
3372 * @param *db A pointer for debug information.
3373 * @param *sel The ir_node that calculates the boolean select.
3374 * @param *ir_true The ir_node that calculates the true result.
3375 * @param *ir_false The ir_node that calculates the false result.
3376 * @param *mode The mode of the node (and it_true and ir_false).
3378 FIRM_API ir_node *new_d_Mux(dbg_info *db, ir_node *sel,
3379 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3381 /** Constructor for a CopyB node.
3383 * @param *db A pointer for debug information.
3384 * @param *store The current memory
3385 * @param *dst The ir_node that represents the destination address.
3386 * @param *src The ir_node that represents the source address.
3387 * @param *data_type The type of the copied data
3389 FIRM_API ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst,
3390 ir_node *src, ir_type *data_type);
3392 /** Constructor for a InstOf node.
3394 * A High-Level Type check.
3396 * @param *db A pointer for debug information.
3397 * @param *store The memory in which the object the entity should be selected
3398 * from is allocated.
3399 * @param *objptr A pointer to a object of a class type.
3400 * @param *type The type of which objptr must be.
3402 FIRM_API ir_node *new_d_InstOf(dbg_info *db, ir_node *store, ir_node *objptr,
3405 /** Constructor for a Raise node.
3407 * A High-Level Exception throw.
3409 * @param *db A pointer for debug information.
3410 * @param *store The current memory.
3411 * @param *obj A pointer to the Except variable.
3413 FIRM_API ir_node *new_d_Raise(dbg_info *db, ir_node *store, ir_node *obj);
3415 /** Constructor for a Bound node.
3417 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
3419 * @param *db A pointer for debug information.
3420 * @param *store The current memory
3421 * @param *idx The ir_node that represents an index.
3422 * @param *lower The ir_node that represents the lower bound for the index.
3423 * @param *upper The ir_node that represents the upper bound for the index.
3425 FIRM_API ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx,
3426 ir_node *lower, ir_node *upper);
3428 /** Constructor for a Pin node.
3430 * @param *db A pointer for debug information.
3431 * @param *node The node which value should be pinned.
3433 FIRM_API ir_node *new_d_Pin(dbg_info *db, ir_node *node);
3435 /** Constructor for an ASM pseudo node.
3437 * @param *db A pointer for debug information.
3438 * @param arity The number of data inputs to the node.
3439 * @param *in The array of length arity of data inputs.
3440 * @param *inputs The array of length arity of input constraints.
3441 * @param n_outs The number of data outputs to the node.
3442 * @param *outputs The array of length n_outs of output constraints.
3443 * @param n_clobber The number of clobbered registers.
3444 * @param *clobber The array of length n_clobber of clobbered registers.
3445 * @param *asm_text The assembler text.
3447 FIRM_API ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[],
3448 ir_asm_constraint *inputs,
3449 int n_outs, ir_asm_constraint *outputs,
3450 int n_clobber, ident *clobber[], ident *asm_text);
3452 /*-----------------------------------------------------------------------*/
3453 /* The block oriented interface without debug support */
3454 /*-----------------------------------------------------------------------*/
3456 /** Constructor for a Block node.
3458 * Constructor for a Block node. Adds the block to the graph in
3459 * current_ir_graph. Constructs a Block with a fixed number of predecessors.
3461 * @param arity The number of control predecessors.
3462 * @param in An array of control predecessors. The length of
3463 * the array must be 'arity'.
3465 FIRM_API ir_node *new_Block(int arity, ir_node *in[]);
3467 /** Constructor for a Start node.
3469 * Adds the node to the block in current_ir_block.
3472 FIRM_API ir_node *new_Start(void);
3474 /** Constructor for an End node.
3476 * Adds the node to the block in current_ir_block.
3478 FIRM_API ir_node *new_End(void);
3480 /** Constructor for a Jump node.
3482 * Adds the node to the block in current_ir_block.
3484 * Jmp represents control flow to a single control successor.
3486 FIRM_API ir_node *new_Jmp(void);
3488 /** Constructor for an IJmp node.
3490 * IJmp represents control flow to a single control successor not
3491 * statically known i.e. an indirect Jmp.
3493 * @param *tgt The IR node representing the target address.
3495 FIRM_API ir_node *new_IJmp(ir_node *tgt);
3497 /** Constructor for a Cond node.
3499 * If c is mode_b represents a conditional branch (if/else). If c is
3500 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
3501 * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3503 * This is not consistent: Input to Cond is Is, Proj has as proj number
3507 * @param *c The conditions parameter.Can be of mode b or I_u.
3509 FIRM_API ir_node *new_Cond(ir_node *c);
3511 /** Constructor for a Return node.
3513 * Returns the memory and zero or more return values. Only node that
3514 * can end regular control flow. Adds the node to the block in current_ir_block.
3516 * @param *store The state of memory.
3517 * @param arity Number of array indices.
3518 * @param *in Array with index inputs to the node.
3520 FIRM_API ir_node *new_Return(ir_node *store, int arity, ir_node *in[]);
3522 /** Constructor for a Const node.
3524 * Constructor for a Const node. The constant represents a target
3525 * value. Sets the type information to type_unknown. (No more
3526 * supported: If tv is entity derives a somehow useful type.)
3527 * Adds the node to the block in current_ir_block.
3528 * Derives mode from passed tarval.
3530 * @param *con Points to an entry in the constant table. This pointer is
3531 * added to the attributes of the node.
3533 FIRM_API ir_node *new_Const(tarval *con);
3536 * Make a const from a long.
3537 * This is just convenience for the usual
3539 * new_Const(mode, tarval_from_long(mode, ...))
3542 * @param mode The mode for the const.
3543 * @param value The value of the constant.
3544 * @return A new const node.
3546 FIRM_API ir_node *new_Const_long(ir_mode *mode, long value);
3548 /** Constructor for a Const node.
3550 * Derives mode from passed tarval. */
3551 FIRM_API ir_node *new_Const_type(tarval *con, ir_type *tp);
3553 /** Constructor for a SymConst_type node.
3555 * This is the constructor for a symbolic constant.
3556 * There are several kinds of symbolic constants:
3557 * - symconst_type_tag The symbolic constant represents a type tag. The
3558 * type the tag stands for is given explicitly.
3559 * - symconst_type_size The symbolic constant represents the size of a type.
3560 * The type of which the constant represents the size
3561 * is given explicitly.
3562 * - symconst_type_align The symbolic constant represents the alignment of a
3563 * type. The type of which the constant represents the
3564 * size is given explicitly.
3565 * - symconst_addr_ent The symbolic constant represents the address of an
3566 * entity (variable or method). The variable is given
3567 * explicitly by a firm entity.
3568 * - symconst_ofs_ent The symbolic constant represents the offset of an
3569 * entity in its owner type.
3570 * - symconst_enum_const The symbolic constant is a enumeration constant of
3571 * an enumeration type.
3573 * Inputs to the node:
3574 * No inputs except the block it belongs to.
3575 * Outputs of the node.
3576 * An unsigned integer (I_u) or a pointer (P).
3578 * Mention union in declaration so that the firmjni generator recognizes that
3579 * it can not cast the argument to an int.
3581 * @param mode The mode for the SymConst.
3582 * @param value A type, ident, entity or enum constant depending on the
3584 * @param kind The kind of the symbolic constant, see the list above
3585 * @param tp The source type of the constant.
3587 FIRM_API ir_node *new_SymConst_type(ir_mode *mode, union symconst_symbol value,
3588 symconst_kind kind, ir_type *tp);
3590 /** Constructor for a SymConst node.
3592 * This is the constructor for a symbolic constant.
3593 * There are several kinds of symbolic constants:
3594 * - symconst_type_tag The symbolic constant represents a type tag. The
3595 * type the tag stands for is given explicitly.
3596 * - symconst_type_size The symbolic constant represents the size of a type.
3597 * The type of which the constant represents the size
3598 * is given explicitly.
3599 * - symconst_type_align The symbolic constant represents the alignment of a
3600 * type. The type of which the constant represents the
3601 * size is given explicitly.
3602 * - symconst_addr_ent The symbolic constant represents the address of an
3603 * entity (variable or method). The variable is given
3604 * explicitly by a firm entity.
3605 * - symconst_ofs_ent The symbolic constant represents the offset of an
3606 * entity in its owner type.
3607 * - symconst_enum_const The symbolic constant is a enumeration constant of
3608 * an enumeration type.
3610 * Inputs to the node:
3611 * No inputs except the block it belongs to.
3612 * Outputs of the node.
3613 * An unsigned integer (I_u) or a pointer (P).
3615 * Mention union in declaration so that the firmjni generator recognizes that
3616 * it can not cast the argument to an int.
3618 * @param mode The mode for the SymConst.
3619 * @param value A type, ident, entity or enum constant depending on the
3621 * @param kind The kind of the symbolic constant, see the list above
3623 FIRM_API ir_node *new_SymConst(ir_mode *mode, union symconst_symbol value,
3624 symconst_kind kind);
3626 /** Constructor for a simpelSel node.
3628 * This is a shortcut for the new_Sel() constructor. To be used for
3629 * Sel nodes that do not select from an array, i.e., have no index
3630 * inputs. It adds the two parameters 0, NULL.
3632 * @param *store The memory in which the object the entity should be selected from is allocated.
3633 * @param *objptr The object from that the Sel operation selects a single attribute out.
3634 * @param *ent The entity to select.
3636 FIRM_API ir_node *new_simpleSel(ir_node *store, ir_node *objptr,
3639 /** Constructor for a Sel node.
3641 * The select node selects an entity (field or method) from an entity
3642 * with a compound type. It explicitly specifies the entity selected.
3643 * Dynamically the node may select entities that overwrite the given
3644 * entity. If the selected entity is an array element entity the Sel
3645 * node takes the required array indices as inputs.
3646 * Adds the node to the block in current_ir_block.
3648 * @param *store The memory in which the object the entity should be selected
3649 * from is allocated.
3650 * @param *objptr A pointer to a compound entity the Sel operation selects a
3651 * single attribute from.
3652 * @param arity The number of array indices needed to select an array element entity.
3653 * @param *in[] If the compound entity is an array the indices of the selected
3654 * element entity. The constructor copies this array.
3655 * @param *ent The entity to select.
3657 FIRM_API ir_node *new_Sel(ir_node *store, ir_node *objptr,
3658 int arity, ir_node *in[], ir_entity *ent);
3660 /** Constructor for a Call node.
3662 * Adds the node to the block in current_ir_block.
3663 * Represents all kinds of method and function calls.
3665 * @param *store The actual store.
3666 * @param *callee A pointer to the called procedure.
3667 * @param arity The number of procedure parameters.
3668 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3669 * @param *tp Type information of the procedure called.
3671 FIRM_API ir_node *new_Call(ir_node *store, ir_node *callee,
3672 int arity, ir_node *in[], ir_type *tp);
3674 /** Constructor for a Builtin node.
3676 * Represents a call of a backend-specific builtin..
3677 * Represents all kinds of method and function calls.
3679 * @param *store The actual store.
3680 * @param kind The kind of the called builtin.
3681 * @param arity The number of procedure parameters.
3682 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3683 * @param *tp Type information of the procedure called.
3685 FIRM_API ir_node *new_Builtin(ir_node *store, int arity, ir_node *in[],
3686 ir_builtin_kind kind, ir_type *tp);
3688 /** Constructor for a Add node.
3690 * Adds the node to the block in current_ir_block.
3692 * @param *op1 The first operand.
3693 * @param *op2 The second operand.
3694 * @param *mode The mode of the operands and the result.
3696 FIRM_API ir_node *new_Add(ir_node *op1, ir_node *op2, ir_mode *mode);
3698 /** Constructor for a Sub node.
3700 * Adds the node to the block in current_ir_block.
3702 * @param *op1 The first operand.
3703 * @param *op2 The second operand.
3704 * @param *mode The mode of the operands and the result.
3706 FIRM_API ir_node *new_Sub(ir_node *op1, ir_node *op2, ir_mode *mode);
3708 /** Constructor for a Minus node.
3710 * Adds the node to the block in current_ir_block.
3712 * @param *op The operand .
3713 * @param *mode The mode of the operand and the result.
3715 FIRM_API ir_node *new_Minus(ir_node *op, ir_mode *mode);
3718 * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3720 * @param *op1 The first operand.
3721 * @param *op2 The second operand.
3722 * @param *mode The mode of the operands and the result.
3724 FIRM_API ir_node *new_Mul(ir_node *op1, ir_node *op2, ir_mode *mode);
3727 * Constructor for a Mulh node. Adds the node to the block in current_ir_block.
3729 * @param *op1 The first operand.
3730 * @param *op2 The second operand.
3731 * @param *mode The mode of the operands and the result.
3733 FIRM_API ir_node *new_Mulh(ir_node *op1, ir_node *op2, ir_mode *mode);
3735 /** Constructor for a Quot node.
3737 * Adds the node to the block in current_ir_block.
3739 * @param *memop The store needed to model exceptions
3740 * @param *op1 The first operand.
3741 * @param *op2 The second operand.
3742 * @param *mode The mode of the result.
3743 * @param state The pinned state.
3745 FIRM_API ir_node *new_Quot(ir_node *memop, ir_node *op1, ir_node *op2,
3746 ir_mode *mode, op_pin_state state);
3748 /** Constructor for a DivMod node.
3750 * Adds the node to the block in current_ir_block.
3752 * @param *memop The store needed to model exceptions
3753 * @param *op1 The first operand.
3754 * @param *op2 The second operand.
3755 * @param *mode The mode of the results.
3756 * @param state The pinned state.
3758 FIRM_API ir_node *new_DivMod(ir_node *memop, ir_node *op1, ir_node *op2,
3759 ir_mode *mode, op_pin_state state);
3761 /** Constructor for a Div node.
3763 * Adds the node to the block in current_ir_block.
3765 * @param *memop The store needed to model exceptions
3766 * @param *op1 The first operand.
3767 * @param *op2 The second operand.
3768 * @param *mode The mode of the result.
3769 * @param state The pinned state.
3771 FIRM_API ir_node *new_Div(ir_node *memop, ir_node *op1, ir_node *op2,
3772 ir_mode *mode, op_pin_state state);
3774 /** Constructor for a remainderless Div node.
3776 * Adds the node to the block in current_ir_block.
3778 * @param *memop The store needed to model exceptions
3779 * @param *op1 The first operand.
3780 * @param *op2 The second operand.
3781 * @param *mode The mode of the result.
3782 * @param state The pinned state.
3784 FIRM_API ir_node *new_DivRL(ir_node *memop, ir_node *op1, ir_node *op2,
3785 ir_mode *mode, op_pin_state state);
3787 /** Constructor for a Mod node.
3789 * Adds the node to the block in current_ir_block.
3791 * @param *memop The store needed to model exceptions
3792 * @param *op1 The first operand.
3793 * @param *op2 The second operand.
3794 * @param *mode The mode of the result.
3795 * @param state The pinned state.
3797 FIRM_API ir_node *new_Mod(ir_node *memop, ir_node *op1, ir_node *op2,
3798 ir_mode *mode, op_pin_state state);
3800 /** Constructor for a And node.
3802 * Adds the node to the block in current_ir_block.
3804 * @param *op1 The first operand.
3805 * @param *op2 The second operand.
3806 * @param *mode The mode of the operands and the result.
3808 FIRM_API ir_node *new_And(ir_node *op1, ir_node *op2, ir_mode *mode);
3811 * Constructor for a Or node. Adds the node to the block in current_ir_block.
3813 * @param *op1 The first operand.
3814 * @param *op2 The second operand.
3815 * @param *mode The mode of the operands and the result.
3817 FIRM_API ir_node *new_Or(ir_node *op1, ir_node *op2, ir_mode *mode);
3820 * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3822 * @param *op1 The first operand.
3823 * @param *op2 The second operand.
3824 * @param *mode The mode of the operands and the results.
3826 FIRM_API ir_node *new_Eor(ir_node *op1, ir_node *op2, ir_mode *mode);
3828 /** Constructor for a Not node.
3830 * Adds the node to the block in current_ir_block.
3832 * @param *op The operand.
3833 * @param *mode The mode of the operand and the result.
3835 FIRM_API ir_node *new_Not(ir_node *op, ir_mode *mode);
3837 /** Constructor for a Shl node.
3839 * Adds the node to the block in current_ir_block.
3841 * @param *op The operand.
3842 * @param *k The number of bits to shift the operand .
3843 * @param *mode The mode of the operand and the result.
3845 FIRM_API ir_node *new_Shl(ir_node *op, ir_node *k, ir_mode *mode);
3848 * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3850 * @param *op The operand.
3851 * @param *k The number of bits to shift the operand .
3852 * @param *mode The mode of the operand and the result.
3854 FIRM_API ir_node *new_Shr(ir_node *op, ir_node *k, ir_mode *mode);
3856 /** Constructor for a Shrs node.
3858 * Adds the node to the block in current_ir_block.
3860 * @param *op The operand.
3861 * @param *k The number of bits to shift the operand .
3862 * @param *mode The mode of the operand and the result.
3864 FIRM_API ir_node *new_Shrs(ir_node *op, ir_node *k, ir_mode *mode);
3866 /** Constructor for a Rotl node.
3868 * Adds the node to the block in current_ir_block.
3870 * @param *op The operand.
3871 * @param *k The number of bits to rotate the operand.
3872 * @param *mode The mode of the operand.
3874 FIRM_API ir_node *new_Rotl(ir_node *op, ir_node *k, ir_mode *mode);
3876 /** Constructor for a Cmp node.
3878 * Adds the node to the block in current_ir_block.
3880 * @param *op1 The first operand.
3881 * @param *op2 The second operand.
3883 FIRM_API ir_node *new_Cmp(ir_node *op1, ir_node *op2);
3885 /** Constructor for a Conv node.
3887 * Adds the node to the block in current_ir_block.
3889 * @param *op The operand.
3890 * @param *mode The mode of this the operand muss be converted.
3892 FIRM_API ir_node *new_Conv(ir_node *op, ir_mode *mode);
3894 /** Constructor for a strict Conv node.
3896 * Adds the node to the block in current_ir_block.
3898 * @param *op The operand.
3899 * @param *mode The mode of this the operand muss be converted.
3901 FIRM_API ir_node *new_strictConv(ir_node *op, ir_mode *mode);
3903 /** Constructor for a Cast node.
3905 * Adds the node to the block in current_ir_block.
3906 * High level type cast
3908 * @param *op The operand.
3909 * @param *to_tp The type of this the operand muss be casted .
3911 FIRM_API ir_node *new_Cast(ir_node *op, ir_type *to_tp);
3913 /** Constructor for a Carry node.
3915 * Adds the node to the block in current_ir_block.
3917 * @param *op1 The first operand.
3918 * @param *op2 The second operand.
3919 * @param *mode The mode of the operands and the result.
3921 FIRM_API ir_node *new_Carry(ir_node *op1, ir_node *op2, ir_mode *mode);
3923 /** Constructor for a Borrow node.
3925 * Adds the node to the block in current_ir_block.
3927 * @param *op1 The first operand.
3928 * @param *op2 The second operand.
3929 * @param *mode The mode of the operands and the result.
3931 FIRM_API ir_node *new_Borrow(ir_node *op1, ir_node *op2, ir_mode *mode);
3933 /** Constructor for a Phi node.
3935 * Adds the node to the block in current_ir_block.
3937 * @param arity The number of predecessors.
3938 * @param *in Array with predecessors.
3939 * @param *mode The mode of it's inputs and output.
3941 FIRM_API ir_node *new_Phi(int arity, ir_node *in[], ir_mode *mode);
3943 /** Constructor for a Load node.
3945 * @param *store The current memory.
3946 * @param *addr A pointer to the variable to be read in this memory.
3947 * @param *mode The mode of the value to be loaded.
3948 * @param flags Additional flags for alignment, volatility and pin state.
3950 FIRM_API ir_node *new_Load(ir_node *store, ir_node *addr, ir_mode *mode,
3951 ir_cons_flags flags);
3953 /** Constructor for a Store node.
3955 * @param *store The current memory.
3956 * @param *addr A pointer to the variable to be read in this memory.
3957 * @param *val The value to write to this variable.
3958 * @param flags Additional flags for alignment, volatility and pin state.
3960 FIRM_API ir_node *new_Store(ir_node *store, ir_node *addr, ir_node *val,
3961 ir_cons_flags flags);
3963 /** Constructor for a Alloc node.
3965 * The Alloc node extends the memory by space for an entity of type alloc_type.
3966 * Adds the node to the block in current_ir_block.
3968 * @param *store The memory which shall contain the new variable.
3969 * @param *count The number of objects to allocate.
3970 * @param *alloc_type The type of the allocated variable.
3971 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3973 FIRM_API ir_node *new_Alloc(ir_node *store, ir_node *count, ir_type *alloc_type,
3974 ir_where_alloc where);
3976 /** Constructor for a Free node.
3978 * Frees the memory occupied by the entity pointed to by the pointer
3979 * arg. Type indicates the type of the entity the argument points to.
3980 * Adds the node to the block in current_ir_block.
3982 * @param *store The memory which shall contain the new variable.
3983 * @param *ptr The pointer to the object to free.
3984 * @param *size The number of objects of type free_type to free in a sequence.
3985 * @param *free_type The type of the freed variable.
3986 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3988 FIRM_API ir_node *new_Free(ir_node *store, ir_node *ptr, ir_node *size,
3989 ir_type *free_type, ir_where_alloc where);
3991 /** Constructor for a Sync node.
3993 * Merges several memory values. The node assumes that a variable
3994 * either occurs only in one of the memories, or it contains the same
3995 * value in all memories where it occurs.
3996 * Adds the node to the block in current_ir_block.
3998 * @param arity The number of memories to synchronize.
3999 * @param **in An array of pointers to nodes that produce an output of type
4000 * memory. The constructor copies this array.
4002 FIRM_API ir_node *new_Sync(int arity, ir_node *in[]);
4004 /** Constructor for a Proj node.
4006 * Projects a single value out of a tuple. The parameter proj gives the
4007 * position of the value within the tuple.
4008 * Adds the node to the block in current_ir_block.
4010 * @param arg A node producing a tuple.
4011 * @param *mode The mode of the value to project.
4012 * @param proj The position of the value in the tuple.
4014 FIRM_API ir_node *new_Proj(ir_node *arg, ir_mode *mode, long proj);
4016 /** Constructor for a defaultProj node.
4018 * Represents the default control flow of a Switch-Cond node.
4019 * Adds the node to the block in current_ir_block.
4021 * @param arg A node producing a tuple.
4022 * @param max_proj The end position of the value in the tuple.
4024 FIRM_API ir_node *new_defaultProj(ir_node *arg, long max_proj);
4026 /** Constructor for a Tuple node.
4028 * This is an auxiliary node to replace a node that returns a tuple
4029 * without changing the corresponding Proj nodes.
4030 * Adds the node to the block in current_ir_block.
4032 * @param arity The number of tuple elements.
4033 * @param **in An array containing pointers to the nodes producing the tuple elements.
4035 FIRM_API ir_node *new_Tuple(int arity, ir_node *in[]);
4037 /** Constructor for an Id node.
4039 * This is an auxiliary node to replace a node that returns a single
4040 * value. Adds the node to the block in current_ir_block.
4042 * @param *val The operand to Id.
4043 * @param *mode The mode of *val.
4045 FIRM_API ir_node *new_Id(ir_node *val, ir_mode *mode);
4047 /** Constructor for a Bad node.
4049 * Returns the unique Bad node of the graph. The same as
4052 FIRM_API ir_node *new_Bad(void);
4054 /** Constructor for a Confirm node.
4056 * Specifies constraints for a value. To support dataflow analyses.
4057 * Adds the node to the block in current_ir_block.
4059 * Example: If the value never exceeds '100' this is expressed by placing a
4060 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
4062 * @param *val The value we express a constraint for
4063 * @param *bound The value to compare against. Must be a firm node, typically a constant.
4064 * @param cmp The compare operation.
4066 FIRM_API ir_node *new_Confirm(ir_node *val, ir_node *bound, pn_Cmp cmp);
4068 /** Constructor for an Unknown node.
4070 * Represents an arbitrary value. Places the node in
4073 * @param *m The mode of the unknown value.
4075 FIRM_API ir_node *new_Unknown(ir_mode *m);
4077 /** Constructor for a NoMem node.
4079 * Returns the unique NoMem node of the graph. The same as
4082 FIRM_API ir_node *new_NoMem(void);
4084 /** Constructor for a Mux node.
4086 * Adds the node to the block in current_ir_block.
4088 * @param *sel The ir_node that calculates the boolean select.
4089 * @param *ir_true The ir_node that calculates the true result.
4090 * @param *ir_false The ir_node that calculates the false result.
4091 * @param *mode The mode of the node (and it_true and ir_false).
4093 FIRM_API ir_node *new_Mux(ir_node *sel, ir_node *ir_false, ir_node *ir_true,
4096 /** Constructor for a CopyB node.
4098 * Adds the node to the block in current_ir_block.
4100 * @param *store The current memory
4101 * @param *dst The ir_node that represents the destination address.
4102 * @param *src The ir_node that represents the source address.
4103 * @param *data_type The type of the copied data
4105 FIRM_API ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src,
4106 ir_type *data_type);
4108 /** Constructor for a InstOf node.
4110 * A High-Level Type check.
4112 * @param *store The memory in which the object the entity should be selected
4113 * from is allocated.
4114 * @param *objptr A pointer to a object of a class type.
4115 * @param *type The type of which objptr must be.
4117 FIRM_API ir_node *new_InstOf(ir_node *store, ir_node *objptr, ir_type *type);
4119 /**Constructor for a Raise node.
4121 * A High-Level Exception throw.
4123 * @param *store The current memory.
4124 * @param *obj A pointer to the Except variable.
4126 FIRM_API ir_node *new_Raise(ir_node *store, ir_node *obj);
4128 /** Constructor for a Bound node.
4130 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
4132 * Adds the node to the block in current_ir_block.
4134 * @param *store The current memory
4135 * @param *idx The ir_node that represents an index.
4136 * @param *lower The ir_node that represents the lower bound for the index.
4137 * @param *upper The ir_node that represents the upper bound for the index.
4139 FIRM_API ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower,
4142 /** Constructor for a Pin node.
4144 * @param *node The node which value should be pinned.
4146 FIRM_API ir_node *new_Pin(ir_node *node);
4148 /** Constructor for an ASM pseudo node.
4150 * @param arity The number of data inputs to the node.
4151 * @param *in The array of length arity of data inputs.
4152 * @param *inputs The array of length arity of input constraints.
4153 * @param n_outs The number of data outputs to the node.
4154 * @param *outputs The array of length n_outs of output constraints.
4155 * @param n_clobber The number of clobbered registers.
4156 * @param *clobber The array of length n_clobber of clobbered registers.
4157 * @param *asm_text The assembler text.
4159 FIRM_API ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
4160 int n_outs, ir_asm_constraint *outputs,
4161 int n_clobber, ident *clobber[], ident *asm_text);
4164 * @brief Constructor for a Dummy node.
4166 * @param *db debug info for the node
4167 * @param *mode The mode of the node.
4168 * @param *irg the graph to put the node into
4169 * @returns the newly created note
4171 FIRM_API ir_node *new_rd_Dummy(dbg_info *db, ir_graph *irg, ir_mode *mode);
4174 * @copybrief new_rd_Dummy()
4176 * @param *mode The mode of the node.
4177 * @param *irg the graph to put the node into
4178 * @returns the newly created note
4180 FIRM_API ir_node *new_r_Dummy(ir_graph *irg, ir_mode *mode);
4183 * @copybrief new_rd_Dummy()
4185 * @param *db debug info for the node
4186 * @param *mode The mode of the node.
4187 * @returns the newly created note
4189 FIRM_API ir_node *new_d_Dummy(dbg_info *db, ir_mode *mode);
4192 * @copybrief new_rd_Dummy()
4194 * @param *mode The mode of the node.
4195 * @returns the newly created note
4197 FIRM_API ir_node *new_Dummy(ir_mode *mode);
4199 /*---------------------------------------------------------------------*/
4200 /* The comfortable interface. */
4201 /* Supports automatic Phi node construction. */
4202 /* All routines of the block oriented interface except new_Block are */
4204 /*---------------------------------------------------------------------*/
4206 /** Create an immature Block.
4208 * An immature Block has an unknown number of predecessors. Predecessors
4209 * can be added with add_immBlock_pred(). Once all predecessors are
4210 * added the block must be matured.
4212 * Adds the block to the graph in current_ir_graph. Can be used with automatic
4213 * Phi node construction.
4214 * This constructor can only be used if the graph is in state_building.
4216 FIRM_API ir_node *new_d_immBlock(dbg_info *db);
4217 FIRM_API ir_node *new_immBlock(void);
4219 /** Add a control flow edge to an immature block. */
4220 FIRM_API void add_immBlock_pred(ir_node *immblock, ir_node *jmp);
4222 /** Finalize a Block node, when all control flows are known. */
4223 FIRM_API void mature_immBlock(ir_node *block);
4225 /** Get the current value of a local variable.
4227 * Use this function to obtain the last definition of the local variable
4228 * associated with pos. Pos may not exceed the value passed as n_loc
4229 * to new_ir_graph. This call automatically inserts Phi nodes.
4231 * @param *db A pointer for debug information.
4232 * @param pos The position/id of the local variable.
4233 * @param *mode The mode of the value to get.
4235 FIRM_API ir_node *get_d_value(dbg_info *db, int pos, ir_mode *mode);
4236 FIRM_API ir_node *get_value(int pos, ir_mode *mode);
4239 * Try to guess the mode of a local variable.
4240 * This is done by recursively going up the control flow graph until
4241 * we find a definition for the variable. The mode of the first found
4242 * definition is returned. NULL in case no definition is found.
4244 * @param pos The position/id of the local variable.
4246 FIRM_API ir_mode *ir_guess_mode(int pos);
4248 /** Remark a new definition of a variable.
4250 * Use this function to remember a new definition of the value
4251 * associated with pos. Pos may not exceed the value passed as n_loc
4252 * to new_ir_graph. This call is needed to automatically inserts Phi
4255 * @param pos The position/id of the local variable.
4256 * @param *value The new value written to the local variable.
4258 FIRM_API void set_value(int pos, ir_node *value);
4261 * Find the value number for a node in the current block.
4263 * @param value the searched value
4265 * @return the value number of the value or -1 if this value has
4266 * no value number in the current block.
4268 FIRM_API int find_value(ir_node *value);
4270 /** Get the current memory state.
4272 * Use this function to obtain the last definition of the memory
4273 * state. This call automatically inserts Phi nodes for the memory
4276 FIRM_API ir_node *get_store(void);
4278 /** Remark a new definition of the memory state.
4280 * Use this function to remember a new definition of the memory state.
4281 * This call is needed to automatically inserts Phi nodes.
4283 * @param *store The new memory state.
4285 FIRM_API void set_store(ir_node *store);
4287 /** keep this node alive even if End is not control-reachable from it
4289 * @param ka The node to keep alive.
4291 FIRM_API void keep_alive(ir_node *ka);
4293 /** Returns the frame type of the current graph */
4294 FIRM_API ir_type *get_cur_frame_type(void);
4297 /* --- initialize and finalize IR construction --- */
4299 /** Puts the graph into state "phase_high" */
4300 FIRM_API void irg_finalize_cons(ir_graph *irg);
4302 /** Puts the program and all graphs into state phase_high.
4304 * This also remarks, the construction of types is finished,
4305 * e.g., that no more subtypes will be added. */
4306 FIRM_API void irp_finalize_cons(void);
4308 FIRM_API void ir_set_uninitialized_local_variable_func(
4309 uninitialized_local_variable_func_t *func);