~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/tgsi/tgsi_text.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "tgsi_util.h"
41
41
#include "tgsi_dump.h"
42
42
 
43
 
static boolean is_alpha_underscore( const char *cur )
 
43
static bool is_alpha_underscore( const char *cur )
44
44
{
45
45
   return
46
46
      (*cur >= 'a' && *cur <= 'z') ||
48
48
      *cur == '_';
49
49
}
50
50
 
51
 
static boolean is_digit( const char *cur )
 
51
static bool is_digit( const char *cur )
52
52
{
53
53
   return *cur >= '0' && *cur <= '9';
54
54
}
55
55
 
56
 
static boolean is_digit_alpha_underscore( const char *cur )
 
56
static bool is_digit_alpha_underscore( const char *cur )
57
57
{
58
58
   return is_digit( cur ) || is_alpha_underscore( cur );
59
59
}
75
75
{
76
76
   while (*str1 && *str2) {
77
77
      if (*str1 != uprcase(*str2))
78
 
         return FALSE;
 
78
         return false;
79
79
      str1++;
80
80
      str2++;
81
81
   }
87
87
 * The pointer to the first string is moved at end of the read word
88
88
 * on success.
89
89
 */
90
 
static boolean str_match_no_case( const char **pcur, const char *str )
 
90
static bool str_match_no_case( const char **pcur, const char *str )
91
91
{
92
92
   const char *cur = *pcur;
93
93
 
97
97
   }
98
98
   if (*str == '\0') {
99
99
      *pcur = cur;
100
 
      return TRUE;
 
100
      return true;
101
101
   }
102
 
   return FALSE;
 
102
   return false;
103
103
}
104
104
 
105
105
/* Return TRUE if both strings match.
108
108
 * The pointer to the first string is moved at end of the read word
109
109
 * on success.
110
110
 */
111
 
static boolean str_match_nocase_whole( const char **pcur, const char *str )
 
111
static bool str_match_nocase_whole( const char **pcur, const char *str )
112
112
{
113
113
   const char *cur = *pcur;
114
114
 
115
115
   if (str_match_no_case(&cur, str) &&
116
116
       !is_digit_alpha_underscore(cur)) {
117
117
      *pcur = cur;
118
 
      return TRUE;
 
118
      return true;
119
119
   }
120
 
   return FALSE;
 
120
   return false;
121
121
}
122
122
 
123
123
/* Return the array index that matches starting at *pcur, where the string at
167
167
/* Eat one or more whitespaces.
168
168
 * Return TRUE if at least one whitespace eaten.
169
169
 */
170
 
static boolean eat_white( const char **pcur )
 
170
static bool eat_white( const char **pcur )
171
171
{
172
172
   const char *cur = *pcur;
173
173
 
178
178
/* Parse unsigned integer.
179
179
 * No checks for overflow.
180
180
 */
181
 
static boolean parse_uint( const char **pcur, uint *val )
 
181
static bool parse_uint( const char **pcur, unsigned *val )
182
182
{
183
183
   const char *cur = *pcur;
184
184
 
187
187
      while (is_digit( cur ))
188
188
         *val = *val * 10 + *cur++ - '0';
189
189
      *pcur = cur;
190
 
      return TRUE;
 
190
      return true;
191
191
   }
192
 
   return FALSE;
 
192
   return false;
193
193
}
194
194
 
195
 
static boolean parse_int( const char **pcur, int *val )
 
195
static bool parse_int( const char **pcur, int *val )
196
196
{
197
197
   const char *cur = *pcur;
198
198
   int sign = (*cur == '-' ? -1 : 1);
200
200
   if (*cur == '+' || *cur == '-')
201
201
      cur++;
202
202
 
203
 
   if (parse_uint(&cur, (uint *)val)) {
 
203
   if (parse_uint(&cur, (unsigned *)val)) {
204
204
      *val *= sign;
205
205
      *pcur = cur;
206
 
      return TRUE;
 
206
      return true;
207
207
   }
208
208
 
209
 
   return FALSE;
 
209
   return false;
210
210
}
211
211
 
212
 
static boolean parse_identifier( const char **pcur, char *ret, size_t len )
 
212
static bool parse_identifier( const char **pcur, char *ret, size_t len )
213
213
{
214
214
   const char *cur = *pcur;
215
215
   size_t i = 0;
217
217
      ret[i++] = *cur++;
218
218
      while (is_alpha_underscore( cur ) || is_digit( cur )) {
219
219
         if (i == len - 1)
220
 
            return FALSE;
 
220
            return false;
221
221
         ret[i++] = *cur++;
222
222
      }
223
223
      ret[i++] = '\0';
224
224
      *pcur = cur;
225
 
      return TRUE;
 
225
      return true;
226
226
   }
227
 
   return FALSE;
 
227
   return false;
228
228
}
229
229
 
230
230
/* Parse floating point.
231
231
 */
232
 
static boolean parse_float( const char **pcur, float *val )
 
232
static bool parse_float( const char **pcur, float *val )
233
233
{
234
234
   const char *cur = *pcur;
235
235
   *val = _mesa_strtof(cur, (char**)pcur);
236
236
   if (*pcur == cur)
237
 
      return FALSE;
238
 
   return TRUE;
 
237
      return false;
 
238
   return true;
239
239
}
240
240
 
241
 
static boolean parse_double( const char **pcur, uint32_t *val0, uint32_t *val1)
 
