Hi Guys,

  I am checking in the patch below to extend the -mmcu command line
  option of the MSP430 port so that it defines a C preprocessor symbol
  based on the name of the MCU part and it also changes the linker
  command line so that it will search for linker scripts specific to
  that part.

Cheers
  Nick

gcc/ChangeLog
2013-11-06  Nick Clifton  <ni...@redhat.com>

        * config/msp430/msp430.h (TARGET_CPU_CPP_BUILTINS): Define the
        name returned by msp430_mcu_name.
        (LIB_SPEC): If a -T option has not been specified then set a
        default, mcu-specific, linker script.
        * config/msp430/t-msp430 (MULTILIB_MATCHES): Add more mcu names.
        * config/msp430/msp430.c (msp430x_names): Likewise.
        Alpha sort the names for ease of comparison.
        (msp430_mcu_name): New function:  Returns a string suitable for
        use as a C preprocessor symbol based upon the name of the MCU
        being targeted.
        (msp430_option_override): Accept msp430x and msp430xv2 as generic
        mcu names.
        * config/msp430/msp430-protos.h (msp430_mcu_name): Prototype.

Index: gcc/config/msp430/msp430-protos.h
===================================================================
--- gcc/config/msp430/msp430-protos.h	(revision 204444)
+++ gcc/config/msp430/msp430-protos.h	(working copy)
@@ -35,6 +35,7 @@
 int	msp430_initial_elimination_offset (int, int);
 bool    msp430_is_interrupt_func (void);
 const char * msp430x_logical_shift_right (rtx);
+const char * msp430_mcu_name (void);
 bool	msp430_modes_tieable_p (enum machine_mode, enum machine_mode);
 void	msp430_output_labelref (FILE *, const char *);
 void	msp430_register_pragmas (void);
Index: gcc/config/msp430/msp430.c
===================================================================
--- gcc/config/msp430/msp430.c	(revision 204444)
+++ gcc/config/msp430/msp430.c	(working copy)
@@ -109,69 +109,87 @@
 #undef  TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE		msp430_option_override
 
