OSDN Git Service

(__va_copy): New definition.
[pf3gnuchains/gcc-fork.git] / gcc / stmt.c
index 5ebadb5..a3f42d5 100644 (file)
@@ -1244,8 +1244,9 @@ fixup_gotos (thisblock, stack_level, cleanup_list, first_insn, dont_jump_in)
              cleanup_insns = get_insns ();
              poplevel (1, 0, 0);
              end_sequence ();
-             f->before_jump
-               = emit_insns_after (cleanup_insns, f->before_jump);
+             if (cleanup_insns != 0)
+               f->before_jump
+                 = emit_insns_after (cleanup_insns, f->before_jump);
 
              f->cleanup_list_list = TREE_CHAIN (lists);
            }
@@ -1369,11 +1370,15 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
   rtx body;
   int ninputs = list_length (inputs);
   int noutputs = list_length (outputs);
+  int ninout = 0;
   int nclobbers;
   tree tail;
   register int i;
   /* Vector of RTX's of evaluated output operands.  */
   rtx *output_rtx = (rtx *) alloca (noutputs * sizeof (rtx));
+  int *inout_opnum = (int *) alloca (noutputs * sizeof (int));
+  enum machine_mode *inout_mode
+    = (enum machine_mode *) alloca (noutputs * sizeof (enum machine_mode));
   /* The insn we have emitted.  */
   rtx insn;
 
@@ -1405,6 +1410,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
       tree val1;
       int j;
       int found_equal = 0;
+      int found_plus = 0;
       int allows_reg = 0;
 
       /* If there's an erroneous arg, emit no insn.  */
@@ -1416,12 +1422,21 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
         the worst that happens if we get it wrong is we issue an error
         message.  */
 
-      for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)); j++)
+      for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)) - 1; j++)
        switch (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j])
          {
          case '+':
-           error ("output operand constraint contains `+'");
-           return;
+           /* Make sure we can specify the matching operand.  */
+           if (i > 9)
+             {
+               error ("output operand constraint %d contains `+'", i);
+               return;
+             }
+
+           /* Replace '+' with '='.  */
+           TREE_STRING_POINTER (TREE_PURPOSE (tail))[j] = '=';
+           found_plus = 1;
+           break;
 
          case '=':
            found_equal = 1;
@@ -1438,19 +1453,18 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
 #endif
            break;
 
-         case 'p':  case 'g':  case 'r':
-           /* Whether or not a numeric constraint allows a register is
-              decided by the matching constraint, and so there is no need
-              to do anything special with them.  We must handle them in
-              the default case, so that we don't unnecessarily force
-              operands to memory.  */
          case '0':  case '1':  case '2':  case '3':  case '4':
+         case '5':  case '6':  case '7':  case '8':  case '9':
+           error ("matching constraint not valid in output operand");
+           break;
+
+         case 'p':  case 'g':  case 'r':
          default:
            allows_reg = 1;
            break;
          }
 
-      if (! found_equal)
+      if (! found_equal && ! found_plus)
        {
          error ("output operand constraint lacks `='");
          return;
@@ -1465,7 +1479,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
          || (TREE_CODE_CLASS (TREE_CODE (val)) == 'd'
              && ! (GET_CODE (DECL_RTL (val)) == REG
                    && GET_MODE (DECL_RTL (val)) != TYPE_MODE (type)))
-         || ! allows_reg)
+         || ! allows_reg
+         || found_plus)
        {
          if (! allows_reg)
            mark_addressable (TREE_VALUE (tail));
@@ -1481,8 +1496,15 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
          output_rtx[i] = assign_temp (type, 0, 0, 0);
          TREE_VALUE (tail) = make_tree (type, output_rtx[i]);
        }
+
+      if (found_plus)
+       {
+         inout_mode[ninout] = TYPE_MODE (TREE_TYPE (TREE_VALUE (tail)));
+         inout_opnum[ninout++] = i;
+       }
     }
 