241
static bool parse_double( const char **pcur, uint32_t *val0, uint32_t *val1)
242
242
{
243
243
   const char *cur = *pcur;
244
244
   union {
248
248
 
249
249
   v.dval = _mesa_strtod(cur, (char**)pcur);
250
250
   if (*pcur == cur)
251
 
      return FALSE;
 
251
      return false;
252
252
 
253
253
   *val0 = v.uval[0];
254
254
   *val1 = v.uval[1];
255
255
 
256
 
   return TRUE;
 
256
   return true;
257
257
}
258
258
 
259
 
static boolean parse_int64( const char **pcur, uint32_t *val0, uint32_t *val1)
 
259
static bool parse_int64( const char **pcur, uint32_t *val0, uint32_t *val1)
260
260
{
261
261
   const char *cur = *pcur;
262
262
   union {
266
266
 
267
267
   v.i64val = strtoll(cur, (char**)pcur, 0);
268
268
   if (*pcur == cur)
269
 
      return FALSE;
 
269
      return false;
270
270
 
271
271
   *val0 = v.uval[0];
272
272
   *val1 = v.uval[1];
273
273
 
274
 
   return TRUE;
 
274
   return true;
275
275
}
276
276
 
277
 
static boolean parse_uint64( const char **pcur, uint32_t *val0, uint32_t *val1)
 
277
static bool parse_uint64( const char **pcur, uint32_t *val0, uint32_t *val1)
278
278
{
279
279
   const char *cur = *pcur;
280
280
   union {
284
284
 
285
285
   v.u64val = strtoull(cur, (char**)pcur, 0);
286
286
   if (*pcur == cur)
287
 
      return FALSE;
 
287
      return false;
288
288
 
289
289
   *val0 = v.uval[0];
290
290
   *val1 = v.uval[1];
291
291
 
292
 
   return TRUE;
 
292
   return true;
293
293
}
294
294
 
295
295
struct translate_ctx
329
329
 *    GEOM
330
330
 *    VERT
331
331
 */
332
 
static boolean parse_header( struct translate_ctx *ctx )
 
332
static bool parse_header( struct translate_ctx *ctx )
333
333
{
334
 
   uint processor;
 
334
   enum pipe_shader_type processor;
335
335
 
336
336
   if (str_match_nocase_whole( &ctx->cur, "FRAG" ))
337
337
      processor = PIPE_SHADER_FRAGMENT;
347
347
      processor = PIPE_SHADER_COMPUTE;
348
348
   else {
349
349
      report_error( ctx, "Unknown header" );
350
 
      return FALSE;
 
350
      return false;
351
351
   }
352
352
 
353
353
   if (ctx->tokens_cur >= ctx->tokens_end)
354
 
      return FALSE;
 
354
      return false;
355
355
   ctx->header = (struct tgsi_header *) ctx->tokens_cur++;
356
356
   *ctx->header = tgsi_build_header();
357
357
 
358
358
   if (ctx->tokens_cur >= ctx->tokens_end)
359
 
      return FALSE;
 
359
      return false;
360
360
   *(struct tgsi_processor *) ctx->tokens_cur++ = tgsi_build_processor( processor, ctx->header );
361
361
   ctx->processor = processor;
362
362
 
363
 
   return TRUE;
 
363
   return true;
364
364
}
365
365
 
366
 
static boolean parse_label( struct translate_ctx *ctx, uint *val )
 
366
static bool parse_label( struct translate_ctx *ctx, unsigned *val )
367
367
{
368
368
   const char *cur = ctx->cur;
369
369
 
372
372
      if (*cur == ':') {
373
373
         cur++;
374
374
         ctx->cur = cur;
375
 
         return TRUE;
 
375
         return true;
376
376
      }
377
377
   }
378
 
   return FALSE;
 
378
   return false;
379
379
}
380
380
 
381
 
static boolean
382
 
parse_file( const char **pcur, uint *file )
 
381
static bool
 
382
parse_file( const char **pcur, enum tgsi_file_type *file )
383
383
{
384
 
   uint i;
 
384
   enum tgsi_file_type i;
385
385
 
386
386
   for (i = 0; i < TGSI_FILE_COUNT; i++) {
387
387
      const char *cur = *pcur;
389
389
      if (str_match_nocase_whole( &cur, tgsi_file_name(i) )) {
390
390
         *pcur = cur;
391
391
         *file = i;
392
 
         return TRUE;
 
392
         return true;
393
393
      }
394
394
   }
395
 
   return FALSE;
 
395
   return false;
396
396
}
397
397
 
398
 
static boolean
 
398
static bool
399
399
parse_opt_writemask(
400
400
   struct translate_ctx *ctx,
401
 
   uint *writemask )
 
401
   unsigned *writemask )
402
402
{
403
403
   const char *cur;
404
404
 
427
427
 
428
428
      if (*writemask == TGSI_WRITEMASK_NONE) {
429
429
         report_error( ctx, "Writemask expected" );
430
 
         return FALSE;
 
430
         return false;
431
431
      }
432
432
 
433
433
      ctx->cur = cur;
435
435
   else {
436
436
      *writemask = TGSI_WRITEMASK_XYZW;
437
437
   }
438
 
   return TRUE;
 
438
   return true;
439
439
}
440
440
 
441
441
 
442
442
/* <register_file_bracket> ::= <file> `['
443
443
 */
444
 
static boolean
 
444
static bool
445
445
parse_register_file_bracket(
446
446
   struct translate_ctx *ctx,
447
 
   uint *file )
 
447
   enum tgsi_file_type *file )
448
448
{
449
449
   if (!parse_file( &ctx->cur, file )) {
450
450
      report_error( ctx, "Unknown register file" );
451
 
      return FALSE;
 
451
      return false;
452
452
   }
453
453
   eat_opt_white( &ctx->cur );
454
454
   if (*ctx->cur != '[') {
455
455
      report_error( ctx, "Expected `['" );
456
 
      return FALSE;
 
456
      return false;
457
457
   }
458
458
   ctx->cur++;
459
 
   return TRUE;
 
459
   return true;
460
460
}
461
461
 
462
462
/* <register_file_bracket_index> ::= <register_file_bracket> <uint>
463
463
 */
464
 
static boolean
 
464
static bool
465
465
parse_register_file_bracket_index(
466
466
   struct translate_ctx *ctx,
467
 
   uint *file,
 
467
   enum tgsi_file_type *file,
468
468
   int *index )
469
469
{
470
 
   uint uindex;
 
470
   unsigned uindex;
471
471
 
472
472
   if (!parse_register_file_bracket( ctx, file ))
473
 
      return FALSE;
 
473
      return false;
474
474
   eat_opt_white( &ctx->cur );
475
475
   if (!parse_uint( &ctx->cur, &uindex )) {
476
476
      report_error( ctx, "Expected literal unsigned integer" );
477
 
      return FALSE;
 
477
      return false;
478
478
   }
479
479
   *index = (int) uindex;
480
 
   return TRUE;
 
480
   return true;
481
481
}
482
482
 
483
483
/* Parse simple 1d register operand.
484
484
 *    <register_dst> ::= <register_file_bracket_index> `]'
485
485
 */
486
 
static boolean
 
486
static bool
487
487
parse_register_1d(struct translate_ctx *ctx,
488
 
                  uint *file,
 
488
                  enum tgsi_file_type *file,
489
489
                  int *index )
490
490
{
491
491
   if (!parse_register_file_bracket_index( ctx, file, index ))
492
 
      return FALSE;
 
492
      return false;
493
493
   eat_opt_white( &ctx->cur );
494
494
   if (*ctx->cur != ']') {
495
495
      report_error( ctx, "Expected `]'" );
496
 
      return FALSE;
 
496
      return false;
497
497
   }
498
498
   ctx->cur++;
499
 
   return TRUE;
 
499
   return true;
500
500
}
501
501
 
502
502
struct parsed_bracket {
503
503
   int index;
504
504
 
505
 
   uint ind_file;
 
505
   enum tgsi_file_type ind_file;
506
506
   int ind_index;
507
 
   uint ind_comp;
508
 
