diff gcc/rtlhooks.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 77e2b8dfacca
children 84e7813d76e9
line wrap: on
line diff
--- a/gcc/rtlhooks.c	Sun Aug 21 07:07:55 2011 +0900
+++ b/gcc/rtlhooks.c	Fri Oct 27 22:46:09 2017 +0900
@@ -1,5 +1,5 @@
 /* Generic hooks for the RTL middle-end.
-   Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004-2017 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -21,10 +21,16 @@
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
+#include "function.h"
 #include "rtl.h"
+#include "tree.h"
+#include "insn-config.h"
+#include "memmodel.h"
+#include "emit-rtl.h"
+#include "recog.h"
 #include "rtlhooks-def.h"
-#include "expr.h"
-#include "recog.h"
+#include "explow.h"
+#include "target.h"
 
 
 /* For speed, we will copy the RTX hooks struct member-by-member
@@ -37,7 +43,7 @@
 struct rtl_hooks rtl_hooks = RTL_HOOKS_INITIALIZER;
 
 rtx
-gen_lowpart_general (enum machine_mode mode, rtx x)
+gen_lowpart_general (machine_mode mode, rtx x)
 {
   rtx result = gen_lowpart_common (mode, x);
 
@@ -53,69 +59,38 @@
     }
   else
     {
-      int offset = 0;
-
       /* The only additional case we can do is MEM.  */
       gcc_assert (MEM_P (x));
 
       /* The following exposes the use of "x" to CSE.  */
-      if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD
-	  && SCALAR_INT_MODE_P (GET_MODE (x))
-	  && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
-				    GET_MODE_BITSIZE (GET_MODE (x)))
+      scalar_int_mode xmode;
+      if (is_a <scalar_int_mode> (GET_MODE (x), &xmode)
+	  && GET_MODE_SIZE (xmode) <= UNITS_PER_WORD
+	  && TRULY_NOOP_TRUNCATION_MODES_P (mode, xmode)
 	  && !reload_completed)
-	return gen_lowpart_general (mode, force_reg (GET_MODE (x), x));
+	return gen_lowpart_general (mode, force_reg (xmode, x));
 
-      if (WORDS_BIG_ENDIAN)
-	offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
-		  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
-
-      if (BYTES_BIG_ENDIAN)
-	/* Adjust the address so that the address-after-the-data
-	   is unchanged.  */
-	offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
-		   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
-
+      HOST_WIDE_INT offset = byte_lowpart_offset (mode, GET_MODE (x));
       return adjust_address (x, mode, offset);
     }
 }
 
-/* Similar to gen_lowpart, but cannot emit any instruction via
-   copy_to_reg or force_reg.  Mainly used in simplify-rtx.c.  */
 rtx
-gen_lowpart_no_emit_general (enum machine_mode mode, rtx x)
-{
-  rtx result = gen_lowpart_if_possible (mode, x);
-  if (result)
-    return result;
-  else
-    return x;
-}
-
-rtx
-reg_num_sign_bit_copies_general (const_rtx x ATTRIBUTE_UNUSED,
-				 enum machine_mode mode ATTRIBUTE_UNUSED,
-                                 const_rtx known_x ATTRIBUTE_UNUSED,
-				 enum machine_mode known_mode ATTRIBUTE_UNUSED,
-                                 unsigned int known_ret ATTRIBUTE_UNUSED,
-                                 unsigned int *result ATTRIBUTE_UNUSED)
+reg_num_sign_bit_copies_general (const_rtx, scalar_int_mode, scalar_int_mode,
+				 unsigned int *)
 {
   return NULL;
 }
 
 rtx
-reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED,
-			  enum machine_mode mode ATTRIBUTE_UNUSED,
-			  const_rtx known_x ATTRIBUTE_UNUSED,
-                          enum machine_mode known_mode ATTRIBUTE_UNUSED,
-                          unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED,
-                          unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED)
+reg_nonzero_bits_general (const_rtx, scalar_int_mode, scalar_int_mode,
+			  unsigned HOST_WIDE_INT *)
 {
   return NULL;
 }
 
 bool
-reg_truncated_to_mode_general (enum machine_mode mode ATTRIBUTE_UNUSED,
+reg_truncated_to_mode_general (machine_mode mode ATTRIBUTE_UNUSED,
 			       const_rtx x ATTRIBUTE_UNUSED)
 {
   return false;
@@ -131,7 +106,7 @@
    This is similar to gen_lowpart_general.  */
 
 rtx
-gen_lowpart_if_possible (enum machine_mode mode, rtx x)
+gen_lowpart_if_possible (machine_mode mode, rtx x)
 {
   rtx result = gen_lowpart_common (mode, x);
 
@@ -140,19 +115,8 @@
   else if (MEM_P (x))
     {
       /* This is the only other case we handle.  */
-      int offset = 0;
-      rtx new_rtx;
-
-      if (WORDS_BIG_ENDIAN)
-	offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
-		  - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
-      if (BYTES_BIG_ENDIAN)
-	/* Adjust the address so that the address-after-the-data is
-	   unchanged.  */
-	offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
-		   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
-
-      new_rtx = adjust_address_nv (x, mode, offset);
+      HOST_WIDE_INT offset = byte_lowpart_offset (mode, GET_MODE (x));
+      rtx new_rtx = adjust_address_nv (x, mode, offset);
       if (! memory_address_addr_space_p (mode, XEXP (new_rtx, 0),
 					 MEM_ADDR_SPACE (x)))
 	return 0;