* config/tc-arm.c (do_t_strexbh): New.
[binutils.git] / gas / config / m68k-parse.y
blob2c58266fb8e6bd8d57515fe5200daaf9a1e450a2
1 /* m68k.y -- bison grammar for m68k operand parsing
2 Copyright 1995, 1996, 1997, 1998, 2001, 2003, 2004, 2005, 2007, 2009
3 Free Software Foundation, Inc.
4 Written by Ken Raeburn and Ian Lance Taylor, Cygnus Support
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. */
23 /* This file holds a bison grammar to parse m68k operands. The m68k
24 has a complicated operand syntax, and gas supports two main
25 variations of it. Using a grammar is probably overkill, but at
26 least it makes clear exactly what we do support. */
30 #include "as.h"
31 #include "tc-m68k.h"
32 #include "m68k-parse.h"
33 #include "safe-ctype.h"
35 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
36 etc), as well as gratuitously global symbol names If other parser
37 generators (bison, byacc, etc) produce additional global names that
38 conflict at link time, then those parser generators need to be
39 fixed instead of adding those names to this list. */
41 #define yymaxdepth m68k_maxdepth
42 #define yyparse m68k_parse
43 #define yylex m68k_lex
44 #define yyerror m68k_error
45 #define yylval m68k_lval
46 #define yychar m68k_char
47 #define yydebug m68k_debug
48 #define yypact m68k_pact
49 #define yyr1 m68k_r1
50 #define yyr2 m68k_r2
51 #define yydef m68k_def
52 #define yychk m68k_chk
53 #define yypgo m68k_pgo
54 #define yyact m68k_act
55 #define yyexca m68k_exca
56 #define yyerrflag m68k_errflag
57 #define yynerrs m68k_nerrs
58 #define yyps m68k_ps
59 #define yypv m68k_pv
60 #define yys m68k_s
61 #define yy_yys m68k_yys
62 #define yystate m68k_state
63 #define yytmp m68k_tmp
64 #define yyv m68k_v
65 #define yy_yyv m68k_yyv
66 #define yyval m68k_val
67 #define yylloc m68k_lloc
68 #define yyreds m68k_reds /* With YYDEBUG defined */
69 #define yytoks m68k_toks /* With YYDEBUG defined */
70 #define yylhs m68k_yylhs
71 #define yylen m68k_yylen
72 #define yydefred m68k_yydefred
73 #define yydgoto m68k_yydgoto
74 #define yysindex m68k_yysindex
75 #define yyrindex m68k_yyrindex
76 #define yygindex m68k_yygindex
77 #define yytable m68k_yytable
78 #define yycheck m68k_yycheck
80 #ifndef YYDEBUG
81 #define YYDEBUG 1
82 #endif
84 /* Internal functions. */
86 static enum m68k_register m68k_reg_parse (char **);
87 static int yylex (void);
88 static void yyerror (const char *);
90 /* The parser sets fields pointed to by this global variable. */
91 static struct m68k_op *op;
95 %union
97 struct m68k_indexreg indexreg;
98 enum m68k_register reg;
99 struct m68k_exp exp;
100 unsigned long mask;
101 int onereg;
102 int trailing_ampersand;
105 %token <reg> DR AR FPR FPCR LPC ZAR ZDR LZPC CREG
106 %token <indexreg> INDEXREG
107 %token <exp> EXPR
109 %type <indexreg> zireg zdireg
110 %type <reg> zadr zdr apc zapc zpc optzapc optczapc
111 %type <exp> optcexpr optexprc
112 %type <mask> reglist ireglist reglistpair
113 %type <onereg> reglistreg
114 %type <trailing_ampersand> optional_ampersand
118 /* An operand. */
120 operand:
121 generic_operand
122 | motorola_operand optional_ampersand
124 op->trailing_ampersand = $2;
126 | mit_operand optional_ampersand
128 op->trailing_ampersand = $2;
132 /* A trailing ampersand(for MAC/EMAC mask addressing). */
133 optional_ampersand:
134 /* empty */
135 { $$ = 0; }
136 | '&'
137 { $$ = 1; }
140 /* A generic operand. */
142 generic_operand:
143 '<' '<'
145 op->mode = LSH;
148 | '>' '>'
150 op->mode = RSH;
153 | DR
155 op->mode = DREG;
156 op->reg = $1;
158 | AR
160 op->mode = AREG;
161 op->reg = $1;
163 | FPR
165 op->mode = FPREG;
166 op->reg = $1;
168 | FPCR
170 op->mode = CONTROL;
171 op->reg = $1;
173 | CREG
175 op->mode = CONTROL;
176 op->reg = $1;
178 | EXPR
180 op->mode = ABSL;
181 op->disp = $1;
183 | '#' EXPR
185 op->mode = IMMED;
186 op->disp = $2;
188 | '&' EXPR
190 op->mode = IMMED;
191 op->disp = $2;
193 | reglist
195 op->mode = REGLST;
196 op->mask = $1;
200 /* An operand in Motorola syntax. This includes MRI syntax as well,
201 which may or may not be different in that it permits commutativity
202 of index and base registers, and permits an offset expression to
203 appear inside or outside of the parentheses. */
205 motorola_operand:
206 '(' AR ')'
208 op->mode = AINDR;
209 op->reg = $2;
211 | '(' AR ')' '+'
213 op->mode = AINC;
214 op->reg = $2;
216 | '-' '(' AR ')'
218 op->mode = ADEC;
219 op->reg = $3;
221 | '(' EXPR ',' zapc ')'
223 op->reg = $4;
224 op->disp = $2;
225 if (($4 >= ZADDR0 && $4 <= ZADDR7)
226 || $4 == ZPC)
227 op->mode = BASE;
228 else
229 op->mode = DISP;
231 | '(' zapc ',' EXPR ')'
233 op->reg = $2;
234 op->disp = $4;
235 if (($2 >= ZADDR0 && $2 <= ZADDR7)
236 || $2 == ZPC)
237 op->mode = BASE;
238 else
239 op->mode = DISP;
241 | EXPR '(' zapc ')'
243 op->reg = $3;
244 op->disp = $1;
245 if (($3 >= ZADDR0 && $3 <= ZADDR7)
246 || $3 == ZPC)
247 op->mode = BASE;
248 else
249 op->mode = DISP;
251 | '(' LPC ')'
253 op->mode = DISP;
254 op->reg = $2;
256 | '(' ZAR ')'
258 op->mode = BASE;
259 op->reg = $2;
261 | '(' LZPC ')'
263 op->mode = BASE;
264 op->reg = $2;
266 | '(' EXPR ',' zapc ',' zireg ')'
268 op->mode = BASE;
269 op->reg = $4;
270 op->disp = $2;
271 op->index = $6;
273 | '(' EXPR ',' zapc ',' zpc ')'
275 if ($4 == PC || $4 == ZPC)
276 yyerror (_("syntax error"));
277 op->mode = BASE;
278 op->reg = $6;
279 op->disp = $2;
280 op->index.reg = $4;
281 op->index.size = SIZE_UNSPEC;
282 op->index.scale = 1;
284 | '(' EXPR ',' zdireg optczapc ')'
286 op->mode = BASE;
287 op->reg = $5;
288 op->disp = $2;
289 op->index = $4;
291 | '(' zdireg ',' EXPR ')'
293 op->mode = BASE;
294 op->disp = $4;
295 op->index = $2;
297 | EXPR '(' zapc ',' zireg ')'
299 op->mode = BASE;
300 op->reg = $3;
301 op->disp = $1;
302 op->index = $5;
304 | '(' zapc ',' zireg ')'
306 op->mode = BASE;
307 op->reg = $2;
308 op->index = $4;
310 | EXPR '(' zapc ',' zpc ')'
312 if ($3 == PC || $3 == ZPC)
313 yyerror (_("syntax error"));
314 op->mode = BASE;
315 op->reg = $5;
316 op->disp = $1;
317 op->index.reg = $3;
318 op->index.size = SIZE_UNSPEC;
319 op->index.scale = 1;
321 | '(' zapc ',' zpc ')'
323 if ($2 == PC || $2 == ZPC)
324 yyerror (_("syntax error"));
325 op->mode = BASE;
326 op->reg = $4;
327 op->index.reg = $2;
328 op->index.size = SIZE_UNSPEC;
329 op->index.scale = 1;
331 | EXPR '(' zdireg optczapc ')'
333 op->mode = BASE;
334 op->reg = $4;
335 op->disp = $1;
336 op->index = $3;
338 | '(' zdireg optczapc ')'
340 op->mode = BASE;
341 op->reg = $3;
342 op->index = $2;
344 | '(' '[' EXPR optczapc ']' ',' zireg optcexpr ')'
346 op->mode = POST;
347 op->reg = $4;
348 op->disp = $3;
349 op->index = $7;
350 op->odisp = $8;
352 | '(' '[' EXPR optczapc ']' optcexpr ')'
354 op->mode = POST;
355 op->reg = $4;
356 op->disp = $3;
357 op->odisp = $6;
359 | '(' '[' zapc ']' ',' zireg optcexpr ')'
361 op->mode = POST;
362 op->reg = $3;
363 op->index = $6;
364 op->odisp = $7;
366 | '(' '[' zapc ']' optcexpr ')'
368 op->mode = POST;
369 op->reg = $3;
370 op->odisp = $5;
372 | '(' '[' EXPR ',' zapc ',' zireg ']' optcexpr ')'
374 op->mode = PRE;
375 op->reg = $5;
376 op->disp = $3;
377 op->index = $7;
378 op->odisp = $9;
380 | '(' '[' zapc ',' zireg ']' optcexpr ')'
382 op->mode = PRE;
383 op->reg = $3;
384 op->index = $5;
385 op->odisp = $7;
387 | '(' '[' EXPR ',' zapc ',' zpc ']' optcexpr ')'
389 if ($5 == PC || $5 == ZPC)
390 yyerror (_("syntax error"));
391 op->mode = PRE;
392 op->reg = $7;
393 op->disp = $3;
394 op->index.reg = $5;
395 op->index.size = SIZE_UNSPEC;
396 op->index.scale = 1;
397 op->odisp = $9;
399 | '(' '[' zapc ',' zpc ']' optcexpr ')'
401 if ($3 == PC || $3 == ZPC)
402 yyerror (_("syntax error"));
403 op->mode = PRE;
404 op->reg = $5;
405 op->index.reg = $3;
406 op->index.size = SIZE_UNSPEC;
407 op->index.scale = 1;
408 op->odisp = $7;
410 | '(' '[' optexprc zdireg optczapc ']' optcexpr ')'
412 op->mode = PRE;
413 op->reg = $5;
414 op->disp = $3;
415 op->index = $4;
416 op->odisp = $7;
420 /* An operand in MIT syntax. */
422 mit_operand:
423 optzapc '@'
425 /* We use optzapc to avoid a shift/reduce conflict. */
426 if ($1 < ADDR0 || $1 > ADDR7)
427 yyerror (_("syntax error"));
428 op->mode = AINDR;
429 op->reg = $1;
431 | optzapc '@' '+'
433 /* We use optzapc to avoid a shift/reduce conflict. */
434 if ($1 < ADDR0 || $1 > ADDR7)
435 yyerror (_("syntax error"));
436 op->mode = AINC;
437 op->reg = $1;
439 | optzapc '@' '-'
441 /* We use optzapc to avoid a shift/reduce conflict. */
442 if ($1 < ADDR0 || $1 > ADDR7)
443 yyerror (_("syntax error"));
444 op->mode = ADEC;
445 op->reg = $1;
447 | optzapc '@' '(' EXPR ')'
449 op->reg = $1;
450 op->disp = $4;
451 if (($1 >= ZADDR0 && $1 <= ZADDR7)
452 || $1 == ZPC)
453 op->mode = BASE;
454 else
455 op->mode = DISP;
457 | optzapc '@' '(' optexprc zireg ')'
459 op->mode = BASE;
460 op->reg = $1;
461 op->disp = $4;
462 op->index = $5;
464 | optzapc '@' '(' EXPR ')' '@' '(' optexprc zireg ')'
466 op->mode = POST;
467 op->reg = $1;
468 op->disp = $4;
469 op->index = $9;
470 op->odisp = $8;
472 | optzapc '@' '(' EXPR ')' '@' '(' EXPR ')'
474 op->mode = POST;
475 op->reg = $1;
476 op->disp = $4;
477 op->odisp = $8;
479 | optzapc '@' '(' optexprc zireg ')' '@' '(' EXPR ')'
481 op->mode = PRE;
482 op->reg = $1;
483 op->disp = $4;
484 op->index = $5;
485 op->odisp = $9;
489 /* An index register, possibly suppressed, which need not have a size
490 or scale. */
492 zireg:
493 INDEXREG
494 | zadr
496 $$.reg = $1;
497 $$.size = SIZE_UNSPEC;
498 $$.scale = 1;
502 /* A register which may be an index register, but which may not be an
503 address register. This nonterminal is used to avoid ambiguity when
504 trying to parse something like (0,d5,a6) as compared to (0,a6,d5). */
506 zdireg:
507 INDEXREG
508 | zdr
510 $$.reg = $1;
511 $$.size = SIZE_UNSPEC;
512 $$.scale = 1;
516 /* An address or data register, or a suppressed address or data
517 register. */
519 zadr:
521 | AR
522 | ZAR
525 /* A data register which may be suppressed. */
527 zdr:
529 | ZDR
532 /* Either an address register or the PC. */
534 apc:
536 | LPC
539 /* Either an address register, or the PC, or a suppressed address
540 register, or a suppressed PC. */
542 zapc:
544 | LZPC
545 | ZAR
548 /* An optional zapc. */
550 optzapc:
551 /* empty */
553 $$ = ZADDR0;
555 | zapc
558 /* The PC, optionally suppressed. */
560 zpc:
562 | LZPC
565 /* ',' zapc when it may be omitted. */
567 optczapc:
568 /* empty */
570 $$ = ZADDR0;
572 | ',' zapc
574 $$ = $2;
578 /* ',' EXPR when it may be omitted. */
580 optcexpr:
581 /* empty */
583 $$.exp.X_op = O_absent;
584 $$.size = SIZE_UNSPEC;
586 | ',' EXPR
588 $$ = $2;
592 /* EXPR ',' when it may be omitted. */
594 optexprc:
595 /* empty */
597 $$.exp.X_op = O_absent;
598 $$.size = SIZE_UNSPEC;
600 | EXPR ','
602 $$ = $1;
606 /* A register list for the movem instruction. */
608 reglist:
609 reglistpair
610 | reglistpair '/' ireglist
612 $$ = $1 | $3;
614 | reglistreg '/' ireglist
616 $$ = (1 << $1) | $3;
620 /* We use ireglist when we know we are looking at a reglist, and we
621 can safely reduce a simple register to reglistreg. If we permitted
622 reglist to reduce to reglistreg, it would be ambiguous whether a
623 plain register were a DREG/AREG/FPREG or a REGLST. */
625 ireglist:
626 reglistreg
628 $$ = 1 << $1;
630 | reglistpair
631 | reglistpair '/' ireglist
633 $$ = $1 | $3;
635 | reglistreg '/' ireglist
637 $$ = (1 << $1) | $3;
641 reglistpair:
642 reglistreg '-' reglistreg
644 if ($1 <= $3)
645 $$ = (1 << ($3 + 1)) - 1 - ((1 << $1) - 1);
646 else
647 $$ = (1 << ($1 + 1)) - 1 - ((1 << $3) - 1);
651 reglistreg:
654 $$ = $1 - DATA0;
656 | AR
658 $$ = $1 - ADDR0 + 8;
660 | FPR
662 $$ = $1 - FP0 + 16;
664 | FPCR
666 if ($1 == FPI)
667 $$ = 24;
668 else if ($1 == FPS)
669 $$ = 25;
670 else
671 $$ = 26;
677 /* The string to parse is stored here, and modified by yylex. */
679 static char *str;
681 /* The original string pointer. */
683 static char *strorig;
685 /* If *CCP could be a register, return the register number and advance
686 *CCP. Otherwise don't change *CCP, and return 0. */
688 static enum m68k_register
689 m68k_reg_parse (ccp)
690 register char **ccp;
692 char *start = *ccp;
693 char c;
694 char *p;
695 symbolS *symbolp;
697 if (flag_reg_prefix_optional)
699 if (*start == REGISTER_PREFIX)
700 start++;
701 p = start;
703 else
705 if (*start != REGISTER_PREFIX)
706 return 0;
707 p = start + 1;
710 if (! is_name_beginner (*p))
711 return 0;
713 p++;
714 while (is_part_of_name (*p) && *p != '.' && *p != ':' && *p != '*')
715 p++;
717 c = *p;
718 *p = 0;
719 symbolp = symbol_find (start);
720 *p = c;
722 if (symbolp != NULL && S_GET_SEGMENT (symbolp) == reg_section)
724 *ccp = p;
725 return S_GET_VALUE (symbolp);
728 /* In MRI mode, something like foo.bar can be equated to a register
729 name. */
730 while (flag_mri && c == '.')
732 ++p;
733 while (is_part_of_name (*p) && *p != '.' && *p != ':' && *p != '*')
734 p++;
735 c = *p;
736 *p = '\0';
737 symbolp = symbol_find (start);
738 *p = c;
739 if (symbolp != NULL && S_GET_SEGMENT (symbolp) == reg_section)
741 *ccp = p;
742 return S_GET_VALUE (symbolp);
746 return 0;
749 /* The lexer. */
751 static int
752 yylex ()
754 enum m68k_register reg;
755 char *s;
756 int parens;
757 int c = 0;
758 int tail = 0;
759 char *hold;
761 if (*str == ' ')
762 ++str;
764 if (*str == '\0')
765 return 0;
767 /* Various special characters are just returned directly. */
768 switch (*str)
770 case '@':
771 /* In MRI mode, this can be the start of an octal number. */
772 if (flag_mri)
774 if (ISDIGIT (str[1])
775 || ((str[1] == '+' || str[1] == '-')
776 && ISDIGIT (str[2])))
777 break;
779 /* Fall through. */
780 case '#':
781 case '&':
782 case ',':
783 case ')':
784 case '/':
785 case '[':
786 case ']':
787 case '<':
788 case '>':
789 return *str++;
790 case '+':
791 /* It so happens that a '+' can only appear at the end of an
792 operand, or if it is trailed by an '&'(see mac load insn).
793 If it appears anywhere else, it must be a unary. */
794 if (str[1] == '\0' || (str[1] == '&' && str[2] == '\0'))
795 return *str++;
796 break;
797 case '-':
798 /* A '-' can only appear in -(ar), rn-rn, or ar@-. If it
799 appears anywhere else, it must be a unary minus on an
800 expression, unless it it trailed by a '&'(see mac load insn). */
801 if (str[1] == '\0' || (str[1] == '&' && str[2] == '\0'))
802 return *str++;
803 s = str + 1;
804 if (*s == '(')
805 ++s;
806 if (m68k_reg_parse (&s) != 0)
807 return *str++;
808 break;
809 case '(':
810 /* A '(' can only appear in `(reg)', `(expr,...', `([', `@(', or
811 `)('. If it appears anywhere else, it must be starting an
812 expression. */
813 if (str[1] == '['
814 || (str > strorig
815 && (str[-1] == '@'
816 || str[-1] == ')')))
817 return *str++;
818 s = str + 1;
819 if (m68k_reg_parse (&s) != 0)
820 return *str++;
821 /* Check for the case of '(expr,...' by scanning ahead. If we
822 find a comma outside of balanced parentheses, we return '('.
823 If we find an unbalanced right parenthesis, then presumably
824 the '(' really starts an expression. */
825 parens = 0;
826 for (s = str + 1; *s != '\0'; s++)
828 if (*s == '(')
829 ++parens;
830 else if (*s == ')')
832 if (parens == 0)
833 break;
834 --parens;
836 else if (*s == ',' && parens == 0)
838 /* A comma can not normally appear in an expression, so
839 this is a case of '(expr,...'. */
840 return *str++;
845 /* See if it's a register. */
847 reg = m68k_reg_parse (&str);
848 if (reg != 0)
850 int ret;
852 yylval.reg = reg;
854 if (reg >= DATA0 && reg <= DATA7)
855 ret = DR;
856 else if (reg >= ADDR0 && reg <= ADDR7)
857 ret = AR;
858 else if (reg >= FP0 && reg <= FP7)
859 return FPR;
860 else if (reg == FPI
861 || reg == FPS
862 || reg == FPC)
863 return FPCR;
864 else if (reg == PC)
865 return LPC;
866 else if (reg >= ZDATA0 && reg <= ZDATA7)
867 ret = ZDR;
868 else if (reg >= ZADDR0 && reg <= ZADDR7)
869 ret = ZAR;
870 else if (reg == ZPC)
871 return LZPC;
872 else
873 return CREG;
875 /* If we get here, we have a data or address register. We
876 must check for a size or scale; if we find one, we must
877 return INDEXREG. */
879 s = str;
881 if (*s != '.' && *s != ':' && *s != '*')
882 return ret;
884 yylval.indexreg.reg = reg;
886 if (*s != '.' && *s != ':')
887 yylval.indexreg.size = SIZE_UNSPEC;
888 else
890 ++s;
891 switch (*s)
893 case 'w':
894 case 'W':
895 yylval.indexreg.size = SIZE_WORD;
896 ++s;
897 break;
898 case 'l':
899 case 'L':
900 yylval.indexreg.size = SIZE_LONG;
901 ++s;
902 break;
903 default:
904 yyerror (_("illegal size specification"));
905 yylval.indexreg.size = SIZE_UNSPEC;
906 break;
910 yylval.indexreg.scale = 1;
912 if (*s == '*' || *s == ':')
914 expressionS scale;
916 ++s;
918 hold = input_line_pointer;
919 input_line_pointer = s;
920 expression (&scale);
921 s = input_line_pointer;
922 input_line_pointer = hold;
924 if (scale.X_op != O_constant)
925 yyerror (_("scale specification must resolve to a number"));
926 else
928 switch (scale.X_add_number)
930 case 1:
931 case 2:
932 case 4:
933 case 8:
934 yylval.indexreg.scale = scale.X_add_number;
935 break;
936 default:
937 yyerror (_("invalid scale value"));
938 break;
943 str = s;
945 return INDEXREG;
948 /* It must be an expression. Before we call expression, we need to
949 look ahead to see if there is a size specification. We must do
950 that first, because otherwise foo.l will be treated as the symbol
951 foo.l, rather than as the symbol foo with a long size
952 specification. The grammar requires that all expressions end at
953 the end of the operand, or with ',', '(', ']', ')'. */
955 parens = 0;
956 for (s = str; *s != '\0'; s++)
958 if (*s == '(')
960 if (parens == 0
961 && s > str
962 && (s[-1] == ')' || ISALNUM (s[-1])))
963 break;
964 ++parens;
966 else if (*s == ')')
968 if (parens == 0)
969 break;
970 --parens;
972 else if (parens == 0
973 && (*s == ',' || *s == ']'))
974 break;
977 yylval.exp.size = SIZE_UNSPEC;
978 if (s <= str + 2
979 || (s[-2] != '.' && s[-2] != ':'))
980 tail = 0;
981 else
983 switch (s[-1])
985 case 's':
986 case 'S':
987 case 'b':
988 case 'B':
989 yylval.exp.size = SIZE_BYTE;
990 break;
991 case 'w':
992 case 'W':
993 yylval.exp.size = SIZE_WORD;
994 break;
995 case 'l':
996 case 'L':
997 yylval.exp.size = SIZE_LONG;
998 break;
999 default:
1000 break;
1002 if (yylval.exp.size != SIZE_UNSPEC)
1003 tail = 2;
1006 #ifdef OBJ_ELF
1008 /* Look for @PLTPC, etc. */
1009 char *cp;
1011 yylval.exp.pic_reloc = pic_none;
1012 cp = s - tail;
1013 if (cp - 7 > str && cp[-7] == '@')
1015 if (strncmp (cp - 7, "@TLSLDM", 7) == 0)
1017 yylval.exp.pic_reloc = pic_tls_ldm;
1018 tail += 7;
1020 else if (strncmp (cp - 7, "@TLSLDO", 7) == 0)
1022 yylval.exp.pic_reloc = pic_tls_ldo;
1023 tail += 7;
1026 else if (cp - 6 > str && cp[-6] == '@')
1028 if (strncmp (cp - 6, "@PLTPC", 6) == 0)
1030 yylval.exp.pic_reloc = pic_plt_pcrel;
1031 tail += 6;
1033 else if (strncmp (cp - 6, "@GOTPC", 6) == 0)
1035 yylval.exp.pic_reloc = pic_got_pcrel;
1036 tail += 6;
1038 else if (strncmp (cp - 6, "@TLSGD", 6) == 0)
1040 yylval.exp.pic_reloc = pic_tls_gd;
1041 tail += 6;
1043 else if (strncmp (cp - 6, "@TLSIE", 6) == 0)
1045 yylval.exp.pic_reloc = pic_tls_ie;
1046 tail += 6;
1048 else if (strncmp (cp - 6, "@TLSLE", 6) == 0)
1050 yylval.exp.pic_reloc = pic_tls_le;
1051 tail += 6;
1054 else if (cp - 4 > str && cp[-4] == '@')
1056 if (strncmp (cp - 4, "@PLT", 4) == 0)
1058 yylval.exp.pic_reloc = pic_plt_off;
1059 tail += 4;
1061 else if (strncmp (cp - 4, "@GOT", 4) == 0)
1063 yylval.exp.pic_reloc = pic_got_off;
1064 tail += 4;
1068 #endif
1070 if (tail != 0)
1072 c = s[-tail];
1073 s[-tail] = 0;
1076 hold = input_line_pointer;
1077 input_line_pointer = str;
1078 expression (&yylval.exp.exp);
1079 str = input_line_pointer;
1080 input_line_pointer = hold;
1082 if (tail != 0)
1084 s[-tail] = c;
1085 str = s;
1088 return EXPR;
1091 /* Parse an m68k operand. This is the only function which is called
1092 from outside this file. */
1095 m68k_ip_op (s, oparg)
1096 char *s;
1097 struct m68k_op *oparg;
1099 memset (oparg, 0, sizeof *oparg);
1100 oparg->error = NULL;
1101 oparg->index.reg = ZDATA0;
1102 oparg->index.scale = 1;
1103 oparg->disp.exp.X_op = O_absent;
1104 oparg->odisp.exp.X_op = O_absent;
1106 str = strorig = s;
1107 op = oparg;
1109 return yyparse ();
1112 /* The error handler. */
1114 static void
1115 yyerror (s)
1116 const char *s;
1118 op->error = s;