2 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief peephole optimisation framework
23 * @author Matthias Braun
33 extern ir_node ***register_values;
35 static inline ir_node *be_peephole_get_value(unsigned regclass_idx,
36 unsigned register_idx)
38 return register_values[regclass_idx][register_idx];
41 static inline ir_node *be_peephole_get_reg_value(const arch_register_t *reg)
43 unsigned regclass_idx = arch_register_class_index(arch_register_get_class(reg));
44 unsigned register_idx = arch_register_get_index(reg);
46 return be_peephole_get_value(regclass_idx, register_idx);
49 typedef ir_node*(*peephole_opt_func) (ir_node *node);
52 * Do peephole optimisations, works backwards over blockschedules and calls the generic op handler function
53 * which should be of type peephole_opt_func. The values of the values in the registers are availble
54 * in the register_values variable during the optimisation functions.
56 void be_peephole_opt(be_irg_t *birg);