Commit 0ada12ba authored by Christoph Mallon's avatar Christoph Mallon
Browse files

irgraph: Use get_irg_obstack() instead of accessing irg->obst directly.

parent 64252961
......@@ -215,7 +215,7 @@ static void ana_Call(ir_node *n, void *env)
ARR_APP1(ir_node *, arr, n);
found->call_list = arr;
} else { /* New node, add Call node and init nesting. */
found = OALLOC(irg->obst, cg_callee_entry);
found = OALLOC(get_irg_obstack(irg), cg_callee_entry);
found->irg = callee;
found->call_list = NEW_ARR_F(ir_node *, 1);
found->call_list[0] = n;
......@@ -571,7 +571,7 @@ static inline void pop_scc_unmark_visit(ir_graph *n)
static ir_loop *new_loop(void)
{
ir_loop *father = current_loop;
ir_loop *son = alloc_loop(father, outermost_ir_graph->obst);
ir_loop *son = alloc_loop(father, get_irg_obstack(outermost_ir_graph));
current_loop = son;
return father;
......@@ -889,7 +889,7 @@ void find_callgraph_recursions(void)
obstack_free(&temp, NULL);
irp->outermost_cg_loop = current_loop;
mature_loops(current_loop, outermost_ir_graph->obst);
mature_loops(current_loop, get_irg_obstack(outermost_ir_graph));
/* -- Reverse the backedge information. -- */
for (i = 0; i < n_irgs; ++i) {
......
......@@ -268,7 +268,7 @@ static inline void pop_scc_unmark_visit(ir_node *n)
static ir_loop *new_loop(void)
{
ir_loop *father = current_loop;
ir_loop *son = alloc_loop(father, outermost_ir_graph->obst);
ir_loop *son = alloc_loop(father, get_irg_obstack(outermost_ir_graph));
if (son->depth > max_loop_depth) max_loop_depth = son->depth;
current_loop = son;
......@@ -647,7 +647,7 @@ int construct_cf_backedges(ir_graph *irg)
obstack_free(&temp, NULL);
assert(head_rem == current_loop);
mature_loops(current_loop, irg->obst);
mature_loops(current_loop, get_irg_obstack(irg));
set_irg_loop(irg, current_loop);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
......
......@@ -318,7 +318,7 @@ static inline void pop_scc_unmark_visit(ir_node *n)
static ir_loop *new_loop(void)
{
ir_loop *father = current_loop;
ir_loop *son = alloc_loop(father, outermost_ir_graph->obst);
ir_loop *son = alloc_loop(father, get_irg_obstack(outermost_ir_graph));
if (son->depth > max_loop_depth) max_loop_depth = son->depth;
current_loop = son;
......@@ -772,7 +772,7 @@ int construct_backedges(ir_graph *irg)
obstack_free(&temp, NULL);
assert(head_rem == current_loop);
mature_loops(current_loop, irg->obst);
mature_loops(current_loop, get_irg_obstack(irg));
set_irg_loop(irg, current_loop);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
assert(get_irg_loop(irg)->kind == k_ir_loop);
......
......@@ -400,8 +400,8 @@ ir_node *be_new_MemPerm(ir_node *block, int n, ir_node *in[])
be_node_set_reg_class_in(irn, 0, sp->reg_class);
attr = (be_memperm_attr_t*)get_irn_generic_attr(irn);
attr->in_entities = OALLOCNZ(irg->obst, ir_entity*, n);
attr->out_entities = OALLOCNZ(irg->obst, ir_entity*, n);
attr->in_entities = OALLOCNZ(get_irg_obstack(irg), ir_entity*, n);
attr->out_entities = OALLOCNZ(get_irg_obstack(irg), ir_entity*, n);
return irn;
}
......@@ -1045,7 +1045,7 @@ ir_node *be_new_Phi(ir_node *block, int n_ins, ir_node **ins, ir_mode *mode,
int i;
ir_node *phi = new_ir_node(NULL, irg, block, op_Phi, mode, n_ins, ins);
phi->attr.phi.u.backedge = new_backedge_arr(irg->obst, n_ins);
phi->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), n_ins);
info = be_get_info(phi);
info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1);
memset(info->out_infos, 0, 1 * sizeof(info->out_infos[0]));
......
......@@ -71,13 +71,12 @@ ir_node *new_rd_ASM(dbg_info *db, ir_node *block, ir_node *mem,
ir_node *res = new_ir_node(db, irg, block, op_ASM, mode_T, r_arity, r_in);
res->attr.assem.pin_state = op_pin_state_pinned;
res->attr.assem.input_constraints
= NEW_ARR_D(ir_asm_constraint, irg->obst, arity);
res->attr.assem.output_constraints
= NEW_ARR_D(ir_asm_constraint, irg->obst, n_outs);
res->attr.assem.clobbers = NEW_ARR_D(ident *, irg->obst, n_clobber);
res->attr.assem.text = text;
struct obstack *const obst = get_irg_obstack(irg);
res->attr.assem.pin_state = op_pin_state_pinned;
res->attr.assem.input_constraints = NEW_ARR_D(ir_asm_constraint, obst, arity);
res->attr.assem.output_constraints = NEW_ARR_D(ir_asm_constraint, obst, n_outs);
res->attr.assem.clobbers = NEW_ARR_D(ident*, obst, n_clobber);
res->attr.assem.text = text;
memcpy(res->attr.assem.input_constraints, inputs, sizeof(inputs[0]) * arity);
memcpy(res->attr.assem.output_constraints, outputs, sizeof(outputs[0]) * n_outs);
......@@ -235,7 +234,7 @@ static ir_node *set_phi_arguments(ir_node *phi, int pos)
in[i] = value;
}
phi->attr.phi.u.backedge = new_backedge_arr(irg->obst, arity);
phi->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), arity);
set_irn_in(phi, arity, in);
irn_verify_irg(phi, irg);
......@@ -322,7 +321,7 @@ void mature_immBlock(ir_node *block)
irg = get_irn_irg(block);
n_preds = ARR_LEN(block->in) - 1;
/* Fix block parameters */
block->attr.block.backedge = new_backedge_arr(irg->obst, n_preds);
block->attr.block.backedge = new_backedge_arr(get_irg_obstack(irg), n_preds);
/* Traverse a chain of Phi nodes attached to this block and mature
these, too. */
......@@ -341,7 +340,7 @@ void mature_immBlock(ir_node *block)
/* create final in-array for the block */
if (block->attr.block.dynamic_ins) {
new_in = NEW_ARR_D(ir_node*, irg->obst, n_preds+1);
new_in = NEW_ARR_D(ir_node*, get_irg_obstack(irg), n_preds + 1);
memcpy(new_in, block->in, (n_preds+1) * sizeof(new_in[0]));
DEL_ARR_F(block->in);
block->in = new_in;
......@@ -445,7 +444,7 @@ ir_node *new_rd_immBlock(dbg_info *dbgi, ir_graph *irg)
set_Block_block_visited(res, 0);
/* Create and initialize array for Phi-node construction. */
res->attr.block.graph_arr = NEW_ARR_D(ir_node *, irg->obst, irg->n_loc);
res->attr.block.graph_arr = NEW_ARR_D(ir_node*, get_irg_obstack(irg), irg->n_loc);
memset(res->attr.block.graph_arr, 0, sizeof(ir_node*) * irg->n_loc);
/* Immature block may not be optimized! */
......@@ -715,11 +714,11 @@ ir_node *new_r_Block_noopt(ir_graph *irg, int arity, ir_node *in[])
{
ir_node *res = new_ir_node(NULL, irg, NULL, op_Block, mode_BB, arity, in);
res->attr.block.irg.irg = irg;
res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
res->attr.block.backedge = new_backedge_arr(get_irg_obstack(irg), arity);
set_Block_matured(res, 1);
/* Create and initialize array for Phi-node construction. */
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_CONSTRUCTION)) {
res->attr.block.graph_arr = NEW_ARR_D(ir_node *, irg->obst, irg->n_loc);
res->attr.block.graph_arr = NEW_ARR_D(ir_node*, get_irg_obstack(irg), irg->n_loc);
memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
}
irn_verify_irg(res, irg);
......
......@@ -96,7 +96,7 @@ void exchange(ir_node *old, ir_node *nw)
}
old->op = op_Id;
old->in = NEW_ARR_D (ir_node *, irg->obst, 2);
old->in = NEW_ARR_D(ir_node*, get_irg_obstack(irg), 2);
old->in[0] = block;
old->in[1] = nw;
}
......
......@@ -105,7 +105,7 @@ ir_node *new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op,
assert(mode);
size_t const node_size = offsetof(ir_node, attr) + op->attr_size;
ir_node *const res = (ir_node*)OALLOCNZ(irg->obst, char, node_size);
ir_node *const res = (ir_node*)OALLOCNZ(get_irg_obstack(irg), char, node_size);
res->kind = k_ir_node;
res->op = op;
......@@ -122,7 +122,7 @@ ir_node *new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op,
if (op == op_End || op == op_Sync)
res->in = NEW_ARR_F(ir_node *, (arity+1));
else
res->in = NEW_ARR_D(ir_node *, irg->obst, (arity+1));
res->in = NEW_ARR_D(ir_node*, get_irg_obstack(irg), arity + 1);
memcpy(&res->in[1], in, sizeof(ir_node *) * arity);
}
......@@ -194,10 +194,10 @@ void set_irn_in(ir_node *node, int arity, ir_node **in)
if (arity != (int)ARR_LEN(*pOld_in) - 1) {
ir_node * block = (*pOld_in)[0];
*pOld_in = NEW_ARR_D(ir_node *, irg->obst, arity + 1);
*pOld_in = NEW_ARR_D(ir_node*, get_irg_obstack(irg), arity + 1);
(*pOld_in)[0] = block;
}
fix_backedges(irg->obst, node);
fix_backedges(get_irg_obstack(irg), node);
memcpy((*pOld_in) + 1, in, sizeof(ir_node *) * arity);
......@@ -935,11 +935,10 @@ ir_entity *get_Call_callee(const ir_node *node, size_t pos)
void set_Call_callee_arr(ir_node *node, size_t n, ir_entity ** arr)
{
ir_graph *irg = get_irn_irg(node);
assert(is_Call(node));
if (node->attr.call.callee_arr == NULL || get_Call_n_callees(node) != n) {
node->attr.call.callee_arr = NEW_ARR_D(ir_entity *, irg->obst, n);
ir_graph *const irg = get_irn_irg(node);
node->attr.call.callee_arr = NEW_ARR_D(ir_entity*, get_irg_obstack(irg), n);
}
memcpy(node->attr.call.callee_arr, arr, n * sizeof(ir_entity *));
}
......
......@@ -527,7 +527,7 @@ static void block_copy_attr(ir_graph *irg, const ir_node *old_node,
default_copy_attr(irg, old_node, new_node);
new_node->attr.block.irg.irg = irg;
new_node->attr.block.phis = NULL;
new_node->attr.block.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node));
new_node->attr.block.backedge = new_backedge_arr(get_irg_obstack(irg), get_irn_arity(new_node));
new_node->attr.block.block_visited = 0;
memset(&new_node->attr.block.dom, 0, sizeof(new_node->attr.block.dom));
memset(&new_node->attr.block.pdom, 0, sizeof(new_node->attr.block.pdom));
......@@ -546,7 +546,7 @@ static void phi_copy_attr(ir_graph *irg, const ir_node *old_node,
{
default_copy_attr(irg, old_node, new_node);
new_node->attr.phi.next = NULL;
new_node->attr.phi.u.backedge = new_backedge_arr(irg->obst, get_irn_arity(new_node));
new_node->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), get_irn_arity(new_node));
}
/**
......@@ -556,9 +556,10 @@ static void ASM_copy_attr(ir_graph *irg, const ir_node *old_node,
ir_node *new_node)
{
default_copy_attr(irg, old_node, new_node);
new_node->attr.assem.input_constraints = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.input_constraints);
new_node->attr.assem.output_constraints = DUP_ARR_D(ir_asm_constraint, irg->obst, old_node->attr.assem.output_constraints);
new_node->attr.assem.clobbers = DUP_ARR_D(ident*, irg->obst, old_node->attr.assem.clobbers);
struct obstack *const obst = get_irg_obstack(irg);
new_node->attr.assem.input_constraints = DUP_ARR_D(ir_asm_constraint, obst, old_node->attr.assem.input_constraints);
new_node->attr.assem.output_constraints = DUP_ARR_D(ir_asm_constraint, obst, old_node->attr.assem.output_constraints);
new_node->attr.assem.clobbers = DUP_ARR_D(ident*, obst, old_node->attr.assem.clobbers);
}
static void switch_copy_attr(ir_graph *irg, const ir_node *old_node,
......
......@@ -39,13 +39,12 @@ static void (*ssa_cons_walker)(ir_graph *, irg_walk_func *, irg_walk_func *, voi
*/
static void prepare_blocks(ir_node *block, void *env)
{
ir_graph *const irg = get_Block_irg(block);
unsigned const n_loc = irg->n_loc;
struct obstack *const obst = irg->obst;
ir_graph *const irg = get_Block_irg(block);
unsigned const n_loc = irg->n_loc;
(void)env;
/* reset mature flag */
set_Block_matured(block, 0);
block->attr.block.graph_arr = NEW_ARR_D(ir_node *, obst, n_loc);
block->attr.block.graph_arr = NEW_ARR_D(ir_node*, get_irg_obstack(irg), n_loc);
memset(block->attr.block.graph_arr, 0, sizeof(ir_node*) * n_loc);
set_Block_phis(block, NULL);
}
......
......@@ -707,8 +707,9 @@ void inline_small_irgs(ir_graph *irg, int size)
if (props & mtp_property_noinline)
continue;
struct obstack *const obst = get_irg_obstack(callee);
if ((props & mtp_property_always_inline) ||
_obstack_memory_used(callee->obst) - (int)obstack_room(callee->obst) < size) {
_obstack_memory_used(obst) - (int)obstack_room(obst) < size) {
inline_method(entry->call, callee);
}
}
......
......@@ -229,12 +229,12 @@ class Block:
init = '''
res->attr.block.irg.irg = irg;
res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
res->attr.block.backedge = new_backedge_arr(get_irg_obstack(irg), arity);
set_Block_matured(res, 1);
/* Create and initialize array for Phi-node construction. */
if (irg_is_constrained(irg, IR_GRAPH_CONSTRAINT_CONSTRUCTION)) {
res->attr.block.graph_arr = NEW_ARR_D(ir_node *, irg->obst, irg->n_loc);
res->attr.block.graph_arr = NEW_ARR_D(ir_node *, get_irg_obstack(irg), irg->n_loc);
memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
}
'''
......@@ -776,7 +776,7 @@ class Phi:
flags = []
attr_struct = "phi_attr"
init = '''
res->attr.phi.u.backedge = new_backedge_arr(irg->obst, arity);'''
res->attr.phi.u.backedge = new_backedge_arr(get_irg_obstack(irg), arity);'''
customSerializer = True
@op
......
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