OSDN Git Service

Index: gcc/cp/ChangeLog
[pf3gnuchains/gcc-fork.git] / gcc / regrename.c
index e4b7894..c55f9c4 100644 (file)
@@ -27,6 +27,7 @@
 #include "tm_p.h"
 #include "insn-config.h"
 #include "regs.h"
+#include "addresses.h"
 #include "hard-reg-set.h"
 #include "basic-block.h"
 #include "reload.h"
@@ -528,7 +529,7 @@ scan_rtx_address (rtx insn, rtx *loc, enum reg_class cl,
        rtx op1 = orig_op1;
        rtx *locI = NULL;
        rtx *locB = NULL;
-       rtx *locB_reg = NULL;
+       enum rtx_code index_code = SCRATCH;
 
        if (GET_CODE (op0) == SUBREG)
          {
@@ -547,59 +548,70 @@ scan_rtx_address (rtx insn, rtx *loc, enum reg_class cl,
          {
            locI = &XEXP (x, 0);
            locB = &XEXP (x, 1);
+           index_code = GET_CODE (*locI);
          }
        else if (code1 == MULT || code1 == SIGN_EXTEND || code1 == TRUNCATE
                 || code1 == ZERO_EXTEND || code0 == MEM)
          {
            locI = &XEXP (x, 1);
            locB = &XEXP (x, 0);
+           index_code = GET_CODE (*locI);
          }
        else if (code0 == CONST_INT || code0 == CONST
                 || code0 == SYMBOL_REF || code0 == LABEL_REF)
-         locB = &XEXP (x, 1);
+         {
+           locB = &XEXP (x, 1);
+           index_code = GET_CODE (XEXP (x, 0));
+         }
        else if (code1 == CONST_INT || code1 == CONST
                 || code1 == SYMBOL_REF || code1 == LABEL_REF)
-         locB = &XEXP (x, 0);
+         {
+           locB = &XEXP (x, 0);
+           index_code = GET_CODE (XEXP (x, 1));
+         }
        else if (code0 == REG && code1 == REG)
          {
            int index_op;
+           unsigned regno0 = REGNO (op0), regno1 = REGNO (op1);
 
-           if (REG_OK_FOR_INDEX_P (op0)
-               && REG_MODE_OK_FOR_REG_BASE_P (op1, mode))
+           if (REGNO_OK_FOR_INDEX_P (regno0)
+               && regno_ok_for_base_p (regno1, mode, PLUS, REG))
              index_op = 0;
-           else if (REG_OK_FOR_INDEX_P (op1)
-                    && REG_MODE_OK_FOR_REG_BASE_P (op0, mode))
+           else if (REGNO_OK_FOR_INDEX_P (regno1)
+                    && regno_ok_for_base_p (regno0, mode, PLUS, REG))
              index_op = 1;
-           else if (REG_MODE_OK_FOR_REG_BASE_P (op1, mode))
+           else if (regno_ok_for_base_p (regno1, mode, PLUS, REG))
              index_op = 0;
-           else if (REG_MODE_OK_FOR_REG_BASE_P (op0, mode))
+           else if (regno_ok_for_base_p (regno0, mode, PLUS, REG))
              index_op = 1;
-           else if (REG_OK_FOR_INDEX_P (op1))
+           else if (REGNO_OK_FOR_INDEX_P (regno1))
              index_op = 1;
            else
              index_op = 0;
 
            locI = &XEXP (x, index_op);
-           locB_reg = &XEXP (x, !index_op);
+           locB = &XEXP (x, !index_op);
+           index_code = GET_CODE (*locI);
          }
        else if (code0 == REG)
          {
            locI = &XEXP (x, 0);
            locB = &XEXP (x, 1);
+           index_code = GET_CODE (*locI);
          }
        else if (code1 == REG)
          {
            locI = &XEXP (x, 1);
            locB = &XEXP (x, 0);
+           index_code = GET_CODE (*locI);
          }
 
        if (locI)
          scan_rtx_address (insn, locI, INDEX_REG_CLASS, action, mode);
        if (locB)
-         scan_rtx_address (insn, locB, MODE_BASE_REG_CLASS (mode), action, mode);
-       if (locB_reg)
-         scan_rtx_address (insn, locB_reg, MODE_BASE_REG_REG_CLASS (mode),
+         scan_rtx_address (insn, locB, base_reg_class (mode, PLUS, index_code),
                            action, mode);
+
        return;
       }
 
@@ -618,7 +630,7 @@ scan_rtx_address (rtx insn, rtx *loc, enum reg_class cl,
 
     case MEM:
       scan_rtx_address (insn, &XEXP (x, 0),
-                       MODE_BASE_REG_CLASS (GET_MODE (x)), action,
+                       base_reg_class (GET_MODE (x), MEM, SCRATCH), action,
                        GET_MODE (x));
       return;
 
@@ -669,7 +681,7 @@ scan_rtx (rtx insn, rtx *loc, enum reg_class cl,
 
     case MEM:
       scan_rtx_address (insn, &XEXP (x, 0),
-                       MODE_BASE_REG_CLASS (GET_MODE (x)), action,
+                       base_reg_class (GET_MODE (x), MEM, SCRATCH), action,
                        GET_MODE (x));
       return;
 
@@ -1441,7 +1453,7 @@ replace_oldest_value_addr (rtx *loc, enum reg_class cl,
        rtx op1 = orig_op1;
        rtx *locI = NULL;
        rtx *locB = NULL;
-       rtx *locB_reg = NULL;
+       enum rtx_code index_code = SCRATCH;
 
        if (GET_CODE (op0) == SUBREG)
          {
@@ -1460,50 +1472,62 @@ replace_oldest_value_addr (rtx *loc, enum reg_class cl,
          {
            locI = &XEXP (x, 0);
            locB = &XEXP (x, 1);
+           index_code = GET_CODE (*locI);
          }
        else if (code1 == MULT || code1 == SIGN_EXTEND || code1 == TRUNCATE
                 || code1 == ZERO_EXTEND || code0 == MEM)
          {
            locI = &XEXP (x, 1);
            locB = &XEXP (x, 0);
+           index_code = GET_CODE (*locI);
          }
        else if (code0 == CONST_INT || code0 == CONST
                 || code0 == SYMBOL_REF || code0 == LABEL_REF)
-         locB = &XEXP (x, 1);
+         {
+           locB = &XEXP (x, 1);
+           index_code = GET_CODE (XEXP (x, 0));
+         }
        else if (code1 == CONST_INT || code1 == CONST
                 || code1 == SYMBOL_REF || code1 == LABEL_REF)
-         locB = &XEXP (x, 0);
+         {
+           locB = &XEXP (x, 0);
+           index_code = GET_CODE (XEXP (x, 1));
+         }
        else if (code0 == REG && code1 == REG)
          {
            int index_op;
+           unsigned regno0 = REGNO (op0), regno1 = REGNO (op1);
 
-           if (REG_OK_FOR_INDEX_P (op0)
-               && REG_MODE_OK_FOR_REG_BASE_P (op1, mode))
+           if (REGNO_OK_FOR_INDEX_P (regno0)
+               && regno_ok_for_base_p (regno1, mode, PLUS, REG))
              index_op = 0;
-           else if (REG_OK_FOR_INDEX_P (op1)
-                    && REG_MODE_OK_FOR_REG_BASE_P (op0, mode))
+           else if (REGNO_OK_FOR_INDEX_P (regno1)
+                    && regno_ok_for_base_p (regno0, mode, PLUS, REG))
              index_op = 1;
-           else if (REG_MODE_OK_FOR_REG_BASE_P (op1, mode))
+           else if (regno_ok_for_base_p (regno1, mode, PLUS, REG))
              index_op = 0;
-           else if (REG_MODE_OK_FOR_REG_BASE_P (op0, mode))
+           else if (regno_ok_for_base_p (regno0, mode, PLUS, REG))
              index_op = 1;
-           else if (REG_OK_FOR_INDEX_P (op1))
+           else if (REGNO_OK_FOR_INDEX_P (regno1))
              index_op = 1;
            else
              index_op = 0;
 
            locI = &XEXP (x, index_op);
-           locB_reg = &XEXP (x, !index_op);
+           locB = &XEXP (x, !index_op);
+           index_code = GET_CODE (*locI);
          }
        else if (code0 == REG)
          {
            locI = &XEXP (x, 0);
            locB = &XEXP (x, 1);
+           index_code = GET_CODE (*locI);
          }
        else if (code1 == REG)
          {
            locI = &XEXP (x, 1);
            locB = &XEXP (x, 0);
+           index_code = GET_CODE (*locI);
          }
 
        if (locI)
@@ -1511,11 +1535,8 @@ replace_oldest_value_addr (rtx *loc, enum reg_class cl,
                                                insn, vd);
        if (locB)
          changed |= replace_oldest_value_addr (locB,
-                                               MODE_BASE_REG_CLASS (mode),
-                                               mode, insn, vd);
-       if (locB_reg)
-         changed |= replace_oldest_value_addr (locB_reg,
-                                               MODE_BASE_REG_REG_CLASS (mode),
+                                               base_reg_class (mode, PLUS,
+                                                               index_code),
                                                mode, insn, vd);
        return changed;
       }
@@ -1559,7 +1580,8 @@ static bool
 replace_oldest_value_mem (rtx x, rtx insn, struct value_data *vd)
 {
   return replace_oldest_value_addr (&XEXP (x, 0),
-                                   MODE_BASE_REG_CLASS (GET_MODE (x)),
+                                   base_reg_class (GET_MODE (x), MEM,
+                                                   SCRATCH),
                                    GET_MODE (x), insn, vd);
 }
 
@@ -1797,7 +1819,7 @@ copyprop_hardreg_forward (void)
 
   need_refresh = false;
 
-  all_vd = xmalloc (sizeof (struct value_data) * last_basic_block);
+  all_vd = XNEWVEC (struct value_data, last_basic_block);
 
   visited = sbitmap_alloc (last_basic_block);
   sbitmap_zero (visited);
@@ -1953,13 +1975,14 @@ gate_handle_regrename (void)
 
 
 /* Run the regrename and cprop passes.  */
-static void
+static unsigned int
 rest_of_handle_regrename (void)
 {
   if (flag_rename_registers)
     regrename_optimize ();
   if (flag_cprop_registers)
     copyprop_hardreg_forward ();
+  return 0;
 }
 
 struct tree_opt_pass pass_regrename =