Commit def92e0a authored by Matthias Braun's avatar Matthias Braun
Browse files

Turn node pinned attribute into a boolean

Avoid using the op_pin_state enum as that contains confusing additional
entries that are not valid on a node. The only remaining state for a
node is pinned/floating which we can simply represent with a 0/1 value.
parent 9d9de9f6
......@@ -384,11 +384,10 @@ FIRM_API ir_node *new_Phi_loop(int arity, ir_node *in[]);
* @param *op1 The first operand.
* @param *op2 The second operand.
* @param *mode The mode of the result.
* @param state The pinned state.
*/
FIRM_API ir_node *new_rd_DivRL(dbg_info *db, ir_node *block, ir_node *memop,
ir_node *op1, ir_node *op2, ir_mode *mode,
op_pin_state state);
int pinned);
/** Constructor for a remainderless Div node.
*
......@@ -401,7 +400,7 @@ FIRM_API ir_node *new_rd_DivRL(dbg_info *db, ir_node *block, ir_node *memop,
*/
FIRM_API ir_node *new_r_DivRL(ir_node *block, ir_node *memop,
ir_node *op1, ir_node *op2, ir_mode *mode,
op_pin_state state);
int pinned);
/** Constructor for a remainderless Div node.
*
......@@ -416,7 +415,7 @@ FIRM_API ir_node *new_r_DivRL(ir_node *block, ir_node *memop,
*/
FIRM_API ir_node *new_d_DivRL(dbg_info *db, ir_node *memop,
ir_node *op1, ir_node *op2, ir_mode *mode,
op_pin_state state);
int pinned);
/** Constructor for a remainderless Div node.
*
......@@ -429,7 +428,7 @@ FIRM_API ir_node *new_d_DivRL(dbg_info *db, ir_node *memop,
* @param state The pinned state.
*/
FIRM_API ir_node *new_DivRL(ir_node *memop, ir_node *op1, ir_node *op2,
ir_mode *mode, op_pin_state state);
ir_mode *mode, int pinned);
/** @} */
......
......@@ -111,17 +111,17 @@ FIRM_API ir_graph *get_irn_irg(const ir_node *node);
of node cast to long. */
FIRM_API long get_irn_node_nr(const ir_node *node);
/** Returns the pinned state of a node.
*
* Returns whether the node _always_ must be pinned.
* I.e., the node is not floating after global cse.
*
* @returns Either state op_pin_state_pinned or op_pin_state_floats.
/**
* Returns whether a node is pinned.
* A pinned node must not be moved to a different block even if the operands
* would allow this.
* Returns 1 if node is pinned, 0 otherwise.
*/
FIRM_API op_pin_state get_irn_pinned(const ir_node *node);
FIRM_API int get_irn_pinned(const ir_node *node);
/** Sets pin state for nodes with op pin state op_pin_state_exc_pinned */
FIRM_API void set_irn_pinned(ir_node *node, op_pin_state state);
/** Sets pin state for nodes with op pin state op_pin_state_exc_pinned.
* @p pinned should be 0 or 1, @see get_irn_pinned() */
FIRM_API void set_irn_pinned(ir_node *node, int pinned);
/**
* IR node constructor.
......
......@@ -153,7 +153,7 @@ ir_node *be_new_Perm(arch_register_class_t const *const cls,
ir_node *irn = new_ir_node(NULL, irg, block, op_be_Perm, mode_T, n, in);
init_node_attr(irn, n, arch_irn_flags_none);
be_node_attr_t *attr = (be_node_attr_t*)get_irn_generic_attr(irn);
attr->exc.pin_state = op_pin_state_pinned;
attr->exc.pinned = true;
for (int i = 0; i < n; ++i) {
const ir_node *input = in[i];
const arch_register_req_t *req = arch_get_irn_register_req(input);
......@@ -195,7 +195,7 @@ static void set_copy_info(ir_node *const irn, ir_graph *const irg, ir_node *cons
{
init_node_attr(irn, 1, flags);
be_node_attr_t *const attr = (be_node_attr_t*)get_irn_generic_attr(irn);
attr->exc.pin_state = op_pin_state_floats;
attr->exc.pinned = false;
arch_register_req_t const *const op_req = arch_get_irn_register_req(op);
arch_register_class_t const *const cls = op_req->cls;
......@@ -232,7 +232,7 @@ ir_node *be_new_Keep(ir_node *const block, int const n,
ir_node *res = new_ir_node(NULL, irg, block, op_be_Keep, mode_ANY, n, in);
init_node_attr(res, 1, arch_irn_flag_schedule_first);
be_node_attr_t *attr = (be_node_attr_t*) get_irn_generic_attr(res);
attr->exc.pin_state = op_pin_state_pinned;
attr->exc.pinned = true;
for (int i = 0; i < n; ++i) {
arch_register_req_t const *const req = arch_get_irn_register_req(in[i]);
......@@ -257,10 +257,10 @@ ir_node *be_new_IncSP(const arch_register_t *sp, ir_node *bl,
ir_node *irn = new_ir_node(NULL, irg, bl, op_be_IncSP, sp->cls->mode,
ARRAY_SIZE(in), in);
init_node_attr(irn, 1, arch_irn_flags_none);
be_incsp_attr_t *a = (be_incsp_attr_t*)get_irn_generic_attr(irn);
a->offset = offset;
a->align = align;
a->base.exc.pin_state = op_pin_state_pinned;
be_incsp_attr_t *a = (be_incsp_attr_t*)get_irn_generic_attr(irn);
a->offset = offset;
a->align = align;
a->base.exc.pinned = true;
/* Set output constraint to stack register. */
be_node_set_register_req_in(irn, 0, sp->cls->class_req);
......
......@@ -56,7 +56,7 @@ ir_node *new_rd_ASM(dbg_info *db, ir_node *block, ir_node *mem,
struct obstack *const obst = get_irg_obstack(irg);
asm_attr *const a = &res->attr.assem;
a->exc.pin_state = op_pin_state_pinned;
a->exc.pinned = true;
a->input_constraints = NEW_ARR_D(ir_asm_constraint, obst, arity);
a->output_constraints = NEW_ARR_D(ir_asm_constraint, obst, n_outs);
a->clobbers = NEW_ARR_D(ident*, obst, n_clobber);
......@@ -314,33 +314,33 @@ ir_node *new_d_ASM(dbg_info *db, ir_node *mem, int arity, ir_node *in[],
inputs, n_outs, outputs, n_clobber, clobber, text);
}
ir_node *new_rd_DivRL(dbg_info *dbgi, ir_node *block, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, op_pin_state pin_state)
ir_node *new_rd_DivRL(dbg_info *dbgi, ir_node *block, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, int pinned)
{
ir_graph *const irg = get_irn_irg(block);
ir_node *const in[] = { irn_mem, irn_left, irn_right };
ir_node *res = new_ir_node(dbgi, irg, block, op_Div, mode_T, ARRAY_SIZE(in), in);
res->attr.div.resmode = resmode;
res->attr.div.no_remainder = 1;
res->attr.div.exc.pin_state = pin_state;
res->attr.div.exc.pinned = pinned;
verify_new_node(res);
res = optimize_node(res);
return res;
}
ir_node *new_r_DivRL(ir_node *block, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, op_pin_state pin_state)
ir_node *new_r_DivRL(ir_node *block, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, int pinned)
{
return new_rd_DivRL(NULL, block, irn_mem, irn_left, irn_right, resmode, pin_state);
return new_rd_DivRL(NULL, block, irn_mem, irn_left, irn_right, resmode, pinned);
}
ir_node *new_d_DivRL(dbg_info *dbgi, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, op_pin_state pin_state)
ir_node *new_d_DivRL(dbg_info *dbgi, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, int pinned)
{
assert(irg_is_constrained(current_ir_graph, IR_GRAPH_CONSTRAINT_CONSTRUCTION));
return new_rd_DivRL(dbgi, current_ir_graph->current_block, irn_mem, irn_left, irn_right, resmode, pin_state);
return new_rd_DivRL(dbgi, current_ir_graph->current_block, irn_mem, irn_left, irn_right, resmode, pinned);
}
ir_node *new_DivRL(ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, op_pin_state pin_state)
ir_node *new_DivRL(ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, int pinned)
{
return new_d_DivRL(NULL, irn_mem, irn_left, irn_right, resmode, pin_state);
return new_d_DivRL(NULL, irn_mem, irn_left, irn_right, resmode, pinned);
}
ir_node *new_rd_Phi_loop(dbg_info *db, ir_node *block, int arity,
......
......@@ -1528,9 +1528,9 @@ static ir_mode_arithmetic read_mode_arithmetic(read_env_t *env)
return (ir_mode_arithmetic)read_enum(env, tt_mode_arithmetic);
}
static op_pin_state read_pin_state(read_env_t *env)
static bool read_pinned(read_env_t *env)
{
return (op_pin_state)read_enum(env, tt_pin_state);
return read_enum(env, tt_pin_state) == op_pin_state_pinned;
}
static ir_type_state read_type_state(read_env_t *env)
......@@ -1989,7 +1989,7 @@ static ir_node *read_ASM(read_env_t *env)
ARR_APP1(ident*, clobbers, clobber);
}
op_pin_state pin_state = read_pin_state(env);
int pinned = read_pinned(env);
int n_in = read_preds(env);
ir_node **in = (ir_node**)obstack_finish(&env->preds_obst);
......@@ -2003,7 +2003,7 @@ static ir_node *read_ASM(read_env_t *env)
input_constraints, ARR_LEN(output_constraints),
output_constraints, ARR_LEN(clobbers),
clobbers, asm_text);
set_irn_pinned(newnode, pin_state);
set_irn_pinned(newnode, pinned);
obstack_free(&env->preds_obst, in);
DEL_ARR_F(clobbers);
DEL_ARR_F(output_constraints);
......
......@@ -313,17 +313,16 @@ void *(get_irn_link)(const ir_node *node)
return get_irn_link_(node);
}
op_pin_state (get_irn_pinned)(const ir_node *node)
int (get_irn_pinned)(const ir_node *node)
{
return get_irn_pinned_(node);
}
void set_irn_pinned(ir_node *node, op_pin_state state)
void set_irn_pinned(ir_node *node, int pinned)
{
assert(get_op_pinned(get_irn_op(node)) >= op_pin_state_exc_pinned);
assert(state == op_pin_state_pinned || state == op_pin_state_floats);
node->attr.except.pin_state = state;
node->attr.except.pinned = (pinned != 0);
}
long get_irn_node_nr(const ir_node *node)
......
......@@ -271,15 +271,13 @@ static inline void *get_irn_link_(const ir_node *node)
*
* Intern version of libFirm.
*/
static inline op_pin_state get_irn_pinned_(const ir_node *node)
static inline int get_irn_pinned_(const ir_node *node)
{
op_pin_state state;
assert(node->kind == k_ir_node);
/* Check opcode */
state = get_op_pinned_(get_irn_op_(node));
op_pin_state state = get_op_pinned_(get_irn_op_(node));
if (state >= op_pin_state_exc_pinned)
return (op_pin_state)node->attr.except.pin_state;
return (op_pin_state)node->attr.except.pinned;
return state;
}
......
......@@ -253,7 +253,7 @@ static unsigned hash_typeconst(const ir_node *node)
/** Compares two exception attributes */
static bool except_attrs_equal(const except_attr *a, const except_attr *b)
{
return a->pin_state == b->pin_state;
return a->pinned == b->pinned;
}
/** Compares the attributes of two Const nodes. */
......
......@@ -227,9 +227,7 @@ typedef struct sel_attr {
/** Attributes for nodes with exceptions (fragile flag). */
typedef struct except_attr {
unsigned pin_state : 2; /**< the pin state for operations with
variable pinned state. Contains a
op_pin_state */
bool pinned : 1;
unsigned throws_exception : 1; /**< if true a fragile op throws and
must produce X_except and X_regular
values */
......
......@@ -419,15 +419,15 @@ def _preprocess_node(node):
if is_dynamic_pinned(node):
if node.pinned_init is not None:
initattrs.append(
Attribute("pin_state", fqname="exc.pin_state",
type="op_pin_state", init=node.pinned_init))
Attribute("pinned", fqname="exc.pinned",
type="int", init=node.pinned_init))
else:
arguments.append(
Attribute("pin_state", type="op_pin_state",
Attribute("pinned", type="int",
comment = "pinned state"))
initattrs.append(
Attribute("pin_state", fqname="exc.pin_state",
type="op_pin_state", init="pin_state"))
Attribute("pin_state", fqname="exc.pinned",
type="int", init="pinned"))
if node.throws_init is not None:
initattrs.append(
Attribute("throws_exception", fqname="exc.throws_exception",
......
......@@ -15,7 +15,7 @@ static ir_node *read_{{node.name}}(read_env_t *env)
{{attr.type}} {{attr.name}} = read_{{attr.type|simplify_type}}(env);
{%- endfor %}
{%- if is_dynamic_pinned(node) %}
op_pin_state pin_state = read_pin_state(env);
int pinned = read_pinned(env);
{%- endif %}
{%- if "fragile" in node.flags %}
bool throws = read_throws(env);
......@@ -32,7 +32,7 @@ static ir_node *read_{{node.name}}(read_env_t *env)
{%- endif %}
{%- endfor %}
{%- if is_dynamic_pinned(node) %}
| (pin_state == op_pin_state_floats ? cons_floats : cons_none)
| (pinned == 0 ? cons_floats : cons_none)
{%- endif %}
{%- if "fragile" in node.flags %}
| (throws ? cons_throws_exception : cons_none)
......@@ -53,7 +53,7 @@ static ir_node *read_{{node.name}}(read_env_t *env)
{%- endfor %}
{%- if not node.constructorFlags %}
{%- if is_dynamic_pinned(node) and hasattr(node, "pinned_init") %}
set_irn_pinned(res, pin_state);
set_irn_pinned(res, pinned);
{%- endif %}
{%- if "fragile" in node.flags and hasattr(node, "throws_init") %}
ir_set_throws_exception(res, throws);
......
Markdown is supported
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