• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2008 Nicolai Haehnle.
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #ifndef __RADEON_PROGRAM_PAIR_H_
7 #define __RADEON_PROGRAM_PAIR_H_
8 
9 #include "radeon_code.h"
10 #include "radeon_opcodes.h"
11 #include "radeon_program_constants.h"
12 
13 struct radeon_compiler;
14 
15 /**
16  * \file
17  * Represents a paired ALU instruction, as found in R300 and R500
18  * fragment programs.
19  *
20  * Note that this representation is taking some liberties as far
21  * as register files are concerned, to allow separate register
22  * allocation.
23  *
24  * Also note that there are some subtleties in that the semantics
25  * of certain opcodes are implicitly changed in this representation;
26  * see \ref rc_pair_translate
27  */
28 
29 /* For rgb and alpha instructions when arg[n].Source = RC_PAIR_PRESUB_SRC, then
30  * the presubtract value will be used, and
31  * {RGB,Alpha}.Src[RC_PAIR_PRESUB_SRC].File will be set to RC_FILE_PRESUB.
32  */
33 #define RC_PAIR_PRESUB_SRC 3
34 
35 struct rc_pair_instruction_source {
36    unsigned int Used : 1;
37    unsigned int File : 4;
38    unsigned int Index : RC_REGISTER_INDEX_BITS;
39 };
40 
41 struct rc_pair_instruction_arg {
42    unsigned int Source : 2;
43    unsigned int Swizzle : 12;
44    unsigned int Abs : 1;
45    unsigned int Negate : 1;
46 };
47 
48 struct rc_pair_sub_instruction {
49    unsigned int Opcode : 8;
50    unsigned int DestIndex : RC_REGISTER_INDEX_BITS;
51    unsigned int WriteMask : 4;
52    unsigned int Target : 2;
53    unsigned int OutputWriteMask : 3;
54    unsigned int DepthWriteMask : 1;
55    unsigned int Saturate : 1;
56    unsigned int Omod : 3;
57 
58    struct rc_pair_instruction_source Src[4];
59    struct rc_pair_instruction_arg Arg[3];
60 };
61 
62 struct rc_pair_instruction {
63    struct rc_pair_sub_instruction RGB;
64    struct rc_pair_sub_instruction Alpha;
65 
66    unsigned int WriteALUResult : 2;
67    unsigned int ALUResultCompare : 3;
68    unsigned int Nop : 1;
69    unsigned int SemWait : 1;
70 };
71 
72 typedef void (*rc_pair_foreach_src_fn)(void *, struct rc_pair_instruction_source *);
73 
74 /**
75  * General helper functions for dealing with the paired instruction format.
76  */
77 /*@{*/
78 int rc_pair_alloc_source(struct rc_pair_instruction *pair, unsigned int rgb, unsigned int alpha,
79                          rc_register_file file, unsigned int index);
80 
81 void rc_pair_foreach_source_that_alpha_reads(struct rc_pair_instruction *pair, void *data,
82                                              rc_pair_foreach_src_fn cb);
83 
84 void rc_pair_foreach_source_that_rgb_reads(struct rc_pair_instruction *pair, void *data,
85                                            rc_pair_foreach_src_fn cb);
86 
87 struct rc_pair_instruction_source *rc_pair_get_src(struct rc_pair_instruction *pair_inst,
88                                                    struct rc_pair_instruction_arg *arg);
89 
90 int rc_pair_get_src_index(struct rc_pair_instruction *pair_inst,
91                           struct rc_pair_instruction_source *src);
92 /*@}*/
93 
94 /**
95  * Compiler passes that operate with the paired format.
96  */
97 /*@{*/
98 struct radeon_pair_handler;
99 
100 void rc_pair_translate(struct radeon_compiler *cc, void *user);
101 void rc_pair_schedule(struct radeon_compiler *cc, void *user);
102 void rc_pair_regalloc(struct radeon_compiler *cc, void *user);
103 void rc_pair_remove_dead_sources(struct radeon_compiler *c, void *user);
104 /*@}*/
105 
106 #endif /* __RADEON_PROGRAM_PAIR_H_ */
107