aboutsummaryrefslogtreecommitdiff
path: root/gcc/targhooks.c
diff options
context:
space:
mode:
authorJames Greenhalgh <james.greenhalgh@arm.com>2014-11-01 08:13:09 +0000
committerJames Greenhalgh <jgreenhalgh@gcc.gnu.org>2014-11-01 08:13:09 +0000
commit7cbed00872ff3e20e5183f0cb788cd0c86bdf168 (patch)
treec478897b6815f2a9b6b21d0aca73130690f0b5fd /gcc/targhooks.c
parent240decf782968d137494cc9850fad5b310192c38 (diff)
downloadgcc-7cbed00872ff3e20e5183f0cb788cd0c86bdf168.zip
gcc-7cbed00872ff3e20e5183f0cb788cd0c86bdf168.tar.gz
gcc-7cbed00872ff3e20e5183f0cb788cd0c86bdf168.tar.bz2
[Patch 1/7] Hookize *_BY_PIECES_P
gcc/ * target.def (use_by_pieces_infrastructure_p): New. * doc/tm.texi.in (MOVE_BY_PIECES_P): Describe that this macro is deprecated. (STORE_BY_PIECES_P): Likewise. (CLEAR_BY_PIECES_P): Likewise. (SET_BY_PIECES_P): Likewise. (TARGET_MOVE_BY_PIECES_PROFITABLE_P): Add hook. * doc/tm.texi: Regenerate. * expr.c (MOVE_BY_PIECES_P): Rewrite in terms of TARGET_USE_BY_PIECES_INFRASTRUCTURE_P. (STORE_BY_PIECES_P): Likewise. (CLEAR_BY_PIECES_P): Likewise. (SET_BY_PIECES_P): Likewise. (STORE_MAX_PIECES): Move to... * defaults.h (STORE_MAX_PIECES): ...here. * targhooks.c (get_move_ratio): New. (default_use_by_pieces_infrastructure_p): Likewise. * targhooks.h (default_use_by_pieces_infrastructure_p): New. * target.h (by_pieces_operation): New. From-SVN: r216996
Diffstat (limited to 'gcc/targhooks.c')
-rw-r--r--gcc/targhooks.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index e482991..eef3d45 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -1406,6 +1406,61 @@ default_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED,
#endif
}
+/* For hooks which use the MOVE_RATIO macro, this gives the legacy default
+ behaviour. SPEED_P is true if we are compiling for speed. */
+
+static unsigned int
+get_move_ratio (bool speed_p ATTRIBUTE_UNUSED)
+{
+ unsigned int move_ratio;
+#ifdef MOVE_RATIO
+ move_ratio = (unsigned int) MOVE_RATIO (speed_p);
+#else
+#if defined (HAVE_movmemqi) || defined (HAVE_movmemhi) || defined (HAVE_movmemsi) || defined (HAVE_movmemdi) || defined (HAVE_movmemti)
+ move_ratio = 2;
+#else /* No movmem patterns, pick a default. */
+ move_ratio = ((speed_p) ? 15 : 3);
+#endif
+#endif
+ return move_ratio;
+}
+
+/* Return TRUE if the move_by_pieces/set_by_pieces infrastructure should be
+ used; return FALSE if the movmem/setmem optab should be expanded, or
+ a call to memcpy emitted. */
+
+bool
+default_use_by_pieces_infrastructure_p (unsigned int size,
+ unsigned int alignment,
+ enum by_pieces_operation op,
+ bool speed_p)
+{
+ unsigned int max_size = 0;
+ unsigned int ratio = 0;
+
+ switch (op)
+ {
+ case CLEAR_BY_PIECES:
+ max_size = STORE_MAX_PIECES;
+ ratio = CLEAR_RATIO (speed_p);
+ break;
+ case MOVE_BY_PIECES:
+ max_size = MOVE_MAX_PIECES;
+ ratio = get_move_ratio (speed_p);
+ break;
+ case SET_BY_PIECES:
+ max_size = STORE_MAX_PIECES;
+ ratio = SET_RATIO (speed_p);
+ break;
+ case STORE_BY_PIECES:
+ max_size = STORE_MAX_PIECES;
+ ratio = get_move_ratio (speed_p);
+ break;
+ }
+
+ return move_by_pieces_ninsns (size, alignment, max_size + 1) < ratio;
+}
+
bool
default_profile_before_prologue (void)
{