mn10300-protos.h (mn10300_address_cost): Declare.
authorAlexandre Oliva <aoliva@cygnus.com>
Fri, 21 Apr 2000 21:19:55 +0000 (21:19 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Fri, 21 Apr 2000 21:19:55 +0000 (21:19 +0000)
* config/mn10300/mn10300-protos.h (mn10300_address_cost): Declare.
* config/mn10300/mn10300.h (ADDRESS_COST): New macro.
* config/mn10300/mn10300.c (mn10300_address_cost): New function.

From-SVN: r33323

gcc/ChangeLog
gcc/config/mn10300/mn10300-protos.h
gcc/config/mn10300/mn10300.c
gcc/config/mn10300/mn10300.h

index 4697137..1bff945 100644 (file)
@@ -1,3 +1,9 @@
+Fri Apr 21 18:17:12 2000  Alexandre Oliva  <aoliva@cygnus.com>
+
+       * config/mn10300/mn10300-protos.h (mn10300_address_cost): Declare.
+       * config/mn10300/mn10300.h (ADDRESS_COST): New macro.
+       * config/mn10300/mn10300.c (mn10300_address_cost): New function.
+
 Fri Apr 21 18:11:56 2000  Alexandre Oliva  <aoliva@cygnus.com>
 
        * config/mn10300/mn10300.md (movdi, movdf): Do not use `movu' when
index 2ae3ba5..66dcbe2 100644 (file)
@@ -36,6 +36,8 @@ extern int symbolic_operand PARAMS ((rtx, enum machine_mode));
 extern int call_address_operand PARAMS ((rtx, enum machine_mode));
 extern int impossible_plus_operand PARAMS ((rtx, enum machine_mode));
 extern int const_8bit_operand PARAMS ((rtx, enum machine_mode));
+
+extern int mn10300_address_cost PARAMS ((rtx, int *));
 #endif /* RTX_CODE */
 
 #ifdef TREE_CODE
index 74eb84a..3c5d359 100644 (file)
@@ -1049,3 +1049,84 @@ legitimize_address (x, oldx, mode)
     }
   return x;
 }
+
+int
+mn10300_address_cost (x, unsig)
+     rtx x;
+     int *unsig;
+{
+  int _s = 0;
+  if (unsig == 0)
+    unsig = &_s;
+  
+  switch (GET_CODE (x))
+    {
+    case REG:
+      switch (REGNO_REG_CLASS (REGNO (x)))
+       {
+       case SP_REGS:
+         *unsig = 1;
+         return 0;
+
+       case ADDRESS_REGS:
+         return 1;
+
+       case DATA_REGS:
+       case EXTENDED_REGS:
+         return 3;
+
+       case NO_REGS:
+         return 5;
+
+       default:
+         abort ();
+       }
+
+    case PLUS:
+    case MINUS:
+    case IOR:
+      return (mn10300_address_cost (XEXP (x, 0), unsig)
+             + mn10300_address_cost (XEXP (x, 1), unsig));
+
+    case EXPR_LIST:
+    case SUBREG:
+    case MEM:
+      return ADDRESS_COST (XEXP (x, 0));
+
+    case ZERO_EXTEND:
+      *unsig = 1;
+      return mn10300_address_cost (XEXP (x, 0), unsig);
+
+    case CONST_INT:
+      if (INTVAL (x) == 0)
+       return 0;
+      if (INTVAL (x) + (*unsig ? 0 : 0x80) < 0x100)
+       return 1;
+      if (INTVAL (x) + (*unsig ? 0 : 0x8000) < 0x10000)
+       return 3;
+      if (INTVAL (x) + (*unsig ? 0 : 0x800000) < 0x1000000)
+       return 5;
+      return 7;
+
+    case CONST:
+    case SYMBOL_REF:
+      return 8;
+
+    case ADDRESSOF:
+      switch (GET_CODE (XEXP (x, 0)))
+       {
+       case MEM:
+         return ADDRESS_COST (XEXP (x, 0));
+
+       case REG:
+         return 1;
+
+       default:
+         abort ();
+       }
+
+    default:
+      abort ();
+
+    }
+}
index c1507c0..29d5e67 100644 (file)
@@ -818,6 +818,8 @@ struct cum_arg {int nbytes; };
   ((CLASS1 == CLASS2 && (CLASS1 == ADDRESS_REGS || CLASS1 == DATA_REGS)) ? 2 :\
    CLASS1 == CLASS2 && CLASS1 == EXTENDED_REGS ? 6 : 4)
 
+#define ADDRESS_COST(X) mn10300_address_cost((X), 0)
+
 /* A crude cut at RTX_COSTS for the MN10300.  */
 
 /* Provide the costs of a rtl expression.  This is in the body of a