r600g/sb: fix kcache handling on r6xx
[mesa.git] / src / gallium / drivers / r600 / sb / sb_expr.h
1 /*
2 * Copyright 2013 Vadim Girlin <vadimgirlin@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Vadim Girlin
25 */
26
27 #ifndef SB_EXPR_H_
28 #define SB_EXPR_H_
29
30 namespace r600_sb {
31
32 inline float float_clamp(float v) {
33 return v < 0.0f ? 0.0f : (v > 1.0f ? 1.0f : v);
34 }
35
36 value* get_select_value_for_em(shader &sh, value *em);
37
38 void convert_predset_to_set(shader &sh, alu_node *a);
39 unsigned invert_setcc_condition(unsigned cc, bool &swap_args);
40 unsigned get_setcc_opcode(unsigned cc, unsigned cmp_type, bool int_dst);
41 unsigned get_predsetcc_opcode(unsigned cc, unsigned cmp_type);
42
43 class expr_handler {
44
45 shader &sh;
46 value_table &vt;
47
48 public:
49
50 expr_handler(shader &sh);
51
52 bool equal(value *l, value *r);
53 bool defs_equal(value *l, value *r);
54 bool args_equal(const vvec &l, const vvec &r);
55 bool ops_equal(const alu_node *l, const alu_node *r);
56 bool ivars_equal(value *l, value *r);
57
58 value* get_const(const literal &l);
59
60 bool try_fold(value *v);
61 bool try_fold(node *n);
62
63 bool fold(node &n);
64 bool fold(container_node &n);
65 bool fold(alu_node &n);
66 bool fold(fetch_node &n);
67 bool fold(cf_node &n);
68
69 bool fold_setcc(alu_node &n);
70
71 bool fold_alu_op1(alu_node &n);
72 bool fold_alu_op2(alu_node &n);
73 bool fold_alu_op3(alu_node &n);
74
75 void apply_alu_src_mod(const bc_alu &bc, unsigned src, literal &v);
76 void apply_alu_dst_mod(const bc_alu &bc, literal &v);
77
78 void assign_source(value *dst, value *src);
79 };
80
81 } // namespace r600_sb
82
83 #endif /* SB_EXPR_H_ */