+/* This list provides a set of known MCU names that support the MSP430X
+   ISA.  The list has been provided by TI and should be kept in sync with
+   the ones in:
+   
+     gcc/config/msp430/t-msp430
+     gas/config/tc-msp430.c
+
+   FIXME: We ought to read the names in from a file at run, rather
+   than having them built in like this.  Also such a file should be
+   shared with gas.  */
+
 static const char * msp430x_names [] =
 {
-  "msp430x",   /* Generic name.  */
-  "msp430xv2", /* Generic name.  */
-
-  /* These names have been provided by TI and match the names currently
-     supported by GAS.
-
-     NB/ This list should be kept in sync with the ones in:
-       gcc/config/msp430/t-msp430
-       gas/config/tc-msp430.c
-
-     FIXME: We ought to read the names in from a file at run, rather
-     than having them built in like this.  Also such a file should be
-     shared with gas.  */
-  
-  "msp430cg4616", "msp430cg4617", "msp430cg4618", "msp430cg4619", "msp430f2416",
-  "msp430f2417",  "msp430f2418",  "msp430f2419",  "msp430f2616",  "msp430f2617",
-  "msp430f2618",  "msp430f2619",  "msp430f47126", "msp430f47127", "msp430f47163",
-  "msp430f47173", "msp430f47183", "msp430f47193", "msp430f47166", "msp430f47176",
-  "msp430f47186", "msp430f47196", "msp430f47167", "msp430f47177", "msp430f47187",
-  "msp430f47197", "msp430f46161", "msp430f46171", "msp430f46181", "msp430f46191",
-  "msp430f4616",  "msp430f4617",  "msp430f4618",  "msp430f4619",  "msp430fg4616",
-  "msp430fg4617", "msp430fg4618", "msp430fg4619", "msp430f5418",  "msp430f5419",
-  "msp430f5435",  "msp430f5436",  "msp430f5437",  "msp430f5438",  "msp430f5418a",
-  "msp430f5419a", "msp430f5435a", "msp430f5436a", "msp430f5437a", "msp430f5438a",
-  "msp430f5212",  "msp430f5213",  "msp430f5214",  "msp430f5217",  "msp430f5218",
-  "msp430f5219",  "msp430f5222",  "msp430f5223",  "msp430f5224",  "msp430f5227",
-  "msp430f5228",  "msp430f5229",  "msp430f5304",  "msp430f5308",  "msp430f5309",
-  "msp430f5310",  "msp430f5340",  "msp430f5341",  "msp430f5342",  "msp430f5324",
-  "msp430f5325",  "msp430f5326",  "msp430f5327",  "msp430f5328",  "msp430f5329",
+  "cc430f5123",   "cc430f5125",   "cc430f5133",   "cc430f5135",   "cc430f5137",
+  "cc430f5143",   "cc430f5145",   "cc430f5147",   "cc430f6125",   "cc430f6126",
+  "cc430f6127",   "cc430f6135",   "cc430f6137",   "cc430f6143",   "cc430f6145",
+  "cc430f6147",   "msp430bt5190", "msp430cg4616", "msp430cg4617", "msp430cg4618",
+  "msp430cg4619", "msp430f2416",  "msp430f2417",  "msp430f2418",  "msp430f2419",
+  "msp430f2616",  "msp430f2617",  "msp430f2618",  "msp430f2619",  "msp430f4616",
+  "msp430f46161", "msp430f4617",  "msp430f46171", "msp430f4618",  "msp430f46181",
+  "msp430f4619",  "msp430f46191", "msp430f47126", "msp430f47127", "msp430f47163",
+  "msp430f47166", "msp430f47167", "msp430f47173", "msp430f47176", "msp430f47177",
+  "msp430f47183", "msp430f47186", "msp430f47187", "msp430f47193", "msp430f47196",
+  "msp430f47197", "msp430f5131",  "msp430f5132",  "msp430f5151",  "msp430f5152",
+  "msp430f5171",  "msp430f5172",  "msp430f5212",  "msp430f5213",  "msp430f5214",
+  "msp430f5217",  "msp430f5218",  "msp430f5219",  "msp430f5222",  "msp430f5223",
+  "msp430f5224",  "msp430f5227",  "msp430f5228",  "msp430f5229",  "msp430f5304",
+  "msp430f5308",  "msp430f5309",  "msp430f5310",  "msp430f5324",  "msp430f5325",
+  "msp430f5326",  "msp430f5327",  "msp430f5328",  "msp430f5329",  "msp430f5333",
+  "msp430f5335",  "msp430f5336",  "msp430f5338",  "msp430f5340",  "msp430f5341",
+  "msp430f5342",  "msp430f5358",  "msp430f5359",  "msp430f5418",  "msp430f5418a",
+  "msp430f5419",  "msp430f5419a", "msp430f5435",  "msp430f5435a", "msp430f5436",
+  "msp430f5436a", "msp430f5437",  "msp430f5437a", "msp430f5438",  "msp430f5438a",
   "msp430f5500",  "msp430f5501",  "msp430f5502",  "msp430f5503",  "msp430f5504",
   "msp430f5505",  "msp430f5506",  "msp430f5507",  "msp430f5508",  "msp430f5509",
   "msp430f5510",  "msp430f5513",  "msp430f5514",  "msp430f5515",  "msp430f5517",
   "msp430f5519",  "msp430f5521",  "msp430f5522",  "msp430f5524",  "msp430f5525",
-  "msp430f5526",  "msp430f5527",  "msp430f5528",  "msp430f5529",   "cc430f5133",
-  "cc430f5135",    "cc430f5137",   "cc430f6125",   "cc430f6126",   "cc430f6127",
-  "cc430f6135",    "cc430f6137",   "cc430f5123",   "cc430f5125",   "cc430f5143",
-  "cc430f5145",    "cc430f5147",   "cc430f6143",   "cc430f6145",   "cc430f6147",
-  "msp430f5333",  "msp430f5335",  "msp430f5336",  "msp430f5338",  "msp430f5630",
+  "msp430f5526",  "msp430f5527",  "msp430f5528",  "msp430f5529",  "msp430f5630",
   "msp430f5631",  "msp430f5632",  "msp430f5633",  "msp430f5634",  "msp430f5635",
-  "msp430f5636",  "msp430f5637",  "msp430f5638",  "msp430f6433",  "msp430f6435",
-  "msp430f6436",  "msp430f6438",  "msp430f6630",  "msp430f6631",  "msp430f6632",
-  "msp430f6633",  "msp430f6634",  "msp430f6635",  "msp430f6636",  "msp430f6637",
-  "msp430f6638",  "msp430f5358",  "msp430f5359",  "msp430f5658",  "msp430f5659",
-  "msp430f6458",  "msp430f6459",  "msp430f6658",  "msp430f6659",  "msp430f5131",
-  "msp430f5151",  "msp430f5171",  "msp430f5132",  "msp430f5152",  "msp430f5172",
-  "msp430f6720",  "msp430f6721",  "msp430f6723",  "msp430f6724",  "msp430f6725",
-  "msp430f6726",  "msp430f6730",  "msp430f6731",  "msp430f6733",  "msp430f6734",
-  "msp430f6735",  "msp430f6736",  "msp430f67451", "msp430f67651", "msp430f67751",
-  "msp430f67461", "msp430f67661", "msp430f67761", "msp430f67471", "msp430f67671",
-  "msp430f67771", "msp430f67481", "msp430f67681", "msp430f67781", "msp430f67491",
-  "msp430f67691", "msp430f67791", "msp430f6745",  "msp430f6765",  "msp430f6775",
-  "msp430f6746",  "msp430f6766",  "msp430f6776",  "msp430f6747",  "msp430f6767",
-  "msp430f6777",  "msp430f6748",  "msp430f6768",  "msp430f6778",  "msp430f6749",
-  "msp430f6769",  "msp430f6779",  "msp430fr5720", "msp430fr5721", "msp430fr5722",
-  "msp430fr5723", "msp430fr5724", "msp430fr5725", "msp430fr5726", "msp430fr5727",
-  "msp430fr5728", "msp430fr5729", "msp430fr5730", "msp430fr5731", "msp430fr5732",
-  "msp430fr5733", "msp430fr5734", "msp430fr5735", "msp430fr5736", "msp430fr5737",
-  "msp430fr5738", "msp430fr5739", "msp430bt5190", "msp430fr5949", "msp430fr5969",
-  "msp430sl5438a"
+  "msp430f5636",  "msp430f5637",  "msp430f5638",  "msp430f5658",  "msp430f5659",
+  "msp430f6433",  "msp430f6435",  "msp430f6436",  "msp430f6438",  "msp430f6458",
+  "msp430f6459",  "msp430f6630",  "msp430f6631",  "msp430f6632",  "msp430f6633",
+  "msp430f6634",  "msp430f6635",  "msp430f6636",  "msp430f6637",  "msp430f6638",
+  "msp430f6658",  "msp430f6659",  "msp430f6720",  "msp430f6721",  "msp430f6723",
+  "msp430f6724",  "msp430f6725",  "msp430f6726",  "msp430f6730",  "msp430f6731",
+  "msp430f6733",  "msp430f6734",  "msp430f6735",  "msp430f6736",  "msp430f6745",
+  "msp430f67451", "msp430f6746",  "msp430f67461", "msp430f6747",  "msp430f67471",
+  "msp430f6748",  "msp430f67481", "msp430f6749",  "msp430f67491", "msp430f6765",
+  "msp430f67651", "msp430f6766",  "msp430f67661", "msp430f6767",  "msp430f67671",
+  "msp430f6768",  "msp430f67681", "msp430f6769",  "msp430f67691", "msp430f6775",
+  "msp430f67751", "msp430f6776",  "msp430f67761", "msp430f6777",  "msp430f67771",
+  "msp430f6778",  "msp430f67781", "msp430f6779",  "msp430f67791", "msp430fg4616",
+  "msp430fg4617", "msp430fg4618", "msp430fg4619", "msp430fr5720", "msp430fr5721",
+  "msp430fr5722", "msp430fr5723", "msp430fr5724", "msp430fr5725", "msp430fr5726",
+  "msp430fr5727", "msp430fr5728", "msp430fr5729", "msp430fr5730", "msp430fr5731",
+  "msp430fr5732", "msp430fr5733", "msp430fr5734", "msp430fr5735", "msp430fr5736",
+  "msp430fr5737", "msp430fr5738", "msp430fr5739", "msp430fr5949", "msp430fr5969",
+  "msp430sl5438a","msp430x241x",  "msp430x26x",   "msp430x461x1", "msp430x46x",
+  "msp430x471x3", "msp430x471x6", "msp430x471x7", "msp430xg46x"
 };
