aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJozef Lawrynowicz <jozef.l@mittosystems.com>2020-11-15 21:02:58 +0000
committerJozef Lawrynowicz <jozef.l@mittosystems.com>2020-11-15 21:04:54 +0000
commit814949ddceaef59725c84fe8ef7c6c617fb5d049 (patch)
tree720149b0645e859c695bdeb7c256e3f074b67a8e
parent9243f0fba68339fa6d8bcac35b0df6e88c1ad099 (diff)
downloadgcc-814949ddceaef59725c84fe8ef7c6c617fb5d049.zip
gcc-814949ddceaef59725c84fe8ef7c6c617fb5d049.tar.gz
gcc-814949ddceaef59725c84fe8ef7c6c617fb5d049.tar.bz2
MSP430: Define function to check 16-bit hwmult support
gcc/ChangeLog: * config/msp430/msp430.c (msp430_use_16bit_hwmult): New. (use_32bit_hwmult): Rename to.. (msp430_use_32bit_hwmult): ..this. (msp430_muldiv_costs): Use msp430_use_16bit_hwmult and msp430_use_32bit_hwmult. (msp430_expand_helper): Use msp430_use_16bit_hwmult and msp430_use_32bit_hwmult. (msp430_output_labelref): Use msp430_use_32bit_hwmult.
-rw-r--r--gcc/config/msp430/msp430.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index e98de8d..38a9938 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -58,7 +58,8 @@
static void msp430_compute_frame_info (void);
-static bool use_32bit_hwmult (void);
+static bool msp430_use_16bit_hwmult (void);
+static bool msp430_use_32bit_hwmult (void);
static bool use_helper_for_const_shift (machine_mode mode, HOST_WIDE_INT amt);
@@ -1318,9 +1319,7 @@ msp430_muldiv_costs (rtx src, rtx dst, bool speed, rtx outer_rtx,
{
enum rtx_code outer_code = GET_CODE (outer_rtx);
const struct msp430_multlib_costs *cost_p;
- bool hwmult_16bit = (msp430_has_hwmult () && !(msp430_use_f5_series_hwmult ()
- || use_32bit_hwmult ()));
- cost_p = (hwmult_16bit
+ cost_p = (msp430_use_16bit_hwmult ()
? &cycle_cost_multlib_32bit
: &cycle_cost_multlib_16bit);
@@ -1346,8 +1345,9 @@ msp430_muldiv_costs (rtx src, rtx dst, bool speed, rtx outer_rtx,
if (outer_code != MULT)
/* Division is always expensive. */
factor = 7;
- else if (((hwmult_16bit && outer_mode != DImode)
- || use_32bit_hwmult () || msp430_use_f5_series_hwmult ()))
+ else if (((msp430_use_16bit_hwmult () && outer_mode != DImode)
+ || msp430_use_32bit_hwmult ()
+ || msp430_use_f5_series_hwmult ()))
/* When the hardware multiplier is available, only disparage
slightly. */
factor = 2;
@@ -1364,7 +1364,7 @@ msp430_muldiv_costs (rtx src, rtx dst, bool speed, rtx outer_rtx,
The 16-bit hardware multiply library cannot be used to produce 64-bit
results. */
if (outer_code != MULT || !msp430_has_hwmult ()
- || (outer_mode == DImode && hwmult_16bit))
+ || (outer_mode == DImode && msp430_use_16bit_hwmult ()))
{
factor = (outer_code == MULT ? 50 : 70);
return factor * mode_factor * msp430_costs (src, dst, speed, outer_rtx);
@@ -3379,7 +3379,7 @@ msp430_expand_helper (rtx *operands, const char *helper_name,
if (msp430_use_f5_series_hwmult ())
fsym = gen_rtx_SYMBOL_REF (VOIDmode, concat (helper_name,
"_f5hw", NULL));
- else if (use_32bit_hwmult ())
+ else if (msp430_use_32bit_hwmult ())
{
/* When the arguments are 16-bits, the 16-bit hardware multiplier is
used. */
@@ -3390,8 +3390,7 @@ msp430_expand_helper (rtx *operands, const char *helper_name,
fsym = gen_rtx_SYMBOL_REF (VOIDmode, concat (helper_name,
"_hw32", NULL));
}
- /* 16-bit hardware multiply. */
- else if (msp430_has_hwmult ())
+ else if (msp430_use_16bit_hwmult ())
fsym = gen_rtx_SYMBOL_REF (VOIDmode, concat (helper_name,
"_hw", NULL));
else
@@ -3932,7 +3931,7 @@ msp430_use_f5_series_hwmult (void)
32-bit hardware multiplier. */
static bool
-use_32bit_hwmult (void)
+msp430_use_32bit_hwmult (void)
{
static const char * cached_match = NULL;
static bool cached_result;
@@ -3955,6 +3954,34 @@ use_32bit_hwmult (void)
return cached_result = false;
}
+/* Returns true if the current MCU has a first generation
+ 16-bit hardware multiplier. */
+
+static bool
+msp430_use_16bit_hwmult (void)
+{
+ static const char * cached_match = NULL;
+ static bool cached_result;
+
+ if (msp430_hwmult_type == MSP430_HWMULT_SMALL)
+ return true;
+
+ if (target_mcu == NULL || msp430_hwmult_type != MSP430_HWMULT_AUTO)
+ return false;
+
+ if (target_mcu == cached_match)
+ return cached_result;
+
+ cached_match = target_mcu;
+
+ msp430_extract_mcu_data (target_mcu);
+ if (extracted_mcu_data.name != NULL)
+ return cached_result = (extracted_mcu_data.hwmpy == 1
+ || extracted_mcu_data.hwmpy == 2);
+
+ return cached_result = false;
+}
+
/* Returns true if the current MCU does not have a
hardware multiplier of any kind. */
@@ -4019,7 +4046,7 @@ msp430_output_labelref (FILE *file, const char *name)
{
if (msp430_use_f5_series_hwmult ())
name = "__mulsi2_f5";
- else if (use_32bit_hwmult ())
+ else if (msp430_use_32bit_hwmult ())
name = "__mulsi2_hw32";
else
name = "__mulsi2";