2013-01-21 Marc Khouzam <marc.khouzam@ericsson.com>
[platform/upstream/binutils.git] / bfd / cpu-tic4x.c
1 /* bfd back-end for TMS320C[34]x support
2    Copyright 1996, 1997, 2002, 2003, 2005, 2007, 2012
3    Free Software Foundation, Inc.
4
5    Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz)
6
7    This file is part of BFD, the Binary File Descriptor library.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22    MA 02110-1301, USA.  */
23
24 #include "sysdep.h"
25 #include "bfd.h"
26 #include "libbfd.h"
27
28 static bfd_boolean
29 tic4x_scan (const struct bfd_arch_info *info,
30             const char *string)
31 {
32   /* Allow strings of form [ti][Cc][34][0-9], let's not be too picky
33      about strange numbered machines in C3x or C4x series.  */
34   if (string[0] == 't' && string[1] == 'i')
35     string += 2;
36   if (*string == 'C' || *string == 'c')
37     string++;
38   if (string[1] < '0' && string[1] > '9')
39     return FALSE;
40
41   if (*string == '3')
42     return (info->mach == bfd_mach_tic3x);
43   else if (*string == '4')
44     return info->mach == bfd_mach_tic4x;
45
46   return FALSE;
47 }
48
49
50 const bfd_arch_info_type bfd_tic3x_arch =
51   {
52     32,                         /* 32 bits in a word.  */
53     32,                         /* 32 bits in an address.  */
54     32,                         /* 32 bits in a byte.  */
55     bfd_arch_tic4x,
56     bfd_mach_tic3x,             /* Machine number.  */
57     "tic3x",                    /* Architecture name.  */
58     "tms320c3x",                /* Printable name.  */
59     0,                          /* Alignment power.  */
60     FALSE,                      /* Not the default architecture.  */
61     bfd_default_compatible,
62     tic4x_scan,
63     bfd_arch_default_fill,
64     0
65   };
66
67 const bfd_arch_info_type bfd_tic4x_arch =
68   {
69     32,                         /* 32 bits in a word.  */
70     32,                         /* 32 bits in an address.  */
71     32,                         /* 32 bits in a byte.  */
72     bfd_arch_tic4x,
73     bfd_mach_tic4x,             /* Machine number.  */
74     "tic4x",                    /* Architecture name.  */
75     "tms320c4x",                /* Printable name.  */
76     0,                          /* Alignment power.  */
77     TRUE,                       /* The default architecture.  */
78     bfd_default_compatible,
79     tic4x_scan,
80     bfd_arch_default_fill,
81     &bfd_tic3x_arch,
82   };
83
84