freedreno/afuc: Add missing rnn_prepdb()
[mesa.git] / src / freedreno / afuc / lexer.l
1 /*
2 * Copyright (c) 2017 Rob Clark <robdclark@gmail.com>
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 "parser.h"
27 #include "asm.h"
28
29 #define YY_NO_INPUT
30 #define YY_NO_UNPUT
31
32 #define TOKEN(t) (yylval.tok = t)
33 extern YYSTYPE yylval;
34
35 %}
36
37 %option noyywrap
38
39 %%
40 "\n" yylineno++;
41 [ \t] ; /* ignore whitespace */
42 ";"[^\n]*"\n" yylineno++; /* ignore comments */
43 [1-9][0-9]* yylval.num = strtoul(yytext, NULL, 0); return T_INT;
44 "0x"[0-9a-fA-F]* yylval.num = strtoul(yytext, NULL, 0); return T_HEX;
45
46 "$"[0-9a-fA-F][0-9a-fA-F] yylval.num = parse_reg(yytext); return T_REGISTER;
47 "$"[a-zA-Z][a-zA-Z0-9]* yylval.num = parse_reg(yytext); return T_REGISTER;
48 "b"[0-9][0-9]* yylval.num = parse_bit(yytext); return T_BIT;
49 "@"[a-zA-Z_][a-zA-Z0-9_]* yylval.num = parse_control_reg(yytext); return T_CONTROL_REG;
50 "#"[a-zA-Z_][a-zA-Z0-9_]* yylval.str = strdup(yytext+1); return T_LABEL_REF; /* label reference */
51 [a-zA-Z_][a-zA-Z0-9_]*":" yylval.str = parse_label_decl(yytext); return T_LABEL_DECL; /* label declaration */
52 "["[0-9a-fA-F][0-9a-fA-F]*"]" yylval.num = parse_literal(yytext); return T_LITERAL;
53
54 /* instructions: */
55 "nop" return TOKEN(T_OP_NOP);
56 "add" return TOKEN(T_OP_ADD);
57 "addhi" return TOKEN(T_OP_ADDHI);
58 "sub" return TOKEN(T_OP_SUB);
59 "subhi" return TOKEN(T_OP_SUBHI);
60 "and" return TOKEN(T_OP_AND);
61 "or" return TOKEN(T_OP_OR);
62 "xor" return TOKEN(T_OP_XOR);
63 "not" return TOKEN(T_OP_NOT);
64 "shl" return TOKEN(T_OP_SHL);
65 "ushr" return TOKEN(T_OP_USHR);
66 "ishr" return TOKEN(T_OP_ISHR);
67 "rot" return TOKEN(T_OP_ROT);
68 "mul8" return TOKEN(T_OP_MUL8);
69 "min" return TOKEN(T_OP_MIN);
70 "max" return TOKEN(T_OP_MAX);
71 "cmp" return TOKEN(T_OP_CMP);
72 "msb" return TOKEN(T_OP_MSB);
73 "mov" return TOKEN(T_OP_MOV);
74 "cwrite" return TOKEN(T_OP_CWRITE);
75 "cread" return TOKEN(T_OP_CREAD);
76 "store" return TOKEN(T_OP_STORE);
77 "load" return TOKEN(T_OP_LOAD);
78 "brne" return TOKEN(T_OP_BRNE);
79 "breq" return TOKEN(T_OP_BREQ);
80 "ret" return TOKEN(T_OP_RET);
81 "call" return TOKEN(T_OP_CALL);
82 "jump" return TOKEN(T_OP_JUMP);
83 "waitin" return TOKEN(T_OP_WAITIN);
84 "preemptleave" return TOKEN(T_OP_PREEMPTLEAVE);
85 "<<" return TOKEN(T_LSHIFT);
86 "(rep)" return TOKEN(T_REP);
87
88 "," return ',';
89 "[" return '[';
90 "]" return ']';
91 "+" return '+';
92
93 . fprintf(stderr, "error at line %d: Unknown token: %s\n", yyget_lineno(), yytext); yyterminate();
94
95 %%