+
+/* Generate a C preprocessor symbol based upon the MCU selected by the user.
+   If a specific MCU has not been selected then return a generic symbol instead.  */
+
+const char *
+msp430_mcu_name (void)
+{
+  if (target_cpu)
+    {
+      unsigned int i;
+      static char mcu_name [64];
+
+      snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_cpu);
+      for (i = strlen (mcu_name); i--;)
+	mcu_name[i] = TOUPPER (mcu_name[i]);
+      return mcu_name;
+    }
   
+  return msp430x ? "__MSP430XGENERIC__" : "__MSP430GENERIC__";
+}
+
 static void
 msp430_option_override (void)
 {
@@ -191,6 +209,13 @@
 	 name.  The msp430x_names array only contains those MCU names
 	 which are currently known to use the MSP430X ISA.  There are
 	 lots of other MCUs which just use the MSP430 ISA.  */
+
+      /* We also recognise two generic MCU 430X names.  They do not
+	 appear in the msp430x_names table as we want to be able to
+	 generate special C preprocessor defines for them.  */
+      if (strcasecmp (target_cpu, "msp430x") == 0
+	  || strcasecmp (target_cpu, "msp430xv2") == 0)
+	msp430x = true;
     }
 
   if (TARGET_LARGE && !msp430x)
