diff mbox

[MIPS] Enable descriptors for nested functions in Ada

Message ID 1686875.o51Xv5tRQl@polaris
State New
Headers show

Commit Message

Eric Botcazou Nov. 13, 2016, 10:31 p.m. UTC
Similarly to x86, PowerPC and SPARC, this enables the use of custom run-time 
descriptors in Ada, thus eliminating the need for trampolines and executable 
stack in presence of pointers to nested functions.

Unfortunately I don't have access to MIPS hardware any more, but the scheme 
was tested on the architecture at some point.  OK for the mainline?


2016-11-13  Eric Botcazou  <ebotcazou@adacore.com>

        PR ada/67205
	* config/mips/mips.c (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Define.

-- 
Eric Botcazou

Comments

Matthew Fortune Nov. 14, 2016, 10:27 a.m. UTC | #1
Eric Botcazou <ebotcazou@adacore.com> writes:
> Similarly to x86, PowerPC and SPARC, this enables the use of custom run-

> time descriptors in Ada, thus eliminating the need for trampolines and

> executable stack in presence of pointers to nested functions.

> 

> Unfortunately I don't have access to MIPS hardware any more, but the

> scheme was tested on the architecture at some point.  OK for the

> mainline?

> 

> 

> 2016-11-13  Eric Botcazou  <ebotcazou@adacore.com>

> 

>         PR ada/67205

> 	* config/mips/mips.c (TARGET_CUSTOM_FUNCTION_DESCRIPTORS): Define.


Hi Eric,

Thanks for the patch. I'm a bit concerned about the interaction this
will have with microMIPS which can (albeit not implemented today) use
2-byte alignment on function entry points.

Is the solution for other targets to mandate 4-byte alignment when
using function descriptors?

If so then I don't see a problem with this. We will have to account for
that when GCC allows 2-byte aligned microMIPS functions.

Thanks,
Matthew
Eric Botcazou Nov. 15, 2016, 8:58 a.m. UTC | #2
> Thanks for the patch. I'm a bit concerned about the interaction this

> will have with microMIPS which can (albeit not implemented today) use

> 2-byte alignment on function entry points.

> 

> Is the solution for other targets to mandate 4-byte alignment when

> using function descriptors?


Yes, the compiler will overalign functions for languages using descriptors 
(only Ada as of this writing): 2-byte alignment if the setting is 1, 4-byte 
alignment if the setting is 2, 8-byte alignment if the setting is 4, etc.

That's done by the FUNCTION_ALIGNMENT macro defined in defaults.h.

> If so then I don't see a problem with this. We will have to account for

> that when GCC allows 2-byte aligned microMIPS functions.


OK, thanks.

-- 
Eric Botcazou
diff mbox

Patch

Index: config/mips/mips.c
===================================================================
--- config/mips/mips.c	(revision 242334)
+++ config/mips/mips.c	(working copy)
@@ -22387,6 +22387,10 @@  mips_promote_function_mode (const_tree t
 #undef TARGET_HARD_REGNO_SCRATCH_OK
 #define TARGET_HARD_REGNO_SCRATCH_OK mips_hard_regno_scratch_ok
 
+/* The architecture reserves bit 0 for MIPS16 so use bit 1 for descriptors.  */
+#undef TARGET_CUSTOM_FUNCTION_DESCRIPTORS
+#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 2
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-mips.h"