mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 19:33:46 +00:00
Estimated hours taken: 3 Implement `:- pragma no_inline'. This pragma prevents the compiler from inlining predicates. compiler/higher_order.m: compiler/unused_args.m: Create new preds using entire marker list, rather than just inlining. compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/prog_data.m: compiler/prog_io_pragma.m: Add code to support no_inline marker and pragma. compiler/hlds_pred.m: Add `no_inline' marker. Create new preds using entire marker list, rather than just inlining. Change `pred_info_is_inlined' to `pred_info_requested_inlining', as it was inappropriately named, and added `pred_info_requested_no_inlining'. compiler/inlining.m: Don't inline predicates with pragma no_inlines compiler/intermod.m: Use `pred_info_requested_inlining'. compiler/make_hlds.m: Add code to check for conflicting markers, check for conflicts between `inline' and `no_inline' markers. Add `no_inline' markers. Rename pragma_set_markers as pragma_add_markers, as it was actually adding extra markers to what was already there. doc/reference_manual.texi: Document no_inline. tests/hard_coded/Mmake: tests/invalid/Mmake: tests/hard_coded/no_inline.exp: tests/hard_coded/no_inline.m: tests/invalid/inline_conflict.err_exp: tests/invalid/inline_conflict.m: Add test cases for no_inline and conflicts between inline and no_inline.
54 lines
1004 B
Mathematica
54 lines
1004 B
Mathematica
|
|
:- module no_inline.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
:- pred baz(io__state::di, io__state::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
main -->
|
|
io__write_string("I'm going to see whether `bar'/2 is inlined.\n"),
|
|
io__write_string("(Remember kids, don't try this one at home.)\n\n"),
|
|
bar,
|
|
io__write_string("It wasn't.\n").
|
|
|
|
:- pragma no_inline(bar/2).
|
|
|
|
:- pred bar(io__state::di, io__state::uo) is det.
|
|
|
|
:- pragma c_header_code("
|
|
#include <stdio.h>
|
|
").
|
|
|
|
:- pragma c_code(bar(IO0::di, IO::uo), "
|
|
/* START INLINING */
|
|
{
|
|
static int i = 0;
|
|
IO = IO0;
|
|
|
|
/* Check if I get run again - I'm supposed to only execute once! */
|
|
|
|
if (i > 0) {
|
|
printf(""bar/2: You inlined me!\n""
|
|
""Read my lips, `no_inline'\n\n"");
|
|
fatal_error(""pragma no_inline ignored."");
|
|
}
|
|
i++;
|
|
|
|
tailcall(ENTRY(mercury__no_inline__baz_2_0),
|
|
ENTRY(mercury__no_inline__bar_2_0));
|
|
/* END INLINING */
|
|
}
|
|
").
|
|
|
|
|
|
:- pragma c_code(baz(IO0::di, IO::uo), "
|
|
IO = IO0;
|
|
proceed();
|
|
").
|
|
|