1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (c) 2013 Rob Clark <robclark@freedesktop.org> 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21bf215546Sopenharmony_ci * SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci%code requires { 25bf215546Sopenharmony_ci#include "ir3/ir3_assembler.h" 26bf215546Sopenharmony_ci#include "ir3/ir3_shader.h" 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_cistruct ir3 * ir3_parse(struct ir3_shader_variant *v, 29bf215546Sopenharmony_ci struct ir3_kernel_info *k, FILE *f); 30bf215546Sopenharmony_ci} 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci%{ 33bf215546Sopenharmony_ci#define YYDEBUG 0 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#include <stdlib.h> 36bf215546Sopenharmony_ci#include <stdio.h> 37bf215546Sopenharmony_ci#include <string.h> 38bf215546Sopenharmony_ci#include <math.h> 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ci#include "util/half_float.h" 41bf215546Sopenharmony_ci#include "util/u_math.h" 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ci#include "ir3/ir3.h" 44bf215546Sopenharmony_ci#include "ir3/ir3_shader.h" 45bf215546Sopenharmony_ci#include "ir3/instr-a3xx.h" 46bf215546Sopenharmony_ci 47bf215546Sopenharmony_ci#include "ir3_parser.h" 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci#define swap(a, b) \ 50bf215546Sopenharmony_ci do { __typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci/* ir3 treats the abs/neg flags as separate flags for float vs integer, 53bf215546Sopenharmony_ci * but in the instruction encoding they are the same thing. Tracking 54bf215546Sopenharmony_ci * them separately is only for the benefit of ir3 opt passes, and not 55bf215546Sopenharmony_ci * required here, so just use the float versions: 56bf215546Sopenharmony_ci */ 57bf215546Sopenharmony_ci#define IR3_REG_ABS IR3_REG_FABS 58bf215546Sopenharmony_ci#define IR3_REG_NEGATE IR3_REG_FNEG 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_cistatic struct ir3_kernel_info *info; 61bf215546Sopenharmony_cistatic struct ir3_shader_variant *variant; 62bf215546Sopenharmony_ci/* NOTE the assembler doesn't really use the ir3_block construction 63bf215546Sopenharmony_ci * like the compiler does. Everything is treated as one large block. 64bf215546Sopenharmony_ci * Which might happen to contain flow control. But since we don't 65bf215546Sopenharmony_ci * use any of the ir3 backend passes (sched, RA, etc) this doesn't 66bf215546Sopenharmony_ci * really matter. 67bf215546Sopenharmony_ci */ 68bf215546Sopenharmony_cistatic struct ir3_block *block; /* current shader block */ 69bf215546Sopenharmony_cistatic struct ir3_instruction *instr; /* current instruction */ 70bf215546Sopenharmony_cistatic unsigned ip; /* current instruction pointer */ 71bf215546Sopenharmony_cistatic struct hash_table *labels; 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_civoid *ir3_parser_dead_ctx; 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_cistatic struct { 76bf215546Sopenharmony_ci unsigned flags; 77bf215546Sopenharmony_ci unsigned repeat; 78bf215546Sopenharmony_ci unsigned nop; 79bf215546Sopenharmony_ci} iflags; 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_cistatic struct { 82bf215546Sopenharmony_ci unsigned flags; 83bf215546Sopenharmony_ci unsigned wrmask; 84bf215546Sopenharmony_ci} rflags; 85bf215546Sopenharmony_ci 86bf215546Sopenharmony_ciint ir3_yyget_lineno(void); 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_cistatic void new_label(const char *name) 89bf215546Sopenharmony_ci{ 90bf215546Sopenharmony_ci ralloc_steal(labels, (void *) name); 91bf215546Sopenharmony_ci _mesa_hash_table_insert(labels, name, (void *)(uintptr_t)ip); 92bf215546Sopenharmony_ci} 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_cistatic struct ir3_instruction * new_instr(opc_t opc) 95bf215546Sopenharmony_ci{ 96bf215546Sopenharmony_ci instr = ir3_instr_create(block, opc, 4, 6); 97bf215546Sopenharmony_ci instr->flags = iflags.flags; 98bf215546Sopenharmony_ci instr->repeat = iflags.repeat; 99bf215546Sopenharmony_ci instr->nop = iflags.nop; 100bf215546Sopenharmony_ci instr->line = ir3_yyget_lineno(); 101bf215546Sopenharmony_ci iflags.flags = iflags.repeat = iflags.nop = 0; 102bf215546Sopenharmony_ci ip++; 103bf215546Sopenharmony_ci return instr; 104bf215546Sopenharmony_ci} 105bf215546Sopenharmony_ci 106bf215546Sopenharmony_cistatic void new_shader(void) 107bf215546Sopenharmony_ci{ 108bf215546Sopenharmony_ci variant->ir = ir3_create(variant->compiler, variant); 109bf215546Sopenharmony_ci block = ir3_block_create(variant->ir); 110bf215546Sopenharmony_ci list_addtail(&block->node, &variant->ir->block_list); 111bf215546Sopenharmony_ci ip = 0; 112bf215546Sopenharmony_ci labels = _mesa_hash_table_create(variant, _mesa_hash_string, _mesa_key_string_equal); 113bf215546Sopenharmony_ci ir3_parser_dead_ctx = ralloc_context(NULL); 114bf215546Sopenharmony_ci} 115bf215546Sopenharmony_ci 116bf215546Sopenharmony_cistatic type_t parse_type(const char **type) 117bf215546Sopenharmony_ci{ 118bf215546Sopenharmony_ci if (!strncmp("f16", *type, 3)) { 119bf215546Sopenharmony_ci *type += 3; 120bf215546Sopenharmony_ci return TYPE_F16; 121bf215546Sopenharmony_ci } else if (!strncmp("f32", *type, 3)) { 122bf215546Sopenharmony_ci *type += 3; 123bf215546Sopenharmony_ci return TYPE_F32; 124bf215546Sopenharmony_ci } else if (!strncmp("u16", *type, 3)) { 125bf215546Sopenharmony_ci *type += 3; 126bf215546Sopenharmony_ci return TYPE_U16; 127bf215546Sopenharmony_ci } else if (!strncmp("u32", *type, 3)) { 128bf215546Sopenharmony_ci *type += 3; 129bf215546Sopenharmony_ci return TYPE_U32; 130bf215546Sopenharmony_ci } else if (!strncmp("s16", *type, 3)) { 131bf215546Sopenharmony_ci *type += 3; 132bf215546Sopenharmony_ci return TYPE_S16; 133bf215546Sopenharmony_ci } else if (!strncmp("s32", *type, 3)) { 134bf215546Sopenharmony_ci *type += 3; 135bf215546Sopenharmony_ci return TYPE_S32; 136bf215546Sopenharmony_ci } else if (!strncmp("u8", *type, 2)) { 137bf215546Sopenharmony_ci *type += 2; 138bf215546Sopenharmony_ci return TYPE_U8; 139bf215546Sopenharmony_ci } else if (!strncmp("s8", *type, 2)) { 140bf215546Sopenharmony_ci *type += 2; 141bf215546Sopenharmony_ci return TYPE_S8; 142bf215546Sopenharmony_ci } else { 143bf215546Sopenharmony_ci assert(0); /* shouldn't get here */ 144bf215546Sopenharmony_ci return ~0; 145bf215546Sopenharmony_ci } 146bf215546Sopenharmony_ci} 147bf215546Sopenharmony_ci 148bf215546Sopenharmony_cistatic struct ir3_instruction * parse_type_type(struct ir3_instruction *instr, 149bf215546Sopenharmony_ci const char *type_type) 150bf215546Sopenharmony_ci{ 151bf215546Sopenharmony_ci instr->cat1.src_type = parse_type(&type_type); 152bf215546Sopenharmony_ci instr->cat1.dst_type = parse_type(&type_type); 153bf215546Sopenharmony_ci return instr; 154bf215546Sopenharmony_ci} 155bf215546Sopenharmony_ci 156bf215546Sopenharmony_cistatic struct ir3_register * new_src(int num, unsigned flags) 157bf215546Sopenharmony_ci{ 158bf215546Sopenharmony_ci struct ir3_register *reg; 159bf215546Sopenharmony_ci flags |= rflags.flags; 160bf215546Sopenharmony_ci if (num & 0x1) 161bf215546Sopenharmony_ci flags |= IR3_REG_HALF; 162bf215546Sopenharmony_ci reg = ir3_src_create(instr, num>>1, flags); 163bf215546Sopenharmony_ci reg->wrmask = MAX2(1, rflags.wrmask); 164bf215546Sopenharmony_ci rflags.flags = rflags.wrmask = 0; 165bf215546Sopenharmony_ci return reg; 166bf215546Sopenharmony_ci} 167bf215546Sopenharmony_ci 168bf215546Sopenharmony_cistatic struct ir3_register * new_dst(int num, unsigned flags) 169bf215546Sopenharmony_ci{ 170bf215546Sopenharmony_ci struct ir3_register *reg; 171bf215546Sopenharmony_ci flags |= rflags.flags; 172bf215546Sopenharmony_ci if (num & 0x1) 173bf215546Sopenharmony_ci flags |= IR3_REG_HALF; 174bf215546Sopenharmony_ci reg = ir3_dst_create(instr, num>>1, flags); 175bf215546Sopenharmony_ci reg->wrmask = MAX2(1, rflags.wrmask); 176bf215546Sopenharmony_ci rflags.flags = rflags.wrmask = 0; 177bf215546Sopenharmony_ci return reg; 178bf215546Sopenharmony_ci} 179bf215546Sopenharmony_ci 180bf215546Sopenharmony_cistatic struct ir3_register * dummy_dst(void) 181bf215546Sopenharmony_ci{ 182bf215546Sopenharmony_ci return new_dst(0, 0); 183bf215546Sopenharmony_ci} 184bf215546Sopenharmony_ci 185bf215546Sopenharmony_cistatic void fixup_cat5_s2en(void) 186bf215546Sopenharmony_ci{ 187bf215546Sopenharmony_ci assert(opc_cat(instr->opc) == 5); 188bf215546Sopenharmony_ci if (!(instr->flags & IR3_INSTR_S2EN)) 189bf215546Sopenharmony_ci return; 190bf215546Sopenharmony_ci /* For various reasons (ie. mainly to make the .s2en src easier to 191bf215546Sopenharmony_ci * find, given that various different cat5 tex instructions can have 192bf215546Sopenharmony_ci * different # of src registers), in ir3 the samp/tex src register 193bf215546Sopenharmony_ci * is first, rather than last. So we have to detect this case and 194bf215546Sopenharmony_ci * fix things up. 195bf215546Sopenharmony_ci */ 196bf215546Sopenharmony_ci struct ir3_register *s2en_src = instr->srcs[instr->srcs_count - 1]; 197bf215546Sopenharmony_ci 198bf215546Sopenharmony_ci if (instr->flags & IR3_INSTR_B) 199bf215546Sopenharmony_ci assert(!(s2en_src->flags & IR3_REG_HALF)); 200bf215546Sopenharmony_ci else 201bf215546Sopenharmony_ci assert(s2en_src->flags & IR3_REG_HALF); 202bf215546Sopenharmony_ci 203bf215546Sopenharmony_ci for (int i = 0; i < instr->srcs_count - 1; i++) { 204bf215546Sopenharmony_ci instr->srcs[i+1] = instr->srcs[i]; 205bf215546Sopenharmony_ci } 206bf215546Sopenharmony_ci instr->srcs[0] = s2en_src; 207bf215546Sopenharmony_ci} 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_cistatic void add_const(unsigned reg, unsigned c0, unsigned c1, unsigned c2, unsigned c3) 210bf215546Sopenharmony_ci{ 211bf215546Sopenharmony_ci struct ir3_const_state *const_state = ir3_const_state(variant); 212bf215546Sopenharmony_ci assert((reg & 0x7) == 0); 213bf215546Sopenharmony_ci int idx = reg >> (1 + 2); /* low bit is half vs full, next two bits are swiz */ 214bf215546Sopenharmony_ci if (idx * 4 + 4 > const_state->immediates_size) { 215bf215546Sopenharmony_ci const_state->immediates = rerzalloc(const_state, 216bf215546Sopenharmony_ci const_state->immediates, 217bf215546Sopenharmony_ci __typeof__(const_state->immediates[0]), 218bf215546Sopenharmony_ci const_state->immediates_size, 219bf215546Sopenharmony_ci idx * 4 + 4); 220bf215546Sopenharmony_ci for (unsigned i = const_state->immediates_size; i < idx * 4; i++) 221bf215546Sopenharmony_ci const_state->immediates[i] = 0xd0d0d0d0; 222bf215546Sopenharmony_ci const_state->immediates_size = const_state->immediates_count = idx * 4 + 4; 223bf215546Sopenharmony_ci } 224bf215546Sopenharmony_ci const_state->immediates[idx * 4 + 0] = c0; 225bf215546Sopenharmony_ci const_state->immediates[idx * 4 + 1] = c1; 226bf215546Sopenharmony_ci const_state->immediates[idx * 4 + 2] = c2; 227bf215546Sopenharmony_ci const_state->immediates[idx * 4 + 3] = c3; 228bf215546Sopenharmony_ci} 229bf215546Sopenharmony_ci 230bf215546Sopenharmony_cistatic void add_sysval(unsigned reg, unsigned compmask, gl_system_value sysval) 231bf215546Sopenharmony_ci{ 232bf215546Sopenharmony_ci unsigned n = variant->inputs_count++; 233bf215546Sopenharmony_ci variant->inputs[n].regid = reg; 234bf215546Sopenharmony_ci variant->inputs[n].sysval = true; 235bf215546Sopenharmony_ci variant->inputs[n].slot = sysval; 236bf215546Sopenharmony_ci variant->inputs[n].compmask = compmask; 237bf215546Sopenharmony_ci variant->total_in++; 238bf215546Sopenharmony_ci} 239bf215546Sopenharmony_ci 240bf215546Sopenharmony_cistatic bool resolve_labels(void) 241bf215546Sopenharmony_ci{ 242bf215546Sopenharmony_ci int instr_ip = 0; 243bf215546Sopenharmony_ci foreach_instr (instr, &block->instr_list) { 244bf215546Sopenharmony_ci if (opc_cat(instr->opc) == 0 && instr->cat0.target_label) { 245bf215546Sopenharmony_ci struct hash_entry *entry = _mesa_hash_table_search(labels, instr->cat0.target_label); 246bf215546Sopenharmony_ci if (!entry) { 247bf215546Sopenharmony_ci fprintf(stderr, "unknown label %s\n", instr->cat0.target_label); 248bf215546Sopenharmony_ci return false; 249bf215546Sopenharmony_ci } 250bf215546Sopenharmony_ci int target_ip = (uintptr_t)entry->data; 251bf215546Sopenharmony_ci instr->cat0.immed = target_ip - instr_ip; 252bf215546Sopenharmony_ci } 253bf215546Sopenharmony_ci instr_ip++; 254bf215546Sopenharmony_ci } 255bf215546Sopenharmony_ci return true; 256bf215546Sopenharmony_ci} 257bf215546Sopenharmony_ci 258bf215546Sopenharmony_ci#ifdef YYDEBUG 259bf215546Sopenharmony_ciint yydebug; 260bf215546Sopenharmony_ci#endif 261bf215546Sopenharmony_ci 262bf215546Sopenharmony_ciextern int yylex(void); 263bf215546Sopenharmony_civoid ir3_yyset_lineno(int _line_number); 264bf215546Sopenharmony_civoid ir3_yyset_input(FILE *f); 265bf215546Sopenharmony_ci 266bf215546Sopenharmony_ciint yyparse(void); 267bf215546Sopenharmony_ci 268bf215546Sopenharmony_cistatic void yyerror(const char *error) 269bf215546Sopenharmony_ci{ 270bf215546Sopenharmony_ci fprintf(stderr, "error at line %d: %s\n", ir3_yyget_lineno(), error); 271bf215546Sopenharmony_ci} 272bf215546Sopenharmony_ci 273bf215546Sopenharmony_cistruct ir3 * ir3_parse(struct ir3_shader_variant *v, 274bf215546Sopenharmony_ci struct ir3_kernel_info *k, FILE *f) 275bf215546Sopenharmony_ci{ 276bf215546Sopenharmony_ci ir3_yyset_lineno(1); 277bf215546Sopenharmony_ci ir3_yyset_input(f); 278bf215546Sopenharmony_ci#ifdef YYDEBUG 279bf215546Sopenharmony_ci yydebug = 1; 280bf215546Sopenharmony_ci#endif 281bf215546Sopenharmony_ci info = k; 282bf215546Sopenharmony_ci variant = v; 283bf215546Sopenharmony_ci if (yyparse() || !resolve_labels()) { 284bf215546Sopenharmony_ci ir3_destroy(variant->ir); 285bf215546Sopenharmony_ci variant->ir = NULL; 286bf215546Sopenharmony_ci } 287bf215546Sopenharmony_ci ralloc_free(labels); 288bf215546Sopenharmony_ci ralloc_free(ir3_parser_dead_ctx); 289bf215546Sopenharmony_ci return variant->ir; 290bf215546Sopenharmony_ci} 291bf215546Sopenharmony_ci%} 292bf215546Sopenharmony_ci 293bf215546Sopenharmony_ci%union { 294bf215546Sopenharmony_ci int tok; 295bf215546Sopenharmony_ci int num; 296bf215546Sopenharmony_ci uint32_t unum; 297bf215546Sopenharmony_ci double flt; 298bf215546Sopenharmony_ci const char *str; 299bf215546Sopenharmony_ci struct ir3_register *reg; 300bf215546Sopenharmony_ci struct { 301bf215546Sopenharmony_ci int start; 302bf215546Sopenharmony_ci int num; 303bf215546Sopenharmony_ci } range; 304bf215546Sopenharmony_ci type_t type; 305bf215546Sopenharmony_ci} 306bf215546Sopenharmony_ci 307bf215546Sopenharmony_ci%{ 308bf215546Sopenharmony_ci#if YYDEBUG 309bf215546Sopenharmony_cistatic void print_token(FILE *file, int type, YYSTYPE value) 310bf215546Sopenharmony_ci{ 311bf215546Sopenharmony_ci fprintf(file, "\ntype: %d\n", type); 312bf215546Sopenharmony_ci} 313bf215546Sopenharmony_ci 314bf215546Sopenharmony_ci#define YYPRINT(file, type, value) print_token(file, type, value) 315bf215546Sopenharmony_ci#endif 316bf215546Sopenharmony_ci%} 317bf215546Sopenharmony_ci 318bf215546Sopenharmony_ci%token <num> T_INT 319bf215546Sopenharmony_ci%token <unum> T_HEX 320bf215546Sopenharmony_ci%token <flt> T_FLOAT 321bf215546Sopenharmony_ci%token <str> T_IDENTIFIER 322bf215546Sopenharmony_ci%token <num> T_REGISTER 323bf215546Sopenharmony_ci%token <num> T_CONSTANT 324bf215546Sopenharmony_ci 325bf215546Sopenharmony_ci/* @ headers (@const/@sampler/@uniform/@varying) */ 326bf215546Sopenharmony_ci%token <tok> T_A_LOCALSIZE 327bf215546Sopenharmony_ci%token <tok> T_A_CONST 328bf215546Sopenharmony_ci%token <tok> T_A_BUF 329bf215546Sopenharmony_ci%token <tok> T_A_INVOCATIONID 330bf215546Sopenharmony_ci%token <tok> T_A_WGID 331bf215546Sopenharmony_ci%token <tok> T_A_NUMWG 332bf215546Sopenharmony_ci%token <tok> T_A_BRANCHSTACK 333bf215546Sopenharmony_ci%token <tok> T_A_IN 334bf215546Sopenharmony_ci%token <tok> T_A_OUT 335bf215546Sopenharmony_ci%token <tok> T_A_TEX 336bf215546Sopenharmony_ci%token <tok> T_A_PVTMEM 337bf215546Sopenharmony_ci%token <tok> T_A_EARLYPREAMBLE 338bf215546Sopenharmony_ci/* todo, re-add @sampler/@uniform/@varying if needed someday */ 339bf215546Sopenharmony_ci 340bf215546Sopenharmony_ci/* src register flags */ 341bf215546Sopenharmony_ci%token <tok> T_ABSNEG 342bf215546Sopenharmony_ci%token <tok> T_NEG 343bf215546Sopenharmony_ci%token <tok> T_ABS 344bf215546Sopenharmony_ci%token <tok> T_R 345bf215546Sopenharmony_ci 346bf215546Sopenharmony_ci%token <tok> T_HR 347bf215546Sopenharmony_ci%token <tok> T_HC 348bf215546Sopenharmony_ci 349bf215546Sopenharmony_ci/* dst register flags */ 350bf215546Sopenharmony_ci%token <tok> T_EVEN 351bf215546Sopenharmony_ci%token <tok> T_POS_INFINITY 352bf215546Sopenharmony_ci%token <tok> T_NEG_INFINITY 353bf215546Sopenharmony_ci%token <tok> T_EI 354bf215546Sopenharmony_ci%token <num> T_WRMASK 355bf215546Sopenharmony_ci 356bf215546Sopenharmony_ci/* Float LUT values accepted as immed: */ 357bf215546Sopenharmony_ci%token <num> T_FLUT_0_0 358bf215546Sopenharmony_ci%token <num> T_FLUT_0_5 359bf215546Sopenharmony_ci%token <num> T_FLUT_1_0 360bf215546Sopenharmony_ci%token <num> T_FLUT_2_0 361bf215546Sopenharmony_ci%token <num> T_FLUT_E 362bf215546Sopenharmony_ci%token <num> T_FLUT_PI 363bf215546Sopenharmony_ci%token <num> T_FLUT_INV_PI 364bf215546Sopenharmony_ci%token <num> T_FLUT_INV_LOG2_E 365bf215546Sopenharmony_ci%token <num> T_FLUT_LOG2_E 366bf215546Sopenharmony_ci%token <num> T_FLUT_INV_LOG2_10 367bf215546Sopenharmony_ci%token <num> T_FLUT_LOG2_10 368bf215546Sopenharmony_ci%token <num> T_FLUT_4_0 369bf215546Sopenharmony_ci 370bf215546Sopenharmony_ci/* instruction flags */ 371bf215546Sopenharmony_ci%token <tok> T_SY 372bf215546Sopenharmony_ci%token <tok> T_SS 373bf215546Sopenharmony_ci%token <tok> T_JP 374bf215546Sopenharmony_ci%token <tok> T_SAT 375bf215546Sopenharmony_ci%token <num> T_RPT 376bf215546Sopenharmony_ci%token <tok> T_UL 377bf215546Sopenharmony_ci%token <tok> T_NOP 378bf215546Sopenharmony_ci 379bf215546Sopenharmony_ci/* category 0: */ 380bf215546Sopenharmony_ci%token <tok> T_OP_NOP 381bf215546Sopenharmony_ci%token <tok> T_OP_BR 382bf215546Sopenharmony_ci%token <tok> T_OP_BRAO 383bf215546Sopenharmony_ci%token <tok> T_OP_BRAA 384bf215546Sopenharmony_ci%token <tok> T_OP_BRAC 385bf215546Sopenharmony_ci%token <tok> T_OP_BANY 386bf215546Sopenharmony_ci%token <tok> T_OP_BALL 387bf215546Sopenharmony_ci%token <tok> T_OP_BRAX 388bf215546Sopenharmony_ci%token <tok> T_OP_JUMP 389bf215546Sopenharmony_ci%token <tok> T_OP_CALL 390bf215546Sopenharmony_ci%token <tok> T_OP_RET 391bf215546Sopenharmony_ci%token <tok> T_OP_KILL 392bf215546Sopenharmony_ci%token <tok> T_OP_END 393bf215546Sopenharmony_ci%token <tok> T_OP_EMIT 394bf215546Sopenharmony_ci%token <tok> T_OP_CUT 395bf215546Sopenharmony_ci%token <tok> T_OP_CHMASK 396bf215546Sopenharmony_ci%token <tok> T_OP_CHSH 397bf215546Sopenharmony_ci%token <tok> T_OP_FLOW_REV 398bf215546Sopenharmony_ci%token <tok> T_OP_BKT 399bf215546Sopenharmony_ci%token <tok> T_OP_STKS 400bf215546Sopenharmony_ci%token <tok> T_OP_STKR 401bf215546Sopenharmony_ci%token <tok> T_OP_XSET 402bf215546Sopenharmony_ci%token <tok> T_OP_XCLR 403bf215546Sopenharmony_ci%token <tok> T_OP_GETLAST 404bf215546Sopenharmony_ci%token <tok> T_OP_GETONE 405bf215546Sopenharmony_ci%token <tok> T_OP_DBG 406bf215546Sopenharmony_ci%token <tok> T_OP_SHPS 407bf215546Sopenharmony_ci%token <tok> T_OP_SHPE 408bf215546Sopenharmony_ci%token <tok> T_OP_PREDT 409bf215546Sopenharmony_ci%token <tok> T_OP_PREDF 410bf215546Sopenharmony_ci%token <tok> T_OP_PREDE 411bf215546Sopenharmony_ci 412bf215546Sopenharmony_ci/* category 1: */ 413bf215546Sopenharmony_ci%token <tok> T_OP_MOVMSK 414bf215546Sopenharmony_ci%token <tok> T_OP_MOVA1 415bf215546Sopenharmony_ci%token <tok> T_OP_MOVA 416bf215546Sopenharmony_ci%token <tok> T_OP_MOV 417bf215546Sopenharmony_ci%token <tok> T_OP_COV 418bf215546Sopenharmony_ci%token <tok> T_OP_SWZ 419bf215546Sopenharmony_ci%token <tok> T_OP_GAT 420bf215546Sopenharmony_ci%token <tok> T_OP_SCT 421bf215546Sopenharmony_ci 422bf215546Sopenharmony_ci/* category 2: */ 423bf215546Sopenharmony_ci%token <tok> T_OP_ADD_F 424bf215546Sopenharmony_ci%token <tok> T_OP_MIN_F 425bf215546Sopenharmony_ci%token <tok> T_OP_MAX_F 426bf215546Sopenharmony_ci%token <tok> T_OP_MUL_F 427bf215546Sopenharmony_ci%token <tok> T_OP_SIGN_F 428bf215546Sopenharmony_ci%token <tok> T_OP_CMPS_F 429bf215546Sopenharmony_ci%token <tok> T_OP_ABSNEG_F 430bf215546Sopenharmony_ci%token <tok> T_OP_CMPV_F 431bf215546Sopenharmony_ci%token <tok> T_OP_FLOOR_F 432bf215546Sopenharmony_ci%token <tok> T_OP_CEIL_F 433bf215546Sopenharmony_ci%token <tok> T_OP_RNDNE_F 434bf215546Sopenharmony_ci%token <tok> T_OP_RNDAZ_F 435bf215546Sopenharmony_ci%token <tok> T_OP_TRUNC_F 436bf215546Sopenharmony_ci%token <tok> T_OP_ADD_U 437bf215546Sopenharmony_ci%token <tok> T_OP_ADD_S 438bf215546Sopenharmony_ci%token <tok> T_OP_SUB_U 439bf215546Sopenharmony_ci%token <tok> T_OP_SUB_S 440bf215546Sopenharmony_ci%token <tok> T_OP_CMPS_U 441bf215546Sopenharmony_ci%token <tok> T_OP_CMPS_S 442bf215546Sopenharmony_ci%token <tok> T_OP_MIN_U 443bf215546Sopenharmony_ci%token <tok> T_OP_MIN_S 444bf215546Sopenharmony_ci%token <tok> T_OP_MAX_U 445bf215546Sopenharmony_ci%token <tok> T_OP_MAX_S 446bf215546Sopenharmony_ci%token <tok> T_OP_ABSNEG_S 447bf215546Sopenharmony_ci%token <tok> T_OP_AND_B 448bf215546Sopenharmony_ci%token <tok> T_OP_OR_B 449bf215546Sopenharmony_ci%token <tok> T_OP_NOT_B 450bf215546Sopenharmony_ci%token <tok> T_OP_XOR_B 451bf215546Sopenharmony_ci%token <tok> T_OP_CMPV_U 452bf215546Sopenharmony_ci%token <tok> T_OP_CMPV_S 453bf215546Sopenharmony_ci%token <tok> T_OP_MUL_U24 454bf215546Sopenharmony_ci%token <tok> T_OP_MUL_S24 455bf215546Sopenharmony_ci%token <tok> T_OP_MULL_U 456bf215546Sopenharmony_ci%token <tok> T_OP_BFREV_B 457bf215546Sopenharmony_ci%token <tok> T_OP_CLZ_S 458bf215546Sopenharmony_ci%token <tok> T_OP_CLZ_B 459bf215546Sopenharmony_ci%token <tok> T_OP_SHL_B 460bf215546Sopenharmony_ci%token <tok> T_OP_SHR_B 461bf215546Sopenharmony_ci%token <tok> T_OP_ASHR_B 462bf215546Sopenharmony_ci%token <tok> T_OP_BARY_F 463bf215546Sopenharmony_ci%token <tok> T_OP_FLAT_B 464bf215546Sopenharmony_ci%token <tok> T_OP_MGEN_B 465bf215546Sopenharmony_ci%token <tok> T_OP_GETBIT_B 466bf215546Sopenharmony_ci%token <tok> T_OP_SETRM 467bf215546Sopenharmony_ci%token <tok> T_OP_CBITS_B 468bf215546Sopenharmony_ci%token <tok> T_OP_SHB 469bf215546Sopenharmony_ci%token <tok> T_OP_MSAD 470bf215546Sopenharmony_ci 471bf215546Sopenharmony_ci/* category 3: */ 472bf215546Sopenharmony_ci%token <tok> T_OP_MAD_U16 473bf215546Sopenharmony_ci%token <tok> T_OP_MADSH_U16 474bf215546Sopenharmony_ci%token <tok> T_OP_MAD_S16 475bf215546Sopenharmony_ci%token <tok> T_OP_MADSH_M16 476bf215546Sopenharmony_ci%token <tok> T_OP_MAD_U24 477bf215546Sopenharmony_ci%token <tok> T_OP_MAD_S24 478bf215546Sopenharmony_ci%token <tok> T_OP_MAD_F16 479bf215546Sopenharmony_ci%token <tok> T_OP_MAD_F32 480bf215546Sopenharmony_ci%token <tok> T_OP_SEL_B16 481bf215546Sopenharmony_ci%token <tok> T_OP_SEL_B32 482bf215546Sopenharmony_ci%token <tok> T_OP_SEL_S16 483bf215546Sopenharmony_ci%token <tok> T_OP_SEL_S32 484bf215546Sopenharmony_ci%token <tok> T_OP_SEL_F16 485bf215546Sopenharmony_ci%token <tok> T_OP_SEL_F32 486bf215546Sopenharmony_ci%token <tok> T_OP_SAD_S16 487bf215546Sopenharmony_ci%token <tok> T_OP_SAD_S32 488bf215546Sopenharmony_ci%token <tok> T_OP_SHRM 489bf215546Sopenharmony_ci%token <tok> T_OP_SHLM 490bf215546Sopenharmony_ci%token <tok> T_OP_SHRG 491bf215546Sopenharmony_ci%token <tok> T_OP_SHLG 492bf215546Sopenharmony_ci%token <tok> T_OP_ANDG 493bf215546Sopenharmony_ci%token <tok> T_OP_DP2ACC 494bf215546Sopenharmony_ci%token <tok> T_OP_DP4ACC 495bf215546Sopenharmony_ci%token <tok> T_OP_WMM 496bf215546Sopenharmony_ci%token <tok> T_OP_WMM_ACCU 497bf215546Sopenharmony_ci 498bf215546Sopenharmony_ci/* category 4: */ 499bf215546Sopenharmony_ci%token <tok> T_OP_RCP 500bf215546Sopenharmony_ci%token <tok> T_OP_RSQ 501bf215546Sopenharmony_ci%token <tok> T_OP_LOG2 502bf215546Sopenharmony_ci%token <tok> T_OP_EXP2 503bf215546Sopenharmony_ci%token <tok> T_OP_SIN 504bf215546Sopenharmony_ci%token <tok> T_OP_COS 505bf215546Sopenharmony_ci%token <tok> T_OP_SQRT 506bf215546Sopenharmony_ci%token <tok> T_OP_HRSQ 507bf215546Sopenharmony_ci%token <tok> T_OP_HLOG2 508bf215546Sopenharmony_ci%token <tok> T_OP_HEXP2 509bf215546Sopenharmony_ci 510bf215546Sopenharmony_ci/* category 5: */ 511bf215546Sopenharmony_ci%token <tok> T_OP_ISAM 512bf215546Sopenharmony_ci%token <tok> T_OP_ISAML 513bf215546Sopenharmony_ci%token <tok> T_OP_ISAMM 514bf215546Sopenharmony_ci%token <tok> T_OP_SAM 515bf215546Sopenharmony_ci%token <tok> T_OP_SAMB 516bf215546Sopenharmony_ci%token <tok> T_OP_SAML 517bf215546Sopenharmony_ci%token <tok> T_OP_SAMGQ 518bf215546Sopenharmony_ci%token <tok> T_OP_GETLOD 519bf215546Sopenharmony_ci%token <tok> T_OP_CONV 520bf215546Sopenharmony_ci%token <tok> T_OP_CONVM 521bf215546Sopenharmony_ci%token <tok> T_OP_GETSIZE 522bf215546Sopenharmony_ci%token <tok> T_OP_GETBUF 523bf215546Sopenharmony_ci%token <tok> T_OP_GETPOS 524bf215546Sopenharmony_ci%token <tok> T_OP_GETINFO 525bf215546Sopenharmony_ci%token <tok> T_OP_DSX 526bf215546Sopenharmony_ci%token <tok> T_OP_DSY 527bf215546Sopenharmony_ci%token <tok> T_OP_GATHER4R 528bf215546Sopenharmony_ci%token <tok> T_OP_GATHER4G 529bf215546Sopenharmony_ci%token <tok> T_OP_GATHER4B 530bf215546Sopenharmony_ci%token <tok> T_OP_GATHER4A 531bf215546Sopenharmony_ci%token <tok> T_OP_SAMGP0 532bf215546Sopenharmony_ci%token <tok> T_OP_SAMGP1 533bf215546Sopenharmony_ci%token <tok> T_OP_SAMGP2 534bf215546Sopenharmony_ci%token <tok> T_OP_SAMGP3 535bf215546Sopenharmony_ci%token <tok> T_OP_DSXPP_1 536bf215546Sopenharmony_ci%token <tok> T_OP_DSYPP_1 537bf215546Sopenharmony_ci%token <tok> T_OP_RGETPOS 538bf215546Sopenharmony_ci%token <tok> T_OP_RGETINFO 539bf215546Sopenharmony_ci%token <tok> T_OP_BRCST_A 540bf215546Sopenharmony_ci%token <tok> T_OP_QSHUFFLE_BRCST 541bf215546Sopenharmony_ci%token <tok> T_OP_QSHUFFLE_H 542bf215546Sopenharmony_ci%token <tok> T_OP_QSHUFFLE_V 543bf215546Sopenharmony_ci%token <tok> T_OP_QSHUFFLE_DIAG 544bf215546Sopenharmony_ci 545bf215546Sopenharmony_ci/* category 6: */ 546bf215546Sopenharmony_ci%token <tok> T_OP_LDG 547bf215546Sopenharmony_ci%token <tok> T_OP_LDG_A 548bf215546Sopenharmony_ci%token <tok> T_OP_LDL 549bf215546Sopenharmony_ci%token <tok> T_OP_LDP 550bf215546Sopenharmony_ci%token <tok> T_OP_STG 551bf215546Sopenharmony_ci%token <tok> T_OP_STG_A 552bf215546Sopenharmony_ci%token <tok> T_OP_STL 553bf215546Sopenharmony_ci%token <tok> T_OP_STP 554bf215546Sopenharmony_ci%token <tok> T_OP_LDIB 555bf215546Sopenharmony_ci%token <tok> T_OP_G2L 556bf215546Sopenharmony_ci%token <tok> T_OP_L2G 557bf215546Sopenharmony_ci%token <tok> T_OP_PREFETCH 558bf215546Sopenharmony_ci%token <tok> T_OP_LDLW 559bf215546Sopenharmony_ci%token <tok> T_OP_STLW 560bf215546Sopenharmony_ci%token <tok> T_OP_RESFMT 561bf215546Sopenharmony_ci%token <tok> T_OP_RESINFO 562bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_ADD 563bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_SUB 564bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_XCHG 565bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_INC 566bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_DEC 567bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_CMPXCHG 568bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_MIN 569bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_MAX 570bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_AND 571bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_OR 572bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_XOR 573bf215546Sopenharmony_ci%token <tok> T_OP_RESINFO_B 574bf215546Sopenharmony_ci%token <tok> T_OP_LDIB_B 575bf215546Sopenharmony_ci%token <tok> T_OP_STIB_B 576bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_ADD 577bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_SUB 578bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_XCHG 579bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_INC 580bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_DEC 581bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_CMPXCHG 582bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_MIN 583bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_MAX 584bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_AND 585bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_OR 586bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_B_XOR 587bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_ADD 588bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_SUB 589bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_XCHG 590bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_INC 591bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_DEC 592bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_CMPXCHG 593bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_MIN 594bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_MAX 595bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_AND 596bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_OR 597bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_S_XOR 598bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_ADD 599bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_SUB 600bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_XCHG 601bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_INC 602bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_DEC 603bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_CMPXCHG 604bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_MIN 605bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_MAX 606bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_AND 607bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_OR 608bf215546Sopenharmony_ci%token <tok> T_OP_ATOMIC_G_XOR 609bf215546Sopenharmony_ci%token <tok> T_OP_LDGB 610bf215546Sopenharmony_ci%token <tok> T_OP_STGB 611bf215546Sopenharmony_ci%token <tok> T_OP_STIB 612bf215546Sopenharmony_ci%token <tok> T_OP_LDC 613bf215546Sopenharmony_ci%token <tok> T_OP_LDLV 614bf215546Sopenharmony_ci%token <tok> T_OP_GETSPID 615bf215546Sopenharmony_ci%token <tok> T_OP_GETWID 616bf215546Sopenharmony_ci%token <tok> T_OP_GETFIBERID 617bf215546Sopenharmony_ci%token <tok> T_OP_STC 618bf215546Sopenharmony_ci 619bf215546Sopenharmony_ci/* category 7: */ 620bf215546Sopenharmony_ci%token <tok> T_OP_BAR 621bf215546Sopenharmony_ci%token <tok> T_OP_FENCE 622bf215546Sopenharmony_ci 623bf215546Sopenharmony_ci/* type qualifiers: */ 624bf215546Sopenharmony_ci%token <tok> T_TYPE_F16 625bf215546Sopenharmony_ci%token <tok> T_TYPE_F32 626bf215546Sopenharmony_ci%token <tok> T_TYPE_U16 627bf215546Sopenharmony_ci%token <tok> T_TYPE_U32 628bf215546Sopenharmony_ci%token <tok> T_TYPE_S16 629bf215546Sopenharmony_ci%token <tok> T_TYPE_S32 630bf215546Sopenharmony_ci%token <tok> T_TYPE_U8 631bf215546Sopenharmony_ci%token <tok> T_TYPE_S8 632bf215546Sopenharmony_ci 633bf215546Sopenharmony_ci%token <tok> T_UNTYPED 634bf215546Sopenharmony_ci%token <tok> T_TYPED 635bf215546Sopenharmony_ci 636bf215546Sopenharmony_ci%token <tok> T_MIXED 637bf215546Sopenharmony_ci%token <tok> T_UNSIGNED 638bf215546Sopenharmony_ci%token <tok> T_LOW 639bf215546Sopenharmony_ci%token <tok> T_HIGH 640bf215546Sopenharmony_ci 641bf215546Sopenharmony_ci%token <tok> T_1D 642bf215546Sopenharmony_ci%token <tok> T_2D 643bf215546Sopenharmony_ci%token <tok> T_3D 644bf215546Sopenharmony_ci%token <tok> T_4D 645bf215546Sopenharmony_ci 646bf215546Sopenharmony_ci/* condition qualifiers: */ 647bf215546Sopenharmony_ci%token <tok> T_LT 648bf215546Sopenharmony_ci%token <tok> T_LE 649bf215546Sopenharmony_ci%token <tok> T_GT 650bf215546Sopenharmony_ci%token <tok> T_GE 651bf215546Sopenharmony_ci%token <tok> T_EQ 652bf215546Sopenharmony_ci%token <tok> T_NE 653bf215546Sopenharmony_ci 654bf215546Sopenharmony_ci%token <tok> T_S2EN 655bf215546Sopenharmony_ci%token <tok> T_SAMP 656bf215546Sopenharmony_ci%token <tok> T_TEX 657bf215546Sopenharmony_ci%token <tok> T_BASE 658bf215546Sopenharmony_ci%token <tok> T_OFFSET 659bf215546Sopenharmony_ci%token <tok> T_UNIFORM 660bf215546Sopenharmony_ci%token <tok> T_NONUNIFORM 661bf215546Sopenharmony_ci%token <tok> T_IMM 662bf215546Sopenharmony_ci 663bf215546Sopenharmony_ci%token <tok> T_NAN 664bf215546Sopenharmony_ci%token <tok> T_INF 665bf215546Sopenharmony_ci%token <num> T_A0 666bf215546Sopenharmony_ci%token <num> T_A1 667bf215546Sopenharmony_ci%token <num> T_P0 668bf215546Sopenharmony_ci%token <num> T_W 669bf215546Sopenharmony_ci%token <str> T_CAT1_TYPE_TYPE 670bf215546Sopenharmony_ci 671bf215546Sopenharmony_ci%type <num> integer offset 672bf215546Sopenharmony_ci%type <num> flut_immed 673bf215546Sopenharmony_ci%type <flt> float 674bf215546Sopenharmony_ci%type <reg> src dst const 675bf215546Sopenharmony_ci%type <tok> cat1_opc 676bf215546Sopenharmony_ci%type <tok> cat2_opc_1src cat2_opc_2src_cnd cat2_opc_2src 677bf215546Sopenharmony_ci%type <tok> cat3_opc 678bf215546Sopenharmony_ci%type <tok> cat4_opc 679bf215546Sopenharmony_ci%type <tok> cat5_opc cat5_samp cat5_tex cat5_type 680bf215546Sopenharmony_ci%type <type> type 681bf215546Sopenharmony_ci%type <unum> const_val 682bf215546Sopenharmony_ci 683bf215546Sopenharmony_ci%error-verbose 684bf215546Sopenharmony_ci 685bf215546Sopenharmony_ci%start shader 686bf215546Sopenharmony_ci 687bf215546Sopenharmony_ci%% 688bf215546Sopenharmony_ci 689bf215546Sopenharmony_cishader: { new_shader(); } headers instrs 690bf215546Sopenharmony_ci 691bf215546Sopenharmony_ciheaders: 692bf215546Sopenharmony_ci| header headers 693bf215546Sopenharmony_ci 694bf215546Sopenharmony_ciheader: localsize_header 695bf215546Sopenharmony_ci| const_header 696bf215546Sopenharmony_ci| buf_header 697bf215546Sopenharmony_ci| invocationid_header 698bf215546Sopenharmony_ci| wgid_header 699bf215546Sopenharmony_ci| numwg_header 700bf215546Sopenharmony_ci| branchstack_header 701bf215546Sopenharmony_ci| in_header 702bf215546Sopenharmony_ci| out_header 703bf215546Sopenharmony_ci| tex_header 704bf215546Sopenharmony_ci| pvtmem_header 705bf215546Sopenharmony_ci| earlypreamble_header 706bf215546Sopenharmony_ci 707bf215546Sopenharmony_ciconst_val: T_FLOAT { $$ = fui($1); } 708bf215546Sopenharmony_ci| T_INT { $$ = $1; } 709bf215546Sopenharmony_ci| '-' T_INT { $$ = -$2; } 710bf215546Sopenharmony_ci| T_HEX { $$ = $1; } 711bf215546Sopenharmony_ci 712bf215546Sopenharmony_cilocalsize_header: T_A_LOCALSIZE const_val ',' const_val ',' const_val { 713bf215546Sopenharmony_ci variant->local_size[0] = $2; 714bf215546Sopenharmony_ci variant->local_size[1] = $4; 715bf215546Sopenharmony_ci variant->local_size[2] = $6; 716bf215546Sopenharmony_ci} 717bf215546Sopenharmony_ci 718bf215546Sopenharmony_ciconst_header: T_A_CONST '(' T_CONSTANT ')' const_val ',' const_val ',' const_val ',' const_val { 719bf215546Sopenharmony_ci add_const($3, $5, $7, $9, $11); 720bf215546Sopenharmony_ci} 721bf215546Sopenharmony_ci 722bf215546Sopenharmony_cibuf_header_addr_reg: 723bf215546Sopenharmony_ci '(' T_CONSTANT ')' { 724bf215546Sopenharmony_ci assert(($2 & 0x1) == 0); /* half-reg not allowed */ 725bf215546Sopenharmony_ci unsigned reg = $2 >> 1; 726bf215546Sopenharmony_ci 727bf215546Sopenharmony_ci info->buf_addr_regs[info->num_bufs - 1] = reg; 728bf215546Sopenharmony_ci /* reserve space in immediates for the actual value to be plugged in later: */ 729bf215546Sopenharmony_ci add_const($2, 0, 0, 0, 0); 730bf215546Sopenharmony_ci} 731bf215546Sopenharmony_ci| 732bf215546Sopenharmony_ci 733bf215546Sopenharmony_cibuf_header: T_A_BUF const_val { 734bf215546Sopenharmony_ci int idx = info->num_bufs++; 735bf215546Sopenharmony_ci assert(idx < MAX_BUFS); 736bf215546Sopenharmony_ci info->buf_sizes[idx] = $2; 737bf215546Sopenharmony_ci} buf_header_addr_reg 738bf215546Sopenharmony_ci 739bf215546Sopenharmony_ciinvocationid_header: T_A_INVOCATIONID '(' T_REGISTER ')' { 740bf215546Sopenharmony_ci assert(($3 & 0x1) == 0); /* half-reg not allowed */ 741bf215546Sopenharmony_ci unsigned reg = $3 >> 1; 742bf215546Sopenharmony_ci add_sysval(reg, 0x7, SYSTEM_VALUE_LOCAL_INVOCATION_ID); 743bf215546Sopenharmony_ci} 744bf215546Sopenharmony_ci 745bf215546Sopenharmony_ciwgid_header: T_A_WGID '(' T_REGISTER ')' { 746bf215546Sopenharmony_ci assert(($3 & 0x1) == 0); /* half-reg not allowed */ 747bf215546Sopenharmony_ci unsigned reg = $3 >> 1; 748bf215546Sopenharmony_ci assert(variant->compiler->gen >= 5); 749bf215546Sopenharmony_ci assert(reg >= regid(48, 0)); /* must be a high reg */ 750bf215546Sopenharmony_ci add_sysval(reg, 0x7, SYSTEM_VALUE_WORKGROUP_ID); 751bf215546Sopenharmony_ci} 752bf215546Sopenharmony_ci| T_A_WGID '(' T_CONSTANT ')' { 753bf215546Sopenharmony_ci assert(($3 & 0x1) == 0); /* half-reg not allowed */ 754bf215546Sopenharmony_ci unsigned reg = $3 >> 1; 755bf215546Sopenharmony_ci assert(variant->compiler->gen < 5); 756bf215546Sopenharmony_ci info->wgid = reg; 757bf215546Sopenharmony_ci} 758bf215546Sopenharmony_ci 759bf215546Sopenharmony_cinumwg_header: T_A_NUMWG '(' T_CONSTANT ')' { 760bf215546Sopenharmony_ci assert(($3 & 0x1) == 0); /* half-reg not allowed */ 761bf215546Sopenharmony_ci unsigned reg = $3 >> 1; 762bf215546Sopenharmony_ci info->numwg = reg; 763bf215546Sopenharmony_ci /* reserve space in immediates for the actual value to be plugged in later: */ 764bf215546Sopenharmony_ci if (variant->compiler->gen >= 5) 765bf215546Sopenharmony_ci add_const($3, 0, 0, 0, 0); 766bf215546Sopenharmony_ci} 767bf215546Sopenharmony_ci 768bf215546Sopenharmony_cibranchstack_header: T_A_BRANCHSTACK const_val { variant->branchstack = $2; } 769bf215546Sopenharmony_ci 770bf215546Sopenharmony_cipvtmem_header: T_A_PVTMEM const_val { variant->pvtmem_size = $2; } 771bf215546Sopenharmony_ci 772bf215546Sopenharmony_ciearlypreamble_header: T_A_EARLYPREAMBLE { info->early_preamble = 1; } 773bf215546Sopenharmony_ci 774bf215546Sopenharmony_ci/* Stubs for now */ 775bf215546Sopenharmony_ciin_header: T_A_IN '(' T_REGISTER ')' T_IDENTIFIER '(' T_IDENTIFIER '=' integer ')' { } 776bf215546Sopenharmony_ci 777bf215546Sopenharmony_ciout_header: T_A_OUT '(' T_REGISTER ')' T_IDENTIFIER '(' T_IDENTIFIER '=' integer ')' { } 778bf215546Sopenharmony_ci 779bf215546Sopenharmony_citex_header: T_A_TEX '(' T_REGISTER ')' 780bf215546Sopenharmony_ci T_IDENTIFIER '=' integer ',' /* src */ 781bf215546Sopenharmony_ci T_IDENTIFIER '=' integer ',' /* samp */ 782bf215546Sopenharmony_ci T_IDENTIFIER '=' integer ',' /* tex */ 783bf215546Sopenharmony_ci T_IDENTIFIER '=' integer ',' /* wrmask */ 784bf215546Sopenharmony_ci T_IDENTIFIER '=' integer /* cmd */ { } 785bf215546Sopenharmony_ci 786bf215546Sopenharmony_ciiflag: T_SY { iflags.flags |= IR3_INSTR_SY; } 787bf215546Sopenharmony_ci| T_SS { iflags.flags |= IR3_INSTR_SS; } 788bf215546Sopenharmony_ci| T_JP { iflags.flags |= IR3_INSTR_JP; } 789bf215546Sopenharmony_ci| T_SAT { iflags.flags |= IR3_INSTR_SAT; } 790bf215546Sopenharmony_ci| T_RPT { iflags.repeat = $1; } 791bf215546Sopenharmony_ci| T_UL { iflags.flags |= IR3_INSTR_UL; } 792bf215546Sopenharmony_ci| T_NOP { iflags.nop = $1; } 793bf215546Sopenharmony_ci 794bf215546Sopenharmony_ciiflags: 795bf215546Sopenharmony_ci| iflag iflags 796bf215546Sopenharmony_ci 797bf215546Sopenharmony_ciinstrs: instrs instr 798bf215546Sopenharmony_ci| instr 799bf215546Sopenharmony_ci 800bf215546Sopenharmony_ciinstr: iflags cat0_instr 801bf215546Sopenharmony_ci| iflags cat1_instr 802bf215546Sopenharmony_ci| iflags cat2_instr 803bf215546Sopenharmony_ci| iflags cat3_instr 804bf215546Sopenharmony_ci| iflags cat4_instr 805bf215546Sopenharmony_ci| iflags cat5_instr { fixup_cat5_s2en(); } 806bf215546Sopenharmony_ci| iflags cat6_instr 807bf215546Sopenharmony_ci| iflags cat7_instr 808bf215546Sopenharmony_ci| label 809bf215546Sopenharmony_ci 810bf215546Sopenharmony_cilabel: T_IDENTIFIER ':' { new_label($1); } 811bf215546Sopenharmony_ci 812bf215546Sopenharmony_cicat0_src1: '!' T_P0 { instr->cat0.inv1 = true; instr->cat0.comp1 = $2 >> 1; } 813bf215546Sopenharmony_ci| T_P0 { instr->cat0.comp1 = $1 >> 1; } 814bf215546Sopenharmony_ci 815bf215546Sopenharmony_cicat0_src2: '!' T_P0 { instr->cat0.inv2 = true; instr->cat0.comp2 = $2 >> 1; } 816bf215546Sopenharmony_ci| T_P0 { instr->cat0.comp2 = $1 >> 1; } 817bf215546Sopenharmony_ci 818bf215546Sopenharmony_cicat0_immed: '#' integer { instr->cat0.immed = $2; } 819bf215546Sopenharmony_ci| '#' T_IDENTIFIER { ralloc_steal(instr, (void *)$2); instr->cat0.target_label = $2; } 820bf215546Sopenharmony_ci 821bf215546Sopenharmony_cicat0_instr: T_OP_NOP { new_instr(OPC_NOP); } 822bf215546Sopenharmony_ci| T_OP_BR { new_instr(OPC_B)->cat0.brtype = BRANCH_PLAIN; } cat0_src1 ',' cat0_immed 823bf215546Sopenharmony_ci| T_OP_BRAO { new_instr(OPC_B)->cat0.brtype = BRANCH_OR; } cat0_src1 ',' cat0_src2 ',' cat0_immed 824bf215546Sopenharmony_ci| T_OP_BRAA { new_instr(OPC_B)->cat0.brtype = BRANCH_AND; } cat0_src1 ',' cat0_src2 ',' cat0_immed 825bf215546Sopenharmony_ci| T_OP_BRAC '.' integer { new_instr(OPC_B)->cat0.brtype = BRANCH_CONST; instr->cat0.idx = $3; } cat0_immed 826bf215546Sopenharmony_ci| T_OP_BANY { new_instr(OPC_B)->cat0.brtype = BRANCH_ANY; } cat0_src1 ',' cat0_immed 827bf215546Sopenharmony_ci| T_OP_BALL { new_instr(OPC_B)->cat0.brtype = BRANCH_ALL; } cat0_src1 ',' cat0_immed 828bf215546Sopenharmony_ci| T_OP_BRAX { new_instr(OPC_B)->cat0.brtype = BRANCH_X; } cat0_immed 829bf215546Sopenharmony_ci| T_OP_JUMP { new_instr(OPC_JUMP); } cat0_immed 830bf215546Sopenharmony_ci| T_OP_CALL { new_instr(OPC_CALL); } cat0_immed 831bf215546Sopenharmony_ci| T_OP_RET { new_instr(OPC_RET); } 832bf215546Sopenharmony_ci| T_OP_KILL { new_instr(OPC_KILL); } cat0_src1 833bf215546Sopenharmony_ci| T_OP_END { new_instr(OPC_END); } 834bf215546Sopenharmony_ci| T_OP_EMIT { new_instr(OPC_EMIT); } 835bf215546Sopenharmony_ci| T_OP_CUT { new_instr(OPC_CUT); } 836bf215546Sopenharmony_ci| T_OP_CHMASK { new_instr(OPC_CHMASK); } 837bf215546Sopenharmony_ci| T_OP_CHSH { new_instr(OPC_CHSH); } 838bf215546Sopenharmony_ci| T_OP_FLOW_REV { new_instr(OPC_FLOW_REV); } 839bf215546Sopenharmony_ci| T_OP_BKT { new_instr(OPC_BKT); } cat0_immed 840bf215546Sopenharmony_ci| T_OP_STKS { new_instr(OPC_STKS); } 841bf215546Sopenharmony_ci| T_OP_STKR { new_instr(OPC_STKR); } 842bf215546Sopenharmony_ci| T_OP_XSET { new_instr(OPC_XSET); } 843bf215546Sopenharmony_ci| T_OP_XCLR { new_instr(OPC_XCLR); } 844bf215546Sopenharmony_ci| T_OP_GETONE { new_instr(OPC_GETONE); } cat0_immed 845bf215546Sopenharmony_ci| T_OP_DBG { new_instr(OPC_DBG); } 846bf215546Sopenharmony_ci| T_OP_SHPS { new_instr(OPC_SHPS); } cat0_immed 847bf215546Sopenharmony_ci| T_OP_SHPE { new_instr(OPC_SHPE); } 848bf215546Sopenharmony_ci| T_OP_PREDT { new_instr(OPC_PREDT); } cat0_src1 849bf215546Sopenharmony_ci| T_OP_PREDF { new_instr(OPC_PREDF); } cat0_src1 850bf215546Sopenharmony_ci| T_OP_PREDE { new_instr(OPC_PREDE); } 851bf215546Sopenharmony_ci| T_OP_GETLAST '.' T_W { new_instr(OPC_GETLAST); } cat0_immed 852bf215546Sopenharmony_ci 853bf215546Sopenharmony_cicat1_opc: T_OP_MOV '.' T_CAT1_TYPE_TYPE { 854bf215546Sopenharmony_ci parse_type_type(new_instr(OPC_MOV), $3); 855bf215546Sopenharmony_ci} 856bf215546Sopenharmony_ci| T_OP_COV '.' T_CAT1_TYPE_TYPE { 857bf215546Sopenharmony_ci parse_type_type(new_instr(OPC_MOV), $3); 858bf215546Sopenharmony_ci} 859bf215546Sopenharmony_ci 860bf215546Sopenharmony_cicat1_src: src_reg_or_const_or_rel 861bf215546Sopenharmony_ci| immediate_cat1 862bf215546Sopenharmony_ci 863bf215546Sopenharmony_cicat1_movmsk: T_OP_MOVMSK '.' T_W { 864bf215546Sopenharmony_ci new_instr(OPC_MOVMSK); 865bf215546Sopenharmony_ci instr->cat1.src_type = TYPE_U32; 866bf215546Sopenharmony_ci instr->cat1.dst_type = TYPE_U32; 867bf215546Sopenharmony_ci } dst_reg { 868bf215546Sopenharmony_ci if (($3 % 32) != 0) 869bf215546Sopenharmony_ci yyerror("w# must be multiple of 32"); 870bf215546Sopenharmony_ci if ($3 < 32) 871bf215546Sopenharmony_ci yyerror("w# must be at least 32"); 872bf215546Sopenharmony_ci 873bf215546Sopenharmony_ci int num = $3 / 32; 874bf215546Sopenharmony_ci 875bf215546Sopenharmony_ci instr->repeat = num - 1; 876bf215546Sopenharmony_ci instr->dsts[0]->wrmask = (1 << num) - 1; 877bf215546Sopenharmony_ci } 878bf215546Sopenharmony_ci 879bf215546Sopenharmony_cicat1_mova1: T_OP_MOVA1 T_A1 ',' { 880bf215546Sopenharmony_ci new_instr(OPC_MOV); 881bf215546Sopenharmony_ci instr->cat1.src_type = TYPE_U16; 882bf215546Sopenharmony_ci instr->cat1.dst_type = TYPE_U16; 883bf215546Sopenharmony_ci new_dst((61 << 3) + 2, IR3_REG_HALF); 884bf215546Sopenharmony_ci } cat1_src 885bf215546Sopenharmony_ci 886bf215546Sopenharmony_cicat1_mova: T_OP_MOVA T_A0 ',' { 887bf215546Sopenharmony_ci new_instr(OPC_MOV); 888bf215546Sopenharmony_ci instr->cat1.src_type = TYPE_S16; 889bf215546Sopenharmony_ci instr->cat1.dst_type = TYPE_S16; 890bf215546Sopenharmony_ci new_dst((61 << 3), IR3_REG_HALF); 891bf215546Sopenharmony_ci } cat1_src 892bf215546Sopenharmony_ci 893bf215546Sopenharmony_cicat1_swz: T_OP_SWZ '.' T_CAT1_TYPE_TYPE { parse_type_type(new_instr(OPC_SWZ), $3); } dst_reg ',' dst_reg ',' src_reg ',' src_reg 894bf215546Sopenharmony_ci 895bf215546Sopenharmony_cicat1_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 896bf215546Sopenharmony_ci 897bf215546Sopenharmony_cicat1_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 898bf215546Sopenharmony_ci 899bf215546Sopenharmony_ci /* NOTE: cat1 can also *write* to relative gpr */ 900bf215546Sopenharmony_cicat1_instr: cat1_movmsk 901bf215546Sopenharmony_ci| cat1_mova1 902bf215546Sopenharmony_ci| cat1_mova 903bf215546Sopenharmony_ci| cat1_swz 904bf215546Sopenharmony_ci| cat1_gat 905bf215546Sopenharmony_ci| cat1_sct 906bf215546Sopenharmony_ci| cat1_opc dst_reg ',' cat1_src 907bf215546Sopenharmony_ci| cat1_opc relative_gpr_dst ',' cat1_src 908bf215546Sopenharmony_ci 909bf215546Sopenharmony_cicat2_opc_1src: T_OP_ABSNEG_F { new_instr(OPC_ABSNEG_F); } 910bf215546Sopenharmony_ci| T_OP_ABSNEG_S { new_instr(OPC_ABSNEG_S); } 911bf215546Sopenharmony_ci| T_OP_CLZ_B { new_instr(OPC_CLZ_B); } 912bf215546Sopenharmony_ci| T_OP_CLZ_S { new_instr(OPC_CLZ_S); } 913bf215546Sopenharmony_ci| T_OP_SIGN_F { new_instr(OPC_SIGN_F); } 914bf215546Sopenharmony_ci| T_OP_FLOOR_F { new_instr(OPC_FLOOR_F); } 915bf215546Sopenharmony_ci| T_OP_CEIL_F { new_instr(OPC_CEIL_F); } 916bf215546Sopenharmony_ci| T_OP_RNDNE_F { new_instr(OPC_RNDNE_F); } 917bf215546Sopenharmony_ci| T_OP_RNDAZ_F { new_instr(OPC_RNDAZ_F); } 918bf215546Sopenharmony_ci| T_OP_TRUNC_F { new_instr(OPC_TRUNC_F); } 919bf215546Sopenharmony_ci| T_OP_NOT_B { new_instr(OPC_NOT_B); } 920bf215546Sopenharmony_ci| T_OP_BFREV_B { new_instr(OPC_BFREV_B); } 921bf215546Sopenharmony_ci| T_OP_SETRM { new_instr(OPC_SETRM); } 922bf215546Sopenharmony_ci| T_OP_CBITS_B { new_instr(OPC_CBITS_B); } 923bf215546Sopenharmony_ci 924bf215546Sopenharmony_cicat2_opc_2src_cnd: T_OP_CMPS_F { new_instr(OPC_CMPS_F); } 925bf215546Sopenharmony_ci| T_OP_CMPS_U { new_instr(OPC_CMPS_U); } 926bf215546Sopenharmony_ci| T_OP_CMPS_S { new_instr(OPC_CMPS_S); } 927bf215546Sopenharmony_ci| T_OP_CMPV_F { new_instr(OPC_CMPV_F); } 928bf215546Sopenharmony_ci| T_OP_CMPV_U { new_instr(OPC_CMPV_U); } 929bf215546Sopenharmony_ci| T_OP_CMPV_S { new_instr(OPC_CMPV_S); } 930bf215546Sopenharmony_ci 931bf215546Sopenharmony_cicat2_opc_2src: T_OP_ADD_F { new_instr(OPC_ADD_F); } 932bf215546Sopenharmony_ci| T_OP_MIN_F { new_instr(OPC_MIN_F); } 933bf215546Sopenharmony_ci| T_OP_MAX_F { new_instr(OPC_MAX_F); } 934bf215546Sopenharmony_ci| T_OP_MUL_F { new_instr(OPC_MUL_F); } 935bf215546Sopenharmony_ci| T_OP_ADD_U { new_instr(OPC_ADD_U); } 936bf215546Sopenharmony_ci| T_OP_ADD_S { new_instr(OPC_ADD_S); } 937bf215546Sopenharmony_ci| T_OP_SUB_U { new_instr(OPC_SUB_U); } 938bf215546Sopenharmony_ci| T_OP_SUB_S { new_instr(OPC_SUB_S); } 939bf215546Sopenharmony_ci| T_OP_MIN_U { new_instr(OPC_MIN_U); } 940bf215546Sopenharmony_ci| T_OP_MIN_S { new_instr(OPC_MIN_S); } 941bf215546Sopenharmony_ci| T_OP_MAX_U { new_instr(OPC_MAX_U); } 942bf215546Sopenharmony_ci| T_OP_MAX_S { new_instr(OPC_MAX_S); } 943bf215546Sopenharmony_ci| T_OP_AND_B { new_instr(OPC_AND_B); } 944bf215546Sopenharmony_ci| T_OP_OR_B { new_instr(OPC_OR_B); } 945bf215546Sopenharmony_ci| T_OP_XOR_B { new_instr(OPC_XOR_B); } 946bf215546Sopenharmony_ci| T_OP_MUL_U24 { new_instr(OPC_MUL_U24); } 947bf215546Sopenharmony_ci| T_OP_MUL_S24 { new_instr(OPC_MUL_S24); } 948bf215546Sopenharmony_ci| T_OP_MULL_U { new_instr(OPC_MULL_U); } 949bf215546Sopenharmony_ci| T_OP_SHL_B { new_instr(OPC_SHL_B); } 950bf215546Sopenharmony_ci| T_OP_SHR_B { new_instr(OPC_SHR_B); } 951bf215546Sopenharmony_ci| T_OP_ASHR_B { new_instr(OPC_ASHR_B); } 952bf215546Sopenharmony_ci| T_OP_BARY_F { new_instr(OPC_BARY_F); } 953bf215546Sopenharmony_ci| T_OP_FLAT_B { new_instr(OPC_FLAT_B); } 954bf215546Sopenharmony_ci| T_OP_MGEN_B { new_instr(OPC_MGEN_B); } 955bf215546Sopenharmony_ci| T_OP_GETBIT_B { new_instr(OPC_GETBIT_B); } 956bf215546Sopenharmony_ci| T_OP_SHB { new_instr(OPC_SHB); } 957bf215546Sopenharmony_ci| T_OP_MSAD { new_instr(OPC_MSAD); } 958bf215546Sopenharmony_ci 959bf215546Sopenharmony_cicond: T_LT { instr->cat2.condition = IR3_COND_LT; } 960bf215546Sopenharmony_ci| T_LE { instr->cat2.condition = IR3_COND_LE; } 961bf215546Sopenharmony_ci| T_GT { instr->cat2.condition = IR3_COND_GT; } 962bf215546Sopenharmony_ci| T_GE { instr->cat2.condition = IR3_COND_GE; } 963bf215546Sopenharmony_ci| T_EQ { instr->cat2.condition = IR3_COND_EQ; } 964bf215546Sopenharmony_ci| T_NE { instr->cat2.condition = IR3_COND_NE; } 965bf215546Sopenharmony_ci 966bf215546Sopenharmony_cicat2_instr: cat2_opc_1src dst_reg ',' src_reg_or_const_or_rel_or_imm 967bf215546Sopenharmony_ci| cat2_opc_2src_cnd '.' cond dst_reg ',' src_reg_or_const_or_rel_or_imm ',' src_reg_or_const_or_rel_or_imm 968bf215546Sopenharmony_ci| cat2_opc_2src dst_reg ',' src_reg_or_const_or_rel_or_imm ',' src_reg_or_const_or_rel_or_imm 969bf215546Sopenharmony_ci 970bf215546Sopenharmony_cicat3_dp_signedness:'.' T_MIXED { instr->cat3.signedness = IR3_SRC_MIXED; } 971bf215546Sopenharmony_ci| '.' T_UNSIGNED{ instr->cat3.signedness = IR3_SRC_UNSIGNED; } 972bf215546Sopenharmony_ci 973bf215546Sopenharmony_cicat3_dp_pack: '.' T_LOW { instr->cat3.packed = IR3_SRC_PACKED_LOW; } 974bf215546Sopenharmony_ci| '.' T_HIGH { instr->cat3.packed = IR3_SRC_PACKED_HIGH; } 975bf215546Sopenharmony_ci 976bf215546Sopenharmony_cicat3_opc: T_OP_MAD_U16 { new_instr(OPC_MAD_U16); } 977bf215546Sopenharmony_ci| T_OP_MADSH_U16 { new_instr(OPC_MADSH_U16); } 978bf215546Sopenharmony_ci| T_OP_MAD_S16 { new_instr(OPC_MAD_S16); } 979bf215546Sopenharmony_ci| T_OP_MADSH_M16 { new_instr(OPC_MADSH_M16); } 980bf215546Sopenharmony_ci| T_OP_MAD_U24 { new_instr(OPC_MAD_U24); } 981bf215546Sopenharmony_ci| T_OP_MAD_S24 { new_instr(OPC_MAD_S24); } 982bf215546Sopenharmony_ci| T_OP_MAD_F16 { new_instr(OPC_MAD_F16); } 983bf215546Sopenharmony_ci| T_OP_MAD_F32 { new_instr(OPC_MAD_F32); } 984bf215546Sopenharmony_ci| T_OP_SEL_B16 { new_instr(OPC_SEL_B16); } 985bf215546Sopenharmony_ci| T_OP_SEL_B32 { new_instr(OPC_SEL_B32); } 986bf215546Sopenharmony_ci| T_OP_SEL_S16 { new_instr(OPC_SEL_S16); } 987bf215546Sopenharmony_ci| T_OP_SEL_S32 { new_instr(OPC_SEL_S32); } 988bf215546Sopenharmony_ci| T_OP_SEL_F16 { new_instr(OPC_SEL_F16); } 989bf215546Sopenharmony_ci| T_OP_SEL_F32 { new_instr(OPC_SEL_F32); } 990bf215546Sopenharmony_ci| T_OP_SAD_S16 { new_instr(OPC_SAD_S16); } 991bf215546Sopenharmony_ci| T_OP_SAD_S32 { new_instr(OPC_SAD_S32); } 992bf215546Sopenharmony_ci 993bf215546Sopenharmony_cicat3_imm_reg_opc: T_OP_SHRM { new_instr(OPC_SHRM); } 994bf215546Sopenharmony_ci| T_OP_SHLM { new_instr(OPC_SHLM); } 995bf215546Sopenharmony_ci| T_OP_SHRG { new_instr(OPC_SHRG); } 996bf215546Sopenharmony_ci| T_OP_SHLG { new_instr(OPC_SHLG); } 997bf215546Sopenharmony_ci| T_OP_ANDG { new_instr(OPC_ANDG); } 998bf215546Sopenharmony_ci 999bf215546Sopenharmony_cicat3_wmm: T_OP_WMM { new_instr(OPC_WMM); } 1000bf215546Sopenharmony_ci| T_OP_WMM_ACCU { new_instr(OPC_WMM_ACCU); } 1001bf215546Sopenharmony_ci 1002bf215546Sopenharmony_cicat3_dp: T_OP_DP2ACC { new_instr(OPC_DP2ACC); } 1003bf215546Sopenharmony_ci| T_OP_DP4ACC { new_instr(OPC_DP4ACC); } 1004bf215546Sopenharmony_ci 1005bf215546Sopenharmony_cicat3_instr: cat3_opc dst_reg ',' src_reg_or_const_or_rel ',' src_reg_or_const ',' src_reg_or_const_or_rel 1006bf215546Sopenharmony_ci| cat3_imm_reg_opc dst_reg ',' src_reg_or_rel_or_imm ',' src_reg_or_const ',' src_reg_or_rel_or_imm 1007bf215546Sopenharmony_ci| cat3_wmm dst_reg ',' src_reg_gpr ',' src_reg ',' immediate 1008bf215546Sopenharmony_ci| cat3_dp cat3_dp_signedness cat3_dp_pack dst_reg ',' src_reg_or_rel_or_imm ',' src_reg_or_const ',' src_reg_or_rel_or_imm 1009bf215546Sopenharmony_ci 1010bf215546Sopenharmony_cicat4_opc: T_OP_RCP { new_instr(OPC_RCP); } 1011bf215546Sopenharmony_ci| T_OP_RSQ { new_instr(OPC_RSQ); } 1012bf215546Sopenharmony_ci| T_OP_LOG2 { new_instr(OPC_LOG2); } 1013bf215546Sopenharmony_ci| T_OP_EXP2 { new_instr(OPC_EXP2); } 1014bf215546Sopenharmony_ci| T_OP_SIN { new_instr(OPC_SIN); } 1015bf215546Sopenharmony_ci| T_OP_COS { new_instr(OPC_COS); } 1016bf215546Sopenharmony_ci| T_OP_SQRT { new_instr(OPC_SQRT); } 1017bf215546Sopenharmony_ci| T_OP_HRSQ { new_instr(OPC_HRSQ); } 1018bf215546Sopenharmony_ci| T_OP_HLOG2 { new_instr(OPC_HLOG2); } 1019bf215546Sopenharmony_ci| T_OP_HEXP2 { new_instr(OPC_HEXP2); } 1020bf215546Sopenharmony_ci 1021bf215546Sopenharmony_cicat4_instr: cat4_opc dst_reg ',' src_reg_or_const_or_rel_or_imm 1022bf215546Sopenharmony_ci 1023bf215546Sopenharmony_cicat5_opc_dsxypp: T_OP_DSXPP_1 { new_instr(OPC_DSXPP_1)->cat5.type = TYPE_F32; } 1024bf215546Sopenharmony_ci| T_OP_DSYPP_1 { new_instr(OPC_DSYPP_1)->cat5.type = TYPE_F32; } 1025bf215546Sopenharmony_ci 1026bf215546Sopenharmony_cicat5_opc: T_OP_ISAM { new_instr(OPC_ISAM); } 1027bf215546Sopenharmony_ci| T_OP_ISAML { new_instr(OPC_ISAML); } 1028bf215546Sopenharmony_ci| T_OP_ISAMM { new_instr(OPC_ISAMM); } 1029bf215546Sopenharmony_ci| T_OP_SAM { new_instr(OPC_SAM); } 1030bf215546Sopenharmony_ci| T_OP_SAMB { new_instr(OPC_SAMB); } 1031bf215546Sopenharmony_ci| T_OP_SAML { new_instr(OPC_SAML); } 1032bf215546Sopenharmony_ci| T_OP_SAMGQ { new_instr(OPC_SAMGQ); } 1033bf215546Sopenharmony_ci| T_OP_GETLOD { new_instr(OPC_GETLOD); } 1034bf215546Sopenharmony_ci| T_OP_CONV { new_instr(OPC_CONV); } 1035bf215546Sopenharmony_ci| T_OP_CONVM { new_instr(OPC_CONVM); } 1036bf215546Sopenharmony_ci| T_OP_GETSIZE { new_instr(OPC_GETSIZE); } 1037bf215546Sopenharmony_ci| T_OP_GETBUF { new_instr(OPC_GETBUF); } 1038bf215546Sopenharmony_ci| T_OP_GETPOS { new_instr(OPC_GETPOS); } 1039bf215546Sopenharmony_ci| T_OP_GETINFO { new_instr(OPC_GETINFO); } 1040bf215546Sopenharmony_ci| T_OP_DSX { new_instr(OPC_DSX); } 1041bf215546Sopenharmony_ci| T_OP_DSY { new_instr(OPC_DSY); } 1042bf215546Sopenharmony_ci| T_OP_GATHER4R { new_instr(OPC_GATHER4R); } 1043bf215546Sopenharmony_ci| T_OP_GATHER4G { new_instr(OPC_GATHER4G); } 1044bf215546Sopenharmony_ci| T_OP_GATHER4B { new_instr(OPC_GATHER4B); } 1045bf215546Sopenharmony_ci| T_OP_GATHER4A { new_instr(OPC_GATHER4A); } 1046bf215546Sopenharmony_ci| T_OP_SAMGP0 { new_instr(OPC_SAMGP0); } 1047bf215546Sopenharmony_ci| T_OP_SAMGP1 { new_instr(OPC_SAMGP1); } 1048bf215546Sopenharmony_ci| T_OP_SAMGP2 { new_instr(OPC_SAMGP2); } 1049bf215546Sopenharmony_ci| T_OP_SAMGP3 { new_instr(OPC_SAMGP3); } 1050bf215546Sopenharmony_ci| T_OP_RGETPOS { new_instr(OPC_RGETPOS); } 1051bf215546Sopenharmony_ci| T_OP_RGETINFO { new_instr(OPC_RGETINFO); } 1052bf215546Sopenharmony_ci| T_OP_BRCST_A { new_instr(OPC_BRCST_ACTIVE); } 1053bf215546Sopenharmony_ci| T_OP_QSHUFFLE_BRCST { new_instr(OPC_QUAD_SHUFFLE_BRCST); } 1054bf215546Sopenharmony_ci| T_OP_QSHUFFLE_H { new_instr(OPC_QUAD_SHUFFLE_HORIZ); } 1055bf215546Sopenharmony_ci| T_OP_QSHUFFLE_V { new_instr(OPC_QUAD_SHUFFLE_VERT); } 1056bf215546Sopenharmony_ci| T_OP_QSHUFFLE_DIAG { new_instr(OPC_QUAD_SHUFFLE_DIAG); } 1057bf215546Sopenharmony_ci 1058bf215546Sopenharmony_cicat5_flag: '.' T_3D { instr->flags |= IR3_INSTR_3D; } 1059bf215546Sopenharmony_ci| '.' 'a' { instr->flags |= IR3_INSTR_A; } 1060bf215546Sopenharmony_ci| '.' 'o' { instr->flags |= IR3_INSTR_O; } 1061bf215546Sopenharmony_ci| '.' 'p' { instr->flags |= IR3_INSTR_P; } 1062bf215546Sopenharmony_ci| '.' 's' { instr->flags |= IR3_INSTR_S; } 1063bf215546Sopenharmony_ci| '.' T_S2EN { instr->flags |= IR3_INSTR_S2EN; } 1064bf215546Sopenharmony_ci| '.' T_UNIFORM { } 1065bf215546Sopenharmony_ci| '.' T_NONUNIFORM { instr->flags |= IR3_INSTR_NONUNIF; } 1066bf215546Sopenharmony_ci| '.' T_BASE { instr->flags |= IR3_INSTR_B; instr->cat5.tex_base = $2; } 1067bf215546Sopenharmony_ci| '.' T_W { instr->cat5.cluster_size = $2; } 1068bf215546Sopenharmony_cicat5_flags: 1069bf215546Sopenharmony_ci| cat5_flag cat5_flags 1070bf215546Sopenharmony_ci 1071bf215546Sopenharmony_cicat5_samp: T_SAMP { instr->cat5.samp = $1; } 1072bf215546Sopenharmony_cicat5_tex: T_TEX { instr->cat5.tex = $1; } 1073bf215546Sopenharmony_cicat5_type: '(' type ')' { instr->cat5.type = $2; } 1074bf215546Sopenharmony_cicat5_a1: src_reg { instr->flags |= IR3_INSTR_A1EN; } 1075bf215546Sopenharmony_ci 1076bf215546Sopenharmony_cicat5_instr: cat5_opc_dsxypp cat5_flags dst_reg ',' src_reg 1077bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg ',' src_reg 1078bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg ',' cat5_samp ',' cat5_tex 1079bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg ',' cat5_samp 1080bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg ',' cat5_tex 1081bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' src_reg 1082bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' cat5_samp ',' cat5_tex 1083bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' cat5_samp ',' cat5_a1 1084bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' cat5_samp 1085bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg ',' cat5_tex 1086bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' src_reg 1087bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' cat5_samp ',' cat5_tex 1088bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' cat5_samp 1089bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg ',' cat5_tex 1090bf215546Sopenharmony_ci| cat5_opc cat5_flags cat5_type dst_reg 1091bf215546Sopenharmony_ci 1092bf215546Sopenharmony_cicat6_typed: '.' T_UNTYPED { instr->cat6.typed = 0; } 1093bf215546Sopenharmony_ci| '.' T_TYPED { instr->cat6.typed = 1; } 1094bf215546Sopenharmony_ci 1095bf215546Sopenharmony_cicat6_dim: '.' T_1D { instr->cat6.d = 1; } 1096bf215546Sopenharmony_ci| '.' T_2D { instr->cat6.d = 2; } 1097bf215546Sopenharmony_ci| '.' T_3D { instr->cat6.d = 3; } 1098bf215546Sopenharmony_ci| '.' T_4D { instr->cat6.d = 4; } 1099bf215546Sopenharmony_ci 1100bf215546Sopenharmony_cicat6_type: '.' type { instr->cat6.type = $2; } 1101bf215546Sopenharmony_cicat6_imm_offset: offset { new_src(0, IR3_REG_IMMED)->iim_val = $1; } 1102bf215546Sopenharmony_cicat6_offset: cat6_imm_offset 1103bf215546Sopenharmony_ci| '+' src 1104bf215546Sopenharmony_cicat6_dst_offset: offset { instr->cat6.dst_offset = $1; } 1105bf215546Sopenharmony_ci| '+' src 1106bf215546Sopenharmony_ci 1107bf215546Sopenharmony_cicat6_immed: integer { instr->cat6.iim_val = $1; } 1108bf215546Sopenharmony_ci 1109bf215546Sopenharmony_cicat6_stg_ldg_a6xx_offset: 1110bf215546Sopenharmony_ci '+' '(' src offset ')' '<' '<' integer { 1111bf215546Sopenharmony_ci assert($8 == 2); 1112bf215546Sopenharmony_ci new_src(0, IR3_REG_IMMED)->uim_val = 0; 1113bf215546Sopenharmony_ci new_src(0, IR3_REG_IMMED)->uim_val = $4; 1114bf215546Sopenharmony_ci } 1115bf215546Sopenharmony_ci| '+' src '<' '<' integer offset '<' '<' integer { 1116bf215546Sopenharmony_ci assert($9 == 2); 1117bf215546Sopenharmony_ci new_src(0, IR3_REG_IMMED)->uim_val = $5 - 2; 1118bf215546Sopenharmony_ci new_src(0, IR3_REG_IMMED)->uim_val = $6; 1119bf215546Sopenharmony_ci } 1120bf215546Sopenharmony_ci 1121bf215546Sopenharmony_cicat6_load: T_OP_LDG { new_instr(OPC_LDG); } cat6_type dst_reg ',' 'g' '[' src cat6_offset ']' ',' immediate 1122bf215546Sopenharmony_ci| T_OP_LDG_A { new_instr(OPC_LDG_A); } cat6_type dst_reg ',' 'g' '[' src cat6_stg_ldg_a6xx_offset ']' ',' immediate 1123bf215546Sopenharmony_ci| T_OP_LDP { new_instr(OPC_LDP); } cat6_type dst_reg ',' 'p' '[' src cat6_offset ']' ',' immediate 1124bf215546Sopenharmony_ci| T_OP_LDL { new_instr(OPC_LDL); } cat6_type dst_reg ',' 'l' '[' src cat6_offset ']' ',' immediate 1125bf215546Sopenharmony_ci| T_OP_LDLW { new_instr(OPC_LDLW); } cat6_type dst_reg ',' 'l' '[' src cat6_offset ']' ',' immediate 1126bf215546Sopenharmony_ci| T_OP_LDLV { new_instr(OPC_LDLV); } cat6_type dst_reg ',' 'l' '[' integer ']' { 1127bf215546Sopenharmony_ci new_src(0, IR3_REG_IMMED)->iim_val = $8; 1128bf215546Sopenharmony_ci } ',' immediate 1129bf215546Sopenharmony_ci 1130bf215546Sopenharmony_cicat6_store: T_OP_STG { new_instr(OPC_STG); dummy_dst(); } cat6_type 'g' '[' src cat6_imm_offset ']' ',' src ',' immediate 1131bf215546Sopenharmony_ci| T_OP_STG_A { new_instr(OPC_STG_A); dummy_dst(); } cat6_type 'g' '[' src cat6_stg_ldg_a6xx_offset ']' ',' src ',' immediate 1132bf215546Sopenharmony_ci| T_OP_STP { new_instr(OPC_STP); dummy_dst(); } cat6_type 'p' '[' src cat6_dst_offset ']' ',' src ',' immediate 1133bf215546Sopenharmony_ci| T_OP_STL { new_instr(OPC_STL); dummy_dst(); } cat6_type 'l' '[' src cat6_dst_offset ']' ',' src ',' immediate 1134bf215546Sopenharmony_ci| T_OP_STLW { new_instr(OPC_STLW); dummy_dst(); } cat6_type 'l' '[' src cat6_dst_offset ']' ',' src ',' immediate 1135bf215546Sopenharmony_ci 1136bf215546Sopenharmony_cicat6_loadib: T_OP_LDIB { new_instr(OPC_LDIB); } cat6_typed cat6_dim cat6_type '.' cat6_immed dst_reg ',' 'g' '[' immediate ']' ',' src ',' src 1137bf215546Sopenharmony_cicat6_storeib: T_OP_STIB { new_instr(OPC_STIB); dummy_dst(); } cat6_typed cat6_dim cat6_type '.' cat6_immed'g' '[' immediate ']' ',' src ',' src ',' src 1138bf215546Sopenharmony_ci 1139bf215546Sopenharmony_cicat6_prefetch: T_OP_PREFETCH { new_instr(OPC_PREFETCH); new_dst(0,0); /* dummy dst */ } 'g' '[' src cat6_offset ']' ',' cat6_immed 1140bf215546Sopenharmony_ci 1141bf215546Sopenharmony_cicat6_atomic_opc: T_OP_ATOMIC_ADD { new_instr(OPC_ATOMIC_ADD); } 1142bf215546Sopenharmony_ci| T_OP_ATOMIC_SUB { new_instr(OPC_ATOMIC_SUB); } 1143bf215546Sopenharmony_ci| T_OP_ATOMIC_XCHG { new_instr(OPC_ATOMIC_XCHG); } 1144bf215546Sopenharmony_ci| T_OP_ATOMIC_INC { new_instr(OPC_ATOMIC_INC); } 1145bf215546Sopenharmony_ci| T_OP_ATOMIC_DEC { new_instr(OPC_ATOMIC_DEC); } 1146bf215546Sopenharmony_ci| T_OP_ATOMIC_CMPXCHG { new_instr(OPC_ATOMIC_CMPXCHG); } 1147bf215546Sopenharmony_ci| T_OP_ATOMIC_MIN { new_instr(OPC_ATOMIC_MIN); } 1148bf215546Sopenharmony_ci| T_OP_ATOMIC_MAX { new_instr(OPC_ATOMIC_MAX); } 1149bf215546Sopenharmony_ci| T_OP_ATOMIC_AND { new_instr(OPC_ATOMIC_AND); } 1150bf215546Sopenharmony_ci| T_OP_ATOMIC_OR { new_instr(OPC_ATOMIC_OR); } 1151bf215546Sopenharmony_ci| T_OP_ATOMIC_XOR { new_instr(OPC_ATOMIC_XOR); } 1152bf215546Sopenharmony_ci 1153bf215546Sopenharmony_cicat6_a3xx_atomic_opc: T_OP_ATOMIC_S_ADD { new_instr(OPC_ATOMIC_S_ADD); } 1154bf215546Sopenharmony_ci| T_OP_ATOMIC_S_SUB { new_instr(OPC_ATOMIC_S_SUB); } 1155bf215546Sopenharmony_ci| T_OP_ATOMIC_S_XCHG { new_instr(OPC_ATOMIC_S_XCHG); } 1156bf215546Sopenharmony_ci| T_OP_ATOMIC_S_INC { new_instr(OPC_ATOMIC_S_INC); } 1157bf215546Sopenharmony_ci| T_OP_ATOMIC_S_DEC { new_instr(OPC_ATOMIC_S_DEC); } 1158bf215546Sopenharmony_ci| T_OP_ATOMIC_S_CMPXCHG { new_instr(OPC_ATOMIC_S_CMPXCHG); } 1159bf215546Sopenharmony_ci| T_OP_ATOMIC_S_MIN { new_instr(OPC_ATOMIC_S_MIN); } 1160bf215546Sopenharmony_ci| T_OP_ATOMIC_S_MAX { new_instr(OPC_ATOMIC_S_MAX); } 1161bf215546Sopenharmony_ci| T_OP_ATOMIC_S_AND { new_instr(OPC_ATOMIC_S_AND); } 1162bf215546Sopenharmony_ci| T_OP_ATOMIC_S_OR { new_instr(OPC_ATOMIC_S_OR); } 1163bf215546Sopenharmony_ci| T_OP_ATOMIC_S_XOR { new_instr(OPC_ATOMIC_S_XOR); } 1164bf215546Sopenharmony_ci 1165bf215546Sopenharmony_cicat6_a6xx_atomic_opc: T_OP_ATOMIC_G_ADD { new_instr(OPC_ATOMIC_G_ADD); } 1166bf215546Sopenharmony_ci| T_OP_ATOMIC_G_SUB { new_instr(OPC_ATOMIC_G_SUB); } 1167bf215546Sopenharmony_ci| T_OP_ATOMIC_G_XCHG { new_instr(OPC_ATOMIC_G_XCHG); } 1168bf215546Sopenharmony_ci| T_OP_ATOMIC_G_INC { new_instr(OPC_ATOMIC_G_INC); } 1169bf215546Sopenharmony_ci| T_OP_ATOMIC_G_DEC { new_instr(OPC_ATOMIC_G_DEC); } 1170bf215546Sopenharmony_ci| T_OP_ATOMIC_G_CMPXCHG { new_instr(OPC_ATOMIC_G_CMPXCHG); } 1171bf215546Sopenharmony_ci| T_OP_ATOMIC_G_MIN { new_instr(OPC_ATOMIC_G_MIN); } 1172bf215546Sopenharmony_ci| T_OP_ATOMIC_G_MAX { new_instr(OPC_ATOMIC_G_MAX); } 1173bf215546Sopenharmony_ci| T_OP_ATOMIC_G_AND { new_instr(OPC_ATOMIC_G_AND); } 1174bf215546Sopenharmony_ci| T_OP_ATOMIC_G_OR { new_instr(OPC_ATOMIC_G_OR); } 1175bf215546Sopenharmony_ci| T_OP_ATOMIC_G_XOR { new_instr(OPC_ATOMIC_G_XOR); } 1176bf215546Sopenharmony_ci 1177bf215546Sopenharmony_cicat6_a3xx_atomic_s: cat6_a3xx_atomic_opc cat6_typed cat6_dim cat6_type '.' cat6_immed '.' 'g' dst_reg ',' 'g' '[' cat6_reg_or_immed ']' ',' src ',' src ',' src 1178bf215546Sopenharmony_ci 1179bf215546Sopenharmony_cicat6_a6xx_atomic_g: cat6_a6xx_atomic_opc cat6_typed cat6_dim cat6_type '.' cat6_immed '.' 'g' dst_reg ',' src ',' src 1180bf215546Sopenharmony_ci 1181bf215546Sopenharmony_cicat6_atomic_l: cat6_atomic_opc cat6_typed cat6_dim cat6_type '.' cat6_immed '.' 'l' dst_reg ',' 'l' '[' cat6_reg_or_immed ']' ',' src 1182bf215546Sopenharmony_ci 1183bf215546Sopenharmony_cicat6_atomic: cat6_atomic_l 1184bf215546Sopenharmony_ci| cat6_a3xx_atomic_s 1185bf215546Sopenharmony_ci| cat6_a6xx_atomic_g 1186bf215546Sopenharmony_ci 1187bf215546Sopenharmony_cicat6_ibo_opc_1src: T_OP_RESINFO { new_instr(OPC_RESINFO); } 1188bf215546Sopenharmony_ci 1189bf215546Sopenharmony_cicat6_ibo_opc_ldgb: T_OP_LDGB { new_instr(OPC_LDGB); } 1190bf215546Sopenharmony_cicat6_ibo_opc_stgb: T_OP_STGB { new_instr(OPC_STGB); } 1191bf215546Sopenharmony_ci 1192bf215546Sopenharmony_cicat6_ibo: cat6_ibo_opc_1src cat6_type cat6_dim dst_reg ',' 'g' '[' cat6_reg_or_immed ']' 1193bf215546Sopenharmony_ci| cat6_ibo_opc_ldgb cat6_typed cat6_dim cat6_type '.' cat6_immed dst_reg ',' 'g' '[' cat6_reg_or_immed ']' ',' src ',' src 1194bf215546Sopenharmony_ci| 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 1195bf215546Sopenharmony_ci 1196bf215546Sopenharmony_cicat6_id_opc: 1197bf215546Sopenharmony_ci T_OP_GETSPID { new_instr(OPC_GETSPID); } 1198bf215546Sopenharmony_ci| T_OP_GETWID { new_instr(OPC_GETWID); } 1199bf215546Sopenharmony_ci| T_OP_GETFIBERID { new_instr(OPC_GETFIBERID); } 1200bf215546Sopenharmony_ci 1201bf215546Sopenharmony_cicat6_id: cat6_id_opc cat6_type dst_reg 1202bf215546Sopenharmony_ci 1203bf215546Sopenharmony_cicat6_bindless_base: 1204bf215546Sopenharmony_ci| '.' T_BASE { instr->flags |= IR3_INSTR_B; instr->cat6.base = $2; } 1205bf215546Sopenharmony_ci 1206bf215546Sopenharmony_cicat6_bindless_mode: T_IMM cat6_bindless_base 1207bf215546Sopenharmony_ci| T_UNIFORM cat6_bindless_base 1208bf215546Sopenharmony_ci| T_NONUNIFORM cat6_bindless_base { instr->flags |= IR3_INSTR_NONUNIF; } 1209bf215546Sopenharmony_ci 1210bf215546Sopenharmony_cicat6_reg_or_immed: src 1211bf215546Sopenharmony_ci| integer { new_src(0, IR3_REG_IMMED)->iim_val = $1; } 1212bf215546Sopenharmony_ci 1213bf215546Sopenharmony_cicat6_bindless_ibo_opc_1src: T_OP_RESINFO_B { new_instr(OPC_RESINFO); } 1214bf215546Sopenharmony_ci 1215bf215546Sopenharmony_cicat6_bindless_ibo_opc_2src: T_OP_ATOMIC_B_ADD { new_instr(OPC_ATOMIC_B_ADD); dummy_dst(); } 1216bf215546Sopenharmony_ci| T_OP_ATOMIC_B_SUB { new_instr(OPC_ATOMIC_B_SUB); dummy_dst(); } 1217bf215546Sopenharmony_ci| T_OP_ATOMIC_B_XCHG { new_instr(OPC_ATOMIC_B_XCHG); dummy_dst(); } 1218bf215546Sopenharmony_ci| T_OP_ATOMIC_B_INC { new_instr(OPC_ATOMIC_B_INC); dummy_dst(); } 1219bf215546Sopenharmony_ci| T_OP_ATOMIC_B_DEC { new_instr(OPC_ATOMIC_B_DEC); dummy_dst(); } 1220bf215546Sopenharmony_ci| T_OP_ATOMIC_B_CMPXCHG { new_instr(OPC_ATOMIC_B_CMPXCHG); dummy_dst(); } 1221bf215546Sopenharmony_ci| T_OP_ATOMIC_B_MIN { new_instr(OPC_ATOMIC_B_MIN); dummy_dst(); } 1222bf215546Sopenharmony_ci| T_OP_ATOMIC_B_MAX { new_instr(OPC_ATOMIC_B_MAX); dummy_dst(); } 1223bf215546Sopenharmony_ci| T_OP_ATOMIC_B_AND { new_instr(OPC_ATOMIC_B_AND); dummy_dst(); } 1224bf215546Sopenharmony_ci| T_OP_ATOMIC_B_OR { new_instr(OPC_ATOMIC_B_OR); dummy_dst(); } 1225bf215546Sopenharmony_ci| T_OP_ATOMIC_B_XOR { new_instr(OPC_ATOMIC_B_XOR); dummy_dst(); } 1226bf215546Sopenharmony_ci| T_OP_STIB_B { new_instr(OPC_STIB); dummy_dst(); } 1227bf215546Sopenharmony_ci 1228bf215546Sopenharmony_cicat6_bindless_ibo_opc_2src_dst: T_OP_LDIB_B { new_instr(OPC_LDIB); } 1229bf215546Sopenharmony_ci 1230bf215546Sopenharmony_cicat6_bindless_ibo: cat6_bindless_ibo_opc_1src cat6_typed cat6_dim cat6_type '.' cat6_immed '.' cat6_bindless_mode dst_reg ',' cat6_reg_or_immed 1231bf215546Sopenharmony_ci| 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]); } 1232bf215546Sopenharmony_ci| 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]); } 1233bf215546Sopenharmony_ci 1234bf215546Sopenharmony_cicat6_bindless_ldc_opc: T_OP_LDC { new_instr(OPC_LDC); } 1235bf215546Sopenharmony_ci 1236bf215546Sopenharmony_ci/* This is separated from the opcode to avoid lookahead/shift-reduce conflicts */ 1237bf215546Sopenharmony_cicat6_bindless_ldc_middle: 1238bf215546Sopenharmony_ci T_OFFSET '.' cat6_immed '.' cat6_bindless_mode dst_reg { instr->cat6.d = $1; } 1239bf215546Sopenharmony_ci| cat6_immed '.' 'k' '.' cat6_bindless_mode 'c' '[' T_A1 ']' { instr->opc = OPC_LDC_K; } 1240bf215546Sopenharmony_ci 1241bf215546Sopenharmony_cicat6_bindless_ldc: cat6_bindless_ldc_opc '.' cat6_bindless_ldc_middle ',' cat6_reg_or_immed ',' cat6_reg_or_immed { 1242bf215546Sopenharmony_ci instr->cat6.type = TYPE_U32; 1243bf215546Sopenharmony_ci /* TODO cleanup ir3 src order: */ 1244bf215546Sopenharmony_ci swap(instr->srcs[0], instr->srcs[1]); 1245bf215546Sopenharmony_ci } 1246bf215546Sopenharmony_ci 1247bf215546Sopenharmony_cistc_dst: integer { new_src(0, IR3_REG_IMMED)->iim_val = $1; } 1248bf215546Sopenharmony_ci| T_A1 { new_src(0, IR3_REG_IMMED)->iim_val = 0; instr->flags |= IR3_INSTR_A1EN; } 1249bf215546Sopenharmony_ci| T_A1 '+' integer { new_src(0, IR3_REG_IMMED)->iim_val = $3; instr->flags |= IR3_INSTR_A1EN; } 1250bf215546Sopenharmony_ci 1251bf215546Sopenharmony_cicat6_stc: T_OP_STC { new_instr(OPC_STC); } cat6_type 'c' '[' stc_dst ']' ',' src_reg ',' cat6_immed 1252bf215546Sopenharmony_ci 1253bf215546Sopenharmony_cicat6_todo: T_OP_G2L { new_instr(OPC_G2L); } 1254bf215546Sopenharmony_ci| T_OP_L2G { new_instr(OPC_L2G); } 1255bf215546Sopenharmony_ci| T_OP_RESFMT { new_instr(OPC_RESFMT); } 1256bf215546Sopenharmony_ci 1257bf215546Sopenharmony_cicat6_instr: cat6_load 1258bf215546Sopenharmony_ci| cat6_loadib 1259bf215546Sopenharmony_ci| cat6_store 1260bf215546Sopenharmony_ci| cat6_storeib 1261bf215546Sopenharmony_ci| cat6_prefetch 1262bf215546Sopenharmony_ci| cat6_atomic 1263bf215546Sopenharmony_ci| cat6_ibo 1264bf215546Sopenharmony_ci| cat6_id 1265bf215546Sopenharmony_ci| cat6_bindless_ldc 1266bf215546Sopenharmony_ci| cat6_bindless_ibo 1267bf215546Sopenharmony_ci| cat6_stc 1268bf215546Sopenharmony_ci| cat6_todo 1269bf215546Sopenharmony_ci 1270bf215546Sopenharmony_cicat7_scope: '.' 'w' { instr->cat7.w = true; } 1271bf215546Sopenharmony_ci| '.' 'r' { instr->cat7.r = true; } 1272bf215546Sopenharmony_ci| '.' 'l' { instr->cat7.l = true; } 1273bf215546Sopenharmony_ci| '.' 'g' { instr->cat7.g = true; } 1274bf215546Sopenharmony_ci 1275bf215546Sopenharmony_cicat7_scopes: 1276bf215546Sopenharmony_ci| cat7_scope cat7_scopes 1277bf215546Sopenharmony_ci 1278bf215546Sopenharmony_cicat7_barrier: T_OP_BAR { new_instr(OPC_BAR); } cat7_scopes 1279bf215546Sopenharmony_ci| T_OP_FENCE { new_instr(OPC_FENCE); } cat7_scopes 1280bf215546Sopenharmony_ci 1281bf215546Sopenharmony_cicat7_instr: cat7_barrier 1282bf215546Sopenharmony_ci 1283bf215546Sopenharmony_cisrc: T_REGISTER { $$ = new_src($1, 0); } 1284bf215546Sopenharmony_ci| T_A0 { $$ = new_src((61 << 3), IR3_REG_HALF); } 1285bf215546Sopenharmony_ci| T_A1 { $$ = new_src((61 << 3) + 1, IR3_REG_HALF); } 1286bf215546Sopenharmony_ci| T_P0 { $$ = new_src((62 << 3) + $1, 0); } 1287bf215546Sopenharmony_ci 1288bf215546Sopenharmony_cidst: T_REGISTER { $$ = new_dst($1, 0); } 1289bf215546Sopenharmony_ci| T_A0 { $$ = new_dst((61 << 3), IR3_REG_HALF); } 1290bf215546Sopenharmony_ci| T_A1 { $$ = new_dst((61 << 3) + 1, IR3_REG_HALF); } 1291bf215546Sopenharmony_ci| T_P0 { $$ = new_dst((62 << 3) + $1, 0); } 1292bf215546Sopenharmony_ci 1293bf215546Sopenharmony_ciconst: T_CONSTANT { $$ = new_src($1, IR3_REG_CONST); } 1294bf215546Sopenharmony_ci 1295bf215546Sopenharmony_cidst_reg_flag: T_EVEN { instr->cat1.round = ROUND_EVEN; } 1296bf215546Sopenharmony_ci| T_POS_INFINITY { instr->cat1.round = ROUND_POS_INF; } 1297bf215546Sopenharmony_ci| T_NEG_INFINITY { instr->cat1.round = ROUND_NEG_INF; } 1298bf215546Sopenharmony_ci| T_EI { rflags.flags |= IR3_REG_EI; } 1299bf215546Sopenharmony_ci| T_WRMASK { rflags.wrmask = $1; } 1300bf215546Sopenharmony_ci 1301bf215546Sopenharmony_cidst_reg_flags: dst_reg_flag 1302bf215546Sopenharmony_ci| dst_reg_flag dst_reg_flags 1303bf215546Sopenharmony_ci 1304bf215546Sopenharmony_ci /* note: destination registers are always incremented in repeat */ 1305bf215546Sopenharmony_cidst_reg: dst { $1->flags |= IR3_REG_R; } 1306bf215546Sopenharmony_ci| dst_reg_flags dst { $2->flags |= IR3_REG_R; } 1307bf215546Sopenharmony_ci 1308bf215546Sopenharmony_cisrc_reg_flag: T_ABSNEG { rflags.flags |= IR3_REG_ABS|IR3_REG_NEGATE; } 1309bf215546Sopenharmony_ci| T_NEG { rflags.flags |= IR3_REG_NEGATE; } 1310bf215546Sopenharmony_ci| T_ABS { rflags.flags |= IR3_REG_ABS; } 1311bf215546Sopenharmony_ci| T_R { rflags.flags |= IR3_REG_R; } 1312bf215546Sopenharmony_ci 1313bf215546Sopenharmony_cisrc_reg_flags: src_reg_flag 1314bf215546Sopenharmony_ci| src_reg_flag src_reg_flags 1315bf215546Sopenharmony_ci 1316bf215546Sopenharmony_cisrc_reg: src 1317bf215546Sopenharmony_ci| src_reg_flags src 1318bf215546Sopenharmony_ci 1319bf215546Sopenharmony_cisrc_reg_gpr: src_reg 1320bf215546Sopenharmony_ci| relative_gpr_src 1321bf215546Sopenharmony_ci 1322bf215546Sopenharmony_cisrc_const: const 1323bf215546Sopenharmony_ci| src_reg_flags const 1324bf215546Sopenharmony_ci 1325bf215546Sopenharmony_cisrc_reg_or_const: src_reg 1326bf215546Sopenharmony_ci| src_const 1327bf215546Sopenharmony_ci 1328bf215546Sopenharmony_cisrc_reg_or_const_or_rel: src_reg_or_const 1329bf215546Sopenharmony_ci| relative 1330bf215546Sopenharmony_ci| src_reg_flags relative 1331bf215546Sopenharmony_ci 1332bf215546Sopenharmony_cisrc_reg_or_const_or_rel_or_imm: src_reg_or_const_or_rel 1333bf215546Sopenharmony_ci| src_reg_flags immediate 1334bf215546Sopenharmony_ci| immediate 1335bf215546Sopenharmony_ci 1336bf215546Sopenharmony_cisrc_reg_or_rel_or_imm: src_reg 1337bf215546Sopenharmony_ci| relative 1338bf215546Sopenharmony_ci| immediate 1339bf215546Sopenharmony_ci 1340bf215546Sopenharmony_cioffset: { $$ = 0; } 1341bf215546Sopenharmony_ci| '+' integer { $$ = $2; } 1342bf215546Sopenharmony_ci| '-' integer { $$ = -$2; } 1343bf215546Sopenharmony_ci 1344bf215546Sopenharmony_cirelative_gpr_src: 'r' '<' T_A0 offset '>' { new_src(0, IR3_REG_RELATIV)->array.offset = $4; } 1345bf215546Sopenharmony_ci| T_HR '<' T_A0 offset '>' { new_src(0, IR3_REG_RELATIV | IR3_REG_HALF)->array.offset = $4; } 1346bf215546Sopenharmony_ci 1347bf215546Sopenharmony_cirelative_gpr_dst: 'r' '<' T_A0 offset '>' { new_dst(0, IR3_REG_RELATIV)->array.offset = $4; } 1348bf215546Sopenharmony_ci| T_HR '<' T_A0 offset '>' { new_dst(0, IR3_REG_RELATIV | IR3_REG_HALF)->array.offset = $4; } 1349bf215546Sopenharmony_ci 1350bf215546Sopenharmony_cirelative_const: 'c' '<' T_A0 offset '>' { new_src(0, IR3_REG_RELATIV | IR3_REG_CONST)->array.offset = $4; } 1351bf215546Sopenharmony_ci| T_HC '<' T_A0 offset '>' { new_src(0, IR3_REG_RELATIV | IR3_REG_CONST | IR3_REG_HALF)->array.offset = $4; } 1352bf215546Sopenharmony_ci 1353bf215546Sopenharmony_cirelative: relative_gpr_src 1354bf215546Sopenharmony_ci| relative_const 1355bf215546Sopenharmony_ci 1356bf215546Sopenharmony_ci/* cat1 immediates differ slighly in the floating point case from the cat2 1357bf215546Sopenharmony_ci * case which can only encode certain predefined values (ie. and index into 1358bf215546Sopenharmony_ci * the FLUT table) 1359bf215546Sopenharmony_ci */ 1360bf215546Sopenharmony_ciimmediate_cat1: integer { new_src(0, IR3_REG_IMMED)->iim_val = type_size(instr->cat1.src_type) < 32 ? $1 & 0xffff : $1; } 1361bf215546Sopenharmony_ci| '(' integer ')' { new_src(0, IR3_REG_IMMED)->fim_val = $2; } 1362bf215546Sopenharmony_ci| '(' float ')' { new_src(0, IR3_REG_IMMED)->fim_val = $2; } 1363bf215546Sopenharmony_ci| 'h' '(' integer ')' { new_src(0, IR3_REG_IMMED | IR3_REG_HALF)->iim_val = $3 & 0xffff; } 1364bf215546Sopenharmony_ci| 'h' '(' float ')' { new_src(0, IR3_REG_IMMED | IR3_REG_HALF)->uim_val = _mesa_float_to_half($3); } 1365bf215546Sopenharmony_ci| '(' T_NAN ')' { new_src(0, IR3_REG_IMMED)->fim_val = NAN; } 1366bf215546Sopenharmony_ci| '(' T_INF ')' { new_src(0, IR3_REG_IMMED)->fim_val = INFINITY; } 1367bf215546Sopenharmony_ci 1368bf215546Sopenharmony_ciimmediate: integer { new_src(0, IR3_REG_IMMED)->iim_val = $1; } 1369bf215546Sopenharmony_ci| '(' integer ')' { new_src(0, IR3_REG_IMMED)->fim_val = $2; } 1370bf215546Sopenharmony_ci| flut_immed { new_src(0, IR3_REG_IMMED)->uim_val = $1; } 1371bf215546Sopenharmony_ci| 'h' '(' integer ')' { new_src(0, IR3_REG_IMMED | IR3_REG_HALF)->iim_val = $3; } 1372bf215546Sopenharmony_ci| 'h' flut_immed { new_src(0, IR3_REG_IMMED | IR3_REG_HALF)->uim_val = $2; } 1373bf215546Sopenharmony_ci 1374bf215546Sopenharmony_ci/* Float LUT values accepted as immed: */ 1375bf215546Sopenharmony_ciflut_immed: T_FLUT_0_0 1376bf215546Sopenharmony_ci| T_FLUT_0_5 1377bf215546Sopenharmony_ci| T_FLUT_1_0 1378bf215546Sopenharmony_ci| T_FLUT_2_0 1379bf215546Sopenharmony_ci| T_FLUT_E 1380bf215546Sopenharmony_ci| T_FLUT_PI 1381bf215546Sopenharmony_ci| T_FLUT_INV_PI 1382bf215546Sopenharmony_ci| T_FLUT_INV_LOG2_E 1383bf215546Sopenharmony_ci| T_FLUT_LOG2_E 1384bf215546Sopenharmony_ci| T_FLUT_INV_LOG2_10 1385bf215546Sopenharmony_ci| T_FLUT_LOG2_10 1386bf215546Sopenharmony_ci| T_FLUT_4_0 1387bf215546Sopenharmony_ci 1388bf215546Sopenharmony_ciinteger: T_INT { $$ = $1; } 1389bf215546Sopenharmony_ci| '-' T_INT { $$ = -$2; } 1390bf215546Sopenharmony_ci| T_HEX { $$ = $1; } 1391bf215546Sopenharmony_ci| '-' T_HEX { $$ = -$2; } 1392bf215546Sopenharmony_ci 1393bf215546Sopenharmony_cifloat: T_FLOAT { $$ = $1; } 1394bf215546Sopenharmony_ci| '-' T_FLOAT { $$ = -$2; } 1395bf215546Sopenharmony_ci 1396bf215546Sopenharmony_citype: T_TYPE_F16 { $$ = TYPE_F16; } 1397bf215546Sopenharmony_ci| T_TYPE_F32 { $$ = TYPE_F32; } 1398bf215546Sopenharmony_ci| T_TYPE_U16 { $$ = TYPE_U16; } 1399bf215546Sopenharmony_ci| T_TYPE_U32 { $$ = TYPE_U32; } 1400bf215546Sopenharmony_ci| T_TYPE_S16 { $$ = TYPE_S16; } 1401bf215546Sopenharmony_ci| T_TYPE_S32 { $$ = TYPE_S32; } 1402bf215546Sopenharmony_ci| T_TYPE_U8 { $$ = TYPE_U8; } 1403bf215546Sopenharmony_ci| T_TYPE_S8 { $$ = TYPE_S8; } 1404