/*
- * Project: libFIRM
- * File name: ir/ir/irnode.h
- * Purpose: Representation of an intermediate operation.
- * Author: Martin Trapp, Christian Schaefer
- * Modified by: Goetz Lindenmaier, Michael Beck
- * Created:
- * CVS-ID: $Id$
- * Copyright: (c) 1998-2006 Universität Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Representation of an intermediate operation.
+ * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
+ * @version $Id$
*/
-#ifndef _FIRM_IR_IRNODE_H_
-#define _FIRM_IR_IRNODE_H_
+#ifndef FIRM_IR_IRNODE_H
+#define FIRM_IR_IRNODE_H
#include <stddef.h>
/**
* Copy all dependencies from a node to another.
- * @param tgt The node which sould be enriched.
+ * @param tgt The node which should be enriched.
* @param src The node whose dependencies shall be copied.
*/
void add_irn_deps(ir_node *tgt, ir_node *src);
/** Replace the n-th predecessor of a node with a new one. */
void set_irn_n(ir_node *node, int n, ir_node *in);
+/**
+ * Appends a new predecessor to a node. This only works for nodes with
+ * variable arity!
+ * @returns the number of the new input
+ */
+int add_irn_n(ir_node *node, ir_node *in);
/* Sets the mode struct of node. */
void set_irn_mode(ir_node *node, ir_mode *mode);
/** Gets the mode struct of a node. */
/** A visited flag only for block nodes.
* @see also: get_irn_visited() inc_irg_visited() inc_irg_block_visited()*/
-unsigned long get_Block_block_visited(ir_node *node);
+unsigned long get_Block_block_visited(const ir_node *node);
void set_Block_block_visited(ir_node *node, unsigned long visit);
/**
/* For this current_ir_graph must be set. */
void mark_Block_block_visited(ir_node *node);
-int Block_not_block_visited(ir_node *node);
+int Block_not_block_visited(const ir_node *node);
+int Block_block_visited(const ir_node *node);
/* Set and remove interprocedural predecessors. If the interprocedural
* predecessors are removed, the node has the same predecessors in
* both views.
* @@@ Maybe better: arity is zero if no cg preds. */
-void set_Block_cg_cfgpred_arr(ir_node * node, int arity, ir_node ** in);
-void set_Block_cg_cfgpred(ir_node * node, int pos, ir_node * pred);
+void set_Block_cg_cfgpred_arr(ir_node *node, int arity, ir_node *in[]);
+void set_Block_cg_cfgpred(ir_node *node, int pos, ir_node *pred);
/* @@@ not supported */
-ir_node **get_Block_cg_cfgpred_arr(ir_node * node);
+ir_node **get_Block_cg_cfgpred_arr(ir_node *node);
/** Returns the number of interprocedural predecessors. 0 if none. */
-int get_Block_cg_n_cfgpreds(ir_node * node);
+int get_Block_cg_n_cfgpreds(ir_node *node);
/** Return the interprocedural predecessor at position pos. */
-ir_node *get_Block_cg_cfgpred(ir_node * node, int pos);
-/* frees the memory. */
-void remove_Block_cg_cfgpred_arr(ir_node * node);
+ir_node *get_Block_cg_cfgpred(ir_node *node, int pos);
+/** Frees the memory allocated for interprocedural predecessors. */
+void remove_Block_cg_cfgpred_arr(ir_node *node);
-/** returns the extended basic block a block belongs to */
+/** Returns the extended basic block a block belongs to. */
ir_extblk *get_Block_extbb(const ir_node *block);
-/** sets the extended basic block a block belongs to */
+/** Sets the extended basic block a block belongs to. */
void set_Block_extbb(ir_node *block, ir_extblk *extblk);
+/** Get the Macro Block header of a (sub-) block. */
+ir_node *get_Block_MacroBlock(const ir_node *block);
+
/** Return the number of Keep alive node. */
int get_End_n_keepalives(ir_node *end);
ir_node *get_Return_res(ir_node *node, int pos);
void set_Return_res(ir_node *node, int pos, ir_node *res);
+/**
+ * Possible classes for constant classification.
+ */
typedef enum {
CNST_NULL = 0, /**< The node is a const(0). */
CNST_ONE = +1, /**< The node is a const(1). */
CNST_NO_CONST = 4 /**< The node is no const at all. */
} cnst_classify_t;
-tarval *get_Const_tarval(ir_node *node);
+tarval *get_Const_tarval(const ir_node *node);
void set_Const_tarval(ir_node *node, tarval *con);
/**
void set_SymConst_type(ir_node *node, ir_type *tp);
/** Only to access SymConst of kind addr_name. Else assertion: */
-ident *get_SymConst_name(ir_node *node);
+ident *get_SymConst_name(const ir_node *node);
void set_SymConst_name(ir_node *node, ident *name);
/** Only to access SymConst of kind addr_ent. Else assertion: */
-ir_entity *get_SymConst_entity(ir_node *node);
+ir_entity *get_SymConst_entity(const ir_node *node);
void set_SymConst_entity(ir_node *node, ir_entity *ent);
/** Only to access SymConst of kind symconst_enum_const. Else assertion: */
-ir_enum_const *get_SymConst_enum(ir_node *node);
+ir_enum_const *get_SymConst_enum(const ir_node *node);
void set_SymConst_enum(ir_node *node, ir_enum_const *ec);
/** Sets both: type and ptrinfo. Needed to treat the node independent of
its semantics. Does a memcpy for the memory sym points to. */
/* write 'union': firmjni then does not create a method... */
-union symconst_symbol get_SymConst_symbol(ir_node *node);
+union symconst_symbol get_SymConst_symbol(const ir_node *node);
void set_SymConst_symbol(ir_node *node,
union symconst_symbol sym);
*/
typedef enum {
pn_Call_M_regular = 0, /**< The memory result. */
- pn_Call_T_result = 2, /**< The tuple containing all (0, 1, 2, ...) results */
- pn_Call_P_value_res_base = 4,/**< A pointer to the memory region containing copied results
+ pn_Call_X_regular = 1, /**< The control flow result when no exception occurs. */
+ pn_Call_X_except = 2, /**< The control flow result branching to the exception handler. */
+ pn_Call_T_result = 3, /**< The tuple containing all (0, 1, 2, ...) results. */
+ pn_Call_M_except = 4, /**< The memory result in case the called method terminated with
+ an exception. */
+ pn_Call_P_value_res_base = 5,/**< A pointer to the memory region containing copied results
passed by value (for compound result types). */
- pn_Call_X_except = 1, /**< The control flow result branching to the exception handler */
- pn_Call_M_except = 3, /**< The memory result in case the called method terminated with
- an exception */
- pn_Call_max = 5 /**< number of projections from a Call */
+ pn_Call_max = 6 /**< number of projections from a Call */
} pn_Call; /* Projection numbers for Call. */
#define pn_Call_M pn_Call_M_regular
binops are: Add, Sub, Mul, Quot, DivMod, Div, Mod, And, Or, Eor, Shl,
Shr, Shrs, Rot, Cmp */
int is_unop(const ir_node *node);
-ir_node *get_unop_op(ir_node *node);
+ir_node *get_unop_op(const ir_node *node);
void set_unop_op(ir_node *node, ir_node *op);
int is_binop(const ir_node *node);
-ir_node *get_binop_left(ir_node *node);
+ir_node *get_binop_left(const ir_node *node);
void set_binop_left(ir_node *node, ir_node *left);
-ir_node *get_binop_right(ir_node *node);
+ir_node *get_binop_right(const ir_node *node);
void set_binop_right(ir_node *node, ir_node *right);
-ir_node *get_Add_left(ir_node *node);
+ir_node *get_Add_left(const ir_node *node);
void set_Add_left(ir_node *node, ir_node *left);
-ir_node *get_Add_right(ir_node *node);
+ir_node *get_Add_right(const ir_node *node);
void set_Add_right(ir_node *node, ir_node *right);
-ir_node *get_Sub_left(ir_node *node);
+ir_node *get_Sub_left(const ir_node *node);
void set_Sub_left(ir_node *node, ir_node *left);
-ir_node *get_Sub_right(ir_node *node);
+ir_node *get_Sub_right(const ir_node *node);
void set_Sub_right(ir_node *node, ir_node *right);
-ir_node *get_Minus_op(ir_node *node);
+ir_node *get_Minus_op(const ir_node *node);
void set_Minus_op(ir_node *node, ir_node *op);
-ir_node *get_Mul_left(ir_node *node);
+ir_node *get_Mul_left(const ir_node *node);
void set_Mul_left(ir_node *node, ir_node *left);
-ir_node *get_Mul_right(ir_node *node);
+ir_node *get_Mul_right(const ir_node *node);
void set_Mul_right(ir_node *node, ir_node *right);
-ir_node *get_Quot_left(ir_node *node);
+ir_node *get_Quot_left(const ir_node *node);
void set_Quot_left(ir_node *node, ir_node *left);
-ir_node *get_Quot_right(ir_node *node);
+ir_node *get_Quot_right(const ir_node *node);
void set_Quot_right(ir_node *node, ir_node *right);
ir_node *get_Quot_mem(ir_node *node);
void set_Quot_mem(ir_node *node, ir_node *mem);
+ir_mode *get_Quot_resmode(const ir_node *node);
+void set_Quot_resmode(ir_node *node, ir_mode *mode);
/**
* Projection numbers for Quot: use for Proj nodes!
*/
typedef enum {
- pn_Quot_M, /**< Memory result. */
+ pn_Quot_M, /**< Memory result. */
+ pn_Quot_X_regular, /**< Execution result if no exception occurred. */
pn_Quot_X_except, /**< Execution result if exception occurred. */
pn_Quot_res, /**< Result of computation. */
pn_Quot_max /**< number of projections from a Quot */
} pn_Quot; /* Projection numbers for Quot. */
-ir_node *get_DivMod_left(ir_node *node);
+ir_node *get_DivMod_left(const ir_node *node);
void set_DivMod_left(ir_node *node, ir_node *left);
-ir_node *get_DivMod_right(ir_node *node);
+ir_node *get_DivMod_right(const ir_node *node);
void set_DivMod_right(ir_node *node, ir_node *right);
ir_node *get_DivMod_mem(ir_node *node);
void set_DivMod_mem(ir_node *node, ir_node *mem);
+ir_mode *get_DivMod_resmode(const ir_node *node);
+void set_DivMod_resmode(ir_node *node, ir_mode *mode);
/**
* Projection numbers for DivMod: use for Proj nodes!
*/
typedef enum {
- pn_DivMod_M, /**< Memory result. */
+ pn_DivMod_M, /**< Memory result. */
+ pn_DivMod_X_regular, /**< Execution result if no exception occurred. */
pn_DivMod_X_except, /**< Execution result if exception occurred. */
pn_DivMod_res_div, /**< Result of computation a / b. */
pn_DivMod_res_mod, /**< Result of computation a % b. */
pn_DivMod_max /**< number of projections from a DivMod */
} pn_DivMod; /* Projection numbers for DivMod. */
-ir_node *get_Div_left(ir_node *node);
+ir_node *get_Div_left(const ir_node *node);
void set_Div_left(ir_node *node, ir_node *left);
-ir_node *get_Div_right(ir_node *node);
+ir_node *get_Div_right(const ir_node *node);
void set_Div_right(ir_node *node, ir_node *right);
ir_node *get_Div_mem(ir_node *node);
void set_Div_mem(ir_node *node, ir_node *mem);
+ir_mode *get_Div_resmode(const ir_node *node);
+void set_Div_resmode(ir_node *node, ir_mode *mode);
/**
* Projection numbers for Div: use for Proj nodes!
*/
typedef enum {
- pn_Div_M, /**< Memory result. */
+ pn_Div_M, /**< Memory result. */
+ pn_Div_X_regular, /**< Execution result if no exception occurred. */
pn_Div_X_except, /**< Execution result if exception occurred. */
pn_Div_res, /**< Result of computation. */
pn_Div_max /**< number of projections from a Div */
} pn_Div; /* Projection numbers for Div. */
-ir_node *get_Mod_left(ir_node *node);
+ir_node *get_Mod_left(const ir_node *node);
void set_Mod_left(ir_node *node, ir_node *left);
-ir_node *get_Mod_right(ir_node *node);
+ir_node *get_Mod_right(const ir_node *node);
void set_Mod_right(ir_node *node, ir_node *right);
ir_node *get_Mod_mem(ir_node *node);
void set_Mod_mem(ir_node *node, ir_node *mem);
+ir_mode *get_Mod_resmode(const ir_node *node);
+void set_Mod_resmode(ir_node *node, ir_mode *mode);
/**
* Projection numbers for Mod: use for Proj nodes!
*/
typedef enum {
pn_Mod_M, /**< Memory result. */
+ pn_Mod_X_regular, /**< Execution result if no exception occurred. */
pn_Mod_X_except, /**< Execution result if exception occurred. */
pn_Mod_res, /**< Result of computation. */
pn_Mod_max /**< number of projections from a Mod */
} pn_Mod; /* Projection numbers for Mod. */
-ir_node *get_Abs_op(ir_node *node);
+ir_node *get_Abs_op(const ir_node *node);
void set_Abs_op(ir_node *node, ir_node *op);
-ir_node *get_And_left(ir_node *node);
+ir_node *get_And_left(const ir_node *node);
void set_And_left(ir_node *node, ir_node *left);
-ir_node *get_And_right(ir_node *node);
+ir_node *get_And_right(const ir_node *node);
void set_And_right(ir_node *node, ir_node *right);
-ir_node *get_Or_left(ir_node *node);
+ir_node *get_Or_left(const ir_node *node);
void set_Or_left(ir_node *node, ir_node *left);
-ir_node *get_Or_right(ir_node *node);
+ir_node *get_Or_right(const ir_node *node);
void set_Or_right(ir_node *node, ir_node *right);
-ir_node *get_Eor_left(ir_node *node);
+ir_node *get_Eor_left(const ir_node *node);
void set_Eor_left(ir_node *node, ir_node *left);
-ir_node *get_Eor_right(ir_node *node);
+ir_node *get_Eor_right(const ir_node *node);
void set_Eor_right(ir_node *node, ir_node *right);
-ir_node *get_Not_op(ir_node *node);
+ir_node *get_Not_op(const ir_node *node);
void set_Not_op(ir_node *node, ir_node *op);
/**
/** Calculates the inversed (R^-1) pnc condition, i.e., "<" --> ">" */
int get_inversed_pnc(int pnc);
-ir_node *get_Cmp_left(ir_node *node);
+ir_node *get_Cmp_left(const ir_node *node);
void set_Cmp_left(ir_node *node, ir_node *left);
-ir_node *get_Cmp_right(ir_node *node);
+ir_node *get_Cmp_right(const ir_node *node);
void set_Cmp_right(ir_node *node, ir_node *right);
-ir_node *get_Shl_left(ir_node *node);
+ir_node *get_Shl_left(const ir_node *node);
void set_Shl_left(ir_node *node, ir_node *left);
-ir_node *get_Shl_right(ir_node *node);
+ir_node *get_Shl_right(const ir_node *node);
void set_Shl_right(ir_node *node, ir_node *right);
-ir_node *get_Shr_left(ir_node *node);
+ir_node *get_Shr_left(const ir_node *node);
void set_Shr_left(ir_node *node, ir_node *left);
-ir_node *get_Shr_right(ir_node *node);
+ir_node *get_Shr_right(const ir_node *node);
void set_Shr_right(ir_node *node, ir_node *right);
-ir_node *get_Shrs_left(ir_node *node);
+ir_node *get_Shrs_left(const ir_node *node);
void set_Shrs_left(ir_node *node, ir_node *left);
-ir_node *get_Shrs_right(ir_node *node);
+ir_node *get_Shrs_right(const ir_node *node);
void set_Shrs_right(ir_node *node, ir_node *right);
-ir_node *get_Rot_left(ir_node *node);
+ir_node *get_Rot_left(const ir_node *node);
void set_Rot_left(ir_node *node, ir_node *left);
-ir_node *get_Rot_right(ir_node *node);
+ir_node *get_Rot_right(const ir_node *node);
void set_Rot_right(ir_node *node, ir_node *right);
-ir_node *get_Conv_op(ir_node *node);
+ir_node *get_Conv_op(const ir_node *node);
void set_Conv_op(ir_node *node, ir_node *op);
int get_Conv_strict(ir_node *node);
void set_Conv_strict(ir_node *node, int flag);
* are accessed in the cast. This required some precaution, to
* get the right memory into the Loads generated from the cast.
*/
-ir_node *get_Cast_op(ir_node *node);
+ir_node *get_Cast_op(const ir_node *node);
void set_Cast_op(ir_node *node, ir_node *op);
ir_type *get_Cast_type(ir_node *node);
void set_Cast_type(ir_node *node, ir_type *to_tp);
int is_Phi0(const ir_node *n);
/* These routines also work for Filter nodes in interprocedural view. */
ir_node **get_Phi_preds_arr(ir_node *node);
-int get_Phi_n_preds(ir_node *node);
-ir_node *get_Phi_pred(ir_node *node, int pos);
+int get_Phi_n_preds(const ir_node *node);
+ir_node *get_Phi_pred(const ir_node *node, int pos);
void set_Phi_pred(ir_node *node, int pos, ir_node *pred);
ir_node *get_Filter_pred(ir_node *node);
* Projection numbers for Load: use for Proj nodes!
*/
typedef enum {
- pn_Load_M, /**< Memory result. */
+ pn_Load_M, /**< Memory result. */
+ pn_Load_X_regular, /**< Execution result if no exception occurred. */
pn_Load_X_except, /**< Execution result if exception occurred. */
pn_Load_res, /**< Result of load operation. */
pn_Load_max /**< number of projections from a Load */
* Projection numbers for Store: use for Proj nodes!
*/
typedef enum {
- pn_Store_M, /**< Memory result. */
+ pn_Store_M, /**< Memory result. */
+ pn_Store_X_regular, /**< Execution result if no exception occurred. */
pn_Store_X_except, /**< Execution result if exception occurred. */
pn_Store_max /**< number of projections from a Store */
} pn_Store; /* Projection numbers for Store. */
*/
typedef enum {
pn_Alloc_M, /**< Memory result. */
+ pn_Alloc_X_regular, /**< Execution result if no exception occurred. */
pn_Alloc_X_except, /**< Execution result if exception occurred. */
pn_Alloc_res, /**< Result of allocation. */
pn_Alloc_max /**< number of projections from an Alloc */
/** Return the projection number of a Proj node. */
long get_Proj_proj(const ir_node *node);
void set_Proj_proj(ir_node *node, long proj);
+long get_VProj_proj(const ir_node *node);
+void set_VProj_proj(ir_node *node, long value);
+
ir_node **get_Tuple_preds_arr(ir_node *node);
int get_Tuple_n_preds(ir_node *node);
*/
typedef enum {
pn_CopyB_M_regular = 0, /**< The memory result. */
- pn_CopyB_X_except = 1, /**< The control flow result branching to the exception handler */
- pn_CopyB_M_except = 2, /**< The memory result in case the runtime function terminated with
+ pn_CopyB_X_regular = 1, /**< Execution result if no exception occurred. */
+ pn_CopyB_X_except = 2, /**< The control flow result branching to the exception handler */
+ pn_CopyB_M_except = 3, /**< The memory result in case the runtime function terminated with
an exception */
- pn_CopyB_max = 3 /**< number of projections from a CopyB */
+ pn_CopyB_max = 4 /**< number of projections from a CopyB */
} pn_CopyB; /* Projection numbers for CopyB. */
#define pn_CopyB_M pn_CopyB_M_regular
*/
typedef enum {
pn_InstOf_M_regular = 0, /**< The memory result. */
- pn_InstOf_X_except = 1, /**< The control flow result branching to the exception handler */
- pn_InstOf_res = 2, /**< The checked object pointer. */
- pn_InstOf_M_except = 3, /**< The memory result in case the runtime function terminated with
+ pn_InstOf_X_regular = 1, /**< Execution result if no exception occurred. */
+ pn_InstOf_X_except = 2, /**< The control flow result branching to the exception handler */
+ pn_InstOf_res = 3, /**< The checked object pointer. */
+ pn_InstOf_M_except = 4, /**< The memory result in case the runtime function terminated with
an exception */
- pn_InstOf_max = 4 /**< number of projections from an InstOf */
+ pn_InstOf_max = 5 /**< number of projections from an InstOf */
} pn_InstOf;
#define pn_InstOf_M pn_InstOf_M_regular
*/
typedef enum {
pn_Bound_M = 0, /**< The memory result. */
- pn_Bound_X_except = 1, /**< The control flow result branching to the exception handler */
- pn_Bound_res = 2, /**< The checked index. */
- pn_Bound_max = 3 /**< number of projections from a Bound */
+ pn_Bound_X_regular = 1, /**< Execution result if no exception occurred. */
+ pn_Bound_X_except = 2, /**< The control flow result branching to the exception handler */
+ pn_Bound_res = 3, /**< The checked index. */
+ pn_Bound_max = 4 /**< number of projections from a Bound */
} pn_Bound;
/** Returns the memory input of a Bound operation. */
void set_Bound_upper(ir_node *bound, ir_node *upper);
/** Return the operand of a Pin node. */
-ir_node *get_Pin_op(ir_node *pin);
+ir_node *get_Pin_op(const ir_node *pin);
void set_Pin_op(ir_node *pin, ir_node *node);
ir_node *skip_HighLevel(ir_node *node);
/** returns true if irn is a Const node. */
int is_Const(const ir_node *node);
+/** returns true if a node is a Conv node */
+int is_Conv(const ir_node *node);
/** returns true if node is a Bad node. */
int is_Bad(const ir_node *node);
/** returns true if node is a NoMem node. */
int is_DivMod(const ir_node *node);
/** return true if node is a Quot node. */
int is_Quot(const ir_node *node);
+/** return true if node is an Add node. */
+int is_Add(const ir_node *node);
+/** return true if node is a Sub node. */
+int is_Sub(const ir_node *node);
/** returns true if the node is not a Block */
int is_no_Block(const ir_node *node);
/** returns true if the node is a Block */
int is_Call(const ir_node *node);
/** returns true if node is a Sel node. */
int is_Sel(const ir_node *node);
+/** returns true if node is a Mul node. */
+int is_Mul(const ir_node *node);
/** returns true if node is a Mux node or a Psi with only one condition. */
int is_Mux(const ir_node *node);
/** returns true if node is a Load node. */
int is_fragile_op(const ir_node *node);
/** Returns the memory operand of fragile operations. */
ir_node *get_fragile_op_mem(ir_node *node);
+/** Returns the result mode of a Div operation. */
+ir_mode *get_divop_resmod(const ir_node *node);
/** Returns true if the operation is a forking control flow
* operation: Cond. */
const char *get_cond_jmp_predicate_name(cond_jmp_predicate pred);
/** Returns the conditional jump prediction of a Cond node. */
-cond_jmp_predicate get_Cond_jmp_pred(ir_node *cond);
+cond_jmp_predicate get_Cond_jmp_pred(const ir_node *cond);
/** Sets a new conditional jump prediction. */
void set_Cond_jmp_pred(ir_node *cond, cond_jmp_predicate pred);
* Needed for user-defined nodes.
*/
void *get_irn_generic_attr(ir_node *node);
+const void *get_irn_generic_attr_const(const ir_node *node);
/**
* Returns the unique node index for the node in its graph.
}
#endif
-#endif /* _FIRM_IR_IRNODE_H_ */
+#endif