1188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle/* 2188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * Copyright 2009 Nicolai Hähnle <nhaehnle@gmail.com> 3188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * 4188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * Permission is hereby granted, free of charge, to any person obtaining a 5188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * copy of this software and associated documentation files (the "Software"), 6188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * to deal in the Software without restriction, including without limitation 7188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * on the rights to use, copy, modify, merge, publish, distribute, sub 8188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * license, and/or sell copies of the Software, and to permit persons to whom 9188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * the Software is furnished to do so, subject to the following conditions: 10188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * 11188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * The above copyright notice and this permission notice (including the next 12188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * paragraph) shall be included in all copies or substantial portions of the 13188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * Software. 14188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * 15188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * THE COPYRIGHT HOLDER(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * USE OR OTHER DEALINGS IN THE SOFTWARE. */ 22188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 23188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle#include "r300_tgsi_to_rc.h" 24188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 251c2c4ddbd1e97bfd13430521e5c09cb5ce8e36e6Marek Olšák#include "compiler/radeon_compiler.h" 26188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 274b8d3480764daf45cbbc03d76cd8b7c81937f532Marek Olšák#include "tgsi/tgsi_info.h" 28188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle#include "tgsi/tgsi_parse.h" 29188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle#include "tgsi/tgsi_scan.h" 30188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle#include "tgsi/tgsi_util.h" 31188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 32188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnlestatic unsigned translate_opcode(unsigned opcode) 33188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 34188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle switch(opcode) { 35d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_ARL: return RC_OPCODE_ARL; 36d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_MOV: return RC_OPCODE_MOV; 37d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_LIT: return RC_OPCODE_LIT; 38d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_RCP: return RC_OPCODE_RCP; 39d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_RSQ: return RC_OPCODE_RSQ; 40d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_EXP: return RC_OPCODE_EXP; 41d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_LOG: return RC_OPCODE_LOG; 42d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_MUL: return RC_OPCODE_MUL; 43d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_ADD: return RC_OPCODE_ADD; 44d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_DP3: return RC_OPCODE_DP3; 45d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_DP4: return RC_OPCODE_DP4; 46d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_DST: return RC_OPCODE_DST; 47d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_MIN: return RC_OPCODE_MIN; 48d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_MAX: return RC_OPCODE_MAX; 49d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SLT: return RC_OPCODE_SLT; 50d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SGE: return RC_OPCODE_SGE; 51d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_MAD: return RC_OPCODE_MAD; 52d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SUB: return RC_OPCODE_SUB; 53d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_LRP: return RC_OPCODE_LRP; 5420141d9efdf674a3c7a13a75fabe533665d02cd0Marek Olšák case TGSI_OPCODE_CND: return RC_OPCODE_CND; 55d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_DP2A: return RC_OPCODE_DP2A; */ 56188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle /* gap */ 57d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_FRC: return RC_OPCODE_FRC; 58e6d798948e00e255b80a69562a7d262257f77ee5Marek Olšák case TGSI_OPCODE_CLAMP: return RC_OPCODE_CLAMP; 59d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_FLR: return RC_OPCODE_FLR; 603d32e589879806297258e36ea80aae5044293ca3Tom Stellard case TGSI_OPCODE_ROUND: return RC_OPCODE_ROUND; 61d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_EX2: return RC_OPCODE_EX2; 62d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_LG2: return RC_OPCODE_LG2; 63d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_POW: return RC_OPCODE_POW; 64d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_XPD: return RC_OPCODE_XPD; 65188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle /* gap */ 66d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_ABS: return RC_OPCODE_ABS; 67d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_RCC: return RC_OPCODE_RCC; */ 68d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_DPH: return RC_OPCODE_DPH; 69d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_COS: return RC_OPCODE_COS; 70d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_DDX: return RC_OPCODE_DDX; 71d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_DDY: return RC_OPCODE_DDY; 72ce929d8210baf0ea66f32565285f0b33cd495e46Tom Stellard case TGSI_OPCODE_KILP: return RC_OPCODE_KILP; 73d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_PK2H: return RC_OPCODE_PK2H; */ 74d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_PK2US: return RC_OPCODE_PK2US; */ 75d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_PK4B: return RC_OPCODE_PK4B; */ 76d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_PK4UB: return RC_OPCODE_PK4UB; */ 77d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_RFL: return RC_OPCODE_RFL; */ 78d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SEQ: return RC_OPCODE_SEQ; 79d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SFL: return RC_OPCODE_SFL; 80d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SGT: return RC_OPCODE_SGT; 81d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SIN: return RC_OPCODE_SIN; 82d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SLE: return RC_OPCODE_SLE; 83d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SNE: return RC_OPCODE_SNE; 84d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_STR: return RC_OPCODE_STR; */ 85d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_TEX: return RC_OPCODE_TEX; 86d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_TXD: return RC_OPCODE_TXD; 87d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_TXP: return RC_OPCODE_TXP; 88d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_UP2H: return RC_OPCODE_UP2H; */ 89d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_UP2US: return RC_OPCODE_UP2US; */ 90d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_UP4B: return RC_OPCODE_UP4B; */ 91d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_UP4UB: return RC_OPCODE_UP4UB; */ 92d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_X2D: return RC_OPCODE_X2D; */ 93d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_ARA: return RC_OPCODE_ARA; */ 94d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_ARR: return RC_OPCODE_ARR; */ 95d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_BRA: return RC_OPCODE_BRA; */ 96d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_CAL: return RC_OPCODE_CAL; */ 97d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_RET: return RC_OPCODE_RET; */ 98b217167056970a9b7d09b7ffe863f013c2083395Marek Olšák case TGSI_OPCODE_SSG: return RC_OPCODE_SSG; 99d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_CMP: return RC_OPCODE_CMP; 100d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_SCS: return RC_OPCODE_SCS; 101d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_TXB: return RC_OPCODE_TXB; 102d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_NRM: return RC_OPCODE_NRM; */ 103d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_DIV: return RC_OPCODE_DIV; */ 10427eb2e275544d78a229eaded9bafc0db60172675Marek Olšák case TGSI_OPCODE_DP2: return RC_OPCODE_DP2; 105d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_TXL: return RC_OPCODE_TXL; 106622fd4d061678027d5de2c84d1c07370830c4264Tom Stellard case TGSI_OPCODE_BRK: return RC_OPCODE_BRK; 107b7cf887ca74561469c144f1d12227e1bcf277e7eNicolai Hähnle case TGSI_OPCODE_IF: return RC_OPCODE_IF; 108622fd4d061678027d5de2c84d1c07370830c4264Tom Stellard case TGSI_OPCODE_BGNLOOP: return RC_OPCODE_BGNLOOP; 109b7cf887ca74561469c144f1d12227e1bcf277e7eNicolai Hähnle case TGSI_OPCODE_ELSE: return RC_OPCODE_ELSE; 110b7cf887ca74561469c144f1d12227e1bcf277e7eNicolai Hähnle case TGSI_OPCODE_ENDIF: return RC_OPCODE_ENDIF; 111622fd4d061678027d5de2c84d1c07370830c4264Tom Stellard case TGSI_OPCODE_ENDLOOP: return RC_OPCODE_ENDLOOP; 112d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_PUSHA: return RC_OPCODE_PUSHA; */ 113d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_POPA: return RC_OPCODE_POPA; */ 114394803b2cd7fd9d4c0a394eb6998ccafec19bcd3Marek Olšák case TGSI_OPCODE_CEIL: return RC_OPCODE_CEIL; 115d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_I2F: return RC_OPCODE_I2F; */ 116d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_NOT: return RC_OPCODE_NOT; */ 1177f0fcf17c342dcb788c2182b20973c48806ee498Marek Olšák case TGSI_OPCODE_TRUNC: return RC_OPCODE_TRUNC; 118d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_SHL: return RC_OPCODE_SHL; */ 1192c046034dc5c95dd2fe84d0b4fd44f25235480b9Michal Krol /* case TGSI_OPCODE_ISHR: return RC_OPCODE_SHR; */ 120d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_AND: return RC_OPCODE_AND; */ 121d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_OR: return RC_OPCODE_OR; */ 122d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_MOD: return RC_OPCODE_MOD; */ 123d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_XOR: return RC_OPCODE_XOR; */ 124d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_SAD: return RC_OPCODE_SAD; */ 125d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_TXF: return RC_OPCODE_TXF; */ 126d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_TXQ: return RC_OPCODE_TXQ; */ 127f78445de5d2316934ebeaa19a616d2f960c89237Tom Stellard case TGSI_OPCODE_CONT: return RC_OPCODE_CONT; 128d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_EMIT: return RC_OPCODE_EMIT; */ 129d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_ENDPRIM: return RC_OPCODE_ENDPRIM; */ 130d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_BGNLOOP2: return RC_OPCODE_BGNLOOP2; */ 131d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_BGNSUB: return RC_OPCODE_BGNSUB; */ 132d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_ENDLOOP2: return RC_OPCODE_ENDLOOP2; */ 133d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_ENDSUB: return RC_OPCODE_ENDSUB; */ 134d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_NOP: return RC_OPCODE_NOP; 135188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle /* gap */ 136d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_NRM4: return RC_OPCODE_NRM4; */ 137d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_CALLNZ: return RC_OPCODE_CALLNZ; */ 138d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_IFC: return RC_OPCODE_IFC; */ 139d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* case TGSI_OPCODE_BREAKC: return RC_OPCODE_BREAKC; */ 140d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_OPCODE_KIL: return RC_OPCODE_KIL; 141188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle } 142188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 1434b8d3480764daf45cbbc03d76cd8b7c81937f532Marek Olšák fprintf(stderr, "r300: Unknown TGSI/RC opcode: %s\n", tgsi_get_opcode_name(opcode)); 144d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle return RC_OPCODE_ILLEGAL_OPCODE; 145188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 146188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 147188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnlestatic unsigned translate_saturate(unsigned saturate) 148188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 149188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle switch(saturate) { 150d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle default: 151d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle fprintf(stderr, "Unknown saturate mode: %i\n", saturate); 152d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* fall-through */ 153d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_SAT_NONE: return RC_SATURATE_NONE; 154d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_SAT_ZERO_ONE: return RC_SATURATE_ZERO_ONE; 155188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle } 156188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 157188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 158188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnlestatic unsigned translate_register_file(unsigned file) 159188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 160188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle switch(file) { 161d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_FILE_CONSTANT: return RC_FILE_CONSTANT; 162d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_FILE_IMMEDIATE: return RC_FILE_CONSTANT; 163d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_FILE_INPUT: return RC_FILE_INPUT; 164d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_FILE_OUTPUT: return RC_FILE_OUTPUT; 165d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle default: 166d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle fprintf(stderr, "Unhandled register file: %i\n", file); 167d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle /* fall-through */ 168d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_FILE_TEMPORARY: return RC_FILE_TEMPORARY; 169d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle case TGSI_FILE_ADDRESS: return RC_FILE_ADDRESS; 170188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle } 171188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 172188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 173188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnlestatic int translate_register_index( 174188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle struct tgsi_to_rc * ttr, 175188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle unsigned file, 176188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle int index) 177188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 178188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle if (file == TGSI_FILE_IMMEDIATE) 179188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle return ttr->immediate_offset + index; 180188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 181188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle return index; 182188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 183188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 184188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnlestatic void transform_dstreg( 185188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle struct tgsi_to_rc * ttr, 186d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle struct rc_dst_register * dst, 187188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle struct tgsi_full_dst_register * src) 188188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 1895b0824dfe5eaf59fa87134e7482b3d147b262901Keith Whitwell dst->File = translate_register_file(src->Register.File); 1905b0824dfe5eaf59fa87134e7482b3d147b262901Keith Whitwell dst->Index = translate_register_index(ttr, src->Register.File, src->Register.Index); 1915b0824dfe5eaf59fa87134e7482b3d147b262901Keith Whitwell dst->WriteMask = src->Register.WriteMask; 192ffcdd49c69811b9f768c0b32acef6527d5626a6eMarek Olšák 193ffcdd49c69811b9f768c0b32acef6527d5626a6eMarek Olšák if (src->Register.Indirect) { 194ffcdd49c69811b9f768c0b32acef6527d5626a6eMarek Olšák ttr->error = TRUE; 195ffcdd49c69811b9f768c0b32acef6527d5626a6eMarek Olšák fprintf(stderr, "r300: Relative addressing of destination operands " 196ffcdd49c69811b9f768c0b32acef6527d5626a6eMarek Olšák "is unsupported.\n"); 197ffcdd49c69811b9f768c0b32acef6527d5626a6eMarek Olšák } 198188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 199188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 200188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnlestatic void transform_srcreg( 201188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle struct tgsi_to_rc * ttr, 202d1b4351e603522be11061522cb6b685da9ef1feeNicolai Hähnle struct rc_src_register * dst, 203188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle struct tgsi_full_src_register * src) 204188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 2059a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson unsigned i, j; 2069a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson 20791a4e6d53f83c45c1da9240b6325011d96b61386Keith Whitwell dst->File = translate_register_file(src->Register.File); 20891a4e6d53f83c45c1da9240b6325011d96b61386Keith Whitwell dst->Index = translate_register_index(ttr, src->Register.File, src->Register.Index); 20991a4e6d53f83c45c1da9240b6325011d96b61386Keith Whitwell dst->RelAddr = src->Register.Indirect; 210b9cb74c7f826dfd320f5e5b54aa933898f7ddd3dKeith Whitwell dst->Swizzle = tgsi_util_get_full_src_register_swizzle(src, 0); 211b9cb74c7f826dfd320f5e5b54aa933898f7ddd3dKeith Whitwell dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 1) << 3; 212b9cb74c7f826dfd320f5e5b54aa933898f7ddd3dKeith Whitwell dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 2) << 6; 213b9cb74c7f826dfd320f5e5b54aa933898f7ddd3dKeith Whitwell dst->Swizzle |= tgsi_util_get_full_src_register_swizzle(src, 3) << 9; 21491a4e6d53f83c45c1da9240b6325011d96b61386Keith Whitwell dst->Abs = src->Register.Absolute; 21591a4e6d53f83c45c1da9240b6325011d96b61386Keith Whitwell dst->Negate = src->Register.Negate ? RC_MASK_XYZW : 0; 2169a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson 2179a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson if (src->Register.File == TGSI_FILE_IMMEDIATE) { 2189a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson for (i = 0; i < ttr->imms_to_swizzle_count; i++) { 2199a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson if (ttr->imms_to_swizzle[i].index == src->Register.Index) { 2209a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson dst->File = RC_FILE_TEMPORARY; 2219a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson dst->Index = 0; 2229a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson dst->Swizzle = 0; 2239a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson for (j = 0; j < 4; j++) { 2249a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson dst->Swizzle |= GET_SWZ(ttr->imms_to_swizzle[i].swizzle, 2259a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson tgsi_util_get_full_src_register_swizzle(src, j)) << (j * 3); 2269a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } 2279a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson break; 2289a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } 2299a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } 2309a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } 231188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 232188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 2336ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšákstatic void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src, 2346ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšák uint32_t *shadowSamplers) 235d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle{ 236d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle switch(src.Texture) { 237d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle case TGSI_TEXTURE_1D: 238995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexSrcTarget = RC_TEXTURE_1D; 239d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle break; 240d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle case TGSI_TEXTURE_2D: 241995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexSrcTarget = RC_TEXTURE_2D; 242d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle break; 243d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle case TGSI_TEXTURE_3D: 244995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexSrcTarget = RC_TEXTURE_3D; 245d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle break; 246d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle case TGSI_TEXTURE_CUBE: 247995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexSrcTarget = RC_TEXTURE_CUBE; 248d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle break; 249d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle case TGSI_TEXTURE_RECT: 250995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexSrcTarget = RC_TEXTURE_RECT; 251d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle break; 252d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle case TGSI_TEXTURE_SHADOW1D: 253995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexSrcTarget = RC_TEXTURE_1D; 254995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexShadow = 1; 2556ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšák *shadowSamplers |= 1 << dst->U.I.TexSrcUnit; 256d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle break; 257d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle case TGSI_TEXTURE_SHADOW2D: 258995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexSrcTarget = RC_TEXTURE_2D; 259995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexShadow = 1; 2606ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšák *shadowSamplers |= 1 << dst->U.I.TexSrcUnit; 261d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle break; 262d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle case TGSI_TEXTURE_SHADOWRECT: 263995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexSrcTarget = RC_TEXTURE_RECT; 264995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.TexShadow = 1; 2656ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšák *shadowSamplers |= 1 << dst->U.I.TexSrcUnit; 266d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle break; 267d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle } 268fe622bac0c1b5b9f2a9fcf9f35b51232a06bea42Tom Stellard dst->U.I.TexSwizzle = RC_SWIZZLE_XYZW; 269d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle} 270d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle 271188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnlestatic void transform_instruction(struct tgsi_to_rc * ttr, struct tgsi_full_instruction * src) 272188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 2731f39d59a2996e2acf6893a8dd1a0293bd8790cc2Joakim Sindholt struct rc_instruction * dst; 2741f39d59a2996e2acf6893a8dd1a0293bd8790cc2Joakim Sindholt int i; 2751f39d59a2996e2acf6893a8dd1a0293bd8790cc2Joakim Sindholt 2761f39d59a2996e2acf6893a8dd1a0293bd8790cc2Joakim Sindholt dst = rc_insert_new_instruction(ttr->compiler, ttr->compiler->Program.Instructions.Prev); 277995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.Opcode = translate_opcode(src->Instruction.Opcode); 278995135479d5662d1b1970c0f233c3c3d944d8b4dNicolai Hähnle dst->U.I.SaturateMode = translate_saturate(src->Instruction.Saturate); 279188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 280188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle if (src->Instruction.NumDstRegs) 2817d6c8f980d1e23ad6f557d650e89c715861a3b0cKeith Whitwell transform_dstreg(ttr, &dst->U.I.DstReg, &src->Dst[0]); 282188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 283d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle for(i = 0; i < src->Instruction.NumSrcRegs; ++i) { 28491a4e6d53f83c45c1da9240b6325011d96b61386Keith Whitwell if (src->Src[i].Register.File == TGSI_FILE_SAMPLER) 28591a4e6d53f83c45c1da9240b6325011d96b61386Keith Whitwell dst->U.I.TexSrcUnit = src->Src[i].Register.Index; 286d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle else 2877d6c8f980d1e23ad6f557d650e89c715861a3b0cKeith Whitwell transform_srcreg(ttr, &dst->U.I.SrcReg[i], &src->Src[i]); 288d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle } 289188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 290d0c398a8e2985b855f923aec3470cef8734a622aNicolai Hähnle /* Texturing. */ 29156ee132f9671f70ff2b3ee04659beac0dfc6126dKeith Whitwell if (src->Instruction.Texture) 2926ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšák transform_texture(dst, src->Texture, 2936ba83cd63f84a4d74dd679d62662d59533fd1bdbMarek Olšák &ttr->compiler->Program.ShadowSamplers); 294188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 295188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 2969a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpsonstatic void handle_immediate(struct tgsi_to_rc * ttr, 2979a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson struct tgsi_full_immediate * imm, 2989a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson unsigned index) 299188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 300188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle struct rc_constant constant; 3019a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson unsigned swizzle = 0; 3029a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson boolean can_swizzle = TRUE; 3039a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson unsigned i; 3049a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson 3059a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson for (i = 0; i < 4; i++) { 3069a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson if (imm->u[i].Float == 0.0f) { 3079a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson swizzle |= RC_SWIZZLE_ZERO << (i * 3); 308229db2b8ade33571e4cece1d838234895db220c2Corbin Simpson } else if (imm->u[i].Float == 0.5f && ttr->use_half_swizzles) { 3099a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson swizzle |= RC_SWIZZLE_HALF << (i * 3); 3109a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } else if (imm->u[i].Float == 1.0f) { 3119a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson swizzle |= RC_SWIZZLE_ONE << (i * 3); 3129a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } else { 3139a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson can_swizzle = FALSE; 3149a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson break; 3159a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } 3169a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } 3179a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson 3189a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson if (can_swizzle) { 319565f0cef26d6da49ae58462d0c1f9b832ee71174Corbin Simpson ttr->imms_to_swizzle[ttr->imms_to_swizzle_count].index = index; 320565f0cef26d6da49ae58462d0c1f9b832ee71174Corbin Simpson ttr->imms_to_swizzle[ttr->imms_to_swizzle_count].swizzle = swizzle; 3219a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson ttr->imms_to_swizzle_count++; 3229a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } else { 3239a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson constant.Type = RC_CONSTANT_IMMEDIATE; 3249a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson constant.Size = 4; 3259a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson for(i = 0; i < 4; ++i) 3269a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson constant.u.Immediate[i] = imm->u[i].Float; 3279a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson rc_constants_add(&ttr->compiler->Program.Constants, &constant); 3289a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson } 329188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 330188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 331229db2b8ade33571e4cece1d838234895db220c2Corbin Simpsonvoid r300_tgsi_to_rc(struct tgsi_to_rc * ttr, 332229db2b8ade33571e4cece1d838234895db220c2Corbin Simpson const struct tgsi_token * tokens) 333188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle{ 3344a16d325eb79d8c9da22df58aae4490bd79edabaMarek Olšák struct tgsi_full_instruction *inst; 335188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle struct tgsi_parse_context parser; 3369a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson unsigned imm_index = 0; 337188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle int i; 338188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 339ffcdd49c69811b9f768c0b32acef6527d5626a6eMarek Olšák ttr->error = FALSE; 340ffcdd49c69811b9f768c0b32acef6527d5626a6eMarek Olšák 341188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle /* Allocate constants placeholders. 342188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * 343188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle * Note: What if declared constants are not contiguous? */ 344188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle for(i = 0; i <= ttr->info->file_max[TGSI_FILE_CONSTANT]; ++i) { 345188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle struct rc_constant constant; 346188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle memset(&constant, 0, sizeof(constant)); 347188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle constant.Type = RC_CONSTANT_EXTERNAL; 348188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle constant.Size = 4; 349188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle constant.u.External = i; 350188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle rc_constants_add(&ttr->compiler->Program.Constants, &constant); 351188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle } 352188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 353188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle ttr->immediate_offset = ttr->compiler->Program.Constants.Count; 354188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 355565f0cef26d6da49ae58462d0c1f9b832ee71174Corbin Simpson ttr->imms_to_swizzle = malloc(ttr->info->immediate_count * sizeof(struct swizzled_imms)); 356565f0cef26d6da49ae58462d0c1f9b832ee71174Corbin Simpson ttr->imms_to_swizzle_count = 0; 357565f0cef26d6da49ae58462d0c1f9b832ee71174Corbin Simpson 358188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle tgsi_parse_init(&parser, tokens); 359188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 360188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle while (!tgsi_parse_end_of_tokens(&parser)) { 361188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle tgsi_parse_token(&parser); 362188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 363188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle switch (parser.FullToken.Token.Type) { 364188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle case TGSI_TOKEN_TYPE_DECLARATION: 365188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle break; 366188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle case TGSI_TOKEN_TYPE_IMMEDIATE: 3679a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson handle_immediate(ttr, &parser.FullToken.FullImmediate, imm_index); 3689a1bf52c184b6c0393543fe4bb03c790630b9e21Corbin Simpson imm_index++; 369188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle break; 370188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle case TGSI_TOKEN_TYPE_INSTRUCTION: 3714a16d325eb79d8c9da22df58aae4490bd79edabaMarek Olšák inst = &parser.FullToken.FullInstruction; 372b6e2c32626551791a33433913dfb4401f8c67cf4Marek Olšák if (inst->Instruction.Opcode == TGSI_OPCODE_END) { 3734a16d325eb79d8c9da22df58aae4490bd79edabaMarek Olšák break; 3744a16d325eb79d8c9da22df58aae4490bd79edabaMarek Olšák } 3754a16d325eb79d8c9da22df58aae4490bd79edabaMarek Olšák 3764a16d325eb79d8c9da22df58aae4490bd79edabaMarek Olšák transform_instruction(ttr, inst); 377188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle break; 378188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle } 379188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle } 380188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 381188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle tgsi_parse_free(&parser); 382188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle 383565f0cef26d6da49ae58462d0c1f9b832ee71174Corbin Simpson free(ttr->imms_to_swizzle); 384565f0cef26d6da49ae58462d0c1f9b832ee71174Corbin Simpson 385188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle rc_calculate_inputs_outputs(ttr->compiler); 386188f8c679254f193cdcfcd4ef338f3c8c5e1146dNicolai Hähnle} 387