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

handle Block_entity like other node attributes

parent 3ddfc6a4
......@@ -306,14 +306,8 @@ FIRM_API ir_extblk *get_Block_extbb(const ir_node *block);
FIRM_API void set_Block_extbb(ir_node *block, ir_extblk *extblk);
/** Returns the ir_graph this Block belongs to. */
FIRM_API ir_graph *get_Block_irg(const ir_node *block);
/** Returns non-zero if the block has an entity assigned */
FIRM_API int has_Block_entity(const ir_node *block);
/** Returns the entity for a Block */
FIRM_API ir_entity *get_Block_entity(const ir_node *block);
/** Returns the entity for a Block (creating it if necessary) */
FIRM_API ir_entity *create_Block_entity(ir_node *block);
/** Set a new entity for a block */
FIRM_API void set_Block_entity(ir_node *block, ir_entity *entity);
/** Gets the head of the Phi list for this block. */
FIRM_API ir_node *get_Block_phis(const ir_node *block);
/** Sets the head of the Phi list for this block. */
......
......@@ -1561,7 +1561,7 @@ void be_gas_emit_entity(const ir_entity *entity)
void be_gas_emit_block_name(const ir_node *block)
{
if (has_Block_entity(block)) {
if (get_Block_entity(block) != NULL) {
ir_entity *entity = get_Block_entity(block);
be_gas_emit_entity(entity);
} else {
......
......@@ -180,7 +180,8 @@ static void remove_empty_block(ir_node *block)
assert(succ_block == NULL);
succ_block = get_edge_src_irn(edge);
if (has_Block_entity(succ_block) && has_Block_entity(block)) {
if (get_Block_entity(succ_block) != NULL
&& get_Block_entity(block) != NULL) {
/*
* Currently we can add only one label for a block.
* Therefore we cannot combine them if both block already have one.
......@@ -191,7 +192,7 @@ static void remove_empty_block(ir_node *block)
set_irn_n(succ_block, pos, pred);
}
if (has_Block_entity(block)) {
if (get_Block_entity(block) != NULL) {
/* move the label to the successor block */
ir_entity *entity = get_Block_entity(block);
set_Block_entity(succ_block, entity);
......
......@@ -118,7 +118,7 @@ static int block_needs_label(const ir_node *block)
int need_label = 1;
int n_cfgpreds = get_Block_n_cfgpreds(block);
if (has_Block_entity(block))
if (get_Block_entity(block) != NULL)
return 1;
if (n_cfgpreds == 0) {
......
......@@ -1270,7 +1270,7 @@ static bool block_needs_label(const ir_node *block, const ir_node *sched_prev)
{
int n_cfgpreds;
if (has_Block_entity(block))
if (get_Block_entity(block) != NULL)
return true;
n_cfgpreds = get_Block_n_cfgpreds(block);
......
......@@ -152,7 +152,7 @@ void dump_irnode_to_file(FILE *F, ir_node *n)
/* Source types */
switch (get_irn_opcode(n)) {
case iro_Block: {
if (has_Block_entity(n))
if (get_Block_entity(n) != NULL)
fprintf(F, " Label: %lu\n", get_entity_label(get_Block_entity(n)));
fprintf(F, " block visited: %lu\n", get_Block_block_visited(n));
fprintf(F, " block marked: %u\n", get_Block_mark(n));
......
......@@ -643,24 +643,6 @@ ir_entity *create_Block_entity(ir_node *block)
return entity;
}
ir_entity *get_Block_entity(const ir_node *block)
{
assert(is_Block(block));
return block->attr.block.entity;
}
void set_Block_entity(ir_node *block, ir_entity *entity)
{
assert(is_Block(block));
assert(get_entity_type(entity) == get_code_type());
block->attr.block.entity = entity;
}
int has_Block_entity(const ir_node *block)
{
return block->attr.block.entity != NULL;
}
ir_node *(get_Block_phis)(const ir_node *block)
{
return get_Block_phis_(block);
......@@ -1674,6 +1656,7 @@ void firm_set_default_get_entity_attr(unsigned code, ir_op_ops *ops)
switch (code) {
case iro_SymConst: ops->get_entity_attr = get_SymConst_attr_entity; break;
case iro_Sel: ops->get_entity_attr = get_Sel_entity; break;
case iro_Block: ops->get_entity_attr = get_Block_entity; break;
default:
/* not allowed to be NULL */
if (! ops->get_entity_attr)
......
......@@ -114,7 +114,7 @@ static void collect_nodes(ir_node *n, void *ctx)
ir_node *block = get_nodes_block(n);
add_Block_phi(block, n);
} else if (is_Block(n)) {
if (has_Block_entity(n)) {
if (get_Block_entity(n) != NULL) {
/* block with a jump label attached cannot be removed. */
set_Block_removable(n, false);
}
......
......@@ -1929,7 +1929,7 @@ static void compute_Block(node_t *node)
int i;
ir_node *block = node->node;
if (block == get_irg_start_block(current_ir_graph) || has_Block_entity(block)) {
if (block == get_irg_start_block(current_ir_graph) || get_Block_entity(block) != NULL) {
/* start block and labelled blocks are always reachable */
node->type.tv = tarval_reachable;
return;
......@@ -2990,7 +2990,7 @@ static int only_one_reachable_proj(ir_node *n)
*/
static int can_exchange(ir_node *pred, ir_node *block)
{
if (is_Start(pred) || has_Block_entity(block))
if (is_Start(pred) || get_Block_entity(block) != NULL)
return 0;
else if (is_Jmp(pred))
return 1;
......
......@@ -187,7 +187,7 @@ static bool can_move_ret(ir_node *ret)
/* check, that predecessors are Jmps */
n = get_Block_n_cfgpreds(retbl);
/* we cannot move above a labeled block, as this might kill the block */
if (n <= 1 || has_Block_entity(retbl))
if (n <= 1 || get_Block_entity(retbl) != NULL)
return false;
for (i = 0; i < n; ++i) {
ir_node *pred = get_Block_cfgpred(retbl, i);
......
......@@ -175,6 +175,14 @@ class Block(Op):
arity = "variable"
flags = [ "labeled" ]
attr_struct = "block_attr"
attrs = [
dict(
name = "entity",
type = "ir_entity*",
comment = "entity representing this block",
init = "NULL",
),
]
customSerializer = True
init = '''
......
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