X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fbe%2Fbepeephole.h;h=be93c224c8f499c1ec1701d7bb797ee9a8b4aa6b;hb=c6571686bfbfb3c87ae24ae1dc568e685d6cd49a;hp=19728434fd01d0ce98efc210209bfd7fad907f18;hpb=65a52a96e8ab7ed601d7f98c516d37c46b674b4a;p=libfirm diff --git a/ir/be/bepeephole.h b/ir/be/bepeephole.h index 19728434f..be93c224c 100644 --- a/ir/be/bepeephole.h +++ b/ir/be/bepeephole.h @@ -21,7 +21,6 @@ * @file * @brief peephole optimisation framework * @author Matthias Braun - * @version $Id$ */ #ifndef BEPEEPHOLE_H #define BEPEEPHOLE_H @@ -29,20 +28,17 @@ #include "beirg.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) { - 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); } /** @@ -53,7 +49,10 @@ typedef void (*peephole_opt_func) (ir_node *node); /** * 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. */ + * 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); /** @@ -62,7 +61,7 @@ void be_peephole_new_node(ir_node *nw); void be_peephole_exchange(ir_node *old, ir_node *nw); /** - * Tries to optimize a beIncSp node with it's previous IncSP node. + * 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 @@ -71,6 +70,19 @@ void be_peephole_exchange(ir_node *old, ir_node *nw); */ ir_node *be_peephole_IncSP_IncSP(ir_node *node); +bool be_has_only_one_user(ir_node *node); + +/** + * 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. + */ +bool be_can_move_before(ir_heights_t *heights, const ir_node *node, + const ir_node *before); + /** * Do peephole optimisations. It traverses the schedule of all blocks in * backward direction. The register_values variable indicates which (live)