11591693c7b415e9869157c711fe11263c95d74eDavid Li/* 21591693c7b415e9869157c711fe11263c95d74eDavid Li * Copyright © 2010 Intel Corporation 31591693c7b415e9869157c711fe11263c95d74eDavid Li * 41591693c7b415e9869157c711fe11263c95d74eDavid Li * Permission is hereby granted, free of charge, to any person obtaining a 51591693c7b415e9869157c711fe11263c95d74eDavid Li * copy of this software and associated documentation files (the "Software"), 61591693c7b415e9869157c711fe11263c95d74eDavid Li * to deal in the Software without restriction, including without limitation 71591693c7b415e9869157c711fe11263c95d74eDavid Li * the rights to use, copy, modify, merge, publish, distribute, sublicense, 81591693c7b415e9869157c711fe11263c95d74eDavid Li * and/or sell copies of the Software, and to permit persons to whom the 91591693c7b415e9869157c711fe11263c95d74eDavid Li * Software is furnished to do so, subject to the following conditions: 101591693c7b415e9869157c711fe11263c95d74eDavid Li * 111591693c7b415e9869157c711fe11263c95d74eDavid Li * The above copyright notice and this permission notice (including the next 121591693c7b415e9869157c711fe11263c95d74eDavid Li * paragraph) shall be included in all copies or substantial portions of the 131591693c7b415e9869157c711fe11263c95d74eDavid Li * Software. 141591693c7b415e9869157c711fe11263c95d74eDavid Li * 151591693c7b415e9869157c711fe11263c95d74eDavid Li * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161591693c7b415e9869157c711fe11263c95d74eDavid Li * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171591693c7b415e9869157c711fe11263c95d74eDavid Li * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 181591693c7b415e9869157c711fe11263c95d74eDavid Li * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 191591693c7b415e9869157c711fe11263c95d74eDavid Li * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 201591693c7b415e9869157c711fe11263c95d74eDavid Li * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 211591693c7b415e9869157c711fe11263c95d74eDavid Li * DEALINGS IN THE SOFTWARE. 221591693c7b415e9869157c711fe11263c95d74eDavid Li */ 231591693c7b415e9869157c711fe11263c95d74eDavid Li 241591693c7b415e9869157c711fe11263c95d74eDavid Li 251591693c7b415e9869157c711fe11263c95d74eDavid Li/** 261591693c7b415e9869157c711fe11263c95d74eDavid Li * \file ir_optimization.h 271591693c7b415e9869157c711fe11263c95d74eDavid Li * 281591693c7b415e9869157c711fe11263c95d74eDavid Li * Prototypes for optimization passes to be called by the compiler and drivers. 291591693c7b415e9869157c711fe11263c95d74eDavid Li */ 301591693c7b415e9869157c711fe11263c95d74eDavid Li 311591693c7b415e9869157c711fe11263c95d74eDavid Li/* Operations for lower_instructions() */ 321591693c7b415e9869157c711fe11263c95d74eDavid Li#define SUB_TO_ADD_NEG 0x01 331591693c7b415e9869157c711fe11263c95d74eDavid Li#define DIV_TO_MUL_RCP 0x02 341591693c7b415e9869157c711fe11263c95d74eDavid Li#define EXP_TO_EXP2 0x04 351591693c7b415e9869157c711fe11263c95d74eDavid Li#define POW_TO_EXP2 0x08 361591693c7b415e9869157c711fe11263c95d74eDavid Li#define LOG_TO_LOG2 0x10 371591693c7b415e9869157c711fe11263c95d74eDavid Li#define MOD_TO_FRACT 0x20 381591693c7b415e9869157c711fe11263c95d74eDavid Li 391591693c7b415e9869157c711fe11263c95d74eDavid Libool do_common_optimization(exec_list *ir, bool linked, unsigned max_unroll_iterations); 401591693c7b415e9869157c711fe11263c95d74eDavid Li 411591693c7b415e9869157c711fe11263c95d74eDavid Libool do_algebraic(exec_list *instructions); 421591693c7b415e9869157c711fe11263c95d74eDavid Libool do_constant_folding(exec_list *instructions); 431591693c7b415e9869157c711fe11263c95d74eDavid Libool do_constant_variable(exec_list *instructions); 441591693c7b415e9869157c711fe11263c95d74eDavid Libool do_constant_variable_unlinked(exec_list *instructions); 451591693c7b415e9869157c711fe11263c95d74eDavid Libool do_copy_propagation(exec_list *instructions); 461591693c7b415e9869157c711fe11263c95d74eDavid Libool do_constant_propagation(exec_list *instructions); 471591693c7b415e9869157c711fe11263c95d74eDavid Libool do_dead_code(exec_list *instructions); 481591693c7b415e9869157c711fe11263c95d74eDavid Libool do_dead_code_local(exec_list *instructions); 491591693c7b415e9869157c711fe11263c95d74eDavid Libool do_dead_code_unlinked(exec_list *instructions); 501591693c7b415e9869157c711fe11263c95d74eDavid Libool do_dead_functions(exec_list *instructions); 511591693c7b415e9869157c711fe11263c95d74eDavid Libool do_function_inlining(exec_list *instructions); 521591693c7b415e9869157c711fe11263c95d74eDavid Libool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lower_sub_return = true, bool lower_main_return = false, bool lower_continue = false, bool lower_break = false); 531591693c7b415e9869157c711fe11263c95d74eDavid Libool do_lower_texture_projection(exec_list *instructions); 541591693c7b415e9869157c711fe11263c95d74eDavid Libool do_if_simplification(exec_list *instructions); 551591693c7b415e9869157c711fe11263c95d74eDavid Libool do_discard_simplification(exec_list *instructions); 561591693c7b415e9869157c711fe11263c95d74eDavid Libool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth = 0); 571591693c7b415e9869157c711fe11263c95d74eDavid Libool do_mat_op_to_vec(exec_list *instructions); 581591693c7b415e9869157c711fe11263c95d74eDavid Libool do_mod_to_fract(exec_list *instructions); 591591693c7b415e9869157c711fe11263c95d74eDavid Libool do_noop_swizzle(exec_list *instructions); 601591693c7b415e9869157c711fe11263c95d74eDavid Libool do_structure_splitting(exec_list *instructions); 611591693c7b415e9869157c711fe11263c95d74eDavid Libool do_sub_to_add_neg(exec_list *instructions); 621591693c7b415e9869157c711fe11263c95d74eDavid Libool do_swizzle_swizzle(exec_list *instructions); 631591693c7b415e9869157c711fe11263c95d74eDavid Libool do_tree_grafting(exec_list *instructions); 641591693c7b415e9869157c711fe11263c95d74eDavid Libool do_vec_index_to_cond_assign(exec_list *instructions); 651591693c7b415e9869157c711fe11263c95d74eDavid Libool do_vec_index_to_swizzle(exec_list *instructions); 661591693c7b415e9869157c711fe11263c95d74eDavid Libool lower_discard(exec_list *instructions); 671591693c7b415e9869157c711fe11263c95d74eDavid Libool lower_instructions(exec_list *instructions, unsigned what_to_lower); 681591693c7b415e9869157c711fe11263c95d74eDavid Libool lower_noise(exec_list *instructions); 691591693c7b415e9869157c711fe11263c95d74eDavid Libool lower_variable_index_to_cond_assign(exec_list *instructions, 701591693c7b415e9869157c711fe11263c95d74eDavid Li bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform); 711591693c7b415e9869157c711fe11263c95d74eDavid Libool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz); 721591693c7b415e9869157c711fe11263c95d74eDavid Libool optimize_redundant_jumps(exec_list *instructions); 73