OSDN Git Service

More of previous change.
[pf3gnuchains/gcc-fork.git] / gcc / emit-rtl.c
index 3bd88b6..f73a61c 100644 (file)
@@ -212,7 +212,7 @@ void init_emit ();
 **     special machine mode associated with the rtx (if any) is specified
 **     in <mode>.
 **
-**         gen_rtx() can be invoked in a way which resembles the lisp-like
+**         gen_rtx can be invoked in a way which resembles the lisp-like
 **     rtx it will generate.   For example, the following rtx structure:
 **
 **           (plus:QI (mem:QI (reg:SI 1))
@@ -330,7 +330,7 @@ gen_rtx (va_alist)
              break;
 
            default:
-             abort();
+             abort ();
            }
        }
     }
@@ -496,7 +496,8 @@ gen_lowpart_common (mode, x)
            / UNITS_PER_WORD);
 
   if ((GET_CODE (x) == ZERO_EXTEND || GET_CODE (x) == SIGN_EXTEND)
-      && GET_MODE_CLASS (mode) == MODE_INT)
+      && (GET_MODE_CLASS (mode) == MODE_INT
+         || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT))
     {
       /* If we are getting the low-order part of something that has been
         sign- or zero-extended, we can either just use the object being
@@ -529,7 +530,14 @@ gen_lowpart_common (mode, x)
       else if (REGNO (x) < FIRST_PSEUDO_REGISTER
               /* integrate.c can't handle parts of a return value register. */
               && (! REG_FUNCTION_VALUE_P (x)
-                  || ! rtx_equal_function_value_matters))
+                  || ! rtx_equal_function_value_matters)
+              /* We want to keep the stack, frame, and arg pointers
+                 special.  */
+              && REGNO (x) != FRAME_POINTER_REGNUM
+#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
+              && REGNO (x) != ARG_POINTER_REGNUM
+#endif
+              && REGNO (x) != STACK_POINTER_REGNUM)
        return gen_rtx (REG, mode, REGNO (x) + word);
       else
        return gen_rtx (SUBREG, mode, x, word);
@@ -537,7 +545,9 @@ gen_lowpart_common (mode, x)
 
   /* If X is a CONST_INT or a CONST_DOUBLE, extract the appropriate bits
      from the low-order part of the constant.  */
-  else if (GET_MODE_CLASS (mode) == MODE_INT && GET_MODE (x) == VOIDmode
+  else if ((GET_MODE_CLASS (mode) == MODE_INT
+           || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
+          && GET_MODE (x) == VOIDmode
           && (GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST_DOUBLE))
     {
       /* If MODE is twice the host word size, X is already the desired
@@ -625,7 +635,8 @@ gen_lowpart_common (mode, x)
   else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
             && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
            || flag_pretend_float)
-          && GET_MODE_CLASS (mode) == MODE_INT
+          && (GET_MODE_CLASS (mode) == MODE_INT
+              || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
           && GET_CODE (x) == CONST_DOUBLE
           && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
           && GET_MODE_BITSIZE (mode) == BITS_PER_WORD)
@@ -639,7 +650,8 @@ gen_lowpart_common (mode, x)
   else if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
             && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
            || flag_pretend_float)
-          && GET_MODE_CLASS (mode) == MODE_INT
+          && (GET_MODE_CLASS (mode) == MODE_INT
+              || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
           && GET_CODE (x) == CONST_DOUBLE
           && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
           && GET_MODE_BITSIZE (mode) == 2 * BITS_PER_WORD)
@@ -656,6 +668,34 @@ gen_lowpart_common (mode, x)
   return 0;
 }
 \f
+/* Return the real part (which has mode MODE) of a complex value X.
+   This always comes at the low address in memory.  */
+
+rtx
+gen_realpart (mode, x)
+     enum machine_mode mode;
+     register rtx x;
+{
+  if (WORDS_BIG_ENDIAN)
+    return gen_highpart (mode, x);
+  else
+    return gen_lowpart (mode, x);
+}
+
+/* Return the imaginary part (which has mode MODE) of a complex value X.
+   This always comes at the high address in memory.  */
+
+rtx
+gen_imagpart (mode, x)
+     enum machine_mode mode;
+     register rtx x;
+{
+  if (WORDS_BIG_ENDIAN)
+    return gen_lowpart (mode, x);
+  else
+    return gen_highpart (mode, x);
+}
+\f
 /* Assuming that X is an rtx (e.g., MEM, REG or SUBREG) for a value,
    return an rtx (MEM, SUBREG, or CONST_INT) that refers to the
    least-significant part of X.
@@ -706,7 +746,7 @@ gen_highpart (mode, x)
       && GET_MODE_SIZE (mode) != GET_MODE_UNIT_SIZE (GET_MODE (x)))
     abort ();
   if (GET_CODE (x) == CONST_DOUBLE
-#if !(TARGET_FLOAT_FORMAT != HOST_FLOAT_FORMAT || defined(REAL_IS_NOT_DOUBLE))
+#if !(TARGET_FLOAT_FORMAT != HOST_FLOAT_FORMAT || defined (REAL_IS_NOT_DOUBLE))
       && GET_MODE_CLASS (GET_MODE (x)) != MODE_FLOAT
 #endif
       )
@@ -748,7 +788,13 @@ gen_highpart (mode, x)
                 - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD))
                / UNITS_PER_WORD);
 #endif
-      if (REGNO (x) < FIRST_PSEUDO_REGISTER)
+      if (REGNO (x) < FIRST_PSEUDO_REGISTER
+         /* We want to keep the stack, frame, and arg pointers special.  */
+         && REGNO (x) != FRAME_POINTER_REGNUM
+#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
+         && REGNO (x) != ARG_POINTER_REGNUM
+#endif
+         && REGNO (x) != STACK_POINTER_REGNUM)
        return gen_rtx (REG, mode, REGNO (x) + word);
       else
        return gen_rtx (SUBREG, mode, x, word);
@@ -832,7 +878,14 @@ operand_subword (op, i, validate_address, mode)
        return 0;
       else if (REGNO (op) >= FIRST_PSEUDO_REGISTER
               || (REG_FUNCTION_VALUE_P (op)
-                  && rtx_equal_function_value_matters))
+                  && rtx_equal_function_value_matters)
+              /* We want to keep the stack, frame, and arg pointers
+                 special.  */
+              || REGNO (op) == FRAME_POINTER_REGNUM
+#if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
+              || REGNO (op) == ARG_POINTER_REGNUM
+#endif
+              || REGNO (op) == STACK_POINTER_REGNUM)
        return gen_rtx (SUBREG, word_mode, op, i);
       else
        return gen_rtx (REG, word_mode, REGNO (op) + i);
@@ -869,6 +922,20 @@ operand_subword (op, i, validate_address, mode)
   /* The only remaining cases are when OP is a constant.  If the host and
      target floating formats are the same, handling two-word floating
      constants are easy.  */
+#ifdef REAL_ARITHMETIC
+  if ((HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
+      && GET_MODE_CLASS (mode) == MODE_FLOAT
+      && GET_MODE_SIZE (mode) == 2 * UNITS_PER_WORD
+      && GET_CODE (op) == CONST_DOUBLE)
+    {
+      HOST_WIDE_INT k[2];
+      REAL_VALUE_TYPE rv;
+
+      REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
+      REAL_VALUE_TO_TARGET_DOUBLE (rv, k);
+      return GEN_INT (k[i]);
+    }
+#else /* no REAL_ARITHMETIC */
   if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
        && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
        || flag_pretend_float)
@@ -888,10 +955,25 @@ operand_subword (op, i, validate_address, mode)
                      ? CONST_DOUBLE_HIGH (op) : CONST_DOUBLE_LOW (op));
 #endif
     }
+#endif /* no REAL_ARITHMETIC */
 
   /* Single word float is a little harder, since single- and double-word
      values often do not have the same high-order bits.  We have already
      verified that we want the only defined word of the single-word value.  */
