Commit 5d0dc805 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

cleanup: Remove several uses of current_ir_graph.

parent 8b9cffd1
......@@ -618,7 +618,6 @@ static void cfscc(ir_node *n)
int construct_cf_backedges(ir_graph *irg)
{
ir_graph *rem = current_ir_graph;
ir_loop *head_rem;
ir_node *end = get_irg_end(irg);
struct obstack temp;
......@@ -626,7 +625,6 @@ int construct_cf_backedges(ir_graph *irg)
max_loop_depth = 0;
current_ir_graph = irg;
outermost_ir_graph = irg;
obstack_init(&temp);
......@@ -653,7 +651,6 @@ int construct_cf_backedges(ir_graph *irg)
set_irg_loop(irg, current_loop);
add_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO);
current_ir_graph = rem;
return max_loop_depth;
}
......
......@@ -470,12 +470,10 @@ static ir_node *gen_Proj_Load(ir_node *node)
*/
static ir_node *gen_Proj(ir_node *node)
{
ir_graph *irg = current_ir_graph;
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *pred = get_Proj_pred(node);
long proj = get_Proj_proj(node);
(void) irg;
(void) dbgi;
if (is_Store(pred)) {
......@@ -498,6 +496,7 @@ static ir_node *gen_Proj(ir_node *node)
#endif
} else if (is_Start(pred)) {
#if 0
ir_graph *const irg = get_irn_irg(node);
if (node == get_irg_anchor(irg, anchor_tls)) {
return gen_Proj_tls(node);
}
......
......@@ -1158,7 +1158,7 @@ static ir_node *ints_to_double(dbg_info *dbgi, ir_node *block, ir_node *node0,
/* the good way to do this would be to use the stm (store multiple)
* instructions, since our input is nearly always 2 consecutive 32bit
* registers... */
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
ir_node *stack = get_irg_frame(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *str0 = new_bd_arm_Str(dbgi, block, stack, node0, nomem, mode_gp,
......@@ -1179,7 +1179,7 @@ static ir_node *ints_to_double(dbg_info *dbgi, ir_node *block, ir_node *node0,
static ir_node *int_to_float(dbg_info *dbgi, ir_node *block, ir_node *node)
{
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
ir_node *stack = get_irg_frame(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *str = new_bd_arm_Str(dbgi, block, stack, node, nomem, mode_gp,
......@@ -1195,7 +1195,7 @@ static ir_node *int_to_float(dbg_info *dbgi, ir_node *block, ir_node *node)
static ir_node *float_to_int(dbg_info *dbgi, ir_node *block, ir_node *node)
{
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
ir_node *stack = get_irg_frame(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *stf = new_bd_arm_Stf(dbgi, block, stack, node, nomem, mode_F,
......@@ -1212,7 +1212,7 @@ static ir_node *float_to_int(dbg_info *dbgi, ir_node *block, ir_node *node)
static void double_to_ints(dbg_info *dbgi, ir_node *block, ir_node *node,
ir_node **out_value0, ir_node **out_value1)
{
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
ir_node *stack = get_irg_frame(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *stf = new_bd_arm_Stf(dbgi, block, stack, node, nomem, mode_D,
......@@ -1426,7 +1426,8 @@ static ir_node *gen_Proj_Proj_Start(ir_node *node)
long pn = get_Proj_proj(node);
ir_node *block = get_nodes_block(node);
ir_node *new_block = be_transform_node(block);
ir_entity *entity = get_irg_entity(current_ir_graph);
ir_graph *irg = get_Block_irg(new_block);
ir_entity *entity = get_irg_entity(irg);
ir_type *method_type = get_entity_type(entity);
ir_type *param_type = get_method_param_type(method_type, pn);
const reg_or_stackslot_t *param;
......@@ -1447,12 +1448,9 @@ static ir_node *gen_Proj_Proj_Start(ir_node *node)
if (param->reg1 != NULL) {
value1 = be_prolog_get_reg_value(abihelper, param->reg1);
} else if (param->entity != NULL) {
ir_graph *irg = get_irn_irg(node);
ir_node *fp = get_irg_frame(irg);
ir_node *mem = be_prolog_get_memory(abihelper);
ir_node *ldr = new_bd_arm_Ldr(NULL, new_block, fp, mem,
mode_gp, param->entity,
0, 0, true);
ir_node *const fp = get_irg_frame(irg);
ir_node *const mem = be_prolog_get_memory(abihelper);
ir_node *const ldr = new_bd_arm_Ldr(NULL, new_block, fp, mem, mode_gp, param->entity, 0, 0, true);
value1 = new_r_Proj(ldr, mode_gp, pn_arm_Ldr_res);
}
......@@ -1466,12 +1464,11 @@ static ir_node *gen_Proj_Proj_Start(ir_node *node)
return value;
} else {
/* argument transmitted on stack */
ir_graph *irg = get_irn_irg(node);
ir_node *fp = get_irg_frame(irg);
ir_node *mem = be_prolog_get_memory(abihelper);
ir_mode *mode = get_type_mode(param->type);
ir_node *load;
ir_node *value;
ir_node *const fp = get_irg_frame(irg);
ir_node *const mem = be_prolog_get_memory(abihelper);
ir_mode *const mode = get_type_mode(param->type);
ir_node *load;
ir_node *value;
if (mode_is_float(mode)) {
load = new_bd_arm_Ldf(NULL, new_block, fp, mem, mode,
......
......@@ -128,7 +128,7 @@ static void lower_outer_frame_sels(ir_node *sel, void *ctx)
dbg_info *dbgi = get_irn_dbg_info(sel);
ir_mode *mode = get_irn_mode(sel);
ir_mode *mode_UInt = get_reference_mode_unsigned_eq(mode);
ir_node *cnst = new_r_Const_long(current_ir_graph, mode_UInt, offset);
ir_node *cnst = new_r_Const_long(irg, mode_UInt, offset);
ptr = new_rd_Add(dbgi, bl, ptr, cnst, mode);
}
......
......@@ -90,7 +90,7 @@ void be_duplicate_deps(ir_node *old_node, ir_node *new_node)
ir_node *be_transform_phi(ir_node *node, const arch_register_req_t *req)
{
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
dbg_info *dbgi = get_irn_dbg_info(node);
/* phi nodes allow loops, so we use the old arguments for now
......
......@@ -585,7 +585,7 @@ ir_node *ia32_turn_back_am(ir_node *node)
default:
panic("Unknown AM type");
}
noreg = ia32_new_NoReg_gp(current_ir_graph);
noreg = ia32_new_NoReg_gp(irg);
set_irn_n(node, n_ia32_base, noreg);
set_irn_n(node, n_ia32_index, noreg);
set_ia32_am_offs_int(node, 0);
......
......@@ -1515,7 +1515,7 @@ static void ia32_emit_node(ir_node *node)
(*func) (node);
} else {
emit_Nothing(node);
ir_fprintf(stderr, "Error: No emit handler for node %+F (%+G, graph %+F)\n", node, node, current_ir_graph);
ir_fprintf(stderr, "Error: No emit handler for node %+F (%+G, graph %+F)\n", node, node, get_irn_irg(node));
abort();
}
......@@ -1597,9 +1597,7 @@ static int should_align_block(const ir_node *block)
*/
static void ia32_emit_block_header(ir_node *block)
{
ir_graph *irg = current_ir_graph;
int need_label = block_needs_label(block);
ir_graph *const irg = get_Block_irg(block);
if (block == get_irg_end_block(irg))
return;
......@@ -1629,6 +1627,7 @@ static void ia32_emit_block_header(ir_node *block)
}
}
int const need_label = block_needs_label(block);
be_gas_begin_block(block, need_label);
}
......
......@@ -166,10 +166,10 @@ static void peephole_ia32_Cmp(ir_node *const node)
return;
dbgi = get_irn_dbg_info(node);
irg = get_irn_irg(node);
block = get_nodes_block(node);
irg = get_Block_irg(block);
noreg = ia32_new_NoReg_gp(irg);
nomem = get_irg_no_mem(current_ir_graph);
nomem = get_irg_no_mem(irg);
op = get_irn_n(node, n_ia32_Cmp_left);
attr = get_ia32_attr(node);
ins_permuted = attr->data.ins_permuted;
......@@ -647,7 +647,7 @@ static void peephole_store_incsp(ir_node *store)
push = new_bd_ia32_Push(dbgi, block, noreg, noreg, mem,
create_push(dbgi, current_ir_graph, block, am_base, store);
create_push(dbgi, block, am_base, store);
}
#endif
......
......@@ -3967,15 +3967,15 @@ static ir_node *gen_be_FrameAddr(ir_node *node)
*/
static ir_node *gen_be_Return(ir_node *node)
{
ir_graph *irg = current_ir_graph;
ir_node *ret_val = get_irn_n(node, n_be_Return_val);
ir_node *ret_mem = get_irn_n(node, n_be_Return_mem);
ir_node *new_ret_val = be_transform_node(ret_val);
ir_node *new_ret_mem = be_transform_node(ret_mem);
ir_entity *ent = get_irg_entity(irg);
ir_type *tp = get_entity_type(ent);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *block = be_transform_node(get_nodes_block(node));
ir_graph *irg = get_Block_irg(block);
ir_entity *ent = get_irg_entity(irg);
ir_type *tp = get_entity_type(ent);
ir_type *res_type;
ir_mode *mode;
ir_node *frame;
......@@ -4223,7 +4223,7 @@ static ir_node *gen_ia32_l_LLtoFloat(ir_node *node)
{
ir_node *src_block = get_nodes_block(node);
ir_node *block = be_transform_node(src_block);
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
dbg_info *dbgi = get_irn_dbg_info(node);
ir_node *frame = get_irg_frame(irg);
ir_node *val_low = get_irn_n(node, n_ia32_l_LLtoFloat_val_low);
......@@ -4295,7 +4295,7 @@ static ir_node *gen_ia32_l_LLtoFloat(ir_node *node)
am.mem_proj = nomem;
am.op_type = ia32_AddrModeS;
am.new_op1 = res;
am.new_op2 = ia32_new_NoReg_fp(current_ir_graph);
am.new_op2 = ia32_new_NoReg_fp(irg);
am.pinned = op_pin_state_floats;
am.commutative = 1;
am.ins_permuted = false;
......@@ -4717,7 +4717,7 @@ static ir_node *gen_be_Call(ir_node *node)
ir_mode *const res_mode = get_type_mode(res_type);
if (res_mode != NULL && mode_is_float(res_mode)) {
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
ia32_irg_data_t *irg_data = ia32_get_irg_data(irg);
irg_data->do_x87_sim = 1;
}
......@@ -5703,7 +5703,7 @@ static void register_transformers(void)
static void ia32_pretransform_node(void)
{
ir_graph *irg = current_ir_graph;
ia32_irg_data_t *irg_data = ia32_get_irg_data(current_ir_graph);
ia32_irg_data_t *irg_data = ia32_get_irg_data(irg);
irg_data->noreg_gp = be_pre_transform_node(irg_data->noreg_gp);
irg_data->noreg_fp = be_pre_transform_node(irg_data->noreg_fp);
......
......@@ -1014,9 +1014,9 @@ static ir_node *gen_Minus(ir_node *node)
/**
* Create an entity for a given (floating point) tarval
*/
static ir_entity *create_float_const_entity(ir_tarval *tv)
static ir_entity *create_float_const_entity(ir_graph *const irg, ir_tarval *const tv)
{
const arch_env_t *arch_env = be_get_irg_arch_env(current_ir_graph);
const arch_env_t *arch_env = be_get_irg_arch_env(irg);
sparc_isa_t *isa = (sparc_isa_t*) arch_env;
ir_entity *entity = pmap_get(ir_entity, isa->constants, tv);
ir_initializer_t *initializer;
......@@ -1043,9 +1043,10 @@ static ir_entity *create_float_const_entity(ir_tarval *tv)
static ir_node *gen_float_const(dbg_info *dbgi, ir_node *block, ir_tarval *tv)
{
ir_entity *entity = create_float_const_entity(tv);
ir_graph *irg = get_Block_irg(block);
ir_entity *entity = create_float_const_entity(irg, tv);
ir_node *hi = new_bd_sparc_SetHi(dbgi, block, entity, 0);
ir_node *mem = get_irg_no_mem(current_ir_graph);
ir_node *mem = get_irg_no_mem(irg);
ir_mode *mode = get_tarval_mode(tv);
ir_node *new_op
= create_ldf(dbgi, block, hi, mem, mode, entity, 0, false);
......@@ -1121,7 +1122,7 @@ static ir_node *gen_Switch(ir_node *node)
idx = new_bd_sparc_Sll_imm(dbgi, new_block, new_selector, NULL, 2);
/* load from jumptable */
load = new_bd_sparc_Ld_reg(dbgi, new_block, table_address, idx,
get_irg_no_mem(current_ir_graph),
get_irg_no_mem(irg),
mode_gp);
address = new_r_Proj(load, mode_gp, pn_sparc_Ld_res);
......@@ -1602,7 +1603,7 @@ static ir_node *gen_Return(ir_node *node)
static ir_node *bitcast_int_to_float(dbg_info *dbgi, ir_node *block,
ir_node *value0, ir_node *value1)
{
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
ir_node *sp = get_irg_frame(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *st = new_bd_sparc_St_imm(dbgi, block, value0, sp, nomem,
......@@ -1657,7 +1658,7 @@ static void bitcast_float_to_int(dbg_info *dbgi, ir_node *block,
result[1] = NULL;
}
} else {
ir_graph *irg = current_ir_graph;
ir_graph *irg = get_Block_irg(block);
ir_node *stack = get_irg_frame(irg);
ir_node *nomem = get_irg_no_mem(irg);
ir_node *new_value = be_transform_node(value);
......
......@@ -39,8 +39,9 @@ static void (*ssa_cons_walker)(ir_graph *, irg_walk_func *, irg_walk_func *, voi
*/
static void prepare_blocks(ir_node *block, void *env)
{
unsigned n_loc = current_ir_graph->n_loc;
struct obstack *obst = current_ir_graph->obst;
ir_graph *const irg = get_Block_irg(block);
unsigned const n_loc = irg->n_loc;
struct obstack *const obst = irg->obst;
(void)env;
/* reset mature flag */
set_Block_matured(block, 0);
......
......@@ -111,7 +111,6 @@ static void lower_sel(ir_node *sel)
lb = get_array_lower_bound(arr_ty, dim);
ub = get_array_upper_bound(arr_ty, dim);
assert(irg == current_ir_graph);
if (! is_Unknown(lb))
lb = new_rd_Conv(dbg, bl, copy_const_value(get_irn_dbg_info(sel), lb, bl), mode_Int);
else
......
......@@ -259,7 +259,8 @@ int i_mapper_bswap(ir_node *call, void *ctx)
ir_node *irn;
(void) ctx;
irn = new_rd_Builtin(dbg, block, get_irg_no_mem(current_ir_graph), 1, &op, ir_bk_bswap, tp);
ir_graph *const irg = get_Block_irg(block);
irn = new_rd_Builtin(dbg, block, get_irg_no_mem(irg), 1, &op, ir_bk_bswap, tp);
set_irn_pinned(irn, op_pin_state_floats);
irn = new_r_Proj(irn, get_irn_mode(op), pn_Builtin_max+1);
replace_call(irn, call, mem, NULL, NULL);
......@@ -1110,11 +1111,10 @@ int i_mapper_RuntimeCall(ir_node *node, runtime_rt *rt)
int i, j, arity, first, n_param, n_res;
long n_proj;
ir_type *mtp;
ir_node *mem, *bl, *call, *addr, *res_proj;
ir_node *mem, *call, *addr, *res_proj;
ir_node **in;
bool throws_exception;
ir_op *op;
ir_graph *irg;
symconst_symbol sym;
ir_mode *mode = get_irn_mode(node);
......@@ -1133,7 +1133,8 @@ int i_mapper_RuntimeCall(ir_node *node, runtime_rt *rt)
mtp = get_entity_type(rt->ent);
n_param = get_method_n_params(mtp);
irg = current_ir_graph;
ir_node *const bl = get_nodes_block(node);
ir_graph *const irg = get_Block_irg(bl);
mem = get_irn_n(node, 0);
if (get_irn_mode(mem) != mode_M) {
......@@ -1177,7 +1178,6 @@ int i_mapper_RuntimeCall(ir_node *node, runtime_rt *rt)
}
/* ok, when we are here, the number of predecessors match as well as the parameter modes */
bl = get_nodes_block(node);
op = get_irn_op(node);
in = NULL;
......
......@@ -1915,7 +1915,8 @@ static void compute_Block(node_t *node)
int i;
ir_node *block = node->node;
if (block == get_irg_start_block(current_ir_graph) || get_Block_entity(block) != NULL) {
ir_graph *const irg = get_Block_irg(block);
if (block == get_irg_start_block(irg) || get_Block_entity(block) != NULL) {
/* start block and labelled blocks are always reachable */
node->type.tv = tarval_reachable;
return;
......@@ -3041,7 +3042,8 @@ static void apply_cf(ir_node *block, void *ctx)
}
}
if (block == get_irg_end_block(current_ir_graph)) {
ir_graph *const irg = get_Block_irg(block);
if (block == get_irg_end_block(irg)) {
/* Analysis found out that the end block is unreachable,
* hence we remove all its control flow predecessors. */
set_irn_in(block, 0, NULL);
......
......@@ -672,12 +672,11 @@ static void copy_walk(ir_node *node, walker_condition *walk_condition,
int arity;
ir_node *cp;
ir_node **cpin;
ir_graph *irg = current_ir_graph;
/**
* break condition and cycle resolver, creating temporary node copies
*/
if (get_irn_visited(node) >= get_irg_visited(irg)) {
if (irn_visited(node)) {
/* Here we rely on nodestate's copy being initialized with NULL */
DB((dbg, LEVEL_5, "copy_walk: We have already visited %N\n", node));
if (get_inversion_copy(node) == NULL) {
......
......@@ -267,10 +267,11 @@ static void set_preds(ir_node *irn, void *env)
irn_copy = (ir_node*)get_irn_link(irn);
if (is_Block(irn)) {
ir_graph *const irg = get_Block_irg(irn);
for (i = get_Block_n_cfgpreds(irn) - 1; i >= 0; --i) {
pred = get_Block_cfgpred(irn, i);
/* "End" block must be handled extra, because it is not matured.*/
if (get_irg_end_block(current_ir_graph) == irn)
if (get_irg_end_block(irg) == irn)
add_immBlock_pred(get_irg_end_block(clone_irg), (ir_node*)get_irn_link(pred));
else
set_Block_cfgpred(irn_copy, i, (ir_node*)get_irn_link(pred));
......
......@@ -146,10 +146,9 @@ static void find_dag_roots(ir_node *node, void *env)
block = get_nodes_block(node);
/* ignore start end end blocks */
if (block == get_irg_start_block(current_ir_graph) ||
block == get_irg_end_block(current_ir_graph)) {
ir_graph *const irg = get_Block_irg(block);
if (block == get_irg_start_block(irg) || block == get_irg_end_block(irg))
return;
} /* if */
/* Phi nodes always references nodes from "other" block */
if (is_Phi(node)) {
......@@ -222,10 +221,9 @@ static void connect_dags(ir_node *node, void *env)
block = get_nodes_block(node);
/* ignore start end end blocks */
if (block == get_irg_start_block(current_ir_graph) ||
block == get_irg_end_block(current_ir_graph)) {
ir_graph *const irg = get_Block_irg(block);
if (block == get_irg_start_block(irg) || block == get_irg_end_block(irg))
return;
} /* if */
/* ignore Phi nodes */
if (is_Phi(node))
......
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