2 * Copyright (C) 1995-2008 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_Abs (ir_node *op, ir_mode *mode);
276 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode);
277 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode);
278 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode);
279 * ir_node *new_Not (ir_node *op, ir_mode *mode);
280 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode);
281 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode);
282 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode);
283 * ir_node *new_Rotl (ir_node *op, ir_node *k, ir_mode *mode);
284 * ir_node *new_Cmp (ir_node *op1, ir_node *op2);
285 * ir_node *new_Conv (ir_node *op, ir_mode *mode);
286 * ir_node *new_Cast (ir_node *op, ir_type *to_tp);
287 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode, ir_cons_flags flags);
288 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val, ir_cons_flags flags);
289 * ir_node *new_Alloc (ir_node *store, ir_node *count, ir_type *alloc_type,
290 * where_alloc where);
291 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
292 * ir_type *free_type, where_alloc where);
293 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
294 * ir_node *new_NoMem (void);
295 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
296 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
297 * ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
298 * ir_node *new_Raise (ir_node *store, ir_node *obj);
299 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
300 * ir_node *new_Pin (ir_node *node);
302 * void add_immBlock_pred (ir_node *block, ir_node *jmp);
303 * void mature_immBlock (ir_node *block);
304 * void set_cur_block (ir_node *target);
305 * ir_node *get_value (int pos, ir_mode *mode);
306 * void set_value (int pos, ir_node *value);
307 * ir_node *get_store (void);
308 * void set_store (ir_node *store);
309 * keep_alive (ir_node ka)
311 * IR_NODES AND CONSTRUCTORS FOR IR_NODES
312 * =======================================
314 * All ir_nodes are defined by a common data structure. They are distinguished
315 * by their opcode and differ in the number of their attributes.
317 * Const nodes are always added to the start block.
318 * All other constructors add the created node to the current_block.
319 * swich_block(block) allows to set the current block to block.
321 * Watch for my inconsistent use of input and predecessor (dataflow view)
322 * and `the node points to' (implementation view).
324 * The following description of the nodes lists four properties them if these
326 * - the parameters to the constructor
327 * - the inputs of the Firm node
328 * - the outputs of the Firm node
329 * - attributes to the node
333 * ir_node *new_immBlock (void)
334 * ----------------------------
336 * Creates a new block. When a new block is created it cannot be known how
337 * many predecessors this block will have in the control flow graph.
338 * Therefore the list of inputs can not be fixed at creation. Predecessors
339 * can be added with add_immBlock_pred (block, control flow operation).
340 * With every added predecessor the number of inputs to Phi nodes also
343 * The block can be completed by mature_immBlock(block) if all predecessors are
344 * known. If several blocks are built at once, mature_immBlock can only be called
345 * after set_value has been called for all values that are life at the end
346 * of the block. This is necessary so that Phi nodes created mature_immBlock
347 * get the right predecessors in case of cyclic dependencies. If all set_values
348 * of this block are called after maturing it and before calling get_value
349 * in some block that is control flow dependent on this block, the construction
352 * Example for faulty IR construction: (draw the graph on a paper and you'll
355 * block_before_loop = new_immBlock();
356 * set_cur_block(block_before_loop);
358 * mature_immBlock(block_before_loop);
359 * before2header = new_Jmp;
361 * loop_header = new_immBlock ();
362 * set_cur_block(loop_header);
363 * header2body - new_Jmp();
365 * loop_body = new_immBlock ();
366 * set_cur_block(loop_body);
367 * body2header = new_Jmp();
369 * add_immBlock_pred(loop_header, before2header);
370 * add_immBlock_pred(loop_header, body2header);
371 * add_immBlock_pred(loop_body, header2body);
373 * mature_immBlock(loop_header);
374 * mature_immBlock(loop_body);
376 * get_value(loop_body, x); // gets the Phi in loop_header
377 * set_value(loop_header, x); // sets the value the above get_value should
378 * // have returned!!!
380 * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
381 * should be called as early as possible, as afterwards the generation of Phi
382 * nodes is more efficient.
385 * There is an input for each control flow predecessor of the block.
386 * The input points to an instruction producing an output of type X.
387 * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
388 * possibly causing an exception. (Often the real predecessors are Projs.)
390 * Mode BB (R), all nodes belonging to this block should consume this output.
391 * As they are strict (except Block and Phi node) it is a necessary condition
392 * that the block node executed before any other node in this block executes.
394 * block.matured Indicates whether the block is mature.
396 * This attribute contains all local values valid in this
397 * block. This is needed to build the Phi nodes and removed
398 * if the graph is complete. This field is used by the
399 * internal construction algorithm and should not be accessed
403 * ir_node *new_Block (int arity, ir_node **in)
404 * --------------------------------------------
406 * Creates a new Block with the given list of predecessors. This block
407 * is mature. As other constructors calls optimization and vrfy for the
408 * block. If one of the predecessors is Unknown (as it has to be filled in
409 * later) optimizations are skipped. This is necessary to
410 * construct Blocks in loops.
413 * CONTROL FLOW OPERATIONS
414 * -----------------------
416 * In each block there must be exactly one of the control flow
417 * operations Start, End, Jmp, Cond, Return or Raise. The output of a
418 * control flow operation points to the block to be executed next.
420 * ir_node *new_Start (void)
421 * -------------------------
423 * Creates a start node. Not actually needed public. There is only one such
424 * node in each procedure which is automatically created by new_ir_graph.
427 * No inputs except the block it belogns to.
429 * A tuple of 4 (5, 6) distinct values. These are labeled by the following
430 * projection numbers (pn_Start):
431 * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
432 * * pn_Start_M mode M, the global store
433 * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
434 * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
435 * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
438 * ir_node *new_End (void)
439 * -----------------------
441 * Creates an end node. Not actually needed public. There is only one such
442 * node in each procedure which is automatically created by new_ir_graph.
445 * No inputs except the block it belongs to.
449 * ir_node *new_Jmp (void)
450 * -----------------------
452 * Creates a Jmp node.
455 * The block the node belongs to
457 * Control flow to the next block.
459 * ir_node *new_IJmp (ir_node *tgt)
460 * -----------------------
462 * Creates an IJmp node.
465 * The node that represents the target jump address
467 * Control flow to an unknown target, must be pinned by
470 * ir_node *new_Cond (ir_node *c)
471 * ------------------------------
473 * Creates a Cond node. There are two versions of this node.
479 * A tuple of two control flows. The first is taken if the input is
480 * false, the second if it is true.
484 * A value of mode I_u. (i)
486 * A tuple of n control flows. If the Cond's input is i, control
487 * flow will procede along output i. If the input is >= n control
488 * flow proceeds along output n.
490 * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
491 * -------------------------------------------------------------
493 * The return node has as inputs the results of the procedure. It
494 * passes the control flow to the end_block.
500 * 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_Abs (ir_node *op, ir_mode *mode)
723 * ---------------------------------------------
727 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
728 * ------------------------------------------------------------
732 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
733 * -----------------------------------------------------------
737 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
738 * ------------------------------------------------------------
742 * ir_node *new_Not (ir_node *op, ir_mode *mode)
743 * ---------------------------------------------
745 * This node constructs a constant where all bits are set to one
746 * and a Eor of this constant and the operator. This simulates a
749 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
750 * ---------------------------------------------------------
754 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
755 * ---------------------------------------------------------
757 * Logic shift right, i.e., zero extended.
760 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
761 * ----------------------------------------------------------
763 * Arithmetic shift right, i.e., sign extended.
765 * ir_node *new_Rotl (ir_node *op, ir_node *k, ir_mode *mode)
766 * ---------------------------------------------------------
768 * Rotates the operand to the left by k bits.
770 * ir_node *new_Conv (ir_node *op, ir_mode *mode)
771 * ---------------------------------------------
773 * Mode conversion. For allowed conversions see UKA Tech Report
776 * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
777 * ---------------------------------------------
780 * The two values to be compared.
782 * A 16-tuple containing the results of the 16 different comparisons.
783 * The following is a list giving the comparisons and a projection
784 * number (pn_Cmp) to use in Proj nodes to extract the proper result.
788 * pn_Cmp_Le less or equal
790 * pn_Cmp_Ge greater of equal
791 * pn_Cmp_Lg less or greater
792 * pn_Cmp_Leg less, equal or greater = ordered
793 * pn_Cmp_Uo unordered
794 * pn_Cmp_Ue unordered or equal
795 * pn_Cmp_Ul unordered or less
796 * pn_Cmp_Ule unordered, less or equal
797 * pn_Cmp_Ug unordered or greater
798 * pn_Cmp_Uge unordered, greater or equal
799 * pn_Cmp_Ne unordered, less or greater = not equal
806 * In general, Phi nodes are automaitcally inserted. In some cases, if
807 * all predecessors of a block are known, an explicit Phi node constructor
808 * is needed. E.g., to construct a FIRM graph for a statement as
809 * a = (b==c) ? 2 : 5;
811 * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
812 * ---------------------------------------------------------
814 * Creates a Phi node. The in's order has to correspond to the order
815 * of in's of current_block. This is not checked by the library!
816 * If one of the predecessors is Unknown (as it has to be filled in
817 * later) optimizations are skipped. This is necessary to
818 * construct Phi nodes in loops.
821 * arity number of predecessors
822 * **in array with predecessors
823 * *mode The mode of it's inputs and output.
825 * A Phi node has as many inputs as the block it belongs to.
826 * Each input points to a definition of the same value on a
827 * different path in the control flow.
829 * The definition valid in this block.
831 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
832 * -----------------------------------------------------------------------------------
834 * Creates a Mux node. This node implements the following semantic:
835 * If the sel node (which must be of mode_b) evaluates to true, its value is
836 * ir_true, else ir_false;
840 * OPERATIONS TO MANAGE MEMORY EXPLICITLY
841 * --------------------------------------
843 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode, ir_cons_flags flags)
844 * -------------------------------------------------------------------------------------
846 * The Load operation reads a value from memory.
849 * *store The current memory.
850 * *addr A pointer to the variable to be read in this memory.
851 * *mode The mode of the value to be loaded.
852 * flags Additional flags for alignment, volatility and pin state.
855 * The memory and a pointer to a variable in this memory.
857 * A tuple of the memory, a control flow to be taken in case of
858 * an exception and the loaded value.
860 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val, ir_cons_flags flags)
861 * -------------------------------------------------------------------------------------
863 * The Store operation writes a value to a variable in memory.
866 * The memory, a pointer to a variable in this memory and the value
867 * to write to this variable.
869 * A tuple of the changed memory and a control flow to be taken in
870 * case of an exception.
872 * ir_node *new_Alloc (ir_node *store, ir_node *count, ir_type *alloc_type,
873 * -----------------------------------------------------------------------
877 * The Alloc node allocates a new variable. It can be specified whether the
878 * variable should be allocated to the stack or to the heap.
881 * *store The memory which shall contain the new variable.
882 * *count This field is for allocating arrays, it specifies how
883 * many array elements are to be allocated.
884 * *alloc_type The type of the allocated variable. In case of allocating
885 * arrays this has to be the array type, not the type of the
887 * where Where to allocate the variable, either heap_alloc or stack_alloc.
890 * A memory and an unsigned integer.
892 * A tuple of the changed memory, a control flow to be taken in
893 * case of an exception and the pointer to the new variable.
895 * a.where Indicates where the variable is allocated.
896 * a.*type A pointer to the class the allocated data object
899 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
900 * -----------------------------------------------------------------------------------
904 * The Free node frees memory of the given variable.
907 * *store The memory which shall contain the new variable.
908 * *ptr The pointer to the object to free.
909 * *size The number of objects of type free_type to free in a sequence.
910 * *free_type The type of the freed variable.
911 * where Where the variable was allocated, either heap_alloc or stack_alloc.
914 * A memory, a pointer and an unsigned integer.
916 * The changed memory.
918 * f.*type A pointer to the type information of the freed data object.
922 * ir_node *new_Sync (int arity, ir_node **in)
923 * -------------------------------------------
925 * The Sync operation unifies several partial memory blocks. These blocks
926 * have to be pairwise disjunct or the values in common locations have to
927 * be identical. This operation allows to specify all operations that eventually
928 * need several partial memory blocks as input with a single entrance by
929 * unifying the memories with a preceding Sync operation.
932 * arity The number of memories to synchronize.
933 * **in An array of pointers to nodes that produce an output of
938 * The unified memory.
944 * ir_node *new_Bad (void)
945 * -----------------------
947 * Returns the unique Bad node current_ir_graph->bad.
948 * This node is used to express results of dead code elimination.
950 * ir_node *new_NoMem (void)
951 * -----------------------------------------------------------------------------------
953 * Returns the unique NoMem node current_ir_graph->no_mem.
954 * This node is used as input for operations that need a Memory, but do not
955 * change it like Div by const != 0, analyzed calls etc.
957 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
958 * ----------------------------------------------------------
960 * Selects one entry of a tuple. This is a hidden edge with attributes.
963 * *arg A node producing a tuple.
964 * *mode The mode of the value to project.
965 * proj The position of the value in the tuple.
971 * ir_node *new_Tuple (int arity, ir_node **in)
972 * --------------------------------------------
974 * Builds a Tuple from single values. This is needed to implement
975 * optimizations that remove a node that produced a tuple. The node can be
976 * replaced by the Tuple operation so that the following Proj nodes have not to
977 * be changed. (They are hard to find due to the implementation with pointers
978 * in only one direction.) The Tuple node is smaller than any other
979 * node, so that a node can be changed into a Tuple by just changing it's
980 * opcode and giving it a new in array.
983 * arity The number of tuple elements.
984 * **in An array containing pointers to the nodes producing the
987 * ir_node *new_Id (ir_node *val, ir_mode *mode)
988 * ---------------------------------------------
990 * The single output of the Id operation is it's input. Also needed
994 * HIGH LEVEL OPERATIONS
995 * ---------------------
997 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
998 * -----------------------------------------------------------------------------------
1000 * Describes a high level block copy of a compound type from address src to
1001 * address dst. Must be lowered to a Call to a runtime memory copy function.
1004 * HIGH LEVEL OPERATIONS: Exception Support
1005 * ----------------------------------------
1006 * See TechReport 1999-14, chapter Exceptions.
1008 * ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
1009 * -----------------------------------------------------------------------------------
1011 * Describes a high level type check. Must be lowered to a Call to a runtime check
1014 * ir_node *new_Raise (ir_node *store, ir_node *obj)
1015 * -------------------------------------------------
1017 * Raises an exception. Unconditional change of control flow. Writes
1018 * an explicit Except variable to memory to pass it to the exception
1019 * handler. Must be lowered to a Call to a runtime check
1024 * A pointer to the Except variable.
1026 * A tuple of control flow and the changed memory state. The control flow
1027 * points to the exception handler if it is definied in this procedure,
1028 * else it points to the end_block.
1030 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
1031 * -----------------------------------------------------------------------------------
1033 * Describes a high level bounds check. Must be lowered to a Call to a runtime check
1036 * ir_node *new_Pin (ir_node *node);
1037 * -----------------------------------------------------------------------------------
1039 * Pin the value of the node node in the current block No users of the Pin node can
1040 * float above the Block of the Pin. The node cannot float behind this block. Often
1041 * used to Pin the NoMem node.
1044 * COPING WITH DATA OBJECTS
1045 * ========================
1047 * Two kinds of data objects have to be distinguished for generating
1048 * FIRM. First there are local variables other than arrays that are
1049 * known to be alias free. Second there are all other data objects.
1050 * For the first a common SSA representation is built, the second
1051 * are modeled by saving them to memory. The memory is treated as
1052 * a single local variable, the alias problem is hidden in the
1053 * content of this variable.
1055 * All values known in a Block are listed in the block's attribute,
1056 * block.**graph_arr which is used to automatically insert Phi nodes.
1057 * The following two functions can be used to add a newly computed value
1058 * to the array, or to get the producer of a value, i.e., the current
1061 * inline void set_value (int pos, ir_node *value)
1062 * -----------------------------------------------
1064 * Has to be called for every assignment to a local variable. It
1065 * adds the value to the array of used values at position pos. Pos
1066 * has to be a unique identifier for an entry in the procedure's
1067 * definition table. It can be used to access the value again.
1068 * Requires current_block to be set correctly.
1070 * ir_node *get_value (int pos, ir_mode *mode)
1071 * -------------------------------------------
1073 * Returns the node defining the value referred to by pos. If the
1074 * value is not defined in this block a Phi node is generated and
1075 * all definitions reaching this Phi node are collected. It can
1076 * happen that the algorithm allocates an unnecessary Phi node,
1077 * e.g. if there is only one definition of this value, but this
1078 * definition reaches the currend block on several different
1079 * paths. This Phi node will be eliminated if optimizations are
1080 * turned on right after it's creation.
1081 * Requires current_block to be set correctly.
1083 * There are two special routines for the global store:
1085 * void set_store (ir_node *store)
1086 * -------------------------------
1088 * Adds the store to the array of known values at a reserved
1090 * Requires current_block to be set correctly.
1092 * ir_node *get_store (void)
1093 * -------------------------
1095 * Returns the node defining the actual store.
1096 * Requires current_block to be set correctly.
1099 * inline void keep_alive (ir_node *ka)
1100 * ------------------------------------
1102 * Keep this node alive because it is (might be) not in the control
1103 * flow from Start to End. Adds the node to the list in the end
1107 #ifndef FIRM_IR_IRCONS_H
1108 #define FIRM_IR_IRCONS_H
1110 #include "firm_types.h"
1115 * constrained flags for memory operations.
1117 typedef enum ir_cons_flags {
1118 cons_none = 0, /**< No constrains. */
1119 cons_volatile = 1U << 0, /**< Memory operation is volatile. */
1120 cons_unaligned = 1U << 1, /**< Memory operation is unaligned. */
1121 cons_floats = 1U << 2 /**< Memory operation can float. */
1124 /*-------------------------------------------------------------------------*/
1125 /* The raw interface */
1126 /*-------------------------------------------------------------------------*/
1128 /** Constructor for a Block node.
1130 * Constructs a mature block with the given predecessors.
1132 * @param *db A Pointer for debug information.
1133 * @param irg The IR graph the block belongs to.
1134 * @param arity The number of control predecessors.
1135 * @param in[] An array of control predecessors. The length of
1136 * the array must be 'arity'. The constructor copies this array.
1138 FIRM_API ir_node *new_rd_Block(dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1140 /** Constructor for a Start node.
1142 * @param *db A pointer for debug information.
1143 * @param *irg The IR graph the node belongs to.
1144 * @param *block The IR block the node belongs to.
1146 FIRM_API ir_node *new_rd_Start(dbg_info *db, ir_graph *irg, ir_node *block);
1148 /** Constructor for a End node.
1150 * @param *db A pointer for debug information.
1151 * @param *irg The IR graph the node belongs to.
1152 * @param *block The IR block the node belongs to.
1154 FIRM_API ir_node *new_rd_End(dbg_info *db, ir_graph *irg, ir_node *block);
1156 /** Constructor for a Jmp node.
1158 * Jmp represents control flow to a single control successor.
1160 * @param *db A pointer for debug information.
1161 * @param *block The IR block the node belongs to.
1163 FIRM_API ir_node *new_rd_Jmp(dbg_info *db, ir_node *block);
1165 /** Constructor for an IJmp node.
1167 * IJmp represents control flow to a single control successor not
1168 * statically known i.e. an indirect Jmp.
1170 * @param *db A pointer for debug information.
1171 * @param *block The IR block the node belongs to.
1172 * @param *tgt The IR node representing the target address.
1174 FIRM_API ir_node *new_rd_IJmp(dbg_info *db, ir_node *block, ir_node *tgt);
1176 /** Constructor for a Cond node.
1178 * If c is mode_b represents a conditional branch (if/else). If c is
1179 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1180 * node, default Proj is 0.)
1182 * This is not consistent: Input to Cond is Is, Proj has as proj number
1185 * @param *db A pointer for debug information.
1186 * @param *block The IR block the node belongs to.
1187 * @param *c The conditions parameter. Can be of mode b or I_u.
1189 FIRM_API ir_node *new_rd_Cond(dbg_info *db, ir_node *block, ir_node *c);
1191 /** Constructor for a Return node.
1193 * Returns the memory and zero or more return values. Only node that
1194 * can end regular control flow.
1196 * @param *db A pointer for debug information.
1197 * @param *block The IR block the node belongs to.
1198 * @param *store The state of memory.
1199 * @param arity Number of return values.
1200 * @param *in Array of length arity with return values. The constructor copies this array.
1202 FIRM_API ir_node *new_rd_Return(dbg_info *db, ir_node *block,
1203 ir_node *store, int arity, ir_node *in[]);
1205 /** Constructor for a Const_type node.
1207 * Adds the node to the start block.
1209 * The constant represents a target value. This constructor sets high
1210 * level type information for the constant value.
1211 * Derives mode from passed tarval.
1213 * @param *db A pointer for debug information.
1214 * @param *irg The IR graph the node belongs to.
1215 * @param *con Points to an entry in the constant table.
1216 * @param *tp The type of the constant.
1218 FIRM_API ir_node *new_rd_Const_type(dbg_info *db, ir_graph *irg,
1219 tarval *con, ir_type *tp);
1221 /** Constructor for a Const node.
1223 * Adds the node to the start block.
1225 * Constructor for a Const node. The constant represents a target
1226 * value. Sets the type information to type_unknown. (No more
1227 * supported: If tv is entity derives a somehow useful type.)
1228 * Derives mode from passed tarval.
1230 * @param *db A pointer for debug information.
1231 * @param *irg The IR graph the node belongs to.
1232 * @param *con Points to an entry in the constant table.
1234 FIRM_API ir_node *new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con);
1237 * Constructor for a Const node.
1239 * Adds the node to the start block.
1241 * Constructor for a Const node. The constant represents a target
1242 * value. Sets the type information to type_unknown. (No more
1243 * supported: If tv is entity derives a somehow useful type.)
1245 * @param *db A pointer for debug information.
1246 * @param *irg The IR graph the node belongs to.
1247 * @param *mode The mode of the operands and results.
1248 * @param value A value from which the tarval is made.
1250 FIRM_API ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg,
1251 ir_mode *mode, long value);
1253 /** Constructor for a SymConst_type node.
1255 * This is the constructor for a symbolic constant.
1256 * There are several kinds of symbolic constants:
1257 * - symconst_type_tag The symbolic constant represents a type tag. The
1258 * type the tag stands for is given explicitly.
1259 * - symconst_type_size The symbolic constant represents the size of a type.
1260 * The type of which the constant represents the size
1261 * is given explicitly.
1262 * - symconst_type_align The symbolic constant represents the alignment of a
1263 * type. The type of which the constant represents the
1264 * size is given explicitly.
1265 * - symconst_addr_ent The symbolic constant represents the address of an
1266 * entity (variable or method). The variable is given
1267 * explicitly by a firm entity.
1268 * - symconst_ofs_ent The symbolic constant represents the offset of an
1269 * entity in its owner type.
1270 * - symconst_enum_const The symbolic constant is a enumeration constant of
1271 * an enumeration type.
1273 * Inputs to the node:
1274 * No inputs except the block it belongs to.
1275 * Outputs of the node.
1276 * An unsigned integer (I_u) or a pointer (P).
1278 * Mention union in declaration so that the firmjni generator recognizes that
1279 * it can not cast the argument to an int.
1281 * @param *db A pointer for debug information.
1282 * @param *irg The IR graph the node belongs to.
1283 * @param mode The mode for the SymConst.
1284 * @param val A type, ident, entity or enum constant depending on the
1286 * @param kind The kind of the symbolic constant, see the list above
1287 * @param tp The source type of the constant.
1289 FIRM_API ir_node *new_rd_SymConst_type(dbg_info *db, ir_graph *irg,
1290 ir_mode *mode, union symconst_symbol val,
1291 symconst_kind kind, ir_type *tp);
1293 /** Constructor for a SymConst node.
1295 * Same as new_rd_SymConst_type, except that it sets the type to type_unknown.
1297 FIRM_API ir_node *new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode,
1298 union symconst_symbol value,
1299 symconst_kind kind);
1301 /** Constructor for a SymConst addr_ent node.
1303 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1304 * symconst_addr_ent.
1305 * Adds the SymConst to the start block of irg. */
1306 FIRM_API ir_node *new_rd_SymConst_addr_ent(dbg_info *db, ir_graph *irg,
1307 ir_mode *mode, ir_entity *symbol,
1310 /** Constructor for a SymConst ofs_ent node.
1312 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1314 * Adds the SymConst to the start block of irg.
1316 FIRM_API ir_node *new_rd_SymConst_ofs_ent(dbg_info *db, ir_graph *irg,
1317 ir_mode *mode, ir_entity *symbol,
1320 /** Constructor for a SymConst type_tag node.
1322 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1323 * symconst_type_tag.
1324 * Adds the SymConst to the start block of irg.
1326 FIRM_API ir_node *new_rd_SymConst_type_tag(dbg_info *db, ir_graph *irg,
1327 ir_mode *mode, ir_type *symbol,
1330 /** Constructor for a SymConst size node.
1332 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1333 * symconst_type_size.
1334 * Adds the SymConst to the start block of irg. */
1335 FIRM_API ir_node *new_rd_SymConst_size(dbg_info *db, ir_graph *irg,
1336 ir_mode *mode, ir_type *symbol,
1339 /** Constructor for a SymConst size node.
1341 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1342 * symconst_type_align.
1343 * Adds the SymConst to the start block of irg.
1345 FIRM_API ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg,
1346 ir_mode *mode, ir_type *symbol,
1349 /** Constructor for a simpleSel node.
1351 * This is a shortcut for the new_rd_Sel() constructor. To be used for
1352 * Sel nodes that do not select from an array, i.e., have no index
1353 * inputs. It adds the two parameters 0, NULL.
1355 * @param *db A pointer for debug information.
1356 * @param *block The IR block the node belongs to.
1357 * @param *store The memory in which the object the entity should be
1358 * selected from is allocated.
1359 * @param *objptr The object from that the Sel operation selects a
1360 * single attribute out.
1361 * @param *ent The entity to select.
1363 FIRM_API ir_node *new_rd_simpleSel(dbg_info *db, ir_node *block, ir_node *store,
1364 ir_node *objptr, ir_entity *ent);
1366 /** Constructor for a Sel node.
1368 * The select node selects an entity (field or method) from an entity
1369 * with a compound type. It explicitly specifies the entity selected.
1370 * Dynamically the node may select entities that overwrite the given
1371 * entity. If the selected entity is an array element entity the Sel
1372 * node takes the required array indices as inputs.
1374 * @param *db A pointer for debug information.
1375 * @param *block The IR block the node belongs to.
1376 * @param *store The memory in which the object the entity should be selected
1377 * from is allocated.
1378 * @param *objptr A pointer to a compound entity the Sel operation selects a
1379 * single attribute from.
1380 * @param *n_index The number of array indices needed to select an array element entity.
1381 * @param *index[] If the compound entity is an array the indices of the selected
1382 * element entity. The constructor copies this array.
1383 * @param *ent The entity to select.
1385 FIRM_API ir_node *new_rd_Sel(dbg_info *db, ir_node *block, ir_node *store,
1386 ir_node *objptr, int n_index, ir_node *index[],
1389 /** Constructor for a Call node.
1391 * Represents all kinds of method and function calls.
1393 * @param *db A pointer for debug information.
1394 * @param *block The IR block the node belongs to.
1395 * @param *store The current memory state.
1396 * @param *callee A pointer to the called procedure.
1397 * @param arity The number of procedure parameters.
1398 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1399 * @param *tp Type information of the procedure called.
1401 FIRM_API ir_node *new_rd_Call(dbg_info *db, ir_node *block, ir_node *store,
1402 ir_node *callee, int arity, ir_node *in[],
1405 /** Constructor for a Builtin node.
1407 * Represents a call of a backend-specific builtin..
1409 * @param *db A pointer for debug information.
1410 * @param *block The IR block the node belongs to.
1411 * @param *store The current memory state.
1412 * @param arity The number of procedure parameters.
1413 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1414 * @param kind The kind of the called builtin.
1415 * @param *tp Type information of the procedure called.
1417 FIRM_API ir_node *new_rd_Builtin(dbg_info *db, ir_node *block, ir_node *store,
1418 int arity, ir_node *in[], ir_builtin_kind kind,
1421 /** Constructor for a Add node.
1423 * @param *db A pointer for debug information.
1424 * @param *block The IR block the node belongs to.
1425 * @param *op1 The first operand.
1426 * @param *op2 The second operand.
1427 * @param *mode The mode of the operands and the result.
1429 FIRM_API ir_node *new_rd_Add(dbg_info *db, ir_node *block, ir_node *op1,
1430 ir_node *op2, ir_mode *mode);
1432 /** Constructor for a Sub node.
1434 * @param *db A pointer for debug information.
1435 * @param *block The IR block the node belongs to.
1436 * @param *op1 The first operand.
1437 * @param *op2 The second operand.
1438 * @param *mode The mode of the operands and the result.
1440 FIRM_API ir_node *new_rd_Sub(dbg_info *db, ir_node *block,
1441 ir_node *op1, ir_node *op2, ir_mode *mode);
1443 /** Constructor for a Minus node.
1445 * @param *db A pointer for debug information.
1446 * @param *block The IR block the node belongs to.
1447 * @param *op The operand .
1448 * @param *mode The mode of the operand and the result.
1450 FIRM_API ir_node *new_rd_Minus(dbg_info *db, ir_node *block,
1451 ir_node *op, ir_mode *mode);
1453 /** Constructor for a Mul node.
1455 * @param *db A pointer for debug information.
1456 * @param *block The IR block the node belongs to.
1457 * @param *op1 The first operand.
1458 * @param *op2 The second operand.
1459 * @param *mode The mode of the operands and the result.
1461 FIRM_API ir_node *new_rd_Mul(dbg_info *db, ir_node *block,
1462 ir_node *op1, ir_node *op2, ir_mode *mode);
1464 /** Constructor for a Mulh node.
1466 * @param *db A pointer for debug information.
1467 * @param *block The IR block the node belongs to.
1468 * @param *op1 The first operand.
1469 * @param *op2 The second operand.
1470 * @param *mode The mode of the operands and the result.
1472 FIRM_API ir_node *new_rd_Mulh(dbg_info *db, ir_node *block,
1473 ir_node *op1, ir_node *op2, ir_mode *mode);
1475 /** Constructor for a Quot node.
1477 * @param *db A pointer for debug information.
1478 * @param *block The IR block the node belongs to.
1479 * @param *memop The store needed to model exceptions
1480 * @param *op1 The first operand.
1481 * @param *op2 The second operand.
1482 * @param *mode The mode of the result.
1483 * @param state The pinned state.
1485 FIRM_API ir_node *new_rd_Quot(dbg_info *db, ir_node *block, ir_node *memop,
1486 ir_node *op1, ir_node *op2, ir_mode *mode,
1487 op_pin_state state);
1489 /** Constructor for a DivMod node.
1491 * @param *db A pointer for debug information.
1492 * @param *block The IR block the node belongs to.
1493 * @param *memop The store needed to model exceptions
1494 * @param *op1 The first operand.
1495 * @param *op2 The second operand.
1496 * @param *mode The mode of the results.
1497 * @param state The pinned state.
1499 FIRM_API ir_node *new_rd_DivMod(dbg_info *db, ir_node *block, ir_node *memop,
1500 ir_node *op1, ir_node *op2, ir_mode *mode,
1501 op_pin_state state);
1503 /** Constructor for a Div node.
1505 * @param *db A pointer for debug information.
1506 * @param *block The IR block the node belongs to.
1507 * @param *memop The store needed to model exceptions
1508 * @param *op1 The first operand.
1509 * @param *op2 The second operand.
1510 * @param *mode The mode of the result.
1511 * @param state The pinned state.
1513 FIRM_API ir_node *new_rd_Div(dbg_info *db, ir_node *block, ir_node *memop,
1514 ir_node *op1, ir_node *op2, ir_mode *mode,
1515 op_pin_state state);
1517 /** Constructor for a remainderless Div node.
1519 * @param *db A pointer for debug information.
1520 * @param *block The IR block the node belongs to.
1521 * @param *memop The store needed to model exceptions
1522 * @param *op1 The first operand.
1523 * @param *op2 The second operand.
1524 * @param *mode The mode of the result.
1525 * @param state The pinned state.
1527 FIRM_API ir_node *new_rd_DivRL(dbg_info *db, ir_node *block, ir_node *memop,
1528 ir_node *op1, ir_node *op2, ir_mode *mode,
1529 op_pin_state state);
1531 /** Constructor for a Mod node.
1533 * @param *db A pointer for debug information.
1534 * @param *block The IR block the node belongs to.
1535 * @param *memop The store needed to model exceptions
1536 * @param *op1 The first operand.
1537 * @param *op2 The second operand.
1538 * @param *mode The mode of the result.
1539 * @param state The pinned state.
1541 FIRM_API ir_node *new_rd_Mod(dbg_info *db, ir_node *block, ir_node *memop,
1542 ir_node *op1, ir_node *op2, ir_mode *mode,
1543 op_pin_state state);
1545 /** Constructor for a Abs node.
1547 * @param *db A pointer for debug information.
1548 * @param *block The IR block the node belongs to.
1549 * @param *op The operand
1550 * @param *mode The mode of the operands and the result.
1552 FIRM_API ir_node *new_rd_Abs(dbg_info *db, ir_node *block, ir_node *op,
1555 /** Constructor for a And node.
1557 * @param *db A pointer for debug information.
1558 * @param *block The IR block the node belongs to.
1559 * @param *op1 The first operand.
1560 * @param *op2 The second operand.
1561 * @param *mode The mode of the operands and the result.
1563 FIRM_API ir_node *new_rd_And(dbg_info *db, ir_node *block,
1564 ir_node *op1, ir_node *op2, ir_mode *mode);
1566 /** Constructor for a Or node.
1568 * @param *db A pointer for debug information.
1569 * @param *block The IR block the node belongs to.
1570 * @param *op1 The first operand.
1571 * @param *op2 The second operand.
1572 * @param *mode The mode of the operands and the result.
1574 FIRM_API ir_node *new_rd_Or(dbg_info *db, ir_node *block,
1575 ir_node *op1, ir_node *op2, ir_mode *mode);
1577 /** Constructor for a Eor node.
1579 * @param *db A pointer for debug information.
1580 * @param *block The IR block the node belongs to.
1581 * @param *op1 The first operand.
1582 * @param *op2 The second operand.
1583 * @param *mode The mode of the operands and the results.
1585 FIRM_API ir_node *new_rd_Eor(dbg_info *db, ir_node *block,
1586 ir_node *op1, ir_node *op2, ir_mode *mode);
1588 /** Constructor for a Not node.
1590 * @param *db A pointer for debug information.
1591 * @param *block The IR block the node belongs to.
1592 * @param *op The operand.
1593 * @param *mode The mode of the operand and the result.
1595 FIRM_API ir_node *new_rd_Not(dbg_info *db, ir_node *block, ir_node *op,
1598 /** Constructor for a Cmp node.
1600 * @param *db A pointer for debug information.
1601 * @param *block The IR block the node belongs to.
1602 * @param *op1 The first operand.
1603 * @param *op2 The second operand.
1605 FIRM_API ir_node *new_rd_Cmp(dbg_info *db, ir_node *block,
1606 ir_node *op1, ir_node *op2);
1608 /** Constructor for a Shl node.
1610 * @param *db A pointer for debug information.
1611 * @param *block The IR block the node belongs to.
1612 * @param *op The operand.
1613 * @param *k The number of bits to shift the operand .
1614 * @param *mode The mode of the operand and the result.
1616 FIRM_API ir_node *new_rd_Shl(dbg_info *db, ir_node *block,
1617 ir_node *op, ir_node *k, ir_mode *mode);
1619 /** Constructor for a Shr node.
1621 * @param *db A pointer for debug information.
1622 * @param *block The IR block the node belongs to.
1623 * @param *op The operand.
1624 * @param *k The number of bits to shift the operand .
1625 * @param *mode The mode of the operand and the result.
1627 FIRM_API ir_node *new_rd_Shr(dbg_info *db, ir_node *block,
1628 ir_node *op, ir_node *k, ir_mode *mode);
1630 /** Constructor for a Shrs node.
1632 * @param *db A pointer for debug information.
1633 * @param *block The IR block the node belongs to.
1634 * @param *op The operand.
1635 * @param *k The number of bits to shift the operand.
1636 * @param *mode The mode of the operand and the result.
1638 FIRM_API ir_node *new_rd_Shrs(dbg_info *db, ir_node *block,
1639 ir_node *op, ir_node *k, ir_mode *mode);
1641 /** Constructor for a Rotl node.
1643 * @param *db A pointer for debug information.
1644 * @param *block The IR block the node belongs to.
1645 * @param *op The operand.
1646 * @param *k The number of bits to rotate the operand.
1647 * @param *mode The mode of the operand.
1649 FIRM_API ir_node *new_rd_Rotl(dbg_info *db, ir_node *block,
1650 ir_node *op, ir_node *k, ir_mode *mode);
1653 /** Constructor for a Conv node.
1655 * @param *db A pointer for debug information.
1656 * @param *block The IR block the node belongs to.
1657 * @param *op The operand.
1658 * @param *mode The mode of this the operand muss be converted .
1660 FIRM_API ir_node *new_rd_Conv(dbg_info *db, ir_node *block, ir_node *op,
1663 /** Constructor for a strictConv node.
1665 * @param *db A pointer for debug information.
1666 * @param *block The IR block the node belongs to.
1667 * @param *op The operand.
1668 * @param *mode The mode of this the operand muss be converted .
1670 FIRM_API ir_node *new_rd_strictConv(dbg_info *db, ir_node *block,
1671 ir_node *op, ir_mode *mode);
1673 /** Constructor for a Cast node.
1675 * High level type cast.
1677 * @param *db A pointer for debug information.
1678 * @param *block The IR block the node belongs to.
1679 * @param *op The operand.
1680 * @param *to_tp The type of this the operand muss be casted .
1682 FIRM_API ir_node *new_rd_Cast(dbg_info *db, ir_node *block,
1683 ir_node *op, ir_type *to_tp);
1685 /** Constructor for a Phi node.
1687 * @param *db A pointer for debug information.
1688 * @param *block The IR block the node belongs to.
1689 * @param arity The number of predecessors
1690 * @param *in[] Array with predecessors. The constructor copies this array.
1691 * @param *mode The mode of it's inputs and output.
1693 FIRM_API ir_node *new_rd_Phi(dbg_info *db, ir_node *block, int arity,
1694 ir_node *in[], ir_mode *mode);
1696 /** Constructor for a Load node.
1698 * @param *db A pointer for debug information.
1699 * @param *block The IR block the node belongs to.
1700 * @param *store The current memory
1701 * @param *adr A pointer to the variable to be read in this memory.
1702 * @param *mode The mode of the value to be loaded.
1703 * @param flags Additional flags for alignment, volatility and pin state.
1705 FIRM_API ir_node *new_rd_Load(dbg_info *db, ir_node *block, ir_node *store,
1706 ir_node *adr, ir_mode *mode, ir_cons_flags flags);
1708 /** Constructor for a Store node.
1710 * @param *db A pointer for debug information.
1711 * @param *block The IR block the node belongs to.
1712 * @param *store The current memory
1713 * @param *adr A pointer to the variable to be read in this memory.
1714 * @param *val The value to write to this variable.
1715 * @param flags Additional flags for alignment, volatility and pin state.
1717 FIRM_API ir_node *new_rd_Store(dbg_info *db, ir_node *block, ir_node *store,
1718 ir_node *adr, ir_node *val, ir_cons_flags flags);
1720 /** Constructor for a Alloc node.
1722 * The Alloc node extends the memory by space for an entity of type alloc_type.
1724 * @param *db A pointer for debug information.
1725 * @param *block The IR block the node belongs to.
1726 * @param *store The memory which shall contain the new variable.
1727 * @param *count The number of objects to allocate.
1728 * @param *alloc_type The type of the allocated variable.
1729 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
1731 FIRM_API ir_node *new_rd_Alloc(dbg_info *db, ir_node *block, ir_node *store,
1732 ir_node *count, ir_type *alloc_type,
1733 ir_where_alloc where);
1735 /** Constructor for a Free node.
1737 * Frees the memory occupied by the entity pointed to by the pointer
1738 * arg. Type indicates the type of the entity the argument points to.
1740 * @param *db A pointer for debug information.
1741 * @param *block The IR block the node belongs to.
1742 * @param *store The memory which shall contain the new variable.
1743 * @param *ptr The pointer to the object to free.
1744 * @param *size The number of objects of type free_type to free in a sequence.
1745 * @param *free_type The type of the freed variable.
1746 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
1748 FIRM_API ir_node *new_rd_Free(dbg_info *db, ir_node *block, ir_node *store,
1749 ir_node *ptr, ir_node *size, ir_type *free_type,
1750 ir_where_alloc where);
1752 /** Constructor for a Sync node.
1754 * Merges several memory values. The node assumes that a variable
1755 * either occurs only in one of the memories, or it contains the same
1756 * value in all memories where it occurs.
1758 * @param *db A pointer for debug information.
1759 * @param *block The IR block the node belongs to.
1760 * @param arity The number of memories to synchronize.
1761 * @param *in[] An array of pointers to nodes that produce an output of type
1762 * memory. The constructor copies this array.
1764 FIRM_API ir_node *new_rd_Sync(dbg_info *db, ir_node *block, int arity,
1767 /** Constructor for a Proj node.
1769 * Projects a single value out of a tuple. The parameter proj gives the
1770 * position of the value within the tuple.
1772 * @param *db A pointer for debug information.
1773 * @param arg A node producing a tuple. The node must have mode_T.
1774 * @param *mode The mode of the value to project.
1775 * @param proj The position of the value in the tuple.
1777 FIRM_API ir_node *new_rd_Proj(dbg_info *db, ir_node *arg, ir_mode *mode,
1780 /** Constructor for a defaultProj node.
1782 * Represents the default control flow of a Switch-Cond node.
1784 * @param *db A pointer for debug information.
1785 * @param arg A node producing a tuple.
1786 * @param max_proj The end position of the value in the tuple.
1788 FIRM_API ir_node *new_rd_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
1790 /** Constructor for a Tuple node.
1792 * This is an auxiliary node to replace a node that returns a tuple
1793 * without changing the corresponding Proj nodes.
1795 * @param *db A pointer for debug information.
1796 * @param *block The IR block the node belongs to.
1797 * @param arity The number of tuple elements.
1798 * @param *in[] An array containing pointers to the nodes producing the tuple
1799 * elements. The constructor copies this array.
1801 FIRM_API ir_node *new_rd_Tuple(dbg_info *db, ir_node *block,
1802 int arity, ir_node *in[]);
1804 /** Constructor for a Id node.
1806 * This is an auxiliary node to replace a node that returns a single
1809 * @param *db A pointer for debug information.
1810 * @param *block The IR block the node belongs to.
1811 * @param *val The value
1812 * @param *mode The mode of *val.
1814 FIRM_API ir_node *new_rd_Id(dbg_info *db, ir_node *block,
1815 ir_node *val, ir_mode *mode);
1817 /** Constructor for a Confirm node.
1819 * Specifies constraints for a value. To support dataflow analyses.
1821 * Example: If the value never exceeds '100' this is expressed by placing a
1822 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
1824 * @param *db A pointer for debug information.
1825 * @param *block The IR block the node belong to.
1826 * @param *val The value we express a constraint for
1827 * @param *bound The value to compare against. Must be a firm node, typically a constant.
1828 * @param cmp The compare operation.
1830 FIRM_API ir_node *new_rd_Confirm(dbg_info *db, ir_node *block,
1831 ir_node *val, ir_node *bound, pn_Cmp cmp);
1833 /** Constructor for an Unknown node.
1835 * Represents an arbitrary value. Places the node in the start block.
1837 * @param *db A pointer for debug information.
1838 * @param *irg The IR graph the node belongs to.
1839 * @param *m The mode of the unknown value.
1841 FIRM_API ir_node *new_rd_Unknown(dbg_info *db, ir_graph *irg, ir_mode *m);
1843 /** Constructor for a Mux node.
1845 * @param *db A pointer for debug information.
1846 * @param *block The block the node belong to.
1847 * @param *sel The ir_node that calculates the boolean select.
1848 * @param *ir_true The ir_node that calculates the true result.
1849 * @param *ir_false The ir_node that calculates the false result.
1850 * @param *mode The mode of the node (and it_true and ir_false).
1852 FIRM_API ir_node *new_rd_Mux(dbg_info *db, ir_node *block, ir_node *sel,
1853 ir_node *ir_false, ir_node *ir_true,
1856 /** Constructor for a CopyB node.
1858 * @param *db A pointer for debug information.
1859 * @param *block The block the node belong to.
1860 * @param *store The current memory
1861 * @param *dst The ir_node that represents the destination address.
1862 * @param *src The ir_node that represents the source address.
1863 * @param *data_type The type of the copied data
1865 FIRM_API ir_node *new_rd_CopyB(dbg_info *db, ir_node *block, ir_node *store,
1866 ir_node *dst, ir_node *src, ir_type *data_type);
1868 /** Constructor for a InstOf node.
1870 * A High-Level Type check.
1872 * @param *db A pointer for debug information.
1873 * @param *block The IR block the node belongs to.
1874 * @param *store The memory in which the object the entity should be selected
1875 * from is allocated.
1876 * @param *objptr A pointer to a object of a class type.
1877 * @param *type The type of which objptr must be.
1879 FIRM_API ir_node *new_rd_InstOf(dbg_info *db, ir_node *block, ir_node *store,
1880 ir_node *objptr, ir_type *type);
1882 /** Constructor for a Raise node.
1884 * A High-Level Exception throw.
1886 * @param *db A pointer for debug information.
1887 * @param *block The IR block the node belongs to.
1888 * @param *store The current memory.
1889 * @param *obj A pointer to the Except variable.
1891 FIRM_API ir_node *new_rd_Raise(dbg_info *db, ir_node *block, ir_node *store,
1894 /** Constructor for a Bound node.
1896 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
1898 * @param *db A pointer for debug information.
1899 * @param *block The block the node belong to.
1900 * @param *store The current memory.
1901 * @param *idx The ir_node that represents an index.
1902 * @param *lower The ir_node that represents the lower bound for the index.
1903 * @param *upper The ir_node that represents the upper bound for the index.
1905 FIRM_API ir_node *new_rd_Bound(dbg_info *db, ir_node *block,
1906 ir_node *store, ir_node *idx, ir_node *lower,
1909 /** Constructor for a Pin node.
1911 * @param *db A pointer for debug information.
1912 * @param *block The block the node belong to.
1913 * @param *node The node which value should be pinned.
1915 FIRM_API ir_node *new_rd_Pin(dbg_info *db, ir_node *block, ir_node *node);
1917 /** Constructor for an ASM pseudo node.
1919 * @param *db A pointer for debug information.
1920 * @param *block The block the node belong to.
1921 * @param arity The number of data inputs to the node.
1922 * @param *in The array of length arity of data inputs.
1923 * @param *inputs The array of length arity of input constraints.
1924 * @param n_outs The number of data outputs to the node.
1925 * @param *outputs The array of length n_outs of output constraints.
1926 * @param n_clobber The number of clobbered registers.
1927 * @param *clobber The array of length n_clobber of clobbered registers.
1928 * @param *asm_text The assembler text.
1930 FIRM_API ir_node *new_rd_ASM(dbg_info *db, ir_node *block,
1931 int arity, ir_node *in[], ir_asm_constraint *inputs,
1932 int n_outs, ir_asm_constraint *outputs,
1933 int n_clobber, ident *clobber[], ident *asm_text);
1935 /*-------------------------------------------------------------------------*/
1936 /* The raw interface without debug support */
1937 /*-------------------------------------------------------------------------*/
1939 /** Constructor for a Block node.
1941 * Constructs a mature block with the given predecessors. Use Unknown
1942 * nodes as predecessors to construct a block if the number of
1943 * predecessors is known, but not the predecessors themselves. This
1944 * constructor does not set current_block. It not be used with
1945 * automatic Phi node construction.
1948 * @param irg The IR graph the block belongs to.
1949 * @param arity The number of control predecessors.
1950 * @param in[] An array of control predecessors. The length of
1951 * the array must be 'arity'. The constructor copies this array.
1953 FIRM_API ir_node *new_r_Block(ir_graph *irg, int arity, ir_node *in[]);
1955 /** Constructor for a Start node.
1957 * @param *irg The IR graph the node belongs to.
1958 * @param *block The IR block the node belongs to.
1960 FIRM_API ir_node *new_r_Start(ir_graph *irg, ir_node *block);
1962 /** Constructor for a End node.
1964 * @param *irg The IR graph the node belongs to.
1965 * @param *block The IR block the node belongs to.
1967 FIRM_API ir_node *new_r_End(ir_graph *irg, ir_node *block);
1969 /** Constructor for a Jmp node.
1971 * Jmp represents control flow to a single control successor.
1973 * @param *block The IR block the node belongs to.
1975 FIRM_API ir_node *new_r_Jmp(ir_node *block);
1977 /** Constructor for an IJmp node.
1979 * IJmp represents control flow to a single control successor not
1980 * statically known i.e. an indirect Jmp.
1982 * @param *block The IR block the node belongs to.
1983 * @param *tgt The IR node representing the target address.
1985 FIRM_API ir_node *new_r_IJmp(ir_node *block, ir_node *tgt);
1987 /** Constructor for a Cond node.
1989 * If c is mode_b represents a conditional branch (if/else). If c is
1990 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1991 * node, default Proj is 0.)
1993 * This is not consistent: Input to Cond is Is, Proj has as proj number
1996 * @param *block The IR block the node belongs to.
1997 * @param *c The conditions parameter.Can be of mode b or I_u.
1999 FIRM_API ir_node *new_r_Cond(ir_node *block, ir_node *c);
2001 /** Constructor for a Return node.
2003 * Returns the memory and zero or more return values. Only node that
2004 * can end regular control flow.
2006 * @param *block The IR block the node belongs to.
2007 * @param *store The state of memory.
2008 * @param arity Number of array indices.
2009 * @param *in[] Array with index inputs to the node. The constructor copies this array.
2011 FIRM_API ir_node *new_r_Return(ir_node *block, ir_node *store,
2012 int arity, ir_node *in[]);
2014 /** Constructor for a Const node.
2016 * Adds the node to the start block.
2018 * Constructor for a Const node. The constant represents a target
2019 * value. Sets the type information to type_unknown. (No more
2020 * supported: If tv is entity derives a somehow useful type.)
2021 * Derives mode from passed tarval.
2023 * @param *irg The IR graph the node belongs to.
2024 * @param *con Points to an entry in the constant table.
2026 FIRM_API ir_node *new_r_Const(ir_graph *irg, tarval *con);
2028 /** Constructor for a Const node.
2030 * Adds the node to the start block.
2032 * Constructor for a Const node. The constant represents a target
2033 * value. Sets the type information to type_unknown. (No more
2034 * supported: If tv is entity derives a somehow useful type.)
2036 * @param *irg The IR graph the node belongs to.
2037 * @param *mode The mode of the operands and the results.
2038 * @param value A value from which the tarval is made.
2040 FIRM_API ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value);
2042 /** Constructor for a Const_type node.
2044 * Adds the node to the start block.
2046 * The constant represents a target value. This constructor sets high
2047 * level type information for the constant value.
2048 * Derives mode from passed tarval.
2050 * @param *irg The IR graph the node belongs to.
2051 * @param *con Points to an entry in the constant table.
2052 * @param *tp The type of the constant.
2054 FIRM_API ir_node *new_r_Const_type(ir_graph *irg, tarval *con, ir_type *tp);
2056 /** Constructor for a SymConst node.
2058 * This is the constructor for a symbolic constant.
2059 * There are several kinds of symbolic constants:
2060 * - symconst_type_tag The symbolic constant represents a type tag. The
2061 * type the tag stands for is given explicitly.
2062 * - symconst_type_size The symbolic constant represents the size of a type.
2063 * The type of which the constant represents the size
2064 * is given explicitly.
2065 * - symconst_type_align The symbolic constant represents the alignment of a
2066 * type. The type of which the constant represents the
2067 * size is given explicitly.
2068 * - symconst_addr_ent The symbolic constant represents the address of an
2069 * entity (variable or method). The variable is given
2070 * explicitly by a firm entity.
2071 * - symconst_ofs_ent The symbolic constant represents the offset of an
2072 * entity in its owner type.
2073 * - symconst_enum_const The symbolic constant is a enumeration constant of
2074 * an enumeration type.
2076 * Inputs to the node:
2077 * No inputs except the block it belongs to.
2078 * Outputs of the node.
2079 * An unsigned integer (I_u) or a pointer (P).
2081 * Mention union in declaration so that the firmjni generator recognizes that
2082 * it can not cast the argument to an int.
2084 * @param *irg The IR graph the node belongs to.
2085 * @param mode The mode for the SymConst.
2086 * @param value A type, ident, entity or enum constant depending on the
2088 * @param kind The kind of the symbolic constant, see the list above
2090 FIRM_API ir_node *new_r_SymConst(ir_graph *irg, ir_mode *mode,
2091 union symconst_symbol value,
2092 symconst_kind kind);
2094 /** Constructor for a simpleSel node.
2096 * This is a shortcut for the new_d_Sel() constructor. To be used for
2097 * Sel nodes that do not select from an array, i.e., have no index
2098 * inputs. It adds the two parameters 0, NULL.
2100 * @param *block The IR block the node belongs to.
2101 * @param *store The memory in which the object the entity should be selected
2102 * from is allocated.
2103 * @param *objptr The object from that the Sel operation selects a
2104 * single attribute out.
2105 * @param *ent The entity to select.
2107 FIRM_API ir_node *new_r_simpleSel(ir_node *block, ir_node *store,
2108 ir_node *objptr, ir_entity *ent);
2110 /** Constructor for a Sel node.
2112 * The select node selects an entity (field or method) from an entity
2113 * with a compound type. It explicitly specifies the entity selected.
2114 * Dynamically the node may select entities that overwrite the given
2115 * entity. If the selected entity is an array element entity the Sel
2116 * node takes the required array indices as inputs.
2118 * @param *block The IR block the node belongs to.
2119 * @param *store The memory in which the object the entity should be selected
2120 * from is allocated.
2121 * @param *objptr A pointer to a compound entity the Sel operation selects a
2122 * single attribute from.
2123 * @param *n_index The number of array indices needed to select an array element entity.
2124 * @param *index[] If the compound entity is an array the indices of the selected
2125 * element entity. The constructor copies this array.
2126 * @param *ent The entity to select.
2128 FIRM_API ir_node *new_r_Sel(ir_node *block, ir_node *store,
2129 ir_node *objptr, int n_index, ir_node *index[],
2132 /** Constructor for a Call node.
2134 * Represents all kinds of method and function calls.
2136 * @param *block The IR block the node belongs to.
2137 * @param *store The actual store.
2138 * @param *callee A pointer to the called procedure.
2139 * @param arity The number of procedure parameters.
2140 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2141 * @param *tp Type information of the procedure called.
2143 FIRM_API ir_node *new_r_Call(ir_node *block, ir_node *store,
2144 ir_node *callee, int arity, ir_node *in[],
2147 /** Constructor for a Builtin node.
2149 * Represents a call of a backend-specific builtin..
2151 * @param *block The IR block the node belongs to.
2152 * @param *store The actual store.
2153 * @param arity The number of procedure parameters.
2154 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2155 * @param kind The kind of the called builtin.
2156 * @param *tp Type information of the procedure called.
2158 FIRM_API ir_node *new_r_Builtin(ir_node *block, ir_node *store,
2159 int arity, ir_node *in[], ir_builtin_kind kind,
2162 /** Constructor for a Add node.
2164 * @param *block The IR block the node belongs to.
2165 * @param *op1 The first operand.
2166 * @param *op2 The second operand.
2167 * @param *mode The mode of the operands and the result.
2169 FIRM_API ir_node *new_r_Add(ir_node *block, ir_node *op1, ir_node *op2,
2173 * Constructor for a Sub node.
2175 * @param *block The IR block the node belongs to.
2176 * @param *op1 The first operand.
2177 * @param *op2 The second operand.
2178 * @param *mode The mode of the operands and the results.
2180 FIRM_API ir_node *new_r_Sub(ir_node *block, ir_node *op1, ir_node *op2,
2183 /** Constructor for a Minus node.
2185 * @param *block The IR block the node belongs to.
2186 * @param *op The operand.
2187 * @param *mode The mode of the operand and the result.
2189 FIRM_API ir_node *new_r_Minus(ir_node *block, ir_node *op, ir_mode *mode);
2191 /** Constructor for a Mul node.
2193 * @param *block The IR block the node belongs to.
2194 * @param *op1 The first operand.
2195 * @param *op2 The second operand.
2196 * @param *mode The mode of the operands and the result.
2198 FIRM_API ir_node *new_r_Mul(ir_node *block, ir_node *op1, ir_node *op2,
2201 /** Constructor for a Mulh node.
2203 * @param *block The IR block the node belongs to.
2204 * @param *op1 The first operand.
2205 * @param *op2 The second operand.
2206 * @param *mode The mode of the operands and the result.
2208 FIRM_API ir_node *new_r_Mulh(ir_node *block, ir_node *op1, ir_node *op2,
2211 /** Constructor for a Quot node.
2213 * @param *block The IR block the node belongs to.
2214 * @param *memop The store needed to model exceptions
2215 * @param *op1 The first operand.
2216 * @param *op2 The second operand.
2217 * @param *mode The mode of the result.
2218 * @param state The pinned state.
2220 FIRM_API ir_node *new_r_Quot(ir_node *block, ir_node *memop,
2221 ir_node *op1, ir_node *op2, ir_mode *mode,
2222 op_pin_state state);
2224 /** Constructor for a DivMod node.
2226 * @param *block The IR block the node belongs to.
2227 * @param *memop The store needed to model exceptions
2228 * @param *op1 The first operand.
2229 * @param *op2 The second operand.
2230 * @param *mode The mode of the results.
2231 * @param state The pinned state.
2233 FIRM_API ir_node *new_r_DivMod(ir_node *block, ir_node *memop,
2234 ir_node *op1, ir_node *op2, ir_mode *mode,
2235 op_pin_state state);
2237 /** Constructor for a Div node.
2239 * @param *block The IR block the node belongs to.
2240 * @param *memop The store needed to model exceptions
2241 * @param *op1 The first operand.
2242 * @param *op2 The second operand.
2243 * @param *mode The mode of the result.
2244 * @param state The pinned state.
2246 FIRM_API ir_node *new_r_Div(ir_node *block, ir_node *memop,
2247 ir_node *op1, ir_node *op2, ir_mode *mode,
2248 op_pin_state state);
2250 /** Constructor for a remainderless Div node.
2252 * @param *block The IR block the node belongs to.
2253 * @param *memop The store needed to model exceptions
2254 * @param *op1 The first operand.
2255 * @param *op2 The second operand.
2256 * @param *mode The mode of the result.
2257 * @param state The pinned state.
2259 FIRM_API ir_node *new_r_DivRL(ir_node *block, ir_node *memop,
2260 ir_node *op1, ir_node *op2, ir_mode *mode,
2261 op_pin_state state);
2263 /** Constructor for a Mod node.
2265 * @param *block The IR block the node belongs to.
2266 * @param *memop The store needed to model exceptions
2267 * @param *op1 The first operand.
2268 * @param *op2 The second operand.
2269 * @param *mode The mode of the result.
2270 * @param state The pinned state.
2272 FIRM_API ir_node *new_r_Mod(ir_node *block, ir_node *memop,
2273 ir_node *op1, ir_node *op2, ir_mode *mode,
2274 op_pin_state state);
2276 /** Constructor for a Abs node.
2278 * @param *block The IR block the node belongs to.
2279 * @param *op The operand
2280 * @param *mode The mode of the operands and the result.
2282 FIRM_API ir_node *new_r_Abs(ir_node *block, ir_node *op, ir_mode *mode);
2284 /** Constructor for a And node.
2286 * @param *block The IR block the node belongs to.
2287 * @param *op1 The first operand.
2288 * @param *op2 The second operand.
2289 * @param *mode The mode of the operands and the result.
2291 FIRM_API ir_node *new_r_And(ir_node *block, ir_node *op1, ir_node *op2,
2294 /** Constructor for a Or node.
2296 * @param *block The IR block the node belongs to.
2297 * @param *op1 The first operand.
2298 * @param *op2 The second operand.
2299 * @param *mode The mode of the operands and the result.
2301 FIRM_API ir_node *new_r_Or(ir_node *block, ir_node *op1, ir_node *op2,
2304 /** Constructor for a Eor node.
2306 * @param *block The IR block the node belongs to.
2307 * @param *op1 The first operand.
2308 * @param *op2 The second operand.
2309 * @param *mode The mode of the operands and the results.
2311 FIRM_API ir_node *new_r_Eor(ir_node *block, ir_node *op1, ir_node *op2,
2314 /** Constructor for a Not node.
2316 * @param *block The IR block the node belongs to.
2317 * @param *op The operand.
2318 * @param *mode The mode of the operand and the result.
2320 FIRM_API ir_node *new_r_Not(ir_node *block, ir_node *op, ir_mode *mode);
2322 /** Constructor for a Cmp node.
2324 * @param *block The IR block the node belongs to.
2325 * @param *op1 The first operand.
2326 * @param *op2 The second operand.
2328 FIRM_API ir_node *new_r_Cmp(ir_node *block, ir_node *op1, ir_node *op2);
2330 /** Constructor for a Shl node.
2332 * @param *block The IR block the node belongs to.
2333 * @param *op The operand.
2334 * @param *k The number of bits to shift the operand .
2335 * @param *mode The mode of the operand and the result.
2337 FIRM_API ir_node *new_r_Shl(ir_node *block, ir_node *op, ir_node *k,
2340 /** Constructor for a Shr node.
2342 * @param *block The IR block the node belongs to.
2343 * @param *op The operand.
2344 * @param *k The number of bits to shift the operand .
2345 * @param *mode The mode of the operand and the result.
2347 FIRM_API ir_node *new_r_Shr(ir_node *block, ir_node *op, ir_node *k,
2351 * Constructor for a Shrs node.
2353 * @param *block The IR block the node belongs to.
2354 * @param *op The operand.
2355 * @param *k The number of bits to shift the operand.
2356 * @param *mode The mode of the operand and the result.
2358 FIRM_API ir_node *new_r_Shrs(ir_node *block, ir_node *op, ir_node *k,
2361 /** Constructor for a Rotl node.
2363 * @param *block The IR block the node belongs to.
2364 * @param *op The operand.
2365 * @param *k The number of bits to rotate the operand.
2366 * @param *mode The mode of the operand.
2368 FIRM_API ir_node *new_r_Rotl(ir_node *block, ir_node *op, ir_node *k,
2371 /** Constructor for a Conv node.
2373 * @param *block The IR block the node belongs to.
2374 * @param *op The operand.
2375 * @param *mode The mode of this the operand muss be converted .
2377 FIRM_API ir_node *new_r_Conv(ir_node *block, ir_node *op, ir_mode *mode);
2379 /** Constructor for a strict Conv node.
2381 * @param *block The IR block the node belongs to.
2382 * @param *op The operand.
2383 * @param *mode The mode of this the operand muss be converted .
2385 FIRM_API ir_node *new_r_strictConv(ir_node *block, ir_node *op, ir_mode *mode);
2387 /** Constructor for a Cast node.
2389 * High level type cast
2391 * @param *block The IR block the node belongs to.
2392 * @param *op The operand.
2393 * @param *to_tp The type of this the operand muss be casted .
2395 FIRM_API ir_node *new_r_Cast(ir_node *block, ir_node *op, ir_type *to_tp);
2397 /** Constructor for a Phi node.
2399 * @param *block The IR block the node belongs to.
2400 * @param arity The number of predecessors
2401 * @param *in[] Array with predecessors. The constructor copies this array.
2402 * @param *mode The mode of it's inputs and output.
2404 FIRM_API ir_node *new_r_Phi(ir_node *block, int arity, ir_node *in[],
2407 /** Constructor for a Load node.
2409 * @param *block The IR block the node belongs to.
2410 * @param *store The current memory
2411 * @param *adr A pointer to the variable to be read in this memory.
2412 * @param *mode The mode of the value to be loaded.
2413 * @param flags Additional flags for alignment, volatility and pin state.
2415 FIRM_API ir_node *new_r_Load(ir_node *block, ir_node *store,
2416 ir_node *adr, ir_mode *mode, ir_cons_flags flags);
2418 /** Constructor for a Store node.
2420 * @param *block The IR block the node belongs to.
2421 * @param *store The current memory
2422 * @param *adr A pointer to the variable to be read in this memory.
2423 * @param *val The value to write to this variable.
2424 * @param flags Additional flags for alignment, volatility and pin state.
2426 FIRM_API ir_node *new_r_Store(ir_node *block, ir_node *store,
2427 ir_node *adr, ir_node *val, ir_cons_flags flags);
2429 /** Constructor for a Alloc node.
2431 * The Alloc node extends the memory by space for an entity of type alloc_type.
2433 * @param *block The IR block the node belongs to.
2434 * @param *store The memory which shall contain the new variable.
2435 * @param *count The number of objects to allocate.
2436 * @param *alloc_type The type of the allocated variable.
2437 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2439 FIRM_API ir_node *new_r_Alloc(ir_node *block, ir_node *store,
2440 ir_node *count, ir_type *alloc_type,
2441 ir_where_alloc where);
2443 /** Constructor for a Free node.
2445 * Frees the memory occupied by the entity pointed to by the pointer
2446 * arg. Type indicates the type of the entity the argument points to.
2448 * @param *block The IR block the node belongs to.
2449 * @param *store The memory which shall contain the new variable.
2450 * @param *ptr The pointer to the object to free.
2451 * @param *size The number of objects of type free_type to free in a sequence.
2452 * @param *free_type The type of the freed variable.
2453 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2455 FIRM_API ir_node *new_r_Free(ir_node *block, ir_node *store, ir_node *ptr,
2456 ir_node *size, ir_type *free_type,
2457 ir_where_alloc where);
2459 /** Constructor for a Sync node.
2461 * Merges several memory values. The node assumes that a variable
2462 * either occurs only in one of the memories, or it contains the same
2463 * value in all memories where it occurs.
2465 * @param *block The IR block the node belongs to.
2466 * @param arity The number of memories to synchronize.
2467 * @param *in[] An array of pointers to nodes that produce an output of type memory.
2468 * The constructor copies this array.
2470 FIRM_API ir_node *new_r_Sync(ir_node *block, int arity, ir_node *in[]);
2472 /** Constructor for a Proj node.
2474 * Projects a single value out of a tuple. The parameter proj gives the
2475 * position of the value within the tuple.
2477 * @param arg A node producing a tuple.
2478 * @param mode The mode of the value to project.
2479 * @param proj The position of the value in the tuple.
2481 FIRM_API ir_node *new_r_Proj(ir_node *arg, ir_mode *mode, long proj);
2483 /** Constructor for a defaultProj node.
2485 * Represents the default control flow of a Switch-Cond node.
2487 * @param arg A node producing a tuple.
2488 * @param max_proj The end position of the value in the tuple.
2490 FIRM_API ir_node *new_r_defaultProj(ir_node *arg, long max_proj);
2493 /** Constructor for a Tuple node.
2495 * This is an auxiliary node to replace a node that returns a tuple
2496 * without changing the corresponding Proj nodes.
2498 * @param *block The IR block the node belongs to.
2499 * @param arity The number of tuple elements.
2500 * @param *in[] An array containing pointers to the nodes producing the tuple elements.
2501 * The constructor copies this array.
2503 FIRM_API ir_node *new_r_Tuple(ir_node *block, int arity, ir_node *in[]);
2505 /** Constructor for a Id node.
2507 * This is an auxiliary node to replace a node that returns a single
2510 * @param *block The IR block the node belongs to.
2511 * @param *val The operand to Id.
2512 * @param *mode The mode of *val.
2514 FIRM_API ir_node *new_r_Id(ir_node *block, ir_node *val, ir_mode *mode);
2516 /** Constructor for a Bad node.
2518 * Returns the unique Bad node of the graph. The same as
2521 * @param *irg The IR graph the node belongs to.
2523 FIRM_API ir_node *new_r_Bad(ir_graph *irg);
2525 /** Constructor for a Confirm node.
2527 * Specifies constraints for a value. To support dataflow analyses.
2529 * Example: If the value never exceeds '100' this is expressed by placing a
2530 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
2532 * @param *block The IR block the node belong to.
2533 * @param *val The value we express a constraint for
2534 * @param *bound The value to compare against. Must be a firm node, typically a constant.
2535 * @param cmp The compare operation.
2537 FIRM_API ir_node *new_r_Confirm(ir_node *block, ir_node *val, ir_node *bound,
2540 /** Constructor for a Unknown node.
2542 * Represents an arbitrary value. Places the node in
2545 * @param *irg The IR graph the node belongs to.
2546 * @param *m The mode of the unknown value.
2548 FIRM_API ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2550 /** Constructor for a NoMem node.
2552 * Returns the unique NoMem node of the graph. The same as
2555 * @param *irg The IR graph the node belongs to.
2557 FIRM_API ir_node *new_r_NoMem(ir_graph *irg);
2559 /** Constructor for a Mux node.
2561 * @param *block The block the node belong to.
2562 * @param *sel The ir_node that calculates the boolean select.
2563 * @param *ir_true The ir_node that calculates the true result.
2564 * @param *ir_false The ir_node that calculates the false result.
2565 * @param *mode The mode of the node (and it_true and ir_false).
2567 FIRM_API ir_node *new_r_Mux(ir_node *block, ir_node *sel,
2568 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2570 /** Constructor for a CopyB node.
2572 * @param *block The block the node belong to.
2573 * @param *store The current memory
2574 * @param *dst The ir_node that represents the destination address.
2575 * @param *src The ir_node that represents the source address.
2576 * @param *data_type The type of the copied data
2578 FIRM_API ir_node *new_r_CopyB(ir_node *block, ir_node *store,
2579 ir_node *dst, ir_node *src, ir_type *data_type);
2581 /** Constructor for a InstOf node.
2583 * A High-Level Type check.
2585 * @param *block The block the node belong to.
2586 * @param *store The memory in which the object the entity should be selected
2587 * from is allocated.
2588 * @param *objptr A pointer to a object of a class type.
2589 * @param *type The type of which objptr must be.
2591 FIRM_API ir_node *new_r_InstOf(ir_node *block, ir_node *store,
2592 ir_node *objptr, ir_type *type);
2594 /** Constructor for a Raise node.
2596 * A High-Level Exception throw.
2598 * @param *block The IR block the node belongs to.
2599 * @param *store The current memory.
2600 * @param *obj A pointer to the Except variable.
2602 FIRM_API ir_node *new_r_Raise(ir_node *block, ir_node *store, ir_node *obj);
2604 /** Constructor for a Bound node.
2606 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
2608 * @param *block The block the node belong to.
2609 * @param *store The current memory.
2610 * @param *idx The ir_node that represents an index.
2611 * @param *lower The ir_node that represents the lower bound for the index.
2612 * @param *upper The ir_node that represents the upper bound for the index.
2614 FIRM_API ir_node *new_r_Bound(ir_node *block, ir_node *store,
2615 ir_node *idx, ir_node *lower, ir_node *upper);
2617 /** Constructor for a Pin node.
2619 * @param *block The block the node belong to.
2620 * @param *node The node which value should be pinned.
2622 FIRM_API ir_node *new_r_Pin(ir_node *block, ir_node *node);
2624 /** Constructor for an ASM pseudo node.
2626 * @param *block The block the node belong to.
2627 * @param arity The number of data inputs to the node.
2628 * @param *in The array of length arity of data inputs.
2629 * @param *inputs The array of length arity of input constraints.
2630 * @param n_outs The number of data outputs to the node.
2631 * @param *outputs The array of length n_outs of output constraints.
2632 * @param n_clobber The number of clobbered registers.
2633 * @param *clobber The array of length n_clobber of clobbered registers.
2634 * @param *asm_text The assembler text.
2636 FIRM_API ir_node *new_r_ASM(ir_node *block,
2637 int arity, ir_node *in[], ir_asm_constraint *inputs,
2638 int n_outs, ir_asm_constraint *outputs,
2639 int n_clobber, ident *clobber[], ident *asm_text);
2641 /*-----------------------------------------------------------------------*/
2642 /* The block oriented interface */
2643 /*-----------------------------------------------------------------------*/
2645 /** Sets the current block in which the following constructors place the
2646 * nodes they construct.
2648 * @param target The new current block.
2650 FIRM_API void set_cur_block(ir_node *target);
2652 /** Returns the current block of the current graph. */
2653 FIRM_API ir_node *get_cur_block(void);
2655 /** Constructor for a Block node.
2657 * Adds the block to the graph in current_ir_graph. Constructs a Block
2658 * with a fixed number of predecessors.
2660 * @param *db A Pointer for debug information.
2661 * @param arity The number of control predecessors.
2662 * @param in[] An array of control predecessors. The length of
2663 * the array must be 'arity'.
2665 FIRM_API ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
2667 /** Constructor for a Start node.
2669 * Adds the node to the block in current_ir_block.
2671 * @param *db A pointer for debug information.
2673 FIRM_API ir_node *new_d_Start(dbg_info *db);
2675 /** Constructor for a End node.
2677 * Adds the node to the block in current_ir_block.
2679 * @param *db A pointer for debug information.
2681 FIRM_API ir_node *new_d_End(dbg_info *db);
2683 /** Constructor for a Jmp node.
2685 * Adds the node to the block in current_ir_block.
2687 * Jmp represents control flow to a single control successor.
2689 * @param *db A pointer for debug information.
2691 FIRM_API ir_node *new_d_Jmp(dbg_info *db);
2693 /** Constructor for an IJmp node.
2695 * IJmp represents control flow to a single control successor not
2696 * statically known i.e. an indirect Jmp.
2698 * @param *db A pointer for debug information.
2699 * @param *tgt The IR node representing the target address.
2701 FIRM_API ir_node *new_d_IJmp(dbg_info *db, ir_node *tgt);
2703 /** Constructor for a Cond node.
2705 * Adds the node to the block in current_ir_block.
2707 * If c is mode_b represents a conditional branch (if/else). If c is
2708 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2709 * node, default Proj is 0.)
2711 * This is not consistent: Input to Cond is Is, Proj has as proj number
2714 * @param *db A pointer for debug information.
2715 * @param *c The conditions parameter.Can be of mode b or I_u.
2717 FIRM_API ir_node *new_d_Cond(dbg_info *db, ir_node *c);
2719 /** Constructor for a Return node.
2721 * Adds the node to the block in current_ir_block.
2723 * Returns the memory and zero or more return values. Only node that
2724 * can end regular control flow.
2726 * @param *db A pointer for debug information.
2727 * @param *store The state of memory.
2728 * @param arity Number of array indices.
2729 * @param *in Array with index inputs to the node.
2731 FIRM_API ir_node *new_d_Return(dbg_info *db, ir_node *store,
2732 int arity, ir_node *in[]);
2734 /** Constructor for a Const_type node.
2736 * Adds the node to the start block.
2738 * The constant represents a target value. This constructor sets high
2739 * level type information for the constant value.
2740 * Derives mode from passed tarval.
2742 * @param *db A pointer for debug information.
2743 * @param *con Points to an entry in the constant table. This pointer is
2744 added to the attributes of the node.
2745 * @param *tp The type of the constant.
2747 FIRM_API ir_node *new_d_Const_type(dbg_info *db, tarval *con, ir_type *tp);
2749 /** Constructor for a Const node.
2751 * Adds the node to the block in current_ir_block.
2753 * Constructor for a Const node. The constant represents a target
2754 * value. Sets the type information to type_unknown. (No more
2755 * supported: If tv is entity derives a somehow useful type.)
2756 * Derives mode from passed tarval.
2758 * @param *db A pointer for debug information.
2759 * @param *con Points to an entry in the constant table. This pointer is added
2760 * to the attributes of the node.
2762 FIRM_API ir_node *new_d_Const(dbg_info *db, tarval *con);
2765 * @see new_rd_Const_long()
2767 * @param *db A pointer for debug information.
2768 * @param *mode The mode of the operands and results.
2769 * @param value A value from which the tarval is made.
2771 FIRM_API ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value);
2773 /** Constructor for a SymConst_type node.
2775 * This is the constructor for a symbolic constant.
2776 * There are several kinds of symbolic constants:
2777 * - symconst_type_tag The symbolic constant represents a type tag. The
2778 * type the tag stands for is given explicitly.
2779 * - symconst_type_size The symbolic constant represents the size of a type.
2780 * The type of which the constant represents the size
2781 * is given explicitly.
2782 * - symconst_type_align The symbolic constant represents the alignment of a
2783 * type. The type of which the constant represents the
2784 * size is given explicitly.
2785 * - symconst_addr_ent The symbolic constant represents the address of an
2786 * entity (variable or method). The variable is given
2787 * explicitly by a firm entity.
2788 * - symconst_ofs_ent The symbolic constant represents the offset of an
2789 * entity in its owner type.
2790 * - symconst_enum_const The symbolic constant is a enumeration constant of
2791 * an enumeration type.
2793 * Inputs to the node:
2794 * No inputs except the block it belongs to.
2795 * Outputs of the node.
2796 * An unsigned integer (I_u) or a pointer (P).
2798 * Mention union in declaration so that the firmjni generator recognizes that
2799 * it can not cast the argument to an int.
2801 * @param *db A pointer for debug information.
2802 * @param mode The mode for the SymConst.
2803 * @param value A type, ident, entity or enum constant depending on the
2805 * @param kind The kind of the symbolic constant, see the list above
2806 * @param tp The source type of the constant.
2808 FIRM_API ir_node *new_d_SymConst_type(dbg_info *db, ir_mode *mode,
2809 union symconst_symbol value,
2810 symconst_kind kind, ir_type *tp);
2812 /** Constructor for a SymConst node.
2814 * Same as new_d_SymConst_type, except that it sets the type to type_unknown.
2816 FIRM_API ir_node *new_d_SymConst(dbg_info *db, ir_mode *mode,
2817 union symconst_symbol value,
2818 symconst_kind kind);
2820 /** Constructor for a simpleSel node.
2822 * This is a shortcut for the new_d_Sel() constructor. To be used for
2823 * Sel nodes that do not select from an array, i.e., have no index
2824 * inputs. It adds the two parameters 0, NULL.
2826 * @param *db A pointer for debug information.
2827 * @param *store The memory in which the object the entity should be
2828 * selected from is allocated.
2829 * @param *objptr The object from that the Sel operation selects a
2830 * single attribute out.
2831 * @param *ent The entity to select.
2833 FIRM_API ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr,
2836 /** Constructor for a Sel node.
2838 * The select node selects an entity (field or method) from an entity
2839 * with a compound type. It explicitly specifies the entity selected.
2840 * Dynamically the node may select entities that overwrite the given
2841 * entity. If the selected entity is an array element entity the Sel
2842 * node takes the required array indices as inputs.
2843 * Adds the node to the block in current_ir_block.
2845 * @param *db A pointer for debug information.
2846 * @param *store The memory in which the object the entity should be selected
2847 * from is allocated.
2848 * @param *objptr A pointer to a compound entity the Sel operation selects a
2849 * single attribute from.
2850 * @param arity The number of array indices needed to select an array element entity.
2851 * @param *in[] If the compound entity is an array the indices of the selected
2852 * element entity. The constructor copies this array.
2853 * @param *ent The entity to select.
2855 FIRM_API ir_node *new_d_Sel(dbg_info *db, ir_node *store, ir_node *objptr,
2856 int arity, ir_node *in[], ir_entity *ent);
2858 /** Constructor for a Call node.
2860 * Represents all kinds of method and function calls.
2861 * Adds the node to the block in current_ir_block.
2863 * @param *db A pointer for debug information.
2864 * @param *store The actual store.
2865 * @param *callee A pointer to the called procedure.
2866 * @param arity The number of procedure parameters.
2867 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2868 * @param *tp Type information of the procedure called.
2870 FIRM_API ir_node *new_d_Call(dbg_info *db, ir_node *store, ir_node *callee,
2871 int arity, ir_node *in[], ir_type *tp);
2873 /** Constructor for a Builtin node.
2875 * Represents a call of a backend-specific builtin..
2876 * Adds the node to the block in current_ir_block.
2878 * @param *db A pointer for debug information.
2879 * @param *store The actual store.
2880 * @param arity The number of procedure parameters.
2881 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2882 * @param kind The kind of the called builtin.
2883 * @param *tp Type information of the procedure called.
2885 FIRM_API ir_node *new_d_Builtin(dbg_info *db, ir_node *store,
2886 int arity, ir_node *in[],
2887 ir_builtin_kind kind, ir_type *tp);
2889 /** Constructor for a Add node.
2891 * Adds the node to the block in current_ir_block.
2893 * @param *db A pointer for debug information.
2894 * @param *op1 The first operand.
2895 * @param *op2 The second operand.
2896 * @param *mode The mode of the operands and the result.
2898 FIRM_API ir_node *new_d_Add(dbg_info *db, ir_node *op1, ir_node *op2,
2901 /** Constructor for a Sub node.
2903 * Adds the node to the block in current_ir_block.
2905 * @param *db A pointer for debug information.
2906 * @param *op1 The first operand.
2907 * @param *op2 The second operand.
2908 * @param *mode The mode of the operands and the result.
2910 FIRM_API ir_node *new_d_Sub(dbg_info *db, ir_node *op1, ir_node *op2,
2913 /** Constructor for a Minus node.
2915 * Adds the node to the block in current_ir_block.
2917 * @param *db A pointer for debug information.
2918 * @param *op The operand .
2919 * @param *mode The mode of the operand and the result.
2921 FIRM_API ir_node *new_d_Minus(dbg_info *db, ir_node *op, ir_mode *mode);
2923 /** Constructor for a Mul 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_Mul(dbg_info *db, ir_node *op1, ir_node *op2,
2935 /** Constructor for a Mulh 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_Mulh(dbg_info *db, ir_node *op1, ir_node *op2,
2947 /** Constructor for a Quot node.
2949 * Adds the node to the block in current_ir_block.
2951 * @param *db A pointer for debug information.
2952 * @param *memop The store needed to model exceptions
2953 * @param *op1 The first operand.
2954 * @param *op2 The second operand.
2955 * @param *mode The mode of the result.
2956 * @param state The pinned state.
2958 FIRM_API ir_node *new_d_Quot(dbg_info *db, ir_node *memop,
2959 ir_node *op1, ir_node *op2, ir_mode *mode,
2960 op_pin_state state);
2962 /** Constructor for a DivMod node.
2964 * Adds the node to the block in current_ir_block.
2966 * @param *db A pointer for debug information.
2967 * @param *memop The store needed to model exceptions
2968 * @param *op1 The first operand.
2969 * @param *op2 The second operand.
2970 * @param *mode The mode of the results.
2971 * @param state The pinned state.
2973 FIRM_API ir_node *new_d_DivMod(dbg_info *db, ir_node *memop, ir_node *op1,
2974 ir_node *op2, ir_mode *mode, op_pin_state state);
2976 /** Constructor for a Div node.
2978 * Adds the node to the block in current_ir_block.
2980 * @param *db A pointer for debug information.
2981 * @param *memop The store needed to model exceptions
2982 * @param *op1 The first operand.
2983 * @param *op2 The second operand.
2984 * @param *mode The mode of the result.
2985 * @param state The pinned state.
2987 FIRM_API ir_node *new_d_Div(dbg_info *db, ir_node *memop, ir_node *op1,
2988 ir_node *op2, ir_mode *mode, op_pin_state state);
2990 /** Constructor for a remainderless Div node.
2992 * Adds the node to the block in current_ir_block.
2994 * @param *db A pointer for debug information.
2995 * @param *memop The store needed to model exceptions
2996 * @param *op1 The first operand.
2997 * @param *op2 The second operand.
2998 * @param *mode The mode of the result.
2999 * @param state The pinned state.
3001 FIRM_API ir_node *new_d_DivRL(dbg_info *db, ir_node *memop,
3002 ir_node *op1, ir_node *op2, ir_mode *mode,
3003 op_pin_state state);
3005 /** Constructor for a Mod node.
3007 * Adds the node to the block in current_ir_block.
3009 * @param *db A pointer for debug information.
3010 * @param *memop The store needed to model exceptions
3011 * @param *op1 The first operand.
3012 * @param *op2 The second operand.
3013 * @param *mode The mode of the result.
3014 * @param state The pinned state.
3016 FIRM_API ir_node *new_d_Mod(dbg_info *db, ir_node *memop,
3017 ir_node *op1, ir_node *op2, ir_mode *mode,
3018 op_pin_state state);
3020 /** Constructor for a Abs node.
3022 * Adds the node to the block in current_ir_block.
3024 * @param *db A pointer for debug information.
3025 * @param *op The operand
3026 * @param *mode The mode of the operands and the result.
3028 FIRM_API ir_node *new_d_Abs(dbg_info *db, ir_node *op, ir_mode *mode);
3030 /** Constructor for a And node.
3032 * Adds the node to the block in current_ir_block.
3034 * @param *db A pointer for debug information.
3035 * @param *op1 The first operand.
3036 * @param *op2 The second operand.
3037 * @param *mode The mode of the operands and the result.
3039 FIRM_API ir_node *new_d_And(dbg_info *db, ir_node *op1, ir_node *op2,
3042 /** Constructor for a Or node.
3044 * Adds the node to the block in current_ir_block.
3046 * @param *db A pointer for debug information.
3047 * @param *op1 The first operand.
3048 * @param *op2 The second operand.
3049 * @param *mode The mode of the operands and the result.
3051 FIRM_API ir_node *new_d_Or(dbg_info *db, ir_node *op1, ir_node *op2,
3054 /** Constructor for a Eor 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 results.
3063 FIRM_API ir_node *new_d_Eor(dbg_info *db, ir_node *op1, ir_node *op2,
3066 /** Constructor for a Not node.
3068 * Adds the node to the block in current_ir_block.
3070 * @param *db A pointer for debug information.
3071 * @param *op The operand.
3072 * @param *mode The mode of the operand and the result.
3074 FIRM_API ir_node *new_d_Not(dbg_info *db, ir_node *op, ir_mode *mode);
3076 /** Constructor for a Shl node.
3078 * Adds the node to the block in current_ir_block.
3080 * @param *db A pointer for debug information.
3081 * @param *op The operand.
3082 * @param *k The number of bits to shift the operand .
3083 * @param *mode The mode of the operand and the result.
3085 FIRM_API ir_node *new_d_Shl(dbg_info *db, ir_node *op, ir_node *k,
3088 /** Constructor for a Shr node.
3090 * Adds the node to the block in current_ir_block.
3092 * @param *db A pointer for debug information.
3093 * @param *op The operand.
3094 * @param *k The number of bits to shift the operand .
3095 * @param *mode The mode of the operand and the result.
3097 FIRM_API ir_node *new_d_Shr(dbg_info *db, ir_node *op, ir_node *k,
3100 /** Constructor for a Shrs 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_Shrs(dbg_info *db, ir_node *op, ir_node *k,
3112 /** Constructor for a Rotl 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 rotate the operand.
3119 * @param *mode The mode of the operand.
3121 FIRM_API ir_node *new_d_Rotl(dbg_info *db, ir_node *op, ir_node *k,
3124 /** Constructor for a Cmp node.
3126 * Adds the node to the block in current_ir_block.
3128 * @param *db A pointer for debug information.
3129 * @param *op1 The first operand.
3130 * @param *op2 The second operand.
3132 FIRM_API ir_node *new_d_Cmp(dbg_info *db, ir_node *op1, ir_node *op2);
3134 /** Constructor for a Conv node.
3136 * Adds the node to the block in current_ir_block.
3138 * @param *db A pointer for debug information.
3139 * @param *op The operand.
3140 * @param *mode The mode of this the operand muss be converted .
3142 FIRM_API ir_node *new_d_Conv(dbg_info *db, ir_node *op, ir_mode *mode);
3144 /** Constructor for a strict Conv node.
3146 * Adds the node to the block in current_ir_block.
3148 * @param *db A pointer for debug information.
3149 * @param *op The operand.
3150 * @param *mode The mode of this the operand muss be converted .
3152 FIRM_API ir_node *new_d_strictConv(dbg_info *db, ir_node *op, ir_mode *mode);
3154 /** Constructor for a Cast node.
3156 * High level type cast
3157 * Adds the node to the block in current_ir_block.
3159 * @param *db A pointer for debug information.
3160 * @param *op The operand.
3161 * @param *to_tp The type of this the operand muss be casted .
3163 FIRM_API ir_node *new_d_Cast(dbg_info *db, ir_node *op, ir_type *to_tp);
3165 /** Constructor for a Phi node.
3167 * Adds the node to the block in current_ir_block.
3169 * @param *db A pointer for debug information.
3170 * @param arity The number of predecessors
3171 * @param *in Array with predecessors
3172 * @param *mode The mode of it's inputs and output.
3174 FIRM_API ir_node *new_d_Phi(dbg_info *db, int arity, ir_node *in[],
3177 /** Constructor for a Load node.
3179 * Adds the node to the block in current_ir_block.
3181 * @param *db A pointer for debug information.
3182 * @param *store The current memory
3183 * @param *addr A pointer to the variable to be read in this memory.
3184 * @param *mode The mode of the value to be loaded.
3185 * @param flags Additional flags for alignment, volatility and pin state.
3187 FIRM_API ir_node *new_d_Load(dbg_info *db, ir_node *store, ir_node *addr,
3188 ir_mode *mode, ir_cons_flags flags);
3190 /** Constructor for a Store node.
3192 * Adds the node to the block in current_ir_block.
3194 * @param *db A pointer for debug information.
3195 * @param *store The current memory
3196 * @param *addr A pointer to the variable to be read in this memory.
3197 * @param *val The value to write to this variable.
3198 * @param flags Additional flags for alignment, volatility and pin state.
3200 FIRM_API ir_node *new_d_Store(dbg_info *db, ir_node *store, ir_node *addr,
3201 ir_node *val, ir_cons_flags flags);
3203 /** Constructor for a Alloc node.
3205 * The Alloc node extends the memory by space for an entity of type alloc_type.
3206 * Adds the node to the block in current_ir_block.
3208 * @param *db A pointer for debug information.
3209 * @param *store The memory which shall contain the new variable.
3210 * @param *count The number of objects to allocate.
3211 * @param *alloc_type The type of the allocated variable.
3212 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3214 FIRM_API ir_node *new_d_Alloc(dbg_info *db, ir_node *store, ir_node *count,
3215 ir_type *alloc_type, ir_where_alloc where);
3217 /** Constructor for a Free node.
3219 * Frees the memory occupied by the entity pointed to by the pointer
3220 * arg. Type indicates the type of the entity the argument points to.
3221 * Adds the node to the block in current_ir_block.
3223 * @param *db A pointer for debug information.
3224 * @param *store The memory which shall contain the new variable.
3225 * @param *ptr The pointer to the object to free.
3226 * @param *size The number of objects of type free_type to free in a sequence.
3227 * @param *free_type The type of the freed variable.
3228 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3230 FIRM_API ir_node *new_d_Free(dbg_info *db, ir_node *store, ir_node *ptr,
3231 ir_node *size, ir_type *free_type,
3232 ir_where_alloc where);
3234 /** Constructor for a Sync node.
3236 * Merges several memory values. The node assumes that a variable
3237 * either occurs only in one of the memories, or it contains the same
3238 * value in all memories where it occurs.
3239 * Adds the node to the block in current_ir_block.
3241 * @param *db A pointer for debug information.
3242 * @param arity The number of memories to synchronize.
3243 * @param **in An array of pointers to nodes that produce an output of type
3244 * memory. The constructor copies this array.
3246 FIRM_API ir_node *new_d_Sync(dbg_info *db, int arity, ir_node *in[]);
3248 /** Constructor for a Proj node.
3250 * Projects a single value out of a tuple. The parameter proj gives the
3251 * position of the value within the tuple.
3252 * Adds the node to the block in current_ir_block.
3254 * @param *db A pointer for deubug information.
3255 * @param arg A node producing a tuple.
3256 * @param *mode The mode of the value to project.
3257 * @param proj The position of the value in the tuple.
3259 FIRM_API ir_node *new_d_Proj(dbg_info *db, ir_node *arg, ir_mode *mode,
3262 /** Constructor for a defaultProj node.
3264 * Represents the default control flow of a Switch-Cond node.
3265 * Adds the node to the block in current_ir_block.
3267 * @param *db A pointer for debug information.
3268 * @param arg A node producing a tuple.
3269 * @param max_proj The end position of the value in the tuple.
3271 FIRM_API ir_node *new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
3273 /** Constructor for a Tuple node.
3275 * This is an auxiliary node to replace a node that returns a tuple
3276 * without changing the corresponding Proj nodes.
3277 * Adds the node to the block in current_ir_block.
3279 * @param *db A pointer for debug information.
3280 * @param arity The number of tuple elements.
3281 * @param **in An array containing pointers to the nodes producing the tuple elements.
3283 FIRM_API ir_node *new_d_Tuple(dbg_info *db, int arity, ir_node *in[]);
3285 /** Constructor for a Id node.
3287 * This is an auxiliary node to replace a node that returns a single
3288 * value. Adds the node to the block in current_ir_block.
3290 * @param *db A pointer for debug information.
3291 * @param *val The operand to Id.
3292 * @param *mode The mode of *val.
3294 FIRM_API ir_node *new_d_Id(dbg_info *db, ir_node *val, ir_mode *mode);
3296 /** Constructor for a Confirm node.
3298 * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3299 * Specifies constraints for a value. To support dataflow analyses.
3301 * Example: If the value never exceeds '100' this is expressed by placing a
3302 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
3304 * @param *db A pointer for debug information.
3305 * @param *val The value we express a constraint for
3306 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3307 * @param cmp The compare operation.
3309 FIRM_API ir_node *new_d_Confirm(dbg_info *db, ir_node *val, ir_node *bound,
3312 /** Constructor for an Unknown node.
3314 * Represents an arbitrary value. Places the node in
3317 * @param *db A pointer for debug information.
3318 * @param *m The mode of the unknown value.
3320 FIRM_API ir_node *new_d_Unknown(dbg_info *db, ir_mode *m);
3322 /** Constructor for a Mux node.
3324 * @param *db A pointer for debug information.
3325 * @param *sel The ir_node that calculates the boolean select.
3326 * @param *ir_true The ir_node that calculates the true result.
3327 * @param *ir_false The ir_node that calculates the false result.
3328 * @param *mode The mode of the node (and it_true and ir_false).
3330 FIRM_API ir_node *new_d_Mux(dbg_info *db, ir_node *sel,
3331 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3333 /** Constructor for a CopyB node.
3335 * @param *db A pointer for debug information.
3336 * @param *store The current memory
3337 * @param *dst The ir_node that represents the destination address.
3338 * @param *src The ir_node that represents the source address.
3339 * @param *data_type The type of the copied data
3341 FIRM_API ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst,
3342 ir_node *src, ir_type *data_type);
3344 /** Constructor for a InstOf node.
3346 * A High-Level Type check.
3348 * @param *db A pointer for debug information.
3349 * @param *store The memory in which the object the entity should be selected
3350 * from is allocated.
3351 * @param *objptr A pointer to a object of a class type.
3352 * @param *type The type of which objptr must be.
3354 FIRM_API ir_node *new_d_InstOf(dbg_info *db, ir_node *store, ir_node *objptr,
3357 /** Constructor for a Raise node.
3359 * A High-Level Exception throw.
3361 * @param *db A pointer for debug information.
3362 * @param *store The current memory.
3363 * @param *obj A pointer to the Except variable.
3365 FIRM_API ir_node *new_d_Raise(dbg_info *db, ir_node *store, ir_node *obj);
3367 /** Constructor for a Bound node.
3369 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
3371 * @param *db A pointer for debug information.
3372 * @param *store The current memory
3373 * @param *idx The ir_node that represents an index.
3374 * @param *lower The ir_node that represents the lower bound for the index.
3375 * @param *upper The ir_node that represents the upper bound for the index.
3377 FIRM_API ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx,
3378 ir_node *lower, ir_node *upper);
3380 /** Constructor for a Pin node.
3382 * @param *db A pointer for debug information.
3383 * @param *node The node which value should be pinned.
3385 FIRM_API ir_node *new_d_Pin(dbg_info *db, ir_node *node);
3387 /** Constructor for an ASM pseudo node.
3389 * @param *db A pointer for debug information.
3390 * @param arity The number of data inputs to the node.
3391 * @param *in The array of length arity of data inputs.
3392 * @param *inputs The array of length arity of input constraints.
3393 * @param n_outs The number of data outputs to the node.
3394 * @param *outputs The array of length n_outs of output constraints.
3395 * @param n_clobber The number of clobbered registers.
3396 * @param *clobber The array of length n_clobber of clobbered registers.
3397 * @param *asm_text The assembler text.
3399 FIRM_API ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[],
3400 ir_asm_constraint *inputs,
3401 int n_outs, ir_asm_constraint *outputs,
3402 int n_clobber, ident *clobber[], ident *asm_text);
3404 /*-----------------------------------------------------------------------*/
3405 /* The block oriented interface without debug support */
3406 /*-----------------------------------------------------------------------*/
3408 /** Constructor for a Block node.
3410 * Constructor for a Block node. Adds the block to the graph in
3411 * current_ir_graph. Constructs a Block with a fixed number of predecessors.
3413 * @param arity The number of control predecessors.
3414 * @param in An array of control predecessors. The length of
3415 * the array must be 'arity'.
3417 FIRM_API ir_node *new_Block(int arity, ir_node *in[]);
3419 /** Constructor for a Start node.
3421 * Adds the node to the block in current_ir_block.
3424 FIRM_API ir_node *new_Start(void);
3426 /** Constructor for an End node.
3428 * Adds the node to the block in current_ir_block.
3430 FIRM_API ir_node *new_End(void);
3432 /** Constructor for a Jump node.
3434 * Adds the node to the block in current_ir_block.
3436 * Jmp represents control flow to a single control successor.
3438 FIRM_API ir_node *new_Jmp(void);
3440 /** Constructor for an IJmp node.
3442 * IJmp represents control flow to a single control successor not
3443 * statically known i.e. an indirect Jmp.
3445 * @param *tgt The IR node representing the target address.
3447 FIRM_API ir_node *new_IJmp(ir_node *tgt);
3449 /** Constructor for a Cond node.
3451 * If c is mode_b represents a conditional branch (if/else). If c is
3452 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
3453 * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3455 * This is not consistent: Input to Cond is Is, Proj has as proj number
3459 * @param *c The conditions parameter.Can be of mode b or I_u.
3461 FIRM_API ir_node *new_Cond(ir_node *c);
3463 /** Constructor for a Return node.
3465 * Returns the memory and zero or more return values. Only node that
3466 * can end regular control flow. Adds the node to the block in current_ir_block.
3468 * @param *store The state of memory.
3469 * @param arity Number of array indices.
3470 * @param *in Array with index inputs to the node.
3472 FIRM_API ir_node *new_Return(ir_node *store, int arity, ir_node *in[]);
3474 /** Constructor for a Const node.
3476 * Constructor for a Const node. The constant represents a target
3477 * value. Sets the type information to type_unknown. (No more
3478 * supported: If tv is entity derives a somehow useful type.)
3479 * Adds the node to the block in current_ir_block.
3480 * Derives mode from passed tarval.
3482 * @param *con Points to an entry in the constant table. This pointer is
3483 * added to the attributes of the node.
3485 FIRM_API ir_node *new_Const(tarval *con);
3488 * Make a const from a long.
3489 * This is just convenience for the usual
3491 * new_Const(mode, tarval_from_long(mode, ...))
3494 * @param mode The mode for the const.
3495 * @param value The value of the constant.
3496 * @return A new const node.
3498 FIRM_API ir_node *new_Const_long(ir_mode *mode, long value);
3500 /** Constructor for a Const node.
3502 * Derives mode from passed tarval. */
3503 FIRM_API ir_node *new_Const_type(tarval *con, ir_type *tp);
3505 /** Constructor for a SymConst_type node.
3507 * This is the constructor for a symbolic constant.
3508 * There are several kinds of symbolic constants:
3509 * - symconst_type_tag The symbolic constant represents a type tag. The
3510 * type the tag stands for is given explicitly.
3511 * - symconst_type_size The symbolic constant represents the size of a type.
3512 * The type of which the constant represents the size
3513 * is given explicitly.
3514 * - symconst_type_align The symbolic constant represents the alignment of a
3515 * type. The type of which the constant represents the
3516 * size is given explicitly.
3517 * - symconst_addr_ent The symbolic constant represents the address of an
3518 * entity (variable or method). The variable is given
3519 * explicitly by a firm entity.
3520 * - symconst_ofs_ent The symbolic constant represents the offset of an
3521 * entity in its owner type.
3522 * - symconst_enum_const The symbolic constant is a enumeration constant of
3523 * an enumeration type.
3525 * Inputs to the node:
3526 * No inputs except the block it belongs to.
3527 * Outputs of the node.
3528 * An unsigned integer (I_u) or a pointer (P).
3530 * Mention union in declaration so that the firmjni generator recognizes that
3531 * it can not cast the argument to an int.
3533 * @param mode The mode for the SymConst.
3534 * @param value A type, ident, entity or enum constant depending on the
3536 * @param kind The kind of the symbolic constant, see the list above
3537 * @param tp The source type of the constant.
3539 FIRM_API ir_node *new_SymConst_type(ir_mode *mode, union symconst_symbol value,
3540 symconst_kind kind, ir_type *tp);
3542 /** Constructor for a SymConst node.
3544 * This is the constructor for a symbolic constant.
3545 * There are several kinds of symbolic constants:
3546 * - symconst_type_tag The symbolic constant represents a type tag. The
3547 * type the tag stands for is given explicitly.
3548 * - symconst_type_size The symbolic constant represents the size of a type.
3549 * The type of which the constant represents the size
3550 * is given explicitly.
3551 * - symconst_type_align The symbolic constant represents the alignment of a
3552 * type. The type of which the constant represents the
3553 * size is given explicitly.
3554 * - symconst_addr_ent The symbolic constant represents the address of an
3555 * entity (variable or method). The variable is given
3556 * explicitly by a firm entity.
3557 * - symconst_ofs_ent The symbolic constant represents the offset of an
3558 * entity in its owner type.
3559 * - symconst_enum_const The symbolic constant is a enumeration constant of
3560 * an enumeration type.
3562 * Inputs to the node:
3563 * No inputs except the block it belongs to.
3564 * Outputs of the node.
3565 * An unsigned integer (I_u) or a pointer (P).
3567 * Mention union in declaration so that the firmjni generator recognizes that
3568 * it can not cast the argument to an int.
3570 * @param mode The mode for the SymConst.
3571 * @param value A type, ident, entity or enum constant depending on the
3573 * @param kind The kind of the symbolic constant, see the list above
3575 FIRM_API ir_node *new_SymConst(ir_mode *mode, union symconst_symbol value,
3576 symconst_kind kind);
3578 /** Constructor for a simpelSel node.
3580 * This is a shortcut for the new_Sel() constructor. To be used for
3581 * Sel nodes that do not select from an array, i.e., have no index
3582 * inputs. It adds the two parameters 0, NULL.
3584 * @param *store The memory in which the object the entity should be selected from is allocated.
3585 * @param *objptr The object from that the Sel operation selects a single attribute out.
3586 * @param *ent The entity to select.
3588 FIRM_API ir_node *new_simpleSel(ir_node *store, ir_node *objptr,
3591 /** Constructor for a Sel node.
3593 * The select node selects an entity (field or method) from an entity
3594 * with a compound type. It explicitly specifies the entity selected.
3595 * Dynamically the node may select entities that overwrite the given
3596 * entity. If the selected entity is an array element entity the Sel
3597 * node takes the required array indices as inputs.
3598 * Adds the node to the block in current_ir_block.
3600 * @param *store The memory in which the object the entity should be selected
3601 * from is allocated.
3602 * @param *objptr A pointer to a compound entity the Sel operation selects a
3603 * single attribute from.
3604 * @param arity The number of array indices needed to select an array element entity.
3605 * @param *in[] If the compound entity is an array the indices of the selected
3606 * element entity. The constructor copies this array.
3607 * @param *ent The entity to select.
3609 FIRM_API ir_node *new_Sel(ir_node *store, ir_node *objptr,
3610 int arity, ir_node *in[], ir_entity *ent);
3612 /** Constructor for a Call node.
3614 * Adds the node to the block in current_ir_block.
3615 * Represents all kinds of method and function calls.
3617 * @param *store The actual store.
3618 * @param *callee A pointer to the called procedure.
3619 * @param arity The number of procedure parameters.
3620 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3621 * @param *tp Type information of the procedure called.
3623 FIRM_API ir_node *new_Call(ir_node *store, ir_node *callee,
3624 int arity, ir_node *in[], ir_type *tp);
3626 /** Constructor for a Builtin node.
3628 * Represents a call of a backend-specific builtin..
3629 * Represents all kinds of method and function calls.
3631 * @param *store The actual store.
3632 * @param kind The kind of the called builtin.
3633 * @param arity The number of procedure parameters.
3634 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3635 * @param *tp Type information of the procedure called.
3637 FIRM_API ir_node *new_Builtin(ir_node *store, int arity, ir_node *in[],
3638 ir_builtin_kind kind, ir_type *tp);
3640 /** Constructor for a Add node.
3642 * Adds the node to the block in current_ir_block.
3644 * @param *op1 The first operand.
3645 * @param *op2 The second operand.
3646 * @param *mode The mode of the operands and the result.
3648 FIRM_API ir_node *new_Add(ir_node *op1, ir_node *op2, ir_mode *mode);
3650 /** Constructor for a Sub node.
3652 * Adds the node to the block in current_ir_block.
3654 * @param *op1 The first operand.
3655 * @param *op2 The second operand.
3656 * @param *mode The mode of the operands and the result.
3658 FIRM_API ir_node *new_Sub(ir_node *op1, ir_node *op2, ir_mode *mode);
3660 /** Constructor for a Minus node.
3662 * Adds the node to the block in current_ir_block.
3664 * @param *op The operand .
3665 * @param *mode The mode of the operand and the result.
3667 FIRM_API ir_node *new_Minus(ir_node *op, ir_mode *mode);
3670 * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3672 * @param *op1 The first operand.
3673 * @param *op2 The second operand.
3674 * @param *mode The mode of the operands and the result.
3676 FIRM_API ir_node *new_Mul(ir_node *op1, ir_node *op2, ir_mode *mode);
3679 * Constructor for a Mulh node. Adds the node to the block in current_ir_block.
3681 * @param *op1 The first operand.
3682 * @param *op2 The second operand.
3683 * @param *mode The mode of the operands and the result.
3685 FIRM_API ir_node *new_Mulh(ir_node *op1, ir_node *op2, ir_mode *mode);
3687 /** Constructor for a Quot node.
3689 * Adds the node to the block in current_ir_block.
3691 * @param *memop The store needed to model exceptions
3692 * @param *op1 The first operand.
3693 * @param *op2 The second operand.
3694 * @param *mode The mode of the result.
3695 * @param state The pinned state.
3697 FIRM_API ir_node *new_Quot(ir_node *memop, ir_node *op1, ir_node *op2,
3698 ir_mode *mode, op_pin_state state);
3700 /** Constructor for a DivMod node.
3702 * Adds the node to the block in current_ir_block.
3704 * @param *memop The store needed to model exceptions
3705 * @param *op1 The first operand.
3706 * @param *op2 The second operand.
3707 * @param *mode The mode of the results.
3708 * @param state The pinned state.
3710 FIRM_API ir_node *new_DivMod(ir_node *memop, ir_node *op1, ir_node *op2,
3711 ir_mode *mode, op_pin_state state);
3713 /** Constructor for a Div node.
3715 * Adds the node to the block in current_ir_block.
3717 * @param *memop The store needed to model exceptions
3718 * @param *op1 The first operand.
3719 * @param *op2 The second operand.
3720 * @param *mode The mode of the result.
3721 * @param state The pinned state.
3723 FIRM_API ir_node *new_Div(ir_node *memop, ir_node *op1, ir_node *op2,
3724 ir_mode *mode, op_pin_state state);
3726 /** Constructor for a remainderless Div node.
3728 * Adds the node to the block in current_ir_block.
3730 * @param *memop The store needed to model exceptions
3731 * @param *op1 The first operand.
3732 * @param *op2 The second operand.
3733 * @param *mode The mode of the result.
3734 * @param state The pinned state.
3736 FIRM_API ir_node *new_DivRL(ir_node *memop, ir_node *op1, ir_node *op2,
3737 ir_mode *mode, op_pin_state state);
3739 /** Constructor for a Mod node.
3741 * Adds the node to the block in current_ir_block.
3743 * @param *memop The store needed to model exceptions
3744 * @param *op1 The first operand.
3745 * @param *op2 The second operand.
3746 * @param *mode The mode of the result.
3747 * @param state The pinned state.
3749 FIRM_API ir_node *new_Mod(ir_node *memop, ir_node *op1, ir_node *op2,
3750 ir_mode *mode, op_pin_state state);
3752 /** Constructor for a Abs node.
3754 * Adds the node to the block in current_ir_block.
3756 * @param *op The operand
3757 * @param *mode The mode of the operands and the result.
3759 FIRM_API ir_node *new_Abs(ir_node *op, ir_mode *mode);
3761 /** Constructor for a And node.
3763 * Adds the node to the block in current_ir_block.
3765 * @param *op1 The first operand.
3766 * @param *op2 The second operand.
3767 * @param *mode The mode of the operands and the result.
3769 FIRM_API ir_node *new_And(ir_node *op1, ir_node *op2, ir_mode *mode);
3772 * Constructor for a Or node. Adds the node to the block in current_ir_block.
3774 * @param *op1 The first operand.
3775 * @param *op2 The second operand.
3776 * @param *mode The mode of the operands and the result.
3778 FIRM_API ir_node *new_Or(ir_node *op1, ir_node *op2, ir_mode *mode);
3781 * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3783 * @param *op1 The first operand.
3784 * @param *op2 The second operand.
3785 * @param *mode The mode of the operands and the results.
3787 FIRM_API ir_node *new_Eor(ir_node *op1, ir_node *op2, ir_mode *mode);
3789 /** Constructor for a Not node.
3791 * Adds the node to the block in current_ir_block.
3793 * @param *op The operand.
3794 * @param *mode The mode of the operand and the result.
3796 FIRM_API ir_node *new_Not(ir_node *op, ir_mode *mode);
3798 /** Constructor for a Shl node.
3800 * Adds the node to the block in current_ir_block.
3802 * @param *op The operand.
3803 * @param *k The number of bits to shift the operand .
3804 * @param *mode The mode of the operand and the result.
3806 FIRM_API ir_node *new_Shl(ir_node *op, ir_node *k, ir_mode *mode);
3809 * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3811 * @param *op The operand.
3812 * @param *k The number of bits to shift the operand .
3813 * @param *mode The mode of the operand and the result.
3815 FIRM_API ir_node *new_Shr(ir_node *op, ir_node *k, ir_mode *mode);
3817 /** Constructor for a Shrs node.
3819 * Adds the node to the block in current_ir_block.
3821 * @param *op The operand.
3822 * @param *k The number of bits to shift the operand .
3823 * @param *mode The mode of the operand and the result.
3825 FIRM_API ir_node *new_Shrs(ir_node *op, ir_node *k, ir_mode *mode);
3827 /** Constructor for a Rotl node.
3829 * Adds the node to the block in current_ir_block.
3831 * @param *op The operand.
3832 * @param *k The number of bits to rotate the operand.
3833 * @param *mode The mode of the operand.
3835 FIRM_API ir_node *new_Rotl(ir_node *op, ir_node *k, ir_mode *mode);
3837 /** Constructor for a Cmp node.
3839 * Adds the node to the block in current_ir_block.
3841 * @param *op1 The first operand.
3842 * @param *op2 The second operand.
3844 FIRM_API ir_node *new_Cmp(ir_node *op1, ir_node *op2);
3846 /** Constructor for a Conv node.
3848 * Adds the node to the block in current_ir_block.
3850 * @param *op The operand.
3851 * @param *mode The mode of this the operand muss be converted.
3853 FIRM_API ir_node *new_Conv(ir_node *op, ir_mode *mode);
3855 /** Constructor for a strict Conv node.
3857 * Adds the node to the block in current_ir_block.
3859 * @param *op The operand.
3860 * @param *mode The mode of this the operand muss be converted.
3862 FIRM_API ir_node *new_strictConv(ir_node *op, ir_mode *mode);
3864 /** Constructor for a Cast node.
3866 * Adds the node to the block in current_ir_block.
3867 * High level type cast
3869 * @param *op The operand.
3870 * @param *to_tp The type of this the operand muss be casted .
3872 FIRM_API ir_node *new_Cast(ir_node *op, ir_type *to_tp);
3874 /** Constructor for a Phi node.
3876 * Adds the node to the block in current_ir_block.
3878 * @param arity The number of predecessors.
3879 * @param *in Array with predecessors.
3880 * @param *mode The mode of it's inputs and output.
3882 FIRM_API ir_node *new_Phi(int arity, ir_node *in[], ir_mode *mode);
3884 /** Constructor for a Load node.
3886 * @param *store The current memory.
3887 * @param *addr A pointer to the variable to be read in this memory.
3888 * @param *mode The mode of the value to be loaded.
3889 * @param flags Additional flags for alignment, volatility and pin state.
3891 FIRM_API ir_node *new_Load(ir_node *store, ir_node *addr, ir_mode *mode,
3892 ir_cons_flags flags);
3894 /** Constructor for a Store node.
3896 * @param *store The current memory.
3897 * @param *addr A pointer to the variable to be read in this memory.
3898 * @param *val The value to write to this variable.
3899 * @param flags Additional flags for alignment, volatility and pin state.
3901 FIRM_API ir_node *new_Store(ir_node *store, ir_node *addr, ir_node *val,
3902 ir_cons_flags flags);
3904 /** Constructor for a Alloc node.
3906 * The Alloc node extends the memory by space for an entity of type alloc_type.
3907 * Adds the node to the block in current_ir_block.
3909 * @param *store The memory which shall contain the new variable.
3910 * @param *count The number of objects to allocate.
3911 * @param *alloc_type The type of the allocated variable.
3912 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3914 FIRM_API ir_node *new_Alloc(ir_node *store, ir_node *count, ir_type *alloc_type,
3915 ir_where_alloc where);
3917 /** Constructor for a Free node.
3919 * Frees the memory occupied by the entity pointed to by the pointer
3920 * arg. Type indicates the type of the entity the argument points to.
3921 * Adds the node to the block in current_ir_block.
3923 * @param *store The memory which shall contain the new variable.
3924 * @param *ptr The pointer to the object to free.
3925 * @param *size The number of objects of type free_type to free in a sequence.
3926 * @param *free_type The type of the freed variable.
3927 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3929 FIRM_API ir_node *new_Free(ir_node *store, ir_node *ptr, ir_node *size,
3930 ir_type *free_type, ir_where_alloc where);
3932 /** Constructor for a Sync node.
3934 * Merges several memory values. The node assumes that a variable
3935 * either occurs only in one of the memories, or it contains the same
3936 * value in all memories where it occurs.
3937 * Adds the node to the block in current_ir_block.
3939 * @param arity The number of memories to synchronize.
3940 * @param **in An array of pointers to nodes that produce an output of type
3941 * memory. The constructor copies this array.
3943 FIRM_API ir_node *new_Sync(int arity, ir_node *in[]);
3945 /** Constructor for a Proj node.
3947 * Projects a single value out of a tuple. The parameter proj gives the
3948 * position of the value within the tuple.
3949 * Adds the node to the block in current_ir_block.
3951 * @param arg A node producing a tuple.
3952 * @param *mode The mode of the value to project.
3953 * @param proj The position of the value in the tuple.
3955 FIRM_API ir_node *new_Proj(ir_node *arg, ir_mode *mode, long proj);
3957 /** Constructor for a defaultProj node.
3959 * Represents the default control flow of a Switch-Cond node.
3960 * Adds the node to the block in current_ir_block.
3962 * @param arg A node producing a tuple.
3963 * @param max_proj The end position of the value in the tuple.
3965 FIRM_API ir_node *new_defaultProj(ir_node *arg, long max_proj);
3967 /** Constructor for a Tuple node.
3969 * This is an auxiliary node to replace a node that returns a tuple
3970 * without changing the corresponding Proj nodes.
3971 * Adds the node to the block in current_ir_block.
3973 * @param arity The number of tuple elements.
3974 * @param **in An array containing pointers to the nodes producing the tuple elements.
3976 FIRM_API ir_node *new_Tuple(int arity, ir_node *in[]);
3978 /** Constructor for an Id node.
3980 * This is an auxiliary node to replace a node that returns a single
3981 * value. Adds the node to the block in current_ir_block.
3983 * @param *val The operand to Id.
3984 * @param *mode The mode of *val.
3986 FIRM_API ir_node *new_Id(ir_node *val, ir_mode *mode);
3988 /** Constructor for a Bad node.
3990 * Returns the unique Bad node of the graph. The same as
3993 FIRM_API ir_node *new_Bad(void);
3995 /** Constructor for a Confirm node.
3997 * Specifies constraints for a value. To support dataflow analyses.
3998 * Adds the node to the block in current_ir_block.
4000 * Example: If the value never exceeds '100' this is expressed by placing a
4001 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
4003 * @param *val The value we express a constraint for
4004 * @param *bound The value to compare against. Must be a firm node, typically a constant.
4005 * @param cmp The compare operation.
4007 FIRM_API ir_node *new_Confirm(ir_node *val, ir_node *bound, pn_Cmp cmp);
4009 /** Constructor for an Unknown node.
4011 * Represents an arbitrary value. Places the node in
4014 * @param *m The mode of the unknown value.
4016 FIRM_API ir_node *new_Unknown(ir_mode *m);
4018 /** Constructor for a NoMem node.
4020 * Returns the unique NoMem node of the graph. The same as
4023 FIRM_API ir_node *new_NoMem(void);
4025 /** Constructor for a Mux node.
4027 * Adds the node to the block in current_ir_block.
4029 * @param *sel The ir_node that calculates the boolean select.
4030 * @param *ir_true The ir_node that calculates the true result.
4031 * @param *ir_false The ir_node that calculates the false result.
4032 * @param *mode The mode of the node (and it_true and ir_false).
4034 FIRM_API ir_node *new_Mux(ir_node *sel, ir_node *ir_false, ir_node *ir_true,
4037 /** Constructor for a CopyB node.
4039 * Adds the node to the block in current_ir_block.
4041 * @param *store The current memory
4042 * @param *dst The ir_node that represents the destination address.
4043 * @param *src The ir_node that represents the source address.
4044 * @param *data_type The type of the copied data
4046 FIRM_API ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src,
4047 ir_type *data_type);
4049 /** Constructor for a InstOf node.
4051 * A High-Level Type check.
4053 * @param *store The memory in which the object the entity should be selected
4054 * from is allocated.
4055 * @param *objptr A pointer to a object of a class type.
4056 * @param *type The type of which objptr must be.
4058 FIRM_API ir_node *new_InstOf(ir_node *store, ir_node *objptr, ir_type *type);
4060 /**Constructor for a Raise node.
4062 * A High-Level Exception throw.
4064 * @param *store The current memory.
4065 * @param *obj A pointer to the Except variable.
4067 FIRM_API ir_node *new_Raise(ir_node *store, ir_node *obj);
4069 /** Constructor for a Bound node.
4071 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
4073 * Adds the node to the block in current_ir_block.
4075 * @param *store The current memory
4076 * @param *idx The ir_node that represents an index.
4077 * @param *lower The ir_node that represents the lower bound for the index.
4078 * @param *upper The ir_node that represents the upper bound for the index.
4080 FIRM_API ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower,
4083 /** Constructor for a Pin node.
4085 * @param *node The node which value should be pinned.
4087 FIRM_API ir_node *new_Pin(ir_node *node);
4089 /** Constructor for an ASM pseudo node.
4091 * @param arity The number of data inputs to the node.
4092 * @param *in The array of length arity of data inputs.
4093 * @param *inputs The array of length arity of input constraints.
4094 * @param n_outs The number of data outputs to the node.
4095 * @param *outputs The array of length n_outs of output constraints.
4096 * @param n_clobber The number of clobbered registers.
4097 * @param *clobber The array of length n_clobber of clobbered registers.
4098 * @param *asm_text The assembler text.
4100 FIRM_API ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
4101 int n_outs, ir_asm_constraint *outputs,
4102 int n_clobber, ident *clobber[], ident *asm_text);
4105 * @brief Constructor for a Dummy node.
4107 * @param *db debug info for the node
4108 * @param *mode The mode of the node.
4109 * @param *irg the graph to put the node into
4110 * @returns the newly created note
4112 FIRM_API ir_node *new_rd_Dummy(dbg_info *db, ir_graph *irg, ir_mode *mode);
4115 * @copybrief new_rd_Dummy()
4117 * @param *mode The mode of the node.
4118 * @param *irg the graph to put the node into
4119 * @returns the newly created note
4121 FIRM_API ir_node *new_r_Dummy(ir_graph *irg, ir_mode *mode);
4124 * @copybrief new_rd_Dummy()
4126 * @param *db debug info for the node
4127 * @param *mode The mode of the node.
4128 * @returns the newly created note
4130 FIRM_API ir_node *new_d_Dummy(dbg_info *db, ir_mode *mode);
4133 * @copybrief new_rd_Dummy()
4135 * @param *mode The mode of the node.
4136 * @returns the newly created note
4138 FIRM_API ir_node *new_Dummy(ir_mode *mode);
4140 /*---------------------------------------------------------------------*/
4141 /* The comfortable interface. */
4142 /* Supports automatic Phi node construction. */
4143 /* All routines of the block oriented interface except new_Block are */
4145 /*---------------------------------------------------------------------*/
4147 /** Create an immature Block.
4149 * An immature Block has an unknown number of predecessors. Predecessors
4150 * can be added with add_immBlock_pred(). Once all predecessors are
4151 * added the block must be matured.
4153 * Adds the block to the graph in current_ir_graph. Can be used with automatic
4154 * Phi node construction.
4155 * This constructor can only be used if the graph is in state_building.
4157 FIRM_API ir_node *new_d_immBlock(dbg_info *db);
4158 FIRM_API ir_node *new_immBlock(void);
4160 /** Create an immature PartBlock.
4162 * An immature block has only one Block or PartBlock predecessor.
4163 * A PartBlock forms together with one BLock and possibly other
4164 * PartBlocks a MacroBlock.
4166 * Adds the PartBlock to the graph in current_ir_graph. Does set
4167 * current_block. Can be used with automatic Phi node construction.
4168 * This constructor can only be used if the graph is in
4171 FIRM_API ir_node *new_d_immPartBlock(dbg_info *db, ir_node *pred_jmp);
4172 FIRM_API ir_node *new_immPartBlock(ir_node *pred_jmp);
4174 /** Add a control flow edge to an immature block. */
4175 FIRM_API void add_immBlock_pred(ir_node *immblock, ir_node *jmp);
4177 /** Finalize a Block node, when all control flows are known. */
4178 FIRM_API void mature_immBlock(ir_node *block);
4179 #define mature_cur_block() mature_immBlock(get_cur_block());
4182 /** Get the current value of a local variable.
4184 * Use this function to obtain the last definition of the local variable
4185 * associated with pos. Pos may not exceed the value passed as n_loc
4186 * to new_ir_graph. This call automatically inserts Phi nodes.
4188 * @param *db A pointer for debug information.
4189 * @param pos The position/id of the local variable.
4190 * @param *mode The mode of the value to get.
4192 FIRM_API ir_node *get_d_value(dbg_info *db, int pos, ir_mode *mode);
4193 FIRM_API ir_node *get_value(int pos, ir_mode *mode);
4196 * Try to guess the mode of a local variable.
4197 * This is done by recursively going up the control flow graph until
4198 * we find a definition for the variable. The mode of the first found
4199 * definition is returned. NULL in case no definition is found.
4201 * @param pos The position/id of the local variable.
4203 FIRM_API ir_mode *ir_guess_mode(int pos);
4205 /** Remark a new definition of a variable.
4207 * Use this function to remember a new definition of the value
4208 * associated with pos. Pos may not exceed the value passed as n_loc
4209 * to new_ir_graph. This call is needed to automatically inserts Phi
4212 * @param pos The position/id of the local variable.
4213 * @param *value The new value written to the local variable.
4215 FIRM_API void set_value(int pos, ir_node *value);
4218 * Find the value number for a node in the current block.
4220 * @param value the searched value
4222 * @return the value number of the value or -1 if this value has
4223 * no value number in the current block.
4225 FIRM_API int find_value(ir_node *value);
4227 /** Get the current memory state.
4229 * Use this function to obtain the last definition of the memory
4230 * state. This call automatically inserts Phi nodes for the memory
4233 FIRM_API ir_node *get_store(void);
4235 /** Remark a new definition of the memory state.
4237 * Use this function to remember a new definition of the memory state.
4238 * This call is needed to automatically inserts Phi nodes.
4240 * @param *store The new memory state.
4242 FIRM_API void set_store(ir_node *store);
4244 /** keep this node alive even if End is not control-reachable from it
4246 * @param ka The node to keep alive.
4248 FIRM_API void keep_alive(ir_node *ka);
4250 /** Returns the frame type of the current graph */
4251 FIRM_API ir_type *get_cur_frame_type(void);
4254 /* --- initialize and finalize IR construction --- */
4256 /** Puts the graph into state "phase_high" */
4257 FIRM_API void irg_finalize_cons(ir_graph *irg);
4259 /** Puts the program and all graphs into state phase_high.
4261 * This also remarks, the construction of types is finished,
4262 * e.g., that no more subtypes will be added. */
4263 FIRM_API void irp_finalize_cons(void);
4265 FIRM_API void ir_set_uninitialized_local_variable_func(
4266 uninitialized_local_variable_func_t *func);