   uint ind_array;
 
507
   unsigned ind_comp;
 
508
   unsigned ind_array;
509
509
};
510
510
 
511
511
 
512
 
static boolean
 
512
static bool
513
513
parse_register_bracket(
514
514
   struct translate_ctx *ctx,
515
515
   struct parsed_bracket *brackets)
516
516
{
517
517
   const char *cur;
518
 
   uint uindex;
 
518
   unsigned uindex;
519
519
 
520
520
   memset(brackets, 0, sizeof(struct parsed_bracket));
521
521
 
525
525
   if (parse_file( &cur, &brackets->ind_file )) {
526
526
      if (!parse_register_1d( ctx, &brackets->ind_file,
527
527
                              &brackets->ind_index ))
528
 
         return FALSE;
 
528
         return false;
529
529
      eat_opt_white( &ctx->cur );
530
530
 
531
531
      if (*ctx->cur == '.') {
547
547
            break;
548
548
         default:
549
549
            report_error(ctx, "Expected indirect register swizzle component `x', `y', `z' or `w'");
550
 
            return FALSE;
 
550
            return false;
551
551
         }
552
552
         ctx->cur++;
553
553
         eat_opt_white(&ctx->cur);
561
561
   else {
562
562
      if (!parse_uint( &ctx->cur, &uindex )) {
563
563
         report_error( ctx, "Expected literal unsigned integer" );
564
 
         return FALSE;
 
564
         return false;
565
565
      }
566
566
      brackets->index = (int) uindex;
567
567
      brackets->ind_file = TGSI_FILE_NULL;
570
570
   eat_opt_white( &ctx->cur );
571
571
   if (*ctx->cur != ']') {
572
572
      report_error( ctx, "Expected `]'" );
573
 
      return FALSE;
 
573
      return false;
574
574
   }
575
575
   ctx->cur++;
576
576
   if (*ctx->cur == '(') {
578
578
      eat_opt_white( &ctx->cur );
579
579
      if (!parse_uint( &ctx->cur, &brackets->ind_array )) {
580
580
         report_error( ctx, "Expected literal unsigned integer" );
581
 
         return FALSE;
 
581
         return false;
582
582
      }
583
583
      eat_opt_white( &ctx->cur );
584
584
      if (*ctx->cur != ')') {
585
585
         report_error( ctx, "Expected `)'" );
586
 
         return FALSE;
 
586
         return false;
587
587
      }
588
588
      ctx->cur++;
589
589
   }
590
 
   return TRUE;
 
590
   return true;
591
591
}
592
592
 
593
 
static boolean
 
593
static bool
594
594
parse_opt_register_src_bracket(
595
595
   struct translate_ctx *ctx,
596
596
   struct parsed_bracket *brackets,
606
606
      ctx->cur = cur;
607
607
 
608
608
      if (!parse_register_bracket(ctx, brackets))
609
 
         return FALSE;
 
609
         return false;
610
610
 
611
611
      *parsed_brackets = 1;
612
612
   }
613
613
 
614
 
   return TRUE;
 
614
   return true;
615
615
}
616
616
 
617
617
 
621
621
 *                       <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `+' <uint> `]' |
622
622
 *                       <register_file_bracket> <register_dst> [`.' (`x' | `y' | `z' | `w')] `-' <uint> `]'
623
623
 */
624
 
static boolean
 
624
static bool
625
625
parse_register_src(
626
626
   struct translate_ctx *ctx,
627
 
   uint *file,
 
627
   enum tgsi_file_type *file,
628
628
   struct parsed_bracket *brackets)
629
629
{
630
630
   brackets->ind_comp = TGSI_SWIZZLE_X;
631
631
   if (!parse_register_file_bracket( ctx, file ))
632
 
      return FALSE;
 
632
      return false;
633
633
   if (!parse_register_bracket( ctx, brackets ))
634
 
       return FALSE;
 
634
       return false;
635
635
 
636
 
   return TRUE;
 
636
   return true;
637
637
}
638
638
 
639
639
struct parsed_dcl_bracket {
640
 
   uint first;
641
 
   uint last;
 
640
   unsigned first;
 
641
   unsigned last;
642
642
};
643
643
 
644
 
static boolean
 
644
static bool
645
645
parse_register_dcl_bracket(
646
646
   struct translate_ctx *ctx,
647
647
   struct parsed_dcl_bracket *bracket)
648
648
{
649
 
   uint uindex;
 
649
   unsigned uindex;
650
650
   memset(bracket, 0, sizeof(struct parsed_dcl_bracket));
651
651
 
652
652
   eat_opt_white( &ctx->cur );
660
660
         goto cleanup;
661
661
      }
662
662
      report_error( ctx, "Expected literal unsigned integer" );
663
 
      return FALSE;
 
663
      return false;
664
664
   }
665
665
   bracket->first = uindex;
666
666
 
667
667
   eat_opt_white( &ctx->cur );
668
668
 
669
669
   if (ctx->cur[0] == '.' && ctx->cur[1] == '.') {
670
 
      uint uindex;
 
670
      unsigned uindex;
671
671
 
672
672
      ctx->cur += 2;
673
673
      eat_opt_white( &ctx->cur );
674
674
      if (!parse_uint( &ctx->cur, &uindex )) {
675
675
         report_error( ctx, "Expected literal integer" );
676
 
         return FALSE;
 
676
         return false;
677
677
      }
678
678
      bracket->last = (int) uindex;
679
679
      eat_opt_white( &ctx->cur );
685
685
cleanup:
686
686
   if (*ctx->cur != ']') {
687
687
      report_error( ctx, "Expected `]' or `..'" );
688
 
      return FALSE;
 
688
      return false;
689
689
   }
690
690
   ctx->cur++;
691
 
   return TRUE;
 
691
   return true;
692
692
}
693
693
 
694
694
/* Parse register declaration.
695
695
 *    <register_dcl> ::= <register_file_bracket_index> `]' |
696
696
 *                       <register_file_bracket_index> `..' <index> `]'
697
697
 */
698
 
static boolean
 
698
static bool
699
699
parse_register_dcl(
700
700
   struct translate_ctx *ctx,
701
 
   uint *file,
 
701
   enum tgsi_file_type *file,
702
702
   struct parsed_dcl_bracket *brackets,
703
703
   int *num_brackets)
