Wunused-parameter warnings are given from cgraph::finalize_function,
[gcc.git] / gcc / rtlhooks.c
index 8939b21bdb53a671b2944749f79501fc112526de..8202f291b812cd152c785d93498f635f08384755 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic hooks for the RTL middle-end.
-   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -23,6 +23,20 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "rtl.h"
 #include "rtlhooks-def.h"
+#include "symtab.h"
+#include "hard-reg-set.h"
+#include "function.h"
+#include "flags.h"
+#include "alias.h"
+#include "tree.h"
+#include "insn-config.h"
+#include "expmed.h"
+#include "dojump.h"
+#include "explow.h"
+#include "calls.h"
+#include "emit-rtl.h"
+#include "varasm.h"
+#include "stmt.h"
 #include "expr.h"
 #include "recog.h"
 \f
@@ -37,17 +51,15 @@ const struct rtl_hooks general_rtl_hooks = RTL_HOOKS_INITIALIZER;
 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);
 
   if (result)
     return result;
-  /* If it's a REG, it must be a hard reg that's not valid in MODE.  */
-  else if (REG_P (x)
-          /* Or we could have a subreg of a floating point value.  */
-          || (GET_CODE (x) == SUBREG
-              && FLOAT_MODE_P (GET_MODE (SUBREG_REG (x)))))
+  /* Handle SUBREGs and hard REGs that were rejected by
+     simplify_gen_subreg.  */
+  else if (REG_P (x) || GET_CODE (x) == SUBREG)
     {
       result = gen_lowpart_common (mode, copy_to_reg (x));
       gcc_assert (result != 0);
@@ -63,8 +75,7 @@ gen_lowpart_general (enum machine_mode mode, rtx 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)))
+         && TRULY_NOOP_TRUNCATION_MODES_P (mode, GET_MODE (x))
          && !reload_completed)
        return gen_lowpart_general (mode, force_reg (GET_MODE (x), x));
 
@@ -82,23 +93,11 @@ gen_lowpart_general (enum machine_mode mode, rtx x)
     }
 }
 
-/* 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,
+                                machine_mode mode ATTRIBUTE_UNUSED,
                                  const_rtx known_x ATTRIBUTE_UNUSED,
-                                enum machine_mode known_mode ATTRIBUTE_UNUSED,
+                                machine_mode known_mode ATTRIBUTE_UNUSED,
                                  unsigned int known_ret ATTRIBUTE_UNUSED,
                                  unsigned int *result ATTRIBUTE_UNUSED)
 {
@@ -107,9 +106,9 @@ reg_num_sign_bit_copies_general (const_rtx x ATTRIBUTE_UNUSED,
 
 rtx
 reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED,
-                         enum machine_mode mode ATTRIBUTE_UNUSED,
+                         machine_mode mode ATTRIBUTE_UNUSED,
                          const_rtx known_x ATTRIBUTE_UNUSED,
-                          enum machine_mode known_mode ATTRIBUTE_UNUSED,
+                          machine_mode known_mode ATTRIBUTE_UNUSED,
                           unsigned HOST_WIDE_INT known_ret ATTRIBUTE_UNUSED,
                           unsigned HOST_WIDE_INT *nonzero ATTRIBUTE_UNUSED)
 {
@@ -117,7 +116,7 @@ reg_nonzero_bits_general (const_rtx x ATTRIBUTE_UNUSED,
 }
 
 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;
@@ -133,7 +132,7 @@ reg_truncated_to_mode_general (enum machine_mode mode ATTRIBUTE_UNUSED,
    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);
 
@@ -143,7 +142,7 @@ gen_lowpart_if_possible (enum machine_mode mode, rtx x)
     {
       /* This is the only other case we handle.  */
       int offset = 0;
-      rtx new;
+      rtx new_rtx;
 
       if (WORDS_BIG_ENDIAN)
        offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
@@ -154,11 +153,12 @@ gen_lowpart_if_possible (enum machine_mode mode, rtx x)
        offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
                   - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
 
-      new = adjust_address_nv (x, mode, offset);
-      if (! memory_address_p (mode, XEXP (new, 0)))
+      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;
 
-      return new;
+      return new_rtx;
     }
   else if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode
           && validate_subreg (mode, GET_MODE (x), x,