2 * Copyright 2010 Tom Stellard <tstellar@gmail.com>
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:
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.
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.
28 #include "radeon_program_constants.h"
30 #ifndef RADEON_PROGRAM_UTIL_H
31 #define RADEON_PROGRAM_UTIL_H
33 #include "radeon_opcodes.h"
35 struct radeon_compiler
;
36 struct rc_instruction
;
37 struct rc_pair_instruction
;
38 struct rc_pair_sub_instruction
;
39 struct rc_src_register
;
41 unsigned int rc_swizzle_to_writemask(unsigned int swz
);
43 rc_swizzle
get_swz(unsigned int swz
, rc_swizzle idx
);
45 unsigned int rc_init_swizzle(unsigned int initial_value
, unsigned int channels
);
47 unsigned int combine_swizzles4(unsigned int src
,
48 rc_swizzle swz_x
, rc_swizzle swz_y
,
49 rc_swizzle swz_z
, rc_swizzle swz_w
);
51 unsigned int combine_swizzles(unsigned int src
, unsigned int swz
);
53 rc_swizzle
rc_mask_to_swizzle(unsigned int mask
);
55 unsigned swizzle_mask(unsigned swizzle
, unsigned mask
);
57 unsigned int rc_adjust_channels(
58 unsigned int old_swizzle
,
59 unsigned int conversion_swizzle
);
61 void rc_pair_rewrite_writemask(
62 struct rc_pair_sub_instruction
* sub
,
63 unsigned int conversion_swizzle
);
65 void rc_normal_rewrite_writemask(
66 struct rc_instruction
* inst
,
67 unsigned int conversion_swizzle
);
69 unsigned int rc_rewrite_swizzle(
71 unsigned int new_mask
);
73 struct rc_src_register
lmul_swizzle(unsigned int swizzle
, struct rc_src_register srcreg
);
75 void reset_srcreg(struct rc_src_register
* reg
);
77 unsigned int rc_src_reads_dst_mask(
78 rc_register_file src_file
,
81 rc_register_file dst_file
,
83 unsigned int dst_mask
);
85 unsigned int rc_source_type_swz(unsigned int swizzle
);
87 unsigned int rc_source_type_mask(unsigned int mask
);
89 unsigned int rc_inst_can_use_presub(
90 struct rc_instruction
* inst
,
91 rc_presubtract_op presub_op
,
92 unsigned int presub_writemask
,
93 const struct rc_src_register
* replace_reg
,
94 const struct rc_src_register
* presub_src0
,
95 const struct rc_src_register
* presub_src1
);
98 struct radeon_compiler
* c
,
99 rc_register_file file
);
101 unsigned int rc_pair_remove_src(
102 struct rc_instruction
* inst
,
103 unsigned int src_type
,
105 unsigned int new_readmask
);
107 rc_opcode
rc_get_flow_control_inst(struct rc_instruction
* inst
);
109 struct rc_instruction
* rc_match_endloop(struct rc_instruction
* endloop
);
110 struct rc_instruction
* rc_match_bgnloop(struct rc_instruction
* bgnloop
);
112 unsigned int rc_make_conversion_swizzle(
113 unsigned int old_mask
,
114 unsigned int new_mask
);
116 unsigned int rc_src_reg_is_immediate(
117 struct radeon_compiler
* c
,
121 float rc_get_constant_value(
122 struct radeon_compiler
* c
,
124 unsigned int swizzle
,
128 unsigned int rc_get_scalar_src_swz(unsigned int swizzle
);
130 #endif /* RADEON_PROGRAM_UTIL_H */