704
704
{
707
707
   *num_brackets = 0;
708
708
 
709
709
   if (!parse_register_file_bracket( ctx, file ))
710
 
      return FALSE;
 
710
      return false;
711
711
   if (!parse_register_dcl_bracket( ctx, &brackets[0] ))
712
 
      return FALSE;
 
712
      return false;
713
713
 
714
714
   *num_brackets = 1;
715
715
 
723
723
      ++cur;
724
724
      ctx->cur = cur;
725
725
      if (!parse_register_dcl_bracket( ctx, &brackets[1] ))
726
 
         return FALSE;
 
726
         return false;
727
727
      /* for geometry shader we don't really care about
728
728
       * the first brackets it's always the size of the
729
729
       * input primitive. so we want to declare just
741
741
      }
742
742
   }
743
743
 
744
 
   return TRUE;
 
744
   return true;
745
745
}
746
746
 
747
747
 
748
748
/* Parse destination register operand.*/
749
 
static boolean
 
749
static bool
750
750
parse_register_dst(
751
751
   struct translate_ctx *ctx,
752
 
   uint *file,
 
752
   enum tgsi_file_type *file,
753
753
   struct parsed_bracket *brackets)
754
754
{
755
755
   brackets->ind_comp = TGSI_SWIZZLE_X;
756
756
   if (!parse_register_file_bracket( ctx, file ))
757
 
      return FALSE;
 
757
      return false;
758
758
   if (!parse_register_bracket( ctx, brackets ))
759
 
       return FALSE;
 
759
       return false;
760
760
 
761
 
   return TRUE;
 
761
   return true;
762
762
}
763
763
 
764
 
static boolean
 
764
static bool
765
765
parse_dst_operand(
766
766
   struct translate_ctx *ctx,
767
767
   struct tgsi_full_dst_register *dst )
768
768
{
769
 
   uint file;
770
 
   uint writemask;
 
769
   enum tgsi_file_type file;
 
770
   unsigned writemask;
771
771
   const char *cur;
772
772
   struct parsed_bracket bracket[2];
773
773
   int parsed_opt_brackets;
774
774
 
775
775
   if (!parse_register_dst( ctx, &file, &bracket[0] ))
776
 
      return FALSE;
 
776
      return false;
777
777
   if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets))
778
 
      return FALSE;
 
778
      return false;
779
779
 
780
780
   cur = ctx->cur;
781
781
   eat_opt_white( &cur );
782
782
 
783
783
   if (!parse_opt_writemask( ctx, &writemask ))
784
 
      return FALSE;
 
784
      return false;
785
785
 
786
786
   dst->Register.File = file;
787
787
   if (parsed_opt_brackets) {
808
808
      dst->Indirect.Swizzle = bracket[0].ind_comp;
809
809
      dst->Indirect.ArrayID = bracket[0].ind_array;
810
810
   }
811
 
   return TRUE;
 
811
   return true;
812
812
}
813
813
 
814
 
static boolean
 
814
static bool
815
815
parse_optional_swizzle(
816
816
   struct translate_ctx *ctx,
817
 
   uint *swizzle,
818
 
   boolean *parsed_swizzle,
 
817
   unsigned *swizzle,
 
818
   bool *parsed_swizzle,
819
819
   int components)
820
820
{
821
821
   const char *cur = ctx->cur;
822
822
 
823
 
   *parsed_swizzle = FALSE;
 
823
   *parsed_swizzle = false;
824
824
 
825
825
   eat_opt_white( &cur );
826
826
   if (*cur == '.') {
839
839
            swizzle[i] = TGSI_SWIZZLE_W;
840
840
         else {
841
841
            report_error( ctx, "Expected register swizzle component `x', `y', `z' or `w'" );
842
 
            return FALSE;
 
842
            return false;
843
843
         }
844
844
         cur++;
845
845
      }
846
 
      *parsed_swizzle = TRUE;
 
846
      *parsed_swizzle = true;
847
847
      ctx->cur = cur;
848
848
   }
849
 
   return TRUE;
 
849
   return true;
850
850
}
851
851
 
852
 
static boolean
 
852
static bool
853
853
parse_src_operand(
854
854
   struct translate_ctx *ctx,
855
855
   struct tgsi_full_src_register *src )
856
856
{
857
 
   uint file;
858
 
   uint swizzle[4];
859
 
   boolean parsed_swizzle;
 
857
   enum tgsi_file_type file;
 
858
   unsigned swizzle[4];
 
859
   bool parsed_swizzle;
860
860
   struct parsed_bracket bracket[2];
861
861
   int parsed_opt_brackets;
862
862
 
873
873
   }
874
874
 
875
875
   if (!parse_register_src(ctx, &file, &bracket[0]))
876
 
      return FALSE;
 
876
      return false;
877
877
   if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets))
878
 
      return FALSE;
 
878
      return false;
879
879
 
880
880
   src->Register.File = file;
881
881
   if (parsed_opt_brackets) {
916
916
      eat_opt_white( &ctx->cur );
917
917
      if (*ctx->cur != '|') {
918
918
         report_error( ctx, "Expected `|'" );
919
 
         return FALSE;
 
919
         return false;
920
920
      }
921
921
      ctx->cur++;
922
922
   }
923
923
 
924
924
 
925
 
   return TRUE;
 
925
   return true;
926
926
}
927
927
 
928
 
static boolean
 
928
static bool
929
929
parse_texoffset_operand(
930
930
   struct translate_ctx *ctx,
931
931
   struct tgsi_texture_offset *src )
932
932
{
933
 
   uint file;
934
 
   uint swizzle[3];
935
 
   boolean parsed_swizzle;
 
933
   enum tgsi_file_type file;
 
934
   unsigned swizzle[3];
 
935
   bool parsed_swizzle;
936
936
   struct parsed_bracket bracket;
937
937
 
938
938
   if (!parse_register_src(ctx, &file, &bracket))
939
 
      return FALSE;
 
939
      return false;
940
940
 
941
941
   src->File = file;
942
942
   src->Index = bracket.index;
951
951
      }
952
952
   }
953
953
 
954
 
   return TRUE;
 
954
   return true;
955
955
}
956
956
 
957
 
static boolean
 
957
static bool
958
958
match_inst(const char **pcur,
959
959
           unsigned *saturate,
960
960
           unsigned *precise,
968
968
      *pcur = cur;
969
969
      *saturate = 0;
970
970
      *precise = 0;
971
 
      return TRUE;
 
971
      return true;
972
972
   }
973
973
 
974
974
   if (str_match_no_case(&cur, mnemonic)) {
984
984
      }
985
985
 
986
986
      if (!is_digit_alpha_underscore(cur))
987
 
         return TRUE;
 
987
         return true;
988
988
   }
989
989
 
990
 
   return FALSE;
 
990
   return false;
991
991
}
992
992
 
993
 
static boolean
 
993
static bool
994
994
parse_instruction(
995
995
   struct translate_ctx *ctx,
996
 
   boolean has_label )
 
996
   bool has_label )
