mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 09:20:13 +01:00
freedreno/afuc: Add more general T_IDENTIFIER in lexer
This frees us from having to strip the trailing colon, and makes it easier to add other identifiers like for section names. The downside is that now we can't name a label with a reserved word like "mov" but that doesn't seem too bad. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26771>
This commit is contained in:
parent
f7bf4db339
commit
a5db8e9c1f
3 changed files with 6 additions and 13 deletions
|
|
@ -94,15 +94,6 @@ parse_bit(const char *str)
|
|||
unsigned parse_control_reg(const char *name);
|
||||
unsigned parse_sqe_reg(const char *name);
|
||||
|
||||
/* string trailing ':' off label: */
|
||||
static inline const char *
|
||||
parse_label_decl(const char *str)
|
||||
{
|
||||
char *s = strdup(str);
|
||||
s[strlen(s) - 1] = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
void yyset_in(FILE *_in_str);
|
||||
|
||||
#endif /* _ASM_H_ */
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ extern YYSTYPE yylval;
|
|||
"b"[0-9][0-9]* yylval.num = parse_bit(yytext); return T_BIT;
|
||||
"@"[a-zA-Z_][a-zA-Z0-9_]* yylval.num = parse_control_reg(yytext); return T_CONTROL_REG;
|
||||
"%"[a-zA-Z_][a-zA-Z0-9_]* yylval.num = parse_sqe_reg(yytext); return T_SQE_REG;
|
||||
"#"[a-zA-Z_][a-zA-Z0-9_]* yylval.str = strdup(yytext+1); return T_LABEL_REF; /* label reference */
|
||||
[a-zA-Z_][a-zA-Z0-9_]*":" yylval.str = parse_label_decl(yytext); return T_LABEL_DECL; /* label declaration */
|
||||
"#"[a-zA-Z_][a-zA-Z0-9_]* yylval.str = strdup(yytext+1); return T_LABEL_REF;
|
||||
"["[0-9a-fA-F][0-9a-fA-F]*"]" yylval.num = parse_literal(yytext); return T_LITERAL;
|
||||
|
||||
/* instructions: */
|
||||
|
|
@ -106,6 +105,9 @@ extern YYSTYPE yylval;
|
|||
"]" return ']';
|
||||
"+" return '+';
|
||||
"!" return '!';
|
||||
":" return ':';
|
||||
|
||||
[a-zA-Z_][a-zA-Z0-9_]* yylval.str = strdup(yytext); return T_IDENTIFIER;
|
||||
|
||||
. fprintf(stderr, "error at line %d: Unknown token: %s\n", yyget_lineno(), yytext); yyterminate();
|
||||
|
||||
|
|
|
|||
|
|
@ -122,11 +122,11 @@ label(const char *str)
|
|||
%token <num> T_HEX
|
||||
%token <num> T_CONTROL_REG
|
||||
%token <num> T_SQE_REG
|
||||
%token <str> T_LABEL_DECL
|
||||
%token <str> T_LABEL_REF
|
||||
%token <num> T_LITERAL
|
||||
%token <num> T_BIT
|
||||
%token <num> T_REGISTER
|
||||
%token <str> T_IDENTIFIER
|
||||
|
||||
%token <tok> T_OP_NOP
|
||||
%token <tok> T_OP_ADD
|
||||
|
|
@ -194,7 +194,7 @@ instr_or_label: instr_r
|
|||
| T_REP instr_r { instr->rep = true; }
|
||||
| branch_instr
|
||||
| other_instr
|
||||
| T_LABEL_DECL { decl_label($1); }
|
||||
| T_IDENTIFIER ':' { decl_label($1); }
|
||||
| T_ALIGN immediate { align_instr($2); }
|
||||
| T_JUMPTBL { decl_jumptbl(); }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue