summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/tgsi/tgsi_text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/tgsi/tgsi_text.c')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c164
1 files changed, 20 insertions, 144 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 35cb3055bb..9454563361 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -28,6 +28,7 @@
#include "pipe/p_debug.h"
#include "tgsi_text.h"
#include "tgsi_build.h"
+#include "tgsi_info.h"
#include "tgsi_parse.h"
#include "tgsi_sanity.h"
#include "tgsi_util.h"
@@ -50,11 +51,18 @@ static boolean is_digit_alpha_underscore( const char *cur )
return is_digit( cur ) || is_alpha_underscore( cur );
}
+static boolean uprcase( char c )
+{
+ if (c >= 'a' && c <= 'z')
+ return c += 'A' - 'a';
+ return c;
+}
+
static boolean str_match_no_case( const char **pcur, const char *str )
{
const char *cur = *pcur;
- while (*str != '\0' && *str == toupper( *cur )) {
+ while (*str != '\0' && *str == uprcase( *cur )) {
str++;
cur++;
}
@@ -130,7 +138,7 @@ static boolean parse_float( const char **pcur, float *val )
}
if (!integral_part && !fractional_part)
return FALSE;
- if (toupper( *cur ) == 'E') {
+ if (uprcase( *cur ) == 'E') {
cur++;
if (*cur == '-' || *cur == '+')
cur++;
@@ -257,19 +265,19 @@ parse_opt_writemask(
cur++;
*writemask = TGSI_WRITEMASK_NONE;
eat_opt_white( &cur );
- if (toupper( *cur ) == 'X') {
+ if (uprcase( *cur ) == 'X') {
cur++;
*writemask |= TGSI_WRITEMASK_X;
}
- if (toupper( *cur ) == 'Y') {
+ if (uprcase( *cur ) == 'Y') {
cur++;
*writemask |= TGSI_WRITEMASK_Y;
}
- if (toupper( *cur ) == 'Z') {
+ if (uprcase( *cur ) == 'Z') {
cur++;
*writemask |= TGSI_WRITEMASK_Z;
}
- if (toupper( *cur ) == 'W') {
+ if (uprcase( *cur ) == 'W') {
cur++;
*writemask |= TGSI_WRITEMASK_W;
}
@@ -515,13 +523,13 @@ parse_optional_swizzle(
cur++;
eat_opt_white( &cur );
for (i = 0; i < 4; i++) {
- if (toupper( *cur ) == 'X')
+ if (uprcase( *cur ) == 'X')
swizzle[i] = TGSI_SWIZZLE_X;
- else if (toupper( *cur ) == 'Y')
+ else if (uprcase( *cur ) == 'Y')
swizzle[i] = TGSI_SWIZZLE_Y;
- else if (toupper( *cur ) == 'Z')
+ else if (uprcase( *cur ) == 'Z')
swizzle[i] = TGSI_SWIZZLE_Z;
- else if (toupper( *cur ) == 'W')
+ else if (uprcase( *cur ) == 'W')
swizzle[i] = TGSI_SWIZZLE_W;
else {
if (*cur == '0')
@@ -719,138 +727,6 @@ parse_src_operand(
return TRUE;
}
-struct opcode_info
-{
- uint num_dst;
- uint num_src;
- uint is_tex;
- uint is_branch;
- const char *mnemonic;
-};
-
-static const struct opcode_info opcode_info[TGSI_OPCODE_LAST] =
-{
- { 1, 1, 0, 0, "ARL" },
- { 1, 1, 0, 0, "MOV" },
- { 1, 1, 0, 0, "LIT" },
- { 1, 1, 0, 0, "RCP" },
- { 1, 1, 0, 0, "RSQ" },
- { 1, 1, 0, 0, "EXP" },
- { 1, 1, 0, 0, "LOG" },
- { 1, 2, 0, 0, "MUL" },
- { 1, 2, 0, 0, "ADD" },
- { 1, 2, 0, 0, "DP3" },
- { 1, 2, 0, 0, "DP4" },
- { 1, 2, 0, 0, "DST" },
- { 1, 2, 0, 0, "MIN" },
- { 1, 2, 0, 0, "MAX" },
- { 1, 2, 0, 0, "SLT" },
- { 1, 2, 0, 0, "SGE" },
- { 1, 3, 0, 0, "MAD" },
- { 1, 2, 0, 0, "SUB" },
- { 1, 3, 0, 0, "LERP" },
- { 1, 3, 0, 0, "CND" },
- { 1, 3, 0, 0, "CND0" },
- { 1, 3, 0, 0, "DOT2ADD" },
- { 1, 2, 0, 0, "INDEX" },
- { 1, 1, 0, 0, "NEGATE" },
- { 1, 1, 0, 0, "FRAC" },
- { 1, 3, 0, 0, "CLAMP" },
- { 1, 1, 0, 0, "FLOOR" },
- { 1, 1, 0, 0, "ROUND" },
- { 1, 1, 0, 0, "EXPBASE2" },
- { 1, 1, 0, 0, "LOGBASE2" },
- { 1, 2, 0, 0, "POWER" },
- { 1, 2, 0, 0, "CROSSPRODUCT" },
- { 1, 2, 0, 0, "MULTIPLYMATRIX" },
- { 1, 1, 0, 0, "ABS" },
- { 1, 1, 0, 0, "RCC" },
- { 1, 2, 0, 0, "DPH" },
- { 1, 1, 0, 0, "COS" },
- { 1, 1, 0, 0, "DDX" },
- { 1, 1, 0, 0, "DDY" },
- { 0, 1, 0, 0, "KILP" },
- { 1, 1, 0, 0, "PK2H" },
- { 1, 1, 0, 0, "PK2US" },
- { 1, 1, 0, 0, "PK4B" },
- { 1, 1, 0, 0, "PK4UB" },
- { 1, 2, 0, 0, "RFL" },
- { 1, 2, 0, 0, "SEQ" },
- { 1, 2, 0, 0, "SFL" },
- { 1, 2, 0, 0, "SGT" },
- { 1, 1, 0, 0, "SIN" },
- { 1, 2, 0, 0, "SLE" },
- { 1, 2, 0, 0, "SNE" },
- { 1, 2, 0, 0, "STR" },
- { 1, 2, 1, 0, "TEX" },
- { 1, 4, 1, 0, "TXD" },
- { 1, 2, 1, 0, "TXP" },
- { 1, 1, 0, 0, "UP2H" },
- { 1, 1, 0, 0, "UP2US" },
- { 1, 1, 0, 0, "UP4B" },
- { 1, 1, 0, 0, "UP4UB" },
- { 1, 3, 0, 0, "X2D" },
- { 1, 1, 0, 0, "ARA" },
- { 1, 1, 0, 0, "ARR" },
- { 0, 1, 0, 0, "BRA" },
- { 0, 0, 0, 1, "CAL" },
- { 0, 0, 0, 0, "RET" },
- { 1, 1, 0, 0, "SSG" },
- { 1, 3, 0, 0, "CMP" },
- { 1, 1, 0, 0, "SCS" },
- { 1, 2, 1, 0, "TXB" },
- { 1, 1, 0, 0, "NRM" },
- { 1, 2, 0, 0, "DIV" },
- { 1, 2, 0, 0, "DP2" },
- { 1, 2, 1, 0, "TXL" },
- { 0, 0, 0, 0, "BRK" },
- { 0, 1, 0, 1, "IF" },
- { 0, 0, 0, 0, "LOOP" },
- { 0, 1, 0, 0, "REP" },
- { 0, 0, 0, 1, "ELSE" },
- { 0, 0, 0, 0, "ENDIF" },
- { 0, 0, 0, 0, "ENDLOOP" },
- { 0, 0, 0, 0, "ENDREP" },
- { 0, 1, 0, 0, "PUSHA" },
- { 1, 0, 0, 0, "POPA" },
- { 1, 1, 0, 0, "CEIL" },
- { 1, 1, 0, 0, "I2F" },
- { 1, 1, 0, 0, "NOT" },
- { 1, 1, 0, 0, "TRUNC" },
- { 1, 2, 0, 0, "SHL" },
- { 1, 2, 0, 0, "SHR" },
- { 1, 2, 0, 0, "AND" },
- { 1, 2, 0, 0, "OR" },
- { 1, 2, 0, 0, "MOD" },
- { 1, 2, 0, 0, "XOR" },
- { 1, 3, 0, 0, "SAD" },
- { 1, 2, 1, 0, "TXF" },
- { 1, 2, 1, 0, "TXQ" },
- { 0, 0, 0, 0, "CONT" },
- { 0, 0, 0, 0, "EMIT" },
- { 0, 0, 0, 0, "ENDPRIM" },
- { 0, 0, 0, 1, "BGNLOOP2" },
- { 0, 0, 0, 0, "BGNSUB" },
- { 0, 0, 0, 1, "ENDLOOP2" },
- { 0, 0, 0, 0, "ENDSUB" },
- { 1, 1, 0, 0, "NOISE1" },
- { 1, 1, 0, 0, "NOISE2" },
- { 1, 1, 0, 0, "NOISE3" },
- { 1, 1, 0, 0, "NOISE4" },
- { 0, 0, 0, 0, "NOP" },
- { 1, 2, 0, 0, "M4X3" },
- { 1, 2, 0, 0, "M3X4" },
- { 1, 2, 0, 0, "M3X3" },
- { 1, 2, 0, 0, "M3X2" },
- { 1, 1, 0, 0, "NRM4" },
- { 0, 1, 0, 0, "CALLNZ" },
- { 0, 1, 0, 0, "IFC" },
- { 0, 1, 0, 0, "BREAKC" },
- { 0, 0, 0, 0, "KIL" },
- { 0, 0, 0, 0, "END" },
- { 1, 1, 0, 0, "SWZ" }
-};
-
static const char *texture_names[TGSI_TEXTURE_COUNT] =
{
"UNKNOWN",
@@ -871,7 +747,7 @@ parse_instruction(
{
uint i;
uint saturate = TGSI_SAT_NONE;
- const struct opcode_info *info;
+ const struct tgsi_opcode_info *info;
struct tgsi_full_instruction inst;
uint advance;
@@ -881,7 +757,7 @@ parse_instruction(
for (i = 0; i < TGSI_OPCODE_LAST; i++) {
const char *cur = ctx->cur;
- info = &opcode_info[i];
+ info = tgsi_get_opcode_info( i );
if (str_match_no_case( &cur, info->mnemonic )) {
if (str_match_no_case( &cur, "_SATNV" ))
saturate = TGSI_SAT_MINUS_PLUS_ONE;