This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [MSP430] Fix device name symbol defined for MSP430i series of devices


In the GCC board support package distributed by TI for msp430 devices, the
preprocessor symbol definition for the MSP430i series of devices expected by
the msp430.h header file differs from the standard template.

For other devices, the expected symbol has all characters in upper case, but
for the MSP430i devices, the 'i' must be lower case.

TI can't change the format of the symbol expected in msp430.h in the BSP, so
this work around is needed to ensure the -mmcu option works for MSP430i*
devices.

Ok for trunk?

>From 6ceb89b2955472b83d1cd1734231b46188e0c9bf Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Mon, 4 Jun 2018 12:04:54 +0100
Subject: [PATCH] MSP430: Fix device name symbol defined for msp430i* devices

2018-06-04  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* gcc/config/msp430/msp430.c (msp430_mcu_name): Set the "i" in the
	symbol defined for msp430i* devices to be lower case.

	gcc/testsuite/gcc.target/msp430/
	* msp430i-device-symbol.c: New test.
	* msp430.h: New test header file.

---
 gcc/config/msp430/msp430.c                              | 16 ++++++++++++----
 gcc/testsuite/gcc.target/msp430/msp430.h                |  6 ++++++
 gcc/testsuite/gcc.target/msp430/msp430i-device-symbol.c |  4 ++++
 3 files changed, 22 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/msp430/msp430.h
 create mode 100644 gcc/testsuite/gcc.target/msp430/msp430i-device-symbol.c

diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index a8fed12..c8ca58d 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -725,11 +725,19 @@ msp430_mcu_name (void)
   if (target_mcu)
     {
       unsigned int i;
-      static char mcu_name [64];
+      static char mcu_name[64];
 
-      snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_mcu);
-      for (i = strlen (mcu_name); i--;)
-	mcu_name[i] = TOUPPER (mcu_name[i]);
+      /* The 'i' in the device name symbol for msp430i* devices must be lower
+	 case, to match the expected symbol in msp430.h.  */
+      if (strncmp (target_mcu, "msp430i", 7) == 0)
+	snprintf (mcu_name, sizeof (mcu_name) - 1, "__MSP430i%s__",
+		  target_mcu + 7);
+      else
+	{
+	  snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_mcu);
+	  for (i = strlen (mcu_name); i--;)
+	    mcu_name[i] = TOUPPER (mcu_name[i]);
+	}
       return mcu_name;
     }
 
diff --git a/gcc/testsuite/gcc.target/msp430/msp430.h b/gcc/testsuite/gcc.target/msp430/msp430.h
new file mode 100644
index 0000000..ee44f6b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/msp430.h
@@ -0,0 +1,6 @@
+#if defined (__MSP430i2020__)
+
+#else
+#error "Device not supported by msp430.h"
+
+#endif
diff --git a/gcc/testsuite/gcc.target/msp430/msp430i-device-symbol.c b/gcc/testsuite/gcc.target/msp430/msp430i-device-symbol.c
new file mode 100644
index 0000000..36a86c1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/msp430i-device-symbol.c
@@ -0,0 +1,4 @@
+/* { dg-do preprocess } */
+/* { dg-skip-if "" { "*-*-*" } { "-mlarge" "-mcpu=msp430x*" "-mmcu=*" "-mhwmult=32bit" "-mhwmult=f5series" } { "" } } */
+/* { dg-options "-mmcu=msp430i2020" } */
+#include "msp430.h"
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]