Missing ChangeLog and files for commit 8b00c176168dc7b0d78d0dc1f7d42f915375dc4a
[deliverable/binutils-gdb.git] / bfd / cpu-i960.c
CommitLineData
252b5132 1/* BFD library support routines for the i960 architecture.
2571583a 2 Copyright (C) 1990-2017 Free Software Foundation, Inc.
252b5132
RH
3 Hacked by Steve Chamberlain of Cygnus Support.
4
0112cd26 5 This file is part of BFD, the Binary File Descriptor library.
252b5132 6
0112cd26
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
cd123cb7 9 the Free Software Foundation; either version 3 of the License, or
0112cd26 10 (at your option) any later version.
252b5132 11
0112cd26
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
0112cd26
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
cd123cb7
NC
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
252b5132
RH
26/* This routine is provided a string, and tries to work out if it
27 could possibly refer to the i960 machine pointed at in the
28 info_struct pointer */
29
b34976b6 30static bfd_boolean
2c3fc389
NC
31scan_960_mach (const bfd_arch_info_type *ap,
32 const char *string)
252b5132
RH
33{
34 unsigned long machine;
b34976b6 35 int fail_because_not_80960 = FALSE;
71f6b586 36
96f6d4c4 37 /* Look for the string i960 at the front of the string. */
6cbac8b9 38 if (strncasecmp ("i960", string, 4) == 0)
96f6d4c4
NC
39 {
40 string += 4;
41
42 /* i960 on it's own means core to us. */
43 if (* string == 0)
44 return ap->mach == bfd_mach_i960_core;
71f6b586 45
96f6d4c4
NC
46 /* "i960:*" is valid, anything else is not. */
47 if (* string != ':')
b34976b6 48 return FALSE;
96f6d4c4
NC
49
50 string ++;
51 }
52 /* In some bfds the cpu-id is written as "80960KA", "80960KB",
53 "80960CA" or "80960MC". */
0112cd26 54 else if (CONST_STRNEQ (string, "80960"))
96f6d4c4
NC
55 {
56 string += 5;
57
b34976b6
AM
58 /* Set this to TRUE here. If a correct matching postfix
59 is detected below it will be reset to FALSE. */
60 fail_because_not_80960 = TRUE;
96f6d4c4
NC
61 }
62 /* No match, can't be us. */
63 else
b34976b6 64 return FALSE;
71f6b586 65
96f6d4c4 66 if (* string == '\0')
b34976b6 67 return FALSE;
71f6b586 68
252b5132
RH
69 if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' &&
70 string[3] == 'e' && string[4] == '\0')
71 machine = bfd_mach_i960_core;
6cbac8b9 72 else if (strcasecmp (string, "ka_sa") == 0)
252b5132 73 machine = bfd_mach_i960_ka_sa;
6cbac8b9 74 else if (strcasecmp (string, "kb_sb") == 0)
252b5132 75 machine = bfd_mach_i960_kb_sb;
96f6d4c4 76 else if (string[1] == '\0' || string[2] != '\0') /* rest are 2-char. */
b34976b6 77 return FALSE;
252b5132 78 else if (string[0] == 'k' && string[1] == 'b')
b34976b6 79 { machine = bfd_mach_i960_kb_sb; fail_because_not_80960 = FALSE; }
252b5132
RH
80 else if (string[0] == 's' && string[1] == 'b')
81 machine = bfd_mach_i960_kb_sb;
82 else if (string[0] == 'm' && string[1] == 'c')
b34976b6 83 { machine = bfd_mach_i960_mc; fail_because_not_80960 = FALSE; }
252b5132
RH
84 else if (string[0] == 'x' && string[1] == 'a')
85 machine = bfd_mach_i960_xa;
86 else if (string[0] == 'c' && string[1] == 'a')
b34976b6 87 { machine = bfd_mach_i960_ca; fail_because_not_80960 = FALSE; }
252b5132 88 else if (string[0] == 'k' && string[1] == 'a')
b34976b6 89 { machine = bfd_mach_i960_ka_sa; fail_because_not_80960 = FALSE; }
252b5132
RH
90 else if (string[0] == 's' && string[1] == 'a')
91 machine = bfd_mach_i960_ka_sa;
92 else if (string[0] == 'j' && string[1] == 'x')
93 machine = bfd_mach_i960_jx;
94 else if (string[0] == 'h' && string[1] == 'x')
95 machine = bfd_mach_i960_hx;
96 else
b34976b6 97 return FALSE;
96f6d4c4
NC
98
99 if (fail_because_not_80960)
b34976b6 100 return FALSE;
71f6b586 101
96f6d4c4 102 if (machine == ap->mach)
b34976b6 103 return TRUE;
71f6b586 104
b34976b6 105 return FALSE;
252b5132
RH
106}
107
252b5132
RH
108/* This routine is provided two arch_infos and works out the i960
109 machine which would be compatible with both and returns a pointer
110 to its info structure */
111
112static const bfd_arch_info_type *
2c3fc389
NC
113compatible (const bfd_arch_info_type *a,
114 const bfd_arch_info_type *b)
252b5132
RH
115{
116
117 /* The i960 has distinct subspecies which may not interbreed:
71f6b586 118 CORE CA
252b5132
RH
119 CORE KA KB MC XA
120 CORE HX JX
121 Any architecture on the same line is compatible, the one on
71f6b586
KH
122 the right is the least restrictive.
123
252b5132
RH
124 We represent this information in an array, each machine to a side */
125
126#define ERROR 0
71f6b586
KH
127#define CORE bfd_mach_i960_core /*1*/
128#define KA bfd_mach_i960_ka_sa /*2*/
252b5132
RH
129#define KB bfd_mach_i960_kb_sb /*3*/
130#define MC bfd_mach_i960_mc /*4*/
131#define XA bfd_mach_i960_xa /*5*/
132#define CA bfd_mach_i960_ca /*6*/
133#define JX bfd_mach_i960_jx /*7*/
134#define HX bfd_mach_i960_hx /*8*/
135#define MAX_ARCH ((int)HX)
136
dc810e39 137 static const unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
252b5132
RH
138 {
139 { ERROR, CORE, KA, KB, MC, XA, CA, JX, HX },
140 { CORE, CORE, KA, KB, MC, XA, CA, JX, HX },
141 { KA, KA, KA, KB, MC, XA, ERROR, ERROR, ERROR},
142 { KB, KB, KB, KB, MC, XA, ERROR, ERROR, ERROR},
143 { MC, MC, MC, MC, MC, XA, ERROR, ERROR, ERROR},
144 { XA, XA, XA, XA, XA, XA, ERROR, ERROR, ERROR},
145 { CA, CA, ERROR, ERROR, ERROR, ERROR, CA, ERROR, ERROR},
146 { JX, JX, ERROR, ERROR, ERROR, ERROR, ERROR, JX, HX },
147 { HX, HX, ERROR, ERROR, ERROR, ERROR, ERROR, HX, HX },
148 };
149
71f6b586 150 if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR)
252b5132 151 return NULL;
2c3fc389
NC
152
153 return (a->mach == matrix[a->mach][b->mach]) ? a : b;
252b5132
RH
154}
155
252b5132 156#define N(a,b,d,n) \
b7761f11
L
157{ 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach, \
158 bfd_arch_default_fill, n,}
252b5132 159
71f6b586
KH
160static const bfd_arch_info_type arch_info_struct[] =
161{
b34976b6
AM
162 N(bfd_mach_i960_ka_sa,"i960:ka_sa",FALSE, &arch_info_struct[1]),
163 N(bfd_mach_i960_kb_sb,"i960:kb_sb",FALSE, &arch_info_struct[2]),
164 N(bfd_mach_i960_mc, "i960:mc", FALSE, &arch_info_struct[3]),
165 N(bfd_mach_i960_xa, "i960:xa", FALSE, &arch_info_struct[4]),
166 N(bfd_mach_i960_ca, "i960:ca", FALSE, &arch_info_struct[5]),
167 N(bfd_mach_i960_jx, "i960:jx", FALSE, &arch_info_struct[6]),
168 N(bfd_mach_i960_hx, "i960:hx", FALSE, 0),
252b5132
RH
169};
170
171const bfd_arch_info_type bfd_i960_arch =
b34976b6 172 N(bfd_mach_i960_core, "i960:core", TRUE, &arch_info_struct[0]);
This page took 0.749385 seconds and 4 git commands to generate.