4 if [ $# -eq 3 -a "$2" = '-d' ]; then
7 elif [ $# -ne 1 ]; then
8 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
13 patch $pdir -f --no-backup-if-mismatch -p0 --fuzz 10 < $0
16 patch $pdir -f --no-backup-if-mismatch -R -p0 --fuzz 10 < $0
19 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
24 # DP: try harder to avoid ldm in function epilogues
26 --- gcc/config/arm/arm.c Fri Mar 5 18:49:42 2004
27 +++ gcc/config/arm/arm.c Fri Mar 5 16:00:21 2004
28 @@ -7598,6 +7629,26 @@
29 return_used_this_function = 0;
32 +/* Return the number (counting from 0) of
33 + the least significant set bit in MASK. */
39 +number_of_first_bit_set (mask)
45 + (mask & (1 << bit)) == 0;
53 arm_output_epilogue (really_return)
55 @@ -7788,27 +7839,47 @@
56 saved_regs_mask |= (1 << PC_REGNUM);
59 - /* Load the registers off the stack. If we only have one register
60 - to load use the LDR instruction - it is faster. */
61 - if (saved_regs_mask == (1 << LR_REGNUM))
63 - /* The exception handler ignores the LR, so we do
64 - not really need to load it off the stack. */
66 - asm_fprintf (f, "\tadd\t%r, %r, #4\n", SP_REGNUM, SP_REGNUM);
68 - asm_fprintf (f, "\tldr\t%r, [%r], #4\n", LR_REGNUM, SP_REGNUM);
70 - else if (saved_regs_mask)
71 + if (saved_regs_mask)
73 - if (saved_regs_mask & (1 << SP_REGNUM))
74 - /* Note - write back to the stack register is not enabled
75 - (ie "ldmfd sp!..."). We know that the stack pointer is
76 - in the list of registers and if we add writeback the
77 - instruction becomes UNPREDICTABLE. */
78 - print_multi_reg (f, "ldmfd\t%r", SP_REGNUM, saved_regs_mask);
79 + /* Load the registers off the stack. If we only have one register
80 + to load use the LDR instruction - it is faster. */
81 + if (bit_count (saved_regs_mask) == 1)
83 + int reg = number_of_first_bit_set (saved_regs_mask);
88 + /* Mustn't use base writeback when loading SP. */
89 + asm_fprintf (f, "\tldr\t%r, [%r]\n", SP_REGNUM, SP_REGNUM);
95 + /* The exception handler ignores the LR, so we do
96 + not really need to load it off the stack. */
97 + asm_fprintf (f, "\tadd\t%r, %r, #4\n", SP_REGNUM, SP_REGNUM);
100 + /* else fall through */
103 + asm_fprintf (f, "\tldr\t%r, [%r], #4\n", reg, SP_REGNUM);
108 - print_multi_reg (f, "ldmfd\t%r!", SP_REGNUM, saved_regs_mask);
110 + if (saved_regs_mask & (1 << SP_REGNUM))
111 + /* Note - write back to the stack register is not enabled
112 + (ie "ldmfd sp!..."). We know that the stack pointer is
113 + in the list of registers and if we add writeback the
114 + instruction becomes UNPREDICTABLE. */
115 + print_multi_reg (f, "ldmfd\t%r", SP_REGNUM, saved_regs_mask);
117 + print_multi_reg (f, "ldmfd\t%r!", SP_REGNUM, saved_regs_mask);
121 if (current_function_pretend_args_size)
122 @@ -9610,26 +9677,6 @@
126 -/* Return the number (counting from 0) of
127 - the least significant set bit in MASK. */
133 -number_of_first_bit_set (mask)
139 - (mask & (1 << bit)) == 0;
146 /* Generate code to return from a thumb function.
147 If 'reg_containing_return_addr' is -1, then the return address is
148 actually on the stack, at the stack pointer. */