1 /* tc-bfin.c -- Assembler for the ADI Blackfin.
2 Copyright 2005, 2006, 2007, 2008, 2009
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
23 #include "struc-symbol.h"
24 #include "bfin-defs.h"
26 #include "safe-ctype.h"
28 #include "dwarf2dbg.h"
31 #include "elf/common.h"
34 extern int yyparse (void);
35 struct yy_buffer_state
;
36 typedef struct yy_buffer_state
*YY_BUFFER_STATE
;
37 extern YY_BUFFER_STATE
yy_scan_string (const char *yy_str
);
38 extern void yy_delete_buffer (YY_BUFFER_STATE b
);
39 static parse_state
parse (char *line
);
41 /* Global variables. */
42 struct bfin_insn
*insn
;
45 extern struct obstack mempool
;
48 /* Flags to set in the elf header */
49 #define DEFAULT_FLAGS 0
52 # define DEFAULT_FDPIC EF_BFIN_FDPIC
54 # define DEFAULT_FDPIC 0
57 static flagword bfin_flags
= DEFAULT_FLAGS
| DEFAULT_FDPIC
;
58 static const char *bfin_pic_flag
= DEFAULT_FDPIC
? "-mfdpic" : (const char *)0;
60 /* Blackfin specific function to handle FD-PIC pointer initializations. */
63 bfin_pic_ptr (int nbytes
)
71 #ifdef md_flush_pending_output
72 md_flush_pending_output ();
75 if (is_it_end_of_statement ())
77 demand_empty_rest_of_line ();
82 md_cons_align (nbytes
);
87 bfd_reloc_code_real_type reloc_type
= BFD_RELOC_BFIN_FUNCDESC
;
89 if (strncasecmp (input_line_pointer
, "funcdesc(", 9) == 0)
91 input_line_pointer
+= 9;
93 if (*input_line_pointer
== ')')
96 as_bad (_("missing ')'"));
99 error ("missing funcdesc in picptr");
103 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, 4, &exp
, 0,
106 while (*input_line_pointer
++ == ',');
108 input_line_pointer
--; /* Put terminator back into stream. */
109 demand_empty_rest_of_line ();
113 bfin_s_bss (int ignore ATTRIBUTE_UNUSED
)
117 temp
= get_absolute_expression ();
118 subseg_set (bss_section
, (subsegT
) temp
);
119 demand_empty_rest_of_line ();
122 const pseudo_typeS md_pseudo_table
[] = {
123 {"align", s_align_bytes
, 0},
126 {"picptr", bfin_pic_ptr
, 4},
127 {"code", obj_elf_section
, 0},
132 {"pdata", s_ignore
, 0},
133 {"var", s_ignore
, 0},
134 {"bss", bfin_s_bss
, 0},
138 /* Characters that are used to denote comments and line separators. */
139 const char comment_chars
[] = "";
140 const char line_comment_chars
[] = "#";
141 const char line_separator_chars
[] = ";";
143 /* Characters that can be used to separate the mantissa from the
144 exponent in floating point numbers. */
145 const char EXP_CHARS
[] = "eE";
147 /* Characters that mean this number is a floating point constant.
148 As in 0f12.456 or 0d1.2345e12. */
149 const char FLT_CHARS
[] = "fFdDxX";
151 typedef enum bfin_cpu_type
185 bfin_cpu_t bfin_cpu_type
= BFIN_CPU_UNKNOWN
;
186 /* -msi-revision support. There are three special values:
187 -1 -msi-revision=none.
188 0xffff -msi-revision=any. */
189 int bfin_si_revision
;
191 unsigned int bfin_anomaly_checks
= 0;
198 unsigned int anomaly_checks
;
201 struct bfin_cpu bfin_cpus
[] =
203 {"bf512", BFIN_CPU_BF512
, 0x0001, AC_05000074
},
204 {"bf512", BFIN_CPU_BF512
, 0x0000, AC_05000074
},
206 {"bf514", BFIN_CPU_BF514
, 0x0001, AC_05000074
},
207 {"bf514", BFIN_CPU_BF514
, 0x0000, AC_05000074
},
209 {"bf516", BFIN_CPU_BF516
, 0x0001, AC_05000074
},
210 {"bf516", BFIN_CPU_BF516
, 0x0000, AC_05000074
},
212 {"bf518", BFIN_CPU_BF518
, 0x0001, AC_05000074
},
213 {"bf518", BFIN_CPU_BF518
, 0x0000, AC_05000074
},
215 {"bf522", BFIN_CPU_BF522
, 0x0002, AC_05000074
},
216 {"bf522", BFIN_CPU_BF522
, 0x0001, AC_05000074
},
217 {"bf522", BFIN_CPU_BF522
, 0x0000, AC_05000074
},
219 {"bf523", BFIN_CPU_BF523
, 0x0002, AC_05000074
},
220 {"bf523", BFIN_CPU_BF523
, 0x0001, AC_05000074
},
221 {"bf523", BFIN_CPU_BF523
, 0x0000, AC_05000074
},
223 {"bf524", BFIN_CPU_BF524
, 0x0002, AC_05000074
},
224 {"bf524", BFIN_CPU_BF524
, 0x0001, AC_05000074
},
225 {"bf524", BFIN_CPU_BF524
, 0x0000, AC_05000074
},
227 {"bf525", BFIN_CPU_BF525
, 0x0002, AC_05000074
},
228 {"bf525", BFIN_CPU_BF525
, 0x0001, AC_05000074
},
229 {"bf525", BFIN_CPU_BF525
, 0x0000, AC_05000074
},
231 {"bf526", BFIN_CPU_BF526
, 0x0002, AC_05000074
},
232 {"bf526", BFIN_CPU_BF526
, 0x0001, AC_05000074
},
233 {"bf526", BFIN_CPU_BF526
, 0x0000, AC_05000074
},
235 {"bf527", BFIN_CPU_BF527
, 0x0002, AC_05000074
},
236 {"bf527", BFIN_CPU_BF527
, 0x0001, AC_05000074
},
237 {"bf527", BFIN_CPU_BF527
, 0x0000, AC_05000074
},
239 {"bf531", BFIN_CPU_BF531
, 0x0006, AC_05000074
},
240 {"bf531", BFIN_CPU_BF531
, 0x0005, AC_05000074
},
241 {"bf531", BFIN_CPU_BF531
, 0x0004, AC_05000074
},
242 {"bf531", BFIN_CPU_BF531
, 0x0003, AC_05000074
},
244 {"bf532", BFIN_CPU_BF532
, 0x0006, AC_05000074
},
245 {"bf532", BFIN_CPU_BF532
, 0x0005, AC_05000074
},
246 {"bf532", BFIN_CPU_BF532
, 0x0004, AC_05000074
},
247 {"bf532", BFIN_CPU_BF532
, 0x0003, AC_05000074
},
249 {"bf533", BFIN_CPU_BF533
, 0x0006, AC_05000074
},
250 {"bf533", BFIN_CPU_BF533
, 0x0005, AC_05000074
},
251 {"bf533", BFIN_CPU_BF533
, 0x0004, AC_05000074
},
252 {"bf533", BFIN_CPU_BF533
, 0x0003, AC_05000074
},
254 {"bf534", BFIN_CPU_BF534
, 0x0003, AC_05000074
},
255 {"bf534", BFIN_CPU_BF534
, 0x0002, AC_05000074
},
256 {"bf534", BFIN_CPU_BF534
, 0x0001, AC_05000074
},
258 {"bf536", BFIN_CPU_BF536
, 0x0003, AC_05000074
},
259 {"bf536", BFIN_CPU_BF536
, 0x0002, AC_05000074
},
260 {"bf536", BFIN_CPU_BF536
, 0x0001, AC_05000074
},
262 {"bf537", BFIN_CPU_BF537
, 0x0003, AC_05000074
},
263 {"bf537", BFIN_CPU_BF537
, 0x0002, AC_05000074
},
264 {"bf537", BFIN_CPU_BF537
, 0x0001, AC_05000074
},
266 {"bf538", BFIN_CPU_BF538
, 0x0005, AC_05000074
},
267 {"bf538", BFIN_CPU_BF538
, 0x0004, AC_05000074
},
268 {"bf538", BFIN_CPU_BF538
, 0x0003, AC_05000074
},
269 {"bf538", BFIN_CPU_BF538
, 0x0002, AC_05000074
},
271 {"bf539", BFIN_CPU_BF539
, 0x0005, AC_05000074
},
272 {"bf539", BFIN_CPU_BF539
, 0x0004, AC_05000074
},
273 {"bf539", BFIN_CPU_BF539
, 0x0003, AC_05000074
},
274 {"bf539", BFIN_CPU_BF539
, 0x0002, AC_05000074
},
276 {"bf542m", BFIN_CPU_BF542M
, 0x0003, AC_05000074
},
278 {"bf542", BFIN_CPU_BF542
, 0x0002, AC_05000074
},
279 {"bf542", BFIN_CPU_BF542
, 0x0001, AC_05000074
},
280 {"bf542", BFIN_CPU_BF542
, 0x0000, AC_05000074
},
282 {"bf544m", BFIN_CPU_BF544M
, 0x0003, AC_05000074
},
284 {"bf544", BFIN_CPU_BF544
, 0x0002, AC_05000074
},
285 {"bf544", BFIN_CPU_BF544
, 0x0001, AC_05000074
},
286 {"bf544", BFIN_CPU_BF544
, 0x0000, AC_05000074
},
288 {"bf547m", BFIN_CPU_BF547M
, 0x0003, AC_05000074
},
290 {"bf547", BFIN_CPU_BF547
, 0x0002, AC_05000074
},
291 {"bf547", BFIN_CPU_BF547
, 0x0001, AC_05000074
},
292 {"bf547", BFIN_CPU_BF547
, 0x0000, AC_05000074
},
294 {"bf548m", BFIN_CPU_BF548M
, 0x0003, AC_05000074
},
296 {"bf548", BFIN_CPU_BF548
, 0x0002, AC_05000074
},
297 {"bf548", BFIN_CPU_BF548
, 0x0001, AC_05000074
},
298 {"bf548", BFIN_CPU_BF548
, 0x0000, AC_05000074
},
300 {"bf549m", BFIN_CPU_BF549M
, 0x0003, AC_05000074
},
302 {"bf549", BFIN_CPU_BF549
, 0x0002, AC_05000074
},
303 {"bf549", BFIN_CPU_BF549
, 0x0001, AC_05000074
},
304 {"bf549", BFIN_CPU_BF549
, 0x0000, AC_05000074
},
306 {"bf561", BFIN_CPU_BF561
, 0x0005, AC_05000074
},
307 {"bf561", BFIN_CPU_BF561
, 0x0003, AC_05000074
},
308 {"bf561", BFIN_CPU_BF561
, 0x0002, AC_05000074
},
313 /* Define bfin-specific command-line options (there are none). */
314 const char *md_shortopts
= "";
316 #define OPTION_FDPIC (OPTION_MD_BASE)
317 #define OPTION_NOPIC (OPTION_MD_BASE + 1)
318 #define OPTION_MCPU (OPTION_MD_BASE + 2)
320 struct option md_longopts
[] =
322 { "mcpu", required_argument
, NULL
, OPTION_MCPU
},
323 { "mfdpic", no_argument
, NULL
, OPTION_FDPIC
},
324 { "mnopic", no_argument
, NULL
, OPTION_NOPIC
},
325 { "mno-fdpic", no_argument
, NULL
, OPTION_NOPIC
},
326 { NULL
, no_argument
, NULL
, 0 },
329 size_t md_longopts_size
= sizeof (md_longopts
);
333 md_parse_option (int c ATTRIBUTE_UNUSED
, char *arg ATTRIBUTE_UNUSED
)
346 while ((p
= bfin_cpus
[i
].name
) != NULL
)
348 if (strncmp (arg
, p
, strlen (p
)) == 0)
354 as_fatal ("-mcpu=%s is not valid", arg
);
356 bfin_cpu_type
= bfin_cpus
[i
].type
;
358 q
= arg
+ strlen (p
);
362 bfin_si_revision
= bfin_cpus
[i
].si_revision
;
363 bfin_anomaly_checks
|= bfin_cpus
[i
].anomaly_checks
;
365 else if (strcmp (q
, "-none") == 0)
366 bfin_si_revision
= -1;
367 else if (strcmp (q
, "-any") == 0)
369 bfin_si_revision
= 0xffff;
370 while (bfin_cpus
[i
].type
== bfin_cpu_type
)
372 bfin_anomaly_checks
|= bfin_cpus
[i
].anomaly_checks
;
378 unsigned int si_major
, si_minor
;
381 rev_len
= strlen (q
);
383 if (sscanf (q
, "-%u.%u%n", &si_major
, &si_minor
, &n
) != 2
385 || si_major
> 0xff || si_minor
> 0xff)
387 invalid_silicon_revision
:
388 as_fatal ("-mcpu=%s has invalid silicon revision", arg
);
391 bfin_si_revision
= (si_major
<< 8) | si_minor
;
393 while (bfin_cpus
[i
].type
== bfin_cpu_type
394 && bfin_cpus
[i
].si_revision
!= bfin_si_revision
)
397 if (bfin_cpus
[i
].type
!= bfin_cpu_type
)
398 goto invalid_silicon_revision
;
400 bfin_anomaly_checks
|= bfin_cpus
[i
].anomaly_checks
;
407 bfin_flags
|= EF_BFIN_FDPIC
;
408 bfin_pic_flag
= "-mfdpic";
412 bfin_flags
&= ~(EF_BFIN_FDPIC
);
421 md_show_usage (FILE * stream ATTRIBUTE_UNUSED
)
423 fprintf (stream
, _(" BFIN specific command line options:\n"));
426 /* Perform machine-specific initializations. */
430 /* Set the ELF flags if desired. */
432 bfd_set_private_flags (stdoutput
, bfin_flags
);
434 /* Set the default machine type. */
435 if (!bfd_set_arch_mach (stdoutput
, bfd_arch_bfin
, 0))
436 as_warn (_("Could not set architecture and machine."));
438 /* Ensure that lines can begin with '(', for multiple
439 register stack pops. */
440 lex_type
['('] = LEX_BEGIN_NAME
;
443 record_alignment (text_section
, 2);
444 record_alignment (data_section
, 2);
445 record_alignment (bss_section
, 2);
449 obstack_init (&mempool
);
452 extern int debug_codeselection
;
453 debug_codeselection
= 1;
459 /* Perform the main parsing, and assembly of the input here. Also,
460 call the required routines for alignment and fixups here.
461 This is called for every line that contains real assembly code. */
464 md_assemble (char *line
)
467 extern char *current_inputline
;
469 struct bfin_insn
*tmp_insn
;
471 static size_t buffer_len
= 0;
475 if (len
+ 2 > buffer_len
)
478 free (current_inputline
);
479 buffer_len
= len
+ 40;
480 current_inputline
= xmalloc (buffer_len
);
482 memcpy (current_inputline
, line
, len
);
483 current_inputline
[len
] = ';';
484 current_inputline
[len
+ 1] = '\0';
486 state
= parse (current_inputline
);
487 if (state
== NO_INSN_GENERATED
)
490 for (insn_size
= 0, tmp_insn
= insn
; tmp_insn
; tmp_insn
= tmp_insn
->next
)
491 if (!tmp_insn
->reloc
|| !tmp_insn
->exp
->symbol
)
495 toP
= frag_more (insn_size
);
497 last_insn_size
= insn_size
;
504 if (insn
->reloc
&& insn
->exp
->symbol
)
506 char *prev_toP
= toP
- 2;
509 case BFD_RELOC_BFIN_24_PCREL_JUMP_L
:
510 case BFD_RELOC_24_PCREL
:
511 case BFD_RELOC_BFIN_16_LOW
:
512 case BFD_RELOC_BFIN_16_HIGH
:
519 /* Following if condition checks for the arithmetic relocations.
520 If the case then it doesn't required to generate the code.
521 It has been assumed that, their ID will be contiguous. */
522 if ((BFD_ARELOC_BFIN_PUSH
<= insn
->reloc
523 && BFD_ARELOC_BFIN_COMP
>= insn
->reloc
)
524 || insn
->reloc
== BFD_RELOC_BFIN_16_IMM
)
528 if (insn
->reloc
== BFD_ARELOC_BFIN_CONST
529 || insn
->reloc
== BFD_ARELOC_BFIN_PUSH
)
533 (prev_toP
- frag_now
->fr_literal
),
534 size
, insn
->exp
->symbol
, insn
->exp
->value
,
535 insn
->pcrel
, insn
->reloc
);
539 md_number_to_chars (toP
, insn
->value
, 2);
545 printf (" %02x%02x", ((unsigned char *) &insn
->value
)[0],
546 ((unsigned char *) &insn
->value
)[1]);
552 dwarf2_emit_insn (insn_size
);
555 while (*line
++ != '\0')
557 bump_line_counters ();
560 /* Parse one line of instructions, and generate opcode for it.
561 To parse the line, YACC and LEX are used, because the instruction set
562 syntax doesn't confirm to the AT&T assembly syntax.
563 To call a YACC & LEX generated parser, we must provide the input via
564 a FILE stream, otherwise stdin is used by default. Below the input
565 to the function will be put into a temporary file, then the generated
566 parser uses the temporary file for parsing. */
572 YY_BUFFER_STATE buffstate
;
574 buffstate
= yy_scan_string (line
);
576 /* our lex requires setting the start state to keyword
577 every line as the first word may be a keyword.
578 Fixes a bug where we could not have keywords as labels. */
581 /* Call yyparse here. */
583 if (state
== SEMANTIC_ERROR
)
585 as_bad (_("Parse failed."));
589 yy_delete_buffer (buffstate
);
593 /* We need to handle various expressions properly.
594 Such as, [SP--] = 34, concerned by md_assemble(). */
597 md_operand (expressionS
* expressionP
)
599 if (*input_line_pointer
== '[')
601 as_tsktsk ("We found a '['!");
602 input_line_pointer
++;
603 expression (expressionP
);
607 /* Handle undefined symbols. */
609 md_undefined_symbol (char *name ATTRIBUTE_UNUSED
)
611 return (symbolS
*) 0;
615 md_estimate_size_before_relax (fragS
* fragP ATTRIBUTE_UNUSED
,
616 segT segment ATTRIBUTE_UNUSED
)
621 /* Convert from target byte order to host byte order. */
624 md_chars_to_number (char *val
, int n
)
628 for (retval
= 0; n
--;)
637 md_apply_fix (fixS
*fixP
, valueT
*valueP
, segT seg ATTRIBUTE_UNUSED
)
639 char *where
= fixP
->fx_frag
->fr_literal
+ fixP
->fx_where
;
641 long value
= *valueP
;
644 switch (fixP
->fx_r_type
)
646 case BFD_RELOC_BFIN_GOT
:
647 case BFD_RELOC_BFIN_GOT17M4
:
648 case BFD_RELOC_BFIN_FUNCDESC_GOT17M4
:
649 fixP
->fx_no_overflow
= 1;
650 newval
= md_chars_to_number (where
, 2);
651 newval
|= 0x0 & 0x7f;
652 md_number_to_chars (where
, newval
, 2);
655 case BFD_RELOC_BFIN_10_PCREL
:
658 if (value
< -1024 || value
> 1022)
659 as_bad_where (fixP
->fx_file
, fixP
->fx_line
,
660 _("pcrel too far BFD_RELOC_BFIN_10"));
662 /* 11 bit offset even numbered, so we remove right bit. */
664 newval
= md_chars_to_number (where
, 2);
665 newval
|= value
& 0x03ff;
666 md_number_to_chars (where
, newval
, 2);
669 case BFD_RELOC_BFIN_12_PCREL_JUMP
:
670 case BFD_RELOC_BFIN_12_PCREL_JUMP_S
:
671 case BFD_RELOC_12_PCREL
:
675 if (value
< -4096 || value
> 4094)
676 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("pcrel too far BFD_RELOC_BFIN_12"));
677 /* 13 bit offset even numbered, so we remove right bit. */
679 newval
= md_chars_to_number (where
, 2);
680 newval
|= value
& 0xfff;
681 md_number_to_chars (where
, newval
, 2);
684 case BFD_RELOC_BFIN_16_LOW
:
685 case BFD_RELOC_BFIN_16_HIGH
:
686 fixP
->fx_done
= FALSE
;
689 case BFD_RELOC_BFIN_24_PCREL_JUMP_L
:
690 case BFD_RELOC_BFIN_24_PCREL_CALL_X
:
691 case BFD_RELOC_24_PCREL
:
695 if (value
< -16777216 || value
> 16777214)
696 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("pcrel too far BFD_RELOC_BFIN_24"));
698 /* 25 bit offset even numbered, so we remove right bit. */
702 md_number_to_chars (where
- 2, value
>> 16, 1);
703 md_number_to_chars (where
, value
, 1);
704 md_number_to_chars (where
+ 1, value
>> 8, 1);
707 case BFD_RELOC_BFIN_5_PCREL
: /* LSETUP (a, b) : "a" */
710 if (value
< 4 || value
> 30)
711 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("pcrel too far BFD_RELOC_BFIN_5"));
713 newval
= md_chars_to_number (where
, 1);
714 newval
= (newval
& 0xf0) | (value
& 0xf);
715 md_number_to_chars (where
, newval
, 1);
718 case BFD_RELOC_BFIN_11_PCREL
: /* LSETUP (a, b) : "b" */
722 if (value
< 4 || value
> 2046)
723 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("pcrel too far BFD_RELOC_BFIN_11_PCREL"));
724 /* 11 bit unsigned even, so we remove right bit. */
726 newval
= md_chars_to_number (where
, 2);
727 newval
|= value
& 0x03ff;
728 md_number_to_chars (where
, newval
, 2);
732 if (value
< -0x80 || value
>= 0x7f)
733 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("rel too far BFD_RELOC_8"));
734 md_number_to_chars (where
, value
, 1);
737 case BFD_RELOC_BFIN_16_IMM
:
739 if (value
< -0x8000 || value
>= 0x7fff)
740 as_bad_where (fixP
->fx_file
, fixP
->fx_line
, _("rel too far BFD_RELOC_16"));
741 md_number_to_chars (where
, value
, 2);
745 md_number_to_chars (where
, value
, 4);
748 case BFD_RELOC_BFIN_PLTPC
:
749 md_number_to_chars (where
, value
, 2);
752 case BFD_RELOC_BFIN_FUNCDESC
:
753 case BFD_RELOC_VTABLE_INHERIT
:
754 case BFD_RELOC_VTABLE_ENTRY
:
755 fixP
->fx_done
= FALSE
;
759 if ((BFD_ARELOC_BFIN_PUSH
> fixP
->fx_r_type
) || (BFD_ARELOC_BFIN_COMP
< fixP
->fx_r_type
))
761 fprintf (stderr
, "Relocation %d not handled in gas." " Contact support.\n", fixP
->fx_r_type
);
767 fixP
->fx_done
= TRUE
;
771 /* Round up a section size to the appropriate boundary. */
773 md_section_align (segment
, size
)
777 int boundary
= bfd_get_section_alignment (stdoutput
, segment
);
778 return ((size
+ (1 << boundary
) - 1) & (-1 << boundary
));
783 md_atof (int type
, char * litP
, int * sizeP
)
785 return ieee_md_atof (type
, litP
, sizeP
, FALSE
);
789 /* If while processing a fixup, a reloc really needs to be created
790 then it is done here. */
793 tc_gen_reloc (seg
, fixp
)
794 asection
*seg ATTRIBUTE_UNUSED
;
799 reloc
= (arelent
*) xmalloc (sizeof (arelent
));
800 reloc
->sym_ptr_ptr
= (asymbol
**) xmalloc (sizeof (asymbol
*));
801 *reloc
->sym_ptr_ptr
= symbol_get_bfdsym (fixp
->fx_addsy
);
802 reloc
->address
= fixp
->fx_frag
->fr_address
+ fixp
->fx_where
;
804 reloc
->addend
= fixp
->fx_offset
;
805 reloc
->howto
= bfd_reloc_type_lookup (stdoutput
, fixp
->fx_r_type
);
807 if (reloc
->howto
== (reloc_howto_type
*) NULL
)
809 as_bad_where (fixp
->fx_file
, fixp
->fx_line
,
810 /* xgettext:c-format. */
811 _("reloc %d not supported by object file format"),
812 (int) fixp
->fx_r_type
);
822 /* The location from which a PC relative jump should be calculated,
823 given a PC relative reloc. */
826 md_pcrel_from_section (fixP
, sec
)
830 if (fixP
->fx_addsy
!= (symbolS
*) NULL
831 && (!S_IS_DEFINED (fixP
->fx_addsy
)
832 || S_GET_SEGMENT (fixP
->fx_addsy
) != sec
))
834 /* The symbol is undefined (or is defined but not in this section).
835 Let the linker figure it out. */
838 return fixP
->fx_frag
->fr_address
+ fixP
->fx_where
;
841 /* Return true if the fix can be handled by GAS, false if it must
842 be passed through to the linker. */
845 bfin_fix_adjustable (fixS
*fixP
)
847 switch (fixP
->fx_r_type
)
849 /* Adjust_reloc_syms doesn't know about the GOT. */
850 case BFD_RELOC_BFIN_GOT
:
851 case BFD_RELOC_BFIN_PLTPC
:
852 /* We need the symbol name for the VTABLE entries. */
853 case BFD_RELOC_VTABLE_INHERIT
:
854 case BFD_RELOC_VTABLE_ENTRY
:
862 /* Special extra functions that help bfin-parse.y perform its job. */
864 struct obstack mempool
;
867 conscode (INSTR_T head
, INSTR_T tail
)
876 conctcode (INSTR_T head
, INSTR_T tail
)
878 INSTR_T temp
= (head
);
889 note_reloc (INSTR_T code
, Expr_Node
* symbol
, int reloc
, int pcrel
)
891 /* Assert that the symbol is not an operator. */
892 gas_assert (symbol
->type
== Expr_Node_Reloc
);
894 return note_reloc1 (code
, symbol
->value
.s_value
, reloc
, pcrel
);
899 note_reloc1 (INSTR_T code
, const char *symbol
, int reloc
, int pcrel
)
902 code
->exp
= mkexpr (0, symbol_find_or_make (symbol
));
908 note_reloc2 (INSTR_T code
, const char *symbol
, int reloc
, int value
, int pcrel
)
911 code
->exp
= mkexpr (value
, symbol_find_or_make (symbol
));
917 gencode (unsigned long x
)
919 INSTR_T cell
= obstack_alloc (&mempool
, sizeof (struct bfin_insn
));
920 memset (cell
, 0, sizeof (struct bfin_insn
));
932 return obstack_alloc (&mempool
, n
);
936 Expr_Node_Create (Expr_Node_Type type
,
937 Expr_Node_Value value
,
938 Expr_Node
*Left_Child
,
939 Expr_Node
*Right_Child
)
943 Expr_Node
*node
= (Expr_Node
*) allocate (sizeof (Expr_Node
));
946 node
->Left_Child
= Left_Child
;
947 node
->Right_Child
= Right_Child
;
951 static const char *con
= ".__constant";
952 static const char *op
= ".__operator";
953 static INSTR_T
Expr_Node_Gen_Reloc_R (Expr_Node
* head
);
954 INSTR_T
Expr_Node_Gen_Reloc (Expr_Node
*head
, int parent_reloc
);
957 Expr_Node_Gen_Reloc (Expr_Node
* head
, int parent_reloc
)
959 /* Top level reloction expression generator VDSP style.
960 If the relocation is just by itself, generate one item
961 else generate this convoluted expression. */
963 INSTR_T note
= NULL_CODE
;
964 INSTR_T note1
= NULL_CODE
;
965 int pcrel
= 1; /* Is the parent reloc pcrelative?
966 This calculation here and HOWTO should match. */
970 /* If it's 32 bit quantity then 16bit code needs to be added. */
973 if (head
->type
== Expr_Node_Constant
)
975 /* If note1 is not null code, we have to generate a right
976 aligned value for the constant. Otherwise the reloc is
977 a part of the basic command and the yacc file
979 value
= head
->value
.i_value
;
981 switch (parent_reloc
)
983 /* Some relocations will need to allocate extra words. */
984 case BFD_RELOC_BFIN_16_IMM
:
985 case BFD_RELOC_BFIN_16_LOW
:
986 case BFD_RELOC_BFIN_16_HIGH
:
987 note1
= conscode (gencode (value
), NULL_CODE
);
990 case BFD_RELOC_BFIN_PLTPC
:
991 note1
= conscode (gencode (value
), NULL_CODE
);
995 case BFD_RELOC_BFIN_GOT
:
996 case BFD_RELOC_BFIN_GOT17M4
:
997 case BFD_RELOC_BFIN_FUNCDESC_GOT17M4
:
998 note1
= conscode (gencode (value
), NULL_CODE
);
1001 case BFD_RELOC_24_PCREL
:
1002 case BFD_RELOC_BFIN_24_PCREL_JUMP_L
:
1003 case BFD_RELOC_BFIN_24_PCREL_CALL_X
:
1004 /* These offsets are even numbered pcrel. */
1005 note1
= conscode (gencode (value
>> 1), NULL_CODE
);
1011 if (head
->type
== Expr_Node_Constant
)
1013 else if (head
->type
== Expr_Node_Reloc
)
1015 note
= note_reloc1 (gencode (0), head
->value
.s_value
, parent_reloc
, pcrel
);
1016 if (note1
!= NULL_CODE
)
1017 note
= conscode (note1
, note
);
1019 else if (head
->type
== Expr_Node_Binop
1020 && (head
->value
.op_value
== Expr_Op_Type_Add
1021 || head
->value
.op_value
== Expr_Op_Type_Sub
)
1022 && head
->Left_Child
->type
== Expr_Node_Reloc
1023 && head
->Right_Child
->type
== Expr_Node_Constant
)
1025 int val
= head
->Right_Child
->value
.i_value
;
1026 if (head
->value
.op_value
== Expr_Op_Type_Sub
)
1028 note
= conscode (note_reloc2 (gencode (0), head
->Left_Child
->value
.s_value
,
1029 parent_reloc
, val
, 0),
1031 if (note1
!= NULL_CODE
)
1032 note
= conscode (note1
, note
);
1036 /* Call the recursive function. */
1037 note
= note_reloc1 (gencode (0), op
, parent_reloc
, pcrel
);
1038 if (note1
!= NULL_CODE
)
1039 note
= conscode (note1
, note
);
1040 note
= conctcode (Expr_Node_Gen_Reloc_R (head
), note
);
1046 Expr_Node_Gen_Reloc_R (Expr_Node
* head
)
1054 case Expr_Node_Constant
:
1055 note
= conscode (note_reloc2 (gencode (0), con
, BFD_ARELOC_BFIN_CONST
, head
->value
.i_value
, 0), NULL_CODE
);
1057 case Expr_Node_Reloc
:
1058 note
= conscode (note_reloc (gencode (0), head
, BFD_ARELOC_BFIN_PUSH
, 0), NULL_CODE
);
1060 case Expr_Node_Binop
:
1061 note1
= conctcode (Expr_Node_Gen_Reloc_R (head
->Left_Child
), Expr_Node_Gen_Reloc_R (head
->Right_Child
));
1062 switch (head
->value
.op_value
)
1064 case Expr_Op_Type_Add
:
1065 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_ADD
, 0), NULL_CODE
));
1067 case Expr_Op_Type_Sub
:
1068 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_SUB
, 0), NULL_CODE
));
1070 case Expr_Op_Type_Mult
:
1071 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_MULT
, 0), NULL_CODE
));
1073 case Expr_Op_Type_Div
:
1074 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_DIV
, 0), NULL_CODE
));
1076 case Expr_Op_Type_Mod
:
1077 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_MOD
, 0), NULL_CODE
));
1079 case Expr_Op_Type_Lshift
:
1080 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_LSHIFT
, 0), NULL_CODE
));
1082 case Expr_Op_Type_Rshift
:
1083 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_RSHIFT
, 0), NULL_CODE
));
1085 case Expr_Op_Type_BAND
:
1086 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_AND
, 0), NULL_CODE
));
1088 case Expr_Op_Type_BOR
:
1089 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_OR
, 0), NULL_CODE
));
1091 case Expr_Op_Type_BXOR
:
1092 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_XOR
, 0), NULL_CODE
));
1094 case Expr_Op_Type_LAND
:
1095 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_LAND
, 0), NULL_CODE
));
1097 case Expr_Op_Type_LOR
:
1098 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_LOR
, 0), NULL_CODE
));
1101 fprintf (stderr
, "%s:%d:Unknown operator found for arithmetic" " relocation", __FILE__
, __LINE__
);
1106 case Expr_Node_Unop
:
1107 note1
= conscode (Expr_Node_Gen_Reloc_R (head
->Left_Child
), NULL_CODE
);
1108 switch (head
->value
.op_value
)
1110 case Expr_Op_Type_NEG
:
1111 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_NEG
, 0), NULL_CODE
));
1113 case Expr_Op_Type_COMP
:
1114 note
= conctcode (note1
, conscode (note_reloc1 (gencode (0), op
, BFD_ARELOC_BFIN_COMP
, 0), NULL_CODE
));
1117 fprintf (stderr
, "%s:%d:Unknown operator found for arithmetic" " relocation", __FILE__
, __LINE__
);
1121 fprintf (stderr
, "%s:%d:Unknown node expression found during " "arithmetic relocation generation", __FILE__
, __LINE__
);
1126 /* Blackfin opcode generation. */
1128 /* These functions are called by the generated parser
1129 (from bfin-parse.y), the register type classification
1130 happens in bfin-lex.l. */
1132 #include "bfin-aux.h"
1133 #include "opcode/bfin.h"
1135 #define INIT(t) t c_code = init_##t
1136 #define ASSIGN(x) c_code.opcode |= ((x & c_code.mask_##x)<<c_code.bits_##x)
1137 #define ASSIGNF(x,f) c_code.opcode |= ((x & c_code.mask_##f)<<c_code.bits_##f)
1138 #define ASSIGN_R(x) c_code.opcode |= (((x ? (x->regno & CODE_MASK) : 0) & c_code.mask_##x)<<c_code.bits_##x)
1140 #define HI(x) ((x >> 16) & 0xffff)
1141 #define LO(x) ((x ) & 0xffff)
1143 #define GROUP(x) ((x->regno & CLASS_MASK) >> 4)
1145 #define GEN_OPCODE32() \
1146 conscode (gencode (HI (c_code.opcode)), \
1147 conscode (gencode (LO (c_code.opcode)), NULL_CODE))
1149 #define GEN_OPCODE16() \
1150 conscode (gencode (c_code.opcode), NULL_CODE)
1153 /* 32 BIT INSTRUCTIONS. */
1156 /* DSP32 instruction generation. */
1159 bfin_gen_dsp32mac (int op1
, int MM
, int mmod
, int w1
, int P
,
1160 int h01
, int h11
, int h00
, int h10
, int op0
,
1161 REG_T dst
, REG_T src0
, REG_T src1
, int w0
)
1177 /* If we have full reg assignments, mask out LSB to encode
1178 single or simultaneous even/odd register moves. */
1188 return GEN_OPCODE32 ();
1192 bfin_gen_dsp32mult (int op1
, int MM
, int mmod
, int w1
, int P
,
1193 int h01
, int h11
, int h00
, int h10
, int op0
,
1194 REG_T dst
, REG_T src0
, REG_T src1
, int w0
)
1219 return GEN_OPCODE32 ();
1223 bfin_gen_dsp32alu (int HL
, int aopcde
, int aop
, int s
, int x
,
1224 REG_T dst0
, REG_T dst1
, REG_T src0
, REG_T src1
)
1238 return GEN_OPCODE32 ();
1242 bfin_gen_dsp32shift (int sopcde
, REG_T dst0
, REG_T src0
,
1243 REG_T src1
, int sop
, int HLs
)
1255 return GEN_OPCODE32 ();
1259 bfin_gen_dsp32shiftimm (int sopcde
, REG_T dst0
, int immag
,
1260 REG_T src1
, int sop
, int HLs
)
1262 INIT (DSP32ShiftImm
);
1272 return GEN_OPCODE32 ();
1278 bfin_gen_loopsetup (Expr_Node
* psoffset
, REG_T c
, int rop
,
1279 Expr_Node
* peoffset
, REG_T reg
)
1281 int soffset
, eoffset
;
1284 soffset
= (EXPR_VALUE (psoffset
) >> 1);
1286 eoffset
= (EXPR_VALUE (peoffset
) >> 1);
1293 conscode (gencode (HI (c_code
.opcode
)),
1294 conctcode (Expr_Node_Gen_Reloc (psoffset
, BFD_RELOC_BFIN_5_PCREL
),
1295 conctcode (gencode (LO (c_code
.opcode
)), Expr_Node_Gen_Reloc (peoffset
, BFD_RELOC_BFIN_11_PCREL
))));
1302 bfin_gen_calla (Expr_Node
* addr
, int S
)
1310 case 0 : rel
= BFD_RELOC_BFIN_24_PCREL_JUMP_L
; break;
1311 case 1 : rel
= BFD_RELOC_24_PCREL
; break;
1312 case 2 : rel
= BFD_RELOC_BFIN_PLTPC
; break;
1318 val
= EXPR_VALUE (addr
) >> 1;
1319 high_val
= val
>> 16;
1321 return conscode (gencode (HI (c_code
.opcode
) | (high_val
& 0xff)),
1322 Expr_Node_Gen_Reloc (addr
, rel
));
1326 bfin_gen_linkage (int R
, int framesize
)
1333 return GEN_OPCODE32 ();
1337 /* Load and Store. */
1340 bfin_gen_ldimmhalf (REG_T reg
, int H
, int S
, int Z
, Expr_Node
* phword
, int rel
)
1343 unsigned val
= EXPR_VALUE (phword
);
1351 grp
= (GROUP (reg
));
1355 return conscode (gencode (HI (c_code
.opcode
)), Expr_Node_Gen_Reloc (phword
, BFD_RELOC_BFIN_16_IMM
));
1359 return conscode (gencode (HI (c_code
.opcode
)), Expr_Node_Gen_Reloc (phword
, IS_H (*reg
) ? BFD_RELOC_BFIN_16_HIGH
: BFD_RELOC_BFIN_16_LOW
));
1366 return GEN_OPCODE32 ();
1370 bfin_gen_ldstidxi (REG_T ptr
, REG_T reg
, int W
, int sz
, int Z
, Expr_Node
* poffset
)
1374 if (!IS_PREG (*ptr
) || (!IS_DREG (*reg
) && !Z
))
1376 fprintf (stderr
, "Warning: possible mixup of Preg/Dreg\n");
1387 if (poffset
->type
!= Expr_Node_Constant
)
1389 /* a GOT relocation such as R0 = [P5 + symbol@GOT] */
1390 /* distinguish between R0 = [P5 + symbol@GOT] and
1391 P5 = [P5 + _current_shared_library_p5_offset_]
1393 if (poffset
->type
== Expr_Node_Reloc
1394 && !strcmp (poffset
->value
.s_value
,
1395 "_current_shared_library_p5_offset_"))
1397 return conscode (gencode (HI (c_code
.opcode
)),
1398 Expr_Node_Gen_Reloc(poffset
, BFD_RELOC_16
));
1400 else if (poffset
->type
!= Expr_Node_GOT_Reloc
)
1403 return conscode (gencode (HI (c_code
.opcode
)),
1404 Expr_Node_Gen_Reloc(poffset
->Left_Child
,
1405 poffset
->value
.i_value
));
1411 { /* load/store access size */
1412 case 0: /* 32 bit */
1413 value
= EXPR_VALUE (poffset
) >> 2;
1415 case 1: /* 16 bit */
1416 value
= EXPR_VALUE (poffset
) >> 1;
1419 value
= EXPR_VALUE (poffset
);
1425 offset
= (value
& 0xffff);
1427 return GEN_OPCODE32 ();
1433 bfin_gen_ldst (REG_T ptr
, REG_T reg
, int aop
, int sz
, int Z
, int W
)
1437 if (!IS_PREG (*ptr
) || (!IS_DREG (*reg
) && !Z
))
1439 fprintf (stderr
, "Warning: possible mixup of Preg/Dreg\n");
1450 return GEN_OPCODE16 ();
1454 bfin_gen_ldstii (REG_T ptr
, REG_T reg
, Expr_Node
* poffset
, int W
, int opc
)
1460 if (!IS_PREG (*ptr
))
1462 fprintf (stderr
, "Warning: possible mixup of Preg/Dreg\n");
1470 value
= EXPR_VALUE (poffset
) >> 1;
1474 value
= EXPR_VALUE (poffset
) >> 2;
1486 return GEN_OPCODE16 ();
1490 bfin_gen_ldstiifp (REG_T sreg
, Expr_Node
* poffset
, int W
)
1492 /* Set bit 4 if it's a Preg. */
1493 int reg
= (sreg
->regno
& CODE_MASK
) | (IS_PREG (*sreg
) ? 0x8 : 0x0);
1494 int offset
= ((~(EXPR_VALUE (poffset
) >> 2)) & 0x1f) + 1;
1500 return GEN_OPCODE16 ();
1504 bfin_gen_ldstpmod (REG_T ptr
, REG_T reg
, int aop
, int W
, REG_T idx
)
1514 return GEN_OPCODE16 ();
1518 bfin_gen_dspldst (REG_T i
, REG_T reg
, int aop
, int W
, int m
)
1528 return GEN_OPCODE16 ();
1532 bfin_gen_logi2op (int opc
, int src
, int dst
)
1540 return GEN_OPCODE16 ();
1544 bfin_gen_brcc (int T
, int B
, Expr_Node
* poffset
)
1551 offset
= ((EXPR_VALUE (poffset
) >> 1));
1553 return conscode (gencode (c_code
.opcode
), Expr_Node_Gen_Reloc (poffset
, BFD_RELOC_BFIN_10_PCREL
));
1557 bfin_gen_ujump (Expr_Node
* poffset
)
1562 offset
= ((EXPR_VALUE (poffset
) >> 1));
1565 return conscode (gencode (c_code
.opcode
),
1566 Expr_Node_Gen_Reloc (
1567 poffset
, BFD_RELOC_BFIN_12_PCREL_JUMP_S
));
1571 bfin_gen_alu2op (REG_T dst
, REG_T src
, int opc
)
1579 return GEN_OPCODE16 ();
1583 bfin_gen_compi2opd (REG_T dst
, int src
, int opc
)
1591 return GEN_OPCODE16 ();
1595 bfin_gen_compi2opp (REG_T dst
, int src
, int opc
)
1603 return GEN_OPCODE16 ();
1607 bfin_gen_dagmodik (REG_T i
, int opc
)
1614 return GEN_OPCODE16 ();
1618 bfin_gen_dagmodim (REG_T i
, REG_T m
, int opc
, int br
)
1627 return GEN_OPCODE16 ();
1631 bfin_gen_ptr2op (REG_T dst
, REG_T src
, int opc
)
1639 return GEN_OPCODE16 ();
1643 bfin_gen_comp3op (REG_T src0
, REG_T src1
, REG_T dst
, int opc
)
1652 return GEN_OPCODE16 ();
1656 bfin_gen_ccflag (REG_T x
, int y
, int opc
, int I
, int G
)
1666 return GEN_OPCODE16 ();
1670 bfin_gen_ccmv (REG_T src
, REG_T dst
, int T
)
1683 return GEN_OPCODE16 ();
1687 bfin_gen_cc2stat (int cbit
, int opc
, int D
)
1695 return GEN_OPCODE16 ();
1699 bfin_gen_regmv (REG_T src
, REG_T dst
)
1712 return GEN_OPCODE16 ();
1716 bfin_gen_cc2dreg (int opc
, REG_T reg
)
1723 return GEN_OPCODE16 ();
1727 bfin_gen_progctrl (int prgfunc
, int poprnd
)
1734 return GEN_OPCODE16 ();
1738 bfin_gen_cactrl (REG_T reg
, int a
, int opc
)
1746 return GEN_OPCODE16 ();
1750 bfin_gen_pushpopmultiple (int dr
, int pr
, int d
, int p
, int W
)
1752 INIT (PushPopMultiple
);
1760 return GEN_OPCODE16 ();
1764 bfin_gen_pushpopreg (REG_T reg
, int W
)
1770 grp
= (GROUP (reg
));
1774 return GEN_OPCODE16 ();
1777 /* Pseudo Debugging Support. */
1780 bfin_gen_pseudodbg (int fn
, int reg
, int grp
)
1788 return GEN_OPCODE16 ();
1792 bfin_gen_pseudodbg_assert (int dbgop
, REG_T regtest
, int expected
)
1795 INIT (PseudoDbg_Assert
);
1799 grp
= GROUP (regtest
);
1803 return GEN_OPCODE32 ();
1806 /* Multiple instruction generation. */
1809 bfin_gen_multi_instr (INSTR_T dsp32
, INSTR_T dsp16_grp1
, INSTR_T dsp16_grp2
)
1813 /* If it's a 0, convert into MNOP. */
1817 SET_MULTI_INSTRUCTION_BIT (dsp32
);
1821 dsp32
= gencode (0xc803);
1822 walk
= gencode (0x1800);
1828 dsp16_grp1
= gencode (0x0000);
1833 dsp16_grp2
= gencode (0x0000);
1836 walk
->next
= dsp16_grp1
;
1837 dsp16_grp1
->next
= dsp16_grp2
;
1838 dsp16_grp2
->next
= NULL_CODE
;
1844 bfin_gen_loop (Expr_Node
*exp
, REG_T reg
, int rop
, REG_T preg
)
1846 const char *loopsym
;
1847 char *lbeginsym
, *lendsym
;
1848 Expr_Node_Value lbeginval
, lendval
;
1849 Expr_Node
*lbegin
, *lend
;
1851 loopsym
= exp
->value
.s_value
;
1852 lbeginsym
= (char *) xmalloc (strlen (loopsym
) + strlen ("__BEGIN") + 5);
1853 lendsym
= (char *) xmalloc (strlen (loopsym
) + strlen ("__END") + 5);
1858 strcat (lbeginsym
, "L$L$");
1859 strcat (lbeginsym
, loopsym
);
1860 strcat (lbeginsym
, "__BEGIN");
1862 strcat (lendsym
, "L$L$");
1863 strcat (lendsym
, loopsym
);
1864 strcat (lendsym
, "__END");
1866 lbeginval
.s_value
= lbeginsym
;
1867 lendval
.s_value
= lendsym
;
1869 lbegin
= Expr_Node_Create (Expr_Node_Reloc
, lbeginval
, NULL
, NULL
);
1870 lend
= Expr_Node_Create (Expr_Node_Reloc
, lendval
, NULL
, NULL
);
1872 symbol_remove (symbol_find (loopsym
), &symbol_rootP
, &symbol_lastP
);
1874 return bfin_gen_loopsetup(lbegin
, reg
, rop
, lend
, preg
);
1878 bfin_loop_beginend (Expr_Node
*exp
, int begin
)
1880 const char *loopsym
;
1883 const char *suffix
= begin
? "__BEGIN" : "__END";
1885 loopsym
= exp
->value
.s_value
;
1886 label_name
= (char *) xmalloc (strlen (loopsym
) + strlen (suffix
) + 5);
1890 strcat (label_name
, "L$L$");
1891 strcat (label_name
, loopsym
);
1892 strcat (label_name
, suffix
);
1894 linelabel
= colon (label_name
);
1896 /* LOOP_END follows the last instruction in the loop.
1897 Adjust label address. */
1899 ((struct local_symbol
*) linelabel
)->lsy_value
-= last_insn_size
;
1903 bfin_eol_in_insn (char *line
)
1905 /* Allow a new-line to appear in the middle of a multi-issue instruction. */
1912 /* A semi-colon followed by a newline is always the end of a line. */
1913 if (line
[-1] == ';')
1916 if (line
[-1] == '|')
1919 /* If the || is on the next line, there might be leading whitespace. */
1921 while (*temp
== ' ' || *temp
== '\t') temp
++;
1930 bfin_start_label (char *s
, char *ptr
)
1934 if (*s
== '(' || *s
== '[')
1943 bfin_force_relocation (struct fix
*fixp
)
1945 if (fixp
->fx_r_type
==BFD_RELOC_BFIN_16_LOW
1946 || fixp
->fx_r_type
== BFD_RELOC_BFIN_16_HIGH
)
1949 return generic_force_reloc (fixp
);
1952 /* This is a stripped down version of the disassembler. The only thing it
1953 does is return a mask of registers modified by an instruction. Only
1954 instructions that can occur in a parallel-issue bundle are handled, and
1955 only the registers that can cause a conflict are recorded. */
1957 #define DREG_MASK(n) (0x101 << (n))
1958 #define DREGH_MASK(n) (0x100 << (n))
1959 #define DREGL_MASK(n) (0x001 << (n))
1960 #define IREG_MASK(n) (1 << ((n) + 16))
1963 decode_ProgCtrl_0 (int iw0
)
1971 decode_LDSTpmod_0 (int iw0
)
1974 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
1975 | 1 | 0 | 0 | 0 |.W.|.aop...|.reg.......|.idx.......|.ptr.......|
1976 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
1977 int W
= ((iw0
>> LDSTpmod_W_bits
) & LDSTpmod_W_mask
);
1978 int aop
= ((iw0
>> LDSTpmod_aop_bits
) & LDSTpmod_aop_mask
);
1979 int idx
= ((iw0
>> LDSTpmod_idx_bits
) & LDSTpmod_idx_mask
);
1980 int ptr
= ((iw0
>> LDSTpmod_ptr_bits
) & LDSTpmod_ptr_mask
);
1981 int reg
= ((iw0
>> LDSTpmod_reg_bits
) & LDSTpmod_reg_mask
);
1983 if (aop
== 1 && W
== 0 && idx
== ptr
)
1984 return DREGL_MASK (reg
);
1985 else if (aop
== 2 && W
== 0 && idx
== ptr
)
1986 return DREGH_MASK (reg
);
1987 else if (aop
== 1 && W
== 1 && idx
== ptr
)
1989 else if (aop
== 2 && W
== 1 && idx
== ptr
)
1991 else if (aop
== 0 && W
== 0)
1992 return DREG_MASK (reg
);
1993 else if (aop
== 1 && W
== 0)
1994 return DREGL_MASK (reg
);
1995 else if (aop
== 2 && W
== 0)
1996 return DREGH_MASK (reg
);
1997 else if (aop
== 3 && W
== 0)
1998 return DREG_MASK (reg
);
1999 else if (aop
== 3 && W
== 1)
2000 return DREG_MASK (reg
);
2001 else if (aop
== 0 && W
== 1)
2003 else if (aop
== 1 && W
== 1)
2005 else if (aop
== 2 && W
== 1)
2014 decode_dagMODim_0 (int iw0
)
2017 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2018 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 |.br| 1 | 1 |.op|.m.....|.i.....|
2019 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2020 int i
= ((iw0
>> DagMODim_i_bits
) & DagMODim_i_mask
);
2021 int opc
= ((iw0
>> DagMODim_op_bits
) & DagMODim_op_mask
);
2023 if (opc
== 0 || opc
== 1)
2024 return IREG_MASK (i
);
2032 decode_dagMODik_0 (int iw0
)
2035 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2036 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0 |.op....|.i.....|
2037 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2038 int i
= ((iw0
>> DagMODik_i_bits
) & DagMODik_i_mask
);
2039 return IREG_MASK (i
);
2044 decode_dspLDST_0 (int iw0
)
2047 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2048 | 1 | 0 | 0 | 1 | 1 | 1 |.W.|.aop...|.m.....|.i.....|.reg.......|
2049 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2050 int i
= ((iw0
>> DspLDST_i_bits
) & DspLDST_i_mask
);
2051 int m
= ((iw0
>> DspLDST_m_bits
) & DspLDST_m_mask
);
2052 int W
= ((iw0
>> DspLDST_W_bits
) & DspLDST_W_mask
);
2053 int aop
= ((iw0
>> DspLDST_aop_bits
) & DspLDST_aop_mask
);
2054 int reg
= ((iw0
>> DspLDST_reg_bits
) & DspLDST_reg_mask
);
2056 if (aop
== 0 && W
== 0 && m
== 0)
2057 return DREG_MASK (reg
) | IREG_MASK (i
);
2058 else if (aop
== 0 && W
== 0 && m
== 1)
2059 return DREGL_MASK (reg
) | IREG_MASK (i
);
2060 else if (aop
== 0 && W
== 0 && m
== 2)
2061 return DREGH_MASK (reg
) | IREG_MASK (i
);
2062 else if (aop
== 1 && W
== 0 && m
== 0)
2063 return DREG_MASK (reg
) | IREG_MASK (i
);
2064 else if (aop
== 1 && W
== 0 && m
== 1)
2065 return DREGL_MASK (reg
) | IREG_MASK (i
);
2066 else if (aop
== 1 && W
== 0 && m
== 2)
2067 return DREGH_MASK (reg
) | IREG_MASK (i
);
2068 else if (aop
== 2 && W
== 0 && m
== 0)
2069 return DREG_MASK (reg
);
2070 else if (aop
== 2 && W
== 0 && m
== 1)
2071 return DREGL_MASK (reg
);
2072 else if (aop
== 2 && W
== 0 && m
== 2)
2073 return DREGH_MASK (reg
);
2074 else if (aop
== 0 && W
== 1 && m
== 0)
2075 return IREG_MASK (i
);
2076 else if (aop
== 0 && W
== 1 && m
== 1)
2077 return IREG_MASK (i
);
2078 else if (aop
== 0 && W
== 1 && m
== 2)
2079 return IREG_MASK (i
);
2080 else if (aop
== 1 && W
== 1 && m
== 0)
2081 return IREG_MASK (i
);
2082 else if (aop
== 1 && W
== 1 && m
== 1)
2083 return IREG_MASK (i
);
2084 else if (aop
== 1 && W
== 1 && m
== 2)
2085 return IREG_MASK (i
);
2086 else if (aop
== 2 && W
== 1 && m
== 0)
2088 else if (aop
== 2 && W
== 1 && m
== 1)
2090 else if (aop
== 2 && W
== 1 && m
== 2)
2092 else if (aop
== 3 && W
== 0)
2093 return DREG_MASK (reg
) | IREG_MASK (i
);
2094 else if (aop
== 3 && W
== 1)
2095 return IREG_MASK (i
);
2102 decode_LDST_0 (int iw0
)
2105 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2106 | 1 | 0 | 0 | 1 |.sz....|.W.|.aop...|.Z.|.ptr.......|.reg.......|
2107 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2108 int Z
= ((iw0
>> LDST_Z_bits
) & LDST_Z_mask
);
2109 int W
= ((iw0
>> LDST_W_bits
) & LDST_W_mask
);
2110 int sz
= ((iw0
>> LDST_sz_bits
) & LDST_sz_mask
);
2111 int aop
= ((iw0
>> LDST_aop_bits
) & LDST_aop_mask
);
2112 int reg
= ((iw0
>> LDST_reg_bits
) & LDST_reg_mask
);
2114 if (aop
== 0 && sz
== 0 && Z
== 0 && W
== 0)
2115 return DREG_MASK (reg
);
2116 else if (aop
== 0 && sz
== 0 && Z
== 1 && W
== 0)
2118 else if (aop
== 0 && sz
== 1 && Z
== 0 && W
== 0)
2119 return DREG_MASK (reg
);
2120 else if (aop
== 0 && sz
== 1 && Z
== 1 && W
== 0)
2121 return DREG_MASK (reg
);
2122 else if (aop
== 0 && sz
== 2 && Z
== 0 && W
== 0)
2123 return DREG_MASK (reg
);
2124 else if (aop
== 0 && sz
== 2 && Z
== 1 && W
== 0)
2125 return DREG_MASK (reg
);
2126 else if (aop
== 1 && sz
== 0 && Z
== 0 && W
== 0)
2127 return DREG_MASK (reg
);
2128 else if (aop
== 1 && sz
== 0 && Z
== 1 && W
== 0)
2130 else if (aop
== 1 && sz
== 1 && Z
== 0 && W
== 0)
2131 return DREG_MASK (reg
);
2132 else if (aop
== 1 && sz
== 1 && Z
== 1 && W
== 0)
2133 return DREG_MASK (reg
);
2134 else if (aop
== 1 && sz
== 2 && Z
== 0 && W
== 0)
2135 return DREG_MASK (reg
);
2136 else if (aop
== 1 && sz
== 2 && Z
== 1 && W
== 0)
2137 return DREG_MASK (reg
);
2138 else if (aop
== 2 && sz
== 0 && Z
== 0 && W
== 0)
2139 return DREG_MASK (reg
);
2140 else if (aop
== 2 && sz
== 0 && Z
== 1 && W
== 0)
2142 else if (aop
== 2 && sz
== 1 && Z
== 0 && W
== 0)
2143 return DREG_MASK (reg
);
2144 else if (aop
== 2 && sz
== 1 && Z
== 1 && W
== 0)
2145 return DREG_MASK (reg
);
2146 else if (aop
== 2 && sz
== 2 && Z
== 0 && W
== 0)
2147 return DREG_MASK (reg
);
2148 else if (aop
== 2 && sz
== 2 && Z
== 1 && W
== 0)
2149 return DREG_MASK (reg
);
2150 else if (aop
== 0 && sz
== 0 && Z
== 0 && W
== 1)
2152 else if (aop
== 0 && sz
== 0 && Z
== 1 && W
== 1)
2154 else if (aop
== 0 && sz
== 1 && Z
== 0 && W
== 1)
2156 else if (aop
== 0 && sz
== 2 && Z
== 0 && W
== 1)
2158 else if (aop
== 1 && sz
== 0 && Z
== 0 && W
== 1)
2160 else if (aop
== 1 && sz
== 0 && Z
== 1 && W
== 1)
2162 else if (aop
== 1 && sz
== 1 && Z
== 0 && W
== 1)
2164 else if (aop
== 1 && sz
== 2 && Z
== 0 && W
== 1)
2166 else if (aop
== 2 && sz
== 0 && Z
== 0 && W
== 1)
2168 else if (aop
== 2 && sz
== 0 && Z
== 1 && W
== 1)
2170 else if (aop
== 2 && sz
== 1 && Z
== 0 && W
== 1)
2172 else if (aop
== 2 && sz
== 2 && Z
== 0 && W
== 1)
2179 decode_LDSTiiFP_0 (int iw0
)
2182 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2183 | 1 | 0 | 1 | 1 | 1 | 0 |.W.|.offset............|.reg...........|
2184 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2185 int reg
= ((iw0
>> LDSTiiFP_reg_bits
) & LDSTiiFP_reg_mask
);
2186 int W
= ((iw0
>> LDSTiiFP_W_bits
) & LDSTiiFP_W_mask
);
2189 return reg
< 8 ? DREG_MASK (reg
) : 0;
2195 decode_LDSTii_0 (int iw0
)
2198 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2199 | 1 | 0 | 1 |.W.|.op....|.offset........|.ptr.......|.reg.......|
2200 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2201 int reg
= ((iw0
>> LDSTii_reg_bit
) & LDSTii_reg_mask
);
2202 int opc
= ((iw0
>> LDSTii_op_bit
) & LDSTii_op_mask
);
2203 int W
= ((iw0
>> LDSTii_W_bit
) & LDSTii_W_mask
);
2205 if (W
== 0 && opc
!= 3)
2206 return DREG_MASK (reg
);
2207 else if (W
== 0 && opc
== 3)
2209 else if (W
== 1 && opc
== 0)
2211 else if (W
== 1 && opc
== 1)
2213 else if (W
== 1 && opc
== 3)
2220 decode_dsp32mac_0 (int iw0
, int iw1
)
2224 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2225 | 1 | 1 | 0 | 0 |.M.| 0 | 0 |.mmod..........|.MM|.P.|.w1|.op1...|
2226 |.h01|.h11|.w0|.op0...|.h00|.h10|.dst.......|.src0......|.src1..|
2227 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2228 int op1
= ((iw0
>> (DSP32Mac_op1_bits
- 16)) & DSP32Mac_op1_mask
);
2229 int w1
= ((iw0
>> (DSP32Mac_w1_bits
- 16)) & DSP32Mac_w1_mask
);
2230 int P
= ((iw0
>> (DSP32Mac_p_bits
- 16)) & DSP32Mac_p_mask
);
2231 int mmod
= ((iw0
>> (DSP32Mac_mmod_bits
- 16)) & DSP32Mac_mmod_mask
);
2232 int w0
= ((iw1
>> DSP32Mac_w0_bits
) & DSP32Mac_w0_mask
);
2233 int MM
= ((iw1
>> DSP32Mac_MM_bits
) & DSP32Mac_MM_mask
);
2234 int dst
= ((iw1
>> DSP32Mac_dst_bits
) & DSP32Mac_dst_mask
);
2235 int op0
= ((iw1
>> DSP32Mac_op0_bits
) & DSP32Mac_op0_mask
);
2237 if (w0
== 0 && w1
== 0 && op1
== 3 && op0
== 3)
2243 if ((w1
|| w0
) && mmod
== M_W32
)
2246 if (((1 << mmod
) & (P
? 0x131b : 0x1b5f)) == 0)
2249 if (w1
== 1 || op1
!= 3)
2254 return DREG_MASK (dst
+ 1);
2256 return DREGH_MASK (dst
);
2260 if (w0
== 1 || op0
!= 3)
2265 return DREG_MASK (dst
);
2267 return DREGL_MASK (dst
);
2275 decode_dsp32mult_0 (int iw0
, int iw1
)
2278 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2279 | 1 | 1 | 0 | 0 |.M.| 0 | 1 |.mmod..........|.MM|.P.|.w1|.op1...|
2280 |.h01|.h11|.w0|.op0...|.h00|.h10|.dst.......|.src0......|.src1..|
2281 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2282 int w1
= ((iw0
>> (DSP32Mac_w1_bits
- 16)) & DSP32Mac_w1_mask
);
2283 int P
= ((iw0
>> (DSP32Mac_p_bits
- 16)) & DSP32Mac_p_mask
);
2284 int mmod
= ((iw0
>> (DSP32Mac_mmod_bits
- 16)) & DSP32Mac_mmod_mask
);
2285 int w0
= ((iw1
>> DSP32Mac_w0_bits
) & DSP32Mac_w0_mask
);
2286 int dst
= ((iw1
>> DSP32Mac_dst_bits
) & DSP32Mac_dst_mask
);
2289 if (w1
== 0 && w0
== 0)
2292 if (((1 << mmod
) & (P
? 0x313 : 0x1b57)) == 0)
2298 return DREG_MASK (dst
| 1);
2300 return DREGH_MASK (dst
);
2306 return DREG_MASK (dst
);
2308 return DREGL_MASK (dst
);
2315 decode_dsp32alu_0 (int iw0
, int iw1
)
2318 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2319 | 1 | 1 | 0 | 0 |.M.| 1 | 0 | - | - | - |.HL|.aopcde............|
2320 |.aop...|.s.|.x.|.dst0......|.dst1......|.src0......|.src1......|
2321 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2322 int s
= ((iw1
>> DSP32Alu_s_bits
) & DSP32Alu_s_mask
);
2323 int x
= ((iw1
>> DSP32Alu_x_bits
) & DSP32Alu_x_mask
);
2324 int aop
= ((iw1
>> DSP32Alu_aop_bits
) & DSP32Alu_aop_mask
);
2325 int dst0
= ((iw1
>> DSP32Alu_dst0_bits
) & DSP32Alu_dst0_mask
);
2326 int dst1
= ((iw1
>> DSP32Alu_dst1_bits
) & DSP32Alu_dst1_mask
);
2327 int HL
= ((iw0
>> (DSP32Alu_HL_bits
- 16)) & DSP32Alu_HL_mask
);
2328 int aopcde
= ((iw0
>> (DSP32Alu_aopcde_bits
- 16)) & DSP32Alu_aopcde_mask
);
2330 if (aop
== 0 && aopcde
== 9 && s
== 0)
2332 else if (aop
== 2 && aopcde
== 9 && HL
== 0 && s
== 0)
2334 else if (aop
>= x
* 2 && aopcde
== 5)
2335 return HL
? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2336 else if (HL
== 0 && aopcde
== 2)
2337 return DREGL_MASK (dst0
);
2338 else if (HL
== 1 && aopcde
== 2)
2339 return DREGH_MASK (dst0
);
2340 else if (HL
== 0 && aopcde
== 3)
2341 return DREGL_MASK (dst0
);
2342 else if (HL
== 1 && aopcde
== 3)
2343 return DREGH_MASK (dst0
);
2345 else if (aop
== 0 && aopcde
== 9 && s
== 1)
2347 else if (aop
== 1 && aopcde
== 9 && s
== 0)
2349 else if (aop
== 2 && aopcde
== 9 && s
== 1)
2351 else if (aop
== 3 && aopcde
== 9 && s
== 0)
2353 else if (aopcde
== 8)
2355 else if (aop
== 0 && aopcde
== 11)
2356 return DREG_MASK (dst0
);
2357 else if (aop
== 1 && aopcde
== 11)
2358 return HL
? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2359 else if (aopcde
== 11)
2361 else if (aopcde
== 22)
2362 return DREG_MASK (dst0
);
2364 else if ((aop
== 0 || aop
== 1) && aopcde
== 14)
2366 else if (aop
== 3 && HL
== 0 && aopcde
== 14)
2369 else if (aop
== 3 && HL
== 0 && aopcde
== 15)
2370 return DREG_MASK (dst0
);
2372 else if (aop
== 1 && aopcde
== 16)
2375 else if (aop
== 0 && aopcde
== 16)
2378 else if (aop
== 3 && HL
== 0 && aopcde
== 16)
2381 else if (aop
== 3 && HL
== 0 && aopcde
== 7)
2382 return DREG_MASK (dst0
);
2383 else if ((aop
== 0 || aop
== 1 || aop
== 2) && aopcde
== 7)
2384 return DREG_MASK (dst0
);
2386 else if (aop
== 0 && aopcde
== 12)
2387 return DREG_MASK (dst0
);
2388 else if (aop
== 1 && aopcde
== 12)
2389 return DREG_MASK (dst0
) | DREG_MASK (dst1
);
2390 else if (aop
== 3 && aopcde
== 12)
2391 return HL
? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2393 else if (aopcde
== 0)
2394 return DREG_MASK (dst0
);
2395 else if (aopcde
== 1)
2396 return DREG_MASK (dst0
) | DREG_MASK (dst1
);
2398 else if (aop
== 0 && aopcde
== 10)
2399 return DREGL_MASK (dst0
);
2400 else if (aop
== 1 && aopcde
== 10)
2401 return DREGL_MASK (dst0
);
2403 else if ((aop
== 1 || aop
== 0) && aopcde
== 4)
2404 return DREG_MASK (dst0
);
2405 else if (aop
== 2 && aopcde
== 4)
2406 return DREG_MASK (dst0
) | DREG_MASK (dst1
);
2408 else if (aop
== 0 && aopcde
== 17)
2409 return DREG_MASK (dst0
) | DREG_MASK (dst1
);
2410 else if (aop
== 1 && aopcde
== 17)
2411 return DREG_MASK (dst0
) | DREG_MASK (dst1
);
2412 else if (aop
== 0 && aopcde
== 18)
2414 else if (aop
== 3 && aopcde
== 18)
2417 else if ((aop
== 0 || aop
== 1 || aop
== 2) && aopcde
== 6)
2418 return DREG_MASK (dst0
);
2420 else if ((aop
== 0 || aop
== 1) && aopcde
== 20)
2421 return DREG_MASK (dst0
);
2423 else if ((aop
== 0 || aop
== 1) && aopcde
== 21)
2424 return DREG_MASK (dst0
) | DREG_MASK (dst1
);
2426 else if (aop
== 0 && aopcde
== 23 && HL
== 1)
2427 return DREG_MASK (dst0
);
2428 else if (aop
== 0 && aopcde
== 23 && HL
== 0)
2429 return DREG_MASK (dst0
);
2431 else if (aop
== 0 && aopcde
== 24)
2432 return DREG_MASK (dst0
);
2433 else if (aop
== 1 && aopcde
== 24)
2434 return DREG_MASK (dst0
) | DREG_MASK (dst1
);
2435 else if (aopcde
== 13)
2436 return DREG_MASK (dst0
) | DREG_MASK (dst1
);
2444 decode_dsp32shift_0 (int iw0
, int iw1
)
2447 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2448 | 1 | 1 | 0 | 0 |.M.| 1 | 1 | 0 | 0 | - | - |.sopcde............|
2449 |.sop...|.HLs...|.dst0......| - | - | - |.src0......|.src1......|
2450 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2451 int HLs
= ((iw1
>> DSP32Shift_HLs_bits
) & DSP32Shift_HLs_mask
);
2452 int sop
= ((iw1
>> DSP32Shift_sop_bits
) & DSP32Shift_sop_mask
);
2453 int src0
= ((iw1
>> DSP32Shift_src0_bits
) & DSP32Shift_src0_mask
);
2454 int src1
= ((iw1
>> DSP32Shift_src1_bits
) & DSP32Shift_src1_mask
);
2455 int dst0
= ((iw1
>> DSP32Shift_dst0_bits
) & DSP32Shift_dst0_mask
);
2456 int sopcde
= ((iw0
>> (DSP32Shift_sopcde_bits
- 16)) & DSP32Shift_sopcde_mask
);
2458 if (sop
== 0 && sopcde
== 0)
2459 return HLs
& 2 ? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2460 else if (sop
== 1 && sopcde
== 0)
2461 return HLs
& 2 ? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2462 else if (sop
== 2 && sopcde
== 0)
2463 return HLs
& 2 ? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2464 else if (sop
== 0 && sopcde
== 3)
2466 else if (sop
== 1 && sopcde
== 3)
2468 else if (sop
== 2 && sopcde
== 3)
2470 else if (sop
== 3 && sopcde
== 3)
2471 return DREG_MASK (dst0
);
2472 else if (sop
== 0 && sopcde
== 1)
2473 return DREG_MASK (dst0
);
2474 else if (sop
== 1 && sopcde
== 1)
2475 return DREG_MASK (dst0
);
2476 else if (sop
== 2 && sopcde
== 1)
2477 return DREG_MASK (dst0
);
2478 else if (sopcde
== 2)
2479 return DREG_MASK (dst0
);
2480 else if (sopcde
== 4)
2481 return DREG_MASK (dst0
);
2482 else if (sop
== 0 && sopcde
== 5)
2483 return DREGL_MASK (dst0
);
2484 else if (sop
== 1 && sopcde
== 5)
2485 return DREGL_MASK (dst0
);
2486 else if (sop
== 2 && sopcde
== 5)
2487 return DREGL_MASK (dst0
);
2488 else if (sop
== 0 && sopcde
== 6)
2489 return DREGL_MASK (dst0
);
2490 else if (sop
== 1 && sopcde
== 6)
2491 return DREGL_MASK (dst0
);
2492 else if (sop
== 3 && sopcde
== 6)
2493 return DREGL_MASK (dst0
);
2494 else if (sop
== 0 && sopcde
== 7)
2495 return DREGL_MASK (dst0
);
2496 else if (sop
== 1 && sopcde
== 7)
2497 return DREGL_MASK (dst0
);
2498 else if (sop
== 2 && sopcde
== 7)
2499 return DREGL_MASK (dst0
);
2500 else if (sop
== 3 && sopcde
== 7)
2501 return DREGL_MASK (dst0
);
2502 else if (sop
== 0 && sopcde
== 8)
2503 return DREG_MASK (src0
) | DREG_MASK (src1
);
2506 OUTS (outf
, "BITMUX (");
2507 OUTS (outf
, dregs (src0
));
2509 OUTS (outf
, dregs (src1
));
2510 OUTS (outf
, ", A0) (ASR)");
2513 else if (sop
== 1 && sopcde
== 8)
2514 return DREG_MASK (src0
) | DREG_MASK (src1
);
2517 OUTS (outf
, "BITMUX (");
2518 OUTS (outf
, dregs (src0
));
2520 OUTS (outf
, dregs (src1
));
2521 OUTS (outf
, ", A0) (ASL)");
2524 else if (sopcde
== 9)
2525 return sop
< 2 ? DREGL_MASK (dst0
) : DREG_MASK (dst0
);
2526 else if (sopcde
== 10)
2527 return DREG_MASK (dst0
);
2528 else if (sop
== 0 && sopcde
== 11)
2529 return DREGL_MASK (dst0
);
2530 else if (sop
== 1 && sopcde
== 11)
2531 return DREGL_MASK (dst0
);
2532 else if (sop
== 0 && sopcde
== 12)
2534 else if (sop
== 1 && sopcde
== 12)
2535 return DREGL_MASK (dst0
);
2536 else if (sop
== 0 && sopcde
== 13)
2537 return DREG_MASK (dst0
);
2538 else if (sop
== 1 && sopcde
== 13)
2539 return DREG_MASK (dst0
);
2540 else if (sop
== 2 && sopcde
== 13)
2541 return DREG_MASK (dst0
);
2547 decode_dsp32shiftimm_0 (int iw0
, int iw1
)
2550 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+
2551 | 1 | 1 | 0 | 0 |.M.| 1 | 1 | 0 | 1 | - | - |.sopcde............|
2552 |.sop...|.HLs...|.dst0......|.immag.................|.src1......|
2553 +---+---+---+---|---+---+---+---|---+---+---+---|---+---+---+---+ */
2554 int sop
= ((iw1
>> DSP32ShiftImm_sop_bits
) & DSP32ShiftImm_sop_mask
);
2555 int bit8
= ((iw1
>> 8) & 0x1);
2556 int dst0
= ((iw1
>> DSP32ShiftImm_dst0_bits
) & DSP32ShiftImm_dst0_mask
);
2557 int sopcde
= ((iw0
>> (DSP32ShiftImm_sopcde_bits
- 16)) & DSP32ShiftImm_sopcde_mask
);
2558 int HLs
= ((iw1
>> DSP32ShiftImm_HLs_bits
) & DSP32ShiftImm_HLs_mask
);
2561 if (sop
== 0 && sopcde
== 0)
2562 return HLs
& 2 ? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2563 else if (sop
== 1 && sopcde
== 0 && bit8
== 0)
2564 return HLs
& 2 ? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2565 else if (sop
== 1 && sopcde
== 0 && bit8
== 1)
2566 return HLs
& 2 ? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2567 else if (sop
== 2 && sopcde
== 0 && bit8
== 0)
2568 return HLs
& 2 ? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2569 else if (sop
== 2 && sopcde
== 0 && bit8
== 1)
2570 return HLs
& 2 ? DREGH_MASK (dst0
) : DREGL_MASK (dst0
);
2571 else if (sop
== 2 && sopcde
== 3 && HLs
== 1)
2573 else if (sop
== 0 && sopcde
== 3 && HLs
== 0 && bit8
== 0)
2575 else if (sop
== 0 && sopcde
== 3 && HLs
== 0 && bit8
== 1)
2577 else if (sop
== 0 && sopcde
== 3 && HLs
== 1 && bit8
== 0)
2579 else if (sop
== 0 && sopcde
== 3 && HLs
== 1 && bit8
== 1)
2581 else if (sop
== 1 && sopcde
== 3 && HLs
== 0)
2583 else if (sop
== 1 && sopcde
== 3 && HLs
== 1)
2585 else if (sop
== 2 && sopcde
== 3 && HLs
== 0)
2587 else if (sop
== 1 && sopcde
== 1 && bit8
== 0)
2588 return DREG_MASK (dst0
);
2589 else if (sop
== 1 && sopcde
== 1 && bit8
== 1)
2590 return DREG_MASK (dst0
);
2591 else if (sop
== 2 && sopcde
== 1 && bit8
== 1)
2592 return DREG_MASK (dst0
);
2593 else if (sop
== 2 && sopcde
== 1 && bit8
== 0)
2594 return DREG_MASK (dst0
);
2595 else if (sop
== 0 && sopcde
== 1)
2596 return DREG_MASK (dst0
);
2597 else if (sop
== 1 && sopcde
== 2)
2598 return DREG_MASK (dst0
);
2599 else if (sop
== 2 && sopcde
== 2 && bit8
== 1)
2600 return DREG_MASK (dst0
);
2601 else if (sop
== 2 && sopcde
== 2 && bit8
== 0)
2602 return DREG_MASK (dst0
);
2603 else if (sop
== 3 && sopcde
== 2)
2604 return DREG_MASK (dst0
);
2605 else if (sop
== 0 && sopcde
== 2)
2606 return DREG_MASK (dst0
);
2612 insn_regmask (int iw0
, int iw1
)
2614 if ((iw0
& 0xf7ff) == 0xc003 && iw1
== 0x1800)
2615 return 0; /* MNOP */
2616 else if ((iw0
& 0xff00) == 0x0000)
2617 return decode_ProgCtrl_0 (iw0
);
2618 else if ((iw0
& 0xffc0) == 0x0240)
2620 else if ((iw0
& 0xff80) == 0x0100)
2622 else if ((iw0
& 0xfe00) == 0x0400)
2624 else if ((iw0
& 0xfe00) == 0x0600)
2626 else if ((iw0
& 0xf800) == 0x0800)
2628 else if ((iw0
& 0xffe0) == 0x0200)
2630 else if ((iw0
& 0xff00) == 0x0300)
2632 else if ((iw0
& 0xf000) == 0x1000)
2634 else if ((iw0
& 0xf000) == 0x2000)
2636 else if ((iw0
& 0xf000) == 0x3000)
2638 else if ((iw0
& 0xfc00) == 0x4000)
2640 else if ((iw0
& 0xfe00) == 0x4400)
2642 else if ((iw0
& 0xf800) == 0x4800)
2644 else if ((iw0
& 0xf000) == 0x5000)
2646 else if ((iw0
& 0xf800) == 0x6000)
2648 else if ((iw0
& 0xf800) == 0x6800)
2650 else if ((iw0
& 0xf000) == 0x8000)
2651 return decode_LDSTpmod_0 (iw0
);
2652 else if ((iw0
& 0xff60) == 0x9e60)
2653 return decode_dagMODim_0 (iw0
);
2654 else if ((iw0
& 0xfff0) == 0x9f60)
2655 return decode_dagMODik_0 (iw0
);
2656 else if ((iw0
& 0xfc00) == 0x9c00)
2657 return decode_dspLDST_0 (iw0
);
2658 else if ((iw0
& 0xf000) == 0x9000)
2659 return decode_LDST_0 (iw0
);
2660 else if ((iw0
& 0xfc00) == 0xb800)
2661 return decode_LDSTiiFP_0 (iw0
);
2662 else if ((iw0
& 0xe000) == 0xA000)
2663 return decode_LDSTii_0 (iw0
);
2664 else if ((iw0
& 0xff80) == 0xe080 && (iw1
& 0x0C00) == 0x0000)
2666 else if ((iw0
& 0xff00) == 0xe100 && (iw1
& 0x0000) == 0x0000)
2668 else if ((iw0
& 0xfe00) == 0xe200 && (iw1
& 0x0000) == 0x0000)
2670 else if ((iw0
& 0xfc00) == 0xe400 && (iw1
& 0x0000) == 0x0000)
2672 else if ((iw0
& 0xfffe) == 0xe800 && (iw1
& 0x0000) == 0x0000)
2674 else if ((iw0
& 0xf600) == 0xc000 && (iw1
& 0x0000) == 0x0000)
2675 return decode_dsp32mac_0 (iw0
, iw1
);
2676 else if ((iw0
& 0xf600) == 0xc200 && (iw1
& 0x0000) == 0x0000)
2677 return decode_dsp32mult_0 (iw0
, iw1
);
2678 else if ((iw0
& 0xf7c0) == 0xc400 && (iw1
& 0x0000) == 0x0000)
2679 return decode_dsp32alu_0 (iw0
, iw1
);
2680 else if ((iw0
& 0xf780) == 0xc600 && (iw1
& 0x01c0) == 0x0000)
2681 return decode_dsp32shift_0 (iw0
, iw1
);
2682 else if ((iw0
& 0xf780) == 0xc680 && (iw1
& 0x0000) == 0x0000)
2683 return decode_dsp32shiftimm_0 (iw0
, iw1
);
2684 else if ((iw0
& 0xff00) == 0xf800)
2686 else if ((iw0
& 0xFFC0) == 0xf000 && (iw1
& 0x0000) == 0x0000)