17ec681f3Smrg/* 27ec681f3Smrg * Copyright (c) 2013 Rob Clark <robclark@freedesktop.org> 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 207ec681f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 217ec681f3Smrg * SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg%code requires { 257ec681f3Smrg#include "ir3/ir3_assembler.h" 267ec681f3Smrg#include "ir3/ir3_shader.h" 277ec681f3Smrg 287ec681f3Smrgstruct ir3 * ir3_parse(struct ir3_shader_variant *v, 297ec681f3Smrg struct ir3_kernel_info *k, FILE *f); 307ec681f3Smrg} 317ec681f3Smrg 327ec681f3Smrg%{ 337ec681f3Smrg#define YYDEBUG 0 347ec681f3Smrg 357ec681f3Smrg#include <stdlib.h> 367ec681f3Smrg#include <stdio.h> 377ec681f3Smrg#include <string.h> 387ec681f3Smrg#include <math.h> 397ec681f3Smrg 407ec681f3Smrg#include "util/half_float.h" 417ec681f3Smrg#include "util/u_math.h" 427ec681f3Smrg 437ec681f3Smrg#include "ir3/ir3.h" 447ec681f3Smrg#include "ir3/ir3_shader.h" 457ec681f3Smrg#include "ir3/instr-a3xx.h" 467ec681f3Smrg 477ec681f3Smrg#include "ir3_parser.h" 487ec681f3Smrg 497ec681f3Smrg#define swap(a, b) \ 507ec681f3Smrg do { __typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) 517ec681f3Smrg 527ec681f3Smrg/* ir3 treats the abs/neg flags as separate flags for float vs integer, 537ec681f3Smrg * but in the instruction encoding they are the same thing. Tracking 547ec681f3Smrg * them separately is only for the benefit of ir3 opt passes, and not 557ec681f3Smrg * required here, so just use the float versions: 567ec681f3Smrg */ 577ec681f3Smrg#define IR3_REG_ABS IR3_REG_FABS 587ec681f3Smrg#define IR3_REG_NEGATE IR3_REG_FNEG 597ec681f3Smrg 607ec681f3Smrgstatic struct ir3_kernel_info *info; 617ec681f3Smrgstatic struct ir3_shader_variant *variant; 627ec681f3Smrg/* NOTE the assembler doesn't really use the ir3_block construction 637ec681f3Smrg * like the compiler does. Everything is treated as one large block. 647ec681f3Smrg * Which might happen to contain flow control. But since we don't 657ec681f3Smrg * use any of the ir3 backend passes (sched, RA, etc) this doesn't 667ec681f3Smrg * really matter. 677ec681f3Smrg */ 687ec681f3Smrgstatic struct ir3_block *block; /* current shader block */ 697ec681f3Smrgstatic struct ir3_instruction *instr; /* current instruction */ 707ec681f3Smrgstatic unsigned ip; /* current instruction pointer */ 717ec681f3Smrgstatic struct hash_table *labels; 727ec681f3Smrg 737ec681f3Smrgvoid *ir3_parser_dead_ctx; 747ec681f3Smrg 757ec681f3Smrgstatic struct { 767ec681f3Smrg unsigned flags; 777ec681f3Smrg unsigned repeat; 787ec681f3Smrg unsigned nop; 797ec681f3Smrg} iflags; 807ec681f3Smrg 817ec681f3Smrgstatic struct { 827ec681f3Smrg unsigned flags; 837ec681f3Smrg unsigned wrmask; 847ec681f3Smrg} rflags; 857ec681f3Smrg 867ec681f3Smrgint ir3_yyget_lineno(void); 877ec681f3Smrg 887ec681f3Smrgstatic void new_label(const char *name) 897ec681f3Smrg{ 907ec681f3Smrg ralloc_steal(labels, (void *) name); 917ec681f3Smrg _mesa_hash_table_insert(labels, name, (void *)(uintptr_t)ip); 927ec681f3Smrg} 937ec681f3Smrg 947ec681f3Smrgstatic struct ir3_instruction * new_instr(opc_t opc) 957ec681f3Smrg{ 967ec681f3Smrg instr = ir3_instr_create(block, opc, 4, 6); 977ec681f3Smrg instr->flags = iflags.flags; 987ec681f3Smrg instr->repeat = iflags.repeat; 997ec681f3Smrg instr->nop = iflags.nop; 1007ec681f3Smrg instr->line = ir3_yyget_lineno(); 1017ec681f3Smrg iflags.flags = iflags.repeat = iflags.nop = 0; 1027ec681f3Smrg ip++; 1037ec681f3Smrg return instr; 1047ec681f3Smrg} 1057ec681f3Smrg 1067ec681f3Smrgstatic void new_shader(void) 1077ec681f3Smrg{ 1087ec681f3Smrg variant->ir = ir3_create(variant->shader->compiler, variant); 1097ec681f3Smrg block = ir3_block_create(variant->ir); 1107ec681f3Smrg list_addtail(&block->node, &variant->ir->block_list); 1117ec681f3Smrg ip = 0; 1127ec681f3Smrg labels = _mesa_hash_table_create(variant, _mesa_hash_string, _mesa_key_string_equal); 1137ec681f3Smrg ir3_parser_dead_ctx = ralloc_context(NULL); 1147ec681f3Smrg} 1157ec681f3Smrg 1167ec681f3Smrgstatic type_t parse_type(const char **type) 1177ec681f3Smrg{ 1187ec681f3Smrg if (!strncmp("f16", *type, 3)) { 1197ec681f3Smrg *type += 3; 1207ec681f3Smrg return TYPE_F16; 1217ec681f3Smrg } else if (!strncmp("f32", *type, 3)) { 1227ec681f3Smrg *type += 3; 1237ec681f3Smrg return TYPE_F32; 1247ec681f3Smrg } else if (!strncmp("u16", *type, 3)) { 1257ec681f3Smrg *type += 3; 1267ec681f3Smrg return TYPE_U16; 1277ec681f3Smrg } else if (!strncmp("u32", *type, 3)) { 1287ec681f3Smrg *type += 3; 1297ec681f3Smrg return TYPE_U32; 1307ec681f3Smrg } else if (!strncmp("s16", *type, 3)) { 1317ec681f3Smrg *type += 3; 1327ec681f3Smrg return TYPE_S16; 1337ec681f3Smrg } else if (!strncmp("s32", *type, 3)) { 1347ec681f3Smrg *type += 3; 1357ec681f3Smrg return TYPE_S32; 1367ec681f3Smrg } else if (!strncmp("u8", *type, 2)) { 1377ec681f3Smrg *type += 2; 1387ec681f3Smrg return TYPE_U8; 1397ec681f3Smrg } else if (!strncmp("s8", *type, 2)) { 1407ec681f3Smrg *type += 2; 1417ec681f3Smrg return TYPE_S8; 1427ec681f3Smrg } else { 1437ec681f3Smrg assert(0); /* shouldn't get here */ 1447ec681f3Smrg return ~0; 1457ec681f3Smrg } 1467ec681f3Smrg} 1477ec681f3Smrg 1487ec681f3Smrgstatic struct ir3_instruction * parse_type_type(struct ir3_instruction *instr, 1497ec681f3Smrg const char *type_type) 1507ec681f3Smrg{ 1517ec681f3Smrg instr->cat1.src_type = parse_type(&type_type); 1527ec681f3Smrg instr->cat1.dst_type = parse_type(&type_type); 1537ec681f3Smrg return instr; 1547ec681f3Smrg} 1557ec681f3Smrg 1567ec681f3Smrgstatic struct ir3_register * new_src(int num, unsigned flags) 1577ec681f3Smrg{ 1587ec681f3Smrg struct ir3_register *reg; 1597ec681f3Smrg flags |= rflags.flags; 1607ec681f3Smrg if (num & 0x1) 1617ec681f3Smrg flags |= IR3_REG_HALF; 1627ec681f3Smrg reg = ir3_src_create(instr, num>>1, flags); 1637ec681f3Smrg reg->wrmask = MAX2(1, rflags.wrmask); 1647ec681f3Smrg rflags.flags = rflags.wrmask = 0; 1657ec681f3Smrg return reg; 1667ec681f3Smrg} 1677ec681f3Smrg 1687ec681f3Smrgstatic struct ir3_register * new_dst(int num, unsigned flags) 1697ec681f3Smrg{ 1707ec681f3Smrg struct ir3_register *reg; 1717ec681f3Smrg flags |= rflags.flags; 1727ec681f3Smrg if (num & 0x1) 1737ec681f3Smrg flags |= IR3_REG_HALF; 1747ec681f3Smrg reg = ir3_dst_create(instr, num>>1, flags); 1757ec681f3Smrg reg->wrmask = MAX2(1, rflags.wrmask); 1767ec681f3Smrg rflags.flags = rflags.wrmask = 0; 1777ec681f3Smrg return reg; 1787ec681f3Smrg} 1797ec681f3Smrg 1807ec681f3Smrgstatic struct ir3_register * dummy_dst(void) 1817ec681f3Smrg{ 1827ec681f3Smrg return new_dst(0, 0); 1837ec681f3Smrg} 1847ec681f3Smrg 1857ec681f3Smrgstatic void fixup_cat5_s2en(void) 1867ec681f3Smrg{ 1877ec681f3Smrg assert(opc_cat(instr->opc) == 5); 1887ec681f3Smrg if (!(instr->flags & IR3_INSTR_S2EN)) 1897ec681f3Smrg return; 1907ec681f3Smrg /* For various reasons (ie. mainly to make the .s2en src easier to 1917ec681f3Smrg * find, given that various different cat5 tex instructions can have 1927ec681f3Smrg * different # of src registers), in ir3 the samp/tex src register 1937ec681f3Smrg * is first, rather than last. So we have to detect this case and 1947ec681f3Smrg * fix things up. 1957ec681f3Smrg */ 1967ec681f3Smrg struct ir3_register *s2en_src = instr->srcs[instr->srcs_count - 1]; 1977ec681f3Smrg 1987ec681f3Smrg if (instr->flags & IR3_INSTR_B) 1997ec681f3Smrg assert(!(s2en_src->flags & IR3_REG_HALF)); 2007ec681f3Smrg else 2017ec681f3Smrg assert(s2en_src->flags & IR3_REG_HALF); 2027ec681f3Smrg 2037ec681f3Smrg for (int i = 0; i < instr->srcs_count - 1; i++) { 2047ec681f3Smrg instr->srcs[i+1] = instr->srcs[i]; 2057ec681f3Smrg } 2067ec681f3Smrg instr->srcs[0] = s2en_src; 2077ec681f3Smrg} 2087ec681f3Smrg 2097ec681f3Smrgstatic void add_const(unsigned reg, unsigned c0, unsigned c1, unsigned c2, unsigned c3) 2107ec681f3Smrg{ 2117ec681f3Smrg struct ir3_const_state *const_state = ir3_const_state(variant); 2127ec681f3Smrg assert((reg & 0x7) == 0); 2137ec681f3Smrg int idx = reg >> (1 + 2); /* low bit is half vs full, next two bits are swiz */ 2147ec681f3Smrg if (idx * 4 + 4 > const_state->immediates_size) { 2157ec681f3Smrg const_state->immediates = rerzalloc(const_state, 2167ec681f3Smrg const_state->immediates, 2177ec681f3Smrg __typeof__(const_state->immediates[0]), 2187ec681f3Smrg const_state->immediates_size, 2197ec681f3Smrg idx * 4 + 4); 2207ec681f3Smrg for (unsigned i = const_state->immediates_size; i < idx * 4; i++) 2217ec681f3Smrg const_state->immediates[i] = 0xd0d0d0d0; 2227ec681f3Smrg const_state->immediates_size = const_state->immediates_count = idx * 4 + 4; 2237ec681f3Smrg } 2247ec681f3Smrg const_state->immediates[idx * 4 + 0] = c0; 2257ec681f3Smrg const_state->immediates[idx * 4 + 1] = c1; 2267ec681f3Smrg const_state->immediates[idx * 4 + 2] = c2; 2277ec681f3Smrg const_state->immediates[idx * 4 + 3] = c3; 2287ec681f3Smrg} 2297ec681f3Smrg 2307ec681f3Smrgstatic void add_sysval(unsigned reg, unsigned compmask, gl_system_value sysval) 2317ec681f3Smrg{ 2327ec681f3Smrg unsigned n = variant->inputs_count++; 2337ec681f3Smrg variant->inputs[n].regid = reg; 2347ec681f3Smrg variant->inputs[n].sysval = true; 2357ec681f3Smrg variant->inputs[n].slot = sysval; 2367ec681f3Smrg variant->inputs[n].compmask = compmask; 2377ec681f3Smrg variant->total_in++; 2387ec681f3Smrg} 2397ec681f3Smrg 2407ec681f3Smrgstatic bool resolve_labels(void) 2417ec681f3Smrg{ 2427ec681f3Smrg int instr_ip = 0; 2437ec681f3Smrg foreach_instr (instr, &block->instr_list) { 2447ec681f3Smrg if (opc_cat(instr->opc) == 0 && instr->cat0.target_label) { 2457ec681f3Smrg struct hash_entry *entry = _mesa_hash_table_search(labels, instr->cat0.target_label); 2467ec681f3Smrg if (!entry) { 2477ec681f3Smrg fprintf(stderr, "unknown label %s\n", instr->cat0.target_label); 2487ec681f3Smrg return false; 2497ec681f3Smrg } 2507ec681f3Smrg int target_ip = (uintptr_t)entry->data; 2517ec681f3Smrg instr->cat0.immed = target_ip - instr_ip; 2527ec681f3Smrg } 2537ec681f3Smrg instr_ip++; 2547ec681f3Smrg } 2557ec681f3Smrg return true; 2567ec681f3Smrg} 2577ec681f3Smrg 2587ec681f3Smrg#ifdef YYDEBUG 2597ec681f3Smrgint yydebug; 2607ec681f3Smrg#endif 2617ec681f3Smrg 2627ec681f3Smrgextern int yylex(void); 2637ec681f3Smrgvoid ir3_yyset_lineno(int _line_number); 2647ec681f3Smrgvoid ir3_yyset_input(FILE *f); 2657ec681f3Smrg 2667ec681f3Smrgint yyparse(void); 2677ec681f3Smrg 2687ec681f3Smrgstatic void yyerror(const char *error) 2697ec681f3Smrg{ 2707ec681f3Smrg fprintf(stderr, "error at line %d: %s\n", ir3_yyget_lineno(), error); 2717ec681f3Smrg} 2727ec681f3Smrg 2737ec681f3Smrgstruct ir3 * ir3_parse(struct ir3_shader_variant *v, 2747ec681f3Smrg struct ir3_kernel_info *k, FILE *f) 2757ec681f3Smrg{ 2767ec681f3Smrg ir3_yyset_lineno(1); 2777ec681f3Smrg ir3_yyset_input(f); 2787ec681f3Smrg#ifdef YYDEBUG 2797ec681f3Smrg yydebug = 1; 2807ec681f3Smrg#endif 2817ec681f3Smrg info = k; 2827ec681f3Smrg variant = v; 2837ec681f3Smrg if (yyparse() || !resolve_labels()) { 2847ec681f3Smrg ir3_destroy(variant->ir); 2857ec681f3Smrg variant->ir = NULL; 2867ec681f3Smrg } 2877ec681f3Smrg ralloc_free(labels); 2887ec681f3Smrg ralloc_free(ir3_parser_dead_ctx); 2897ec681f3Smrg return variant->ir; 2907ec681f3Smrg} 2917ec681f3Smrg%} 2927ec681f3Smrg 2937ec681f3Smrg%union { 2947ec681f3Smrg int tok; 2957ec681f3Smrg int num; 2967ec681f3Smrg uint32_t unum; 2977ec681f3Smrg double flt; 2987ec681f3Smrg const char *str; 2997ec681f3Smrg struct ir3_register *reg; 3007ec681f3Smrg struct { 3017ec681f3Smrg int start; 3027ec681f3Smrg int num; 3037ec681f3Smrg } range; 3047ec681f3Smrg type_t type; 3057ec681f3Smrg} 3067ec681f3Smrg 3077ec681f3Smrg%{ 3087ec681f3Smrg#if YYDEBUG 3097ec681f3Smrgstatic void print_token(FILE *file, int type, YYSTYPE value) 3107ec681f3Smrg{ 3117ec681f3Smrg fprintf(file, "\ntype: %d\n", type); 3127ec681f3Smrg} 3137ec681f3Smrg 3147ec681f3Smrg#define YYPRINT(file, type, value) print_token(file, type, value) 3157ec681f3Smrg#endif 3167ec681f3Smrg%} 3177ec681f3Smrg 3187ec681f3Smrg%token <num> T_INT 3197ec681f3Smrg%token <unum> T_HEX 3207ec681f3Smrg%token <flt> T_FLOAT 3217ec681f3Smrg%token <str> T_IDENTIFIER 3227ec681f3Smrg%token <num> T_REGISTER 3237ec681f3Smrg%token <num> T_CONSTANT 3247ec681f3Smrg 3257ec681f3Smrg/* @ headers (@const/@sampler/@uniform/@varying) */ 3267ec681f3Smrg%token <tok> T_A_LOCALSIZE 3277ec681f3Smrg%token <tok> T_A_CONST 3287ec681f3Smrg%token <tok> T_A_BUF 3297ec681f3Smrg%token <tok> T_A_INVOCATIONID 3307ec681f3Smrg%token <tok> T_A_WGID 3317ec681f3Smrg%token <tok> T_A_NUMWG 3327ec681f3Smrg%token <tok> T_A_BRANCHSTACK 3337ec681f3Smrg%token <tok> T_A_IN 3347ec681f3Smrg%token <tok> T_A_OUT 3357ec681f3Smrg%token <tok> T_A_TEX 3367ec681f3Smrg%token <tok> T_A_PVTMEM 3377ec681f3Smrg/* todo, re-add @sampler/@uniform/@varying if needed someday */ 3387ec681f3Smrg 3397ec681f3Smrg/* src register flags */ 3407ec681f3Smrg%token <tok> T_ABSNEG 3417ec681f3Smrg%token <tok> T_NEG 3427ec681f3Smrg%token <tok> T_ABS 3437ec681f3Smrg%token <tok> T_R 3447ec681f3Smrg 3457ec681f3Smrg%token <tok> T_HR 3467ec681f3Smrg%token <tok> T_HC 3477ec681f3Smrg 3487ec681f3Smrg/* dst register flags */ 3497ec681f3Smrg%token <tok> T_EVEN 3507ec681f3Smrg%token <tok> T_POS_INFINITY 3517ec681f3Smrg%token <tok> T_NEG_INFINITY 3527ec681f3Smrg%token <tok> T_EI 3537ec681f3Smrg%token <num> T_WRMASK 3547ec681f3Smrg 3557ec681f3Smrg/* Float LUT values accepted as immed: */ 3567ec681f3Smrg%token <num> T_FLUT_0_0 3577ec681f3Smrg%token <num> T_FLUT_0_5 3587ec681f3Smrg%token <num> T_FLUT_1_0 3597ec681f3Smrg%token <num> T_FLUT_2_0 3607ec681f3Smrg%token <num> T_FLUT_E 3617ec681f3Smrg%token <num> T_FLUT_PI 3627ec681f3Smrg%token <num> T_FLUT_INV_PI 3637ec681f3Smrg%token <num> T_FLUT_INV_LOG2_E 3647ec681f3Smrg%token <num> T_FLUT_LOG2_E 3657ec681f3Smrg%token <num> T_FLUT_INV_LOG2_10 3667ec681f3Smrg%token <num> T_FLUT_LOG2_10 3677ec681f3Smrg%token <num> T_FLUT_4_0 3687ec681f3Smrg 3697ec681f3Smrg/* instruction flags */ 3707ec681f3Smrg%token <tok> T_SY 3717ec681f3Smrg%token <tok> T_SS 3727ec681f3Smrg%token <tok> T_JP 3737ec681f3Smrg%token <tok> T_SAT 3747ec681f3Smrg%token <num> T_RPT 3757ec681f3Smrg%token <tok> T_UL 3767ec681f3Smrg%token <tok> T_NOP 3777ec681f3Smrg 3787ec681f3Smrg/* category 0: */ 3797ec681f3Smrg%token <tok> T_OP_NOP 3807ec681f3Smrg%token <tok> T_OP_BR 3817ec681f3Smrg%token <tok> T_OP_BRAO 3827ec681f3Smrg%token <tok> T_OP_BRAA 3837ec681f3Smrg%token <tok> T_OP_BRAC 3847ec681f3Smrg%token <tok> T_OP_BANY 3857ec681f3Smrg%token <tok> T_OP_BALL 3867ec681f3Smrg%token <tok> T_OP_BRAX 3877ec681f3Smrg%token <tok> T_OP_JUMP 3887ec681f3Smrg%token <tok> T_OP_CALL 3897ec681f3Smrg%token <tok> T_OP_RET 3907ec681f3Smrg%token <tok> T_OP_KILL 3917ec681f3Smrg%token <tok> T_OP_END 3927ec681f3Smrg%token <tok> T_OP_EMIT 3937ec681f3Smrg%token <tok> T_OP_CUT 3947ec681f3Smrg%token <tok> T_OP_CHMASK 3957ec681f3Smrg%token <tok> T_OP_CHSH 3967ec681f3Smrg%token <tok> T_OP_FLOW_REV 3977ec681f3Smrg%token <tok> T_OP_BKT 3987ec681f3Smrg%token <tok> T_OP_STKS 3997ec681f3Smrg%token <tok> T_OP_STKR 4007ec681f3Smrg%token <tok> T_OP_XSET 4017ec681f3Smrg%token <tok> T_OP_XCLR 4027ec681f3Smrg%token <tok> T_OP_GETONE 4037ec681f3Smrg%token <tok> T_OP_DBG 4047ec681f3Smrg%token <tok> T_OP_SHPS 4057ec681f3Smrg%token <tok> T_OP_SHPE 4067ec681f3Smrg%token <tok> T_OP_PREDT 4077ec681f3Smrg%token <tok> T_OP_PREDF 4087ec681f3Smrg%token <tok> T_OP_PREDE 4097ec681f3Smrg 4107ec681f3Smrg/* category 1: */ 4117ec681f3Smrg%token <tok> T_OP_MOVMSK 4127ec681f3Smrg%token <tok> T_OP_MOVA1 4137ec681f3Smrg%token <tok> T_OP_MOVA 4147ec681f3Smrg%token <tok> T_OP_MOV 4157ec681f3Smrg%token <tok> T_OP_COV 4167ec681f3Smrg%token <tok> T_OP_SWZ 4177ec681f3Smrg%token <tok> T_OP_GAT 4187ec681f3Smrg%token <tok> T_OP_SCT 4197ec681f3Smrg 4207ec681f3Smrg/* category 2: */ 4217ec681f3Smrg%token <tok> T_OP_ADD_F 4227ec681f3Smrg%token <tok> T_OP_MIN_F 4237ec681f3Smrg%token <tok> T_OP_MAX_F 4247ec681f3Smrg%token <tok> T_OP_MUL_F 4257ec681f3Smrg%token <tok> T_OP_SIGN_F 4267ec681f3Smrg%token <tok> T_OP_CMPS_F 4277ec681f3Smrg%token <tok> T_OP_ABSNEG_F 4287ec681f3Smrg%token <tok> T_OP_CMPV_F 4297ec681f3Smrg%token <tok> T_OP_FLOOR_F 4307ec681f3Smrg%token <tok> T_OP_CEIL_F 4317ec681f3Smrg%token <tok> T_OP_RNDNE_F 4327ec681f3Smrg%token <tok> T_OP_RNDAZ_F 4337ec681f3Smrg%token <tok> T_OP_TRUNC_F 4347ec681f3Smrg%token <tok> T_OP_ADD_U 4357ec681f3Smrg%token <tok> T_OP_ADD_S 4367ec681f3Smrg%token <tok> T_OP_SUB_U 4377ec681f3Smrg%token <tok> T_OP_SUB_S 4387ec681f3Smrg%token <tok> T_OP_CMPS_U 4397ec681f3Smrg%token <tok> T_OP_CMPS_S 4407ec681f3Smrg%token <tok> T_OP_MIN_U 4417ec681f3Smrg%token <tok> T_OP_MIN_S 4427ec681f3Smrg%token <tok> T_OP_MAX_U 4437ec681f3Smrg%token <tok> T_OP_MAX_S 4447ec681f3Smrg%token <tok> T_OP_ABSNEG_S 4457ec681f3Smrg%token <tok> T_OP_AND_B 4467ec681f3Smrg%token <tok> T_OP_OR_B 4477ec681f3Smrg%token <tok> T_OP_NOT_B 4487ec681f3Smrg%token <tok> T_OP_XOR_B 4497ec681f3Smrg%token <tok> T_OP_CMPV_U 4507ec681f3Smrg%token <tok> T_OP_CMPV_S 4517ec681f3Smrg%token <tok> T_OP_MUL_U24 4527ec681f3Smrg%token <tok> T_OP_MUL_S24 4537ec681f3Smrg%token <tok> T_OP_MULL_U 4547ec681f3Smrg%token <tok> T_OP_BFREV_B 4557ec681f3Smrg%token <tok> T_OP_CLZ_S 4567ec681f3Smrg%token <tok> T_OP_CLZ_B 4577ec681f3Smrg%token <tok> T_OP_SHL_B 4587ec681f3Smrg%token <tok> T_OP_SHR_B 4597ec681f3Smrg%token <tok> T_OP_ASHR_B 4607ec681f3Smrg%token <tok> T_OP_BARY_F 4617ec681f3Smrg%token <tok> T_OP_MGEN_B 4627ec681f3Smrg%token <tok> T_OP_GETBIT_B 4637ec681f3Smrg%token <tok> T_OP_SETRM 4647ec681f3Smrg%token <tok> T_OP_CBITS_B 4657ec681f3Smrg%token <tok> T_OP_SHB 4667ec681f3Smrg%token <tok> T_OP_MSAD 4677ec681f3Smrg 4687ec681f3Smrg/* category 3: */ 4697ec681f3Smrg%token <tok> T_OP_MAD_U16 4707ec681f3Smrg%token <tok> T_OP_MADSH_U16 4717ec681f3Smrg%token <tok> T_OP_MAD_S16 4727ec681f3Smrg%token <tok> T_OP_MADSH_M16 4737ec681f3Smrg%token <tok> T_OP_MAD_U24 4747ec681f3Smrg%token <tok> T_OP_MAD_S24 4757ec681f3Smrg%token <tok> T_OP_MAD_F16 4767ec681f3Smrg%token <tok> T_OP_MAD_F32 4777ec681f3Smrg%token <tok> T_OP_SEL_B16 4787ec681f3Smrg%token <tok> T_OP_SEL_B32 4797ec681f3Smrg%token <tok> T_OP_SEL_S16 4807ec681f3Smrg%token <tok> T_OP_SEL_S32 4817ec681f3Smrg%token <tok> T_OP_SEL_F16 4827ec681f3Smrg%token <tok> T_OP_SEL_F32 4837ec681f3Smrg%token <tok> T_OP_SAD_S16 4847ec681f3Smrg%token <tok> T_OP_SAD_S32 4857ec681f3Smrg%token <tok> T_OP_SHLG_B16 4867ec681f3Smrg 4877ec681f3Smrg/* category 4: */ 4887ec681f3Smrg%token <tok> T_OP_RCP 4897ec681f3Smrg%token <tok> T_OP_RSQ 4907ec681f3Smrg%token <tok> T_OP_LOG2 4917ec681f3Smrg%token <tok> T_OP_EXP2 4927ec681f3Smrg%token <tok> T_OP_SIN 4937ec681f3Smrg%token <tok> T_OP_COS 4947ec681f3Smrg%token <tok> T_OP_SQRT 4957ec681f3Smrg%token <tok> T_OP_HRSQ 4967ec681f3Smrg%token <tok> T_OP_HLOG2 4977ec681f3Smrg%token <tok> T_OP_HEXP2 4987ec681f3Smrg 4997ec681f3Smrg/* category 5: */ 5007ec681f3Smrg%token <tok> T_OP_ISAM 5017ec681f3Smrg%token <tok> T_OP_ISAML 5027ec681f3Smrg%token <tok> T_OP_ISAMM 5037ec681f3Smrg%token <tok> T_OP_SAM 5047ec681f3Smrg%token <tok> T_OP_SAMB 5057ec681f3Smrg%token <tok> T_OP_SAML 5067ec681f3Smrg%token <tok> T_OP_SAMGQ 5077ec681f3Smrg%token <tok> T_OP_GETLOD 5087ec681f3Smrg%token <tok> T_OP_CONV 5097ec681f3Smrg%token <tok> T_OP_CONVM 5107ec681f3Smrg%token <tok> T_OP_GETSIZE 5117ec681f3Smrg%token <tok> T_OP_GETBUF 5127ec681f3Smrg%token <tok> T_OP_GETPOS 5137ec681f3Smrg%token <tok> T_OP_GETINFO 5147ec681f3Smrg%token <tok> T_OP_DSX 5157ec681f3Smrg%token <tok> T_OP_DSY 5167ec681f3Smrg%token <tok> T_OP_GATHER4R 5177ec681f3Smrg%token <tok> T_OP_GATHER4G 5187ec681f3Smrg%token <tok> T_OP_GATHER4B 5197ec681f3Smrg%token <tok> T_OP_GATHER4A 5207ec681f3Smrg%token <tok> T_OP_SAMGP0 5217ec681f3Smrg%token <tok> T_OP_SAMGP1 5227ec681f3Smrg%token <tok> T_OP_SAMGP2 5237ec681f3Smrg%token <tok> T_OP_SAMGP3 5247ec681f3Smrg%token <tok> T_OP_DSXPP_1 5257ec681f3Smrg%token <tok> T_OP_DSYPP_1 5267ec681f3Smrg%token <tok> T_OP_RGETPOS 5277ec681f3Smrg%token <tok> T_OP_RGETINFO 5287ec681f3Smrg 5297ec681f3Smrg/* category 6: */ 5307ec681f3Smrg%token <tok> T_OP_LDG 5317ec681f3Smrg%token <tok> T_OP_LDG_A 5327ec681f3Smrg%token <tok> T_OP_LDL 5337ec681f3Smrg%token <tok> T_OP_LDP 5347ec681f3Smrg%token <tok> T_OP_STG 5357ec681f3Smrg%token <tok> T_OP_STG_A 5367ec681f3Smrg%token <tok> T_OP_STL 5377ec681f3Smrg%token <tok> T_OP_STP 5387ec681f3Smrg%token <tok> T_OP_LDIB 5397ec681f3Smrg%token <tok> T_OP_G2L 5407ec681f3Smrg%token <tok> T_OP_L2G 5417ec681f3Smrg%token <tok> T_OP_PREFETCH 5427ec681f3Smrg%token <tok> T_OP_LDLW 5437ec681f3Smrg%token <tok> T_OP_STLW 5447ec681f3Smrg%token <tok> T_OP_RESFMT 5457ec681f3Smrg%token <tok> T_OP_RESINFO 5467ec681f3Smrg%token <tok> T_OP_ATOMIC_ADD 5477ec681f3Smrg%token <tok> T_OP_ATOMIC_SUB 5487ec681f3Smrg%token <tok> T_OP_ATOMIC_XCHG 5497ec681f3Smrg%token <tok> T_OP_ATOMIC_INC 5507ec681f3Smrg%token <tok> T_OP_ATOMIC_DEC 5517ec681f3Smrg%token <tok> T_OP_ATOMIC_CMPXCHG 5527ec681f3Smrg%token <tok> T_OP_ATOMIC_MIN 5537ec681f3Smrg%token <tok> T_OP_ATOMIC_MAX 5547ec681f3Smrg%token <tok> T_OP_ATOMIC_AND 5557ec681f3Smrg%token <tok> T_OP_ATOMIC_OR 5567ec681f3Smrg%token <tok> T_OP_ATOMIC_XOR 5577ec681f3Smrg%token <tok> T_OP_RESINFO_B 5587ec681f3Smrg%token <tok> T_OP_LDIB_B 5597ec681f3Smrg%token <tok> T_OP_STIB_B 5607ec681f3Smrg%token <tok> T_OP_ATOMIC_B_ADD 5617ec681f3Smrg%token <tok> T_OP_ATOMIC_B_SUB 5627ec681f3Smrg%token <tok> T_OP_ATOMIC_B_XCHG 5637ec681f3Smrg%token <tok> T_OP_ATOMIC_B_INC 5647ec681f3Smrg%token <tok> T_OP_ATOMIC_B_DEC 5657ec681f3Smrg%token <tok> T_OP_ATOMIC_B_CMPXCHG 5667ec681f3Smrg%token <tok> T_OP_ATOMIC_B_MIN 5677ec681f3Smrg%token <tok> T_OP_ATOMIC_B_MAX 5687ec681f3Smrg%token <tok> T_OP_ATOMIC_B_AND 5697ec681f3Smrg%token <tok> T_OP_ATOMIC_B_OR 5707ec681f3Smrg%token <tok> T_OP_ATOMIC_B_XOR 5717ec681f3Smrg%token <tok> T_OP_LDGB 5727ec681f3Smrg%token <tok> T_OP_STGB 5737ec681f3Smrg%token <tok> T_OP_STIB 5747ec681f3Smrg%token <tok> T_OP_LDC 5757ec681f3Smrg%token <tok> T_OP_LDLV 5767ec681f3Smrg%token <tok> T_OP_GETSPID 5777ec681f3Smrg%token <tok> T_OP_GETWID 5787ec681f3Smrg 5797ec681f3Smrg/* category 7: */ 5807ec681f3Smrg%token <tok> T_OP_BAR 5817ec681f3Smrg%token <tok> T_OP_FENCE 5827ec681f3Smrg 5837ec681f3Smrg/* type qualifiers: */ 5847ec681f3Smrg%token <tok> T_TYPE_F16 5857ec681f3Smrg%token <tok> T_TYPE_F32 5867ec681f3Smrg%token <tok> T_TYPE_U16 5877ec681f3Smrg%token <tok> T_TYPE_U32 5887ec681f3Smrg%token <tok> T_TYPE_S16 5897ec681f3Smrg%token <tok> T_TYPE_S32 5907ec681f3Smrg%token <tok> T_TYPE_U8 5917ec681f3Smrg%token <tok> T_TYPE_S8 5927ec681f3Smrg 5937ec681f3Smrg%token <tok> T_UNTYPED 5947ec681f3Smrg%token <tok> T_TYPED 5957ec681f3Smrg 5967ec681f3Smrg%token <tok> T_1D 5977ec681f3Smrg%token <tok> T_2D 5987ec681f3Smrg%token <tok> T_3D 5997ec681f3Smrg%token <tok> T_4D 6007ec681f3Smrg 6017ec681f3Smrg/* condition qualifiers: */ 6027ec681f3Smrg%token <tok> T_LT 6037ec681f3Smrg%token <tok> T_LE 6047ec681f3Smrg%token <tok> T_GT 6057ec681f3Smrg%token <tok> T_GE 6067ec681f3Smrg%token <tok> T_EQ 6077ec681f3Smrg%token <tok> T_NE 6087ec681f3Smrg 6097ec681f3Smrg%token <tok> T_S2EN 6107ec681f3Smrg%token <tok> T_SAMP 6117ec681f3Smrg%token <tok> T_TEX 6127ec681f3Smrg%token <tok> T_BASE 6137ec681f3Smrg%token <tok> T_OFFSET 6147ec681f3Smrg%token <tok> T_UNIFORM 6157ec681f3Smrg%token <tok> T_NONUNIFORM 6167ec681f3Smrg%token <tok> T_IMM 6177ec681f3Smrg 6187ec681f3Smrg%token <tok> T_NAN 6197ec681f3Smrg%token <tok> T_INF 6207ec681f3Smrg%token <num> T_A0 6217ec681f3Smrg%token <num> T_A1 6227ec681f3Smrg%token <num> T_P0 6237ec681f3Smrg%token <num> T_W 6247ec681f3Smrg%token <str> T_CAT1_TYPE_TYPE 6257ec681f3Smrg 6267ec681f3Smrg%type <num> integer offset 6277ec681f3Smrg%type <num> flut_immed 6287ec681f3Smrg%type <flt> float 6297ec681f3Smrg%type <reg> src dst const 6307ec681f3Smrg%type <tok> cat1_opc 6317ec681f3Smrg%type <tok> cat2_opc_1src cat2_opc_2src_cnd cat2_opc_2src 6327ec681f3Smrg%type <tok> cat3_opc 6337ec681f3Smrg%type <tok> cat4_opc 6347ec681f3Smrg%type <tok> cat5_opc cat5_samp cat5_tex cat5_type 6357ec681f3Smrg%type <type> type 6367ec681f3Smrg%type <unum> const_val 6377ec681f3Smrg 6387ec681f3Smrg%error-verbose 6397ec681f3Smrg 6407ec681f3Smrg%start shader 6417ec681f3Smrg 6427ec681f3Smrg%% 6437ec681f3Smrg 6447ec681f3Smrgshader: { new_shader(); } headers instrs 6457ec681f3Smrg 6467ec681f3Smrgheaders: 6477ec681f3Smrg| header headers 6487ec681f3Smrg 6497ec681f3Smrgheader: localsize_header 6507ec681f3Smrg| const_header 6517ec681f3Smrg| buf_header 6527ec681f3Smrg| invocationid_header 6537ec681f3Smrg| wgid_header 6547ec681f3Smrg| numwg_header 6557ec681f3Smrg| branchstack_header 6567ec681f3Smrg| in_header 6577ec681f3Smrg| out_header 6587ec681f3Smrg| tex_header 6597ec681f3Smrg| pvtmem_header 6607ec681f3Smrg 6617ec681f3Smrgconst_val: T_FLOAT { $$ = fui($1); } 6627ec681f3Smrg| T_INT { $$ = $1; } 6637ec681f3Smrg| '-' T_INT { $$ = -$2; } 6647ec681f3Smrg| T_HEX { $$ = $1; } 6657ec681f3Smrg 6667ec681f3Smrglocalsize_header: T_A_LOCALSIZE const_val ',' const_val ',' const_val { 6677ec681f3Smrg variant->local_size[0] = $2; 6687ec681f3Smrg variant->local_size[1] = $4; 6697ec681f3Smrg variant->local_size[2] = $6; 6707ec681f3Smrg} 6717ec681f3Smrg 6727ec681f3Smrgconst_header: T_A_CONST '(' T_CONSTANT ')' const_val ',' const_val ',' const_val ',' const_val { 6737ec681f3Smrg add_const($3, $5, $7, $9, $11); 6747ec681f3Smrg} 6757ec681f3Smrg 6767ec681f3Smrgbuf_header_addr_reg: 6777ec681f3Smrg '(' T_CONSTANT ')' { 6787ec681f3Smrg assert(($2 & 0x1) == 0); /* half-reg not allowed */ 6797ec681f3Smrg unsigned reg = $2 >> 1; 6807ec681f3Smrg 6817ec681f3Smrg info->buf_addr_regs[info->num_bufs - 1] = reg; 6827ec681f3Smrg /* reserve space in immediates for the actual value to be plugged in later: */ 6837ec681f3Smrg add_const($2, 0, 0, 0, 0); 6847ec681f3Smrg} 6857ec681f3Smrg| 6867ec681f3Smrg 6877ec681f3Smrgbuf_header: T_A_BUF const_val { 6887ec681f3Smrg int idx = info->num_bufs++; 6897ec681f3Smrg assert(idx < MAX_BUFS); 6907ec681f3Smrg info->buf_sizes[idx] = $2; 6917ec681f3Smrg} buf_header_addr_reg 6927ec681f3Smrg 6937ec681f3Smrginvocationid_header: T_A_INVOCATIONID '(' T_REGISTER ')' { 6947ec681f3Smrg assert(($3 & 0x1) == 0); /* half-reg not allowed */ 6957ec681f3Smrg unsigned reg = $3 >> 1; 6967ec681f3Smrg add_sysval(reg, 0x7, SYSTEM_VALUE_LOCAL_INVOCATION_ID); 6977ec681f3Smrg} 6987ec681f3Smrg 6997ec681f3Smrgwgid_header: T_A_WGID '(' T_REGISTER ')' { 7007ec681f3Smrg assert(($3 & 0x1) == 0); /* half-reg not allowed */ 7017ec681f3Smrg unsigned reg = $3 >> 1; 7027ec681f3Smrg assert(variant->shader->compiler->gen >= 5); 7037ec681f3Smrg assert(reg >= regid(48, 0)); /* must be a high reg */ 7047ec681f3Smrg add_sysval(reg, 0x7, SYSTEM_VALUE_WORKGROUP_ID); 7057ec681f3Smrg} 7067ec681f3Smrg| T_A_WGID '(' T_CONSTANT ')' { 7077ec681f3Smrg assert(($3 & 0x1) == 0); /* half-reg not allowed */ 7087ec681f3Smrg unsigned reg = $3 >> 1; 7097ec681f3Smrg assert(variant->shader->compiler->gen < 5); 7107ec681f3Smrg info->wgid = reg; 7117ec681f3Smrg} 7127ec681f3Smrg 7137ec681f3Smrgnumwg_header: T_A_NUMWG '(' T_CONSTANT ')' { 7147ec681f3Smrg assert(($3 & 0x1) == 0); /* half-reg not allowed */ 7157ec681f3Smrg unsigned reg = $3 >> 1; 7167ec681f3Smrg info->numwg = reg; 7177ec681f3Smrg /* reserve space in immediates for the actual value to be plugged in later: */ 7187ec681f3Smrg if (variant->shader->compiler->gen >= 5) 7197ec681f3Smrg add_const($3, 0, 0, 0, 0); 7207ec681f3Smrg} 7217ec681f3Smrg 7227ec681f3Smrgbranchstack_header: T_A_BRANCHSTACK const_val { variant->branchstack = $2; } 7237ec681f3Smrg 7247ec681f3Smrgpvtmem_header: T_A_PVTMEM const_val { variant->pvtmem_size = $2; } 7257ec681f3Smrg 7267ec681f3Smrg/* Stubs for now */ 7277ec681f3Smrgin_header: T_A_IN '(' T_REGISTER ')' T_IDENTIFIER '(' T_IDENTIFIER '=' integer ')' { } 7287ec681f3Smrg 7297ec681f3Smrgout_header: T_A_OUT '(' T_REGISTER ')' T_IDENTIFIER '(' T_IDENTIFIER '=' integer ')' { } 7307ec681f3Smrg 7317ec681f3Smrgtex_header: T_A_TEX '(' T_REGISTER ')' 7327ec681f3Smrg T_IDENTIFIER '=' integer ',' /* src */ 7337ec681f3Smrg T_IDENTIFIER '=' integer ',' /* samp */ 7347ec681f3Smrg T_IDENTIFIER '=' integer ',' /* tex */ 7357ec681f3Smrg T_IDENTIFIER '=' integer ',' /* wrmask */ 7367ec681f3Smrg T_IDENTIFIER '=' integer /* cmd */ { } 7377ec681f3Smrg 7387ec681f3Smrgiflag: T_SY { iflags.flags |= IR3_INSTR_SY; } 7397ec681f3Smrg| T_SS { iflags.flags |= IR3_INSTR_SS; } 7407ec681f3Smrg| T_JP { iflags.flags |= IR3_INSTR_JP; } 7417ec681f3Smrg| T_SAT { iflags.flags |= IR3_INSTR_SAT; } 7427ec681f3Smrg| T_RPT { iflags.repeat = $1; } 7437ec681f3Smrg| T_UL { iflags.flags |= IR3_INSTR_UL; } 7447ec681f3Smrg| T_NOP { iflags.nop = $1; } 7457ec681f3Smrg 7467ec681f3Smrgiflags: 7477ec681f3Smrg| iflag iflags 7487ec681f3Smrg 7497ec681f3Smrginstrs: instr instrs 7507ec681f3Smrg| instr 7517ec681f3Smrg 7527ec681f3Smrginstr: iflags cat0_instr 7537ec681f3Smrg| iflags cat1_instr 7547ec681f3Smrg| iflags cat2_instr 7557ec681f3Smrg| iflags cat3_instr 7567ec681f3Smrg| iflags cat4_instr 7577ec681f3Smrg| iflags cat5_instr { fixup_cat5_s2en(); } 7587ec681f3Smrg| iflags cat6_instr 7597ec681f3Smrg| iflags cat7_instr 7607ec681f3Smrg| label 7617ec681f3Smrg 7627ec681f3Smrglabel: T_IDENTIFIER ':' { new_label($1); } 7637ec681f3Smrg 7647ec681f3Smrgcat0_src1: '!' T_P0 { instr->cat0.inv1 = true; instr->cat0.comp1 = $2 >> 1; } 7657ec681f3Smrg| T_P0 { instr->cat0.comp1 = $1 >> 1; } 7667ec681f3Smrg 7677ec681f3Smrgcat0_src2: '!' T_P0 { instr->cat0.inv2 = true; instr->cat0.comp2 = $2 >> 1; } 7687ec681f3Smrg| T_P0 { instr->cat0.comp2 = $1 >> 1; } 7697ec681f3Smrg 7707ec681f3Smrgcat0_immed: '#' integer { instr->cat0.immed = $2; } 7717ec681f3Smrg| '#' T_IDENTIFIER { ralloc_steal(instr, (void *)$2); instr->cat0.target_label = $2; } 7727ec681f3Smrg 7737ec681f3Smrgcat0_instr: T_OP_NOP { new_instr(OPC_NOP); } 7747ec681f3Smrg| T_OP_BR { new_instr(OPC_B)->cat0.brtype = BRANCH_PLAIN; } cat0_src1 ',' cat0_immed 7757ec681f3Smrg| T_OP_BRAO { new_instr(OPC_B)->cat0.brtype = BRANCH_OR; } cat0_src1 ',' cat0_src2 ',' cat0_immed 7767ec681f3Smrg| T_OP_BRAA { new_instr(OPC_B)->cat0.brtype = BRANCH_AND; } cat0_src1 ',' cat0_src2 ',' cat0_immed 7777ec681f3Smrg| T_OP_BRAC '.' integer { new_instr(OPC_B)->cat0.brtype = BRANCH_CONST; instr->cat0.idx = $3; } cat0_immed 7787ec681f3Smrg| T_OP_BANY { new_instr(OPC_B)->cat0.brtype = BRANCH_ANY; } cat0_src1 ',' cat0_immed 7797ec681f3Smrg| T_OP_BALL { new_instr(OPC_B)->cat0.brtype = BRANCH_ALL; } cat0_src1 ',' cat0_immed 7807ec681f3Smrg| T_OP_BRAX { new_instr(OPC_B)->cat0.brtype = BRANCH_X; } cat0_immed 7817ec681f3Smrg| T_OP_JUMP { new_instr(OPC_JUMP); } cat0_immed 7827ec681f3Smrg| T_OP_CALL { new_instr(OPC_CALL); } cat0_immed 7837ec681f3Smrg| T_OP_RET { new_instr(OPC_RET); } 7847ec681f3Smrg| T_OP_KILL { new_instr(OPC_KILL); } cat0_src1 7857ec681f3Smrg| T_OP_END { new_instr(OPC_END); } 7867ec681f3Smrg| T_OP_EMIT { new_instr(OPC_EMIT); } 7877ec681f3Smrg| T_OP_CUT { new_instr(OPC_CUT); } 7887ec681f3Smrg| T_OP_CHMASK { new_instr(OPC_CHMASK); } 7897ec681f3Smrg| T_OP_CHSH { new_instr(OPC_CHSH); } 7907ec681f3Smrg| T_OP_FLOW_REV { new_instr(OPC_FLOW_REV); } 7917ec681f3Smrg| T_OP_BKT { new_instr(OPC_BKT); } cat0_immed 7927ec681f3Smrg| T_OP_STKS { new_instr(OPC_STKS); } 7937ec681f3Smrg| T_OP_STKR { new_instr(OPC_STKR); } 7947ec681f3Smrg| T_OP_XSET { new_instr(OPC_XSET); } 7957ec681f3Smrg| T_OP_XCLR { new_instr(OPC_XCLR); } 7967ec681f3Smrg| T_OP_GETONE { new_instr(OPC_GETONE); } cat0_immed 7977ec681f3Smrg| T_OP_DBG { new_instr(OPC_DBG); } 7987ec681f3Smrg| T_OP_SHPS { new_instr(OPC_SHPS); } cat0_immed 7997ec681f3Smrg| T_OP_SHPE { new_instr(OPC_SHPE); } 8007ec681f3Smrg| T_OP_PREDT { new_instr(OPC_PREDT); } cat0_src1 8017ec681f3Smrg| T_OP_PREDF { new_instr(OPC_PREDF); } cat0_src1 8027ec681f3Smrg| T_OP_PREDE { new_instr(OPC_PREDE); } 8037ec681f3Smrg 8047ec681f3Smrgcat1_opc: T_OP_MOV '.' T_CAT1_TYPE_TYPE { 8057ec681f3Smrg parse_type_type(new_instr(OPC_MOV), $3); 8067ec681f3Smrg} 8077ec681f3Smrg| T_OP_COV '.' T_CAT1_TYPE_TYPE { 8087ec681f3Smrg parse_type_type(new_instr(OPC_MOV), $3); 8097ec681f3Smrg} 8107ec681f3Smrg 8117ec681f3Smrgcat1_src: src_reg_or_const_or_rel 8127ec681f3Smrg| immediate_cat1 8137ec681f3Smrg 8147ec681f3Smrgcat1_movmsk: T_OP_MOVMSK '.' T_W { 8157ec681f3Smrg new_instr(OPC_MOVMSK); 8167ec681f3Smrg instr->cat1.src_type = TYPE_U32; 8177ec681f3Smrg instr->cat1.dst_type = TYPE_U32; 8187ec681f3Smrg instr->repeat = $3 - 1; 8197ec681f3Smrg } dst_reg { 8207ec681f3Smrg instr->dsts[0]->wrmask = (1 << $3) - 1; 8217ec681f3Smrg } 8227ec681f3Smrg 8237ec681f3Smrgcat1_mova1: T_OP_MOVA1 T_A1 ',' { 8247ec681f3Smrg new_instr(OPC_MOV); 8257ec681f3Smrg instr->cat1.src_type = TYPE_U16; 8267ec681f3Smrg instr->cat1.dst_type = TYPE_U16; 8277ec681f3Smrg new_dst((61 << 3) + 2, IR3_REG_HALF); 8287ec681f3Smrg } cat1_src 8297ec681f3Smrg 8307ec681f3Smrgcat1_mova: T_OP_MOVA T_A0 ',' { 8317ec681f3Smrg new_instr(OPC_MOV); 8327ec681f3Smrg instr->cat1.src_type = TYPE_S16; 8337ec681f3Smrg instr->cat1.dst_type = TYPE_S16; 8347ec681f3Smrg new_dst((61 << 3), IR3_REG_HALF); 8357ec681f3Smrg } cat1_src 8367ec681f3Smrg 8377ec681f3Smrgcat1_swz: T_OP_SWZ '.' T_CAT1_TYPE_TYPE { parse_type_type(new_instr(OPC_SWZ), $3); } dst_reg ',' dst_reg ',' src_reg ',' src_reg 8387ec681f3Smrg 8397ec681f3Smrgcat1_gat: T_OP_GAT '.' T_CAT1_TYPE_TYPE { parse_type_type(new_instr(OPC_GAT), $3); } dst_reg ',' src_reg ',' src_reg ',' src_reg ',' src_reg 8407ec681f3Smrg 8417ec681f3Smrgcat1_sct: T_OP_SCT '.' T_CAT1_TYPE_TYPE { parse_type_type(new_instr(OPC_SCT), $3); } dst_reg ',' dst_reg ',' dst_reg ',' dst_reg ',' src_reg 8427ec681f3Smrg 8437ec681f3Smrg /* NOTE: cat1 can also *write* to relative gpr */ 8447ec681f3Smrgcat1_instr: cat1_movmsk 8457ec681f3Smrg| cat1_mova1 8467ec681f3Smrg| cat1_mova 8477ec681f3Smrg| cat1_swz 8487ec681f3Smrg| cat1_gat 8497ec681f3Smrg| cat1_sct 8507ec681f3Smrg| cat1_opc dst_reg ',' cat1_src 8517ec681f3Smrg| cat1_opc relative_gpr_dst ',' cat1_src 8527ec681f3Smrg 8537ec681f3Smrgcat2_opc_1src: T_OP_ABSNEG_F { new_instr(OPC_ABSNEG_F); } 8547ec681f3Smrg| T_OP_ABSNEG_S { new_instr(OPC_ABSNEG_S); } 8557ec681f3Smrg| T_OP_CLZ_B { new_instr(OPC_CLZ_B); } 8567ec681f3Smrg| T_OP_CLZ_S { new_instr(OPC_CLZ_S); } 8577ec681f3Smrg| T_OP_SIGN_F { new_instr(OPC_SIGN_F); } 8587ec681f3Smrg| T_OP_FLOOR_F { new_instr(OPC_FLOOR_F); } 8597ec681f3Smrg| T_OP_CEIL_F { new_instr(OPC_CEIL_F); } 8607ec681f3Smrg| T_OP_RNDNE_F { new_instr(OPC_RNDNE_F); } 8617ec681f3Smrg| T_OP_RNDAZ_F { new_instr(OPC_RNDAZ_F); } 8627ec681f3Smrg| T_OP_TRUNC_F { new_instr(OPC_TRUNC_F); } 8637ec681f3Smrg| T_OP_NOT_B { new_instr(OPC_NOT_B); } 8647ec681f3Smrg| T_OP_BFREV_B { new_instr(OPC_BFREV_B); } 8657ec681f3Smrg| T_OP_SETRM { new_instr(OPC_SETRM); } 8667ec681f3Smrg| T_OP_CBITS_B { new_instr(OPC_CBITS_B); } 8677ec681f3Smrg 8687ec681f3Smrgcat2_opc_2src_cnd: T_OP_CMPS_F { new_instr(OPC_CMPS_F); } 8697ec681f3Smrg| T_OP_CMPS_U { new_instr(OPC_CMPS_U); } 8707ec681f3Smrg| T_OP_CMPS_S { new_instr(OPC_CMPS_S); } 8717ec681f3Smrg| T_OP_CMPV_F { new_instr(OPC_CMPV_F); } 8727ec681f3Smrg| T_OP_CMPV_U { new_instr(OPC_CMPV_U); } 8737ec681f3Smrg| T_OP_CMPV_S { new_instr(OPC_CMPV_S); } 8747ec681f3Smrg 8757ec681f3Smrgcat2_opc_2src: T_OP_ADD_F { new_instr(OPC_ADD_F); } 8767ec681f3Smrg| T_OP_MIN_F { new_instr(OPC_MIN_F); } 8777ec681f3Smrg| T_OP_MAX_F { new_instr(OPC_MAX_F); } 8787ec681f3Smrg| T_OP_MUL_F { new_instr(OPC_MUL_F); } 8797ec681f3Smrg| T_OP_ADD_U { new_instr(OPC_ADD_U); } 8807ec681f3Smrg| T_OP_ADD_S { new_instr(OPC_ADD_S); } 8817ec681f3Smrg| T_OP_SUB_U { new_instr(OPC_SUB_U); } 8827ec681f3Smrg| T_OP_SUB_S { new_instr(OPC_SUB_S); } 8837ec681f3Smrg| T_OP_MIN_U { new_instr(OPC_MIN_U); } 8847ec681f3Smrg| T_OP_MIN_S { new_instr(OPC_MIN_S); } 8857ec681f3Smrg| T_OP_MAX_U { new_instr(OPC_MAX_U); } 8867ec681f3Smrg| T_OP_MAX_S { new_instr(OPC_MAX_S); } 8877ec681f3Smrg| T_OP_AND_B { new_instr(OPC_AND_B); } 8887ec681f3Smrg| T_OP_OR_B { new_instr(OPC_OR_B); } 8897ec681f3Smrg| T_OP_XOR_B { new_instr(OPC_XOR_B); } 8907ec681f3Smrg| T_OP_MUL_U24 { new_instr(OPC_MUL_U24); } 8917ec681f3Smrg| T_OP_MUL_S24 { new_instr(OPC_MUL_S24); } 8927ec681f3Smrg| T_OP_MULL_U { new_instr(OPC_MULL_U); } 8937ec681f3Smrg| T_OP_SHL_B { new_instr(OPC_SHL_B); } 8947ec681f3Smrg| T_OP_SHR_B { new_instr(OPC_SHR_B); } 8957ec681f3Smrg| T_OP_ASHR_B { new_instr(OPC_ASHR_B); } 8967ec681f3Smrg| T_OP_BARY_F { new_instr(OPC_BARY_F); } 8977ec681f3Smrg| T_OP_MGEN_B { new_instr(OPC_MGEN_B); } 8987ec681f3Smrg| T_OP_GETBIT_B { new_instr(OPC_GETBIT_B); } 8997ec681f3Smrg| T_OP_SHB { new_instr(OPC_SHB); } 9007ec681f3Smrg| T_OP_MSAD { new_instr(OPC_MSAD); } 9017ec681f3Smrg 9027ec681f3Smrgcond: T_LT { instr->cat2.condition = IR3_COND_LT; } 9037ec681f3Smrg| T_LE { instr->cat2.condition = IR3_COND_LE; } 9047ec681f3Smrg| T_GT { instr->cat2.condition = IR3_COND_GT; } 9057ec681f3Smrg| T_GE { instr->cat2.condition = IR3_COND_GE; } 9067ec681f3Smrg| T_EQ { instr->cat2.condition = IR3_COND_EQ; } 9077ec681f3Smrg| T_NE { instr->cat2.condition = IR3_COND_NE; } 9087ec681f3Smrg 9097ec681f3Smrgcat2_instr: cat2_opc_1src dst_reg ',' src_reg_or_const_or_rel_or_imm 9107ec681f3Smrg| cat2_opc_2src_cnd '.' cond dst_reg ',' src_reg_or_const_or_rel_or_imm ',' src_reg_or_const_or_rel_or_imm 9117ec681f3Smrg| cat2_opc_2src dst_reg ',' src_reg_or_const_or_rel_or_imm ',' src_reg_or_const_or_rel_or_imm 9127ec681f3Smrg 9137ec681f3Smrgcat3_opc: T_OP_MAD_U16 { new_instr(OPC_MAD_U16); } 9147ec681f3Smrg| T_OP_MADSH_U16 { new_instr(OPC_MADSH_U16); } 9157ec681f3Smrg| T_OP_MAD_S16 { new_instr(OPC_MAD_S16); } 9167ec681f3Smrg| T_OP_MADSH_M16 { new_instr(OPC_MADSH_M16); } 9177ec681f3Smrg| T_OP_MAD_U24 { new_instr(OPC_MAD_U24); } 9187ec681f3Smrg| T_OP_MAD_S24 { new_instr(OPC_MAD_S24); } 9197ec681f3Smrg| T_OP_MAD_F16 { new_instr(OPC_MAD_F16); } 9207ec681f3Smrg| T_OP_MAD_F32 { new_instr(OPC_MAD_F32); } 9217ec681f3Smrg| T_OP_SEL_B16 { new_instr(OPC_SEL_B16); } 9227ec681f3Smrg| T_OP_SEL_B32 { new_instr(OPC_SEL_B32); } 9237ec681f3Smrg| T_OP_SEL_S16 { new_instr(OPC_SEL_S16); } 9247ec681f3Smrg| T_OP_SEL_S32 { new_instr(OPC_SEL_S32); } 9257ec681f3Smrg| T_OP_SEL_F16 { new_instr(OPC_SEL_F16); } 9267ec681f3Smrg| T_OP_SEL_F32 { new_instr(OPC_SEL_F32); } 9277ec681f3Smrg| T_OP_SAD_S16 { new_instr(OPC_SAD_S16); } 9287ec681f3Smrg| T_OP_SAD_S32 { new_instr(OPC_SAD_S32); } 9297ec681f3Smrg 9307ec681f3Smrgcat3_instr: cat3_opc dst_reg ',' src_reg_or_const_or_rel ',' src_reg_or_const ',' src_reg_or_const_or_rel 9317ec681f3Smrg| T_OP_SHLG_B16 { new_instr(OPC_SHLG_B16); } dst_reg ',' src_reg_or_rel_or_imm ',' src_reg_or_const ',' src_reg_or_rel_or_imm 9327ec681f3Smrg 9337ec681f3Smrgcat4_opc: T_OP_RCP { new_instr(OPC_RCP); } 9347ec681f3Smrg| T_OP_RSQ { new_instr(OPC_RSQ); } 9357ec681f3Smrg| T_OP_LOG2 { new_instr(OPC_LOG2); } 9367ec681f3Smrg| T_OP_EXP2 { new_instr(OPC_EXP2); } 9377ec681f3Smrg| T_OP_SIN { new_instr(OPC_SIN); } 9387ec681f3Smrg| T_OP_COS { new_instr(OPC_COS); } 9397ec681f3Smrg| T_OP_SQRT { new_instr(OPC_SQRT); } 9407ec681f3Smrg| T_OP_HRSQ { new_instr(OPC_HRSQ); } 9417ec681f3Smrg| T_OP_HLOG2 { new_instr(OPC_HLOG2); } 9427ec681f3Smrg| T_OP_HEXP2 { new_instr(OPC_HEXP2); } 9437ec681f3Smrg 9447ec681f3Smrgcat4_instr: cat4_opc dst_reg ',' src_reg_or_const_or_rel_or_imm 9457ec681f3Smrg 9467ec681f3Smrgcat5_opc_dsxypp: T_OP_DSXPP_1 { new_instr(OPC_DSXPP_1)->cat5.type = TYPE_F32; } 9477ec681f3Smrg| T_OP_DSYPP_1 { new_instr(OPC_DSYPP_1)->cat5.type = TYPE_F32; } 9487ec681f3Smrg 9497ec681f3Smrgcat5_opc: T_OP_ISAM { new_instr(OPC_ISAM); } 9507ec681f3Smrg| T_OP_ISAML { new_instr(OPC_ISAML); } 9517ec681f3Smrg| T_OP_ISAMM { new_instr(OPC_ISAMM); } 9527ec681f3Smrg| T_OP_SAM { new_instr(OPC_SAM); } 9537ec681f3Smrg| T_OP_SAMB { new_instr(OPC_SAMB); } 9547ec681f3Smrg| T_OP_SAML { new_instr(OPC_SAML); } 9557ec681f3Smrg| T_OP_SAMGQ { new_instr(OPC_SAMGQ); } 9567ec681f3Smrg| T_OP_GETLOD { new_instr(OPC_GETLOD); } 9577ec681f3Smrg| T_OP_CONV { new_instr(OPC_CONV); } 9587ec681f3Smrg| T_OP_CONVM { new_instr(OPC_CONVM); } 9597ec681f3Smrg| T_OP_GETSIZE { new_instr(OPC_GETSIZE); } 9607ec681f3Smrg| T_OP_GETBUF { new_instr(OPC_GETBUF); } 9617ec681f3Smrg| T_OP_GETPOS { new_instr(OPC_GETPOS); } 9627ec681f3Smrg| T_OP_GETINFO { new_instr(OPC_GETINFO); } 9637ec681f3Smrg| T_OP_DSX { new_instr(OPC_DSX); } 9647ec681f3Smrg| T_OP_DSY { new_instr(OPC_DSY); } 9657ec681f3Smrg| T_OP_GATHER4R { new_instr(OPC_GATHER4R); } 9667ec681f3Smrg| T_OP_GATHER4G { new_instr(OPC_GATHER4G); } 9677ec681f3Smrg| T_OP_GATHER4B { new_instr(OPC_GATHER4B); } 9687ec681f3Smrg| T_OP_GATHER4A { new_instr(OPC_GATHER4A); } 9697ec681f3Smrg| T_OP_SAMGP0 { new_instr(OPC_SAMGP0); } 9707ec681f3Smrg| T_OP_SAMGP1 { new_instr(OPC_SAMGP1); } 9717ec681f3Smrg| T_OP_SAMGP2 { new_instr(OPC_SAMGP2); } 9727ec681f3Smrg| T_OP_SAMGP3 { new_instr(OPC_SAMGP3); } 9737ec681f3Smrg| T_OP_RGETPOS { new_instr(OPC_RGETPOS); } 9747ec681f3Smrg| T_OP_RGETINFO { new_instr(OPC_RGETINFO); } 9757ec681f3Smrg 9767ec681f3Smrgcat5_flag: '.' T_3D { instr->flags |= IR3_INSTR_3D; } 9777ec681f3Smrg| '.' 'a' { instr->flags |= IR3_INSTR_A; } 9787ec681f3Smrg| '.' 'o' { instr->flags |= IR3_INSTR_O; } 9797ec681f3Smrg| '.' 'p' { instr->flags |= IR3_INSTR_P; } 9807ec681f3Smrg| '.' 's' { instr->flags |= IR3_INSTR_S; } 9817ec681f3Smrg| '.' T_S2EN { instr->flags |= IR3_INSTR_S2EN; } 9827ec681f3Smrg| '.' T_NONUNIFORM { instr->flags |= IR3_INSTR_NONUNIF; } 9837ec681f3Smrg| '.' T_BASE { instr->flags |= IR3_INSTR_B; instr->cat5.tex_base = $2; } 9847ec681f3Smrgcat5_flags: 9857ec681f3Smrg| cat5_flag cat5_flags 9867ec681f3Smrg 9877ec681f3Smrgcat5_samp: T_SAMP { instr->cat5.samp = $1; } 9887ec681f3Smrgcat5_tex: T_TEX { if (instr->flags & IR3_INSTR_B) instr->cat5.samp |= ($1 << 4); else instr->cat5.tex = $1; } 9897ec681f3Smrgcat5_type: '(' type ')' { instr->cat5.type = $2; } 9907ec681f3Smrgcat5_a1: src_reg { instr->flags |= IR3_INSTR_A1EN; } 9917ec681f3Smrg 9927ec681f3Smrgcat5_instr: cat5_opc_dsxypp cat5_flags dst_reg ',' src_reg 9937ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg ',' src_reg 9947ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg ',' cat5_samp ',' cat5_tex 9957ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg ',' cat5_samp 9967ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg ',' cat5_tex 9977ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg 9987ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' cat5_samp ',' cat5_tex 9997ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' cat5_samp ',' cat5_a1 10007ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' cat5_samp 10017ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' cat5_tex 10027ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg 10037ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' cat5_samp ',' cat5_tex 10047ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' cat5_samp 10057ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg ',' cat5_tex 10067ec681f3Smrg| cat5_opc cat5_flags cat5_type dst_reg 10077ec681f3Smrg 10087ec681f3Smrgcat6_typed: '.' T_UNTYPED { instr->cat6.typed = 0; } 10097ec681f3Smrg| '.' T_TYPED { instr->cat6.typed = 1; } 10107ec681f3Smrg 10117ec681f3Smrgcat6_dim: '.' T_1D { instr->cat6.d = 1; } 10127ec681f3Smrg| '.' T_2D { instr->cat6.d = 2; } 10137ec681f3Smrg| '.' T_3D { instr->cat6.d = 3; } 10147ec681f3Smrg| '.' T_4D { instr->cat6.d = 4; } 10157ec681f3Smrg 10167ec681f3Smrgcat6_type: '.' type { instr->cat6.type = $2; } 10177ec681f3Smrgcat6_imm_offset: offset { new_src(0, IR3_REG_IMMED)->iim_val = $1; } 10187ec681f3Smrgcat6_offset: cat6_imm_offset 10197ec681f3Smrg| '+' src 10207ec681f3Smrgcat6_dst_offset: offset { instr->cat6.dst_offset = $1; } 10217ec681f3Smrg| '+' src { instr->flags |= IR3_INSTR_G; } 10227ec681f3Smrg 10237ec681f3Smrgcat6_immed: integer { instr->cat6.iim_val = $1; } 10247ec681f3Smrg 10257ec681f3Smrgcat6_stg_ldg_a6xx_offset: 10267ec681f3Smrg '+' '(' src offset ')' '<' '<' integer { 10277ec681f3Smrg assert($8 == 2); 10287ec681f3Smrg new_src(0, IR3_REG_IMMED)->uim_val = 0; 10297ec681f3Smrg new_src(0, IR3_REG_IMMED)->uim_val = $4; 10307ec681f3Smrg } 10317ec681f3Smrg| '+' src '<' '<' integer offset '<' '<' integer { 10327ec681f3Smrg assert($9 == 2); 10337ec681f3Smrg new_src(0, IR3_REG_IMMED)->uim_val = $5 - 2; 10347ec681f3Smrg new_src(0, IR3_REG_IMMED)->uim_val = $6; 10357ec681f3Smrg } 10367ec681f3Smrg 10377ec681f3Smrgcat6_load: T_OP_LDG { new_instr(OPC_LDG); } cat6_type dst_reg ',' 'g' '[' src cat6_offset ']' ',' immediate 10387ec681f3Smrg| T_OP_LDG_A { new_instr(OPC_LDG_A); } cat6_type dst_reg ',' 'g' '[' src cat6_stg_ldg_a6xx_offset ']' ',' immediate 10397ec681f3Smrg| T_OP_LDP { new_instr(OPC_LDP); } cat6_type dst_reg ',' 'p' '[' src cat6_offset ']' ',' immediate 10407ec681f3Smrg| T_OP_LDL { new_instr(OPC_LDL); } cat6_type dst_reg ',' 'l' '[' src cat6_offset ']' ',' immediate 10417ec681f3Smrg| T_OP_LDLW { new_instr(OPC_LDLW); } cat6_type dst_reg ',' 'l' '[' src cat6_offset ']' ',' immediate 10427ec681f3Smrg| T_OP_LDLV { new_instr(OPC_LDLV); } cat6_type dst_reg ',' 'l' '[' integer ']' { 10437ec681f3Smrg new_src(0, IR3_REG_IMMED)->iim_val = $8; 10447ec681f3Smrg } ',' immediate 10457ec681f3Smrg 10467ec681f3Smrgcat6_store: T_OP_STG { new_instr(OPC_STG); dummy_dst(); } cat6_type 'g' '[' src cat6_imm_offset ']' ',' src ',' immediate 10477ec681f3Smrg| T_OP_STG_A { new_instr(OPC_STG_A); dummy_dst(); } cat6_type 'g' '[' src cat6_stg_ldg_a6xx_offset ']' ',' src ',' immediate 10487ec681f3Smrg| T_OP_STP { new_instr(OPC_STP); dummy_dst(); } cat6_type 'p' '[' src cat6_dst_offset ']' ',' src ',' immediate 10497ec681f3Smrg| T_OP_STL { new_instr(OPC_STL); dummy_dst(); } cat6_type 'l' '[' src cat6_dst_offset ']' ',' src ',' immediate 10507ec681f3Smrg| T_OP_STLW { new_instr(OPC_STLW); dummy_dst(); } cat6_type 'l' '[' src cat6_dst_offset ']' ',' src ',' immediate 10517ec681f3Smrg 10527ec681f3Smrgcat6_loadib: T_OP_LDIB { new_instr(OPC_LDIB); } cat6_typed cat6_dim cat6_type '.' cat6_immed dst_reg ',' 'g' '[' immediate ']' ',' src ',' src 10537ec681f3Smrgcat6_storeib: T_OP_STIB { new_instr(OPC_STIB); dummy_dst(); } cat6_typed cat6_dim cat6_type '.' cat6_immed'g' '[' immediate ']' ',' src ',' src ',' src 10547ec681f3Smrg 10557ec681f3Smrgcat6_prefetch: T_OP_PREFETCH { new_instr(OPC_PREFETCH); new_dst(0,0); /* dummy dst */ } 'g' '[' src cat6_offset ']' ',' cat6_immed 10567ec681f3Smrg 10577ec681f3Smrgcat6_atomic_opc: T_OP_ATOMIC_ADD { new_instr(OPC_ATOMIC_ADD); } 10587ec681f3Smrg| T_OP_ATOMIC_SUB { new_instr(OPC_ATOMIC_SUB); } 10597ec681f3Smrg| T_OP_ATOMIC_XCHG { new_instr(OPC_ATOMIC_XCHG); } 10607ec681f3Smrg| T_OP_ATOMIC_INC { new_instr(OPC_ATOMIC_INC); } 10617ec681f3Smrg| T_OP_ATOMIC_DEC { new_instr(OPC_ATOMIC_DEC); } 10627ec681f3Smrg| T_OP_ATOMIC_CMPXCHG { new_instr(OPC_ATOMIC_CMPXCHG); } 10637ec681f3Smrg| T_OP_ATOMIC_MIN { new_instr(OPC_ATOMIC_MIN); } 10647ec681f3Smrg| T_OP_ATOMIC_MAX { new_instr(OPC_ATOMIC_MAX); } 10657ec681f3Smrg| T_OP_ATOMIC_AND { new_instr(OPC_ATOMIC_AND); } 10667ec681f3Smrg| T_OP_ATOMIC_OR { new_instr(OPC_ATOMIC_OR); } 10677ec681f3Smrg| T_OP_ATOMIC_XOR { new_instr(OPC_ATOMIC_XOR); } 10687ec681f3Smrg 10697ec681f3Smrgcat6_atomic_g: cat6_atomic_opc cat6_typed cat6_dim cat6_type '.' cat6_immed '.' 'g' dst_reg ',' 'g' '[' cat6_reg_or_immed ']' ',' src ',' src ',' src { 10707ec681f3Smrg instr->flags |= IR3_INSTR_G; 10717ec681f3Smrg } 10727ec681f3Smrg 10737ec681f3Smrgcat6_atomic_l: cat6_atomic_opc cat6_typed cat6_dim cat6_type '.' cat6_immed '.' 'l' dst_reg ',' 'l' '[' cat6_reg_or_immed ']' ',' src 10747ec681f3Smrg 10757ec681f3Smrgcat6_atomic: cat6_atomic_g 10767ec681f3Smrg| cat6_atomic_l 10777ec681f3Smrg 10787ec681f3Smrgcat6_ibo_opc_1src: T_OP_RESINFO { new_instr(OPC_RESINFO); } 10797ec681f3Smrg 10807ec681f3Smrgcat6_ibo_opc_ldgb: T_OP_LDGB { new_instr(OPC_LDGB); } 10817ec681f3Smrgcat6_ibo_opc_stgb: T_OP_STGB { new_instr(OPC_STGB); } 10827ec681f3Smrg 10837ec681f3Smrgcat6_ibo: cat6_ibo_opc_1src cat6_type cat6_dim dst_reg ',' 'g' '[' cat6_reg_or_immed ']' 10847ec681f3Smrg| cat6_ibo_opc_ldgb cat6_typed cat6_dim cat6_type '.' cat6_immed dst_reg ',' 'g' '[' cat6_reg_or_immed ']' ',' src ',' src 10857ec681f3Smrg| cat6_ibo_opc_stgb cat6_typed cat6_dim cat6_type '.' cat6_immed { dummy_dst(); } 'g' '[' cat6_reg_or_immed ']' ',' src ',' cat6_reg_or_immed ',' src 10867ec681f3Smrg 10877ec681f3Smrgcat6_id_opc: 10887ec681f3Smrg T_OP_GETSPID { new_instr(OPC_GETSPID); } 10897ec681f3Smrg| T_OP_GETWID { new_instr(OPC_GETWID); } 10907ec681f3Smrg 10917ec681f3Smrgcat6_id: cat6_id_opc cat6_type dst_reg 10927ec681f3Smrg 10937ec681f3Smrgcat6_bindless_base: 10947ec681f3Smrg| '.' T_BASE { instr->flags |= IR3_INSTR_B; instr->cat6.base = $2; } 10957ec681f3Smrg 10967ec681f3Smrgcat6_bindless_mode: T_IMM cat6_bindless_base 10977ec681f3Smrg| T_UNIFORM cat6_bindless_base 10987ec681f3Smrg| T_NONUNIFORM cat6_bindless_base { instr->flags |= IR3_INSTR_NONUNIF; } 10997ec681f3Smrg 11007ec681f3Smrgcat6_reg_or_immed: src 11017ec681f3Smrg| integer { new_src(0, IR3_REG_IMMED)->iim_val = $1; } 11027ec681f3Smrg 11037ec681f3Smrgcat6_bindless_ibo_opc_1src: T_OP_RESINFO_B { new_instr(OPC_RESINFO); } 11047ec681f3Smrg 11057ec681f3Smrgcat6_bindless_ibo_opc_2src: T_OP_ATOMIC_B_ADD { new_instr(OPC_ATOMIC_ADD)->flags |= IR3_INSTR_G; dummy_dst(); } 11067ec681f3Smrg| T_OP_ATOMIC_B_SUB { new_instr(OPC_ATOMIC_SUB)->flags |= IR3_INSTR_G; dummy_dst(); } 11077ec681f3Smrg| T_OP_ATOMIC_B_XCHG { new_instr(OPC_ATOMIC_XCHG)->flags |= IR3_INSTR_G; dummy_dst(); } 11087ec681f3Smrg| T_OP_ATOMIC_B_INC { new_instr(OPC_ATOMIC_INC)->flags |= IR3_INSTR_G; dummy_dst(); } 11097ec681f3Smrg| T_OP_ATOMIC_B_DEC { new_instr(OPC_ATOMIC_DEC)->flags |= IR3_INSTR_G; dummy_dst(); } 11107ec681f3Smrg| T_OP_ATOMIC_B_CMPXCHG { new_instr(OPC_ATOMIC_CMPXCHG)->flags |= IR3_INSTR_G; dummy_dst(); } 11117ec681f3Smrg| T_OP_ATOMIC_B_MIN { new_instr(OPC_ATOMIC_MIN)->flags |= IR3_INSTR_G; dummy_dst(); } 11127ec681f3Smrg| T_OP_ATOMIC_B_MAX { new_instr(OPC_ATOMIC_MAX)->flags |= IR3_INSTR_G; dummy_dst(); } 11137ec681f3Smrg| T_OP_ATOMIC_B_AND { new_instr(OPC_ATOMIC_AND)->flags |= IR3_INSTR_G; dummy_dst(); } 11147ec681f3Smrg| T_OP_ATOMIC_B_OR { new_instr(OPC_ATOMIC_OR)->flags |= IR3_INSTR_G; dummy_dst(); } 11157ec681f3Smrg| T_OP_ATOMIC_B_XOR { new_instr(OPC_ATOMIC_XOR)->flags |= IR3_INSTR_G; dummy_dst(); } 11167ec681f3Smrg| T_OP_STIB_B { new_instr(OPC_STIB); dummy_dst(); } 11177ec681f3Smrg 11187ec681f3Smrgcat6_bindless_ibo_opc_2src_dst: T_OP_LDIB_B { new_instr(OPC_LDIB); } 11197ec681f3Smrg 11207ec681f3Smrgcat6_bindless_ibo: cat6_bindless_ibo_opc_1src cat6_typed cat6_dim cat6_type '.' cat6_immed '.' cat6_bindless_mode dst_reg ',' cat6_reg_or_immed 11217ec681f3Smrg| cat6_bindless_ibo_opc_2src cat6_typed cat6_dim cat6_type '.' cat6_immed '.' cat6_bindless_mode src_reg ',' cat6_reg_or_immed ',' cat6_reg_or_immed { swap(instr->srcs[0], instr->srcs[2]); } 11227ec681f3Smrg| cat6_bindless_ibo_opc_2src_dst cat6_typed cat6_dim cat6_type '.' cat6_immed '.' cat6_bindless_mode dst_reg ',' cat6_reg_or_immed ',' cat6_reg_or_immed { swap(instr->srcs[0], instr->srcs[1]); } 11237ec681f3Smrg 11247ec681f3Smrgcat6_bindless_ldc_opc: T_OP_LDC { new_instr(OPC_LDC); } 11257ec681f3Smrg 11267ec681f3Smrgcat6_bindless_ldc: cat6_bindless_ldc_opc '.' T_OFFSET '.' cat6_immed '.' cat6_bindless_mode dst_reg ',' cat6_reg_or_immed ',' cat6_reg_or_immed { 11277ec681f3Smrg instr->cat6.d = $3; 11287ec681f3Smrg instr->cat6.type = TYPE_U32; 11297ec681f3Smrg /* TODO cleanup ir3 src order: */ 11307ec681f3Smrg swap(instr->srcs[0], instr->srcs[1]); 11317ec681f3Smrg } 11327ec681f3Smrg 11337ec681f3Smrgcat6_todo: T_OP_G2L { new_instr(OPC_G2L); } 11347ec681f3Smrg| T_OP_L2G { new_instr(OPC_L2G); } 11357ec681f3Smrg| T_OP_RESFMT { new_instr(OPC_RESFMT); } 11367ec681f3Smrg 11377ec681f3Smrgcat6_instr: cat6_load 11387ec681f3Smrg| cat6_loadib 11397ec681f3Smrg| cat6_store 11407ec681f3Smrg| cat6_storeib 11417ec681f3Smrg| cat6_prefetch 11427ec681f3Smrg| cat6_atomic 11437ec681f3Smrg| cat6_ibo 11447ec681f3Smrg| cat6_id 11457ec681f3Smrg| cat6_bindless_ldc 11467ec681f3Smrg| cat6_bindless_ibo 11477ec681f3Smrg| cat6_todo 11487ec681f3Smrg 11497ec681f3Smrgcat7_scope: '.' 'w' { instr->cat7.w = true; } 11507ec681f3Smrg| '.' 'r' { instr->cat7.r = true; } 11517ec681f3Smrg| '.' 'l' { instr->cat7.l = true; } 11527ec681f3Smrg| '.' 'g' { instr->cat7.g = true; } 11537ec681f3Smrg 11547ec681f3Smrgcat7_scopes: 11557ec681f3Smrg| cat7_scope cat7_scopes 11567ec681f3Smrg 11577ec681f3Smrgcat7_barrier: T_OP_BAR { new_instr(OPC_BAR); } cat7_scopes 11587ec681f3Smrg| T_OP_FENCE { new_instr(OPC_FENCE); } cat7_scopes 11597ec681f3Smrg 11607ec681f3Smrgcat7_instr: cat7_barrier 11617ec681f3Smrg 11627ec681f3Smrgsrc: T_REGISTER { $$ = new_src($1, 0); } 11637ec681f3Smrg| T_A0 { $$ = new_src((61 << 3), IR3_REG_HALF); } 11647ec681f3Smrg| T_A1 { $$ = new_src((61 << 3) + 1, IR3_REG_HALF); } 11657ec681f3Smrg| T_P0 { $$ = new_src((62 << 3) + $1, 0); } 11667ec681f3Smrg 11677ec681f3Smrgdst: T_REGISTER { $$ = new_dst($1, 0); } 11687ec681f3Smrg| T_A0 { $$ = new_dst((61 << 3), IR3_REG_HALF); } 11697ec681f3Smrg| T_A1 { $$ = new_dst((61 << 3) + 1, IR3_REG_HALF); } 11707ec681f3Smrg| T_P0 { $$ = new_dst((62 << 3) + $1, 0); } 11717ec681f3Smrg 11727ec681f3Smrgconst: T_CONSTANT { $$ = new_src($1, IR3_REG_CONST); } 11737ec681f3Smrg 11747ec681f3Smrgdst_reg_flag: T_EVEN { instr->cat1.round = ROUND_EVEN; } 11757ec681f3Smrg| T_POS_INFINITY { instr->cat1.round = ROUND_POS_INF; } 11767ec681f3Smrg| T_NEG_INFINITY { instr->cat1.round = ROUND_NEG_INF; } 11777ec681f3Smrg| T_EI { rflags.flags |= IR3_REG_EI; } 11787ec681f3Smrg| T_WRMASK { rflags.wrmask = $1; } 11797ec681f3Smrg 11807ec681f3Smrgdst_reg_flags: dst_reg_flag 11817ec681f3Smrg| dst_reg_flag dst_reg_flags 11827ec681f3Smrg 11837ec681f3Smrg /* note: destination registers are always incremented in repeat */ 11847ec681f3Smrgdst_reg: dst { $1->flags |= IR3_REG_R; } 11857ec681f3Smrg| dst_reg_flags dst { $2->flags |= IR3_REG_R; } 11867ec681f3Smrg 11877ec681f3Smrgsrc_reg_flag: T_ABSNEG { rflags.flags |= IR3_REG_ABS|IR3_REG_NEGATE; } 11887ec681f3Smrg| T_NEG { rflags.flags |= IR3_REG_NEGATE; } 11897ec681f3Smrg| T_ABS { rflags.flags |= IR3_REG_ABS; } 11907ec681f3Smrg| T_R { rflags.flags |= IR3_REG_R; } 11917ec681f3Smrg 11927ec681f3Smrgsrc_reg_flags: src_reg_flag 11937ec681f3Smrg| src_reg_flag src_reg_flags 11947ec681f3Smrg 11957ec681f3Smrgsrc_reg: src 11967ec681f3Smrg| src_reg_flags src 11977ec681f3Smrg 11987ec681f3Smrgsrc_const: const 11997ec681f3Smrg| src_reg_flags const 12007ec681f3Smrg 12017ec681f3Smrgsrc_reg_or_const: src_reg 12027ec681f3Smrg| src_const 12037ec681f3Smrg 12047ec681f3Smrgsrc_reg_or_const_or_rel: src_reg_or_const 12057ec681f3Smrg| relative 12067ec681f3Smrg| src_reg_flags relative 12077ec681f3Smrg 12087ec681f3Smrgsrc_reg_or_const_or_rel_or_imm: src_reg_or_const_or_rel 12097ec681f3Smrg| src_reg_flags immediate 12107ec681f3Smrg| immediate 12117ec681f3Smrg 12127ec681f3Smrgsrc_reg_or_rel_or_imm: src_reg 12137ec681f3Smrg| relative 12147ec681f3Smrg| immediate 12157ec681f3Smrg 12167ec681f3Smrgoffset: { $$ = 0; } 12177ec681f3Smrg| '+' integer { $$ = $2; } 12187ec681f3Smrg| '-' integer { $$ = -$2; } 12197ec681f3Smrg 12207ec681f3Smrgrelative_gpr_src: 'r' '<' T_A0 offset '>' { new_src(0, IR3_REG_RELATIV)->array.offset = $4; } 12217ec681f3Smrg| T_HR '<' T_A0 offset '>' { new_src(0, IR3_REG_RELATIV | IR3_REG_HALF)->array.offset = $4; } 12227ec681f3Smrg 12237ec681f3Smrgrelative_gpr_dst: 'r' '<' T_A0 offset '>' { new_dst(0, IR3_REG_RELATIV)->array.offset = $4; } 12247ec681f3Smrg| T_HR '<' T_A0 offset '>' { new_dst(0, IR3_REG_RELATIV | IR3_REG_HALF)->array.offset = $4; } 12257ec681f3Smrg 12267ec681f3Smrgrelative_const: 'c' '<' T_A0 offset '>' { new_src(0, IR3_REG_RELATIV | IR3_REG_CONST)->array.offset = $4; } 12277ec681f3Smrg| T_HC '<' T_A0 offset '>' { new_src(0, IR3_REG_RELATIV | IR3_REG_CONST | IR3_REG_HALF)->array.offset = $4; } 12287ec681f3Smrg 12297ec681f3Smrgrelative: relative_gpr_src 12307ec681f3Smrg| relative_const 12317ec681f3Smrg 12327ec681f3Smrg/* cat1 immediates differ slighly in the floating point case from the cat2 12337ec681f3Smrg * case which can only encode certain predefined values (ie. and index into 12347ec681f3Smrg * the FLUT table) 12357ec681f3Smrg */ 12367ec681f3Smrgimmediate_cat1: integer { new_src(0, IR3_REG_IMMED)->iim_val = type_size(instr->cat1.src_type) < 32 ? $1 & 0xffff : $1; } 12377ec681f3Smrg| '(' integer ')' { new_src(0, IR3_REG_IMMED)->fim_val = $2; } 12387ec681f3Smrg| '(' float ')' { new_src(0, IR3_REG_IMMED)->fim_val = $2; } 12397ec681f3Smrg| 'h' '(' integer ')' { new_src(0, IR3_REG_IMMED | IR3_REG_HALF)->iim_val = $3 & 0xffff; } 12407ec681f3Smrg| 'h' '(' float ')' { new_src(0, IR3_REG_IMMED | IR3_REG_HALF)->uim_val = _mesa_float_to_half($3); } 12417ec681f3Smrg| '(' T_NAN ')' { new_src(0, IR3_REG_IMMED)->fim_val = NAN; } 12427ec681f3Smrg| '(' T_INF ')' { new_src(0, IR3_REG_IMMED)->fim_val = INFINITY; } 12437ec681f3Smrg 12447ec681f3Smrgimmediate: integer { new_src(0, IR3_REG_IMMED)->iim_val = $1; } 12457ec681f3Smrg| '(' integer ')' { new_src(0, IR3_REG_IMMED)->fim_val = $2; } 12467ec681f3Smrg| flut_immed { new_src(0, IR3_REG_IMMED)->uim_val = $1; } 12477ec681f3Smrg| 'h' '(' integer ')' { new_src(0, IR3_REG_IMMED | IR3_REG_HALF)->iim_val = $3; } 12487ec681f3Smrg| 'h' flut_immed { new_src(0, IR3_REG_IMMED | IR3_REG_HALF)->uim_val = $2; } 12497ec681f3Smrg 12507ec681f3Smrg/* Float LUT values accepted as immed: */ 12517ec681f3Smrgflut_immed: T_FLUT_0_0 12527ec681f3Smrg| T_FLUT_0_5 12537ec681f3Smrg| T_FLUT_1_0 12547ec681f3Smrg| T_FLUT_2_0 12557ec681f3Smrg| T_FLUT_E 12567ec681f3Smrg| T_FLUT_PI 12577ec681f3Smrg| T_FLUT_INV_PI 12587ec681f3Smrg| T_FLUT_INV_LOG2_E 12597ec681f3Smrg| T_FLUT_LOG2_E 12607ec681f3Smrg| T_FLUT_INV_LOG2_10 12617ec681f3Smrg| T_FLUT_LOG2_10 12627ec681f3Smrg| T_FLUT_4_0 12637ec681f3Smrg 12647ec681f3Smrginteger: T_INT { $$ = $1; } 12657ec681f3Smrg| '-' T_INT { $$ = -$2; } 12667ec681f3Smrg| T_HEX { $$ = $1; } 12677ec681f3Smrg| '-' T_HEX { $$ = -$2; } 12687ec681f3Smrg 12697ec681f3Smrgfloat: T_FLOAT { $$ = $1; } 12707ec681f3Smrg| '-' T_FLOAT { $$ = -$2; } 12717ec681f3Smrg 12727ec681f3Smrgtype: T_TYPE_F16 { $$ = TYPE_F16; } 12737ec681f3Smrg| T_TYPE_F32 { $$ = TYPE_F32; } 12747ec681f3Smrg| T_TYPE_U16 { $$ = TYPE_U16; } 12757ec681f3Smrg| T_TYPE_U32 { $$ = TYPE_U32; } 12767ec681f3Smrg| T_TYPE_S16 { $$ = TYPE_S16; } 12777ec681f3Smrg| T_TYPE_S32 { $$ = TYPE_S32; } 12787ec681f3Smrg| T_TYPE_U8 { $$ = TYPE_U8; } 12797ec681f3Smrg| T_TYPE_S8 { $$ = TYPE_S8; } 1280