997
997
{
998
998
   int i;
999
 
   uint saturate = 0;
1000
 
   uint precise = 0;
 
999
   unsigned saturate = 0;
 
1000
   unsigned precise = 0;
1001
1001
   const struct tgsi_opcode_info *info;
1002
1002
   struct tgsi_full_instruction inst;
1003
1003
   const char *cur;
1004
 
   uint advance;
 
1004
   unsigned advance;
1005
1005
 
1006
1006
   inst = tgsi_default_full_instruction();
1007
1007
 
1028
1028
         report_error( ctx, "Unknown opcode" );
1029
1029
      else
1030
1030
         report_error( ctx, "Expected `DCL', `IMM' or a label" );
1031
 
      return FALSE;
 
1031
      return false;
1032
1032
   }
1033
1033
 
1034
1034
   inst.Instruction.Opcode = i;
1063
1063
         eat_opt_white( &ctx->cur );
1064
1064
         if (*ctx->cur != ',') {
1065
1065
            report_error( ctx, "Expected `,'" );
1066
 
            return FALSE;
 
1066
            return false;
1067
1067
         }
1068
1068
         ctx->cur++;
1069
1069
         eat_opt_white( &ctx->cur );
1071
1071
 
1072
1072
      if (i < info->num_dst) {
1073
1073
         if (!parse_dst_operand( ctx, &inst.Dst[i] ))
1074
 
            return FALSE;
 
1074
            return false;
1075
1075
      }
1076
1076
      else if (i < info->num_dst + info->num_src) {
1077
1077
         if (!parse_src_operand( ctx, &inst.Src[i - info->num_dst] ))
1078
 
            return FALSE;
 
1078
            return false;
1079
1079
      }
1080
1080
      else {
1081
 
         uint j;
 
1081
         unsigned j;
1082
1082
 
1083
1083
         for (j = 0; j < TGSI_TEXTURE_COUNT; j++) {
1084
1084
            if (str_match_nocase_whole( &ctx->cur, tgsi_texture_names[j] )) {
1089
1089
         }
1090
1090
         if (j == TGSI_TEXTURE_COUNT) {
1091
1091
            report_error( ctx, "Expected texture target" );
1092
 
            return FALSE;
 
1092
            return false;
1093
1093
         }
1094
1094
      }
1095
1095
   }
1101
1101
         eat_opt_white( &cur );
1102
1102
         ctx->cur = cur;
1103
1103
         if (!parse_texoffset_operand( ctx, &inst.TexOffsets[i] ))
1104
 
            return FALSE;
 
1104
            return false;
1105
1105
         cur = ctx->cur;
1106
1106
         eat_opt_white( &cur );
1107
1107
   }
1139
1139
 
1140
1140
      ctx->cur = cur;
1141
1141
      report_error(ctx, "Expected memory qualifier, texture target, or format\n");
1142
 
      return FALSE;
 
1142
      return false;
1143
1143
   }
1144
1144
 
1145
1145
   cur = ctx->cur;
1146
1146
   eat_opt_white( &cur );
1147
1147
   if (info->is_branch && *cur == ':') {
1148
 
      uint target;
 
1148
      unsigned target;
1149
1149
 
1150
1150
      cur++;
1151
1151
      eat_opt_white( &cur );
1152
1152
      if (!parse_uint( &cur, &target )) {
1153
1153
         report_error( ctx, "Expected a label" );
1154
 
         return FALSE;
 
1154
         return false;
1155
1155
      }
1156
1156
      inst.Instruction.Label = 1;
1157
1157
      inst.Label.Label = target;
1162
1162
      &inst,
1163
1163
      ctx->tokens_cur,
1164
1164
      ctx->header,
1165
 
      (uint) (ctx->tokens_end - ctx->tokens_cur) );
 
1165
      (unsigned) (ctx->tokens_end - ctx->tokens_cur) );
1166
1166
   if (advance == 0)
1167
 
      return FALSE;
 
1167
      return false;
1168
1168
   ctx->tokens_cur += advance;
1169
1169
 
1170
 
   return TRUE;
 
1170
   return true;
1171
1171
}
1172
1172
 
1173
1173
/* parses a 4-touple of the form {x, y, z, w}
1174
1174
 * where x, y, z, w are numbers */
1175
 
static boolean parse_immediate_data(struct translate_ctx *ctx, unsigned type,
1176
 
                                    union tgsi_immediate_data *values)
 
1175
static bool parse_immediate_data(struct translate_ctx *ctx, unsigned type,
 
1176
                                 union tgsi_immediate_data *values)
1177
1177
{
1178
1178
   unsigned i;
1179
1179
   int ret;
1181
1181
   eat_opt_white( &ctx->cur );
1182
1182
   if (*ctx->cur != '{') {
1183
1183
      report_error( ctx, "Expected `{'" );
1184
 
      return FALSE;
 
1184
      return false;
1185
1185
   }
1186
1186
   ctx->cur++;
1187
1187
   for (i = 0; i < 4; i++) {
1189
1189
      if (i > 0) {
1190
1190
         if (*ctx->cur != ',') {
1191
1191
            report_error( ctx, "Expected `,'" );
1192
 
            return FALSE;
 
1192
            return false;
1193
1193
         }
1194
1194
         ctx->cur++;
1195
1195
         eat_opt_white( &ctx->cur );
1219
1219
         break;
1220
1220
      default:
1221
1221
         assert(0);
1222
 
         ret = FALSE;
 
1222
         ret = false;
1223
1223
         break;
1224
1224
      }
1225
1225
 
1226
1226
      if (!ret) {
1227
1227
         report_error( ctx, "Expected immediate constant" );
1228
 
         return FALSE;
 
1228
         return false;
1229
1229
      }
1230
1230
   }
1231
1231
   eat_opt_white( &ctx->cur );
1232
1232
   if (*ctx->cur != '}') {
1233
1233
      report_error( ctx, "Expected `}'" );
1234
 
      return FALSE;
 
1234
      return false;
1235
1235
   }
1236
1236
   ctx->cur++;
1237
1237
 
1238
 
   return TRUE;
 
1238
   return true;
1239
1239
}
1240
1240
 
1241
 
static boolean parse_declaration( struct translate_ctx *ctx )
 
