X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbepeephole.h;h=757fe4b64a6e44f6fa746c1bbb5daa1e9014ec3f;hb=9c456297552bb20d04e2fe76fd4a712afa8aa63f;hp=496634d51fc0a6d4d0c6c147a9dd81f1dc14aaf4;hpb=bce5f15071a9be1f7cdc5e66436dd54cb29900df;p=libfirm diff --git a/ir/be/bepeephole.h b/ir/be/bepeephole.h index 496634d51..757fe4b64 100644 --- a/ir/be/bepeephole.h +++ b/ir/be/bepeephole.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * * This file is part of libFirm. * @@ -21,29 +21,23 @@ * @file * @brief peephole optimisation framework * @author Matthias Braun - * @version $Id$ */ - #ifndef BEPEEPHOLE_H #define BEPEEPHOLE_H -#include "beirg.h" -#include "bearch_t.h" +#include "bearch.h" -extern ir_node ***register_values; +extern ir_node **register_values; -static INLINE ir_node *be_peephole_get_value(unsigned regclass_idx, - unsigned register_idx) +static inline ir_node *be_peephole_get_value(unsigned register_idx) { - return register_values[regclass_idx][register_idx]; + return register_values[register_idx]; } -static INLINE ir_node *be_peephole_get_reg_value(const arch_register_t *reg) +static inline ir_node *be_peephole_get_reg_value(const arch_register_t *reg) { - unsigned regclass_idx = arch_register_class_index(arch_register_get_class(reg)); - unsigned register_idx = arch_register_get_index(reg); - - return be_peephole_get_value(regclass_idx, register_idx); + unsigned register_idx = reg->global_index; + return be_peephole_get_value(register_idx); } /** @@ -52,25 +46,53 @@ static INLINE ir_node *be_peephole_get_reg_value(const arch_register_t *reg) typedef void (*peephole_opt_func) (ir_node *node); /** - * must be called from peephole optimisations before a node is exchanged, - * so bepeephole can update it's internal state. + * Notify the peephole phase about a newly added node, so it can update its + * internal state. This is not needed for the new node, when + * be_peephole_exchange() is used. + * Note: Contrary to normal exchange you mustn't remove the node from the + * schedule either before exchange. Exchange will do that for you. + */ +void be_peephole_new_node(ir_node *nw); + +/** + * When doing peephole optimisation use this function instead of plain + * exchange(), so it can update its internal state. */ +void be_peephole_exchange(ir_node *old, ir_node *nw); + +/** + * Tries to optimize a beIncSp node with its previous IncSP node. + * Must be run from a be_peephole_opt() context. + * + * @param node a be_IncSP node + * + * @return the new IncSP node or node itself */ -void be_peephole_before_exchange(const ir_node *old_node, ir_node *new_node); +ir_node *be_peephole_IncSP_IncSP(ir_node *node); + +bool be_has_only_one_user(ir_node *node); /** - * must be called from peephole optimisations after a node is exchanged, - * so bepeephole can update it's internal state. + * In a scheduled program with registers assigned, + * checks wether @p node can be moved before @p before without changing program + * semantics. + * + * Note: It is allowed to use this function without being in a peephole + * optimization phase. */ -void be_peephole_after_exchange(ir_node *new_node); +bool be_can_move_down(ir_heights_t *heights, const ir_node *node, + const ir_node *before); + +bool be_can_move_up(ir_heights_t *heights, const ir_node *node, + const ir_node *after); /** * Do peephole optimisations. It traverses the schedule of all blocks in * backward direction. The register_values variable indicates which (live) * values are stored in which register. * The generic op handler is called for each node if it exists. That's where - * backedn specific optimisations should be performed based on the + * backend specific optimisations should be performed based on the * register-liveness information. */ -void be_peephole_opt(be_irg_t *birg); +void be_peephole_opt(ir_graph *irg); #endif