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]

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


On 06/06/18 17:43, DJ Delorie wrote:
Jozef Lawrynowicz <jozef.l@mittosystems.com> writes:
Word from TI is that the lowercase i is an exception, the rule is to have all
uppercase letters. No further msp430i devices are planned so the rules for
generating device names in this patch shouldn't need any future changes.
So a future-proof patch would TOUPPER the 430i suffixes, but the
expectation is that there will never be anything for the TOUPPER to
upper, yes?

Well that's a good point, there's no harm in calling to TOUPPER on the
characters after 'i', given that the lower case i is the exception.
I also added a test for the regular case where the whole string is made
uppercase.

Here's an updated patch, device name tests pass with this applied.
Ok to apply?

Thanks,
Jozef

>From efd996c3efa7f14fa649630b2e88decb0a48ac90 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.
	* msp430f-device-symbol.c: New test.
	* msp430.h: New test header file.
---
 gcc/config/msp430/msp430.c                            | 19 ++++++++++++++++---
 gcc/testsuite/gcc.target/msp430/msp430.h              |  8 ++++++++
 .../gcc.target/msp430/msp430f-device-symbol.c         |  4 ++++
 .../gcc.target/msp430/msp430i-device-symbol.c         |  4 ++++
 4 files changed, 32 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/msp430/msp430.h
 create mode 100644 gcc/testsuite/gcc.target/msp430/msp430f-device-symbol.c
 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..b535c0b 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -725,10 +725,23 @@ msp430_mcu_name (void)
   if (target_mcu)
     {
       unsigned int i;
-      static char mcu_name [64];
+      unsigned int start_upper;
+      static char mcu_name[64];
 
-      snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_mcu);
-      for (i = strlen (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);
+	  start_upper = 9;
+	}
+      else
+	{
+	  snprintf (mcu_name, sizeof (mcu_name) - 1, "__%s__", target_mcu);
+	  start_upper = 0;
+	}
+      for (i = start_upper; 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..1dedbc0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/msp430.h
@@ -0,0 +1,8 @@
+#if defined (__MSP430i2020__)
+
+#elif defined (__MSP430F5529__)
+
+#else
+#error "Device not supported by msp430.h"
+
+#endif
diff --git a/gcc/testsuite/gcc.target/msp430/msp430f-device-symbol.c b/gcc/testsuite/gcc.target/msp430/msp430f-device-symbol.c
new file mode 100644
index 0000000..e41cdaf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/msp430f-device-symbol.c
@@ -0,0 +1,4 @@
+/* { dg-do preprocess } */
+/* { dg-skip-if "" { "*-*-*" } { "-mcpu=msp430" "-mmcu=*" "-mhwmult=32bit" "-mhwmult=16bit" } { "" } } */
+/* { dg-options "-mmcu=msp430f5529" } */
+#include "msp430.h"
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]