[PATCH 22/57][Arm][GAS] Add support for MVE instructions: vmlaldav, vmlalv, vmlsldav...
[binutils-gdb.git] / gas / config / bfin-lex.l
blob1fd759a86e0df14614f61e459850239fd5e9b631
1 %option noyywrap
3 /* bfin-lex.l  ADI Blackfin lexer
4    Copyright (C) 2005-2019 Free Software Foundation, Inc.
6    This file is part of GAS, the GNU Assembler.
8    GAS is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3, or (at your option)
11    any later version.
13    GAS is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
18    You should have received a copy of the GNU General Public License
19    along with GAS; see the file COPYING.  If not, write to the Free
20    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21    02110-1301, USA.  */
24 #include "as.h"
25 #include "bfin-defs.h"
26 #include "bfin-parse.h"
28 static long parse_int (char **end);
29 static int parse_halfreg (Register *r, int cl, char *hr);
30 static int parse_reg (Register *r, int type, char *rt);
31 int yylex (void);
33 #define _REG yylval.reg
38 /* Define Start States ... Actually we will use exclusion.
39    If no start state is specified it should match any state
40    and <INITIAL> would match some keyword rules only with
41    initial.  */
42 %s KEYWORD
43 %s FLAGS
46 [sS][fF][tT][rR][eE][sS][eE][tT]        _REG.regno = REG_sftreset;  return REG;
47 [oO][mM][oO][dD][eE]                    _REG.regno = REG_omode;     return REG;
48 [iI][dD][lL][eE]_[rR][eE][qQ]           _REG.regno = REG_idle_req;  return REG;
49 [hH][wW][eE][rR][rR][cC][aA][uU][sS][eE] _REG.regno = REG_hwerrcause; return REG;
50 [eE][xX][cC][aA][uU][sS][eE]            _REG.regno = REG_excause;   return REG;
51 [eE][mM][uU][cC][aA][uU][sS][eE]        _REG.regno = REG_emucause;  return REG;
52 <FLAGS>[zZ]                             return Z;
53 <FLAGS>[xX]                             return X;
54 [wW]32                                  yylval.value = M_W32; return MMOD;
55 [wW]                                    return W;
56 [vV][iI][tT]_[mM][aA][xX]               return VIT_MAX;
57 [vV]               return V; /* Special: V is a statflag and a modifier.  */
58 [uU][sS][pP]       _REG.regno = REG_USP; return REG;
59 [tT][lL]                                return TL;
60 [tT][hH]                                return TH;
61 [tT][fF][uU]                            yylval.value = M_TFU; return MMOD;
62 [tT][eE][sS][tT][sS][eE][tT]            return TESTSET;
63 <FLAGS>[tT]                             yylval.value = M_T; return MMOD;
64 <FLAGS>[sS]                             return S;
65 [sS][yY][sS][cC][fF][gG]       _REG.regno = REG_SYSCFG; return REG;
66 [sS][tT][iI]                            return STI;
67 [sS][sS][yY][nN][cC]                    return SSYNC;
68 [sS][pP]"."[lL]                         _REG.regno = REG_SP; _REG.flags = F_REG_LOW; return HALF_REG;
69 [sS][pP]"."[hH]                         _REG.regno = REG_SP; _REG.flags = F_REG_HIGH; return HALF_REG;
70 [sS][pP]                                _REG.regno = REG_SP; return REG;
71 [sS][iI][gG][nN][bB][iI][tT][sS]        return SIGNBITS;
72 [sS][iI][gG][nN]                        return SIGN;
73 [sS][eE][qQ][sS][tT][aA][tT]     _REG.regno = REG_SEQSTAT; return REG;
74 [sS][eE][aA][rR][cC][hH]                return SEARCH;
75 [sS][hH][iI][fF][tT]                    return SHIFT;
76 [sS][cC][oO]                            return SCO;
78 [sS][aA][aA]                            return SAA;
79 [sS]2[rR][nN][dD]                       yylval.value = M_S2RND; return MMOD;
80 [rR][tT][xX]                            return RTX;
81 [rR][tT][sS]                            return RTS;
82 [rR][tT][nN]                            return RTN;
83 [rR][tT][iI]                            return RTI;
84 [rR][tT][eE]                            return RTE;
85 [rR][oO][tT]                            return ROT;
86 [rR][nN][dD]20                          return RND20;
87 [rR][nN][dD]12                          return RND12;
88 [rR][nN][dD][lL]                        return RNDL;
89 [rR][nN][dD][hH]                        return RNDH;
90 [rR][nN][dD]                            return RND;
92 [rR][0-7]"."[lLhHbB]  return parse_halfreg(&yylval.reg, T_REG_R, yytext);
94 [rR][eE][tT][sS]                _REG.regno = REG_RETS; return REG;
95 [rR][eE][tT][iI]                _REG.regno = REG_RETI; return REG;
96 [rR][eE][tT][xX]                _REG.regno = REG_RETX; return REG;
97 [rR][eE][tT][nN]                _REG.regno = REG_RETN; return REG;
98 [rR][eE][tT][eE]                _REG.regno = REG_RETE; return REG;
99 [eE][mM][uU][dD][aA][tT]        _REG.regno = REG_EMUDAT; return REG;
100 [rR][aA][iI][sS][eE]            return RAISE;
102 [rR][0-7]           return parse_reg (&yylval.reg, T_REG_R, yytext);
104 [rR]      return R;
105 [pP][rR][nN][tT]                        return PRNT;
106 [pP][cC]                                return PC;
107 [pP][aA][cC][kK]                        return PACK;
109 [pP][0-5]"."[lLhH]  return parse_halfreg (&yylval.reg, T_REG_P, yytext);
110 [pP][0-5]           return parse_reg (&yylval.reg, T_REG_P, yytext);
112 [oO][uU][tT][cC]                        return OUTC;
113 [oO][nN][eE][sS]                        return ONES;
115 [nN][oO][tT]                            return NOT;
116 [nN][oO][pP]                            return NOP;
117 [mM][nN][oO][pP]                        return MNOP;
118 [nN][sS]                                return NS;
121 [mM][iI][nN]                            return MIN;
122 [mM][aA][xX]                            return MAX;
124 [mM][0-3]"."[lLhH]  return parse_halfreg (&yylval.reg, T_REG_M, yytext);
125 [mM][0-3]           return parse_reg (&yylval.reg, T_REG_M, yytext);
127 <FLAGS>[mM]                             return M;
128 [lL][tT]                                return LT;
129 [lL][sS][hH][iI][fF][tT]                return LSHIFT;
130 [lL][sS][eE][tT][uU][pP]                return LSETUP;
131 [lL][oO][oO][pP]                        return LOOP;
132 [lL][oO][oO][pP]_[bB][eE][gG][iI][nN]   return LOOP_BEGIN;
133 [lL][oO][oO][pP]_[eE][nN][dD]           return LOOP_END;
135 [lL][eE]                                return LE;
136 [lL][cC]0 _REG.regno = REG_LC0; return REG;
137 [lL][tT]0 _REG.regno = REG_LT0; return REG;
138 [lL][bB]0 _REG.regno = REG_LB0; return REG;
139 [lL][cC]1 _REG.regno = REG_LC1; return REG;
140 [lL][tT]1 _REG.regno = REG_LT1; return REG;
141 [lL][bB]1 _REG.regno = REG_LB1; return REG;
143 [lL][0-3]"."[lLhH]  return parse_halfreg (&yylval.reg, T_REG_L, yytext);
144 [lL][0-3]           return parse_reg (&yylval.reg, T_REG_L, yytext);
145 [lL][oO]                                return LO;
146 [jJ][uU][mM][pP]"."[sS]                 { BEGIN 0; return JUMP_DOT_S;}
147 [jJ][uU][mM][pP]"."[lL]                 { BEGIN 0; return JUMP_DOT_L;}
148 [jJ][uU][mM][pP]                        { BEGIN 0; return JUMP;}
149 [jJ][uU][mM][pP]"."[xX]                 { BEGIN 0; return JUMP_DOT_L; }
150 [iI][uU]                                yylval.value = M_IU;   return MMOD;
151 [iI][sS][sS]2                           yylval.value = M_ISS2; return MMOD;
152 [iI][sS]                                yylval.value = M_IS;   return MMOD;
153 [iI][hH]                                yylval.value = M_IH;   return MMOD;
154 [iI][fF]                                return IF;
155 [iI][0-3]"."[lLhH]  return parse_halfreg (&yylval.reg, T_REG_I, yytext);
156 [iI][0-3]           return parse_reg (&yylval.reg, T_REG_I, yytext);
157 [hH][lL][tT]                            return HLT;
158 [hH][iI]                                return HI;
159 [gG][tT]                                return GT;
160 [gG][eE]                                return GE;
161 [fF][uU]                                yylval.value = M_FU; return MMOD;
162 [fF][pP]         _REG.regno = REG_FP; return REG;
163 [fF][pP]"."[lL]  _REG.regno = REG_FP; _REG.flags = F_REG_LOW; return HALF_REG;
164 [fF][pP]"."[hH]  _REG.regno = REG_FP; _REG.flags = F_REG_HIGH; return HALF_REG;
166 [eE][xX][tT][rR][aA][cC][tT]            return EXTRACT;
167 [eE][xX][pP][aA][dD][jJ]                return EXPADJ;
168 [eE][xX][cC][pP][tT]                    return EXCPT;
169 [eE][mM][uU][eE][xX][cC][pP][tT]        return EMUEXCPT;
170 [dD][iI][vV][sS]                        return DIVS;
171 [dD][iI][vV][qQ]                        return DIVQ;
172 [dD][iI][sS][aA][lL][gG][nN][eE][xX][cC][pP][tT]  return DISALGNEXCPT;
173 [dD][eE][pP][oO][sS][iI][tT]            return DEPOSIT;
174 [dD][bB][gG][hH][aA][lL][tT]            return DBGHALT;
175 [dD][bB][gG][cC][mM][pP][lL][xX]        return DBGCMPLX;
176 [dD][bB][gG][aA][lL]                    return DBGAL;
177 [dD][bB][gG][aA][hH]                    return DBGAH;
178 [dD][bB][gG][aA]                        return DBGA;
179 [dD][bB][gG]                            return DBG;
180 [cC][yY][cC][lL][eE][sS]2  { _REG.regno = REG_CYCLES2; return REG; }
181 [cC][yY][cC][lL][eE][sS]  { _REG.regno = REG_CYCLES; return REG; }
182 [cC][sS][yY][nN][cC]                    return CSYNC;
183 [cC][oO]                                return CO;
184 [cC][lL][iI]                            return CLI;
186 [cC][cC]     _REG.regno = REG_CC; return CCREG;
187 [cC][aA][lL][lL]"."[xX]                 { BEGIN 0; return CALL;}
188 [cC][aA][lL][lL]                        { BEGIN 0; return CALL;}
189 [bB][yY][tT][eE][uU][nN][pP][aA][cC][kK] return BYTEUNPACK;
190 [bB][yY][tT][eE][pP][aA][cC][kK]        return BYTEPACK;
191 [bB][yY][tT][eE][oO][pP]16[mM]          return BYTEOP16M;
192 [bB][yY][tT][eE][oO][pP]16[pP]          return BYTEOP16P;
193 [bB][yY][tT][eE][oO][pP]3[pP]           return BYTEOP3P;
194 [bB][yY][tT][eE][oO][pP]2[pP]           return BYTEOP2P;
195 [bB][yY][tT][eE][oO][pP]1[pP]           return BYTEOP1P;
196 [bB][yY]                                return BY;
197 [bB][xX][oO][rR][sS][hH][iI][fF][tT]    return BXORSHIFT;
198 [bB][xX][oO][rR]                        return BXOR;
200 [bB][rR][eE][vV]                        return BREV;
201 [bB][pP]                                return BP;
202 [bB][iI][tT][tT][sS][tT]                return BITTST;
203 [bB][iI][tT][tT][gG][lL]                return BITTGL;
204 [bB][iI][tT][sS][eE][tT]                return BITSET;
205 [bB][iI][tT][mM][uU][xX]                return BITMUX;
206 [bB][iI][tT][cC][lL][rR]                return BITCLR;
207 [bB][0-3]"."[lLhH]  return parse_halfreg (&yylval.reg, T_REG_B, yytext);
208 [bB][0-3]           return parse_reg (&yylval.reg, T_REG_B, yytext);
209 [bB]                                    return B;
210 [aA][zZ]  _REG.regno = S_AZ;   return STATUS_REG;
211 [aA][nN]  _REG.regno = S_AN;   return STATUS_REG;
212 [aA][cC]0_[cC][oO][pP][yY]  _REG.regno = S_AC0_COPY; return STATUS_REG;
213 [vV]_[cC][oO][pP][yY]       _REG.regno = S_V_COPY;   return STATUS_REG;
214 [aA][qQ]  _REG.regno = S_AQ;   return STATUS_REG;
215 [aA][cC]0 _REG.regno = S_AC0;  return STATUS_REG;
216 [aA][cC]1 _REG.regno = S_AC1;  return STATUS_REG;
217 [aA][vV]0 _REG.regno = S_AV0;  return STATUS_REG;
218 [aA][vV]0[sS] _REG.regno = S_AV0S; return STATUS_REG;
219 [aA][vV]1 _REG.regno = S_AV1;  return STATUS_REG;
220 [aA][vV]1[sS] _REG.regno = S_AV1S; return STATUS_REG;
221 [vV][sS]  _REG.regno = S_VS;   return STATUS_REG;
222 [rR][nN][dD]_[mM][oO][dD]  _REG.regno = S_RND_MOD; return STATUS_REG;
225 [aA][sS][tT][aA][tT]   _REG.regno = REG_ASTAT; return REG;
226 [aA][sS][hH][iI][fF][tT]                return ASHIFT;
227 [aA][sS][lL]                            return ASL;
228 [aA][sS][rR]                            return ASR;
229 [aA][lL][iI][gG][nN]8                   return ALIGN8;
230 [aA][lL][iI][gG][nN]16                  return ALIGN16;
231 [aA][lL][iI][gG][nN]24                  return ALIGN24;
232 [aA]1"."[lL]    return A_ONE_DOT_L;
233 [aA]0"."[lL]    return A_ZERO_DOT_L;
234 [aA]1"."[hH]    return A_ONE_DOT_H;
235 [aA]0"."[hH]    return A_ZERO_DOT_H;
236 [aA][bB][sS]                            return ABS;
237 [aA][bB][oO][rR][tT]                    return ABORT;
238 [aA]1"."[xX]    _REG.regno = REG_A1x; return REG;
239 [aA]1"."[wW]    _REG.regno = REG_A1w; return REG;
240 [aA]1           _REG.regno = REG_A1;  return REG_A_DOUBLE_ONE;
241 [aA]0"."[xX]    _REG.regno = REG_A0x; return REG;
242 [aA]0"."[wW]    _REG.regno = REG_A0w; return REG;
243 [aA]0           _REG.regno = REG_A0;  return REG_A_DOUBLE_ZERO;
244 [Gg][Oo][Tt]    return GOT;
245 [Gg][Oo][Tt]"17"[Mm]"4" return GOT17M4;
246 [Ff][Uu][Nn][Cc][Dd][Ee][Ss][Cc]"_"[Gg][Oo][Tt]"17"[Mm]"4" return FUNCDESC_GOT17M4;
247 [Pp][Ll][Tt][Pp][Cc]    return PLTPC;
250 "~"                     return TILDA;
251 "|="                    return _BAR_ASSIGN;
252 "|"                     return BAR;
253 "^="                    return _CARET_ASSIGN;
254 "^"                     return CARET;
255 "]"                     return RBRACK;
256 "["                     return LBRACK;
257 ">>>="                  return _GREATER_GREATER_GREATER_THAN_ASSIGN;
258 ">>="                   return _GREATER_GREATER_ASSIGN;
259 ">>>"                   return _GREATER_GREATER_GREATER;
260 ">>"                    return GREATER_GREATER;
261 "=="                    return _ASSIGN_ASSIGN;
262 "="                     return ASSIGN;
263 "<="                    return _LESS_THAN_ASSIGN;
264 "<<="                   return _LESS_LESS_ASSIGN;
265 "<<"                    return LESS_LESS;
266 "<"                     return LESS_THAN;
267 "("                     BEGIN(FLAGS); return LPAREN;
268 ")"                     BEGIN(INITIAL); return RPAREN;
269 ":"                     return COLON;
270 "/"                     return SLASH;
271 "-="                    return _MINUS_ASSIGN;
272 "+|+"                                   return _PLUS_BAR_PLUS;
273 "-|+"                                   return _MINUS_BAR_PLUS;
274 "+|-"                                   return _PLUS_BAR_MINUS;
275 "-|-"                                   return _MINUS_BAR_MINUS;
276 "--"                    return _MINUS_MINUS;
277 "-"                     return MINUS;
278 ","                     return COMMA;
279 "+="                    return _PLUS_ASSIGN;
280 "++"                    return _PLUS_PLUS;
281 "+"                     return PLUS;
282 "*="                    return _STAR_ASSIGN;
283 "*"                     return STAR;
284 "&="                    return _AMPERSAND_ASSIGN;
285 "&"                     return AMPERSAND;
286 "%"                     return PERCENT;
287 "!"                     return BANG;
288 ";"                     return SEMICOLON;
289 "=!"                    return _ASSIGN_BANG;
290 "||"                    return DOUBLE_BAR;
291 "@"                     return AT;
292 <KEYWORD>[pP][rR][eE][fF][eE][tT][cC][hH]        return PREFETCH;
293 <KEYWORD>[uU][nN][lL][iI][nN][kK]                return UNLINK;
294 <KEYWORD>[lL][iI][nN][kK]                        return LINK;
295 <KEYWORD>[iI][dD][lL][eE]                        return IDLE;
296 <KEYWORD>[iI][fF][lL][uU][sS][hH]                return IFLUSH;
297 <KEYWORD>[fF][lL][uU][sS][hH][iI][nN][vV]        return FLUSHINV;
298 <KEYWORD>[fF][lL][uU][sS][hH]                    return FLUSH;
299 ([0-9]+)|(0[xX][0-9a-fA-F]+)|([bhfodBHOFD]#[0-9a-fA-F]+)|(0"."[0-9]+) {
300     yylval.value = parse_int (&yytext);
301     return NUMBER;
302   }
303 [[:alpha:]\x80-\xff_$.][[:alnum:]\x80-\xff_$.]* {
304     yylval.symbol = symbol_find_or_make (yytext);
305     symbol_mark_used (yylval.symbol);
306     return SYMBOL;
307   }
308 [0-9][bfBF] {
309     char *name;
310     char *ref = strdup (yytext);
311     if (ref[1] == 'b' || ref[1] == 'B')
312       {
313         name = fb_label_name ((int) (ref[0] - '0'), 0);
314         yylval.symbol = symbol_find (name);
316         if ((yylval.symbol != NULL)
317              && (S_IS_DEFINED (yylval.symbol)))
318           return SYMBOL;
319         as_bad ("backward reference to unknown label %d:",
320                                                   (int) (ref[0] - '0'));
321       }
322     else if (ref[1] == 'f' || ref[1] == 'F')
323       {
324         /* Forward reference.  Expect symbol to be undefined or
325            unknown.  undefined: seen it before.  unknown: never seen
326            it before.
328            Construct a local label name, then an undefined symbol.
329            Just return it as never seen before.  */
331         name = fb_label_name ((int) (ref[0] - '0'), 1);
332         yylval.symbol = symbol_find_or_make (name);
333         /* We have no need to check symbol properties.  */
334         return SYMBOL;
335       }
336   }
337 [ \t\n]                                    ;
338 "/*".*"*/"                                 ;
339 .                                          return yytext[0];
341 static long parse_int (char **end)
343   char fmt = '\0';
344   int not_done = 1;
345   int shiftvalue = 0;
346   char * char_bag;
347   long value = 0;
348   char *arg = *end;
350   while (*arg && *arg == ' ')
351     arg++;
353   switch (*arg)
354     {
355       case '1':
356       case '2':
357       case '3':
358       case '4':
359       case '5':
360       case '6':
361       case '7':
362       case '8':
363       case '9':
364         fmt = 'd';
365         break;
367       case '0':  /* Accept different formatted integers hex octal and binary. */
368         {
369           char c = *++arg;
370           arg++;
371           if (c == 'x' || c == 'X') /* Hex input.  */
372             fmt = 'h';
373           else if (c == 'b' || c == 'B')
374             fmt = 'b';
375           else if (c == '.')
376             fmt = 'f';
377           else
378             {             /* Octal.  */
379               arg--;
380               fmt = 'o';
381             }
382           break;
383         }
385       case 'd':
386       case 'D':
387       case 'h':
388       case 'H':
389       case 'o':
390       case 'O':
391       case 'b':
392       case 'B':
393       case 'f':
394       case 'F':
395         {
396           fmt = *arg++;
397           if (*arg == '#')
398             arg++;
399         }
400     }
402   switch (fmt)
403     {
404       case 'h':
405       case 'H':
406         shiftvalue = 4;
407         char_bag = "0123456789ABCDEFabcdef";
408         break;
410       case 'o':
411       case 'O':
412         shiftvalue = 3;
413         char_bag = "01234567";
414         break;
416       case 'b':
417       case 'B':
418         shiftvalue = 1;
419         char_bag = "01";
420         break;
422 /* The assembler allows for fractional constants to be created
423    by either the 0.xxxx or the f#xxxx format
425    i.e.   0.5 would result in 0x4000
427    note .5 would result in the identifier .5.
429    The assembler converts to fractional format 1.15 by the simple rule:
431              value = (short) (finput * (1 << 15)).  */
433       case 'f':
434       case 'F':
435         {
436           float fval = 0.0;
437           float pos = 10.0;
438           while (1)
439             {
440               int c;
441               c = *arg++;
443               if (c >= '0' && c <= '9')
444                 {
445                   float digit = (c - '0') / pos;
446                   fval = fval + digit;
447                   pos = pos * 10.0;
448                 }
449               else
450                 {
451                   *--arg = c;
452                   value = (short) (fval * (1 << 15));
453                   break;
454                 }
455             }
456           *end = arg+1;
457           return value;
458         }
460       case 'd':
461       case 'D':
462       default:
463         {
464           while (1)
465             {
466               char c;
467               c = *arg++;
468               if (c >= '0' && c <= '9')
469                 value = (value * 10) + (c - '0');
470               else
471                 {
472                   /* Constants that are suffixed with k|K are multiplied by 1024
473                      This suffix is only allowed on decimal constants. */
474                   if (c == 'k' || c == 'K')
475                     value *= 1024;
476                   else
477                     *--arg = c;
478                   break;
479                 }
480             }
481           *end = arg+1;
482           return value;
483         }
484     }
486   while (not_done)
487     {
488       char c;
489       c = *arg++;
490       if (c == 0 || !strchr (char_bag, c))
491         {
492           not_done = 0;
493           *--arg = c;
494         }
495       else
496         {
497           if (c >= 'a' && c <= 'z')
498             c = c - ('a' - '9') + 1;
499           else if (c >= 'A' && c <= 'Z')
500             c = c - ('A' - '9') + 1;
502           c -= '0';
503           value = (value << shiftvalue) + c;
504         }
505     }
506   *end = arg+1;
507   return value;
511 static int parse_reg (Register *r, int cl, char *rt)
513   r->regno = cl | (rt[1] - '0');
514   r->flags = F_REG_NONE;
515   return REG;
518 static int parse_halfreg (Register *r, int cl, char *rt)
520   r->regno = cl | (rt[1] - '0');
522   switch (rt[3])
523     {
524       case 'b':
525       case 'B':
526         return BYTE_DREG;
528       case 'l':
529       case 'L':
530         r->flags = F_REG_LOW;
531         break;
533       case 'h':
534       case 'H':
535         r->flags = F_REG_HIGH;
536         break;
537     }
539   return HALF_REG;
542 /* Our start state is KEYWORD as we have
543    command keywords such as PREFETCH.  */
545 void
546 set_start_state (void)
548   BEGIN KEYWORD;