* alpha-tdep.c (alpha_push_dummy_call): Handle COMPLEX types.
[binutils-gdb.git] / bfd / cpu-h8300.c
1 /* BFD library support routines for the Renesas H8/300 architecture.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
4 Hacked by Steve Chamberlain of Cygnus Support.
5
6 This file is part of BFD, the Binary File Descriptor library.
7
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.
12
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.
17
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. */
21
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "libbfd.h"
25
26 static bfd_boolean h8300_scan
27 PARAMS ((const struct bfd_arch_info *, const char *));
28 static const bfd_arch_info_type * compatible
29 PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
30
31 static bfd_boolean
32 h8300_scan (info, string)
33 const struct bfd_arch_info *info;
34 const char *string;
35 {
36 if (*string != 'h' && *string != 'H')
37 return FALSE;
38
39 string++;
40 if (*string != '8')
41 return FALSE;
42
43 string++;
44 if (*string == '/')
45 string++;
46
47 if (*string != '3')
48 return FALSE;
49 string++;
50 if (*string != '0')
51 return FALSE;
52 string++;
53 if (*string != '0')
54 return FALSE;
55 string++;
56 if (*string == '-')
57 string++;
58
59 /* In ELF linker scripts, we typically express the architecture/machine
60 as architecture:machine.
61
62 So if we've matched so far and encounter a colon, try to match the
63 string following the colon. */
64 if (*string == ':')
65 {
66 string++;
67 return h8300_scan (info, string);
68 }
69
70 if (*string == 'h' || *string == 'H')
71 {
72 string++;
73 if (*string == 'n' || *string == 'N')
74 return (info->mach == bfd_mach_h8300hn);
75
76 return (info->mach == bfd_mach_h8300h);
77 }
78 else if (*string == 's' || *string == 'S')
79 {
80 string++;
81 if (*string == 'n' || *string == 'N')
82 return (info->mach == bfd_mach_h8300sn);
83
84 if (*string == 'x' || *string == 'X')
85 return (info->mach == bfd_mach_h8300sx);
86
87 return (info->mach == bfd_mach_h8300s);
88 }
89 else
90 return info->mach == bfd_mach_h8300;
91 }
92
93 /* This routine is provided two arch_infos and works out the machine
94 which would be compatible with both and returns a pointer to its
95 info structure. */
96
97 static const bfd_arch_info_type *
98 compatible (in, out)
99 const bfd_arch_info_type *in;
100 const bfd_arch_info_type *out;
101 {
102 /* It's really not a good idea to mix and match modes. */
103 if (in->arch != out->arch || in->mach != out->mach)
104 return 0;
105 else
106 return in;
107 }
108
109 static const bfd_arch_info_type h8300sx_info_struct =
110 {
111 32, /* 32 bits in a word */
112 32, /* 32 bits in an address */
113 8, /* 8 bits in a byte */
114 bfd_arch_h8300,
115 bfd_mach_h8300sx,
116 "h8300sx", /* arch_name */
117 "h8300sx", /* printable name */
118 1,
119 FALSE, /* the default machine */
120 compatible,
121 h8300_scan,
122 0
123 };
124
125 static const bfd_arch_info_type h8300sn_info_struct =
126 {
127 32, /* 32 bits in a word. */
128 32, /* 32 bits in an address. */
129 8, /* 8 bits in a byte. */
130 bfd_arch_h8300,
131 bfd_mach_h8300sn,
132 "h8300sn", /* Architecture name. */
133 "h8300sn", /* Printable name. */
134 1,
135 FALSE, /* The default machine. */
136 compatible,
137 h8300_scan,
138 &h8300sx_info_struct
139 };
140
141
142 static const bfd_arch_info_type h8300hn_info_struct =
143 {
144 32, /* 32 bits in a word. */
145 32, /* 32 bits in an address. */
146 8, /* 8 bits in a byte. */
147 bfd_arch_h8300,
148 bfd_mach_h8300hn,
149 "h8300hn", /* Architecture name. */
150 "h8300hn", /* Printable name. */
151 1,
152 FALSE, /* The default machine. */
153 compatible,
154 h8300_scan,
155 &h8300sn_info_struct
156 };
157
158 static const bfd_arch_info_type h8300s_info_struct =
159 {
160 32, /* 32 bits in a word. */
161 32, /* 32 bits in an address. */
162 8, /* 8 bits in a byte. */
163 bfd_arch_h8300,
164 bfd_mach_h8300s,
165 "h8300s", /* Architecture name. */
166 "h8300s", /* Printable name. */
167 1,
168 FALSE, /* The default machine. */
169 compatible,
170 h8300_scan,
171 & h8300hn_info_struct
172 };
173
174 static const bfd_arch_info_type h8300h_info_struct =
175 {
176 32, /* 32 bits in a word. */
177 32, /* 32 bits in an address. */
178 8, /* 8 bits in a byte. */
179 bfd_arch_h8300,
180 bfd_mach_h8300h,
181 "h8300h", /* Architecture name. */
182 "h8300h", /* Printable name. */
183 1,
184 FALSE, /* The default machine. */
185 compatible,
186 h8300_scan,
187 &h8300s_info_struct
188 };
189
190 const bfd_arch_info_type bfd_h8300_arch =
191 {
192 16, /* 16 bits in a word. */
193 16, /* 16 bits in an address. */
194 8, /* 8 bits in a byte. */
195 bfd_arch_h8300,
196 bfd_mach_h8300,
197 "h8300", /* Architecture name. */
198 "h8300", /* Printable name. */
199 1,
200 TRUE, /* The default machine. */
201 compatible,
202 h8300_scan,
203 &h8300h_info_struct
204 };