Packages are modules whose only job is to serve as a container for submodules.
Modules like top_level.m, hlds.m, parse_tree.m and ll_backend.m are packages
in this (informal) sense.
Besides the include_module declarations for their submodules, most of the
packages in the compiler used to import some modules, mostly other packages
whose component modules their submodules may need. For example, ll_backend.m
used to import parse_tree.m. This meant that modules in the ll_backend package
did not have to import parse_tree.m before importing modules in the parse_tree
package.
However, this had a price. When we add a new module to the parse_tree package,
parse_tree.int would change, and this would require the recompilation of ALL
the modules in the ll_backend package, even the ones that did NOT import ANY
of the modules in the parse_tree package.
This happened even at one remove. Pretty much all modules in every one
of the backend have to import one or more modules in the hlds package,
and they therefore have import hlds.m. Since hlds.m imported transform_hlds.m,
any addition of a new middle pass to the transform_hlds package required
the recompilation of all backend modules, even in the usual case of the two
having nothing to do with each other.
This diff removes all import_module declarations from the packages,
and replaces them with import_module declarations in the modules that need
them. This includes only a SUBSET of their child modules and of the non-child
modules that import them.
compiler/*.m:
Module qualify the end_module declarations. In some cases, add them.
compiler/table_gen.m:
Remove an unused predicate, and inline another in the only place
where it is used.
compiler/add_pragma.m:
Give some predicates more meaningful names.
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: 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.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.
Estimated hours taken: 2
Branches: main
compiler/*ctgc*.m:
compiler/structure_sharing*.m:
Further cleanups, mostly renaming predicates with ambiguous names,
and turning some lambda expressions into named predicates.
Estimated hours taken: 1.5
Branches main.
Clean up (some of) the formatting of the recently committed CTGC modules so
that they conform more closely to our coding standards. I made these changes
while reviewing these modules (I'll post the actual review comments
separately). There are no changes to any algorithms.
compiler/ctgc.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.fixpoint_table.m:
compiler/ctgc.selector.m:
compiler/ctgc.util.m:
compiler/prog_ctgc.m:
compiler/prog_data.m:
compiler/structure_sharing.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
Use four-space indentation in all of these modules.
Fix inconsistent indentation.
Use state variables in more places.
Use switches in preference to if-then-elses.
Use procedures from the sv* modules where appropriate.
s/io__state/io/
Remove unnecessary module qualification.
Lots of other minor formatting changes.
Estimated hours taken: 120
Branches: main
Implementation of the structure sharing analysis (part of the CTGC system).
compiler/ctgc.datastruct.m:
(new file) Manipulation of a datastruct (defined in prog_data.m)
compiler/ctgc.selector.m:
(new file) Manipulation of a selector (defined in prog_data.m)
compiler/ctgc.fixpoint_table.m:
(new file) Definition of a generic fixpoint table to be used by the
structure sharing analysis framework as well as the structure reuse
part.
compiler/ctgc.util.m:
(new file) General operations valid for both structure sharing
analysis as structure reuse analysis.
compiler/ctgc.m:
Included additional modules.
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/structure_sharing.m:
Structure sharing analysis and domain.
compiler/add_pragma.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
compiler/prog_item.m:
compiler/recompilation.version.m:
compiler/trans_opt.m:
Added structure_sharing pragma and ways to handle it.
compiler/handle_options.m:
- Structure sharing analysis implies transitive optimization.
- Added character "S" to be used to dump structure sharing related
information in the hlds_dump-files.
compiler/hlds_out.m:
Dump structure sharing information.
compiler/hlds_pred.m:
Store structure sharing information in proc_info.
compiler/mercury_compile.m:
Perform structure sharing when creating .opt, .trans-opt files, and
when compiling to c.
compiler/options.m:
New options: structure-sharing and structure-sharing-widening.
compiler/parse_tree.m:
compiler/prog_ctgc.m:
(new file) This module contains printing/parsing and renaming
routines for handling the public representation used for
structure sharing information.
compiler/prog_data.m:
Public representation for structure sharing information.
Estimated hours taken: 1
Branches: main
Preparing the field for adding CTGC into the compiler by starting to add the
structure sharing analysis.
compiler/mercury_compile.m:
compiler/options.m:
compiler/transform_hlds.m:
Add structure sharing analysis as a new pass of the mercury compiler.
compiler/ctgc.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.m:
New files.