


## 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 id = inlining_data; # inlining_data is from src/lib/compiler/front/typer-stuff/basics/inlining-data.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_data: " + s);
exception BASEOP_WRAPPER (hbo::Baseop, types::Type);
Inlining_Data = id::Inlining_Data;
inline_baseop = id::DATA o BASEOP_WRAPPER;
inline_package = id::LIST;
inline_nothing = id::NULL;
fun case_inlining_data inlining_data { do_inline_baseop, do_inline_package, do_inline_nothing }
=
case inlining_data
#
id::DATA (BASEOP_WRAPPER x) => do_inline_baseop x;
id::DATA _ => bug "bogus DATA node";
#
id::LIST l => do_inline_package l;
id::NULL => do_inline_nothing ();
esac;
fun print_inlining_data inlining_data
=
cat (loop (inlining_data, []))
where
fun loop (inlining_data, result)
=
case_inlining_data inlining_data
{
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_backward (fn (x, a) = ", " ! loop (x, a))
("}" ! result)
t
);
end
};
end;
select_inlining_data = id::select;
is_baseop_info = id::is_simple;
fun is_callcc_baseop (id::DATA (BASEOP_WRAPPER ((hbo::CALLCC | hbo::CALL_WITH_CURRENT_CONTROL_FATE), _)))
=>
TRUE;
is_callcc_baseop _
=>
FALSE;
end;
fun pure_info (id::DATA (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_data = inline_baseop;
make_package_inlining_data = inline_package;
null_inlining_data = inline_nothing;
};
end;


