1 /* bfin-parse.y ADI Blackfin parser
2 Copyright 2005, 2006, 2007
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
, ...
)
174 va_start
(ap
, format
);
175 vsprintf
(buffer
, format
, ap
);
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 (vector) mac funcs and ops. */
270 check_macfuncs
(Macfunc
*aa
, Opt_mode
*opa
,
271 Macfunc
*ab
, Opt_mode
*opb
)
273 /* Variables for swapping. */
277 /* If a0macfunc comes before a1macfunc, swap them. */
281 /* (M) is not allowed here. */
283 return
yyerror ("(M) not allowed with A0MAC");
285 return
yyerror ("Vector AxMACs can't be same");
287 mtmp
= *aa
; *aa
= *ab
; *ab
= mtmp
;
288 otmp
= *opa
; *opa
= *opb
; *opb
= otmp
;
293 return
yyerror ("(M) not allowed with A0MAC");
295 return
yyerror ("Bad opt mode");
297 return
yyerror ("Vector AxMACs can't be same");
300 /* If both ops are one of 0, 1, or 2, we have multiply_halfregs in both
301 assignment_or_macfuncs. */
302 if
(aa
->op
< 3 && aa
->op
>=0
303 && ab
->op
< 3 && ab
->op
>= 0)
305 if
(check_multiply_halfregs
(aa
, ab
) < 0)
310 /* Only one of the assign_macfuncs has a half reg multiply
311 Evil trick: Just 'OR' their source register codes:
312 We can do that, because we know they were initialized to 0
313 in the rules that don't use multiply_halfregs. */
314 aa
->s0.regno |
= (ab
->s0.regno
& CODE_MASK
);
315 aa
->s1.regno |
= (ab
->s1.regno
& CODE_MASK
);
318 if
(aa
->w
== ab
->w
&& aa
->P
!= ab
->P
)
320 return
yyerror ("macfuncs must differ");
321 if
(aa
->w
&& (aa
->dst.regno
- ab
->dst.regno
!= 1))
322 return
yyerror ("Destination Dregs must differ by one");
324 /* We assign to full regs, thus obey even/odd rules. */
325 else if
((aa
->w
&& aa
->P
&& IS_EVEN
(aa
->dst
))
326 ||
(ab
->w
&& ab
->P
&& !IS_EVEN
(ab
->dst
)))
327 return
yyerror ("Even/Odd register assignment mismatch");
328 /* We assign to half regs, thus obey hi/low rules. */
329 else if
( (aa
->w
&& !aa
->P
&& !IS_H
(aa
->dst
))
330 ||
(ab
->w
&& !aa
->P
&& IS_H
(ab
->dst
)))
331 return
yyerror ("High/Low register assignment mismatch");
333 /* Make sure first macfunc has got both P flags ORed. */
336 /* Make sure mod flags get ORed, too. */
337 opb
->mod |
= opa
->mod
;
343 is_group1
(INSTR_T x
)
345 /* Group1 is dpsLDST, LDSTpmod, LDST, LDSTiiFP, LDSTii. */
346 if
((x
->value
& 0xc000) == 0x8000 ||
(x
->value
== 0x0000))
353 is_group2
(INSTR_T x
)
355 if
((((x
->value
& 0xfc00) == 0x9c00) /* dspLDST. */
356 && !((x
->value
& 0xfde0) == 0x9c60) /* dagMODim. */
357 && !((x
->value
& 0xfde0) == 0x9ce0) /* dagMODim with bit rev. */
358 && !((x
->value
& 0xfde0) == 0x9d60)) /* pick dagMODik. */
359 ||
(x
->value
== 0x0000))
373 struct { int r0
; int s0
; int x0
; int aop
; } modcodes
;
374 struct { int r0
; } r0
;
381 /* Vector Specific. */
382 %token BYTEOP16P BYTEOP16M
383 %token BYTEOP1P BYTEOP2P BYTEOP2M BYTEOP3P
384 %token BYTEUNPACK BYTEPACK
387 %token ALIGN8 ALIGN16 ALIGN24
389 %token EXTRACT DEPOSIT EXPADJ SEARCH
390 %token ONES SIGN SIGNBITS
398 %token CCREG BYTE_DREG
399 %token REG_A_DOUBLE_ZERO REG_A_DOUBLE_ONE
400 %token A_ZERO_DOT_L A_ZERO_DOT_H A_ONE_DOT_L A_ONE_DOT_H
405 %token RTI RTS RTX RTN RTE
416 %token JUMP JUMP_DOT_S JUMP_DOT_L
423 %token NOT TILDA BANG
429 %token MINUS PLUS STAR SLASH
433 %token _PLUS_BAR_PLUS _PLUS_BAR_MINUS _MINUS_BAR_PLUS _MINUS_BAR_MINUS
434 %token _MINUS_MINUS _PLUS_PLUS
436 /* Shift/rotate ops. */
437 %token SHIFT LSHIFT ASHIFT BXORSHIFT
438 %token _GREATER_GREATER_GREATER_THAN_ASSIGN
440 %token LESS_LESS GREATER_GREATER
441 %token _GREATER_GREATER_GREATER
442 %token _LESS_LESS_ASSIGN _GREATER_GREATER_ASSIGN
445 /* In place operators. */
446 %token ASSIGN _STAR_ASSIGN
447 %token _BAR_ASSIGN _CARET_ASSIGN _AMPERSAND_ASSIGN
448 %token _MINUS_ASSIGN _PLUS_ASSIGN
450 /* Assignments, comparisons. */
451 %token _ASSIGN_BANG _LESS_THAN_ASSIGN _ASSIGN_ASSIGN
456 %token FLUSHINV FLUSH
457 %token IFLUSH PREFETCH
474 %token R RND RNDL RNDH RND12 RND20
479 %token BITTGL BITCLR BITSET BITTST BITMUX
482 %token DBGAL DBGAH DBGHALT DBG DBGA DBGCMPLX
484 /* Semantic auxiliaries. */
487 %token COLON SEMICOLON
488 %token RPAREN LPAREN LBRACK RBRACK
492 %token GOT GOT17M4 FUNCDESC_GOT17M4
502 %type
<modcodes
> byteop_mod
504 %type
<reg
> a_plusassign
505 %type
<reg
> a_minusassign
506 %type
<macfunc
> multiply_halfregs
507 %type
<macfunc
> assign_macfunc
508 %type
<macfunc
> a_macfunc
512 %type
<modcodes
> vsmod
513 %type
<modcodes
> ccstat
516 %type
<reg
> reg_with_postinc
517 %type
<reg
> reg_with_predec
521 %type
<symbol
> SYMBOL
524 %type
<reg
> BYTE_DREG
525 %type
<reg
> REG_A_DOUBLE_ZERO
526 %type
<reg
> REG_A_DOUBLE_ONE
528 %type
<reg
> STATUS_REG
532 %type
<modcodes
> smod
533 %type
<modcodes
> b3_op
534 %type
<modcodes
> rnd_op
535 %type
<modcodes
> post_op
537 %type
<r0
> iu_or_nothing
538 %type
<r0
> plus_minus
542 %type
<modcodes
> amod0
543 %type
<modcodes
> amod1
544 %type
<modcodes
> amod2
546 %type
<r0
> w32_or_nothing
550 %type
<expr
> got_or_expr
552 %type
<value
> any_gotrel GOT GOT17M4 FUNCDESC_GOT17M4
554 /* Precedence rules. */
558 %left LESS_LESS GREATER_GREATER
560 %left STAR SLASH PERCENT
571 if
(insn
== (INSTR_T
) 0)
572 return NO_INSN_GENERATED
;
573 else if
(insn
== (INSTR_T
) - 1)
574 return SEMANTIC_ERROR
;
576 return INSN_GENERATED
;
581 /* Parallel instructions. */
582 | asm_1 DOUBLE_BAR asm_1 DOUBLE_BAR asm_1 SEMICOLON
584 if
(($1->value
& 0xf800) == 0xc000)
586 if
(is_group1
($3) && is_group2
($5))
587 $$
= bfin_gen_multi_instr
($1, $3, $5);
588 else if
(is_group2
($3) && is_group1
($5))
589 $$
= bfin_gen_multi_instr
($1, $5, $3);
591 return
yyerror ("Wrong 16 bit instructions groups, slot 2 and slot 3 must be 16-bit instrution group");
593 else if
(($3->value
& 0xf800) == 0xc000)
595 if
(is_group1
($1) && is_group2
($5))
596 $$
= bfin_gen_multi_instr
($3, $1, $5);
597 else if
(is_group2
($1) && is_group1
($5))
598 $$
= bfin_gen_multi_instr
($3, $5, $1);
600 return
yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 3 must be 16-bit instrution group");
602 else if
(($5->value
& 0xf800) == 0xc000)
604 if
(is_group1
($1) && is_group2
($3))
605 $$
= bfin_gen_multi_instr
($5, $1, $3);
606 else if
(is_group2
($1) && is_group1
($3))
607 $$
= bfin_gen_multi_instr
($5, $3, $1);
609 return
yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 2 must be 16-bit instrution group");
612 error ("\nIllegal Multi Issue Construct, at least any one of the slot must be DSP32 instruction group\n");
615 | asm_1 DOUBLE_BAR asm_1 SEMICOLON
617 if
(($1->value
& 0xf800) == 0xc000)
620 $$
= bfin_gen_multi_instr
($1, $3, 0);
621 else if
(is_group2
($3))
622 $$
= bfin_gen_multi_instr
($1, 0, $3);
624 return
yyerror ("Wrong 16 bit instructions groups, slot 2 must be the 16-bit instruction group");
626 else if
(($3->value
& 0xf800) == 0xc000)
629 $$
= bfin_gen_multi_instr
($3, $1, 0);
630 else if
(is_group2
($1))
631 $$
= bfin_gen_multi_instr
($3, 0, $1);
633 return
yyerror ("Wrong 16 bit instructions groups, slot 1 must be the 16-bit instruction group");
635 else if
(is_group1
($1) && is_group2
($3))
636 $$
= bfin_gen_multi_instr
(0, $1, $3);
637 else if
(is_group2
($1) && is_group1
($3))
638 $$
= bfin_gen_multi_instr
(0, $3, $1);
640 return
yyerror ("Wrong 16 bit instructions groups, slot 1 and slot 2 must be the 16-bit instruction group");
655 $$
= DSP32MAC
(3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0);
657 | assign_macfunc opt_mode
661 int h00
, h10
, h01
, h11
;
666 return
yyerror ("(m) not allowed with a0 unit");
685 $$
= DSP32MAC
(op1
, $2.MM
, $2.mod
, w1
, $1.P
, h01
, h11
, h00
, h10
,
686 &$1.dst
, op0
, &$1.s0
, &$1.s1
, w0
);
692 | assign_macfunc opt_mode COMMA assign_macfunc opt_mode
696 if
(check_macfuncs
(&$1, &$2, &$4, &$5) < 0)
698 notethat
("assign_macfunc (.), assign_macfunc (.)\n");
705 $$
= DSP32MAC
($1.op
, $2.MM
, $5.mod
, $1.w
, $1.P
,
706 IS_H
($1.s0
), IS_H
($1.s1
), IS_H
($4.s0
), IS_H
($4.s1
),
707 dst
, $4.op
, &$1.s0
, &$1.s1
, $4.w
);
714 notethat
("dsp32alu: DISALGNEXCPT\n");
715 $$
= DSP32ALU
(18, 0, 0, 0, 0, 0, 0, 0, 3);
717 | REG ASSIGN LPAREN a_plusassign REG_A RPAREN
719 if
(IS_DREG
($1) && !IS_A1
($4) && IS_A1
($5))
721 notethat
("dsp32alu: dregs = ( A0 += A1 )\n");
722 $$
= DSP32ALU
(11, 0, 0, &$1, 0, 0, 0, 0, 0);
725 return
yyerror ("Register mismatch");
727 | HALF_REG ASSIGN LPAREN a_plusassign REG_A RPAREN
729 if
(!IS_A1
($4) && IS_A1
($5))
731 notethat
("dsp32alu: dregs_half = ( A0 += A1 )\n");
732 $$
= DSP32ALU
(11, IS_H
($1), 0, &$1, 0, 0, 0, 0, 1);
735 return
yyerror ("Register mismatch");
737 | A_ZERO_DOT_H ASSIGN HALF_REG
739 notethat
("dsp32alu: A_ZERO_DOT_H = dregs_hi\n");
740 $$
= DSP32ALU
(9, IS_H
($3), 0, 0, &$3, 0, 0, 0, 0);
742 | A_ONE_DOT_H ASSIGN HALF_REG
744 notethat
("dsp32alu: A_ZERO_DOT_H = dregs_hi\n");
745 $$
= DSP32ALU
(9, IS_H
($3), 0, 0, &$3, 0, 0, 0, 2);
747 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEOP16P LPAREN REG
748 COLON expr COMMA REG COLON expr RPAREN aligndir
750 if
(!IS_DREG
($2) ||
!IS_DREG
($4))
751 return
yyerror ("Dregs expected");
752 else if
(!valid_dreg_pair
(&$9, $11))
753 return
yyerror ("Bad dreg pair");
754 else if
(!valid_dreg_pair
(&$13, $15))
755 return
yyerror ("Bad dreg pair");
758 notethat
("dsp32alu: (dregs , dregs ) = BYTEOP16P (dregs_pair , dregs_pair ) (half)\n");
759 $$
= DSP32ALU
(21, 0, &$2, &$4, &$9, &$13, $17.r0
, 0, 0);
763 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEOP16M LPAREN REG COLON expr COMMA
764 REG COLON expr RPAREN aligndir
766 if
(!IS_DREG
($2) ||
!IS_DREG
($4))
767 return
yyerror ("Dregs expected");
768 else if
(!valid_dreg_pair
(&$9, $11))
769 return
yyerror ("Bad dreg pair");
770 else if
(!valid_dreg_pair
(&$13, $15))
771 return
yyerror ("Bad dreg pair");
774 notethat
("dsp32alu: (dregs , dregs ) = BYTEOP16M (dregs_pair , dregs_pair ) (aligndir)\n");
775 $$
= DSP32ALU
(21, 0, &$2, &$4, &$9, &$13, $17.r0
, 0, 1);
779 | LPAREN REG COMMA REG RPAREN ASSIGN BYTEUNPACK REG COLON expr aligndir
781 if
(!IS_DREG
($2) ||
!IS_DREG
($4))
782 return
yyerror ("Dregs expected");
783 else if
(!valid_dreg_pair
(&$8, $10))
784 return
yyerror ("Bad dreg pair");
787 notethat
("dsp32alu: (dregs , dregs ) = BYTEUNPACK dregs_pair (aligndir)\n");
788 $$
= DSP32ALU
(24, 0, &$2, &$4, &$8, 0, $11.r0
, 0, 1);
791 | LPAREN REG COMMA REG RPAREN ASSIGN SEARCH REG LPAREN searchmod RPAREN
793 if
(IS_DREG
($2) && IS_DREG
($4) && IS_DREG
($8))
795 notethat
("dsp32alu: (dregs , dregs ) = SEARCH dregs (searchmod)\n");
796 $$
= DSP32ALU
(13, 0, &$2, &$4, &$8, 0, 0, 0, $10.r0
);
799 return
yyerror ("Register mismatch");
801 | REG ASSIGN A_ONE_DOT_L PLUS A_ONE_DOT_H COMMA
802 REG ASSIGN A_ZERO_DOT_L PLUS A_ZERO_DOT_H
804 if
(IS_DREG
($1) && IS_DREG
($7))
806 notethat
("dsp32alu: dregs = A1.l + A1.h, dregs = A0.l + A0.h \n");
807 $$
= DSP32ALU
(12, 0, &$1, &$7, 0, 0, 0, 0, 1);
810 return
yyerror ("Register mismatch");
814 | REG ASSIGN REG_A PLUS REG_A COMMA REG ASSIGN REG_A MINUS REG_A amod1
816 if
(IS_DREG
($1) && IS_DREG
($7) && !REG_SAME
($3, $5)
817 && IS_A1
($9) && !IS_A1
($11))
819 notethat
("dsp32alu: dregs = A1 + A0 , dregs = A1 - A0 (amod1)\n");
820 $$
= DSP32ALU
(17, 0, &$1, &$7, 0, 0, $12.s0
, $12.x0
, 0);
823 else if
(IS_DREG
($1) && IS_DREG
($7) && !REG_SAME
($3, $5)
824 && !IS_A1
($9) && IS_A1
($11))
826 notethat
("dsp32alu: dregs = A0 + A1 , dregs = A0 - A1 (amod1)\n");
827 $$
= DSP32ALU
(17, 0, &$1, &$7, 0, 0, $12.s0
, $12.x0
, 1);
830 return
yyerror ("Register mismatch");
833 | REG ASSIGN REG plus_minus REG COMMA REG ASSIGN REG plus_minus REG amod1
836 return
yyerror ("Operators must differ");
838 if
(IS_DREG
($1) && IS_DREG
($3) && IS_DREG
($5)
839 && REG_SAME
($3, $9) && REG_SAME
($5, $11))
841 notethat
("dsp32alu: dregs = dregs + dregs,"
842 "dregs = dregs - dregs (amod1)\n");
843 $$
= DSP32ALU
(4, 0, &$1, &$7, &$3, &$5, $12.s0
, $12.x0
, 2);
846 return
yyerror ("Register mismatch");
849 /* Bar Operations. */
851 | REG ASSIGN REG op_bar_op REG COMMA REG ASSIGN REG op_bar_op REG amod2
853 if
(!REG_SAME
($3, $9) ||
!REG_SAME
($5, $11))
854 return
yyerror ("Differing source registers");
856 if
(!IS_DREG
($1) ||
!IS_DREG
($3) ||
!IS_DREG
($5) ||
!IS_DREG
($7))
857 return
yyerror ("Dregs expected");
860 if
($4.r0
== 1 && $10.r0
== 2)
862 notethat
("dsp32alu: dregs = dregs .|. dregs , dregs = dregs .|. dregs (amod2)\n");
863 $$
= DSP32ALU
(1, 1, &$1, &$7, &$3, &$5, $12.s0
, $12.x0
, $12.r0
);
865 else if
($4.r0
== 0 && $10.r0
== 3)
867 notethat
("dsp32alu: dregs = dregs .|. dregs , dregs = dregs .|. dregs (amod2)\n");
868 $$
= DSP32ALU
(1, 0, &$1, &$7, &$3, &$5, $12.s0
, $12.x0
, $12.r0
);
871 return
yyerror ("Bar operand mismatch");
874 | REG ASSIGN ABS REG vmod
878 if
(IS_DREG
($1) && IS_DREG
($4))
882 notethat
("dsp32alu: dregs = ABS dregs (v)\n");
887 /* Vector version of ABS. */
888 notethat
("dsp32alu: dregs = ABS dregs\n");
891 $$
= DSP32ALU
(op
, 0, 0, &$1, &$4, 0, 0, 0, 2);
894 return
yyerror ("Dregs expected");
898 notethat
("dsp32alu: Ax = ABS Ax\n");
899 $$
= DSP32ALU
(16, IS_A1
($1), 0, 0, 0, 0, 0, 0, IS_A1
($3));
901 | A_ZERO_DOT_L ASSIGN HALF_REG
905 notethat
("dsp32alu: A0.l = reg_half\n");
906 $$
= DSP32ALU
(9, IS_H
($3), 0, 0, &$3, 0, 0, 0, 0);
909 return
yyerror ("A0.l = Rx.l expected");
911 | A_ONE_DOT_L ASSIGN HALF_REG
915 notethat
("dsp32alu: A1.l = reg_half\n");
916 $$
= DSP32ALU
(9, IS_H
($3), 0, 0, &$3, 0, 0, 0, 2);
919 return
yyerror ("A1.l = Rx.l expected");
922 | REG ASSIGN c_align LPAREN REG COMMA REG RPAREN
924 if
(IS_DREG
($1) && IS_DREG
($5) && IS_DREG
($7))
926 notethat
("dsp32shift: dregs = ALIGN8 (dregs , dregs )\n");
927 $$
= DSP32SHIFT
(13, &$1, &$7, &$5, $3.r0
, 0);
930 return
yyerror ("Dregs expected");
933 | REG ASSIGN BYTEOP1P LPAREN REG COLON expr COMMA REG COLON expr RPAREN byteop_mod
936 return
yyerror ("Dregs expected");
937 else if
(!valid_dreg_pair
(&$5, $7))
938 return
yyerror ("Bad dreg pair");
939 else if
(!valid_dreg_pair
(&$9, $11))
940 return
yyerror ("Bad dreg pair");
943 notethat
("dsp32alu: dregs = BYTEOP1P (dregs_pair , dregs_pair ) (T)\n");
944 $$
= DSP32ALU
(20, 0, 0, &$1, &$5, &$9, $13.s0
, 0, $13.r0
);
947 | REG ASSIGN BYTEOP1P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
950 return
yyerror ("Dregs expected");
951 else if
(!valid_dreg_pair
(&$5, $7))
952 return
yyerror ("Bad dreg pair");
953 else if
(!valid_dreg_pair
(&$9, $11))
954 return
yyerror ("Bad dreg pair");
957 notethat
("dsp32alu: dregs = BYTEOP1P (dregs_pair , dregs_pair ) (T)\n");
958 $$
= DSP32ALU
(20, 0, 0, &$1, &$5, &$9, 0, 0, 0);
962 | REG ASSIGN BYTEOP2P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
966 return
yyerror ("Dregs expected");
967 else if
(!valid_dreg_pair
(&$5, $7))
968 return
yyerror ("Bad dreg pair");
969 else if
(!valid_dreg_pair
(&$9, $11))
970 return
yyerror ("Bad dreg pair");
973 notethat
("dsp32alu: dregs = BYTEOP2P (dregs_pair , dregs_pair ) (rnd_op)\n");
974 $$
= DSP32ALU
(22, $13.r0
, 0, &$1, &$5, &$9, $13.s0
, $13.x0
, $13.aop
);
978 | REG ASSIGN BYTEOP2M LPAREN REG COLON expr COMMA REG COLON expr RPAREN
982 return
yyerror ("Dregs expected");
983 else if
(!valid_dreg_pair
(&$5, $7))
984 return
yyerror ("Bad dreg pair");
985 else if
(!valid_dreg_pair
(&$9, $11))
986 return
yyerror ("Bad dreg pair");
989 notethat
("dsp32alu: dregs = BYTEOP2P (dregs_pair , dregs_pair ) (rnd_op)\n");
990 $$
= DSP32ALU
(22, $13.r0
, 0, &$1, &$5, &$9, $13.s0
, 0, $13.x0
);
994 | REG ASSIGN BYTEOP3P LPAREN REG COLON expr COMMA REG COLON expr RPAREN
998 return
yyerror ("Dregs expected");
999 else if
(!valid_dreg_pair
(&$5, $7))
1000 return
yyerror ("Bad dreg pair");
1001 else if
(!valid_dreg_pair
(&$9, $11))
1002 return
yyerror ("Bad dreg pair");
1005 notethat
("dsp32alu: dregs = BYTEOP3P (dregs_pair , dregs_pair ) (b3_op)\n");
1006 $$
= DSP32ALU
(23, $13.x0
, 0, &$1, &$5, &$9, $13.s0
, 0, 0);
1010 | REG ASSIGN BYTEPACK LPAREN REG COMMA REG RPAREN
1012 if
(IS_DREG
($1) && IS_DREG
($5) && IS_DREG
($7))
1014 notethat
("dsp32alu: dregs = BYTEPACK (dregs , dregs )\n");
1015 $$
= DSP32ALU
(24, 0, 0, &$1, &$5, &$7, 0, 0, 0);
1018 return
yyerror ("Dregs expected");
1021 | HALF_REG ASSIGN HALF_REG ASSIGN SIGN LPAREN HALF_REG RPAREN STAR
1022 HALF_REG PLUS SIGN LPAREN HALF_REG RPAREN STAR HALF_REG
1024 if
(IS_HCOMPL
($1, $3) && IS_HCOMPL
($7, $14) && IS_HCOMPL
($10, $17))
1026 notethat
("dsp32alu: dregs_hi = dregs_lo ="
1027 "SIGN (dregs_hi) * dregs_hi + "
1028 "SIGN (dregs_lo) * dregs_lo \n");
1030 $$
= DSP32ALU
(12, 0, 0, &$1, &$7, &$10, 0, 0, 0);
1033 return
yyerror ("Dregs expected");
1035 | REG ASSIGN REG plus_minus REG amod1
1037 if
(IS_DREG
($1) && IS_DREG
($3) && IS_DREG
($5))
1041 /* No saturation flag specified, generate the 16 bit variant. */
1042 notethat
("COMP3op: dregs = dregs +- dregs\n");
1043 $$
= COMP3OP
(&$1, &$3, &$5, $4.r0
);
1047 /* Saturation flag specified, generate the 32 bit variant. */
1048 notethat
("dsp32alu: dregs = dregs +- dregs (amod1)\n");
1049 $$
= DSP32ALU
(4, 0, 0, &$1, &$3, &$5, $6.s0
, $6.x0
, $4.r0
);
1053 if
(IS_PREG
($1) && IS_PREG
($3) && IS_PREG
($5) && $4.r0
== 0)
1055 notethat
("COMP3op: pregs = pregs + pregs\n");
1056 $$
= COMP3OP
(&$1, &$3, &$5, 5);
1059 return
yyerror ("Dregs expected");
1061 | REG ASSIGN min_max LPAREN REG COMMA REG RPAREN vmod
1065 if
(IS_DREG
($1) && IS_DREG
($5) && IS_DREG
($7))
1072 notethat
("dsp32alu: dregs = {MIN|MAX} (dregs, dregs)\n");
1073 $$
= DSP32ALU
(op
, 0, 0, &$1, &$5, &$7, 0, 0, $3.r0
);
1076 return
yyerror ("Dregs expected");
1079 | a_assign MINUS REG_A
1081 notethat
("dsp32alu: Ax = - Ax\n");
1082 $$
= DSP32ALU
(14, IS_A1
($1), 0, 0, 0, 0, 0, 0, IS_A1
($3));
1084 | HALF_REG ASSIGN HALF_REG plus_minus HALF_REG amod1
1086 notethat
("dsp32alu: dregs_lo = dregs_lo +- dregs_lo (amod1)\n");
1087 $$
= DSP32ALU
(2 |
$4.r0
, IS_H
($1), 0, &$1, &$3, &$5,
1088 $6.s0
, $6.x0
, HL2
($3, $5));
1090 | a_assign a_assign expr
1092 if
(EXPR_VALUE
($3) == 0 && !REG_SAME
($1, $2))
1094 notethat
("dsp32alu: A1 = A0 = 0\n");
1095 $$
= DSP32ALU
(8, 0, 0, 0, 0, 0, 0, 0, 2);
1098 return
yyerror ("Bad value, 0 expected");
1102 | a_assign REG_A LPAREN S RPAREN
1104 if
(REG_SAME
($1, $2))
1106 notethat
("dsp32alu: Ax = Ax (S)\n");
1107 $$
= DSP32ALU
(8, 0, 0, 0, 0, 0, 1, 0, IS_A1
($1));
1110 return
yyerror ("Registers must be equal");
1113 | HALF_REG ASSIGN REG LPAREN RND RPAREN
1117 notethat
("dsp32alu: dregs_half = dregs (RND)\n");
1118 $$
= DSP32ALU
(12, IS_H
($1), 0, &$1, &$3, 0, 0, 0, 3);
1121 return
yyerror ("Dregs expected");
1124 | HALF_REG ASSIGN REG plus_minus REG LPAREN RND12 RPAREN
1126 if
(IS_DREG
($3) && IS_DREG
($5))
1128 notethat
("dsp32alu: dregs_half = dregs (+-) dregs (RND12)\n");
1129 $$
= DSP32ALU
(5, IS_H
($1), 0, &$1, &$3, &$5, 0, 0, $4.r0
);
1132 return
yyerror ("Dregs expected");
1135 | HALF_REG ASSIGN REG plus_minus REG LPAREN RND20 RPAREN
1137 if
(IS_DREG
($3) && IS_DREG
($5))
1139 notethat
("dsp32alu: dregs_half = dregs -+ dregs (RND20)\n");
1140 $$
= DSP32ALU
(5, IS_H
($1), 0, &$1, &$3, &$5, 0, 1, $4.r0 |
2);
1143 return
yyerror ("Dregs expected");
1148 if
(!REG_SAME
($1, $2))
1150 notethat
("dsp32alu: An = Am\n");
1151 $$
= DSP32ALU
(8, 0, 0, 0, 0, 0, IS_A1
($1), 0, 3);
1154 return
yyerror ("Accu reg arguments must differ");
1161 notethat
("dsp32alu: An = dregs\n");
1162 $$
= DSP32ALU
(9, 0, 0, 0, &$2, 0, 1, 0, IS_A1
($1) << 1);
1165 return
yyerror ("Dregs expected");
1168 | REG ASSIGN HALF_REG xpmod
1172 if
($1.regno
== REG_A0x
&& IS_DREG
($3))
1174 notethat
("dsp32alu: A0.x = dregs_lo\n");
1175 $$
= DSP32ALU
(9, 0, 0, 0, &$3, 0, 0, 0, 1);
1177 else if
($1.regno
== REG_A1x
&& IS_DREG
($3))
1179 notethat
("dsp32alu: A1.x = dregs_lo\n");
1180 $$
= DSP32ALU
(9, 0, 0, 0, &$3, 0, 0, 0, 3);
1182 else if
(IS_DREG
($1) && IS_DREG
($3))
1184 notethat
("ALU2op: dregs = dregs_lo\n");
1185 $$
= ALU2OP
(&$1, &$3, 10 |
($4.r0 ?
0: 1));
1188 return
yyerror ("Register mismatch");
1191 return
yyerror ("Low reg expected");
1194 | HALF_REG ASSIGN expr
1196 notethat
("LDIMMhalf: pregs_half = imm16\n");
1198 if
(!IS_DREG
($1) && !IS_PREG
($1) && !IS_IREG
($1)
1199 && !IS_MREG
($1) && !IS_BREG
($1) && !IS_LREG
($1))
1200 return
yyerror ("Wrong register for load immediate");
1202 if
(!IS_IMM
($3, 16) && !IS_UIMM
($3, 16))
1203 return
yyerror ("Constant out of range");
1205 $$
= LDIMMHALF_R
(&$1, IS_H
($1), 0, 0, $3);
1210 notethat
("dsp32alu: An = 0\n");
1213 return
yyerror ("0 expected");
1215 $$
= DSP32ALU
(8, 0, 0, 0, 0, 0, 0, 0, IS_A1
($1));
1218 | REG ASSIGN expr xpmod1
1220 if
(!IS_DREG
($1) && !IS_PREG
($1) && !IS_IREG
($1)
1221 && !IS_MREG
($1) && !IS_BREG
($1) && !IS_LREG
($1))
1222 return
yyerror ("Wrong register for load immediate");
1226 /* 7 bit immediate value if possible.
1227 We will check for that constant value for efficiency
1228 If it goes to reloc, it will be 16 bit. */
1229 if
(IS_CONST
($3) && IS_IMM
($3, 7) && IS_DREG
($1))
1231 notethat
("COMPI2opD: dregs = imm7 (x) \n");
1232 $$
= COMPI2OPD
(&$1, imm7
($3), 0);
1234 else if
(IS_CONST
($3) && IS_IMM
($3, 7) && IS_PREG
($1))
1236 notethat
("COMPI2opP: pregs = imm7 (x)\n");
1237 $$
= COMPI2OPP
(&$1, imm7
($3), 0);
1241 if
(IS_CONST
($3) && !IS_IMM
($3, 16))
1242 return
yyerror ("Immediate value out of range");
1244 notethat
("LDIMMhalf: regs = luimm16 (x)\n");
1246 $$
= LDIMMHALF_R5
(&$1, 0, 1, 0, $3);
1251 /* (z) There is no 7 bit zero extended instruction.
1252 If the expr is a relocation, generate it. */
1254 if
(IS_CONST
($3) && !IS_UIMM
($3, 16))
1255 return
yyerror ("Immediate value out of range");
1257 notethat
("LDIMMhalf: regs = luimm16 (x)\n");
1259 $$
= LDIMMHALF_R5
(&$1, 0, 0, 1, $3);
1263 | HALF_REG ASSIGN REG
1266 return
yyerror ("Low reg expected");
1268 if
(IS_DREG
($1) && $3.regno
== REG_A0x
)
1270 notethat
("dsp32alu: dregs_lo = A0.x\n");
1271 $$
= DSP32ALU
(10, 0, 0, &$1, 0, 0, 0, 0, 0);
1273 else if
(IS_DREG
($1) && $3.regno
== REG_A1x
)
1275 notethat
("dsp32alu: dregs_lo = A1.x\n");
1276 $$
= DSP32ALU
(10, 0, 0, &$1, 0, 0, 0, 0, 1);
1279 return
yyerror ("Register mismatch");
1282 | REG ASSIGN REG op_bar_op REG amod0
1284 if
(IS_DREG
($1) && IS_DREG
($3) && IS_DREG
($5))
1286 notethat
("dsp32alu: dregs = dregs .|. dregs (amod0)\n");
1287 $$
= DSP32ALU
(0, 0, 0, &$1, &$3, &$5, $6.s0
, $6.x0
, $4.r0
);
1290 return
yyerror ("Register mismatch");
1293 | REG ASSIGN BYTE_DREG xpmod
1295 if
(IS_DREG
($1) && IS_DREG
($3))
1297 notethat
("ALU2op: dregs = dregs_byte\n");
1298 $$
= ALU2OP
(&$1, &$3, 12 |
($4.r0 ?
0: 1));
1301 return
yyerror ("Register mismatch");
1304 | a_assign ABS REG_A COMMA a_assign ABS REG_A
1306 if
(REG_SAME
($1, $3) && REG_SAME
($5, $7) && !REG_SAME
($1, $5))
1308 notethat
("dsp32alu: A1 = ABS A1 , A0 = ABS A0\n");
1309 $$
= DSP32ALU
(16, 0, 0, 0, 0, 0, 0, 0, 3);
1312 return
yyerror ("Register mismatch");
1315 | a_assign MINUS REG_A COMMA a_assign MINUS REG_A
1317 if
(REG_SAME
($1, $3) && REG_SAME
($5, $7) && !REG_SAME
($1, $5))
1319 notethat
("dsp32alu: A1 = - A1 , A0 = - A0\n");
1320 $$
= DSP32ALU
(14, 0, 0, 0, 0, 0, 0, 0, 3);
1323 return
yyerror ("Register mismatch");
1326 | a_minusassign REG_A w32_or_nothing
1328 if
(!IS_A1
($1) && IS_A1
($2))
1330 notethat
("dsp32alu: A0 -= A1\n");
1331 $$
= DSP32ALU
(11, 0, 0, 0, 0, 0, $3.r0
, 0, 3);
1334 return
yyerror ("Register mismatch");
1337 | REG _MINUS_ASSIGN expr
1339 if
(IS_IREG
($1) && EXPR_VALUE
($3) == 4)
1341 notethat
("dagMODik: iregs -= 4\n");
1342 $$
= DAGMODIK
(&$1, 3);
1344 else if
(IS_IREG
($1) && EXPR_VALUE
($3) == 2)
1346 notethat
("dagMODik: iregs -= 2\n");
1347 $$
= DAGMODIK
(&$1, 1);
1350 return
yyerror ("Register or value mismatch");
1353 | REG _PLUS_ASSIGN REG LPAREN BREV RPAREN
1355 if
(IS_IREG
($1) && IS_MREG
($3))
1357 notethat
("dagMODim: iregs += mregs (opt_brev)\n");
1359 $$
= DAGMODIM
(&$1, &$3, 0, 1);
1361 else if
(IS_PREG
($1) && IS_PREG
($3))
1363 notethat
("PTR2op: pregs += pregs (BREV )\n");
1364 $$
= PTR2OP
(&$1, &$3, 5);
1367 return
yyerror ("Register mismatch");
1370 | REG _MINUS_ASSIGN REG
1372 if
(IS_IREG
($1) && IS_MREG
($3))
1374 notethat
("dagMODim: iregs -= mregs\n");
1375 $$
= DAGMODIM
(&$1, &$3, 1, 0);
1377 else if
(IS_PREG
($1) && IS_PREG
($3))
1379 notethat
("PTR2op: pregs -= pregs\n");
1380 $$
= PTR2OP
(&$1, &$3, 0);
1383 return
yyerror ("Register mismatch");
1386 | REG_A _PLUS_ASSIGN REG_A w32_or_nothing
1388 if
(!IS_A1
($1) && IS_A1
($3))
1390 notethat
("dsp32alu: A0 += A1 (W32)\n");
1391 $$
= DSP32ALU
(11, 0, 0, 0, 0, 0, $4.r0
, 0, 2);
1394 return
yyerror ("Register mismatch");
1397 | REG _PLUS_ASSIGN REG
1399 if
(IS_IREG
($1) && IS_MREG
($3))
1401 notethat
("dagMODim: iregs += mregs\n");
1402 $$
= DAGMODIM
(&$1, &$3, 0, 0);
1405 return
yyerror ("iregs += mregs expected");
1408 | REG _PLUS_ASSIGN expr
1412 if
(EXPR_VALUE
($3) == 4)
1414 notethat
("dagMODik: iregs += 4\n");
1415 $$
= DAGMODIK
(&$1, 2);
1417 else if
(EXPR_VALUE
($3) == 2)
1419 notethat
("dagMODik: iregs += 2\n");
1420 $$
= DAGMODIK
(&$1, 0);
1423 return
yyerror ("iregs += [ 2 | 4 ");
1425 else if
(IS_PREG
($1) && IS_IMM
($3, 7))
1427 notethat
("COMPI2opP: pregs += imm7\n");
1428 $$
= COMPI2OPP
(&$1, imm7
($3), 1);
1430 else if
(IS_DREG
($1) && IS_IMM
($3, 7))
1432 notethat
("COMPI2opD: dregs += imm7\n");
1433 $$
= COMPI2OPD
(&$1, imm7
($3), 1);
1435 else if
((IS_DREG
($1) || IS_PREG
($1)) && IS_CONST
($3))
1436 return
yyerror ("Immediate value out of range");
1438 return
yyerror ("Register mismatch");
1441 | REG _STAR_ASSIGN REG
1443 if
(IS_DREG
($1) && IS_DREG
($3))
1445 notethat
("ALU2op: dregs *= dregs\n");
1446 $$
= ALU2OP
(&$1, &$3, 3);
1449 return
yyerror ("Register mismatch");
1452 | SAA LPAREN REG COLON expr COMMA REG COLON expr RPAREN aligndir
1454 if
(!valid_dreg_pair
(&$3, $5))
1455 return
yyerror ("Bad dreg pair");
1456 else if
(!valid_dreg_pair
(&$7, $9))
1457 return
yyerror ("Bad dreg pair");
1460 notethat
("dsp32alu: SAA (dregs_pair , dregs_pair ) (aligndir)\n");
1461 $$
= DSP32ALU
(18, 0, 0, 0, &$3, &$7, $11.r0
, 0, 0);
1465 | a_assign REG_A LPAREN S RPAREN COMMA a_assign REG_A LPAREN S RPAREN
1467 if
(REG_SAME
($1, $2) && REG_SAME
($7, $8) && !REG_SAME
($1, $7))
1469 notethat
("dsp32alu: A1 = A1 (S) , A0 = A0 (S)\n");
1470 $$
= DSP32ALU
(8, 0, 0, 0, 0, 0, 1, 0, 2);
1473 return
yyerror ("Register mismatch");
1476 | REG ASSIGN LPAREN REG PLUS REG RPAREN LESS_LESS expr
1478 if
(IS_DREG
($1) && IS_DREG
($4) && IS_DREG
($6)
1479 && REG_SAME
($1, $4))
1481 if
(EXPR_VALUE
($9) == 1)
1483 notethat
("ALU2op: dregs = (dregs + dregs) << 1\n");
1484 $$
= ALU2OP
(&$1, &$6, 4);
1486 else if
(EXPR_VALUE
($9) == 2)
1488 notethat
("ALU2op: dregs = (dregs + dregs) << 2\n");
1489 $$
= ALU2OP
(&$1, &$6, 5);
1492 return
yyerror ("Bad shift value");
1494 else if
(IS_PREG
($1) && IS_PREG
($4) && IS_PREG
($6)
1495 && REG_SAME
($1, $4))
1497 if
(EXPR_VALUE
($9) == 1)
1499 notethat
("PTR2op: pregs = (pregs + pregs) << 1\n");
1500 $$
= PTR2OP
(&$1, &$6, 6);
1502 else if
(EXPR_VALUE
($9) == 2)
1504 notethat
("PTR2op: pregs = (pregs + pregs) << 2\n");
1505 $$
= PTR2OP
(&$1, &$6, 7);
1508 return
yyerror ("Bad shift value");
1511 return
yyerror ("Register mismatch");
1515 | REG ASSIGN REG BAR REG
1517 if
(IS_DREG
($1) && IS_DREG
($3) && IS_DREG
($5))
1519 notethat
("COMP3op: dregs = dregs | dregs\n");
1520 $$
= COMP3OP
(&$1, &$3, &$5, 3);
1523 return
yyerror ("Dregs expected");
1525 | REG ASSIGN REG CARET REG
1527 if
(IS_DREG
($1) && IS_DREG
($3) && IS_DREG
($5))
1529 notethat
("COMP3op: dregs = dregs ^ dregs\n");
1530 $$
= COMP3OP
(&$1, &$3, &$5, 4);
1533 return
yyerror ("Dregs expected");
1535 | REG ASSIGN REG PLUS LPAREN REG LESS_LESS expr RPAREN
1537 if
(IS_PREG
($1) && IS_PREG
($3) && IS_PREG
($6))
1539 if
(EXPR_VALUE
($8) == 1)
1541 notethat
("COMP3op: pregs = pregs + (pregs << 1)\n");
1542 $$
= COMP3OP
(&$1, &$3, &$6, 6);
1544 else if
(EXPR_VALUE
($8) == 2)
1546 notethat
("COMP3op: pregs = pregs + (pregs << 2)\n");
1547 $$
= COMP3OP
(&$1, &$3, &$6, 7);
1550 return
yyerror ("Bad shift value");
1553 return
yyerror ("Dregs expected");
1555 | CCREG ASSIGN REG_A _ASSIGN_ASSIGN REG_A
1557 if
(!REG_SAME
($3, $5))
1559 notethat
("CCflag: CC = A0 == A1\n");
1560 $$
= CCFLAG
(0, 0, 5, 0, 0);
1563 return
yyerror ("CC register expected");
1565 | CCREG ASSIGN REG_A LESS_THAN REG_A
1567 if
(!REG_SAME
($3, $5))
1569 notethat
("CCflag: CC = A0 < A1\n");
1570 $$
= CCFLAG
(0, 0, 6, 0, 0);
1573 return
yyerror ("Register mismatch");
1575 | CCREG ASSIGN REG LESS_THAN REG iu_or_nothing
1577 if
(REG_CLASS
($3) == REG_CLASS
($5))
1579 notethat
("CCflag: CC = dpregs < dpregs\n");
1580 $$
= CCFLAG
(&$3, $5.regno
& CODE_MASK
, $6.r0
, 0, IS_PREG
($3) ?
1 : 0);
1583 return
yyerror ("Compare only of same register class");
1585 | CCREG ASSIGN REG LESS_THAN expr iu_or_nothing
1587 if
(($6.r0
== 1 && IS_IMM
($5, 3))
1588 ||
($6.r0
== 3 && IS_UIMM
($5, 3)))
1590 notethat
("CCflag: CC = dpregs < (u)imm3\n");
1591 $$
= CCFLAG
(&$3, imm3
($5), $6.r0
, 1, IS_PREG
($3) ?
1 : 0);
1594 return
yyerror ("Bad constant value");
1596 | CCREG ASSIGN REG _ASSIGN_ASSIGN REG
1598 if
(REG_CLASS
($3) == REG_CLASS
($5))
1600 notethat
("CCflag: CC = dpregs == dpregs\n");
1601 $$
= CCFLAG
(&$3, $5.regno
& CODE_MASK
, 0, 0, IS_PREG
($3) ?
1 : 0);
1604 | CCREG ASSIGN REG _ASSIGN_ASSIGN expr
1608 notethat
("CCflag: CC = dpregs == imm3\n");
1609 $$
= CCFLAG
(&$3, imm3
($5), 0, 1, IS_PREG
($3) ?
1 : 0);
1612 return
yyerror ("Bad constant range");
1614 | CCREG ASSIGN REG_A _LESS_THAN_ASSIGN REG_A
1616 if
(!REG_SAME
($3, $5))
1618 notethat
("CCflag: CC = A0 <= A1\n");
1619 $$
= CCFLAG
(0, 0, 7, 0, 0);
1622 return
yyerror ("CC register expected");
1624 | CCREG ASSIGN REG _LESS_THAN_ASSIGN REG iu_or_nothing
1626 if
(REG_CLASS
($3) == REG_CLASS
($5))
1628 notethat
("CCflag: CC = pregs <= pregs (..)\n");
1629 $$
= CCFLAG
(&$3, $5.regno
& CODE_MASK
,
1630 1 + $6.r0
, 0, IS_PREG
($3) ?
1 : 0);
1633 return
yyerror ("Compare only of same register class");
1635 | CCREG ASSIGN REG _LESS_THAN_ASSIGN expr iu_or_nothing
1637 if
(($6.r0
== 1 && IS_IMM
($5, 3))
1638 ||
($6.r0
== 3 && IS_UIMM
($5, 3)))
1642 notethat
("CCflag: CC = dregs <= (u)imm3\n");
1644 $$
= CCFLAG
(&$3, imm3
($5), 1 + $6.r0
, 1, 0);
1646 else if
(IS_PREG
($3))
1648 notethat
("CCflag: CC = pregs <= (u)imm3\n");
1650 $$
= CCFLAG
(&$3, imm3
($5), 1 + $6.r0
, 1, 1);
1653 return
yyerror ("Dreg or Preg expected");
1656 return
yyerror ("Bad constant value");
1659 | REG ASSIGN REG AMPERSAND REG
1661 if
(IS_DREG
($1) && IS_DREG
($3) && IS_DREG
($5))
1663 notethat
("COMP3op: dregs = dregs & dregs\n");
1664 $$
= COMP3OP
(&$1, &$3, &$5, 2);
1667 return
yyerror ("Dregs expected");
1672 notethat
("CC2stat operation\n");
1673 $$
= bfin_gen_cc2stat
($1.r0
, $1.x0
, $1.s0
);
1678 if
(IS_ALLREG
($1) && IS_ALLREG
($3))
1680 notethat
("REGMV: allregs = allregs\n");
1681 $$
= bfin_gen_regmv
(&$3, &$1);
1684 return
yyerror ("Register mismatch");
1691 notethat
("CC2dreg: CC = dregs\n");
1692 $$
= bfin_gen_cc2dreg
(1, &$3);
1695 return
yyerror ("Register mismatch");
1702 notethat
("CC2dreg: dregs = CC\n");
1703 $$
= bfin_gen_cc2dreg
(0, &$1);
1706 return
yyerror ("Register mismatch");
1709 | CCREG _ASSIGN_BANG CCREG
1711 notethat
("CC2dreg: CC =! CC\n");
1712 $$
= bfin_gen_cc2dreg
(3, 0);
1717 | HALF_REG ASSIGN multiply_halfregs opt_mode
1719 notethat
("dsp32mult: dregs_half = multiply_halfregs (opt_mode)\n");
1721 if
(!IS_H
($1) && $4.MM
)
1722 return
yyerror ("(M) not allowed with MAC0");
1726 $$
= DSP32MULT
(0, $4.MM
, $4.mod
, 1, 0,
1727 IS_H
($3.s0
), IS_H
($3.s1
), 0, 0,
1728 &$1, 0, &$3.s0
, &$3.s1
, 0);
1732 $$
= DSP32MULT
(0, 0, $4.mod
, 0, 0,
1733 0, 0, IS_H
($3.s0
), IS_H
($3.s1
),
1734 &$1, 0, &$3.s0
, &$3.s1
, 1);
1738 | REG ASSIGN multiply_halfregs opt_mode
1740 /* Odd registers can use (M). */
1742 return
yyerror ("Dreg expected");
1744 if
(IS_EVEN
($1) && $4.MM
)
1745 return
yyerror ("(M) not allowed with MAC0");
1749 notethat
("dsp32mult: dregs = multiply_halfregs (opt_mode)\n");
1751 $$
= DSP32MULT
(0, $4.MM
, $4.mod
, 1, 1,
1752 IS_H
($3.s0
), IS_H
($3.s1
), 0, 0,
1753 &$1, 0, &$3.s0
, &$3.s1
, 0);
1757 notethat
("dsp32mult: dregs = multiply_halfregs opt_mode\n");
1758 $$
= DSP32MULT
(0, 0, $4.mod
, 0, 1,
1759 0, 0, IS_H
($3.s0
), IS_H
($3.s1
),
1760 &$1, 0, &$3.s0
, &$3.s1
, 1);
1764 | HALF_REG ASSIGN multiply_halfregs opt_mode COMMA
1765 HALF_REG ASSIGN multiply_halfregs opt_mode
1767 if
(!IS_DREG
($1) ||
!IS_DREG
($6))
1768 return
yyerror ("Dregs expected");
1770 if
(!IS_HCOMPL
($1, $6))
1771 return
yyerror ("Dest registers mismatch");
1773 if
(check_multiply_halfregs
(&$3, &$8) < 0)
1776 if
((!IS_H
($1) && $4.MM
)
1777 ||
(!IS_H
($6) && $9.MM
))
1778 return
yyerror ("(M) not allowed with MAC0");
1780 notethat
("dsp32mult: dregs_hi = multiply_halfregs mxd_mod, "
1781 "dregs_lo = multiply_halfregs opt_mode\n");
1784 $$
= DSP32MULT
(0, $4.MM
, $9.mod
, 1, 0,
1785 IS_H
($3.s0
), IS_H
($3.s1
), IS_H
($8.s0
), IS_H
($8.s1
),
1786 &$1, 0, &$3.s0
, &$3.s1
, 1);
1788 $$
= DSP32MULT
(0, $9.MM
, $9.mod
, 1, 0,
1789 IS_H
($8.s0
), IS_H
($8.s1
), IS_H
($3.s0
), IS_H
($3.s1
),
1790 &$1, 0, &$3.s0
, &$3.s1
, 1);
1793 | REG ASSIGN multiply_halfregs opt_mode COMMA REG ASSIGN multiply_halfregs opt_mode
1795 if
(!IS_DREG
($1) ||
!IS_DREG
($6))
1796 return
yyerror ("Dregs expected");
1798 if
((IS_EVEN
($1) && $6.regno
- $1.regno
!= 1)
1799 ||
(IS_EVEN
($6) && $1.regno
- $6.regno
!= 1))
1800 return
yyerror ("Dest registers mismatch");
1802 if
(check_multiply_halfregs
(&$3, &$8) < 0)
1805 if
((IS_EVEN
($1) && $4.MM
)
1806 ||
(IS_EVEN
($6) && $9.MM
))
1807 return
yyerror ("(M) not allowed with MAC0");
1809 notethat
("dsp32mult: dregs = multiply_halfregs mxd_mod, "
1810 "dregs = multiply_halfregs opt_mode\n");
1813 $$
= DSP32MULT
(0, $9.MM
, $9.mod
, 1, 1,
1814 IS_H
($8.s0
), IS_H
($8.s1
), IS_H
($3.s0
), IS_H
($3.s1
),
1815 &$1, 0, &$3.s0
, &$3.s1
, 1);
1817 $$
= DSP32MULT
(0, $4.MM
, $9.mod
, 1, 1,
1818 IS_H
($3.s0
), IS_H
($3.s1
), IS_H
($8.s0
), IS_H
($8.s1
),
1819 &$1, 0, &$3.s0
, &$3.s1
, 1);
1824 | a_assign ASHIFT REG_A BY HALF_REG
1826 if
(!REG_SAME
($1, $3))
1827 return
yyerror ("Aregs must be same");
1829 if
(IS_DREG
($5) && !IS_H
($5))
1831 notethat
("dsp32shift: A0 = ASHIFT A0 BY dregs_lo\n");
1832 $$
= DSP32SHIFT
(3, 0, &$5, 0, 0, IS_A1
($1));
1835 return
yyerror ("Dregs expected");
1838 | HALF_REG ASSIGN ASHIFT HALF_REG BY HALF_REG smod
1840 if
(IS_DREG
($6) && !IS_H
($6))
1842 notethat
("dsp32shift: dregs_half = ASHIFT dregs_half BY dregs_lo\n");
1843 $$
= DSP32SHIFT
(0, &$1, &$6, &$4, $7.s0
, HL2
($1, $4));
1846 return
yyerror ("Dregs expected");
1849 | a_assign REG_A LESS_LESS expr
1851 if
(!REG_SAME
($1, $2))
1852 return
yyerror ("Aregs must be same");
1854 if
(IS_UIMM
($4, 5))
1856 notethat
("dsp32shiftimm: A0 = A0 << uimm5\n");
1857 $$
= DSP32SHIFTIMM
(3, 0, imm5
($4), 0, 0, IS_A1
($1));
1860 return
yyerror ("Bad shift value");
1863 | REG ASSIGN REG LESS_LESS expr vsmod
1865 if
(IS_DREG
($1) && IS_DREG
($3) && IS_UIMM
($5, 5))
1870 notethat
("dsp32shiftimm: dregs = dregs << expr (V, .)\n");
1871 $$
= DSP32SHIFTIMM
(1, &$1, imm4
($5), &$3, $6.s0 ?
1 : 2, 0);
1875 notethat
("dsp32shiftimm: dregs = dregs << uimm5 (.)\n");
1876 $$
= DSP32SHIFTIMM
(2, &$1, imm6
($5), &$3, $6.s0 ?
1 : 2, 0);
1879 else if
($6.s0
== 0 && IS_PREG
($1) && IS_PREG
($3))
1881 if
(EXPR_VALUE
($5) == 2)
1883 notethat
("PTR2op: pregs = pregs << 2\n");
1884 $$
= PTR2OP
(&$1, &$3, 1);
1886 else if
(EXPR_VALUE
($5) == 1)
1888 notethat
("COMP3op: pregs = pregs << 1\n");
1889 $$
= COMP3OP
(&$1, &$3, &$3, 5);
1892 return
yyerror ("Bad shift value");
1895 return
yyerror ("Bad shift value or register");
1897 | HALF_REG ASSIGN HALF_REG LESS_LESS expr
1899 if
(IS_UIMM
($5, 4))
1901 notethat
("dsp32shiftimm: dregs_half = dregs_half << uimm4\n");
1902 $$
= DSP32SHIFTIMM
(0x0, &$1, imm5
($5), &$3, 2, HL2
($1, $3));
1905 return
yyerror ("Bad shift value");
1907 | HALF_REG ASSIGN HALF_REG LESS_LESS expr smod
1909 if
(IS_UIMM
($5, 4))
1911 notethat
("dsp32shiftimm: dregs_half = dregs_half << uimm4\n");
1912 $$
= DSP32SHIFTIMM
(0x0, &$1, imm5
($5), &$3, $6.s0
, HL2
($1, $3));
1915 return
yyerror ("Bad shift value");
1917 | REG ASSIGN ASHIFT REG BY HALF_REG vsmod
1921 if
(IS_DREG
($1) && IS_DREG
($4) && IS_DREG
($6) && !IS_H
($6))
1926 notethat
("dsp32shift: dregs = ASHIFT dregs BY "
1927 "dregs_lo (V, .)\n");
1933 notethat
("dsp32shift: dregs = ASHIFT dregs BY dregs_lo (.)\n");
1935 $$
= DSP32SHIFT
(op
, &$1, &$6, &$4, $7.s0
, 0);
1938 return
yyerror ("Dregs expected");
1942 | HALF_REG ASSIGN EXPADJ LPAREN REG COMMA HALF_REG RPAREN vmod
1944 if
(IS_DREG_L
($1) && IS_DREG_L
($5) && IS_DREG_L
($7))
1946 notethat
("dsp32shift: dregs_lo = EXPADJ (dregs , dregs_lo )\n");
1947 $$
= DSP32SHIFT
(7, &$1, &$7, &$5, $9.r0
, 0);
1950 return
yyerror ("Bad shift value or register");
1954 | HALF_REG ASSIGN EXPADJ LPAREN HALF_REG COMMA HALF_REG RPAREN
1956 if
(IS_DREG_L
($1) && IS_DREG_L
($5) && IS_DREG_L
($7))
1958 notethat
("dsp32shift: dregs_lo = EXPADJ (dregs_lo, dregs_lo)\n");
1959 $$
= DSP32SHIFT
(7, &$1, &$7, &$5, 2, 0);
1961 else if
(IS_DREG_L
($1) && IS_DREG_H
($5) && IS_DREG_L
($7))
1963 notethat
("dsp32shift: dregs_lo = EXPADJ (dregs_hi, dregs_lo)\n");
1964 $$
= DSP32SHIFT
(7, &$1, &$7, &$5, 3, 0);
1967 return
yyerror ("Bad shift value or register");
1972 | REG ASSIGN DEPOSIT LPAREN REG COMMA REG RPAREN
1974 if
(IS_DREG
($1) && IS_DREG
($5) && IS_DREG
($7))
1976 notethat
("dsp32shift: dregs = DEPOSIT (dregs , dregs )\n");
1977 $$
= DSP32SHIFT
(10, &$1, &$7, &$5, 2, 0);
1980 return
yyerror ("Register mismatch");
1983 | REG ASSIGN DEPOSIT LPAREN REG COMMA REG RPAREN LPAREN X RPAREN
1985 if
(IS_DREG
($1) && IS_DREG
($5) && IS_DREG
($7))
1987 notethat
("dsp32shift: dregs = DEPOSIT (dregs , dregs ) (X)\n");
1988 $$
= DSP32SHIFT
(10, &$1, &$7, &$5, 3, 0);
1991 return
yyerror ("Register mismatch");
1994 | REG ASSIGN EXTRACT LPAREN REG COMMA HALF_REG RPAREN xpmod
1996 if
(IS_DREG
($1) && IS_DREG
($5) && IS_DREG_L
($7))
1998 notethat
("dsp32shift: dregs = EXTRACT (dregs, dregs_lo ) (.)\n");
1999 $$
= DSP32SHIFT
(10, &$1, &$7, &$5, $9.r0
, 0);
2002 return
yyerror ("Register mismatch");
2005 | a_assign REG_A _GREATER_GREATER_GREATER expr
2007 if
(!REG_SAME
($1, $2))
2008 return
yyerror ("Aregs must be same");
2010 if
(IS_UIMM
($4, 5))
2012 notethat
("dsp32shiftimm: Ax = Ax >>> uimm5\n");
2013 $$
= DSP32SHIFTIMM
(3, 0, -imm6
($4), 0, 0, IS_A1
($1));
2016 return
yyerror ("Shift value range error");
2018 | a_assign LSHIFT REG_A BY HALF_REG
2020 if
(REG_SAME
($1, $3) && IS_DREG_L
($5))
2022 notethat
("dsp32shift: Ax = LSHIFT Ax BY dregs_lo\n");
2023 $$
= DSP32SHIFT
(3, 0, &$5, 0, 1, IS_A1
($1));
2026 return
yyerror ("Register mismatch");
2029 | HALF_REG ASSIGN LSHIFT HALF_REG BY HALF_REG
2031 if
(IS_DREG
($1) && IS_DREG
($4) && IS_DREG_L
($6))
2033 notethat
("dsp32shift: dregs_lo = LSHIFT dregs_hi BY dregs_lo\n");
2034 $$
= DSP32SHIFT
(0, &$1, &$6, &$4, 2, HL2
($1, $4));
2037 return
yyerror ("Register mismatch");
2040 | REG ASSIGN LSHIFT REG BY HALF_REG vmod
2042 if
(IS_DREG
($1) && IS_DREG
($4) && IS_DREG_L
($6))
2044 notethat
("dsp32shift: dregs = LSHIFT dregs BY dregs_lo (V )\n");
2045 $$
= DSP32SHIFT
($7.r0 ?
1: 2, &$1, &$6, &$4, 2, 0);
2048 return
yyerror ("Register mismatch");
2051 | REG ASSIGN SHIFT REG BY HALF_REG
2053 if
(IS_DREG
($1) && IS_DREG
($4) && IS_DREG_L
($6))
2055 notethat
("dsp32shift: dregs = SHIFT dregs BY dregs_lo\n");
2056 $$
= DSP32SHIFT
(2, &$1, &$6, &$4, 2, 0);
2059 return
yyerror ("Register mismatch");
2062 | a_assign REG_A GREATER_GREATER expr
2064 if
(REG_SAME
($1, $2) && IS_IMM
($4, 6) >= 0)
2066 notethat
("dsp32shiftimm: Ax = Ax >> imm6\n");
2067 $$
= DSP32SHIFTIMM
(3, 0, -imm6
($4), 0, 1, IS_A1
($1));
2070 return
yyerror ("Accu register expected");
2073 | REG ASSIGN REG GREATER_GREATER expr vmod
2077 if
(IS_DREG
($1) && IS_DREG
($3) && IS_UIMM
($5, 5))
2079 notethat
("dsp32shiftimm: dregs = dregs >> uimm5 (V)\n");
2080 $$
= DSP32SHIFTIMM
(1, &$1, -uimm5
($5), &$3, 2, 0);
2083 return
yyerror ("Register mismatch");
2087 if
(IS_DREG
($1) && IS_DREG
($3) && IS_UIMM
($5, 5))
2089 notethat
("dsp32shiftimm: dregs = dregs >> uimm5\n");
2090 $$
= DSP32SHIFTIMM
(2, &$1, -imm6
($5), &$3, 2, 0);
2092 else if
(IS_PREG
($1) && IS_PREG
($3) && EXPR_VALUE
($5) == 2)
2094 notethat
("PTR2op: pregs = pregs >> 2\n");
2095 $$
= PTR2OP
(&$1, &$3, 3);
2097 else if
(IS_PREG
($1) && IS_PREG
($3) && EXPR_VALUE
($5) == 1)
2099 notethat
("PTR2op: pregs = pregs >> 1\n");
2100 $$
= PTR2OP
(&$1, &$3, 4);
2103 return
yyerror ("Register mismatch");
2106 | HALF_REG ASSIGN HALF_REG GREATER_GREATER expr
2108 if
(IS_UIMM
($5, 5))
2110 notethat
("dsp32shiftimm: dregs_half = dregs_half >> uimm5\n");
2111 $$
= DSP32SHIFTIMM
(0, &$1, -uimm5
($5), &$3, 2, HL2
($1, $3));
2114 return
yyerror ("Register mismatch");
2116 | HALF_REG ASSIGN HALF_REG _GREATER_GREATER_GREATER expr smod
2118 if
(IS_UIMM
($5, 5))
2120 notethat
("dsp32shiftimm: dregs_half = dregs_half >>> uimm5\n");
2121 $$
= DSP32SHIFTIMM
(0, &$1, -uimm5
($5), &$3,
2122 $6.s0
, HL2
($1, $3));
2125 return
yyerror ("Register or modifier mismatch");
2129 | REG ASSIGN REG _GREATER_GREATER_GREATER expr vsmod
2131 if
(IS_DREG
($1) && IS_DREG
($3) && IS_UIMM
($5, 5))
2136 notethat
("dsp32shiftimm: dregs = dregs >>> uimm5 (V, .)\n");
2137 $$
= DSP32SHIFTIMM
(1, &$1, -uimm5
($5), &$3, $6.s0
, 0);
2141 notethat
("dsp32shiftimm: dregs = dregs >>> uimm5 (.)\n");
2142 $$
= DSP32SHIFTIMM
(2, &$1, -uimm5
($5), &$3, $6.s0
, 0);
2146 return
yyerror ("Register mismatch");
2149 | HALF_REG ASSIGN ONES REG
2151 if
(IS_DREG_L
($1) && IS_DREG
($4))
2153 notethat
("dsp32shift: dregs_lo = ONES dregs\n");
2154 $$
= DSP32SHIFT
(6, &$1, 0, &$4, 3, 0);
2157 return
yyerror ("Register mismatch");
2160 | REG ASSIGN PACK LPAREN HALF_REG COMMA HALF_REG RPAREN
2162 if
(IS_DREG
($1) && IS_DREG
($5) && IS_DREG
($7))
2164 notethat
("dsp32shift: dregs = PACK (dregs_hi , dregs_hi )\n");
2165 $$
= DSP32SHIFT
(4, &$1, &$7, &$5, HL2
($5, $7), 0);
2168 return
yyerror ("Register mismatch");
2171 | HALF_REG ASSIGN CCREG ASSIGN BXORSHIFT LPAREN REG_A COMMA REG RPAREN
2174 && $7.regno
== REG_A0
2175 && IS_DREG
($9) && !IS_H
($1) && !IS_A1
($7))
2177 notethat
("dsp32shift: dregs_lo = CC = BXORSHIFT (A0 , dregs )\n");
2178 $$
= DSP32SHIFT
(11, &$1, &$9, 0, 0, 0);
2181 return
yyerror ("Register mismatch");
2184 | HALF_REG ASSIGN CCREG ASSIGN BXOR LPAREN REG_A COMMA REG RPAREN
2187 && $7.regno
== REG_A0
2188 && IS_DREG
($9) && !IS_H
($1) && !IS_A1
($7))
2190 notethat
("dsp32shift: dregs_lo = CC = BXOR (A0 , dregs)\n");
2191 $$
= DSP32SHIFT
(11, &$1, &$9, 0, 1, 0);
2194 return
yyerror ("Register mismatch");
2197 | HALF_REG ASSIGN CCREG ASSIGN BXOR LPAREN REG_A COMMA REG_A COMMA CCREG RPAREN
2199 if
(IS_DREG
($1) && !IS_H
($1) && !REG_SAME
($7, $9))
2201 notethat
("dsp32shift: dregs_lo = CC = BXOR (A0 , A1 , CC)\n");
2202 $$
= DSP32SHIFT
(12, &$1, 0, 0, 1, 0);
2205 return
yyerror ("Register mismatch");
2208 | a_assign ROT REG_A BY HALF_REG
2210 if
(REG_SAME
($1, $3) && IS_DREG_L
($5))
2212 notethat
("dsp32shift: Ax = ROT Ax BY dregs_lo\n");
2213 $$
= DSP32SHIFT
(3, 0, &$5, 0, 2, IS_A1
($1));
2216 return
yyerror ("Register mismatch");
2219 | REG ASSIGN ROT REG BY HALF_REG
2221 if
(IS_DREG
($1) && IS_DREG
($4) && IS_DREG_L
($6))
2223 notethat
("dsp32shift: dregs = ROT dregs BY dregs_lo\n");
2224 $$
= DSP32SHIFT
(2, &$1, &$6, &$4, 3, 0);
2227 return
yyerror ("Register mismatch");
2230 | a_assign ROT REG_A BY expr
2234 notethat
("dsp32shiftimm: An = ROT An BY imm6\n");
2235 $$
= DSP32SHIFTIMM
(3, 0, imm6
($5), 0, 2, IS_A1
($1));
2238 return
yyerror ("Register mismatch");
2241 | REG ASSIGN ROT REG BY expr
2243 if
(IS_DREG
($1) && IS_DREG
($4) && IS_IMM
($6, 6))
2245 $$
= DSP32SHIFTIMM
(2, &$1, imm6
($6), &$4, 3, IS_A1
($1));
2248 return
yyerror ("Register mismatch");
2251 | HALF_REG ASSIGN SIGNBITS REG_A
2255 notethat
("dsp32shift: dregs_lo = SIGNBITS An\n");
2256 $$
= DSP32SHIFT
(6, &$1, 0, 0, IS_A1
($4), 0);
2259 return
yyerror ("Register mismatch");
2262 | HALF_REG ASSIGN SIGNBITS REG
2264 if
(IS_DREG_L
($1) && IS_DREG
($4))
2266 notethat
("dsp32shift: dregs_lo = SIGNBITS dregs\n");
2267 $$
= DSP32SHIFT
(5, &$1, 0, &$4, 0, 0);
2270 return
yyerror ("Register mismatch");
2273 | HALF_REG ASSIGN SIGNBITS HALF_REG
2277 notethat
("dsp32shift: dregs_lo = SIGNBITS dregs_lo\n");
2278 $$
= DSP32SHIFT
(5, &$1, 0, &$4, 1 + IS_H
($4), 0);
2281 return
yyerror ("Register mismatch");
2284 /* The ASR bit is just inverted here. */
2285 | HALF_REG ASSIGN VIT_MAX LPAREN REG RPAREN asr_asl
2287 if
(IS_DREG_L
($1) && IS_DREG
($5))
2289 notethat
("dsp32shift: dregs_lo = VIT_MAX (dregs) (..)\n");
2290 $$
= DSP32SHIFT
(9, &$1, 0, &$5, ($7.r0 ?
0 : 1), 0);
2293 return
yyerror ("Register mismatch");
2296 | REG ASSIGN VIT_MAX LPAREN REG COMMA REG RPAREN asr_asl
2298 if
(IS_DREG
($1) && IS_DREG
($5) && IS_DREG
($7))
2300 notethat
("dsp32shift: dregs = VIT_MAX (dregs, dregs) (ASR)\n");
2301 $$
= DSP32SHIFT
(9, &$1, &$7, &$5, 2 |
($9.r0 ?
0 : 1), 0);
2304 return
yyerror ("Register mismatch");
2307 | BITMUX LPAREN REG COMMA REG COMMA REG_A RPAREN asr_asl
2309 if
(IS_DREG
($3) && IS_DREG
($5) && !IS_A1
($7))
2311 notethat
("dsp32shift: BITMUX (dregs , dregs , A0) (ASR)\n");
2312 $$
= DSP32SHIFT
(8, 0, &$3, &$5, $9.r0
, 0);
2315 return
yyerror ("Register mismatch");
2318 | a_assign BXORSHIFT LPAREN REG_A COMMA REG_A COMMA CCREG RPAREN
2320 if
(!IS_A1
($1) && !IS_A1
($4) && IS_A1
($6))
2322 notethat
("dsp32shift: A0 = BXORSHIFT (A0 , A1 , CC )\n");
2323 $$
= DSP32SHIFT
(12, 0, 0, 0, 0, 0);
2326 return
yyerror ("Dregs expected");
2330 /* LOGI2op: BITCLR (dregs, uimm5). */
2331 | BITCLR LPAREN REG COMMA expr RPAREN
2333 if
(IS_DREG
($3) && IS_UIMM
($5, 5))
2335 notethat
("LOGI2op: BITCLR (dregs , uimm5 )\n");
2336 $$
= LOGI2OP
($3, uimm5
($5), 4);
2339 return
yyerror ("Register mismatch");
2342 /* LOGI2op: BITSET (dregs, uimm5). */
2343 | BITSET LPAREN REG COMMA expr RPAREN
2345 if
(IS_DREG
($3) && IS_UIMM
($5, 5))
2347 notethat
("LOGI2op: BITCLR (dregs , uimm5 )\n");
2348 $$
= LOGI2OP
($3, uimm5
($5), 2);
2351 return
yyerror ("Register mismatch");
2354 /* LOGI2op: BITTGL (dregs, uimm5). */
2355 | BITTGL LPAREN REG COMMA expr RPAREN
2357 if
(IS_DREG
($3) && IS_UIMM
($5, 5))
2359 notethat
("LOGI2op: BITCLR (dregs , uimm5 )\n");
2360 $$
= LOGI2OP
($3, uimm5
($5), 3);
2363 return
yyerror ("Register mismatch");
2366 | CCREG _ASSIGN_BANG BITTST LPAREN REG COMMA expr RPAREN
2368 if
(IS_DREG
($5) && IS_UIMM
($7, 5))
2370 notethat
("LOGI2op: CC =! BITTST (dregs , uimm5 )\n");
2371 $$
= LOGI2OP
($5, uimm5
($7), 0);
2374 return
yyerror ("Register mismatch or value error");
2377 | CCREG ASSIGN BITTST LPAREN REG COMMA expr RPAREN
2379 if
(IS_DREG
($5) && IS_UIMM
($7, 5))
2381 notethat
("LOGI2op: CC = BITTST (dregs , uimm5 )\n");
2382 $$
= LOGI2OP
($5, uimm5
($7), 1);
2385 return
yyerror ("Register mismatch or value error");
2388 | IF BANG CCREG REG ASSIGN REG
2390 if
((IS_DREG
($4) || IS_PREG
($4))
2391 && (IS_DREG
($6) || IS_PREG
($6)))
2393 notethat
("ccMV: IF ! CC gregs = gregs\n");
2394 $$
= CCMV
(&$6, &$4, 0);
2397 return
yyerror ("Register mismatch");
2400 | IF CCREG REG ASSIGN REG
2402 if
((IS_DREG
($5) || IS_PREG
($5))
2403 && (IS_DREG
($3) || IS_PREG
($3)))
2405 notethat
("ccMV: IF CC gregs = gregs\n");
2406 $$
= CCMV
(&$5, &$3, 1);
2409 return
yyerror ("Register mismatch");
2412 | IF BANG CCREG JUMP expr
2414 if
(IS_PCREL10
($5))
2416 notethat
("BRCC: IF !CC JUMP pcrel11m2\n");
2417 $$
= BRCC
(0, 0, $5);
2420 return
yyerror ("Bad jump offset");
2423 | IF BANG CCREG JUMP expr LPAREN BP RPAREN
2425 if
(IS_PCREL10
($5))
2427 notethat
("BRCC: IF !CC JUMP pcrel11m2\n");
2428 $$
= BRCC
(0, 1, $5);
2431 return
yyerror ("Bad jump offset");
2434 | IF CCREG JUMP expr
2436 if
(IS_PCREL10
($4))
2438 notethat
("BRCC: IF CC JUMP pcrel11m2\n");
2439 $$
= BRCC
(1, 0, $4);
2442 return
yyerror ("Bad jump offset");
2445 | IF CCREG JUMP expr LPAREN BP RPAREN
2447 if
(IS_PCREL10
($4))
2449 notethat
("BRCC: IF !CC JUMP pcrel11m2\n");
2450 $$
= BRCC
(1, 1, $4);
2453 return
yyerror ("Bad jump offset");
2457 notethat
("ProgCtrl: NOP\n");
2458 $$
= PROGCTRL
(0, 0);
2463 notethat
("ProgCtrl: RTS\n");
2464 $$
= PROGCTRL
(1, 0);
2469 notethat
("ProgCtrl: RTI\n");
2470 $$
= PROGCTRL
(1, 1);
2475 notethat
("ProgCtrl: RTX\n");
2476 $$
= PROGCTRL
(1, 2);
2481 notethat
("ProgCtrl: RTN\n");
2482 $$
= PROGCTRL
(1, 3);
2487 notethat
("ProgCtrl: RTE\n");
2488 $$
= PROGCTRL
(1, 4);
2493 notethat
("ProgCtrl: IDLE\n");
2494 $$
= PROGCTRL
(2, 0);
2499 notethat
("ProgCtrl: CSYNC\n");
2500 $$
= PROGCTRL
(2, 3);
2505 notethat
("ProgCtrl: SSYNC\n");
2506 $$
= PROGCTRL
(2, 4);
2511 notethat
("ProgCtrl: EMUEXCPT\n");
2512 $$
= PROGCTRL
(2, 5);
2519 notethat
("ProgCtrl: CLI dregs\n");
2520 $$
= PROGCTRL
(3, $2.regno
& CODE_MASK
);
2523 return
yyerror ("Dreg expected for CLI");
2530 notethat
("ProgCtrl: STI dregs\n");
2531 $$
= PROGCTRL
(4, $2.regno
& CODE_MASK
);
2534 return
yyerror ("Dreg expected for STI");
2537 | JUMP LPAREN REG RPAREN
2541 notethat
("ProgCtrl: JUMP (pregs )\n");
2542 $$
= PROGCTRL
(5, $3.regno
& CODE_MASK
);
2545 return
yyerror ("Bad register for indirect jump");
2548 | CALL LPAREN REG RPAREN
2552 notethat
("ProgCtrl: CALL (pregs )\n");
2553 $$
= PROGCTRL
(6, $3.regno
& CODE_MASK
);
2556 return
yyerror ("Bad register for indirect call");
2559 | CALL LPAREN PC PLUS REG RPAREN
2563 notethat
("ProgCtrl: CALL (PC + pregs )\n");
2564 $$
= PROGCTRL
(7, $5.regno
& CODE_MASK
);
2567 return
yyerror ("Bad register for indirect call");
2570 | JUMP LPAREN PC PLUS REG RPAREN
2574 notethat
("ProgCtrl: JUMP (PC + pregs )\n");
2575 $$
= PROGCTRL
(8, $5.regno
& CODE_MASK
);
2578 return
yyerror ("Bad register for indirect jump");
2583 if
(IS_UIMM
($2, 4))
2585 notethat
("ProgCtrl: RAISE uimm4\n");
2586 $$
= PROGCTRL
(9, uimm4
($2));
2589 return
yyerror ("Bad value for RAISE");
2594 notethat
("ProgCtrl: EMUEXCPT\n");
2595 $$
= PROGCTRL
(10, uimm4
($2));
2598 | TESTSET LPAREN REG RPAREN
2602 notethat
("ProgCtrl: TESTSET (pregs )\n");
2603 $$
= PROGCTRL
(11, $3.regno
& CODE_MASK
);
2606 return
yyerror ("Preg expected");
2611 if
(IS_PCREL12
($2))
2613 notethat
("UJUMP: JUMP pcrel12\n");
2617 return
yyerror ("Bad value for relative jump");
2622 if
(IS_PCREL12
($2))
2624 notethat
("UJUMP: JUMP_DOT_S pcrel12\n");
2628 return
yyerror ("Bad value for relative jump");
2633 if
(IS_PCREL24
($2))
2635 notethat
("CALLa: jump.l pcrel24\n");
2639 return
yyerror ("Bad value for long jump");
2644 if
(IS_PCREL24
($2))
2646 notethat
("CALLa: jump.l pcrel24\n");
2650 return
yyerror ("Bad value for long jump");
2655 if
(IS_PCREL24
($2))
2657 notethat
("CALLa: CALL pcrel25m2\n");
2661 return
yyerror ("Bad call address");
2665 if
(IS_PCREL24
($2))
2667 notethat
("CALLa: CALL pcrel25m2\n");
2671 return
yyerror ("Bad call address");
2675 /* ALU2op: DIVQ (dregs, dregs). */
2676 | DIVQ LPAREN REG COMMA REG RPAREN
2678 if
(IS_DREG
($3) && IS_DREG
($5))
2679 $$
= ALU2OP
(&$3, &$5, 8);
2681 return
yyerror ("Bad registers for DIVQ");
2684 | DIVS LPAREN REG COMMA REG RPAREN
2686 if
(IS_DREG
($3) && IS_DREG
($5))
2687 $$
= ALU2OP
(&$3, &$5, 9);
2689 return
yyerror ("Bad registers for DIVS");
2692 | REG ASSIGN MINUS REG vsmod
2694 if
(IS_DREG
($1) && IS_DREG
($4))
2696 if
($5.r0
== 0 && $5.s0
== 0 && $5.aop
== 0)
2698 notethat
("ALU2op: dregs = - dregs\n");
2699 $$
= ALU2OP
(&$1, &$4, 14);
2701 else if
($5.r0
== 1 && $5.s0
== 0 && $5.aop
== 3)
2703 notethat
("dsp32alu: dregs = - dregs (.)\n");
2704 $$
= DSP32ALU
(15, 0, 0, &$1, &$4, 0, $5.s0
, 0, 3);
2708 notethat
("dsp32alu: dregs = - dregs (.)\n");
2709 $$
= DSP32ALU
(7, 0, 0, &$1, &$4, 0, $5.s0
, 0, 3);
2713 return
yyerror ("Dregs expected");
2716 | REG ASSIGN TILDA REG
2718 if
(IS_DREG
($1) && IS_DREG
($4))
2720 notethat
("ALU2op: dregs = ~dregs\n");
2721 $$
= ALU2OP
(&$1, &$4, 15);
2724 return
yyerror ("Dregs expected");
2727 | REG _GREATER_GREATER_ASSIGN REG
2729 if
(IS_DREG
($1) && IS_DREG
($3))
2731 notethat
("ALU2op: dregs >>= dregs\n");
2732 $$
= ALU2OP
(&$1, &$3, 1);
2735 return
yyerror ("Dregs expected");
2738 | REG _GREATER_GREATER_ASSIGN expr
2740 if
(IS_DREG
($1) && IS_UIMM
($3, 5))
2742 notethat
("LOGI2op: dregs >>= uimm5\n");
2743 $$
= LOGI2OP
($1, uimm5
($3), 6);
2746 return
yyerror ("Dregs expected or value error");
2749 | REG _GREATER_GREATER_GREATER_THAN_ASSIGN REG
2751 if
(IS_DREG
($1) && IS_DREG
($3))
2753 notethat
("ALU2op: dregs >>>= dregs\n");
2754 $$
= ALU2OP
(&$1, &$3, 0);
2757 return
yyerror ("Dregs expected");
2760 | REG _LESS_LESS_ASSIGN REG
2762 if
(IS_DREG
($1) && IS_DREG
($3))
2764 notethat
("ALU2op: dregs <<= dregs\n");
2765 $$
= ALU2OP
(&$1, &$3, 2);
2768 return
yyerror ("Dregs expected");
2771 | REG _LESS_LESS_ASSIGN expr
2773 if
(IS_DREG
($1) && IS_UIMM
($3, 5))
2775 notethat
("LOGI2op: dregs <<= uimm5\n");
2776 $$
= LOGI2OP
($1, uimm5
($3), 7);
2779 return
yyerror ("Dregs expected or const value error");
2783 | REG _GREATER_GREATER_GREATER_THAN_ASSIGN expr
2785 if
(IS_DREG
($1) && IS_UIMM
($3, 5))
2787 notethat
("LOGI2op: dregs >>>= uimm5\n");
2788 $$
= LOGI2OP
($1, uimm5
($3), 5);
2791 return
yyerror ("Dregs expected");
2794 /* Cache Control. */
2796 | FLUSH LBRACK REG RBRACK
2798 notethat
("CaCTRL: FLUSH [ pregs ]\n");
2800 $$
= CACTRL
(&$3, 0, 2);
2802 return
yyerror ("Bad register(s) for FLUSH");
2805 | FLUSH reg_with_postinc
2809 notethat
("CaCTRL: FLUSH [ pregs ++ ]\n");
2810 $$
= CACTRL
(&$2, 1, 2);
2813 return
yyerror ("Bad register(s) for FLUSH");
2816 | FLUSHINV LBRACK REG RBRACK
2820 notethat
("CaCTRL: FLUSHINV [ pregs ]\n");
2821 $$
= CACTRL
(&$3, 0, 1);
2824 return
yyerror ("Bad register(s) for FLUSH");
2827 | FLUSHINV reg_with_postinc
2831 notethat
("CaCTRL: FLUSHINV [ pregs ++ ]\n");
2832 $$
= CACTRL
(&$2, 1, 1);
2835 return
yyerror ("Bad register(s) for FLUSH");
2838 /* CaCTRL: IFLUSH [pregs]. */
2839 | IFLUSH LBRACK REG RBRACK
2843 notethat
("CaCTRL: IFLUSH [ pregs ]\n");
2844 $$
= CACTRL
(&$3, 0, 3);
2847 return
yyerror ("Bad register(s) for FLUSH");
2850 | IFLUSH reg_with_postinc
2854 notethat
("CaCTRL: IFLUSH [ pregs ++ ]\n");
2855 $$
= CACTRL
(&$2, 1, 3);
2858 return
yyerror ("Bad register(s) for FLUSH");
2861 | PREFETCH LBRACK REG RBRACK
2865 notethat
("CaCTRL: PREFETCH [ pregs ]\n");
2866 $$
= CACTRL
(&$3, 0, 0);
2869 return
yyerror ("Bad register(s) for PREFETCH");
2872 | PREFETCH reg_with_postinc
2876 notethat
("CaCTRL: PREFETCH [ pregs ++ ]\n");
2877 $$
= CACTRL
(&$2, 1, 0);
2880 return
yyerror ("Bad register(s) for PREFETCH");
2884 /* LDST: B [ pregs <post_op> ] = dregs. */
2886 | B LBRACK REG post_op RBRACK ASSIGN REG
2888 if
(IS_PREG
($3) && IS_DREG
($7))
2890 notethat
("LDST: B [ pregs <post_op> ] = dregs\n");
2891 $$
= LDST
(&$3, &$7, $4.x0
, 2, 0, 1);
2894 return
yyerror ("Register mismatch");
2897 /* LDSTidxI: B [ pregs + imm16 ] = dregs. */
2898 | B LBRACK REG plus_minus expr RBRACK ASSIGN REG
2900 if
(IS_PREG
($3) && IS_RANGE
(16, $5, $4.r0
, 1) && IS_DREG
($8))
2902 notethat
("LDST: B [ pregs + imm16 ] = dregs\n");
2905 $$
= LDSTIDXI
(&$3, &$8, 1, 2, 0, $5);
2908 return
yyerror ("Register mismatch or const size wrong");
2912 /* LDSTii: W [ pregs + uimm4s2 ] = dregs. */
2913 | W LBRACK REG plus_minus expr RBRACK ASSIGN REG
2915 if
(IS_PREG
($3) && IS_URANGE
(4, $5, $4.r0
, 2) && IS_DREG
($8))
2917 notethat
("LDSTii: W [ pregs +- uimm5m2 ] = dregs\n");
2918 $$
= LDSTII
(&$3, &$8, $5, 1, 1);
2920 else if
(IS_PREG
($3) && IS_RANGE
(16, $5, $4.r0
, 2) && IS_DREG
($8))
2922 notethat
("LDSTidxI: W [ pregs + imm17m2 ] = dregs\n");
2925 $$
= LDSTIDXI
(&$3, &$8, 1, 1, 0, $5);
2928 return
yyerror ("Bad register(s) or wrong constant size");
2931 /* LDST: W [ pregs <post_op> ] = dregs. */
2932 | W LBRACK REG post_op RBRACK ASSIGN REG
2934 if
(IS_PREG
($3) && IS_DREG
($7))
2936 notethat
("LDST: W [ pregs <post_op> ] = dregs\n");
2937 $$
= LDST
(&$3, &$7, $4.x0
, 1, 0, 1);
2940 return
yyerror ("Bad register(s) for STORE");
2943 | W LBRACK REG post_op RBRACK ASSIGN HALF_REG
2947 notethat
("dspLDST: W [ iregs <post_op> ] = dregs_half\n");
2948 $$
= DSPLDST
(&$3, 1 + IS_H
($7), &$7, $4.x0
, 1);
2950 else if
($4.x0
== 2 && IS_PREG
($3) && IS_DREG
($7))
2952 notethat
("LDSTpmod: W [ pregs <post_op>] = dregs_half\n");
2953 $$
= LDSTPMOD
(&$3, &$7, &$3, 1 + IS_H
($7), 1);
2957 return
yyerror ("Bad register(s) for STORE");
2960 /* LDSTiiFP: [ FP - const ] = dpregs. */
2961 | LBRACK REG plus_minus expr RBRACK ASSIGN REG
2963 Expr_Node
*tmp
= $4;
2964 int ispreg
= IS_PREG
($7);
2967 return
yyerror ("Preg expected for indirect");
2969 if
(!IS_DREG
($7) && !ispreg
)
2970 return
yyerror ("Bad source register for STORE");
2973 tmp
= unary
(Expr_Op_Type_NEG
, tmp
);
2975 if
(in_range_p
(tmp
, 0, 63, 3))
2977 notethat
("LDSTii: dpregs = [ pregs + uimm6m4 ]\n");
2978 $$
= LDSTII
(&$2, &$7, tmp
, 1, ispreg ?
3 : 0);
2980 else if
($2.regno
== REG_FP
&& in_range_p
(tmp
, -128, 0, 3))
2982 notethat
("LDSTiiFP: dpregs = [ FP - uimm7m4 ]\n");
2983 tmp
= unary
(Expr_Op_Type_NEG
, tmp
);
2984 $$
= LDSTIIFP
(tmp
, &$7, 1);
2986 else if
(in_range_p
(tmp
, -131072, 131071, 3))
2988 notethat
("LDSTidxI: [ pregs + imm18m4 ] = dpregs\n");
2989 $$
= LDSTIDXI
(&$2, &$7, 1, 0, ispreg ?
1: 0, tmp
);
2992 return
yyerror ("Displacement out of range for store");
2995 | REG ASSIGN W LBRACK REG plus_minus expr RBRACK xpmod
2997 if
(IS_DREG
($1) && IS_PREG
($5) && IS_URANGE
(4, $7, $6.r0
, 2))
2999 notethat
("LDSTii: dregs = W [ pregs + uimm4s2 ] (.)\n");
3000 $$
= LDSTII
(&$5, &$1, $7, 0, 1 << $9.r0
);
3002 else if
(IS_DREG
($1) && IS_PREG
($5) && IS_RANGE
(16, $7, $6.r0
, 2))
3004 notethat
("LDSTidxI: dregs = W [ pregs + imm17m2 ] (.)\n");
3007 $$
= LDSTIDXI
(&$5, &$1, 0, 1, $9.r0
, $7);
3010 return
yyerror ("Bad register or constant for LOAD");
3013 | HALF_REG ASSIGN W LBRACK REG post_op RBRACK
3017 notethat
("dspLDST: dregs_half = W [ iregs ]\n");
3018 $$
= DSPLDST
(&$5, 1 + IS_H
($1), &$1, $6.x0
, 0);
3020 else if
($6.x0
== 2 && IS_DREG
($1) && IS_PREG
($5))
3022 notethat
("LDSTpmod: dregs_half = W [ pregs ]\n");
3023 $$
= LDSTPMOD
(&$5, &$1, &$5, 1 + IS_H
($1), 0);
3026 return
yyerror ("Bad register or post_op for LOAD");
3030 | REG ASSIGN W LBRACK REG post_op RBRACK xpmod
3032 if
(IS_DREG
($1) && IS_PREG
($5))
3034 notethat
("LDST: dregs = W [ pregs <post_op> ] (.)\n");
3035 $$
= LDST
(&$5, &$1, $6.x0
, 1, $8.r0
, 0);
3038 return
yyerror ("Bad register for LOAD");
3041 | REG ASSIGN W LBRACK REG _PLUS_PLUS REG RBRACK xpmod
3043 if
(IS_DREG
($1) && IS_PREG
($5) && IS_PREG
($7))
3045 notethat
("LDSTpmod: dregs = W [ pregs ++ pregs ] (.)\n");
3046 $$
= LDSTPMOD
(&$5, &$1, &$7, 3, $9.r0
);
3049 return
yyerror ("Bad register for LOAD");
3052 | HALF_REG ASSIGN W LBRACK REG _PLUS_PLUS REG RBRACK
3054 if
(IS_DREG
($1) && IS_PREG
($5) && IS_PREG
($7))
3056 notethat
("LDSTpmod: dregs_half = W [ pregs ++ pregs ]\n");
3057 $$
= LDSTPMOD
(&$5, &$1, &$7, 1 + IS_H
($1), 0);
3060 return
yyerror ("Bad register for LOAD");
3063 | LBRACK REG post_op RBRACK ASSIGN REG
3065 if
(IS_IREG
($2) && IS_DREG
($6))
3067 notethat
("dspLDST: [ iregs <post_op> ] = dregs\n");
3068 $$
= DSPLDST
(&$2, 0, &$6, $3.x0
, 1);
3070 else if
(IS_PREG
($2) && IS_DREG
($6))
3072 notethat
("LDST: [ pregs <post_op> ] = dregs\n");
3073 $$
= LDST
(&$2, &$6, $3.x0
, 0, 0, 1);
3075 else if
(IS_PREG
($2) && IS_PREG
($6))
3077 notethat
("LDST: [ pregs <post_op> ] = pregs\n");
3078 $$
= LDST
(&$2, &$6, $3.x0
, 0, 1, 1);
3081 return
yyerror ("Bad register for STORE");
3084 | LBRACK REG _PLUS_PLUS REG RBRACK ASSIGN REG
3087 return
yyerror ("Expected Dreg for last argument");
3089 if
(IS_IREG
($2) && IS_MREG
($4))
3091 notethat
("dspLDST: [ iregs ++ mregs ] = dregs\n");
3092 $$
= DSPLDST
(&$2, $4.regno
& CODE_MASK
, &$7, 3, 1);
3094 else if
(IS_PREG
($2) && IS_PREG
($4))
3096 notethat
("LDSTpmod: [ pregs ++ pregs ] = dregs\n");
3097 $$
= LDSTPMOD
(&$2, &$7, &$4, 0, 1);
3100 return
yyerror ("Bad register for STORE");
3103 | W LBRACK REG _PLUS_PLUS REG RBRACK ASSIGN HALF_REG
3106 return
yyerror ("Expect Dreg as last argument");
3107 if
(IS_PREG
($3) && IS_PREG
($5))
3109 notethat
("LDSTpmod: W [ pregs ++ pregs ] = dregs_half\n");
3110 $$
= LDSTPMOD
(&$3, &$8, &$5, 1 + IS_H
($8), 1);
3113 return
yyerror ("Bad register for STORE");
3116 | REG ASSIGN B LBRACK REG plus_minus expr RBRACK xpmod
3118 if
(IS_DREG
($1) && IS_PREG
($5) && IS_RANGE
(16, $7, $6.r0
, 1))
3120 notethat
("LDSTidxI: dregs = B [ pregs + imm16 ] (%c)\n",
3124 $$
= LDSTIDXI
(&$5, &$1, 0, 2, $9.r0
, $7);
3127 return
yyerror ("Bad register or value for LOAD");
3130 | REG ASSIGN B LBRACK REG post_op RBRACK xpmod
3132 if
(IS_DREG
($1) && IS_PREG
($5))
3134 notethat
("LDST: dregs = B [ pregs <post_op> ] (%c)\n",
3136 $$
= LDST
(&$5, &$1, $6.x0
, 2, $8.r0
, 0);
3139 return
yyerror ("Bad register for LOAD");
3142 | REG ASSIGN LBRACK REG _PLUS_PLUS REG RBRACK
3144 if
(IS_DREG
($1) && IS_IREG
($4) && IS_MREG
($6))
3146 notethat
("dspLDST: dregs = [ iregs ++ mregs ]\n");
3147 $$
= DSPLDST
(&$4, $6.regno
& CODE_MASK
, &$1, 3, 0);
3149 else if
(IS_DREG
($1) && IS_PREG
($4) && IS_PREG
($6))
3151 notethat
("LDSTpmod: dregs = [ pregs ++ pregs ]\n");
3152 $$
= LDSTPMOD
(&$4, &$1, &$6, 0, 0);
3155 return
yyerror ("Bad register for LOAD");
3158 | REG ASSIGN LBRACK REG plus_minus got_or_expr RBRACK
3160 Expr_Node
*tmp
= $6;
3161 int ispreg
= IS_PREG
($1);
3162 int isgot
= IS_RELOC
($6);
3165 return
yyerror ("Preg expected for indirect");
3167 if
(!IS_DREG
($1) && !ispreg
)
3168 return
yyerror ("Bad destination register for LOAD");
3171 tmp
= unary
(Expr_Op_Type_NEG
, tmp
);
3174 notethat
("LDSTidxI: dpregs = [ pregs + sym@got ]\n");
3175 $$
= LDSTIDXI
(&$4, &$1, 0, 0, ispreg ?
1: 0, tmp
);
3177 else if
(in_range_p
(tmp
, 0, 63, 3))
3179 notethat
("LDSTii: dpregs = [ pregs + uimm7m4 ]\n");
3180 $$
= LDSTII
(&$4, &$1, tmp
, 0, ispreg ?
3 : 0);
3182 else if
($4.regno
== REG_FP
&& in_range_p
(tmp
, -128, 0, 3))
3184 notethat
("LDSTiiFP: dpregs = [ FP - uimm7m4 ]\n");
3185 tmp
= unary
(Expr_Op_Type_NEG
, tmp
);
3186 $$
= LDSTIIFP
(tmp
, &$1, 0);
3188 else if
(in_range_p
(tmp
, -131072, 131071, 3))
3190 notethat
("LDSTidxI: dpregs = [ pregs + imm18m4 ]\n");
3191 $$
= LDSTIDXI
(&$4, &$1, 0, 0, ispreg ?
1: 0, tmp
);
3195 return
yyerror ("Displacement out of range for load");
3198 | REG ASSIGN LBRACK REG post_op RBRACK
3200 if
(IS_DREG
($1) && IS_IREG
($4))
3202 notethat
("dspLDST: dregs = [ iregs <post_op> ]\n");
3203 $$
= DSPLDST
(&$4, 0, &$1, $5.x0
, 0);
3205 else if
(IS_DREG
($1) && IS_PREG
($4))
3207 notethat
("LDST: dregs = [ pregs <post_op> ]\n");
3208 $$
= LDST
(&$4, &$1, $5.x0
, 0, 0, 0);
3210 else if
(IS_PREG
($1) && IS_PREG
($4))
3212 if
(REG_SAME
($1, $4) && $5.x0
!= 2)
3213 return
yyerror ("Pregs can't be same");
3215 notethat
("LDST: pregs = [ pregs <post_op> ]\n");
3216 $$
= LDST
(&$4, &$1, $5.x0
, 0, 1, 0);
3218 else if
($4.regno
== REG_SP
&& IS_ALLREG
($1) && $5.x0
== 0)
3220 notethat
("PushPopReg: allregs = [ SP ++ ]\n");
3221 $$
= PUSHPOPREG
(&$1, 0);
3224 return
yyerror ("Bad register or value");
3228 /* PushPopMultiple. */
3229 | reg_with_predec ASSIGN LPAREN REG COLON expr COMMA REG COLON expr RPAREN
3231 if
($1.regno
!= REG_SP
)
3232 yyerror ("Stack Pointer expected");
3233 if
($4.regno
== REG_R7
3234 && IN_RANGE
($6, 0, 7)
3235 && $8.regno
== REG_P5
3236 && IN_RANGE
($10, 0, 5))
3238 notethat
("PushPopMultiple: [ -- SP ] = (R7 : reglim , P5 : reglim )\n");
3239 $$
= PUSHPOPMULTIPLE
(imm5
($6), imm5
($10), 1, 1, 1);
3242 return
yyerror ("Bad register for PushPopMultiple");
3245 | reg_with_predec ASSIGN LPAREN REG COLON expr RPAREN
3247 if
($1.regno
!= REG_SP
)
3248 yyerror ("Stack Pointer expected");
3250 if
($4.regno
== REG_R7
&& IN_RANGE
($6, 0, 7))
3252 notethat
("PushPopMultiple: [ -- SP ] = (R7 : reglim )\n");
3253 $$
= PUSHPOPMULTIPLE
(imm5
($6), 0, 1, 0, 1);
3255 else if
($4.regno
== REG_P5
&& IN_RANGE
($6, 0, 6))
3257 notethat
("PushPopMultiple: [ -- SP ] = (P5 : reglim )\n");
3258 $$
= PUSHPOPMULTIPLE
(0, imm5
($6), 0, 1, 1);
3261 return
yyerror ("Bad register for PushPopMultiple");
3264 | LPAREN REG COLON expr COMMA REG COLON expr RPAREN ASSIGN reg_with_postinc
3266 if
($11.regno
!= REG_SP
)
3267 yyerror ("Stack Pointer expected");
3268 if
($2.regno
== REG_R7
&& (IN_RANGE
($4, 0, 7))
3269 && $6.regno
== REG_P5
&& (IN_RANGE
($8, 0, 6)))
3271 notethat
("PushPopMultiple: (R7 : reglim , P5 : reglim ) = [ SP ++ ]\n");
3272 $$
= PUSHPOPMULTIPLE
(imm5
($4), imm5
($8), 1, 1, 0);
3275 return
yyerror ("Bad register range for PushPopMultiple");
3278 | LPAREN REG COLON expr RPAREN ASSIGN reg_with_postinc
3280 if
($7.regno
!= REG_SP
)
3281 yyerror ("Stack Pointer expected");
3283 if
($2.regno
== REG_R7
&& IN_RANGE
($4, 0, 7))
3285 notethat
("PushPopMultiple: (R7 : reglim ) = [ SP ++ ]\n");
3286 $$
= PUSHPOPMULTIPLE
(imm5
($4), 0, 1, 0, 0);
3288 else if
($2.regno
== REG_P5
&& IN_RANGE
($4, 0, 6))
3290 notethat
("PushPopMultiple: (P5 : reglim ) = [ SP ++ ]\n");
3291 $$
= PUSHPOPMULTIPLE
(0, imm5
($4), 0, 1, 0);
3294 return
yyerror ("Bad register range for PushPopMultiple");
3297 | reg_with_predec ASSIGN REG
3299 if
($1.regno
!= REG_SP
)
3300 yyerror ("Stack Pointer expected");
3304 notethat
("PushPopReg: [ -- SP ] = allregs\n");
3305 $$
= PUSHPOPREG
(&$3, 1);
3308 return
yyerror ("Bad register for PushPopReg");
3315 if
(IS_URANGE
(16, $2, 0, 4))
3316 $$
= LINKAGE
(0, uimm16s4
($2));
3318 return
yyerror ("Bad constant for LINK");
3323 notethat
("linkage: UNLINK\n");
3324 $$
= LINKAGE
(1, 0);
3330 | LSETUP LPAREN expr COMMA expr RPAREN REG
3332 if
(IS_PCREL4
($3) && IS_LPPCREL10
($5) && IS_CREG
($7))
3334 notethat
("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters\n");
3335 $$
= LOOPSETUP
($3, &$7, 0, $5, 0);
3338 return
yyerror ("Bad register or values for LSETUP");
3341 | LSETUP LPAREN expr COMMA expr RPAREN REG ASSIGN REG
3343 if
(IS_PCREL4
($3) && IS_LPPCREL10
($5)
3344 && IS_PREG
($9) && IS_CREG
($7))
3346 notethat
("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters = pregs\n");
3347 $$
= LOOPSETUP
($3, &$7, 1, $5, &$9);
3350 return
yyerror ("Bad register or values for LSETUP");
3353 | LSETUP LPAREN expr COMMA expr RPAREN REG ASSIGN REG GREATER_GREATER expr
3355 if
(IS_PCREL4
($3) && IS_LPPCREL10
($5)
3356 && IS_PREG
($9) && IS_CREG
($7)
3357 && EXPR_VALUE
($11) == 1)
3359 notethat
("LoopSetup: LSETUP (pcrel4 , lppcrel10 ) counters = pregs >> 1\n");
3360 $$
= LOOPSETUP
($3, &$7, 3, $5, &$9);
3363 return
yyerror ("Bad register or values for LSETUP");
3370 return
yyerror ("Invalid expression in loop statement");
3372 return
yyerror ("Invalid loop counter register");
3373 $$
= bfin_gen_loop
($2, &$3, 0, 0);
3375 | LOOP expr REG ASSIGN REG
3377 if
(IS_RELOC
($2) && IS_PREG
($5) && IS_CREG
($3))
3379 notethat
("Loop: LOOP expr counters = pregs\n");
3380 $$
= bfin_gen_loop
($2, &$3, 1, &$5);
3383 return
yyerror ("Bad register or values for LOOP");
3385 | LOOP expr REG ASSIGN REG GREATER_GREATER expr
3387 if
(IS_RELOC
($2) && IS_PREG
($5) && IS_CREG
($3) && EXPR_VALUE
($7) == 1)
3389 notethat
("Loop: LOOP expr counters = pregs >> 1\n");
3390 $$
= bfin_gen_loop
($2, &$3, 3, &$5);
3393 return
yyerror ("Bad register or values for LOOP");
3399 notethat
("pseudoDEBUG: DBG\n");
3400 $$
= bfin_gen_pseudodbg
(3, 7, 0);
3404 notethat
("pseudoDEBUG: DBG REG_A\n");
3405 $$
= bfin_gen_pseudodbg
(3, IS_A1
($2), 0);
3409 notethat
("pseudoDEBUG: DBG allregs\n");
3410 $$
= bfin_gen_pseudodbg
(0, $2.regno
& CODE_MASK
, $2.regno
& CLASS_MASK
);
3413 | DBGCMPLX LPAREN REG RPAREN
3416 return
yyerror ("Dregs expected");
3417 notethat
("pseudoDEBUG: DBGCMPLX (dregs )\n");
3418 $$
= bfin_gen_pseudodbg
(3, 6, $3.regno
& CODE_MASK
);
3423 notethat
("psedoDEBUG: DBGHALT\n");
3424 $$
= bfin_gen_pseudodbg
(3, 5, 0);
3427 | DBGA LPAREN HALF_REG COMMA expr RPAREN
3429 notethat
("pseudodbg_assert: DBGA (dregs_lo , uimm16 )\n");
3430 $$
= bfin_gen_pseudodbg_assert
(IS_H
($3), &$3, uimm16
($5));
3433 | DBGAH LPAREN REG COMMA expr RPAREN
3435 notethat
("pseudodbg_assert: DBGAH (dregs , uimm16 )\n");
3436 $$
= bfin_gen_pseudodbg_assert
(3, &$3, uimm16
($5));
3439 | DBGAL LPAREN REG COMMA expr RPAREN
3441 notethat
("psedodbg_assert: DBGAL (dregs , uimm16 )\n");
3442 $$
= bfin_gen_pseudodbg_assert
(2, &$3, uimm16
($5));
3450 /* Register rules. */
3452 REG_A: REG_A_DOUBLE_ZERO
3470 | LPAREN M COMMA MMOD RPAREN
3475 | LPAREN MMOD COMMA M RPAREN
3480 | LPAREN MMOD RPAREN
3492 asr_asl: LPAREN ASL RPAREN
3573 | LPAREN asr_asl_0 RPAREN
3585 | LPAREN asr_asl_0 COMMA sco RPAREN
3591 | LPAREN sco COMMA asr_asl_0 RPAREN
3651 | LPAREN V COMMA S RPAREN
3656 | LPAREN S COMMA V RPAREN
3718 | LPAREN MMOD RPAREN
3721 return
yyerror ("Bad modifier");
3725 | LPAREN MMOD COMMA R RPAREN
3728 return
yyerror ("Bad modifier");
3732 | LPAREN R COMMA MMOD RPAREN
3735 return
yyerror ("Bad modifier");
3762 | LPAREN MMOD RPAREN
3767 return
yyerror ("Only (W32) allowed");
3775 | LPAREN MMOD RPAREN
3780 return
yyerror ("(IU) expected");
3784 reg_with_predec: LBRACK _MINUS_MINUS REG RBRACK
3790 reg_with_postinc: LBRACK REG _PLUS_PLUS RBRACK
3842 $$.r0
= 1; /* HL. */
3845 $$.aop
= 0; /* aop. */
3850 $$.r0
= 1; /* HL. */
3853 $$.aop
= 1; /* aop. */
3856 | LPAREN RNDL RPAREN
3858 $$.r0
= 0; /* HL. */
3861 $$.aop
= 0; /* aop. */
3866 $$.r0
= 0; /* HL. */
3872 | LPAREN RNDH COMMA R RPAREN
3874 $$.r0
= 1; /* HL. */
3877 $$.aop
= 0; /* aop. */
3879 | LPAREN TH COMMA R RPAREN
3881 $$.r0
= 1; /* HL. */
3884 $$.aop
= 1; /* aop. */
3886 | LPAREN RNDL COMMA R RPAREN
3888 $$.r0
= 0; /* HL. */
3891 $$.aop
= 0; /* aop. */
3894 | LPAREN TL COMMA R RPAREN
3896 $$.r0
= 0; /* HL. */
3899 $$.aop
= 1; /* aop. */
3907 $$.x0
= 0; /* HL. */
3912 $$.x0
= 1; /* HL. */
3914 | LPAREN LO COMMA R RPAREN
3917 $$.x0
= 0; /* HL. */
3919 | LPAREN HI COMMA R RPAREN
3922 $$.x0
= 1; /* HL. */
3940 /* Assignments, Macfuncs. */
3974 if
(IS_A1
($3) && IS_EVEN
($1))
3975 return
yyerror ("Cannot move A1 to even register");
3976 else if
(!IS_A1
($3) && !IS_EVEN
($1))
3977 return
yyerror ("Cannot move A0 to odd register");
3985 | REG ASSIGN LPAREN a_macfunc RPAREN
3993 | HALF_REG ASSIGN LPAREN a_macfunc RPAREN
4001 | HALF_REG ASSIGN REG_A
4011 if
(IS_A1
($3) && !IS_H
($1))
4012 return
yyerror ("Cannot move A1 to low half of register");
4013 else if
(!IS_A1
($3) && IS_H
($1))
4014 return
yyerror ("Cannot move A0 to high half of register");
4019 a_assign multiply_halfregs
4026 | a_plusassign multiply_halfregs
4033 | a_minusassign multiply_halfregs
4043 HALF_REG STAR HALF_REG
4045 if
(IS_DREG
($1) && IS_DREG
($3))
4051 return
yyerror ("Dregs expected");
4075 CCREG cc_op STATUS_REG
4087 | STATUS_REG cc_op CCREG
4101 /* Expressions and Symbols. */
4105 Expr_Node_Value val
;
4106 val.s_value
= S_GET_NAME
($1);
4107 $$
= Expr_Node_Create
(Expr_Node_Reloc
, val
, NULL
, NULL
);
4113 { $$
= BFD_RELOC_BFIN_GOT
; }
4115 { $$
= BFD_RELOC_BFIN_GOT17M4
; }
4117 { $$
= BFD_RELOC_BFIN_FUNCDESC_GOT17M4
; }
4120 got: symbol AT any_gotrel
4122 Expr_Node_Value val
;
4124 $$
= Expr_Node_Create
(Expr_Node_GOT_Reloc
, val
, $1, NULL
);
4147 Expr_Node_Value val
;
4149 $$
= Expr_Node_Create
(Expr_Node_Constant
, val
, NULL
, NULL
);
4155 | LPAREN expr_1 RPAREN
4161 $$
= unary
(Expr_Op_Type_COMP
, $2);
4163 | MINUS expr_1 %prec TILDA
4165 $$
= unary
(Expr_Op_Type_NEG
, $2);
4175 expr_1: expr_1 STAR expr_1
4177 $$
= binary
(Expr_Op_Type_Mult
, $1, $3);
4179 | expr_1 SLASH expr_1
4181 $$
= binary
(Expr_Op_Type_Div
, $1, $3);
4183 | expr_1 PERCENT expr_1
4185 $$
= binary
(Expr_Op_Type_Mod
, $1, $3);
4187 | expr_1 PLUS expr_1
4189 $$
= binary
(Expr_Op_Type_Add
, $1, $3);
4191 | expr_1 MINUS expr_1
4193 $$
= binary
(Expr_Op_Type_Sub
, $1, $3);
4195 | expr_1 LESS_LESS expr_1
4197 $$
= binary
(Expr_Op_Type_Lshift
, $1, $3);
4199 | expr_1 GREATER_GREATER expr_1
4201 $$
= binary
(Expr_Op_Type_Rshift
, $1, $3);
4203 | expr_1 AMPERSAND expr_1
4205 $$
= binary
(Expr_Op_Type_BAND
, $1, $3);
4207 | expr_1 CARET expr_1
4209 $$
= binary
(Expr_Op_Type_LOR
, $1, $3);
4213 $$
= binary
(Expr_Op_Type_BOR
, $1, $3);
4225 mkexpr
(int x
, SYMBOL_T s
)
4227 EXPR_T e
= (EXPR_T
) ALLOCATE
(sizeof
(struct expression_cell
));
4234 value_match
(Expr_Node
*expr
, int sz
, int sign
, int mul
, int issigned
)
4236 long umax
= (1L << sz
) - 1;
4237 long min
= -1L << (sz
- 1);
4238 long max
= (1L << (sz
- 1)) - 1;
4240 long v
= EXPR_VALUE
(expr
);
4244 error ("%s:%d: Value Error -- Must align to %d\n", __FILE__
, __LINE__
, mul
);
4255 if
(v
>= min
&& v
<= max
) return
1;
4258 fprintf
(stderr
, "signed value %lx out of range\n", v
* mul
);
4262 if
(v
<= umax
&& v
>= 0)
4265 fprintf
(stderr
, "unsigned value %lx out of range\n", v
* mul
);
4270 /* Return the expression structure that allows symbol operations.
4271 If the left and right children are constants, do the operation. */
4273 binary
(Expr_Op_Type op
, Expr_Node
*x
, Expr_Node
*y
)
4275 Expr_Node_Value val
;
4277 if
(x
->type
== Expr_Node_Constant
&& y
->type
== Expr_Node_Constant
)
4281 case Expr_Op_Type_Add
:
4282 x
->value.i_value
+= y
->value.i_value
;
4284 case Expr_Op_Type_Sub
:
4285 x
->value.i_value
-= y
->value.i_value
;
4287 case Expr_Op_Type_Mult
:
4288 x
->value.i_value
*= y
->value.i_value
;
4290 case Expr_Op_Type_Div
:
4291 if
(y
->value.i_value
== 0)
4292 error ("Illegal Expression: Division by zero.");
4294 x
->value.i_value
/= y
->value.i_value
;
4296 case Expr_Op_Type_Mod
:
4297 x
->value.i_value %
= y
->value.i_value
;
4299 case Expr_Op_Type_Lshift
:
4300 x
->value.i_value
<<= y
->value.i_value
;
4302 case Expr_Op_Type_Rshift
:
4303 x
->value.i_value
>>= y
->value.i_value
;
4305 case Expr_Op_Type_BAND
:
4306 x
->value.i_value
&= y
->value.i_value
;
4308 case Expr_Op_Type_BOR
:
4309 x
->value.i_value |
= y
->value.i_value
;
4311 case Expr_Op_Type_BXOR
:
4312 x
->value.i_value ^
= y
->value.i_value
;
4314 case Expr_Op_Type_LAND
:
4315 x
->value.i_value
= x
->value.i_value
&& y
->value.i_value
;
4317 case Expr_Op_Type_LOR
:
4318 x
->value.i_value
= x
->value.i_value || y
->value.i_value
;
4322 error ("%s:%d: Internal compiler error\n", __FILE__
, __LINE__
);
4326 /* Canonicalize order to EXPR OP CONSTANT. */
4327 if
(x
->type
== Expr_Node_Constant
)
4333 /* Canonicalize subtraction of const to addition of negated const. */
4334 if
(op
== Expr_Op_Type_Sub
&& y
->type
== Expr_Node_Constant
)
4336 op
= Expr_Op_Type_Add
;
4337 y
->value.i_value
= -y
->value.i_value
;
4339 if
(y
->type
== Expr_Node_Constant
&& x
->type
== Expr_Node_Binop
4340 && x
->Right_Child
->type
== Expr_Node_Constant
)
4342 if
(op
== x
->value.op_value
&& x
->value.op_value
== Expr_Op_Type_Add
)
4344 x
->Right_Child
->value.i_value
+= y
->value.i_value
;
4349 /* Create a new expression structure. */
4351 return Expr_Node_Create
(Expr_Node_Binop
, val
, x
, y
);
4355 unary
(Expr_Op_Type op
, Expr_Node
*x
)
4357 if
(x
->type
== Expr_Node_Constant
)
4361 case Expr_Op_Type_NEG
:
4362 x
->value.i_value
= -x
->value.i_value
;
4364 case Expr_Op_Type_COMP
:
4365 x
->value.i_value
= ~x
->value.i_value
;
4368 error ("%s:%d: Internal compiler error\n", __FILE__
, __LINE__
);
4374 /* Create a new expression structure. */
4375 Expr_Node_Value val
;
4377 return Expr_Node_Create
(Expr_Node_Unop
, val
, x
, NULL
);
4381 int debug_codeselection
= 0;
4383 notethat
(char *format
, ...
)
4386 va_start
(ap
, format
);
4387 if
(debug_codeselection
)
4389 vfprintf
(errorf
, format
, ap
);
4395 main
(int argc
, char **argv
)