X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firnode.c;h=fb96fa8db0a7820e88e6f0df53e747a768e905d5;hb=bccd30d684ad0b08a697bdad571d34bd855a3dc2;hp=695a3465dd2ebc25e39b751dbf74e0f2c94f8a52;hpb=acec916796fe96c897197a46813757394623ad21;p=libfirm diff --git a/ir/ir/irnode.c b/ir/ir/irnode.c index 695a3465d..fb96fa8db 100644 --- a/ir/ir/irnode.c +++ b/ir/ir/irnode.c @@ -1,15 +1,28 @@ /* - * Project: libFIRM - * File name: ir/ir/irnode.c - * 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$ + */ #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -123,7 +136,7 @@ new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mo ir_node *res; size_t node_size = offsetof(ir_node, attr) + op->attr_size + firm_add_node_size; char *p; - int i, is_bl; + int i; assert(irg && op && mode); p = obstack_alloc (irg->obst, node_size); @@ -156,8 +169,9 @@ new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mo for(i = 0; i < EDGE_KIND_LAST; ++i) INIT_LIST_HEAD(&res->edge_info[i].outs_head); - is_bl = is_Block(res); - for (i = is_bl; i <= arity; ++i) + // don't put this into the for loop, arity is -1 for some nodes! + edges_notify_edge(res, -1, res->in[0], NULL, irg); + for (i = 1; i <= arity; ++i) edges_notify_edge(res, i - 1, res->in[i], NULL, irg); hook_new_node(irg, res); @@ -301,6 +315,22 @@ set_irn_n (ir_node *node, int n, ir_node *in) { node->in[n + 1] = in; } +int add_irn_n(ir_node *node, ir_node *in) +{ + int pos; + ir_graph *irg = get_irn_irg(node); + + assert(node->op->opar == oparity_dynamic); + pos = ARR_LEN(node->in) - 1; + ARR_APP1(ir_node *, node->in, in); + edges_notify_edge(node, pos, node->in[pos + 1], NULL, irg); + + /* Call the hook */ + hook_set_irn_n(node, pos, node->in[pos + 1], NULL); + + return pos; +} + int (get_irn_deps)(const ir_node *node) { @@ -567,17 +597,15 @@ get_irn_block_attr(ir_node *node) { } load_attr -get_irn_load_attr(ir_node *node) -{ - assert(node->op == op_Load); - return node->attr.load; +get_irn_load_attr(ir_node *node) { + assert(node->op == op_Load); + return node->attr.load; } store_attr -get_irn_store_attr(ir_node *node) -{ - assert(node->op == op_Store); - return node->attr.store; +get_irn_store_attr(ir_node *node) { + assert(node->op == op_Store); + return node->attr.store; } except_attr @@ -587,9 +615,14 @@ get_irn_except_attr(ir_node *node) { return node->attr.except; } -void * -get_irn_generic_attr(ir_node *node) { - return &node->attr; +void *(get_irn_generic_attr)(ir_node *node) { + assert(is_ir_node(node)); + return _get_irn_generic_attr(node); +} + +const void *(get_irn_generic_attr_const)(const ir_node *node) { + assert(is_ir_node(node)); + return _get_irn_generic_attr_const(node); } unsigned (get_irn_idx)(const ir_node *node) { @@ -712,7 +745,7 @@ set_Block_matured(ir_node *node, int matured) { } unsigned long -(get_Block_block_visited)(ir_node *node) { +(get_Block_block_visited)(const ir_node *node) { return _get_Block_block_visited(node); } @@ -728,10 +761,15 @@ void } int -(Block_not_block_visited)(ir_node *node) { +(Block_not_block_visited)(const ir_node *node) { return _Block_not_block_visited(node); } +int +(Block_block_visited)(const ir_node *node) { + return _Block_block_visited(node); +} + ir_node * get_Block_graph_arr (ir_node *node, int pos) { assert(node->op == op_Block); @@ -825,13 +863,8 @@ get_End_keepalive(ir_node *end, int pos) { void add_End_keepalive (ir_node *end, ir_node *ka) { - int l; - ir_graph *irg = get_irn_irg(end); - assert(end->op == op_End); - l = ARR_LEN(end->in); - ARR_APP1(ir_node *, end->in, ka); - edges_notify_edge(end, l - 1, end->in[l], NULL, irg); + add_irn_n(end, ka); } void @@ -846,14 +879,14 @@ void set_End_keepalives(ir_node *end, int n, ir_node *in[]) { ir_graph *irg = get_irn_irg(end); /* notify that edges are deleted */ - for (i = 1 + END_KEEPALIVE_OFFSET; i < ARR_LEN(end->in); ++i) { - edges_notify_edge(end, i, end->in[i], NULL, irg); + for (i = END_KEEPALIVE_OFFSET; i < ARR_LEN(end->in) - 1; ++i) { + edges_notify_edge(end, i, NULL, end->in[i + 1], irg); } ARR_RESIZE(ir_node *, end->in, n + 1 + END_KEEPALIVE_OFFSET); for (i = 0; i < n; ++i) { end->in[1 + END_KEEPALIVE_OFFSET + i] = in[i]; - edges_notify_edge(end, END_KEEPALIVE_OFFSET + i, NULL, end->in[1 + END_KEEPALIVE_OFFSET + i], irg); + edges_notify_edge(end, END_KEEPALIVE_OFFSET + i, end->in[1 + END_KEEPALIVE_OFFSET + i], NULL, irg); } } @@ -1068,7 +1101,7 @@ set_SymConst_type(ir_node *node, ir_type *tp) { } ident * -get_SymConst_name(ir_node *node) { +get_SymConst_name(const ir_node *node) { assert(node->op == op_SymConst && SYMCONST_HAS_ID(get_SymConst_kind(node))); return node->attr.symc.sym.ident_p; } @@ -1081,7 +1114,7 @@ set_SymConst_name(ir_node *node, ident *name) { /* Only to access SymConst of kind symconst_addr_ent. Else assertion: */ -ir_entity *get_SymConst_entity(ir_node *node) { +ir_entity *get_SymConst_entity(const ir_node *node) { assert(node->op == op_SymConst && SYMCONST_HAS_ENT(get_SymConst_kind(node))); return node->attr.symc.sym.entity_p; } @@ -1091,7 +1124,7 @@ void set_SymConst_entity(ir_node *node, ir_entity *ent) { node->attr.symc.sym.entity_p = ent; } -ir_enum_const *get_SymConst_enum(ir_node *node) { +ir_enum_const *get_SymConst_enum(const ir_node *node) { assert(node->op == op_SymConst && SYMCONST_HAS_ENUM(get_SymConst_kind(node))); return node->attr.symc.sym.enum_p; } @@ -1102,7 +1135,7 @@ void set_SymConst_enum(ir_node *node, ir_enum_const *ec) { } union symconst_symbol -get_SymConst_symbol(ir_node *node) { +get_SymConst_symbol(const ir_node *node) { assert(node->op == op_SymConst); return node->attr.symc.sym; } @@ -1322,7 +1355,7 @@ void set_CallBegin_call(ir_node *node, ir_node *call) { #define BINOP(OP) \ -ir_node * get_##OP##_left(ir_node *node) { \ +ir_node * get_##OP##_left(const ir_node *node) { \ assert(node->op == op_##OP); \ return get_irn_n(node, node->op->op_index); \ } \ @@ -1330,7 +1363,7 @@ void set_##OP##_left(ir_node *node, ir_node *left) { \ assert(node->op == op_##OP); \ set_irn_n(node, node->op->op_index, left); \ } \ -ir_node *get_##OP##_right(ir_node *node) { \ +ir_node *get_##OP##_right(const ir_node *node) { \ assert(node->op == op_##OP); \ return get_irn_n(node, node->op->op_index + 1); \ } \ @@ -1340,7 +1373,7 @@ void set_##OP##_right(ir_node *node, ir_node *right) { \ } #define UNOP(OP) \ -ir_node *get_##OP##_op(ir_node *node) { \ +ir_node *get_##OP##_op(const ir_node *node) { \ assert(node->op == op_##OP); \ return get_irn_n(node, node->op->op_index); \ } \ @@ -1459,7 +1492,7 @@ int } ir_node * -get_unop_op(ir_node *node) { +get_unop_op(const ir_node *node) { if (node->op->opar == oparity_unary) return get_irn_n(node, node->op->op_index); @@ -1481,7 +1514,7 @@ int } ir_node * -get_binop_left(ir_node *node) { +get_binop_left(const ir_node *node) { assert(node->op->opar == oparity_binary); return get_irn_n(node, node->op->op_index); } @@ -1493,7 +1526,7 @@ set_binop_left(ir_node *node, ir_node *left) { } ir_node * -get_binop_right(ir_node *node) { +get_binop_right(const ir_node *node) { assert(node->op->opar == oparity_binary); return get_irn_n(node, node->op->op_index + 1); } @@ -1817,13 +1850,8 @@ void set_Sync_pred(ir_node *node, int pos, ir_node *pred) { /* Add a new Sync predecessor */ void add_Sync_pred(ir_node *node, ir_node *pred) { - int l; - ir_graph *irg = get_irn_irg(node); - assert(node->op == op_Sync); - l = ARR_LEN(node->in); - ARR_APP1(ir_node *, node->in, pred); - edges_notify_edge(node, l, node->in[l], NULL, irg); + add_irn_n(node, pred); } /* Returns the source language type of a Proj node. */ @@ -1870,6 +1898,16 @@ set_Proj_pred(ir_node *node, ir_node *pred) { set_irn_n(node, 0, pred); } +long get_VProj_proj(const ir_node *node) +{ + return node->attr.proj; +} + +void set_VProj_proj(ir_node *node, long value) +{ + node->attr.proj = value; +} + long get_Proj_proj(const ir_node *node) { assert(is_Proj(node)); @@ -2271,7 +2309,7 @@ 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) { assert(pin->op == op_Pin); return get_irn_n(pin, 0); } @@ -2458,6 +2496,21 @@ int return _is_DivMod(node); } +int +(is_Quot)(const ir_node *node) { + return _is_Quot(node); +} + +int +(is_Add)(const ir_node *node) { + return _is_Add(node); +} + +int +(is_Sub)(const ir_node *node) { + return _is_Sub(node); +} + int (is_Start)(const ir_node *node) { return _is_Start(node); @@ -2473,6 +2526,11 @@ int return _is_Const(node); } +int +(is_Conv)(const ir_node *node) { + return _is_Conv(node); +} + int (is_no_Block)(const ir_node *node) { return _is_no_Block(node);