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_Carry (ir_node *op1, ir_node *op2, ir_mode *mode);
288 * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode);
289 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode, ir_cons_flags flags);
290 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val, ir_cons_flags flags);
291 * ir_node *new_Alloc (ir_node *store, ir_node *count, ir_type *alloc_type,
292 * where_alloc where);
293 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size,
294 * ir_type *free_type, where_alloc where);
295 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
296 * ir_node *new_NoMem (void);
297 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
298 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type);
299 * ir_node *new_InstOf (ir_node *store, ir_node obj, ir_type *ent);
300 * ir_node *new_Raise (ir_node *store, ir_node *obj);
301 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
302 * ir_node *new_Pin (ir_node *node);
304 * void add_immBlock_pred (ir_node *block, ir_node *jmp);
305 * void mature_immBlock (ir_node *block);
306 * void set_cur_block (ir_node *target);
307 * ir_node *get_value (int pos, ir_mode *mode);
308 * void set_value (int pos, ir_node *value);
309 * ir_node *get_store (void);
310 * void set_store (ir_node *store);
311 * keep_alive (ir_node ka)
313 * IR_NODES AND CONSTRUCTORS FOR IR_NODES
314 * =======================================
316 * All ir_nodes are defined by a common data structure. They are distinguished
317 * by their opcode and differ in the number of their attributes.
319 * Const nodes are always added to the start block.
320 * All other constructors add the created node to the current_block.
321 * swich_block(block) allows to set the current block to block.
323 * Watch for my inconsistent use of input and predecessor (dataflow view)
324 * and `the node points to' (implementation view).
326 * The following description of the nodes lists four properties them if these
328 * - the parameters to the constructor
329 * - the inputs of the Firm node
330 * - the outputs of the Firm node
331 * - attributes to the node
335 * ir_node *new_immBlock (void)
336 * ----------------------------
338 * Creates a new block. When a new block is created it cannot be known how
339 * many predecessors this block will have in the control flow graph.
340 * Therefore the list of inputs can not be fixed at creation. Predecessors
341 * can be added with add_immBlock_pred (block, control flow operation).
342 * With every added predecessor the number of inputs to Phi nodes also
345 * The block can be completed by mature_immBlock(block) if all predecessors are
346 * known. If several blocks are built at once, mature_immBlock can only be called
347 * after set_value has been called for all values that are life at the end
348 * of the block. This is necessary so that Phi nodes created mature_immBlock
349 * get the right predecessors in case of cyclic dependencies. If all set_values
350 * of this block are called after maturing it and before calling get_value
351 * in some block that is control flow dependent on this block, the construction
354 * Example for faulty IR construction: (draw the graph on a paper and you'll
357 * block_before_loop = new_immBlock();
358 * set_cur_block(block_before_loop);
360 * mature_immBlock(block_before_loop);
361 * before2header = new_Jmp;
363 * loop_header = new_immBlock ();
364 * set_cur_block(loop_header);
365 * header2body - new_Jmp();
367 * loop_body = new_immBlock ();
368 * set_cur_block(loop_body);
369 * body2header = new_Jmp();
371 * add_immBlock_pred(loop_header, before2header);
372 * add_immBlock_pred(loop_header, body2header);
373 * add_immBlock_pred(loop_body, header2body);
375 * mature_immBlock(loop_header);
376 * mature_immBlock(loop_body);
378 * get_value(loop_body, x); // gets the Phi in loop_header
379 * set_value(loop_header, x); // sets the value the above get_value should
380 * // have returned!!!
382 * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
383 * should be called as early as possible, as afterwards the generation of Phi
384 * nodes is more efficient.
387 * There is an input for each control flow predecessor of the block.
388 * The input points to an instruction producing an output of type X.
389 * Possible predecessors: Start, Jmp, Cond, Raise or Return or any node
390 * possibly causing an exception. (Often the real predecessors are Projs.)
392 * Mode BB (R), all nodes belonging to this block should consume this output.
393 * As they are strict (except Block and Phi node) it is a necessary condition
394 * that the block node executed before any other node in this block executes.
396 * block.matured Indicates whether the block is mature.
398 * This attribute contains all local values valid in this
399 * block. This is needed to build the Phi nodes and removed
400 * if the graph is complete. This field is used by the
401 * internal construction algorithm and should not be accessed
405 * ir_node *new_Block (int arity, ir_node **in)
406 * --------------------------------------------
408 * Creates a new Block with the given list of predecessors. This block
409 * is mature. As other constructors calls optimization and vrfy for the
410 * block. If one of the predecessors is Unknown (as it has to be filled in
411 * later) optimizations are skipped. This is necessary to
412 * construct Blocks in loops.
415 * CONTROL FLOW OPERATIONS
416 * -----------------------
418 * In each block there must be exactly one of the control flow
419 * operations Start, End, Jmp, Cond, Return or Raise. The output of a
420 * control flow operation points to the block to be executed next.
422 * ir_node *new_Start (void)
423 * -------------------------
425 * Creates a start node. Not actually needed public. There is only one such
426 * node in each procedure which is automatically created by new_ir_graph.
429 * No inputs except the block it belogns to.
431 * A tuple of 4 (5, 6) distinct values. These are labeled by the following
432 * projection numbers (pn_Start):
433 * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
434 * * pn_Start_M mode M, the global store
435 * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
436 * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
437 * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
440 * ir_node *new_End (void)
441 * -----------------------
443 * Creates an end node. Not actually needed public. There is only one such
444 * node in each procedure which is automatically created by new_ir_graph.
447 * No inputs except the block it belongs to.
451 * ir_node *new_Jmp (void)
452 * -----------------------
454 * Creates a Jmp node.
457 * The block the node belongs to
459 * Control flow to the next block.
461 * ir_node *new_IJmp (ir_node *tgt)
462 * -----------------------
464 * Creates an IJmp node.
467 * The node that represents the target jump address
469 * Control flow to an unknown target, must be pinned by
472 * ir_node *new_Cond (ir_node *c)
473 * ------------------------------
475 * Creates a Cond node. There are two versions of this node.
481 * A tuple of two control flows. The first is taken if the input is
482 * false, the second if it is true.
486 * A value of mode I_u. (i)
488 * A tuple of n control flows. If the Cond's input is i, control
489 * flow will procede along output i. If the input is >= n control
490 * flow proceeds along output n.
492 * ir_node *new_Return (ir_node *store, int arity, ir_node **in)
493 * -------------------------------------------------------------
495 * The return node has as inputs the results of the procedure. It
496 * passes the control flow to the end_block.
502 * Control flow to the end block.
506 * ir_node *new_Const (tarval *con)
507 * -----------------------------------------------
509 * Creates a constant in the constant table and adds a Const node
510 * returning this value to the start block. The mode is derived
514 * *con Points to an entry in the constant table.
515 * This pointer is added to the attributes of
516 * the node (self->attr.con)
518 * No inputs except the block it belogns to.
520 * The constant value.
522 * attr.con A tarval* pointer to the proper entry in the constant
525 * ir_node *new_SymConst (ir_mode *mode, union symconst_symbol value, symconst_addr_ent kind)
526 * -----------------------------------------------------------------------------------------
528 * There are several symbolic constants:
529 * symconst_type_tag The symbolic constant represents a type tag.
530 * symconst_type_size The symbolic constant represents the size of a type.
531 * symconst_type_align The symbolic constant represents the alignment of a type.
532 * symconst_addr_ent The symbolic constant represents the address of an entity.
533 * symconst_ofs_ent The symbolic constant represents the offset of an
534 * entity in its owner type.
535 * symconst_enum_const The symbolic constant is a enumeration constant of an
539 * mode P for SymConsts representing addresses, Iu otherwise.
540 * value The type, ident, entity or enum constant, depending on the
542 * kind The kind of the symbolic constant, see the list above.
545 * No inputs except the block it belongs to.
547 * A symbolic constant.
550 * attr.i.num The symconst_addr_ent, i.e. one of
552 * -symconst_type_size
553 * -symconst_type_align
556 * If the attr.i.num is symconst_type_tag, symconst_type_size or symconst_type_align,
557 * the node contains an attribute:
559 * attr.i.*type, a pointer to a type_class.
560 * if it is linkage_ptr_info it contains
561 * attr.i.*ptrinfo, an ident holding information for the linker.
565 * ir_node *new_simpleSel (ir_node *store, ir_node *frame, ir_entity *sel)
566 * -----------------------------------------------------------------------
569 * Selects an entity from a compound type. This entity can be a field or
573 * *store The memory in which the object the entity should be selected
575 * *frame The pointer to the object.
576 * *sel The entity to select.
579 * The memory containing the object.
580 * A pointer to the object.
581 * An unsigned integer.
583 * A pointer to the selected entity.
585 * attr.sel Pointer to the entity
588 * ir_node *new_Sel (ir_node *store, ir_node *frame, int arity, ir_node **in,
589 * --------------------------------------------------------------------------
593 * Selects a field from an array type. The entity has as owner the array, as
594 * type the arrays element type. The indices to access an array element are
598 * *store The memory in which the object the entity should be selected from
600 * *frame The pointer to the object.
601 * *arity number of array indices.
602 * *in array with index inputs to the node.
603 * *sel The entity to select.
606 * The memory containing the object.
607 * A pointer to the object.
608 * As much unsigned integer as there are array expressions.
610 * A pointer to the selected entity.
612 * attr.sel Pointer to the entity
614 * The constructors new_Sel and new_simpleSel generate the same IR nodes.
615 * simpleSel just sets the arity of the index inputs to zero.
618 * ARITHMETIC OPERATIONS
619 * ---------------------
621 * ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
622 * ----------------------------------------------------------------------------
626 * Creates a procedure call.
629 * *store The actual store.
630 * *callee A pointer to the called procedure.
631 * arity The number of procedure parameters.
632 * **in An array with the pointers to the parameters.
633 * The constructor copies this array.
634 * *type Type information of the procedure called.
637 * The store, the callee and the parameters.
639 * A tuple containing the eventually changed store and the procedure
642 * attr.call Contains the attributes for the procedure.
644 * ir_node *new_Builtin(ir_node *store, ir_builtin_kind kind, int arity, ir_node **in,
645 * -----------------------------------------------------------------------------------
649 * Creates a builtin call.
652 * *store The actual store.
653 * kind Describes the called builtin.
654 * arity The number of procedure parameters.
655 * **in An array with the pointers to the parameters.
656 * The constructor copies this array.
657 * *type Type information of the procedure called.
660 * The store, the kind and the parameters.
662 * A tuple containing the eventually changed store and the procedure
665 * attr.builtin Contains the attributes for the called builtin.
667 * ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode)
668 * ------------------------------------------------------------
672 * ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode)
673 * ------------------------------------------------------------
677 * ir_node *new_Minus (ir_node *op, ir_mode *mode)
678 * -----------------------------------------------
680 * Unary Minus operations on integer and floating point values.
682 * ir_node *new_Mul (ir_node *op1, ir_node *op2, ir_mode *mode)
683 * ------------------------------------------------------------
687 * ir_node *new_Mulh (ir_node *op1, ir_node *op2, ir_mode *mode)
688 * ------------------------------------------------------------
690 * Returns the high order bits of a n*n=2n multiplication.
692 * ir_node *new_Quot (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
693 * -------------------------------------------------------------------------------------------------
695 * Quot performs exact division of floating point numbers. It's mode
696 * is Tuple, the mode of the result must match the Proj mode
697 * that extracts the result of the arithmetic operations.
700 * The store needed to model exceptions and the two operands.
702 * A tuple containing a memory and a execution for modeling exceptions
703 * and the result of the arithmetic operation.
705 * ir_node *new_DivMod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
706 * ---------------------------------------------------------------------------------------------------
708 * Performs Div and Mod on integer values.
711 * A tuple containing a memory and a execution for modeling exceptions
712 * and the two result of the arithmetic operations.
714 * ir_node *new_Div (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
715 * ------------------------------------------------------------------------------------------------
719 * ir_node *new_Mod (ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state)
720 * ------------------------------------------------------------------------------------------------
724 * ir_node *new_Abs (ir_node *op, ir_mode *mode)
725 * ---------------------------------------------
729 * ir_node *new_And (ir_node *op1, ir_node *op2, ir_mode *mode)
730 * ------------------------------------------------------------
734 * ir_node *new_Or (ir_node *op1, ir_node *op2, ir_mode *mode)
735 * -----------------------------------------------------------
739 * ir_node *new_Eor (ir_node *op1, ir_node *op2, ir_mode *mode)
740 * ------------------------------------------------------------
744 * ir_node *new_Not (ir_node *op, ir_mode *mode)
745 * ---------------------------------------------
747 * This node constructs a constant where all bits are set to one
748 * and a Eor of this constant and the operator. This simulates a
751 * ir_node *new_Shl (ir_node *op, ir_node *k, ir_mode *mode)
752 * ---------------------------------------------------------
756 * ir_node *new_Shr (ir_node *op, ir_node *k, ir_mode *mode)
757 * ---------------------------------------------------------
759 * Logic shift right, i.e., zero extended.
762 * ir_node *new_Shrs (ir_node *op, ir_node *k, ir_mode *mode)
763 * ----------------------------------------------------------
765 * Arithmetic shift right, i.e., sign extended.
767 * ir_node *new_Rotl (ir_node *op, ir_node *k, ir_mode *mode)
768 * ---------------------------------------------------------
770 * Rotates the operand to the left by k bits.
772 * ir_node *new_Carry (ir_node *op1, ir_node *op2, ir_mode *mode)
773 * ------------------------------------------------------------
775 * Calculates the Carry value for integer addition. Used only
778 * ir_node *new_Borrow (ir_node *op1, ir_node *op2, ir_mode *mode)
779 * ------------------------------------------------------------
781 * Calculates the Borrow value for integer substraction. Used only
784 * ir_node *new_Conv (ir_node *op, ir_mode *mode)
785 * ---------------------------------------------
787 * Mode conversion. For allowed conversions see UKA Tech Report
790 * ir_node *new_Cmp (ir_node *op1, ir_node *op2)
791 * ---------------------------------------------
794 * The two values to be compared.
796 * A 16-tuple containing the results of the 16 different comparisons.
797 * The following is a list giving the comparisons and a projection
798 * number (pn_Cmp) to use in Proj nodes to extract the proper result.
802 * pn_Cmp_Le less or equal
804 * pn_Cmp_Ge greater of equal
805 * pn_Cmp_Lg less or greater
806 * pn_Cmp_Leg less, equal or greater = ordered
807 * pn_Cmp_Uo unordered
808 * pn_Cmp_Ue unordered or equal
809 * pn_Cmp_Ul unordered or less
810 * pn_Cmp_Ule unordered, less or equal
811 * pn_Cmp_Ug unordered or greater
812 * pn_Cmp_Uge unordered, greater or equal
813 * pn_Cmp_Ne unordered, less or greater = not equal
820 * In general, Phi nodes are automaitcally inserted. In some cases, if
821 * all predecessors of a block are known, an explicit Phi node constructor
822 * is needed. E.g., to construct a FIRM graph for a statement as
823 * a = (b==c) ? 2 : 5;
825 * ir_node *new_Phi (int arity, ir_node **in, ir_mode *mode)
826 * ---------------------------------------------------------
828 * Creates a Phi node. The in's order has to correspond to the order
829 * of in's of current_block. This is not checked by the library!
830 * If one of the predecessors is Unknown (as it has to be filled in
831 * later) optimizations are skipped. This is necessary to
832 * construct Phi nodes in loops.
835 * arity number of predecessors
836 * **in array with predecessors
837 * *mode The mode of it's inputs and output.
839 * A Phi node has as many inputs as the block it belongs to.
840 * Each input points to a definition of the same value on a
841 * different path in the control flow.
843 * The definition valid in this block.
845 * ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode)
846 * -----------------------------------------------------------------------------------
848 * Creates a Mux node. This node implements the following semantic:
849 * If the sel node (which must be of mode_b) evaluates to true, its value is
850 * ir_true, else ir_false;
854 * OPERATIONS TO MANAGE MEMORY EXPLICITLY
855 * --------------------------------------
857 * ir_node *new_Load (ir_node *store, ir_node *addr, ir_mode *mode, ir_cons_flags flags)
858 * -------------------------------------------------------------------------------------
860 * The Load operation reads a value from memory.
863 * *store The current memory.
864 * *addr A pointer to the variable to be read in this memory.
865 * *mode The mode of the value to be loaded.
866 * flags Additional flags for alignment, volatility and pin state.
869 * The memory and a pointer to a variable in this memory.
871 * A tuple of the memory, a control flow to be taken in case of
872 * an exception and the loaded value.
874 * ir_node *new_Store (ir_node *store, ir_node *addr, ir_node *val, ir_cons_flags flags)
875 * -------------------------------------------------------------------------------------
877 * The Store operation writes a value to a variable in memory.
880 * The memory, a pointer to a variable in this memory and the value
881 * to write to this variable.
883 * A tuple of the changed memory and a control flow to be taken in
884 * case of an exception.
886 * ir_node *new_Alloc (ir_node *store, ir_node *count, ir_type *alloc_type,
887 * -----------------------------------------------------------------------
891 * The Alloc node allocates a new variable. It can be specified whether the
892 * variable should be allocated to the stack or to the heap.
895 * *store The memory which shall contain the new variable.
896 * *count This field is for allocating arrays, it specifies how
897 * many array elements are to be allocated.
898 * *alloc_type The type of the allocated variable. In case of allocating
899 * arrays this has to be the array type, not the type of the
901 * where Where to allocate the variable, either heap_alloc or stack_alloc.
904 * A memory and an unsigned integer.
906 * A tuple of the changed memory, a control flow to be taken in
907 * case of an exception and the pointer to the new variable.
909 * a.where Indicates where the variable is allocated.
910 * a.*type A pointer to the class the allocated data object
913 * ir_node *new_Free (ir_node *store, ir_node *ptr, ir_node *size, ir_type *free_type,
914 * -----------------------------------------------------------------------------------
918 * The Free node frees memory of the given variable.
921 * *store The memory which shall contain the new variable.
922 * *ptr The pointer to the object to free.
923 * *size The number of objects of type free_type to free in a sequence.
924 * *free_type The type of the freed variable.
925 * where Where the variable was allocated, either heap_alloc or stack_alloc.
928 * A memory, a pointer and an unsigned integer.
930 * The changed memory.
932 * f.*type A pointer to the type information of the freed data object.
936 * ir_node *new_Sync (int arity, ir_node **in)
937 * -------------------------------------------
939 * The Sync operation unifies several partial memory blocks. These blocks
940 * have to be pairwise disjunct or the values in common locations have to
941 * be identical. This operation allows to specify all operations that eventually
942 * need several partial memory blocks as input with a single entrance by
943 * unifying the memories with a preceding Sync operation.
946 * arity The number of memories to synchronize.
947 * **in An array of pointers to nodes that produce an output of
952 * The unified memory.
958 * ir_node *new_Bad (void)
959 * -----------------------
961 * Returns the unique Bad node current_ir_graph->bad.
962 * This node is used to express results of dead code elimination.
964 * ir_node *new_NoMem (void)
965 * -----------------------------------------------------------------------------------
967 * Returns the unique NoMem node current_ir_graph->no_mem.
968 * This node is used as input for operations that need a Memory, but do not
969 * change it like Div by const != 0, analyzed calls etc.
971 * ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj)
972 * ----------------------------------------------------------
974 * Selects one entry of a tuple. This is a hidden edge with attributes.
977 * *arg A node producing a tuple.
978 * *mode The mode of the value to project.
979 * proj The position of the value in the tuple.
985 * ir_node *new_Tuple (int arity, ir_node **in)
986 * --------------------------------------------
988 * Builds a Tuple from single values. This is needed to implement
989 * optimizations that remove a node that produced a tuple. The node can be
990 * replaced by the Tuple operation so that the following Proj nodes have not to
991 * be changed. (They are hard to find due to the implementation with pointers
992 * in only one direction.) The Tuple node is smaller than any other
993 * node, so that a node can be changed into a Tuple by just changing it's
994 * opcode and giving it a new in array.
997 * arity The number of tuple elements.
998 * **in An array containing pointers to the nodes producing the
1001 * ir_node *new_Id (ir_node *val, ir_mode *mode)
1002 * ---------------------------------------------
1004 * The single output of the Id operation is it's input. Also needed
1005 * for optimizations.
1008 * HIGH LEVEL OPERATIONS
1009 * ---------------------
1011 * ir_node *new_CopyB (ir_node *store, ir_node *dst, ir_node *src, ir_type *data_type)
1012 * -----------------------------------------------------------------------------------
1014 * Describes a high level block copy of a compound type from address src to
1015 * address dst. Must be lowered to a Call to a runtime memory copy function.
1018 * HIGH LEVEL OPERATIONS: Exception Support
1019 * ----------------------------------------
1020 * See TechReport 1999-14, chapter Exceptions.
1022 * ir_node *new_InstOf(ir_node *store, ir_node *ptr, ir_type *type);
1023 * -----------------------------------------------------------------------------------
1025 * Describes a high level type check. Must be lowered to a Call to a runtime check
1028 * ir_node *new_Raise (ir_node *store, ir_node *obj)
1029 * -------------------------------------------------
1031 * Raises an exception. Unconditional change of control flow. Writes
1032 * an explicit Except variable to memory to pass it to the exception
1033 * handler. Must be lowered to a Call to a runtime check
1038 * A pointer to the Except variable.
1040 * A tuple of control flow and the changed memory state. The control flow
1041 * points to the exception handler if it is definied in this procedure,
1042 * else it points to the end_block.
1044 * ir_node *new_Bound (ir_node *store, ir_node *idx, ir_node *lower, ir_node *upper);
1045 * -----------------------------------------------------------------------------------
1047 * Describes a high level bounds check. Must be lowered to a Call to a runtime check
1050 * ir_node *new_Pin (ir_node *node);
1051 * -----------------------------------------------------------------------------------
1053 * Pin the value of the node node in the current block No users of the Pin node can
1054 * float above the Block of the Pin. The node cannot float behind this block. Often
1055 * used to Pin the NoMem node.
1058 * COPING WITH DATA OBJECTS
1059 * ========================
1061 * Two kinds of data objects have to be distinguished for generating
1062 * FIRM. First there are local variables other than arrays that are
1063 * known to be alias free. Second there are all other data objects.
1064 * For the first a common SSA representation is built, the second
1065 * are modeled by saving them to memory. The memory is treated as
1066 * a single local variable, the alias problem is hidden in the
1067 * content of this variable.
1069 * All values known in a Block are listed in the block's attribute,
1070 * block.**graph_arr which is used to automatically insert Phi nodes.
1071 * The following two functions can be used to add a newly computed value
1072 * to the array, or to get the producer of a value, i.e., the current
1075 * inline void set_value (int pos, ir_node *value)
1076 * -----------------------------------------------
1078 * Has to be called for every assignment to a local variable. It
1079 * adds the value to the array of used values at position pos. Pos
1080 * has to be a unique identifier for an entry in the procedure's
1081 * definition table. It can be used to access the value again.
1082 * Requires current_block to be set correctly.
1084 * ir_node *get_value (int pos, ir_mode *mode)
1085 * -------------------------------------------
1087 * Returns the node defining the value referred to by pos. If the
1088 * value is not defined in this block a Phi node is generated and
1089 * all definitions reaching this Phi node are collected. It can
1090 * happen that the algorithm allocates an unnecessary Phi node,
1091 * e.g. if there is only one definition of this value, but this
1092 * definition reaches the currend block on several different
1093 * paths. This Phi node will be eliminated if optimizations are
1094 * turned on right after it's creation.
1095 * Requires current_block to be set correctly.
1097 * There are two special routines for the global store:
1099 * void set_store (ir_node *store)
1100 * -------------------------------
1102 * Adds the store to the array of known values at a reserved
1104 * Requires current_block to be set correctly.
1106 * ir_node *get_store (void)
1107 * -------------------------
1109 * Returns the node defining the actual store.
1110 * Requires current_block to be set correctly.
1113 * inline void keep_alive (ir_node *ka)
1114 * ------------------------------------
1116 * Keep this node alive because it is (might be) not in the control
1117 * flow from Start to End. Adds the node to the list in the end
1121 #ifndef FIRM_IR_IRCONS_H
1122 #define FIRM_IR_IRCONS_H
1124 #include "firm_types.h"
1129 * constrained flags for memory operations.
1131 typedef enum ir_cons_flags {
1132 cons_none = 0, /**< No constrains. */
1133 cons_volatile = 1U << 0, /**< Memory operation is volatile. */
1134 cons_unaligned = 1U << 1, /**< Memory operation is unaligned. */
1135 cons_floats = 1U << 2 /**< Memory operation can float. */
1138 /*-------------------------------------------------------------------------*/
1139 /* The raw interface */
1140 /*-------------------------------------------------------------------------*/
1142 /** Constructor for a Block node.
1144 * Constructs a mature block with the given predecessors.
1146 * @param *db A Pointer for debug information.
1147 * @param irg The IR graph the block belongs to.
1148 * @param arity The number of control predecessors.
1149 * @param in[] An array of control predecessors. The length of
1150 * the array must be 'arity'. The constructor copies this array.
1152 FIRM_API ir_node *new_rd_Block(dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
1154 /** Constructor for a Start node.
1156 * @param *db A pointer for debug information.
1157 * @param *irg The IR graph the node belongs to.
1158 * @param *block The IR block the node belongs to.
1160 FIRM_API ir_node *new_rd_Start(dbg_info *db, ir_graph *irg, ir_node *block);
1162 /** Constructor for a End node.
1164 * @param *db A pointer for debug information.
1165 * @param *irg The IR graph the node belongs to.
1166 * @param *block The IR block the node belongs to.
1168 FIRM_API ir_node *new_rd_End(dbg_info *db, ir_graph *irg, ir_node *block);
1170 /** Constructor for a Jmp node.
1172 * Jmp represents control flow to a single control successor.
1174 * @param *db A pointer for debug information.
1175 * @param *block The IR block the node belongs to.
1177 FIRM_API ir_node *new_rd_Jmp(dbg_info *db, ir_node *block);
1179 /** Constructor for an IJmp node.
1181 * IJmp represents control flow to a single control successor not
1182 * statically known i.e. an indirect Jmp.
1184 * @param *db A pointer for debug information.
1185 * @param *block The IR block the node belongs to.
1186 * @param *tgt The IR node representing the target address.
1188 FIRM_API ir_node *new_rd_IJmp(dbg_info *db, ir_node *block, ir_node *tgt);
1190 /** Constructor for a Cond node.
1192 * If c is mode_b represents a conditional branch (if/else). If c is
1193 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
1194 * node, default Proj is 0.)
1196 * This is not consistent: Input to Cond is Is, Proj has as proj number
1199 * @param *db A pointer for debug information.
1200 * @param *block The IR block the node belongs to.
1201 * @param *c The conditions parameter. Can be of mode b or I_u.
1203 FIRM_API ir_node *new_rd_Cond(dbg_info *db, ir_node *block, ir_node *c);
1205 /** Constructor for a Return node.
1207 * Returns the memory and zero or more return values. Only node that
1208 * can end regular control flow.
1210 * @param *db A pointer for debug information.
1211 * @param *block The IR block the node belongs to.
1212 * @param *store The state of memory.
1213 * @param arity Number of return values.
1214 * @param *in Array of length arity with return values. The constructor copies this array.
1216 FIRM_API ir_node *new_rd_Return(dbg_info *db, ir_node *block,
1217 ir_node *store, int arity, ir_node *in[]);
1219 /** Constructor for a Const_type node.
1221 * Adds the node to the start block.
1223 * The constant represents a target value. This constructor sets high
1224 * level type information for the constant value.
1225 * Derives mode from passed tarval.
1227 * @param *db A pointer for debug information.
1228 * @param *irg The IR graph the node belongs to.
1229 * @param *con Points to an entry in the constant table.
1230 * @param *tp The type of the constant.
1232 FIRM_API ir_node *new_rd_Const_type(dbg_info *db, ir_graph *irg,
1233 tarval *con, ir_type *tp);
1235 /** Constructor for a Const node.
1237 * Adds the node to the start block.
1239 * Constructor for a Const node. The constant represents a target
1240 * value. Sets the type information to type_unknown. (No more
1241 * supported: If tv is entity derives a somehow useful type.)
1242 * Derives mode from passed tarval.
1244 * @param *db A pointer for debug information.
1245 * @param *irg The IR graph the node belongs to.
1246 * @param *con Points to an entry in the constant table.
1248 FIRM_API ir_node *new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con);
1251 * Constructor for a Const node.
1253 * Adds the node to the start block.
1255 * Constructor for a Const node. The constant represents a target
1256 * value. Sets the type information to type_unknown. (No more
1257 * supported: If tv is entity derives a somehow useful type.)
1259 * @param *db A pointer for debug information.
1260 * @param *irg The IR graph the node belongs to.
1261 * @param *mode The mode of the operands and results.
1262 * @param value A value from which the tarval is made.
1264 FIRM_API ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg,
1265 ir_mode *mode, long value);
1267 /** Constructor for a SymConst_type node.
1269 * This is the constructor for a symbolic constant.
1270 * There are several kinds of symbolic constants:
1271 * - symconst_type_tag The symbolic constant represents a type tag. The
1272 * type the tag stands for is given explicitly.
1273 * - symconst_type_size The symbolic constant represents the size of a type.
1274 * The type of which the constant represents the size
1275 * is given explicitly.
1276 * - symconst_type_align The symbolic constant represents the alignment of a
1277 * type. The type of which the constant represents the
1278 * size is given explicitly.
1279 * - symconst_addr_ent The symbolic constant represents the address of an
1280 * entity (variable or method). The variable is given
1281 * explicitly by a firm entity.
1282 * - symconst_ofs_ent The symbolic constant represents the offset of an
1283 * entity in its owner type.
1284 * - symconst_enum_const The symbolic constant is a enumeration constant of
1285 * an enumeration type.
1287 * Inputs to the node:
1288 * No inputs except the block it belongs to.
1289 * Outputs of the node.
1290 * An unsigned integer (I_u) or a pointer (P).
1292 * Mention union in declaration so that the firmjni generator recognizes that
1293 * it can not cast the argument to an int.
1295 * @param *db A pointer for debug information.
1296 * @param *irg The IR graph the node belongs to.
1297 * @param mode The mode for the SymConst.
1298 * @param val A type, ident, entity or enum constant depending on the
1300 * @param kind The kind of the symbolic constant, see the list above
1301 * @param tp The source type of the constant.
1303 FIRM_API ir_node *new_rd_SymConst_type(dbg_info *db, ir_graph *irg,
1304 ir_mode *mode, union symconst_symbol val,
1305 symconst_kind kind, ir_type *tp);
1307 /** Constructor for a SymConst node.
1309 * Same as new_rd_SymConst_type, except that it sets the type to type_unknown.
1311 FIRM_API ir_node *new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode,
1312 union symconst_symbol value,
1313 symconst_kind kind);
1315 /** Constructor for a SymConst addr_ent node.
1317 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1318 * symconst_addr_ent.
1319 * Adds the SymConst to the start block of irg. */
1320 FIRM_API ir_node *new_rd_SymConst_addr_ent(dbg_info *db, ir_graph *irg,
1321 ir_mode *mode, ir_entity *symbol,
1324 /** Constructor for a SymConst ofs_ent node.
1326 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1328 * Adds the SymConst to the start block of irg.
1330 FIRM_API ir_node *new_rd_SymConst_ofs_ent(dbg_info *db, ir_graph *irg,
1331 ir_mode *mode, ir_entity *symbol,
1334 /** Constructor for a SymConst type_tag node.
1336 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1337 * symconst_type_tag.
1338 * Adds the SymConst to the start block of irg.
1340 FIRM_API ir_node *new_rd_SymConst_type_tag(dbg_info *db, ir_graph *irg,
1341 ir_mode *mode, ir_type *symbol,
1344 /** Constructor for a SymConst size node.
1346 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1347 * symconst_type_size.
1348 * Adds the SymConst to the start block of irg. */
1349 FIRM_API ir_node *new_rd_SymConst_size(dbg_info *db, ir_graph *irg,
1350 ir_mode *mode, ir_type *symbol,
1353 /** Constructor for a SymConst size node.
1355 * Same as new_rd_SymConst_type, except that the constructor is tailored for
1356 * symconst_type_align.
1357 * Adds the SymConst to the start block of irg.
1359 FIRM_API ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg,
1360 ir_mode *mode, ir_type *symbol,
1363 /** Constructor for a simpleSel node.
1365 * This is a shortcut for the new_rd_Sel() constructor. To be used for
1366 * Sel nodes that do not select from an array, i.e., have no index
1367 * inputs. It adds the two parameters 0, NULL.
1369 * @param *db A pointer for debug information.
1370 * @param *block The IR block the node belongs to.
1371 * @param *store The memory in which the object the entity should be
1372 * selected from is allocated.
1373 * @param *objptr The object from that the Sel operation selects a
1374 * single attribute out.
1375 * @param *ent The entity to select.
1377 FIRM_API ir_node *new_rd_simpleSel(dbg_info *db, ir_node *block, ir_node *store,
1378 ir_node *objptr, ir_entity *ent);
1380 /** Constructor for a Sel node.
1382 * The select node selects an entity (field or method) from an entity
1383 * with a compound type. It explicitly specifies the entity selected.
1384 * Dynamically the node may select entities that overwrite the given
1385 * entity. If the selected entity is an array element entity the Sel
1386 * node takes the required array indices as inputs.
1388 * @param *db A pointer for debug information.
1389 * @param *block The IR block the node belongs to.
1390 * @param *store The memory in which the object the entity should be selected
1391 * from is allocated.
1392 * @param *objptr A pointer to a compound entity the Sel operation selects a
1393 * single attribute from.
1394 * @param *n_index The number of array indices needed to select an array element entity.
1395 * @param *index[] If the compound entity is an array the indices of the selected
1396 * element entity. The constructor copies this array.
1397 * @param *ent The entity to select.
1399 FIRM_API ir_node *new_rd_Sel(dbg_info *db, ir_node *block, ir_node *store,
1400 ir_node *objptr, int n_index, ir_node *index[],
1403 /** Constructor for a Call node.
1405 * Represents all kinds of method and function calls.
1407 * @param *db A pointer for debug information.
1408 * @param *block The IR block the node belongs to.
1409 * @param *store The current memory state.
1410 * @param *callee A pointer to the called procedure.
1411 * @param arity The number of procedure parameters.
1412 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1413 * @param *tp Type information of the procedure called.
1415 FIRM_API ir_node *new_rd_Call(dbg_info *db, ir_node *block, ir_node *store,
1416 ir_node *callee, int arity, ir_node *in[],
1419 /** Constructor for a Builtin node.
1421 * Represents a call of a backend-specific builtin..
1423 * @param *db A pointer for debug information.
1424 * @param *block The IR block the node belongs to.
1425 * @param *store The current memory state.
1426 * @param arity The number of procedure parameters.
1427 * @param *in[] An array with the procedure parameters. The constructor copies this array.
1428 * @param kind The kind of the called builtin.
1429 * @param *tp Type information of the procedure called.
1431 FIRM_API ir_node *new_rd_Builtin(dbg_info *db, ir_node *block, ir_node *store,
1432 int arity, ir_node *in[], ir_builtin_kind kind,
1435 /** Constructor for a Add node.
1437 * @param *db A pointer for debug information.
1438 * @param *block The IR block the node belongs to.
1439 * @param *op1 The first operand.
1440 * @param *op2 The second operand.
1441 * @param *mode The mode of the operands and the result.
1443 FIRM_API ir_node *new_rd_Add(dbg_info *db, ir_node *block, ir_node *op1,
1444 ir_node *op2, ir_mode *mode);
1446 /** Constructor for a Sub node.
1448 * @param *db A pointer for debug information.
1449 * @param *block The IR block the node belongs to.
1450 * @param *op1 The first operand.
1451 * @param *op2 The second operand.
1452 * @param *mode The mode of the operands and the result.
1454 FIRM_API ir_node *new_rd_Sub(dbg_info *db, ir_node *block,
1455 ir_node *op1, ir_node *op2, ir_mode *mode);
1457 /** Constructor for a Minus node.
1459 * @param *db A pointer for debug information.
1460 * @param *block The IR block the node belongs to.
1461 * @param *op The operand .
1462 * @param *mode The mode of the operand and the result.
1464 FIRM_API ir_node *new_rd_Minus(dbg_info *db, ir_node *block,
1465 ir_node *op, ir_mode *mode);
1467 /** Constructor for a Mul node.
1469 * @param *db A pointer for debug information.
1470 * @param *block The IR block the node belongs to.
1471 * @param *op1 The first operand.
1472 * @param *op2 The second operand.
1473 * @param *mode The mode of the operands and the result.
1475 FIRM_API ir_node *new_rd_Mul(dbg_info *db, ir_node *block,
1476 ir_node *op1, ir_node *op2, ir_mode *mode);
1478 /** Constructor for a Mulh node.
1480 * @param *db A pointer for debug information.
1481 * @param *block The IR block the node belongs to.
1482 * @param *op1 The first operand.
1483 * @param *op2 The second operand.
1484 * @param *mode The mode of the operands and the result.
1486 FIRM_API ir_node *new_rd_Mulh(dbg_info *db, ir_node *block,
1487 ir_node *op1, ir_node *op2, ir_mode *mode);
1489 /** Constructor for a Quot 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 result.
1497 * @param state The pinned state.
1499 FIRM_API ir_node *new_rd_Quot(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 DivMod 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 results.
1511 * @param state The pinned state.
1513 FIRM_API ir_node *new_rd_DivMod(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 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_Div(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 remainderless Div 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_DivRL(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 Mod node.
1547 * @param *db A pointer for debug information.
1548 * @param *block The IR block the node belongs to.
1549 * @param *memop The store needed to model exceptions
1550 * @param *op1 The first operand.
1551 * @param *op2 The second operand.
1552 * @param *mode The mode of the result.
1553 * @param state The pinned state.
1555 FIRM_API ir_node *new_rd_Mod(dbg_info *db, ir_node *block, ir_node *memop,
1556 ir_node *op1, ir_node *op2, ir_mode *mode,
1557 op_pin_state state);
1559 /** Constructor for a Abs node.
1561 * @param *db A pointer for debug information.
1562 * @param *block The IR block the node belongs to.
1563 * @param *op The operand
1564 * @param *mode The mode of the operands and the result.
1566 FIRM_API ir_node *new_rd_Abs(dbg_info *db, ir_node *block, ir_node *op,
1569 /** Constructor for a And node.
1571 * @param *db A pointer for debug information.
1572 * @param *block The IR block the node belongs to.
1573 * @param *op1 The first operand.
1574 * @param *op2 The second operand.
1575 * @param *mode The mode of the operands and the result.
1577 FIRM_API ir_node *new_rd_And(dbg_info *db, ir_node *block,
1578 ir_node *op1, ir_node *op2, ir_mode *mode);
1580 /** Constructor for a Or node.
1582 * @param *db A pointer for debug information.
1583 * @param *block The IR block the node belongs to.
1584 * @param *op1 The first operand.
1585 * @param *op2 The second operand.
1586 * @param *mode The mode of the operands and the result.
1588 FIRM_API ir_node *new_rd_Or(dbg_info *db, ir_node *block,
1589 ir_node *op1, ir_node *op2, ir_mode *mode);
1591 /** Constructor for a Eor node.
1593 * @param *db A pointer for debug information.
1594 * @param *block The IR block the node belongs to.
1595 * @param *op1 The first operand.
1596 * @param *op2 The second operand.
1597 * @param *mode The mode of the operands and the results.
1599 FIRM_API ir_node *new_rd_Eor(dbg_info *db, ir_node *block,
1600 ir_node *op1, ir_node *op2, ir_mode *mode);
1602 /** Constructor for a Not node.
1604 * @param *db A pointer for debug information.
1605 * @param *block The IR block the node belongs to.
1606 * @param *op The operand.
1607 * @param *mode The mode of the operand and the result.
1609 FIRM_API ir_node *new_rd_Not(dbg_info *db, ir_node *block, ir_node *op,
1612 /** Constructor for a Cmp node.
1614 * @param *db A pointer for debug information.
1615 * @param *block The IR block the node belongs to.
1616 * @param *op1 The first operand.
1617 * @param *op2 The second operand.
1619 FIRM_API ir_node *new_rd_Cmp(dbg_info *db, ir_node *block,
1620 ir_node *op1, ir_node *op2);
1622 /** Constructor for a Shl node.
1624 * @param *db A pointer for debug information.
1625 * @param *block The IR block the node belongs to.
1626 * @param *op The operand.
1627 * @param *k The number of bits to shift the operand .
1628 * @param *mode The mode of the operand and the result.
1630 FIRM_API ir_node *new_rd_Shl(dbg_info *db, ir_node *block,
1631 ir_node *op, ir_node *k, ir_mode *mode);
1633 /** Constructor for a Shr node.
1635 * @param *db A pointer for debug information.
1636 * @param *block The IR block the node belongs to.
1637 * @param *op The operand.
1638 * @param *k The number of bits to shift the operand .
1639 * @param *mode The mode of the operand and the result.
1641 FIRM_API ir_node *new_rd_Shr(dbg_info *db, ir_node *block,
1642 ir_node *op, ir_node *k, ir_mode *mode);
1644 /** Constructor for a Shrs node.
1646 * @param *db A pointer for debug information.
1647 * @param *block The IR block the node belongs to.
1648 * @param *op The operand.
1649 * @param *k The number of bits to shift the operand.
1650 * @param *mode The mode of the operand and the result.
1652 FIRM_API ir_node *new_rd_Shrs(dbg_info *db, ir_node *block,
1653 ir_node *op, ir_node *k, ir_mode *mode);
1655 /** Constructor for a Rotl node.
1657 * @param *db A pointer for debug information.
1658 * @param *block The IR block the node belongs to.
1659 * @param *op The operand.
1660 * @param *k The number of bits to rotate the operand.
1661 * @param *mode The mode of the operand.
1663 FIRM_API ir_node *new_rd_Rotl(dbg_info *db, ir_node *block,
1664 ir_node *op, ir_node *k, ir_mode *mode);
1667 /** Constructor for a Conv node.
1669 * @param *db A pointer for debug information.
1670 * @param *block The IR block the node belongs to.
1671 * @param *op The operand.
1672 * @param *mode The mode of this the operand muss be converted .
1674 FIRM_API ir_node *new_rd_Conv(dbg_info *db, ir_node *block, ir_node *op,
1677 /** Constructor for a strictConv node.
1679 * @param *db A pointer for debug information.
1680 * @param *block The IR block the node belongs to.
1681 * @param *op The operand.
1682 * @param *mode The mode of this the operand muss be converted .
1684 FIRM_API ir_node *new_rd_strictConv(dbg_info *db, ir_node *block,
1685 ir_node *op, ir_mode *mode);
1687 /** Constructor for a Cast node.
1689 * High level type cast.
1691 * @param *db A pointer for debug information.
1692 * @param *block The IR block the node belongs to.
1693 * @param *op The operand.
1694 * @param *to_tp The type of this the operand muss be casted .
1696 FIRM_API ir_node *new_rd_Cast(dbg_info *db, ir_node *block,
1697 ir_node *op, ir_type *to_tp);
1699 /** Constructor for a Carry node.
1701 * @param *db A pointer for debug information.
1702 * @param *block The IR block the node belongs to.
1703 * @param *op1 The first operand.
1704 * @param *op2 The second operand.
1705 * @param *mode The mode of the operands and the result.
1707 FIRM_API ir_node *new_rd_Carry(dbg_info *db, ir_node *block,
1708 ir_node *op1, ir_node *op2, ir_mode *mode);
1710 /** Constructor for a Borrow node.
1712 * @param *db A pointer for debug information.
1713 * @param *block The IR block the node belongs to.
1714 * @param *op1 The first operand.
1715 * @param *op2 The second operand.
1716 * @param *mode The mode of the operands and the result.
1718 FIRM_API ir_node *new_rd_Borrow(dbg_info *db, ir_node *block,
1719 ir_node *op1, ir_node *op2, ir_mode *mode);
1721 /** Constructor for a Phi node.
1723 * @param *db A pointer for debug information.
1724 * @param *block The IR block the node belongs to.
1725 * @param arity The number of predecessors
1726 * @param *in[] Array with predecessors. The constructor copies this array.
1727 * @param *mode The mode of it's inputs and output.
1729 FIRM_API ir_node *new_rd_Phi(dbg_info *db, ir_node *block, int arity,
1730 ir_node *in[], ir_mode *mode);
1732 /** Constructor for a Load node.
1734 * @param *db A pointer for debug information.
1735 * @param *block The IR block the node belongs to.
1736 * @param *store The current memory
1737 * @param *adr A pointer to the variable to be read in this memory.
1738 * @param *mode The mode of the value to be loaded.
1739 * @param flags Additional flags for alignment, volatility and pin state.
1741 FIRM_API ir_node *new_rd_Load(dbg_info *db, ir_node *block, ir_node *store,
1742 ir_node *adr, ir_mode *mode, ir_cons_flags flags);
1744 /** Constructor for a Store node.
1746 * @param *db A pointer for debug information.
1747 * @param *block The IR block the node belongs to.
1748 * @param *store The current memory
1749 * @param *adr A pointer to the variable to be read in this memory.
1750 * @param *val The value to write to this variable.
1751 * @param flags Additional flags for alignment, volatility and pin state.
1753 FIRM_API ir_node *new_rd_Store(dbg_info *db, ir_node *block, ir_node *store,
1754 ir_node *adr, ir_node *val, ir_cons_flags flags);
1756 /** Constructor for a Alloc node.
1758 * The Alloc node extends the memory by space for an entity of type alloc_type.
1760 * @param *db A pointer for debug information.
1761 * @param *block The IR block the node belongs to.
1762 * @param *store The memory which shall contain the new variable.
1763 * @param *count The number of objects to allocate.
1764 * @param *alloc_type The type of the allocated variable.
1765 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
1767 FIRM_API ir_node *new_rd_Alloc(dbg_info *db, ir_node *block, ir_node *store,
1768 ir_node *count, ir_type *alloc_type,
1769 ir_where_alloc where);
1771 /** Constructor for a Free node.
1773 * Frees the memory occupied by the entity pointed to by the pointer
1774 * arg. Type indicates the type of the entity the argument points to.
1776 * @param *db A pointer for debug information.
1777 * @param *block The IR block the node belongs to.
1778 * @param *store The memory which shall contain the new variable.
1779 * @param *ptr The pointer to the object to free.
1780 * @param *size The number of objects of type free_type to free in a sequence.
1781 * @param *free_type The type of the freed variable.
1782 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
1784 FIRM_API ir_node *new_rd_Free(dbg_info *db, ir_node *block, ir_node *store,
1785 ir_node *ptr, ir_node *size, ir_type *free_type,
1786 ir_where_alloc where);
1788 /** Constructor for a Sync node.
1790 * Merges several memory values. The node assumes that a variable
1791 * either occurs only in one of the memories, or it contains the same
1792 * value in all memories where it occurs.
1794 * @param *db A pointer for debug information.
1795 * @param *block The IR block the node belongs to.
1796 * @param arity The number of memories to synchronize.
1797 * @param *in[] An array of pointers to nodes that produce an output of type
1798 * memory. The constructor copies this array.
1800 FIRM_API ir_node *new_rd_Sync(dbg_info *db, ir_node *block, int arity,
1803 /** Constructor for a Proj node.
1805 * Projects a single value out of a tuple. The parameter proj gives the
1806 * position of the value within the tuple.
1808 * @param *db A pointer for debug information.
1809 * @param arg A node producing a tuple. The node must have mode_T.
1810 * @param *mode The mode of the value to project.
1811 * @param proj The position of the value in the tuple.
1813 FIRM_API ir_node *new_rd_Proj(dbg_info *db, ir_node *arg, ir_mode *mode,
1816 /** Constructor for a defaultProj node.
1818 * Represents the default control flow of a Switch-Cond node.
1820 * @param *db A pointer for debug information.
1821 * @param arg A node producing a tuple.
1822 * @param max_proj The end position of the value in the tuple.
1824 FIRM_API ir_node *new_rd_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
1826 /** Constructor for a Tuple node.
1828 * This is an auxiliary node to replace a node that returns a tuple
1829 * without changing the corresponding Proj nodes.
1831 * @param *db A pointer for debug information.
1832 * @param *block The IR block the node belongs to.
1833 * @param arity The number of tuple elements.
1834 * @param *in[] An array containing pointers to the nodes producing the tuple
1835 * elements. The constructor copies this array.
1837 FIRM_API ir_node *new_rd_Tuple(dbg_info *db, ir_node *block,
1838 int arity, ir_node *in[]);
1840 /** Constructor for a Id node.
1842 * This is an auxiliary node to replace a node that returns a single
1845 * @param *db A pointer for debug information.
1846 * @param *block The IR block the node belongs to.
1847 * @param *val The value
1848 * @param *mode The mode of *val.
1850 FIRM_API ir_node *new_rd_Id(dbg_info *db, ir_node *block,
1851 ir_node *val, ir_mode *mode);
1853 /** Constructor for a Confirm node.
1855 * Specifies constraints for a value. To support dataflow analyses.
1857 * Example: If the value never exceeds '100' this is expressed by placing a
1858 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
1860 * @param *db A pointer for debug information.
1861 * @param *block The IR block the node belong to.
1862 * @param *val The value we express a constraint for
1863 * @param *bound The value to compare against. Must be a firm node, typically a constant.
1864 * @param cmp The compare operation.
1866 FIRM_API ir_node *new_rd_Confirm(dbg_info *db, ir_node *block,
1867 ir_node *val, ir_node *bound, pn_Cmp cmp);
1869 /** Constructor for an Unknown node.
1871 * Represents an arbitrary value. Places the node in the start block.
1873 * @param *db A pointer for debug information.
1874 * @param *irg The IR graph the node belongs to.
1875 * @param *m The mode of the unknown value.
1877 FIRM_API ir_node *new_rd_Unknown(dbg_info *db, ir_graph *irg, ir_mode *m);
1879 /** Constructor for a Mux node.
1881 * @param *db A pointer for debug information.
1882 * @param *block The block the node belong to.
1883 * @param *sel The ir_node that calculates the boolean select.
1884 * @param *ir_true The ir_node that calculates the true result.
1885 * @param *ir_false The ir_node that calculates the false result.
1886 * @param *mode The mode of the node (and it_true and ir_false).
1888 FIRM_API ir_node *new_rd_Mux(dbg_info *db, ir_node *block, ir_node *sel,
1889 ir_node *ir_false, ir_node *ir_true,
1892 /** Constructor for a CopyB node.
1894 * @param *db A pointer for debug information.
1895 * @param *block The block the node belong to.
1896 * @param *store The current memory
1897 * @param *dst The ir_node that represents the destination address.
1898 * @param *src The ir_node that represents the source address.
1899 * @param *data_type The type of the copied data
1901 FIRM_API ir_node *new_rd_CopyB(dbg_info *db, ir_node *block, ir_node *store,
1902 ir_node *dst, ir_node *src, ir_type *data_type);
1904 /** Constructor for a InstOf node.
1906 * A High-Level Type check.
1908 * @param *db A pointer for debug information.
1909 * @param *block The IR block the node belongs to.
1910 * @param *store The memory in which the object the entity should be selected
1911 * from is allocated.
1912 * @param *objptr A pointer to a object of a class type.
1913 * @param *type The type of which objptr must be.
1915 FIRM_API ir_node *new_rd_InstOf(dbg_info *db, ir_node *block, ir_node *store,
1916 ir_node *objptr, ir_type *type);
1918 /** Constructor for a Raise node.
1920 * A High-Level Exception throw.
1922 * @param *db A pointer for debug information.
1923 * @param *block The IR block the node belongs to.
1924 * @param *store The current memory.
1925 * @param *obj A pointer to the Except variable.
1927 FIRM_API ir_node *new_rd_Raise(dbg_info *db, ir_node *block, ir_node *store,
1930 /** Constructor for a Bound node.
1932 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
1934 * @param *db A pointer for debug information.
1935 * @param *block The block the node belong to.
1936 * @param *store The current memory.
1937 * @param *idx The ir_node that represents an index.
1938 * @param *lower The ir_node that represents the lower bound for the index.
1939 * @param *upper The ir_node that represents the upper bound for the index.
1941 FIRM_API ir_node *new_rd_Bound(dbg_info *db, ir_node *block,
1942 ir_node *store, ir_node *idx, ir_node *lower,
1945 /** Constructor for a Pin node.
1947 * @param *db A pointer for debug information.
1948 * @param *block The block the node belong to.
1949 * @param *node The node which value should be pinned.
1951 FIRM_API ir_node *new_rd_Pin(dbg_info *db, ir_node *block, ir_node *node);
1953 /** Constructor for an ASM pseudo node.
1955 * @param *db A pointer for debug information.
1956 * @param *block The block the node belong to.
1957 * @param arity The number of data inputs to the node.
1958 * @param *in The array of length arity of data inputs.
1959 * @param *inputs The array of length arity of input constraints.
1960 * @param n_outs The number of data outputs to the node.
1961 * @param *outputs The array of length n_outs of output constraints.
1962 * @param n_clobber The number of clobbered registers.
1963 * @param *clobber The array of length n_clobber of clobbered registers.
1964 * @param *asm_text The assembler text.
1966 FIRM_API ir_node *new_rd_ASM(dbg_info *db, ir_node *block,
1967 int arity, ir_node *in[], ir_asm_constraint *inputs,
1968 int n_outs, ir_asm_constraint *outputs,
1969 int n_clobber, ident *clobber[], ident *asm_text);
1971 /*-------------------------------------------------------------------------*/
1972 /* The raw interface without debug support */
1973 /*-------------------------------------------------------------------------*/
1975 /** Constructor for a Block node.
1977 * Constructs a mature block with the given predecessors. Use Unknown
1978 * nodes as predecessors to construct a block if the number of
1979 * predecessors is known, but not the predecessors themselves. This
1980 * constructor does not set current_block. It not be used with
1981 * automatic Phi node construction.
1984 * @param irg The IR graph the block belongs to.
1985 * @param arity The number of control predecessors.
1986 * @param in[] An array of control predecessors. The length of
1987 * the array must be 'arity'. The constructor copies this array.
1989 FIRM_API ir_node *new_r_Block(ir_graph *irg, int arity, ir_node *in[]);
1991 /** Constructor for a Start node.
1993 * @param *irg The IR graph the node belongs to.
1994 * @param *block The IR block the node belongs to.
1996 FIRM_API ir_node *new_r_Start(ir_graph *irg, ir_node *block);
1998 /** Constructor for a End node.
2000 * @param *irg The IR graph the node belongs to.
2001 * @param *block The IR block the node belongs to.
2003 FIRM_API ir_node *new_r_End(ir_graph *irg, ir_node *block);
2005 /** Constructor for a Jmp node.
2007 * Jmp represents control flow to a single control successor.
2009 * @param *block The IR block the node belongs to.
2011 FIRM_API ir_node *new_r_Jmp(ir_node *block);
2013 /** Constructor for an IJmp node.
2015 * IJmp represents control flow to a single control successor not
2016 * statically known i.e. an indirect Jmp.
2018 * @param *block The IR block the node belongs to.
2019 * @param *tgt The IR node representing the target address.
2021 FIRM_API ir_node *new_r_IJmp(ir_node *block, ir_node *tgt);
2023 /** Constructor for a Cond node.
2025 * If c is mode_b represents a conditional branch (if/else). If c is
2026 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2027 * node, default Proj is 0.)
2029 * This is not consistent: Input to Cond is Is, Proj has as proj number
2032 * @param *block The IR block the node belongs to.
2033 * @param *c The conditions parameter.Can be of mode b or I_u.
2035 FIRM_API ir_node *new_r_Cond(ir_node *block, ir_node *c);
2037 /** Constructor for a Return node.
2039 * Returns the memory and zero or more return values. Only node that
2040 * can end regular control flow.
2042 * @param *block The IR block the node belongs to.
2043 * @param *store The state of memory.
2044 * @param arity Number of array indices.
2045 * @param *in[] Array with index inputs to the node. The constructor copies this array.
2047 FIRM_API ir_node *new_r_Return(ir_node *block, ir_node *store,
2048 int arity, ir_node *in[]);
2050 /** Constructor for a Const node.
2052 * Adds the node to the start block.
2054 * Constructor for a Const node. The constant represents a target
2055 * value. Sets the type information to type_unknown. (No more
2056 * supported: If tv is entity derives a somehow useful type.)
2057 * Derives mode from passed tarval.
2059 * @param *irg The IR graph the node belongs to.
2060 * @param *con Points to an entry in the constant table.
2062 FIRM_API ir_node *new_r_Const(ir_graph *irg, tarval *con);
2064 /** Constructor for a Const node.
2066 * Adds the node to the start block.
2068 * Constructor for a Const node. The constant represents a target
2069 * value. Sets the type information to type_unknown. (No more
2070 * supported: If tv is entity derives a somehow useful type.)
2072 * @param *irg The IR graph the node belongs to.
2073 * @param *mode The mode of the operands and the results.
2074 * @param value A value from which the tarval is made.
2076 FIRM_API ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value);
2078 /** Constructor for a Const_type node.
2080 * Adds the node to the start block.
2082 * The constant represents a target value. This constructor sets high
2083 * level type information for the constant value.
2084 * Derives mode from passed tarval.
2086 * @param *irg The IR graph the node belongs to.
2087 * @param *con Points to an entry in the constant table.
2088 * @param *tp The type of the constant.
2090 FIRM_API ir_node *new_r_Const_type(ir_graph *irg, tarval *con, ir_type *tp);
2092 /** Constructor for a SymConst node.
2094 * This is the constructor for a symbolic constant.
2095 * There are several kinds of symbolic constants:
2096 * - symconst_type_tag The symbolic constant represents a type tag. The
2097 * type the tag stands for is given explicitly.
2098 * - symconst_type_size The symbolic constant represents the size of a type.
2099 * The type of which the constant represents the size
2100 * is given explicitly.
2101 * - symconst_type_align The symbolic constant represents the alignment of a
2102 * type. The type of which the constant represents the
2103 * size is given explicitly.
2104 * - symconst_addr_ent The symbolic constant represents the address of an
2105 * entity (variable or method). The variable is given
2106 * explicitly by a firm entity.
2107 * - symconst_ofs_ent The symbolic constant represents the offset of an
2108 * entity in its owner type.
2109 * - symconst_enum_const The symbolic constant is a enumeration constant of
2110 * an enumeration type.
2112 * Inputs to the node:
2113 * No inputs except the block it belongs to.
2114 * Outputs of the node.
2115 * An unsigned integer (I_u) or a pointer (P).
2117 * Mention union in declaration so that the firmjni generator recognizes that
2118 * it can not cast the argument to an int.
2120 * @param *irg The IR graph the node belongs to.
2121 * @param mode The mode for the SymConst.
2122 * @param value A type, ident, entity or enum constant depending on the
2124 * @param kind The kind of the symbolic constant, see the list above
2126 FIRM_API ir_node *new_r_SymConst(ir_graph *irg, ir_mode *mode,
2127 union symconst_symbol value,
2128 symconst_kind kind);
2130 /** Constructor for a simpleSel node.
2132 * This is a shortcut for the new_d_Sel() constructor. To be used for
2133 * Sel nodes that do not select from an array, i.e., have no index
2134 * inputs. It adds the two parameters 0, NULL.
2136 * @param *block The IR block the node belongs to.
2137 * @param *store The memory in which the object the entity should be selected
2138 * from is allocated.
2139 * @param *objptr The object from that the Sel operation selects a
2140 * single attribute out.
2141 * @param *ent The entity to select.
2143 FIRM_API ir_node *new_r_simpleSel(ir_node *block, ir_node *store,
2144 ir_node *objptr, ir_entity *ent);
2146 /** Constructor for a Sel node.
2148 * The select node selects an entity (field or method) from an entity
2149 * with a compound type. It explicitly specifies the entity selected.
2150 * Dynamically the node may select entities that overwrite the given
2151 * entity. If the selected entity is an array element entity the Sel
2152 * node takes the required array indices as inputs.
2154 * @param *block The IR block the node belongs to.
2155 * @param *store The memory in which the object the entity should be selected
2156 * from is allocated.
2157 * @param *objptr A pointer to a compound entity the Sel operation selects a
2158 * single attribute from.
2159 * @param *n_index The number of array indices needed to select an array element entity.
2160 * @param *index[] If the compound entity is an array the indices of the selected
2161 * element entity. The constructor copies this array.
2162 * @param *ent The entity to select.
2164 FIRM_API ir_node *new_r_Sel(ir_node *block, ir_node *store,
2165 ir_node *objptr, int n_index, ir_node *index[],
2168 /** Constructor for a Call node.
2170 * Represents all kinds of method and function calls.
2172 * @param *block The IR block the node belongs to.
2173 * @param *store The actual store.
2174 * @param *callee A pointer to the called procedure.
2175 * @param arity The number of procedure parameters.
2176 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2177 * @param *tp Type information of the procedure called.
2179 FIRM_API ir_node *new_r_Call(ir_node *block, ir_node *store,
2180 ir_node *callee, int arity, ir_node *in[],
2183 /** Constructor for a Builtin node.
2185 * Represents a call of a backend-specific builtin..
2187 * @param *block The IR block the node belongs to.
2188 * @param *store The actual store.
2189 * @param arity The number of procedure parameters.
2190 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2191 * @param kind The kind of the called builtin.
2192 * @param *tp Type information of the procedure called.
2194 FIRM_API ir_node *new_r_Builtin(ir_node *block, ir_node *store,
2195 int arity, ir_node *in[], ir_builtin_kind kind,
2198 /** Constructor for a Add node.
2200 * @param *block The IR block the node belongs to.
2201 * @param *op1 The first operand.
2202 * @param *op2 The second operand.
2203 * @param *mode The mode of the operands and the result.
2205 FIRM_API ir_node *new_r_Add(ir_node *block, ir_node *op1, ir_node *op2,
2209 * Constructor for a Sub node.
2211 * @param *block The IR block the node belongs to.
2212 * @param *op1 The first operand.
2213 * @param *op2 The second operand.
2214 * @param *mode The mode of the operands and the results.
2216 FIRM_API ir_node *new_r_Sub(ir_node *block, ir_node *op1, ir_node *op2,
2219 /** Constructor for a Minus node.
2221 * @param *block The IR block the node belongs to.
2222 * @param *op The operand.
2223 * @param *mode The mode of the operand and the result.
2225 FIRM_API ir_node *new_r_Minus(ir_node *block, ir_node *op, ir_mode *mode);
2227 /** Constructor for a Mul node.
2229 * @param *block The IR block the node belongs to.
2230 * @param *op1 The first operand.
2231 * @param *op2 The second operand.
2232 * @param *mode The mode of the operands and the result.
2234 FIRM_API ir_node *new_r_Mul(ir_node *block, ir_node *op1, ir_node *op2,
2237 /** Constructor for a Mulh node.
2239 * @param *block The IR block the node belongs to.
2240 * @param *op1 The first operand.
2241 * @param *op2 The second operand.
2242 * @param *mode The mode of the operands and the result.
2244 FIRM_API ir_node *new_r_Mulh(ir_node *block, ir_node *op1, ir_node *op2,
2247 /** Constructor for a Quot node.
2249 * @param *block The IR block the node belongs to.
2250 * @param *memop The store needed to model exceptions
2251 * @param *op1 The first operand.
2252 * @param *op2 The second operand.
2253 * @param *mode The mode of the result.
2254 * @param state The pinned state.
2256 FIRM_API ir_node *new_r_Quot(ir_node *block, ir_node *memop,
2257 ir_node *op1, ir_node *op2, ir_mode *mode,
2258 op_pin_state state);
2260 /** Constructor for a DivMod node.
2262 * @param *block The IR block the node belongs to.
2263 * @param *memop The store needed to model exceptions
2264 * @param *op1 The first operand.
2265 * @param *op2 The second operand.
2266 * @param *mode The mode of the results.
2267 * @param state The pinned state.
2269 FIRM_API ir_node *new_r_DivMod(ir_node *block, ir_node *memop,
2270 ir_node *op1, ir_node *op2, ir_mode *mode,
2271 op_pin_state state);
2273 /** Constructor for a Div node.
2275 * @param *block The IR block the node belongs to.
2276 * @param *memop The store needed to model exceptions
2277 * @param *op1 The first operand.
2278 * @param *op2 The second operand.
2279 * @param *mode The mode of the result.
2280 * @param state The pinned state.
2282 FIRM_API ir_node *new_r_Div(ir_node *block, ir_node *memop,
2283 ir_node *op1, ir_node *op2, ir_mode *mode,
2284 op_pin_state state);
2286 /** Constructor for a remainderless Div node.
2288 * @param *block The IR block the node belongs to.
2289 * @param *memop The store needed to model exceptions
2290 * @param *op1 The first operand.
2291 * @param *op2 The second operand.
2292 * @param *mode The mode of the result.
2293 * @param state The pinned state.
2295 FIRM_API ir_node *new_r_DivRL(ir_node *block, ir_node *memop,
2296 ir_node *op1, ir_node *op2, ir_mode *mode,
2297 op_pin_state state);
2299 /** Constructor for a Mod node.
2301 * @param *block The IR block the node belongs to.
2302 * @param *memop The store needed to model exceptions
2303 * @param *op1 The first operand.
2304 * @param *op2 The second operand.
2305 * @param *mode The mode of the result.
2306 * @param state The pinned state.
2308 FIRM_API ir_node *new_r_Mod(ir_node *block, ir_node *memop,
2309 ir_node *op1, ir_node *op2, ir_mode *mode,
2310 op_pin_state state);
2312 /** Constructor for a Abs node.
2314 * @param *block The IR block the node belongs to.
2315 * @param *op The operand
2316 * @param *mode The mode of the operands and the result.
2318 FIRM_API ir_node *new_r_Abs(ir_node *block, ir_node *op, ir_mode *mode);
2320 /** Constructor for a And node.
2322 * @param *block The IR block the node belongs to.
2323 * @param *op1 The first operand.
2324 * @param *op2 The second operand.
2325 * @param *mode The mode of the operands and the result.
2327 FIRM_API ir_node *new_r_And(ir_node *block, ir_node *op1, ir_node *op2,
2330 /** Constructor for a Or node.
2332 * @param *block The IR block the node belongs to.
2333 * @param *op1 The first operand.
2334 * @param *op2 The second operand.
2335 * @param *mode The mode of the operands and the result.
2337 FIRM_API ir_node *new_r_Or(ir_node *block, ir_node *op1, ir_node *op2,
2340 /** Constructor for a Eor node.
2342 * @param *block The IR block the node belongs to.
2343 * @param *op1 The first operand.
2344 * @param *op2 The second operand.
2345 * @param *mode The mode of the operands and the results.
2347 FIRM_API ir_node *new_r_Eor(ir_node *block, ir_node *op1, ir_node *op2,
2350 /** Constructor for a Not node.
2352 * @param *block The IR block the node belongs to.
2353 * @param *op The operand.
2354 * @param *mode The mode of the operand and the result.
2356 FIRM_API ir_node *new_r_Not(ir_node *block, ir_node *op, ir_mode *mode);
2358 /** Constructor for a Cmp node.
2360 * @param *block The IR block the node belongs to.
2361 * @param *op1 The first operand.
2362 * @param *op2 The second operand.
2364 FIRM_API ir_node *new_r_Cmp(ir_node *block, ir_node *op1, ir_node *op2);
2366 /** Constructor for a Shl node.
2368 * @param *block The IR block the node belongs to.
2369 * @param *op The operand.
2370 * @param *k The number of bits to shift the operand .
2371 * @param *mode The mode of the operand and the result.
2373 FIRM_API ir_node *new_r_Shl(ir_node *block, ir_node *op, ir_node *k,
2376 /** Constructor for a Shr node.
2378 * @param *block The IR block the node belongs to.
2379 * @param *op The operand.
2380 * @param *k The number of bits to shift the operand .
2381 * @param *mode The mode of the operand and the result.
2383 FIRM_API ir_node *new_r_Shr(ir_node *block, ir_node *op, ir_node *k,
2387 * Constructor for a Shrs node.
2389 * @param *block The IR block the node belongs to.
2390 * @param *op The operand.
2391 * @param *k The number of bits to shift the operand.
2392 * @param *mode The mode of the operand and the result.
2394 FIRM_API ir_node *new_r_Shrs(ir_node *block, ir_node *op, ir_node *k,
2397 /** Constructor for a Rotl node.
2399 * @param *block The IR block the node belongs to.
2400 * @param *op The operand.
2401 * @param *k The number of bits to rotate the operand.
2402 * @param *mode The mode of the operand.
2404 FIRM_API ir_node *new_r_Rotl(ir_node *block, ir_node *op, ir_node *k,
2407 /** Constructor for a Conv node.
2409 * @param *block The IR block the node belongs to.
2410 * @param *op The operand.
2411 * @param *mode The mode of this the operand muss be converted .
2413 FIRM_API ir_node *new_r_Conv(ir_node *block, ir_node *op, ir_mode *mode);
2415 /** Constructor for a strict Conv node.
2417 * @param *block The IR block the node belongs to.
2418 * @param *op The operand.
2419 * @param *mode The mode of this the operand muss be converted .
2421 FIRM_API ir_node *new_r_strictConv(ir_node *block, ir_node *op, ir_mode *mode);
2423 /** Constructor for a Cast node.
2425 * High level type cast
2427 * @param *block The IR block the node belongs to.
2428 * @param *op The operand.
2429 * @param *to_tp The type of this the operand muss be casted .
2431 FIRM_API ir_node *new_r_Cast(ir_node *block, ir_node *op, ir_type *to_tp);
2433 /** Constructor for a Carry node.
2435 * @param *block The IR block the node belongs to.
2436 * @param *op1 The first operand.
2437 * @param *op2 The second operand.
2438 * @param *mode The mode of the operands and the result.
2440 FIRM_API ir_node *new_r_Carry(ir_node *block, ir_node *op1, ir_node *op2,
2444 * Constructor for a Borrow node.
2446 * @param *block The IR block the node belongs to.
2447 * @param *op1 The first operand.
2448 * @param *op2 The second operand.
2449 * @param *mode The mode of the operands and the results.
2451 FIRM_API ir_node *new_r_Borrow(ir_node *block, ir_node *op1, ir_node *op2,
2454 /** Constructor for a Phi node.
2456 * @param *block The IR block the node belongs to.
2457 * @param arity The number of predecessors
2458 * @param *in[] Array with predecessors. The constructor copies this array.
2459 * @param *mode The mode of it's inputs and output.
2461 FIRM_API ir_node *new_r_Phi(ir_node *block, int arity, ir_node *in[],
2464 /** Constructor for a Load node.
2466 * @param *block The IR block the node belongs to.
2467 * @param *store The current memory
2468 * @param *adr A pointer to the variable to be read in this memory.
2469 * @param *mode The mode of the value to be loaded.
2470 * @param flags Additional flags for alignment, volatility and pin state.
2472 FIRM_API ir_node *new_r_Load(ir_node *block, ir_node *store,
2473 ir_node *adr, ir_mode *mode, ir_cons_flags flags);
2475 /** Constructor for a Store node.
2477 * @param *block The IR block the node belongs to.
2478 * @param *store The current memory
2479 * @param *adr A pointer to the variable to be read in this memory.
2480 * @param *val The value to write to this variable.
2481 * @param flags Additional flags for alignment, volatility and pin state.
2483 FIRM_API ir_node *new_r_Store(ir_node *block, ir_node *store,
2484 ir_node *adr, ir_node *val, ir_cons_flags flags);
2486 /** Constructor for a Alloc node.
2488 * The Alloc node extends the memory by space for an entity of type alloc_type.
2490 * @param *block The IR block the node belongs to.
2491 * @param *store The memory which shall contain the new variable.
2492 * @param *count The number of objects to allocate.
2493 * @param *alloc_type The type of the allocated variable.
2494 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
2496 FIRM_API ir_node *new_r_Alloc(ir_node *block, ir_node *store,
2497 ir_node *count, ir_type *alloc_type,
2498 ir_where_alloc where);
2500 /** Constructor for a Free node.
2502 * Frees the memory occupied by the entity pointed to by the pointer
2503 * arg. Type indicates the type of the entity the argument points to.
2505 * @param *block The IR block the node belongs to.
2506 * @param *store The memory which shall contain the new variable.
2507 * @param *ptr The pointer to the object to free.
2508 * @param *size The number of objects of type free_type to free in a sequence.
2509 * @param *free_type The type of the freed variable.
2510 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
2512 FIRM_API ir_node *new_r_Free(ir_node *block, ir_node *store, ir_node *ptr,
2513 ir_node *size, ir_type *free_type,
2514 ir_where_alloc where);
2516 /** Constructor for a Sync node.
2518 * Merges several memory values. The node assumes that a variable
2519 * either occurs only in one of the memories, or it contains the same
2520 * value in all memories where it occurs.
2522 * @param *block The IR block the node belongs to.
2523 * @param arity The number of memories to synchronize.
2524 * @param *in[] An array of pointers to nodes that produce an output of type memory.
2525 * The constructor copies this array.
2527 FIRM_API ir_node *new_r_Sync(ir_node *block, int arity, ir_node *in[]);
2529 /** Constructor for a Proj node.
2531 * Projects a single value out of a tuple. The parameter proj gives the
2532 * position of the value within the tuple.
2534 * @param arg A node producing a tuple.
2535 * @param mode The mode of the value to project.
2536 * @param proj The position of the value in the tuple.
2538 FIRM_API ir_node *new_r_Proj(ir_node *arg, ir_mode *mode, long proj);
2540 /** Constructor for a defaultProj node.
2542 * Represents the default control flow of a Switch-Cond node.
2544 * @param arg A node producing a tuple.
2545 * @param max_proj The end position of the value in the tuple.
2547 FIRM_API ir_node *new_r_defaultProj(ir_node *arg, long max_proj);
2550 /** Constructor for a Tuple node.
2552 * This is an auxiliary node to replace a node that returns a tuple
2553 * without changing the corresponding Proj nodes.
2555 * @param *block The IR block the node belongs to.
2556 * @param arity The number of tuple elements.
2557 * @param *in[] An array containing pointers to the nodes producing the tuple elements.
2558 * The constructor copies this array.
2560 FIRM_API ir_node *new_r_Tuple(ir_node *block, int arity, ir_node *in[]);
2562 /** Constructor for a Id node.
2564 * This is an auxiliary node to replace a node that returns a single
2567 * @param *block The IR block the node belongs to.
2568 * @param *val The operand to Id.
2569 * @param *mode The mode of *val.
2571 FIRM_API ir_node *new_r_Id(ir_node *block, ir_node *val, ir_mode *mode);
2573 /** Constructor for a Bad node.
2575 * Returns the unique Bad node of the graph. The same as
2578 * @param *irg The IR graph the node belongs to.
2580 FIRM_API ir_node *new_r_Bad(ir_graph *irg);
2582 /** Constructor for a Confirm node.
2584 * Specifies constraints for a value. To support dataflow analyses.
2586 * Example: If the value never exceeds '100' this is expressed by placing a
2587 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
2589 * @param *block The IR block the node belong to.
2590 * @param *val The value we express a constraint for
2591 * @param *bound The value to compare against. Must be a firm node, typically a constant.
2592 * @param cmp The compare operation.
2594 FIRM_API ir_node *new_r_Confirm(ir_node *block, ir_node *val, ir_node *bound,
2597 /** Constructor for a Unknown node.
2599 * Represents an arbitrary value. Places the node in
2602 * @param *irg The IR graph the node belongs to.
2603 * @param *m The mode of the unknown value.
2605 FIRM_API ir_node *new_r_Unknown(ir_graph *irg, ir_mode *m);
2607 /** Constructor for a NoMem node.
2609 * Returns the unique NoMem node of the graph. The same as
2612 * @param *irg The IR graph the node belongs to.
2614 FIRM_API ir_node *new_r_NoMem(ir_graph *irg);
2616 /** Constructor for a Mux node.
2618 * @param *block The block the node belong to.
2619 * @param *sel The ir_node that calculates the boolean select.
2620 * @param *ir_true The ir_node that calculates the true result.
2621 * @param *ir_false The ir_node that calculates the false result.
2622 * @param *mode The mode of the node (and it_true and ir_false).
2624 FIRM_API ir_node *new_r_Mux(ir_node *block, ir_node *sel,
2625 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
2627 /** Constructor for a CopyB node.
2629 * @param *block The block the node belong to.
2630 * @param *store The current memory
2631 * @param *dst The ir_node that represents the destination address.
2632 * @param *src The ir_node that represents the source address.
2633 * @param *data_type The type of the copied data
2635 FIRM_API ir_node *new_r_CopyB(ir_node *block, ir_node *store,
2636 ir_node *dst, ir_node *src, ir_type *data_type);
2638 /** Constructor for a InstOf node.
2640 * A High-Level Type check.
2642 * @param *block The block the node belong to.
2643 * @param *store The memory in which the object the entity should be selected
2644 * from is allocated.
2645 * @param *objptr A pointer to a object of a class type.
2646 * @param *type The type of which objptr must be.
2648 FIRM_API ir_node *new_r_InstOf(ir_node *block, ir_node *store,
2649 ir_node *objptr, ir_type *type);
2651 /** Constructor for a Raise node.
2653 * A High-Level Exception throw.
2655 * @param *block The IR block the node belongs to.
2656 * @param *store The current memory.
2657 * @param *obj A pointer to the Except variable.
2659 FIRM_API ir_node *new_r_Raise(ir_node *block, ir_node *store, ir_node *obj);
2661 /** Constructor for a Bound node.
2663 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
2665 * @param *block The block the node belong to.
2666 * @param *store The current memory.
2667 * @param *idx The ir_node that represents an index.
2668 * @param *lower The ir_node that represents the lower bound for the index.
2669 * @param *upper The ir_node that represents the upper bound for the index.
2671 FIRM_API ir_node *new_r_Bound(ir_node *block, ir_node *store,
2672 ir_node *idx, ir_node *lower, ir_node *upper);
2674 /** Constructor for a Pin node.
2676 * @param *block The block the node belong to.
2677 * @param *node The node which value should be pinned.
2679 FIRM_API ir_node *new_r_Pin(ir_node *block, ir_node *node);
2681 /** Constructor for an ASM pseudo node.
2683 * @param *block The block the node belong to.
2684 * @param arity The number of data inputs to the node.
2685 * @param *in The array of length arity of data inputs.
2686 * @param *inputs The array of length arity of input constraints.
2687 * @param n_outs The number of data outputs to the node.
2688 * @param *outputs The array of length n_outs of output constraints.
2689 * @param n_clobber The number of clobbered registers.
2690 * @param *clobber The array of length n_clobber of clobbered registers.
2691 * @param *asm_text The assembler text.
2693 FIRM_API ir_node *new_r_ASM(ir_node *block,
2694 int arity, ir_node *in[], ir_asm_constraint *inputs,
2695 int n_outs, ir_asm_constraint *outputs,
2696 int n_clobber, ident *clobber[], ident *asm_text);
2698 /*-----------------------------------------------------------------------*/
2699 /* The block oriented interface */
2700 /*-----------------------------------------------------------------------*/
2702 /** Sets the current block in which the following constructors place the
2703 * nodes they construct.
2705 * @param target The new current block.
2707 FIRM_API void set_cur_block(ir_node *target);
2709 /** Returns the current block of the current graph. */
2710 FIRM_API ir_node *get_cur_block(void);
2712 /** Constructor for a Block node.
2714 * Adds the block to the graph in current_ir_graph. Constructs a Block
2715 * with a fixed number of predecessors.
2717 * @param *db A Pointer for debug information.
2718 * @param arity The number of control predecessors.
2719 * @param in[] An array of control predecessors. The length of
2720 * the array must be 'arity'.
2722 FIRM_API ir_node *new_d_Block(dbg_info *db, int arity, ir_node *in[]);
2724 /** Constructor for a Start node.
2726 * Adds the node to the block in current_ir_block.
2728 * @param *db A pointer for debug information.
2730 FIRM_API ir_node *new_d_Start(dbg_info *db);
2732 /** Constructor for a End node.
2734 * Adds the node to the block in current_ir_block.
2736 * @param *db A pointer for debug information.
2738 FIRM_API ir_node *new_d_End(dbg_info *db);
2740 /** Constructor for a Jmp node.
2742 * Adds the node to the block in current_ir_block.
2744 * Jmp represents control flow to a single control successor.
2746 * @param *db A pointer for debug information.
2748 FIRM_API ir_node *new_d_Jmp(dbg_info *db);
2750 /** Constructor for an IJmp node.
2752 * IJmp represents control flow to a single control successor not
2753 * statically known i.e. an indirect Jmp.
2755 * @param *db A pointer for debug information.
2756 * @param *tgt The IR node representing the target address.
2758 FIRM_API ir_node *new_d_IJmp(dbg_info *db, ir_node *tgt);
2760 /** Constructor for a Cond node.
2762 * Adds the node to the block in current_ir_block.
2764 * If c is mode_b represents a conditional branch (if/else). If c is
2765 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
2766 * node, default Proj is 0.)
2768 * This is not consistent: Input to Cond is Is, Proj has as proj number
2771 * @param *db A pointer for debug information.
2772 * @param *c The conditions parameter.Can be of mode b or I_u.
2774 FIRM_API ir_node *new_d_Cond(dbg_info *db, ir_node *c);
2776 /** Constructor for a Return node.
2778 * Adds the node to the block in current_ir_block.
2780 * Returns the memory and zero or more return values. Only node that
2781 * can end regular control flow.
2783 * @param *db A pointer for debug information.
2784 * @param *store The state of memory.
2785 * @param arity Number of array indices.
2786 * @param *in Array with index inputs to the node.
2788 FIRM_API ir_node *new_d_Return(dbg_info *db, ir_node *store,
2789 int arity, ir_node *in[]);
2791 /** Constructor for a Const_type node.
2793 * Adds the node to the start block.
2795 * The constant represents a target value. This constructor sets high
2796 * level type information for the constant value.
2797 * Derives mode from passed tarval.
2799 * @param *db A pointer for debug information.
2800 * @param *con Points to an entry in the constant table. This pointer is
2801 added to the attributes of the node.
2802 * @param *tp The type of the constant.
2804 FIRM_API ir_node *new_d_Const_type(dbg_info *db, tarval *con, ir_type *tp);
2806 /** Constructor for a Const node.
2808 * Adds the node to the block in current_ir_block.
2810 * Constructor for a Const node. The constant represents a target
2811 * value. Sets the type information to type_unknown. (No more
2812 * supported: If tv is entity derives a somehow useful type.)
2813 * Derives mode from passed tarval.
2815 * @param *db A pointer for debug information.
2816 * @param *con Points to an entry in the constant table. This pointer is added
2817 * to the attributes of the node.
2819 FIRM_API ir_node *new_d_Const(dbg_info *db, tarval *con);
2822 * @see new_rd_Const_long()
2824 * @param *db A pointer for debug information.
2825 * @param *mode The mode of the operands and results.
2826 * @param value A value from which the tarval is made.
2828 FIRM_API ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value);
2830 /** Constructor for a SymConst_type node.
2832 * This is the constructor for a symbolic constant.
2833 * There are several kinds of symbolic constants:
2834 * - symconst_type_tag The symbolic constant represents a type tag. The
2835 * type the tag stands for is given explicitly.
2836 * - symconst_type_size The symbolic constant represents the size of a type.
2837 * The type of which the constant represents the size
2838 * is given explicitly.
2839 * - symconst_type_align The symbolic constant represents the alignment of a
2840 * type. The type of which the constant represents the
2841 * size is given explicitly.
2842 * - symconst_addr_ent The symbolic constant represents the address of an
2843 * entity (variable or method). The variable is given
2844 * explicitly by a firm entity.
2845 * - symconst_ofs_ent The symbolic constant represents the offset of an
2846 * entity in its owner type.
2847 * - symconst_enum_const The symbolic constant is a enumeration constant of
2848 * an enumeration type.
2850 * Inputs to the node:
2851 * No inputs except the block it belongs to.
2852 * Outputs of the node.
2853 * An unsigned integer (I_u) or a pointer (P).
2855 * Mention union in declaration so that the firmjni generator recognizes that
2856 * it can not cast the argument to an int.
2858 * @param *db A pointer for debug information.
2859 * @param mode The mode for the SymConst.
2860 * @param value A type, ident, entity or enum constant depending on the
2862 * @param kind The kind of the symbolic constant, see the list above
2863 * @param tp The source type of the constant.
2865 FIRM_API ir_node *new_d_SymConst_type(dbg_info *db, ir_mode *mode,
2866 union symconst_symbol value,
2867 symconst_kind kind, ir_type *tp);
2869 /** Constructor for a SymConst node.
2871 * Same as new_d_SymConst_type, except that it sets the type to type_unknown.
2873 FIRM_API ir_node *new_d_SymConst(dbg_info *db, ir_mode *mode,
2874 union symconst_symbol value,
2875 symconst_kind kind);
2877 /** Constructor for a simpleSel node.
2879 * This is a shortcut for the new_d_Sel() constructor. To be used for
2880 * Sel nodes that do not select from an array, i.e., have no index
2881 * inputs. It adds the two parameters 0, NULL.
2883 * @param *db A pointer for debug information.
2884 * @param *store The memory in which the object the entity should be
2885 * selected from is allocated.
2886 * @param *objptr The object from that the Sel operation selects a
2887 * single attribute out.
2888 * @param *ent The entity to select.
2890 FIRM_API ir_node *new_d_simpleSel(dbg_info *db, ir_node *store, ir_node *objptr,
2893 /** Constructor for a Sel node.
2895 * The select node selects an entity (field or method) from an entity
2896 * with a compound type. It explicitly specifies the entity selected.
2897 * Dynamically the node may select entities that overwrite the given
2898 * entity. If the selected entity is an array element entity the Sel
2899 * node takes the required array indices as inputs.
2900 * Adds the node to the block in current_ir_block.
2902 * @param *db A pointer for debug information.
2903 * @param *store The memory in which the object the entity should be selected
2904 * from is allocated.
2905 * @param *objptr A pointer to a compound entity the Sel operation selects a
2906 * single attribute from.
2907 * @param arity The number of array indices needed to select an array element entity.
2908 * @param *in[] If the compound entity is an array the indices of the selected
2909 * element entity. The constructor copies this array.
2910 * @param *ent The entity to select.
2912 FIRM_API ir_node *new_d_Sel(dbg_info *db, ir_node *store, ir_node *objptr,
2913 int arity, ir_node *in[], ir_entity *ent);
2915 /** Constructor for a Call node.
2917 * Represents all kinds of method and function calls.
2918 * Adds the node to the block in current_ir_block.
2920 * @param *db A pointer for debug information.
2921 * @param *store The actual store.
2922 * @param *callee A pointer to the called procedure.
2923 * @param arity The number of procedure parameters.
2924 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2925 * @param *tp Type information of the procedure called.
2927 FIRM_API ir_node *new_d_Call(dbg_info *db, ir_node *store, ir_node *callee,
2928 int arity, ir_node *in[], ir_type *tp);
2930 /** Constructor for a Builtin node.
2932 * Represents a call of a backend-specific builtin..
2933 * Adds the node to the block in current_ir_block.
2935 * @param *db A pointer for debug information.
2936 * @param *store The actual store.
2937 * @param arity The number of procedure parameters.
2938 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
2939 * @param kind The kind of the called builtin.
2940 * @param *tp Type information of the procedure called.
2942 FIRM_API ir_node *new_d_Builtin(dbg_info *db, ir_node *store,
2943 int arity, ir_node *in[],
2944 ir_builtin_kind kind, ir_type *tp);
2946 /** Constructor for a Add node.
2948 * Adds the node to the block in current_ir_block.
2950 * @param *db A pointer for debug information.
2951 * @param *op1 The first operand.
2952 * @param *op2 The second operand.
2953 * @param *mode The mode of the operands and the result.
2955 FIRM_API ir_node *new_d_Add(dbg_info *db, ir_node *op1, ir_node *op2,
2958 /** Constructor for a Sub node.
2960 * Adds the node to the block in current_ir_block.
2962 * @param *db A pointer for debug information.
2963 * @param *op1 The first operand.
2964 * @param *op2 The second operand.
2965 * @param *mode The mode of the operands and the result.
2967 FIRM_API ir_node *new_d_Sub(dbg_info *db, ir_node *op1, ir_node *op2,
2970 /** Constructor for a Minus node.
2972 * Adds the node to the block in current_ir_block.
2974 * @param *db A pointer for debug information.
2975 * @param *op The operand .
2976 * @param *mode The mode of the operand and the result.
2978 FIRM_API ir_node *new_d_Minus(dbg_info *db, ir_node *op, ir_mode *mode);
2980 /** Constructor for a Mul node.
2982 * Adds the node to the block in current_ir_block.
2984 * @param *db A pointer for debug information.
2985 * @param *op1 The first operand.
2986 * @param *op2 The second operand.
2987 * @param *mode The mode of the operands and the result.
2989 FIRM_API ir_node *new_d_Mul(dbg_info *db, ir_node *op1, ir_node *op2,
2992 /** Constructor for a Mulh node.
2994 * Adds the node to the block in current_ir_block.
2996 * @param *db A pointer for debug information.
2997 * @param *op1 The first operand.
2998 * @param *op2 The second operand.
2999 * @param *mode The mode of the operands and the result.
3001 FIRM_API ir_node *new_d_Mulh(dbg_info *db, ir_node *op1, ir_node *op2,
3004 /** Constructor for a Quot node.
3006 * Adds the node to the block in current_ir_block.
3008 * @param *db A pointer for debug information.
3009 * @param *memop The store needed to model exceptions
3010 * @param *op1 The first operand.
3011 * @param *op2 The second operand.
3012 * @param *mode The mode of the result.
3013 * @param state The pinned state.
3015 FIRM_API ir_node *new_d_Quot(dbg_info *db, ir_node *memop,
3016 ir_node *op1, ir_node *op2, ir_mode *mode,
3017 op_pin_state state);
3019 /** Constructor for a DivMod node.
3021 * Adds the node to the block in current_ir_block.
3023 * @param *db A pointer for debug information.
3024 * @param *memop The store needed to model exceptions
3025 * @param *op1 The first operand.
3026 * @param *op2 The second operand.
3027 * @param *mode The mode of the results.
3028 * @param state The pinned state.
3030 FIRM_API ir_node *new_d_DivMod(dbg_info *db, ir_node *memop, ir_node *op1,
3031 ir_node *op2, ir_mode *mode, op_pin_state state);
3033 /** Constructor for a Div node.
3035 * Adds the node to the block in current_ir_block.
3037 * @param *db A pointer for debug information.
3038 * @param *memop The store needed to model exceptions
3039 * @param *op1 The first operand.
3040 * @param *op2 The second operand.
3041 * @param *mode The mode of the result.
3042 * @param state The pinned state.
3044 FIRM_API ir_node *new_d_Div(dbg_info *db, ir_node *memop, ir_node *op1,
3045 ir_node *op2, ir_mode *mode, op_pin_state state);
3047 /** Constructor for a remainderless Div node.
3049 * Adds the node to the block in current_ir_block.
3051 * @param *db A pointer for debug information.
3052 * @param *memop The store needed to model exceptions
3053 * @param *op1 The first operand.
3054 * @param *op2 The second operand.
3055 * @param *mode The mode of the result.
3056 * @param state The pinned state.
3058 FIRM_API ir_node *new_d_DivRL(dbg_info *db, ir_node *memop,
3059 ir_node *op1, ir_node *op2, ir_mode *mode,
3060 op_pin_state state);
3062 /** Constructor for a Mod node.
3064 * Adds the node to the block in current_ir_block.
3066 * @param *db A pointer for debug information.
3067 * @param *memop The store needed to model exceptions
3068 * @param *op1 The first operand.
3069 * @param *op2 The second operand.
3070 * @param *mode The mode of the result.
3071 * @param state The pinned state.
3073 FIRM_API ir_node *new_d_Mod(dbg_info *db, ir_node *memop,
3074 ir_node *op1, ir_node *op2, ir_mode *mode,
3075 op_pin_state state);
3077 /** Constructor for a Abs node.
3079 * Adds the node to the block in current_ir_block.
3081 * @param *db A pointer for debug information.
3082 * @param *op The operand
3083 * @param *mode The mode of the operands and the result.
3085 FIRM_API ir_node *new_d_Abs(dbg_info *db, ir_node *op, ir_mode *mode);
3087 /** Constructor for a And node.
3089 * Adds the node to the block in current_ir_block.
3091 * @param *db A pointer for debug information.
3092 * @param *op1 The first operand.
3093 * @param *op2 The second operand.
3094 * @param *mode The mode of the operands and the result.
3096 FIRM_API ir_node *new_d_And(dbg_info *db, ir_node *op1, ir_node *op2,
3099 /** Constructor for a Or node.
3101 * Adds the node to the block in current_ir_block.
3103 * @param *db A pointer for debug information.
3104 * @param *op1 The first operand.
3105 * @param *op2 The second operand.
3106 * @param *mode The mode of the operands and the result.
3108 FIRM_API ir_node *new_d_Or(dbg_info *db, ir_node *op1, ir_node *op2,
3111 /** Constructor for a Eor node.
3113 * Adds the node to the block in current_ir_block.
3115 * @param *db A pointer for debug information.
3116 * @param *op1 The first operand.
3117 * @param *op2 The second operand.
3118 * @param *mode The mode of the operands and the results.
3120 FIRM_API ir_node *new_d_Eor(dbg_info *db, ir_node *op1, ir_node *op2,
3123 /** Constructor for a Not node.
3125 * Adds the node to the block in current_ir_block.
3127 * @param *db A pointer for debug information.
3128 * @param *op The operand.
3129 * @param *mode The mode of the operand and the result.
3131 FIRM_API ir_node *new_d_Not(dbg_info *db, ir_node *op, ir_mode *mode);
3133 /** Constructor for a Shl node.
3135 * Adds the node to the block in current_ir_block.
3137 * @param *db A pointer for debug information.
3138 * @param *op The operand.
3139 * @param *k The number of bits to shift the operand .
3140 * @param *mode The mode of the operand and the result.
3142 FIRM_API ir_node *new_d_Shl(dbg_info *db, ir_node *op, ir_node *k,
3145 /** Constructor for a Shr node.
3147 * Adds the node to the block in current_ir_block.
3149 * @param *db A pointer for debug information.
3150 * @param *op The operand.
3151 * @param *k The number of bits to shift the operand .
3152 * @param *mode The mode of the operand and the result.
3154 FIRM_API ir_node *new_d_Shr(dbg_info *db, ir_node *op, ir_node *k,
3157 /** Constructor for a Shrs node.
3159 * Adds the node to the block in current_ir_block.
3161 * @param *db A pointer for debug information.
3162 * @param *op The operand.
3163 * @param *k The number of bits to shift the operand .
3164 * @param *mode The mode of the operand and the result.
3166 FIRM_API ir_node *new_d_Shrs(dbg_info *db, ir_node *op, ir_node *k,
3169 /** Constructor for a Rotl node.
3171 * Adds the node to the block in current_ir_block.
3173 * @param *db A pointer for debug information.
3174 * @param *op The operand.
3175 * @param *k The number of bits to rotate the operand.
3176 * @param *mode The mode of the operand.
3178 FIRM_API ir_node *new_d_Rotl(dbg_info *db, ir_node *op, ir_node *k,
3181 /** Constructor for a Cmp node.
3183 * Adds the node to the block in current_ir_block.
3185 * @param *db A pointer for debug information.
3186 * @param *op1 The first operand.
3187 * @param *op2 The second operand.
3189 FIRM_API ir_node *new_d_Cmp(dbg_info *db, ir_node *op1, ir_node *op2);
3191 /** Constructor for a Conv node.
3193 * Adds the node to the block in current_ir_block.
3195 * @param *db A pointer for debug information.
3196 * @param *op The operand.
3197 * @param *mode The mode of this the operand muss be converted .
3199 FIRM_API ir_node *new_d_Conv(dbg_info *db, ir_node *op, ir_mode *mode);
3201 /** Constructor for a strict Conv node.
3203 * Adds the node to the block in current_ir_block.
3205 * @param *db A pointer for debug information.
3206 * @param *op The operand.
3207 * @param *mode The mode of this the operand muss be converted .
3209 FIRM_API ir_node *new_d_strictConv(dbg_info *db, ir_node *op, ir_mode *mode);
3211 /** Constructor for a Cast node.
3213 * High level type cast
3214 * Adds the node to the block in current_ir_block.
3216 * @param *db A pointer for debug information.
3217 * @param *op The operand.
3218 * @param *to_tp The type of this the operand muss be casted .
3220 FIRM_API ir_node *new_d_Cast(dbg_info *db, ir_node *op, ir_type *to_tp);
3222 /** Constructor for a Carry node.
3224 * Adds the node to the block in current_ir_block.
3226 * @param *db A pointer for debug information.
3227 * @param *op1 The first operand.
3228 * @param *op2 The second operand.
3229 * @param *mode The mode of the operands and the result.
3231 FIRM_API ir_node *new_d_Carry(dbg_info *db, ir_node *op1, ir_node *op2,
3234 /** Constructor for a Borrow node.
3236 * Adds the node to the block in current_ir_block.
3238 * @param *db A pointer for debug information.
3239 * @param *op1 The first operand.
3240 * @param *op2 The second operand.
3241 * @param *mode The mode of the operands and the result.
3243 FIRM_API ir_node *new_d_Borrow(dbg_info *db, ir_node *op1, ir_node *op2,
3246 /** Constructor for a Phi node.
3248 * Adds the node to the block in current_ir_block.
3250 * @param *db A pointer for debug information.
3251 * @param arity The number of predecessors
3252 * @param *in Array with predecessors
3253 * @param *mode The mode of it's inputs and output.
3255 FIRM_API ir_node *new_d_Phi(dbg_info *db, int arity, ir_node *in[],
3258 /** Constructor for a Load node.
3260 * Adds the node to the block in current_ir_block.
3262 * @param *db A pointer for debug information.
3263 * @param *store The current memory
3264 * @param *addr A pointer to the variable to be read in this memory.
3265 * @param *mode The mode of the value to be loaded.
3266 * @param flags Additional flags for alignment, volatility and pin state.
3268 FIRM_API ir_node *new_d_Load(dbg_info *db, ir_node *store, ir_node *addr,
3269 ir_mode *mode, ir_cons_flags flags);
3271 /** Constructor for a Store node.
3273 * Adds the node to the block in current_ir_block.
3275 * @param *db A pointer for debug information.
3276 * @param *store The current memory
3277 * @param *addr A pointer to the variable to be read in this memory.
3278 * @param *val The value to write to this variable.
3279 * @param flags Additional flags for alignment, volatility and pin state.
3281 FIRM_API ir_node *new_d_Store(dbg_info *db, ir_node *store, ir_node *addr,
3282 ir_node *val, ir_cons_flags flags);
3284 /** Constructor for a Alloc node.
3286 * The Alloc node extends the memory by space for an entity of type alloc_type.
3287 * Adds the node to the block in current_ir_block.
3289 * @param *db A pointer for debug information.
3290 * @param *store The memory which shall contain the new variable.
3291 * @param *count The number of objects to allocate.
3292 * @param *alloc_type The type of the allocated variable.
3293 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
3295 FIRM_API ir_node *new_d_Alloc(dbg_info *db, ir_node *store, ir_node *count,
3296 ir_type *alloc_type, ir_where_alloc where);
3298 /** Constructor for a Free node.
3300 * Frees the memory occupied by the entity pointed to by the pointer
3301 * arg. Type indicates the type of the entity the argument points to.
3302 * Adds the node to the block in current_ir_block.
3304 * @param *db A pointer for debug information.
3305 * @param *store The memory which shall contain the new variable.
3306 * @param *ptr The pointer to the object to free.
3307 * @param *size The number of objects of type free_type to free in a sequence.
3308 * @param *free_type The type of the freed variable.
3309 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
3311 FIRM_API ir_node *new_d_Free(dbg_info *db, ir_node *store, ir_node *ptr,
3312 ir_node *size, ir_type *free_type,
3313 ir_where_alloc where);
3315 /** Constructor for a Sync node.
3317 * Merges several memory values. The node assumes that a variable
3318 * either occurs only in one of the memories, or it contains the same
3319 * value in all memories where it occurs.
3320 * Adds the node to the block in current_ir_block.
3322 * @param *db A pointer for debug information.
3323 * @param arity The number of memories to synchronize.
3324 * @param **in An array of pointers to nodes that produce an output of type
3325 * memory. The constructor copies this array.
3327 FIRM_API ir_node *new_d_Sync(dbg_info *db, int arity, ir_node *in[]);
3329 /** Constructor for a Proj node.
3331 * Projects a single value out of a tuple. The parameter proj gives the
3332 * position of the value within the tuple.
3333 * Adds the node to the block in current_ir_block.
3335 * @param *db A pointer for deubug information.
3336 * @param arg A node producing a tuple.
3337 * @param *mode The mode of the value to project.
3338 * @param proj The position of the value in the tuple.
3340 FIRM_API ir_node *new_d_Proj(dbg_info *db, ir_node *arg, ir_mode *mode,
3343 /** Constructor for a defaultProj node.
3345 * Represents the default control flow of a Switch-Cond node.
3346 * Adds the node to the block in current_ir_block.
3348 * @param *db A pointer for debug information.
3349 * @param arg A node producing a tuple.
3350 * @param max_proj The end position of the value in the tuple.
3352 FIRM_API ir_node *new_d_defaultProj(dbg_info *db, ir_node *arg, long max_proj);
3354 /** Constructor for a Tuple node.
3356 * This is an auxiliary node to replace a node that returns a tuple
3357 * without changing the corresponding Proj nodes.
3358 * Adds the node to the block in current_ir_block.
3360 * @param *db A pointer for debug information.
3361 * @param arity The number of tuple elements.
3362 * @param **in An array containing pointers to the nodes producing the tuple elements.
3364 FIRM_API ir_node *new_d_Tuple(dbg_info *db, int arity, ir_node *in[]);
3366 /** Constructor for a Id node.
3368 * This is an auxiliary node to replace a node that returns a single
3369 * value. Adds the node to the block in current_ir_block.
3371 * @param *db A pointer for debug information.
3372 * @param *val The operand to Id.
3373 * @param *mode The mode of *val.
3375 FIRM_API ir_node *new_d_Id(dbg_info *db, ir_node *val, ir_mode *mode);
3377 /** Constructor for a Confirm node.
3379 * Constructor for a Confirm node. Adds the node to the block in current_ir_block.
3380 * Specifies constraints for a value. To support dataflow analyses.
3382 * Example: If the value never exceeds '100' this is expressed by placing a
3383 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
3385 * @param *db A pointer for debug information.
3386 * @param *val The value we express a constraint for
3387 * @param *bound The value to compare against. Must be a firm node, typically a constant.
3388 * @param cmp The compare operation.
3390 FIRM_API ir_node *new_d_Confirm(dbg_info *db, ir_node *val, ir_node *bound,
3393 /** Constructor for an Unknown node.
3395 * Represents an arbitrary value. Places the node in
3398 * @param *db A pointer for debug information.
3399 * @param *m The mode of the unknown value.
3401 FIRM_API ir_node *new_d_Unknown(dbg_info *db, ir_mode *m);
3403 /** Constructor for a Mux node.
3405 * @param *db A pointer for debug information.
3406 * @param *sel The ir_node that calculates the boolean select.
3407 * @param *ir_true The ir_node that calculates the true result.
3408 * @param *ir_false The ir_node that calculates the false result.
3409 * @param *mode The mode of the node (and it_true and ir_false).
3411 FIRM_API ir_node *new_d_Mux(dbg_info *db, ir_node *sel,
3412 ir_node *ir_false, ir_node *ir_true, ir_mode *mode);
3414 /** Constructor for a CopyB node.
3416 * @param *db A pointer for debug information.
3417 * @param *store The current memory
3418 * @param *dst The ir_node that represents the destination address.
3419 * @param *src The ir_node that represents the source address.
3420 * @param *data_type The type of the copied data
3422 FIRM_API ir_node *new_d_CopyB(dbg_info *db, ir_node *store, ir_node *dst,
3423 ir_node *src, ir_type *data_type);
3425 /** Constructor for a InstOf node.
3427 * A High-Level Type check.
3429 * @param *db A pointer for debug information.
3430 * @param *store The memory in which the object the entity should be selected
3431 * from is allocated.
3432 * @param *objptr A pointer to a object of a class type.
3433 * @param *type The type of which objptr must be.
3435 FIRM_API ir_node *new_d_InstOf(dbg_info *db, ir_node *store, ir_node *objptr,
3438 /** Constructor for a Raise node.
3440 * A High-Level Exception throw.
3442 * @param *db A pointer for debug information.
3443 * @param *store The current memory.
3444 * @param *obj A pointer to the Except variable.
3446 FIRM_API ir_node *new_d_Raise(dbg_info *db, ir_node *store, ir_node *obj);
3448 /** Constructor for a Bound node.
3450 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
3452 * @param *db A pointer for debug information.
3453 * @param *store The current memory
3454 * @param *idx The ir_node that represents an index.
3455 * @param *lower The ir_node that represents the lower bound for the index.
3456 * @param *upper The ir_node that represents the upper bound for the index.
3458 FIRM_API ir_node *new_d_Bound(dbg_info *db, ir_node *store, ir_node *idx,
3459 ir_node *lower, ir_node *upper);
3461 /** Constructor for a Pin node.
3463 * @param *db A pointer for debug information.
3464 * @param *node The node which value should be pinned.
3466 FIRM_API ir_node *new_d_Pin(dbg_info *db, ir_node *node);
3468 /** Constructor for an ASM pseudo node.
3470 * @param *db A pointer for debug information.
3471 * @param arity The number of data inputs to the node.
3472 * @param *in The array of length arity of data inputs.
3473 * @param *inputs The array of length arity of input constraints.
3474 * @param n_outs The number of data outputs to the node.
3475 * @param *outputs The array of length n_outs of output constraints.
3476 * @param n_clobber The number of clobbered registers.
3477 * @param *clobber The array of length n_clobber of clobbered registers.
3478 * @param *asm_text The assembler text.
3480 FIRM_API ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[],
3481 ir_asm_constraint *inputs,
3482 int n_outs, ir_asm_constraint *outputs,
3483 int n_clobber, ident *clobber[], ident *asm_text);
3485 /*-----------------------------------------------------------------------*/
3486 /* The block oriented interface without debug support */
3487 /*-----------------------------------------------------------------------*/
3489 /** Constructor for a Block node.
3491 * Constructor for a Block node. Adds the block to the graph in
3492 * current_ir_graph. Constructs a Block with a fixed number of predecessors.
3494 * @param arity The number of control predecessors.
3495 * @param in An array of control predecessors. The length of
3496 * the array must be 'arity'.
3498 FIRM_API ir_node *new_Block(int arity, ir_node *in[]);
3500 /** Constructor for a Start node.
3502 * Adds the node to the block in current_ir_block.
3505 FIRM_API ir_node *new_Start(void);
3507 /** Constructor for an End node.
3509 * Adds the node to the block in current_ir_block.
3511 FIRM_API ir_node *new_End(void);
3513 /** Constructor for a Jump node.
3515 * Adds the node to the block in current_ir_block.
3517 * Jmp represents control flow to a single control successor.
3519 FIRM_API ir_node *new_Jmp(void);
3521 /** Constructor for an IJmp node.
3523 * IJmp represents control flow to a single control successor not
3524 * statically known i.e. an indirect Jmp.
3526 * @param *tgt The IR node representing the target address.
3528 FIRM_API ir_node *new_IJmp(ir_node *tgt);
3530 /** Constructor for a Cond node.
3532 * If c is mode_b represents a conditional branch (if/else). If c is
3533 * mode_Is/mode_Iu (?) represents a switch. (Allocates dense Cond
3534 * node, default Proj is 0.). Adds the node to the block in current_ir_block.
3536 * This is not consistent: Input to Cond is Is, Proj has as proj number
3540 * @param *c The conditions parameter.Can be of mode b or I_u.
3542 FIRM_API ir_node *new_Cond(ir_node *c);
3544 /** Constructor for a Return node.
3546 * Returns the memory and zero or more return values. Only node that
3547 * can end regular control flow. Adds the node to the block in current_ir_block.
3549 * @param *store The state of memory.
3550 * @param arity Number of array indices.
3551 * @param *in Array with index inputs to the node.
3553 FIRM_API ir_node *new_Return(ir_node *store, int arity, ir_node *in[]);
3555 /** Constructor for a Const node.
3557 * Constructor for a Const node. The constant represents a target
3558 * value. Sets the type information to type_unknown. (No more
3559 * supported: If tv is entity derives a somehow useful type.)
3560 * Adds the node to the block in current_ir_block.
3561 * Derives mode from passed tarval.
3563 * @param *con Points to an entry in the constant table. This pointer is
3564 * added to the attributes of the node.
3566 FIRM_API ir_node *new_Const(tarval *con);
3569 * Make a const from a long.
3570 * This is just convenience for the usual
3572 * new_Const(mode, tarval_from_long(mode, ...))
3575 * @param mode The mode for the const.
3576 * @param value The value of the constant.
3577 * @return A new const node.
3579 FIRM_API ir_node *new_Const_long(ir_mode *mode, long value);
3581 /** Constructor for a Const node.
3583 * Derives mode from passed tarval. */
3584 FIRM_API ir_node *new_Const_type(tarval *con, ir_type *tp);
3586 /** Constructor for a SymConst_type node.
3588 * This is the constructor for a symbolic constant.
3589 * There are several kinds of symbolic constants:
3590 * - symconst_type_tag The symbolic constant represents a type tag. The
3591 * type the tag stands for is given explicitly.
3592 * - symconst_type_size The symbolic constant represents the size of a type.
3593 * The type of which the constant represents the size
3594 * is given explicitly.
3595 * - symconst_type_align The symbolic constant represents the alignment of a
3596 * type. The type of which the constant represents the
3597 * size is given explicitly.
3598 * - symconst_addr_ent The symbolic constant represents the address of an
3599 * entity (variable or method). The variable is given
3600 * explicitly by a firm entity.
3601 * - symconst_ofs_ent The symbolic constant represents the offset of an
3602 * entity in its owner type.
3603 * - symconst_enum_const The symbolic constant is a enumeration constant of
3604 * an enumeration type.
3606 * Inputs to the node:
3607 * No inputs except the block it belongs to.
3608 * Outputs of the node.
3609 * An unsigned integer (I_u) or a pointer (P).
3611 * Mention union in declaration so that the firmjni generator recognizes that
3612 * it can not cast the argument to an int.
3614 * @param mode The mode for the SymConst.
3615 * @param value A type, ident, entity or enum constant depending on the
3617 * @param kind The kind of the symbolic constant, see the list above
3618 * @param tp The source type of the constant.
3620 FIRM_API ir_node *new_SymConst_type(ir_mode *mode, union symconst_symbol value,
3621 symconst_kind kind, ir_type *tp);
3623 /** Constructor for a SymConst node.
3625 * This is the constructor for a symbolic constant.
3626 * There are several kinds of symbolic constants:
3627 * - symconst_type_tag The symbolic constant represents a type tag. The
3628 * type the tag stands for is given explicitly.
3629 * - symconst_type_size The symbolic constant represents the size of a type.
3630 * The type of which the constant represents the size
3631 * is given explicitly.
3632 * - symconst_type_align The symbolic constant represents the alignment of a
3633 * type. The type of which the constant represents the
3634 * size is given explicitly.
3635 * - symconst_addr_ent The symbolic constant represents the address of an
3636 * entity (variable or method). The variable is given
3637 * explicitly by a firm entity.
3638 * - symconst_ofs_ent The symbolic constant represents the offset of an
3639 * entity in its owner type.
3640 * - symconst_enum_const The symbolic constant is a enumeration constant of
3641 * an enumeration type.
3643 * Inputs to the node:
3644 * No inputs except the block it belongs to.
3645 * Outputs of the node.
3646 * An unsigned integer (I_u) or a pointer (P).
3648 * Mention union in declaration so that the firmjni generator recognizes that
3649 * it can not cast the argument to an int.
3651 * @param mode The mode for the SymConst.
3652 * @param value A type, ident, entity or enum constant depending on the
3654 * @param kind The kind of the symbolic constant, see the list above
3656 FIRM_API ir_node *new_SymConst(ir_mode *mode, union symconst_symbol value,
3657 symconst_kind kind);
3659 /** Constructor for a simpelSel node.
3661 * This is a shortcut for the new_Sel() constructor. To be used for
3662 * Sel nodes that do not select from an array, i.e., have no index
3663 * inputs. It adds the two parameters 0, NULL.
3665 * @param *store The memory in which the object the entity should be selected from is allocated.
3666 * @param *objptr The object from that the Sel operation selects a single attribute out.
3667 * @param *ent The entity to select.
3669 FIRM_API ir_node *new_simpleSel(ir_node *store, ir_node *objptr,
3672 /** Constructor for a Sel node.
3674 * The select node selects an entity (field or method) from an entity
3675 * with a compound type. It explicitly specifies the entity selected.
3676 * Dynamically the node may select entities that overwrite the given
3677 * entity. If the selected entity is an array element entity the Sel
3678 * node takes the required array indices as inputs.
3679 * Adds the node to the block in current_ir_block.
3681 * @param *store The memory in which the object the entity should be selected
3682 * from is allocated.
3683 * @param *objptr A pointer to a compound entity the Sel operation selects a
3684 * single attribute from.
3685 * @param arity The number of array indices needed to select an array element entity.
3686 * @param *in[] If the compound entity is an array the indices of the selected
3687 * element entity. The constructor copies this array.
3688 * @param *ent The entity to select.
3690 FIRM_API ir_node *new_Sel(ir_node *store, ir_node *objptr,
3691 int arity, ir_node *in[], ir_entity *ent);
3693 /** Constructor for a Call node.
3695 * Adds the node to the block in current_ir_block.
3696 * Represents all kinds of method and function calls.
3698 * @param *store The actual store.
3699 * @param *callee A pointer to the called procedure.
3700 * @param arity The number of procedure parameters.
3701 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3702 * @param *tp Type information of the procedure called.
3704 FIRM_API ir_node *new_Call(ir_node *store, ir_node *callee,
3705 int arity, ir_node *in[], ir_type *tp);
3707 /** Constructor for a Builtin node.
3709 * Represents a call of a backend-specific builtin..
3710 * Represents all kinds of method and function calls.
3712 * @param *store The actual store.
3713 * @param kind The kind of the called builtin.
3714 * @param arity The number of procedure parameters.
3715 * @param *in[] An array with the pointers to the parameters. The constructor copies this array.
3716 * @param *tp Type information of the procedure called.
3718 FIRM_API ir_node *new_Builtin(ir_node *store, int arity, ir_node *in[],
3719 ir_builtin_kind kind, ir_type *tp);
3721 /** Constructor for a Add node.
3723 * Adds the node to the block in current_ir_block.
3725 * @param *op1 The first operand.
3726 * @param *op2 The second operand.
3727 * @param *mode The mode of the operands and the result.
3729 FIRM_API ir_node *new_Add(ir_node *op1, ir_node *op2, ir_mode *mode);
3731 /** Constructor for a Sub node.
3733 * Adds the node to the block in current_ir_block.
3735 * @param *op1 The first operand.
3736 * @param *op2 The second operand.
3737 * @param *mode The mode of the operands and the result.
3739 FIRM_API ir_node *new_Sub(ir_node *op1, ir_node *op2, ir_mode *mode);
3741 /** Constructor for a Minus node.
3743 * Adds the node to the block in current_ir_block.
3745 * @param *op The operand .
3746 * @param *mode The mode of the operand and the result.
3748 FIRM_API ir_node *new_Minus(ir_node *op, ir_mode *mode);
3751 * Constructor for a Mul node. Adds the node to the block in current_ir_block.
3753 * @param *op1 The first operand.
3754 * @param *op2 The second operand.
3755 * @param *mode The mode of the operands and the result.
3757 FIRM_API ir_node *new_Mul(ir_node *op1, ir_node *op2, ir_mode *mode);
3760 * Constructor for a Mulh node. Adds the node to the block in current_ir_block.
3762 * @param *op1 The first operand.
3763 * @param *op2 The second operand.
3764 * @param *mode The mode of the operands and the result.
3766 FIRM_API ir_node *new_Mulh(ir_node *op1, ir_node *op2, ir_mode *mode);
3768 /** Constructor for a Quot node.
3770 * Adds the node to the block in current_ir_block.
3772 * @param *memop The store needed to model exceptions
3773 * @param *op1 The first operand.
3774 * @param *op2 The second operand.
3775 * @param *mode The mode of the result.
3776 * @param state The pinned state.
3778 FIRM_API ir_node *new_Quot(ir_node *memop, ir_node *op1, ir_node *op2,
3779 ir_mode *mode, op_pin_state state);
3781 /** Constructor for a DivMod node.
3783 * Adds the node to the block in current_ir_block.
3785 * @param *memop The store needed to model exceptions
3786 * @param *op1 The first operand.
3787 * @param *op2 The second operand.
3788 * @param *mode The mode of the results.
3789 * @param state The pinned state.
3791 FIRM_API ir_node *new_DivMod(ir_node *memop, ir_node *op1, ir_node *op2,
3792 ir_mode *mode, op_pin_state state);
3794 /** Constructor for a Div node.
3796 * Adds the node to the block in current_ir_block.
3798 * @param *memop The store needed to model exceptions
3799 * @param *op1 The first operand.
3800 * @param *op2 The second operand.
3801 * @param *mode The mode of the result.
3802 * @param state The pinned state.
3804 FIRM_API ir_node *new_Div(ir_node *memop, ir_node *op1, ir_node *op2,
3805 ir_mode *mode, op_pin_state state);
3807 /** Constructor for a remainderless Div node.
3809 * Adds the node to the block in current_ir_block.
3811 * @param *memop The store needed to model exceptions
3812 * @param *op1 The first operand.
3813 * @param *op2 The second operand.
3814 * @param *mode The mode of the result.
3815 * @param state The pinned state.
3817 FIRM_API ir_node *new_DivRL(ir_node *memop, ir_node *op1, ir_node *op2,
3818 ir_mode *mode, op_pin_state state);
3820 /** Constructor for a Mod node.
3822 * Adds the node to the block in current_ir_block.
3824 * @param *memop The store needed to model exceptions
3825 * @param *op1 The first operand.
3826 * @param *op2 The second operand.
3827 * @param *mode The mode of the result.
3828 * @param state The pinned state.
3830 FIRM_API ir_node *new_Mod(ir_node *memop, ir_node *op1, ir_node *op2,
3831 ir_mode *mode, op_pin_state state);
3833 /** Constructor for a Abs node.
3835 * Adds the node to the block in current_ir_block.
3837 * @param *op The operand
3838 * @param *mode The mode of the operands and the result.
3840 FIRM_API ir_node *new_Abs(ir_node *op, ir_mode *mode);
3842 /** Constructor for a And node.
3844 * Adds the node to the block in current_ir_block.
3846 * @param *op1 The first operand.
3847 * @param *op2 The second operand.
3848 * @param *mode The mode of the operands and the result.
3850 FIRM_API ir_node *new_And(ir_node *op1, ir_node *op2, ir_mode *mode);
3853 * Constructor for a Or node. Adds the node to the block in current_ir_block.
3855 * @param *op1 The first operand.
3856 * @param *op2 The second operand.
3857 * @param *mode The mode of the operands and the result.
3859 FIRM_API ir_node *new_Or(ir_node *op1, ir_node *op2, ir_mode *mode);
3862 * Constructor for a Eor node. Adds the node to the block in current_ir_block.
3864 * @param *op1 The first operand.
3865 * @param *op2 The second operand.
3866 * @param *mode The mode of the operands and the results.
3868 FIRM_API ir_node *new_Eor(ir_node *op1, ir_node *op2, ir_mode *mode);
3870 /** Constructor for a Not node.
3872 * Adds the node to the block in current_ir_block.
3874 * @param *op The operand.
3875 * @param *mode The mode of the operand and the result.
3877 FIRM_API ir_node *new_Not(ir_node *op, ir_mode *mode);
3879 /** Constructor for a Shl node.
3881 * Adds the node to the block in current_ir_block.
3883 * @param *op The operand.
3884 * @param *k The number of bits to shift the operand .
3885 * @param *mode The mode of the operand and the result.
3887 FIRM_API ir_node *new_Shl(ir_node *op, ir_node *k, ir_mode *mode);
3890 * Constructor for a Shr node. Adds the node to the block in current_ir_block.
3892 * @param *op The operand.
3893 * @param *k The number of bits to shift the operand .
3894 * @param *mode The mode of the operand and the result.
3896 FIRM_API ir_node *new_Shr(ir_node *op, ir_node *k, ir_mode *mode);
3898 /** Constructor for a Shrs node.
3900 * Adds the node to the block in current_ir_block.
3902 * @param *op The operand.
3903 * @param *k The number of bits to shift the operand .
3904 * @param *mode The mode of the operand and the result.
3906 FIRM_API ir_node *new_Shrs(ir_node *op, ir_node *k, ir_mode *mode);
3908 /** Constructor for a Rotl node.
3910 * Adds the node to the block in current_ir_block.
3912 * @param *op The operand.
3913 * @param *k The number of bits to rotate the operand.
3914 * @param *mode The mode of the operand.
3916 FIRM_API ir_node *new_Rotl(ir_node *op, ir_node *k, ir_mode *mode);
3918 /** Constructor for a Cmp node.
3920 * Adds the node to the block in current_ir_block.
3922 * @param *op1 The first operand.
3923 * @param *op2 The second operand.
3925 FIRM_API ir_node *new_Cmp(ir_node *op1, ir_node *op2);
3927 /** Constructor for a Conv node.
3929 * Adds the node to the block in current_ir_block.
3931 * @param *op The operand.
3932 * @param *mode The mode of this the operand muss be converted.
3934 FIRM_API ir_node *new_Conv(ir_node *op, ir_mode *mode);
3936 /** Constructor for a strict Conv node.
3938 * Adds the node to the block in current_ir_block.
3940 * @param *op The operand.
3941 * @param *mode The mode of this the operand muss be converted.
3943 FIRM_API ir_node *new_strictConv(ir_node *op, ir_mode *mode);
3945 /** Constructor for a Cast node.
3947 * Adds the node to the block in current_ir_block.
3948 * High level type cast
3950 * @param *op The operand.
3951 * @param *to_tp The type of this the operand muss be casted .
3953 FIRM_API ir_node *new_Cast(ir_node *op, ir_type *to_tp);
3955 /** Constructor for a Carry node.
3957 * Adds the node to the block in current_ir_block.
3959 * @param *op1 The first operand.
3960 * @param *op2 The second operand.
3961 * @param *mode The mode of the operands and the result.
3963 FIRM_API ir_node *new_Carry(ir_node *op1, ir_node *op2, ir_mode *mode);
3965 /** Constructor for a Borrow node.
3967 * Adds the node to the block in current_ir_block.
3969 * @param *op1 The first operand.
3970 * @param *op2 The second operand.
3971 * @param *mode The mode of the operands and the result.
3973 FIRM_API ir_node *new_Borrow(ir_node *op1, ir_node *op2, ir_mode *mode);
3975 /** Constructor for a Phi node.
3977 * Adds the node to the block in current_ir_block.
3979 * @param arity The number of predecessors.
3980 * @param *in Array with predecessors.
3981 * @param *mode The mode of it's inputs and output.
3983 FIRM_API ir_node *new_Phi(int arity, ir_node *in[], ir_mode *mode);
3985 /** Constructor for a Load node.
3987 * @param *store The current memory.
3988 * @param *addr A pointer to the variable to be read in this memory.
3989 * @param *mode The mode of the value to be loaded.
3990 * @param flags Additional flags for alignment, volatility and pin state.
3992 FIRM_API ir_node *new_Load(ir_node *store, ir_node *addr, ir_mode *mode,
3993 ir_cons_flags flags);
3995 /** Constructor for a Store node.
3997 * @param *store The current memory.
3998 * @param *addr A pointer to the variable to be read in this memory.
3999 * @param *val The value to write to this variable.
4000 * @param flags Additional flags for alignment, volatility and pin state.
4002 FIRM_API ir_node *new_Store(ir_node *store, ir_node *addr, ir_node *val,
4003 ir_cons_flags flags);
4005 /** Constructor for a Alloc node.
4007 * The Alloc node extends the memory by space for an entity of type alloc_type.
4008 * Adds the node to the block in current_ir_block.
4010 * @param *store The memory which shall contain the new variable.
4011 * @param *count The number of objects to allocate.
4012 * @param *alloc_type The type of the allocated variable.
4013 * @param where Where to allocate the variable, either heap_alloc or stack_alloc.
4015 FIRM_API ir_node *new_Alloc(ir_node *store, ir_node *count, ir_type *alloc_type,
4016 ir_where_alloc where);
4018 /** Constructor for a Free node.
4020 * Frees the memory occupied by the entity pointed to by the pointer
4021 * arg. Type indicates the type of the entity the argument points to.
4022 * Adds the node to the block in current_ir_block.
4024 * @param *store The memory which shall contain the new variable.
4025 * @param *ptr The pointer to the object to free.
4026 * @param *size The number of objects of type free_type to free in a sequence.
4027 * @param *free_type The type of the freed variable.
4028 * @param where Where the variable was allocated, either heap_alloc or stack_alloc.
4030 FIRM_API ir_node *new_Free(ir_node *store, ir_node *ptr, ir_node *size,
4031 ir_type *free_type, ir_where_alloc where);
4033 /** Constructor for a Sync node.
4035 * Merges several memory values. The node assumes that a variable
4036 * either occurs only in one of the memories, or it contains the same
4037 * value in all memories where it occurs.
4038 * Adds the node to the block in current_ir_block.
4040 * @param arity The number of memories to synchronize.
4041 * @param **in An array of pointers to nodes that produce an output of type
4042 * memory. The constructor copies this array.
4044 FIRM_API ir_node *new_Sync(int arity, ir_node *in[]);
4046 /** Constructor for a Proj node.
4048 * Projects a single value out of a tuple. The parameter proj gives the
4049 * position of the value within the tuple.
4050 * Adds the node to the block in current_ir_block.
4052 * @param arg A node producing a tuple.
4053 * @param *mode The mode of the value to project.
4054 * @param proj The position of the value in the tuple.
4056 FIRM_API ir_node *new_Proj(ir_node *arg, ir_mode *mode, long proj);
4058 /** Constructor for a defaultProj node.
4060 * Represents the default control flow of a Switch-Cond node.
4061 * Adds the node to the block in current_ir_block.
4063 * @param arg A node producing a tuple.
4064 * @param max_proj The end position of the value in the tuple.
4066 FIRM_API ir_node *new_defaultProj(ir_node *arg, long max_proj);
4068 /** Constructor for a Tuple node.
4070 * This is an auxiliary node to replace a node that returns a tuple
4071 * without changing the corresponding Proj nodes.
4072 * Adds the node to the block in current_ir_block.
4074 * @param arity The number of tuple elements.
4075 * @param **in An array containing pointers to the nodes producing the tuple elements.
4077 FIRM_API ir_node *new_Tuple(int arity, ir_node *in[]);
4079 /** Constructor for an Id node.
4081 * This is an auxiliary node to replace a node that returns a single
4082 * value. Adds the node to the block in current_ir_block.
4084 * @param *val The operand to Id.
4085 * @param *mode The mode of *val.
4087 FIRM_API ir_node *new_Id(ir_node *val, ir_mode *mode);
4089 /** Constructor for a Bad node.
4091 * Returns the unique Bad node of the graph. The same as
4094 FIRM_API ir_node *new_Bad(void);
4096 /** Constructor for a Confirm node.
4098 * Specifies constraints for a value. To support dataflow analyses.
4099 * Adds the node to the block in current_ir_block.
4101 * Example: If the value never exceeds '100' this is expressed by placing a
4102 * Confirm node val = new_d_Confirm(db, val, 100, '<=') on the dataflow edge.
4104 * @param *val The value we express a constraint for
4105 * @param *bound The value to compare against. Must be a firm node, typically a constant.
4106 * @param cmp The compare operation.
4108 FIRM_API ir_node *new_Confirm(ir_node *val, ir_node *bound, pn_Cmp cmp);
4110 /** Constructor for an Unknown node.
4112 * Represents an arbitrary value. Places the node in
4115 * @param *m The mode of the unknown value.
4117 FIRM_API ir_node *new_Unknown(ir_mode *m);
4119 /** Constructor for a NoMem node.
4121 * Returns the unique NoMem node of the graph. The same as
4124 FIRM_API ir_node *new_NoMem(void);
4126 /** Constructor for a Mux node.
4128 * Adds the node to the block in current_ir_block.
4130 * @param *sel The ir_node that calculates the boolean select.
4131 * @param *ir_true The ir_node that calculates the true result.
4132 * @param *ir_false The ir_node that calculates the false result.
4133 * @param *mode The mode of the node (and it_true and ir_false).
4135 FIRM_API ir_node *new_Mux(ir_node *sel, ir_node *ir_false, ir_node *ir_true,
4138 /** Constructor for a CopyB node.
4140 * Adds the node to the block in current_ir_block.
4142 * @param *store The current memory
4143 * @param *dst The ir_node that represents the destination address.
4144 * @param *src The ir_node that represents the source address.
4145 * @param *data_type The type of the copied data
4147 FIRM_API ir_node *new_CopyB(ir_node *store, ir_node *dst, ir_node *src,
4148 ir_type *data_type);
4150 /** Constructor for a InstOf node.
4152 * A High-Level Type check.
4154 * @param *store The memory in which the object the entity should be selected
4155 * from is allocated.
4156 * @param *objptr A pointer to a object of a class type.
4157 * @param *type The type of which objptr must be.
4159 FIRM_API ir_node *new_InstOf(ir_node *store, ir_node *objptr, ir_type *type);
4161 /**Constructor for a Raise node.
4163 * A High-Level Exception throw.
4165 * @param *store The current memory.
4166 * @param *obj A pointer to the Except variable.
4168 FIRM_API ir_node *new_Raise(ir_node *store, ir_node *obj);
4170 /** Constructor for a Bound node.
4172 * A High-Level bounds check. Checks whether lower <= idx && idx < upper.
4174 * Adds the node to the block in current_ir_block.
4176 * @param *store The current memory
4177 * @param *idx The ir_node that represents an index.
4178 * @param *lower The ir_node that represents the lower bound for the index.
4179 * @param *upper The ir_node that represents the upper bound for the index.
4181 FIRM_API ir_node *new_Bound(ir_node *store, ir_node *idx, ir_node *lower,
4184 /** Constructor for a Pin node.
4186 * @param *node The node which value should be pinned.
4188 FIRM_API ir_node *new_Pin(ir_node *node);
4190 /** Constructor for an ASM pseudo node.
4192 * @param arity The number of data inputs to the node.
4193 * @param *in The array of length arity of data inputs.
4194 * @param *inputs The array of length arity of input constraints.
4195 * @param n_outs The number of data outputs to the node.
4196 * @param *outputs The array of length n_outs of output constraints.
4197 * @param n_clobber The number of clobbered registers.
4198 * @param *clobber The array of length n_clobber of clobbered registers.
4199 * @param *asm_text The assembler text.
4201 FIRM_API ir_node *new_ASM(int arity, ir_node *in[], ir_asm_constraint *inputs,
4202 int n_outs, ir_asm_constraint *outputs,
4203 int n_clobber, ident *clobber[], ident *asm_text);
4206 * @brief Constructor for a Dummy node.
4208 * @param *db debug info for the node
4209 * @param *mode The mode of the node.
4210 * @param *irg the graph to put the node into
4211 * @returns the newly created note
4213 FIRM_API ir_node *new_rd_Dummy(dbg_info *db, ir_graph *irg, ir_mode *mode);
4216 * @copybrief new_rd_Dummy()
4218 * @param *mode The mode of the node.
4219 * @param *irg the graph to put the node into
4220 * @returns the newly created note
4222 FIRM_API ir_node *new_r_Dummy(ir_graph *irg, ir_mode *mode);
4225 * @copybrief new_rd_Dummy()
4227 * @param *db debug info for the node
4228 * @param *mode The mode of the node.
4229 * @returns the newly created note
4231 FIRM_API ir_node *new_d_Dummy(dbg_info *db, ir_mode *mode);
4234 * @copybrief new_rd_Dummy()
4236 * @param *mode The mode of the node.
4237 * @returns the newly created note
4239 FIRM_API ir_node *new_Dummy(ir_mode *mode);
4241 /*---------------------------------------------------------------------*/
4242 /* The comfortable interface. */
4243 /* Supports automatic Phi node construction. */
4244 /* All routines of the block oriented interface except new_Block are */
4246 /*---------------------------------------------------------------------*/
4248 /** Create an immature Block.
4250 * An immature Block has an unknown number of predecessors. Predecessors
4251 * can be added with add_immBlock_pred(). Once all predecessors are
4252 * added the block must be matured.
4254 * Adds the block to the graph in current_ir_graph. Can be used with automatic
4255 * Phi node construction.
4256 * This constructor can only be used if the graph is in state_building.
4258 FIRM_API ir_node *new_d_immBlock(dbg_info *db);
4259 FIRM_API ir_node *new_immBlock(void);
4261 /** Create an immature PartBlock.
4263 * An immature block has only one Block or PartBlock predecessor.
4264 * A PartBlock forms together with one BLock and possibly other
4265 * PartBlocks a MacroBlock.
4267 * Adds the PartBlock to the graph in current_ir_graph. Does set
4268 * current_block. Can be used with automatic Phi node construction.
4269 * This constructor can only be used if the graph is in
4272 FIRM_API ir_node *new_d_immPartBlock(dbg_info *db, ir_node *pred_jmp);
4273 FIRM_API ir_node *new_immPartBlock(ir_node *pred_jmp);
4275 /** Add a control flow edge to an immature block. */
4276 FIRM_API void add_immBlock_pred(ir_node *immblock, ir_node *jmp);
4278 /** Finalize a Block node, when all control flows are known. */
4279 FIRM_API void mature_immBlock(ir_node *block);
4280 #define mature_cur_block() mature_immBlock(get_cur_block());
4283 /** Get the current value of a local variable.
4285 * Use this function to obtain the last definition of the local variable
4286 * associated with pos. Pos may not exceed the value passed as n_loc
4287 * to new_ir_graph. This call automatically inserts Phi nodes.
4289 * @param *db A pointer for debug information.
4290 * @param pos The position/id of the local variable.
4291 * @param *mode The mode of the value to get.
4293 FIRM_API ir_node *get_d_value(dbg_info *db, int pos, ir_mode *mode);
4294 FIRM_API ir_node *get_value(int pos, ir_mode *mode);
4297 * Try to guess the mode of a local variable.
4298 * This is done by recursively going up the control flow graph until
4299 * we find a definition for the variable. The mode of the first found
4300 * definition is returned. NULL in case no definition is found.
4302 * @param pos The position/id of the local variable.
4304 FIRM_API ir_mode *ir_guess_mode(int pos);
4306 /** Remark a new definition of a variable.
4308 * Use this function to remember a new definition of the value
4309 * associated with pos. Pos may not exceed the value passed as n_loc
4310 * to new_ir_graph. This call is needed to automatically inserts Phi
4313 * @param pos The position/id of the local variable.
4314 * @param *value The new value written to the local variable.
4316 FIRM_API void set_value(int pos, ir_node *value);
4319 * Find the value number for a node in the current block.
4321 * @param value the searched value
4323 * @return the value number of the value or -1 if this value has
4324 * no value number in the current block.
4326 FIRM_API int find_value(ir_node *value);
4328 /** Get the current memory state.
4330 * Use this function to obtain the last definition of the memory
4331 * state. This call automatically inserts Phi nodes for the memory
4334 FIRM_API ir_node *get_store(void);
4336 /** Remark a new definition of the memory state.
4338 * Use this function to remember a new definition of the memory state.
4339 * This call is needed to automatically inserts Phi nodes.
4341 * @param *store The new memory state.
4343 FIRM_API void set_store(ir_node *store);
4345 /** keep this node alive even if End is not control-reachable from it
4347 * @param ka The node to keep alive.
4349 FIRM_API void keep_alive(ir_node *ka);
4351 /** Returns the frame type of the current graph */
4352 FIRM_API ir_type *get_cur_frame_type(void);
4355 /* --- initialize and finalize IR construction --- */
4357 /** Puts the graph into state "phase_high" */
4358 FIRM_API void irg_finalize_cons(ir_graph *irg);
4360 /** Puts the program and all graphs into state phase_high.
4362 * This also remarks, the construction of types is finished,
4363 * e.g., that no more subtypes will be added. */
4364 FIRM_API void irp_finalize_cons(void);
4366 FIRM_API void ir_set_uninitialized_local_variable_func(
4367 uninitialized_local_variable_func_t *func);