msp430.c (msp430_mcu_name): Set the "i" in the symbol defined for msp430i* devices...
authorJozef Lawrynowicz <jozef.l@mittosystems.com>
Thu, 7 Jun 2018 10:09:42 +0000 (10:09 +0000)
committerJozef Lawrynowicz <jozefl@gcc.gnu.org>
Thu, 7 Jun 2018 10:09:42 +0000 (10:09 +0000)
* 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.

From-SVN: r261268

gcc/ChangeLog
gcc/config/msp430/msp430.c
gcc/testsuite/gcc.target/msp430/msp430.h [new file with mode: 0644]
gcc/testsuite/gcc.target/msp430/msp430f-device-symbol.c [new file with mode: 0644]
gcc/testsuite/gcc.target/msp430/msp430i-device-symbol.c [new file with mode: 0644]

index 6526ca2800dc61df43213ff4a9be313b71b9bad4..aa5cf3a1c8a0f811ff86af8c4cc883bc4a1ba357 100644 (file)
@@ -1,3 +1,13 @@
+2018-06-07  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.
+
 2018-06-07  Richard Biener  <rguenther@suse.de>
 
        * graphite-sese-to-poly.c (extract_affine): Avoid unneded
index 90517615bba9b69cea731cd8bef871907b386ece..685bdc8f7858796d193426983b09de5139ab2cfd 100644 (file)
@@ -725,10 +725,25 @@ msp430_mcu_name (void)
   if (target_mcu)
     {
       unsigned int i;
-      static char mcu_name [64];
+      unsigned int start_upper;
+      unsigned int end_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 = 2;
+       }
+      end_upper = strlen (mcu_name) - 2;
+      for (i = start_upper; i < end_upper; 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 (file)
index 0000000..1dedbc0
--- /dev/null
@@ -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 (file)
index 0000000..e41cdaf
--- /dev/null
@@ -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 (file)
index 0000000..36a86c1
--- /dev/null
@@ -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"