Commit 6dd417e1 authored by Michael Beck's avatar Michael Beck
Browse files

Add strict flag to Conv attributes alloweing to mark those Conv's

that should remain due to strict fp rounding rules.
Removed unused Start attibutes.
Renamed attribute names to more understandable names.

[r7982]
parent 74b3b538
......@@ -328,19 +328,20 @@ new_bd_defaultProj (dbg_info *db, ir_node *block, ir_node *arg,
ir_graph *irg = current_ir_graph;
assert(arg->op == op_Cond);
arg->attr.c.kind = fragmentary;
arg->attr.c.default_proj = max_proj;
arg->attr.cond.kind = fragmentary;
arg->attr.cond.default_proj = max_proj;
res = new_rd_Proj (db, irg, block, arg, mode_X, max_proj);
return res;
}
static ir_node *
new_bd_Conv (dbg_info *db, ir_node *block, ir_node *op, ir_mode *mode)
new_bd_Conv (dbg_info *db, ir_node *block, ir_node *op, ir_mode *mode, int strict_flag)
{
ir_node *res;
ir_graph *irg = current_ir_graph;
res = new_ir_node(db, irg, block, op_Conv, mode, 1, &op);
res->attr.conv.strict = strict_flag;
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
return res;
......@@ -441,9 +442,9 @@ new_bd_Cond (dbg_info *db, ir_node *block, ir_node *c)
ir_graph *irg = current_ir_graph;
res = new_ir_node (db, irg, block, op_Cond, mode_T, 1, &c);
res->attr.c.kind = dense;
res->attr.c.default_proj = 0;
res->attr.c.pred = COND_JMP_PRED_NONE;
res->attr.cond.kind = dense;
res->attr.cond.default_proj = 0;
res->attr.cond.pred = COND_JMP_PRED_NONE;
res = optimize_node (res);
IRN_VRFY_IRG(res, irg);
return res;
......@@ -543,9 +544,9 @@ new_bd_Alloc (dbg_info *db, ir_node *block, ir_node *store,
in[0] = store;
in[1] = size;
res = new_ir_node(db, irg, block, op_Alloc, mode_T, 2, in);
res->attr.a.exc.pin_state = op_pin_state_pinned;
res->attr.a.where = where;
res->attr.a.type = alloc_type;
res->attr.alloc.exc.pin_state = op_pin_state_pinned;
res->attr.alloc.where = where;
res->attr.alloc.type = alloc_type;
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
return res;
......@@ -563,8 +564,8 @@ new_bd_Free (dbg_info *db, ir_node *block, ir_node *store,
in[1] = ptr;
in[2] = size;
res = new_ir_node (db, irg, block, op_Free, mode_M, 3, in);
res->attr.f.where = where;
res->attr.f.type = free_type;
res->attr.free.where = where;
res->attr.free.type = free_type;
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
return res;
......@@ -590,7 +591,7 @@ new_bd_Sel (dbg_info *db, ir_node *block, ir_node *store, ir_node *objptr,
* FIXM: Sel's can select functions which should be of mode mode_P_code.
*/
res = new_ir_node(db, irg, block, op_Sel, mode_P_data, r_arity, r_in);
res->attr.s.ent = ent;
res->attr.sel.ent = ent;
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
return res;
......@@ -610,9 +611,9 @@ new_bd_SymConst_type (dbg_info *db, ir_node *block, symconst_symbol value,
res = new_ir_node(db, irg, block, op_SymConst, mode, 0, NULL);
res->attr.i.num = symkind;
res->attr.i.sym = value;
res->attr.i.tp = tp;
res->attr.symc.num = symkind;
res->attr.symc.sym = value;
res->attr.symc.tp = tp;
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
......@@ -818,7 +819,7 @@ new_bd_InstOf (dbg_info *db, ir_node *block, ir_node *store,
in[0] = store;
in[1] = objptr;
res = new_ir_node(db, irg, block, op_Sel, mode_T, 2, in);
res->attr.io.type = type;
res->attr.instof.type = type;
res = optimize_node(res);
IRN_VRFY_IRG(res, irg);
return res;
......@@ -999,7 +1000,7 @@ new_rd_Conv (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode *
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
res = new_bd_Conv(db, block, op, mode);
res = new_bd_Conv(db, block, op, mode, 0);
current_ir_graph = rem;
return res;
......@@ -2247,7 +2248,7 @@ get_frag_arr (ir_node *n) {
case iro_Call:
return n->attr.call.exc.frag_arr;
case iro_Alloc:
return n->attr.a.exc.frag_arr;
return n->attr.alloc.exc.frag_arr;
case iro_Load:
return n->attr.load.exc.frag_arr;
case iro_Store:
......@@ -2622,27 +2623,29 @@ new_d_defaultProj (dbg_info *db, ir_node *arg, long max_proj)
{
ir_node *res;
assert(arg->op == op_Cond);
arg->attr.c.kind = fragmentary;
arg->attr.c.default_proj = max_proj;
arg->attr.cond.kind = fragmentary;
arg->attr.cond.default_proj = max_proj;
res = new_Proj (arg, mode_X, max_proj);
return res;
}
ir_node *
new_d_Conv (dbg_info *db, ir_node *op, ir_mode *mode)
{
return new_bd_Conv(db, current_ir_graph->current_block, op, mode);
new_d_Conv (dbg_info *db, ir_node *op, ir_mode *mode) {
return new_bd_Conv(db, current_ir_graph->current_block, op, mode, 0);
}
ir_node *
new_d_Cast (dbg_info *db, ir_node *op, ir_type *to_tp)
{
new_d_strictConv (dbg_info *db, ir_node *op, ir_mode *mode) {
return new_bd_Conv(db, current_ir_graph->current_block, op, mode, 1);
}
ir_node *
new_d_Cast (dbg_info *db, ir_node *op, ir_type *to_tp) {
return new_bd_Cast(db, current_ir_graph->current_block, op, to_tp);
}
ir_node *
new_d_Tuple (dbg_info *db, int arity, ir_node **in)
{
new_d_Tuple (dbg_info *db, int arity, ir_node **in) {
return new_bd_Tuple(db, current_ir_graph->current_block, arity, in);
}
......@@ -2807,7 +2810,7 @@ new_d_Alloc (dbg_info *db, ir_node *store, ir_node *size, ir_type *alloc_type,
res = new_bd_Alloc (db, current_ir_graph->current_block,
store, size, alloc_type, where);
#if PRECISE_EXC_CONTEXT
allocate_frag_arr(res, op_Alloc, &res->attr.a.exc.frag_arr); /* Could be optimized away. */
allocate_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr); /* Could be optimized away. */
#endif
return res;
......@@ -3264,6 +3267,9 @@ ir_node *new_Cmp (ir_node *op1, ir_node *op2) {
ir_node *new_Conv (ir_node *op, ir_mode *mode) {
return new_d_Conv(NULL, op, mode);
}
ir_node *new_strictConv (ir_node *op, ir_mode *mode) {
return new_d_strictConv(NULL, op, mode);
}
ir_node *new_Cast (ir_node *op, ir_type *to_tp) {
return new_d_Cast(NULL, op, to_tp);
}
......
......@@ -13,7 +13,7 @@
/**
@todo
Ideas for imrovement:
Ideas for improvement:
-# Handle construction of exceptions more comfortable:
Add new constructors that pass the exception region (or better the
Phi for the memories, the ex. region can be found from there) as parameter,
......@@ -3134,6 +3134,16 @@ ir_node *new_d_Cmp (dbg_info *db, ir_node *op1, ir_node *op2);
*/
ir_node *new_d_Conv (dbg_info *db, ir_node *op, ir_mode *mode);
/** Constructor for a strict Conv node.
*
* Adds the node to the block in current_ir_block.
*
* @param *db A pointer for debug information.
* @param *op The operand.
* @param *mode The mode of this the operand muss be converted .
*/
ir_node *new_d_strictConv (dbg_info *db, ir_node *op, ir_mode *mode);
/** Constructor for a Cast node.
*
* High level type cast
......@@ -3852,11 +3862,20 @@ ir_node *new_Cmp (ir_node *op1, ir_node *op2);
*
* Adds the node to the block in current_ir_block.
*
* @param *op The operand.
* @param *mode The mode of this the operand muss be converted .
* @param *op The operand.
* @param *mode The mode of this the operand muss be converted.
*/
ir_node *new_Conv (ir_node *op, ir_mode *mode);
/** Constructor for a strict Conv node.
*
* Adds the node to the block in current_ir_block.
*
* @param *op The operand.
* @param *mode The mode of this the operand muss be converted.
*/
ir_node *new_strictConv (ir_node *op, ir_mode *mode);
/** Constructor for a Cast node.
*
* Adds the node to the block in current_ir_block.
......
......@@ -733,6 +733,11 @@ int dump_node_opcode(FILE *F, ir_node *n)
case iro_Block:
fprintf (F, "%s%s", is_Block_dead(n) ? "Dead " : "", get_irn_opname(n));
break;
case iro_Conv:
if (get_Conv_strict(n))
fprintf (F, "strict");
fprintf (F, "%s", get_irn_opname(n));
break;
default:
default_case:
......
......@@ -487,21 +487,21 @@ alloc_attr
get_irn_alloc_attr (ir_node *node)
{
assert (node->op == op_Alloc);
return node->attr.a;
return node->attr.alloc;
}
free_attr
get_irn_free_attr (ir_node *node)
{
assert (node->op == op_Free);
return node->attr.f;
return node->attr.free;
}
symconst_attr
get_irn_symconst_attr (ir_node *node)
{
assert (node->op == op_SymConst);
return node->attr.i;
return node->attr.symc;
}
ir_type *
......@@ -515,7 +515,7 @@ sel_attr
get_irn_sel_attr (ir_node *node)
{
assert (node->op == op_Sel);
return node->attr.s;
return node->attr.sel;
}
int
......@@ -892,19 +892,19 @@ set_Cond_selector (ir_node *node, ir_node *selector) {
cond_kind
get_Cond_kind (ir_node *node) {
assert (node->op == op_Cond);
return node->attr.c.kind;
return node->attr.cond.kind;
}
void
set_Cond_kind (ir_node *node, cond_kind kind) {
assert (node->op == op_Cond);
node->attr.c.kind = kind;
node->attr.cond.kind = kind;
}
long
get_Cond_defaultProj (ir_node *node) {
assert (node->op == op_Cond);
return node->attr.c.default_proj;
return node->attr.cond.default_proj;
}
ir_node *
......@@ -994,41 +994,41 @@ set_Const_type (ir_node *node, ir_type *tp) {
symconst_kind
get_SymConst_kind (const ir_node *node) {
assert (node->op == op_SymConst);
return node->attr.i.num;
return node->attr.symc.num;
}
void
set_SymConst_kind (ir_node *node, symconst_kind num) {
assert (node->op == op_SymConst);
node->attr.i.num = num;
node->attr.symc.num = num;
}
ir_type *
get_SymConst_type (ir_node *node) {
assert( (node->op == op_SymConst)
&& (SYMCONST_HAS_TYPE(get_SymConst_kind(node))));
return node->attr.i.sym.type_p = skip_tid(node->attr.i.sym.type_p);
return node->attr.symc.sym.type_p = skip_tid(node->attr.symc.sym.type_p);
}
void
set_SymConst_type (ir_node *node, ir_type *tp) {
assert( (node->op == op_SymConst)
&& (SYMCONST_HAS_TYPE(get_SymConst_kind(node))));
node->attr.i.sym.type_p = tp;
node->attr.symc.sym.type_p = tp;
}
ident *
get_SymConst_name (ir_node *node) {
assert ( (node->op == op_SymConst)
&& (get_SymConst_kind(node) == symconst_addr_name));
return node->attr.i.sym.ident_p;
return node->attr.symc.sym.ident_p;
}
void
set_SymConst_name (ir_node *node, ident *name) {
assert ( (node->op == op_SymConst)
&& (get_SymConst_kind(node) == symconst_addr_name));
node->attr.i.sym.ident_p = name;
node->attr.symc.sym.ident_p = name;
}
......@@ -1036,39 +1036,38 @@ set_SymConst_name (ir_node *node, ident *name) {
entity *get_SymConst_entity (ir_node *node) {
assert ( (node->op == op_SymConst)
&& (get_SymConst_kind (node) == symconst_addr_ent));
return node->attr.i.sym.entity_p;
return node->attr.symc.sym.entity_p;
}
void set_SymConst_entity (ir_node *node, entity *ent) {
assert ( (node->op == op_SymConst)
&& (get_SymConst_kind(node) == symconst_addr_ent));
node->attr.i.sym.entity_p = ent;
node->attr.symc.sym.entity_p = ent;
}
union symconst_symbol
get_SymConst_symbol (ir_node *node) {
assert (node->op == op_SymConst);
return node->attr.i.sym;
return node->attr.symc.sym;
}
void
set_SymConst_symbol (ir_node *node, union symconst_symbol sym) {
assert (node->op == op_SymConst);
//memcpy (&(node->attr.i.sym), sym, sizeof(type_or_id));
node->attr.i.sym = sym;
node->attr.symc.sym = sym;
}
ir_type *
get_SymConst_value_type (ir_node *node) {
assert (node->op == op_SymConst);
if (node->attr.i.tp) node->attr.i.tp = skip_tid(node->attr.i.tp);
return node->attr.i.tp;
if (node->attr.symc.tp) node->attr.symc.tp = skip_tid(node->attr.symc.tp);
return node->attr.symc.tp;
}
void
set_SymConst_value_type (ir_node *node, ir_type *tp) {
assert (node->op == op_SymConst);
node->attr.i.tp = tp;
node->attr.symc.tp = tp;
}
ir_node *
......@@ -1126,13 +1125,13 @@ set_Sel_index (ir_node *node, int pos, ir_node *index) {
entity *
get_Sel_entity (ir_node *node) {
assert (node->op == op_Sel);
return node->attr.s.ent;
return node->attr.sel.ent;
}
void
set_Sel_entity (ir_node *node, entity *ent) {
assert (node->op == op_Sel);
node->attr.s.ent = ent;
node->attr.sel.ent = ent;
}
......@@ -1342,13 +1341,13 @@ BINOP(Mod)
ir_node *
get_Mod_mem (ir_node *node) {
assert (node->op == op_Mod);
assert(node->op == op_Mod);
return get_irn_n(node, 0);
}
void
set_Mod_mem (ir_node *node, ir_node *mem) {
assert (node->op == op_Mod);
assert(node->op == op_Mod);
set_irn_n(node, 0, mem);
}
......@@ -1365,15 +1364,25 @@ BINOP(Cmp)
UNOP(Conv)
UNOP(Cast)
int get_Conv_strict(ir_node *node) {
assert(node->op == op_Conv);
return node->attr.conv.strict;
}
void set_Conv_strict(ir_node *node, int strict_flag) {
assert(node->op == op_Conv);
node->attr.conv.strict = (char)strict_flag;
}
ir_type *
get_Cast_type (ir_node *node) {
assert (node->op == op_Cast);
assert(node->op == op_Cast);
return node->attr.cast.totype;
}
void
set_Cast_type (ir_node *node, ir_type *to_tp) {
assert (node->op == op_Cast);
assert(node->op == op_Cast);
node->attr.cast.totype = to_tp;
}
......@@ -1687,25 +1696,25 @@ set_Alloc_size (ir_node *node, ir_node *size) {
ir_type *
get_Alloc_type (ir_node *node) {
assert (node->op == op_Alloc);
return node->attr.a.type = skip_tid(node->attr.a.type);
return node->attr.alloc.type = skip_tid(node->attr.alloc.type);
}
void
set_Alloc_type (ir_node *node, ir_type *tp) {
assert (node->op == op_Alloc);
node->attr.a.type = tp;
node->attr.alloc.type = tp;
}
where_alloc
get_Alloc_where (ir_node *node) {
assert (node->op == op_Alloc);
return node->attr.a.where;
return node->attr.alloc.where;
}
void
set_Alloc_where (ir_node *node, where_alloc where) {
assert (node->op == op_Alloc);
node->attr.a.where = where;
node->attr.alloc.where = where;
}
......@@ -1748,25 +1757,25 @@ set_Free_size (ir_node *node, ir_node *size) {
ir_type *
get_Free_type (ir_node *node) {
assert (node->op == op_Free);
return node->attr.f.type = skip_tid(node->attr.f.type);
return node->attr.free.type = skip_tid(node->attr.free.type);
}
void
set_Free_type (ir_node *node, ir_type *tp) {
assert (node->op == op_Free);
node->attr.f.type = tp;
node->attr.free.type = tp;
}
where_alloc
get_Free_where (ir_node *node) {
assert (node->op == op_Free);
return node->attr.f.where;
return node->attr.free.where;
}
void
set_Free_where (ir_node *node, where_alloc where) {
assert (node->op == op_Free);
node->attr.f.where = where;
node->attr.free.where = where;
}
ir_node **get_Sync_preds_arr (ir_node *node) {
......@@ -2137,13 +2146,13 @@ void set_CopyB_type(ir_node *node, ir_type *data_type) {
ir_type *
get_InstOf_type (ir_node *node) {
assert (node->op = op_InstOf);
return node->attr.io.type;
return node->attr.instof.type;
}
void
set_InstOf_type (ir_node *node, ir_type *type) {
assert (node->op = op_InstOf);
node->attr.io.type = type;
node->attr.instof.type = type;
}
ir_node *
......
......@@ -3,7 +3,7 @@
* File name: ir/ir/irnode.h
* Purpose: Representation of an intermediate operation.
* Author: Martin Trapp, Christian Schaefer
* Modified by: Goetz Lindenmaier
* Modified by: Goetz Lindenmaier, Michael Beck
* Created:
* CVS-ID: $Id$
* Copyright: (c) 1998-2003 Universität Karlsruhe
......@@ -767,6 +767,8 @@ void set_Rot_right (ir_node *node, ir_node *right);
ir_node *get_Conv_op (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);
/* Does Cast need a mem operator?
* Cast should only depend on the type, not on the state of an
......
......@@ -71,37 +71,32 @@ typedef struct {
} block_attr;
/** Start attributes */
typedef struct {
char dummy;
/* ir_graph *irg; @@@ now in block */
} start_attr;
/** Cond attributes */
/** Cond attributes. */
typedef struct {
cond_kind kind; /**< flavor of Cond */
long default_proj; /**< only for non-binary Conds: biggest Proj number, i.e. the one used for default. */
cond_jmp_predicate pred; /**< only for binary Conds: The jump predication. */
} cond_attr;
/** Const attributes */
/** Const attributes. */
typedef struct {
tarval *tv; /**< the target value */
ir_type *tp; /**< the source type, for analyses. default: type_unknown. */
} const_attr;
/** SymConst attributes. */
typedef struct {
symconst_symbol sym; // old tori
symconst_kind num;
ir_type *tp; /**< the source type, for analyses. default: type_unknown. */
} symconst_attr;
/** Sel attributes */
/** Sel attributes. */
typedef struct {
entity *ent; /**< entity to select */
} sel_attr;
/** Exception attributes */
/** Exception attributes. */
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
......@@ -111,33 +106,33 @@ typedef struct {
#endif
} except_attr;
/** Call attributes */
/** Call attributes. */
typedef struct {
except_attr exc; /**< the exception attribute. MUST be the first one. */
ir_type *cld_tp; /**< type of called procedure */
entity ** callee_arr; /**< result of callee analysis */
} call_attr;
/** Alloc attributes */
/** Alloc attributes. */
typedef struct {
except_attr exc; /**< the exception attribute. MUST be the first one. */
ir_type *type; /**< Type of the allocated object. */
where_alloc where; /**< stack, heap or other managed part of memory */
} alloc_attr;
/** Free attributes */
/** Free attributes. */
typedef struct {
ir_type *type; /**< Type of the allocated object. */
where_alloc where; /**< stack, heap or other managed part of memory */
} free_attr;
/** InstOf attributes */
/** InstOf attributes. */
typedef struct {
except_attr exc; /**< the exception attribute. MUST be the first one. */
ir_type *type; /**< the type of which the object pointer must be */
} io_attr;
/** Filter attributes */
/** Filter attributes. */
typedef struct {
long proj; /**< contains the result position to project (Proj) */
ir_node ** in_cg; /**< array with interprocedural predecessors (Phi) */
......@@ -145,29 +140,29 @@ typedef struct {
@todo Ev. replace by bitfield! */
} filter_attr;
/** EndReg/EndExcept attributes */
/** EndReg/EndExcept attributes. */
typedef struct {
char dummy;
} end_attr;
/** CallBegin attributes */
/** CallBegin attributes. */
typedef struct {
ir_node * call; /**< Associated Call-operation. */
} callbegin_attr;