


## inlining-junk.pkg
## (C) 2001 Lucent Technologies, Bell Labs
#
# The Mythryl compiler contains several sort of inlining.
# The oldest (and in practice currently most important) is
# the 'Baseop' ops defined in
#
# src/lib/compiler/back/top/highcode/highcode-baseops.api#
# and then made available to application programmers via the 'inline' package in
#
# src/lib/compiler/front/semantic/symbolmapstack/base-types-and-ops-symbolmapstack.pkg#
# and then the inline_t package in
#
# src/lib/core/init/built-in.pkg#
# These are basic operations like addition, multiplication and fetch-from-vector
# which absolutely must expand into inline code if we are to produce decent quality
# native code, so we hardwire the inlining process.
#
# The first stage in this hardwired-inlining process is fun translate_variable_in_expression
#
# src/lib/compiler/back/top/translate/translate-deep-syntax-to-lambdacode.pkg#
# Compiled by:
# src/lib/compiler/core.sublib### "If I had eight hours to chop down a tree,
### I'd spend six sharpening my axe."
###
### -- Abraham Lincoln
stipulate
package err = error_message; # error_message is from src/lib/compiler/front/basics/errormsg/error-message.pkg package ii = inlining_information; # inlining_information is from src/lib/compiler/front/typer-stuff/basics/inlining-information.pkg package hbo = highcode_baseops; # highcode_baseops is from src/lib/compiler/back/top/highcode/highcode-baseops.pkgherein
package inlining_junk
: (weak) Inlining_Junk # Inlining_Junk is from src/lib/compiler/front/semantic/basics/inlining-junk.api {
fun bug s
=
err::impossible ("inlining_info: " + s);
exception BASEOP_WRAPPER (hbo::Baseop, types::Type);
Inlining_Info = ii::Inlining_Information;
inline_baseop = ii::INFO o BASEOP_WRAPPER;
inline_package = ii::LIST;
inline_nothing = ii::NULL;
fun case_inlining_info inlining_info { do_inline_baseop, do_inline_package, do_inline_nothing }
=
case inlining_info
#
ii::INFO (BASEOP_WRAPPER x) => do_inline_baseop x;
ii::INFO _ => bug "bogus Info node";
ii::LIST l => do_inline_package l;
ii::NULL => do_inline_nothing ();
esac;
fun print_inlining_info inlining_info
=
cat (loop (inlining_info, []))
where
fun loop (inlining_info, result)
=
case_inlining_info inlining_info
{
do_inline_baseop => fn (p, _) = hbo::baseop_to_string p ! result,
do_inline_nothing => fn () = "<InlNo>" ! result,
do_inline_package => fn [] => "{ }" ! result;
h ! t => "{ " ! loop ( h, # "h" == "head"; "t" == "tail".
fold_right (fn (x, a) = ", " ! loop (x, a))
("}" ! result)
t
);
end
};
end;
select_inlining_info = ii::select;
is_baseop_info = ii::is_simple;
fun is_callcc_baseop (ii::INFO (BASEOP_WRAPPER ((hbo::CALLCC | hbo::CAPTURE_FATE), _)))
=>
TRUE;
is_callcc_baseop _
=>
FALSE;
end;
fun pure_info (ii::INFO (BASEOP_WRAPPER (baseop, _)))
=>
is_pure baseop
where
fun is_pure hbo::CAST => TRUE;
is_pure _ => FALSE;
end;
# isPure = hbo::purePrimop
end;
pure_info _
=>
FALSE;
end;
make_baseop_inlining_info = inline_baseop;
make_package_inlining_info = inline_package;
null_inlining_info = inline_nothing;
};
end;


