1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * 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, sub license, 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 portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "util/u_debug.h"
29 #include "util/u_memory.h"
30 #include "tgsi_info.h"
32 static const struct tgsi_opcode_info opcode_info
[TGSI_OPCODE_LAST
] =
34 { 1, 1, 0, 0, 0, 0, "ARL", TGSI_OPCODE_ARL
},
35 { 1, 1, 0, 0, 0, 0, "MOV", TGSI_OPCODE_MOV
},
36 { 1, 1, 0, 0, 0, 0, "LIT", TGSI_OPCODE_LIT
},
37 { 1, 1, 0, 0, 0, 0, "RCP", TGSI_OPCODE_RCP
},
38 { 1, 1, 0, 0, 0, 0, "RSQ", TGSI_OPCODE_RSQ
},
39 { 1, 1, 0, 0, 0, 0, "EXP", TGSI_OPCODE_EXP
},
40 { 1, 1, 0, 0, 0, 0, "LOG", TGSI_OPCODE_LOG
},
41 { 1, 2, 0, 0, 0, 0, "MUL", TGSI_OPCODE_MUL
},
42 { 1, 2, 0, 0, 0, 0, "ADD", TGSI_OPCODE_ADD
},
43 { 1, 2, 0, 0, 0, 0, "DP3", TGSI_OPCODE_DP3
},
44 { 1, 2, 0, 0, 0, 0, "DP4", TGSI_OPCODE_DP4
},
45 { 1, 2, 0, 0, 0, 0, "DST", TGSI_OPCODE_DST
},
46 { 1, 2, 0, 0, 0, 0, "MIN", TGSI_OPCODE_MIN
},
47 { 1, 2, 0, 0, 0, 0, "MAX", TGSI_OPCODE_MAX
},
48 { 1, 2, 0, 0, 0, 0, "SLT", TGSI_OPCODE_SLT
},
49 { 1, 2, 0, 0, 0, 0, "SGE", TGSI_OPCODE_SGE
},
50 { 1, 3, 0, 0, 0, 0, "MAD", TGSI_OPCODE_MAD
},
51 { 1, 2, 0, 0, 0, 0, "SUB", TGSI_OPCODE_SUB
},
52 { 1, 3, 0, 0, 0, 0, "LRP", TGSI_OPCODE_LRP
},
53 { 1, 3, 0, 0, 0, 0, "CND", TGSI_OPCODE_CND
},
54 { 0, 0, 0, 0, 0, 0, "", 20 }, /* removed */
55 { 1, 3, 0, 0, 0, 0, "DP2A", TGSI_OPCODE_DP2A
},
56 { 0, 0, 0, 0, 0, 0, "", 22 }, /* removed */
57 { 0, 0, 0, 0, 0, 0, "", 23 }, /* removed */
58 { 1, 1, 0, 0, 0, 0, "FRC", TGSI_OPCODE_FRC
},
59 { 1, 3, 0, 0, 0, 0, "CLAMP", TGSI_OPCODE_CLAMP
},
60 { 1, 1, 0, 0, 0, 0, "FLR", TGSI_OPCODE_FLR
},
61 { 1, 1, 0, 0, 0, 0, "ROUND", TGSI_OPCODE_ROUND
},
62 { 1, 1, 0, 0, 0, 0, "EX2", TGSI_OPCODE_EX2
},
63 { 1, 1, 0, 0, 0, 0, "LG2", TGSI_OPCODE_LG2
},
64 { 1, 2, 0, 0, 0, 0, "POW", TGSI_OPCODE_POW
},
65 { 1, 2, 0, 0, 0, 0, "XPD", TGSI_OPCODE_XPD
},
66 { 0, 0, 0, 0, 0, 0, "", 32 }, /* removed */
67 { 1, 1, 0, 0, 0, 0, "ABS", TGSI_OPCODE_ABS
},
68 { 1, 1, 0, 0, 0, 0, "RCC", TGSI_OPCODE_RCC
},
69 { 1, 2, 0, 0, 0, 0, "DPH", TGSI_OPCODE_DPH
},
70 { 1, 1, 0, 0, 0, 0, "COS", TGSI_OPCODE_COS
},
71 { 1, 1, 0, 0, 0, 0, "DDX", TGSI_OPCODE_DDX
},
72 { 1, 1, 0, 0, 0, 0, "DDY", TGSI_OPCODE_DDY
},
73 { 0, 0, 0, 0, 0, 0, "KILP", TGSI_OPCODE_KILP
},
74 { 1, 1, 0, 0, 0, 0, "PK2H", TGSI_OPCODE_PK2H
},
75 { 1, 1, 0, 0, 0, 0, "PK2US", TGSI_OPCODE_PK2US
},
76 { 1, 1, 0, 0, 0, 0, "PK4B", TGSI_OPCODE_PK4B
},
77 { 1, 1, 0, 0, 0, 0, "PK4UB", TGSI_OPCODE_PK4UB
},
78 { 1, 2, 0, 0, 0, 0, "RFL", TGSI_OPCODE_RFL
},
79 { 1, 2, 0, 0, 0, 0, "SEQ", TGSI_OPCODE_SEQ
},
80 { 1, 2, 0, 0, 0, 0, "SFL", TGSI_OPCODE_SFL
},
81 { 1, 2, 0, 0, 0, 0, "SGT", TGSI_OPCODE_SGT
},
82 { 1, 1, 0, 0, 0, 0, "SIN", TGSI_OPCODE_SIN
},
83 { 1, 2, 0, 0, 0, 0, "SLE", TGSI_OPCODE_SLE
},
84 { 1, 2, 0, 0, 0, 0, "SNE", TGSI_OPCODE_SNE
},
85 { 1, 2, 0, 0, 0, 0, "STR", TGSI_OPCODE_STR
},
86 { 1, 2, 1, 0, 0, 0, "TEX", TGSI_OPCODE_TEX
},
87 { 1, 4, 1, 0, 0, 0, "TXD", TGSI_OPCODE_TXD
},
88 { 1, 2, 1, 0, 0, 0, "TXP", TGSI_OPCODE_TXP
},
89 { 1, 1, 0, 0, 0, 0, "UP2H", TGSI_OPCODE_UP2H
},
90 { 1, 1, 0, 0, 0, 0, "UP2US", TGSI_OPCODE_UP2US
},
91 { 1, 1, 0, 0, 0, 0, "UP4B", TGSI_OPCODE_UP4B
},
92 { 1, 1, 0, 0, 0, 0, "UP4UB", TGSI_OPCODE_UP4UB
},
93 { 1, 3, 0, 0, 0, 0, "X2D", TGSI_OPCODE_X2D
},
94 { 1, 1, 0, 0, 0, 0, "ARA", TGSI_OPCODE_ARA
},
95 { 1, 1, 0, 0, 0, 0, "ARR", TGSI_OPCODE_ARR
},
96 { 0, 1, 0, 0, 0, 0, "BRA", TGSI_OPCODE_BRA
},
97 { 0, 0, 0, 1, 0, 0, "CAL", TGSI_OPCODE_CAL
},
98 { 0, 0, 0, 0, 0, 0, "RET", TGSI_OPCODE_RET
},
99 { 1, 1, 0, 0, 0, 0, "SSG", TGSI_OPCODE_SSG
},
100 { 1, 3, 0, 0, 0, 0, "CMP", TGSI_OPCODE_CMP
},
101 { 1, 1, 0, 0, 0, 0, "SCS", TGSI_OPCODE_SCS
},
102 { 1, 2, 1, 0, 0, 0, "TXB", TGSI_OPCODE_TXB
},
103 { 1, 1, 0, 0, 0, 0, "NRM", TGSI_OPCODE_NRM
},
104 { 1, 2, 0, 0, 0, 0, "DIV", TGSI_OPCODE_DIV
},
105 { 1, 2, 0, 0, 0, 0, "DP2", TGSI_OPCODE_DP2
},
106 { 1, 2, 1, 0, 0, 0, "TXL", TGSI_OPCODE_TXL
},
107 { 0, 0, 0, 0, 0, 0, "BRK", TGSI_OPCODE_BRK
},
108 { 0, 1, 0, 1, 0, 1, "IF", TGSI_OPCODE_IF
},
109 { 1, 1, 0, 0, 0, 1, "", 75 }, /* removed */
110 { 0, 1, 0, 0, 0, 1, "", 76 }, /* removed */
111 { 0, 0, 0, 1, 1, 1, "ELSE", TGSI_OPCODE_ELSE
},
112 { 0, 0, 0, 0, 1, 0, "ENDIF", TGSI_OPCODE_ENDIF
},
113 { 1, 0, 0, 0, 1, 0, "", 79 }, /* removed */
114 { 0, 0, 0, 0, 1, 0, "", 80 }, /* removed */
115 { 0, 1, 0, 0, 0, 0, "PUSHA", TGSI_OPCODE_PUSHA
},
116 { 1, 0, 0, 0, 0, 0, "POPA", TGSI_OPCODE_POPA
},
117 { 1, 1, 0, 0, 0, 0, "CEIL", TGSI_OPCODE_CEIL
},
118 { 1, 1, 0, 0, 0, 0, "I2F", TGSI_OPCODE_I2F
},
119 { 1, 1, 0, 0, 0, 0, "NOT", TGSI_OPCODE_NOT
},
120 { 1, 1, 0, 0, 0, 0, "TRUNC", TGSI_OPCODE_TRUNC
},
121 { 1, 2, 0, 0, 0, 0, "SHL", TGSI_OPCODE_SHL
},
122 { 0, 0, 0, 0, 0, 0, "", 88 }, /* removed */
123 { 1, 2, 0, 0, 0, 0, "AND", TGSI_OPCODE_AND
},
124 { 1, 2, 0, 0, 0, 0, "OR", TGSI_OPCODE_OR
},
125 { 1, 2, 0, 0, 0, 0, "MOD", TGSI_OPCODE_MOD
},
126 { 1, 2, 0, 0, 0, 0, "XOR", TGSI_OPCODE_XOR
},
127 { 1, 3, 0, 0, 0, 0, "SAD", TGSI_OPCODE_SAD
},
128 { 1, 2, 1, 0, 0, 0, "TXF", TGSI_OPCODE_TXF
},
129 { 1, 2, 1, 0, 0, 0, "TXQ", TGSI_OPCODE_TXQ
},
130 { 0, 0, 0, 0, 0, 0, "CONT", TGSI_OPCODE_CONT
},
131 { 0, 0, 0, 0, 0, 0, "EMIT", TGSI_OPCODE_EMIT
},
132 { 0, 0, 0, 0, 0, 0, "ENDPRIM", TGSI_OPCODE_ENDPRIM
},
133 { 0, 0, 0, 1, 0, 1, "BGNLOOP", TGSI_OPCODE_BGNLOOP
},
134 { 0, 0, 0, 0, 0, 1, "BGNSUB", TGSI_OPCODE_BGNSUB
},
135 { 0, 0, 0, 1, 1, 0, "ENDLOOP", TGSI_OPCODE_ENDLOOP
},
136 { 0, 0, 0, 0, 1, 0, "ENDSUB", TGSI_OPCODE_ENDSUB
},
137 { 0, 0, 0, 0, 0, 0, "", 103 }, /* removed */
138 { 0, 0, 0, 0, 0, 0, "", 104 }, /* removed */
139 { 0, 0, 0, 0, 0, 0, "", 105 }, /* removed */
140 { 0, 0, 0, 0, 0, 0, "", 106 }, /* removed */
141 { 0, 0, 0, 0, 0, 0, "NOP", TGSI_OPCODE_NOP
},
142 { 0, 0, 0, 0, 0, 0, "", 108 }, /* removed */
143 { 0, 0, 0, 0, 0, 0, "", 109 }, /* removed */
144 { 0, 0, 0, 0, 0, 0, "", 110 }, /* removed */
145 { 0, 0, 0, 0, 0, 0, "", 111 }, /* removed */
146 { 1, 1, 0, 0, 0, 0, "NRM4", TGSI_OPCODE_NRM4
},
147 { 0, 1, 0, 0, 0, 0, "CALLNZ", TGSI_OPCODE_CALLNZ
},
148 { 0, 1, 0, 0, 0, 0, "IFC", TGSI_OPCODE_IFC
},
149 { 0, 1, 0, 0, 0, 0, "BREAKC", TGSI_OPCODE_BREAKC
},
150 { 0, 1, 0, 0, 0, 0, "KIL", TGSI_OPCODE_KIL
},
151 { 0, 0, 0, 0, 0, 0, "END", TGSI_OPCODE_END
},
152 { 0, 0, 0, 0, 0, 0, "", 118 }, /* removed */
153 { 1, 1, 0, 0, 0, 0, "F2I", TGSI_OPCODE_F2I
},
154 { 1, 2, 0, 0, 0, 0, "IDIV", TGSI_OPCODE_IDIV
},
155 { 1, 2, 0, 0, 0, 0, "IMAX", TGSI_OPCODE_IMAX
},
156 { 1, 2, 0, 0, 0, 0, "IMIN", TGSI_OPCODE_IMIN
},
157 { 1, 1, 0, 0, 0, 0, "INEG", TGSI_OPCODE_INEG
},
158 { 1, 2, 0, 0, 0, 0, "ISGE", TGSI_OPCODE_ISGE
},
159 { 1, 2, 0, 0, 0, 0, "ISHR", TGSI_OPCODE_ISHR
},
160 { 1, 2, 0, 0, 0, 0, "ISLT", TGSI_OPCODE_ISLT
},
161 { 1, 1, 0, 0, 0, 0, "F2U", TGSI_OPCODE_F2U
},
162 { 1, 1, 0, 0, 0, 0, "U2F", TGSI_OPCODE_U2F
},
163 { 1, 2, 0, 0, 0, 0, "UADD", TGSI_OPCODE_UADD
},
164 { 1, 2, 0, 0, 0, 0, "UDIV", TGSI_OPCODE_UDIV
},
165 { 1, 3, 0, 0, 0, 0, "UMAD", TGSI_OPCODE_UMAD
},
166 { 1, 2, 0, 0, 0, 0, "UMAX", TGSI_OPCODE_UMAX
},
167 { 1, 2, 0, 0, 0, 0, "UMIN", TGSI_OPCODE_UMIN
},
168 { 1, 2, 0, 0, 0, 0, "UMOD", TGSI_OPCODE_UMOD
},
169 { 1, 2, 0, 0, 0, 0, "UMUL", TGSI_OPCODE_UMUL
},
170 { 1, 2, 0, 0, 0, 0, "USEQ", TGSI_OPCODE_USEQ
},
171 { 1, 2, 0, 0, 0, 0, "USGE", TGSI_OPCODE_USGE
},
172 { 1, 2, 0, 0, 0, 0, "USHR", TGSI_OPCODE_USHR
},
173 { 1, 2, 0, 0, 0, 0, "USLT", TGSI_OPCODE_USLT
},
174 { 1, 2, 0, 0, 0, 0, "USNE", TGSI_OPCODE_USNE
},
175 { 0, 1, 0, 0, 0, 0, "SWITCH", TGSI_OPCODE_SWITCH
},
176 { 0, 1, 0, 0, 0, 0, "CASE", TGSI_OPCODE_CASE
},
177 { 0, 0, 0, 0, 0, 0, "DEFAULT", TGSI_OPCODE_DEFAULT
},
178 { 0, 0, 0, 0, 0, 0, "ENDSWITCH", TGSI_OPCODE_ENDSWITCH
},
180 { 1, 2, 0, 0, 0, 0, "LOAD", TGSI_OPCODE_LOAD
},
181 { 1, 2, 0, 0, 0, 0, "LOAD_MS", TGSI_OPCODE_LOAD_MS
},
182 { 1, 3, 0, 0, 0, 0, "SAMPLE", TGSI_OPCODE_SAMPLE
},
183 { 1, 4, 0, 0, 0, 0, "SAMPLE_B", TGSI_OPCODE_SAMPLE_B
},
184 { 1, 4, 0, 0, 0, 0, "SAMPLE_C", TGSI_OPCODE_SAMPLE_C
},
185 { 1, 4, 0, 0, 0, 0, "SAMPLE_C_LZ", TGSI_OPCODE_SAMPLE_C_LZ
},
186 { 1, 5, 0, 0, 0, 0, "SAMPLE_D", TGSI_OPCODE_SAMPLE_D
},
187 { 1, 3, 0, 0, 0, 0, "SAMPLE_L", TGSI_OPCODE_SAMPLE_L
},
188 { 1, 3, 0, 0, 0, 0, "GATHER4", TGSI_OPCODE_GATHER4
},
189 { 1, 2, 0, 0, 0, 0, "RESINFO", TGSI_OPCODE_RESINFO
},
190 { 1, 2, 0, 0, 0, 0, "SAMPLE_POS", TGSI_OPCODE_SAMPLE_POS
},
191 { 1, 2, 0, 0, 0, 0, "SAMPLE_INFO", TGSI_OPCODE_SAMPLE_INFO
},
194 const struct tgsi_opcode_info
*
195 tgsi_get_opcode_info( uint opcode
)
197 static boolean firsttime
= 1;
202 for (i
= 0; i
< Elements(opcode_info
); i
++)
203 assert(opcode_info
[i
].opcode
== i
);
206 if (opcode
< TGSI_OPCODE_LAST
)
207 return &opcode_info
[opcode
];
215 tgsi_get_opcode_name( uint opcode
)
217 const struct tgsi_opcode_info
*info
= tgsi_get_opcode_info(opcode
);
218 return info
->mnemonic
;
223 tgsi_get_processor_name( uint processor
)
226 case TGSI_PROCESSOR_VERTEX
:
227 return "vertex shader";
228 case TGSI_PROCESSOR_FRAGMENT
:
229 return "fragment shader";
230 case TGSI_PROCESSOR_GEOMETRY
:
231 return "geometry shader";
233 return "unknown shader type!";