[PATCH][ARM][GAS]: Support to MVE VCTP instruction.
[deliverable/binutils-gdb.git] / bfd / cpu-arc.c
CommitLineData
252b5132 1/* BFD support for the ARC processor
82704155 2 Copyright (C) 1994-2019 Free Software Foundation, Inc.
252b5132
RH
3 Contributed by Doug Evans (dje@cygnus.com).
4
cd123cb7 5 This file is part of BFD, the Binary File Descriptor library.
252b5132 6
cd123cb7
NC
7 This program 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 of the License, or
10 (at your option) any later version.
252b5132 11
cd123cb7
NC
12 This program 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.
252b5132 16
cd123cb7
NC
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
252b5132 21
252b5132 22#include "sysdep.h"
3db64b00 23#include "bfd.h"
252b5132
RH
24#include "libbfd.h"
25
64984c22
AK
26static const bfd_arch_info_type *
27arc_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b);
28
252b5132
RH
29#define ARC(mach, print_name, default_p, next) \
30{ \
0d2bcfaf
NC
31 32, /* 32 bits in a word */ \
32 32, /* 32 bits in an address */ \
33 8, /* 8 bits in a byte */ \
252b5132
RH
34 bfd_arch_arc, \
35 mach, \
36 "arc", \
37 print_name, \
0d2bcfaf 38 4, /* section alignment power */ \
252b5132 39 default_p, \
64984c22 40 arc_compatible, \
252b5132 41 bfd_default_scan, \
b7761f11 42 bfd_arch_default_fill, \
252b5132
RH
43 next, \
44 }
45
252b5132
RH
46static const bfd_arch_info_type arch_info_struct[] =
47{
37cd3877
AK
48 ARC (bfd_mach_arc_arc600, "A6" , FALSE, &arch_info_struct[1]),
49 ARC (bfd_mach_arc_arc601, "ARC601", FALSE, &arch_info_struct[2]),
50 ARC (bfd_mach_arc_arc700, "ARC700", FALSE, &arch_info_struct[3]),
51 ARC (bfd_mach_arc_arc700, "A7", FALSE, &arch_info_struct[4]),
52 ARC (bfd_mach_arc_arcv2, "ARCv2", FALSE, &arch_info_struct[5]),
53 ARC (bfd_mach_arc_arcv2, "EM", FALSE, &arch_info_struct[6]),
886a2506 54 ARC (bfd_mach_arc_arcv2, "HS", FALSE, NULL),
252b5132 55};
252b5132
RH
56
57const bfd_arch_info_type bfd_arc_arch =
bdbca4e6 58 ARC (bfd_mach_arc_arc600, "ARC600", TRUE, &arch_info_struct[0]);
64984c22
AK
59
60/* ARC-specific "compatible" function. The general rule is that if A and B are
61 compatible, then this function should return architecture that is more
62 "feature-rich", that is, can run both A and B. ARCv2, EM and HS all has
63 same mach number, so bfd_default_compatible assumes they are the same, and
64 returns an A. That causes issues with GDB, because GDB assumes that if
65 machines are compatible, then "compatible ()" always returns same machine
66 regardless of argument order. As a result GDB gets confused because, for
67 example, compatible (ARCv2, EM) returns ARCv2, but compatible (EM, ARCv2)
68 returns EM, hence GDB is not sure if they are compatible and prints a
69 warning. */
70
71static const bfd_arch_info_type *
72arc_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b)
73{
74 const bfd_arch_info_type * const em = &arch_info_struct[5];
75 const bfd_arch_info_type * const hs = &arch_info_struct[6];
76
77 /* Trivial case where a and b is the same instance. Some callers already
78 check this condition but some do not and get an invalid result. */
79 if (a == b)
80 return a;
81
82 /* If a & b are for different architecture we can do nothing. */
83 if (a->arch != b->arch)
84 return NULL;
85
86 if (a->bits_per_word != b->bits_per_word)
87 return NULL;
88
89 /* ARCv2|EM and EM. */
90 if ((a->mach == bfd_mach_arc_arcv2 && b == em)
91 || (b->mach == bfd_mach_arc_arcv2 && a == em))
92 return em;
93
94 /* ARCv2|HS and HS. */
95 if ((a->mach == bfd_mach_arc_arcv2 && b == hs)
96 || (b->mach == bfd_mach_arc_arcv2 && a == hs))
97 return hs;
98
99 return bfd_default_compatible (a, b);
100}
This page took 1.113117 seconds and 4 git commands to generate.