aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/arm
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2008-08-04 16:27:17 +0000
committerPaul Brook <pbrook@gcc.gnu.org>2008-08-04 16:27:17 +0000
commit795dc4fc9010a608ed06857c4781f0c51b839431 (patch)
tree7c8fe332e90fe048461d3ee6391e17764a0c3221 /gcc/config/arm
parent367a9e66e0bf0f97e38dd4525887a8ed76a61a54 (diff)
downloadgcc-795dc4fc9010a608ed06857c4781f0c51b839431.zip
gcc-795dc4fc9010a608ed06857c4781f0c51b839431.tar.gz
gcc-795dc4fc9010a608ed06857c4781f0c51b839431.tar.bz2
arm.c (thumb_core_reg_alloc_order): New.
2008-08-04 Paul Brook <paul@codesourcery.com> gcc/ * cofig/arm/arm.c (thumb_core_reg_alloc_order): New. (arm_order_regs_for_local_alloc): New function. * config/arm/arm-protos.h (arm_order_regs_for_local_alloc): Add prototype. * config/arm/arm.h (ORDER_REGS_FOR_LOCAL_ALLOC): Define. From-SVN: r138640
Diffstat (limited to 'gcc/config/arm')
-rw-r--r--gcc/config/arm/arm-protos.h2
-rw-r--r--gcc/config/arm/arm.c24
-rw-r--r--gcc/config/arm/arm.h3
3 files changed, 29 insertions, 0 deletions
diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index a296349..bdf9a04 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -208,4 +208,6 @@ extern void arm_lang_object_attributes_init(void);
extern const char *arm_mangle_type (const_tree);
+extern void arm_order_regs_for_local_alloc (void);
+
#endif /* ! GCC_ARM_PROTOS_H */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index a89229e..8b89904 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -19046,4 +19046,28 @@ arm_mangle_type (const_tree type)
return NULL;
}
+/* Order of allocation of core registers for Thumb: this allocation is
+ written over the corresponding initial entries of the array
+ initialized with REG_ALLOC_ORDER. We allocate all low registers
+ first. Saving and restoring a low register is usually cheaper than
+ using a call-clobbered high register. */
+
+static const int thumb_core_reg_alloc_order[] =
+{
+ 3, 2, 1, 0, 4, 5, 6, 7,
+ 14, 12, 8, 9, 10, 11, 13, 15
+};
+
+/* Adjust register allocation order when compiling for Thumb. */
+
+void
+arm_order_regs_for_local_alloc (void)
+{
+ const int arm_reg_alloc_order[] = REG_ALLOC_ORDER;
+ memcpy(reg_alloc_order, arm_reg_alloc_order, sizeof (reg_alloc_order));
+ if (TARGET_THUMB)
+ memcpy (reg_alloc_order, thumb_core_reg_alloc_order,
+ sizeof (thumb_core_reg_alloc_order));
+}
+
#include "gt-arm.h"
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index 9f662f3..2ab44c2 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1080,6 +1080,9 @@ extern int arm_structure_size_boundary;
127 \
}
+/* Use different register alloc ordering for Thumb. */
+#define ORDER_REGS_FOR_LOCAL_ALLOC arm_order_regs_for_local_alloc ()
+
/* Interrupt functions can only use registers that have already been
saved by the prologue, even if they would normally be
call-clobbered. */