1241
static bool parse_declaration( struct translate_ctx *ctx )
1242
1242
{
1243
1243
   struct tgsi_full_declaration decl;
1244
 
   uint file;
 
1244
   enum tgsi_file_type file;
1245
1245
   struct parsed_dcl_bracket brackets[2];
1246
1246
   int num_brackets;
1247
 
   uint writemask;
 
1247
   unsigned writemask;
1248
1248
   const char *cur, *cur2;
1249
 
   uint advance;
1250
 
   boolean is_vs_input;
 
1249
   unsigned advance;
 
1250
   bool is_vs_input;
1251
1251
 
1252
1252
   if (!eat_white( &ctx->cur )) {
1253
1253
      report_error( ctx, "Syntax error" );
1254
 
      return FALSE;
 
1254
      return false;
1255
1255
   }
1256
1256
   if (!parse_register_dcl( ctx, &file, brackets, &num_brackets))
1257
 
      return FALSE;
 
1257
      return false;
1258
1258
   if (!parse_opt_writemask( ctx, &writemask ))
1259
 
      return FALSE;
 
1259
      return false;
1260
1260
 
1261
1261
   decl = tgsi_default_full_declaration();
1262
1262
   decl.Declaration.File = file;
1286
1286
         int arrayid;
1287
1287
         if (*cur2 != '(') {
1288
1288
            report_error( ctx, "Expected `('" );
1289
 
            return FALSE;
 
1289
            return false;
1290
1290
         }
1291
1291
         cur2++;
1292
1292
         eat_opt_white( &cur2 );
1293
1293
         if (!parse_int( &cur2, &arrayid )) {
1294
1294
            report_error( ctx, "Expected `,'" );
1295
 
            return FALSE;
 
1295
            return false;
1296
1296
         }
1297
1297
         eat_opt_white( &cur2 );
1298
1298
         if (*cur2 != ')') {
1299
1299
            report_error( ctx, "Expected `)'" );
1300
 
            return FALSE;
 
1300
            return false;
1301
1301
         }
1302
1302
         cur2++;
1303
1303
         decl.Declaration.Array = 1;
1307
1307
   }
1308
1308
 
1309
1309
   if (*cur == ',' && !is_vs_input) {
1310
 
      uint i, j;
 
1310
      unsigned i, j;
1311
1311
 
1312
1312
      cur++;
1313
1313
      eat_opt_white( &cur );
1320
1320
         }
1321
1321
         if (i == TGSI_TEXTURE_COUNT) {
1322
1322
            report_error(ctx, "Expected texture target");
1323
 
            return FALSE;
 
1323
            return false;
1324
1324
         }
1325
1325
 
1326
1326
         cur2 = cur;
1356
1356
         }
1357
1357
         if (i == TGSI_TEXTURE_COUNT) {
1358
1358
            report_error(ctx, "Expected texture target");
1359
 
            return FALSE;
 
1359
            return false;
1360
1360
         }
1361
1361
         eat_opt_white( &cur );
1362
1362
         if (*cur != ',') {
1363
1363
            report_error( ctx, "Expected `,'" );
1364
 
            return FALSE;
 
1364
            return false;
1365
1365
         }
1366
1366
         ++cur;
1367
1367
         eat_opt_white( &cur );
1390
1390
            if (i == TGSI_RETURN_TYPE_COUNT) {
1391
1391
               if (j == 0 || j >  2) {
1392
1392
                  report_error(ctx, "Expected type name");
1393
 
                  return FALSE;
 
1393
                  return false;
1394
1394
               }
1395
1395
               break;
1396
1396
            } else {
1446
1446
 
1447
1447
            for (i = 0; i < TGSI_SEMANTIC_COUNT; i++) {
1448
1448
               if (str_match_nocase_whole(&cur, tgsi_semantic_names[i])) {
1449
 
                  uint index;
 
1449
                  unsigned index;
1450
1450
 
1451
1451
                  cur2 = cur;
1452
1452
                  eat_opt_white( &cur2 );
1455
1455
                     eat_opt_white( &cur2 );
1456
1456
                     if (!parse_uint( &cur2, &index )) {
1457
1457
                        report_error( ctx, "Expected literal integer" );
1458
 
                        return FALSE;
 
1458
                        return false;
1459
1459
                     }
1460
1460
                     eat_opt_white( &cur2 );
1461
1461
                     if (*cur2 != ']') {
1462
1462
                        report_error( ctx, "Expected `]'" );
1463
 
                        return FALSE;
 
1463
                        return false;
1464
1464
                     }
1465
1465
                     cur2++;
1466
1466
 
1487
1487
      cur++;
1488
1488
      eat_opt_white(&cur);
1489
1489
      if (str_match_nocase_whole(&cur, "STREAM")) {
1490
 
         uint stream[4];
 
1490
         unsigned stream[4];
1491
1491
 
1492
1492
         eat_opt_white(&cur);
1493
1493
         if (*cur != '(') {
1494
1494
            report_error(ctx, "Expected '('");
1495
 
            return FALSE;
 
1495
            return false;
1496
1496
         }
1497
1497
         cur++;
1498
1498
 
1500
1500
            eat_opt_white(&cur);
1501
1501
            if (!parse_uint(&cur, &stream[i])) {
1502
1502
               report_error(ctx, "Expected literal integer");
1503
 
               return FALSE;
 
1503
               return false;
1504
1504
            }
1505
1505
 
1506
1506
            eat_opt_white(&cur);
1507
1507
            if (i < 3) {
1508
1508
               if (*cur != ',') {
1509
1509
                  report_error(ctx, "Expected ','");
1510
 
                  return FALSE;
 
1510
                  return false;
1511
1511
               }
1512
1512
               cur++;
1513
1513
            }
1515
1515
 
1516
1516
         if (*cur != ')') {
1517
1517
            report_error(ctx, "Expected ')'");
1518
 
            return FALSE;
 
1518
            return false;
1519
1519
         }
1520
1520
         cur++;
1521
1521
 
1531
1531
   cur = ctx->cur;
1532
1532
   eat_opt_white( &cur );
1533
1533
   if (*cur == ',' && !is_vs_input) {
1534
 
      uint i;
 
1534
      unsigned i;
1535
1535
 
1536
1536
      cur++;
1537
1537
      eat_opt_white( &cur );
1549
1549
   cur = ctx->cur;
1550
1550
   eat_opt_white( &cur );
1551
1551
   if (*cur == ',' && !is_vs_input) {
1552
 
      uint i;
 
1552
      unsigned i;
1553
1553
 
1554
1554
      cur++;
1555
1555
      eat_opt_white( &cur );
1573
1573
         ctx->cur = cur;
1574
1574
      } else {
1575
1575
         report_error( ctx, "Expected semantic, interpolate attribute, or invariant ");
1576
 
         return FALSE;
 
1576
         return false;
1577
1577
      }
1578
1578
   }
1579
1579
 
1581
1581
      &decl,
1582
1582
      ctx->tokens_cur,
1583
1583
      ctx->header,
1584
 
      (uint) (ctx->tokens_end - ctx->tokens_cur) );
 
1584
      (unsigned) (ctx->tokens_end - ctx->tokens_cur) );
1585
1585
 
1586
1586
   if (advance == 0)
1587
 
      return FALSE;
 
1587
      return false;
1588
1588
   ctx->tokens_cur += advance;
1589
1589
 
1590
 
   return TRUE;
 
1590
   return true;
1591
1591
}
1592
1592
 
1593
 
static boolean parse_immediate( struct translate_ctx *ctx )
 
1593
static bool parse_immediate( struct translate_ctx *ctx )
1594
1594
{
1595
1595
   struct tgsi_full_immediate imm;
1596
 
   uint advance;
1597
 
   uint type;
 
1596
   unsigned advance;
 
1597
   unsigned type;
1598
1598
 
1599
1599
   if (*ctx->cur == '[') {
1600
 
      uint uindex;
 
1600
      unsigned uindex;
1601
1601
 
1602
1602
      ++ctx->cur;
1603
1603
 
1604
1604
      eat_opt_white( &ctx->cur );
1605
1605
      if (!parse_uint( &ctx->cur, &uindex )) {
1606
1606
         report_error( ctx, "Expected literal unsigned integer" );
1607
 
         return FALSE;
 
1607
         return false;
1608
1608
      }
1609
1609
 
1610
1610
      if (uindex != ctx->num_immediates) {
1611
1611
         report_error( ctx, "Immediates must be sorted" );
1612
 
         return FALSE;
 
1612
         return false;
1613
1613
      }
1614
1614
 
1615
1615
      eat_opt_white( &ctx->cur );
1616
1616
      if (*ctx->cur != ']') {
1617
1617
         report_error( ctx, "Expected `]'" );
1618
 
         return FALSE;
 
1618
         return false;
1619
1619
      }
1620
1620
 
1621
1621
      ctx->cur++;
1623
1623
 
1624
1624
   if (!eat_white( &ctx->cur )) {
1625
1625
      report_error( ctx, "Syntax error" );
1626
 
      return FALSE;
 
1626
      return false;
1627
1627
   }
1628
1628
   for (type = 0; type < ARRAY_SIZE(tgsi_immediate_type_names); ++type) {
1629
1629
      if (str_match_nocase_whole(&ctx->cur, tgsi_immediate_type_names[type]))
1631
1631
   }
1632
1632
   if (type == ARRAY_SIZE(tgsi_immediate_type_names)) {
1633
1633
      report_error( ctx, "Expected immediate type" );
1634
 
      return FALSE;
 
1634
      return false;
1635
1635
   }
1636
1636
 
1637
1637
   imm = tgsi_default_full_immediate();
1643
1643
      &imm,
1644
1644
      ctx->tokens_cur,
1645
1645
      ctx->header,
1646
 
      (uint) (ctx->tokens_end - ctx->tokens_cur) );
 
1646
      (unsigned) (ctx->tokens_end - ctx->tokens_cur) );
1647
1647
   if (advance == 0)
1648
 
      return FALSE;
 
1648
      return false;
1649
1649
   ctx->tokens_cur += advance;
1650
1650
 
1651
1651
   ctx->num_immediates++;
1652
1652
 
1653
 
   return TRUE;
 
1653
   return true;
1654
1654
}
1655
1655
 
