xref: /netbsd-src/external/gpl3/binutils.old/dist/bfd/cpu-msp430.c (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos /* BFD library support routines for the MSP architecture.
2*e992f068Schristos    Copyright (C) 2002-2022 Free Software Foundation, Inc.
375fd0b74Schristos    Contributed by Dmitry Diky <diwil@mail.ru>
475fd0b74Schristos 
575fd0b74Schristos    This file is part of BFD, the Binary File Descriptor library.
675fd0b74Schristos 
775fd0b74Schristos    This program is free software; you can redistribute it and/or modify
875fd0b74Schristos    it under the terms of the GNU General Public License as published by
975fd0b74Schristos    the Free Software Foundation; either version 3 of the License, or
1075fd0b74Schristos    (at your option) any later version.
1175fd0b74Schristos 
1275fd0b74Schristos    This program is distributed in the hope that it will be useful,
1375fd0b74Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1475fd0b74Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1575fd0b74Schristos    GNU General Public License for more details.
1675fd0b74Schristos 
1775fd0b74Schristos    You should have received a copy of the GNU General Public License
1875fd0b74Schristos    along with this program; if not, write to the Free Software
1975fd0b74Schristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
2075fd0b74Schristos    MA 02110-1301, USA.  */
2175fd0b74Schristos 
2275fd0b74Schristos #include "sysdep.h"
2375fd0b74Schristos #include "bfd.h"
2475fd0b74Schristos #include "libbfd.h"
2575fd0b74Schristos 
2675fd0b74Schristos /* This routine is provided two arch_infos and works out which MSP
2775fd0b74Schristos    machine which would be compatible with both and returns a pointer
2875fd0b74Schristos    to its info structure.  */
2975fd0b74Schristos 
3075fd0b74Schristos static const bfd_arch_info_type *
compatible(const bfd_arch_info_type * a,const bfd_arch_info_type * b)3175fd0b74Schristos compatible (const bfd_arch_info_type * a,
3275fd0b74Schristos 	    const bfd_arch_info_type * b)
3375fd0b74Schristos {
3475fd0b74Schristos   /* If a & b are for different architectures we can do nothing.  */
3575fd0b74Schristos   if (a->arch != b->arch)
3675fd0b74Schristos     return NULL;
3775fd0b74Schristos 
3875fd0b74Schristos   if (a->mach <= b->mach)
3975fd0b74Schristos     return b;
4075fd0b74Schristos 
4175fd0b74Schristos   return a;
4275fd0b74Schristos }
4375fd0b74Schristos 
4475fd0b74Schristos #define N(addr_bits, machine, print, default, next)		\
4575fd0b74Schristos {								\
46012573ebSchristos   16,				/* Bits in a word.  */		\
4775fd0b74Schristos   addr_bits,			/* Bits in an address.  */	\
48012573ebSchristos   8,				/* Bits in a byte.  */		\
4975fd0b74Schristos   bfd_arch_msp430,						\
5075fd0b74Schristos   machine,			/* Machine number.  */		\
5175fd0b74Schristos   "msp430",			/* Architecture name.   */	\
5275fd0b74Schristos   print,			/* Printable name.  */		\
5375fd0b74Schristos   1,				/* Section align power.  */	\
5475fd0b74Schristos   default,			/* The default machine.  */	\
5575fd0b74Schristos   compatible,							\
5675fd0b74Schristos   bfd_default_scan,						\
5775fd0b74Schristos   bfd_arch_default_fill,					\
58012573ebSchristos   next,								\
59012573ebSchristos   0 /* Maximum offset of a reloc from the start of an insn.  */ \
6075fd0b74Schristos }
6175fd0b74Schristos 
6275fd0b74Schristos static const bfd_arch_info_type arch_info_struct[] =
6375fd0b74Schristos {
6475fd0b74Schristos   /* msp430x11x.  */
65*e992f068Schristos   N (16, bfd_mach_msp11, "MSP430", false, & arch_info_struct[1]),
6675fd0b74Schristos 
6775fd0b74Schristos   /* msp430x11x1.  */
68*e992f068Schristos   N (16, bfd_mach_msp110, "MSP430x11x1", false, & arch_info_struct[2]),
6975fd0b74Schristos 
7075fd0b74Schristos   /* msp430x12x.  */
71*e992f068Schristos   N (16, bfd_mach_msp12, "MSP430x12", false, & arch_info_struct[3]),
7275fd0b74Schristos 
7375fd0b74Schristos   /* msp430x13x.  */
74*e992f068Schristos   N (16, bfd_mach_msp13, "MSP430x13", false, & arch_info_struct[4]),
7575fd0b74Schristos 
7675fd0b74Schristos   /* msp430x14x.  */
77*e992f068Schristos   N (16, bfd_mach_msp14, "MSP430x14", false, & arch_info_struct[5]),
7875fd0b74Schristos 
7975fd0b74Schristos   /* msp430x15x.  */
80*e992f068Schristos   N (16, bfd_mach_msp15, "MSP430x15", false, & arch_info_struct[6]),
8175fd0b74Schristos 
8275fd0b74Schristos   /* msp430x16x.  */
83*e992f068Schristos   N (16, bfd_mach_msp16, "MSP430x16", false, & arch_info_struct[7]),
8475fd0b74Schristos 
8575fd0b74Schristos   /* msp430x20x.  */
86*e992f068Schristos   N (16, bfd_mach_msp20, "MSP430x20", false, & arch_info_struct[8]),
8775fd0b74Schristos 
8875fd0b74Schristos   /* msp430x21x.  */
89*e992f068Schristos   N (16, bfd_mach_msp21, "MSP430x21", false, & arch_info_struct[9]),
9075fd0b74Schristos 
9175fd0b74Schristos   /* msp430x22x.  */
92*e992f068Schristos   N (16, bfd_mach_msp22, "MSP430x22", false, & arch_info_struct[10]),
9375fd0b74Schristos 
9475fd0b74Schristos   /* msp430x23x.  */
95*e992f068Schristos   N (16, bfd_mach_msp23, "MSP430x23", false, & arch_info_struct[11]),
9675fd0b74Schristos 
9775fd0b74Schristos   /* msp430x24x.  */
98*e992f068Schristos   N (16, bfd_mach_msp24, "MSP430x24", false, & arch_info_struct[12]),
9975fd0b74Schristos 
10075fd0b74Schristos   /* msp430x26x.  */
101*e992f068Schristos   N (16, bfd_mach_msp26, "MSP430x26", false, & arch_info_struct[13]),
10275fd0b74Schristos 
10375fd0b74Schristos   /* msp430x31x.  */
104*e992f068Schristos   N (16, bfd_mach_msp31, "MSP430x31", false, & arch_info_struct[14]),
10575fd0b74Schristos 
10675fd0b74Schristos   /* msp430x32x.  */
107*e992f068Schristos   N (16, bfd_mach_msp32, "MSP430x32", false, & arch_info_struct[15]),
10875fd0b74Schristos 
10975fd0b74Schristos   /* msp430x33x.  */
110*e992f068Schristos   N (16, bfd_mach_msp33, "MSP430x33", false, & arch_info_struct[16]),
11175fd0b74Schristos 
11275fd0b74Schristos   /* msp430x41x.  */
113*e992f068Schristos   N (16, bfd_mach_msp41, "MSP430x41", false, & arch_info_struct[17]),
11475fd0b74Schristos 
11575fd0b74Schristos   /* msp430x42x.  */
116*e992f068Schristos   N (16, bfd_mach_msp42, "MSP430x42", false, & arch_info_struct[18]),
11775fd0b74Schristos 
11875fd0b74Schristos   /* msp430x43x.  */
119*e992f068Schristos   N (16, bfd_mach_msp43, "MSP430x43", false, & arch_info_struct[19]),
12075fd0b74Schristos 
12175fd0b74Schristos   /* msp430x44x.  */
122*e992f068Schristos   N (16, bfd_mach_msp43, "MSP430x44", false, & arch_info_struct[20]),
12375fd0b74Schristos 
12475fd0b74Schristos   /* msp430x46x.  */
125*e992f068Schristos   N (16, bfd_mach_msp46, "MSP430x46", false, & arch_info_struct[21]),
12675fd0b74Schristos 
12775fd0b74Schristos   /* msp430x47x.  */
128*e992f068Schristos   N (16, bfd_mach_msp47, "MSP430x47", false, & arch_info_struct[22]),
12975fd0b74Schristos 
13075fd0b74Schristos   /* msp430x54x.  */
131*e992f068Schristos   N (16, bfd_mach_msp54, "MSP430x54", false, & arch_info_struct[23]),
13275fd0b74Schristos 
133*e992f068Schristos   N (32, bfd_mach_msp430x, "MSP430X", false, NULL)
13475fd0b74Schristos 
13575fd0b74Schristos };
13675fd0b74Schristos 
13775fd0b74Schristos const bfd_arch_info_type bfd_msp430_arch =
138*e992f068Schristos   N (16, bfd_mach_msp14, "msp:14", true, & arch_info_struct[0]);
13975fd0b74Schristos 
140