1 /* Common hooks for Texas Instruments MSP430. 2 Copyright (C) 2014-2015 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 /* Handle -mcpu= and -mmcu= here. We want to ensure that only one 31 of these two options - the last specified on the command line - 32 is passed on to the msp430 backend. */ 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 target_mcu = NULL; 50 } 51 else if (strcasecmp (decoded->arg, "msp430") == 0 52 || strcasecmp (decoded->arg, "430") == 0) 53 { 54 target_cpu = "msp430"; 55 target_mcu = NULL; 56 } 57 else 58 { 59 error ("unrecognised argument of -mcpu: %s", decoded->arg); 60 return false; 61 } 62 break; 63 64 case OPT_mmcu_: 65 /* For backwards compatibility we recognise two generic MCU 66 430X names. However we want to be able to generate special C 67 preprocessor defines for them, which is why we set target_mcu 68 to NULL. */ 69 if (strcasecmp (decoded->arg, "msp430") == 0) 70 { 71 target_cpu = "msp430"; 72 target_mcu = NULL; 73 } 74 else if (strcasecmp (decoded->arg, "msp430x") == 0 75 || strcasecmp (decoded->arg, "msp430xv2") == 0) 76 { 77 target_cpu = "msp430x"; 78 target_mcu = NULL; 79 } 80 else 81 target_cpu = NULL; 82 break; 83 } 84 85 return true; 86 } 87 88 #undef TARGET_HANDLE_OPTION 89 #define TARGET_HANDLE_OPTION msp430_handle_option 90 91 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; 92