1 /*
2 * Copyright (c) 2013 Rob Clark <robclark@freedesktop.org>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 %{
25 #include <stdlib.h>
26 #include "util/ralloc.h"
27 #include "ir3/ir3.h"
28 #include "ir3_parser.h"
29
30 #define YY_NO_INPUT
31 #define YY_NO_UNPUT
32 #define TOKEN(t) (ir3_yylval.tok = t)
33 extern YYSTYPE ir3_yylval;
34 extern void *ir3_parser_dead_ctx;
35 extern char *current_line;
36
37 const char *input_buffer = NULL;
38 size_t input_buffer_len = 256;
39
40 /**
41 * Return up to max_size chars from the current input_buffer. Reads a new
42 * line into the input_buffer if it is currently empty.
43 */
yy_input(char * buf,size_t max_size)44 static size_t yy_input(char *buf, size_t max_size)
45 {
46 if (!input_buffer)
47 current_line = malloc(input_buffer_len);
48
49 if (!input_buffer || !strlen(input_buffer)) {
50 if (getline(¤t_line, &input_buffer_len, ir3_yyin) < 0) {
51 if (ferror(ir3_yyin))
52 fprintf(stderr, "Could not read input:\n");
53 } else {
54 input_buffer = current_line;
55 }
56 }
57
58 size_t to_copy = MIN2(max_size, strlen(input_buffer));
59 memcpy(buf, input_buffer, to_copy);
60 input_buffer += to_copy;
61
62 return to_copy;
63 }
64
65 #define YY_INPUT(buf, result, max_size) \
66 result = yy_input(buf, max_size);
67
68
69 void ir3_yyset_input(FILE *f);
70
ir3_yyset_input(FILE * f)71 void ir3_yyset_input(FILE *f)
72 {
73 YY_FLUSH_BUFFER;
74 ir3_yyin = f;
75 if (input_buffer)
76 input_buffer = "";
77 }
78
parse_wrmask(const char * src)79 static int parse_wrmask(const char *src)
80 {
81 int i, num = 0;
82 for (i = 0; i < 4; i++) {
83 if ("xyzw"[i] == src[1]) {
84 num |= (1 << i);
85 src++;
86 }
87 }
88 return num;
89 }
90
parse_reg(const char * str)91 static int parse_reg(const char *str)
92 {
93 int num = 0;
94 if (str[0] == 'h') {
95 str++;
96 num++;
97 }
98 str++;
99 num += strtol(str, (char **)&str, 10) << 3;
100 switch (str[1]) {
101 case 'x': num += 0; break;
102 case 'y': num += 2; break;
103 case 'z': num += 4; break;
104 case 'w': num += 6; break;
105 default: assert(0); break;
106 }
107 return num;
108 }
109
110 %}
111
112 %option noyywrap
113 %option prefix="ir3_yy"
114
115 %%
116 "\n" yylineno++;
117 [ \t] ; /* ignore whitespace */
118 ";"[^\n]*"\n" yylineno++; /* ignore comments */
119 "(0.0)" ir3_yylval.num = 0; return T_FLUT_0_0;
120 "(0.5)" ir3_yylval.num = 1; return T_FLUT_0_5;
121 "(1.0)" ir3_yylval.num = 2; return T_FLUT_1_0;
122 "(2.0)" ir3_yylval.num = 3; return T_FLUT_2_0;
123 "(e)" ir3_yylval.num = 4; return T_FLUT_E;
124 "(pi)" ir3_yylval.num = 5; return T_FLUT_PI;
125 "(1/pi)" ir3_yylval.num = 6; return T_FLUT_INV_PI;
126 "(1/log2(e))" ir3_yylval.num = 7; return T_FLUT_INV_LOG2_E;
127 "(log2(e))" ir3_yylval.num = 8; return T_FLUT_LOG2_E;
128 "(1/log2(10))" ir3_yylval.num = 9; return T_FLUT_INV_LOG2_10;
129 "(log2(10))" ir3_yylval.num = 10; return T_FLUT_LOG2_10;
130 "(4.0)" ir3_yylval.num = 11; return T_FLUT_4_0;
131 [0-9]+"."[0-9]+ ir3_yylval.flt = strtod(yytext, NULL); return T_FLOAT;
132 [0-9]* ir3_yylval.num = strtoul(yytext, NULL, 0); return T_INT;
133 "0x"[0-9a-fA-F]* ir3_yylval.num = strtoul(yytext, NULL, 0); return T_HEX;
134 "raw 0x"[0-9a-fA-F]* ir3_yylval.u64 = strtoull(yytext + 4, NULL, 0); return T_RAW;
135 "@localsize" return TOKEN(T_A_LOCALSIZE);
136 "@const" return TOKEN(T_A_CONST);
137 "@buf" return TOKEN(T_A_BUF);
138 "@invocationid" return TOKEN(T_A_INVOCATIONID);
139 "@wgid" return TOKEN(T_A_WGID);
140 "@numwg" return TOKEN(T_A_NUMWG);
141 "@branchstack" return TOKEN(T_A_BRANCHSTACK);
142 "@in" return TOKEN(T_A_IN);
143 "@out" return TOKEN(T_A_OUT);
144 "@tex" return TOKEN(T_A_TEX);
145 "@pvtmem" return TOKEN(T_A_PVTMEM);
146 "@localmem" return TOKEN(T_A_LOCALMEM);
147 "@earlypreamble" return TOKEN(T_A_EARLYPREAMBLE);
148 "@fullnopstart" return TOKEN(T_A_FULLNOPSTART);
149 "@fullnopend" return TOKEN(T_A_FULLNOPEND);
150 "@fullsyncstart" return TOKEN(T_A_FULLSYNCSTART);
151 "@fullsyncend" return TOKEN(T_A_FULLSYNCEND);
152 "(sy)" return TOKEN(T_SY);
153 "(ss)" return TOKEN(T_SS);
154 "(absneg)" return TOKEN(T_ABSNEG);
155 "(neg)" return TOKEN(T_NEG);
156 "(abs)" return TOKEN(T_ABS);
157 "(r)" return TOKEN(T_R);
158 "(last)" return TOKEN(T_LAST);
159 "(ul)" return TOKEN(T_UL);
160 "(even)" return TOKEN(T_EVEN);
161 "(pos_infinity)" return TOKEN(T_POS_INFINITY);
162 "(neg_infinity)" return TOKEN(T_NEG_INFINITY);
163 "(ei)" return TOKEN(T_EI);
164 "(jp)" return TOKEN(T_JP);
165 "(eq)" return TOKEN(T_EQ_FLAG);
166 "(sat)" return TOKEN(T_SAT);
167 "(rpt"[0-7]")" ir3_yylval.num = strtol(yytext+4, NULL, 10); return T_RPT;
168 "(nop"[0-7]")" ir3_yylval.num = strtol(yytext+4, NULL, 10); return T_NOP;
169 "("[x]?[y]?[z]?[w]?")" ir3_yylval.num = parse_wrmask(yytext); return T_WRMASK;
170
171 [h]?"r"[0-9]+"."[xyzw] ir3_yylval.num = parse_reg(yytext); return T_REGISTER;
172 [h]?"c"[0-9]+"."[xyzw] ir3_yylval.num = parse_reg(yytext); return T_CONSTANT;
173 "a0.x" return T_A0;
174 "a1.x" return T_A1;
175 "p0."[xyzw] ir3_yylval.num = parse_reg(yytext); return T_P0;
176 "w"[0-9]+ ir3_yylval.num = strtol(yytext+1, NULL, 10); return T_W;
177 "s#"[0-9]+ ir3_yylval.num = strtol(yytext+2, NULL, 10); return T_SAMP;
178 "t#"[0-9]+ ir3_yylval.num = strtol(yytext+2, NULL, 10); return T_TEX;
179
180 /* category 0: */
181 "nop" return TOKEN(T_OP_NOP);
182 "br" return TOKEN(T_OP_BR);
183 "brao" return TOKEN(T_OP_BRAO);
184 "braa" return TOKEN(T_OP_BRAA);
185 "brac" return TOKEN(T_OP_BRAC);
186 "bany" return TOKEN(T_OP_BANY);
187 "ball" return TOKEN(T_OP_BALL);
188 "brax" return TOKEN(T_OP_BRAX);
189 "jump" return TOKEN(T_OP_JUMP);
190 "call" return TOKEN(T_OP_CALL);
191 "ret" return TOKEN(T_OP_RET);
192 "kill" return TOKEN(T_OP_KILL);
193 "end" return TOKEN(T_OP_END);
194 "emit" return TOKEN(T_OP_EMIT);
195 "cut" return TOKEN(T_OP_CUT);
196 "chmask" return TOKEN(T_OP_CHMASK);
197 "chsh" return TOKEN(T_OP_CHSH);
198 "flow_rev" return TOKEN(T_OP_FLOW_REV);
199 "bkt" return TOKEN(T_OP_BKT);
200 "stks" return TOKEN(T_OP_STKS);
201 "stkr" return TOKEN(T_OP_STKR);
202 "xset" return TOKEN(T_OP_XSET);
203 "xclr" return TOKEN(T_OP_XCLR);
204 "getlast" return TOKEN(T_OP_GETLAST);
205 "getone" return TOKEN(T_OP_GETONE);
206 "dbg" return TOKEN(T_OP_DBG);
207 "shps" return TOKEN(T_OP_SHPS);
208 "shpe" return TOKEN(T_OP_SHPE);
209 "predt" return TOKEN(T_OP_PREDT);
210 "predf" return TOKEN(T_OP_PREDF);
211 "prede" return TOKEN(T_OP_PREDE);
212
213 /* category 1: */
214 "movmsk" return TOKEN(T_OP_MOVMSK);
215 "mova1" return TOKEN(T_OP_MOVA1);
216 "mova" return TOKEN(T_OP_MOVA);
217 "mov" return TOKEN(T_OP_MOV);
218 "cov" return TOKEN(T_OP_COV);
219 "swz" return TOKEN(T_OP_SWZ);
220 "gat" return TOKEN(T_OP_GAT);
221 "sct" return TOKEN(T_OP_SCT);
222
223 ("f16"|"f32"|"u16"|"u32"|"s16"|"s32"|"u8"|"u8_32"|"u64"){2} ir3_yylval.str = yytext; return T_CAT1_TYPE_TYPE;
224 /* category 2: */
225 "add.f" return TOKEN(T_OP_ADD_F);
226 "min.f" return TOKEN(T_OP_MIN_F);
227 "max.f" return TOKEN(T_OP_MAX_F);
228 "mul.f" return TOKEN(T_OP_MUL_F);
229 "sign.f" return TOKEN(T_OP_SIGN_F);
230 "cmps.f" return TOKEN(T_OP_CMPS_F);
231 "absneg.f" return TOKEN(T_OP_ABSNEG_F);
232 "cmpv.f" return TOKEN(T_OP_CMPV_F);
233 "floor.f" return TOKEN(T_OP_FLOOR_F);
234 "ceil.f" return TOKEN(T_OP_CEIL_F);
235 "rndne.f" return TOKEN(T_OP_RNDNE_F);
236 "rndaz.f" return TOKEN(T_OP_RNDAZ_F);
237 "trunc.f" return TOKEN(T_OP_TRUNC_F);
238 "add.u" return TOKEN(T_OP_ADD_U);
239 "add.s" return TOKEN(T_OP_ADD_S);
240 "sub.u" return TOKEN(T_OP_SUB_U);
241 "sub.s" return TOKEN(T_OP_SUB_S);
242 "cmps.u" return TOKEN(T_OP_CMPS_U);
243 "cmps.s" return TOKEN(T_OP_CMPS_S);
244 "min.u" return TOKEN(T_OP_MIN_U);
245 "min.s" return TOKEN(T_OP_MIN_S);
246 "max.u" return TOKEN(T_OP_MAX_U);
247 "max.s" return TOKEN(T_OP_MAX_S);
248 "absneg.s" return TOKEN(T_OP_ABSNEG_S);
249 "and.b" return TOKEN(T_OP_AND_B);
250 "or.b" return TOKEN(T_OP_OR_B);
251 "not.b" return TOKEN(T_OP_NOT_B);
252 "xor.b" return TOKEN(T_OP_XOR_B);
253 "cmpv.u" return TOKEN(T_OP_CMPV_U);
254 "cmpv.s" return TOKEN(T_OP_CMPV_S);
255 "mul.u24" return TOKEN(T_OP_MUL_U24);
256 "mul.s24" return TOKEN(T_OP_MUL_S24);
257 "mull.u" return TOKEN(T_OP_MULL_U);
258 "bfrev.b" return TOKEN(T_OP_BFREV_B);
259 "clz.s" return TOKEN(T_OP_CLZ_S);
260 "clz.b" return TOKEN(T_OP_CLZ_B);
261 "shl.b" return TOKEN(T_OP_SHL_B);
262 "shr.b" return TOKEN(T_OP_SHR_B);
263 "ashr.b" return TOKEN(T_OP_ASHR_B);
264 "bary.f" return TOKEN(T_OP_BARY_F);
265 "flat.b" return TOKEN(T_OP_FLAT_B);
266 "mgen.b" return TOKEN(T_OP_MGEN_B);
267 "getbit.b" return TOKEN(T_OP_GETBIT_B);
268 "setrm" return TOKEN(T_OP_SETRM);
269 "cbits.b" return TOKEN(T_OP_CBITS_B);
270 "shb" return TOKEN(T_OP_SHB);
271 "msad" return TOKEN(T_OP_MSAD);
272
273 /* category 3: */
274 "mad.u16" return TOKEN(T_OP_MAD_U16);
275 "madsh.u16" return TOKEN(T_OP_MADSH_U16);
276 "mad.s16" return TOKEN(T_OP_MAD_S16);
277 "madsh.m16" return TOKEN(T_OP_MADSH_M16);
278 "mad.u24" return TOKEN(T_OP_MAD_U24);
279 "mad.s24" return TOKEN(T_OP_MAD_S24);
280 "mad.f16" return TOKEN(T_OP_MAD_F16);
281 "mad.f32" return TOKEN(T_OP_MAD_F32);
282 "sel.b16" return TOKEN(T_OP_SEL_B16);
283 "sel.b32" return TOKEN(T_OP_SEL_B32);
284 "sel.s16" return TOKEN(T_OP_SEL_S16);
285 "sel.s32" return TOKEN(T_OP_SEL_S32);
286 "sel.f16" return TOKEN(T_OP_SEL_F16);
287 "sel.f32" return TOKEN(T_OP_SEL_F32);
288 "sad.s16" return TOKEN(T_OP_SAD_S16);
289 "sad.s32" return TOKEN(T_OP_SAD_S32);
290 "shrm" return TOKEN(T_OP_SHRM);
291 "shlm" return TOKEN(T_OP_SHLM);
292 "shrg" return TOKEN(T_OP_SHRG);
293 "shlg" return TOKEN(T_OP_SHLG);
294 "andg" return TOKEN(T_OP_ANDG);
295 "dp2acc" return TOKEN(T_OP_DP2ACC);
296 "dp4acc" return TOKEN(T_OP_DP4ACC);
297 "wmm" return TOKEN(T_OP_WMM);
298 "wmm.accu" return TOKEN(T_OP_WMM_ACCU);
299
300 /* category 4: */
301 "rcp" return TOKEN(T_OP_RCP);
302 "rsq" return TOKEN(T_OP_RSQ);
303 "log2" return TOKEN(T_OP_LOG2);
304 "exp2" return TOKEN(T_OP_EXP2);
305 "sin" return TOKEN(T_OP_SIN);
306 "cos" return TOKEN(T_OP_COS);
307 "sqrt" return TOKEN(T_OP_SQRT);
308 "hrsq" return TOKEN(T_OP_HRSQ);
309 "hlog2" return TOKEN(T_OP_HLOG2);
310 "hexp2" return TOKEN(T_OP_HEXP2);
311
312 /* category 5: */
313 "isam" return TOKEN(T_OP_ISAM);
314 "isaml" return TOKEN(T_OP_ISAML);
315 "isamm" return TOKEN(T_OP_ISAMM);
316 "sam" return TOKEN(T_OP_SAM);
317 "samb" return TOKEN(T_OP_SAMB);
318 "saml" return TOKEN(T_OP_SAML);
319 "samgq" return TOKEN(T_OP_SAMGQ);
320 "getlod" return TOKEN(T_OP_GETLOD);
321 "conv" return TOKEN(T_OP_CONV);
322 "convm" return TOKEN(T_OP_CONVM);
323 "getsize" return TOKEN(T_OP_GETSIZE);
324 "getbuf" return TOKEN(T_OP_GETBUF);
325 "getpos" return TOKEN(T_OP_GETPOS);
326 "getinfo" return TOKEN(T_OP_GETINFO);
327 "dsx" return TOKEN(T_OP_DSX);
328 "dsy" return TOKEN(T_OP_DSY);
329 "gather4r" return TOKEN(T_OP_GATHER4R);
330 "gather4g" return TOKEN(T_OP_GATHER4G);
331 "gather4b" return TOKEN(T_OP_GATHER4B);
332 "gather4a" return TOKEN(T_OP_GATHER4A);
333 "samgp0" return TOKEN(T_OP_SAMGP0);
334 "samgp1" return TOKEN(T_OP_SAMGP1);
335 "samgp2" return TOKEN(T_OP_SAMGP2);
336 "samgp3" return TOKEN(T_OP_SAMGP3);
337 "dsxpp.1" return TOKEN(T_OP_DSXPP_1);
338 "dsypp.1" return TOKEN(T_OP_DSYPP_1);
339 "rgetpos" return TOKEN(T_OP_RGETPOS);
340 "rgetinfo" return TOKEN(T_OP_RGETINFO);
341 "brcst.active" return TOKEN(T_OP_BRCST_A);
342 "quad_shuffle.brcst" return TOKEN(T_OP_QSHUFFLE_BRCST);
343 "quad_shuffle.horiz" return TOKEN(T_OP_QSHUFFLE_H);
344 "quad_shuffle.vert" return TOKEN(T_OP_QSHUFFLE_V);
345 "quad_shuffle.diag" return TOKEN(T_OP_QSHUFFLE_DIAG);
346 "tcinv" return TOKEN(T_OP_TCINV);
347
348 /* category 6: */
349 "ldg" return TOKEN(T_OP_LDG);
350 "ldg.a" return TOKEN(T_OP_LDG_A);
351 "ldg.k" return TOKEN(T_OP_LDG_K);
352 "ldl" return TOKEN(T_OP_LDL);
353 "ldp" return TOKEN(T_OP_LDP);
354 "stg" return TOKEN(T_OP_STG);
355 "stg.a" return TOKEN(T_OP_STG_A);
356 "stl" return TOKEN(T_OP_STL);
357 "stp" return TOKEN(T_OP_STP);
358 "ldib" return TOKEN(T_OP_LDIB);
359 "g2l" return TOKEN(T_OP_G2L);
360 "l2g" return TOKEN(T_OP_L2G);
361 "prefetch" return TOKEN(T_OP_PREFETCH);
362 "ldlw" return TOKEN(T_OP_LDLW);
363 "stlw" return TOKEN(T_OP_STLW);
364 "resfmt" return TOKEN(T_OP_RESFMT);
365 "resinfo" return TOKEN(T_OP_RESINFO);
366 "atomic.add" return TOKEN(T_OP_ATOMIC_ADD);
367 "atomic.sub" return TOKEN(T_OP_ATOMIC_SUB);
368 "atomic.xchg" return TOKEN(T_OP_ATOMIC_XCHG);
369 "atomic.inc" return TOKEN(T_OP_ATOMIC_INC);
370 "atomic.dec" return TOKEN(T_OP_ATOMIC_DEC);
371 "atomic.cmpxchg" return TOKEN(T_OP_ATOMIC_CMPXCHG);
372 "atomic.min" return TOKEN(T_OP_ATOMIC_MIN);
373 "atomic.max" return TOKEN(T_OP_ATOMIC_MAX);
374 "atomic.and" return TOKEN(T_OP_ATOMIC_AND);
375 "atomic.or" return TOKEN(T_OP_ATOMIC_OR);
376 "atomic.xor" return TOKEN(T_OP_ATOMIC_XOR);
377 "resinfo.b" return TOKEN(T_OP_RESINFO_B);
378 "ldib.b" return TOKEN(T_OP_LDIB_B);
379 "stib.b" return TOKEN(T_OP_STIB_B);
380 "atomic.b.add" return TOKEN(T_OP_ATOMIC_B_ADD);
381 "atomic.b.sub" return TOKEN(T_OP_ATOMIC_B_SUB);
382 "atomic.b.xchg" return TOKEN(T_OP_ATOMIC_B_XCHG);
383 "atomic.b.inc" return TOKEN(T_OP_ATOMIC_B_INC);
384 "atomic.b.dec" return TOKEN(T_OP_ATOMIC_B_DEC);
385 "atomic.b.cmpxchg" return TOKEN(T_OP_ATOMIC_B_CMPXCHG);
386 "atomic.b.min" return TOKEN(T_OP_ATOMIC_B_MIN);
387 "atomic.b.max" return TOKEN(T_OP_ATOMIC_B_MAX);
388 "atomic.b.and" return TOKEN(T_OP_ATOMIC_B_AND);
389 "atomic.b.or" return TOKEN(T_OP_ATOMIC_B_OR);
390 "atomic.b.xor" return TOKEN(T_OP_ATOMIC_B_XOR);
391 "atomic.s.add" return TOKEN(T_OP_ATOMIC_S_ADD);
392 "atomic.s.sub" return TOKEN(T_OP_ATOMIC_S_SUB);
393 "atomic.s.xchg" return TOKEN(T_OP_ATOMIC_S_XCHG);
394 "atomic.s.inc" return TOKEN(T_OP_ATOMIC_S_INC);
395 "atomic.s.dec" return TOKEN(T_OP_ATOMIC_S_DEC);
396 "atomic.s.cmpxchg" return TOKEN(T_OP_ATOMIC_S_CMPXCHG);
397 "atomic.s.min" return TOKEN(T_OP_ATOMIC_S_MIN);
398 "atomic.s.max" return TOKEN(T_OP_ATOMIC_S_MAX);
399 "atomic.s.and" return TOKEN(T_OP_ATOMIC_S_AND);
400 "atomic.s.or" return TOKEN(T_OP_ATOMIC_S_OR);
401 "atomic.s.xor" return TOKEN(T_OP_ATOMIC_S_XOR);
402 "atomic.g.add" return TOKEN(T_OP_ATOMIC_G_ADD);
403 "atomic.g.sub" return TOKEN(T_OP_ATOMIC_G_SUB);
404 "atomic.g.xchg" return TOKEN(T_OP_ATOMIC_G_XCHG);
405 "atomic.g.inc" return TOKEN(T_OP_ATOMIC_G_INC);
406 "atomic.g.dec" return TOKEN(T_OP_ATOMIC_G_DEC);
407 "atomic.g.cmpxchg" return TOKEN(T_OP_ATOMIC_G_CMPXCHG);
408 "atomic.g.min" return TOKEN(T_OP_ATOMIC_G_MIN);
409 "atomic.g.max" return TOKEN(T_OP_ATOMIC_G_MAX);
410 "atomic.g.and" return TOKEN(T_OP_ATOMIC_G_AND);
411 "atomic.g.or" return TOKEN(T_OP_ATOMIC_G_OR);
412 "atomic.g.xor" return TOKEN(T_OP_ATOMIC_G_XOR);
413
414 "ldgb" return TOKEN(T_OP_LDGB);
415 "stgb" return TOKEN(T_OP_STGB);
416 "stib" return TOKEN(T_OP_STIB);
417 "ldc" return TOKEN(T_OP_LDC);
418 "ldlv" return TOKEN(T_OP_LDLV);
419 "getspid" return TOKEN(T_OP_GETSPID);
420 "getwid" return TOKEN(T_OP_GETWID);
421 "getfiberid" return TOKEN(T_OP_GETFIBERID);
422 "stc" return TOKEN(T_OP_STC);
423 "stsc" return TOKEN(T_OP_STSC);
424 "shfl" return TOKEN(T_OP_SHFL);
425
426 ("b16"|"b32"){1} ir3_yylval.str = yytext; return T_INSTR_TYPE;
427
428 /* category 7: */
429 "bar" return TOKEN(T_OP_BAR);
430 "fence" return TOKEN(T_OP_FENCE);
431 "sleep.l" return TOKEN(T_OP_SLEEP);
432 "icinv" return TOKEN(T_OP_ICINV);
433 "dccln.all" return TOKEN(T_OP_DCCLN);
434 "dcinv.all" return TOKEN(T_OP_DCINV);
435 "dcflu.all" return TOKEN(T_OP_DCFLU);
436 "ccinv" return TOKEN(T_OP_CCINV);
437 "lock" return TOKEN(T_OP_LOCK);
438 "unlock" return TOKEN(T_OP_UNLOCK);
439 "alias" return TOKEN(T_OP_ALIAS);
440
441 "print" return TOKEN(T_OP_PRINT);
442
443 "f16" return TOKEN(T_TYPE_F16);
444 "f32" return TOKEN(T_TYPE_F32);
445 "u16" return TOKEN(T_TYPE_U16);
446 "u32" return TOKEN(T_TYPE_U32);
447 "s16" return TOKEN(T_TYPE_S16);
448 "s32" return TOKEN(T_TYPE_S32);
449 "u8" return TOKEN(T_TYPE_U8);
450 "u8_32" return TOKEN(T_TYPE_U8_32);
451 "u64" return TOKEN(T_TYPE_U64);
452
453 "untyped" return TOKEN(T_UNTYPED);
454 "typed" return TOKEN(T_TYPED);
455
456 "unsigned" return TOKEN(T_UNSIGNED);
457 "mixed" return TOKEN(T_MIXED);
458 "low" return TOKEN(T_LOW);
459 "high" return TOKEN(T_HIGH);
460
461 "1d" return TOKEN(T_1D);
462 "2d" return TOKEN(T_2D);
463 "3d" return TOKEN(T_3D);
464 "4d" return TOKEN(T_4D);
465
466 "lt" return TOKEN(T_LT);
467 "le" return TOKEN(T_LE);
468 "gt" return TOKEN(T_GT);
469 "ge" return TOKEN(T_GE);
470 "eq" return TOKEN(T_EQ);
471 "ne" return TOKEN(T_NE);
472
473 "a" return 'a';
474 "o" return 'o';
475 "p" return 'p';
476 "s2en" return TOKEN(T_S2EN);
477 "s" return 's';
478 "k" return 'k';
479 "u" return 'u';
480 "v" return 'v';
481 "base"[0-9]+ ir3_yylval.num = strtol(yytext+4, NULL, 10); return T_BASE;
482 "offset"[0-9]+ ir3_yylval.num = strtol(yytext+6, NULL, 10); return T_OFFSET;
483 "uniform" return T_UNIFORM;
484 "nonuniform" return T_NONUNIFORM;
485 "imm" return T_IMM;
486
487 "tex" return T_MOD_TEX;
488 "mem" return T_MOD_MEM;
489 "rt" return T_MOD_RT;
490
491 "xor" return T_MOD_XOR;
492 "up" return T_MOD_UP;
493 "down" return T_MOD_DOWN;
494 "rup" return T_MOD_RUP;
495 "rdown" return T_MOD_RDOWN;
496
497 "h" return 'h';
498 "=" return '=';
499 "(" return '(';
500 ")" return ')';
501 "[" return '[';
502 "]" return ']';
503 "," return ',';
504 "." return '.';
505 "-" return '-';
506 "+" return '+';
507 "|" return '|';
508 "c" return 'c';
509 "r" return 'r';
510 "hc" return TOKEN(T_HC);
511 "hr" return TOKEN(T_HR);
512 "g" return 'g';
513 "w" return 'w';
514 "l" return 'l';
515 "<" return '<';
516 ">" return '>';
517 "!" return '!';
518 "#" return '#';
519 ":" return ':';
520
521 "nan" return TOKEN(T_NAN);
522 "inf" return TOKEN(T_INF);
523
524 [a-zA-Z_][a-zA-Z_0-9]* ir3_yylval.str = ralloc_strdup(ir3_parser_dead_ctx, yytext); return T_IDENTIFIER;
525 . fprintf(stderr, "error at line %d: Unknown token: %s\n", ir3_yyget_lineno(), yytext); yyterminate();
526 %%
527