mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-10 03:13:46 +00:00
Estimated hours taken: 16 Add support for using a different C calling convention for the C functions generated by the MLDS back-end, if you're on x86 and you define MR_USE_REGPARM. The code do to this uses GNU C's function attributes extension; it will only work if you have the latest snapshot versions of gcc. So MR_USE_REGPARM is not enabled by default. compiler/ml_call_gen.m: For higher-order calls and class method calls, assign the function pointer to a local variable. This is needed for current versions of gcc, since gcc doesn't support function attributes on function types in function pointer type casts. compiler/mlds_to_c.m: Output "MR_CALL" in function declarations. Also output a reference to MR_GRADE_VAR, like we do for the LLDS back-end. runtime/mercury_std.h: Define MR_CALL. This is a macro that can expand to some implementation-specific C extension to specify the calling convention used for the MLDS back-end. E.g. for gcc, on x86, if MR_USE_REGPARM is defined it expands to `__attribute__((__regparm__(3), __stdcall__))'. runtime/mercury_conf_param.h: Document MR_USE_REGPARM. runtime/mercury_grade.h: Encode the setting of MR_USE_REGPARM in the mangled grade name. runtime/mercury_types.h: runtime/mercury.h: runtime/mercury.c: runtime/mercury_wrapper.h: runtime/mercury_wrapper.c: util/mkinit.c: library/array.m: library/builtin.m: library/exception.m: Use MR_CALL for functions that should have the Mercury calling convention. runtime/mercury_types.h: runtime/mercury.h: Move the definition of MR_Cont and MR_NestedCont from mercury_types.h to mercury.h. This was needed to avoid a cyclic header dependency problem and is also a good idea anyway, since MR_Cont and MR_NestedCont are specific to the MLDS back-end.