1 /* bfin-parse.y ADI Blackfin parser
2 Copyright 2005, 2006, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
26 #include "bfin-aux.h" /* Opcode generating auxiliaries. */
28 #include "elf/common.h"
31 #define DSP32ALU(aopcde, HL, dst1, dst0, src0, src1, s, x, aop) \
32 bfin_gen_dsp32alu (HL, aopcde, aop, s, x, dst0, dst1, src0, src1)
34 #define DSP32MAC(op1, MM, mmod, w1, P, h01, h11, h00, h10, dst, op0, src0, src1, w0) \
35 bfin_gen_dsp32mac (op1, MM, mmod, w1, P, h01, h11, h00, h10, op0, \
38 #define DSP32MULT(op1, MM, mmod, w1, P, h01, h11, h00, h10, dst, op0, src0, src1, w0) \
39 bfin_gen_dsp32mult (op1, MM, mmod, w1, P, h01, h11, h00, h10, op0, \
42 #define DSP32SHIFT(sopcde, dst0, src0, src1, sop, hls) \
43 bfin_gen_dsp32shift (sopcde, dst0, src0, src1, sop, hls)
45 #define DSP32SHIFTIMM(sopcde, dst0, immag, src1, sop, hls) \
46 bfin_gen_dsp32shiftimm (sopcde, dst0, immag, src1, sop, hls)
48 #define LDIMMHALF_R(reg, h, s, z, hword) \
49 bfin_gen_ldimmhalf (reg, h, s, z, hword, 1)
51 #define LDIMMHALF_R5(reg, h, s, z, hword) \
52 bfin_gen_ldimmhalf (reg, h, s, z, hword, 2)
54 #define LDSTIDXI(ptr, reg, w, sz, z, offset) \
55 bfin_gen_ldstidxi (ptr, reg, w, sz, z, offset)
57 #define LDST(ptr, reg, aop, sz, z, w) \
58 bfin_gen_ldst (ptr, reg, aop, sz, z, w)
60 #define LDSTII(ptr, reg, offset, w, op) \
61 bfin_gen_ldstii (ptr, reg, offset, w, op)
63 #define DSPLDST(i, m, reg, aop, w) \
64 bfin_gen_dspldst (i, reg, aop, w, m)
66 #define LDSTPMOD(ptr, reg, idx, aop, w) \
67 bfin_gen_ldstpmod (ptr, reg, aop, w, idx)
69 #define LDSTIIFP(offset, reg, w) \
70 bfin_gen_ldstiifp (reg, offset, w)
72 #define LOGI2OP(dst, src, opc) \
73 bfin_gen_logi2op (opc, src, dst.regno & CODE_MASK)
75 #define ALU2OP(dst, src, opc) \
76 bfin_gen_alu2op (dst, src, opc)
78 #define BRCC(t, b, offset) \
79 bfin_gen_brcc (t, b, offset)
81 #define UJUMP(offset) \
82 bfin_gen_ujump (offset)
84 #define PROGCTRL(prgfunc, poprnd) \
85 bfin_gen_progctrl (prgfunc, poprnd)
87 #define PUSHPOPMULTIPLE(dr, pr, d, p, w) \
88 bfin_gen_pushpopmultiple (dr, pr, d, p, w)
90 #define PUSHPOPREG(reg, w) \
91 bfin_gen_pushpopreg (reg, w)
93 #define CALLA(addr, s) \
94 bfin_gen_calla (addr, s)
96 #define LINKAGE(r, framesize) \
97 bfin_gen_linkage (r, framesize)
99 #define COMPI2OPD(dst, src, op) \
100 bfin_gen_compi2opd (dst, src, op)
102 #define COMPI2OPP(dst, src, op) \
103 bfin_gen_compi2opp (dst, src, op)
105 #define DAGMODIK(i, op) \
106 bfin_gen_dagmodik (i, op)
108 #define DAGMODIM(i, m, op, br) \
109 bfin_gen_dagmodim (i, m, op, br)
111 #define COMP3OP(dst, src0, src1, opc) \
112 bfin_gen_comp3op (src0, src1, dst, opc)
114 #define PTR2OP(dst, src, opc) \
115 bfin_gen_ptr2op (dst, src, opc)
117 #define CCFLAG(x, y, opc, i, g) \
118 bfin_gen_ccflag (x, y, opc, i, g)
120 #define CCMV(src, dst, t) \
121 bfin_gen_ccmv (src, dst, t)
123 #define CACTRL(reg, a, op) \
124 bfin_gen_cactrl (reg, a, op)
126 #define LOOPSETUP(soffset, c, rop, eoffset, reg) \
127 bfin_gen_loopsetup (soffset, c, rop, eoffset, reg)
129 #define HL2(r1, r0) (IS_H (r1) << 1 | IS_H (r0))
130 #define IS_RANGE(bits, expr, sign, mul) \
131 value_match(expr, bits, sign, mul, 1)
132 #define IS_URANGE(bits, expr, sign, mul) \
133 value_match(expr, bits, sign, mul, 0)
134 #define IS_CONST(expr) (expr->type == Expr_Node_Constant)
135 #define IS_RELOC(expr) (expr->type != Expr_Node_Constant)
136 #define IS_IMM(expr, bits) value_match (expr, bits, 0, 1, 1)
137 #define IS_UIMM(expr, bits) value_match (expr, bits, 0, 1, 0)
139 #define IS_PCREL4(expr) \
140 (value_match (expr, 4, 0, 2, 0))
142 #define IS_LPPCREL10(expr) \
143 (value_match (expr, 10, 0, 2, 0))
145 #define IS_PCREL10(expr) \
146 (value_match (expr, 10, 0, 2, 1))
148 #define IS_PCREL12(expr) \
149 (value_match (expr, 12, 0, 2, 1))
151 #define IS_PCREL24(expr) \
152 (value_match (expr, 24, 0, 2, 1))
155 static int value_match (Expr_Node *, int, int, int, int);
160 static Expr_Node *binary (Expr_Op_Type, Expr_Node *, Expr_Node *);
161 static Expr_Node *unary (Expr_Op_Type, Expr_Node *);
163 static void notethat (char *, ...);
165 char *current_inputline;
167 int yyerror (char *);
169 void error (char *format, ...)
172 static char buffer[2000];
174 va_start (ap, format);
175 vsprintf (buffer, format, ap);
178 as_bad ("%s", buffer);
187 else if (yytext[0] != ';')
188 error ("%s. Input text was %s.", msg, yytext);
196 in_range_p (Expr_Node *exp, int from, int to, unsigned int mask)
198 int val = EXPR_VALUE (exp);
199 if (exp->type != Expr_Node_Constant)
201 if (val < from || val > to)
203 return (val & mask) == 0;
206 extern int yylex (void);
208 #define imm3(x) EXPR_VALUE (x)
209 #define imm4(x) EXPR_VALUE (x)
210 #define uimm4(x) EXPR_VALUE (x)
211 #define imm5(x) EXPR_VALUE (x)
212 #define uimm5(x) EXPR_VALUE (x)
213 #define imm6(x) EXPR_VALUE (x)
214 #define imm7(x) EXPR_VALUE (x)
215 #define imm16(x) EXPR_VALUE (x)
216 #define uimm16s4(x) ((EXPR_VALUE (x)) >> 2)
217 #define uimm16(x) EXPR_VALUE (x)
219 /* Return true if a value is inside a range. */
220 #define IN_RANGE(x, low, high) \
221 (((EXPR_VALUE(x)) >= (low)) && (EXPR_VALUE(x)) <= ((high)))
223 /* Auxiliary functions. */
226 valid_dreg_pair (Register *reg1, Expr_Node *reg2)
228 if (!IS_DREG (*reg1))
230 yyerror ("Dregs expected");
234 if (reg1->regno != 1 && reg1->regno != 3)
236 yyerror ("Bad register pair");
240 if (imm7 (reg2) != reg1->regno - 1)
242 yyerror ("Bad register pair");
251 check_multiply_halfregs (Macfunc *aa, Macfunc *ab)
253 if ((!REG_EQUAL (aa->s0, ab->s0) && !REG_EQUAL (aa->s0, ab->s1))
254 || (!REG_EQUAL (aa->s1, ab->s1) && !REG_EQUAL (aa->s1, ab->s0)))
255 return yyerror ("Source multiplication register mismatch");
261 /* Check mac option. */
264 check_macfunc_option (Macfunc *a, Opt_mode *opt)
266 /* Default option is always valid. */
270 if ((a->w == 1 && a->P == 1
271 && opt->mod != M_FU && opt->mod != M_IS && opt->mod != M_IU
272 && opt->mod != M_S2RND && opt->mod != M_ISS2)
273 || (a->w == 1 && a->P == 0
274 && opt->mod != M_FU && opt->mod != M_IS && opt->mod != M_IU
275 && opt->mod != M_T && opt->mod != M_TFU && opt->mod != M_S2RND
276 && opt->mod != M_ISS2 && opt->mod != M_IH)
277 || (a->w == 0 && a->P == 0
278 && opt->mod != M_FU && opt->mod != M_IS && opt->mod != M_W32))
284 /* Check (vector) mac funcs and ops. */
287 check_macfuncs (Macfunc *aa, Opt_mode *opa,
288 Macfunc *ab, Opt_mode *opb)
290 /* Variables for swapping. */
294 /* The option mode should be put at the end of the second instruction
295 of the vector except M, which should follow MAC1 instruction. */
297 return yyerror ("Bad opt mode");
299 /* If a0macfunc comes before a1macfunc, swap them. */
303 /* (M) is not allowed here. */
305 return yyerror ("(M) not allowed with A0MAC");
307 return yyerror ("Vector AxMACs can't be same");
309 mtmp = *aa; *aa = *ab; *ab = mtmp;
310 otmp = *opa; *opa = *opb; *opb = otmp;
315 return yyerror ("(M) not allowed with A0MAC");
317 return yyerror ("Vector AxMACs can't be same");
320 /* If both ops are one of 0, 1, or 2, we have multiply_halfregs in both
321 assignment_or_macfuncs. */
322 if ((aa->op == 0 || aa->op == 1 || aa->op == 2)
323 && (ab->op == 0 || ab->op == 1 || ab->op == 2))
325 if (check_multiply_halfregs (aa, ab) < 0)
330 /* Only one of the assign_macfuncs has a half reg multiply
331 Evil trick: Just 'OR' their source register codes:
332 We can do that, because we know they were initialized to 0
333 in the rules that don't use multiply_halfregs. */
334 aa->s0.regno |= (ab->s0.regno & CODE_MASK);
335 aa->s1.regno |= (ab->s1.regno & CODE_MASK);
338 if (aa->w == ab->w && aa->P != ab->P)
340 return yyerror ("macfuncs must differ");
341 if (aa->w && (aa->dst.regno - ab->dst.regno != 1))
342 return yyerror ("Destination Dregs must differ by one");
345 /* Make sure mod flags get ORed, too. */
346 opb->mod |= opa->mod;
349 if (check_macfunc_option (aa, opb) < 0
350 && check_macfunc_option (ab, opb) < 0)
351 return yyerror ("bad option");
353 /* Make sure first macfunc has got both P flags ORed. */
361 is_group1 (INSTR_T x)
363 /* Group1 is dpsLDST, LDSTpmod, LDST, LDSTiiFP, LDSTii. */
364 if ((x->value & 0xc000) == 0x8000 || (x->value == 0x0000))
371 is_group2 (INSTR_T x)
373 if ((((x->value & 0xfc00) == 0x9c00) /* dspLDST. */
374 && !((x->value & 0xfde0) == 0x9c60) /* dagMODim. */
375 && !((x->value & 0xfde0) == 0x9ce0) /* dagMODim with bit rev. */
376 && !((x->value & 0xfde0) == 0x9d60)) /* pick dagMODik. */
377 || (x->value == 0x0000))
383 gen_multi_instr_1 (INSTR_T dsp32, INSTR_T dsp16_grp1, INSTR_T dsp16_grp2)
385 int mask1 = dsp32 ? insn_regmask (dsp32->value, dsp32->next->value) : 0;
386 int mask2 = dsp16_grp1 ? insn_regmask (dsp16_grp1->value, 0) : 0;
387 int mask3 = dsp16_grp2 ? insn_regmask (dsp16_grp2->value, 0) : 0;
389 if ((mask1 & mask2) || (mask1 & mask3) || (mask2 & mask3))
390 yyerror ("resource conflict in multi-issue instruction");
392 /* Anomaly 05000074 */
393 if (ENABLE_AC_05000074
394 && dsp32 != NULL && dsp16_grp1 != NULL
395 && (dsp32->value & 0xf780) == 0xc680
396 && ((dsp16_grp1->value & 0xfe40) == 0x9240
397 || (dsp16_grp1->value & 0xfe08) == 0xba08
398 || (dsp16_grp1->value & 0xfc00) == 0xbc00))
399 yyerror ("anomaly 05000074 - Multi-Issue Instruction with \
400 dsp32shiftimm in slot1 and P-reg Store in slot2 Not Supported");
402 return bfin_gen_multi_instr (dsp32, dsp16_grp1, dsp16_grp2);
414 struct { int r0; int s0; int x0; int aop; } modcodes;
415 struct { int r0; } r0;
422 /* Vector Specific. */
423 %token BYTEOP16P BYTEOP16M
424 %token BYTEOP1P BYTEOP2P BYTEOP2M BYTEOP3P
425 %token BYTEUNPACK BYTEPACK
428 %token ALIGN8 ALIGN16 ALIGN24
430 %token EXTRACT DEPOSIT EXPADJ SEARCH
431 %token ONES SIGN SIGNBITS
439 %token CCREG BYTE_DREG
440 %token REG_A_DOUBLE_ZERO REG_A_DOUBLE_ONE
441 %token A_ZERO_DOT_L A_ZERO_DOT_H A_ONE_DOT_L A_ONE_DOT_H
446 %token RTI RTS RTX RTN RTE
457 %token JUMP JUMP_DOT_S JUMP_DOT_L
464 %token NOT TILDA BANG
470 %token MINUS PLUS STAR SLASH
474 %token _PLUS_BAR_PLUS _PLUS_BAR_MINUS _MINUS_BAR_PLUS _MINUS_BAR_MINUS
475 %token _MINUS_MINUS _PLUS_PLUS
477 /* Shift/rotate ops. */
478 %token SHIFT LSHIFT ASHIFT BXORSHIFT
479 %token _GREATER_GREATER_GREATER_THAN_ASSIGN
481 %token LESS_LESS GREATER_GREATER
482 %token _GREATER_GREATER_GREATER
483 %token _LESS_LESS_ASSIGN _GREATER_GREATER_ASSIGN
486 /* In place operators. */
487 %token ASSIGN _STAR_ASSIGN
488 %token _BAR_ASSIGN _CARET_ASSIGN _AMPERSAND_ASSIGN
489 %token _MINUS_ASSIGN _PLUS_ASSIGN
491 /* Assignments, comparisons. */
492 %token _ASSIGN_BANG _LESS_THAN_ASSIGN _ASSIGN_ASSIGN
497 %token FLUSHINV FLUSH
498 %token IFLUSH PREFETCH
515 %token R RND RNDL RNDH RND12 RND20
520 %token BITTGL BITCLR BITSET BITTST BITMUX
523 %token DBGAL DBGAH DBGHALT DBG DBGA DBGCMPLX
525 /* Semantic auxiliaries. */
528 %token COLON SEMICOLON
529 %token RPAREN LPAREN LBRACK RBRACK
533 %token GOT GOT17M4 FUNCDESC_GOT17M4
543 %type <modcodes> byteop_mod
545 %type <reg> a_plusassign
546 %type <reg> a_minusassign
547 %type <macfunc> multiply_halfregs
548 %type <macfunc> assign_macfunc
549 %type <macfunc> a_macfunc
553 %type <modcodes> vsmod
554 %type <modcodes> ccstat
557 %type <reg> reg_with_postinc
558 %type <reg> reg_with_predec
562 %type <symbol> SYMBOL
565 %type <reg> BYTE_DREG
566 %type <reg> REG_A_DOUBLE_ZERO
567 %type <reg> REG_A_DOUBLE_ONE
569 %type <reg> STATUS_REG
573 %type <modcodes> smod
574 %type <modcodes> b3_op
575 %type <modcodes> rnd_op
576 %type <modcodes> post_op
578 %type <r0> iu_or_nothing
579 %type <r0> plus_minus
583 %type <modcodes> amod0
584 %type <modcodes> amod1
585 %type <modcodes> amod2
587 %type <r0> w32_or_nothing
591 %type <expr> got_or_expr
593 %type <value> any_gotrel GOT GOT17M4 FUNCDESC_GOT17M4
595 /* Precedence rules. */
599 %left LESS_LESS GREATER_GREATER
601 %left STAR SLASH PERCENT
612 if (insn == (INSTR_T) 0)
613 return NO_INSN_GENERATED;
614 else if (insn == (INSTR_T) - 1)
615 return SEMANTIC_ERROR;
617 return INSN_GENERATED;
622 /* Parallel instructions. */
623 | asm_1 DOUBLE_BAR asm_1 DOUBLE_BAR asm_1 SEMICOLON
625 if (($1->value & 0xf800) == 0xc000)
627 if (is_group1 ($3) && is_group2 ($5))
628 $$ = gen_multi_instr_1 ($1, $3, $5);
629 else if (is_group2 ($3) && is_group1 ($5))
630 $$ = gen_multi_instr_1 ($1, $5, $3);
632 return yyerror ("Wrong 16 bit instructions groups, slot 2 and slot 3 must be 16-bit instrution group");
634 else if (($3->value & 0xf800) == 0xc000)
636 if (is_group1 ($1) && is_group2 ($5))
637 $$ = gen_multi_instr_1 ($3, $1, $5);
638 else if (is_group2 ($1) && is_group1 ($5))
639 $$ = gen_multi_instr_1 ($3, $5, $1);
641 return yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 3 must be 16-bit instrution group");
643 else if (($5->value & 0xf800) == 0xc000)
645 if (is_group1 ($1) && is_group2 ($3))
646 $$ = gen_multi_instr_1 ($5, $1, $3);
647 else if (is_group2 ($1) && is_group1 ($3))
648 $$ = gen_multi_instr_1 ($5, $3, $1);
650 return yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 2 must be 16-bit instrution group");
653 error ("\nIllegal Multi Issue Construct, at least any one of the slot must be DSP32 instruction group\n");
656 | asm_1 DOUBLE_BAR asm_1 SEMICOLON
658 if (($1->value & 0xf800) == 0xc000)
661 $$ = gen_multi_instr_1 ($1, $3, 0);
662 else if (is_group2 ($3))
663 $$ = gen_multi_instr_1 ($1, 0, $3);
665 return yyerror ("Wrong 16 bit instructions groups, slot 2 must be the 16-bit instruction group");
667 else if (($3->value & 0xf800) == 0xc000)
670 $$ = gen_multi_instr_1 ($3, $1, 0);
671 else if (is_group2 ($1))
672 $$ = gen_multi_instr_1 ($3, 0, $1);
674 return yyerror ("Wrong 16 bit instructions groups, slot 1 must be the 16-bit instruction group");
676 else if (is_group1 ($1) && is_group2 ($3))
677 $$ = gen_multi_instr_1 (0, $1, $3);
678 else if (is_group2 ($1) && is_group1 ($3))
679 $$ = gen_multi_instr_1 (0, $3, $1);
681 return yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 2 must be the 16-bit instruction group");
696 $$ = DSP32MAC (3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0);
698 | assign_macfunc opt_mode
702 int h00, h10, h01, h11;
704 if (check_macfunc_option (&$1, &$2) < 0)
705 return yyerror ("bad option");
710 return yyerror ("(m) not allowed with a0 unit");
729 $$ = DSP32MAC (op1, $2.MM, $2.mod, w1, $1.P, h01, h11, h00, h10,
730 &$1.dst, op0, &$1.s0, &$1.s1, w0);
736 | assign_macfunc opt_mode COMMA assign_macfunc opt_mode
740 if (check_macfuncs (&$1, &$2, &$4, &$5) < 0)
742 notethat ("assign_macfunc (.), assign_macfunc (.)\n");
749 $$ = DSP32MAC ($1.op, $2.MM, $5.mod, $1.w, $1.P,
750 IS_H ($1.s0), IS_H ($1.s1), IS_H ($4.s0), IS_H ($4.s1),
751 dst, $4.op, &$1.s0, &$1.s1, $4.w);
758 notethat ("dsp32alu: DISALGNEXCPT\n");
759 $$ = DSP32ALU (18, 0, 0, 0, 0, 0, 0, 0, 3);
761 | REG ASSIGN LPAREN a_plusassign REG_A RPAREN
763 if (IS_DREG ($1) && !IS_A1 ($4) && IS_A1 ($5))
765 notethat ("dsp32alu: dregs = ( A0 += A1 )\n");
766 $$ = DSP32ALU (11, 0, 0, &$1, 0, 0, 0, 0, 0);
769 return yyerror ("Register mismatch");
771 | HALF_REG ASSIGN LPAREN a_plusassign REG_A RPAREN
773 if (!IS_A1 ($4) && IS_A1 ($5))
775 notethat ("dsp32alu: dregs_half = ( A0 += A1 )\n");
776 $$ = DSP32ALU (11, IS_H ($1), 0, &$1, 0, 0, 0, 0, 1);
779 return yyerror ("Register mismatch");
781 | A_ZERO_DOT_H ASSIGN HALF_REG
783 notethat ("dsp32alu: A_ZERO_DOT_H = dregs_hi\n");
784 $$ = DSP32ALU (9, IS_H ($3), 0, 0, &$3, 0, 0, 0, 0);
786 | A_ONE_DOT_H ASSIGN HALF_REG
788 notethat ("dsp32alu: A_ZERO_DOT_H = dregs_hi\n");
789 $$ = DSP32ALU (9, IS_H ($3), 0, 0, &$3, 0, 0, 0, 2);
791 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEOP16P LPAREN REG
792 COLON expr COMMA REG COLON expr RPAREN aligndir
794 if (!IS_DREG ($2) || !IS_DREG ($4))
795 return yyerror ("Dregs expected");
796 else if (!valid_dreg_pair (&$9, $11))
797 return yyerror ("Bad dreg pair");
798 else if (!valid_dreg_pair (&$13, $15))
799 return yyerror ("Bad dreg pair");
802 notethat ("dsp32alu: (dregs , dregs ) = BYTEOP16P (dregs_pair , dregs_pair ) (half)\n");
803 $$ = DSP32ALU (21, 0, &$2, &$4, &$9, &$13, $17.r0, 0, 0);
807 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEOP16M LPAREN REG COLON expr COMMA
808 REG COLON expr RPAREN aligndir
810 if (!IS_DREG ($2) || !IS_DREG ($4))
811 return yyerror ("Dregs expected");
812 else if (!valid_dreg_pair (&$9, $11))
813 return yyerror ("Bad dreg pair");
814 else if (!valid_dreg_pair (&$13, $15))
815 return yyerror ("Bad dreg pair");
818 notethat ("dsp32alu: (dregs , dregs ) = BYTEOP16M (dregs_pair , dregs_pair ) (aligndir)\n");
819 $$ = DSP32ALU (21, 0, &$2, &$4, &$9, &$13, $17.r0, 0, 1);
823 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEUNPACK REG COLON expr aligndir
825 if (!IS_DREG ($2) || !IS_DREG ($4))
826 return yyerror ("Dregs expected");
827 else if (!valid_dreg_pair (&$8, $10))
828 return yyerror ("Bad dreg pair");
831 notethat ("dsp32alu: (dregs , dregs ) = BYTEUNPACK dregs_pair (aligndir)\n");
832 $$ = DSP32ALU (24, 0, &$2, &$4, &$8, 0, $11.r0, 0, 1);
835 | LPAREN REG COMMA REG RPAREN ASSIGN SEARCH REG LPAREN searchmod RPAREN
837 if (IS_DREG ($2) && IS_DREG ($4) && IS_DREG ($8))
839 notethat ("dsp32alu: (dregs , dregs ) = SEARCH dregs (searchmod)\n");
840 $$ = DSP32ALU (13, 0, &$2, &$4, &$8, 0, 0, 0, $10.r0);
843 return yyerror ("Register mismatch");
845 | REG ASSIGN A_ONE_DOT_L PLUS A_ONE_DOT_H COMMA
846 REG ASSIGN A_ZERO_DOT_L PLUS A_ZERO_DOT_H
848 if (IS_DREG ($1) && IS_DREG ($7))
850 notethat ("dsp32alu: dregs = A1.l + A1.h, dregs = A0.l + A0.h \n");
851 $$ = DSP32ALU (12, 0, &$1, &$7, 0, 0, 0, 0, 1);
854 return yyerror ("Register mismatch");
858 | REG ASSIGN REG_A PLUS REG_A COMMA REG ASSIGN REG_A MINUS REG_A amod1
860 if (IS_DREG ($1) && IS_DREG ($7) && !REG_SAME ($3, $5)
861 && IS_A1 ($9) && !IS_A1 ($11))
863 notethat ("dsp32alu: dregs = A1 + A0 , dregs = A1 - A0 (amod1)\n");
864 $$ = DSP32ALU (17, 0, &$1, &$7, 0, 0, $12.s0, $12.x0, 0);
867 else if (IS_DREG ($1) && IS_DREG ($7) && !REG_SAME ($3, $5)
868 && !IS_A1 ($9) && IS_A1 ($11))
870 notethat ("dsp32alu: dregs = A0 + A1 , dregs = A0 - A1 (amod1)\n");
871 $$ = DSP32ALU (17, 0, &$1, &$7, 0, 0, $12.s0, $12.x0, 1);
874 return yyerror ("Register mismatch");
877 | REG ASSIGN REG plus_minus REG COMMA REG ASSIGN REG plus_minus REG amod1
880 return yyerror ("Operators must differ");
882 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5)
883 && REG_SAME ($3, $9) && REG_SAME ($5, $11))
885 notethat ("dsp32alu: dregs = dregs + dregs,"
886 "dregs = dregs - dregs (amod1)\n");
887 $$ = DSP32ALU (4, 0, &$1, &$7, &$3, &$5, $12.s0, $12.x0, 2);
890 return yyerror ("Register mismatch");
893 /* Bar Operations. */
895 | REG ASSIGN REG op_bar_op REG COMMA REG ASSIGN REG op_bar_op REG amod2
897 if (!REG_SAME ($3, $9) || !REG_SAME ($5, $11))
898 return yyerror ("Differing source registers");
900 if (!IS_DREG ($1) || !IS_DREG ($3) || !IS_DREG ($5) || !IS_DREG ($7))
901 return yyerror ("Dregs expected");
904 if ($4.r0 == 1 && $10.r0 == 2)
906 notethat ("dsp32alu: dregs = dregs .|. dregs , dregs = dregs .|. dregs (amod2)\n");
907 $$ = DSP32ALU (1, 1, &$1, &$7, &$3, &$5, $12.s0, $12.x0, $12.r0);
909 else if ($4.r0 == 0 && $10.r0 == 3)
911 notethat ("dsp32alu: dregs = dregs .|. dregs , dregs = dregs .|. dregs (amod2)\n");
912 $$ = DSP32ALU (1, 0, &$1, &$7, &$3, &$5, $12.s0, $12.x0, $12.r0);
915 return yyerror ("Bar operand mismatch");
918 | REG ASSIGN ABS REG vmod
922 if (IS_DREG ($1) && IS_DREG ($4))
926 notethat ("dsp32alu: dregs = ABS dregs (v)\n");
931 /* Vector version of ABS. */
932 notethat ("dsp32alu: dregs = ABS dregs\n");
935 $$ = DSP32ALU (op, 0, 0, &$1, &$4, 0, 0, 0, 2);
938 return yyerror ("Dregs expected");
942 notethat ("dsp32alu: Ax = ABS Ax\n");
943 $$ = DSP32ALU (16, IS_A1 ($1), 0, 0, 0, 0, 0, 0, IS_A1 ($3));
945 | A_ZERO_DOT_L ASSIGN HALF_REG
949 notethat ("dsp32alu: A0.l = reg_half\n");
950 $$ = DSP32ALU (9, IS_H ($3), 0, 0, &$3, 0, 0, 0, 0);
953 return yyerror ("A0.l = Rx.l expected");
955 | A_ONE_DOT_L ASSIGN HALF_REG
959 notethat ("dsp32alu: A1.l = reg_half\n");
960 $$ = DSP32ALU (9, IS_H ($3), 0, 0, &$3, 0, 0, 0, 2);
963 return yyerror ("A1.l = Rx.l expected");
966 | REG ASSIGN c_align LPAREN REG COMMA REG RPAREN
968 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
970 notethat ("dsp32shift: dregs = ALIGN8 (dregs , dregs )\n");
971 $$ = DSP32SHIFT (13, &$1, &$7, &$5, $3.r0, 0);
974 return yyerror ("Dregs expected");
977 | REG ASSIGN BYTEOP1P LPAREN REG COLON expr COMMA REG COLON expr RPAREN byteop_mod
980 return yyerror ("Dregs expected");
981 else if (!valid_dreg_pair (&$5, $7))
982 return yyerror ("Bad dreg pair");
983 else if (!valid_dreg_pair (&$9, $11))
984 return yyerror ("Bad dreg pair");
987 notethat ("dsp32alu: dregs = BYTEOP1P (dregs_pair , dregs_pair ) (T)\n");
988 $$ = DSP32ALU (20, 0, 0, &$1, &$5, &$9, $13.s0, 0, $13.r0);
991 | REG ASSIGN BYTEOP1P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
994 return yyerror ("Dregs expected");
995 else if (!valid_dreg_pair (&$5, $7))
996 return yyerror ("Bad dreg pair");
997 else if (!valid_dreg_pair (&$9, $11))
998 return yyerror ("Bad dreg pair");
1001 notethat ("dsp32alu: dregs = BYTEOP1P (dregs_pair , dregs_pair ) (T)\n");
1002 $$ = DSP32ALU (20, 0, 0, &$1, &$5, &$9, 0, 0, 0);
1006 | REG ASSIGN BYTEOP2P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
1010 return yyerror ("Dregs expected");
1011 else if (!valid_dreg_pair (&$5, $7))
1012 return yyerror ("Bad dreg pair");
1013 else if (!valid_dreg_pair (&$9, $11))
1014 return yyerror ("Bad dreg pair");
1017 notethat ("dsp32alu: dregs = BYTEOP2P (dregs_pair , dregs_pair ) (rnd_op)\n");
1018 $$ = DSP32ALU (22, $13.r0, 0, &$1, &$5, &$9, $13.s0, $13.x0, $13.aop);
1022 | REG ASSIGN BYTEOP2M LPAREN REG COLON expr COMMA REG COLON expr RPAREN
1026 return yyerror ("Dregs expected");
1027 else if (!valid_dreg_pair (&$5, $7))
1028 return yyerror ("Bad dreg pair");
1029 else if (!valid_dreg_pair (&$9, $11))
1030 return yyerror ("Bad dreg pair");
1033 notethat ("dsp32alu: dregs = BYTEOP2P (dregs_pair , dregs_pair ) (rnd_op)\n");
1034 $$ = DSP32ALU (22, $13.r0, 0, &$1, &$5, &$9, $13.s0, 0, $13.x0);
1038 | REG ASSIGN BYTEOP3P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
1042 return yyerror ("Dregs expected");
1043 else if (!valid_dreg_pair (&$5, $7))
1044 return yyerror ("Bad dreg pair");
1045 else if (!valid_dreg_pair (&$9, $11))
1046 return yyerror ("Bad dreg pair");
1049 notethat ("dsp32alu: dregs = BYTEOP3P (dregs_pair , dregs_pair ) (b3_op)\n");
1050 $$ = DSP32ALU (23, $13.x0, 0, &$1, &$5, &$9, $13.s0, 0, 0);
1054 | REG ASSIGN BYTEPACK LPAREN REG COMMA REG RPAREN
1056 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
1058 notethat ("dsp32alu: dregs = BYTEPACK (dregs , dregs )\n");
1059 $$ = DSP32ALU (24, 0, 0, &$1, &$5, &$7, 0, 0, 0);
1062 return yyerror ("Dregs expected");
1065 | HALF_REG ASSIGN HALF_REG ASSIGN SIGN LPAREN HALF_REG RPAREN STAR
1066 HALF_REG PLUS SIGN LPAREN HALF_REG RPAREN STAR HALF_REG
1068 if (IS_HCOMPL ($1, $3) && IS_HCOMPL ($7, $14) && IS_HCOMPL ($10, $17))
1070 notethat ("dsp32alu: dregs_hi = dregs_lo ="
1071 "SIGN (dregs_hi) * dregs_hi + "
1072 "SIGN (dregs_lo) * dregs_lo \n");
1074 $$ = DSP32ALU (12, 0, 0, &$1, &$7, &$10, 0, 0, 0);
1077 return yyerror ("Dregs expected");
1079 | REG ASSIGN REG plus_minus REG amod1
1081 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1085 /* No saturation flag specified, generate the 16 bit variant. */
1086 notethat ("COMP3op: dregs = dregs +- dregs\n");
1087 $$ = COMP3OP (&$1, &$3, &$5, $4.r0);
1091 /* Saturation flag specified, generate the 32 bit variant. */
1092 notethat ("dsp32alu: dregs = dregs +- dregs (amod1)\n");
1093 $$ = DSP32ALU (4, 0, 0, &$1, &$3, &$5, $6.s0, $6.x0, $4.r0);
1097 if (IS_PREG ($1) && IS_PREG ($3) && IS_PREG ($5) && $4.r0 == 0)
1099 notethat ("COMP3op: pregs = pregs + pregs\n");
1100 $$ = COMP3OP (&$1, &$3, &$5, 5);
1103 return yyerror ("Dregs expected");
1105 | REG ASSIGN min_max LPAREN REG COMMA REG RPAREN vmod
1109 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
1116 notethat ("dsp32alu: dregs = {MIN|MAX} (dregs, dregs)\n");
1117 $$ = DSP32ALU (op, 0, 0, &$1, &$5, &$7, 0, 0, $3.r0);
1120 return yyerror ("Dregs expected");
1123 | a_assign MINUS REG_A
1125 notethat ("dsp32alu: Ax = - Ax\n");
1126 $$ = DSP32ALU (14, IS_A1 ($1), 0, 0, 0, 0, 0, 0, IS_A1 ($3));
1128 | HALF_REG ASSIGN HALF_REG plus_minus HALF_REG amod1
1130 notethat ("dsp32alu: dregs_lo = dregs_lo +- dregs_lo (amod1)\n");
1131 $$ = DSP32ALU (2 | $4.r0, IS_H ($1), 0, &$1, &$3, &$5,
1132 $6.s0, $6.x0, HL2 ($3, $5));
1134 | a_assign a_assign expr
1136 if (EXPR_VALUE ($3) == 0 && !REG_SAME ($1, $2))
1138 notethat ("dsp32alu: A1 = A0 = 0\n");
1139 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, 0, 0, 2);
1142 return yyerror ("Bad value, 0 expected");
1146 | a_assign REG_A LPAREN S RPAREN
1148 if (REG_SAME ($1, $2))
1150 notethat ("dsp32alu: Ax = Ax (S)\n");
1151 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, 1, 0, IS_A1 ($1));
1154 return yyerror ("Registers must be equal");
1157 | HALF_REG ASSIGN REG LPAREN RND RPAREN
1161 notethat ("dsp32alu: dregs_half = dregs (RND)\n");
1162 $$ = DSP32ALU (12, IS_H ($1), 0, &$1, &$3, 0, 0, 0, 3);
1165 return yyerror ("Dregs expected");
1168 | HALF_REG ASSIGN REG plus_minus REG LPAREN RND12 RPAREN
1170 if (IS_DREG ($3) && IS_DREG ($5))
1172 notethat ("dsp32alu: dregs_half = dregs (+-) dregs (RND12)\n");
1173 $$ = DSP32ALU (5, IS_H ($1), 0, &$1, &$3, &$5, 0, 0, $4.r0);
1176 return yyerror ("Dregs expected");
1179 | HALF_REG ASSIGN REG plus_minus REG LPAREN RND20 RPAREN
1181 if (IS_DREG ($3) && IS_DREG ($5))
1183 notethat ("dsp32alu: dregs_half = dregs -+ dregs (RND20)\n");
1184 $$ = DSP32ALU (5, IS_H ($1), 0, &$1, &$3, &$5, 0, 1, $4.r0 | 2);
1187 return yyerror ("Dregs expected");
1192 if (!REG_SAME ($1, $2))
1194 notethat ("dsp32alu: An = Am\n");
1195 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, IS_A1 ($1), 0, 3);
1198 return yyerror ("Accu reg arguments must differ");
1205 notethat ("dsp32alu: An = dregs\n");
1206 $$ = DSP32ALU (9, 0, 0, 0, &$2, 0, 1, 0, IS_A1 ($1) << 1);
1209 return yyerror ("Dregs expected");
1212 | REG ASSIGN HALF_REG xpmod
1216 if ($1.regno == REG_A0x && IS_DREG ($3))
1218 notethat ("dsp32alu: A0.x = dregs_lo\n");
1219 $$ = DSP32ALU (9, 0, 0, 0, &$3, 0, 0, 0, 1);
1221 else if ($1.regno == REG_A1x && IS_DREG ($3))
1223 notethat ("dsp32alu: A1.x = dregs_lo\n");
1224 $$ = DSP32ALU (9, 0, 0, 0, &$3, 0, 0, 0, 3);
1226 else if (IS_DREG ($1) && IS_DREG ($3))
1228 notethat ("ALU2op: dregs = dregs_lo\n");
1229 $$ = ALU2OP (&$1, &$3, 10 | ($4.r0 ? 0: 1));
1232 return yyerror ("Register mismatch");
1235 return yyerror ("Low reg expected");
1238 | HALF_REG ASSIGN expr
1240 notethat ("LDIMMhalf: pregs_half = imm16\n");
1242 if (!IS_DREG ($1) && !IS_PREG ($1) && !IS_IREG ($1)
1243 && !IS_MREG ($1) && !IS_BREG ($1) && !IS_LREG ($1))
1244 return yyerror ("Wrong register for load immediate");
1246 if (!IS_IMM ($3, 16) && !IS_UIMM ($3, 16))
1247 return yyerror ("Constant out of range");
1249 $$ = LDIMMHALF_R (&$1, IS_H ($1), 0, 0, $3);
1254 notethat ("dsp32alu: An = 0\n");
1257 return yyerror ("0 expected");
1259 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, 0, 0, IS_A1 ($1));
1262 | REG ASSIGN expr xpmod1
1264 if (!IS_DREG ($1) && !IS_PREG ($1) && !IS_IREG ($1)
1265 && !IS_MREG ($1) && !IS_BREG ($1) && !IS_LREG ($1))
1266 return yyerror ("Wrong register for load immediate");
1270 /* 7 bit immediate value if possible.
1271 We will check for that constant value for efficiency
1272 If it goes to reloc, it will be 16 bit. */
1273 if (IS_CONST ($3) && IS_IMM ($3, 7) && IS_DREG ($1))
1275 notethat ("COMPI2opD: dregs = imm7 (x) \n");
1276 $$ = COMPI2OPD (&$1, imm7 ($3), 0);
1278 else if (IS_CONST ($3) && IS_IMM ($3, 7) && IS_PREG ($1))
1280 notethat ("COMPI2opP: pregs = imm7 (x)\n");
1281 $$ = COMPI2OPP (&$1, imm7 ($3), 0);
1285 if (IS_CONST ($3) && !IS_IMM ($3, 16))
1286 return yyerror ("Immediate value out of range");
1288 notethat ("LDIMMhalf: regs = luimm16 (x)\n");
1290 $$ = LDIMMHALF_R5 (&$1, 0, 1, 0, $3);
1295 /* (z) There is no 7 bit zero extended instruction.
1296 If the expr is a relocation, generate it. */
1298 if (IS_CONST ($3) && !IS_UIMM ($3, 16))
1299 return yyerror ("Immediate value out of range");
1301 notethat ("LDIMMhalf: regs = luimm16 (x)\n");
1303 $$ = LDIMMHALF_R5 (&$1, 0, 0, 1, $3);
1307 | HALF_REG ASSIGN REG
1310 return yyerror ("Low reg expected");
1312 if (IS_DREG ($1) && $3.regno == REG_A0x)
1314 notethat ("dsp32alu: dregs_lo = A0.x\n");
1315 $$ = DSP32ALU (10, 0, 0, &$1, 0, 0, 0, 0, 0);
1317 else if (IS_DREG ($1) && $3.regno == REG_A1x)
1319 notethat ("dsp32alu: dregs_lo = A1.x\n");
1320 $$ = DSP32ALU (10, 0, 0, &$1, 0, 0, 0, 0, 1);
1323 return yyerror ("Register mismatch");
1326 | REG ASSIGN REG op_bar_op REG amod0
1328 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1330 notethat ("dsp32alu: dregs = dregs .|. dregs (amod0)\n");
1331 $$ = DSP32ALU (0, 0, 0, &$1, &$3, &$5, $6.s0, $6.x0, $4.r0);
1334 return yyerror ("Register mismatch");
1337 | REG ASSIGN BYTE_DREG xpmod
1339 if (IS_DREG ($1) && IS_DREG ($3))
1341 notethat ("ALU2op: dregs = dregs_byte\n");
1342 $$ = ALU2OP (&$1, &$3, 12 | ($4.r0 ? 0: 1));
1345 return yyerror ("Register mismatch");
1348 | a_assign ABS REG_A COMMA a_assign ABS REG_A
1350 if (REG_SAME ($1, $3) && REG_SAME ($5, $7) && !REG_SAME ($1, $5))
1352 notethat ("dsp32alu: A1 = ABS A1 , A0 = ABS A0\n");
1353 $$ = DSP32ALU (16, 0, 0, 0, 0, 0, 0, 0, 3);
1356 return yyerror ("Register mismatch");
1359 | a_assign MINUS REG_A COMMA a_assign MINUS REG_A
1361 if (REG_SAME ($1, $3) && REG_SAME ($5, $7) && !REG_SAME ($1, $5))
1363 notethat ("dsp32alu: A1 = - A1 , A0 = - A0\n");
1364 $$ = DSP32ALU (14, 0, 0, 0, 0, 0, 0, 0, 3);
1367 return yyerror ("Register mismatch");
1370 | a_minusassign REG_A w32_or_nothing
1372 if (!IS_A1 ($1) && IS_A1 ($2))
1374 notethat ("dsp32alu: A0 -= A1\n");
1375 $$ = DSP32ALU (11, 0, 0, 0, 0, 0, $3.r0, 0, 3);
1378 return yyerror ("Register mismatch");
1381 | REG _MINUS_ASSIGN expr
1383 if (IS_IREG ($1) && EXPR_VALUE ($3) == 4)
1385 notethat ("dagMODik: iregs -= 4\n");
1386 $$ = DAGMODIK (&$1, 3);
1388 else if (IS_IREG ($1) && EXPR_VALUE ($3) == 2)
1390 notethat ("dagMODik: iregs -= 2\n");
1391 $$ = DAGMODIK (&$1, 1);
1394 return yyerror ("Register or value mismatch");
1397 | REG _PLUS_ASSIGN REG LPAREN BREV RPAREN
1399 if (IS_IREG ($1) && IS_MREG ($3))
1401 notethat ("dagMODim: iregs += mregs (opt_brev)\n");
1403 $$ = DAGMODIM (&$1, &$3, 0, 1);
1405 else if (IS_PREG ($1) && IS_PREG ($3))
1407 notethat ("PTR2op: pregs += pregs (BREV )\n");
1408 $$ = PTR2OP (&$1, &$3, 5);
1411 return yyerror ("Register mismatch");
1414 | REG _MINUS_ASSIGN REG
1416 if (IS_IREG ($1) && IS_MREG ($3))
1418 notethat ("dagMODim: iregs -= mregs\n");
1419 $$ = DAGMODIM (&$1, &$3, 1, 0);
1421 else if (IS_PREG ($1) && IS_PREG ($3))
1423 notethat ("PTR2op: pregs -= pregs\n");
1424 $$ = PTR2OP (&$1, &$3, 0);
1427 return yyerror ("Register mismatch");
1430 | REG_A _PLUS_ASSIGN REG_A w32_or_nothing
1432 if (!IS_A1 ($1) && IS_A1 ($3))
1434 notethat ("dsp32alu: A0 += A1 (W32)\n");
1435 $$ = DSP32ALU (11, 0, 0, 0, 0, 0, $4.r0, 0, 2);
1438 return yyerror ("Register mismatch");
1441 | REG _PLUS_ASSIGN REG
1443 if (IS_IREG ($1) && IS_MREG ($3))
1445 notethat ("dagMODim: iregs += mregs\n");
1446 $$ = DAGMODIM (&$1, &$3, 0, 0);
1449 return yyerror ("iregs += mregs expected");
1452 | REG _PLUS_ASSIGN expr
1456 if (EXPR_VALUE ($3) == 4)
1458 notethat ("dagMODik: iregs += 4\n");
1459 $$ = DAGMODIK (&$1, 2);
1461 else if (EXPR_VALUE ($3) == 2)
1463 notethat ("dagMODik: iregs += 2\n");
1464 $$ = DAGMODIK (&$1, 0);
1467 return yyerror ("iregs += [ 2 | 4 ");
1469 else if (IS_PREG ($1) && IS_IMM ($3, 7))
1471 notethat ("COMPI2opP: pregs += imm7\n");
1472 $$ = COMPI2OPP (&$1, imm7 ($3), 1);
1474 else if (IS_DREG ($1) && IS_IMM ($3, 7))
1476 notethat ("COMPI2opD: dregs += imm7\n");
1477 $$ = COMPI2OPD (&$1, imm7 ($3), 1);
1479 else if ((IS_DREG ($1) || IS_PREG ($1)) && IS_CONST ($3))
1480 return yyerror ("Immediate value out of range");
1482 return yyerror ("Register mismatch");
1485 | REG _STAR_ASSIGN REG
1487 if (IS_DREG ($1) && IS_DREG ($3))
1489 notethat ("ALU2op: dregs *= dregs\n");
1490 $$ = ALU2OP (&$1, &$3, 3);
1493 return yyerror ("Register mismatch");
1496 | SAA LPAREN REG COLON expr COMMA REG COLON expr RPAREN aligndir
1498 if (!valid_dreg_pair (&$3, $5))
1499 return yyerror ("Bad dreg pair");
1500 else if (!valid_dreg_pair (&$7, $9))
1501 return yyerror ("Bad dreg pair");
1504 notethat ("dsp32alu: SAA (dregs_pair , dregs_pair ) (aligndir)\n");
1505 $$ = DSP32ALU (18, 0, 0, 0, &$3, &$7, $11.r0, 0, 0);
1509 | a_assign REG_A LPAREN S RPAREN COMMA a_assign REG_A LPAREN S RPAREN
1511 if (REG_SAME ($1, $2) && REG_SAME ($7, $8) && !REG_SAME ($1, $7))
1513 notethat ("dsp32alu: A1 = A1 (S) , A0 = A0 (S)\n");
1514 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, 1, 0, 2);
1517 return yyerror ("Register mismatch");
1520 | REG ASSIGN LPAREN REG PLUS REG RPAREN LESS_LESS expr
1522 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG ($6)
1523 && REG_SAME ($1, $4))
1525 if (EXPR_VALUE ($9) == 1)
1527 notethat ("ALU2op: dregs = (dregs + dregs) << 1\n");
1528 $$ = ALU2OP (&$1, &$6, 4);
1530 else if (EXPR_VALUE ($9) == 2)
1532 notethat ("ALU2op: dregs = (dregs + dregs) << 2\n");
1533 $$ = ALU2OP (&$1, &$6, 5);
1536 return yyerror ("Bad shift value");
1538 else if (IS_PREG ($1) && IS_PREG ($4) && IS_PREG ($6)
1539 && REG_SAME ($1, $4))
1541 if (EXPR_VALUE ($9) == 1)
1543 notethat ("PTR2op: pregs = (pregs + pregs) << 1\n");
1544 $$ = PTR2OP (&$1, &$6, 6);
1546 else if (EXPR_VALUE ($9) == 2)
1548 notethat ("PTR2op: pregs = (pregs + pregs) << 2\n");
1549 $$ = PTR2OP (&$1, &$6, 7);
1552 return yyerror ("Bad shift value");
1555 return yyerror ("Register mismatch");
1559 | REG ASSIGN REG BAR REG
1561 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1563 notethat ("COMP3op: dregs = dregs | dregs\n");
1564 $$ = COMP3OP (&$1, &$3, &$5, 3);
1567 return yyerror ("Dregs expected");
1569 | REG ASSIGN REG CARET REG
1571 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1573 notethat ("COMP3op: dregs = dregs ^ dregs\n");
1574 $$ = COMP3OP (&$1, &$3, &$5, 4);
1577 return yyerror ("Dregs expected");
1579 | REG ASSIGN REG PLUS LPAREN REG LESS_LESS expr RPAREN
1581 if (IS_PREG ($1) && IS_PREG ($3) && IS_PREG ($6))
1583 if (EXPR_VALUE ($8) == 1)
1585 notethat ("COMP3op: pregs = pregs + (pregs << 1)\n");
1586 $$ = COMP3OP (&$1, &$3, &$6, 6);
1588 else if (EXPR_VALUE ($8) == 2)
1590 notethat ("COMP3op: pregs = pregs + (pregs << 2)\n");
1591 $$ = COMP3OP (&$1, &$3, &$6, 7);
1594 return yyerror ("Bad shift value");
1597 return yyerror ("Dregs expected");
1599 | CCREG ASSIGN REG_A _ASSIGN_ASSIGN REG_A
1601 if ($3.regno == REG_A0 && $5.regno == REG_A1)
1603 notethat ("CCflag: CC = A0 == A1\n");
1604 $$ = CCFLAG (0, 0, 5, 0, 0);
1607 return yyerror ("AREGs are in bad order or same");
1609 | CCREG ASSIGN REG_A LESS_THAN REG_A
1611 if ($3.regno == REG_A0 && $5.regno == REG_A1)
1613 notethat ("CCflag: CC = A0 < A1\n");
1614 $$ = CCFLAG (0, 0, 6, 0, 0);
1617 return yyerror ("AREGs are in bad order or same");
1619 | CCREG ASSIGN REG LESS_THAN REG iu_or_nothing
1621 if ((IS_DREG ($3) && IS_DREG ($5))
1622 || (IS_PREG ($3) && IS_PREG ($5)))
1624 notethat ("CCflag: CC = dpregs < dpregs\n");
1625 $$ = CCFLAG (&$3, $5.regno & CODE_MASK, $6.r0, 0, IS_PREG ($3) ? 1 : 0);
1628 return yyerror ("Bad register in comparison");
1630 | CCREG ASSIGN REG LESS_THAN expr iu_or_nothing
1632 if (!IS_DREG ($3) && !IS_PREG ($3))
1633 return yyerror ("Bad register in comparison");
1635 if (($6.r0 == 1 && IS_IMM ($5, 3))
1636 || ($6.r0 == 3 && IS_UIMM ($5, 3)))
1638 notethat ("CCflag: CC = dpregs < (u)imm3\n");
1639 $$ = CCFLAG (&$3, imm3 ($5), $6.r0, 1, IS_PREG ($3) ? 1 : 0);
1642 return yyerror ("Bad constant value");
1644 | CCREG ASSIGN REG _ASSIGN_ASSIGN REG
1646 if ((IS_DREG ($3) && IS_DREG ($5))
1647 || (IS_PREG ($3) && IS_PREG ($5)))
1649 notethat ("CCflag: CC = dpregs == dpregs\n");
1650 $$ = CCFLAG (&$3, $5.regno & CODE_MASK, 0, 0, IS_PREG ($3) ? 1 : 0);
1653 return yyerror ("Bad register in comparison");
1655 | CCREG ASSIGN REG _ASSIGN_ASSIGN expr
1657 if (!IS_DREG ($3) && !IS_PREG ($3))
1658 return yyerror ("Bad register in comparison");
1662 notethat ("CCflag: CC = dpregs == imm3\n");
1663 $$ = CCFLAG (&$3, imm3 ($5), 0, 1, IS_PREG ($3) ? 1 : 0);
1666 return yyerror ("Bad constant range");
1668 | CCREG ASSIGN REG_A _LESS_THAN_ASSIGN REG_A
1670 if ($3.regno == REG_A0 && $5.regno == REG_A1)
1672 notethat ("CCflag: CC = A0 <= A1\n");
1673 $$ = CCFLAG (0, 0, 7, 0, 0);
1676 return yyerror ("AREGs are in bad order or same");
1678 | CCREG ASSIGN REG _LESS_THAN_ASSIGN REG iu_or_nothing
1680 if ((IS_DREG ($3) && IS_DREG ($5))
1681 || (IS_PREG ($3) && IS_PREG ($5)))
1683 notethat ("CCflag: CC = dpregs <= dpregs (..)\n");
1684 $$ = CCFLAG (&$3, $5.regno & CODE_MASK,
1685 1 + $6.r0, 0, IS_PREG ($3) ? 1 : 0);
1688 return yyerror ("Bad register in comparison");
1690 | CCREG ASSIGN REG _LESS_THAN_ASSIGN expr iu_or_nothing
1692 if (!IS_DREG ($3) && !IS_PREG ($3))
1693 return yyerror ("Bad register in comparison");
1695 if (($6.r0 == 1 && IS_IMM ($5, 3))
1696 || ($6.r0 == 3 && IS_UIMM ($5, 3)))
1698 notethat ("CCflag: CC = dpregs <= (u)imm3\n");
1699 $$ = CCFLAG (&$3, imm3 ($5), 1 + $6.r0, 1, IS_PREG ($3) ? 1 : 0);
1702 return yyerror ("Bad constant value");
1705 | REG ASSIGN REG AMPERSAND REG
1707 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1709 notethat ("COMP3op: dregs = dregs & dregs\n");
1710 $$ = COMP3OP (&$1, &$3, &$5, 2);
1713 return yyerror ("Dregs expected");
1718 notethat ("CC2stat operation\n");
1719 $$ = bfin_gen_cc2stat ($1.r0, $1.x0, $1.s0);
1724 if ((IS_GENREG ($1) && IS_GENREG ($3))
1725 || (IS_GENREG ($1) && IS_DAGREG ($3))
1726 || (IS_DAGREG ($1) && IS_GENREG ($3))
1727 || (IS_DAGREG ($1) && IS_DAGREG ($3))
1728 || (IS_GENREG ($1) && $3.regno == REG_USP)
1729 || ($1.regno == REG_USP && IS_GENREG ($3))
1730 || (IS_DREG ($1) && IS_SYSREG ($3))
1731 || (IS_PREG ($1) && IS_SYSREG ($3))
1732 || (IS_SYSREG ($1) && IS_DREG ($3))
1733 || (IS_SYSREG ($1) && IS_PREG ($3))
1734 || (IS_SYSREG ($1) && $3.regno == REG_USP))
1736 $$ = bfin_gen_regmv (&$3, &$1);
1739 return yyerror ("Register mismatch");
1746 notethat ("CC2dreg: CC = dregs\n");
1747 $$ = bfin_gen_cc2dreg (1, &$3);
1750 return yyerror ("Register mismatch");
1757 notethat ("CC2dreg: dregs = CC\n");
1758 $$ = bfin_gen_cc2dreg (0, &$1);
1761 return yyerror ("Register mismatch");
1764 | CCREG _ASSIGN_BANG CCREG
1766 notethat ("CC2dreg: CC =! CC\n");
1767 $$ = bfin_gen_cc2dreg (3, 0);
1772 | HALF_REG ASSIGN multiply_halfregs opt_mode
1774 notethat ("dsp32mult: dregs_half = multiply_halfregs (opt_mode)\n");
1776 if (!IS_H ($1) && $4.MM)
1777 return yyerror ("(M) not allowed with MAC0");
1779 if ($4.mod != 0 && $4.mod != M_FU && $4.mod != M_IS
1780 && $4.mod != M_IU && $4.mod != M_T && $4.mod != M_TFU
1781 && $4.mod != M_S2RND && $4.mod != M_ISS2 && $4.mod != M_IH)
1782 return yyerror ("bad option.");
1786 $$ = DSP32MULT (0, $4.MM, $4.mod, 1, 0,
1787 IS_H ($3.s0), IS_H ($3.s1), 0, 0,
1788 &$1, 0, &$3.s0, &$3.s1, 0);
1792 $$ = DSP32MULT (0, 0, $4.mod, 0, 0,
1793 0, 0, IS_H ($3.s0), IS_H ($3.s1),
1794 &$1, 0, &$3.s0, &$3.s1, 1);
1798 | REG ASSIGN multiply_halfregs opt_mode
1800 /* Odd registers can use (M). */
1802 return yyerror ("Dreg expected");
1804 if (IS_EVEN ($1) && $4.MM)
1805 return yyerror ("(M) not allowed with MAC0");
1807 if ($4.mod != 0 && $4.mod != M_FU && $4.mod != M_IS
1808 && $4.mod != M_S2RND && $4.mod != M_ISS2)
1809 return yyerror ("bad option");
1813 notethat ("dsp32mult: dregs = multiply_halfregs (opt_mode)\n");
1815 $$ = DSP32MULT (0, $4.MM, $4.mod, 1, 1,
1816 IS_H ($3.s0), IS_H ($3.s1), 0, 0,
1817 &$1, 0, &$3.s0, &$3.s1, 0);
1821 notethat ("dsp32mult: dregs = multiply_halfregs opt_mode\n");
1822 $$ = DSP32MULT (0, 0, $4.mod, 0, 1,
1823 0, 0, IS_H ($3.s0), IS_H ($3.s1),
1824 &$1, 0, &$3.s0, &$3.s1, 1);
1828 | HALF_REG ASSIGN multiply_halfregs opt_mode COMMA
1829 HALF_REG ASSIGN multiply_halfregs opt_mode
1831 if (!IS_DREG ($1) || !IS_DREG ($6))
1832 return yyerror ("Dregs expected");
1834 if (!IS_HCOMPL($1, $6))
1835 return yyerror ("Dest registers mismatch");
1837 if (check_multiply_halfregs (&$3, &$8) < 0)
1840 if ((!IS_H ($1) && $4.MM)
1841 || (!IS_H ($6) && $9.MM))
1842 return yyerror ("(M) not allowed with MAC0");
1844 notethat ("dsp32mult: dregs_hi = multiply_halfregs mxd_mod, "
1845 "dregs_lo = multiply_halfregs opt_mode\n");
1848 $$ = DSP32MULT (0, $4.MM, $9.mod, 1, 0,
1849 IS_H ($3.s0), IS_H ($3.s1), IS_H ($8.s0), IS_H ($8.s1),
1850 &$1, 0, &$3.s0, &$3.s1, 1);
1852 $$ = DSP32MULT (0, $9.MM, $9.mod, 1, 0,
1853 IS_H ($8.s0), IS_H ($8.s1), IS_H ($3.s0), IS_H ($3.s1),
1854 &$1, 0, &$3.s0, &$3.s1, 1);
1857 | REG ASSIGN multiply_halfregs opt_mode COMMA REG ASSIGN multiply_halfregs opt_mode
1859 if (!IS_DREG ($1) || !IS_DREG ($6))
1860 return yyerror ("Dregs expected");
1862 if ((IS_EVEN ($1) && $6.regno - $1.regno != 1)
1863 || (IS_EVEN ($6) && $1.regno - $6.regno != 1))
1864 return yyerror ("Dest registers mismatch");
1866 if (check_multiply_halfregs (&$3, &$8) < 0)
1869 if ((IS_EVEN ($1) && $4.MM)
1870 || (IS_EVEN ($6) && $9.MM))
1871 return yyerror ("(M) not allowed with MAC0");
1873 notethat ("dsp32mult: dregs = multiply_halfregs mxd_mod, "
1874 "dregs = multiply_halfregs opt_mode\n");
1877 $$ = DSP32MULT (0, $9.MM, $9.mod, 1, 1,
1878 IS_H ($8.s0), IS_H ($8.s1), IS_H ($3.s0), IS_H ($3.s1),
1879 &$1, 0, &$3.s0, &$3.s1, 1);
1881 $$ = DSP32MULT (0, $4.MM, $9.mod, 1, 1,
1882 IS_H ($3.s0), IS_H ($3.s1), IS_H ($8.s0), IS_H ($8.s1),
1883 &$1, 0, &$3.s0, &$3.s1, 1);
1888 | a_assign ASHIFT REG_A BY HALF_REG
1890 if (!REG_SAME ($1, $3))
1891 return yyerror ("Aregs must be same");
1893 if (IS_DREG ($5) && !IS_H ($5))
1895 notethat ("dsp32shift: A0 = ASHIFT A0 BY dregs_lo\n");
1896 $$ = DSP32SHIFT (3, 0, &$5, 0, 0, IS_A1 ($1));
1899 return yyerror ("Dregs expected");
1902 | HALF_REG ASSIGN ASHIFT HALF_REG BY HALF_REG smod
1904 if (IS_DREG ($6) && !IS_H ($6))
1906 notethat ("dsp32shift: dregs_half = ASHIFT dregs_half BY dregs_lo\n");
1907 $$ = DSP32SHIFT (0, &$1, &$6, &$4, $7.s0, HL2 ($1, $4));
1910 return yyerror ("Dregs expected");
1913 | a_assign REG_A LESS_LESS expr
1915 if (!REG_SAME ($1, $2))
1916 return yyerror ("Aregs must be same");
1918 if (IS_UIMM ($4, 5))
1920 notethat ("dsp32shiftimm: A0 = A0 << uimm5\n");
1921 $$ = DSP32SHIFTIMM (3, 0, imm5 ($4), 0, 0, IS_A1 ($1));
1924 return yyerror ("Bad shift value");
1927 | REG ASSIGN REG LESS_LESS expr vsmod
1929 if (IS_DREG ($1) && IS_DREG ($3) && IS_UIMM ($5, 5))
1934 notethat ("dsp32shiftimm: dregs = dregs << expr (V, .)\n");
1935 $$ = DSP32SHIFTIMM (1, &$1, imm4 ($5), &$3, $6.s0 ? 1 : 2, 0);
1939 notethat ("dsp32shiftimm: dregs = dregs << uimm5 (.)\n");
1940 $$ = DSP32SHIFTIMM (2, &$1, imm6 ($5), &$3, $6.s0 ? 1 : 2, 0);
1943 else if ($6.s0 == 0 && IS_PREG ($1) && IS_PREG ($3))
1945 if (EXPR_VALUE ($5) == 2)
1947 notethat ("PTR2op: pregs = pregs << 2\n");
1948 $$ = PTR2OP (&$1, &$3, 1);
1950 else if (EXPR_VALUE ($5) == 1)
1952 notethat ("COMP3op: pregs = pregs << 1\n");
1953 $$ = COMP3OP (&$1, &$3, &$3, 5);
1956 return yyerror ("Bad shift value");
1959 return yyerror ("Bad shift value or register");
1961 | HALF_REG ASSIGN HALF_REG LESS_LESS expr smod
1963 if (IS_UIMM ($5, 4))
1967 notethat ("dsp32shiftimm: dregs_half = dregs_half << uimm4 (S)\n");
1968 $$ = DSP32SHIFTIMM (0x0, &$1, imm5 ($5), &$3, $6.s0, HL2 ($1, $3));
1972 notethat ("dsp32shiftimm: dregs_half = dregs_half << uimm4\n");
1973 $$ = DSP32SHIFTIMM (0x0, &$1, imm5 ($5), &$3, 2, HL2 ($1, $3));
1977 return yyerror ("Bad shift value");
1979 | REG ASSIGN ASHIFT REG BY HALF_REG vsmod
1983 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG ($6) && !IS_H ($6))
1988 notethat ("dsp32shift: dregs = ASHIFT dregs BY "
1989 "dregs_lo (V, .)\n");
1995 notethat ("dsp32shift: dregs = ASHIFT dregs BY dregs_lo (.)\n");
1997 $$ = DSP32SHIFT (op, &$1, &$6, &$4, $7.s0, 0);
2000 return yyerror ("Dregs expected");
2004 | HALF_REG ASSIGN EXPADJ LPAREN REG COMMA HALF_REG RPAREN vmod
2006 if (IS_DREG_L ($1) && IS_DREG_L ($5) && IS_DREG_L ($7))
2008 notethat ("dsp32shift: dregs_lo = EXPADJ (dregs , dregs_lo )\n");
2009 $$ = DSP32SHIFT (7, &$1, &$7, &$5, $9.r0, 0);
2012 return yyerror ("Bad shift value or register");
2016 | HALF_REG ASSIGN EXPADJ LPAREN HALF_REG COMMA HALF_REG RPAREN
2018 if (IS_DREG_L ($1) && IS_DREG_L ($5) && IS_DREG_L ($7))
2020 notethat ("dsp32shift: dregs_lo = EXPADJ (dregs_lo, dregs_lo)\n");
2021 $$ = DSP32SHIFT (7, &$1, &$7, &$5, 2, 0);
2023 else if (IS_DREG_L ($1) && IS_DREG_H ($5) && IS_DREG_L ($7))
2025 notethat ("dsp32shift: dregs_lo = EXPADJ (dregs_hi, dregs_lo)\n");
2026 $$ = DSP32SHIFT (7, &$1, &$7, &$5, 3, 0);
2029 return yyerror ("Bad shift value or register");
2034 | REG ASSIGN DEPOSIT LPAREN REG COMMA REG RPAREN
2036 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
2038 notethat ("dsp32shift: dregs = DEPOSIT (dregs , dregs )\n");
2039 $$ = DSP32SHIFT (10, &$1, &$7, &$5, 2, 0);
2042 return yyerror ("Register mismatch");
2045 | REG ASSIGN DEPOSIT LPAREN REG COMMA REG RPAREN LPAREN X RPAREN
2047 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
2049 notethat ("dsp32shift: dregs = DEPOSIT (dregs , dregs ) (X)\n");
2050 $$ = DSP32SHIFT (10, &$1, &$7, &$5, 3, 0);
2053 return yyerror ("Register mismatch");
2056 | REG ASSIGN EXTRACT LPAREN REG COMMA HALF_REG RPAREN xpmod
2058 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG_L ($7))
2060 notethat ("dsp32shift: dregs = EXTRACT (dregs, dregs_lo ) (.)\n");
2061 $$ = DSP32SHIFT (10, &$1, &$7, &$5, $9.r0, 0);
2064 return yyerror ("Register mismatch");
2067 | a_assign REG_A _GREATER_GREATER_GREATER expr
2069 if (!REG_SAME ($1, $2))
2070 return yyerror ("Aregs must be same");
2072 if (IS_UIMM ($4, 5))
2074 notethat ("dsp32shiftimm: Ax = Ax >>> uimm5\n");
2075 $$ = DSP32SHIFTIMM (3, 0, -imm6 ($4), 0, 0, IS_A1 ($1));
2078 return yyerror ("Shift value range error");
2080 | a_assign LSHIFT REG_A BY HALF_REG
2082 if (REG_SAME ($1, $3) && IS_DREG_L ($5))
2084 notethat ("dsp32shift: Ax = LSHIFT Ax BY dregs_lo\n");
2085 $$ = DSP32SHIFT (3, 0, &$5, 0, 1, IS_A1 ($1));
2088 return yyerror ("Register mismatch");
2091 | HALF_REG ASSIGN LSHIFT HALF_REG BY HALF_REG
2093 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG_L ($6))
2095 notethat ("dsp32shift: dregs_lo = LSHIFT dregs_hi BY dregs_lo\n");
2096 $$ = DSP32SHIFT (0, &$1, &$6, &$4, 2, HL2 ($1, $4));
2099 return yyerror ("Register mismatch");
2102 | REG ASSIGN LSHIFT REG BY HALF_REG vmod
2104 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG_L ($6))
2106 notethat ("dsp32shift: dregs = LSHIFT dregs BY dregs_lo (V )\n");
2107 $$ = DSP32SHIFT ($7.r0 ? 1: 2, &$1, &$6, &$4, 2, 0);
2110 return yyerror ("Register mismatch");
2113 | REG ASSIGN SHIFT REG BY HALF_REG
2115 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG_L ($6))
2117 notethat ("dsp32shift: dregs = SHIFT dregs BY dregs_lo\n");
2118 $$ = DSP32SHIFT (2, &$1, &$6, &$4, 2, 0);
2121 return yyerror ("Register mismatch");
2124 | a_assign REG_A GREATER_GREATER expr
2126 if (REG_SAME ($1, $2) && IS_IMM ($4, 6) >= 0)
2128 notethat ("dsp32shiftimm: Ax = Ax >> imm6\n");
2129 $$ = DSP32SHIFTIMM (3, 0, -imm6 ($4), 0, 1, IS_A1 ($1));
2132 return yyerror ("Accu register expected");
2135 | REG ASSIGN REG GREATER_GREATER expr vmod
2139 if (IS_DREG ($1) && IS_DREG ($3) && IS_UIMM ($5, 5))
2141 notethat ("dsp32shiftimm: dregs = dregs >> uimm5 (V)\n");
2142 $$ = DSP32SHIFTIMM (1, &$1, -uimm5 ($5), &$3, 2, 0);
2145 return yyerror ("Register mismatch");
2149 if (IS_DREG ($1) && IS_DREG ($3) && IS_UIMM ($5, 5))
2151 notethat ("dsp32shiftimm: dregs = dregs >> uimm5\n");
2152 $$ = DSP32SHIFTIMM (2, &$1, -imm6 ($5), &$3, 2, 0);
2154 else if (IS_PREG ($1) && IS_PREG ($3) && EXPR_VALUE ($5) == 2)
2156 notethat ("PTR2op: pregs = pregs >> 2\n");
2157 $$ = PTR2OP (&$1, &$3, 3);
2159 else if (IS_PREG ($1) && IS_PREG ($3) && EXPR_VALUE ($5) == 1)
2161 notethat ("PTR2op: pregs = pregs >> 1\n");
2162 $$ = PTR2OP (&$1, &$3, 4);
2165 return yyerror ("Register mismatch");
2168 | HALF_REG ASSIGN HALF_REG GREATER_GREATER expr
2170 if (IS_UIMM ($5, 5))
2172 notethat ("dsp32shiftimm: dregs_half = dregs_half >> uimm5\n");
2173 $$ = DSP32SHIFTIMM (0, &$1, -uimm5 ($5), &$3, 2, HL2 ($1, $3));
2176 return yyerror ("Register mismatch");
2178 | HALF_REG ASSIGN HALF_REG _GREATER_GREATER_GREATER expr smod
2180 if (IS_UIMM ($5, 5))
2182 notethat ("dsp32shiftimm: dregs_half = dregs_half >>> uimm5\n");
2183 $$ = DSP32SHIFTIMM (0, &$1, -uimm5 ($5), &$3,
2184 $6.s0, HL2 ($1, $3));
2187 return yyerror ("Register or modifier mismatch");
2191 | REG ASSIGN REG _GREATER_GREATER_GREATER expr vsmod
2193 if (IS_DREG ($1) && IS_DREG ($3) && IS_UIMM ($5, 5))
2198 notethat ("dsp32shiftimm: dregs = dregs >>> uimm5 (V, .)\n");
2199 $$ = DSP32SHIFTIMM (1, &$1, -uimm5 ($5), &$3, $6.s0, 0);
2203 notethat ("dsp32shiftimm: dregs = dregs >>> uimm5 (.)\n");
2204 $$ = DSP32SHIFTIMM (2, &$1, -uimm5 ($5), &$3, $6.s0, 0);
2208 return yyerror ("Register mismatch");
2211 | HALF_REG ASSIGN ONES REG
2213 if (IS_DREG_L ($1) && IS_DREG ($4))
2215 notethat ("dsp32shift: dregs_lo = ONES dregs\n");
2216 $$ = DSP32SHIFT (6, &$1, 0, &$4, 3, 0);
2219 return yyerror ("Register mismatch");
2222 | REG ASSIGN PACK LPAREN HALF_REG COMMA HALF_REG RPAREN
2224 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
2226 notethat ("dsp32shift: dregs = PACK (dregs_hi , dregs_hi )\n");
2227 $$ = DSP32SHIFT (4, &$1, &$7, &$5, HL2 ($5, $7), 0);
2230 return yyerror ("Register mismatch");
2233 | HALF_REG ASSIGN CCREG ASSIGN BXORSHIFT LPAREN REG_A COMMA REG RPAREN
2236 && $7.regno == REG_A0
2237 && IS_DREG ($9) && !IS_H ($1) && !IS_A1 ($7))
2239 notethat ("dsp32shift: dregs_lo = CC = BXORSHIFT (A0 , dregs )\n");
2240 $$ = DSP32SHIFT (11, &$1, &$9, 0, 0, 0);
2243 return yyerror ("Register mismatch");
2246 | HALF_REG ASSIGN CCREG ASSIGN BXOR LPAREN REG_A COMMA REG RPAREN
2249 && $7.regno == REG_A0
2250 && IS_DREG ($9) && !IS_H ($1) && !IS_A1 ($7))
2252 notethat ("dsp32shift: dregs_lo = CC = BXOR (A0 , dregs)\n");
2253 $$ = DSP32SHIFT (11, &$1, &$9, 0, 1, 0);
2256 return yyerror ("Register mismatch");
2259 | HALF_REG ASSIGN CCREG ASSIGN BXOR LPAREN REG_A COMMA REG_A COMMA CCREG RPAREN
2261 if (IS_DREG ($1) && !IS_H ($1) && !REG_SAME ($7, $9))
2263 notethat ("dsp32shift: dregs_lo = CC = BXOR (A0 , A1 , CC)\n");
2264 $$ = DSP32SHIFT (12, &$1, 0, 0, 1, 0);
2267 return yyerror ("Register mismatch");
2270 | a_assign ROT REG_A BY HALF_REG
2272 if (REG_SAME ($1, $3) && IS_DREG_L ($5))
2274 notethat ("dsp32shift: Ax = ROT Ax BY dregs_lo\n");
2275 $$ = DSP32SHIFT (3, 0, &$5, 0, 2, IS_A1 ($1));
2278 return yyerror ("Register mismatch");
2281 | REG ASSIGN ROT REG BY HALF_REG
2283 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG_L ($6))
2285 notethat ("dsp32shift: dregs = ROT dregs BY dregs_lo\n");
2286 $$ = DSP32SHIFT (2, &$1, &$6, &$4, 3, 0);
2289 return yyerror ("Register mismatch");
2292 | a_assign ROT REG_A BY expr
2296 notethat ("dsp32shiftimm: An = ROT An BY imm6\n");
2297 $$ = DSP32SHIFTIMM (3, 0, imm6 ($5), 0, 2, IS_A1 ($1));
2300 return yyerror ("Register mismatch");
2303 | REG ASSIGN ROT REG BY expr
2305 if (IS_DREG ($1) && IS_DREG ($4) && IS_IMM ($6, 6))
2307 $$ = DSP32SHIFTIMM (2, &$1, imm6 ($6), &$4, 3, IS_A1 ($1));
2310 return yyerror ("Register mismatch");
2313 | HALF_REG ASSIGN SIGNBITS REG_A
2317 notethat ("dsp32shift: dregs_lo = SIGNBITS An\n");
2318 $$ = DSP32SHIFT (6, &$1, 0, 0, IS_A1 ($4), 0);
2321 return yyerror ("Register mismatch");
2324 | HALF_REG ASSIGN SIGNBITS REG
2326 if (IS_DREG_L ($1) && IS_DREG ($4))
2328 notethat ("dsp32shift: dregs_lo = SIGNBITS dregs\n");
2329 $$ = DSP32SHIFT (5, &$1, 0, &$4, 0, 0);
2332 return yyerror ("Register mismatch");
2335 | HALF_REG ASSIGN SIGNBITS HALF_REG
2339 notethat ("dsp32shift: dregs_lo = SIGNBITS dregs_lo\n");
2340 $$ = DSP32SHIFT (5, &$1, 0, &$4, 1 + IS_H ($4), 0);
2343 return yyerror ("Register mismatch");
2346 /* The ASR bit is just inverted here. */
2347 | HALF_REG ASSIGN VIT_MAX LPAREN REG RPAREN asr_asl
2349 if (IS_DREG_L ($1) && IS_DREG ($5))
2351 notethat ("dsp32shift: dregs_lo = VIT_MAX (dregs) (..)\n");
2352 $$ = DSP32SHIFT (9, &$1, 0, &$5, ($7.r0 ? 0 : 1), 0);
2355 return yyerror ("Register mismatch");
2358 | REG ASSIGN VIT_MAX LPAREN REG COMMA REG RPAREN asr_asl
2360 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
2362 notethat ("dsp32shift: dregs = VIT_MAX (dregs, dregs) (ASR)\n");
2363 $$ = DSP32SHIFT (9, &$1, &$7, &$5, 2 | ($9.r0 ? 0 : 1), 0);
2366 return yyerror ("Register mismatch");
2369 | BITMUX LPAREN REG COMMA REG COMMA REG_A RPAREN asr_asl
2371 if (IS_DREG ($3) && IS_DREG ($5) && !IS_A1 ($7))
2373 notethat ("dsp32shift: BITMUX (dregs , dregs , A0) (ASR)\n");
2374 $$ = DSP32SHIFT (8, 0, &$3, &$5, $9.r0, 0);
2377 return yyerror ("Register mismatch");
2380 | a_assign BXORSHIFT LPAREN REG_A COMMA REG_A COMMA CCREG RPAREN
2382 if (!IS_A1 ($1) && !IS_A1 ($4) && IS_A1 ($6))
2384 notethat ("dsp32shift: A0 = BXORSHIFT (A0 , A1 , CC )\n");
2385 $$ = DSP32SHIFT (12, 0, 0, 0, 0, 0);
2388 return yyerror ("Dregs expected");
2392 /* LOGI2op: BITCLR (dregs, uimm5). */
2393 | BITCLR LPAREN REG COMMA expr RPAREN
2395 if (IS_DREG ($3) && IS_UIMM ($5, 5))
2397 notethat ("LOGI2op: BITCLR (dregs , uimm5 )\n");
2398 $$ = LOGI2OP ($3, uimm5 ($5), 4);
2401 return yyerror ("Register mismatch");
2404 /* LOGI2op: BITSET (dregs, uimm5). */
2405 | BITSET LPAREN REG COMMA expr RPAREN
2407 if (IS_DREG ($3) && IS_UIMM ($5, 5))
2409 notethat ("LOGI2op: BITCLR (dregs , uimm5 )\n");
2410 $$ = LOGI2OP ($3, uimm5 ($5), 2);
2413 return yyerror ("Register mismatch");
2416 /* LOGI2op: BITTGL (dregs, uimm5). */
2417 | BITTGL LPAREN REG COMMA expr RPAREN
2419 if (IS_DREG ($3) && IS_UIMM ($5, 5))
2421 notethat ("LOGI2op: BITCLR (dregs , uimm5 )\n");
2422 $$ = LOGI2OP ($3, uimm5 ($5), 3);
2425 return yyerror ("Register mismatch");
2428 | CCREG _ASSIGN_BANG BITTST LPAREN REG COMMA expr RPAREN
2430 if (IS_DREG ($5) && IS_UIMM ($7, 5))
2432 notethat ("LOGI2op: CC =! BITTST (dregs , uimm5 )\n");
2433 $$ = LOGI2OP ($5, uimm5 ($7), 0);
2436 return yyerror ("Register mismatch or value error");
2439 | CCREG ASSIGN BITTST LPAREN REG COMMA expr RPAREN
2441 if (IS_DREG ($5) && IS_UIMM ($7, 5))
2443 notethat ("LOGI2op: CC = BITTST (dregs , uimm5 )\n");
2444 $$ = LOGI2OP ($5, uimm5 ($7), 1);
2447 return yyerror ("Register mismatch or value error");
2450 | IF BANG CCREG REG ASSIGN REG
2452 if ((IS_DREG ($4) || IS_PREG ($4))
2453 && (IS_DREG ($6) || IS_PREG ($6)))
2455 notethat ("ccMV: IF ! CC gregs = gregs\n");
2456 $$ = CCMV (&$6, &$4, 0);
2459 return yyerror ("Register mismatch");
2462 | IF CCREG REG ASSIGN REG
2464 if ((IS_DREG ($5) || IS_PREG ($5))
2465 && (IS_DREG ($3) || IS_PREG ($3)))
2467 notethat ("ccMV: IF CC gregs = gregs\n");
2468 $$ = CCMV (&$5, &$3, 1);
2471 return yyerror ("Register mismatch");
2474 | IF BANG CCREG JUMP expr
2476 if (IS_PCREL10 ($5))
2478 notethat ("BRCC: IF !CC JUMP pcrel11m2\n");
2479 $$ = BRCC (0, 0, $5);
2482 return yyerror ("Bad jump offset");
2485 | IF BANG CCREG JUMP expr LPAREN BP RPAREN
2487 if (IS_PCREL10 ($5))
2489 notethat ("BRCC: IF !CC JUMP pcrel11m2\n");
2490 $$ = BRCC (0, 1, $5);
2493 return yyerror ("Bad jump offset");
2496 | IF CCREG JUMP expr
2498 if (IS_PCREL10 ($4))
2500 notethat ("BRCC: IF CC JUMP pcrel11m2\n");
2501 $$ = BRCC (1, 0, $4);
2504 return yyerror ("Bad jump offset");
2507 | IF CCREG JUMP expr LPAREN BP RPAREN
2509 if (IS_PCREL10 ($4))
2511 notethat ("BRCC: IF !CC JUMP pcrel11m2\n");
2512 $$ = BRCC (1, 1, $4);
2515 return yyerror ("Bad jump offset");
2519 notethat ("ProgCtrl: NOP\n");
2520 $$ = PROGCTRL (0, 0);
2525 notethat ("ProgCtrl: RTS\n");
2526 $$ = PROGCTRL (1, 0);
2531 notethat ("ProgCtrl: RTI\n");
2532 $$ = PROGCTRL (1, 1);
2537 notethat ("ProgCtrl: RTX\n");
2538 $$ = PROGCTRL (1, 2);
2543 notethat ("ProgCtrl: RTN\n");
2544 $$ = PROGCTRL (1, 3);
2549 notethat ("ProgCtrl: RTE\n");
2550 $$ = PROGCTRL (1, 4);
2555 notethat ("ProgCtrl: IDLE\n");
2556 $$ = PROGCTRL (2, 0);
2561 notethat ("ProgCtrl: CSYNC\n");
2562 $$ = PROGCTRL (2, 3);
2567 notethat ("ProgCtrl: SSYNC\n");
2568 $$ = PROGCTRL (2, 4);
2573 notethat ("ProgCtrl: EMUEXCPT\n");
2574 $$ = PROGCTRL (2, 5);
2581 notethat ("ProgCtrl: CLI dregs\n");
2582 $$ = PROGCTRL (3, $2.regno & CODE_MASK);
2585 return yyerror ("Dreg expected for CLI");
2592 notethat ("ProgCtrl: STI dregs\n");
2593 $$ = PROGCTRL (4, $2.regno & CODE_MASK);
2596 return yyerror ("Dreg expected for STI");
2599 | JUMP LPAREN REG RPAREN
2603 notethat ("ProgCtrl: JUMP (pregs )\n");
2604 $$ = PROGCTRL (5, $3.regno & CODE_MASK);
2607 return yyerror ("Bad register for indirect jump");
2610 | CALL LPAREN REG RPAREN
2614 notethat ("ProgCtrl: CALL (pregs )\n");
2615 $$ = PROGCTRL (6, $3.regno & CODE_MASK);
2618 return yyerror ("Bad register for indirect call");
2621 | CALL LPAREN PC PLUS REG RPAREN
2625 notethat ("ProgCtrl: CALL (PC + pregs )\n");
2626 $$ = PROGCTRL (7, $5.regno & CODE_MASK);
2629 return yyerror ("Bad register for indirect call");
2632 | JUMP LPAREN PC PLUS REG RPAREN
2636 notethat ("ProgCtrl: JUMP (PC + pregs )\n");
2637 $$ = PROGCTRL (8, $5.regno & CODE_MASK);
2640 return yyerror ("Bad register for indirect jump");
2645 if (IS_UIMM ($2, 4))
2647 notethat ("ProgCtrl: RAISE uimm4\n");
2648 $$ = PROGCTRL (9, uimm4 ($2));
2651 return yyerror ("Bad value for RAISE");
2656 notethat ("ProgCtrl: EMUEXCPT\n");
2657 $$ = PROGCTRL (10, uimm4 ($2));
2660 | TESTSET LPAREN REG RPAREN
2664 notethat ("ProgCtrl: TESTSET (pregs )\n");
2665 $$ = PROGCTRL (11, $3.regno & CODE_MASK);
2668 return yyerror ("Preg expected");
2673 if (IS_PCREL12 ($2))
2675 notethat ("UJUMP: JUMP pcrel12\n");
2679 return yyerror ("Bad value for relative jump");
2684 if (IS_PCREL12 ($2))
2686 notethat ("UJUMP: JUMP_DOT_S pcrel12\n");
2690 return yyerror ("Bad value for relative jump");
2695 if (IS_PCREL24 ($2))
2697 notethat ("CALLa: jump.l pcrel24\n");
2701 return yyerror ("Bad value for long jump");
2706 if (IS_PCREL24 ($2))
2708 notethat ("CALLa: jump.l pcrel24\n");
2712 return yyerror ("Bad value for long jump");
2717 if (IS_PCREL24 ($2))
2719 notethat ("CALLa: CALL pcrel25m2\n");
2723 return yyerror ("Bad call address");
2727 if (IS_PCREL24 ($2))
2729 notethat ("CALLa: CALL pcrel25m2\n");
2733 return yyerror ("Bad call address");
2737 /* ALU2op: DIVQ (dregs, dregs). */
2738 | DIVQ LPAREN REG COMMA REG RPAREN
2740 if (IS_DREG ($3) && IS_DREG ($5))
2741 $$ = ALU2OP (&$3, &$5, 8);
2743 return yyerror ("Bad registers for DIVQ");
2746 | DIVS LPAREN REG COMMA REG RPAREN
2748 if (IS_DREG ($3) && IS_DREG ($5))
2749 $$ = ALU2OP (&$3, &$5, 9);
2751 return yyerror ("Bad registers for DIVS");
2754 | REG ASSIGN MINUS REG vsmod
2756 if (IS_DREG ($1) && IS_DREG ($4))
2758 if ($5.r0 == 0 && $5.s0 == 0 && $5.aop == 0)
2760 notethat ("ALU2op: dregs = - dregs\n");
2761 $$ = ALU2OP (&$1, &$4, 14);
2763 else if ($5.r0 == 1 && $5.s0 == 0 && $5.aop == 3)
2765 notethat ("dsp32alu: dregs = - dregs (.)\n");
2766 $$ = DSP32ALU (15, 0, 0, &$1, &$4, 0, $5.s0, 0, 3);
2770 notethat ("dsp32alu: dregs = - dregs (.)\n");
2771 $$ = DSP32ALU (7, 0, 0, &$1, &$4, 0, $5.s0, 0, 3);
2775 return yyerror ("Dregs expected");
2778 | REG ASSIGN TILDA REG
2780 if (IS_DREG ($1) && IS_DREG ($4))
2782 notethat ("ALU2op: dregs = ~dregs\n");
2783 $$ = ALU2OP (&$1, &$4, 15);
2786 return yyerror ("Dregs expected");
2789 | REG _GREATER_GREATER_ASSIGN REG
2791 if (IS_DREG ($1) && IS_DREG ($3))
2793 notethat ("ALU2op: dregs >>= dregs\n");
2794 $$ = ALU2OP (&$1, &$3, 1);
2797 return yyerror ("Dregs expected");
2800 | REG _GREATER_GREATER_ASSIGN expr
2802 if (IS_DREG ($1) && IS_UIMM ($3, 5))
2804 notethat ("LOGI2op: dregs >>= uimm5\n");
2805 $$ = LOGI2OP ($1, uimm5 ($3), 6);
2808 return yyerror ("Dregs expected or value error");
2811 | REG _GREATER_GREATER_GREATER_THAN_ASSIGN REG
2813 if (IS_DREG ($1) && IS_DREG ($3))
2815 notethat ("ALU2op: dregs >>>= dregs\n");
2816 $$ = ALU2OP (&$1, &$3, 0);
2819 return yyerror ("Dregs expected");
2822 | REG _LESS_LESS_ASSIGN REG
2824 if (IS_DREG ($1) && IS_DREG ($3))
2826 notethat ("ALU2op: dregs <<= dregs\n");
2827 $$ = ALU2OP (&$1, &$3, 2);
2830 return yyerror ("Dregs expected");
2833 | REG _LESS_LESS_ASSIGN expr
2835 if (IS_DREG ($1) && IS_UIMM ($3, 5))
2837 notethat ("LOGI2op: dregs <<= uimm5\n");
2838 $$ = LOGI2OP ($1, uimm5 ($3), 7);
2841 return yyerror ("Dregs expected or const value error");
2845 | REG _GREATER_GREATER_GREATER_THAN_ASSIGN expr
2847 if (IS_DREG ($1) && IS_UIMM ($3, 5))
2849 notethat ("LOGI2op: dregs >>>= uimm5\n");
2850 $$ = LOGI2OP ($1, uimm5 ($3), 5);
2853 return yyerror ("Dregs expected");
2856 /* Cache Control. */
2858 | FLUSH LBRACK REG RBRACK
2860 notethat ("CaCTRL: FLUSH [ pregs ]\n");
2862 $$ = CACTRL (&$3, 0, 2);
2864 return yyerror ("Bad register(s) for FLUSH");
2867 | FLUSH reg_with_postinc
2871 notethat ("CaCTRL: FLUSH [ pregs ++ ]\n");
2872 $$ = CACTRL (&$2, 1, 2);
2875 return yyerror ("Bad register(s) for FLUSH");
2878 | FLUSHINV LBRACK REG RBRACK
2882 notethat ("CaCTRL: FLUSHINV [ pregs ]\n");
2883 $$ = CACTRL (&$3, 0, 1);
2886 return yyerror ("Bad register(s) for FLUSH");
2889 | FLUSHINV reg_with_postinc
2893 notethat ("CaCTRL: FLUSHINV [ pregs ++ ]\n");
2894 $$ = CACTRL (&$2, 1, 1);
2897 return yyerror ("Bad register(s) for FLUSH");
2900 /* CaCTRL: IFLUSH [pregs]. */
2901 | IFLUSH LBRACK REG RBRACK
2905 notethat ("CaCTRL: IFLUSH [ pregs ]\n");
2906 $$ = CACTRL (&$3, 0, 3);
2909 return yyerror ("Bad register(s) for FLUSH");
2912 | IFLUSH reg_with_postinc
2916 notethat ("CaCTRL: IFLUSH [ pregs ++ ]\n");
2917 $$ = CACTRL (&$2, 1, 3);
2920 return yyerror ("Bad register(s) for FLUSH");
2923 | PREFETCH LBRACK REG RBRACK
2927 notethat ("CaCTRL: PREFETCH [ pregs ]\n");
2928 $$ = CACTRL (&$3, 0, 0);
2931 return yyerror ("Bad register(s) for PREFETCH");
2934 | PREFETCH reg_with_postinc
2938 notethat ("CaCTRL: PREFETCH [ pregs ++ ]\n");
2939 $$ = CACTRL (&$2, 1, 0);
2942 return yyerror ("Bad register(s) for PREFETCH");
2946 /* LDST: B [ pregs <post_op> ] = dregs. */
2948 | B LBRACK REG post_op RBRACK ASSIGN REG
2951 return yyerror ("Dreg expected for source operand");
2953 return yyerror ("Preg expected in address");
2955 notethat ("LDST: B [ pregs <post_op> ] = dregs\n");
2956 $$ = LDST (&$3, &$7, $4.x0, 2, 0, 1);
2959 /* LDSTidxI: B [ pregs + imm16 ] = dregs. */
2960 | B LBRACK REG plus_minus expr RBRACK ASSIGN REG
2962 Expr_Node *tmp = $5;
2965 return yyerror ("Dreg expected for source operand");
2967 return yyerror ("Preg expected in address");
2970 return yyerror ("Plain symbol used as offset");
2973 tmp = unary (Expr_Op_Type_NEG, tmp);
2975 if (in_range_p (tmp, -32768, 32767, 0))
2977 notethat ("LDST: B [ pregs + imm16 ] = dregs\n");
2978 $$ = LDSTIDXI (&$3, &$8, 1, 2, 0, $5);
2981 return yyerror ("Displacement out of range");
2985 /* LDSTii: W [ pregs + uimm4s2 ] = dregs. */
2986 | W LBRACK REG plus_minus expr RBRACK ASSIGN REG
2988 Expr_Node *tmp = $5;
2991 return yyerror ("Dreg expected for source operand");
2993 return yyerror ("Preg expected in address");
2996 tmp = unary (Expr_Op_Type_NEG, tmp);
2999 return yyerror ("Plain symbol used as offset");
3001 if (in_range_p (tmp, 0, 30, 1))
3003 notethat ("LDSTii: W [ pregs +- uimm5m2 ] = dregs\n");
3004 $$ = LDSTII (&$3, &$8, tmp, 1, 1);
3006 else if (in_range_p (tmp, -65536, 65535, 1))
3008 notethat ("LDSTidxI: W [ pregs + imm17m2 ] = dregs\n");
3009 $$ = LDSTIDXI (&$3, &$8, 1, 1, 0, tmp);
3012 return yyerror ("Displacement out of range");
3015 /* LDST: W [ pregs <post_op> ] = dregs. */
3016 | W LBRACK REG post_op RBRACK ASSIGN REG
3019 return yyerror ("Dreg expected for source operand");
3021 return yyerror ("Preg expected in address");
3023 notethat ("LDST: W [ pregs <post_op> ] = dregs\n");
3024 $$ = LDST (&$3, &$7, $4.x0, 1, 0, 1);
3027 | W LBRACK REG post_op RBRACK ASSIGN HALF_REG
3030 return yyerror ("Dreg expected for source operand");
3033 if (!IS_IREG ($3) && !IS_PREG ($3))
3034 return yyerror ("Ireg or Preg expected in address");
3036 else if (!IS_IREG ($3))
3037 return yyerror ("Ireg expected in address");
3041 notethat ("dspLDST: W [ iregs <post_op> ] = dregs_half\n");
3042 $$ = DSPLDST (&$3, 1 + IS_H ($7), &$7, $4.x0, 1);
3046 notethat ("LDSTpmod: W [ pregs ] = dregs_half\n");
3047 $$ = LDSTPMOD (&$3, &$7, &$3, 1 + IS_H ($7), 1);
3051 /* LDSTiiFP: [ FP - const ] = dpregs. */
3052 | LBRACK REG plus_minus expr RBRACK ASSIGN REG
3054 Expr_Node *tmp = $4;
3055 int ispreg = IS_PREG ($7);
3058 return yyerror ("Preg expected in address");
3060 if (!IS_DREG ($7) && !ispreg)
3061 return yyerror ("Preg expected for source operand");
3064 tmp = unary (Expr_Op_Type_NEG, tmp);
3067 return yyerror ("Plain symbol used as offset");
3069 if (in_range_p (tmp, 0, 63, 3))
3071 notethat ("LDSTii: dpregs = [ pregs + uimm6m4 ]\n");
3072 $$ = LDSTII (&$2, &$7, tmp, 1, ispreg ? 3 : 0);
3074 else if ($2.regno == REG_FP && in_range_p (tmp, -128, 0, 3))
3076 notethat ("LDSTiiFP: dpregs = [ FP - uimm7m4 ]\n");
3077 tmp = unary (Expr_Op_Type_NEG, tmp);
3078 $$ = LDSTIIFP (tmp, &$7, 1);
3080 else if (in_range_p (tmp, -131072, 131071, 3))
3082 notethat ("LDSTidxI: [ pregs + imm18m4 ] = dpregs\n");
3083 $$ = LDSTIDXI (&$2, &$7, 1, 0, ispreg ? 1 : 0, tmp);
3086 return yyerror ("Displacement out of range");
3089 | REG ASSIGN W LBRACK REG plus_minus expr RBRACK xpmod
3091 Expr_Node *tmp = $7;
3093 return yyerror ("Dreg expected for destination operand");
3095 return yyerror ("Preg expected in address");
3098 tmp = unary (Expr_Op_Type_NEG, tmp);
3101 return yyerror ("Plain symbol used as offset");
3103 if (in_range_p (tmp, 0, 30, 1))
3105 notethat ("LDSTii: dregs = W [ pregs + uimm5m2 ] (.)\n");
3106 $$ = LDSTII (&$5, &$1, tmp, 0, 1 << $9.r0);
3108 else if (in_range_p (tmp, -65536, 65535, 1))
3110 notethat ("LDSTidxI: dregs = W [ pregs + imm17m2 ] (.)\n");
3111 $$ = LDSTIDXI (&$5, &$1, 0, 1, $9.r0, tmp);
3114 return yyerror ("Displacement out of range");
3117 | HALF_REG ASSIGN W LBRACK REG post_op RBRACK
3120 return yyerror ("Dreg expected for source operand");
3123 if (!IS_IREG ($5) && !IS_PREG ($5))
3124 return yyerror ("Ireg or Preg expected in address");
3126 else if (!IS_IREG ($5))
3127 return yyerror ("Ireg expected in address");
3131 notethat ("dspLDST: dregs_half = W [ iregs <post_op> ]\n");
3132 $$ = DSPLDST(&$5, 1 + IS_H ($1), &$1, $6.x0, 0);
3136 notethat ("LDSTpmod: dregs_half = W [ pregs <post_op> ]\n");
3137 $$ = LDSTPMOD (&$5, &$1, &$5, 1 + IS_H ($1), 0);
3142 | REG ASSIGN W LBRACK REG post_op RBRACK xpmod
3145 return yyerror ("Dreg expected for destination operand");
3147 return yyerror ("Preg expected in address");
3149 notethat ("LDST: dregs = W [ pregs <post_op> ] (.)\n");
3150 $$ = LDST (&$5, &$1, $6.x0, 1, $8.r0, 0);
3153 | REG ASSIGN W LBRACK REG _PLUS_PLUS REG RBRACK xpmod
3156 return yyerror ("Dreg expected for destination operand");
3157 if (!IS_PREG ($5) || !IS_PREG ($7))
3158 return yyerror ("Preg expected in address");
3160 notethat ("LDSTpmod: dregs = W [ pregs ++ pregs ] (.)\n");
3161 $$ = LDSTPMOD (&$5, &$1, &$7, 3, $9.r0);
3164 | HALF_REG ASSIGN W LBRACK REG _PLUS_PLUS REG RBRACK
3167 return yyerror ("Dreg expected for destination operand");
3168 if (!IS_PREG ($5) || !IS_PREG ($7))
3169 return yyerror ("Preg expected in address");
3171 notethat ("LDSTpmod: dregs_half = W [ pregs ++ pregs ]\n");
3172 $$ = LDSTPMOD (&$5, &$1, &$7, 1 + IS_H ($1), 0);
3175 | LBRACK REG post_op RBRACK ASSIGN REG
3177 if (!IS_IREG ($2) && !IS_PREG ($2))
3178 return yyerror ("Ireg or Preg expected in address");
3179 else if (IS_IREG ($2) && !IS_DREG ($6))
3180 return yyerror ("Dreg expected for source operand");
3181 else if (IS_PREG ($2) && !IS_DREG ($6) && !IS_PREG ($6))
3182 return yyerror ("Dreg or Preg expected for source operand");
3186 notethat ("dspLDST: [ iregs <post_op> ] = dregs\n");
3187 $$ = DSPLDST(&$2, 0, &$6, $3.x0, 1);
3189 else if (IS_DREG ($6))
3191 notethat ("LDST: [ pregs <post_op> ] = dregs\n");
3192 $$ = LDST (&$2, &$6, $3.x0, 0, 0, 1);
3196 notethat ("LDST: [ pregs <post_op> ] = pregs\n");
3197 $$ = LDST (&$2, &$6, $3.x0, 0, 1, 1);
3201 | LBRACK REG _PLUS_PLUS REG RBRACK ASSIGN REG
3204 return yyerror ("Dreg expected for source operand");
3206 if (IS_IREG ($2) && IS_MREG ($4))
3208 notethat ("dspLDST: [ iregs ++ mregs ] = dregs\n");
3209 $$ = DSPLDST(&$2, $4.regno & CODE_MASK, &$7, 3, 1);
3211 else if (IS_PREG ($2) && IS_PREG ($4))
3213 notethat ("LDSTpmod: [ pregs ++ pregs ] = dregs\n");
3214 $$ = LDSTPMOD (&$2, &$7, &$4, 0, 1);
3217 return yyerror ("Preg ++ Preg or Ireg ++ Mreg expected in address");
3220 | W LBRACK REG _PLUS_PLUS REG RBRACK ASSIGN HALF_REG
3223 return yyerror ("Dreg expected for source operand");
3225 if (IS_PREG ($3) && IS_PREG ($5))
3227 notethat ("LDSTpmod: W [ pregs ++ pregs ] = dregs_half\n");
3228 $$ = LDSTPMOD (&$3, &$8, &$5, 1 + IS_H ($8), 1);
3231 return yyerror ("Preg ++ Preg expected in address");
3234 | REG ASSIGN B LBRACK REG plus_minus expr RBRACK xpmod
3236 Expr_Node *tmp = $7;
3238 return yyerror ("Dreg expected for destination operand");
3240 return yyerror ("Preg expected in address");
3243 tmp = unary (Expr_Op_Type_NEG, tmp);
3246 return yyerror ("Plain symbol used as offset");
3248 if (in_range_p (tmp, -32768, 32767, 0))
3250 notethat ("LDSTidxI: dregs = B [ pregs + imm16 ] (%c)\n",
3252 $$ = LDSTIDXI (&$5, &$1, 0, 2, $9.r0, tmp);
3255 return yyerror ("Displacement out of range");
3258 | REG ASSIGN B LBRACK REG post_op RBRACK xpmod
3261 return yyerror ("Dreg expected for destination operand");
3263 return yyerror ("Preg expected in address");
3265 notethat ("LDST: dregs = B [ pregs <post_op> ] (%c)\n",
3267 $$ = LDST (&$5, &$1, $6.x0, 2, $8.r0, 0);
3270 | REG ASSIGN LBRACK REG _PLUS_PLUS REG RBRACK
3273 return yyerror ("Dreg expected for destination operand");
3275 if (IS_IREG ($4) && IS_MREG ($6))
3277 notethat ("dspLDST: dregs = [ iregs ++ mregs ]\n");
3278 $$ = DSPLDST(&$4, $6.regno & CODE_MASK, &$1, 3, 0);
3280 else if (IS_PREG ($4) && IS_PREG ($6))
3282 notethat ("LDSTpmod: dregs = [ pregs ++ pregs ]\n");
3283 $$ = LDSTPMOD (&$4, &$1, &$6, 0, 0);
3286 return yyerror ("Preg ++ Preg or Ireg ++ Mreg expected in address");
3289 | REG ASSIGN LBRACK REG plus_minus got_or_expr RBRACK
3291 Expr_Node *tmp = $6;
3292 int ispreg = IS_PREG ($1);
3293 int isgot = IS_RELOC($6);
3296 return yyerror ("Preg expected in address");
3298 if (!IS_DREG ($1) && !ispreg)
3299 return yyerror ("Dreg or Preg expected for destination operand");
3301 if (tmp->type == Expr_Node_Reloc
3302 && strcmp (tmp->value.s_value,
3303 "_current_shared_library_p5_offset_") != 0)
3304 return yyerror ("Plain symbol used as offset");
3307 tmp = unary (Expr_Op_Type_NEG, tmp);
3311 notethat ("LDSTidxI: dpregs = [ pregs + sym@got ]\n");
3312 $$ = LDSTIDXI (&$4, &$1, 0, 0, ispreg ? 1 : 0, tmp);
3314 else if (in_range_p (tmp, 0, 63, 3))
3316 notethat ("LDSTii: dpregs = [ pregs + uimm7m4 ]\n");
3317 $$ = LDSTII (&$4, &$1, tmp, 0, ispreg ? 3 : 0);
3319 else if ($4.regno == REG_FP && in_range_p (tmp, -128, 0, 3))
3321 notethat ("LDSTiiFP: dpregs = [ FP - uimm7m4 ]\n");
3322 tmp = unary (Expr_Op_Type_NEG, tmp);
3323 $$ = LDSTIIFP (tmp, &$1, 0);
3325 else if (in_range_p (tmp, -131072, 131071, 3))
3327 notethat ("LDSTidxI: dpregs = [ pregs + imm18m4 ]\n");
3328 $$ = LDSTIDXI (&$4, &$1, 0, 0, ispreg ? 1 : 0, tmp);
3332 return yyerror ("Displacement out of range");
3335 | REG ASSIGN LBRACK REG post_op RBRACK
3337 if (!IS_IREG ($4) && !IS_PREG ($4))
3338 return yyerror ("Ireg or Preg expected in address");
3339 else if (IS_IREG ($4) && !IS_DREG ($1))
3340 return yyerror ("Dreg expected in destination operand");
3341 else if (IS_PREG ($4) && !IS_DREG ($1) && !IS_PREG ($1)
3342 && ($4.regno != REG_SP || !IS_ALLREG ($1) || $5.x0 != 0))
3343 return yyerror ("Dreg or Preg expected in destination operand");
3347 notethat ("dspLDST: dregs = [ iregs <post_op> ]\n");
3348 $$ = DSPLDST (&$4, 0, &$1, $5.x0, 0);
3350 else if (IS_DREG ($1))
3352 notethat ("LDST: dregs = [ pregs <post_op> ]\n");
3353 $$ = LDST (&$4, &$1, $5.x0, 0, 0, 0);
3355 else if (IS_PREG ($1))
3357 if (REG_SAME ($1, $4) && $5.x0 != 2)
3358 return yyerror ("Pregs can't be same");
3360 notethat ("LDST: pregs = [ pregs <post_op> ]\n");
3361 $$ = LDST (&$4, &$1, $5.x0, 0, 1, 0);
3365 notethat ("PushPopReg: allregs = [ SP ++ ]\n");
3366 $$ = PUSHPOPREG (&$1, 0);
3371 /* PushPopMultiple. */
3372 | reg_with_predec ASSIGN LPAREN REG COLON expr COMMA REG COLON expr RPAREN
3374 if ($1.regno != REG_SP)
3375 yyerror ("Stack Pointer expected");
3376 if ($4.regno == REG_R7
3377 && IN_RANGE ($6, 0, 7)
3378 && $8.regno == REG_P5
3379 && IN_RANGE ($10, 0, 5))
3381 notethat ("PushPopMultiple: [ -- SP ] = (R7 : reglim , P5 : reglim )\n");
3382 $$ = PUSHPOPMULTIPLE (imm5 ($6), imm5 ($10), 1, 1, 1);
3385 return yyerror ("Bad register for PushPopMultiple");
3388 | reg_with_predec ASSIGN LPAREN REG COLON expr RPAREN
3390 if ($1.regno != REG_SP)
3391 yyerror ("Stack Pointer expected");
3393 if ($4.regno == REG_R7 && IN_RANGE ($6, 0, 7))
3395 notethat ("PushPopMultiple: [ -- SP ] = (R7 : reglim )\n");
3396 $$ = PUSHPOPMULTIPLE (imm5 ($6), 0, 1, 0, 1);
3398 else if ($4.regno == REG_P5 && IN_RANGE ($6, 0, 6))
3400 notethat ("PushPopMultiple: [ -- SP ] = (P5 : reglim )\n");
3401 $$ = PUSHPOPMULTIPLE (0, imm5 ($6), 0, 1, 1);
3404 return yyerror ("Bad register for PushPopMultiple");
3407 | LPAREN REG COLON expr COMMA REG COLON expr RPAREN ASSIGN reg_with_postinc
3409 if ($11.regno != REG_SP)
3410 yyerror ("Stack Pointer expected");
3411 if ($2.regno == REG_R7 && (IN_RANGE ($4, 0, 7))
3412 && $6.regno == REG_P5 && (IN_RANGE ($8, 0, 6)))
3414 notethat ("PushPopMultiple: (R7 : reglim , P5 : reglim ) = [ SP ++ ]\n");
3415 $$ = PUSHPOPMULTIPLE (imm5 ($4), imm5 ($8), 1, 1, 0);
3418 return yyerror ("Bad register range for PushPopMultiple");
3421 | LPAREN REG COLON expr RPAREN ASSIGN reg_with_postinc
3423 if ($7.regno != REG_SP)
3424 yyerror ("Stack Pointer expected");
3426 if ($2.regno == REG_R7 && IN_RANGE ($4, 0, 7))
3428 notethat ("PushPopMultiple: (R7 : reglim ) = [ SP ++ ]\n");
3429 $$ = PUSHPOPMULTIPLE (imm5 ($4), 0, 1, 0, 0);
3431 else if ($2.regno == REG_P5 && IN_RANGE ($4, 0, 6))
3433 notethat ("PushPopMultiple: (P5 : reglim ) = [ SP ++ ]\n");
3434 $$ = PUSHPOPMULTIPLE (0, imm5 ($4), 0, 1, 0);
3437 return yyerror ("Bad register range for PushPopMultiple");
3440 | reg_with_predec ASSIGN REG
3442 if ($1.regno != REG_SP)
3443 yyerror ("Stack Pointer expected");
3447 notethat ("PushPopReg: [ -- SP ] = allregs\n");
3448 $$ = PUSHPOPREG (&$3, 1);
3451 return yyerror ("Bad register for PushPopReg");
3458 if (IS_URANGE (16, $2, 0, 4))
3459 $$ = LINKAGE (0, uimm16s4 ($2));
3461 return yyerror ("Bad constant for LINK");
3466 notethat ("linkage: UNLINK\n");
3467 $$ = LINKAGE (1, 0);
3473 | LSETUP LPAREN expr COMMA expr RPAREN REG
3475 if (IS_PCREL4 ($3) && IS_LPPCREL10 ($5) && IS_CREG ($7))
3477 notethat ("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters\n");
3478 $$ = LOOPSETUP ($3, &$7, 0, $5, 0);
3481 return yyerror ("Bad register or values for LSETUP");
3484 | LSETUP LPAREN expr COMMA expr RPAREN REG ASSIGN REG
3486 if (IS_PCREL4 ($3) && IS_LPPCREL10 ($5)
3487 && IS_PREG ($9) && IS_CREG ($7))
3489 notethat ("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters = pregs\n");
3490 $$ = LOOPSETUP ($3, &$7, 1, $5, &$9);
3493 return yyerror ("Bad register or values for LSETUP");
3496 | LSETUP LPAREN expr COMMA expr RPAREN REG ASSIGN REG GREATER_GREATER expr
3498 if (IS_PCREL4 ($3) && IS_LPPCREL10 ($5)
3499 && IS_PREG ($9) && IS_CREG ($7)
3500 && EXPR_VALUE ($11) == 1)
3502 notethat ("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters = pregs >> 1\n");
3503 $$ = LOOPSETUP ($3, &$7, 3, $5, &$9);
3506 return yyerror ("Bad register or values for LSETUP");
3513 return yyerror ("Invalid expression in loop statement");
3515 return yyerror ("Invalid loop counter register");
3516 $$ = bfin_gen_loop ($2, &$3, 0, 0);
3518 | LOOP expr REG ASSIGN REG
3520 if (IS_RELOC ($2) && IS_PREG ($5) && IS_CREG ($3))
3522 notethat ("Loop: LOOP expr counters = pregs\n");
3523 $$ = bfin_gen_loop ($2, &$3, 1, &$5);
3526 return yyerror ("Bad register or values for LOOP");
3528 | LOOP expr REG ASSIGN REG GREATER_GREATER expr
3530 if (IS_RELOC ($2) && IS_PREG ($5) && IS_CREG ($3) && EXPR_VALUE ($7) == 1)
3532 notethat ("Loop: LOOP expr counters = pregs >> 1\n");
3533 $$ = bfin_gen_loop ($2, &$3, 3, &$5);
3536 return yyerror ("Bad register or values for LOOP");
3543 return yyerror ("Invalid expression in LOOP_BEGIN statement");
3545 bfin_loop_beginend ($2, 1);
3553 return yyerror ("Invalid expression in LOOP_END statement");
3555 bfin_loop_beginend ($2, 0);
3563 notethat ("pseudoDEBUG: DBG\n");
3564 $$ = bfin_gen_pseudodbg (3, 7, 0);
3568 notethat ("pseudoDEBUG: DBG REG_A\n");
3569 $$ = bfin_gen_pseudodbg (3, IS_A1 ($2), 0);
3573 notethat ("pseudoDEBUG: DBG allregs\n");
3574 $$ = bfin_gen_pseudodbg (0, $2.regno & CODE_MASK, $2.regno & CLASS_MASK);
3577 | DBGCMPLX LPAREN REG RPAREN
3580 return yyerror ("Dregs expected");
3581 notethat ("pseudoDEBUG: DBGCMPLX (dregs )\n");
3582 $$ = bfin_gen_pseudodbg (3, 6, $3.regno & CODE_MASK);
3587 notethat ("psedoDEBUG: DBGHALT\n");
3588 $$ = bfin_gen_pseudodbg (3, 5, 0);
3593 notethat ("psedoDEBUG: HLT\n");
3594 $$ = bfin_gen_pseudodbg (3, 4, 0);
3597 | DBGA LPAREN HALF_REG COMMA expr RPAREN
3599 notethat ("pseudodbg_assert: DBGA (regs_lo/hi , uimm16 )\n");
3600 $$ = bfin_gen_pseudodbg_assert (IS_H ($3), &$3, uimm16 ($5));
3603 | DBGAH LPAREN REG COMMA expr RPAREN
3605 notethat ("pseudodbg_assert: DBGAH (regs , uimm16 )\n");
3606 $$ = bfin_gen_pseudodbg_assert (3, &$3, uimm16 ($5));
3609 | DBGAL LPAREN REG COMMA expr RPAREN
3611 notethat ("psedodbg_assert: DBGAL (regs , uimm16 )\n");
3612 $$ = bfin_gen_pseudodbg_assert (2, &$3, uimm16 ($5));
3620 /* Register rules. */
3622 REG_A: REG_A_DOUBLE_ZERO
3640 | LPAREN M COMMA MMOD RPAREN
3645 | LPAREN MMOD COMMA M RPAREN
3650 | LPAREN MMOD RPAREN
3662 asr_asl: LPAREN ASL RPAREN
3743 | LPAREN asr_asl_0 RPAREN
3755 | LPAREN asr_asl_0 COMMA sco RPAREN
3761 | LPAREN sco COMMA asr_asl_0 RPAREN
3821 | LPAREN V COMMA S RPAREN
3826 | LPAREN S COMMA V RPAREN
3888 | LPAREN MMOD RPAREN
3891 return yyerror ("Bad modifier");
3895 | LPAREN MMOD COMMA R RPAREN
3898 return yyerror ("Bad modifier");
3902 | LPAREN R COMMA MMOD RPAREN
3905 return yyerror ("Bad modifier");
3932 | LPAREN MMOD RPAREN
3937 return yyerror ("Only (W32) allowed");
3945 | LPAREN MMOD RPAREN
3950 return yyerror ("(IU) expected");
3954 reg_with_predec: LBRACK _MINUS_MINUS REG RBRACK
3960 reg_with_postinc: LBRACK REG _PLUS_PLUS RBRACK
4012 $$.r0 = 1; /* HL. */
4015 $$.aop = 0; /* aop. */
4020 $$.r0 = 1; /* HL. */
4023 $$.aop = 1; /* aop. */
4026 | LPAREN RNDL RPAREN
4028 $$.r0 = 0; /* HL. */
4031 $$.aop = 0; /* aop. */
4036 $$.r0 = 0; /* HL. */
4042 | LPAREN RNDH COMMA R RPAREN
4044 $$.r0 = 1; /* HL. */
4047 $$.aop = 0; /* aop. */
4049 | LPAREN TH COMMA R RPAREN
4051 $$.r0 = 1; /* HL. */
4054 $$.aop = 1; /* aop. */
4056 | LPAREN RNDL COMMA R RPAREN
4058 $$.r0 = 0; /* HL. */
4061 $$.aop = 0; /* aop. */
4064 | LPAREN TL COMMA R RPAREN
4066 $$.r0 = 0; /* HL. */
4069 $$.aop = 1; /* aop. */
4077 $$.x0 = 0; /* HL. */
4082 $$.x0 = 1; /* HL. */
4084 | LPAREN LO COMMA R RPAREN
4087 $$.x0 = 0; /* HL. */
4089 | LPAREN HI COMMA R RPAREN
4092 $$.x0 = 1; /* HL. */
4110 /* Assignments, Macfuncs. */
4136 if (IS_A1 ($3) && IS_EVEN ($1))
4137 return yyerror ("Cannot move A1 to even register");
4138 else if (!IS_A1 ($3) && !IS_EVEN ($1))
4139 return yyerror ("Cannot move A0 to odd register");
4155 | REG ASSIGN LPAREN a_macfunc RPAREN
4157 if ($4.n && IS_EVEN ($1))
4158 return yyerror ("Cannot move A1 to even register");
4159 else if (!$4.n && !IS_EVEN ($1))
4160 return yyerror ("Cannot move A0 to odd register");
4168 | HALF_REG ASSIGN LPAREN a_macfunc RPAREN
4170 if ($4.n && !IS_H ($1))
4171 return yyerror ("Cannot move A1 to low half of register");
4172 else if (!$4.n && IS_H ($1))
4173 return yyerror ("Cannot move A0 to high half of register");
4181 | HALF_REG ASSIGN REG_A
4183 if (IS_A1 ($3) && !IS_H ($1))
4184 return yyerror ("Cannot move A1 to low half of register");
4185 else if (!IS_A1 ($3) && IS_H ($1))
4186 return yyerror ("Cannot move A0 to high half of register");
4199 a_assign multiply_halfregs
4206 | a_plusassign multiply_halfregs
4213 | a_minusassign multiply_halfregs
4223 HALF_REG STAR HALF_REG
4225 if (IS_DREG ($1) && IS_DREG ($3))
4231 return yyerror ("Dregs expected");
4255 CCREG cc_op STATUS_REG
4267 | STATUS_REG cc_op CCREG
4281 /* Expressions and Symbols. */
4285 Expr_Node_Value val;
4286 val.s_value = S_GET_NAME($1);
4287 $$ = Expr_Node_Create (Expr_Node_Reloc, val, NULL, NULL);
4293 { $$ = BFD_RELOC_BFIN_GOT; }
4295 { $$ = BFD_RELOC_BFIN_GOT17M4; }
4297 { $$ = BFD_RELOC_BFIN_FUNCDESC_GOT17M4; }
4300 got: symbol AT any_gotrel
4302 Expr_Node_Value val;
4304 $$ = Expr_Node_Create (Expr_Node_GOT_Reloc, val, $1, NULL);
4327 Expr_Node_Value val;
4329 $$ = Expr_Node_Create (Expr_Node_Constant, val, NULL, NULL);
4335 | LPAREN expr_1 RPAREN
4341 $$ = unary (Expr_Op_Type_COMP, $2);
4343 | MINUS expr_1 %prec TILDA
4345 $$ = unary (Expr_Op_Type_NEG, $2);
4355 expr_1: expr_1 STAR expr_1
4357 $$ = binary (Expr_Op_Type_Mult, $1, $3);
4359 | expr_1 SLASH expr_1
4361 $$ = binary (Expr_Op_Type_Div, $1, $3);
4363 | expr_1 PERCENT expr_1
4365 $$ = binary (Expr_Op_Type_Mod, $1, $3);
4367 | expr_1 PLUS expr_1
4369 $$ = binary (Expr_Op_Type_Add, $1, $3);
4371 | expr_1 MINUS expr_1
4373 $$ = binary (Expr_Op_Type_Sub, $1, $3);
4375 | expr_1 LESS_LESS expr_1
4377 $$ = binary (Expr_Op_Type_Lshift, $1, $3);
4379 | expr_1 GREATER_GREATER expr_1
4381 $$ = binary (Expr_Op_Type_Rshift, $1, $3);
4383 | expr_1 AMPERSAND expr_1
4385 $$ = binary (Expr_Op_Type_BAND, $1, $3);
4387 | expr_1 CARET expr_1
4389 $$ = binary (Expr_Op_Type_LOR, $1, $3);
4393 $$ = binary (Expr_Op_Type_BOR, $1, $3);
4405 mkexpr (int x, SYMBOL_T s)
4407 EXPR_T e = (EXPR_T) ALLOCATE (sizeof (struct expression_cell));
4414 value_match (Expr_Node *exp, int sz, int sign, int mul, int issigned)
4416 int umax = (1 << sz) - 1;
4417 int min = -1 << (sz - 1);
4418 int max = (1 << (sz - 1)) - 1;
4420 int v = (EXPR_VALUE (exp)) & 0xffffffff;
4424 error ("%s:%d: Value Error -- Must align to %d\n", __FILE__, __LINE__, mul);
4435 if (v >= min && v <= max) return 1;
4438 fprintf(stderr, "signed value %lx out of range\n", v * mul);
4442 if (v <= umax && v >= 0)
4445 fprintf(stderr, "unsigned value %lx out of range\n", v * mul);
4450 /* Return the expression structure that allows symbol operations.
4451 If the left and right children are constants, do the operation. */
4453 binary (Expr_Op_Type op, Expr_Node *x, Expr_Node *y)
4455 Expr_Node_Value val;
4457 if (x->type == Expr_Node_Constant && y->type == Expr_Node_Constant)
4461 case Expr_Op_Type_Add:
4462 x->value.i_value += y->value.i_value;
4464 case Expr_Op_Type_Sub:
4465 x->value.i_value -= y->value.i_value;
4467 case Expr_Op_Type_Mult:
4468 x->value.i_value *= y->value.i_value;
4470 case Expr_Op_Type_Div:
4471 if (y->value.i_value == 0)
4472 error ("Illegal Expression: Division by zero.");
4474 x->value.i_value /= y->value.i_value;
4476 case Expr_Op_Type_Mod:
4477 x->value.i_value %= y->value.i_value;
4479 case Expr_Op_Type_Lshift:
4480 x->value.i_value <<= y->value.i_value;
4482 case Expr_Op_Type_Rshift:
4483 x->value.i_value >>= y->value.i_value;
4485 case Expr_Op_Type_BAND:
4486 x->value.i_value &= y->value.i_value;
4488 case Expr_Op_Type_BOR:
4489 x->value.i_value |= y->value.i_value;
4491 case Expr_Op_Type_BXOR:
4492 x->value.i_value ^= y->value.i_value;
4494 case Expr_Op_Type_LAND:
4495 x->value.i_value = x->value.i_value && y->value.i_value;
4497 case Expr_Op_Type_LOR:
4498 x->value.i_value = x->value.i_value || y->value.i_value;
4502 error ("%s:%d: Internal assembler error\n", __FILE__, __LINE__);
4506 /* Canonicalize order to EXPR OP CONSTANT. */
4507 if (x->type == Expr_Node_Constant)
4513 /* Canonicalize subtraction of const to addition of negated const. */
4514 if (op == Expr_Op_Type_Sub && y->type == Expr_Node_Constant)
4516 op = Expr_Op_Type_Add;
4517 y->value.i_value = -y->value.i_value;
4519 if (y->type == Expr_Node_Constant && x->type == Expr_Node_Binop
4520 && x->Right_Child->type == Expr_Node_Constant)
4522 if (op == x->value.op_value && x->value.op_value == Expr_Op_Type_Add)
4524 x->Right_Child->value.i_value += y->value.i_value;
4529 /* Create a new expression structure. */
4531 return Expr_Node_Create (Expr_Node_Binop, val, x, y);
4535 unary (Expr_Op_Type op, Expr_Node *x)
4537 if (x->type == Expr_Node_Constant)
4541 case Expr_Op_Type_NEG:
4542 x->value.i_value = -x->value.i_value;
4544 case Expr_Op_Type_COMP:
4545 x->value.i_value = ~x->value.i_value;
4548 error ("%s:%d: Internal assembler error\n", __FILE__, __LINE__);
4554 /* Create a new expression structure. */
4555 Expr_Node_Value val;
4557 return Expr_Node_Create (Expr_Node_Unop, val, x, NULL);
4561 int debug_codeselection = 0;
4563 notethat (char *format, ...)
4566 va_start (ap, format);
4567 if (debug_codeselection)
4569 vfprintf (errorf, format, ap);
4575 main (int argc, char **argv)