Sure, there is some substantial changes between 4.0.x and 4.1.x to handle, but once the right patches are created, it is easy to add the option "-mpreferred-stack-boundary=n" now.A couple of devkitPSP users have been asking about getting a version of the toolchain which includes your preferred stack boundary patch. I noticed it's gone from the latest psp svn patches & I've been having a bit of trouble getting it to apply to 4.1.2.
I decided to make it publicly here in case some other people may be interested.
We need to patch three files :
- mips.c.patch
Code: Select all
Index: mips.c
===================================================================
--- mips.c (revision 13)
+++ mips.c (working copy)
@@ -612,6 +612,8 @@
should arrange to call mips32 hard floating point code. */
int mips16_hard_float;
+unsigned int mips_preferred_stack_boundary;
+unsigned int mips_preferred_stack_align;
/* The architecture selected by -mipsN. */
static const struct mips_cpu_info *mips_isa_info;
@@ -5057,6 +5059,21 @@
mips_lo_relocs[SYMBOL_GOTOFF_LOADGP] = "%lo(%neg(%gp_rel(";
}
+ /* Validate -mpreferred-stack-boundary= value, or provide default.
+ The default of 128-bit is for newABI else 64-bit. */
+ mips_preferred_stack_boundary = (TARGET_NEWABI ? 128 : 64);
+ mips_preferred_stack_align = (TARGET_NEWABI ? 16 : 8);
+ if (mips_preferred_stack_boundary_string)
+ {
+ i = atoi (mips_preferred_stack_boundary_string);
+ if (i < 2 || i > 12)
+ error ("-mpreferred-stack-boundary=%d is not between 2 and 12", i);
+ else
+ {
+ mips_preferred_stack_align = (1 << i);
+ mips_preferred_stack_boundary = mips_preferred_stack_align * 8;
+ }
+ }
/* Thread-local relocation operators. */
mips_lo_relocs[SYMBOL_TLSGD] = "%tlsgd(";
mips_lo_relocs[SYMBOL_TLSLDM] = "%tlsldm(";
Code: Select all
Index: mips.h
===================================================================
--- mips.h (revision 13)
+++ mips.h (working copy)
@@ -1953,7 +1953,7 @@
`current_function_outgoing_args_size'. */
#define OUTGOING_REG_PARM_STACK_SPACE
-#define STACK_BOUNDARY (TARGET_NEWABI ? 128 : 64)
+#define STACK_BOUNDARY (mips_preferred_stack_boundary)
#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
@@ -2109,7 +2109,7 @@
/* Treat LOC as a byte offset from the stack pointer and round it up
to the next fully-aligned offset. */
#define MIPS_STACK_ALIGN(LOC) \
- (TARGET_NEWABI ? ((LOC) + 15) & -16 : ((LOC) + 7) & -8)
+ ((LOC) + (mips_preferred_stack_align - 1) & -(mips_preferred_stack_align))
/* Implement `va_start' for varargs and stdarg. */
@@ -2812,6 +2812,9 @@
#endif
#endif
+extern unsigned int mips_preferred_stack_boundary;
+extern unsigned int mips_preferred_stack_align;
+extern const char *mips_preferred_stack_boundary_string;
#ifndef HAVE_AS_TLS
#define HAVE_AS_TLS 0
#endif
Code: Select all
Index: mips.opt
===================================================================
--- mips.opt (revision 13)
+++ mips.opt (working copy)
@@ -216,3 +216,7 @@
mxgot
Target Report Var(TARGET_XGOT)
Lift restrictions on GOT size
+
+mpreferred-stack-boundary=
+Target RejectNegative Joined Var(mips_preferred_stack_boundary_string)
+Attempt to keep stack aligned to this power of 2