Estimated hours taken: 12
Branches: main
compiler/*.m:
Convert predicates that used to have one clause for each kind of
HLDS goal into explicit disjunctions, since this gives the debugger
a meaningful name for each argument. In some cases, this exposed
arguments that were used by *no* clause. In other cases, it allowed
factoring out common code, as well as code that *should* have been
common but wasn't.
Put the disjuncts in a meaningful order. In too many cases, they were
almost random.
Merge the resulting predicates into their parents, in places where
the Prolog indexing one could get from separate clauses was the only
reason for separating those predicates from their parents in the first
place. Similarly, merge child predicates handling generic call kinds
and such back into the main predicate where this improves clarity.
In some cases, this allows putting the extraction of hlds_goal_expr
from a hlds_goal into one place, instead of repeating it in lots of
places.
Give some predicates more descriptive names. In some cases, rationalize
argument order. In some cases, rationalize the order of predicates
in the module.
Replace some uses of booleans with purpose-specific types.
Give some fields names, and put type-identifying prefixes on the names
of other fields, to make tag files work better.
In some cases, reorder fields to them put into related groups.
Use more standard and/or more descriptive variable names
Use a standard syntax for if-then-else in each module.
Follow our style convention for comments.
Estimated hours taken: 20
Branches: main
Create optimised versions for all the procedures for which possibilities for
structure reuse are detected. Put the mechanism in place to generate reuse
pragmas, and to parse them back in.
compiler/add_pragma.m:
compiler/structure_sharing.analysis.m:
compiler/hlds_pred.m:
Postpone the processing (renaming) of structure sharing pragmas
until the beginning of the actual structure sharing analysis.
compiler/add_pragma.m:
compiler/hlds_pred.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/prog_ctgc.m:
compiler/prog_io_pragma.m:
compiler/trans_opt.m:
Add the mechanism to output and parse the structure_reuse pragmas.
(Remove the name of the reuse-version procedures in the
pragma structure_reuse).
compiler/hlds_module.m:
Simplify the type structure_reuse_info.
compiler/prog_data.m:
Add types for the public representation of reuse conditions.
(remove the previous name "reuse_tuple", which simply does not sound
adequate).
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_item.m:
compiler/recompilation.version.m:
Remove the name of the reuse-version procedures in the pragma
structure_reuse.
compiler/prog_type.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
Add functions to remove all typeinfo-vars from a given list (resp. set)
of vars. These functions are used when deriving the variables in
local and forward use, where typeinfo-variables are irrelevant.
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.versions.m:
compiler/structure_reuse.m:
Process the reuse information of any imported procedures.
Create optimised versions for the procedures for which
reuse was detected.
(structure_reuse.versions.m = new file)
compiler/structure_reuse.domain.m:
Conversion procedures between the public and private representation
for structure reuse conditions.
compiler/structure_reuse.indirect.m:
Do not try to replace call information even when you know the
pred_proc_id of the reuse version of that call (which is the case for
imported procedures with reuse). It is more consistent
to do this at the same time when all the other conversions are done,
i.e. when generating the optimised versions of the procedures with
reuse (even with unconditional reuse).
Estimated hours taken: 12
Branches: main
Provide the indirect reuse analysis part of the CTGC system. Using a fixpoint
computation, this propagates the reuse conditions determined by the direct
reuse analysis step through procedure calls.
compiler/ctgc.datastruct.m:
Minor additions.
compiler/ctgc.livedata.m:
(new file) Types and operations needed for defining the lattice of
possibly live datastructures.
compiler/ctgc.m:
Add livedata submodule.
compiler/ctgc.util.m:
Provide the operations for determining variable and type renamings,
used both by the structure sharing analysis as well as the reuse
analysis.
compiler/hlds_module.m:
Add structure reuse information to collect the mapping between
procedures, and their reuse versions.
compiler/prog_data.m:
New types "dead_vars", "live_vars".
compiler/structure_reuse.analysis.m:
Add the indirect reuse analysis step.
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_sharing.domain.m:
Mainly moving the operation of looking up sharing information and
combining it with existing sharing to a more appropriate place, namely
structure_sharing.domain.m
(also rename the bottom and top elements of the structure sharing
domain).
compiler/structure_reuse.domain.m:
Add a renaming operation but especially two predicates needed to
verify whether a given procedure call satisfies the derived reuse
conditions, and to translate these reuse conditions to the
head variables of the procedure in which the procedure call occurs.
compiler/structure_reuse.indirect.m:
The actual indirect reuse analysis.
compiler/structure_reuse.m:
Add "structure_reuse.indirect" as a submodule.
compiler/structure_sharing.analysis.m:
small changes.
Estimated hours taken: 25
Branches: main
Provide the direct reuse analysis part of the structure reuse analysis (which
itself is part of the CTGC system).
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
Additional predicates.
compiler/ctgc.m:
Add structure reuse module.
compiler/handle_options.m:
compiler/options.m:
Add new options "structure_reuse_analysis" and related ones.
compiler/handle_options.m:
compiler/hlds_out.m:
Add dump option "R" to dump structure reuse related information
in the hlds_dump files.
compiler/hlds_goal.m:
Types to record structure reuse information at the level of each
goal.
Additional "case_get_goal" function to extract the goal from an case.
compiler/mercury_compile.m:
Add structure reuse analysis as a new compiler stage.
compiler/structure_reuse.analysis.m:
The top level analysis predicates.
compiler/structure_reuse.m:
compiler/structure_reuse.direct.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
Direct reuse analysis is split into 2 steps: determining when and how
data structures become garbage, and then choosing how these dead
data structures might best be reused.
compiler/structure_reuse.domain.m:
The abstract domain for keeping track of reuse conditions, the main
domain in the structure reuse analysis.
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
To determine whether data structures become dead or not, one needs to
know which variables in a goal are needed with respect to forward
execution (lfu = local forward use), and backward execution, i.e.
backtracking (lbu = local backward use). These two modules provide
the necessary functionality to pre-annotate the goals with lfu and
lbu information.
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
Remove the structure sharing table from the interface of the analysis
predicate in structure_sharing.analysis.m;
Move predicates to structure_sharing.domain.m so that they become
more easily accessible for the structure_reuse modules.
compiler/prog_data.m:
New types "dead_var", "live_var" and alike.