Index: gcc/config/msp430/msp430.h
===================================================================
--- gcc/config/msp430/msp430.h	(revision 204444)
+++ gcc/config/msp430/msp430.h	(working copy)
@@ -31,6 +31,7 @@
     {                                           \
       builtin_define ("NO_TRAMPOLINES");        \
       builtin_define ("__MSP430__"); 		\
+      builtin_define (msp430_mcu_name ());	\
       if (msp430x)				\
 	{					\
 	  builtin_define ("__MSP430X__");	\
@@ -70,10 +71,11 @@
 %{msim:-lsim}						\
 %{!msim:-lnosys}					\
 --end-group					   	\
-%{!T*: %{msim: %{mlarge:%Tmsp430xl-sim.ld}%{!mlarge:%Tmsp430-sim.ld}}%{!msim:%Tmsp430.ld}}	\
+%{!T*:%{!msim:%{mmcu=*:--script=%*/memory.ld --script=%*/peripherals.ld}}}	\
+%{!T*:%{!msim:%{!mmcu=*:%Tmsp430.ld}}} \
+%{!T*:%{msim:%{mlarge:%Tmsp430xl-sim.ld}%{!mlarge:%Tmsp430-sim.ld}}} \
 "
 
-
 /* Storage Layout */
 
 #define BITS_BIG_ENDIAN 		0
Index: gcc/config/msp430/t-msp430
===================================================================
--- gcc/config/msp430/t-msp430	(revision 204444)
+++ gcc/config/msp430/t-msp430	(working copy)
@@ -254,8 +254,16 @@
 MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430fr5949
 MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430fr5969
 MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430sl5438a
-  
+MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430x241x
+MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430x26x
+MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430x461x1
+MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430x46x
+MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430x471x3
+MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430x471x6
+MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430x471x7
+MULTILIB_MATCHES += mmcu?msp430x=mmcu?msp430xg46x
 
+
 MULTILIB_EXCEPTIONS = mlarge
 
 MULTILIB_EXTRA_OPTS =

Reply via email to