Merge remote branch 'origin/7.8'
[mesa.git] / src / mesa / drivers / dri / r300 / compiler / radeon_opcodes.h
1 /*
2 * Copyright (C) 2009 Nicolai Haehnle.
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 #ifndef RADEON_OPCODES_H
29 #define RADEON_OPCODES_H
30
31 #include <assert.h>
32
33 /**
34 * Opcodes understood by the Radeon compiler.
35 */
36 typedef enum {
37 RC_OPCODE_NOP = 0,
38 RC_OPCODE_ILLEGAL_OPCODE,
39
40 /** vec4 instruction: dst.c = abs(src0.c); */
41 RC_OPCODE_ABS,
42
43 /** vec4 instruction: dst.c = src0.c + src1.c; */
44 RC_OPCODE_ADD,
45
46 /** special instruction: load address register
47 * dst.x = floor(src.x), where dst must be an address register */
48 RC_OPCODE_ARL,
49
50 /** vec4 instruction: dst.c = src0.c < 0.0 ? src1.c : src2.c */
51 RC_OPCODE_CMP,
52
53 /** scalar instruction: dst = cos(src0.x) */
54 RC_OPCODE_COS,
55
56 /** special instruction: take vec4 partial derivative in X direction
57 * dst.c = d src0.c / dx */
58 RC_OPCODE_DDX,
59
60 /** special instruction: take vec4 partial derivative in Y direction
61 * dst.c = d src0.c / dy */
62 RC_OPCODE_DDY,
63
64 /** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z */
65 RC_OPCODE_DP3,
66
67 /** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z + src0.w*src1.w */
68 RC_OPCODE_DP4,
69
70 /** scalar instruction: dst = src0.x*src1.x + src0.y*src1.y + src0.z*src1.z + src1.w */
71 RC_OPCODE_DPH,
72
73 /** special instruction, see ARB_fragment_program */
74 RC_OPCODE_DST,
75
76 /** scalar instruction: dst = 2**src0.x */
77 RC_OPCODE_EX2,
78
79 /** special instruction, see ARB_vertex_program */
80 RC_OPCODE_EXP,
81
82 /** vec4 instruction: dst.c = floor(src0.c) */
83 RC_OPCODE_FLR,
84
85 /** vec4 instruction: dst.c = src0.c - floor(src0.c) */
86 RC_OPCODE_FRC,
87
88 /** special instruction: stop execution if any component of src0 is negative */
89 RC_OPCODE_KIL,
90
91 /** scalar instruction: dst = log_2(src0.x) */
92 RC_OPCODE_LG2,
93
94 /** special instruction, see ARB_vertex_program */
95 RC_OPCODE_LIT,
96
97 /** special instruction, see ARB_vertex_program */
98 RC_OPCODE_LOG,
99
100 /** vec4 instruction: dst.c = src0.c*src1.c + (1 - src0.c)*src2.c */
101 RC_OPCODE_LRP,
102
103 /** vec4 instruction: dst.c = src0.c*src1.c + src2.c */
104 RC_OPCODE_MAD,
105
106 /** vec4 instruction: dst.c = max(src0.c, src1.c) */
107 RC_OPCODE_MAX,
108
109 /** vec4 instruction: dst.c = min(src0.c, src1.c) */
110 RC_OPCODE_MIN,
111
112 /** vec4 instruction: dst.c = src0.c */
113 RC_OPCODE_MOV,
114
115 /** vec4 instruction: dst.c = src0.c*src1.c */
116 RC_OPCODE_MUL,
117
118 /** scalar instruction: dst = src0.x ** src1.x */
119 RC_OPCODE_POW,
120
121 /** scalar instruction: dst = 1 / src0.x */
122 RC_OPCODE_RCP,
123
124 /** scalar instruction: dst = 1 / sqrt(src0.x) */
125 RC_OPCODE_RSQ,
126
127 /** special instruction, see ARB_fragment_program */
128 RC_OPCODE_SCS,
129
130 /** vec4 instruction: dst.c = (src0.c == src1.c) ? 1.0 : 0.0 */
131 RC_OPCODE_SEQ,
132
133 /** vec4 instruction: dst.c = 0.0 */
134 RC_OPCODE_SFL,
135
136 /** vec4 instruction: dst.c = (src0.c >= src1.c) ? 1.0 : 0.0 */
137 RC_OPCODE_SGE,
138
139 /** vec4 instruction: dst.c = (src0.c > src1.c) ? 1.0 : 0.0 */
140 RC_OPCODE_SGT,
141
142 /** scalar instruction: dst = sin(src0.x) */
143 RC_OPCODE_SIN,
144
145 /** vec4 instruction: dst.c = (src0.c <= src1.c) ? 1.0 : 0.0 */
146 RC_OPCODE_SLE,
147
148 /** vec4 instruction: dst.c = (src0.c < src1.c) ? 1.0 : 0.0 */
149 RC_OPCODE_SLT,
150
151 /** vec4 instruction: dst.c = (src0.c != src1.c) ? 1.0 : 0.0 */
152 RC_OPCODE_SNE,
153
154 /** vec4 instruction: dst.c = src0.c - src1.c */
155 RC_OPCODE_SUB,
156
157 /** vec4 instruction: dst.c = src0.c */
158 RC_OPCODE_SWZ,
159
160 /** special instruction, see ARB_fragment_program */
161 RC_OPCODE_XPD,
162
163 RC_OPCODE_TEX,
164 RC_OPCODE_TXB,
165 RC_OPCODE_TXD,
166 RC_OPCODE_TXL,
167 RC_OPCODE_TXP,
168
169 /** branch instruction:
170 * If src0.x != 0.0, continue with the next instruction;
171 * otherwise, jump to matching RC_OPCODE_ELSE or RC_OPCODE_ENDIF.
172 */
173 RC_OPCODE_IF,
174
175 /** branch instruction: jump to matching RC_OPCODE_ENDIF */
176 RC_OPCODE_ELSE,
177
178 /** branch instruction: has no effect */
179 RC_OPCODE_ENDIF,
180
181 /** special instruction, used in R300-R500 fragment program pair instructions
182 * indicates that the result of the alpha operation shall be replicated
183 * across all other channels */
184 RC_OPCODE_REPL_ALPHA,
185
186 /** special instruction, used in R300-R500 fragment programs
187 * to indicate the start of a block of texture instructions that
188 * can run simultaneously. */
189 RC_OPCODE_BEGIN_TEX,
190
191 MAX_RC_OPCODE
192 } rc_opcode;
193
194
195 struct rc_opcode_info {
196 rc_opcode Opcode;
197 const char * Name;
198
199 /** true if the instruction reads from a texture.
200 *
201 * \note This is false for the KIL instruction, even though KIL is
202 * a texture instruction from a hardware point of view. */
203 unsigned int HasTexture:1;
204
205 unsigned int NumSrcRegs:2;
206 unsigned int HasDstReg:1;
207
208 /** true if this instruction affects control flow */
209 unsigned int IsFlowControl:1;
210
211 /** true if this is a vector instruction that operates on components in parallel
212 * without any cross-component interaction */
213 unsigned int IsComponentwise:1;
214
215 /** true if this instruction sources only its operands X components
216 * to compute one result which is smeared across all output channels */
217 unsigned int IsStandardScalar:1;
218 };
219
220 extern struct rc_opcode_info rc_opcodes[MAX_RC_OPCODE];
221
222 static inline const struct rc_opcode_info * rc_get_opcode_info(rc_opcode opcode)
223 {
224 assert((unsigned int)opcode < MAX_RC_OPCODE);
225 assert(rc_opcodes[opcode].Opcode == opcode);
226
227 return &rc_opcodes[opcode];
228 }
229
230 void rc_compute_sources_for_writemask(
231 const struct rc_opcode_info * opcode,
232 unsigned int writemask,
233 unsigned int *srcmasks);
234
235 #endif /* RADEON_OPCODES_H */