1656
 
static boolean
1657
 
parse_primitive( const char **pcur, uint *primitive )
 
1656
static bool
 
1657
parse_primitive( const char **pcur, unsigned *primitive )
1658
1658
{
1659
 
   uint i;
 
1659
   unsigned i;
1660
1660
 
1661
 
   for (i = 0; i < PIPE_PRIM_MAX; i++) {
 
1661
   for (i = 0; i < MESA_PRIM_COUNT; i++) {
1662
1662
      const char *cur = *pcur;
1663
1663
 
1664
1664
      if (str_match_nocase_whole( &cur, tgsi_primitive_names[i])) {
1665
1665
         *primitive = i;
1666
1666
         *pcur = cur;
1667
 
         return TRUE;
 
1667
         return true;
1668
1668
      }
1669
1669
   }
1670
 
   return FALSE;
 
1670
   return false;
1671
1671
}
1672
1672
 
1673
 
static boolean
1674
 
parse_fs_coord_origin( const char **pcur, uint *fs_coord_origin )
 
1673
static bool
 
1674
parse_fs_coord_origin( const char **pcur, unsigned *fs_coord_origin )
1675
1675
{
1676
 
   uint i;
 
1676
   unsigned i;
1677
1677
 
1678
1678
   for (i = 0; i < ARRAY_SIZE(tgsi_fs_coord_origin_names); i++) {
1679
1679
      const char *cur = *pcur;
1681
1681
      if (str_match_nocase_whole( &cur, tgsi_fs_coord_origin_names[i])) {
1682
1682
         *fs_coord_origin = i;
1683
1683
         *pcur = cur;
1684
 
         return TRUE;
 
1684
         return true;
1685
1685
      }
1686
1686
   }
1687
 
   return FALSE;
 
1687
   return false;
1688
1688
}
1689
1689
 
1690
 
static boolean
1691
 
parse_fs_coord_pixel_center( const char **pcur, uint *fs_coord_pixel_center )
 
1690
static bool
 
1691
parse_fs_coord_pixel_center( const char **pcur, unsigned *fs_coord_pixel_center )
1692
1692
{
1693
 
   uint i;
 
1693
   unsigned i;
1694
1694
 
1695
1695
   for (i = 0; i < ARRAY_SIZE(tgsi_fs_coord_pixel_center_names); i++) {
1696
1696
      const char *cur = *pcur;
1698
1698
      if (str_match_nocase_whole( &cur, tgsi_fs_coord_pixel_center_names[i])) {
1699
1699
         *fs_coord_pixel_center = i;
1700
1700
         *pcur = cur;
1701
 
         return TRUE;
 
1701
         return true;
1702
1702
      }
1703
1703
   }
1704
 
   return FALSE;
 
1704
   return false;
1705
1705
}
1706
1706
 
1707
 
static boolean
1708
 
parse_property_next_shader( const char **pcur, uint *next_shader )
 
1707
static bool
 
1708
parse_property_next_shader( const char **pcur, unsigned *next_shader )
1709
1709
{
1710
 
   uint i;
 
1710
   unsigned i;
1711
1711
 
1712
1712
   for (i = 0; i < ARRAY_SIZE(tgsi_processor_type_names); i++) {
1713
1713
      const char *cur = *pcur;
1715
1715
      if (str_match_nocase_whole( &cur, tgsi_processor_type_names[i])) {
1716
1716
         *next_shader = i;
1717
1717
         *pcur = cur;
1718
 
         return TRUE;
 
1718
         return true;
1719
1719
      }
1720
1720
   }
1721
 
   return FALSE;
 
1721
   return false;
1722
1722
}
1723
1723
 
1724
 
static boolean parse_property( struct translate_ctx *ctx )
 
1724
static bool parse_property( struct translate_ctx *ctx )
1725
1725
{
1726
1726
   struct tgsi_full_property prop;
1727
 
   uint property_name;
1728
 
   uint values[8];
1729
 
   uint advance;
 
1727
   enum tgsi_property_name property_name;
 
1728
   unsigned values[8];
 
1729
   unsigned advance;
1730
1730
   char id[64];
1731
1731
 
1732
1732
   if (!eat_white( &ctx->cur )) {
1733
1733
      report_error( ctx, "Syntax error" );
1734
 
      return FALSE;
 
1734
      return false;
1735
1735
   }
1736
1736
   if (!parse_identifier( &ctx->cur, id, sizeof(id) )) {
1737
1737
      report_error( ctx, "Syntax error" );
1738
 
      return FALSE;
 
1738
      return false;
1739
1739
   }
1740
1740
   for (property_name = 0; property_name < TGSI_PROPERTY_COUNT;
1741
1741
        ++property_name) {
1745
1745
   }
1746
1746
   if (property_name >= TGSI_PROPERTY_COUNT) {
1747
1747
      debug_printf( "\nError: Unknown property : '%s'", id );
1748
 
      return FALSE;
 
1748
      return false;
1749
1749
   }
1750
1750
 
1751
1751
   eat_opt_white( &ctx->cur );
1754
1754
   case TGSI_PROPERTY_GS_OUTPUT_PRIM:
1755
1755
      if (!parse_primitive(&ctx->cur, &values[0] )) {
1756
1756
         report_error( ctx, "Unknown primitive name as property!" );
1757
 
         return FALSE;
 
1757
         return false;
1758
1758
      }
1759
1759
      if (property_name == TGSI_PROPERTY_GS_INPUT_PRIM &&
1760
1760
          ctx->processor == PIPE_SHADER_GEOMETRY) {
1764
1764
   case TGSI_PROPERTY_FS_COORD_ORIGIN:
1765
1765
      if (!parse_fs_coord_origin(&ctx->cur, &values[0] )) {
1766
1766
         report_error( ctx, "Unknown coord origin as property: must be UPPER_LEFT or LOWER_LEFT!" );
1767
 
         return FALSE;
 
1767
         return false;
1768
1768
      }
1769
1769
      break;
1770
1770
   case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER:
1771
1771
      if (!parse_fs_coord_pixel_center(&ctx->cur, &values[0] )) {
1772
1772
         report_error( ctx, "Unknown coord pixel center as property: must be HALF_INTEGER or INTEGER!" );
1773
 
         return FALSE;
 
1773
         return false;
1774
1774
      }
1775
1775
      break;
1776
1776
   case TGSI_PROPERTY_NEXT_SHADER:
1777
1777
      if (!parse_property_next_shader(&ctx->cur, &values[0] )) {
1778
1778
         report_error( ctx, "Unknown next shader property value." );
1779
 
         return FALSE;
 
1779
         return false;
1780
1780
      }
1781
1781
      break;
1782
1782
   case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS:
1783
1783
   default:
1784
1784
      if (!parse_uint(&ctx->cur, &values[0] )) {
1785
1785
         report_error( ctx, "Expected unsigned integer as property!" );
1786
 
         return FALSE;
 
1786
         return false;
1787
1787
      }
1788
1788
   }
1789
1789
 
1796
1796
      &prop,
1797
1797
      ctx->tokens_cur,
1798
1798
      ctx->header,
1799
 
      (uint) (ctx->tokens_end - ctx->tokens_cur) );
 
1799
      (unsigned) (ctx->tokens_end - ctx->tokens_cur) );
