shouldn't be here anymore
[libfirm] / ir / be / bepeephole.h
index 697f8fe..def4b8e 100644 (file)
@@ -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.
  *
 
 extern ir_node ***register_values;
 
-static inline ir_node *be_peephole_get_value(unsigned regclass_idx,
+static INLINE ir_node *be_peephole_get_value(unsigned regclass_idx,
                                              unsigned register_idx)
 {
        return register_values[regclass_idx][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);
@@ -46,12 +46,30 @@ static inline ir_node *be_peephole_get_reg_value(const arch_register_t *reg)
        return be_peephole_get_value(regclass_idx, register_idx);
 }
 
-typedef ir_node*(*peephole_opt_func) (ir_node *node);
+/**
+ * Datatype of the generic op handler for optimisation.
+ */
+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.
+ */
+void be_peephole_before_exchange(const ir_node *old_node, ir_node *new_node);
+
+/**
+ * must be called from peephole optimisations after a node is exchanged,
+ * so bepeephole can update it's internal state.
+ */
+void be_peephole_after_exchange(ir_node *new_node);
 
 /**
- * Do peephole optimisations, works backwards over blockschedules and calls the generic op handler function
- * which should be of type peephole_opt_func. The values of the values in the registers are availble
- * in the register_values variable during the optimisation functions.
+ * 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
+ * register-liveness information.
  */
 void be_peephole_opt(be_irg_t *birg);