aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/arm/arm.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2003-12-12 02:23:03 +0000
committerZack Weinberg <zack@gcc.gnu.org>2003-12-12 02:23:03 +0000
commitd2b6eb76fa7c35f512f8f8dd16b027a525550460 (patch)
treeb29e5a38125660e31d9f4f926bb316c898713a73 /gcc/config/arm/arm.c
parent15975b43148e152b057eece4d461b0fe0375c656 (diff)
downloadgcc-d2b6eb76fa7c35f512f8f8dd16b027a525550460.zip
gcc-d2b6eb76fa7c35f512f8f8dd16b027a525550460.tar.gz
gcc-d2b6eb76fa7c35f512f8f8dd16b027a525550460.tar.bz2
arm.c (ARM_ADDRESS_COST, [...]): Convert macros to inline functions...
* arm.c (ARM_ADDRESS_COST, THUMB_ADDRESS_COST): Convert macros to inline functions: arm_arm_address_cost, arm_thumb_address_cost respectively. (arm_address_cost): Use 'em. From-SVN: r74560
Diffstat (limited to 'gcc/config/arm/arm.c')
-rw-r--r--gcc/config/arm/arm.c66
1 files changed, 43 insertions, 23 deletions
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index cadbe65..3d99144 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -3535,32 +3535,52 @@ arm_rtx_costs (rtx x, int code, int outer_code, int *total)
the same for practically all of them. So we weight the different types
of address here in the order (most pref first):
PRE/POST_INC/DEC, SHIFT or NON-INT sum, INT sum, REG, MEM or LABEL. */
+static inline int
+arm_arm_address_cost (rtx x)
+{
+ enum rtx_code c = GET_CODE (x);
+
+ if (c == PRE_INC || c == PRE_DEC || c == POST_INC || c == POST_DEC)
+ return 0;
+ if (c == MEM || c == LABEL_REF || c == SYMBOL_REF)
+ return 10;
+
+ if (c == PLUS || c == MINUS)
+ {
+ char cl0 = GET_RTX_CLASS (GET_CODE (XEXP (x, 0)));
+ char cl1 = GET_RTX_CLASS (GET_CODE (XEXP (x, 1)));
+
+ if (GET_CODE (XEXP (x, 0)) == CONST_INT)
+ return 2;
+
+ if (cl0 == '2' || cl0 == 'c' || cl1 == '2' || cl1 == 'c')
+ return 3;
+
+ return 4;
+ }
+
+ return 6;
+}
+
+static inline int
+arm_thumb_address_cost (rtx x)
+{
+ enum rtx_code c = GET_CODE (x);
+
+ if (c == REG)
+ return 1;
+ if (c == PLUS
+ && GET_CODE (XEXP (x, 0)) == REG
+ && GET_CODE (XEXP (x, 1)) == CONST_INT)
+ return 1;
+
+ return 2;
+}
+
static int
arm_address_cost (rtx x)
{
-#define ARM_ADDRESS_COST(X) \
- (10 - ((GET_CODE (X) == MEM || GET_CODE (X) == LABEL_REF \
- || GET_CODE (X) == SYMBOL_REF) \
- ? 0 \
- : ((GET_CODE (X) == PRE_INC || GET_CODE (X) == PRE_DEC \
- || GET_CODE (X) == POST_INC || GET_CODE (X) == POST_DEC) \
- ? 10 \
- : (((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS) \
- ? 6 + (GET_CODE (XEXP (X, 1)) == CONST_INT ? 2 \
- : ((GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == '2' \
- || GET_RTX_CLASS (GET_CODE (XEXP (X, 0))) == 'c' \
- || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == '2' \
- || GET_RTX_CLASS (GET_CODE (XEXP (X, 1))) == 'c') \
- ? 1 : 0)) \
- : 4)))))
-
-#define THUMB_ADDRESS_COST(X) \
- ((GET_CODE (X) == REG \
- || (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == REG \
- && GET_CODE (XEXP (X, 1)) == CONST_INT)) \
- ? 1 : 2)
-
- return (TARGET_ARM ? ARM_ADDRESS_COST (x) : THUMB_ADDRESS_COST (x));
+ return TARGET_ARM ? arm_arm_address_cost (x) : arm_thumb_address_cost (x);
}
static int