2003-05-14 Jeff Johnston <jjohnstn@redhat.com>
[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
0a83638b
JL
27 PARAMS ((const struct bfd_arch_info *, const char *));
28static const bfd_arch_info_type * compatible
29 PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
30
b34976b6 31static bfd_boolean
252b5132
RH
32h8300_scan (info, string)
33 const struct bfd_arch_info *info;
34 const char *string;
35{
36 if (*string != 'h' && *string != 'H')
b34976b6 37 return FALSE;
252b5132
RH
38
39 string++;
40 if (*string != '8')
b34976b6 41 return FALSE;
252b5132
RH
42
43 string++;
44 if (*string == '/')
45 string++;
46
47 if (*string != '3')
b34976b6 48 return FALSE;
252b5132
RH
49 string++;
50 if (*string != '0')
b34976b6 51 return FALSE;
252b5132
RH
52 string++;
53 if (*string != '0')
b34976b6 54 return FALSE;
252b5132
RH
55 string++;
56 if (*string == '-')
57 string++;
0a83638b
JL
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++;
eea78af1 67 return h8300_scan (info, string);
0a83638b
JL
68 }
69
252b5132
RH
70 if (*string == 'h' || *string == 'H')
71 {
8d9cd6b1
NC
72 string++;
73 if (*string == 'n' || *string == 'N')
74 return (info->mach == bfd_mach_h8300hn);
75
252b5132
RH
76 return (info->mach == bfd_mach_h8300h);
77 }
78 else if (*string == 's' || *string == 'S')
79 {
8d9cd6b1
NC
80 string++;
81 if (*string == 'n' || *string == 'N')
82 return (info->mach == bfd_mach_h8300sn);
83
252b5132
RH
84 return (info->mach == bfd_mach_h8300s);
85 }
86 else
8d9cd6b1 87 return info->mach == bfd_mach_h8300;
252b5132
RH
88}
89
cc040812
NC
90/* This routine is provided two arch_infos and works out the machine
91 which would be compatible with both and returns a pointer to its
92 info structure. */
252b5132
RH
93
94static const bfd_arch_info_type *
95compatible (in, out)
cc040812
NC
96 const bfd_arch_info_type *in;
97 const bfd_arch_info_type *out;
252b5132
RH
98{
99 /* It's really not a good idea to mix and match modes. */
b74fa2cd 100 if (in->arch != out->arch || in->mach != out->mach)
252b5132
RH
101 return 0;
102 else
103 return in;
104}
105
8d9cd6b1
NC
106static const bfd_arch_info_type h8300sn_info_struct =
107{
108 32, /* 32 bits in a word. */
109 32, /* 32 bits in an address. */
110 8, /* 8 bits in a byte. */
111 bfd_arch_h8300,
112 bfd_mach_h8300sn,
113 "h8300sn", /* Architecture name. */
114 "h8300sn", /* Printable name. */
115 1,
116 FALSE, /* The default machine. */
117 compatible,
118 h8300_scan,
119 0
120};
121
122
123static const bfd_arch_info_type h8300hn_info_struct =
124{
125 32, /* 32 bits in a word. */
126 32, /* 32 bits in an address. */
127 8, /* 8 bits in a byte. */
128 bfd_arch_h8300,
129 bfd_mach_h8300hn,
130 "h8300hn", /* Architecture name. */
131 "h8300hn", /* Printable name. */
132 1,
133 FALSE, /* The default machine. */
134 compatible,
135 h8300_scan,
136 &h8300sn_info_struct
137};
138
4c7aad1c 139static const bfd_arch_info_type h8300s_info_struct =
252b5132 140{
8d9cd6b1
NC
141 32, /* 32 bits in a word. */
142 32, /* 32 bits in an address. */
143 8, /* 8 bits in a byte. */
252b5132 144 bfd_arch_h8300,
4c7aad1c 145 bfd_mach_h8300s,
8d9cd6b1
NC
146 "h8300s", /* Architecture name. */
147 "h8300s", /* Printable name. */
252b5132 148 1,
8d9cd6b1 149 FALSE, /* The default machine. */
252b5132
RH
150 compatible,
151 h8300_scan,
8d9cd6b1 152 & h8300hn_info_struct
252b5132
RH
153};
154
155static const bfd_arch_info_type h8300h_info_struct =
156{
8d9cd6b1
NC
157 32, /* 32 bits in a word. */
158 32, /* 32 bits in an address. */
159 8, /* 8 bits in a byte. */
252b5132
RH
160 bfd_arch_h8300,
161 bfd_mach_h8300h,
8d9cd6b1
NC
162 "h8300h", /* Architecture name. */
163 "h8300h", /* Printable name. */
252b5132 164 1,
8d9cd6b1 165 FALSE, /* The default machine. */
252b5132
RH
166 compatible,
167 h8300_scan,
4c7aad1c 168 &h8300s_info_struct
252b5132
RH
169};
170
171const bfd_arch_info_type bfd_h8300_arch =
172{
8d9cd6b1
NC
173 16, /* 16 bits in a word. */
174 16, /* 16 bits in an address. */
175 8, /* 8 bits in a byte. */
252b5132 176 bfd_arch_h8300,
4c7aad1c 177 bfd_mach_h8300,
8d9cd6b1
NC
178 "h8300", /* Architecture name. */
179 "h8300", /* Printable name. */
252b5132 180 1,
8d9cd6b1 181 TRUE, /* The default machine. */
252b5132
RH
182 compatible,
183 h8300_scan,
4c7aad1c 184 &h8300h_info_struct
252b5132 185};
This page took 0.210714 seconds and 4 git commands to generate.