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 
36 void ir3_yyset_input(FILE *f);
37 
ir3_yyset_input(FILE * f)38 void ir3_yyset_input(FILE *f)
39 {
40 	YY_FLUSH_BUFFER;
41 	ir3_yyin = f;
42 }
43 
parse_wrmask(const char * src)44 static int parse_wrmask(const char *src)
45 {
46 	int i, num = 0;
47 	for (i = 0; i < 4; i++) {
48 		if ("xyzw"[i] == src[1]) {
49 			num |= (1 << i);
50 			src++;
51 		}
52 	}
53 	return num;
54 }
55 
parse_reg(const char * str)56 static int parse_reg(const char *str)
57 {
58 	int num = 0;
59 	if (str[0] == 'h') {
60 		str++;
61 		num++;
62 	}
63 	str++;
64 	num += strtol(str, (char **)&str, 10) << 3;
65 	switch (str[1]) {
66 	case 'x': num += 0; break;
67 	case 'y': num += 2; break;
68 	case 'z': num += 4; break;
69 	case 'w': num += 6; break;
70 	default: assert(0); break;
71 	}
72 	return num;
73 }
74 
75 %}
76 
77 %option noyywrap
78 %option prefix="ir3_yy"
79 
80 %%
81 "\n"                              yylineno++;
82 [ \t]                             ; /* ignore whitespace */
83 ";"[^\n]*"\n"                     yylineno++; /* ignore comments */
84 "(0.0)"                           ir3_yylval.num = 0;  return T_FLUT_0_0;
85 "(0.5)"                           ir3_yylval.num = 1;  return T_FLUT_0_5;
86 "(1.0)"                           ir3_yylval.num = 2;  return T_FLUT_1_0;
87 "(2.0)"                           ir3_yylval.num = 3;  return T_FLUT_2_0;
88 "(e)"                             ir3_yylval.num = 4;  return T_FLUT_E;
89 "(pi)"                            ir3_yylval.num = 5;  return T_FLUT_PI;
90 "(1/pi)"                          ir3_yylval.num = 6;  return T_FLUT_INV_PI;
91 "(1/log2(e))"                     ir3_yylval.num = 7;  return T_FLUT_INV_LOG2_E;
92 "(log2(e))"                       ir3_yylval.num = 8;  return T_FLUT_LOG2_E;
93 "(1/log2(10))"                    ir3_yylval.num = 9;  return T_FLUT_INV_LOG2_10;
94 "(log2(10))"                      ir3_yylval.num = 10; return T_FLUT_LOG2_10;
95 "(4.0)"                           ir3_yylval.num = 11; return T_FLUT_4_0;
96 [0-9]+"."[0-9]+                   ir3_yylval.flt = strtod(yytext, NULL);       return T_FLOAT;
97 [0-9]*                            ir3_yylval.num = strtoul(yytext, NULL, 0);    return T_INT;
98 "0x"[0-9a-fA-F]*                  ir3_yylval.num = strtoul(yytext, NULL, 0);    return T_HEX;
99 "@localsize"                      return TOKEN(T_A_LOCALSIZE);
100 "@const"                          return TOKEN(T_A_CONST);
101 "@buf"                            return TOKEN(T_A_BUF);
102 "@invocationid"                   return TOKEN(T_A_INVOCATIONID);
103 "@wgid"                           return TOKEN(T_A_WGID);
104 "@numwg"                          return TOKEN(T_A_NUMWG);
105 "@branchstack"                    return TOKEN(T_A_BRANCHSTACK);
106 "@in"                             return TOKEN(T_A_IN);
107 "@out"                            return TOKEN(T_A_OUT);
108 "@tex"                            return TOKEN(T_A_TEX);
109 "@pvtmem"                         return TOKEN(T_A_PVTMEM);
110 "(sy)"                            return TOKEN(T_SY);
111 "(ss)"                            return TOKEN(T_SS);
112 "(absneg)"                        return TOKEN(T_ABSNEG);
113 "(neg)"                           return TOKEN(T_NEG);
114 "(abs)"                           return TOKEN(T_ABS);
115 "(r)"                             return TOKEN(T_R);
116 "(ul)"                            return TOKEN(T_UL);
117 "(even)"                          return TOKEN(T_EVEN);
118 "(pos_infinity)"                  return TOKEN(T_POS_INFINITY);
119 "(neg_infinity)"                  return TOKEN(T_NEG_INFINITY);
120 "(ei)"                            return TOKEN(T_EI);
121 "(jp)"                            return TOKEN(T_JP);
122 "(sat)"                           return TOKEN(T_SAT);
123 "(rpt"[0-7]")"                    ir3_yylval.num = strtol(yytext+4, NULL, 10); return T_RPT;
124 "(nop"[0-7]")"                    ir3_yylval.num = strtol(yytext+4, NULL, 10); return T_NOP;
125 "("[x]?[y]?[z]?[w]?")"            ir3_yylval.num = parse_wrmask(yytext); return T_WRMASK;
126 
127 [h]?"r"[0-9]+"."[xyzw]            ir3_yylval.num = parse_reg(yytext); return T_REGISTER;
128 [h]?"c"[0-9]+"."[xyzw]            ir3_yylval.num = parse_reg(yytext); return T_CONSTANT;
129 "a0.x"                            return T_A0;
130 "a1.x"                            return T_A1;
131 "p0."[xyzw]                       ir3_yylval.num = parse_reg(yytext); return T_P0;
132 "w"[0-9]+                         ir3_yylval.num = strtol(yytext+1, NULL, 10); return T_W;
133 "s#"[0-9]+                        ir3_yylval.num = strtol(yytext+2, NULL, 10); return T_SAMP;
134 "t#"[0-9]+                        ir3_yylval.num = strtol(yytext+2, NULL, 10); return T_TEX;
135 
136                                   /* category 0: */
137 "nop"                             return TOKEN(T_OP_NOP);
138 "br"                              return TOKEN(T_OP_BR);
139 "brao"                            return TOKEN(T_OP_BRAO);
140 "braa"                            return TOKEN(T_OP_BRAA);
141 "brac"                            return TOKEN(T_OP_BRAC);
142 "bany"                            return TOKEN(T_OP_BANY);
143 "ball"                            return TOKEN(T_OP_BALL);
144 "brax"                            return TOKEN(T_OP_BRAX);
145 "jump"                            return TOKEN(T_OP_JUMP);
146 "call"                            return TOKEN(T_OP_CALL);
147 "ret"                             return TOKEN(T_OP_RET);
148 "kill"                            return TOKEN(T_OP_KILL);
149 "end"                             return TOKEN(T_OP_END);
150 "emit"                            return TOKEN(T_OP_EMIT);
151 "cut"                             return TOKEN(T_OP_CUT);
152 "chmask"                          return TOKEN(T_OP_CHMASK);
153 "chsh"                            return TOKEN(T_OP_CHSH);
154 "flow_rev"                        return TOKEN(T_OP_FLOW_REV);
155 "bkt"                             return TOKEN(T_OP_BKT);
156 "stks"                            return TOKEN(T_OP_STKS);
157 "stkr"                            return TOKEN(T_OP_STKR);
158 "xset"                            return TOKEN(T_OP_XSET);
159 "xclr"                            return TOKEN(T_OP_XCLR);
160 "getlast"                         return TOKEN(T_OP_GETLAST);
161 "getone"                          return TOKEN(T_OP_GETONE);
162 "dbg"                             return TOKEN(T_OP_DBG);
163 "shps"                            return TOKEN(T_OP_SHPS);
164 "shpe"                            return TOKEN(T_OP_SHPE);
165 "predt"                           return TOKEN(T_OP_PREDT);
166 "predf"                           return TOKEN(T_OP_PREDF);
167 "prede"                           return TOKEN(T_OP_PREDE);
168 
169                                   /* category 1: */
170 "movmsk"                          return TOKEN(T_OP_MOVMSK);
171 "mova1"                           return TOKEN(T_OP_MOVA1);
172 "mova"                            return TOKEN(T_OP_MOVA);
173 "mov"                             return TOKEN(T_OP_MOV);
174 "cov"                             return TOKEN(T_OP_COV);
175 "swz"                             return TOKEN(T_OP_SWZ);
176 "gat"                             return TOKEN(T_OP_GAT);
177 "sct"                             return TOKEN(T_OP_SCT);
178 
179 ("f16"|"f32"|"u16"|"u32"|"s16"|"s32"|"u8"|"s8"){2} ir3_yylval.str = yytext; return T_CAT1_TYPE_TYPE;
180 
181                                   /* category 2: */
182 "add.f"                           return TOKEN(T_OP_ADD_F);
183 "min.f"                           return TOKEN(T_OP_MIN_F);
184 "max.f"                           return TOKEN(T_OP_MAX_F);
185 "mul.f"                           return TOKEN(T_OP_MUL_F);
186 "sign.f"                          return TOKEN(T_OP_SIGN_F);
187 "cmps.f"                          return TOKEN(T_OP_CMPS_F);
188 "absneg.f"                        return TOKEN(T_OP_ABSNEG_F);
189 "cmpv.f"                          return TOKEN(T_OP_CMPV_F);
190 "floor.f"                         return TOKEN(T_OP_FLOOR_F);
191 "ceil.f"                          return TOKEN(T_OP_CEIL_F);
192 "rndne.f"                         return TOKEN(T_OP_RNDNE_F);
193 "rndaz.f"                         return TOKEN(T_OP_RNDAZ_F);
194 "trunc.f"                         return TOKEN(T_OP_TRUNC_F);
195 "add.u"                           return TOKEN(T_OP_ADD_U);
196 "add.s"                           return TOKEN(T_OP_ADD_S);
197 "sub.u"                           return TOKEN(T_OP_SUB_U);
198 "sub.s"                           return TOKEN(T_OP_SUB_S);
199 "cmps.u"                          return TOKEN(T_OP_CMPS_U);
200 "cmps.s"                          return TOKEN(T_OP_CMPS_S);
201 "min.u"                           return TOKEN(T_OP_MIN_U);
202 "min.s"                           return TOKEN(T_OP_MIN_S);
203 "max.u"                           return TOKEN(T_OP_MAX_U);
204 "max.s"                           return TOKEN(T_OP_MAX_S);
205 "absneg.s"                        return TOKEN(T_OP_ABSNEG_S);
206 "and.b"                           return TOKEN(T_OP_AND_B);
207 "or.b"                            return TOKEN(T_OP_OR_B);
208 "not.b"                           return TOKEN(T_OP_NOT_B);
209 "xor.b"                           return TOKEN(T_OP_XOR_B);
210 "cmpv.u"                          return TOKEN(T_OP_CMPV_U);
211 "cmpv.s"                          return TOKEN(T_OP_CMPV_S);
212 "mul.u24"                         return TOKEN(T_OP_MUL_U24);
213 "mul.s24"                         return TOKEN(T_OP_MUL_S24);
214 "mull.u"                          return TOKEN(T_OP_MULL_U);
215 "bfrev.b"                         return TOKEN(T_OP_BFREV_B);
216 "clz.s"                           return TOKEN(T_OP_CLZ_S);
217 "clz.b"                           return TOKEN(T_OP_CLZ_B);
218 "shl.b"                           return TOKEN(T_OP_SHL_B);
219 "shr.b"                           return TOKEN(T_OP_SHR_B);
220 "ashr.b"                          return TOKEN(T_OP_ASHR_B);
221 "bary.f"                          return TOKEN(T_OP_BARY_F);
222 "flat.b"                          return TOKEN(T_OP_FLAT_B);
223 "mgen.b"                          return TOKEN(T_OP_MGEN_B);
224 "getbit.b"                        return TOKEN(T_OP_GETBIT_B);
225 "setrm"                           return TOKEN(T_OP_SETRM);
226 "cbits.b"                         return TOKEN(T_OP_CBITS_B);
227 "shb"                             return TOKEN(T_OP_SHB);
228 "msad"                            return TOKEN(T_OP_MSAD);
229 
230                                   /* category 3: */
231 "mad.u16"                         return TOKEN(T_OP_MAD_U16);
232 "madsh.u16"                       return TOKEN(T_OP_MADSH_U16);
233 "mad.s16"                         return TOKEN(T_OP_MAD_S16);
234 "madsh.m16"                       return TOKEN(T_OP_MADSH_M16);
235 "mad.u24"                         return TOKEN(T_OP_MAD_U24);
236 "mad.s24"                         return TOKEN(T_OP_MAD_S24);
237 "mad.f16"                         return TOKEN(T_OP_MAD_F16);
238 "mad.f32"                         return TOKEN(T_OP_MAD_F32);
239 "sel.b16"                         return TOKEN(T_OP_SEL_B16);
240 "sel.b32"                         return TOKEN(T_OP_SEL_B32);
241 "sel.s16"                         return TOKEN(T_OP_SEL_S16);
242 "sel.s32"                         return TOKEN(T_OP_SEL_S32);
243 "sel.f16"                         return TOKEN(T_OP_SEL_F16);
244 "sel.f32"                         return TOKEN(T_OP_SEL_F32);
245 "sad.s16"                         return TOKEN(T_OP_SAD_S16);
246 "sad.s32"                         return TOKEN(T_OP_SAD_S32);
247 "shrm"                            return TOKEN(T_OP_SHRM);
248 "shlm"                            return TOKEN(T_OP_SHLM);
249 "shrg"                            return TOKEN(T_OP_SHRG);
250 "shlg"                            return TOKEN(T_OP_SHLG);
251 "andg"                            return TOKEN(T_OP_ANDG);
252 "dp2acc"                          return TOKEN(T_OP_DP2ACC);
253 "dp4acc"                          return TOKEN(T_OP_DP4ACC);
254 "wmm"                             return TOKEN(T_OP_WMM);
255 "wmm.accu"                        return TOKEN(T_OP_WMM_ACCU);
256 
257                                   /* category 4: */
258 "rcp"                             return TOKEN(T_OP_RCP);
259 "rsq"                             return TOKEN(T_OP_RSQ);
260 "log2"                            return TOKEN(T_OP_LOG2);
261 "exp2"                            return TOKEN(T_OP_EXP2);
262 "sin"                             return TOKEN(T_OP_SIN);
263 "cos"                             return TOKEN(T_OP_COS);
264 "sqrt"                            return TOKEN(T_OP_SQRT);
265 "hrsq"                            return TOKEN(T_OP_HRSQ);
266 "hlog2"                           return TOKEN(T_OP_HLOG2);
267 "hexp2"                           return TOKEN(T_OP_HEXP2);
268 
269                                   /* category 5: */
270 "isam"                            return TOKEN(T_OP_ISAM);
271 "isaml"                           return TOKEN(T_OP_ISAML);
272 "isamm"                           return TOKEN(T_OP_ISAMM);
273 "sam"                             return TOKEN(T_OP_SAM);
274 "samb"                            return TOKEN(T_OP_SAMB);
275 "saml"                            return TOKEN(T_OP_SAML);
276 "samgq"                           return TOKEN(T_OP_SAMGQ);
277 "getlod"                          return TOKEN(T_OP_GETLOD);
278 "conv"                            return TOKEN(T_OP_CONV);
279 "convm"                           return TOKEN(T_OP_CONVM);
280 "getsize"                         return TOKEN(T_OP_GETSIZE);
281 "getbuf"                          return TOKEN(T_OP_GETBUF);
282 "getpos"                          return TOKEN(T_OP_GETPOS);
283 "getinfo"                         return TOKEN(T_OP_GETINFO);
284 "dsx"                             return TOKEN(T_OP_DSX);
285 "dsy"                             return TOKEN(T_OP_DSY);
286 "gather4r"                        return TOKEN(T_OP_GATHER4R);
287 "gather4g"                        return TOKEN(T_OP_GATHER4G);
288 "gather4b"                        return TOKEN(T_OP_GATHER4B);
289 "gather4a"                        return TOKEN(T_OP_GATHER4A);
290 "samgp0"                          return TOKEN(T_OP_SAMGP0);
291 "samgp1"                          return TOKEN(T_OP_SAMGP1);
292 "samgp2"                          return TOKEN(T_OP_SAMGP2);
293 "samgp3"                          return TOKEN(T_OP_SAMGP3);
294 "dsxpp.1"                         return TOKEN(T_OP_DSXPP_1);
295 "dsypp.1"                         return TOKEN(T_OP_DSYPP_1);
296 "rgetpos"                         return TOKEN(T_OP_RGETPOS);
297 "rgetinfo"                        return TOKEN(T_OP_RGETINFO);
298 "brcst.active"                    return TOKEN(T_OP_BRCST_A);
299 "quad_shuffle.brcst"              return TOKEN(T_OP_QSHUFFLE_BRCST);
300 "quad_shuffle.horiz"              return TOKEN(T_OP_QSHUFFLE_H);
301 "quad_shuffle.vert"               return TOKEN(T_OP_QSHUFFLE_V);
302 "quad_shuffle.diag"               return TOKEN(T_OP_QSHUFFLE_DIAG);
303 
304                                   /* category 6: */
305 "ldg"                             return TOKEN(T_OP_LDG);
306 "ldg.a"                           return TOKEN(T_OP_LDG_A);
307 "ldl"                             return TOKEN(T_OP_LDL);
308 "ldp"                             return TOKEN(T_OP_LDP);
309 "stg"                             return TOKEN(T_OP_STG);
310 "stg.a"                           return TOKEN(T_OP_STG_A);
311 "stl"                             return TOKEN(T_OP_STL);
312 "stp"                             return TOKEN(T_OP_STP);
313 "ldib"                            return TOKEN(T_OP_LDIB);
314 "g2l"                             return TOKEN(T_OP_G2L);
315 "l2g"                             return TOKEN(T_OP_L2G);
316 "prefetch"                        return TOKEN(T_OP_PREFETCH);
317 "ldlw"                            return TOKEN(T_OP_LDLW);
318 "stlw"                            return TOKEN(T_OP_STLW);
319 "resfmt"                          return TOKEN(T_OP_RESFMT);
320 "resinfo"                         return TOKEN(T_OP_RESINFO);
321 "atomic.add"                      return TOKEN(T_OP_ATOMIC_ADD);
322 "atomic.sub"                      return TOKEN(T_OP_ATOMIC_SUB);
323 "atomic.xchg"                     return TOKEN(T_OP_ATOMIC_XCHG);
324 "atomic.inc"                      return TOKEN(T_OP_ATOMIC_INC);
325 "atomic.dec"                      return TOKEN(T_OP_ATOMIC_DEC);
326 "atomic.cmpxchg"                  return TOKEN(T_OP_ATOMIC_CMPXCHG);
327 "atomic.min"                      return TOKEN(T_OP_ATOMIC_MIN);
328 "atomic.max"                      return TOKEN(T_OP_ATOMIC_MAX);
329 "atomic.and"                      return TOKEN(T_OP_ATOMIC_AND);
330 "atomic.or"                       return TOKEN(T_OP_ATOMIC_OR);
331 "atomic.xor"                      return TOKEN(T_OP_ATOMIC_XOR);
332 "resinfo.b"                       return TOKEN(T_OP_RESINFO_B);
333 "ldib.b"                          return TOKEN(T_OP_LDIB_B);
334 "stib.b"                          return TOKEN(T_OP_STIB_B);
335 "atomic.b.add"                    return TOKEN(T_OP_ATOMIC_B_ADD);
336 "atomic.b.sub"                    return TOKEN(T_OP_ATOMIC_B_SUB);
337 "atomic.b.xchg"                   return TOKEN(T_OP_ATOMIC_B_XCHG);
338 "atomic.b.inc"                    return TOKEN(T_OP_ATOMIC_B_INC);
339 "atomic.b.dec"                    return TOKEN(T_OP_ATOMIC_B_DEC);
340 "atomic.b.cmpxchg"                return TOKEN(T_OP_ATOMIC_B_CMPXCHG);
341 "atomic.b.min"                    return TOKEN(T_OP_ATOMIC_B_MIN);
342 "atomic.b.max"                    return TOKEN(T_OP_ATOMIC_B_MAX);
343 "atomic.b.and"                    return TOKEN(T_OP_ATOMIC_B_AND);
344 "atomic.b.or"                     return TOKEN(T_OP_ATOMIC_B_OR);
345 "atomic.b.xor"                    return TOKEN(T_OP_ATOMIC_B_XOR);
346 "atomic.s.add"                    return TOKEN(T_OP_ATOMIC_S_ADD);
347 "atomic.s.sub"                    return TOKEN(T_OP_ATOMIC_S_SUB);
348 "atomic.s.xchg"                   return TOKEN(T_OP_ATOMIC_S_XCHG);
349 "atomic.s.inc"                    return TOKEN(T_OP_ATOMIC_S_INC);
350 "atomic.s.dec"                    return TOKEN(T_OP_ATOMIC_S_DEC);
351 "atomic.s.cmpxchg"                return TOKEN(T_OP_ATOMIC_S_CMPXCHG);
352 "atomic.s.min"                    return TOKEN(T_OP_ATOMIC_S_MIN);
353 "atomic.s.max"                    return TOKEN(T_OP_ATOMIC_S_MAX);
354 "atomic.s.and"                    return TOKEN(T_OP_ATOMIC_S_AND);
355 "atomic.s.or"                     return TOKEN(T_OP_ATOMIC_S_OR);
356 "atomic.s.xor"                    return TOKEN(T_OP_ATOMIC_S_XOR);
357 "atomic.g.add"                    return TOKEN(T_OP_ATOMIC_G_ADD);
358 "atomic.g.sub"                    return TOKEN(T_OP_ATOMIC_G_SUB);
359 "atomic.g.xchg"                   return TOKEN(T_OP_ATOMIC_G_XCHG);
360 "atomic.g.inc"                    return TOKEN(T_OP_ATOMIC_G_INC);
361 "atomic.g.dec"                    return TOKEN(T_OP_ATOMIC_G_DEC);
362 "atomic.g.cmpxchg"                return TOKEN(T_OP_ATOMIC_G_CMPXCHG);
363 "atomic.g.min"                    return TOKEN(T_OP_ATOMIC_G_MIN);
364 "atomic.g.max"                    return TOKEN(T_OP_ATOMIC_G_MAX);
365 "atomic.g.and"                    return TOKEN(T_OP_ATOMIC_G_AND);
366 "atomic.g.or"                     return TOKEN(T_OP_ATOMIC_G_OR);
367 "atomic.g.xor"                    return TOKEN(T_OP_ATOMIC_G_XOR);
368 
369 "ldgb"                            return TOKEN(T_OP_LDGB);
370 "stgb"                            return TOKEN(T_OP_STGB);
371 "stib"                            return TOKEN(T_OP_STIB);
372 "ldc"                             return TOKEN(T_OP_LDC);
373 "ldlv"                            return TOKEN(T_OP_LDLV);
374 "getspid"                         return TOKEN(T_OP_GETSPID);
375 "getwid"                          return TOKEN(T_OP_GETWID);
376 "getfiberid"                      return TOKEN(T_OP_GETFIBERID);
377 "stc"                             return TOKEN(T_OP_STC);
378 
379                                   /* category 7: */
380 "bar"                             return TOKEN(T_OP_BAR);
381 "fence"                           return TOKEN(T_OP_FENCE);
382 
383 "f16"                             return TOKEN(T_TYPE_F16);
384 "f32"                             return TOKEN(T_TYPE_F32);
385 "u16"                             return TOKEN(T_TYPE_U16);
386 "u32"                             return TOKEN(T_TYPE_U32);
387 "s16"                             return TOKEN(T_TYPE_S16);
388 "s32"                             return TOKEN(T_TYPE_S32);
389 "u8"                              return TOKEN(T_TYPE_U8);
390 "s8"                              return TOKEN(T_TYPE_S8);
391 
392 "untyped"                         return TOKEN(T_UNTYPED);
393 "typed"                           return TOKEN(T_TYPED);
394 
395 "unsigned"                        return TOKEN(T_UNSIGNED);
396 "mixed"                           return TOKEN(T_MIXED);
397 "low"                             return TOKEN(T_LOW);
398 "high"                            return TOKEN(T_HIGH);
399 
400 "1d"                              return TOKEN(T_1D);
401 "2d"                              return TOKEN(T_2D);
402 "3d"                              return TOKEN(T_3D);
403 "4d"                              return TOKEN(T_4D);
404 
405 "lt"                              return TOKEN(T_LT);
406 "le"                              return TOKEN(T_LE);
407 "gt"                              return TOKEN(T_GT);
408 "ge"                              return TOKEN(T_GE);
409 "eq"                              return TOKEN(T_EQ);
410 "ne"                              return TOKEN(T_NE);
411 
412 "a"                               return 'a';
413 "o"                               return 'o';
414 "p"                               return 'p';
415 "s2en"                            return TOKEN(T_S2EN);
416 "s"                               return 's';
417 "k"                               return 'k';
418 "base"[0-9]+                      ir3_yylval.num = strtol(yytext+4, NULL, 10); return T_BASE;
419 "offset"[0-9]+                    ir3_yylval.num = strtol(yytext+6, NULL, 10); return T_OFFSET;
420 "uniform"                         return T_UNIFORM;
421 "nonuniform"                      return T_NONUNIFORM;
422 "imm"                             return T_IMM;
423 
424 "h"                               return 'h';
425 "="                               return '=';
426 "("                               return '(';
427 ")"                               return ')';
428 "["                               return '[';
429 "]"                               return ']';
430 ","                               return ',';
431 "."                               return '.';
432 "-"                               return '-';
433 "+"                               return '+';
434 "|"                               return '|';
435 "c"                               return 'c';
436 "r"                               return 'r';
437 "hc"                              return TOKEN(T_HC);
438 "hr"                              return TOKEN(T_HR);
439 "g"                               return 'g';
440 "w"                               return 'w';
441 "l"                               return 'l';
442 "<"                               return '<';
443 ">"                               return '>';
444 "!"                               return '!';
445 "#"                               return '#';
446 ":"                               return ':';
447 
448 "nan"                             return TOKEN(T_NAN);
449 "inf"                             return TOKEN(T_INF);
450 
451 [a-zA-Z_][a-zA-Z_0-9]*            ir3_yylval.str = ralloc_strdup(ir3_parser_dead_ctx, yytext); return T_IDENTIFIER;
452 .                                 fprintf(stderr, "error at line %d: Unknown token: %s\n", ir3_yyget_lineno(), yytext); yyterminate();
453 %%
454