mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
master
83 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
85876a9ecc |
Split equiv_type.m into two parts.
The old equiv_type.m's growth was organic, not planned. It mixed predicates
operating on different levels, and even predicates on the same level
were not always logically organized.
compiler/equiv_type_parse_tree.m:
This module contains the bulk of the old equiv_type.m, the part
concerned with processing parse tree items and their major components.
compiler/equiv_type.m:
The part of the old equiv_type.m that deals with expanding equivalences
inside basic parts of program representations.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/decide_type_repn.m:
compiler/mercury_compile_make_hlds.m:
Conform to the changes above.
|
||
|
|
b024b5f533 |
Carve build_eqv_maps.m out of equiv_type.m.
compiler/build_eqv_maps.m:
compiler/equiv_type.m:
As above.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/decide_type_repn.m:
compiler/equiv_type_hlds.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile_make_hlds.m:
compiler/qual_info.m:
Conform to the changes above.
|
||
|
|
d5ed3079de |
Carve type_inst_mode_map.m out of convert_parse_tree.m.
compiler/convert_parse_tree.m:
compiler/type_inst_mode_map.m:
As above.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add the new module to the parse_tree package, and document it.
compiler/comp_unit_interface.m:
compiler/recompilation.version.m:
Conform to the changes above.
|
||
|
|
1e425c5baf |
Move modules to the packages' implementation sections.
compiler/check_hlds.m:
compiler/ll_backend.m:
compiler/ml_backend.m:
compiler/parse_tree.m:
compiler/top_level.m:
compiler/transform_hlds.m:
Before this diff, these packages had no implementation sections;
they included every submodule in their interface. Fix this by
moving to their implementation sections all modules that are
not needed in the interface section.
The other packages have either had properly-populated implementation
sections already, or truly need to export all their submodules.
compiler/backend_libs.m:
Conform to our usual programming style.
|
||
|
|
fce9f97ae5 | Rename generate_dep_d_files.m to d_file_deps.m. | ||
|
|
8aaa0a958f |
Carve two new modules out of item_util.m.
compiler/convert_import_use.m:
New module for converting to and from checked representations
of import_module and use_module declarations.
compiler/convert_include.m:
New module for converting to and from checked representations
of include_module declarations.
compiler/item_util.m:
Delete the moved code.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/check_import_accessibility.m:
compiler/comp_unit_interface.m:
compiler/convert_parse_tree.m:
compiler/grab_modules.m:
compiler/make_hlds_separate_items.m:
compiler/parse_module.m:
compiler/parse_tree_out.m:
compiler/unused_imports.m:
Conform to the changes above.
|
||
|
|
ba31ed494b |
Update and fix copyright notices.
compiler/*.m:
As above.
|
||
|
|
79bfb1247f |
Carve prog_parse_tree.m out of prog_item.m.
compiler/prog_item.m:
compiler/prog_parse_tree.m:
Split prog_item.m into two modules, with the new module prog_parse_tree.m
containing the definitions of the file-kind-specific parse trees,
and prog_item.m continuing to contain the definitions of the items
that occur in those parse trees. Specialize the top-of-module comment
to the current contents of each module.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/*.m:
Conform to the changes above.
|
||
|
|
276f94071f |
Carve two modules out of generate_dep_d_files.m.
compiler/output_imports_graph.m:
compiler/warn_unread_modules.m:
The two new modules, which each do just one job.
compiler/parse_tree.m:
compiler/generate_dep_d_files.m:
compiler/notes/compiler_design.html:
Include, import and document the new modules.
|
||
|
|
50459653ff |
Carve parse_goal_util.m out of parse_goal.m.
compiler/parse_goal.m:
compiler/parse_goal_util.m:
As above. This improves the cohesion of parse_goal.m.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add the new module to the parse_tree package, and document it.
compiler/parse_dcg_goal.m:
Conform to the change above.
|
||
|
|
b187e2d096 |
Carve opt_deps_spec.m out of generate_dep_d_files.m.
compiler/opt_deps_spec.m:
This new module contains the parts of the old generate_dep_d_files.m
that deal mainly with dependencies involving .trans_opt files, with
a few parts dealing with .opt files.
compiler/generate_dep_d_files.m:
Delete the code moved to the new module.
Eliminate a totally unnecessary use of higher order code.
compiler/parse_tree.m:
Add the new module to this package.
compiler/notes/compiler_design.html:
Document the new module.
|
||
|
|
116caa6225 |
Carve two new modules out of write_deps_file.m.
compiler/generate_mmakefile_fragments.m:
New module containing the parts of the old write_deps_file.m that
construct the mmakefile fragments that go into .d, .dv and .dep files.
compiler/make_module_file_names.m:
New module containing the parts of the old write_deps_file.m that
construct the filenames that go into those mmakefile fragments,
including the caching algorithm.
compiler/write_deps_file.m:
Delete the parts moved to the new modules.
compiler/parse_tree.m:
Include the new modules in this package.
compiler/notes/compiler_design.html
Document the new modules.
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
Conform to the changes above.
|
||
|
|
4d0ce5c35a |
Carve parse_tree_out_item.m out of parse_tree_out.m.
compiler/parse_tree_out.m:
compiler/parse_tree_out_item.m:
Move the parts of the old parse_tree_out.m that deal with the output
of individual items, or item components, to the new module
parse_tree_out_item.m.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add and document the new module.
compiler/comp_unit_interface.m:
compiler/hlds_out_type_table.m:
compiler/hlds_out_typeclass_table.m:
compiler/intermod.m:
compiler/intermod_analysis.m:
Import the new module instead of the old.
compiler/indent.m:
compiler/mlds_to_target_util.m:
compiler/parse_tree_out_misc.m:
Sort imports.
|
||
|
|
ebf770719b |
Carve parse_tree_output.m from parse_tree_out_info.m.
compiler/parse_tree_out_info.m:
compiler/parse_tree_output.m:
Move the parts of the parse_tree_out_info.m that define the pt_output
type class, its instances, and the methods of those instances, to the
new module parse_tree_output.m. Both new modules have better cohesion
than the one original module.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add and document the new module.
compiler/hlds_out_pred.m:
Simplify some related code.
compiler/hlds_out_goal.m:
compiler/hlds_out_mode.m:
compiler/layout_out.m:
compiler/llds_out_file.m:
compiler/lp_rational.m:
compiler/mlds_to_c_stmt.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_cs_stmt.m:
compiler/mlds_to_java_export.m:
compiler/mlds_to_java_func.m:
compiler/mlds_to_java_stmt.m:
compiler/opt_debug.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_clause.m:
compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_out_misc.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_tree_out_pred_decl.m:
compiler/parse_tree_out_sym_name.m:
compiler/parse_tree_out_term.m:
compiler/parse_tree_out_type.m:
compiler/parse_tree_out_type_repn.m:
compiler/prog_ctgc.m:
compiler/rtti_out.m:
Import parse_tree_out.m as well as, or instead of, parse_tree_out_info.m.
|
||
|
|
625ec287f1 |
Carve five new modules out of prog_type.m.
compiler/prog_type_construct.m:
New module for constructing types.
compiler/prog_type_repn.m:
New module for testing things related to type representation.
compiler/prog_type_scan.m:
New module for gather type vars in types.
compiler/prog_type_test.m:
New module containing simple tests on types.
compiler/prog_type_unify.m:
New module for testing whether two types unify, or whether
one type subsumes another.
compiler/prog_type.m:
Delete the code moved to the new modules.
compiler/parse_tree.m:
Include the new modules.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/*.m:
Conform to the changes above, by adjusting imports as needed,
and by deleting any explicit module qualifications that
this diff makes obsolete.
|
||
|
|
f369aeeba8 |
Carve check_import_accessibility.m out of grab_modules.m.
The new module is completely independent of the rest of grab_modules.m.
compiler/check_import_accessibility.m:
compiler/grab_modules.m:
As above.
Make some slight changes in predicate names.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new module.
|
||
|
|
67bb8fce33 |
Move uint_emu.m's contents into int_emu.m ...
... as a preliminary for extending the emulation to sized ints and uints.
compiler/int_emu.m:
Move all the emulation operations from uint_emu.m to int_emu.m,
moving each uint operation next to its int equivalent. To make this
possible without naming conflicts, add a distinguishing prefix
to the name of each emulation predicate. (The emulations of each op
for signed and unsigned ints are related though somewhat different,
and both the similarities and differences are easily visible and checkable
when their code is next to each other.)
On the other hand, the emulation code for an operation for e.g.
int/int8/int16/int32/int64 can be *identical* when the number of bits
is a parameter of that code, and the next diff will exploit this fact.
Unify the target_bits_per_int predicate from int_emu.m and the
target_bits_per_uint predicate from uint_emu.m, which had exactly
the same logic, and call it target_word_bits.
compiler/uint_emu.m:
Delete this module.
compiler/libs.m:
Delete both int_emu.m and uint_emu as a submodule of this package.
compiler/parse_tree.m:
Move int_emu.m to become a submodule of this package, to allow the next
change to it to use the some_int_const type in prog_data.m.
compiler/notes/compiler_design.html:
Generalize the description of int_emu.m. Note that the description
of uint_emu.m cannot be deleted, because it didn't exist :-(
compiler/const_prop.m:
compiler/simplify_goal_call.m:
Conform to the changes above.
|
||
|
|
b6178ef723 |
Delete prog_out.m, moving its code to other modules.
compiler/parse_tree_out_cons_id.m:
Move the predicates and functions in prog_out.m that deal with cons_ids
to this module.
compiler/parse_tree_out_sym_name.m:
Move the predicates and functions in prog_out.m that deal with sym_names
and similar entities to this module.
compiler/parse_tree_out_type.m:
Move the predicates and functions in prog_out.m that deal with types
to this module.
compiler/parse_tree_out_misc.m:
Move the predicates and functions in prog_out.m that deal with simple
types to this module.
Delete mercury_output_det and mercury_format_det, replacing all their
uses with calls to mercury_det_to_string.
compiler/prog_out.m:
Delete this module.
compiler/parse_tree.m:
Delete prog_out from the parse_tree package.
compiler/Mercury.options:
compiler/notes/compiler_design.html:
Delete references to prog_out.m.
compiler/*.m:
Update imports and any explicit module qualifications to account
for the moved code.
tools/filter_sort_imports:
Automatically filter out any repeated imports. This can help with
changes like this that redistribute the contents of one module to other
modules. In this case, after a global replacement of prog_out's import
with the import of parse_tree_out_misc, this updated script could
remove this changed import from modules that already imported
parse_tree_out_misc.
|
||
|
|
e2a8a8cbfa |
Break up mercury_to_mercury.m.
compiler/mercury_to_mercury.m:
Delete this module, and replace it with ...
compiler/parse_tree_out_cons_id.m:
compiler/parse_tree_out_sym_name.m:
compiler/parse_tree_out_type.m:
compiler/parse_tree_out_misc.m:
... these four modules. The first three write out the entities
in their names: cons_ids, sym_names, and types. The fourth contains
the rest of the old mercury_to_mercury.m, plus a few predicates
moved there from prog_out.m that deal with indentation.
compiler/parse_tree.m:
Include the four new modules, and stop including the deleted module.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/prog_out.m:
Delete the code moved to parse_tree_out_misc.m.
compiler/*.m:
Adjust the imports as needed. Most modules need only one, maybe two
of mercury_to_mercury's four successor modules.
|
||
|
|
307b1dc148 |
Split up error_util.m into five modules.
compiler/error_spec.m:
This new module contains the part of the old error_util.m that defines
the error_spec type, and some functions that can help construct pieces
of error_specs. Most modules of the compiler that deal with errors
will need to import only this part of the old error_util.m.
This change also renames the format_component type to format_piece,
which matches our long-standing naming convention for variables containing
(lists of) values of this type.
compiler/write_error_spec.m:
This new module contains the part of the old error_util.m that
writes out error specs, and converts them to strings.
This diff marks as obsolete the versions of predicates that
write out error specs to the current output stream, without
*explicitly* specifying the intended stream.
compiler/error_sort.m:
This new module contains the part of the old error_util.m that
sorts lists of error specs and error msgs.
compiler/error_type_util.m:
This new module contains the part of the old error_util.m that
convert types to format_pieces that generate readable output.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/error_util.m:
The code remaining in the original error_util.m consists of
general utility predicates and functions that don't fit into
any of the modules above.
Delete an unneeded pair of I/O states from the argument list
of a predicate.
compiler/file_util.m:
Move the unable_to_open_file predicate here from error_util.m,
since it belongs here. Mark another predicate that writes
to the current output stream as obsolete.
compiler/hlds_error_util.m:
Mark two predicates that wrote out error_spec to the current output
stream as obsolete, and add versions that take an explicit output stream.
compiler/Mercury.options:
Compile the modules that call the newly obsoleted predicates
with --no-warn-obsolete, for the time being.
compiler/*.m:
Conform to the changes above, mostly by updating import_module
declarations, and renaming format_component to format_piece.
|
||
|
|
f7355f708b |
Move var_db and var_{name,type}_source to var_db.m.
In the process, restrict the use of these types to just those modules
that need to provide services both other modules that use var_tables,
and modules that do not. The latter are modules that either can,
or always do, execute before var_tables are set up.
In some cases, code that previously operated on e.g. var_name_sources
had all its callers converted to use var_tables. In those cases, replace
the use of var_name_sources with var_tables directly.
In other cases, code that previously operated on e.g. var_name_sources
still has some callers that use varsets. In those cases,
- provide versions using var_tables if most callers use var_tables,
renaming predicates/functions to make this the version seem the default,
- leave the operation to work on var_name_sources if some its callers
also have only var_name_sources,
- if there are no such callers, keep just the two versions operating
on varsets and var_tables respectively.
compiler/var_db.m:
compiler/var_table.m:
Move the part of var_table.m that contains the definitions
of the above three types, and the operations on them, to the
new module var_db.m. Only 25 modules currently need var_db.m,
compared to 176 for var_table.m.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add and document the new module.
compiler/parse_tree_out_term.m:
Add a "_vs" suffix to the names of operations that print variables
or terms using varsets, and reuse their old names for versions
that use var_table arguments. For the operations that need var_name_source
versions, make it just select between the varset and var_table versions.
compiler/hlds_out_goal.m:
compiler/instmap.m:
compiler/hlds_out_mode.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/pd_info.m:
Change some predicates that used to operate on var_{name,type}_sources
to operate on var_tables.
In hlds_out_mode.m, delete some unused predicates, and stop exporting
a predicate whose only caller is local.
compiler/*.m:
Conform to the changes above.
|
||
|
|
08365979d0 |
Move pred_name.m to the HLDS package.
This is so that it can become the home of the type currently named
pred_origin in hlds_pred.m, which (after being given new name) will become
a structured representation of predicate names.
The only thing that kept pred_name.m in the parse_tree package was the fact
that parse_pragma.m, which has no access to the hlds package, called it
to create the name of a type-specialized predicate when parsing
type_spec pragmas. The main part of this diff, apart from the trivial
updates to import hlds.pred_name instead parse_tree.pred_name, deals
with this issue.
The problem is how to ensure that the compiler invocations that create
type-specialized predicates (invocations that compile the module containing
the type_spec pragma that calls for this) and the invocations that create
the calls to those predicates (invocations that mostly compile other modules)
agree on the name of the name of the type-specialized predicate.
The old approach was this.
When reading in (say) mod1.m which contains a type_spec pragma,
we construct the name of the type-specialized predicate from
- the name of the module (mod1),
- the name of the predicate to be specialized, and
- the type substitution in the pragma.
We then record this name in the pragma.
If the compiler invocation generates code, we use this name in the
predicate definition. If the compiler invocation creates a .int file,
we record the name in the third argument of the type_spec pragma.
This third argument is NOT allowed to exist in .m files.
Other compiler invocations that read in mod1.int when compiling
another module, e.g. mod2.m, use the specialized name in the third argument
of the type_spec pragma as the name to use in calls.
In this approach, the single-source-of-truth about the name of the
type-specialized predicate is the name constructed when parsing mod1.m,
which is conveyed to compiler invocations on other modules through
the third argument of the type_spec pragma.
The new approach is this:
When reading in (say) mod1.m which contains a type_spec pragma,
we give guaranteed-to-be-unique names to all the anonymous variables
in the type_spec pragma. We also record in the type_spec pragma
the name of the module whose (source or interface) file we read
the pragma from. The name of the predicate to be specialized
was of course already in the pragma.
If the compiler invocation generates code, we construct the name
of the type-specialized version of the predicate when we add the
all-tvars-are-named type_spec pragma to the HLDS. If the compiler
invocation creates a .int file, we write out the all-tvars-are-named
version of the type_spec pragma. The pragma also contains the predicate
name to be specialized. It does not contain the name of the module,
but we will write out type_spec pragmas from module_x.m *only* to
module_x.int, never to any other .int file, so any readers of
the type_spec pragma from mod1.int will also know the name of the
module that the pragma came from.
Other compiler invocations that read in mod1.int when compiling
another module, e.g. mod2.m, therefore get exactly the same
- module name,
- the name of the predicate to be specialized, and
- the type substitution in the pragma
as the compiler invocations on mod1.m. The module name are the
predicate name are never changed by being written out and then
read back in, and *due to the explicit names given to any formerly
anonymous variables*, the type substitution is changed by this either.
This means that the compiler invocations on mod1.m and mod2.m
give the same parameters to the same function, and therefore they are
guaranteed to get the same string as the name of the type-specialized
version of the predicate.
In this approach, the single-source-of-truth about the name of the
type-specialized predicate is the function constructing that name
and its inputs.
compiler/hlds.m:
compiler/parse_tree.m:
compiler/pred_name.m:
Move pred_name.m from the parse_tree package to the hlds package.
compiler/prog_item.m:
Change the representation of type_spec pragmas to
- delete the name of the specialized predicate, and replace it with
- the name of the module the pragma was read in from.
compiler/parse_pragma.m:
Delete the code for parsing the third argument of type_spec pragmas.
Allow them to exist for a short transition period, but ignore them.
(If we read in files containing them, the result will be a link error
if the type substitution contains anonymous variables. In that case,
a rebuild of the program with all modules compiled using the *same
compiler version* will work.)
Give guaranteed-to-be-unique names to all anonymous type variable
in the type substitution part of the type_spec pragma we construct.
compiler/add_pragma_type_spec.m:
Construct the name of the type-specialized predicate as the type_spec
pragma is added to the HLDS.
compiler/parse_tree_out_pragma.m:
Never write out a type_spec par_loop_control with a third argument.
Delete the var_name_print argument of the predicate that writes out
type_spec pragmas. Instead, *always* use print_name_only.
compiler/options.m:
Add a way of testing whether the installed compiler has this change.
compiler/accumulator.m:
compiler/add_pragma_tabling.m:
compiler/add_special_pred.m:
compiler/base_typeclass_info.m:
compiler/check_typeclass.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/loop_inv.m:
compiler/make_hlds_passes.m:
compiler/name_mangle.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_loop_control.m:
compiler/parse_tree_out.m:
compiler/pd_info.m:
compiler/prog_rep.m:
compiler/ssdebug.m:
compiler/stm_expand.m:
compiler/structure_reuse.versions.m:
compiler/table_gen.m:
compiler/tupling.m:
compiler/untupling.m:
compiler/unused_args.m:
|
||
|
|
ea4f95a7ed |
Use var_tables in lco.m, and when dumping goals.
Since this is the first converted module that dumps out goals when
debugging trace flags are enabled, this required generalizing the code
that does that, to take either varsets or var_tables as a means of
specifying the names of variables. We do this via a new type,
var_name_source, which contains either a varset or a var_table.
Almost all of this diff is there to implement this generalization.
A large part of it affects code in the parse_tree package that we use
to write out the parts of HLDS goals that are defined by types defined
in that package. Since we want to avoid making any part of the parse_tree
package dependent on the hlds package, this required defining the
var_name_source type in the parse_tree package, which in turn requires
var_table.m to be in that same package.
compiler/lco.m:
Convert this module to use var_tables instead of varsets and vartypes.
compiler/var_table.m:
Move this module from the hlds package to the parse_tree package.
To make this, possible, move the parts that required access to the HLDS
to hlds_pred.m, from where it was usually invoked.
Export some utility predicates to allow the moved code to work
in hlds_pred.m without access to the actual definition of the
var_table type.
Define the var_name_source type.
Add some utility functions for use by code writing out variable names.
compiler/hlds_pred.m:
Add the code moved from var_table.m.
compiler/vartypes.m:
Move this module from the hlds package to the parse_tree package,
for symmetry with var_table.m. It did not depend on being in hlds
in any way.
compiler/hlds.m:
compiler/parse_tree.m:
Move vartypes.m and var_table.m from the hlds package
to the parse_tree package.
compiler/hlds_out_goal.m:
Change all the predicates in this module to take a var_name_source
instead of a prog_varset.
Fix some comments.
compiler/hlds_out_util.m:
Change some of the predicates in this module (those called from
hlds_out_goal.m) to take a var_name_source instead of a prog_varset.
compiler/parse_tree_out_term.m:
Provide variants of some existing predicates and functions that take
var_name_sources instead of varsets. The code of the copies
duplicates the logic of the originals, though I hope that this
duplication can be done away with at the end of the transition.
(The best solution would be to use a typeclass with methods
that convert vars to their names, but we would want to ensure
that the compiler can specialize all the affected predicates
and functions to the two instances of this typeclass, which is
something that we cannot do yet. In the meantime, the lack of
any generalization in the old versions preserves their performance.)
tools/sort_imports:
tools/filter_sort_imports:
A new tool that automatically sorts any occurrences of consecutive
":- import_module" declarations in the named files. The sorting is done
in filter_sort_imports; sort_imports loops over the named files.
After automatically replacing all occurrences of hlds.{vartypes,var_table}
in import_module declarations with their parse_tree versions, the updated
import_module declarations were usually out of order with respect to
their neighbours. I used this script to fix that, and some earlier
out-of-order imports.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_heap_ops.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_trail_ops.m:
compiler/analysis.m:
compiler/arg_info.m:
compiler/build_mode_constraints.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/check_promise.m:
compiler/closure_analysis.m:
compiler/closure_gen.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/common.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/continuation_info.m:
compiler/convert_parse_tree.m:
compiler/coverage_profiling.m:
compiler/cse_detection.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
compiler/dead_proc_elim.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/direct_arg_in_out.m:
compiler/disj_gen.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/exception_analysis.m:
compiler/file_names.m:
compiler/float_regs.m:
compiler/follow_vars.m:
compiler/format_call.m:
compiler/generate_dep_d_files.m:
compiler/get_dependencies.m:
compiler/goal_expr_to_goal.m:
compiler/goal_mode.m:
compiler/goal_path.m:
compiler/goal_store.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_clauses.m:
compiler/hlds_code_util.m:
compiler/hlds_error_util.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/hlds_out_pred.m:
compiler/hlds_rtti.m:
compiler/hlds_statistics.m:
compiler/inlining.m:
compiler/inst_check.m:
compiler/inst_test.m:
compiler/inst_user.m:
compiler/instance_method_clauses.m:
compiler/instmap.m:
compiler/intermod.m:
compiler/intermod_analysis.m:
compiler/interval.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/item_util.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/llds.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_util.m:
compiler/lookup_switch.m:
compiler/loop_inv.m:
compiler/make.module_target.m:
compiler/make.util.m:
compiler/make_goal.m:
compiler/make_hlds_separate_items.m:
compiler/make_hlds_types.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/middle_rec.m:
compiler/ml_accurate_gc.m:
compiler/ml_args_util.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_commit_gen.m:
compiler/ml_disj_gen.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_proc_gen.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_unify_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/ml_unify_gen_deconstruct.m:
compiler/ml_unify_gen_test.m:
compiler/ml_unify_gen_util.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_func.m:
compiler/mlds_to_c_global.m:
compiler/mlds_to_cs_class.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_data.m:
compiler/mlds_to_java_file.m:
compiler/mlds_to_java_stmt.m:
compiler/mlds_to_java_type.m:
compiler/mmc_analysis.m:
compiler/mode_comparison.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_ordering.m:
compiler/modecheck_call.m:
compiler/modecheck_coerce.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/opt_debug.m:
compiler/optimize.m:
compiler/options_file.m:
compiler/ordering_mode_constraints.m:
compiler/par_loop_control.m:
compiler/parse_item.m:
compiler/parse_string_format.m:
compiler/parse_tree_out_inst.m:
compiler/parse_tree_to_term.m:
compiler/parse_util.m:
compiler/pd_debug.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/peephole.m:
compiler/polymorphism.m:
compiler/polymorphism_info.m:
compiler/polymorphism_lambda.m:
compiler/polymorphism_type_class_info.m:
compiler/polymorphism_type_info.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/pred_name.m:
compiler/pred_table.m:
compiler/prog_item.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/push_goals_together.m:
compiler/qual_info.m:
compiler/quantification.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.points_to_graph.m:
compiler/rbmm.points_to_info.m:
compiler/rbmm.region_resurrection_renaming.m:
compiler/rbmm.region_transformation.m:
compiler/recompilation.used_file.m:
compiler/recompilation.version.m:
compiler/recompute_instmap_deltas.m:
compiler/resolve_unify_functor.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/set_of_var.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_scope.m:
compiler/simplify_goal_switch.m:
compiler/simplify_goal_unify.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/smm_common.m:
compiler/ssdebug.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_data.m:
compiler/term_constr_initial.m:
compiler/term_constr_main.m:
compiler/term_constr_main_types.m:
compiler/term_constr_util.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/transform_llds.m:
compiler/try_expand.m:
compiler/tupling.m:
compiler/type_assign.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/typecheck_debug.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_gen_construct.m:
compiler/unify_gen_deconstruct.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/var_locn.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Conform to the changes above.
|
||
|
|
3503128d9b |
Rename module_imports.m to module_baggage.m.
compiler/module_baggage.m:
This reflects the changes to this module over the last year.
compiler/parse_tree.m:
Change the module name in the include_module declaration.
compiler/deps_map.m:
compiler/generate_dep_d_files.m:
compiler/grab_modules.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/mercury_compile_main.m:
compiler/module_dep_info.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.used_file.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
Change the module name in import_module declarations.
compiler/notes/compiler_design.html:
Change the module name in the module description.
|
||
|
|
c99b6777e5 |
Rename check_raw_comp_unit.m to check_module_interface.m.
compiler/check_module_interface.m:
As above. This module has not worked on raw compilation units for a while.
compiler/mercury_compile_main.m:
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Conform to the change above.
|
||
|
|
2eeeddaae0 |
Carve pred_name.m out of prog_util.m.
compiler/pred_name.m:
compiler/prog_util.m:
As above.
compiler/notes/compiler_design.html:
Document the new module.
compiler/accumulator.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/lambda.m:
compiler/loop_inv.m:
compiler/par_loop_control.m:
compiler/parse_pragma.m:
compiler/parse_tree.m:
compiler/pd_info.m:
compiler/structure_reuse.versions.m:
compiler/tupling.m:
compiler/untupling.m:
compiler/unused_args.m:
Conform to the change above.
|
||
|
|
c8725fb4bc |
Carve module_dep_info.m out of module_imports.m.
compiler/module_dep_info.m:
As above. The only change is added documentation.
compiler/parse_tree.m:
Include the new module in the parse_tree package.
compiler/notes/compiler_design.html:
Document the new module, and update the documentation of module_imports.m.
compiler/module_imports.m:
Delete the moved code, put the main data structure at the top,
and add some documentation for it.
compiler/compile_target_code.m:
compiler/generate_dep_d_files.m:
compiler/make.dependencies.m:
compiler/make.make_info.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/module_deps_graph.m:
Import module_dep_info.m, usually instead of module_imports.m,
sometimes beside module_imports.m.
|
||
|
|
22038a5b28 |
Rename check_parse_tree_type_defns.m ...
... to check_type_inst_mode_defns.m.
compiler/parse_tree.m:
Change the name in the include_module declaration.
compiler/comp_unit_interface.m:
compiler/convert_parse_tree.m:
compiler/decide_type_repn.m:
compiler/prog_foreign_enum.m:
compiler/prog_item.m:
Change the name in import_module declarations.
compiler/notes/compiler_design.html:
Change the name in the documentation.
|
||
|
|
6ea29f4f72 |
Factor common code into prog_foreign_enum.m.
compiler/prog_foreign_enum.m:
This new module contains
- code that used to be duplicated in add_foreign_enum.m and
check_parse_tree_type_defns.m, and
- utility predicates called by that common code.
Moving all this code into a new module in the parse_tree package
allows check_parse_tree_type_defns.m which is also in the parse_tree
package, to avoid importing add_foreign_enum.m, which is in the hlds
package.
compiler/parse_tree.m:
Include the new module in the parse_tree package.
compiler/notes/compiler_design.html:
Document the new module.
compiler/add_foreign_enum.m:
compiler/check_parse_tree_type_defns.m:
Delete the code moved to prog_foreign_enum.m.
|
||
|
|
125d437199 |
Break up parse_pragma.m.
It was one of the largest modules in the compiler, and it had low cohesion.
This diff contains no algorithmic changes.
compiler/parse_pragma_analysis.m:
compiler/parse_pragma_foreign.m:
compiler/parse_pragma_tabling.m:
Add these three modules carved out of parse_pragma.m. They handle
- pragmas that record the results of analyses,
- pragmas that deal with foreign languages, and
- tabling pragmas
respectively.
compiler/parse_tree.m:
Include the three new modules.
compiler/notes/compiler_design.html:
Document the three new modules.
compiler/parse_pragma.m:
Delete the code moved to the new modules. Group related predicates
together. Rename a few predicates.
Move the utility predicates that are needed both b parse_pragma.m
and one of the new modules to parse_util.m
compiler/parse_util.m:
Add the modules moved from parse_pragma.m.
Rename some existing predicates to differentiate them from the moves
predicates.
compiler/parse_item.m:
compiler/parse_mutable.m:
compiler/parse_type_repn.m:
Conform to the changes above.
|
||
|
|
9cbe5d2caf |
Put type_repn items for complex types into .int files.
compiler/decide_type_repn.m:
Previously, this module computed type_repn items to put into .int3 files
for a subset of the type constructors defined in the current module:
the direct_dummy, enum and notag types (the *simple* types),
and the du types whose representation is guaranteed to be
a word-aligned pointer when targeting C. (We care about pointers
being word-aligned only when applying the direct arg optimization.
This optimization is applicable only with the low level data
representation, which we use only when targeting C.)
This diff adds code to decide the representations of *all* the
type constructors defined in the current module.
This code is based on the existing code in du_type_layout.m,
which it is intended to eventually replace, but its job is more general,
because it decides the representation of each type not just for
one platform (the one we want to generate code), but for all possible
platforms. This is because we want to put the descriptions of type
representations into the module's .int file to serve as a single source
of truth for all modules that use the types defined in this module,
and the contents of .int files should be platform-independent.
For our purposes, there are six kinds of platforms, which are
distinguished along three axes: 64 vs 32 bit machines, spf vs non-spf
grades, and direct arg optimization enabled vs disabled. That is eight
combinations, but on 64 bit machines, a float takes up one word whether
that float is single or double precision, so two combinations aren't valid.
Some of the change to this module consists of generalizing the existing
code so that it can decide simple types not just when targeting .int3 files
but .int files as well. However, the bulk of it is code for deciding
the representations of non-simple types. The code is not lifted straight
from du_type_layout.m. There are two main kinds of changes.
First, I took the opportunity to simplify the algorithms used.
For example, while du_type_layout.m passes over each function symbol
in the most general kind of type twice: once to assign it a cons_tag,
and once to decide how to pack its arguments, the code here does both jobs
in one pass. Another example is that for historical reasons,
du_type_layout.m computed the amount of space needed for an argument
in one place for sub-word-sized arguments, and in another place
for more-than-word-sized arguments; decide_type_repn.m does it all
in one place.
Second, since we compute a representation for each type six times,
I tried to avoid obvious inefficiencies, but only if the code
remained simple. In the future, we may want to use an approach
based on the idea that in the process of computing the first
representation, we look out for any indication that the representation
may be different on any of the other five platforms, and if not,
we just reuse the first representation on the other five platforms as well.
However, that would be appropriate only *after* we have a simpler
system that has proven to work in practice.
There is a third, smaller change: when deciding whether an argument
is packable, we take into account not just equivalence type
definitions, but the definitions of notag types as well.
This takes advantage of the fact that if a notag type is abstract
exported, its representation is put into the relevant .int3 file
even though its definition isn't. (This is why du_type_layout.m
couldn't "see through" notag types: it couldn't depend on knowing
which types were notags.)
compiler/prog_item.m:
Change the types we use for type representation information.
Their previous definitions baked in the assumption that the only
distinction between platforms that mattered was the 64 vs 32 bit
distinction, which is not the case.
Use a more consistent naming scheme for the types we use
to represent type representation information.
Include the "dereferenced" types of the arguments in functors'
representations. (I use "dereferencing" here to mean expanding
equivalence types and throwing away any notag wrappers.).
We don't need it when generating C code using the low level
data representation, but we do need it to create constructors
when generating e.g. Java code that uses the high level data
representation.
compiler/parse_type_repn.m:
Rewrite most of this module due to the changes in prog_item.m.
compiler/parse_tree_out_type_repn.m:
A new module containing the code for writing out type representations.
The original code used to be in parse_tree_out.m, but it has been
mostly rewritten. Partly this is due the changes in prog_item.m,
but partly it is to provide much more structured output for humans,
since this makes debugging so much easier.
compiler/parse_tree.m:
Add the new module to the parse_tree package.
compiler/parse_tree_out.m:
Delete the code moved to parse_tree_out_type_repn.m.
compiler/parse_tree_out_info.m:
Provide a mechanism for selecting between output for machines
(the default) and output for humans.
compiler/hlds_data.m:
compiler/prog_data.m:
Move the ptag type from hlds_data.m to prog_data.m, to make it
accessible in prog_item.m.
Add some documentation in prog_data.m.
compiler/comp_unit_interface.m:
If the experiment1 option is enabled, invoke decide_type_repn.m
to decide what type_repn items to put into the .int file we are
generating. Otherwise, maintain the status quo.
compiler/write_module_interface_files.m:
Pass the globals to comp_unit_interface.m so it can look up experiment1.
compiler/equiv_type.m:
Add a predicate for expanding equivalence types for use by
decide_type_repn.m. This predicate expands just one type,
but reports any use of circular equivalence types in that type.
Improve the error message for circular equivalence types by *naming*
the type constructors involved. To make this possible, pass around
sets of such type constructors instead of just a boolean saying
*whether* we have found *some* circular equivalence type.
Replace bools used as changed/unchanged flag with a bespoke type.
Standardize some variable names.
compiler/options.m:
Add the developer-only option --pack-everything, which, if set,
tells decide_type_repn.m to turn on all the packing options
that currently work. This is to allow the testing of decide_type_repn.m
in the eventual intended mode of operation, even if the various
allow-packing-... options used by du_type_layout.m are set to "no".
compiler/disj_gen.m:
compiler/equiv_type_hlds.m:
compiler/llds_out_data.m:
compiler/lookup_util.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/mlds_to_c_data.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/tag_switch.m:
Conform to the changes above (mostly the move of ptag to prog_data.m.)
compiler/parse_pragma.m:
Improve indentation.
tests/valid_make_int/test_repn.m:
tests/valid_make_int/test_repn_sub.m:
A fairly comprehensive test case of the new functionality.
test_repn_sub.m defines one ore more simple type constructors
of each possible kind, and test_repn.m uses them to define types
that use each possible kind of complex type representation.
tests/valid_make_int/Mmakefile:
tests/valid_make_int/Mercury.options:
Enable the new test case.
|
||
|
|
c7bc31f2d2 |
Rename convert_interface.m to convert_parse_tree.m.
compiler/convert_interface.m:
As above. I am about to add code to convert optimization files as well.
compiler/parse_tree.m:
Include the module under its new name.
compiler/notes/compiler_design.html:
Document the module under its new name.
compiler/comp_unit_interface.m:
compiler/intermod.m:
compiler/parse_module.m:
Import the module under its new name.
|
||
|
|
9891677bf3 |
Carve convert_interface.m out of prog_item.m.
compiler/convert_interface.m:
compiler/prog_item.m:
As above.
compiler/parse_tree.m:
Include the new module.
compiler/comp_unit_interface.m:
compiler/parse_module.m:
Import the new module.
|
||
|
|
19ef98b66f |
Check the type definitions in a module for consistency ...
... when generating interface files.
compiler/check_parse_tree_type_defns.m:
A new module for doing the checking.
compiler/parse_tree.m:
Add the new module.
compiler/comp_unit_interface.m:
When computing what should go into a .intN file, use the new module
to check for inconsistencies in the source code of the module.
Making the above possible requires retaining some information
(such as contexts in foreign enum definitions, and the presence
of definitions, as opposed to declarations, for some types)
for longer than was needed until now.
Give some predicates more descriptive names.
Move the record_foreign_enum_spec predicate near where it is used.
compiler/write_module_interface_files.m:
If comp_unit_interface.m reports any errors when generating the
would-be contents of an interface file, do NOT create that
interface file.
The errors comp_unit_interface.m and check_parse_tree_type_defns.m
now generate are the kinds of inconsistencies whose resolution requires
everything depending on this module to be recompiled anyway,
so stopping the compilation process *without* producing
the would-be-erroneous interface file should be a net win
almost all the time.
compiler/prog_item.m:
Factor out some commonalities in data structures.
When converting the generic parse_tree_int we get from reading
in a .intN file to the parse tree type specific to that N,
check the definitions we read in for consistency.
As in comp_unit_interface, making the above possible requires
retaining some information for longer than was needed until now.
Never output two or more declarations of the same type_ctor
in the same section of an interface file, since the code
*reading* interface files now reports such redundancies
(but see the change to options.m).
compiler/options.m:
Disable the printing of error messages for problems found in
interface files, since the new code in check_parse_tree_type_defns.m
now finds problems in interface files generated by currently
installed compilers. Specifically, many contain duplicate
declarations for Mercury types. One declaration is written
by the programmer, the other is the type's actual definition
turned into the redundant declaration by the compiler.
compiler/parse_pragma.m:
When parsing foreign enum pragmas, implicitly qualify the
name of the type constructor they are for with the current module name.
This is semantically sound, since foreign_enum pragmas *must* be
for a type constructor defined in the same module. It is desirable
because type_ctors in type definitions are module qualified.
The code of check_parse_tree_type_defns.m needs to process
the type definitions and foreign enums for a type_ctor at the
same time, and doing so would be more needlessly complicated
if the type ctor keys in the "type_ctor to type definitions"
and "type_ctor to foreign enums" maps were incompatible due to
the difference in qualification.
The type_ctor in a foreign enum definition may still be manually
module qualified by programmers; it just happens that any qualification
other than the default is a semantic error.
compiler/module_qual.qual_errors.m:
When printing error messages about undefined type_ctors in
foreign enum definitions, do not print this implicitly
added qualification, since it adds only clutter.
compiler/error_util.m:
Provide a mechanism for printing type_ctors directly,
i.e. without converting them to a sym_name/arity pair.
Put a qual_ prefix in front of top_ctor_of_type, since it
always prints module qualification. (This is to remind people
who may use this component about that qualification.)
Factor out some common code.
compiler/det_analysis.m:
Conform to the change in error_util.m.
compiler/parse_module.m:
Fix too-long lines.
compiler/Mercury.options:
Require some of the modules above to have no dead predicates.
library/erlang_rtti_implementation.m:
library/io.m:
Delete declarations of types that are unneeded because the types
also have definitions.
tests/typeclasses/unqualified_method2.m:
Move an import out of the interface, since we now print the warning
generated for its improper location.
|
||
|
|
7ea66c40e2 |
Rename modules.m to grab_modules.m.
compiler/grab_modules.m:
As above. The new name indicates the module's function
much more clearly.
compiler/parse_tree.m:
Rename the module in its containing package.
compiler/mercury_compile_main.m:
compiler/write_module_interface_files.m:
Conform to the change above.
compiler/notes/compiler_design.html:
Document the change. Put the description of the related modules
into a more logical order.
|
||
|
|
e9430b115a |
Prep for recording simple type representations in .int3 files.
compiler/decide_type_repn.m:
New module for computing the set of type representation items
to put into the interface files of a module. For now, it generates
this information only for .int3 files.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Add the new module to the parse_tree package.
compiler/comp_unit_interface.m:
Invoke the new module to add type representation items to .int3 files
if the experiment option has the right value. Give it the information
it needs to do its job.
compiler/add_foreign_enum.m:
Export a predicate for use by decide_type_repn.m. Maybe eventually
it should be *moved* to decide_type_repn.m.
compiler/hlds_data.m:
compiler/prog_data.m:
Change the representation of lists of constructors in a type
from lists, which can be empty, with one_or_more, which cannot.
This encodes the invariant that a type constructor cannot have
zero data constructors in the structure of the type.
compiler/prog_item.m:
Change the representation of lists of constructors in a type
from lists, which can be empty, with one_or_more, which cannot.
This encodes the invariant that a type constructor cannot have
zero data constructors in the structure of the type.
Include information about assertions in type representation items
about foreign types.
Do not record whether a type whose representation item says its values
are guaranteed to be word aligned is a Mercury type or a foreign type.
We generate such items only for Mercury types; for foreign types,
their assertions will contain that information. We need this separation
because when we generate .int3 files, we don't the backend that we will
eventually generate code for, and thus do not know whether a given
foreign type declaration is in effect on that backend or not.
compiler/parse_tree_out.m:
Fix the printing of type representation items.
compiler/prog_type.m:
Conform to the changes above, and delete an unused predicate.
compiler/parse_type_repn.m:
Factor out some common code.
Fix an old bug about yes/no vs du_repn/no_du_repn.
Conform to the changes above.
compiler/parse_pragma.m:
Export a predicate for parse_type_repn.m.
Note a possible improvement.
Conform to the changes above.
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/check_typeclass.m:
compiler/det_report.m:
compiler/du_type_layout.m:
compiler/equiv_type.m:
compiler/hlds_out_module.m:
compiler/inst_check.m:
compiler/intermod.m:
compiler/mode_util.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out_pragma.m:
compiler/parse_type_defn.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/resolve_unify_functor.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_norm.m:
compiler/type_util.m:
compiler/untupling.m:
compiler/unused_imports.m:
compiler/xml_documentation.m:
Conform to the changes above.
compiler/simplify_goal_ite.m:
Add a comment.
compiler/canonicalize_interface.m:
compiler/get_dependencies.m:
Do not abort when seeing type representation items.
compiler/mmakefiles.m:
Delete a predicate that this diff adds to list.m.
library/list.m:
Add new predicates to convert from one_or_more to list
and vice versa.
NEWS:
Announce the new predicates.
library/bimap.m:
library/map.m:
library/tree234.m:
Expand a comment.
|
||
|
|
bfadeb3653 |
Carve canonicalize_interface.m out of write_module_interface_files.m.
compiler/write_module_interface_files.m:
compiler/canonicalize_interface.m:
As above.
compiler/parse_tree.m:
Include the new module in the parse_tree package (which also contains
write_module_interface_files.m).
compiler/notes/compiler_design.html:
Document the new module.
|
||
|
|
fb97df69ed |
Make "compute type representations" a separate pass.
The ultimate purpose of this diff is to prepare for future improvements
in type representations, allowing values of some data types to be represented
more compactly than up to now.
The main way this diff does that is by creating a separate pass for deciding
how values of each type should be represented. We have traditionally decided
data representations for each type as its type definition was processed
during the make_hlds pass, but these decisions were always tentative,
and could be overridden later, e.g. when we processed foreign_type or
foreign_enum pragmas for the type. This dispersed decision making algorithm
is hard to understand, and therefore to change.
This diff centralizes decisions about type representations in a separate
pass that does nothing else. It leaves the algorithm distributed among
several files (du_type_layout.m, make_tags.m, and add_foreign_enum.m) for now,
to make reviewing this diff easier, but soon after it is committed I intend
to move all the relevant code to du_type_layout.m, to centralize the decision
code in "space" as well as in time.
For the reason why this pass runs before any of the semantic analysis
passes, instead of after all of them as I originally intended and as we
discussed on m-dev in late october 2017, see the big comment at the start of
du_type_layout.m.
As per another part of that same discussion on m-dev, this diff
makes a start on implementing a new type of item, the type_repn item,
which is intended *only* to be used in compiler-generated interface files,
*not* in source files. It is only a start because we can use these items
only *after* the creation of a separate type representation decision pass,
and this diff is already very big. The code for making the compiler understand
these items will be added later. The code for generating them will be added
later still, once the code for understanding them has been installed on
all our systems.
Since I was going to be working on the affected code anyway, this diff
also carries out two other decisions that came out of that discussion:
- the deletion of the ability to reserve a tag in a type for HAL,
either via a compiler option or via a pragma, and
- the deletion of the ability to represent a functor using the address
of a statically allocated object (which we haven't used and won't use,
because it slows down accesses to *all the other functors* of the type).
compiler/mercury_compile_front_end.m:
Invoke the new pass for making decisions about type representations
after the make_hlds pass. (We used to do only the final part of it then.)
Fix a bad dump stage name.
Add an extra check for what it means for a module to be error free.
Make a sub-switch explicit.
compiler/hlds.m:
compiler/make_hlds.m:
Move the modules that implement the new pass from the make_hlds package
to the hlds package, to give the compiler's top level access to them.
Make the same move for the modules that the new pass's modules need.
Since they are now part of hlds, they cannot reach into make_hlds,
and I think this is a cleaner solution than forwarding predicates.
Delete some forwarding predicates that are no longer needed.
compiler/notes/compiler_design.html:
Document the updated location of the moved modules.
Add an XXX to note a place where the documentation has not been
updated in the past.
compiler/du_type_layout.m:
Add code to implement the new pass.
Keep the algorithm for deciding type representations as close
to the previously used algorithm as possible, since this diff
is already big enough. (The previous algorithm was scattered across
add_type.m, add_foreign_enum.m, and make_hlds_passes.m.)
Simplifications and optimizations will come later, after this module
is merged with make_tags.m and with (at least) the foreign_enum half of
add_foreign_enum.m.
compiler/make_tags.m:
Keep the functionality of this module, which does both the first part
of deciding type representations (tentatively assigning tags to functors,
an assignment that may be overridden later), and the last part (packing
multiple adjacent less-than-word-sized enum args into a single word,
if possible.), but simplify it where possible, and note possibilities
for further improvements.
compiler/add_foreign_enum.m:
This module has two halves, one dealing with foreign_enum pragmas
and one dealing with foreign_export_enum pragmas.
Change the half that deals with foreign_enum pragmas to just build
a data structure that du_type_layout.m will need to make its decisions,
this structure being a map from type_ctors to the foreign enum
specification applicable to the current target language. Include
in this structure a component that add_foreign_enum.m itself can use
to report better error messages for duplicate foreign_enum pragmas;
this component records, for each type_ctor and language, the context
of the previous foreign_enum pragma for that combo.
Change the input for the half that deals with foreign_export_enum pragmas
to reflect the fact that it is invoked by du_type_layout.m after all
decisions about type representations have already been made.
compiler/add_special_pred.m:
Move this module from the make_hlds package to the hlds package,
since the code that adds special preds for type is now called from
du_type_layout.m.
Change the names of predicates to make clear whether they add
only the declaration of a predicate, only its definition, or both.
Don't try to pre-guess whether the implementation of a type's
compare predicate will need an index predicate. Let the code
that generates calls to the index predicate both declare and define
the index predicate. This change removes the potential for
inconsistencies between the two pieces of code.
compiler/add_pred.m:
Move this module from the make_hlds package to the hlds package,
since add_special_pred.m needs access to it.
compiler/add_type.m:
When adding a type definition to the HLDS, don't try to decide
its representation. Any such decision was tentative anyway, due
to the possibility of e.g. the later processing of foreign_type
or foreign_enum pragmas for the type. Likewise, don't try to
create the special (unify, compare) predicates for the type.
Leave both tasks to the du_type_layout pass.
Likewise, don't try to pack the representation of types, or record
no_tag types in the table of no_tag types, during the post-processing
pass either; leave both of these to du_type_layout as well.
Rename the predicate that post_processes type definitions to reflect
the two tasks left for it to do.
compiler/prog_data.m:
Do not store width information about the arguments of those data
constructors in the parse tree. That information is not computed
until later; until then, it was always filled in with dummy values.
(But see hlds_data.m below.)
Use bespoke types to represent the presence or absence of user-specified
unify and compare predicates.
Change the representation of data constructors to use a single "maybe"
type, not two lists, to denote the presence or absence of existentially
typed arguments.
Give the HLDS the ability to hold representation information about
abstract types that in the future we will get from type_repn items
in the defining modules' interface files.
Delete the uses_reserved_tag type, since we never use reserved tags
anymore.
compiler/prog_item.m:
Add the new type_repn item type, which is not used yet.
Delete the reserve_tag pragma.
Fix an earlier mistake in the wording of a context message.
compiler/hlds_data.m:
Put all the fields of hlds_du_type (the type definition variant dealing
with discriminated union types) that deal with type representation
issues in a single "maybe" field that is set to "no" before the
type representation decision pass has been run.
Add new type, constructor_repn, that stores the same information as the old
constructor type (defined in prog_data.m), PLUS the information
describing how terms with that data constructor are stored.
Likewise, add a new type ctor_arg_rep, which likewise stores
the widths of each constructor argument. When we implement
argument reordering, we would store the offset of the arg as well.
Since the parse tree representations of constructors and their arguments
don't store representation information anymore, the cons_table they
are stored in doesn't either. Make the lookup of representation information
for a given constructor possible by adding a map to the new "maybe" field
of hlds_du_type.
Provide some utility predicates.
Optimize some existing predicates.
Rename some types to better reflect their meaning.
compiler/hlds_module.m:
Provide a slot in the module_info for storing the information
gathered by make_hlds.m that is needed by the new pass.
compiler/make_hlds_separate_items.m:
When we see either a foreign_enum or a foreign_export_enum pragma,
return values of a bespoke type for them (a type defined in
hlds_module.m), instead of an item_pragma. This makes handling them
considerably easier.
compiler/make_hlds_passes.m:
With the changes in this diff, adding a type to the HLDS won't
decide its representation. Therefore delete the code that used
to loop over foreign_export_enum pragmas; in the absence of
the final type representation information, it won't work right.
Record the information that the du_type_layout pass will need
in the module_info.
compiler/add_pragma.m:
Delete the code for passing on foreign_enum and foreign_export_enum
pragmas to add_foreign_enum.m; they are now passed to add_foreign_enum.m
by du_type_layout.m.
Move a utility predicate to make_hlds_error.m, to allow add_foreign_enum.m
to call it.
compiler/make_hlds_error.m:
Add the utility predicate moved from add_pragma.m.
Move the module from the make_hlds to the hlds package.
compiler/module_qual.m:
Provide a mechanism for recording error messages about e.g. undefined
types without recording that we found an undefined type. This sounds
strange, but there is a valid use case.
When a type definition declares a functor's argument to be of an
undefined type, that error is usually fatal; we stop the compiler
from proceeding even to typechecking, since the typechecker will
probably abort with a map lookup failure. Most other references
to undefined types are similarly fatal for the same reason. However,
if e.g. a foreign_export_enum pragma refers to an undefined type,
that error *won't* be visible to the typechecker, and therefore
won't crash it. The error will still cause the compiler to exit
without generating any target language code, but at least it will be
able to run the typechecker and other semantic analysis passes.
Without this change, the compiler will report only one error in
the ee_invalid.m test case; with it, it reports *every* error
in the test case expected output.
compiler/module_qual.qualify_items.m:
Use the capability describe above for undefined types in
foreign_export_enum pragmas.
compiler/module_qual.qual_errors.m:
Delete a (somewhat incorrect) copy of a predicate in prog_item.m,
to reduce code duplication.
compiler/prog_type.m:
Add ways to represent abstract types whose representations are nevertheless
known (from type_repn items in the defining modules' interface files)
to be notag or dummy types. This will be needed to fix Mantis bug #441,
a fix that will probably be one of the first later changes to build
on this diff.
Delete a type moved to type_util.m.
compiler/type_util.m:
Provide extra versions of some predicates, with the difference between
the old and the new versions being that one requires type representations
to have been decided already, and the other one does not.
Move the definition of the ctor_defn type here from prog_type.m,
since prog_type.m itself does not use it, but type_util.m does.
Give some predicates more meaningful names.
compiler/parse_type_defn.m:
Simplify the code for parsing type definitions, to make it easier
to reuse to parse type_repn items.
Add a sanity check that requires existential constraints to have
*some* existential variables to apply to.
Allow "type_is_representable_in_n_bits" as a synonym for
"type_is_abstract_enum", since in the future we want to be able to pack
e.g. multiple int8s, not just multiple enums, into a single word.
Generate more specific error messages for some classes of malformed input.
compiler/parse_type_repn.m:
New module to parse type_repn items.
compiler/polymorphism.m:
Make some predicates that operate on type constructors take
the type constructors themselves as input arguments, not a whole type
*using* that type constructor. Put the arguments of those predicates
in a more standard order.
Note that some predicates don't belong in this module.
compiler/special_pred.m:
Make the code that decides whether a special predicate for a type
constructor can be defined lazily avoid using type representation
information. (Actually, we now make decisions about lazy vs eager
definitions after type representation is available, but that was
not so in an earlier version of this change, and the new code
is more robust.)
compiler/unify_proc.m:
When we decide to generate code for a compare predicate that needs
the type to have an index predicate, don't presume that the index
predicate has already been declared and defined; instead, declare
and define it then and there. (Index predicates are *never* called
from anywhere else.)
Pack the information needed to define a special predicate
into a single structure, to simplify the above.
Since the creation of a clause for a compare predicate may now require
the declaration and definition of an index predicate, the module_info
field of the unify_proc_info is now a writeable field.
Give some predicates and function symbols more meaningful names.
Note some problems with the existing code.
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_mode.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_solver.m:
compiler/check_typeclass.m:
compiler/code_info.m:
compiler/comp_unit_interface.m:
compiler/ctgc.selector.m:
compiler/ctgc.util.m:
compiler/default_func_mode.m:
compiler/det_report.m:
compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/erl_code_gen.m:
compiler/export.m:
compiler/foreign.m:
compiler/get_dependencies.m:
compiler/goal_expr_to_goal.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_out_module.m:
compiler/inst_check.m:
compiler/inst_test.m:
compiler/inst_util.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/make_hlds_warn.m:
compiler/ml_accurate_gc.m:
compiler/ml_simplify_switch.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/mode_util.m:
compiler/modecheck_goal.m:
compiler/module_qual.collect_mq_info.m:
compiler/modules.m:
compiler/parse_item.m:
compiler/parse_pragma.m:
compiler/parse_tree.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_pragma.m:
compiler/post_term_analysis.m:
compiler/proc_requests.m:
compiler/prog_item_stats.m:
compiler/qual_info.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/resolve_unify_functor.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/simplify_goal_ite.m:
compiler/stack_opt.m:
compiler/state_var.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/superhomogeneous.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_constr_build.m:
compiler/term_norm.m:
compiler/trailing_analysis.m:
compiler/type_constraints.m:
compiler/type_ctor_info.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/untupling.m:
compiler/unused_imports.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the changes above.
tests/invalid/Mmakefile:
Disable the reserve_tag test case, as it is not applicable anymore.
tests/invalid/exported_foreign_enum.{m,err_exp}:
tests/invalid/pragma_qual_error.{m,err_exp}:
Delete reserve_tag pragmas from these test cases, and its effects
from the expected outputs.
tests/invalid/bad_foreign_type.err_exp:
tests/invalid/bigtest.err_exp:
tests/invalid/foreign_enum_invalid.err_exp:
tests/invalid/type_lhs_var.err_exp:
tests/invalid/uu_type.err_exp:
tests/invalid/where_abstract_enum.err_exp:
tests/invalid/where_direct_arg.err_exp:
Expect the updated messages for some errors.
tests/valid/Mmake.valid.common:
tests/valid/Mmakefile:
Disable any reserve_tag test cases, as they are not applicable anymore.
|
||
|
|
4ebc3ffa04 |
Carve four modules out of prog_data.m.
The prog_data.m module is imported by most modules of the compiler; by
359 modules out of 488, to be exact. Yet it has many parts that most of
those 359 modules don't need. This diff puts those parts into four new
modules. The number of imports of these modules:
348 modules import prog_data.m
84 modules import prog_data_foreign.m
62 modules import prog_data_pragma.m
12 modules import prog_data_event.m
5 modules import prog_data_used_modules.m
compiler/prog_data_event.m:
compiler/prog_data_foreign.m:
compiler/prog_data_pragma.m:
compiler/prog_data_used_modules.m:
New modules. They contain the parts of the parse tree that deal
respectively with the specification of events and event sets,
interfacing to foreign languages, pragmas, and the sets of used
(i.e. not unused) modules.
compiler/prog_data.m:
Delete the stuff that is now in the new modules. Put the remaining parts
of the module into a logical order.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/globals.m:
Move a type here from prog_data.m, since this is where it belongs.
compiler/add_foreign_proc.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/call_gen.m:
compiler/code_gen.m:
compiler/code_loc_dep.m:
compiler/comp_unit_interface.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/continuation_info.m:
compiler/coverage_profiling.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.livedata.m:
compiler/ctgc.selector.m:
compiler/deep_profiling.m:
compiler/dep_par_conj.m:
compiler/deps_map.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/elds_to_erlang.m:
compiler/equiv_type.m:
compiler/erl_call_gen.m:
compiler/exception_analysis.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/frameopt.m:
compiler/get_dependencies.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hlds_goal.m:
compiler/hlds_module.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/ite_gen.m:
compiler/item_util.m:
compiler/jumpopt.m:
compiler/layout.m:
compiler/layout_out.m:
compiler/live_vars.m:
compiler/livemap.m:
compiler/llds.m:
compiler/llds_out_file.m:
compiler/llds_out_global.m:
compiler/llds_out_instr.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make_hlds.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_foreign_proc_gen.m:
compiler/ml_proc_gen.m:
compiler/ml_tailcall.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/modecheck_goal.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/module_qual.qualify_items.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/par_conj_gen.m:
compiler/parse_pragma.m:
compiler/parse_tree_out_info.m:
compiler/parse_tree_out_pragma.m:
compiler/pd_cost.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_gen.m:
compiler/prog_ctgc.m:
compiler/prog_event.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.points_to_graph.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_scope.m:
compiler/simplify_proc.m:
compiler/smm_common.m:
compiler/stack_layout.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.indirect.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_initial.m:
compiler/term_constr_main.m:
compiler/term_constr_main_types.m:
compiler/term_constr_pass2.m:
compiler/term_constr_util.m:
compiler/term_errors.m:
compiler/term_pass1.m:
compiler/term_pass2.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/termination.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/unique_modes.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/use_local_vars.m:
compiler/write_deps_file.m:
Conform to the changes above.
|
||
|
|
f1df5d2dd1 |
Give parsing-related modules more meaningful names.
The mapping from the old to the new module names is:
prog_io -> parse_module
prog_io_dcg -> parse_dcg_goal
prog_io_error -> parse_error
prog_io_find -> find_module
prog_io_goal -> parse_goal
prog_io_inst_mode_defn -> parse_inst_mode_defn
prog_io_inst_mode_name -> parse_inst_mode_name
prog_io_iom -> parse_types
prog_io_item -> parse_item
prog_io_mutable -> parse_mutable
prog_io_pragma -> parse_pragma
prog_io_sym_name -> parse_sym_name
prog_io_type_defn -> parse_type_defn
prog_io_type_name -> parse_type_name
prog_io_typeclass -> parse_class
prog_io_util -> parse_util
prog_io_vars -> parse_vars
unparse -> parse_tree_to_term
|
||
|
|
ec1302f0d1 |
Move unparsing code into a new module.
compiler/unparse.m: New module containing unparsing code. compiler/hlds_out_mode.m: compiler/prog_io_type_name.m: Delete unparsing code from its previous location. compiler/*.m: Update module imports as required. |
||
|
|
897711ffc3 |
Break up prog_io_util.m.
compiler/prog_io_type_name.m:
compiler/prog_io_inst_mode_name.m:
compiler/prog_io_vars.m:
Three new modules carved out of prog_io_util. They respectively contain
code to parse type names, inst and mode names, and lists of variables.
They each have much higher cohesion than the old prog_io_util.
compiler/prog_io_sym_name.m:
Move some type definitions here from prog_io_util.m, since they are
needed only here.
compiler/prog_io_util.m:
Delete the code that is now in the new modules. Delete some types
that were already unused. Group the related (remaining) types and
predicates together.
compiler/prog_io_inst_mode_defn.m:
Rename the old prog_io_mode_defn.m to this, since it parses inst
definitions as well as mode definitions.
compiler/parse_tree.m:
Add the new modules, and handle the rename.
compiler/notes/compiler_design.html:
Document the new modules and the rename.
compiler/add_clause.m:
compiler/check_raw_comp_unit.m:
compiler/hlds_out_mode.m:
compiler/mercury_to_mercury.m:
compiler/parse_tree_out.m:
compiler/prog_ctgc.m:
compiler/prog_io_dcg.m:
compiler/prog_io_error.m:
compiler/prog_io_find.m:
compiler/prog_io_goal.m:
compiler/prog_io_iom.m:
compiler/prog_io_item.m:
compiler/prog_io_mutable.m:
compiler/prog_io_pragma.m:
compiler/prog_io_type_defn.m:
compiler/prog_io_typeclass.m:
compiler/superhomogeneous.m:
compiler/typecheck_errors.m:
Conform to the changes above. In most places, this entails replacing
an import of prog_io_util with the import of just one of its successor
modules.
|
||
|
|
bb01d13482 |
Make the parsing of items more direct.
We used to parse items (and markers) using a fallback strategy: first we
tried to parse a term as this kind of declaration, then as that kind of marker,
etc, and finally as a clause. This meant that if the term was a malformed
declaration or marker (e.g. because it used the right keyword/functor with
the wrong arity), it could be eventually parsed as a clause.
This diff changes over to a direct parsing strategy: deciding what kind
of item or marker a term SHOULD BE given its top level functor, and
committing to that choice.
There are only two exceptions. The first is that when we see ":- mode",
we keep our mind open about whether this is the definition of a new named mode,
or the declaration of a mode of a predicate or function until we see
a functor one level down.
The second exception is that when we see a purity annotation, a variable
quantification or a constraint at the top level. We used to handle these,
and the "solver" annotation, as "declaration attributes". We started the
processing of every declaration by looking for these attributes, and switching
on the declaration's top functor only if we didn't find them. We now
process their functors in main switch on declarations' functors ("type",
"inst", "pred" etc). Only if one of these switch arms is taken do we go
over into a mode where we gather attributes, and once we have processed
all the attributes in the term, we switch between only the limited set
of declaration types that allow attributes. This avoids having to include
a check for "there were no attributes" in the code that processes all
the *other* kinds of declarations.
Handle the purity annotations separately from the variable quantifications
and the constraints, since while the latter are allowed on both item_pred_decls
and item_mode_decls, the former are allowed only on item_pred_decls.
Handle the solver annotation outside the annotation system altogether,
since it applies only type item_type_defns, and is simple enough
not to need e.g. loops for its processing.
In situations where the top level functor of the term being parsed tells us
that the term SHOULD be an item or marker of a particular kind, but it isn't,
our new approach requires us to generate new error messages.
compiler/prog_io_item.m:
Make the changes described above. By testing the top level of the term
being parsed only once, instead of several times, this should lead to
a very minor speedup. (The main objective of the diff is clarity, not
speed.)
Make the little remaining code dealing with declaration attributes
simpler, replacing multiple traversals with a single traversal.
We used to export parse_decl for prog_io_type_defn to use
to parse method specifications in typeclasses. Replace that
with an exported predicate that is much more closely tailored
for this use case.
Make the predicates that switch on terms' top level functors do
nothing but the switch; put all the code of parsing items or markers
of a given kind into item-or-marker-kind-specific predicates. This
allows us to have two versions of the switch (for "we haven't seen
any attributes" and "we have seen some attributes") without duplicating
any significant amount of code.
Delete the type moved to prog_io_iom.m.
compiler/prog_io_iom.m:
A new module which contains only the definition of the item_or_marker type.
This type used to be private to prog_io_item.m, but some of the other
prog_io_*.m modules can use it to construct values of
maybe1(item_or_marker) directly, instead of constructing just
a maybe1(item) and having prog_io_item.m convert that
maybe1(item_or_marker). The direct method is cleaner
as well as more efficient.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Mention the new module.
compiler/prog_io_util.m:
Delete the stuff dealing with decl_attrs, since these have been replaced
with more tightly defined types in prog_io_item.
Make parse_list_of_vars generate useful error messages.
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_mode_defn.m:
compiler/prog_io_mutable.m:
compiler/prog_io_pragma.m:
compiler/prog_io_type_defn.m:
compiler/prog_io_typeclass.m:
Take advantage of the above.
Process source_file pragmas in prog_io_pragma.m, not in prog_io_item.m.
In prog_io_type_defn.m, provide a specialized version of a test
for prog_io_pragma.m to use when processing foreign_type pragmas.
In some places, improve error messages.
compiler/recompilation.version.m:
Add a comment.
tests/invalid/bad_initialise_decl.err_exp:
tests/invalid/bigtest.err_exp:
tests/invalid/pragma_source_file.err_exp:
tests/invalid/some.err_exp:
tests/invalid/where_direct_arg2.err_exp:
Expect updated error messages.
|
||
|
|
cc9912faa8 |
Don't import anything in packages.
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. |
||
|
|
ecbe12cfa6 |
Provide a mechanism for gathering statistics about items.
compiler/prog_item_stats.m:
New module to gather and print out statistics about items.
compiler/make_hlds_passes.m:
Invoke the new module if this module was compiled with a trace flag
that calls for this. (It is of course off by default.)
compiler/parse_tree.m:
Include the new module.
compiler/notes/compiler_design.html:
Document the new module, and improve the formatting of the documentation
of related modules.
tools/item_stats:
A new script to summarize the statistics gathered by prog_item_stats.m.
tools/sum_stats:
A much earlier version of that script, which may be useful in other
contexts.
|
||
|
|
2f1ec6b91c |
Don't abort if a curried predicate has no declared determinism.
compiler/polymorphism.m:
When it sees a curried predicate call, polymorphism converts it to an
explicit lambda expression in order to add the unifications that
construct the type_infos and/or typeclass_infos the call needs.
For this, it needs to know the call's determinism. If the predicate had
no declared determinism, we used to abort the compiler, which is
too drastic a response to a simple programmer error.
Change this so that in this situation, we simply report an error,
and record that it is not safe to continue the compilation process.
In reality, it is not safe to continue the compilation only of the
predicate that the lambda expression occurs in, but in the vast, vast
majority of cases, this should be more than good enough.
I did try to code this change so that we continued the compilation
of other predicates when this error occurs, but it turned out to be
a bit too complicated for the very small potential benefit. Nevertheless,
some of the changes below are the results of this attempt; I kept them
because they are useful in their own right.
Change the code for traversing the procedures of a predicate
to be more direct.
Put the access predicates in the poly_info type in the same order
as the fields they operate on.
compiler/error_util.m:
Allow recording that an error is discovered during the polymorphism pass.
compiler/mercury_compile_front_end.m:
If polymorphism finds errors, print their messages, and then stop;
don't continue to the later passes.
compiler/maybe_error.m:
New module, containing the maybeN types (taken from prog_io_utio.m)
and the safe_to_continue type (taken from modes.m). These are now
needed by polymorphism.m as well.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Mention the new module.
compiler/options.m:
doc/user_guide.texi:
Delete the (undocumented, developer-only) --no-polymorphism option,
since its use cannot lead to anything other than a compiler abort,
and this won't change in the future.
compiler/hlds_pred.m:
Rename the "marker" type to "pred_marker", to clarify its purpose.
Rename the "attribute" type to "pred_attribute", for the same reason.
Make the pred_markers and attributes types true sets, not lists
masquerading as sets.
Add a predicate to add more than one marker at a time to a set of markers.
Delete an unused predicate.
Rename the functors of the can_process type to clarify its purpose.
(I tried to use it to record the presence of errors discovered by
polymorphism.m, and this did not work; these renames should spare
others a similar experience.)
Make the code that construct pred_infos build its components from first
field to last field, not in random order.
compiler/det_analysis.m:
Specialize an exported predicate to its actual uses.
compiler/hlds_out_pred.m:
Dump the cannot_process_yet flag for procedures that have them.
compiler/add_pragma.m:
compiler/add_pred.m:
compiler/complexity.m:
compiler/deforest.m:
compiler/equiv_type_hlds.m:
compiler/field_access.m:
compiler/goal_expr_to_goal.m:
compiler/higher_order.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/ml_accurate_gc.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_item.m:
compiler/prog_io_mode_defn.m:
compiler/prog_io_mutable.m:
compiler/prog_io_pragma.m:
compiler/prog_io_sym_name.m:
compiler/prog_io_type_defn.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/simplify_goal_unify.m:
compiler/ssdebug.m:
compiler/stm_expand.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/try_expand.m:
compiler/unify_proc.m:
Conform to the changes above.
tests/invalid/higher_order_no_detism.{m,err_exp}:
A new test case to test that the compiler does not abort, but generates
an error message when it sees a curried predicate call to a predicate with
no declared determinism.
tests/invalid/Mmakefile:
Enable the new test case.
|
||
|
|
ea094b5bb7 |
Make the import_status type part of the HLDS.
The import_status type was defined in parse_tree.status.m, but it is
not actually used in the parse_tree package. It is used, extensively,
in the hlds package.
compiler/status.m:
compiler/prog_item.m:
compiler/prog_data.m:
Move the parts of status.m that *are* needed in the parse_tree package
to modules in that package. The section markers and the import_locn type
are moved to prog_item.m, while the need_qualifier type is moved to
prog_data.m.
compiler/parse_tree.m:
compiler/hlds.m:
Switch the status.m module from being in the parse_tree package
to being in the hlds package.
compiler/notes/compiler_design.html:
Document the switch.
compiler/*.m:
Update import_module declarations as needed after the above change.
In some places, import parse_tree.prog_item as well as hlds.status,
even if we are only intested in statuses, because the import_locn type,
which part of some statuses, *is* used in the parse_tree package,
and must therefore be defined there. These undesirable dependencies
will go away when we implement the proposal for purpose-specific status
types.
|
||
|
|
bbb2535eb5 |
Break up mercury_to_mercury.m.
With almost 6000 lines, mercury_to_mercury.m was one of the biggest modules
of compiler, but it was far from cohesive. This diff carves seven new modules
out of it, each of which is much more cohesive. The stuff remaining in
mercury_to_mercury.m is still not as cohesive as one would like, but it is
now small enough that moving its individually-cohesive parts into modules
of their own would be overkill.
Three consequences of the old mercury_to_mercury.m's lack of cohesion
were that
- the order of predicate declarations often did not match the order of
their implementation;
- related predicates were not grouped together;
- even when they were grouped together, the order of those groups
was often random.
This diff fixes all three of these problems for all eight successor modules
of mercury_to_mercury.m: the seven new modules, and the new
mercury_to_mercury.m itself.
In some cases, this diff adds or improves the documentation of the predicates
in mercury_to_mercury.m's successor modules. In some other cases, it just
documents the lack of documentation :-(. In yet other cases, it removes
"documentation" that says nothing that isn't obvious from the predicate's name.
There are some algorithmic changes, but they are all trivial.
compiler/parse_tree_out.m:
New module containing the code to print out the top levels of parse trees,
including most sorts of items.
compiler/parse_tree_out_clause.m:
New module containing the code to print out clauses and goals.
compiler/parse_tree_out_pragma.m:
New module containing the code to print out pragmas.
compiler/parse_tree_out_pred_decl.m:
New module containing the code to print out predicate, function and
mode declarations. It is separate from parse_tree_out.m because a
significant number of compiler modules need only its functionality,
and not parse_tree_out.m's functionality.
compiler/parse_tree_out_inst.m:
New module containing the code to print out insts and modes.
compiler/parse_tree_out_term.m:
New module containing the code to print out variables and terms.
compiler/parse_tree_out_info.m:
New module containing the infrastructure of both mercury_to_mercury.m
and the other new modules.
compiler/parse_tree.m:
Include the new modules.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/Mercury.options:
Transfer an option from mercury_to_mercury.m to the successor module
that needs it.
compiler/*.m:
Import one of the new modules either as well as, or instead of,
mercury_to_mercury.m. In most cases, we need to import only one
or two of mercury_to_mercury.m's successor modules; nowhere do we
need to import all eight.
Clean up some code in termination.m around a call to one of the
new modules.
tools/speedtest:
Replace mercury_to_mercury.m on the list of the ten largest modules
of the compiler.
|
||
|
|
04dec8c205 |
Carve vartypes.m, prog_detism.m and prog_rename.m out of prog_data.m.
Besides defining most of the types representing the smaller parts of
parse trees (parts smaller than items), prog_data.m also has many utility
predicates that operate on values of these types. Carve the three substantial
clusters of predicates out of prog_data.m, and move them into their own
modules, which are each imported by fewer modules than prog_data.m itself.
compiler/vartypes.m:
New module containing the vartypes type and the predicates that operate
on it. The new module has *much* better cohesion than the old prog_data.m.
The vartypes type does not appear in any parse tree; it is used only
in the HLDS. So make vartypes.m part of the hlds.m package, not
parse_tree.m.
Move three predicates that perform renamings and substitutions on vartypes
here from prog_type_subst.m, since the latter is part of the parse_tree.m
package, and thus doesn't have access to hlds.vartypes. Make private
the service predicate that these three moved predicates used to rely on,
since it has no other callers.
compiler/prog_detism.m:
New module containing utility predicates that operate on determinisms
and determinism components.
compiler/prog_rename.m:
New module containing utility predicates that rename variables in
various data structures.
compiler/prog_data.m:
Remove the stuff now in the three new modules.
compiler/prog_type_subst.m:
Remove the three predicates now in vartypes.m.
compiler/mercury_to_mercury.m:
Delete an unneded predicate, which was the only part of this module
that referred to vartypes.
compiler/prog_type.m:
compiler/builtin_lib_types.m:
compiler/type_util.m:
Move some utility predicates that refer to vartypes from prog_type.m
and builtin_lib_types.m (both part of parse_tree.m) to type_util.m
(part of check_hlds.m).
compiler/parse_tree.m:
compiler/hlds.m:
compiler/notes/compiler_design.html:
Mention the new modules.
compiler/accumulator.m:
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_heap_ops.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_trail_ops.m:
compiler/arg_info.m:
compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/clause_to_proc.m:
compiler/closure_analysis.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/common.m:
compiler/complexity.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/continuation_info.m:
compiler/coverage_profiling.m:
compiler/cse_detection.m:
compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/disj_gen.m:
compiler/equiv_type_hlds.m:
compiler/erl_call_gen.m:
compiler/erl_code_gen.m:
compiler/erl_code_util.m:
compiler/exception_analysis.m:
compiler/float_regs.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/goal_path.m:
compiler/goal_store.m:
compiler/goal_util.m:
compiler/headvar_names.m:
compiler/hhf.m:
compiler/higher_order.m:
compiler/hlds_clauses.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_module.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/hlds_rtti.m:
compiler/inlining.m:
compiler/inst_util.m:
compiler/instmap.m:
compiler/intermod.m:
compiler/interval.m:
compiler/lambda.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/lookup_switch.m:
compiler/make_goal.m:
compiler/mark_tail_calls.m:
compiler/ml_accurate_gc.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_disj_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_proc_gen.m:
compiler/ml_unify_gen.m:
compiler/mode_constraints.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/modecheck_call.m:
compiler/modecheck_conj.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/par_loop_control.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/qual_info.m:
compiler/quantification.m:
compiler/rbmm.points_to_graph.m:
compiler/rbmm.points_to_info.m:
compiler/rbmm.region_liveness_info.m:
compiler/rbmm.region_transformation.m:
compiler/saved_vars.m:
compiler/set_of_var.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_goal_scope.m:
compiler/simplify_goal_switch.m:
compiler/simplify_goal_unify.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/ssdebug.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/stm_expand.m:
compiler/store_alloc.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
compiler/switch_detection.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/term_util.m:
compiler/trace_gen.m:
compiler/trailing_analysis.m:
compiler/try_expand.m:
compiler/tupling.m:
compiler/type_assign.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/untupling.m:
compiler/unused_args.m:
compiler/var_locn.m:
Conform to the above changes, mostly by importing some of the
three new modules as well as, or instead of, prog_data.m.
|
||
|
|
7e1fad7ba6 |
Carve check_raw_comp_unit.m out of modules.m.
compiler/check_raw_comp_unit.m:
New module formed out of one group of predicates in modules.m.
compiler/modules.m:
Remove the stuff now in check_raw_comp_unit.m, thus increasing its
cohesion.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Mention the new module.
compiler/notes/mercury_compile.m:
compiler/notes/write_module_interface_files.m:
Conform to the above change.
|