1#include "radeon_program_constants.h"
2
3#ifndef RADEON_PROGRAM_UTIL_H
4#define RADEON_PROGRAM_UTIL_H
5
6#include "radeon_opcodes.h"
7
8struct radeon_compiler;
9struct rc_instruction;
10struct rc_pair_instruction;
11struct rc_pair_sub_instruction;
12struct rc_src_register;
13
14unsigned int rc_swizzle_to_writemask(unsigned int swz);
15
16rc_swizzle get_swz(unsigned int swz, rc_swizzle idx);
17
18unsigned int rc_init_swizzle(unsigned int initial_value, unsigned int channels);
19
20unsigned int combine_swizzles4(unsigned int src,
21			       rc_swizzle swz_x, rc_swizzle swz_y,
22			       rc_swizzle swz_z, rc_swizzle swz_w);
23
24unsigned int combine_swizzles(unsigned int src, unsigned int swz);
25
26rc_swizzle rc_mask_to_swizzle(unsigned int mask);
27
28unsigned swizzle_mask(unsigned swizzle, unsigned mask);
29
30unsigned int rc_adjust_channels(
31	unsigned int old_swizzle,
32	unsigned int conversion_swizzle);
33
34void rc_pair_rewrite_writemask(
35	struct rc_pair_sub_instruction * sub,
36	unsigned int conversion_swizzle);
37
38void rc_normal_rewrite_writemask(
39	struct rc_instruction * inst,
40	unsigned int conversion_swizzle);
41
42unsigned int rc_rewrite_swizzle(
43	unsigned int swizzle,
44	unsigned int new_mask);
45
46struct rc_src_register lmul_swizzle(unsigned int swizzle, struct rc_src_register srcreg);
47
48void reset_srcreg(struct rc_src_register* reg);
49
50unsigned int rc_src_reads_dst_mask(
51		rc_register_file src_file,
52		unsigned int src_idx,
53		unsigned int src_swz,
54		rc_register_file dst_file,
55		unsigned int dst_idx,
56		unsigned int dst_mask);
57
58unsigned int rc_source_type_swz(unsigned int swizzle);
59
60unsigned int rc_source_type_mask(unsigned int mask);
61
62unsigned int rc_inst_can_use_presub(
63	struct rc_instruction * inst,
64	rc_presubtract_op presub_op,
65	unsigned int presub_writemask,
66	const struct rc_src_register * replace_reg,
67	const struct rc_src_register * presub_src0,
68	const struct rc_src_register * presub_src1);
69
70int rc_get_max_index(
71	struct radeon_compiler * c,
72	rc_register_file file);
73
74unsigned int rc_pair_remove_src(
75	struct rc_instruction * inst,
76	unsigned int src_type,
77	unsigned int source,
78	unsigned int new_readmask);
79
80rc_opcode rc_get_flow_control_inst(struct rc_instruction * inst);
81
82struct rc_instruction * rc_match_endloop(struct rc_instruction * endloop);
83struct rc_instruction * rc_match_bgnloop(struct rc_instruction * bgnloop);
84
85unsigned int rc_make_conversion_swizzle(
86	unsigned int old_mask,
87	unsigned int new_mask);
88
89unsigned int rc_src_reg_is_immediate(
90	struct radeon_compiler * c,
91	unsigned int file,
92	unsigned int index);
93
94float rc_get_constant_value(
95	struct radeon_compiler * c,
96	unsigned int index,
97	unsigned int swizzle,
98	unsigned int negate,
99	unsigned int chan);
100
101unsigned int rc_get_scalar_src_swz(unsigned int swizzle);
102
103#endif /* RADEON_PROGRAM_UTIL_H */
104