Commit a644cbe0 authored by Michael Beck's avatar Michael Beck
Browse files

Every node has now a pinned attribute that is inherited from the op.

The pinned attibute can be changed for nodes that are exception/memory pinned
or floating point nodes.

[r8014]
parent 2cee4704
...@@ -114,36 +114,40 @@ unsigned register_additional_node_data(unsigned size) { ...@@ -114,36 +114,40 @@ unsigned register_additional_node_data(unsigned size) {
void void
init_irnode(void) { init_irnode(void) {
/* Forbid the addition of new data to an ir node. */ /* Forbid the addition of new data to an ir node. */
forbid_new_data = 1; forbid_new_data = 1;
} }
/* /*
* irnode constructor. * IR node constructor.
* Create a new irnode in irg, with an op, mode, arity and * Create a new IR node in irg, with an op, mode, arity and
* some incoming irnodes. * some incoming IR nodes.
* If arity is negative, a node with a dynamic array is created. * If arity is negative, a node with a dynamic array is created.
*/ */
ir_node * ir_node *
new_ir_node (dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mode, new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mode,
int arity, ir_node **in) int arity, ir_node **in)
{ {
ir_node *res; ir_node *res;
size_t node_size = offsetof(ir_node, attr) + op->attr_size + firm_add_node_size; size_t node_size = offsetof(ir_node, attr) + op->attr_size + firm_add_node_size;
char *p; char *p;
int i, is_bl; int i, is_bl;
op_pin_state state;
assert(irg && op && mode); assert(irg && op && mode);
p = obstack_alloc (irg->obst, node_size); p = obstack_alloc (irg->obst, node_size);
memset(p, 0, node_size); memset(p, 0, node_size);
res = (ir_node *) (p + firm_add_node_size); res = (ir_node *) (p + firm_add_node_size);
res->kind = k_ir_node; state = get_op_pinned(op);
res->op = op;
res->mode = mode; res->kind = k_ir_node;
res->visited = 0; res->op = op;
res->node_idx = irg_register_node_idx(irg, res); res->mode = mode;
res->link = NULL; res->visited = 0;
res->node_idx = irg_register_node_idx(irg, res);
res->pinned = state != op_pin_state_floats;
res->link = NULL;
if (arity < 0) { if (arity < 0) {
res->in = NEW_ARR_F (ir_node *, 1); /* 1: space for block */ res->in = NEW_ARR_F (ir_node *, 1); /* 1: space for block */
} else { } else {
...@@ -428,10 +432,16 @@ void set_irn_pinned(ir_node *node, op_pin_state state) { ...@@ -428,10 +432,16 @@ void set_irn_pinned(ir_node *node, op_pin_state state) {
if (get_irn_op(node) == op_Tuple) if (get_irn_op(node) == op_Tuple)
return; return;
assert(node && get_op_pinned(get_irn_op(node)) >= op_pin_state_exc_pinned); assert(node);
assert(
/* the node is exception/memory pinned OR */
(get_op_pinned(get_irn_op(node)) >= op_pin_state_exc_pinned) ||
/* a floating point node can be pinned if fp_exceptions are enabled */
(mode_is_float(get_irn_mode(node)) && get_irg_fp_model(get_irn_irg(node)) & fp_exceptions)
);
assert(state == op_pin_state_pinned || state == op_pin_state_floats); assert(state == op_pin_state_pinned || state == op_pin_state_floats);
node->attr.except.pin_state = state; node->pinned = state != op_pin_state_floats;
} }
#ifdef DO_HEAPANALYSIS #ifdef DO_HEAPANALYSIS
......
...@@ -194,17 +194,17 @@ void set_irn_pinned(ir_node *node, op_pin_state state); ...@@ -194,17 +194,17 @@ void set_irn_pinned(ir_node *node, op_pin_state state);
op_pin_state is_irn_pinned_in_irg (const ir_node *node); op_pin_state is_irn_pinned_in_irg (const ir_node *node);
/** /**
* irnode constructor. * IR node constructor.
* Create a new irnode in irg, with an op, mode, arity and * Create a new IR node in irg, with an op, mode, arity and
* some incoming irnodes. * some incoming IR nodes.
* This constructor is used in every specified irnode constructor. * This constructor is used in every specific IR node constructor.
* *
* @param db Debug info. * @param db Debug info.
* @param irg IR-graph on with this new node should be constructed. * @param irg IR-graph on with this new node should be constructed.
* @param block The block the new node belongs to * @param block The block the new node belongs to
* @param op The opcode of the new node. * @param op The opcode of the new node.
* @param mode The mode of the new node. * @param mode The mode of the new node.
* @param arity The arity of the new node, may be <0 if yet. * @param arity The arity of the new node, <0 if can be changed dynamically.
* @param in An array of arity predecessor nodes. * @param in An array of arity predecessor nodes.
*/ */
ir_node * ir_node *
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* File name: ir/ir/irnode_t.h * File name: ir/ir/irnode_t.h
* Purpose: Representation of an intermediate operation -- private header. * Purpose: Representation of an intermediate operation -- private header.
* Author: Martin Trapp, Christian Schaefer * Author: Martin Trapp, Christian Schaefer
* Modified by: Goetz Lindenmaier * Modified by: Goetz Lindenmaier, Michael Beck
* Created: * Created:
* CVS-ID: $Id$ * CVS-ID: $Id$
* Copyright: (c) 1998-2003 Universität Karlsruhe * Copyright: (c) 1998-2003 Universität Karlsruhe
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
* *
* @author Martin Trapp, Christian Schaefer * @author Martin Trapp, Christian Schaefer
*/ */
#ifndef _IRNODE_T_H_
# ifndef _IRNODE_T_H_ #define _IRNODE_T_H_
# define _IRNODE_T_H_
#include "firm_config.h" #include "firm_config.h"
#include "irnode.h" #include "irnode.h"
...@@ -40,7 +39,7 @@ ...@@ -40,7 +39,7 @@
#include "irextbb_t.h" #include "irextbb_t.h"
/** ir node attributes **/ /** IR node attributes **/
/** Block attributes */ /** Block attributes */
typedef struct { typedef struct {
...@@ -98,9 +97,6 @@ typedef struct { ...@@ -98,9 +97,6 @@ typedef struct {
/** Exception attributes. */ /** Exception attributes. */
typedef struct { typedef struct {
op_pin_state pin_state; /**< the pin state for operations that might generate a exception:
If it's know that no exception will be generated, could be set to
op_pin_state_floats. */
#if PRECISE_EXC_CONTEXT #if PRECISE_EXC_CONTEXT
struct ir_node **frag_arr; /**< For Phi node construction in case of exception */ struct ir_node **frag_arr; /**< For Phi node construction in case of exception */
#endif #endif
...@@ -238,10 +234,11 @@ struct ir_node { ...@@ -238,10 +234,11 @@ struct ir_node {
firm_kind kind; /**< distinguishes this node from others */ firm_kind kind; /**< distinguishes this node from others */
ir_op *op; /**< Opcode of this node. */ ir_op *op; /**< Opcode of this node. */
ir_mode *mode; /**< Mode of this node. */ ir_mode *mode; /**< Mode of this node. */
struct ir_node **in; /**< array with predecessors / operands */ struct ir_node **in; /**< The array of predecessors / operands. */
unsigned long visited; /**< visited counter for walks of the graph */ unsigned long visited; /**< Visited counter for walks of the graph. */
unsigned node_idx; /**< the node index of this node in its graph */ unsigned node_idx; /**< The node index of this node in its graph. */
void *link; /**< to attach additional information to the node, e.g. unsigned pinned : 1; /**< A node is either pinned or not. */
void *link; /**< To attach additional information to the node, e.g.
used while construction to link Phi0 nodes and used while construction to link Phi0 nodes and
during optimization to link to nodes that during optimization to link to nodes that
shall replace a node. */ shall replace a node. */
...@@ -251,12 +248,12 @@ struct ir_node { ...@@ -251,12 +248,12 @@ struct ir_node {
/* ------- For debugging ------- */ /* ------- For debugging ------- */
#ifdef DEBUG_libfirm #ifdef DEBUG_libfirm
int out_valid; int out_valid;
long node_nr; /**< a unique node number for each node to make output long node_nr; /**< A unique node number for each node to make output
readable. */ readable. */
#endif #endif
/* ------- For analyses -------- */ /* ------- For analyses -------- */
ir_loop *loop; /**< the loop the node is in. Access routines in irloop.h */ ir_loop *loop; /**< the loop the node is in. Access routines in irloop.h */
#ifdef DO_HEAPANALYSIS #ifdef DO_HEAPANALYSIS
struct abstval *av; /**< the abstract value of this node */ struct abstval *av; /**< the abstract value of this node */
struct section *sec; struct section *sec;
#endif #endif
...@@ -340,7 +337,7 @@ ir_op_ops *firm_set_default_get_entity_attr(opcode code, ir_op_ops *ops); ...@@ -340,7 +337,7 @@ ir_op_ops *firm_set_default_get_entity_attr(opcode code, ir_op_ops *ops);
* Intern version for libFirm. * Intern version for libFirm.
*/ */
static INLINE int static INLINE int
_is_ir_node (const void *thing) { _is_ir_node(const void *thing) {
return (get_kind(thing) == k_ir_node); return (get_kind(thing) == k_ir_node);
} }
...@@ -349,14 +346,14 @@ _is_ir_node (const void *thing) { ...@@ -349,14 +346,14 @@ _is_ir_node (const void *thing) {
* Intern version for libFirm. * Intern version for libFirm.
*/ */
static INLINE ir_op * static INLINE ir_op *
_get_irn_op (const ir_node *node) { _get_irn_op(const ir_node *node) {
assert (node); assert(node);
return node->op; return node->op;
} }
static INLINE void static INLINE void
_set_irn_op (ir_node *node, ir_op *op) { _set_irn_op(ir_node *node, ir_op *op) {
assert (node); assert(node);
node->op = op; node->op = op;
} }
...@@ -375,9 +372,9 @@ copy_node_attr(const ir_node *old_node, ir_node *new_node) { ...@@ -375,9 +372,9 @@ copy_node_attr(const ir_node *old_node, ir_node *new_node) {
* Intern version for libFirm. * Intern version for libFirm.
*/ */
static INLINE opcode static INLINE opcode
_get_irn_opcode (const ir_node *node) { _get_irn_opcode(const ir_node *node) {
assert (k_ir_node == get_kind(node)); assert(k_ir_node == get_kind(node));
assert (node->op); assert(node->op);
return node->op->code; return node->op->code;
} }
...@@ -386,7 +383,7 @@ _get_irn_opcode (const ir_node *node) { ...@@ -386,7 +383,7 @@ _get_irn_opcode (const ir_node *node) {
* Intern version for libFirm. * Intern version for libFirm.
*/ */
static INLINE int static INLINE int
_get_irn_intra_arity (const ir_node *node) { _get_irn_intra_arity(const ir_node *node) {
assert(node); assert(node);
return ARR_LEN(node->in) - 1; return ARR_LEN(node->in) - 1;
} }
...@@ -396,7 +393,7 @@ _get_irn_intra_arity (const ir_node *node) { ...@@ -396,7 +393,7 @@ _get_irn_intra_arity (const ir_node *node) {
* Intern version for libFirm. * Intern version for libFirm.
*/ */
static INLINE int static INLINE int
_get_irn_inter_arity (const ir_node *node) { _get_irn_inter_arity(const ir_node *node) {
assert(node); assert(node);
if (_get_irn_op(node) == op_Filter) { if (_get_irn_op(node) == op_Filter) {
assert(node->attr.filter.in_cg); assert(node->attr.filter.in_cg);
...@@ -417,7 +414,7 @@ extern int (*_get_irn_arity)(const ir_node *node); ...@@ -417,7 +414,7 @@ extern int (*_get_irn_arity)(const ir_node *node);
* Intern version for libFirm. * Intern version for libFirm.
*/ */
static INLINE ir_node * static INLINE ir_node *
_get_irn_intra_n (const ir_node *node, int n) { _get_irn_intra_n(const ir_node *node, int n) {
ir_node *nn; ir_node *nn;
assert(node); assert(-1 <= n && n < _get_irn_intra_arity(node)); assert(node); assert(-1 <= n && n < _get_irn_intra_arity(node));
...@@ -432,7 +429,7 @@ _get_irn_intra_n (const ir_node *node, int n) { ...@@ -432,7 +429,7 @@ _get_irn_intra_n (const ir_node *node, int n) {
* Intern version for libFirm. * Intern version for libFirm.
*/ */
static INLINE ir_node* static INLINE ir_node*
_get_irn_inter_n (const ir_node *node, int n) { _get_irn_inter_n(const ir_node *node, int n) {
assert(node); assert(-1 <= n && n < _get_irn_inter_arity(node)); assert(node); assert(-1 <= n && n < _get_irn_inter_arity(node));
/* handle Filter and Block specially */ /* handle Filter and Block specially */
...@@ -443,7 +440,7 @@ _get_irn_inter_n (const ir_node *node, int n) { ...@@ -443,7 +440,7 @@ _get_irn_inter_n (const ir_node *node, int n) {
return (node->attr.block.in_cg[n + 1] = skip_Id(node->attr.block.in_cg[n + 1])); return (node->attr.block.in_cg[n + 1] = skip_Id(node->attr.block.in_cg[n + 1]));
} }
return _get_irn_intra_n (node, n); return _get_irn_intra_n(node, n);
} }
/** /**
...@@ -462,7 +459,7 @@ extern ir_node *(*_get_irn_n)(const ir_node *node, int n); ...@@ -462,7 +459,7 @@ extern ir_node *(*_get_irn_n)(const ir_node *node, int n);
*/ */
static INLINE ir_mode * static INLINE ir_mode *
_get_irn_mode(const ir_node *node) { _get_irn_mode(const ir_node *node) {
assert (node); assert(node);
return node->mode; return node->mode;
} }
...@@ -472,7 +469,7 @@ _get_irn_mode(const ir_node *node) { ...@@ -472,7 +469,7 @@ _get_irn_mode(const ir_node *node) {
*/ */
static INLINE void static INLINE void
_set_irn_mode(ir_node *node, ir_mode *mode) { _set_irn_mode(ir_node *node, ir_mode *mode) {
assert (node); assert(node);
node->mode = mode; node->mode = mode;
} }
...@@ -482,7 +479,7 @@ _set_irn_mode(ir_node *node, ir_mode *mode) { ...@@ -482,7 +479,7 @@ _set_irn_mode(ir_node *node, ir_mode *mode) {
*/ */
static INLINE unsigned long static INLINE unsigned long
_get_irn_visited(const ir_node *node) { _get_irn_visited(const ir_node *node) {
assert (node); assert(node);
return node->visited; return node->visited;
} }
...@@ -492,7 +489,7 @@ _get_irn_visited(const ir_node *node) { ...@@ -492,7 +489,7 @@ _get_irn_visited(const ir_node *node) {
*/ */
static INLINE void static INLINE void
_set_irn_visited(ir_node *node, unsigned long visited) { _set_irn_visited(ir_node *node, unsigned long visited) {
assert (node); assert(node);
node->visited = visited; node->visited = visited;
} }
...@@ -502,7 +499,7 @@ _set_irn_visited(ir_node *node, unsigned long visited) { ...@@ -502,7 +499,7 @@ _set_irn_visited(ir_node *node, unsigned long visited) {
*/ */
static INLINE void static INLINE void
_mark_irn_visited(ir_node *node) { _mark_irn_visited(ir_node *node) {
assert (node); assert(node);
node->visited = current_ir_graph->visited; node->visited = current_ir_graph->visited;
} }
...@@ -512,7 +509,7 @@ _mark_irn_visited(ir_node *node) { ...@@ -512,7 +509,7 @@ _mark_irn_visited(ir_node *node) {
*/ */
static INLINE int static INLINE int
_irn_visited(const ir_node *node) { _irn_visited(const ir_node *node) {
assert (node); assert(node);
return (node->visited >= current_ir_graph->visited); return (node->visited >= current_ir_graph->visited);
} }
...@@ -522,7 +519,7 @@ _irn_visited(const ir_node *node) { ...@@ -522,7 +519,7 @@ _irn_visited(const ir_node *node) {
*/ */
static INLINE int static INLINE int
_irn_not_visited(const ir_node *node) { _irn_not_visited(const ir_node *node) {
assert (node); assert(node);
return (node->visited < current_ir_graph->visited); return (node->visited < current_ir_graph->visited);
} }
...@@ -532,7 +529,7 @@ _irn_not_visited(const ir_node *node) { ...@@ -532,7 +529,7 @@ _irn_not_visited(const ir_node *node) {
*/ */
static INLINE void static INLINE void
_set_irn_link(ir_node *node, void *link) { _set_irn_link(ir_node *node, void *link) {
assert (node); assert(node);
/* Link field is used for Phi construction and various optimizations /* Link field is used for Phi construction and various optimizations
in iropt. */ in iropt. */
assert(get_irg_phase_state(get_irn_irg(node)) != phase_building); assert(get_irg_phase_state(get_irn_irg(node)) != phase_building);
...@@ -546,7 +543,7 @@ _set_irn_link(ir_node *node, void *link) { ...@@ -546,7 +543,7 @@ _set_irn_link(ir_node *node, void *link) {
*/ */
static INLINE void * static INLINE void *
_get_irn_link(const ir_node *node) { _get_irn_link(const ir_node *node) {
assert (node && _is_ir_node(node)); assert(node && _is_ir_node(node));
return node->link; return node->link;
} }
...@@ -564,14 +561,14 @@ _get_irn_pinned(const ir_node *node) { ...@@ -564,14 +561,14 @@ _get_irn_pinned(const ir_node *node) {
state = _get_op_pinned(_get_irn_op(node)); state = _get_op_pinned(_get_irn_op(node));
if (state >= op_pin_state_exc_pinned) if (state >= op_pin_state_exc_pinned)
return get_opt_fragile_ops() ? node->attr.except.pin_state : op_pin_state_pinned; return get_opt_fragile_ops() ? (op_pin_state)node->pinned : op_pin_state_pinned;
return state; return (op_pin_state)node->pinned;
} }
static INLINE op_pin_state static INLINE op_pin_state
_is_irn_pinned_in_irg(const ir_node *node) { _is_irn_pinned_in_irg(const ir_node *node) {
if (get_irg_pinned(get_irn_irg(node)) == op_pin_state_floats) if (_get_irg_pinned(get_irn_irg(node)) == op_pin_state_floats)
return get_irn_pinned(node); return _get_irn_pinned(node);
return op_pin_state_pinned; return op_pin_state_pinned;
} }
...@@ -697,26 +694,26 @@ _get_Block_cfgpred_block(ir_node *node, int pos) { ...@@ -697,26 +694,26 @@ _get_Block_cfgpred_block(ir_node *node, int pos) {
static INLINE unsigned long static INLINE unsigned long
_get_Block_block_visited(ir_node *node) { _get_Block_block_visited(ir_node *node) {
assert (node->op == op_Block); assert(node->op == op_Block);
return node->attr.block.block_visited; return node->attr.block.block_visited;
} }
static INLINE void static INLINE void
_set_Block_block_visited(ir_node *node, unsigned long visit) { _set_Block_block_visited(ir_node *node, unsigned long visit) {
assert (node->op == op_Block); assert(node->op == op_Block);
node->attr.block.block_visited = visit; node->attr.block.block_visited = visit;
} }
/* For this current_ir_graph must be set. */ /* For this current_ir_graph must be set. */
static INLINE void static INLINE void
_mark_Block_block_visited(ir_node *node) { _mark_Block_block_visited(ir_node *node) {
assert (node->op == op_Block); assert(node->op == op_Block);
node->attr.block.block_visited = get_irg_block_visited(current_ir_graph); node->attr.block.block_visited = get_irg_block_visited(current_ir_graph);
} }
static INLINE int static INLINE int
_Block_not_block_visited(ir_node *node) { _Block_not_block_visited(ir_node *node) {
assert (node->op == op_Block); assert(node->op == op_Block);
return (node->attr.block.block_visited < get_irg_block_visited(current_ir_graph)); return (node->attr.block.block_visited < get_irg_block_visited(current_ir_graph));
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment