aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMatthew Fortune <matthew.fortune@imgtec.com>2025-08-10 11:20:30 -0600
committerJeff Law <jlaw@ventanamicro.com>2025-08-10 11:20:30 -0600
commit767f65cf82b516656dda95802a83bf905550f0b3 (patch)
tree9e17c50b68819cbabec494a42aa1a92ff29613f6 /gcc
parent14ad799ae1545569be158b00865f6f2f951657bd (diff)
downloadgcc-767f65cf82b516656dda95802a83bf905550f0b3.zip
gcc-767f65cf82b516656dda95802a83bf905550f0b3.tar.gz
gcc-767f65cf82b516656dda95802a83bf905550f0b3.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/mips/mips.h10
-rw-r--r--gcc/config/mips/mips.opt4
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index e224ade..494f14c 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -2363,8 +2363,14 @@ enum reg_class
#define STACK_GROWS_DOWNWARD 1
-#define FRAME_GROWS_DOWNWARD (flag_stack_protect != 0 \
- || (flag_sanitize & SANITIZE_ADDRESS) != 0)
+/* Growing the frame downwards allows us to put spills closest to
+ the stack pointer which is good as they are likely to be accessed
+ frequently. We can also arrange for normal stack usage to place
+ scalars last so that they too are close to the stack pointer. */
+#define FRAME_GROWS_DOWNWARD ((TARGET_MIPS16 \
+ && TARGET_FRAME_GROWS_DOWNWARDS) \
+ || (flag_stack_protect != 0 \
+ || (flag_sanitize & SANITIZE_ADDRESS) != 0))
/* Size of the area allocated in the frame to save the GP. */
diff --git a/gcc/config/mips/mips.opt b/gcc/config/mips/mips.opt
index e245654..f07db5a 100644
--- a/gcc/config/mips/mips.opt
+++ b/gcc/config/mips/mips.opt
@@ -473,6 +473,10 @@ mframe-header-opt
Target Var(flag_frame_header_optimization) Optimization
Optimize frame header.
+mgrow-frame-downwards
+Target Var(TARGET_FRAME_GROWS_DOWNWARDS) Init(1) Undocumented
+Change the behaviour to grow the frame downwards.
+
noasmopt
Driver