## lowhalf-notes.pkg
#
# Here we customize the generic 'note' facility with support for:
#
# Conditional-jump branch probabilities.
# Basic-block execution frequencies.
# Comments.
# No-reorder constraint on instructions in a basic block.
# Control-dependency definitions and uses.
# no_optimization flag.
# call-heapcleaner flag.
# heapcleaner-safepoint flag.
# heapcleaner_info flag.
# block-names.
# empty-block flag.
# mark-reg
# print-register-info.
# no branch-chaining.
# uses-virtual-frame-pointer flag.
# return_arg
# Compiled by:
#
src/lib/compiler/back/low/lib/lowhalf.lib# These are some basic annotations
# understood by the lowhalf system:
#
# -- Allen Leung
stipulate
package nt = note; # note is from
src/lib/src/note.pkg package rkj = registerkinds_junk; # registerkinds_junk is from
src/lib/compiler/back/low/code/registerkinds-junk.pkgherein
package lowhalf_notes
: (weak) Lowhalf_Notes # Lowhalf_Notes is from
src/lib/compiler/back/low/code/lowhalf-notes.api {
# The branch probability of conditional
# branches in percentage
#
exception BRANCH_PROBABILITY probability::Probability;
branch_probability
=
nt::make_notekind'
{ x_to_note => BRANCH_PROBABILITY,
#
to_string => \\ p = "branch(" + probability::to_string p + ")",
#
get => \\ BRANCH_PROBABILITY b => b;
e => raise exception e;
end
};
# The execution frequency of a basic block:
#
exception EXECUTION_FREQUENCY Int;
execution_freq
=
nt::make_notekind'
{ x_to_note => EXECUTION_FREQUENCY,
#
to_string => \\ r = "freq(" + int::to_string r + ")",
#
get => \\ EXECUTION_FREQUENCY x => x;
e => raise exception e;
end
};
# No effect at all; just allows
# you to insert comments:
#
comment = nt::make_notekind (THE (\\ s = s));
# Instructions in the block
# should not be reordered:
#
noreorder = nt::make_notekind (NULL: Null_Or( Void -> String ) );
fun listify f
=
g
where
fun g [] => "";
g [x] => f x;
g (x ! xs) => f x + " " + g xs;
end;
end;
# Control dependence use:
#
exception CONTROL_DEPENDENCY_DEF rkj::Codetemp_Info;
exception CONTROL_DEPENDENCY_USE rkj::Codetemp_Info;
ctrl_use = nt::make_notekind'
{
x_to_note => CONTROL_DEPENDENCY_USE,
#
to_string => rkj::register_to_string,
#
get => \\ CONTROL_DEPENDENCY_USE x => x;
e => raise exception e;
end
};
ctrl_def = nt::make_notekind'
{
x_to_note => CONTROL_DEPENDENCY_DEF,
#
to_string => rkj::register_to_string,
#
get => \\ CONTROL_DEPENDENCY_DEF x => x;
e => raise exception e;
end
};
no_optimization = nt::make_notekind (THE (\\ () = "NO_OPTIMIZATION"));
call_heapcleaner = nt::make_notekind (THE (\\ () = "CALL_HEAPCLEANER"));
#
heapcleaner_safepoint = nt::make_notekind (THE (\\ s = "HEAPCLEANER_SAFEPOINT: " + s));
heapcleaner_info = nt::make_notekind (THE (\\ () = "HEAPCLEANER_INFO"));
exception BLOCKNAMES nt::Notes;
block_names
=
nt::make_notekind'
{ x_to_note => BLOCKNAMES,
#
to_string => \\ _ = "BLOCK_NAMES",
#
get => \\ BLOCKNAMES n => n;
e => raise exception e;
end
};
exception EMPTYBLOCK;
empty_block
=
nt::make_notekind'
{
x_to_note => \\ () = EMPTYBLOCK,
#
to_string => \\ () = "EMPTY_BLOCK",
#
get => \\ EMPTYBLOCK => ();
e => raise exception e;
end
};
exception MARKREG rkj::Codetemp_Info -> Void;
mark_reg
=
nt::make_notekind'
{
x_to_note => MARKREG,
#
to_string => \\ _ = "MARK_REG",
#
get => \\ MARKREG f => f;
e => raise exception e;
end
};
print_register_info
=
nt::make_notekind (THE (\\ _ = "PRINT_REGISTER_INFO"))
:
nt::Notekind (rkj::Codetemp_Info -> String);
no_branch_chaining
=
nt::make_notekind (THE (\\ () = "NO_BRANCH_CHAINING"));
uses_virtual_framepointer
=
nt::make_notekind (THE (\\ () = "HAS_VIRTUAL_FRAMEPOINTER"));
return_arg
=
nt::make_notekind (THE (rkj::register_to_string));
};
end;
## COPYRIGHT (c) 2002 Bell Labs, Lucent Technologies
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.