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 "pipe/p_defines.h"
31 #include "tgsi_text.h"
32 #include "tgsi_build.h"
33 #include "tgsi_info.h"
34 #include "tgsi_parse.h"
35 #include "tgsi_sanity.h"
36 #include "tgsi_util.h"
38 static boolean
is_alpha_underscore( const char *cur
)
41 (*cur
>= 'a' && *cur
<= 'z') ||
42 (*cur
>= 'A' && *cur
<= 'Z') ||
46 static boolean
is_digit( const char *cur
)
48 return *cur
>= '0' && *cur
<= '9';
51 static boolean
is_digit_alpha_underscore( const char *cur
)
53 return is_digit( cur
) || is_alpha_underscore( cur
);
56 static boolean
uprcase( char c
)
58 if (c
>= 'a' && c
<= 'z')
59 return c
+= 'A' - 'a';
64 * Ignore case of str1 and assume str2 is already uppercase.
65 * Return TRUE iff str1 and str2 are equal.
68 streq_nocase_uprcase(const char *str1
,
71 while (*str1
&& uprcase(*str1
) == *str2
) {
75 return *str1
== *str2
;
78 static boolean
str_match_no_case( const char **pcur
, const char *str
)
80 const char *cur
= *pcur
;
82 while (*str
!= '\0' && *str
== uprcase( *cur
)) {
93 /* Eat zero or more whitespaces.
95 static void eat_opt_white( const char **pcur
)
97 while (**pcur
== ' ' || **pcur
== '\t' || **pcur
== '\n')
101 /* Eat one or more whitespaces.
102 * Return TRUE if at least one whitespace eaten.
104 static boolean
eat_white( const char **pcur
)
106 const char *cur
= *pcur
;
108 eat_opt_white( pcur
);
112 /* Parse unsigned integer.
113 * No checks for overflow.
115 static boolean
parse_uint( const char **pcur
, uint
*val
)
117 const char *cur
= *pcur
;
119 if (is_digit( cur
)) {
121 while (is_digit( cur
))
122 *val
= *val
* 10 + *cur
++ - '0';
129 static boolean
parse_identifier( const char **pcur
, char *ret
)
131 const char *cur
= *pcur
;
133 if (is_alpha_underscore( cur
)) {
135 while (is_alpha_underscore( cur
))
143 /* Parse floating point.
145 static boolean
parse_float( const char **pcur
, float *val
)
147 const char *cur
= *pcur
;
148 boolean integral_part
= FALSE
;
149 boolean fractional_part
= FALSE
;
151 *val
= (float) atof( cur
);
153 if (*cur
== '-' || *cur
== '+')
155 if (is_digit( cur
)) {
157 integral_part
= TRUE
;
158 while (is_digit( cur
))
163 if (is_digit( cur
)) {
165 fractional_part
= TRUE
;
166 while (is_digit( cur
))
170 if (!integral_part
&& !fractional_part
)
172 if (uprcase( *cur
) == 'E') {
174 if (*cur
== '-' || *cur
== '+')
176 if (is_digit( cur
)) {
178 while (is_digit( cur
))
192 struct tgsi_token
*tokens
;
193 struct tgsi_token
*tokens_cur
;
194 struct tgsi_token
*tokens_end
;
195 struct tgsi_header
*header
;
198 static void report_error( struct translate_ctx
*ctx
, const char *msg
)
200 debug_printf( "\nError: %s", msg
);
203 /* Parse shader header.
204 * Return TRUE for one of the following headers.
209 static boolean
parse_header( struct translate_ctx
*ctx
)
213 if (str_match_no_case( &ctx
->cur
, "FRAG" ))
214 processor
= TGSI_PROCESSOR_FRAGMENT
;
215 else if (str_match_no_case( &ctx
->cur
, "VERT" ))
216 processor
= TGSI_PROCESSOR_VERTEX
;
217 else if (str_match_no_case( &ctx
->cur
, "GEOM" ))
218 processor
= TGSI_PROCESSOR_GEOMETRY
;
220 report_error( ctx
, "Unknown header" );
224 if (ctx
->tokens_cur
>= ctx
->tokens_end
)
226 ctx
->header
= (struct tgsi_header
*) ctx
->tokens_cur
++;
227 *ctx
->header
= tgsi_build_header();
229 if (ctx
->tokens_cur
>= ctx
->tokens_end
)
231 *(struct tgsi_processor
*) ctx
->tokens_cur
++ = tgsi_build_processor( processor
, ctx
->header
);
236 static boolean
parse_label( struct translate_ctx
*ctx
, uint
*val
)
238 const char *cur
= ctx
->cur
;
240 if (parse_uint( &cur
, val
)) {
241 eat_opt_white( &cur
);
251 static const char *file_names
[TGSI_FILE_COUNT
] =
267 parse_file( const char **pcur
, uint
*file
)
271 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
272 const char *cur
= *pcur
;
274 if (str_match_no_case( &cur
, file_names
[i
] )) {
275 if (!is_digit_alpha_underscore( cur
)) {
287 struct translate_ctx
*ctx
,
293 eat_opt_white( &cur
);
296 *writemask
= TGSI_WRITEMASK_NONE
;
297 eat_opt_white( &cur
);
298 if (uprcase( *cur
) == 'X') {
300 *writemask
|= TGSI_WRITEMASK_X
;
302 if (uprcase( *cur
) == 'Y') {
304 *writemask
|= TGSI_WRITEMASK_Y
;
306 if (uprcase( *cur
) == 'Z') {
308 *writemask
|= TGSI_WRITEMASK_Z
;
310 if (uprcase( *cur
) == 'W') {
312 *writemask
|= TGSI_WRITEMASK_W
;
315 if (*writemask
== TGSI_WRITEMASK_NONE
) {
316 report_error( ctx
, "Writemask expected" );
323 *writemask
= TGSI_WRITEMASK_XYZW
;
328 /* <register_file_bracket> ::= <file> `['
331 parse_register_file_bracket(
332 struct translate_ctx
*ctx
,
335 if (!parse_file( &ctx
->cur
, file
)) {
336 report_error( ctx
, "Unknown register file" );
339 eat_opt_white( &ctx
->cur
);
340 if (*ctx
->cur
!= '[') {
341 report_error( ctx
, "Expected `['" );
348 /* <register_file_bracket_index> ::= <register_file_bracket> <uint>
351 parse_register_file_bracket_index(
352 struct translate_ctx
*ctx
,
358 if (!parse_register_file_bracket( ctx
, file
))
360 eat_opt_white( &ctx
->cur
);
361 if (!parse_uint( &ctx
->cur
, &uindex
)) {
362 report_error( ctx
, "Expected literal unsigned integer" );
365 *index
= (int) uindex
;
369 /* Parse destination register operand.
370 * <register_dst> ::= <register_file_bracket_index> `]'
374 struct translate_ctx
*ctx
,
378 if (!parse_register_file_bracket_index( ctx
, file
, index
))
380 eat_opt_white( &ctx
->cur
);
381 if (*ctx
->cur
!= ']') {
382 report_error( ctx
, "Expected `]'" );
389 /* Parse source register operand.
390 * <register_src> ::= <register_file_bracket_index> `]' |
391 * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `]' |
392 * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `+' <uint> `]' |
393 * <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `-' <uint> `]'
397 struct translate_ctx
*ctx
,
407 *ind_comp
= TGSI_SWIZZLE_X
;
408 if (!parse_register_file_bracket( ctx
, file
))
410 eat_opt_white( &ctx
->cur
);
412 if (parse_file( &cur
, ind_file
)) {
413 if (!parse_register_dst( ctx
, ind_file
, ind_index
))
415 eat_opt_white( &ctx
->cur
);
417 if (*ctx
->cur
== '.') {
419 eat_opt_white(&ctx
->cur
);
421 switch (uprcase(*ctx
->cur
)) {
423 *ind_comp
= TGSI_SWIZZLE_X
;
426 *ind_comp
= TGSI_SWIZZLE_Y
;
429 *ind_comp
= TGSI_SWIZZLE_Z
;
432 *ind_comp
= TGSI_SWIZZLE_W
;
435 report_error(ctx
, "Expected indirect register swizzle component `x', `y', `z' or `w'");
439 eat_opt_white(&ctx
->cur
);
442 if (*ctx
->cur
== '+' || *ctx
->cur
== '-') {
445 negate
= *ctx
->cur
== '-';
447 eat_opt_white( &ctx
->cur
);
448 if (!parse_uint( &ctx
->cur
, &uindex
)) {
449 report_error( ctx
, "Expected literal unsigned integer" );
453 *index
= -(int) uindex
;
455 *index
= (int) uindex
;
462 if (!parse_uint( &ctx
->cur
, &uindex
)) {
463 report_error( ctx
, "Expected literal unsigned integer" );
466 *index
= (int) uindex
;
467 *ind_file
= TGSI_FILE_NULL
;
470 eat_opt_white( &ctx
->cur
);
471 if (*ctx
->cur
!= ']') {
472 report_error( ctx
, "Expected `]'" );
479 /* Parse register declaration.
480 * <register_dcl> ::= <register_file_bracket_index> `]' |
481 * <register_file_bracket_index> `..' <index> `]'
485 struct translate_ctx
*ctx
,
490 if (!parse_register_file_bracket_index( ctx
, file
, first
))
492 eat_opt_white( &ctx
->cur
);
493 if (ctx
->cur
[0] == '.' && ctx
->cur
[1] == '.') {
497 eat_opt_white( &ctx
->cur
);
498 if (!parse_uint( &ctx
->cur
, &uindex
)) {
499 report_error( ctx
, "Expected literal integer" );
502 *last
= (int) uindex
;
503 eat_opt_white( &ctx
->cur
);
508 if (*ctx
->cur
!= ']') {
509 report_error( ctx
, "Expected `]' or `..'" );
519 struct translate_ctx
*ctx
,
520 struct tgsi_full_dst_register
*dst
)
527 if (!parse_register_dst( ctx
, &file
, &index
))
531 eat_opt_white( &cur
);
533 if (!parse_opt_writemask( ctx
, &writemask
))
536 dst
->Register
.File
= file
;
537 dst
->Register
.Index
= index
;
538 dst
->Register
.WriteMask
= writemask
;
543 parse_optional_swizzle(
544 struct translate_ctx
*ctx
,
546 boolean
*parsed_swizzle
)
548 const char *cur
= ctx
->cur
;
550 *parsed_swizzle
= FALSE
;
552 eat_opt_white( &cur
);
557 eat_opt_white( &cur
);
558 for (i
= 0; i
< 4; i
++) {
559 if (uprcase( *cur
) == 'X')
560 swizzle
[i
] = TGSI_SWIZZLE_X
;
561 else if (uprcase( *cur
) == 'Y')
562 swizzle
[i
] = TGSI_SWIZZLE_Y
;
563 else if (uprcase( *cur
) == 'Z')
564 swizzle
[i
] = TGSI_SWIZZLE_Z
;
565 else if (uprcase( *cur
) == 'W')
566 swizzle
[i
] = TGSI_SWIZZLE_W
;
568 report_error( ctx
, "Expected register swizzle component `x', `y', `z', `w', `0' or `1'" );
573 *parsed_swizzle
= TRUE
;
581 struct translate_ctx
*ctx
,
582 struct tgsi_full_src_register
*src
)
590 boolean parsed_swizzle
;
592 if (*ctx
->cur
== '-') {
594 eat_opt_white( &ctx
->cur
);
595 src
->Register
.Negate
= 1;
598 if (*ctx
->cur
== '|') {
600 eat_opt_white( &ctx
->cur
);
601 src
->Register
.Absolute
= 1;
604 if (!parse_register_src(ctx
, &file
, &index
, &ind_file
, &ind_index
, &ind_comp
))
606 src
->Register
.File
= file
;
607 src
->Register
.Index
= index
;
608 if (ind_file
!= TGSI_FILE_NULL
) {
609 src
->Register
.Indirect
= 1;
610 src
->Indirect
.File
= ind_file
;
611 src
->Indirect
.Index
= ind_index
;
612 src
->Indirect
.SwizzleX
= ind_comp
;
613 src
->Indirect
.SwizzleY
= ind_comp
;
614 src
->Indirect
.SwizzleZ
= ind_comp
;
615 src
->Indirect
.SwizzleW
= ind_comp
;
618 /* Parse optional swizzle.
620 if (parse_optional_swizzle( ctx
, swizzle
, &parsed_swizzle
)) {
621 if (parsed_swizzle
) {
622 src
->Register
.SwizzleX
= swizzle
[0];
623 src
->Register
.SwizzleY
= swizzle
[1];
624 src
->Register
.SwizzleZ
= swizzle
[2];
625 src
->Register
.SwizzleW
= swizzle
[3];
629 if (src
->Register
.Absolute
) {
630 eat_opt_white( &ctx
->cur
);
631 if (*ctx
->cur
!= '|') {
632 report_error( ctx
, "Expected `|'" );
642 static const char *texture_names
[TGSI_TEXTURE_COUNT
] =
656 match_inst_mnemonic(const char **pcur
,
657 const struct tgsi_opcode_info
*info
)
659 if (str_match_no_case(pcur
, info
->mnemonic
)) {
667 struct translate_ctx
*ctx
,
671 uint saturate
= TGSI_SAT_NONE
;
672 const struct tgsi_opcode_info
*info
;
673 struct tgsi_full_instruction inst
;
676 /* Parse instruction name.
678 eat_opt_white( &ctx
->cur
);
679 for (i
= 0; i
< TGSI_OPCODE_LAST
; i
++) {
680 const char *cur
= ctx
->cur
;
682 info
= tgsi_get_opcode_info( i
);
683 if (match_inst_mnemonic(&cur
, info
)) {
684 if (str_match_no_case( &cur
, "_SATNV" ))
685 saturate
= TGSI_SAT_MINUS_PLUS_ONE
;
686 else if (str_match_no_case( &cur
, "_SAT" ))
687 saturate
= TGSI_SAT_ZERO_ONE
;
689 if (info
->num_dst
+ info
->num_src
+ info
->is_tex
== 0) {
690 if (!is_digit_alpha_underscore( cur
)) {
695 else if (*cur
== '\0' || eat_white( &cur
)) {
701 if (i
== TGSI_OPCODE_LAST
) {
703 report_error( ctx
, "Unknown opcode" );
705 report_error( ctx
, "Expected `DCL', `IMM' or a label" );
709 inst
= tgsi_default_full_instruction();
710 inst
.Instruction
.Opcode
= i
;
711 inst
.Instruction
.Saturate
= saturate
;
712 inst
.Instruction
.NumDstRegs
= info
->num_dst
;
713 inst
.Instruction
.NumSrcRegs
= info
->num_src
;
715 /* Parse instruction operands.
717 for (i
= 0; i
< info
->num_dst
+ info
->num_src
+ info
->is_tex
; i
++) {
719 eat_opt_white( &ctx
->cur
);
720 if (*ctx
->cur
!= ',') {
721 report_error( ctx
, "Expected `,'" );
725 eat_opt_white( &ctx
->cur
);
728 if (i
< info
->num_dst
) {
729 if (!parse_dst_operand( ctx
, &inst
.Dst
[i
] ))
732 else if (i
< info
->num_dst
+ info
->num_src
) {
733 if (!parse_src_operand( ctx
, &inst
.Src
[i
- info
->num_dst
] ))
739 for (j
= 0; j
< TGSI_TEXTURE_COUNT
; j
++) {
740 if (str_match_no_case( &ctx
->cur
, texture_names
[j
] )) {
741 if (!is_digit_alpha_underscore( ctx
->cur
)) {
742 inst
.Instruction
.Texture
= 1;
743 inst
.Texture
.Texture
= j
;
748 if (j
== TGSI_TEXTURE_COUNT
) {
749 report_error( ctx
, "Expected texture target" );
755 if (info
->is_branch
) {
758 eat_opt_white( &ctx
->cur
);
759 if (*ctx
->cur
!= ':') {
760 report_error( ctx
, "Expected `:'" );
764 eat_opt_white( &ctx
->cur
);
765 if (!parse_uint( &ctx
->cur
, &target
)) {
766 report_error( ctx
, "Expected a label" );
769 inst
.Instruction
.Label
= 1;
770 inst
.Label
.Label
= target
;
773 advance
= tgsi_build_full_instruction(
777 (uint
) (ctx
->tokens_end
- ctx
->tokens_cur
) );
780 ctx
->tokens_cur
+= advance
;
785 static const char *semantic_names
[TGSI_SEMANTIC_COUNT
] =
799 static const char *interpolate_names
[TGSI_INTERPOLATE_COUNT
] =
806 static boolean
parse_declaration( struct translate_ctx
*ctx
)
808 struct tgsi_full_declaration decl
;
816 assert(Elements(semantic_names
) == TGSI_SEMANTIC_COUNT
);
817 assert(Elements(interpolate_names
) == TGSI_INTERPOLATE_COUNT
);
819 if (!eat_white( &ctx
->cur
)) {
820 report_error( ctx
, "Syntax error" );
823 if (!parse_register_dcl( ctx
, &file
, &first
, &last
))
825 if (!parse_opt_writemask( ctx
, &writemask
))
828 decl
= tgsi_default_full_declaration();
829 decl
.Declaration
.File
= file
;
830 decl
.Declaration
.UsageMask
= writemask
;
831 decl
.Range
.First
= first
;
832 decl
.Range
.Last
= last
;
835 eat_opt_white( &cur
);
840 eat_opt_white( &cur
);
841 for (i
= 0; i
< TGSI_SEMANTIC_COUNT
; i
++) {
842 if (str_match_no_case( &cur
, semantic_names
[i
] )) {
843 const char *cur2
= cur
;
846 if (is_digit_alpha_underscore( cur
))
848 eat_opt_white( &cur2
);
851 eat_opt_white( &cur2
);
852 if (!parse_uint( &cur2
, &index
)) {
853 report_error( ctx
, "Expected literal integer" );
856 eat_opt_white( &cur2
);
858 report_error( ctx
, "Expected `]'" );
863 decl
.Semantic
.Index
= index
;
868 decl
.Declaration
.Semantic
= 1;
869 decl
.Semantic
.Name
= i
;
878 eat_opt_white( &cur
);
883 eat_opt_white( &cur
);
884 for (i
= 0; i
< TGSI_INTERPOLATE_COUNT
; i
++) {
885 if (str_match_no_case( &cur
, interpolate_names
[i
] )) {
886 if (is_digit_alpha_underscore( cur
))
888 decl
.Declaration
.Interpolate
= i
;
894 if (i
== TGSI_INTERPOLATE_COUNT
) {
895 report_error( ctx
, "Expected semantic or interpolate attribute" );
900 advance
= tgsi_build_full_declaration(
904 (uint
) (ctx
->tokens_end
- ctx
->tokens_cur
) );
907 ctx
->tokens_cur
+= advance
;
912 static boolean
parse_immediate( struct translate_ctx
*ctx
)
914 struct tgsi_full_immediate imm
;
919 if (!eat_white( &ctx
->cur
)) {
920 report_error( ctx
, "Syntax error" );
923 if (!str_match_no_case( &ctx
->cur
, "FLT32" ) || is_digit_alpha_underscore( ctx
->cur
)) {
924 report_error( ctx
, "Expected `FLT32'" );
927 eat_opt_white( &ctx
->cur
);
928 if (*ctx
->cur
!= '{') {
929 report_error( ctx
, "Expected `{'" );
933 for (i
= 0; i
< 4; i
++) {
934 eat_opt_white( &ctx
->cur
);
936 if (*ctx
->cur
!= ',') {
937 report_error( ctx
, "Expected `,'" );
941 eat_opt_white( &ctx
->cur
);
943 if (!parse_float( &ctx
->cur
, &values
[i
] )) {
944 report_error( ctx
, "Expected literal floating point" );
948 eat_opt_white( &ctx
->cur
);
949 if (*ctx
->cur
!= '}') {
950 report_error( ctx
, "Expected `}'" );
955 imm
= tgsi_default_full_immediate();
956 imm
.Immediate
.NrTokens
+= 4;
957 imm
.Immediate
.DataType
= TGSI_IMM_FLOAT32
;
958 imm
.u
[0].Float
= values
[0];
959 imm
.u
[1].Float
= values
[1];
960 imm
.u
[2].Float
= values
[2];
961 imm
.u
[3].Float
= values
[3];
963 advance
= tgsi_build_full_immediate(
967 (uint
) (ctx
->tokens_end
- ctx
->tokens_cur
) );
970 ctx
->tokens_cur
+= advance
;
975 static const char *property_names
[] =
977 "GS_INPUT_PRIMITIVE",
978 "GS_OUTPUT_PRIMITIVE",
979 "GS_MAX_OUTPUT_VERTICES"
982 static const char *primitive_names
[] =
997 parse_primitive( const char **pcur
, uint
*primitive
)
1001 for (i
= 0; i
< PIPE_PRIM_MAX
; i
++) {
1002 const char *cur
= *pcur
;
1004 if (str_match_no_case( &cur
, primitive_names
[i
])) {
1014 static boolean
parse_property( struct translate_ctx
*ctx
)
1016 struct tgsi_full_property prop
;
1022 if (!eat_white( &ctx
->cur
)) {
1023 report_error( ctx
, "Syntax error" );
1026 if (!parse_identifier( &ctx
->cur
, id
)) {
1027 report_error( ctx
, "Syntax error" );
1030 for (property_name
= 0; property_name
< TGSI_PROPERTY_COUNT
;
1032 if (streq_nocase_uprcase(id
, property_names
[property_name
])) {
1036 if (property_name
>= TGSI_PROPERTY_COUNT
) {
1037 debug_printf( "\nError: Unknown property : '%s'", id
);
1041 eat_opt_white( &ctx
->cur
);
1042 switch(property_name
) {
1043 case TGSI_PROPERTY_GS_INPUT_PRIM
:
1044 case TGSI_PROPERTY_GS_OUTPUT_PRIM
:
1045 if (!parse_primitive(&ctx
->cur
, &values
[0] )) {
1046 report_error( ctx
, "Unknown primitive name as property!" );
1051 if (!parse_uint(&ctx
->cur
, &values
[0] )) {
1052 report_error( ctx
, "Expected unsigned integer as property!" );
1057 prop
= tgsi_default_full_property();
1058 prop
.Property
.PropertyName
= property_name
;
1059 prop
.Property
.NrTokens
+= 1;
1060 prop
.u
[0].Data
= values
[0];
1062 advance
= tgsi_build_full_property(
1066 (uint
) (ctx
->tokens_end
- ctx
->tokens_cur
) );
1069 ctx
->tokens_cur
+= advance
;
1075 static boolean
translate( struct translate_ctx
*ctx
)
1077 eat_opt_white( &ctx
->cur
);
1078 if (!parse_header( ctx
))
1081 while (*ctx
->cur
!= '\0') {
1083 if (!eat_white( &ctx
->cur
)) {
1084 report_error( ctx
, "Syntax error" );
1088 if (*ctx
->cur
== '\0')
1090 if (parse_label( ctx
, &label_val
)) {
1091 if (!parse_instruction( ctx
, TRUE
))
1094 else if (str_match_no_case( &ctx
->cur
, "DCL" )) {
1095 if (!parse_declaration( ctx
))
1098 else if (str_match_no_case( &ctx
->cur
, "IMM" )) {
1099 if (!parse_immediate( ctx
))
1102 else if (str_match_no_case( &ctx
->cur
, "PROPERTY" )) {
1103 if (!parse_property( ctx
))
1106 else if (!parse_instruction( ctx
, FALSE
)) {
1115 tgsi_text_translate(
1117 struct tgsi_token
*tokens
,
1120 struct translate_ctx ctx
;
1124 ctx
.tokens
= tokens
;
1125 ctx
.tokens_cur
= tokens
;
1126 ctx
.tokens_end
= tokens
+ num_tokens
;
1128 if (!translate( &ctx
))
1131 return tgsi_sanity_check( tokens
);