OSDN Git Service

2005-04-02 Daniel Berlin <dberlin@dberlin.org>
[pf3gnuchains/gcc-fork.git] / gcc / rtlhooks.c
index 5cb14ef..dbe9593 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic hooks for the RTL middle-end.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -47,15 +47,16 @@ gen_lowpart_general (enum machine_mode mode, rtx x)
     {
       /* Must be a hard reg that's not valid in MODE.  */
       result = gen_lowpart_common (mode, copy_to_reg (x));
-      if (result == 0)
-       abort ();
+      gcc_assert (result != 0);
       return result;
     }
-  else if (MEM_P (x))
+  else
     {
-      /* The only additional case we can do is MEM.  */
       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))
@@ -76,8 +77,19 @@ gen_lowpart_general (enum machine_mode mode, rtx x)
 
       return adjust_address (x, mode, offset);
     }
-  else
-    abort ();
+}
+
+/* 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_common (mode, x);
+  if (result)
+    return result;
+  if (mode != GET_MODE (x) && GET_MODE (x) != VOIDmode)
+    return gen_lowpart_SUBREG (mode, x);
+  return x;
 }
 
 rtx