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 "tgsi_text.h"
30 #include "tgsi_build.h"
31 #include "tgsi_info.h"
32 #include "tgsi_parse.h"
33 #include "tgsi_sanity.h"
34 #include "tgsi_util.h"
36 static boolean
is_alpha_underscore( const char *cur
)
39 (*cur
>= 'a' && *cur
<= 'z') ||
40 (*cur
>= 'A' && *cur
<= 'Z') ||
44 static boolean
is_digit( const char *cur
)
46 return *cur
>= '0' && *cur
<= '9';
49 static boolean
is_digit_alpha_underscore( const char *cur
)
51 return is_digit( cur
) || is_alpha_underscore( cur
);
54 static boolean
uprcase( char c
)
56 if (c
>= 'a' && c
<= 'z')
57 return c
+= 'A' - 'a';
61 static boolean
str_match_no_case( const char **pcur
, const char *str
)
63 const char *cur
= *pcur
;
65 while (*str
!= '\0' && *str
== uprcase( *cur
)) {
76 /* Eat zero or more whitespaces.
78 static void eat_opt_white( const char **pcur
)
80 while (**pcur
== ' ' || **pcur
== '\t' || **pcur
== '\n')
84 /* Eat one or more whitespaces.
85 * Return TRUE if at least one whitespace eaten.
87 static boolean
eat_white( const char **pcur
)
89 const char *cur
= *pcur
;
91 eat_opt_white( pcur
);
95 /* Parse unsigned integer.
96 * No checks for overflow.
98 static boolean
parse_uint( const char **pcur
, uint
*val
)
100 const char *cur
= *pcur
;
102 if (is_digit( cur
)) {
104 while (is_digit( cur
))
105 *val
= *val
* 10 + *cur
++ - '0';
112 /* Parse floating point.
114 static boolean
parse_float( const char **pcur
, float *val
)
116 const char *cur
= *pcur
;
117 boolean integral_part
= FALSE
;
118 boolean fractional_part
= FALSE
;
120 *val
= (float) atof( cur
);
122 if (*cur
== '-' || *cur
== '+')
124 if (is_digit( cur
)) {
126 integral_part
= TRUE
;
127 while (is_digit( cur
))
132 if (is_digit( cur
)) {
134 fractional_part
= TRUE
;
135 while (is_digit( cur
))
139 if (!integral_part
&& !fractional_part
)
141 if (uprcase( *cur
) == 'E') {
143 if (*cur
== '-' || *cur
== '+')
145 if (is_digit( cur
)) {
147 while (is_digit( cur
))
161 struct tgsi_token
*tokens
;
162 struct tgsi_token
*tokens_cur
;
163 struct tgsi_token
*tokens_end
;
164 struct tgsi_header
*header
;
167 static void report_error( struct translate_ctx
*ctx
, const char *msg
)
169 debug_printf( "\nError: %s", msg
);
172 /* Parse shader header.
173 * Return TRUE for one of the following headers.
178 static boolean
parse_header( struct translate_ctx
*ctx
)
182 if (str_match_no_case( &ctx
->cur
, "FRAG1.1" ))
183 processor
= TGSI_PROCESSOR_FRAGMENT
;
184 else if (str_match_no_case( &ctx
->cur
, "VERT1.1" ))
185 processor
= TGSI_PROCESSOR_VERTEX
;
186 else if (str_match_no_case( &ctx
->cur
, "GEOM1.1" ))
187 processor
= TGSI_PROCESSOR_GEOMETRY
;
189 report_error( ctx
, "Unknown header" );
193 if (ctx
->tokens_cur
>= ctx
->tokens_end
)
195 *(struct tgsi_version
*) ctx
->tokens_cur
++ = tgsi_build_version();
197 if (ctx
->tokens_cur
>= ctx
->tokens_end
)
199 ctx
->header
= (struct tgsi_header
*) ctx
->tokens_cur
++;
200 *ctx
->header
= tgsi_build_header();
202 if (ctx
->tokens_cur
>= ctx
->tokens_end
)
204 *(struct tgsi_processor
*) ctx
->tokens_cur
++ = tgsi_build_processor( processor
, ctx
->header
);
209 static boolean
parse_label( struct translate_ctx
*ctx
, uint
*val
)
211 const char *cur
= ctx
->cur
;
213 if (parse_uint( &cur
, val
)) {
214 eat_opt_white( &cur
);
224 static const char *file_names
[TGSI_FILE_COUNT
] =
237 parse_file( const char **pcur
, uint
*file
)
241 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
242 const char *cur
= *pcur
;
244 if (str_match_no_case( &cur
, file_names
[i
] )) {
245 if (!is_digit_alpha_underscore( cur
)) {
257 struct translate_ctx
*ctx
,
263 eat_opt_white( &cur
);
266 *writemask
= TGSI_WRITEMASK_NONE
;
267 eat_opt_white( &cur
);
268 if (uprcase( *cur
) == 'X') {
270 *writemask
|= TGSI_WRITEMASK_X
;
272 if (uprcase( *cur
) == 'Y') {
274 *writemask
|= TGSI_WRITEMASK_Y
;
276 if (uprcase( *cur
) == 'Z') {
278 *writemask
|= TGSI_WRITEMASK_Z
;
280 if (uprcase( *cur
) == 'W') {
282 *writemask
|= TGSI_WRITEMASK_W
;
285 if (*writemask
== TGSI_WRITEMASK_NONE
) {
286 report_error( ctx
, "Writemask expected" );
293 *writemask
= TGSI_WRITEMASK_XYZW
;
298 /* <register_file_bracket> ::= <file> `['
301 parse_register_file_bracket(
302 struct translate_ctx
*ctx
,
305 if (!parse_file( &ctx
->cur
, file
)) {
306 report_error( ctx
, "Unknown register file" );
309 eat_opt_white( &ctx
->cur
);
310 if (*ctx
->cur
!= '[') {
311 report_error( ctx
, "Expected `['" );
318 /* <register_file_bracket_index> ::= <register_file_bracket> <uint>
321 parse_register_file_bracket_index(
322 struct translate_ctx
*ctx
,
328 if (!parse_register_file_bracket( ctx
, file
))
330 eat_opt_white( &ctx
->cur
);
331 if (!parse_uint( &ctx
->cur
, &uindex
)) {
332 report_error( ctx
, "Expected literal unsigned integer" );
335 *index
= (int) uindex
;
339 /* Parse destination register operand.
340 * <register_dst> ::= <register_file_bracket_index> `]'
344 struct translate_ctx
*ctx
,
348 if (!parse_register_file_bracket_index( ctx
, file
, index
))
350 eat_opt_white( &ctx
->cur
);
351 if (*ctx
->cur
!= ']') {
352 report_error( ctx
, "Expected `]'" );
359 /* Parse source register operand.
360 * <register_src> ::= <register_file_bracket_index> `]' |
361 * <register_file_bracket> <register_dst> `]' |
362 * <register_file_bracket> <register_dst> `+' <uint> `]' |
363 * <register_file_bracket> <register_dst> `-' <uint> `]'
367 struct translate_ctx
*ctx
,
376 if (!parse_register_file_bracket( ctx
, file
))
378 eat_opt_white( &ctx
->cur
);
380 if (parse_file( &cur
, ind_file
)) {
381 if (!parse_register_dst( ctx
, ind_file
, ind_index
))
383 eat_opt_white( &ctx
->cur
);
384 if (*ctx
->cur
== '+' || *ctx
->cur
== '-') {
387 negate
= *ctx
->cur
== '-';
389 eat_opt_white( &ctx
->cur
);
390 if (!parse_uint( &ctx
->cur
, &uindex
)) {
391 report_error( ctx
, "Expected literal unsigned integer" );
395 *index
= -(int) uindex
;
397 *index
= (int) uindex
;
404 if (!parse_uint( &ctx
->cur
, &uindex
)) {
405 report_error( ctx
, "Expected literal unsigned integer" );
408 *index
= (int) uindex
;
409 *ind_file
= TGSI_FILE_NULL
;
412 eat_opt_white( &ctx
->cur
);
413 if (*ctx
->cur
!= ']') {
414 report_error( ctx
, "Expected `]'" );
421 /* Parse register declaration.
422 * <register_dcl> ::= <register_file_bracket_index> `]' |
423 * <register_file_bracket_index> `..' <index> `]'
427 struct translate_ctx
*ctx
,
432 if (!parse_register_file_bracket_index( ctx
, file
, first
))
434 eat_opt_white( &ctx
->cur
);
435 if (ctx
->cur
[0] == '.' && ctx
->cur
[1] == '.') {
439 eat_opt_white( &ctx
->cur
);
440 if (!parse_uint( &ctx
->cur
, &uindex
)) {
441 report_error( ctx
, "Expected literal integer" );
444 *last
= (int) uindex
;
445 eat_opt_white( &ctx
->cur
);
450 if (*ctx
->cur
!= ']') {
451 report_error( ctx
, "Expected `]' or `..'" );
458 static const char *modulate_names
[TGSI_MODULATE_COUNT
] =
471 struct translate_ctx
*ctx
,
472 struct tgsi_full_dst_register
*dst
)
479 if (!parse_register_dst( ctx
, &file
, &index
))
483 eat_opt_white( &cur
);
487 for (i
= 0; i
< TGSI_MODULATE_COUNT
; i
++) {
488 if (str_match_no_case( &cur
, modulate_names
[i
] )) {
489 if (!is_digit_alpha_underscore( cur
)) {
490 dst
->DstRegisterExtModulate
.Modulate
= i
;
498 if (!parse_opt_writemask( ctx
, &writemask
))
501 dst
->DstRegister
.File
= file
;
502 dst
->DstRegister
.Index
= index
;
503 dst
->DstRegister
.WriteMask
= writemask
;
508 parse_optional_swizzle(
509 struct translate_ctx
*ctx
,
511 boolean
*parsed_swizzle
,
512 boolean
*parsed_extswizzle
)
514 const char *cur
= ctx
->cur
;
516 *parsed_swizzle
= FALSE
;
517 *parsed_extswizzle
= FALSE
;
519 eat_opt_white( &cur
);
524 eat_opt_white( &cur
);
525 for (i
= 0; i
< 4; i
++) {
526 if (uprcase( *cur
) == 'X')
527 swizzle
[i
] = TGSI_SWIZZLE_X
;
528 else if (uprcase( *cur
) == 'Y')
529 swizzle
[i
] = TGSI_SWIZZLE_Y
;
530 else if (uprcase( *cur
) == 'Z')
531 swizzle
[i
] = TGSI_SWIZZLE_Z
;
532 else if (uprcase( *cur
) == 'W')
533 swizzle
[i
] = TGSI_SWIZZLE_W
;
536 swizzle
[i
] = TGSI_EXTSWIZZLE_ZERO
;
537 else if (*cur
== '1')
538 swizzle
[i
] = TGSI_EXTSWIZZLE_ONE
;
540 report_error( ctx
, "Expected register swizzle component `x', `y', `z', `w', `0' or `1'" );
543 *parsed_extswizzle
= TRUE
;
547 *parsed_swizzle
= TRUE
;
555 struct translate_ctx
*ctx
,
556 struct tgsi_full_src_register
*src
)
565 boolean parsed_swizzle
;
566 boolean parsed_extswizzle
;
568 if (*ctx
->cur
== '-') {
571 eat_opt_white( &cur
);
574 src
->SrcRegisterExtMod
.Negate
= 1;
575 eat_opt_white( &cur
);
580 if (*ctx
->cur
== '|') {
582 eat_opt_white( &ctx
->cur
);
583 src
->SrcRegisterExtMod
.Absolute
= 1;
586 if (*ctx
->cur
== '-') {
588 eat_opt_white( &ctx
->cur
);
589 src
->SrcRegister
.Negate
= 1;
593 if (parse_float( &cur
, &value
)) {
595 eat_opt_white( &cur
);
597 report_error( ctx
, "Expected `*'" );
602 report_error( ctx
, "Expected `('" );
606 src
->SrcRegisterExtMod
.Scale2X
= 1;
607 eat_opt_white( &cur
);
612 if (*ctx
->cur
== '(') {
614 eat_opt_white( &ctx
->cur
);
615 src
->SrcRegisterExtMod
.Bias
= 1;
619 if (parse_float( &cur
, &value
)) {
621 eat_opt_white( &cur
);
623 report_error( ctx
, "Expected `-'" );
628 report_error( ctx
, "Expected `('" );
632 src
->SrcRegisterExtMod
.Complement
= 1;
633 eat_opt_white( &cur
);
638 if (!parse_register_src( ctx
, &file
, &index
, &ind_file
, &ind_index
))
640 src
->SrcRegister
.File
= file
;
641 src
->SrcRegister
.Index
= index
;
642 if (ind_file
!= TGSI_FILE_NULL
) {
643 src
->SrcRegister
.Indirect
= 1;
644 src
->SrcRegisterInd
.File
= ind_file
;
645 src
->SrcRegisterInd
.Index
= ind_index
;
648 /* Parse optional swizzle.
650 if (parse_optional_swizzle( ctx
, swizzle
, &parsed_swizzle
, &parsed_extswizzle
)) {
651 if (parsed_extswizzle
) {
652 assert( parsed_swizzle
);
654 src
->SrcRegisterExtSwz
.ExtSwizzleX
= swizzle
[0];
655 src
->SrcRegisterExtSwz
.ExtSwizzleY
= swizzle
[1];
656 src
->SrcRegisterExtSwz
.ExtSwizzleZ
= swizzle
[2];
657 src
->SrcRegisterExtSwz
.ExtSwizzleW
= swizzle
[3];
659 else if (parsed_swizzle
) {
660 src
->SrcRegister
.SwizzleX
= swizzle
[0];
661 src
->SrcRegister
.SwizzleY
= swizzle
[1];
662 src
->SrcRegister
.SwizzleZ
= swizzle
[2];
663 src
->SrcRegister
.SwizzleW
= swizzle
[3];
667 if (src
->SrcRegisterExtMod
.Complement
) {
668 eat_opt_white( &ctx
->cur
);
669 if (*ctx
->cur
!= ')') {
670 report_error( ctx
, "Expected `)'" );
676 if (src
->SrcRegisterExtMod
.Bias
) {
677 eat_opt_white( &ctx
->cur
);
678 if (*ctx
->cur
!= ')') {
679 report_error( ctx
, "Expected `)'" );
683 eat_opt_white( &ctx
->cur
);
684 if (*ctx
->cur
!= '-') {
685 report_error( ctx
, "Expected `-'" );
689 eat_opt_white( &ctx
->cur
);
690 if (!parse_float( &ctx
->cur
, &value
)) {
691 report_error( ctx
, "Expected literal floating point" );
695 report_error( ctx
, "Expected 0.5" );
700 if (src
->SrcRegisterExtMod
.Scale2X
) {
701 eat_opt_white( &ctx
->cur
);
702 if (*ctx
->cur
!= ')') {
703 report_error( ctx
, "Expected `)'" );
709 if (src
->SrcRegisterExtMod
.Absolute
) {
710 eat_opt_white( &ctx
->cur
);
711 if (*ctx
->cur
!= '|') {
712 report_error( ctx
, "Expected `|'" );
718 if (src
->SrcRegisterExtMod
.Negate
) {
719 eat_opt_white( &ctx
->cur
);
720 if (*ctx
->cur
!= ')') {
721 report_error( ctx
, "Expected `)'" );
730 static const char *texture_names
[TGSI_TEXTURE_COUNT
] =
745 struct translate_ctx
*ctx
,
749 uint saturate
= TGSI_SAT_NONE
;
750 const struct tgsi_opcode_info
*info
;
751 struct tgsi_full_instruction inst
;
754 /* Parse instruction name.
756 eat_opt_white( &ctx
->cur
);
757 for (i
= 0; i
< TGSI_OPCODE_LAST
; i
++) {
758 const char *cur
= ctx
->cur
;
760 info
= tgsi_get_opcode_info( i
);
761 if (str_match_no_case( &cur
, info
->mnemonic
)) {
762 if (str_match_no_case( &cur
, "_SATNV" ))
763 saturate
= TGSI_SAT_MINUS_PLUS_ONE
;
764 else if (str_match_no_case( &cur
, "_SAT" ))
765 saturate
= TGSI_SAT_ZERO_ONE
;
767 if (info
->num_dst
+ info
->num_src
+ info
->is_tex
== 0) {
768 if (!is_digit_alpha_underscore( cur
)) {
773 else if (*cur
== '\0' || eat_white( &cur
)) {
779 if (i
== TGSI_OPCODE_LAST
) {
781 report_error( ctx
, "Unknown opcode" );
783 report_error( ctx
, "Expected `DCL', `IMM' or a label" );
787 inst
= tgsi_default_full_instruction();
788 inst
.Instruction
.Opcode
= i
;
789 inst
.Instruction
.Saturate
= saturate
;
790 inst
.Instruction
.NumDstRegs
= info
->num_dst
;
791 inst
.Instruction
.NumSrcRegs
= info
->num_src
;
793 /* Parse instruction operands.
795 for (i
= 0; i
< info
->num_dst
+ info
->num_src
+ info
->is_tex
; i
++) {
797 eat_opt_white( &ctx
->cur
);
798 if (*ctx
->cur
!= ',') {
799 report_error( ctx
, "Expected `,'" );
803 eat_opt_white( &ctx
->cur
);
806 if (i
< info
->num_dst
) {
807 if (!parse_dst_operand( ctx
, &inst
.FullDstRegisters
[i
] ))
810 else if (i
< info
->num_dst
+ info
->num_src
) {
811 if (!parse_src_operand( ctx
, &inst
.FullSrcRegisters
[i
- info
->num_dst
] ))
817 for (j
= 0; j
< TGSI_TEXTURE_COUNT
; j
++) {
818 if (str_match_no_case( &ctx
->cur
, texture_names
[j
] )) {
819 if (!is_digit_alpha_underscore( ctx
->cur
)) {
820 inst
.InstructionExtTexture
.Texture
= j
;
825 if (j
== TGSI_TEXTURE_COUNT
) {
826 report_error( ctx
, "Expected texture target" );
832 if (info
->is_branch
) {
835 eat_opt_white( &ctx
->cur
);
836 if (*ctx
->cur
!= ':') {
837 report_error( ctx
, "Expected `:'" );
841 eat_opt_white( &ctx
->cur
);
842 if (!parse_uint( &ctx
->cur
, &target
)) {
843 report_error( ctx
, "Expected a label" );
846 inst
.InstructionExtLabel
.Label
= target
;
849 advance
= tgsi_build_full_instruction(
853 (uint
) (ctx
->tokens_end
- ctx
->tokens_cur
) );
856 ctx
->tokens_cur
+= advance
;
861 static const char *semantic_names
[TGSI_SEMANTIC_COUNT
] =
872 static const char *interpolate_names
[TGSI_INTERPOLATE_COUNT
] =
879 static boolean
parse_declaration( struct translate_ctx
*ctx
)
881 struct tgsi_full_declaration decl
;
889 if (!eat_white( &ctx
->cur
)) {
890 report_error( ctx
, "Syntax error" );
893 if (!parse_register_dcl( ctx
, &file
, &first
, &last
))
895 if (!parse_opt_writemask( ctx
, &writemask
))
898 decl
= tgsi_default_full_declaration();
899 decl
.Declaration
.File
= file
;
900 decl
.Declaration
.UsageMask
= writemask
;
901 decl
.DeclarationRange
.First
= first
;
902 decl
.DeclarationRange
.Last
= last
;
905 eat_opt_white( &cur
);
910 eat_opt_white( &cur
);
911 for (i
= 0; i
< TGSI_SEMANTIC_COUNT
; i
++) {
912 if (str_match_no_case( &cur
, semantic_names
[i
] )) {
913 const char *cur2
= cur
;
916 if (is_digit_alpha_underscore( cur
))
918 eat_opt_white( &cur2
);
921 eat_opt_white( &cur2
);
922 if (!parse_uint( &cur2
, &index
)) {
923 report_error( ctx
, "Expected literal integer" );
926 eat_opt_white( &cur2
);
928 report_error( ctx
, "Expected `]'" );
933 decl
.Semantic
.SemanticIndex
= index
;
938 decl
.Declaration
.Semantic
= 1;
939 decl
.Semantic
.SemanticName
= i
;
948 eat_opt_white( &cur
);
953 eat_opt_white( &cur
);
954 for (i
= 0; i
< TGSI_INTERPOLATE_COUNT
; i
++) {
955 if (str_match_no_case( &cur
, interpolate_names
[i
] )) {
956 if (is_digit_alpha_underscore( cur
))
958 decl
.Declaration
.Interpolate
= i
;
964 if (i
== TGSI_INTERPOLATE_COUNT
) {
965 report_error( ctx
, "Expected semantic or interpolate attribute" );
970 advance
= tgsi_build_full_declaration(
974 (uint
) (ctx
->tokens_end
- ctx
->tokens_cur
) );
977 ctx
->tokens_cur
+= advance
;
982 static boolean
parse_immediate( struct translate_ctx
*ctx
)
984 struct tgsi_full_immediate imm
;
989 if (!eat_white( &ctx
->cur
)) {
990 report_error( ctx
, "Syntax error" );
993 if (!str_match_no_case( &ctx
->cur
, "FLT32" ) || is_digit_alpha_underscore( ctx
->cur
)) {
994 report_error( ctx
, "Expected `FLT32'" );
997 eat_opt_white( &ctx
->cur
);
998 if (*ctx
->cur
!= '{') {
999 report_error( ctx
, "Expected `{'" );
1003 for (i
= 0; i
< 4; i
++) {
1004 eat_opt_white( &ctx
->cur
);
1006 if (*ctx
->cur
!= ',') {
1007 report_error( ctx
, "Expected `,'" );
1011 eat_opt_white( &ctx
->cur
);
1013 if (!parse_float( &ctx
->cur
, &values
[i
] )) {
1014 report_error( ctx
, "Expected literal floating point" );
1018 eat_opt_white( &ctx
->cur
);
1019 if (*ctx
->cur
!= '}') {
1020 report_error( ctx
, "Expected `}'" );
1025 imm
= tgsi_default_full_immediate();
1026 imm
.Immediate
.NrTokens
+= 4;
1027 imm
.Immediate
.DataType
= TGSI_IMM_FLOAT32
;
1028 imm
.u
.Pointer
= values
;
1030 advance
= tgsi_build_full_immediate(
1034 (uint
) (ctx
->tokens_end
- ctx
->tokens_cur
) );
1037 ctx
->tokens_cur
+= advance
;
1042 static boolean
translate( struct translate_ctx
*ctx
)
1044 eat_opt_white( &ctx
->cur
);
1045 if (!parse_header( ctx
))
1048 while (*ctx
->cur
!= '\0') {
1051 if (!eat_white( &ctx
->cur
)) {
1052 report_error( ctx
, "Syntax error" );
1056 if (*ctx
->cur
== '\0')
1059 if (parse_label( ctx
, &label_val
)) {
1060 if (!parse_instruction( ctx
, TRUE
))
1063 else if (str_match_no_case( &ctx
->cur
, "DCL" )) {
1064 if (!parse_declaration( ctx
))
1067 else if (str_match_no_case( &ctx
->cur
, "IMM" )) {
1068 if (!parse_immediate( ctx
))
1071 else if (!parse_instruction( ctx
, FALSE
)) {
1080 tgsi_text_translate(
1082 struct tgsi_token
*tokens
,
1085 struct translate_ctx ctx
;
1089 ctx
.tokens
= tokens
;
1090 ctx
.tokens_cur
= tokens
;
1091 ctx
.tokens_end
= tokens
+ num_tokens
;
1093 if (!translate( &ctx
))
1096 return tgsi_sanity_check( tokens
);