The naming scheme used by GCC to reference MSP430 hardware multiply
library functions is inconsistent.

Sometimes the "GCC" names (e.g. mulsi2) are used, other times the
"MSPABI" names (e.g. __mspabi_mpyl) are used. The __mspabi names should
always be used.

Also, sometimes an identifier for the hardware multiply support is
appended to the GCC name, when the functions are defined, but this is
not required.

This patch fixes those issues, so the names used to refer to the
hardware multiply library functions follow a consistent pattern.

Successfully regtested for msp430-elf.

Committed as obvious.
>From c746fc40f4ec8cfc1092efd49d567751858d2099 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <joze...@mittosystems.com>
Date: Sun, 15 Nov 2020 21:03:06 +0000
Subject: [PATCH] MSP430: Fix inconsistent naming of hwmult libfuncs

The naming scheme used by GCC to reference MSP430 hardware multiply
library functions is inconsistent.

Sometimes the "GCC" names (e.g. mulsi2) are used, other times the
"MSPABI" names (e.g. __mspabi_mpyl) are used.

Also, sometimes an identifier for the hardware multiply support is
appended to the GCC name, when the functions are defined, but this is
not required.

This patch fixes those issues, so the names used to refer to the
hardware multiply library functions follow a consistent pattern.

gcc/ChangeLog:

        * config/msp430/msp430.c (msp430_output_labelref): Don't process mspabi
        hwmult library function names into GCC-style names.

libgcc/ChangeLog:

        * config/msp430/lib2hw_mul.S: Omit _hw* suffix from GCC names for
        hwmult library functions.

gcc/testsuite/ChangeLog:

        * gcc.target/msp430/rtx-cost-Os-f5series.c: Adjust test to use new
        hwmult library function name.
---
 gcc/config/msp430/msp430.c                    | 22 -------------------
 .../gcc.target/msp430/rtx-cost-Os-f5series.c  |  2 +-
 libgcc/config/msp430/lib2hw_mul.S             | 12 +++++-----
 3 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index 38a9938255e..51f49edffa8 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -4031,28 +4031,6 @@ msp430_output_labelref (FILE *file, const char *name)
        break;
       }
 
-  /* If we have been given a specific MCU name then we may be
-     able to make use of its hardware multiply capabilities.  */
-  if (msp430_has_hwmult ())
-    {
-      if (strcmp ("__mspabi_mpyi", name) == 0)
-       {
-         if (msp430_use_f5_series_hwmult ())
-           name = "__mulhi2_f5";
-         else
-           name = "__mulhi2";
-       }
-      else if (strcmp ("__mspabi_mpyl", name) == 0)
-       {
-         if (msp430_use_f5_series_hwmult ())
-           name = "__mulsi2_f5";
-         else if (msp430_use_32bit_hwmult ())
-           name = "__mulsi2_hw32";
-         else
-           name = "__mulsi2";
-       }
-    }
-
   if (user_label_prefix[0] != 0)
     fputs (user_label_prefix, file);
 
diff --git a/gcc/testsuite/gcc.target/msp430/rtx-cost-Os-f5series.c 
b/gcc/testsuite/gcc.target/msp430/rtx-cost-Os-f5series.c
index bb37f9083d9..67d91983715 100644
--- a/gcc/testsuite/gcc.target/msp430/rtx-cost-Os-f5series.c
+++ b/gcc/testsuite/gcc.target/msp430/rtx-cost-Os-f5series.c
@@ -24,7 +24,7 @@ unsigned long res3;
 **     MOV.B   #100, R14
 **     MOV.B   #0, R15
 ** ...
-**     CALL.*  #__mulsi2_f5
+**     CALL.*  #__mspabi_mpyl_f5hw
 ** ...
 */
 void foo (void)
diff --git a/libgcc/config/msp430/lib2hw_mul.S 
b/libgcc/config/msp430/lib2hw_mul.S
index de840d934f6..0fbafcd8b95 100644
--- a/libgcc/config/msp430/lib2hw_mul.S
+++ b/libgcc/config/msp430/lib2hw_mul.S
@@ -353,9 +353,9 @@
        mult1632 MPY, OP2, RESLO, RESHI
        end_func   __umulhisi2
 
-       start_func __mulsi2_hw32  __mspabi_mpyl  __mspabi_mpyl_hw32
+       start_func __mulsi2  __mspabi_mpyl  __mspabi_mpyl_hw32
        mult32_hw MPY32L, MPY32H, OP2L, OP2H, RES0, RES1
-       end_func   __mulsi2_hw32
+       end_func   __mulsi2
 
        start_func __mulsidi2  __mspabi_mpysll  __mspabi_mpysll_hw32
        mult3264_hw MPYS32L, MPYS32H, OP2L, OP2H, RES0, RES1, RES2, RES3
@@ -373,9 +373,9 @@
    as the second generation hardware, but they are accessed from different
    memory registers.  */
 
-       start_func __mulhi2_f5 __mspabi_mpyi  __mspabi_mpyi_f5hw
+       start_func __mulhi2 __mspabi_mpyi  __mspabi_mpyi_f5hw
        mult16 MPY_F5, OP2_F5, RESLO_F5
-       end_func   __mulhi2_f5
+       end_func   __mulhi2
 
        start_func __mulhisi2  __mspabi_mpysl  __mspabi_mpysl_f5hw
        mult1632 MPYS_F5, OP2_F5, RESLO_F5, RESHI_F5
@@ -385,9 +385,9 @@
        mult1632 MPY_F5, OP2_F5, RESLO_F5, RESHI_F5
        end_func   __umulhisi2
 
-       start_func __mulsi2_f5  __mspabi_mpyl  __mspabi_mpyl_f5hw
+       start_func __mulsi2  __mspabi_mpyl  __mspabi_mpyl_f5hw
        mult32_hw MPY32L_F5, MPY32H_F5, OP2L_F5, OP2H_F5, RES0_F5, RES1_F5
-       end_func   __mulsi2_f5
+       end_func   __mulsi2
 
        start_func __mulsidi2  __mspabi_mpysll  __mspabi_mpysll_f5hw
        mult3264_hw MPYS32L_F5, MPYS32H_F5, OP2L_F5, OP2H_F5, RES0_F5, RES1_F5, 
RES2_F5, RES3_F5
-- 
2.29.2

Reply via email to