daily update
[deliverable/binutils-gdb.git] / bfd / cpu-h8300.c
CommitLineData
c2dcd04e
NC
1/* BFD library support routines for the Renesas H8/300 architecture.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2000, 2001, 2002, 2003
7898deda 3 Free Software Foundation, Inc.
252b5132
RH
4 Hacked by Steve Chamberlain of Cygnus Support.
5
c2dcd04e 6 This file is part of BFD, the Binary File Descriptor library.
252b5132 7
c2dcd04e
NC
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
252b5132 12
c2dcd04e
NC
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
252b5132 17
c2dcd04e
NC
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
252b5132
RH
21
22#include "bfd.h"
23#include "sysdep.h"
24#include "libbfd.h"
25
b34976b6 26static bfd_boolean h8300_scan
c6baf75e 27 (const struct bfd_arch_info *, const char *);
0a83638b 28static const bfd_arch_info_type * compatible
c6baf75e 29 (const bfd_arch_info_type *, const bfd_arch_info_type *);
0a83638b 30
b34976b6 31static bfd_boolean
c6baf75e 32h8300_scan (const struct bfd_arch_info *info, const char *string)
252b5132
RH
33{
34 if (*string != 'h' && *string != 'H')
b34976b6 35 return FALSE;
252b5132
RH
36
37 string++;
38 if (*string != '8')
b34976b6 39 return FALSE;
252b5132
RH
40
41 string++;
42 if (*string == '/')
43 string++;
44
45 if (*string != '3')
b34976b6 46 return FALSE;
252b5132
RH
47 string++;
48 if (*string != '0')
b34976b6 49 return FALSE;
252b5132
RH
50 string++;
51 if (*string != '0')
b34976b6 52 return FALSE;
252b5132
RH
53 string++;
54 if (*string == '-')
55 string++;
0a83638b
JL
56
57 /* In ELF linker scripts, we typically express the architecture/machine
58 as architecture:machine.
59
60 So if we've matched so far and encounter a colon, try to match the
61 string following the colon. */
62 if (*string == ':')
63 {
64 string++;
eea78af1 65 return h8300_scan (info, string);
0a83638b
JL
66 }
67
252b5132
RH
68 if (*string == 'h' || *string == 'H')
69 {
8d9cd6b1
NC
70 string++;
71 if (*string == 'n' || *string == 'N')
72 return (info->mach == bfd_mach_h8300hn);
73
252b5132
RH
74 return (info->mach == bfd_mach_h8300h);
75 }
76 else if (*string == 's' || *string == 'S')
77 {
8d9cd6b1
NC
78 string++;
79 if (*string == 'n' || *string == 'N')
80 return (info->mach == bfd_mach_h8300sn);
81
5d1db417 82 if (*string == 'x' || *string == 'X')
f4984206
RS
83 {
84 string++;
85 if (*string == 'n' || *string == 'N')
86 return (info->mach == bfd_mach_h8300sxn);
87
88 return (info->mach == bfd_mach_h8300sx);
89 }
5d1db417 90
252b5132
RH
91 return (info->mach == bfd_mach_h8300s);
92 }
93 else
8d9cd6b1 94 return info->mach == bfd_mach_h8300;
252b5132
RH
95}
96
cc040812
NC
97/* This routine is provided two arch_infos and works out the machine
98 which would be compatible with both and returns a pointer to its
99 info structure. */
252b5132
RH
100
101static const bfd_arch_info_type *
c6baf75e 102compatible (const bfd_arch_info_type *in, const bfd_arch_info_type *out)
252b5132
RH
103{
104 /* It's really not a good idea to mix and match modes. */
b74fa2cd 105 if (in->arch != out->arch || in->mach != out->mach)
252b5132
RH
106 return 0;
107 else
108 return in;
109}
110
f4984206
RS
111static const bfd_arch_info_type h8300sxn_info_struct =
112{
113 32, /* 32 bits in a word */
114 32, /* 32 bits in an address */
115 8, /* 8 bits in a byte */
116 bfd_arch_h8300,
117 bfd_mach_h8300sxn,
118 "h8300sxn", /* arch_name */
119 "h8300sxn", /* printable name */
120 1,
121 FALSE, /* the default machine */
122 compatible,
123 h8300_scan,
124 0
125};
126
5d1db417
MS
127static const bfd_arch_info_type h8300sx_info_struct =
128{
129 32, /* 32 bits in a word */
130 32, /* 32 bits in an address */
131 8, /* 8 bits in a byte */
132 bfd_arch_h8300,
133 bfd_mach_h8300sx,
134 "h8300sx", /* arch_name */
135 "h8300sx", /* printable name */
136 1,
137 FALSE, /* the default machine */
138 compatible,
139 h8300_scan,
f4984206 140 &h8300sxn_info_struct
5d1db417
MS
141};
142
8d9cd6b1
NC
143static const bfd_arch_info_type h8300sn_info_struct =
144{
145 32, /* 32 bits in a word. */
146 32, /* 32 bits in an address. */
147 8, /* 8 bits in a byte. */
148 bfd_arch_h8300,
149 bfd_mach_h8300sn,
150 "h8300sn", /* Architecture name. */
151 "h8300sn", /* Printable name. */
152 1,
153 FALSE, /* The default machine. */
154 compatible,
155 h8300_scan,
5d1db417 156 &h8300sx_info_struct
8d9cd6b1
NC
157};
158
159
160static const bfd_arch_info_type h8300hn_info_struct =
161{
162 32, /* 32 bits in a word. */
163 32, /* 32 bits in an address. */
164 8, /* 8 bits in a byte. */
165 bfd_arch_h8300,
166 bfd_mach_h8300hn,
167 "h8300hn", /* Architecture name. */
168 "h8300hn", /* Printable name. */
169 1,
170 FALSE, /* The default machine. */
171 compatible,
172 h8300_scan,
173 &h8300sn_info_struct
174};
175
4c7aad1c 176static const bfd_arch_info_type h8300s_info_struct =
252b5132 177{
8d9cd6b1
NC
178 32, /* 32 bits in a word. */
179 32, /* 32 bits in an address. */
180 8, /* 8 bits in a byte. */
252b5132 181 bfd_arch_h8300,
4c7aad1c 182 bfd_mach_h8300s,
8d9cd6b1
NC
183 "h8300s", /* Architecture name. */
184 "h8300s", /* Printable name. */
252b5132 185 1,
8d9cd6b1 186 FALSE, /* The default machine. */
252b5132
RH
187 compatible,
188 h8300_scan,
8d9cd6b1 189 & h8300hn_info_struct
252b5132
RH
190};
191
192static const bfd_arch_info_type h8300h_info_struct =
193{
8d9cd6b1
NC
194 32, /* 32 bits in a word. */
195 32, /* 32 bits in an address. */
196 8, /* 8 bits in a byte. */
252b5132
RH
197 bfd_arch_h8300,
198 bfd_mach_h8300h,
8d9cd6b1
NC
199 "h8300h", /* Architecture name. */
200 "h8300h", /* Printable name. */
252b5132 201 1,
8d9cd6b1 202 FALSE, /* The default machine. */
252b5132
RH
203 compatible,
204 h8300_scan,
4c7aad1c 205 &h8300s_info_struct
252b5132
RH
206};
207
208const bfd_arch_info_type bfd_h8300_arch =
209{
8d9cd6b1
NC
210 16, /* 16 bits in a word. */
211 16, /* 16 bits in an address. */
212 8, /* 8 bits in a byte. */
252b5132 213 bfd_arch_h8300,
4c7aad1c 214 bfd_mach_h8300,
8d9cd6b1
NC
215 "h8300", /* Architecture name. */
216 "h8300", /* Printable name. */
252b5132 217 1,
8d9cd6b1 218 TRUE, /* The default machine. */
252b5132
RH
219 compatible,
220 h8300_scan,
4c7aad1c 221 &h8300h_info_struct
252b5132 222};
This page took 0.255985 seconds and 4 git commands to generate.