Lines Matching refs:ctx
350 static void report_error( struct translate_ctx *ctx, const char *msg )
354 const char *itr = ctx->text;
356 while (itr != ctx->cur) {
374 static boolean parse_header( struct translate_ctx *ctx )
378 if (str_match_nocase_whole( &ctx->cur, "FRAG" ))
380 else if (str_match_nocase_whole( &ctx->cur, "VERT" ))
382 else if (str_match_nocase_whole( &ctx->cur, "GEOM" ))
384 else if (str_match_nocase_whole( &ctx->cur, "TESS_CTRL" ))
386 else if (str_match_nocase_whole( &ctx->cur, "TESS_EVAL" ))
388 else if (str_match_nocase_whole( &ctx->cur, "COMP" ))
391 report_error( ctx, "Unknown header" );
395 if (ctx->tokens_cur >= ctx->tokens_end)
397 ctx->header = (struct tgsi_header *) ctx->tokens_cur++;
398 *ctx->header = tgsi_build_header();
400 if (ctx->tokens_cur >= ctx->tokens_end)
402 *(struct tgsi_processor *) ctx->tokens_cur++ = tgsi_build_processor( processor, ctx->header );
403 ctx->processor = processor;
408 static boolean parse_label( struct translate_ctx *ctx, uint *val )
410 const char *cur = ctx->cur;
416 ctx->cur = cur;
442 struct translate_ctx *ctx,
447 cur = ctx->cur;
471 report_error( ctx, "Writemask expected" );
475 ctx->cur = cur;
488 struct translate_ctx *ctx,
491 if (!parse_file( &ctx->cur, file )) {
492 report_error( ctx, "Unknown register file" );
495 eat_opt_white( &ctx->cur );
496 if (*ctx->cur != '[') {
497 report_error( ctx, "Expected `['" );
500 ctx->cur++;
508 struct translate_ctx *ctx,
514 if (!parse_register_file_bracket( ctx, file ))
516 eat_opt_white( &ctx->cur );
517 if (!parse_uint( &ctx->cur, &uindex )) {
518 report_error( ctx, "Expected literal unsigned integer" );
529 parse_register_1d(struct translate_ctx *ctx,
533 if (!parse_register_file_bracket_index( ctx, file, index ))
535 eat_opt_white( &ctx->cur );
536 if (*ctx->cur != ']') {
537 report_error( ctx, "Expected `]'" );
540 ctx->cur++;
556 struct translate_ctx *ctx,
564 eat_opt_white( &ctx->cur );
566 cur = ctx->cur;
568 if (!parse_register_1d( ctx, &brackets->ind_file,
571 eat_opt_white( &ctx->cur );
573 if (*ctx->cur == '.') {
574 ctx->cur++;
575 eat_opt_white(&ctx->cur);
577 switch (uprcase(*ctx->cur)) {
591 report_error(ctx, "Expected indirect register swizzle component `x', `y', `z' or `w'");
594 ctx->cur++;
595 eat_opt_white(&ctx->cur);
598 if (*ctx->cur == '+' || *ctx->cur == '-')
599 parse_int( &ctx->cur, &brackets->index );
604 if (!parse_uint( &ctx->cur, &uindex )) {
605 report_error( ctx, "Expected literal unsigned integer" );
612 eat_opt_white( &ctx->cur );
613 if (*ctx->cur != ']') {
614 report_error( ctx, "Expected `]'" );
617 ctx->cur++;
618 if (*ctx->cur == '(') {
619 ctx->cur++;
620 eat_opt_white( &ctx->cur );
621 if (!parse_uint( &ctx->cur, &brackets->ind_array )) {
622 report_error( ctx, "Expected literal unsigned integer" );
625 eat_opt_white( &ctx->cur );
626 if (*ctx->cur != ')') {
627 report_error( ctx, "Expected `)'" );
630 ctx->cur++;
637 struct translate_ctx *ctx,
641 const char *cur = ctx->cur;
648 ctx->cur = cur;
650 if (!parse_register_bracket(ctx, brackets))
668 struct translate_ctx *ctx,
673 if (!parse_register_file_bracket( ctx, file ))
675 if (!parse_register_bracket( ctx, brackets ))
688 struct translate_ctx *ctx,
694 eat_opt_white( &ctx->cur );
696 if (!parse_uint( &ctx->cur, &uindex )) {
699 if (ctx->cur[0] == ']' && ctx->implied_array_size != 0) {
701 bracket->last = ctx->implied_array_size - 1;
704 report_error( ctx, "Expected literal unsigned integer" );
709 eat_opt_white( &ctx->cur );
711 if (ctx->cur[0] == '.' && ctx->cur[1] == '.') {
714 ctx->cur += 2;
715 eat_opt_white( &ctx->cur );
716 if (!parse_uint( &ctx->cur, &uindex )) {
717 report_error( ctx, "Expected literal integer" );
721 eat_opt_white( &ctx->cur );
728 if (*ctx->cur != ']') {
729 report_error( ctx, "Expected `]' or `..'" );
732 ctx->cur++;
742 struct translate_ctx *ctx,
751 if (!parse_register_file_bracket( ctx, file ))
753 if (!parse_register_dcl_bracket( ctx, &brackets[0] ))
758 cur = ctx->cur;
766 ctx->cur = cur;
767 if (!parse_register_dcl_bracket( ctx, &brackets[1] ))
776 if ((ctx->processor == PIPE_SHADER_GEOMETRY && is_in) ||
777 (ctx->processor == PIPE_SHADER_TESS_EVAL && is_in) ||
778 (ctx->processor == PIPE_SHADER_TESS_CTRL && (is_in || is_out))) {
793 struct translate_ctx *ctx,
798 if (!parse_register_file_bracket( ctx, file ))
800 if (!parse_register_bracket( ctx, brackets ))
808 struct translate_ctx *ctx,
817 if (!parse_register_dst( ctx, &file, &bracket[0] ))
819 if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets))
822 cur = ctx->cur;
825 if (!parse_opt_writemask( ctx, &writemask ))
858 struct translate_ctx *ctx,
863 const char *cur = ctx->cur;
883 report_error( ctx, "Expected register swizzle component `x', `y', `z' or `w'" );
889 ctx->cur = cur;
896 struct translate_ctx *ctx,
905 if (*ctx->cur == '-') {
906 ctx->cur++;
907 eat_opt_white( &ctx->cur );
911 if (*ctx->cur == '|') {
912 ctx->cur++;
913 eat_opt_white( &ctx->cur );
917 if (!parse_register_src(ctx, &file, &bracket[0]))
919 if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets))
948 if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, 4 )) {
958 eat_opt_white( &ctx->cur );
959 if (*ctx->cur != '|') {
960 report_error( ctx, "Expected `|'" );
963 ctx->cur++;
972 struct translate_ctx *ctx,
980 if (!parse_register_src(ctx, &file, &bracket))
988 if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, 3 )) {
1037 struct translate_ctx *ctx,
1052 eat_opt_white( &ctx->cur );
1054 cur = ctx->cur;
1059 ctx->cur = cur;
1063 ctx->cur = cur;
1070 report_error( ctx, "Unknown opcode" );
1072 report_error( ctx, "Expected `DCL', `IMM' or a label" );
1105 eat_opt_white( &ctx->cur );
1106 if (*ctx->cur != ',') {
1107 report_error( ctx, "Expected `,'" );
1110 ctx->cur++;
1111 eat_opt_white( &ctx->cur );
1115 if (!parse_dst_operand( ctx, &inst.Dst[i] ))
1119 if (!parse_src_operand( ctx, &inst.Src[i - info->num_dst] ))
1126 if (str_match_nocase_whole( &ctx->cur, tgsi_texture_names[j] )) {
1133 report_error( ctx, "Expected texture target" );
1139 cur = ctx->cur;
1144 ctx->cur = cur;
1145 if (!parse_texoffset_operand( ctx, &inst.TexOffsets[i] ))
1147 cur = ctx->cur;
1152 cur = ctx->cur;
1156 ctx->cur = cur, eat_opt_white(&cur)) {
1182 ctx->cur = cur;
1183 report_error(ctx, "Expected memory qualifier, texture target, or format\n");
1187 cur = ctx->cur;
1195 report_error( ctx, "Expected a label" );
1200 ctx->cur = cur;
1205 ctx->tokens_cur,
1206 ctx->header,
1207 (uint) (ctx->tokens_end - ctx->tokens_cur) );
1210 ctx->tokens_cur += advance;
1217 static boolean parse_immediate_data(struct translate_ctx *ctx, unsigned type,
1223 eat_opt_white( &ctx->cur );
1224 if (*ctx->cur != '{') {
1225 report_error( ctx, "Expected `{'" );
1228 ctx->cur++;
1230 eat_opt_white( &ctx->cur );
1232 if (*ctx->cur != ',') {
1233 report_error( ctx, "Expected `,'" );
1236 ctx->cur++;
1237 eat_opt_white( &ctx->cur );
1242 ret = parse_double(&ctx->cur, &values[i].Uint, &values[i+1].Uint);
1246 ret = parse_int64(&ctx->cur, &values[i].Uint, &values[i+1].Uint);
1250 ret = parse_uint64(&ctx->cur, &values[i].Uint, &values[i+1].Uint);
1254 ret = parse_float(&ctx->cur, &values[i].Float);
1257 ret = parse_uint(&ctx->cur, &values[i].Uint);
1260 ret = parse_int(&ctx->cur, &values[i].Int);
1269 report_error( ctx, "Expected immediate constant" );
1273 eat_opt_white( &ctx->cur );
1274 if (*ctx->cur != '}') {
1275 report_error( ctx, "Expected `}'" );
1278 ctx->cur++;
1283 static boolean parse_declaration( struct translate_ctx *ctx )
1294 if (!eat_white( &ctx->cur )) {
1295 report_error( ctx, "Syntax error" );
1298 if (!parse_register_dcl( ctx, &file, brackets, &num_brackets))
1300 if (!parse_opt_writemask( ctx, &writemask ))
1319 ctx->processor == PIPE_SHADER_VERTEX);
1321 cur = ctx->cur;
1330 report_error( ctx, "Expected `('" );
1336 report_error( ctx, "Expected `,'" );
1341 report_error( ctx, "Expected `)'" );
1347 ctx->cur = cur = cur2;
1364 report_error(ctx, "Expected texture target");
1390 ctx->cur = cur;
1400 report_error(ctx, "Expected texture target");
1405 report_error( ctx, "Expected `,'" );
1434 report_error(ctx, "Expected type name");
1456 ctx->cur = cur;
1460 ctx->cur = cur;
1466 ctx->cur = cur;
1469 ctx->cur = cur;
1472 ctx->cur = cur;
1475 ctx->cur = cur;
1480 ctx->cur = cur;
1483 cur = ctx->cur;
1499 report_error( ctx, "Expected literal integer" );
1504 report_error( ctx, "Expected `]'" );
1517 ctx->cur = cur;
1525 cur = ctx->cur;
1528 file == TGSI_FILE_OUTPUT && ctx->processor == PIPE_SHADER_GEOMETRY) {
1536 report_error(ctx, "Expected '('");
1544 report_error(ctx, "Expected literal integer");
1551 report_error(ctx, "Expected ','");
1559 report_error(ctx, "Expected ')'");
1569 ctx->cur = cur;
1573 cur = ctx->cur;
1585 ctx->cur = cur;
1591 cur = ctx->cur;
1602 ctx->cur = cur;
1608 cur = ctx->cur;
1615 ctx->cur = cur;
1617 report_error( ctx, "Expected semantic, interpolate attribute, or invariant ");
1624 ctx->tokens_cur,
1625 ctx->header,
1626 (uint) (ctx->tokens_end - ctx->tokens_cur) );
1630 ctx->tokens_cur += advance;
1635 static boolean parse_immediate( struct translate_ctx *ctx )
1641 if (*ctx->cur == '[') {
1644 ++ctx->cur;
1646 eat_opt_white( &ctx->cur );
1647 if (!parse_uint( &ctx->cur, &uindex )) {
1648 report_error( ctx, "Expected literal unsigned integer" );
1652 if (uindex != ctx->num_immediates) {
1653 report_error( ctx, "Immediates must be sorted" );
1657 eat_opt_white( &ctx->cur );
1658 if (*ctx->cur != ']') {
1659 report_error( ctx, "Expected `]'" );
1663 ctx->cur++;
1666 if (!eat_white( &ctx->cur )) {
1667 report_error( ctx, "Syntax error" );
1671 if (str_match_nocase_whole(&ctx->cur, tgsi_immediate_type_names[type]))
1675 report_error( ctx, "Expected immediate type" );
1682 parse_immediate_data(ctx, type, imm.u);
1686 ctx->tokens_cur,
1687 ctx->header,
1688 (uint) (ctx->tokens_end - ctx->tokens_cur) );
1691 ctx->tokens_cur += advance;
1693 ctx->num_immediates++;
1766 static boolean parse_property( struct translate_ctx *ctx )
1774 if (!eat_white( &ctx->cur )) {
1775 report_error( ctx, "Syntax error" );
1778 if (!parse_identifier( &ctx->cur, id, sizeof(id) )) {
1779 report_error( ctx, "Syntax error" );
1793 eat_opt_white( &ctx->cur );
1797 if (!parse_primitive(&ctx->cur, &values[0] )) {
1798 report_error( ctx, "Unknown primitive name as property!" );
1802 ctx->processor == PIPE_SHADER_GEOMETRY) {
1803 ctx->implied_array_size = u_vertices_per_prim(values[0]);
1807 if (!parse_fs_coord_origin(&ctx->cur, &values[0] )) {
1808 report_error( ctx, "Unknown coord origin as property: must be UPPER_LEFT or LOWER_LEFT!" );
1813 if (!parse_fs_coord_pixel_center(&ctx->cur, &values[0] )) {
1814 report_error( ctx, "Unknown coord pixel center as property: must be HALF_INTEGER or INTEGER!" );
1819 if (!parse_property_next_shader(&ctx->cur, &values[0] )) {
1820 report_error( ctx, "Unknown next shader property value." );
1826 if (!parse_uint(&ctx->cur, &values[0] )) {
1827 report_error( ctx, "Expected unsigned integer as property!" );
1839 ctx->tokens_cur,
1840 ctx->header,
1841 (uint) (ctx->tokens_end - ctx->tokens_cur) );
1844 ctx->tokens_cur += advance;
1850 static boolean translate( struct translate_ctx *ctx )
1852 eat_opt_white( &ctx->cur );
1853 if (!parse_header( ctx ))
1856 if (ctx->processor == PIPE_SHADER_TESS_CTRL ||
1857 ctx->processor == PIPE_SHADER_TESS_EVAL)
1858 ctx->implied_array_size = 32;
1860 while (*ctx->cur != '\0') {
1862 if (!eat_white( &ctx->cur )) {
1863 report_error( ctx, "Syntax error" );
1867 if (*ctx->cur == '\0')
1869 if (parse_label( ctx, &label_val )) {
1870 if (!parse_instruction( ctx, TRUE ))
1873 else if (str_match_nocase_whole( &ctx->cur, "DCL" )) {
1874 if (!parse_declaration( ctx ))
1877 else if (str_match_nocase_whole( &ctx->cur, "IMM" )) {
1878 if (!parse_immediate( ctx ))
1881 else if (str_match_nocase_whole( &ctx->cur, "PROPERTY" )) {
1882 if (!parse_property( ctx ))
1885 else if (!parse_instruction( ctx, FALSE )) {
1899 struct translate_ctx ctx = {0};
1901 ctx.text = text;
1902 ctx.cur = text;
1903 ctx.tokens = tokens;
1904 ctx.tokens_cur = tokens;
1905 ctx.tokens_end = tokens + num_tokens;
1907 if (!translate( &ctx ))