1 /* Common hooks for Texas Instruments MSP430.
2 Copyright (C) 2014-2022 Free Software Foundation, Inc.
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 -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
msp430_handle_option(struct gcc_options * opts ATTRIBUTE_UNUSED,struct gcc_options * opts_set ATTRIBUTE_UNUSED,const struct cl_decoded_option * decoded,location_t loc ATTRIBUTE_UNUSED)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_mmcu_:
43 /* For backwards compatibility we recognise two generic MCU
44 430X names. However we want to be able to generate special C
45 preprocessor defines for them, which is why we set target_mcu
46 to NULL. */
47 if (strcasecmp (decoded->arg, "msp430") == 0)
48 {
49 target_cpu = MSP430_CPU_MSP430;
50 target_mcu = NULL;
51 }
52 else if (strcasecmp (decoded->arg, "msp430x") == 0
53 || strcasecmp (decoded->arg, "msp430xv2") == 0)
54 {
55 target_cpu = MSP430_CPU_MSP430X;
56 target_mcu = NULL;
57 }
58 break;
59 }
60
61 return true;
62 }
63
64 #undef TARGET_HANDLE_OPTION
65 #define TARGET_HANDLE_OPTION msp430_handle_option
66
67 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
68