• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2010 Tom Stellard <tstellar@gmail.com>
3  *
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial
16  * portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  */
27 
28 #include "radeon_program_constants.h"
29 
30 #ifndef RADEON_PROGRAM_UTIL_H
31 #define RADEON_PROGRAM_UTIL_H
32 
33 #include <stdbool.h>
34 
35 #include "radeon_opcodes.h"
36 
37 struct radeon_compiler;
38 struct rc_instruction;
39 struct rc_pair_instruction;
40 struct rc_pair_sub_instruction;
41 struct rc_src_register;
42 
43 unsigned int rc_swizzle_to_writemask(unsigned int swz);
44 
45 rc_swizzle get_swz(unsigned int swz, rc_swizzle idx);
46 
47 unsigned int rc_init_swizzle(unsigned int initial_value, unsigned int channels);
48 
49 unsigned int combine_swizzles4(unsigned int src,
50 			       rc_swizzle swz_x, rc_swizzle swz_y,
51 			       rc_swizzle swz_z, rc_swizzle swz_w);
52 
53 unsigned int combine_swizzles(unsigned int src, unsigned int swz);
54 
55 rc_swizzle rc_mask_to_swizzle(unsigned int mask);
56 
57 unsigned swizzle_mask(unsigned swizzle, unsigned mask);
58 
59 unsigned int rc_adjust_channels(
60 	unsigned int old_swizzle,
61 	unsigned int conversion_swizzle);
62 
63 void rc_pair_rewrite_writemask(
64 	struct rc_pair_sub_instruction * sub,
65 	unsigned int conversion_swizzle);
66 
67 void rc_normal_rewrite_writemask(
68 	struct rc_instruction * inst,
69 	unsigned int conversion_swizzle);
70 
71 unsigned int rc_rewrite_swizzle(
72 	unsigned int swizzle,
73 	unsigned int new_mask);
74 
75 struct rc_src_register lmul_swizzle(unsigned int swizzle, struct rc_src_register srcreg);
76 
77 void reset_srcreg(struct rc_src_register* reg);
78 
79 unsigned int rc_src_reads_dst_mask(
80 		rc_register_file src_file,
81 		unsigned int src_idx,
82 		unsigned int src_swz,
83 		rc_register_file dst_file,
84 		unsigned int dst_idx,
85 		unsigned int dst_mask);
86 
87 unsigned int rc_source_type_swz(unsigned int swizzle);
88 
89 unsigned int rc_source_type_mask(unsigned int mask);
90 
91 unsigned int rc_inst_can_use_presub(
92 	struct radeon_compiler * c,
93 	struct rc_instruction * inst,
94 	rc_presubtract_op presub_op,
95 	unsigned int presub_writemask,
96 	const struct rc_src_register * replace_reg,
97 	const struct rc_src_register * presub_src0,
98 	const struct rc_src_register * presub_src1);
99 
100 int rc_get_max_index(
101 	struct radeon_compiler * c,
102 	rc_register_file file);
103 
104 void rc_pair_remove_src(struct rc_instruction * inst,
105 	unsigned int src_type,
106 	unsigned int source);
107 
108 rc_opcode rc_get_flow_control_inst(struct rc_instruction * inst);
109 
110 struct rc_instruction * rc_match_endloop(struct rc_instruction * endloop);
111 struct rc_instruction * rc_match_bgnloop(struct rc_instruction * bgnloop);
112 
113 unsigned int rc_make_conversion_swizzle(
114 	unsigned int old_mask,
115 	unsigned int new_mask);
116 
117 unsigned int rc_src_reg_is_immediate(
118 	struct radeon_compiler * c,
119 	unsigned int file,
120 	unsigned int index);
121 
122 float rc_get_constant_value(
123 	struct radeon_compiler * c,
124 	unsigned int index,
125 	unsigned int swizzle,
126 	unsigned int negate,
127 	unsigned int chan);
128 
129 unsigned int rc_get_scalar_src_swz(unsigned int swizzle);
130 
131 bool rc_inst_has_three_diff_temp_srcs(struct rc_instruction *inst);
132 #endif /* RADEON_PROGRAM_UTIL_H */
133