1 /* bfin-parse.y ADI Blackfin parser
2 Copyright 2005, 2006, 2007, 2008
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 *expr, int sz, int sign, int mul, int issigned);
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 *format, ...);
165 char *current_inputline;
167 int yyerror (char *msg);
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 *expr, int from, int to, unsigned int mask)
198 int val = EXPR_VALUE (expr);
199 if (expr->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 neg_value (Expr_Node *expr)
228 expr->value.i_value = -expr->value.i_value;
232 valid_dreg_pair (Register *reg1, Expr_Node *reg2)
234 if (!IS_DREG (*reg1))
236 yyerror ("Dregs expected");
240 if (reg1->regno != 1 && reg1->regno != 3)
242 yyerror ("Bad register pair");
246 if (imm7 (reg2) != reg1->regno - 1)
248 yyerror ("Bad register pair");
257 check_multiply_halfregs (Macfunc *aa, Macfunc *ab)
259 if ((!REG_EQUAL (aa->s0, ab->s0) && !REG_EQUAL (aa->s0, ab->s1))
260 || (!REG_EQUAL (aa->s1, ab->s1) && !REG_EQUAL (aa->s1, ab->s0)))
261 return yyerror ("Source multiplication register mismatch");
267 /* Check mac option. */
270 check_macfunc_option (Macfunc *a, Opt_mode *opt)
272 /* Default option is always valid. */
276 if ((a->w == 1 && a->P == 1
277 && opt->mod != M_FU && opt->mod != M_IS && opt->mod != M_IU
278 && opt->mod != M_S2RND && opt->mod != M_ISS2)
279 || (a->w == 1 && a->P == 0
280 && opt->mod != M_FU && opt->mod != M_IS && opt->mod != M_IU
281 && opt->mod != M_T && opt->mod != M_TFU && opt->mod != M_S2RND
282 && opt->mod != M_ISS2 && opt->mod != M_IH)
283 || (a->w == 0 && a->P == 0
284 && opt->mod != M_FU && opt->mod != M_IS && opt->mod != M_W32))
290 /* Check (vector) mac funcs and ops. */
293 check_macfuncs (Macfunc *aa, Opt_mode *opa,
294 Macfunc *ab, Opt_mode *opb)
296 /* Variables for swapping. */
300 /* The option mode should be put at the end of the second instruction
301 of the vector except M, which should follow MAC1 instruction. */
303 return yyerror ("Bad opt mode");
305 /* If a0macfunc comes before a1macfunc, swap them. */
309 /* (M) is not allowed here. */
311 return yyerror ("(M) not allowed with A0MAC");
313 return yyerror ("Vector AxMACs can't be same");
315 mtmp = *aa; *aa = *ab; *ab = mtmp;
316 otmp = *opa; *opa = *opb; *opb = otmp;
321 return yyerror ("(M) not allowed with A0MAC");
323 return yyerror ("Vector AxMACs can't be same");
326 /* If both ops are one of 0, 1, or 2, we have multiply_halfregs in both
327 assignment_or_macfuncs. */
328 if ((aa->op == 0 || aa->op == 1 || aa->op == 2)
329 && (ab->op == 0 || ab->op == 1 || ab->op == 2))
331 if (check_multiply_halfregs (aa, ab) < 0)
336 /* Only one of the assign_macfuncs has a half reg multiply
337 Evil trick: Just 'OR' their source register codes:
338 We can do that, because we know they were initialized to 0
339 in the rules that don't use multiply_halfregs. */
340 aa->s0.regno |= (ab->s0.regno & CODE_MASK);
341 aa->s1.regno |= (ab->s1.regno & CODE_MASK);
344 if (aa->w == ab->w && aa->P != ab->P)
346 return yyerror ("macfuncs must differ");
347 if (aa->w && (aa->dst.regno - ab->dst.regno != 1))
348 return yyerror ("Destination Dregs must differ by one");
351 /* Make sure mod flags get ORed, too. */
352 opb->mod |= opa->mod;
355 if (check_macfunc_option (aa, opb) < 0
356 && check_macfunc_option (ab, opb) < 0)
357 return yyerror ("bad option");
359 /* Make sure first macfunc has got both P flags ORed. */
367 is_group1 (INSTR_T x)
369 /* Group1 is dpsLDST, LDSTpmod, LDST, LDSTiiFP, LDSTii. */
370 if ((x->value & 0xc000) == 0x8000 || (x->value == 0x0000))
377 is_group2 (INSTR_T x)
379 if ((((x->value & 0xfc00) == 0x9c00) /* dspLDST. */
380 && !((x->value & 0xfde0) == 0x9c60) /* dagMODim. */
381 && !((x->value & 0xfde0) == 0x9ce0) /* dagMODim with bit rev. */
382 && !((x->value & 0xfde0) == 0x9d60)) /* pick dagMODik. */
383 || (x->value == 0x0000))
389 gen_multi_instr_1 (INSTR_T dsp32, INSTR_T dsp16_grp1, INSTR_T dsp16_grp2)
391 int mask1 = dsp32 ? insn_regmask (dsp32->value, dsp32->next->value) : 0;
392 int mask2 = dsp16_grp1 ? insn_regmask (dsp16_grp1->value, 0) : 0;
393 int mask3 = dsp16_grp2 ? insn_regmask (dsp16_grp2->value, 0) : 0;
395 if ((mask1 & mask2) || (mask1 & mask3) || (mask2 & mask3))
396 yyerror ("resource conflict in multi-issue instruction");
397 return bfin_gen_multi_instr (dsp32, dsp16_grp1, dsp16_grp2);
409 struct { int r0; int s0; int x0; int aop; } modcodes;
410 struct { int r0; } r0;
417 /* Vector Specific. */
418 %token BYTEOP16P BYTEOP16M
419 %token BYTEOP1P BYTEOP2P BYTEOP2M BYTEOP3P
420 %token BYTEUNPACK BYTEPACK
423 %token ALIGN8 ALIGN16 ALIGN24
425 %token EXTRACT DEPOSIT EXPADJ SEARCH
426 %token ONES SIGN SIGNBITS
434 %token CCREG BYTE_DREG
435 %token REG_A_DOUBLE_ZERO REG_A_DOUBLE_ONE
436 %token A_ZERO_DOT_L A_ZERO_DOT_H A_ONE_DOT_L A_ONE_DOT_H
441 %token RTI RTS RTX RTN RTE
452 %token JUMP JUMP_DOT_S JUMP_DOT_L
459 %token NOT TILDA BANG
465 %token MINUS PLUS STAR SLASH
469 %token _PLUS_BAR_PLUS _PLUS_BAR_MINUS _MINUS_BAR_PLUS _MINUS_BAR_MINUS
470 %token _MINUS_MINUS _PLUS_PLUS
472 /* Shift/rotate ops. */
473 %token SHIFT LSHIFT ASHIFT BXORSHIFT
474 %token _GREATER_GREATER_GREATER_THAN_ASSIGN
476 %token LESS_LESS GREATER_GREATER
477 %token _GREATER_GREATER_GREATER
478 %token _LESS_LESS_ASSIGN _GREATER_GREATER_ASSIGN
481 /* In place operators. */
482 %token ASSIGN _STAR_ASSIGN
483 %token _BAR_ASSIGN _CARET_ASSIGN _AMPERSAND_ASSIGN
484 %token _MINUS_ASSIGN _PLUS_ASSIGN
486 /* Assignments, comparisons. */
487 %token _ASSIGN_BANG _LESS_THAN_ASSIGN _ASSIGN_ASSIGN
492 %token FLUSHINV FLUSH
493 %token IFLUSH PREFETCH
510 %token R RND RNDL RNDH RND12 RND20
515 %token BITTGL BITCLR BITSET BITTST BITMUX
518 %token DBGAL DBGAH DBGHALT DBG DBGA DBGCMPLX
520 /* Semantic auxiliaries. */
523 %token COLON SEMICOLON
524 %token RPAREN LPAREN LBRACK RBRACK
528 %token GOT GOT17M4 FUNCDESC_GOT17M4
538 %type <modcodes> byteop_mod
540 %type <reg> a_plusassign
541 %type <reg> a_minusassign
542 %type <macfunc> multiply_halfregs
543 %type <macfunc> assign_macfunc
544 %type <macfunc> a_macfunc
548 %type <modcodes> vsmod
549 %type <modcodes> ccstat
552 %type <reg> reg_with_postinc
553 %type <reg> reg_with_predec
557 %type <symbol> SYMBOL
560 %type <reg> BYTE_DREG
561 %type <reg> REG_A_DOUBLE_ZERO
562 %type <reg> REG_A_DOUBLE_ONE
564 %type <reg> STATUS_REG
568 %type <modcodes> smod
569 %type <modcodes> b3_op
570 %type <modcodes> rnd_op
571 %type <modcodes> post_op
573 %type <r0> iu_or_nothing
574 %type <r0> plus_minus
578 %type <modcodes> amod0
579 %type <modcodes> amod1
580 %type <modcodes> amod2
582 %type <r0> w32_or_nothing
586 %type <expr> got_or_expr
588 %type <value> any_gotrel GOT GOT17M4 FUNCDESC_GOT17M4
590 /* Precedence rules. */
594 %left LESS_LESS GREATER_GREATER
596 %left STAR SLASH PERCENT
607 if (insn == (INSTR_T) 0)
608 return NO_INSN_GENERATED;
609 else if (insn == (INSTR_T) - 1)
610 return SEMANTIC_ERROR;
612 return INSN_GENERATED;
617 /* Parallel instructions. */
618 | asm_1 DOUBLE_BAR asm_1 DOUBLE_BAR asm_1 SEMICOLON
620 if (($1->value & 0xf800) == 0xc000)
622 if (is_group1 ($3) && is_group2 ($5))
623 $$ = gen_multi_instr_1 ($1, $3, $5);
624 else if (is_group2 ($3) && is_group1 ($5))
625 $$ = gen_multi_instr_1 ($1, $5, $3);
627 return yyerror ("Wrong 16 bit instructions groups, slot 2 and slot 3 must be 16-bit instrution group");
629 else if (($3->value & 0xf800) == 0xc000)
631 if (is_group1 ($1) && is_group2 ($5))
632 $$ = gen_multi_instr_1 ($3, $1, $5);
633 else if (is_group2 ($1) && is_group1 ($5))
634 $$ = gen_multi_instr_1 ($3, $5, $1);
636 return yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 3 must be 16-bit instrution group");
638 else if (($5->value & 0xf800) == 0xc000)
640 if (is_group1 ($1) && is_group2 ($3))
641 $$ = gen_multi_instr_1 ($5, $1, $3);
642 else if (is_group2 ($1) && is_group1 ($3))
643 $$ = gen_multi_instr_1 ($5, $3, $1);
645 return yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 2 must be 16-bit instrution group");
648 error ("\nIllegal Multi Issue Construct, at least any one of the slot must be DSP32 instruction group\n");
651 | asm_1 DOUBLE_BAR asm_1 SEMICOLON
653 if (($1->value & 0xf800) == 0xc000)
656 $$ = gen_multi_instr_1 ($1, $3, 0);
657 else if (is_group2 ($3))
658 $$ = gen_multi_instr_1 ($1, 0, $3);
660 return yyerror ("Wrong 16 bit instructions groups, slot 2 must be the 16-bit instruction group");
662 else if (($3->value & 0xf800) == 0xc000)
665 $$ = gen_multi_instr_1 ($3, $1, 0);
666 else if (is_group2 ($1))
667 $$ = gen_multi_instr_1 ($3, 0, $1);
669 return yyerror ("Wrong 16 bit instructions groups, slot 1 must be the 16-bit instruction group");
671 else if (is_group1 ($1) && is_group2 ($3))
672 $$ = gen_multi_instr_1 (0, $1, $3);
673 else if (is_group2 ($1) && is_group1 ($3))
674 $$ = gen_multi_instr_1 (0, $3, $1);
676 return yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 2 must be the 16-bit instruction group");
691 $$ = DSP32MAC (3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0);
693 | assign_macfunc opt_mode
697 int h00, h10, h01, h11;
699 if (check_macfunc_option (&$1, &$2) < 0)
700 return yyerror ("bad option");
705 return yyerror ("(m) not allowed with a0 unit");
724 $$ = DSP32MAC (op1, $2.MM, $2.mod, w1, $1.P, h01, h11, h00, h10,
725 &$1.dst, op0, &$1.s0, &$1.s1, w0);
731 | assign_macfunc opt_mode COMMA assign_macfunc opt_mode
735 if (check_macfuncs (&$1, &$2, &$4, &$5) < 0)
737 notethat ("assign_macfunc (.), assign_macfunc (.)\n");
744 $$ = DSP32MAC ($1.op, $2.MM, $5.mod, $1.w, $1.P,
745 IS_H ($1.s0), IS_H ($1.s1), IS_H ($4.s0), IS_H ($4.s1),
746 dst, $4.op, &$1.s0, &$1.s1, $4.w);
753 notethat ("dsp32alu: DISALGNEXCPT\n");
754 $$ = DSP32ALU (18, 0, 0, 0, 0, 0, 0, 0, 3);
756 | REG ASSIGN LPAREN a_plusassign REG_A RPAREN
758 if (IS_DREG ($1) && !IS_A1 ($4) && IS_A1 ($5))
760 notethat ("dsp32alu: dregs = ( A0 += A1 )\n");
761 $$ = DSP32ALU (11, 0, 0, &$1, 0, 0, 0, 0, 0);
764 return yyerror ("Register mismatch");
766 | HALF_REG ASSIGN LPAREN a_plusassign REG_A RPAREN
768 if (!IS_A1 ($4) && IS_A1 ($5))
770 notethat ("dsp32alu: dregs_half = ( A0 += A1 )\n");
771 $$ = DSP32ALU (11, IS_H ($1), 0, &$1, 0, 0, 0, 0, 1);
774 return yyerror ("Register mismatch");
776 | A_ZERO_DOT_H ASSIGN HALF_REG
778 notethat ("dsp32alu: A_ZERO_DOT_H = dregs_hi\n");
779 $$ = DSP32ALU (9, IS_H ($3), 0, 0, &$3, 0, 0, 0, 0);
781 | A_ONE_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, 2);
786 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEOP16P LPAREN REG
787 COLON expr COMMA REG COLON expr RPAREN aligndir
789 if (!IS_DREG ($2) || !IS_DREG ($4))
790 return yyerror ("Dregs expected");
791 else if (!valid_dreg_pair (&$9, $11))
792 return yyerror ("Bad dreg pair");
793 else if (!valid_dreg_pair (&$13, $15))
794 return yyerror ("Bad dreg pair");
797 notethat ("dsp32alu: (dregs , dregs ) = BYTEOP16P (dregs_pair , dregs_pair ) (half)\n");
798 $$ = DSP32ALU (21, 0, &$2, &$4, &$9, &$13, $17.r0, 0, 0);
802 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEOP16M LPAREN REG COLON expr COMMA
803 REG COLON expr RPAREN aligndir
805 if (!IS_DREG ($2) || !IS_DREG($4))
806 return yyerror ("Dregs expected");
807 else if (!valid_dreg_pair (&$9, $11))
808 return yyerror ("Bad dreg pair");
809 else if (!valid_dreg_pair (&$13, $15))
810 return yyerror ("Bad dreg pair");
813 notethat ("dsp32alu: (dregs , dregs ) = BYTEOP16M (dregs_pair , dregs_pair ) (aligndir)\n");
814 $$ = DSP32ALU (21, 0, &$2, &$4, &$9, &$13, $17.r0, 0, 1);
818 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEUNPACK REG COLON expr aligndir
820 if (!IS_DREG ($2) || !IS_DREG ($4))
821 return yyerror ("Dregs expected");
822 else if (!valid_dreg_pair (&$8, $10))
823 return yyerror ("Bad dreg pair");
826 notethat ("dsp32alu: (dregs , dregs ) = BYTEUNPACK dregs_pair (aligndir)\n");
827 $$ = DSP32ALU (24, 0, &$2, &$4, &$8, 0, $11.r0, 0, 1);
830 | LPAREN REG COMMA REG RPAREN ASSIGN SEARCH REG LPAREN searchmod RPAREN
832 if (IS_DREG ($2) && IS_DREG ($4) && IS_DREG ($8))
834 notethat ("dsp32alu: (dregs , dregs ) = SEARCH dregs (searchmod)\n");
835 $$ = DSP32ALU (13, 0, &$2, &$4, &$8, 0, 0, 0, $10.r0);
838 return yyerror ("Register mismatch");
840 | REG ASSIGN A_ONE_DOT_L PLUS A_ONE_DOT_H COMMA
841 REG ASSIGN A_ZERO_DOT_L PLUS A_ZERO_DOT_H
843 if (IS_DREG ($1) && IS_DREG ($7))
845 notethat ("dsp32alu: dregs = A1.l + A1.h, dregs = A0.l + A0.h \n");
846 $$ = DSP32ALU (12, 0, &$1, &$7, 0, 0, 0, 0, 1);
849 return yyerror ("Register mismatch");
853 | REG ASSIGN REG_A PLUS REG_A COMMA REG ASSIGN REG_A MINUS REG_A amod1
855 if (IS_DREG ($1) && IS_DREG ($7) && !REG_SAME ($3, $5)
856 && IS_A1 ($9) && !IS_A1 ($11))
858 notethat ("dsp32alu: dregs = A1 + A0 , dregs = A1 - A0 (amod1)\n");
859 $$ = DSP32ALU (17, 0, &$1, &$7, 0, 0, $12.s0, $12.x0, 0);
862 else if (IS_DREG ($1) && IS_DREG ($7) && !REG_SAME ($3, $5)
863 && !IS_A1 ($9) && IS_A1 ($11))
865 notethat ("dsp32alu: dregs = A0 + A1 , dregs = A0 - A1 (amod1)\n");
866 $$ = DSP32ALU (17, 0, &$1, &$7, 0, 0, $12.s0, $12.x0, 1);
869 return yyerror ("Register mismatch");
872 | REG ASSIGN REG plus_minus REG COMMA REG ASSIGN REG plus_minus REG amod1
875 return yyerror ("Operators must differ");
877 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5)
878 && REG_SAME ($3, $9) && REG_SAME ($5, $11))
880 notethat ("dsp32alu: dregs = dregs + dregs,"
881 "dregs = dregs - dregs (amod1)\n");
882 $$ = DSP32ALU (4, 0, &$1, &$7, &$3, &$5, $12.s0, $12.x0, 2);
885 return yyerror ("Register mismatch");
888 /* Bar Operations. */
890 | REG ASSIGN REG op_bar_op REG COMMA REG ASSIGN REG op_bar_op REG amod2
892 if (!REG_SAME ($3, $9) || !REG_SAME ($5, $11))
893 return yyerror ("Differing source registers");
895 if (!IS_DREG ($1) || !IS_DREG ($3) || !IS_DREG ($5) || !IS_DREG ($7))
896 return yyerror ("Dregs expected");
899 if ($4.r0 == 1 && $10.r0 == 2)
901 notethat ("dsp32alu: dregs = dregs .|. dregs , dregs = dregs .|. dregs (amod2)\n");
902 $$ = DSP32ALU (1, 1, &$1, &$7, &$3, &$5, $12.s0, $12.x0, $12.r0);
904 else if ($4.r0 == 0 && $10.r0 == 3)
906 notethat ("dsp32alu: dregs = dregs .|. dregs , dregs = dregs .|. dregs (amod2)\n");
907 $$ = DSP32ALU (1, 0, &$1, &$7, &$3, &$5, $12.s0, $12.x0, $12.r0);
910 return yyerror ("Bar operand mismatch");
913 | REG ASSIGN ABS REG vmod
917 if (IS_DREG ($1) && IS_DREG ($4))
921 notethat ("dsp32alu: dregs = ABS dregs (v)\n");
926 /* Vector version of ABS. */
927 notethat ("dsp32alu: dregs = ABS dregs\n");
930 $$ = DSP32ALU (op, 0, 0, &$1, &$4, 0, 0, 0, 2);
933 return yyerror ("Dregs expected");
937 notethat ("dsp32alu: Ax = ABS Ax\n");
938 $$ = DSP32ALU (16, IS_A1 ($1), 0, 0, 0, 0, 0, 0, IS_A1 ($3));
940 | A_ZERO_DOT_L ASSIGN HALF_REG
944 notethat ("dsp32alu: A0.l = reg_half\n");
945 $$ = DSP32ALU (9, IS_H ($3), 0, 0, &$3, 0, 0, 0, 0);
948 return yyerror ("A0.l = Rx.l expected");
950 | A_ONE_DOT_L ASSIGN HALF_REG
954 notethat ("dsp32alu: A1.l = reg_half\n");
955 $$ = DSP32ALU (9, IS_H ($3), 0, 0, &$3, 0, 0, 0, 2);
958 return yyerror ("A1.l = Rx.l expected");
961 | REG ASSIGN c_align LPAREN REG COMMA REG RPAREN
963 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
965 notethat ("dsp32shift: dregs = ALIGN8 (dregs , dregs )\n");
966 $$ = DSP32SHIFT (13, &$1, &$7, &$5, $3.r0, 0);
969 return yyerror ("Dregs expected");
972 | REG ASSIGN BYTEOP1P LPAREN REG COLON expr COMMA REG COLON expr RPAREN byteop_mod
975 return yyerror ("Dregs expected");
976 else if (!valid_dreg_pair (&$5, $7))
977 return yyerror ("Bad dreg pair");
978 else if (!valid_dreg_pair (&$9, $11))
979 return yyerror ("Bad dreg pair");
982 notethat ("dsp32alu: dregs = BYTEOP1P (dregs_pair , dregs_pair ) (T)\n");
983 $$ = DSP32ALU (20, 0, 0, &$1, &$5, &$9, $13.s0, 0, $13.r0);
986 | REG ASSIGN BYTEOP1P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
989 return yyerror ("Dregs expected");
990 else if (!valid_dreg_pair (&$5, $7))
991 return yyerror ("Bad dreg pair");
992 else if (!valid_dreg_pair (&$9, $11))
993 return yyerror ("Bad dreg pair");
996 notethat ("dsp32alu: dregs = BYTEOP1P (dregs_pair , dregs_pair ) (T)\n");
997 $$ = DSP32ALU (20, 0, 0, &$1, &$5, &$9, 0, 0, 0);
1001 | REG ASSIGN BYTEOP2P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
1005 return yyerror ("Dregs expected");
1006 else if (!valid_dreg_pair (&$5, $7))
1007 return yyerror ("Bad dreg pair");
1008 else if (!valid_dreg_pair (&$9, $11))
1009 return yyerror ("Bad dreg pair");
1012 notethat ("dsp32alu: dregs = BYTEOP2P (dregs_pair , dregs_pair ) (rnd_op)\n");
1013 $$ = DSP32ALU (22, $13.r0, 0, &$1, &$5, &$9, $13.s0, $13.x0, $13.aop);
1017 | REG ASSIGN BYTEOP2M LPAREN REG COLON expr COMMA REG COLON expr RPAREN
1021 return yyerror ("Dregs expected");
1022 else if (!valid_dreg_pair (&$5, $7))
1023 return yyerror ("Bad dreg pair");
1024 else if (!valid_dreg_pair (&$9, $11))
1025 return yyerror ("Bad dreg pair");
1028 notethat ("dsp32alu: dregs = BYTEOP2P (dregs_pair , dregs_pair ) (rnd_op)\n");
1029 $$ = DSP32ALU (22, $13.r0, 0, &$1, &$5, &$9, $13.s0, 0, $13.x0);
1033 | REG ASSIGN BYTEOP3P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
1037 return yyerror ("Dregs expected");
1038 else if (!valid_dreg_pair (&$5, $7))
1039 return yyerror ("Bad dreg pair");
1040 else if (!valid_dreg_pair (&$9, $11))
1041 return yyerror ("Bad dreg pair");
1044 notethat ("dsp32alu: dregs = BYTEOP3P (dregs_pair , dregs_pair ) (b3_op)\n");
1045 $$ = DSP32ALU (23, $13.x0, 0, &$1, &$5, &$9, $13.s0, 0, 0);
1049 | REG ASSIGN BYTEPACK LPAREN REG COMMA REG RPAREN
1051 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
1053 notethat ("dsp32alu: dregs = BYTEPACK (dregs , dregs )\n");
1054 $$ = DSP32ALU (24, 0, 0, &$1, &$5, &$7, 0, 0, 0);
1057 return yyerror ("Dregs expected");
1060 | HALF_REG ASSIGN HALF_REG ASSIGN SIGN LPAREN HALF_REG RPAREN STAR
1061 HALF_REG PLUS SIGN LPAREN HALF_REG RPAREN STAR HALF_REG
1063 if (IS_HCOMPL ($1, $3) && IS_HCOMPL ($7, $14) && IS_HCOMPL ($10, $17))
1065 notethat ("dsp32alu: dregs_hi = dregs_lo ="
1066 "SIGN (dregs_hi) * dregs_hi + "
1067 "SIGN (dregs_lo) * dregs_lo \n");
1069 $$ = DSP32ALU (12, 0, 0, &$1, &$7, &$10, 0, 0, 0);
1072 return yyerror ("Dregs expected");
1074 | REG ASSIGN REG plus_minus REG amod1
1076 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1080 /* No saturation flag specified, generate the 16 bit variant. */
1081 notethat ("COMP3op: dregs = dregs +- dregs\n");
1082 $$ = COMP3OP (&$1, &$3, &$5, $4.r0);
1086 /* Saturation flag specified, generate the 32 bit variant. */
1087 notethat ("dsp32alu: dregs = dregs +- dregs (amod1)\n");
1088 $$ = DSP32ALU (4, 0, 0, &$1, &$3, &$5, $6.s0, $6.x0, $4.r0);
1092 if (IS_PREG ($1) && IS_PREG ($3) && IS_PREG ($5) && $4.r0 == 0)
1094 notethat ("COMP3op: pregs = pregs + pregs\n");
1095 $$ = COMP3OP (&$1, &$3, &$5, 5);
1098 return yyerror ("Dregs expected");
1100 | REG ASSIGN min_max LPAREN REG COMMA REG RPAREN vmod
1104 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
1111 notethat ("dsp32alu: dregs = {MIN|MAX} (dregs, dregs)\n");
1112 $$ = DSP32ALU (op, 0, 0, &$1, &$5, &$7, 0, 0, $3.r0);
1115 return yyerror ("Dregs expected");
1118 | a_assign MINUS REG_A
1120 notethat ("dsp32alu: Ax = - Ax\n");
1121 $$ = DSP32ALU (14, IS_A1 ($1), 0, 0, 0, 0, 0, 0, IS_A1 ($3));
1123 | HALF_REG ASSIGN HALF_REG plus_minus HALF_REG amod1
1125 notethat ("dsp32alu: dregs_lo = dregs_lo +- dregs_lo (amod1)\n");
1126 $$ = DSP32ALU (2 | $4.r0, IS_H ($1), 0, &$1, &$3, &$5,
1127 $6.s0, $6.x0, HL2 ($3, $5));
1129 | a_assign a_assign expr
1131 if (EXPR_VALUE ($3) == 0 && !REG_SAME ($1, $2))
1133 notethat ("dsp32alu: A1 = A0 = 0\n");
1134 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, 0, 0, 2);
1137 return yyerror ("Bad value, 0 expected");
1141 | a_assign REG_A LPAREN S RPAREN
1143 if (REG_SAME ($1, $2))
1145 notethat ("dsp32alu: Ax = Ax (S)\n");
1146 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, 1, 0, IS_A1 ($1));
1149 return yyerror ("Registers must be equal");
1152 | HALF_REG ASSIGN REG LPAREN RND RPAREN
1156 notethat ("dsp32alu: dregs_half = dregs (RND)\n");
1157 $$ = DSP32ALU (12, IS_H ($1), 0, &$1, &$3, 0, 0, 0, 3);
1160 return yyerror ("Dregs expected");
1163 | HALF_REG ASSIGN REG plus_minus REG LPAREN RND12 RPAREN
1165 if (IS_DREG ($3) && IS_DREG ($5))
1167 notethat ("dsp32alu: dregs_half = dregs (+-) dregs (RND12)\n");
1168 $$ = DSP32ALU (5, IS_H ($1), 0, &$1, &$3, &$5, 0, 0, $4.r0);
1171 return yyerror ("Dregs expected");
1174 | HALF_REG ASSIGN REG plus_minus REG LPAREN RND20 RPAREN
1176 if (IS_DREG ($3) && IS_DREG ($5))
1178 notethat ("dsp32alu: dregs_half = dregs -+ dregs (RND20)\n");
1179 $$ = DSP32ALU (5, IS_H ($1), 0, &$1, &$3, &$5, 0, 1, $4.r0 | 2);
1182 return yyerror ("Dregs expected");
1187 if (!REG_SAME ($1, $2))
1189 notethat ("dsp32alu: An = Am\n");
1190 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, IS_A1 ($1), 0, 3);
1193 return yyerror ("Accu reg arguments must differ");
1200 notethat ("dsp32alu: An = dregs\n");
1201 $$ = DSP32ALU (9, 0, 0, 0, &$2, 0, 1, 0, IS_A1 ($1) << 1);
1204 return yyerror ("Dregs expected");
1207 | REG ASSIGN HALF_REG xpmod
1211 if ($1.regno == REG_A0x && IS_DREG ($3))
1213 notethat ("dsp32alu: A0.x = dregs_lo\n");
1214 $$ = DSP32ALU (9, 0, 0, 0, &$3, 0, 0, 0, 1);
1216 else if ($1.regno == REG_A1x && IS_DREG ($3))
1218 notethat ("dsp32alu: A1.x = dregs_lo\n");
1219 $$ = DSP32ALU (9, 0, 0, 0, &$3, 0, 0, 0, 3);
1221 else if (IS_DREG ($1) && IS_DREG ($3))
1223 notethat ("ALU2op: dregs = dregs_lo\n");
1224 $$ = ALU2OP (&$1, &$3, 10 | ($4.r0 ? 0: 1));
1227 return yyerror ("Register mismatch");
1230 return yyerror ("Low reg expected");
1233 | HALF_REG ASSIGN expr
1235 notethat ("LDIMMhalf: pregs_half = imm16\n");
1237 if (!IS_DREG ($1) && !IS_PREG ($1) && !IS_IREG ($1)
1238 && !IS_MREG ($1) && !IS_BREG ($1) && !IS_LREG ($1))
1239 return yyerror ("Wrong register for load immediate");
1241 if (!IS_IMM ($3, 16) && !IS_UIMM ($3, 16))
1242 return yyerror ("Constant out of range");
1244 $$ = LDIMMHALF_R (&$1, IS_H ($1), 0, 0, $3);
1249 notethat ("dsp32alu: An = 0\n");
1252 return yyerror ("0 expected");
1254 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, 0, 0, IS_A1 ($1));
1257 | REG ASSIGN expr xpmod1
1259 if (!IS_DREG ($1) && !IS_PREG ($1) && !IS_IREG ($1)
1260 && !IS_MREG ($1) && !IS_BREG ($1) && !IS_LREG ($1))
1261 return yyerror ("Wrong register for load immediate");
1265 /* 7 bit immediate value if possible.
1266 We will check for that constant value for efficiency
1267 If it goes to reloc, it will be 16 bit. */
1268 if (IS_CONST ($3) && IS_IMM ($3, 7) && IS_DREG ($1))
1270 notethat ("COMPI2opD: dregs = imm7 (x) \n");
1271 $$ = COMPI2OPD (&$1, imm7 ($3), 0);
1273 else if (IS_CONST ($3) && IS_IMM ($3, 7) && IS_PREG ($1))
1275 notethat ("COMPI2opP: pregs = imm7 (x)\n");
1276 $$ = COMPI2OPP (&$1, imm7 ($3), 0);
1280 if (IS_CONST ($3) && !IS_IMM ($3, 16))
1281 return yyerror ("Immediate value out of range");
1283 notethat ("LDIMMhalf: regs = luimm16 (x)\n");
1285 $$ = LDIMMHALF_R5 (&$1, 0, 1, 0, $3);
1290 /* (z) There is no 7 bit zero extended instruction.
1291 If the expr is a relocation, generate it. */
1293 if (IS_CONST ($3) && !IS_UIMM ($3, 16))
1294 return yyerror ("Immediate value out of range");
1296 notethat ("LDIMMhalf: regs = luimm16 (x)\n");
1298 $$ = LDIMMHALF_R5 (&$1, 0, 0, 1, $3);
1302 | HALF_REG ASSIGN REG
1305 return yyerror ("Low reg expected");
1307 if (IS_DREG ($1) && $3.regno == REG_A0x)
1309 notethat ("dsp32alu: dregs_lo = A0.x\n");
1310 $$ = DSP32ALU (10, 0, 0, &$1, 0, 0, 0, 0, 0);
1312 else if (IS_DREG ($1) && $3.regno == REG_A1x)
1314 notethat ("dsp32alu: dregs_lo = A1.x\n");
1315 $$ = DSP32ALU (10, 0, 0, &$1, 0, 0, 0, 0, 1);
1318 return yyerror ("Register mismatch");
1321 | REG ASSIGN REG op_bar_op REG amod0
1323 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1325 notethat ("dsp32alu: dregs = dregs .|. dregs (amod0)\n");
1326 $$ = DSP32ALU (0, 0, 0, &$1, &$3, &$5, $6.s0, $6.x0, $4.r0);
1329 return yyerror ("Register mismatch");
1332 | REG ASSIGN BYTE_DREG xpmod
1334 if (IS_DREG ($1) && IS_DREG ($3))
1336 notethat ("ALU2op: dregs = dregs_byte\n");
1337 $$ = ALU2OP (&$1, &$3, 12 | ($4.r0 ? 0: 1));
1340 return yyerror ("Register mismatch");
1343 | a_assign ABS REG_A COMMA a_assign ABS REG_A
1345 if (REG_SAME ($1, $3) && REG_SAME ($5, $7) && !REG_SAME ($1, $5))
1347 notethat ("dsp32alu: A1 = ABS A1 , A0 = ABS A0\n");
1348 $$ = DSP32ALU (16, 0, 0, 0, 0, 0, 0, 0, 3);
1351 return yyerror ("Register mismatch");
1354 | a_assign MINUS REG_A COMMA a_assign MINUS REG_A
1356 if (REG_SAME ($1, $3) && REG_SAME ($5, $7) && !REG_SAME ($1, $5))
1358 notethat ("dsp32alu: A1 = - A1 , A0 = - A0\n");
1359 $$ = DSP32ALU (14, 0, 0, 0, 0, 0, 0, 0, 3);
1362 return yyerror ("Register mismatch");
1365 | a_minusassign REG_A w32_or_nothing
1367 if (!IS_A1 ($1) && IS_A1 ($2))
1369 notethat ("dsp32alu: A0 -= A1\n");
1370 $$ = DSP32ALU (11, 0, 0, 0, 0, 0, $3.r0, 0, 3);
1373 return yyerror ("Register mismatch");
1376 | REG _MINUS_ASSIGN expr
1378 if (IS_IREG ($1) && EXPR_VALUE ($3) == 4)
1380 notethat ("dagMODik: iregs -= 4\n");
1381 $$ = DAGMODIK (&$1, 3);
1383 else if (IS_IREG ($1) && EXPR_VALUE ($3) == 2)
1385 notethat ("dagMODik: iregs -= 2\n");
1386 $$ = DAGMODIK (&$1, 1);
1389 return yyerror ("Register or value mismatch");
1392 | REG _PLUS_ASSIGN REG LPAREN BREV RPAREN
1394 if (IS_IREG ($1) && IS_MREG ($3))
1396 notethat ("dagMODim: iregs += mregs (opt_brev)\n");
1398 $$ = DAGMODIM (&$1, &$3, 0, 1);
1400 else if (IS_PREG ($1) && IS_PREG ($3))
1402 notethat ("PTR2op: pregs += pregs (BREV )\n");
1403 $$ = PTR2OP (&$1, &$3, 5);
1406 return yyerror ("Register mismatch");
1409 | REG _MINUS_ASSIGN REG
1411 if (IS_IREG ($1) && IS_MREG ($3))
1413 notethat ("dagMODim: iregs -= mregs\n");
1414 $$ = DAGMODIM (&$1, &$3, 1, 0);
1416 else if (IS_PREG ($1) && IS_PREG ($3))
1418 notethat ("PTR2op: pregs -= pregs\n");
1419 $$ = PTR2OP (&$1, &$3, 0);
1422 return yyerror ("Register mismatch");
1425 | REG_A _PLUS_ASSIGN REG_A w32_or_nothing
1427 if (!IS_A1 ($1) && IS_A1 ($3))
1429 notethat ("dsp32alu: A0 += A1 (W32)\n");
1430 $$ = DSP32ALU (11, 0, 0, 0, 0, 0, $4.r0, 0, 2);
1433 return yyerror ("Register mismatch");
1436 | REG _PLUS_ASSIGN REG
1438 if (IS_IREG ($1) && IS_MREG ($3))
1440 notethat ("dagMODim: iregs += mregs\n");
1441 $$ = DAGMODIM (&$1, &$3, 0, 0);
1444 return yyerror ("iregs += mregs expected");
1447 | REG _PLUS_ASSIGN expr
1451 if (EXPR_VALUE ($3) == 4)
1453 notethat ("dagMODik: iregs += 4\n");
1454 $$ = DAGMODIK (&$1, 2);
1456 else if (EXPR_VALUE ($3) == 2)
1458 notethat ("dagMODik: iregs += 2\n");
1459 $$ = DAGMODIK (&$1, 0);
1462 return yyerror ("iregs += [ 2 | 4 ");
1464 else if (IS_PREG ($1) && IS_IMM ($3, 7))
1466 notethat ("COMPI2opP: pregs += imm7\n");
1467 $$ = COMPI2OPP (&$1, imm7 ($3), 1);
1469 else if (IS_DREG ($1) && IS_IMM ($3, 7))
1471 notethat ("COMPI2opD: dregs += imm7\n");
1472 $$ = COMPI2OPD (&$1, imm7 ($3), 1);
1474 else if ((IS_DREG ($1) || IS_PREG ($1)) && IS_CONST ($3))
1475 return yyerror ("Immediate value out of range");
1477 return yyerror ("Register mismatch");
1480 | REG _STAR_ASSIGN REG
1482 if (IS_DREG ($1) && IS_DREG ($3))
1484 notethat ("ALU2op: dregs *= dregs\n");
1485 $$ = ALU2OP (&$1, &$3, 3);
1488 return yyerror ("Register mismatch");
1491 | SAA LPAREN REG COLON expr COMMA REG COLON expr RPAREN aligndir
1493 if (!valid_dreg_pair (&$3, $5))
1494 return yyerror ("Bad dreg pair");
1495 else if (!valid_dreg_pair (&$7, $9))
1496 return yyerror ("Bad dreg pair");
1499 notethat ("dsp32alu: SAA (dregs_pair , dregs_pair ) (aligndir)\n");
1500 $$ = DSP32ALU (18, 0, 0, 0, &$3, &$7, $11.r0, 0, 0);
1504 | a_assign REG_A LPAREN S RPAREN COMMA a_assign REG_A LPAREN S RPAREN
1506 if (REG_SAME ($1, $2) && REG_SAME ($7, $8) && !REG_SAME ($1, $7))
1508 notethat ("dsp32alu: A1 = A1 (S) , A0 = A0 (S)\n");
1509 $$ = DSP32ALU (8, 0, 0, 0, 0, 0, 1, 0, 2);
1512 return yyerror ("Register mismatch");
1515 | REG ASSIGN LPAREN REG PLUS REG RPAREN LESS_LESS expr
1517 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG ($6)
1518 && REG_SAME ($1, $4))
1520 if (EXPR_VALUE ($9) == 1)
1522 notethat ("ALU2op: dregs = (dregs + dregs) << 1\n");
1523 $$ = ALU2OP (&$1, &$6, 4);
1525 else if (EXPR_VALUE ($9) == 2)
1527 notethat ("ALU2op: dregs = (dregs + dregs) << 2\n");
1528 $$ = ALU2OP (&$1, &$6, 5);
1531 return yyerror ("Bad shift value");
1533 else if (IS_PREG ($1) && IS_PREG ($4) && IS_PREG ($6)
1534 && REG_SAME ($1, $4))
1536 if (EXPR_VALUE ($9) == 1)
1538 notethat ("PTR2op: pregs = (pregs + pregs) << 1\n");
1539 $$ = PTR2OP (&$1, &$6, 6);
1541 else if (EXPR_VALUE ($9) == 2)
1543 notethat ("PTR2op: pregs = (pregs + pregs) << 2\n");
1544 $$ = PTR2OP (&$1, &$6, 7);
1547 return yyerror ("Bad shift value");
1550 return yyerror ("Register mismatch");
1554 | REG ASSIGN REG BAR REG
1556 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1558 notethat ("COMP3op: dregs = dregs | dregs\n");
1559 $$ = COMP3OP (&$1, &$3, &$5, 3);
1562 return yyerror ("Dregs expected");
1564 | REG ASSIGN REG CARET REG
1566 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1568 notethat ("COMP3op: dregs = dregs ^ dregs\n");
1569 $$ = COMP3OP (&$1, &$3, &$5, 4);
1572 return yyerror ("Dregs expected");
1574 | REG ASSIGN REG PLUS LPAREN REG LESS_LESS expr RPAREN
1576 if (IS_PREG ($1) && IS_PREG ($3) && IS_PREG ($6))
1578 if (EXPR_VALUE ($8) == 1)
1580 notethat ("COMP3op: pregs = pregs + (pregs << 1)\n");
1581 $$ = COMP3OP (&$1, &$3, &$6, 6);
1583 else if (EXPR_VALUE ($8) == 2)
1585 notethat ("COMP3op: pregs = pregs + (pregs << 2)\n");
1586 $$ = COMP3OP (&$1, &$3, &$6, 7);
1589 return yyerror ("Bad shift value");
1592 return yyerror ("Dregs expected");
1594 | CCREG ASSIGN REG_A _ASSIGN_ASSIGN REG_A
1596 if ($3.regno == REG_A0 && $5.regno == REG_A1)
1598 notethat ("CCflag: CC = A0 == A1\n");
1599 $$ = CCFLAG (0, 0, 5, 0, 0);
1602 return yyerror ("AREGs are in bad order or same");
1604 | CCREG ASSIGN REG_A LESS_THAN REG_A
1606 if ($3.regno == REG_A0 && $5.regno == REG_A1)
1608 notethat ("CCflag: CC = A0 < A1\n");
1609 $$ = CCFLAG (0, 0, 6, 0, 0);
1612 return yyerror ("AREGs are in bad order or same");
1614 | CCREG ASSIGN REG LESS_THAN REG iu_or_nothing
1616 if (REG_CLASS($3) == REG_CLASS($5))
1618 notethat ("CCflag: CC = dpregs < dpregs\n");
1619 $$ = CCFLAG (&$3, $5.regno & CODE_MASK, $6.r0, 0, IS_PREG ($3) ? 1 : 0);
1622 return yyerror ("Compare only of same register class");
1624 | CCREG ASSIGN REG LESS_THAN expr iu_or_nothing
1626 if (($6.r0 == 1 && IS_IMM ($5, 3))
1627 || ($6.r0 == 3 && IS_UIMM ($5, 3)))
1629 notethat ("CCflag: CC = dpregs < (u)imm3\n");
1630 $$ = CCFLAG (&$3, imm3 ($5), $6.r0, 1, IS_PREG ($3) ? 1 : 0);
1633 return yyerror ("Bad constant value");
1635 | CCREG ASSIGN REG _ASSIGN_ASSIGN REG
1637 if (REG_CLASS($3) == REG_CLASS($5))
1639 notethat ("CCflag: CC = dpregs == dpregs\n");
1640 $$ = CCFLAG (&$3, $5.regno & CODE_MASK, 0, 0, IS_PREG ($3) ? 1 : 0);
1643 return yyerror ("Compare only of same register class");
1645 | CCREG ASSIGN REG _ASSIGN_ASSIGN expr
1649 notethat ("CCflag: CC = dpregs == imm3\n");
1650 $$ = CCFLAG (&$3, imm3 ($5), 0, 1, IS_PREG ($3) ? 1 : 0);
1653 return yyerror ("Bad constant range");
1655 | CCREG ASSIGN REG_A _LESS_THAN_ASSIGN REG_A
1657 if ($3.regno == REG_A0 && $5.regno == REG_A1)
1659 notethat ("CCflag: CC = A0 <= A1\n");
1660 $$ = CCFLAG (0, 0, 7, 0, 0);
1663 return yyerror ("AREGs are in bad order or same");
1665 | CCREG ASSIGN REG _LESS_THAN_ASSIGN REG iu_or_nothing
1667 if (REG_CLASS($3) == REG_CLASS($5))
1669 notethat ("CCflag: CC = pregs <= pregs (..)\n");
1670 $$ = CCFLAG (&$3, $5.regno & CODE_MASK,
1671 1 + $6.r0, 0, IS_PREG ($3) ? 1 : 0);
1674 return yyerror ("Compare only of same register class");
1676 | CCREG ASSIGN REG _LESS_THAN_ASSIGN expr iu_or_nothing
1678 if (($6.r0 == 1 && IS_IMM ($5, 3))
1679 || ($6.r0 == 3 && IS_UIMM ($5, 3)))
1683 notethat ("CCflag: CC = dregs <= (u)imm3\n");
1685 $$ = CCFLAG (&$3, imm3 ($5), 1 + $6.r0, 1, 0);
1687 else if (IS_PREG ($3))
1689 notethat ("CCflag: CC = pregs <= (u)imm3\n");
1691 $$ = CCFLAG (&$3, imm3 ($5), 1 + $6.r0, 1, 1);
1694 return yyerror ("Dreg or Preg expected");
1697 return yyerror ("Bad constant value");
1700 | REG ASSIGN REG AMPERSAND REG
1702 if (IS_DREG ($1) && IS_DREG ($3) && IS_DREG ($5))
1704 notethat ("COMP3op: dregs = dregs & dregs\n");
1705 $$ = COMP3OP (&$1, &$3, &$5, 2);
1708 return yyerror ("Dregs expected");
1713 notethat ("CC2stat operation\n");
1714 $$ = bfin_gen_cc2stat ($1.r0, $1.x0, $1.s0);
1719 if (IS_ALLREG ($1) && IS_ALLREG ($3))
1721 notethat ("REGMV: allregs = allregs\n");
1722 $$ = bfin_gen_regmv (&$3, &$1);
1725 return yyerror ("Register mismatch");
1732 notethat ("CC2dreg: CC = dregs\n");
1733 $$ = bfin_gen_cc2dreg (1, &$3);
1736 return yyerror ("Register mismatch");
1743 notethat ("CC2dreg: dregs = CC\n");
1744 $$ = bfin_gen_cc2dreg (0, &$1);
1747 return yyerror ("Register mismatch");
1750 | CCREG _ASSIGN_BANG CCREG
1752 notethat ("CC2dreg: CC =! CC\n");
1753 $$ = bfin_gen_cc2dreg (3, 0);
1758 | HALF_REG ASSIGN multiply_halfregs opt_mode
1760 notethat ("dsp32mult: dregs_half = multiply_halfregs (opt_mode)\n");
1762 if (!IS_H ($1) && $4.MM)
1763 return yyerror ("(M) not allowed with MAC0");
1765 if ($4.mod != 0 && $4.mod != M_FU && $4.mod != M_IS
1766 && $4.mod != M_IU && $4.mod != M_T && $4.mod != M_TFU
1767 && $4.mod != M_S2RND && $4.mod != M_ISS2 && $4.mod != M_IH)
1768 return yyerror ("bad option.");
1772 $$ = DSP32MULT (0, $4.MM, $4.mod, 1, 0,
1773 IS_H ($3.s0), IS_H ($3.s1), 0, 0,
1774 &$1, 0, &$3.s0, &$3.s1, 0);
1778 $$ = DSP32MULT (0, 0, $4.mod, 0, 0,
1779 0, 0, IS_H ($3.s0), IS_H ($3.s1),
1780 &$1, 0, &$3.s0, &$3.s1, 1);
1784 | REG ASSIGN multiply_halfregs opt_mode
1786 /* Odd registers can use (M). */
1788 return yyerror ("Dreg expected");
1790 if (IS_EVEN ($1) && $4.MM)
1791 return yyerror ("(M) not allowed with MAC0");
1793 if ($4.mod != 0 && $4.mod != M_FU && $4.mod != M_IS
1794 && $4.mod != M_S2RND && $4.mod != M_ISS2)
1795 return yyerror ("bad option");
1799 notethat ("dsp32mult: dregs = multiply_halfregs (opt_mode)\n");
1801 $$ = DSP32MULT (0, $4.MM, $4.mod, 1, 1,
1802 IS_H ($3.s0), IS_H ($3.s1), 0, 0,
1803 &$1, 0, &$3.s0, &$3.s1, 0);
1807 notethat ("dsp32mult: dregs = multiply_halfregs opt_mode\n");
1808 $$ = DSP32MULT (0, 0, $4.mod, 0, 1,
1809 0, 0, IS_H ($3.s0), IS_H ($3.s1),
1810 &$1, 0, &$3.s0, &$3.s1, 1);
1814 | HALF_REG ASSIGN multiply_halfregs opt_mode COMMA
1815 HALF_REG ASSIGN multiply_halfregs opt_mode
1817 if (!IS_DREG ($1) || !IS_DREG ($6))
1818 return yyerror ("Dregs expected");
1820 if (!IS_HCOMPL($1, $6))
1821 return yyerror ("Dest registers mismatch");
1823 if (check_multiply_halfregs (&$3, &$8) < 0)
1826 if ((!IS_H ($1) && $4.MM)
1827 || (!IS_H ($6) && $9.MM))
1828 return yyerror ("(M) not allowed with MAC0");
1830 notethat ("dsp32mult: dregs_hi = multiply_halfregs mxd_mod, "
1831 "dregs_lo = multiply_halfregs opt_mode\n");
1834 $$ = DSP32MULT (0, $4.MM, $9.mod, 1, 0,
1835 IS_H ($3.s0), IS_H ($3.s1), IS_H ($8.s0), IS_H ($8.s1),
1836 &$1, 0, &$3.s0, &$3.s1, 1);
1838 $$ = DSP32MULT (0, $9.MM, $9.mod, 1, 0,
1839 IS_H ($8.s0), IS_H ($8.s1), IS_H ($3.s0), IS_H ($3.s1),
1840 &$1, 0, &$3.s0, &$3.s1, 1);
1843 | REG ASSIGN multiply_halfregs opt_mode COMMA REG ASSIGN multiply_halfregs opt_mode
1845 if (!IS_DREG ($1) || !IS_DREG ($6))
1846 return yyerror ("Dregs expected");
1848 if ((IS_EVEN ($1) && $6.regno - $1.regno != 1)
1849 || (IS_EVEN ($6) && $1.regno - $6.regno != 1))
1850 return yyerror ("Dest registers mismatch");
1852 if (check_multiply_halfregs (&$3, &$8) < 0)
1855 if ((IS_EVEN ($1) && $4.MM)
1856 || (IS_EVEN ($6) && $9.MM))
1857 return yyerror ("(M) not allowed with MAC0");
1859 notethat ("dsp32mult: dregs = multiply_halfregs mxd_mod, "
1860 "dregs = multiply_halfregs opt_mode\n");
1863 $$ = DSP32MULT (0, $9.MM, $9.mod, 1, 1,
1864 IS_H ($8.s0), IS_H ($8.s1), IS_H ($3.s0), IS_H ($3.s1),
1865 &$1, 0, &$3.s0, &$3.s1, 1);
1867 $$ = DSP32MULT (0, $4.MM, $9.mod, 1, 1,
1868 IS_H ($3.s0), IS_H ($3.s1), IS_H ($8.s0), IS_H ($8.s1),
1869 &$1, 0, &$3.s0, &$3.s1, 1);
1874 | a_assign ASHIFT REG_A BY HALF_REG
1876 if (!REG_SAME ($1, $3))
1877 return yyerror ("Aregs must be same");
1879 if (IS_DREG ($5) && !IS_H ($5))
1881 notethat ("dsp32shift: A0 = ASHIFT A0 BY dregs_lo\n");
1882 $$ = DSP32SHIFT (3, 0, &$5, 0, 0, IS_A1 ($1));
1885 return yyerror ("Dregs expected");
1888 | HALF_REG ASSIGN ASHIFT HALF_REG BY HALF_REG smod
1890 if (IS_DREG ($6) && !IS_H ($6))
1892 notethat ("dsp32shift: dregs_half = ASHIFT dregs_half BY dregs_lo\n");
1893 $$ = DSP32SHIFT (0, &$1, &$6, &$4, $7.s0, HL2 ($1, $4));
1896 return yyerror ("Dregs expected");
1899 | a_assign REG_A LESS_LESS expr
1901 if (!REG_SAME ($1, $2))
1902 return yyerror ("Aregs must be same");
1904 if (IS_UIMM ($4, 5))
1906 notethat ("dsp32shiftimm: A0 = A0 << uimm5\n");
1907 $$ = DSP32SHIFTIMM (3, 0, imm5 ($4), 0, 0, IS_A1 ($1));
1910 return yyerror ("Bad shift value");
1913 | REG ASSIGN REG LESS_LESS expr vsmod
1915 if (IS_DREG ($1) && IS_DREG ($3) && IS_UIMM ($5, 5))
1920 notethat ("dsp32shiftimm: dregs = dregs << expr (V, .)\n");
1921 $$ = DSP32SHIFTIMM (1, &$1, imm4 ($5), &$3, $6.s0 ? 1 : 2, 0);
1925 notethat ("dsp32shiftimm: dregs = dregs << uimm5 (.)\n");
1926 $$ = DSP32SHIFTIMM (2, &$1, imm6 ($5), &$3, $6.s0 ? 1 : 2, 0);
1929 else if ($6.s0 == 0 && IS_PREG ($1) && IS_PREG ($3))
1931 if (EXPR_VALUE ($5) == 2)
1933 notethat ("PTR2op: pregs = pregs << 2\n");
1934 $$ = PTR2OP (&$1, &$3, 1);
1936 else if (EXPR_VALUE ($5) == 1)
1938 notethat ("COMP3op: pregs = pregs << 1\n");
1939 $$ = COMP3OP (&$1, &$3, &$3, 5);
1942 return yyerror ("Bad shift value");
1945 return yyerror ("Bad shift value or register");
1947 | HALF_REG ASSIGN HALF_REG LESS_LESS expr smod
1949 if (IS_UIMM ($5, 4))
1953 notethat ("dsp32shiftimm: dregs_half = dregs_half << uimm4 (S)\n");
1954 $$ = DSP32SHIFTIMM (0x0, &$1, imm5 ($5), &$3, $6.s0, HL2 ($1, $3));
1958 notethat ("dsp32shiftimm: dregs_half = dregs_half << uimm4\n");
1959 $$ = DSP32SHIFTIMM (0x0, &$1, imm5 ($5), &$3, 2, HL2 ($1, $3));
1963 return yyerror ("Bad shift value");
1965 | REG ASSIGN ASHIFT REG BY HALF_REG vsmod
1969 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG ($6) && !IS_H ($6))
1974 notethat ("dsp32shift: dregs = ASHIFT dregs BY "
1975 "dregs_lo (V, .)\n");
1981 notethat ("dsp32shift: dregs = ASHIFT dregs BY dregs_lo (.)\n");
1983 $$ = DSP32SHIFT (op, &$1, &$6, &$4, $7.s0, 0);
1986 return yyerror ("Dregs expected");
1990 | HALF_REG ASSIGN EXPADJ LPAREN REG COMMA HALF_REG RPAREN vmod
1992 if (IS_DREG_L ($1) && IS_DREG_L ($5) && IS_DREG_L ($7))
1994 notethat ("dsp32shift: dregs_lo = EXPADJ (dregs , dregs_lo )\n");
1995 $$ = DSP32SHIFT (7, &$1, &$7, &$5, $9.r0, 0);
1998 return yyerror ("Bad shift value or register");
2002 | HALF_REG ASSIGN EXPADJ LPAREN HALF_REG COMMA HALF_REG RPAREN
2004 if (IS_DREG_L ($1) && IS_DREG_L ($5) && IS_DREG_L ($7))
2006 notethat ("dsp32shift: dregs_lo = EXPADJ (dregs_lo, dregs_lo)\n");
2007 $$ = DSP32SHIFT (7, &$1, &$7, &$5, 2, 0);
2009 else if (IS_DREG_L ($1) && IS_DREG_H ($5) && IS_DREG_L ($7))
2011 notethat ("dsp32shift: dregs_lo = EXPADJ (dregs_hi, dregs_lo)\n");
2012 $$ = DSP32SHIFT (7, &$1, &$7, &$5, 3, 0);
2015 return yyerror ("Bad shift value or register");
2020 | REG ASSIGN DEPOSIT LPAREN REG COMMA REG RPAREN
2022 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
2024 notethat ("dsp32shift: dregs = DEPOSIT (dregs , dregs )\n");
2025 $$ = DSP32SHIFT (10, &$1, &$7, &$5, 2, 0);
2028 return yyerror ("Register mismatch");
2031 | REG ASSIGN DEPOSIT LPAREN REG COMMA REG RPAREN LPAREN X RPAREN
2033 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
2035 notethat ("dsp32shift: dregs = DEPOSIT (dregs , dregs ) (X)\n");
2036 $$ = DSP32SHIFT (10, &$1, &$7, &$5, 3, 0);
2039 return yyerror ("Register mismatch");
2042 | REG ASSIGN EXTRACT LPAREN REG COMMA HALF_REG RPAREN xpmod
2044 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG_L ($7))
2046 notethat ("dsp32shift: dregs = EXTRACT (dregs, dregs_lo ) (.)\n");
2047 $$ = DSP32SHIFT (10, &$1, &$7, &$5, $9.r0, 0);
2050 return yyerror ("Register mismatch");
2053 | a_assign REG_A _GREATER_GREATER_GREATER expr
2055 if (!REG_SAME ($1, $2))
2056 return yyerror ("Aregs must be same");
2058 if (IS_UIMM ($4, 5))
2060 notethat ("dsp32shiftimm: Ax = Ax >>> uimm5\n");
2061 $$ = DSP32SHIFTIMM (3, 0, -imm6 ($4), 0, 0, IS_A1 ($1));
2064 return yyerror ("Shift value range error");
2066 | a_assign LSHIFT REG_A BY HALF_REG
2068 if (REG_SAME ($1, $3) && IS_DREG_L ($5))
2070 notethat ("dsp32shift: Ax = LSHIFT Ax BY dregs_lo\n");
2071 $$ = DSP32SHIFT (3, 0, &$5, 0, 1, IS_A1 ($1));
2074 return yyerror ("Register mismatch");
2077 | HALF_REG ASSIGN LSHIFT HALF_REG BY HALF_REG
2079 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG_L ($6))
2081 notethat ("dsp32shift: dregs_lo = LSHIFT dregs_hi BY dregs_lo\n");
2082 $$ = DSP32SHIFT (0, &$1, &$6, &$4, 2, HL2 ($1, $4));
2085 return yyerror ("Register mismatch");
2088 | REG ASSIGN LSHIFT REG BY HALF_REG vmod
2090 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG_L ($6))
2092 notethat ("dsp32shift: dregs = LSHIFT dregs BY dregs_lo (V )\n");
2093 $$ = DSP32SHIFT ($7.r0 ? 1: 2, &$1, &$6, &$4, 2, 0);
2096 return yyerror ("Register mismatch");
2099 | REG ASSIGN SHIFT REG BY HALF_REG
2101 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG_L ($6))
2103 notethat ("dsp32shift: dregs = SHIFT dregs BY dregs_lo\n");
2104 $$ = DSP32SHIFT (2, &$1, &$6, &$4, 2, 0);
2107 return yyerror ("Register mismatch");
2110 | a_assign REG_A GREATER_GREATER expr
2112 if (REG_SAME ($1, $2) && IS_IMM ($4, 6) >= 0)
2114 notethat ("dsp32shiftimm: Ax = Ax >> imm6\n");
2115 $$ = DSP32SHIFTIMM (3, 0, -imm6 ($4), 0, 1, IS_A1 ($1));
2118 return yyerror ("Accu register expected");
2121 | REG ASSIGN REG GREATER_GREATER expr vmod
2125 if (IS_DREG ($1) && IS_DREG ($3) && IS_UIMM ($5, 5))
2127 notethat ("dsp32shiftimm: dregs = dregs >> uimm5 (V)\n");
2128 $$ = DSP32SHIFTIMM (1, &$1, -uimm5 ($5), &$3, 2, 0);
2131 return yyerror ("Register mismatch");
2135 if (IS_DREG ($1) && IS_DREG ($3) && IS_UIMM ($5, 5))
2137 notethat ("dsp32shiftimm: dregs = dregs >> uimm5\n");
2138 $$ = DSP32SHIFTIMM (2, &$1, -imm6 ($5), &$3, 2, 0);
2140 else if (IS_PREG ($1) && IS_PREG ($3) && EXPR_VALUE ($5) == 2)
2142 notethat ("PTR2op: pregs = pregs >> 2\n");
2143 $$ = PTR2OP (&$1, &$3, 3);
2145 else if (IS_PREG ($1) && IS_PREG ($3) && EXPR_VALUE ($5) == 1)
2147 notethat ("PTR2op: pregs = pregs >> 1\n");
2148 $$ = PTR2OP (&$1, &$3, 4);
2151 return yyerror ("Register mismatch");
2154 | HALF_REG ASSIGN HALF_REG GREATER_GREATER expr
2156 if (IS_UIMM ($5, 5))
2158 notethat ("dsp32shiftimm: dregs_half = dregs_half >> uimm5\n");
2159 $$ = DSP32SHIFTIMM (0, &$1, -uimm5 ($5), &$3, 2, HL2 ($1, $3));
2162 return yyerror ("Register mismatch");
2164 | HALF_REG ASSIGN HALF_REG _GREATER_GREATER_GREATER expr smod
2166 if (IS_UIMM ($5, 5))
2168 notethat ("dsp32shiftimm: dregs_half = dregs_half >>> uimm5\n");
2169 $$ = DSP32SHIFTIMM (0, &$1, -uimm5 ($5), &$3,
2170 $6.s0, HL2 ($1, $3));
2173 return yyerror ("Register or modifier mismatch");
2177 | REG ASSIGN REG _GREATER_GREATER_GREATER expr vsmod
2179 if (IS_DREG ($1) && IS_DREG ($3) && IS_UIMM ($5, 5))
2184 notethat ("dsp32shiftimm: dregs = dregs >>> uimm5 (V, .)\n");
2185 $$ = DSP32SHIFTIMM (1, &$1, -uimm5 ($5), &$3, $6.s0, 0);
2189 notethat ("dsp32shiftimm: dregs = dregs >>> uimm5 (.)\n");
2190 $$ = DSP32SHIFTIMM (2, &$1, -uimm5 ($5), &$3, $6.s0, 0);
2194 return yyerror ("Register mismatch");
2197 | HALF_REG ASSIGN ONES REG
2199 if (IS_DREG_L ($1) && IS_DREG ($4))
2201 notethat ("dsp32shift: dregs_lo = ONES dregs\n");
2202 $$ = DSP32SHIFT (6, &$1, 0, &$4, 3, 0);
2205 return yyerror ("Register mismatch");
2208 | REG ASSIGN PACK LPAREN HALF_REG COMMA HALF_REG RPAREN
2210 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
2212 notethat ("dsp32shift: dregs = PACK (dregs_hi , dregs_hi )\n");
2213 $$ = DSP32SHIFT (4, &$1, &$7, &$5, HL2 ($5, $7), 0);
2216 return yyerror ("Register mismatch");
2219 | HALF_REG ASSIGN CCREG ASSIGN BXORSHIFT LPAREN REG_A COMMA REG RPAREN
2222 && $7.regno == REG_A0
2223 && IS_DREG ($9) && !IS_H ($1) && !IS_A1 ($7))
2225 notethat ("dsp32shift: dregs_lo = CC = BXORSHIFT (A0 , dregs )\n");
2226 $$ = DSP32SHIFT (11, &$1, &$9, 0, 0, 0);
2229 return yyerror ("Register mismatch");
2232 | HALF_REG ASSIGN CCREG ASSIGN BXOR LPAREN REG_A COMMA REG RPAREN
2235 && $7.regno == REG_A0
2236 && IS_DREG ($9) && !IS_H ($1) && !IS_A1 ($7))
2238 notethat ("dsp32shift: dregs_lo = CC = BXOR (A0 , dregs)\n");
2239 $$ = DSP32SHIFT (11, &$1, &$9, 0, 1, 0);
2242 return yyerror ("Register mismatch");
2245 | HALF_REG ASSIGN CCREG ASSIGN BXOR LPAREN REG_A COMMA REG_A COMMA CCREG RPAREN
2247 if (IS_DREG ($1) && !IS_H ($1) && !REG_SAME ($7, $9))
2249 notethat ("dsp32shift: dregs_lo = CC = BXOR (A0 , A1 , CC)\n");
2250 $$ = DSP32SHIFT (12, &$1, 0, 0, 1, 0);
2253 return yyerror ("Register mismatch");
2256 | a_assign ROT REG_A BY HALF_REG
2258 if (REG_SAME ($1, $3) && IS_DREG_L ($5))
2260 notethat ("dsp32shift: Ax = ROT Ax BY dregs_lo\n");
2261 $$ = DSP32SHIFT (3, 0, &$5, 0, 2, IS_A1 ($1));
2264 return yyerror ("Register mismatch");
2267 | REG ASSIGN ROT REG BY HALF_REG
2269 if (IS_DREG ($1) && IS_DREG ($4) && IS_DREG_L ($6))
2271 notethat ("dsp32shift: dregs = ROT dregs BY dregs_lo\n");
2272 $$ = DSP32SHIFT (2, &$1, &$6, &$4, 3, 0);
2275 return yyerror ("Register mismatch");
2278 | a_assign ROT REG_A BY expr
2282 notethat ("dsp32shiftimm: An = ROT An BY imm6\n");
2283 $$ = DSP32SHIFTIMM (3, 0, imm6 ($5), 0, 2, IS_A1 ($1));
2286 return yyerror ("Register mismatch");
2289 | REG ASSIGN ROT REG BY expr
2291 if (IS_DREG ($1) && IS_DREG ($4) && IS_IMM ($6, 6))
2293 $$ = DSP32SHIFTIMM (2, &$1, imm6 ($6), &$4, 3, IS_A1 ($1));
2296 return yyerror ("Register mismatch");
2299 | HALF_REG ASSIGN SIGNBITS REG_A
2303 notethat ("dsp32shift: dregs_lo = SIGNBITS An\n");
2304 $$ = DSP32SHIFT (6, &$1, 0, 0, IS_A1 ($4), 0);
2307 return yyerror ("Register mismatch");
2310 | HALF_REG ASSIGN SIGNBITS REG
2312 if (IS_DREG_L ($1) && IS_DREG ($4))
2314 notethat ("dsp32shift: dregs_lo = SIGNBITS dregs\n");
2315 $$ = DSP32SHIFT (5, &$1, 0, &$4, 0, 0);
2318 return yyerror ("Register mismatch");
2321 | HALF_REG ASSIGN SIGNBITS HALF_REG
2325 notethat ("dsp32shift: dregs_lo = SIGNBITS dregs_lo\n");
2326 $$ = DSP32SHIFT (5, &$1, 0, &$4, 1 + IS_H ($4), 0);
2329 return yyerror ("Register mismatch");
2332 /* The ASR bit is just inverted here. */
2333 | HALF_REG ASSIGN VIT_MAX LPAREN REG RPAREN asr_asl
2335 if (IS_DREG_L ($1) && IS_DREG ($5))
2337 notethat ("dsp32shift: dregs_lo = VIT_MAX (dregs) (..)\n");
2338 $$ = DSP32SHIFT (9, &$1, 0, &$5, ($7.r0 ? 0 : 1), 0);
2341 return yyerror ("Register mismatch");
2344 | REG ASSIGN VIT_MAX LPAREN REG COMMA REG RPAREN asr_asl
2346 if (IS_DREG ($1) && IS_DREG ($5) && IS_DREG ($7))
2348 notethat ("dsp32shift: dregs = VIT_MAX (dregs, dregs) (ASR)\n");
2349 $$ = DSP32SHIFT (9, &$1, &$7, &$5, 2 | ($9.r0 ? 0 : 1), 0);
2352 return yyerror ("Register mismatch");
2355 | BITMUX LPAREN REG COMMA REG COMMA REG_A RPAREN asr_asl
2357 if (IS_DREG ($3) && IS_DREG ($5) && !IS_A1 ($7))
2359 notethat ("dsp32shift: BITMUX (dregs , dregs , A0) (ASR)\n");
2360 $$ = DSP32SHIFT (8, 0, &$3, &$5, $9.r0, 0);
2363 return yyerror ("Register mismatch");
2366 | a_assign BXORSHIFT LPAREN REG_A COMMA REG_A COMMA CCREG RPAREN
2368 if (!IS_A1 ($1) && !IS_A1 ($4) && IS_A1 ($6))
2370 notethat ("dsp32shift: A0 = BXORSHIFT (A0 , A1 , CC )\n");
2371 $$ = DSP32SHIFT (12, 0, 0, 0, 0, 0);
2374 return yyerror ("Dregs expected");
2378 /* LOGI2op: BITCLR (dregs, uimm5). */
2379 | BITCLR LPAREN REG COMMA expr RPAREN
2381 if (IS_DREG ($3) && IS_UIMM ($5, 5))
2383 notethat ("LOGI2op: BITCLR (dregs , uimm5 )\n");
2384 $$ = LOGI2OP ($3, uimm5 ($5), 4);
2387 return yyerror ("Register mismatch");
2390 /* LOGI2op: BITSET (dregs, uimm5). */
2391 | BITSET LPAREN REG COMMA expr RPAREN
2393 if (IS_DREG ($3) && IS_UIMM ($5, 5))
2395 notethat ("LOGI2op: BITCLR (dregs , uimm5 )\n");
2396 $$ = LOGI2OP ($3, uimm5 ($5), 2);
2399 return yyerror ("Register mismatch");
2402 /* LOGI2op: BITTGL (dregs, uimm5). */
2403 | BITTGL LPAREN REG COMMA expr RPAREN
2405 if (IS_DREG ($3) && IS_UIMM ($5, 5))
2407 notethat ("LOGI2op: BITCLR (dregs , uimm5 )\n");
2408 $$ = LOGI2OP ($3, uimm5 ($5), 3);
2411 return yyerror ("Register mismatch");
2414 | CCREG _ASSIGN_BANG BITTST LPAREN REG COMMA expr RPAREN
2416 if (IS_DREG ($5) && IS_UIMM ($7, 5))
2418 notethat ("LOGI2op: CC =! BITTST (dregs , uimm5 )\n");
2419 $$ = LOGI2OP ($5, uimm5 ($7), 0);
2422 return yyerror ("Register mismatch or value error");
2425 | CCREG ASSIGN BITTST LPAREN REG COMMA expr RPAREN
2427 if (IS_DREG ($5) && IS_UIMM ($7, 5))
2429 notethat ("LOGI2op: CC = BITTST (dregs , uimm5 )\n");
2430 $$ = LOGI2OP ($5, uimm5 ($7), 1);
2433 return yyerror ("Register mismatch or value error");
2436 | IF BANG CCREG REG ASSIGN REG
2438 if ((IS_DREG ($4) || IS_PREG ($4))
2439 && (IS_DREG ($6) || IS_PREG ($6)))
2441 notethat ("ccMV: IF ! CC gregs = gregs\n");
2442 $$ = CCMV (&$6, &$4, 0);
2445 return yyerror ("Register mismatch");
2448 | IF CCREG REG ASSIGN REG
2450 if ((IS_DREG ($5) || IS_PREG ($5))
2451 && (IS_DREG ($3) || IS_PREG ($3)))
2453 notethat ("ccMV: IF CC gregs = gregs\n");
2454 $$ = CCMV (&$5, &$3, 1);
2457 return yyerror ("Register mismatch");
2460 | IF BANG CCREG JUMP expr
2462 if (IS_PCREL10 ($5))
2464 notethat ("BRCC: IF !CC JUMP pcrel11m2\n");
2465 $$ = BRCC (0, 0, $5);
2468 return yyerror ("Bad jump offset");
2471 | IF BANG CCREG JUMP expr LPAREN BP RPAREN
2473 if (IS_PCREL10 ($5))
2475 notethat ("BRCC: IF !CC JUMP pcrel11m2\n");
2476 $$ = BRCC (0, 1, $5);
2479 return yyerror ("Bad jump offset");
2482 | IF CCREG JUMP expr
2484 if (IS_PCREL10 ($4))
2486 notethat ("BRCC: IF CC JUMP pcrel11m2\n");
2487 $$ = BRCC (1, 0, $4);
2490 return yyerror ("Bad jump offset");
2493 | IF CCREG JUMP expr LPAREN BP RPAREN
2495 if (IS_PCREL10 ($4))
2497 notethat ("BRCC: IF !CC JUMP pcrel11m2\n");
2498 $$ = BRCC (1, 1, $4);
2501 return yyerror ("Bad jump offset");
2505 notethat ("ProgCtrl: NOP\n");
2506 $$ = PROGCTRL (0, 0);
2511 notethat ("ProgCtrl: RTS\n");
2512 $$ = PROGCTRL (1, 0);
2517 notethat ("ProgCtrl: RTI\n");
2518 $$ = PROGCTRL (1, 1);
2523 notethat ("ProgCtrl: RTX\n");
2524 $$ = PROGCTRL (1, 2);
2529 notethat ("ProgCtrl: RTN\n");
2530 $$ = PROGCTRL (1, 3);
2535 notethat ("ProgCtrl: RTE\n");
2536 $$ = PROGCTRL (1, 4);
2541 notethat ("ProgCtrl: IDLE\n");
2542 $$ = PROGCTRL (2, 0);
2547 notethat ("ProgCtrl: CSYNC\n");
2548 $$ = PROGCTRL (2, 3);
2553 notethat ("ProgCtrl: SSYNC\n");
2554 $$ = PROGCTRL (2, 4);
2559 notethat ("ProgCtrl: EMUEXCPT\n");
2560 $$ = PROGCTRL (2, 5);
2567 notethat ("ProgCtrl: CLI dregs\n");
2568 $$ = PROGCTRL (3, $2.regno & CODE_MASK);
2571 return yyerror ("Dreg expected for CLI");
2578 notethat ("ProgCtrl: STI dregs\n");
2579 $$ = PROGCTRL (4, $2.regno & CODE_MASK);
2582 return yyerror ("Dreg expected for STI");
2585 | JUMP LPAREN REG RPAREN
2589 notethat ("ProgCtrl: JUMP (pregs )\n");
2590 $$ = PROGCTRL (5, $3.regno & CODE_MASK);
2593 return yyerror ("Bad register for indirect jump");
2596 | CALL LPAREN REG RPAREN
2600 notethat ("ProgCtrl: CALL (pregs )\n");
2601 $$ = PROGCTRL (6, $3.regno & CODE_MASK);
2604 return yyerror ("Bad register for indirect call");
2607 | CALL LPAREN PC PLUS REG RPAREN
2611 notethat ("ProgCtrl: CALL (PC + pregs )\n");
2612 $$ = PROGCTRL (7, $5.regno & CODE_MASK);
2615 return yyerror ("Bad register for indirect call");
2618 | JUMP LPAREN PC PLUS REG RPAREN
2622 notethat ("ProgCtrl: JUMP (PC + pregs )\n");
2623 $$ = PROGCTRL (8, $5.regno & CODE_MASK);
2626 return yyerror ("Bad register for indirect jump");
2631 if (IS_UIMM ($2, 4))
2633 notethat ("ProgCtrl: RAISE uimm4\n");
2634 $$ = PROGCTRL (9, uimm4 ($2));
2637 return yyerror ("Bad value for RAISE");
2642 notethat ("ProgCtrl: EMUEXCPT\n");
2643 $$ = PROGCTRL (10, uimm4 ($2));
2646 | TESTSET LPAREN REG RPAREN
2650 notethat ("ProgCtrl: TESTSET (pregs )\n");
2651 $$ = PROGCTRL (11, $3.regno & CODE_MASK);
2654 return yyerror ("Preg expected");
2659 if (IS_PCREL12 ($2))
2661 notethat ("UJUMP: JUMP pcrel12\n");
2665 return yyerror ("Bad value for relative jump");
2670 if (IS_PCREL12 ($2))
2672 notethat ("UJUMP: JUMP_DOT_S pcrel12\n");
2676 return yyerror ("Bad value for relative jump");
2681 if (IS_PCREL24 ($2))
2683 notethat ("CALLa: jump.l pcrel24\n");
2687 return yyerror ("Bad value for long jump");
2692 if (IS_PCREL24 ($2))
2694 notethat ("CALLa: jump.l pcrel24\n");
2698 return yyerror ("Bad value for long jump");
2703 if (IS_PCREL24 ($2))
2705 notethat ("CALLa: CALL pcrel25m2\n");
2709 return yyerror ("Bad call address");
2713 if (IS_PCREL24 ($2))
2715 notethat ("CALLa: CALL pcrel25m2\n");
2719 return yyerror ("Bad call address");
2723 /* ALU2op: DIVQ (dregs, dregs). */
2724 | DIVQ LPAREN REG COMMA REG RPAREN
2726 if (IS_DREG ($3) && IS_DREG ($5))
2727 $$ = ALU2OP (&$3, &$5, 8);
2729 return yyerror ("Bad registers for DIVQ");
2732 | DIVS LPAREN REG COMMA REG RPAREN
2734 if (IS_DREG ($3) && IS_DREG ($5))
2735 $$ = ALU2OP (&$3, &$5, 9);
2737 return yyerror ("Bad registers for DIVS");
2740 | REG ASSIGN MINUS REG vsmod
2742 if (IS_DREG ($1) && IS_DREG ($4))
2744 if ($5.r0 == 0 && $5.s0 == 0 && $5.aop == 0)
2746 notethat ("ALU2op: dregs = - dregs\n");
2747 $$ = ALU2OP (&$1, &$4, 14);
2749 else if ($5.r0 == 1 && $5.s0 == 0 && $5.aop == 3)
2751 notethat ("dsp32alu: dregs = - dregs (.)\n");
2752 $$ = DSP32ALU (15, 0, 0, &$1, &$4, 0, $5.s0, 0, 3);
2756 notethat ("dsp32alu: dregs = - dregs (.)\n");
2757 $$ = DSP32ALU (7, 0, 0, &$1, &$4, 0, $5.s0, 0, 3);
2761 return yyerror ("Dregs expected");
2764 | REG ASSIGN TILDA REG
2766 if (IS_DREG ($1) && IS_DREG ($4))
2768 notethat ("ALU2op: dregs = ~dregs\n");
2769 $$ = ALU2OP (&$1, &$4, 15);
2772 return yyerror ("Dregs expected");
2775 | REG _GREATER_GREATER_ASSIGN REG
2777 if (IS_DREG ($1) && IS_DREG ($3))
2779 notethat ("ALU2op: dregs >>= dregs\n");
2780 $$ = ALU2OP (&$1, &$3, 1);
2783 return yyerror ("Dregs expected");
2786 | REG _GREATER_GREATER_ASSIGN expr
2788 if (IS_DREG ($1) && IS_UIMM ($3, 5))
2790 notethat ("LOGI2op: dregs >>= uimm5\n");
2791 $$ = LOGI2OP ($1, uimm5 ($3), 6);
2794 return yyerror ("Dregs expected or value error");
2797 | REG _GREATER_GREATER_GREATER_THAN_ASSIGN REG
2799 if (IS_DREG ($1) && IS_DREG ($3))
2801 notethat ("ALU2op: dregs >>>= dregs\n");
2802 $$ = ALU2OP (&$1, &$3, 0);
2805 return yyerror ("Dregs expected");
2808 | REG _LESS_LESS_ASSIGN REG
2810 if (IS_DREG ($1) && IS_DREG ($3))
2812 notethat ("ALU2op: dregs <<= dregs\n");
2813 $$ = ALU2OP (&$1, &$3, 2);
2816 return yyerror ("Dregs expected");
2819 | REG _LESS_LESS_ASSIGN expr
2821 if (IS_DREG ($1) && IS_UIMM ($3, 5))
2823 notethat ("LOGI2op: dregs <<= uimm5\n");
2824 $$ = LOGI2OP ($1, uimm5 ($3), 7);
2827 return yyerror ("Dregs expected or const value error");
2831 | REG _GREATER_GREATER_GREATER_THAN_ASSIGN expr
2833 if (IS_DREG ($1) && IS_UIMM ($3, 5))
2835 notethat ("LOGI2op: dregs >>>= uimm5\n");
2836 $$ = LOGI2OP ($1, uimm5 ($3), 5);
2839 return yyerror ("Dregs expected");
2842 /* Cache Control. */
2844 | FLUSH LBRACK REG RBRACK
2846 notethat ("CaCTRL: FLUSH [ pregs ]\n");
2848 $$ = CACTRL (&$3, 0, 2);
2850 return yyerror ("Bad register(s) for FLUSH");
2853 | FLUSH reg_with_postinc
2857 notethat ("CaCTRL: FLUSH [ pregs ++ ]\n");
2858 $$ = CACTRL (&$2, 1, 2);
2861 return yyerror ("Bad register(s) for FLUSH");
2864 | FLUSHINV LBRACK REG RBRACK
2868 notethat ("CaCTRL: FLUSHINV [ pregs ]\n");
2869 $$ = CACTRL (&$3, 0, 1);
2872 return yyerror ("Bad register(s) for FLUSH");
2875 | FLUSHINV reg_with_postinc
2879 notethat ("CaCTRL: FLUSHINV [ pregs ++ ]\n");
2880 $$ = CACTRL (&$2, 1, 1);
2883 return yyerror ("Bad register(s) for FLUSH");
2886 /* CaCTRL: IFLUSH [pregs]. */
2887 | IFLUSH LBRACK REG RBRACK
2891 notethat ("CaCTRL: IFLUSH [ pregs ]\n");
2892 $$ = CACTRL (&$3, 0, 3);
2895 return yyerror ("Bad register(s) for FLUSH");
2898 | IFLUSH reg_with_postinc
2902 notethat ("CaCTRL: IFLUSH [ pregs ++ ]\n");
2903 $$ = CACTRL (&$2, 1, 3);
2906 return yyerror ("Bad register(s) for FLUSH");
2909 | PREFETCH LBRACK REG RBRACK
2913 notethat ("CaCTRL: PREFETCH [ pregs ]\n");
2914 $$ = CACTRL (&$3, 0, 0);
2917 return yyerror ("Bad register(s) for PREFETCH");
2920 | PREFETCH reg_with_postinc
2924 notethat ("CaCTRL: PREFETCH [ pregs ++ ]\n");
2925 $$ = CACTRL (&$2, 1, 0);
2928 return yyerror ("Bad register(s) for PREFETCH");
2932 /* LDST: B [ pregs <post_op> ] = dregs. */
2934 | B LBRACK REG post_op RBRACK ASSIGN REG
2936 if (IS_PREG ($3) && IS_DREG ($7))
2938 notethat ("LDST: B [ pregs <post_op> ] = dregs\n");
2939 $$ = LDST (&$3, &$7, $4.x0, 2, 0, 1);
2942 return yyerror ("Register mismatch");
2945 /* LDSTidxI: B [ pregs + imm16 ] = dregs. */
2946 | B LBRACK REG plus_minus expr RBRACK ASSIGN REG
2948 if (IS_PREG ($3) && IS_RANGE(16, $5, $4.r0, 1) && IS_DREG ($8))
2950 notethat ("LDST: B [ pregs + imm16 ] = dregs\n");
2953 $$ = LDSTIDXI (&$3, &$8, 1, 2, 0, $5);
2956 return yyerror ("Register mismatch or const size wrong");
2960 /* LDSTii: W [ pregs + uimm4s2 ] = dregs. */
2961 | W LBRACK REG plus_minus expr RBRACK ASSIGN REG
2963 if (IS_PREG ($3) && IS_URANGE (4, $5, $4.r0, 2) && IS_DREG ($8))
2965 notethat ("LDSTii: W [ pregs +- uimm5m2 ] = dregs\n");
2966 $$ = LDSTII (&$3, &$8, $5, 1, 1);
2968 else if (IS_PREG ($3) && IS_RANGE(16, $5, $4.r0, 2) && IS_DREG ($8))
2970 notethat ("LDSTidxI: W [ pregs + imm17m2 ] = dregs\n");
2973 $$ = LDSTIDXI (&$3, &$8, 1, 1, 0, $5);
2976 return yyerror ("Bad register(s) or wrong constant size");
2979 /* LDST: W [ pregs <post_op> ] = dregs. */
2980 | W LBRACK REG post_op RBRACK ASSIGN REG
2982 if (IS_PREG ($3) && IS_DREG ($7))
2984 notethat ("LDST: W [ pregs <post_op> ] = dregs\n");
2985 $$ = LDST (&$3, &$7, $4.x0, 1, 0, 1);
2988 return yyerror ("Bad register(s) for STORE");
2991 | W LBRACK REG post_op RBRACK ASSIGN HALF_REG
2995 notethat ("dspLDST: W [ iregs <post_op> ] = dregs_half\n");
2996 $$ = DSPLDST (&$3, 1 + IS_H ($7), &$7, $4.x0, 1);
2998 else if ($4.x0 == 2 && IS_PREG ($3) && IS_DREG ($7))
3000 notethat ("LDSTpmod: W [ pregs <post_op>] = dregs_half\n");
3001 $$ = LDSTPMOD (&$3, &$7, &$3, 1 + IS_H ($7), 1);
3005 return yyerror ("Bad register(s) for STORE");
3008 /* LDSTiiFP: [ FP - const ] = dpregs. */
3009 | LBRACK REG plus_minus expr RBRACK ASSIGN REG
3011 Expr_Node *tmp = $4;
3012 int ispreg = IS_PREG ($7);
3015 return yyerror ("Preg expected for indirect");
3017 if (!IS_DREG ($7) && !ispreg)
3018 return yyerror ("Bad source register for STORE");
3021 tmp = unary (Expr_Op_Type_NEG, tmp);
3023 if (in_range_p (tmp, 0, 63, 3))
3025 notethat ("LDSTii: dpregs = [ pregs + uimm6m4 ]\n");
3026 $$ = LDSTII (&$2, &$7, tmp, 1, ispreg ? 3 : 0);
3028 else if ($2.regno == REG_FP && in_range_p (tmp, -128, 0, 3))
3030 notethat ("LDSTiiFP: dpregs = [ FP - uimm7m4 ]\n");
3031 tmp = unary (Expr_Op_Type_NEG, tmp);
3032 $$ = LDSTIIFP (tmp, &$7, 1);
3034 else if (in_range_p (tmp, -131072, 131071, 3))
3036 notethat ("LDSTidxI: [ pregs + imm18m4 ] = dpregs\n");
3037 $$ = LDSTIDXI (&$2, &$7, 1, 0, ispreg ? 1: 0, tmp);
3040 return yyerror ("Displacement out of range for store");
3043 | REG ASSIGN W LBRACK REG plus_minus expr RBRACK xpmod
3045 if (IS_DREG ($1) && IS_PREG ($5) && IS_URANGE (4, $7, $6.r0, 2))
3047 notethat ("LDSTii: dregs = W [ pregs + uimm4s2 ] (.)\n");
3048 $$ = LDSTII (&$5, &$1, $7, 0, 1 << $9.r0);
3050 else if (IS_DREG ($1) && IS_PREG ($5) && IS_RANGE(16, $7, $6.r0, 2))
3052 notethat ("LDSTidxI: dregs = W [ pregs + imm17m2 ] (.)\n");
3055 $$ = LDSTIDXI (&$5, &$1, 0, 1, $9.r0, $7);
3058 return yyerror ("Bad register or constant for LOAD");
3061 | HALF_REG ASSIGN W LBRACK REG post_op RBRACK
3065 notethat ("dspLDST: dregs_half = W [ iregs ]\n");
3066 $$ = DSPLDST(&$5, 1 + IS_H ($1), &$1, $6.x0, 0);
3068 else if ($6.x0 == 2 && IS_DREG ($1) && IS_PREG ($5))
3070 notethat ("LDSTpmod: dregs_half = W [ pregs ]\n");
3071 $$ = LDSTPMOD (&$5, &$1, &$5, 1 + IS_H ($1), 0);
3074 return yyerror ("Bad register or post_op for LOAD");
3078 | REG ASSIGN W LBRACK REG post_op RBRACK xpmod
3080 if (IS_DREG ($1) && IS_PREG ($5))
3082 notethat ("LDST: dregs = W [ pregs <post_op> ] (.)\n");
3083 $$ = LDST (&$5, &$1, $6.x0, 1, $8.r0, 0);
3086 return yyerror ("Bad register for LOAD");
3089 | REG ASSIGN W LBRACK REG _PLUS_PLUS REG RBRACK xpmod
3091 if (IS_DREG ($1) && IS_PREG ($5) && IS_PREG ($7))
3093 notethat ("LDSTpmod: dregs = W [ pregs ++ pregs ] (.)\n");
3094 $$ = LDSTPMOD (&$5, &$1, &$7, 3, $9.r0);
3097 return yyerror ("Bad register for LOAD");
3100 | HALF_REG ASSIGN W LBRACK REG _PLUS_PLUS REG RBRACK
3102 if (IS_DREG ($1) && IS_PREG ($5) && IS_PREG ($7))
3104 notethat ("LDSTpmod: dregs_half = W [ pregs ++ pregs ]\n");
3105 $$ = LDSTPMOD (&$5, &$1, &$7, 1 + IS_H ($1), 0);
3108 return yyerror ("Bad register for LOAD");
3111 | LBRACK REG post_op RBRACK ASSIGN REG
3113 if (IS_IREG ($2) && IS_DREG ($6))
3115 notethat ("dspLDST: [ iregs <post_op> ] = dregs\n");
3116 $$ = DSPLDST(&$2, 0, &$6, $3.x0, 1);
3118 else if (IS_PREG ($2) && IS_DREG ($6))
3120 notethat ("LDST: [ pregs <post_op> ] = dregs\n");
3121 $$ = LDST (&$2, &$6, $3.x0, 0, 0, 1);
3123 else if (IS_PREG ($2) && IS_PREG ($6))
3125 notethat ("LDST: [ pregs <post_op> ] = pregs\n");
3126 $$ = LDST (&$2, &$6, $3.x0, 0, 1, 1);
3129 return yyerror ("Bad register for STORE");
3132 | LBRACK REG _PLUS_PLUS REG RBRACK ASSIGN REG
3135 return yyerror ("Expected Dreg for last argument");
3137 if (IS_IREG ($2) && IS_MREG ($4))
3139 notethat ("dspLDST: [ iregs ++ mregs ] = dregs\n");
3140 $$ = DSPLDST(&$2, $4.regno & CODE_MASK, &$7, 3, 1);
3142 else if (IS_PREG ($2) && IS_PREG ($4))
3144 notethat ("LDSTpmod: [ pregs ++ pregs ] = dregs\n");
3145 $$ = LDSTPMOD (&$2, &$7, &$4, 0, 1);
3148 return yyerror ("Bad register for STORE");
3151 | W LBRACK REG _PLUS_PLUS REG RBRACK ASSIGN HALF_REG
3154 return yyerror ("Expect Dreg as last argument");
3155 if (IS_PREG ($3) && IS_PREG ($5))
3157 notethat ("LDSTpmod: W [ pregs ++ pregs ] = dregs_half\n");
3158 $$ = LDSTPMOD (&$3, &$8, &$5, 1 + IS_H ($8), 1);
3161 return yyerror ("Bad register for STORE");
3164 | REG ASSIGN B LBRACK REG plus_minus expr RBRACK xpmod
3166 if (IS_DREG ($1) && IS_PREG ($5) && IS_RANGE(16, $7, $6.r0, 1))
3168 notethat ("LDSTidxI: dregs = B [ pregs + imm16 ] (%c)\n",
3172 $$ = LDSTIDXI (&$5, &$1, 0, 2, $9.r0, $7);
3175 return yyerror ("Bad register or value for LOAD");
3178 | REG ASSIGN B LBRACK REG post_op RBRACK xpmod
3180 if (IS_DREG ($1) && IS_PREG ($5))
3182 notethat ("LDST: dregs = B [ pregs <post_op> ] (%c)\n",
3184 $$ = LDST (&$5, &$1, $6.x0, 2, $8.r0, 0);
3187 return yyerror ("Bad register for LOAD");
3190 | REG ASSIGN LBRACK REG _PLUS_PLUS REG RBRACK
3192 if (IS_DREG ($1) && IS_IREG ($4) && IS_MREG ($6))
3194 notethat ("dspLDST: dregs = [ iregs ++ mregs ]\n");
3195 $$ = DSPLDST(&$4, $6.regno & CODE_MASK, &$1, 3, 0);
3197 else if (IS_DREG ($1) && IS_PREG ($4) && IS_PREG ($6))
3199 notethat ("LDSTpmod: dregs = [ pregs ++ pregs ]\n");
3200 $$ = LDSTPMOD (&$4, &$1, &$6, 0, 0);
3203 return yyerror ("Bad register for LOAD");
3206 | REG ASSIGN LBRACK REG plus_minus got_or_expr RBRACK
3208 Expr_Node *tmp = $6;
3209 int ispreg = IS_PREG ($1);
3210 int isgot = IS_RELOC($6);
3213 return yyerror ("Preg expected for indirect");
3215 if (!IS_DREG ($1) && !ispreg)
3216 return yyerror ("Bad destination register for LOAD");
3218 if (tmp->type == Expr_Node_Reloc
3219 && strcmp (tmp->value.s_value,
3220 "_current_shared_library_p5_offset_") != 0)
3221 return yyerror ("Plain symbol used as offset");
3224 tmp = unary (Expr_Op_Type_NEG, tmp);
3227 notethat ("LDSTidxI: dpregs = [ pregs + sym@got ]\n");
3228 $$ = LDSTIDXI (&$4, &$1, 0, 0, ispreg ? 1: 0, tmp);
3230 else if (in_range_p (tmp, 0, 63, 3))
3232 notethat ("LDSTii: dpregs = [ pregs + uimm7m4 ]\n");
3233 $$ = LDSTII (&$4, &$1, tmp, 0, ispreg ? 3 : 0);
3235 else if ($4.regno == REG_FP && in_range_p (tmp, -128, 0, 3))
3237 notethat ("LDSTiiFP: dpregs = [ FP - uimm7m4 ]\n");
3238 tmp = unary (Expr_Op_Type_NEG, tmp);
3239 $$ = LDSTIIFP (tmp, &$1, 0);
3241 else if (in_range_p (tmp, -131072, 131071, 3))
3243 notethat ("LDSTidxI: dpregs = [ pregs + imm18m4 ]\n");
3244 $$ = LDSTIDXI (&$4, &$1, 0, 0, ispreg ? 1: 0, tmp);
3248 return yyerror ("Displacement out of range for load");
3251 | REG ASSIGN LBRACK REG post_op RBRACK
3253 if (IS_DREG ($1) && IS_IREG ($4))
3255 notethat ("dspLDST: dregs = [ iregs <post_op> ]\n");
3256 $$ = DSPLDST (&$4, 0, &$1, $5.x0, 0);
3258 else if (IS_DREG ($1) && IS_PREG ($4))
3260 notethat ("LDST: dregs = [ pregs <post_op> ]\n");
3261 $$ = LDST (&$4, &$1, $5.x0, 0, 0, 0);
3263 else if (IS_PREG ($1) && IS_PREG ($4))
3265 if (REG_SAME ($1, $4) && $5.x0 != 2)
3266 return yyerror ("Pregs can't be same");
3268 notethat ("LDST: pregs = [ pregs <post_op> ]\n");
3269 $$ = LDST (&$4, &$1, $5.x0, 0, 1, 0);
3271 else if ($4.regno == REG_SP && IS_ALLREG ($1) && $5.x0 == 0)
3273 notethat ("PushPopReg: allregs = [ SP ++ ]\n");
3274 $$ = PUSHPOPREG (&$1, 0);
3277 return yyerror ("Bad register or value");
3281 /* PushPopMultiple. */
3282 | reg_with_predec ASSIGN LPAREN REG COLON expr COMMA REG COLON expr RPAREN
3284 if ($1.regno != REG_SP)
3285 yyerror ("Stack Pointer expected");
3286 if ($4.regno == REG_R7
3287 && IN_RANGE ($6, 0, 7)
3288 && $8.regno == REG_P5
3289 && IN_RANGE ($10, 0, 5))
3291 notethat ("PushPopMultiple: [ -- SP ] = (R7 : reglim , P5 : reglim )\n");
3292 $$ = PUSHPOPMULTIPLE (imm5 ($6), imm5 ($10), 1, 1, 1);
3295 return yyerror ("Bad register for PushPopMultiple");
3298 | reg_with_predec ASSIGN LPAREN REG COLON expr RPAREN
3300 if ($1.regno != REG_SP)
3301 yyerror ("Stack Pointer expected");
3303 if ($4.regno == REG_R7 && IN_RANGE ($6, 0, 7))
3305 notethat ("PushPopMultiple: [ -- SP ] = (R7 : reglim )\n");
3306 $$ = PUSHPOPMULTIPLE (imm5 ($6), 0, 1, 0, 1);
3308 else if ($4.regno == REG_P5 && IN_RANGE ($6, 0, 6))
3310 notethat ("PushPopMultiple: [ -- SP ] = (P5 : reglim )\n");
3311 $$ = PUSHPOPMULTIPLE (0, imm5 ($6), 0, 1, 1);
3314 return yyerror ("Bad register for PushPopMultiple");
3317 | LPAREN REG COLON expr COMMA REG COLON expr RPAREN ASSIGN reg_with_postinc
3319 if ($11.regno != REG_SP)
3320 yyerror ("Stack Pointer expected");
3321 if ($2.regno == REG_R7 && (IN_RANGE ($4, 0, 7))
3322 && $6.regno == REG_P5 && (IN_RANGE ($8, 0, 6)))
3324 notethat ("PushPopMultiple: (R7 : reglim , P5 : reglim ) = [ SP ++ ]\n");
3325 $$ = PUSHPOPMULTIPLE (imm5 ($4), imm5 ($8), 1, 1, 0);
3328 return yyerror ("Bad register range for PushPopMultiple");
3331 | LPAREN REG COLON expr RPAREN ASSIGN reg_with_postinc
3333 if ($7.regno != REG_SP)
3334 yyerror ("Stack Pointer expected");
3336 if ($2.regno == REG_R7 && IN_RANGE ($4, 0, 7))
3338 notethat ("PushPopMultiple: (R7 : reglim ) = [ SP ++ ]\n");
3339 $$ = PUSHPOPMULTIPLE (imm5 ($4), 0, 1, 0, 0);
3341 else if ($2.regno == REG_P5 && IN_RANGE ($4, 0, 6))
3343 notethat ("PushPopMultiple: (P5 : reglim ) = [ SP ++ ]\n");
3344 $$ = PUSHPOPMULTIPLE (0, imm5 ($4), 0, 1, 0);
3347 return yyerror ("Bad register range for PushPopMultiple");
3350 | reg_with_predec ASSIGN REG
3352 if ($1.regno != REG_SP)
3353 yyerror ("Stack Pointer expected");
3357 notethat ("PushPopReg: [ -- SP ] = allregs\n");
3358 $$ = PUSHPOPREG (&$3, 1);
3361 return yyerror ("Bad register for PushPopReg");
3368 if (IS_URANGE (16, $2, 0, 4))
3369 $$ = LINKAGE (0, uimm16s4 ($2));
3371 return yyerror ("Bad constant for LINK");
3376 notethat ("linkage: UNLINK\n");
3377 $$ = LINKAGE (1, 0);
3383 | LSETUP LPAREN expr COMMA expr RPAREN REG
3385 if (IS_PCREL4 ($3) && IS_LPPCREL10 ($5) && IS_CREG ($7))
3387 notethat ("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters\n");
3388 $$ = LOOPSETUP ($3, &$7, 0, $5, 0);
3391 return yyerror ("Bad register or values for LSETUP");
3394 | LSETUP LPAREN expr COMMA expr RPAREN REG ASSIGN REG
3396 if (IS_PCREL4 ($3) && IS_LPPCREL10 ($5)
3397 && IS_PREG ($9) && IS_CREG ($7))
3399 notethat ("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters = pregs\n");
3400 $$ = LOOPSETUP ($3, &$7, 1, $5, &$9);
3403 return yyerror ("Bad register or values for LSETUP");
3406 | LSETUP LPAREN expr COMMA expr RPAREN REG ASSIGN REG GREATER_GREATER expr
3408 if (IS_PCREL4 ($3) && IS_LPPCREL10 ($5)
3409 && IS_PREG ($9) && IS_CREG ($7)
3410 && EXPR_VALUE ($11) == 1)
3412 notethat ("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters = pregs >> 1\n");
3413 $$ = LOOPSETUP ($3, &$7, 3, $5, &$9);
3416 return yyerror ("Bad register or values for LSETUP");
3423 return yyerror ("Invalid expression in loop statement");
3425 return yyerror ("Invalid loop counter register");
3426 $$ = bfin_gen_loop ($2, &$3, 0, 0);
3428 | LOOP expr REG ASSIGN REG
3430 if (IS_RELOC ($2) && IS_PREG ($5) && IS_CREG ($3))
3432 notethat ("Loop: LOOP expr counters = pregs\n");
3433 $$ = bfin_gen_loop ($2, &$3, 1, &$5);
3436 return yyerror ("Bad register or values for LOOP");
3438 | LOOP expr REG ASSIGN REG GREATER_GREATER expr
3440 if (IS_RELOC ($2) && IS_PREG ($5) && IS_CREG ($3) && EXPR_VALUE ($7) == 1)
3442 notethat ("Loop: LOOP expr counters = pregs >> 1\n");
3443 $$ = bfin_gen_loop ($2, &$3, 3, &$5);
3446 return yyerror ("Bad register or values for LOOP");
3452 notethat ("pseudoDEBUG: DBG\n");
3453 $$ = bfin_gen_pseudodbg (3, 7, 0);
3457 notethat ("pseudoDEBUG: DBG REG_A\n");
3458 $$ = bfin_gen_pseudodbg (3, IS_A1 ($2), 0);
3462 notethat ("pseudoDEBUG: DBG allregs\n");
3463 $$ = bfin_gen_pseudodbg (0, $2.regno & CODE_MASK, $2.regno & CLASS_MASK);
3466 | DBGCMPLX LPAREN REG RPAREN
3469 return yyerror ("Dregs expected");
3470 notethat ("pseudoDEBUG: DBGCMPLX (dregs )\n");
3471 $$ = bfin_gen_pseudodbg (3, 6, $3.regno & CODE_MASK);
3476 notethat ("psedoDEBUG: DBGHALT\n");
3477 $$ = bfin_gen_pseudodbg (3, 5, 0);
3480 | DBGA LPAREN HALF_REG COMMA expr RPAREN
3482 notethat ("pseudodbg_assert: DBGA (dregs_lo , uimm16 )\n");
3483 $$ = bfin_gen_pseudodbg_assert (IS_H ($3), &$3, uimm16 ($5));
3486 | DBGAH LPAREN REG COMMA expr RPAREN
3488 notethat ("pseudodbg_assert: DBGAH (dregs , uimm16 )\n");
3489 $$ = bfin_gen_pseudodbg_assert (3, &$3, uimm16 ($5));
3492 | DBGAL LPAREN REG COMMA expr RPAREN
3494 notethat ("psedodbg_assert: DBGAL (dregs , uimm16 )\n");
3495 $$ = bfin_gen_pseudodbg_assert (2, &$3, uimm16 ($5));
3503 /* Register rules. */
3505 REG_A: REG_A_DOUBLE_ZERO
3523 | LPAREN M COMMA MMOD RPAREN
3528 | LPAREN MMOD COMMA M RPAREN
3533 | LPAREN MMOD RPAREN
3545 asr_asl: LPAREN ASL RPAREN
3626 | LPAREN asr_asl_0 RPAREN
3638 | LPAREN asr_asl_0 COMMA sco RPAREN
3644 | LPAREN sco COMMA asr_asl_0 RPAREN
3704 | LPAREN V COMMA S RPAREN
3709 | LPAREN S COMMA V RPAREN
3771 | LPAREN MMOD RPAREN
3774 return yyerror ("Bad modifier");
3778 | LPAREN MMOD COMMA R RPAREN
3781 return yyerror ("Bad modifier");
3785 | LPAREN R COMMA MMOD RPAREN
3788 return yyerror ("Bad modifier");
3815 | LPAREN MMOD RPAREN
3820 return yyerror ("Only (W32) allowed");
3828 | LPAREN MMOD RPAREN
3833 return yyerror ("(IU) expected");
3837 reg_with_predec: LBRACK _MINUS_MINUS REG RBRACK
3843 reg_with_postinc: LBRACK REG _PLUS_PLUS RBRACK
3895 $$.r0 = 1; /* HL. */
3898 $$.aop = 0; /* aop. */
3903 $$.r0 = 1; /* HL. */
3906 $$.aop = 1; /* aop. */
3909 | LPAREN RNDL RPAREN
3911 $$.r0 = 0; /* HL. */
3914 $$.aop = 0; /* aop. */
3919 $$.r0 = 0; /* HL. */
3925 | LPAREN RNDH COMMA R RPAREN
3927 $$.r0 = 1; /* HL. */
3930 $$.aop = 0; /* aop. */
3932 | LPAREN TH COMMA R RPAREN
3934 $$.r0 = 1; /* HL. */
3937 $$.aop = 1; /* aop. */
3939 | LPAREN RNDL COMMA R RPAREN
3941 $$.r0 = 0; /* HL. */
3944 $$.aop = 0; /* aop. */
3947 | LPAREN TL COMMA R RPAREN
3949 $$.r0 = 0; /* HL. */
3952 $$.aop = 1; /* aop. */
3960 $$.x0 = 0; /* HL. */
3965 $$.x0 = 1; /* HL. */
3967 | LPAREN LO COMMA R RPAREN
3970 $$.x0 = 0; /* HL. */
3972 | LPAREN HI COMMA R RPAREN
3975 $$.x0 = 1; /* HL. */
3993 /* Assignments, Macfuncs. */
4019 if (IS_A1 ($3) && IS_EVEN ($1))
4020 return yyerror ("Cannot move A1 to even register");
4021 else if (!IS_A1 ($3) && !IS_EVEN ($1))
4022 return yyerror ("Cannot move A0 to odd register");
4038 | REG ASSIGN LPAREN a_macfunc RPAREN
4040 if ($4.n && IS_EVEN ($1))
4041 return yyerror ("Cannot move A1 to even register");
4042 else if (!$4.n && !IS_EVEN ($1))
4043 return yyerror ("Cannot move A0 to odd register");
4051 | HALF_REG ASSIGN LPAREN a_macfunc RPAREN
4053 if ($4.n && !IS_H ($1))
4054 return yyerror ("Cannot move A1 to low half of register");
4055 else if (!$4.n && IS_H ($1))
4056 return yyerror ("Cannot move A0 to high half of register");
4064 | HALF_REG ASSIGN REG_A
4066 if (IS_A1 ($3) && !IS_H ($1))
4067 return yyerror ("Cannot move A1 to low half of register");
4068 else if (!IS_A1 ($3) && IS_H ($1))
4069 return yyerror ("Cannot move A0 to high half of register");
4082 a_assign multiply_halfregs
4089 | a_plusassign multiply_halfregs
4096 | a_minusassign multiply_halfregs
4106 HALF_REG STAR HALF_REG
4108 if (IS_DREG ($1) && IS_DREG ($3))
4114 return yyerror ("Dregs expected");
4138 CCREG cc_op STATUS_REG
4150 | STATUS_REG cc_op CCREG
4164 /* Expressions and Symbols. */
4168 Expr_Node_Value val;
4169 val.s_value = S_GET_NAME($1);
4170 $$ = Expr_Node_Create (Expr_Node_Reloc, val, NULL, NULL);
4176 { $$ = BFD_RELOC_BFIN_GOT; }
4178 { $$ = BFD_RELOC_BFIN_GOT17M4; }
4180 { $$ = BFD_RELOC_BFIN_FUNCDESC_GOT17M4; }
4183 got: symbol AT any_gotrel
4185 Expr_Node_Value val;
4187 $$ = Expr_Node_Create (Expr_Node_GOT_Reloc, val, $1, NULL);
4210 Expr_Node_Value val;
4212 $$ = Expr_Node_Create (Expr_Node_Constant, val, NULL, NULL);
4218 | LPAREN expr_1 RPAREN
4224 $$ = unary (Expr_Op_Type_COMP, $2);
4226 | MINUS expr_1 %prec TILDA
4228 $$ = unary (Expr_Op_Type_NEG, $2);
4238 expr_1: expr_1 STAR expr_1
4240 $$ = binary (Expr_Op_Type_Mult, $1, $3);
4242 | expr_1 SLASH expr_1
4244 $$ = binary (Expr_Op_Type_Div, $1, $3);
4246 | expr_1 PERCENT expr_1
4248 $$ = binary (Expr_Op_Type_Mod, $1, $3);
4250 | expr_1 PLUS expr_1
4252 $$ = binary (Expr_Op_Type_Add, $1, $3);
4254 | expr_1 MINUS expr_1
4256 $$ = binary (Expr_Op_Type_Sub, $1, $3);
4258 | expr_1 LESS_LESS expr_1
4260 $$ = binary (Expr_Op_Type_Lshift, $1, $3);
4262 | expr_1 GREATER_GREATER expr_1
4264 $$ = binary (Expr_Op_Type_Rshift, $1, $3);
4266 | expr_1 AMPERSAND expr_1
4268 $$ = binary (Expr_Op_Type_BAND, $1, $3);
4270 | expr_1 CARET expr_1
4272 $$ = binary (Expr_Op_Type_LOR, $1, $3);
4276 $$ = binary (Expr_Op_Type_BOR, $1, $3);
4288 mkexpr (int x, SYMBOL_T s)
4290 EXPR_T e = (EXPR_T) ALLOCATE (sizeof (struct expression_cell));
4297 value_match (Expr_Node *expr, int sz, int sign, int mul, int issigned)
4299 long umax = (1L << sz) - 1;
4300 long min = -1L << (sz - 1);
4301 long max = (1L << (sz - 1)) - 1;
4303 long v = EXPR_VALUE (expr);
4307 error ("%s:%d: Value Error -- Must align to %d\n", __FILE__, __LINE__, mul);
4318 if (v >= min && v <= max) return 1;
4321 fprintf(stderr, "signed value %lx out of range\n", v * mul);
4325 if (v <= umax && v >= 0)
4328 fprintf(stderr, "unsigned value %lx out of range\n", v * mul);
4333 /* Return the expression structure that allows symbol operations.
4334 If the left and right children are constants, do the operation. */
4336 binary (Expr_Op_Type op, Expr_Node *x, Expr_Node *y)
4338 Expr_Node_Value val;
4340 if (x->type == Expr_Node_Constant && y->type == Expr_Node_Constant)
4344 case Expr_Op_Type_Add:
4345 x->value.i_value += y->value.i_value;
4347 case Expr_Op_Type_Sub:
4348 x->value.i_value -= y->value.i_value;
4350 case Expr_Op_Type_Mult:
4351 x->value.i_value *= y->value.i_value;
4353 case Expr_Op_Type_Div:
4354 if (y->value.i_value == 0)
4355 error ("Illegal Expression: Division by zero.");
4357 x->value.i_value /= y->value.i_value;
4359 case Expr_Op_Type_Mod:
4360 x->value.i_value %= y->value.i_value;
4362 case Expr_Op_Type_Lshift:
4363 x->value.i_value <<= y->value.i_value;
4365 case Expr_Op_Type_Rshift:
4366 x->value.i_value >>= y->value.i_value;
4368 case Expr_Op_Type_BAND:
4369 x->value.i_value &= y->value.i_value;
4371 case Expr_Op_Type_BOR:
4372 x->value.i_value |= y->value.i_value;
4374 case Expr_Op_Type_BXOR:
4375 x->value.i_value ^= y->value.i_value;
4377 case Expr_Op_Type_LAND:
4378 x->value.i_value = x->value.i_value && y->value.i_value;
4380 case Expr_Op_Type_LOR:
4381 x->value.i_value = x->value.i_value || y->value.i_value;
4385 error ("%s:%d: Internal assembler error\n", __FILE__, __LINE__);
4389 /* Canonicalize order to EXPR OP CONSTANT. */
4390 if (x->type == Expr_Node_Constant)
4396 /* Canonicalize subtraction of const to addition of negated const. */
4397 if (op == Expr_Op_Type_Sub && y->type == Expr_Node_Constant)
4399 op = Expr_Op_Type_Add;
4400 y->value.i_value = -y->value.i_value;
4402 if (y->type == Expr_Node_Constant && x->type == Expr_Node_Binop
4403 && x->Right_Child->type == Expr_Node_Constant)
4405 if (op == x->value.op_value && x->value.op_value == Expr_Op_Type_Add)
4407 x->Right_Child->value.i_value += y->value.i_value;
4412 /* Create a new expression structure. */
4414 return Expr_Node_Create (Expr_Node_Binop, val, x, y);
4418 unary (Expr_Op_Type op, Expr_Node *x)
4420 if (x->type == Expr_Node_Constant)
4424 case Expr_Op_Type_NEG:
4425 x->value.i_value = -x->value.i_value;
4427 case Expr_Op_Type_COMP:
4428 x->value.i_value = ~x->value.i_value;
4431 error ("%s:%d: Internal assembler error\n", __FILE__, __LINE__);
4437 /* Create a new expression structure. */
4438 Expr_Node_Value val;
4440 return Expr_Node_Create (Expr_Node_Unop, val, x, NULL);
4444 int debug_codeselection = 0;
4446 notethat (char *format, ...)
4449 va_start (ap, format);
4450 if (debug_codeselection)
4452 vfprintf (errorf, format, ap);
4458 main (int argc, char **argv)