[COMMITTED,MSP430] Move C code for addsi define_split to its own function

Message ID 20191007213511.5c5b817f@jozef-kubuntu
State New
Headers show
Series
  • [COMMITTED,MSP430] Move C code for addsi define_split to its own function
Related show

Commit Message

Jozef Lawrynowicz Oct. 7, 2019, 8:35 p.m.
In preparation for upcoming changes to the addsi splitter, the attached patch
puts C code to perform the splitting in its own function.

Regtested on trunk.
Committed as obvious.

Patch

From 41e73d742fda612b0978cf84ae8732b430c4ef5a Mon Sep 17 00:00:00 2001
From: jozefl <jozefl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 7 Oct 2019 20:05:30 +0000
Subject: [PATCH] 2019-10-07  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* config/msp430/msp430-protos.h (msp430_split_addsi): New prototype.
	* config/msp430/msp430.c (msp430_split_addsi): New.
	* config/msp430/msp430.md: Call msp430_split_addsi () instead of using
	a block of C code for splitting addsi.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276670 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                     |  7 +++++++
 gcc/config/msp430/msp430-protos.h |  1 +
 gcc/config/msp430/msp430.c        | 23 +++++++++++++++++++++++
 gcc/config/msp430/msp430.md       | 20 +++-----------------
 4 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bbdce86a0f8..91ebb5a114c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@ 
+2019-10-07  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
+
+	* config/msp430/msp430-protos.h (msp430_split_addsi): New prototype.
+	* config/msp430/msp430.c (msp430_split_addsi): New.
+	* config/msp430/msp430.md: Call msp430_split_addsi () instead of using
+	a block of C code for splitting addsi.
+
 2019-10-07  UroŇ° Bizjak  <ubizjak@gmail.com>
 
 	* config/i386/i386-expand.c (ix86_expand_floorceildf_32,
diff --git a/gcc/config/msp430/msp430-protos.h b/gcc/config/msp430/msp430-protos.h
index 1c1757fc7ab..37ca48297ac 100644
--- a/gcc/config/msp430/msp430-protos.h
+++ b/gcc/config/msp430/msp430-protos.h
@@ -44,6 +44,7 @@  void	msp430_output_labelref (FILE *, const char *);
 void	msp430_register_pragmas (void);
 rtx	msp430_return_addr_rtx (int);
 void	msp430_split_movsi (rtx *);
+int msp430_split_addsi (rtx *);
 void    msp430_start_function (FILE *, const char *, tree);
 rtx	msp430_subreg (machine_mode, rtx, machine_mode, int);
 bool    msp430_use_f5_series_hwmult (void);
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index 354b4ddb419..add19bdb97c 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -2841,6 +2841,29 @@  msp430_subreg (machine_mode mode, rtx r, machine_mode omode, int byte)
   return rv;
 }
 
+int
+msp430_split_addsi (rtx *operands)
+{
+  operands[3] = msp430_subreg (HImode, operands[0], SImode, 0);
+  operands[4] = msp430_subreg (HImode, operands[1], SImode, 0);
+  operands[5] = msp430_subreg (HImode, operands[2], SImode, 0);
+  operands[6] = msp430_subreg (HImode, operands[0], SImode, 2);
+  operands[7] = msp430_subreg (HImode, operands[1], SImode, 2);
+  operands[8] = msp430_subreg (HImode, operands[2], SImode, 2);
+
+  /* BZ 64160: Do not use this splitter when the dest partially overlaps the
+     source.  */
+  if (reg_overlap_mentioned_p (operands[3], operands[7])
+      || reg_overlap_mentioned_p (operands[3], operands[8]))
+    return 1;
+
+  if (GET_CODE (operands[5]) == CONST_INT)
+    operands[9] = GEN_INT (INTVAL (operands[5]) & 0xffff);
+  else
+    operands[9] = gen_rtx_ZERO_EXTEND (SImode, operands[5]);
+  return 0;
+}
+
 /* Called by movsi_x to generate the HImode operands.  */
 void
 msp430_split_movsi (rtx *operands)
diff --git a/gcc/config/msp430/msp430.md b/gcc/config/msp430/msp430.md
index c72f7aade30..e1c61f5ea3d 100644
--- a/gcc/config/msp430/msp430.md
+++ b/gcc/config/msp430/msp430.md
@@ -423,23 +423,9 @@ 
 		 (zero_extend:HI (reg:BI CARRY))))
    ]
   "
-   operands[3] = msp430_subreg (HImode, operands[0], SImode, 0);
-   operands[4] = msp430_subreg (HImode, operands[1], SImode, 0);
-   operands[5] = msp430_subreg (HImode, operands[2], SImode, 0);
-   operands[6] = msp430_subreg (HImode, operands[0], SImode, 2);
-   operands[7] = msp430_subreg (HImode, operands[1], SImode, 2);
-   operands[8] = msp430_subreg (HImode, operands[2], SImode, 2);
-
-   /* BZ 64160: Do not use this splitter when the dest partially overlaps the source.  */
-   if (reg_overlap_mentioned_p (operands[3], operands[7])
-       || reg_overlap_mentioned_p (operands[3], operands[8]))
-      FAIL;
-
-   if (GET_CODE (operands[5]) == CONST_INT)
-     operands[9] = GEN_INT (INTVAL (operands[5]) & 0xffff);
-   else
-     operands[9] = gen_rtx_ZERO_EXTEND (SImode, operands[5]);
-   "
+  if (msp430_split_addsi (operands))
+    FAIL;
+  "
   )
 
 
-- 
2.17.1