2 #include "radeon_compiler.h"
3 #include "radeon_compiler_util.h"
4 #include "radeon_opcodes.h"
5 #include "radeon_program_pair.h"
7 static void mark_used_presub(struct rc_pair_sub_instruction
* sub
)
9 if (sub
->Src
[RC_PAIR_PRESUB_SRC
].Used
) {
10 unsigned int presub_reg_count
= rc_presubtract_src_reg_count(
11 sub
->Src
[RC_PAIR_PRESUB_SRC
].Index
);
13 for (i
= 0; i
< presub_reg_count
; i
++) {
19 static void mark_used(
20 struct rc_instruction
* inst
,
21 struct rc_pair_sub_instruction
* sub
)
24 const struct rc_opcode_info
* info
= rc_get_opcode_info(sub
->Opcode
);
25 for (i
= 0; i
< info
->NumSrcRegs
; i
++) {
26 unsigned int src_type
= rc_source_type_swz(sub
->Arg
[i
].Swizzle
);
27 if (src_type
& RC_SOURCE_RGB
) {
28 inst
->U
.P
.RGB
.Src
[sub
->Arg
[i
].Source
].Used
= 1;
31 if (src_type
& RC_SOURCE_ALPHA
) {
32 inst
->U
.P
.Alpha
.Src
[sub
->Arg
[i
].Source
].Used
= 1;
38 * This pass finds sources that are not used by their instruction and marks
41 void rc_pair_remove_dead_sources(struct radeon_compiler
* c
, void *user
)
43 struct rc_instruction
* inst
;
44 for (inst
= c
->Program
.Instructions
.Next
;
45 inst
!= &c
->Program
.Instructions
;
48 if (inst
->Type
== RC_INSTRUCTION_NORMAL
)
51 /* Mark all sources as unused */
52 for (i
= 0; i
< 4; i
++) {
53 inst
->U
.P
.RGB
.Src
[i
].Used
= 0;
54 inst
->U
.P
.Alpha
.Src
[i
].Used
= 0;
56 mark_used(inst
, &inst
->U
.P
.RGB
);
57 mark_used(inst
, &inst
->U
.P
.Alpha
);
59 mark_used_presub(&inst
->U
.P
.RGB
);
60 mark_used_presub(&inst
->U
.P
.Alpha
);