+#ifdef REAL_ARITHMETIC
+  if ((HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
+      && GET_MODE_CLASS (mode) == MODE_FLOAT
+      && GET_MODE_SIZE (mode) == UNITS_PER_WORD
+      && GET_CODE (op) == CONST_DOUBLE)
+    {
+      HOST_WIDE_INT l;
+      REAL_VALUE_TYPE rv;
+
+      REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
+      REAL_VALUE_TO_TARGET_SINGLE (rv, l);
+      return GEN_INT (l);
+    }
+#else
   if (((HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT
        && HOST_BITS_PER_WIDE_INT == BITS_PER_WORD)
        || flag_pretend_float)
@@ -907,6 +989,7 @@ operand_subword (op, i, validate_address, mode)
       u.f = d;
       return GEN_INT (u.i);
     }
+#endif /* no REAL_ARITHMETIC */
       
   /* The only remaining cases that we can handle are integers.
      Convert to proper endianness now since these cases need it.
@@ -1214,6 +1297,15 @@ copy_rtx_if_shared (orig)
       /* SCRATCH must be shared because they represent distinct values. */
       return x;
 
+    case CONST:
+      /* CONST can be shared if it contains a SYMBOL_REF.  If it contains
+        a LABEL_REF, it isn't sharable.  */
+      if (GET_CODE (XEXP (x, 0)) == PLUS
+         && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF
+         && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)
+       return x;
+      break;
+
     case INSN:
     case JUMP_INSN:
     case CALL_INSN:
@@ -1778,13 +1870,13 @@ make_insn_raw (pattern)
 {
   register rtx insn;
 
-  insn = rtx_alloc(INSN);
-  INSN_UID(insn) = cur_insn_uid++;
+  insn = rtx_alloc (INSN);
+  INSN_UID (insn) = cur_insn_uid++;
 
   PATTERN (insn) = pattern;
   INSN_CODE (insn) = -1;
-  LOG_LINKS(insn) = NULL;
-  REG_NOTES(insn) = NULL;
+  LOG_LINKS (insn) = NULL;
+  REG_NOTES (insn) = NULL;
 
   return insn;
 }
@@ -1798,13 +1890,13 @@ make_jump_insn_raw (pattern)
   register rtx insn;
 
   insn = rtx_alloc (JUMP_INSN);
-  INSN_UID(insn) = cur_insn_uid++;
+  INSN_UID (insn) = cur_insn_uid++;
 
   PATTERN (insn) = pattern;
   INSN_CODE (insn) = -1;
-  LOG_LINKS(insn) = NULL;
-  REG_NOTES(insn) = NULL;
-  JUMP_LABEL(insn) = NULL;
+  LOG_LINKS (insn) = NULL;
+  REG_NOTES (insn) = NULL;
+  JUMP_LABEL (insn) = NULL;
 
   return insn;
 }
@@ -2002,7 +2094,7 @@ emit_jump_insn_before (pattern, before)
     insn = emit_insn_before (pattern, before);
   else
     {
-      insn = make_jump_insn_raw (pattern, NULL_RTVEC);
+      insn = make_jump_insn_raw (pattern);
       add_insn_after (insn, PREV_INSN (before));
     }
 
@@ -2118,7 +2210,7 @@ emit_jump_insn_after (pattern, after)
     insn = emit_insn_after (pattern, after);
   else
     {
-      insn = make_jump_insn_raw (pattern, NULL_RTVEC);
+      insn = make_jump_insn_raw (pattern);
       add_insn_after (insn, after);
     }
 
@@ -2316,7 +2408,7 @@ emit_jump_insn (pattern)
     return emit_insn (pattern);
   else
     {
-      register rtx insn = make_jump_insn_raw (pattern, NULL_RTVEC);
+      register rtx insn = make_jump_insn_raw (pattern);
       add_insn (insn);
       return insn;
     }
