Skip to content

Commit 767f65c

Browse files
mfortuneJeffreyALaw
authored andcommitted
Add -mgrow-frame-downwards
Grow the local frame down instead of up for mips16 code size. By growing the frame downwards we get spill slots created at the lowest address rather than highest address in a local frame. The benefit being that when the frame is large the spill slots can still be accessed using a 16bit instruction whereas it is less important for large local variables to be accessed using short instructions as they are (probably) accessed less frequently. This is default on for MIPS16. gcc/ * config/mips/mips.h (FRAME_GROWS_DOWNWARD) Allow the frame to grow downwards for mips16 when -mgrow-frame-downwards is set. * config/mips/mips.opt: Add -mgrow-frame-downwards option.
1 parent 14ad799 commit 767f65c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

gcc/config/mips/mips.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,8 +2363,14 @@ enum reg_class
23632363

23642364
#define STACK_GROWS_DOWNWARD 1
23652365

2366-
#define FRAME_GROWS_DOWNWARD (flag_stack_protect != 0 \
2367-
|| (flag_sanitize & SANITIZE_ADDRESS) != 0)
2366+
/* Growing the frame downwards allows us to put spills closest to
2367+
the stack pointer which is good as they are likely to be accessed
2368+
frequently. We can also arrange for normal stack usage to place
2369+
scalars last so that they too are close to the stack pointer. */
2370+
#define FRAME_GROWS_DOWNWARD ((TARGET_MIPS16 \
2371+
&& TARGET_FRAME_GROWS_DOWNWARDS) \
2372+
|| (flag_stack_protect != 0 \
2373+
|| (flag_sanitize & SANITIZE_ADDRESS) != 0))
23682374

23692375
/* Size of the area allocated in the frame to save the GP. */
23702376

gcc/config/mips/mips.opt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ mframe-header-opt
473473
Target Var(flag_frame_header_optimization) Optimization
474474
Optimize frame header.
475475

476+
mgrow-frame-downwards
477+
Target Var(TARGET_FRAME_GROWS_DOWNWARDS) Init(1) Undocumented
478+
Change the behaviour to grow the frame downwards.
479+
476480
noasmopt
477481
Driver
478482

0 commit comments

Comments
 (0)