Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5564 | serge | 1 | /* |
2 | * Copyright 2013 Vadim Girlin |
||
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_op(unsigned cc, unsigned cmp_type, bool int_dst); |
||
41 | unsigned get_predsetcc_op(unsigned cc, unsigned cmp_type); |
||
42 | unsigned get_killcc_op(unsigned cc, unsigned cmp_type); |
||
43 | unsigned get_cndcc_op(unsigned cc, unsigned cmp_type); |
||
44 | |||
45 | void convert_to_mov(alu_node &n, value *src, |
||
46 | bool neg = false, bool abs = false); |
||
47 | |||
48 | class expr_handler { |
||
49 | |||
50 | shader &sh; |
||
51 | value_table &vt; |
||
52 | |||
53 | public: |
||
54 | |||
55 | expr_handler(shader &sh); |
||
56 | |||
57 | bool equal(value *l, value *r); |
||
58 | bool defs_equal(value *l, value *r); |
||
59 | bool args_equal(const vvec &l, const vvec &r); |
||
60 | bool ops_equal(const alu_node *l, const alu_node *r); |
||
61 | bool ivars_equal(value *l, value *r); |
||
62 | |||
63 | value* get_const(const literal &l); |
||
64 | |||
65 | bool try_fold(value *v); |
||
66 | bool try_fold(node *n); |
||
67 | |||
68 | bool fold(node &n); |
||
69 | bool fold(container_node &n); |
||
70 | bool fold(alu_node &n); |
||
71 | bool fold(fetch_node &n); |
||
72 | bool fold(cf_node &n); |
||
73 | |||
74 | bool fold_setcc(alu_node &n); |
||
75 | |||
76 | bool fold_alu_op1(alu_node &n); |
||
77 | bool fold_alu_op2(alu_node &n); |
||
78 | bool fold_alu_op3(alu_node &n); |
||
79 | |||
80 | bool fold_mul_add(alu_node *n); |
||
81 | bool eval_const_op(unsigned op, literal &r, literal cv0, literal cv1); |
||
82 | bool fold_assoc(alu_node *n); |
||
83 | |||
84 | static void apply_alu_src_mod(const bc_alu &bc, unsigned src, literal &v); |
||
85 | static void apply_alu_dst_mod(const bc_alu &bc, literal &v); |
||
86 | |||
87 | void assign_source(value *dst, value *src); |
||
88 | |||
89 | static bool evaluate_condition(unsigned alu_cnd_flags, literal s1, |
||
90 | literal s2); |
||
91 | }; |
||
92 | |||
93 | } // namespace r600_sb |
||
94 | |||
95 | #endif /* SB_EXPR_H_ */> |