+  ninputs += ninout;
   if (ninputs + noutputs > MAX_RECOG_OPERANDS)
     {
       error ("more than %d operands in `asm'", MAX_RECOG_OPERANDS);
@@ -1522,7 +1544,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
 
       /* Make sure constraint has neither `=' nor `+'.  */
 
-      for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)); j++)
+      for (j = 0; j < TREE_STRING_LENGTH (TREE_PURPOSE (tail)) - 1; j++)
        switch (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j])
          {
          case '+':   case '=':
@@ -1541,13 +1563,20 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
 #endif
            break;
 
-         case 'p':  case 'g':  case 'r':
            /* Whether or not a numeric constraint allows a register is
               decided by the matching constraint, and so there is no need
               to do anything special with them.  We must handle them in
               the default case, so that we don't unnecessarily force
               operands to memory.  */
          case '0':  case '1':  case '2':  case '3':  case '4':
+         case '5':  case '6':  case '7':  case '8':  case '9':
+           if (TREE_STRING_POINTER (TREE_PURPOSE (tail))[j]
+               >= '0' + noutputs)
+             error ("matching constraint references invalid operand number");
+
+           /* ... fall through ... */
+
+         case 'p':  case 'g':  case 'r':
          default:
            allows_reg = 1;
            break;
@@ -1593,12 +1622,25 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
   /* Protect all the operands from the queue,
      now that they have all been evaluated.  */
 
-  for (i = 0; i < ninputs; i++)
+  for (i = 0; i < ninputs - ninout; i++)
     XVECEXP (body, 3, i) = protect_from_queue (XVECEXP (body, 3, i), 0);
 
   for (i = 0; i < noutputs; i++)
     output_rtx[i] = protect_from_queue (output_rtx[i], 1);
 
+  /* For in-out operands, copy output rtx to input rtx. */
+  for (i = 0; i < ninout; i++)
+    {
+      static char match[9+1][2]
+       = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
+      int j = inout_opnum[i];
+
+      XVECEXP (body, 3, ninputs - ninout + i)      /* argvec */
+       = output_rtx[j];
+      XVECEXP (body, 4, ninputs - ninout + i)      /* constraints */
+       = gen_rtx (ASM_INPUT, inout_mode[j], match[j]);
+    }
+
   /* Now, for each output, construct an rtx
      (set OUTPUT (asm_operands INSN OUTPUTNUMBER OUTPUTCONSTRAINT
                               ARGVEC CONSTRAINTS))
@@ -2681,14 +2723,14 @@ expand_return (retval)
       tree expr;
 
       do_jump (TREE_OPERAND (retval_rhs, 0), label, NULL_RTX);
-      expr = build (MODIFY_EXPR, TREE_TYPE (current_function_decl),
+      expr = build (MODIFY_EXPR, TREE_TYPE (TREE_TYPE (current_function_decl)),
                    DECL_RESULT (current_function_decl),
                    TREE_OPERAND (retval_rhs, 1));
       TREE_SIDE_EFFECTS (expr) = 1;
       expand_return (expr);
       emit_label (label);
 
-      expr = build (MODIFY_EXPR, TREE_TYPE (current_function_decl),
+      expr = build (MODIFY_EXPR, TREE_TYPE (TREE_TYPE (current_function_decl)),
                    DECL_RESULT (current_function_decl),
                    TREE_OPERAND (retval_rhs, 2));
       TREE_SIDE_EFFECTS (expr) = 1;
@@ -2877,6 +2919,7 @@ expand_return (retval)
       result_reg = gen_reg_rtx (result_reg_mode);
 
       /* Now that the value is in pseudos, copy it to the result reg(s).  */
+      expand_cleanups_to (NULL_TREE);
       emit_queue ();
       free_temp_slots ();
       for (i = 0; i < n_regs; i++)
@@ -2894,7 +2937,10 @@ expand_return (retval)
       && GET_CODE (DECL_RTL (DECL_RESULT (current_function_decl))) == REG)
     {
       /* Calculate the return value into a pseudo reg.  */
-      val = expand_expr (retval_rhs, NULL_RTX, VOIDmode, 0);
+      val = gen_reg_rtx (DECL_MODE (DECL_RESULT (current_function_decl)));
+      val = expand_expr (retval_rhs, val, GET_MODE (val), 0);
+      val = force_not_mem (val);
+      expand_cleanups_to (NULL_TREE);
       emit_queue ();
       /* All temporaries have now been used.  */
       free_temp_slots ();
@@ -2906,6 +2952,7 @@ expand_return (retval)
       /* No cleanups or no hard reg used;
         calculate value into hard return reg.  */
       expand_expr (retval, const0_rtx, VOIDmode, 0);
+      expand_cleanups_to (NULL_TREE);
       emit_queue ();
       free_temp_slots ();
       expand_value_return (DECL_RTL (DECL_RESULT (current_function_decl)));
@@ -3412,30 +3459,15 @@ expand_decl (decl)
       enum machine_mode reg_mode
        = promote_mode (type, DECL_MODE (decl), &unsignedp, 0);
 
-      if (TREE_CODE (type) == COMPLEX_TYPE)
-       {
-         rtx realpart, imagpart;
-         enum machine_mode partmode = TYPE_MODE (TREE_TYPE (type));
-
-         /* For a complex type variable, make a CONCAT of two pseudos
-            so that the real and imaginary parts
-            can be allocated separately.  */
-         realpart = gen_reg_rtx (partmode);
-         REG_USERVAR_P (realpart) = 1;
-         imagpart = gen_reg_rtx (partmode);
-         REG_USERVAR_P (imagpart) = 1;
-         DECL_RTL (decl) = gen_rtx (CONCAT, reg_mode, realpart, imagpart);
-       }
-      else
-       {
-         DECL_RTL (decl) = gen_reg_rtx (reg_mode);
-         if (TREE_CODE (type) == POINTER_TYPE)
-           mark_reg_pointer (DECL_RTL (decl),
-                             (TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl)))
-                              / BITS_PER_UNIT));
-         REG_USERVAR_P (DECL_RTL (decl)) = 1;
-       }
+      DECL_RTL (decl) = gen_reg_rtx (reg_mode);
+      mark_user_reg (DECL_RTL (decl));
+
+      if (TREE_CODE (type) == POINTER_TYPE)
+       mark_reg_pointer (DECL_RTL (decl),
+                         (TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl)))
+                          / BITS_PER_UNIT));
     }
+
   else if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
     {
       /* Variable of fixed size that goes on the stack.  */
@@ -5558,12 +5590,18 @@ group_case_nodes (head)
   while (node)
     {
       rtx lb = next_real_insn (label_rtx (node->code_label));
+      rtx lb2;
       case_node_ptr np = node;
 
       /* Try to group the successors of NODE with NODE.  */
       while (((np = np->right) != 0)
             /* Do they jump to the same place?  */
-            && next_real_insn (label_rtx (np->code_label)) == lb
+            && ((lb2 = next_real_insn (label_rtx (np->code_label))) == lb
+                || (lb != 0 && lb2 != 0
+                    && simplejump_p (lb)
+                    && simplejump_p (lb2)
+                    && rtx_equal_p (SET_SRC (PATTERN (lb)),
+                                    SET_SRC (PATTERN (lb2)))))
             /* Are their ranges consecutive?  */
             && tree_int_cst_equal (np->low,
                                    fold (build (PLUS_EXPR,