X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firnode_t.h;h=1ec1f16529e4f7456c22ff4f639a0391e36b6a0a;hb=fed1bdc07c9ec7b4d07a9243ad093c9fdd239fbd;hp=fa1cf226f4702c85ccfb17ee0ddedf386a92ae14;hpb=f727a093b858da14853a0ec5aa9866ae80066e87;p=libfirm diff --git a/ir/ir/irnode_t.h b/ir/ir/irnode_t.h index fa1cf226f..1ec1f1652 100644 --- a/ir/ir/irnode_t.h +++ b/ir/ir/irnode_t.h @@ -240,18 +240,19 @@ struct ir_node { ir_mode *mode; /**< Mode of this node. */ struct ir_node **in; /**< array with predecessors / operands */ unsigned long visited; /**< visited counter for walks of the graph */ + unsigned node_idx; /**< the node index of this node in its graph */ void *link; /**< to attach additional information to the node, e.g. used while construction to link Phi0 nodes and - during optimization to link to nodes that - shall replace a node. */ + during optimization to link to nodes that + shall replace a node. */ /* ------- Fields for optimizations / analysis information ------- */ struct ir_node **out; /**< @deprecated array of out edges. */ struct dbg_info* dbi; /**< A pointer to information for debug support. */ /* ------- For debugging ------- */ #ifdef DEBUG_libfirm - int out_valid; - int node_nr; /**< a unique node number for each node to make output - readable. */ + int out_valid; + long node_nr; /**< a unique node number for each node to make output + readable. */ #endif /* ------- For analyses -------- */ ir_loop *loop; /**< the loop the node is in. Access routines in irloop.h */ @@ -268,8 +269,12 @@ struct ir_node { }; -/** Returns the array with the ins. The content of the array may not be - changed. */ +/** + * Returns the array with the ins. The content of the array may not be + * changed. + * Note that this function returns the whole in array including the + * block predecessor. So, it is NOT symmetric with set_irn_in(). + */ ir_node **get_irn_in (const ir_node *node); /** @{ */ @@ -351,6 +356,12 @@ _get_irn_op (const ir_node *node) { return node->op; } +static INLINE void +_set_irn_op (ir_node *node, ir_op *op) { + assert (node); + node->op = op; +} + /** Copies all attributes stored in the old node to the new node. Assumes both have the same opcode and sufficient size. */ static INLINE void @@ -600,6 +611,34 @@ _is_Unknown (const ir_node *node) { return (node && _get_irn_op(node) == op_Unknown); } +static INLINE int +_is_Return (const ir_node *node) { + assert(node); + return (node && _get_irn_op(node) == op_Return); +} + +static INLINE int +_is_Call (const ir_node *node) { + assert(node); + return (node && _get_irn_op(node) == op_Call); +} + +static INLINE int +_is_Sel (const ir_node *node) { + assert(node); + return (node && _get_irn_op(node) == op_Sel); +} + +static INLINE int +_is_Mux (const ir_node *node) { + assert(node); + if (node) { + ir_op *op = _get_irn_op(node); + return (op == op_Mux || ((op == op_Psi) && _get_irn_arity(node) == 3)); + } + return 0; +} + static INLINE int _is_no_Block(const ir_node *node) { assert(node && _is_ir_node(node)); @@ -727,6 +766,22 @@ static INLINE int _is_irn_constlike(const ir_node *node) { return is_op_constlike(_get_irn_op(node)); } +static INLINE int _is_irn_keep(const ir_node *node) { + return is_op_keep(_get_irn_op(node)); +} + +static INLINE int _is_irn_machine_op(const ir_node *node) { + return is_op_machine(_get_irn_op(node)); +} + +static INLINE int _is_irn_machine_operand(const ir_node *node) { + return is_op_machine_operand(_get_irn_op(node)); +} + +static INLINE int _is_irn_machine_user(const ir_node *node, unsigned n) { + return is_op_machine_user(_get_irn_op(node), n); +} + static INLINE cond_jmp_predicate _get_Cond_jmp_pred(ir_node *node) { assert (_get_irn_op(node) == op_Cond); return node->attr.c.pred; @@ -737,6 +792,15 @@ static INLINE void _set_Cond_jmp_pred(ir_node *node, cond_jmp_predicate pred) { node->attr.c.pred = pred; } +static INLINE int _get_Psi_n_conds(ir_node *node) { + assert(_get_irn_op(node) == op_Psi); + return _get_irn_arity(node) >> 1; +} + +static INLINE unsigned _get_irn_idx(const ir_node *node) { + return node->node_idx; +} + /* this section MUST contain all inline functions */ #define is_ir_node(thing) _is_ir_node(thing) #define get_irn_intra_arity(node) _get_irn_intra_arity(node) @@ -748,6 +812,7 @@ static INLINE void _set_Cond_jmp_pred(ir_node *node, cond_jmp_predicate pred) { #define get_irn_mode(node) _get_irn_mode(node) #define set_irn_mode(node, mode) _set_irn_mode(node, mode) #define get_irn_op(node) _get_irn_op(node) +#define set_irn_op(node, op) _set_irn_op(node, op) #define get_irn_opcode(node) _get_irn_opcode(node) #define get_irn_visited(node) _get_irn_visited(node) #define set_irn_visited(node, v) _set_irn_visited(node, v) @@ -762,6 +827,10 @@ static INLINE void _set_Cond_jmp_pred(ir_node *node, cond_jmp_predicate pred) { #define is_binop(node) _is_binop(node) #define is_Const(node) _is_Const(node) #define is_Unknown(node) _is_Unknown(node) +#define is_Return(node) _is_Return(node) +#define is_Call(node) _is_Call(node) +#define is_Sel(node) _is_Sel(node) +#define is_Mux(node) _is_Mux(node) #define is_Bad(node) _is_Bad(node) #define is_no_Block(node) _is_no_Block(node) #define is_Block(node) _is_Block(node) @@ -781,7 +850,13 @@ static INLINE void _set_Cond_jmp_pred(ir_node *node, cond_jmp_predicate pred) { #define get_irn_type_attr(node) _get_irn_type_attr(node) #define get_irn_entity_attr(node) _get_irn_entity_attr(node) #define is_irn_constlike(node) _is_irn_constlike(node) +#define is_irn_keep(node) _is_irn_keep(node) +#define is_irn_machine_op(node) _is_irn_machine_op(node) +#define is_irn_machine_operand(node) _is_irn_machine_operand(node) +#define is_irn_machine_user(node, n) _is_irn_machine_user(node, n) #define get_Cond_jmp_pred(node) _get_Cond_jmp_pred(node) #define set_Cond_jmp_pred(node, pred) _set_Cond_jmp_pred(node, pred) +#define get_Psi_n_conds(node) _get_Psi_n_conds(node) +#define get_irn_idx(node) _get_irn_idx(node) # endif /* _IRNODE_T_H_ */