diff options
Diffstat (limited to 'src/gallium/drivers/r600/sb/sb_expr.h')
-rw-r--r-- | src/gallium/drivers/r600/sb/sb_expr.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/gallium/drivers/r600/sb/sb_expr.h b/src/gallium/drivers/r600/sb/sb_expr.h new file mode 100644 index 00000000000..7f3bd15ba37 --- /dev/null +++ b/src/gallium/drivers/r600/sb/sb_expr.h @@ -0,0 +1,83 @@ +/* + * Copyright 2013 Vadim Girlin <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Vadim Girlin + */ + +#ifndef SB_EXPR_H_ +#define SB_EXPR_H_ + +namespace r600_sb { + +inline float float_clamp(float v) { + return v < 0.0f ? 0.0f : (v > 1.0f ? 1.0f : v); +} + +value* get_select_value_for_em(shader &sh, value *em); + +void convert_predset_to_set(shader &sh, alu_node *a); +unsigned invert_setcc_condition(unsigned cc, bool &swap_args); +unsigned get_setcc_opcode(unsigned cc, unsigned cmp_type, bool int_dst); +unsigned get_predsetcc_opcode(unsigned cc, unsigned cmp_type); + +class expr_handler { + + shader &sh; + value_table &vt; + +public: + + expr_handler(shader &sh); + + bool equal(value *l, value *r); + bool defs_equal(value *l, value *r); + bool args_equal(const vvec &l, const vvec &r); + bool ops_equal(const alu_node *l, const alu_node *r); + bool ivars_equal(value *l, value *r); + + value* get_const(const literal &l); + + bool try_fold(value *v); + bool try_fold(node *n); + + bool fold(node &n); + bool fold(container_node &n); + bool fold(alu_node &n); + bool fold(fetch_node &n); + bool fold(cf_node &n); + + bool fold_setcc(alu_node &n); + + bool fold_alu_op1(alu_node &n); + bool fold_alu_op2(alu_node &n); + bool fold_alu_op3(alu_node &n); + + void apply_alu_src_mod(const bc_alu &bc, unsigned src, literal &v); + void apply_alu_dst_mod(const bc_alu &bc, literal &v); + + void assign_source(value *dst, value *src); +}; + +} // namespace r600_sb + +#endif /* SB_EXPR_H_ */ |