@@ -2552,6 +2644,40 @@ push_to_sequence (first)
   last_insn = last;
 }
 
+/* Set up the outer-level insn chain
+   as the current sequence, saving the previously current one.  */
+
+void
+push_topmost_sequence ()
+{
+  struct sequence_stack *stack, *top;
+
+  start_sequence ();
+
+  for (stack = sequence_stack; stack; stack = stack->next)
+    top = stack;
+
+  first_insn = top->first;
+  last_insn = top->last;
+}
+
+/* After emitting to the outer-level insn chain, update the outer-level
+   insn chain, and restore the previous saved state.  */
+
+void
+pop_topmost_sequence ()
+{
+  struct sequence_stack *stack, *top;
+
+  for (stack = sequence_stack; stack; stack = stack->next)
+    top = stack;
+
+  top->first = first_insn;
+  top->last = last_insn;
+
+  end_sequence ();
+}
+
 /* After emitting to a sequence, restore previous saved state.
 
    To get the contents of the sequence just made,
@@ -2615,10 +2741,10 @@ gen_sequence ()
     {
       /* Ensure that this rtl goes in saveable_obstack, since we may be
         caching it.  */
-      int in_current_obstack = rtl_in_saveable_obstack ();
+      push_obstacks_nochange ();
+      rtl_in_saveable_obstack ();
       result = gen_rtx (SEQUENCE, VOIDmode, rtvec_alloc (len));
-      if (in_current_obstack)
-       rtl_in_current_obstack ();
+      pop_obstacks ();
     }
 
   for (i = 0, tem = first_insn; tem; tem = NEXT_INSN (tem), i++)
@@ -2781,6 +2907,7 @@ init_emit ()
   last_filename = 0;
   first_label_num = label_num;
   last_label_num = 0;
+  sequence_stack = NULL;
 
   /* Clear the start_sequence/gen_sequence cache.  */
   sequence_element_free_list = 0;
@@ -2815,6 +2942,10 @@ init_emit ()
   REGNO_POINTER_FLAG (VIRTUAL_STACK_VARS_REGNUM) = 1;
   REGNO_POINTER_FLAG (VIRTUAL_STACK_DYNAMIC_REGNUM) = 1;
   REGNO_POINTER_FLAG (VIRTUAL_OUTGOING_ARGS_REGNUM) = 1;
+
+#ifdef INIT_EXPANDERS
+  INIT_EXPANDERS;
+#endif
 }
 
 /* Create some permanent unique rtl objects shared between all functions.
@@ -2854,10 +2985,10 @@ init_emit_once (line_numbers)
   /* This will usually be one of the above constants, but may be a new rtx.  */
   const_true_rtx = GEN_INT (STORE_FLAG_VALUE);
 
-  dconst0 = REAL_VALUE_ATOF ("0");
-  dconst1 = REAL_VALUE_ATOF ("1");
-  dconst2 = REAL_VALUE_ATOF ("2");
-  dconstm1 = REAL_VALUE_ATOF ("-1");
+  dconst0 = REAL_VALUE_ATOF ("0", DFmode);
+  dconst1 = REAL_VALUE_ATOF ("1", DFmode);
+  dconst2 = REAL_VALUE_ATOF ("2", DFmode);
+  dconstm1 = REAL_VALUE_ATOF ("-1", DFmode);
 
   for (i = 0; i <= 2; i++)
     {
@@ -2882,6 +3013,11 @@ init_emit_once (line_numbers)
       for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode;
           mode = GET_MODE_WIDER_MODE (mode))
        const_tiny_rtx[i][(int) mode] = GEN_INT (i);
+
+      for (mode = GET_CLASS_NARROWEST_MODE (MODE_PARTIAL_INT);
+          mode != VOIDmode;
+          mode = GET_MODE_WIDER_MODE (mode))
+       const_tiny_rtx[i][(int) mode] = GEN_INT (i);
     }
 
   for (mode = GET_CLASS_NARROWEST_MODE (MODE_CC); mode != VOIDmode;