- arch_register_t *reg;
-
- for (reg = pset_first(abi->ignore_regs); reg; reg = pset_next(abi->ignore_regs))
- if (reg->reg_class == cls)
- bitset_set(bs, reg->index);
-}
-
-void be_abi_set_non_ignore_regs(be_abi_irg_t *abi, const arch_register_class_t *cls, unsigned *raw_bitset)
-{
- unsigned i;
- arch_register_t *reg;
-
- for (i = 0; i < cls->n_regs; ++i) {
- if (arch_register_type_is(&cls->regs[i], ignore))
- continue;
-
- rbitset_set(raw_bitset, i);
- }
-
- for (reg = pset_first(abi->ignore_regs); reg != NULL;
- reg = pset_next(abi->ignore_regs)) {
- if (reg->reg_class != cls)
- continue;
-
- rbitset_clear(raw_bitset, reg->index);
- }
-}
-
-/*
- _____ _ ____ _ _
- | ___(_)_ __ / ___|| |_ __ _ ___| | __
- | |_ | \ \/ / \___ \| __/ _` |/ __| |/ /
- | _| | |> < ___) | || (_| | (__| <
- |_| |_/_/\_\ |____/ \__\__,_|\___|_|\_\
-
-*/
-
-typedef ir_node **node_array;
-
-typedef struct fix_stack_walker_env_t {
- node_array sp_nodes;
-} fix_stack_walker_env_t;
-
-/**
- * Walker. Collect all stack modifying nodes.
- */
-static void collect_stack_nodes_walker(ir_node *node, void *data)
-{
- ir_node *insn = node;
- fix_stack_walker_env_t *env = data;
- const arch_register_req_t *req;
-
- if (is_Proj(node)) {
- insn = get_Proj_pred(node);
- }
-
- if (arch_irn_get_n_outs(insn) == 0)
- return;
- if (get_irn_mode(node) == mode_T)
- return;
-
- req = arch_get_register_req_out(node);
- if (! (req->type & arch_register_req_type_produces_sp))
- return;
-
- ARR_APP1(ir_node*, env->sp_nodes, node);
-}
-
-void be_abi_fix_stack_nodes(be_abi_irg_t *env)
-{
- be_ssa_construction_env_t senv;
- int i, len;
- ir_node **phis;
- ir_graph *irg = env->irg;
- be_lv_t *lv = be_get_irg_liveness(irg);
- fix_stack_walker_env_t walker_env;
-
- walker_env.sp_nodes = NEW_ARR_F(ir_node*, 0);
-
- irg_walk_graph(irg, collect_stack_nodes_walker, NULL, &walker_env);
-
- /* nothing to be done if we didn't find any node, in fact we mustn't
- * continue, as for endless loops incsp might have had no users and is bad
- * now.
- */
- len = ARR_LEN(walker_env.sp_nodes);
- if (len == 0) {
- DEL_ARR_F(walker_env.sp_nodes);
- return;
- }
-
- be_ssa_construction_init(&senv, irg);
- be_ssa_construction_add_copies(&senv, walker_env.sp_nodes,
- ARR_LEN(walker_env.sp_nodes));
- be_ssa_construction_fix_users_array(&senv, walker_env.sp_nodes,
- ARR_LEN(walker_env.sp_nodes));
-
- if (lv != NULL) {
- len = ARR_LEN(walker_env.sp_nodes);
- for (i = 0; i < len; ++i) {
- be_liveness_update(lv, walker_env.sp_nodes[i]);
- }
- be_ssa_construction_update_liveness_phis(&senv, lv);
- }
-
- phis = be_ssa_construction_get_new_phis(&senv);