111
|
1 /* Common hooks for Texas Instruments MSP430.
|
145
|
2 Copyright (C) 2014-2020 Free Software Foundation, Inc.
|
111
|
3
|
|
4 This file is part of GCC.
|
|
5
|
|
6 GCC is free software; you can redistribute it and/or modify
|
|
7 it under the terms of the GNU General Public License as published by
|
|
8 the Free Software Foundation; either version 3, or (at your option)
|
|
9 any later version.
|
|
10
|
|
11 GCC is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 GNU General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with GCC; see the file COPYING3. If not see
|
|
18 <http://www.gnu.org/licenses/>. */
|
|
19
|
|
20 #include "config.h"
|
|
21 #include "system.h"
|
|
22 #include "coretypes.h"
|
|
23 #include "diagnostic-core.h"
|
|
24 #include "tm.h"
|
|
25 #include "common/common-target.h"
|
|
26 #include "common/common-target-def.h"
|
|
27 #include "opts.h"
|
|
28 #include "flags.h"
|
|
29
|
|
30 /* Check for generic -mcpu= and -mmcu= names here. If found then we
|
|
31 convert to a baseline cpu name. Otherwise we allow the option to
|
|
32 be passed on to the backend where it can be checked more fully. */
|
|
33
|
|
34 static bool
|
|
35 msp430_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED,
|
|
36 struct gcc_options *opts_set ATTRIBUTE_UNUSED,
|
|
37 const struct cl_decoded_option *decoded,
|
|
38 location_t loc ATTRIBUTE_UNUSED)
|
|
39 {
|
|
40 switch (decoded->opt_index)
|
|
41 {
|
|
42 case OPT_mcpu_:
|
|
43 if (strcasecmp (decoded->arg, "msp430x") == 0
|
|
44 || strcasecmp (decoded->arg, "msp430xv2") == 0
|
|
45 || strcasecmp (decoded->arg, "430x") == 0
|
|
46 || strcasecmp (decoded->arg, "430xv2") == 0)
|
|
47 {
|
|
48 target_cpu = "msp430x";
|
|
49 }
|
|
50 else if (strcasecmp (decoded->arg, "msp430") == 0
|
|
51 || strcasecmp (decoded->arg, "430") == 0)
|
|
52 {
|
|
53 target_cpu = "msp430";
|
|
54 }
|
|
55 else
|
|
56 {
|
145
|
57 error ("unrecognized argument of %<-mcpu%>: %s", decoded->arg);
|
111
|
58 return false;
|
|
59 }
|
|
60 break;
|
|
61
|
|
62 case OPT_mmcu_:
|
|
63 /* For backwards compatibility we recognise two generic MCU
|
|
64 430X names. However we want to be able to generate special C
|
|
65 preprocessor defines for them, which is why we set target_mcu
|
|
66 to NULL. */
|
|
67 if (strcasecmp (decoded->arg, "msp430") == 0)
|
|
68 {
|
|
69 target_cpu = "msp430";
|
|
70 target_mcu = NULL;
|
|
71 }
|
|
72 else if (strcasecmp (decoded->arg, "msp430x") == 0
|
|
73 || strcasecmp (decoded->arg, "msp430xv2") == 0)
|
|
74 {
|
|
75 target_cpu = "msp430x";
|
|
76 target_mcu = NULL;
|
|
77 }
|
|
78 break;
|
|
79 }
|
|
80
|
|
81 return true;
|
|
82 }
|
|
83
|
|
84 #undef TARGET_HANDLE_OPTION
|
|
85 #define TARGET_HANDLE_OPTION msp430_handle_option
|
|
86
|
|
87 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
|