1800
1800
   if (advance == 0)
1801
 
      return FALSE;
 
1801
      return false;
1802
1802
   ctx->tokens_cur += advance;
1803
1803
 
1804
 
   return TRUE;
 
1804
   return true;
1805
1805
}
1806
1806
 
1807
1807
 
1808
 
static boolean translate( struct translate_ctx *ctx )
 
1808
static bool translate( struct translate_ctx *ctx )
1809
1809
{
1810
1810
   eat_opt_white( &ctx->cur );
1811
1811
   if (!parse_header( ctx ))
1812
 
      return FALSE;
 
1812
      return false;
1813
1813
 
1814
1814
   if (ctx->processor == PIPE_SHADER_TESS_CTRL ||
1815
1815
       ctx->processor == PIPE_SHADER_TESS_EVAL)
1816
1816
       ctx->implied_array_size = 32;
1817
1817
 
1818
1818
   while (*ctx->cur != '\0') {
1819
 
      uint label_val = 0;
 
1819
      unsigned label_val = 0;
1820
1820
      if (!eat_white( &ctx->cur )) {
1821
1821
         report_error( ctx, "Syntax error" );
1822
 
         return FALSE;
 
1822
         return false;
1823
1823
      }
1824
1824
 
1825
1825
      if (*ctx->cur == '\0')
1826
1826
         break;
1827
1827
      if (parse_label( ctx, &label_val )) {
1828
 
         if (!parse_instruction( ctx, TRUE ))
1829
 
            return FALSE;
 
1828
         if (!parse_instruction( ctx, true ))
 
1829
            return false;
1830
1830
      }
1831
1831
      else if (str_match_nocase_whole( &ctx->cur, "DCL" )) {
1832
1832
         if (!parse_declaration( ctx ))
1833
 
            return FALSE;
 
1833
            return false;
1834
1834
      }
1835
1835
      else if (str_match_nocase_whole( &ctx->cur, "IMM" )) {
1836
1836
         if (!parse_immediate( ctx ))
1837
 
            return FALSE;
 
1837
            return false;
1838
1838
      }
1839
1839
      else if (str_match_nocase_whole( &ctx->cur, "PROPERTY" )) {
1840
1840
         if (!parse_property( ctx ))
1841
 
            return FALSE;
 
1841
            return false;
1842
1842
      }
1843
 
      else if (!parse_instruction( ctx, FALSE )) {
1844
 
         return FALSE;
 
1843
      else if (!parse_instruction( ctx, false )) {
 
1844
         return false;
1845
1845
      }
1846
1846
   }
1847
1847
 
1848
 
   return TRUE;
 
1848
   return true;
1849
1849
}
1850
1850
 
1851
 
boolean
 
1851
bool
1852
1852
tgsi_text_translate(
1853
1853
   const char *text,
1854
1854
   struct tgsi_token *tokens,
1855
 
   uint num_tokens )
 
1855
   unsigned num_tokens )
1856
1856
{
1857
1857
   struct translate_ctx ctx = {0};
1858
1858
 
1863
1863
   ctx.tokens_end = tokens + num_tokens;
1864
1864
 
1865
1865
   if (!translate( &ctx ))
1866
 
      return FALSE;
 
1866
      return false;
1867
1867
 
1868
1868
   return tgsi_sanity_check( tokens );
1869
1869
}