1 /************************************************************************** 2 * 3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * All Rights Reserved. 5 * 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: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 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. 25 * 26 **************************************************************************/ 27 28 #include "util/u_debug.h" 29 #include "util/u_memory.h" 30 #include "tgsi_info.h" 31 32 #define NONE TGSI_OUTPUT_NONE 33 #define COMP TGSI_OUTPUT_COMPONENTWISE 34 #define REPL TGSI_OUTPUT_REPLICATE 35 #define CHAN TGSI_OUTPUT_CHAN_DEPENDENT 36 #define OTHR TGSI_OUTPUT_OTHER 37 38 static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] = 39 { 40 { 1, 1, 0, 0, 0, 0, COMP, "ARL", TGSI_OPCODE_ARL }, 41 { 1, 1, 0, 0, 0, 0, COMP, "MOV", TGSI_OPCODE_MOV }, 42 { 1, 1, 0, 0, 0, 0, CHAN, "LIT", TGSI_OPCODE_LIT }, 43 { 1, 1, 0, 0, 0, 0, REPL, "RCP", TGSI_OPCODE_RCP }, 44 { 1, 1, 0, 0, 0, 0, REPL, "RSQ", TGSI_OPCODE_RSQ }, 45 { 1, 1, 0, 0, 0, 0, CHAN, "EXP", TGSI_OPCODE_EXP }, 46 { 1, 1, 0, 0, 0, 0, CHAN, "LOG", TGSI_OPCODE_LOG }, 47 { 1, 2, 0, 0, 0, 0, COMP, "MUL", TGSI_OPCODE_MUL }, 48 { 1, 2, 0, 0, 0, 0, COMP, "ADD", TGSI_OPCODE_ADD }, 49 { 1, 2, 0, 0, 0, 0, REPL, "DP3", TGSI_OPCODE_DP3 }, 50 { 1, 2, 0, 0, 0, 0, REPL, "DP4", TGSI_OPCODE_DP4 }, 51 { 1, 2, 0, 0, 0, 0, CHAN, "DST", TGSI_OPCODE_DST }, 52 { 1, 2, 0, 0, 0, 0, COMP, "MIN", TGSI_OPCODE_MIN }, 53 { 1, 2, 0, 0, 0, 0, COMP, "MAX", TGSI_OPCODE_MAX }, 54 { 1, 2, 0, 0, 0, 0, COMP, "SLT", TGSI_OPCODE_SLT }, 55 { 1, 2, 0, 0, 0, 0, COMP, "SGE", TGSI_OPCODE_SGE }, 56 { 1, 3, 0, 0, 0, 0, COMP, "MAD", TGSI_OPCODE_MAD }, 57 { 1, 2, 0, 0, 0, 0, COMP, "SUB", TGSI_OPCODE_SUB }, 58 { 1, 3, 0, 0, 0, 0, COMP, "LRP", TGSI_OPCODE_LRP }, 59 { 1, 3, 0, 0, 0, 0, COMP, "CND", TGSI_OPCODE_CND }, 60 { 0, 0, 0, 0, 0, 0, NONE, "", 20 }, /* removed */ 61 { 1, 3, 0, 0, 0, 0, REPL, "DP2A", TGSI_OPCODE_DP2A }, 62 { 0, 0, 0, 0, 0, 0, NONE, "", 22 }, /* removed */ 63 { 0, 0, 0, 0, 0, 0, NONE, "", 23 }, /* removed */ 64 { 1, 1, 0, 0, 0, 0, COMP, "FRC", TGSI_OPCODE_FRC }, 65 { 1, 3, 0, 0, 0, 0, COMP, "CLAMP", TGSI_OPCODE_CLAMP }, 66 { 1, 1, 0, 0, 0, 0, COMP, "FLR", TGSI_OPCODE_FLR }, 67 { 1, 1, 0, 0, 0, 0, COMP, "ROUND", TGSI_OPCODE_ROUND }, 68 { 1, 1, 0, 0, 0, 0, REPL, "EX2", TGSI_OPCODE_EX2 }, 69 { 1, 1, 0, 0, 0, 0, REPL, "LG2", TGSI_OPCODE_LG2 }, 70 { 1, 2, 0, 0, 0, 0, REPL, "POW", TGSI_OPCODE_POW }, 71 { 1, 2, 0, 0, 0, 0, COMP, "XPD", TGSI_OPCODE_XPD }, 72 { 0, 0, 0, 0, 0, 0, NONE, "", 32 }, /* removed */ 73 { 1, 1, 0, 0, 0, 0, COMP, "ABS", TGSI_OPCODE_ABS }, 74 { 1, 1, 0, 0, 0, 0, REPL, "RCC", TGSI_OPCODE_RCC }, 75 { 1, 2, 0, 0, 0, 0, REPL, "DPH", TGSI_OPCODE_DPH }, 76 { 1, 1, 0, 0, 0, 0, REPL, "COS", TGSI_OPCODE_COS }, 77 { 1, 1, 0, 0, 0, 0, COMP, "DDX", TGSI_OPCODE_DDX }, 78 { 1, 1, 0, 0, 0, 0, COMP, "DDY", TGSI_OPCODE_DDY }, 79 { 0, 0, 0, 0, 0, 0, NONE, "KILP", TGSI_OPCODE_KILP }, 80 { 1, 1, 0, 0, 0, 0, COMP, "PK2H", TGSI_OPCODE_PK2H }, 81 { 1, 1, 0, 0, 0, 0, COMP, "PK2US", TGSI_OPCODE_PK2US }, 82 { 1, 1, 0, 0, 0, 0, COMP, "PK4B", TGSI_OPCODE_PK4B }, 83 { 1, 1, 0, 0, 0, 0, COMP, "PK4UB", TGSI_OPCODE_PK4UB }, 84 { 1, 2, 0, 0, 0, 0, COMP, "RFL", TGSI_OPCODE_RFL }, 85 { 1, 2, 0, 0, 0, 0, COMP, "SEQ", TGSI_OPCODE_SEQ }, 86 { 1, 2, 0, 0, 0, 0, REPL, "SFL", TGSI_OPCODE_SFL }, 87 { 1, 2, 0, 0, 0, 0, COMP, "SGT", TGSI_OPCODE_SGT }, 88 { 1, 1, 0, 0, 0, 0, REPL, "SIN", TGSI_OPCODE_SIN }, 89 { 1, 2, 0, 0, 0, 0, COMP, "SLE", TGSI_OPCODE_SLE }, 90 { 1, 2, 0, 0, 0, 0, COMP, "SNE", TGSI_OPCODE_SNE }, 91 { 1, 2, 0, 0, 0, 0, REPL, "STR", TGSI_OPCODE_STR }, 92 { 1, 2, 1, 0, 0, 0, OTHR, "TEX", TGSI_OPCODE_TEX }, 93 { 1, 4, 1, 0, 0, 0, OTHR, "TXD", TGSI_OPCODE_TXD }, 94 { 1, 2, 1, 0, 0, 0, OTHR, "TXP", TGSI_OPCODE_TXP }, 95 { 1, 1, 0, 0, 0, 0, COMP, "UP2H", TGSI_OPCODE_UP2H }, 96 { 1, 1, 0, 0, 0, 0, COMP, "UP2US", TGSI_OPCODE_UP2US }, 97 { 1, 1, 0, 0, 0, 0, COMP, "UP4B", TGSI_OPCODE_UP4B }, 98 { 1, 1, 0, 0, 0, 0, COMP, "UP4UB", TGSI_OPCODE_UP4UB }, 99 { 1, 3, 0, 0, 0, 0, COMP, "X2D", TGSI_OPCODE_X2D }, 100 { 1, 1, 0, 0, 0, 0, COMP, "ARA", TGSI_OPCODE_ARA }, 101 { 1, 1, 0, 0, 0, 0, COMP, "ARR", TGSI_OPCODE_ARR }, 102 { 0, 1, 0, 0, 0, 0, NONE, "BRA", TGSI_OPCODE_BRA }, 103 { 0, 0, 0, 1, 0, 0, NONE, "CAL", TGSI_OPCODE_CAL }, 104 { 0, 0, 0, 0, 0, 0, NONE, "RET", TGSI_OPCODE_RET }, 105 { 1, 1, 0, 0, 0, 0, COMP, "SSG", TGSI_OPCODE_SSG }, 106 { 1, 3, 0, 0, 0, 0, COMP, "CMP", TGSI_OPCODE_CMP }, 107 { 1, 1, 0, 0, 0, 0, CHAN, "SCS", TGSI_OPCODE_SCS }, 108 { 1, 2, 1, 0, 0, 0, OTHR, "TXB", TGSI_OPCODE_TXB }, 109 { 1, 1, 0, 0, 0, 0, COMP, "NRM", TGSI_OPCODE_NRM }, 110 { 1, 2, 0, 0, 0, 0, COMP, "DIV", TGSI_OPCODE_DIV }, 111 { 1, 2, 0, 0, 0, 0, REPL, "DP2", TGSI_OPCODE_DP2 }, 112 { 1, 2, 1, 0, 0, 0, OTHR, "TXL", TGSI_OPCODE_TXL }, 113 { 0, 0, 0, 0, 0, 0, NONE, "BRK", TGSI_OPCODE_BRK }, 114 { 0, 1, 0, 1, 0, 1, NONE, "IF", TGSI_OPCODE_IF }, 115 { 1, 1, 0, 0, 0, 1, NONE, "", 75 }, /* removed */ 116 { 0, 1, 0, 0, 0, 1, NONE, "", 76 }, /* removed */ 117 { 0, 0, 0, 1, 1, 1, NONE, "ELSE", TGSI_OPCODE_ELSE }, 118 { 0, 0, 0, 0, 1, 0, NONE, "ENDIF", TGSI_OPCODE_ENDIF }, 119 { 1, 0, 0, 0, 1, 0, NONE, "", 79 }, /* removed */ 120 { 0, 0, 0, 0, 1, 0, NONE, "", 80 }, /* removed */ 121 { 0, 1, 0, 0, 0, 0, NONE, "PUSHA", TGSI_OPCODE_PUSHA }, 122 { 1, 0, 0, 0, 0, 0, NONE, "POPA", TGSI_OPCODE_POPA }, 123 { 1, 1, 0, 0, 0, 0, COMP, "CEIL", TGSI_OPCODE_CEIL }, 124 { 1, 1, 0, 0, 0, 0, COMP, "I2F", TGSI_OPCODE_I2F }, 125 { 1, 1, 0, 0, 0, 0, COMP, "NOT", TGSI_OPCODE_NOT }, 126 { 1, 1, 0, 0, 0, 0, COMP, "TRUNC", TGSI_OPCODE_TRUNC }, 127 { 1, 2, 0, 0, 0, 0, COMP, "SHL", TGSI_OPCODE_SHL }, 128 { 0, 0, 0, 0, 0, 0, NONE, "", 88 }, /* removed */ 129 { 1, 2, 0, 0, 0, 0, COMP, "AND", TGSI_OPCODE_AND }, 130 { 1, 2, 0, 0, 0, 0, COMP, "OR", TGSI_OPCODE_OR }, 131 { 1, 2, 0, 0, 0, 0, COMP, "MOD", TGSI_OPCODE_MOD }, 132 { 1, 2, 0, 0, 0, 0, COMP, "XOR", TGSI_OPCODE_XOR }, 133 { 1, 3, 0, 0, 0, 0, COMP, "SAD", TGSI_OPCODE_SAD }, 134 { 1, 2, 1, 0, 0, 0, OTHR, "TXF", TGSI_OPCODE_TXF }, 135 { 1, 2, 1, 0, 0, 0, OTHR, "TXQ", TGSI_OPCODE_TXQ }, 136 { 0, 0, 0, 0, 0, 0, NONE, "CONT", TGSI_OPCODE_CONT }, 137 { 0, 0, 0, 0, 0, 0, NONE, "EMIT", TGSI_OPCODE_EMIT }, 138 { 0, 0, 0, 0, 0, 0, NONE, "ENDPRIM", TGSI_OPCODE_ENDPRIM }, 139 { 0, 0, 0, 1, 0, 1, NONE, "BGNLOOP", TGSI_OPCODE_BGNLOOP }, 140 { 0, 0, 0, 0, 0, 1, NONE, "BGNSUB", TGSI_OPCODE_BGNSUB }, 141 { 0, 0, 0, 1, 1, 0, NONE, "ENDLOOP", TGSI_OPCODE_ENDLOOP }, 142 { 0, 0, 0, 0, 1, 0, NONE, "ENDSUB", TGSI_OPCODE_ENDSUB }, 143 { 1, 1, 1, 0, 0, 0, OTHR, "TXQ_LZ", TGSI_OPCODE_TXQ_LZ }, 144 { 0, 0, 0, 0, 0, 0, NONE, "", 104 }, /* removed */ 145 { 0, 0, 0, 0, 0, 0, NONE, "", 105 }, /* removed */ 146 { 0, 0, 0, 0, 0, 0, NONE, "", 106 }, /* removed */ 147 { 0, 0, 0, 0, 0, 0, NONE, "NOP", TGSI_OPCODE_NOP }, 148 { 0, 0, 0, 0, 0, 0, NONE, "", 108 }, /* removed */ 149 { 0, 0, 0, 0, 0, 0, NONE, "", 109 }, /* removed */ 150 { 0, 0, 0, 0, 0, 0, NONE, "", 110 }, /* removed */ 151 { 0, 0, 0, 0, 0, 0, NONE, "", 111 }, /* removed */ 152 { 1, 1, 0, 0, 0, 0, REPL, "NRM4", TGSI_OPCODE_NRM4 }, 153 { 0, 1, 0, 0, 0, 0, NONE, "CALLNZ", TGSI_OPCODE_CALLNZ }, 154 { 0, 1, 0, 0, 0, 0, NONE, "IFC", TGSI_OPCODE_IFC }, 155 { 0, 1, 0, 0, 0, 0, NONE, "BREAKC", TGSI_OPCODE_BREAKC }, 156 { 0, 1, 0, 0, 0, 0, NONE, "KIL", TGSI_OPCODE_KIL }, 157 { 0, 0, 0, 0, 0, 0, NONE, "END", TGSI_OPCODE_END }, 158 { 0, 0, 0, 0, 0, 0, NONE, "", 118 }, /* removed */ 159 { 1, 1, 0, 0, 0, 0, COMP, "F2I", TGSI_OPCODE_F2I }, 160 { 1, 2, 0, 0, 0, 0, COMP, "IDIV", TGSI_OPCODE_IDIV }, 161 { 1, 2, 0, 0, 0, 0, COMP, "IMAX", TGSI_OPCODE_IMAX }, 162 { 1, 2, 0, 0, 0, 0, COMP, "IMIN", TGSI_OPCODE_IMIN }, 163 { 1, 1, 0, 0, 0, 0, COMP, "INEG", TGSI_OPCODE_INEG }, 164 { 1, 2, 0, 0, 0, 0, COMP, "ISGE", TGSI_OPCODE_ISGE }, 165 { 1, 2, 0, 0, 0, 0, COMP, "ISHR", TGSI_OPCODE_ISHR }, 166 { 1, 2, 0, 0, 0, 0, COMP, "ISLT", TGSI_OPCODE_ISLT }, 167 { 1, 1, 0, 0, 0, 0, COMP, "F2U", TGSI_OPCODE_F2U }, 168 { 1, 1, 0, 0, 0, 0, COMP, "U2F", TGSI_OPCODE_U2F }, 169 { 1, 2, 0, 0, 0, 0, COMP, "UADD", TGSI_OPCODE_UADD }, 170 { 1, 2, 0, 0, 0, 0, COMP, "UDIV", TGSI_OPCODE_UDIV }, 171 { 1, 3, 0, 0, 0, 0, COMP, "UMAD", TGSI_OPCODE_UMAD }, 172 { 1, 2, 0, 0, 0, 0, COMP, "UMAX", TGSI_OPCODE_UMAX }, 173 { 1, 2, 0, 0, 0, 0, COMP, "UMIN", TGSI_OPCODE_UMIN }, 174 { 1, 2, 0, 0, 0, 0, COMP, "UMOD", TGSI_OPCODE_UMOD }, 175 { 1, 2, 0, 0, 0, 0, COMP, "UMUL", TGSI_OPCODE_UMUL }, 176 { 1, 2, 0, 0, 0, 0, COMP, "USEQ", TGSI_OPCODE_USEQ }, 177 { 1, 2, 0, 0, 0, 0, COMP, "USGE", TGSI_OPCODE_USGE }, 178 { 1, 2, 0, 0, 0, 0, COMP, "USHR", TGSI_OPCODE_USHR }, 179 { 1, 2, 0, 0, 0, 0, COMP, "USLT", TGSI_OPCODE_USLT }, 180 { 1, 2, 0, 0, 0, 0, COMP, "USNE", TGSI_OPCODE_USNE }, 181 { 0, 1, 0, 0, 0, 0, NONE, "SWITCH", TGSI_OPCODE_SWITCH }, 182 { 0, 1, 0, 0, 0, 0, NONE, "CASE", TGSI_OPCODE_CASE }, 183 { 0, 0, 0, 0, 0, 0, NONE, "DEFAULT", TGSI_OPCODE_DEFAULT }, 184 { 0, 0, 0, 0, 0, 0, NONE, "ENDSWITCH", TGSI_OPCODE_ENDSWITCH }, 185 186 { 1, 3, 0, 0, 0, 0, OTHR, "SAMPLE", TGSI_OPCODE_SAMPLE }, 187 { 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_I", TGSI_OPCODE_SAMPLE_I }, 188 { 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_I_MS", TGSI_OPCODE_SAMPLE_I_MS }, 189 { 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_B", TGSI_OPCODE_SAMPLE_B }, 190 { 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_C", TGSI_OPCODE_SAMPLE_C }, 191 { 1, 4, 0, 0, 0, 0, OTHR, "SAMPLE_C_LZ", TGSI_OPCODE_SAMPLE_C_LZ }, 192 { 1, 5, 0, 0, 0, 0, OTHR, "SAMPLE_D", TGSI_OPCODE_SAMPLE_D }, 193 { 1, 3, 0, 0, 0, 0, OTHR, "SAMPLE_L", TGSI_OPCODE_SAMPLE_L }, 194 { 1, 3, 0, 0, 0, 0, OTHR, "GATHER4", TGSI_OPCODE_GATHER4 }, 195 { 1, 2, 0, 0, 0, 0, OTHR, "SVIEWINFO", TGSI_OPCODE_SVIEWINFO }, 196 { 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_POS", TGSI_OPCODE_SAMPLE_POS }, 197 { 1, 2, 0, 0, 0, 0, OTHR, "SAMPLE_INFO", TGSI_OPCODE_SAMPLE_INFO }, 198 { 1, 1, 0, 0, 0, 0, COMP, "UARL", TGSI_OPCODE_UARL }, 199 { 1, 3, 0, 0, 0, 0, COMP, "UCMP", TGSI_OPCODE_UCMP }, 200 { 1, 1, 0, 0, 0, 0, COMP, "IABS", TGSI_OPCODE_IABS }, 201 { 1, 1, 0, 0, 0, 0, COMP, "ISSG", TGSI_OPCODE_ISSG }, 202 { 1, 2, 0, 0, 0, 0, OTHR, "LOAD", TGSI_OPCODE_LOAD }, 203 { 1, 2, 0, 0, 0, 0, OTHR, "STORE", TGSI_OPCODE_STORE }, 204 { 1, 0, 0, 0, 0, 0, OTHR, "MFENCE", TGSI_OPCODE_MFENCE }, 205 { 1, 0, 0, 0, 0, 0, OTHR, "LFENCE", TGSI_OPCODE_LFENCE }, 206 { 1, 0, 0, 0, 0, 0, OTHR, "SFENCE", TGSI_OPCODE_SFENCE }, 207 { 0, 0, 0, 0, 0, 0, OTHR, "BARRIER", TGSI_OPCODE_BARRIER }, 208 209 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMUADD", TGSI_OPCODE_ATOMUADD }, 210 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMXCHG", TGSI_OPCODE_ATOMXCHG }, 211 { 1, 4, 0, 0, 0, 0, OTHR, "ATOMCAS", TGSI_OPCODE_ATOMCAS }, 212 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMAND", TGSI_OPCODE_ATOMAND }, 213 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMOR", TGSI_OPCODE_ATOMOR }, 214 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMXOR", TGSI_OPCODE_ATOMXOR }, 215 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMUMIN", TGSI_OPCODE_ATOMUMIN }, 216 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMUMAX", TGSI_OPCODE_ATOMUMAX }, 217 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMIMIN", TGSI_OPCODE_ATOMIMIN }, 218 { 1, 3, 0, 0, 0, 0, OTHR, "ATOMIMAX", TGSI_OPCODE_ATOMIMAX } 219 }; 220 221 const struct tgsi_opcode_info * 222 tgsi_get_opcode_info( uint opcode ) 223 { 224 static boolean firsttime = 1; 225 226 if (firsttime) { 227 unsigned i; 228 firsttime = 0; 229 for (i = 0; i < Elements(opcode_info); i++) 230 assert(opcode_info[i].opcode == i); 231 } 232 233 if (opcode < TGSI_OPCODE_LAST) 234 return &opcode_info[opcode]; 235 236 assert( 0 ); 237 return NULL; 238 } 239 240 241 const char * 242 tgsi_get_opcode_name( uint opcode ) 243 { 244 const struct tgsi_opcode_info *info = tgsi_get_opcode_info(opcode); 245 return info->mnemonic; 246 } 247 248 249 const char * 250 tgsi_get_processor_name( uint processor ) 251 { 252 switch (processor) { 253 case TGSI_PROCESSOR_VERTEX: 254 return "vertex shader"; 255 case TGSI_PROCESSOR_FRAGMENT: 256 return "fragment shader"; 257 case TGSI_PROCESSOR_GEOMETRY: 258 return "geometry shader"; 259 default: 260 return "unknown shader type!"; 261 } 262 } 263 264 /* 265 * infer the source type of a TGSI opcode. 266 * MOV is special so return VOID 267 */ 268 enum tgsi_opcode_type 269 tgsi_opcode_infer_src_type( uint opcode ) 270 { 271 switch (opcode) { 272 case TGSI_OPCODE_MOV: 273 return TGSI_TYPE_UNTYPED; 274 case TGSI_OPCODE_AND: 275 case TGSI_OPCODE_OR: 276 case TGSI_OPCODE_XOR: 277 case TGSI_OPCODE_SAD: 278 case TGSI_OPCODE_U2F: 279 case TGSI_OPCODE_UADD: 280 case TGSI_OPCODE_UDIV: 281 case TGSI_OPCODE_UMOD: 282 case TGSI_OPCODE_UMAD: 283 case TGSI_OPCODE_UMUL: 284 case TGSI_OPCODE_UMAX: 285 case TGSI_OPCODE_UMIN: 286 case TGSI_OPCODE_USEQ: 287 case TGSI_OPCODE_USGE: 288 case TGSI_OPCODE_USLT: 289 case TGSI_OPCODE_USNE: 290 case TGSI_OPCODE_USHR: 291 case TGSI_OPCODE_SHL: 292 case TGSI_OPCODE_TXQ: 293 return TGSI_TYPE_UNSIGNED; 294 case TGSI_OPCODE_MOD: 295 case TGSI_OPCODE_I2F: 296 case TGSI_OPCODE_IDIV: 297 case TGSI_OPCODE_IMAX: 298 case TGSI_OPCODE_IMIN: 299 case TGSI_OPCODE_INEG: 300 case TGSI_OPCODE_ISGE: 301 case TGSI_OPCODE_ISHR: 302 case TGSI_OPCODE_ISLT: 303 case TGSI_OPCODE_IABS: 304 case TGSI_OPCODE_ISSG: 305 case TGSI_OPCODE_UARL: 306 return TGSI_TYPE_SIGNED; 307 default: 308 return TGSI_TYPE_FLOAT; 309 } 310 } 311 312 /* 313 * infer the destination type of a TGSI opcode. 314 * MOV is special so return VOID 315 */ 316 enum tgsi_opcode_type 317 tgsi_opcode_infer_dst_type( uint opcode ) 318 { 319 switch (opcode) { 320 case TGSI_OPCODE_MOV: 321 return TGSI_TYPE_UNTYPED; 322 case TGSI_OPCODE_F2U: 323 case TGSI_OPCODE_AND: 324 case TGSI_OPCODE_OR: 325 case TGSI_OPCODE_XOR: 326 case TGSI_OPCODE_SAD: 327 case TGSI_OPCODE_UADD: 328 case TGSI_OPCODE_UDIV: 329 case TGSI_OPCODE_UMOD: 330 case TGSI_OPCODE_UMAD: 331 case TGSI_OPCODE_UMUL: 332 case TGSI_OPCODE_UMAX: 333 case TGSI_OPCODE_UMIN: 334 case TGSI_OPCODE_USEQ: 335 case TGSI_OPCODE_USGE: 336 case TGSI_OPCODE_USLT: 337 case TGSI_OPCODE_USNE: 338 case TGSI_OPCODE_USHR: 339 case TGSI_OPCODE_SHL: 340 case TGSI_OPCODE_TXQ: 341 case TGSI_OPCODE_TXQ_LZ: 342 return TGSI_TYPE_UNSIGNED; 343 case TGSI_OPCODE_F2I: 344 case TGSI_OPCODE_IDIV: 345 case TGSI_OPCODE_IMAX: 346 case TGSI_OPCODE_IMIN: 347 case TGSI_OPCODE_INEG: 348 case TGSI_OPCODE_ISGE: 349 case TGSI_OPCODE_ISHR: 350 case TGSI_OPCODE_ISLT: 351 case TGSI_OPCODE_MOD: 352 case TGSI_OPCODE_UARL: 353 case TGSI_OPCODE_ARL: 354 case TGSI_OPCODE_ARR: 355 case TGSI_OPCODE_IABS: 356 case TGSI_OPCODE_ISSG: 357 return TGSI_TYPE_SIGNED; 358 default: 359 return TGSI_TYPE_FLOAT; 360 } 361 } 362