mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 06:47:17 +00:00
faa18a15bd332b51ec6d6fdae4d999ec2bf3fa82
13 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3ebda6545f |
Move the stuff currently in hlds_pred.m that deals with clauses into a new
Estimated hours taken: 1.5 Branches: main Move the stuff currently in hlds_pred.m that deals with clauses into a new module, hlds_clauses.m. Move the stuff currently in hlds_pred.m that deals with RTTI into a new module, hlds_rtti.m. Move the stuff currently in hlds_module.m that deals with predicate tables into a new module, pred_table.m. These changes make hlds_pred.m and hlds_module.m much more cohesive, but there are no changes in algorithms. compiler/hlds_clauses.m: compiler/hlds_rtti.m: compiler/pred_table.m: New modules as described above. In some cases, fix mixleading or ambiguous predicate names in the process, and convert a few predicates to functions. compiler/hlds_pred.m: compiler/hlds_module.m: Delete the stuff moved to other modules. compiler/*.m: In modules that need the functionality moved a new module, import the new module. It is rare for all the new modules to be needed, and many modules don't need any of the new modules at all. (For example, of the 200+ modules that import hlds_module.m, only about 40 need pred_table.m.) Conform to the few minor changes to e.g. predicate names. compiler/notes/compiler_design.html: Document the new modules. |
||
|
|
765109cde2 |
Extend constraints based mode analysis.
Estimated hours taken: 120. Branches: main. Extend constraints based mode analysis. Constraints on the producing and consuming goals for program variables are now solved, and the solutions used for conjunction reordering. The resulting HLDS is then thrown away, after maybe being dumped (stage 33). Extend dumping of mode analysis constraints. Constraints are no longer dumped to file - they are displayed as error messages when the --debug-mode-constraints is set. After conjunction ordering, the original goal paths are printed in the order they now appear. compiler/options.m: Added the option described above, and some comments describing various mode constraint options. compiler/check_hlds.m: Grouped ":- include_module"s for propagation solver constraints based mode analysis, and included new modules in this area - mcsolver and ordering_mode_constraints. compiler/mode_constraints.m: Changes to the nature of constraint dumping - introduction of the use of --debug-mode-constraints. Introduction of conjunction ordering (call to module ordering_mode_constraints). compiler/prop_mode_constraints.m: Changes to way constraints are dumped as described above. Changes to the way constraint variables are created - constraint variables can now be constructed as needed when the constraints are built. Structural changes to make constraint generation more natural (eg introduction of state variables, instead of use of functions). compiler/abstract_mode_constraints.m: Changes to the way constraints are stored - the old speculative code became redundant with the introduction of rafe's solver (see mcsolver.m). New, specialised constraint generation predicates. Constraints are now created with a context attached, and space was left for adding other information. compiler/build_mode_constraints.m: Changes to the way constraint variables are created - constraint variables can now be constructed as needed when the constraints are built. Structural changes to make constraint generation more natural (eg introduction of state variables, instead of use of functions). Constraints are now created with a context attached. compiler/ordering_mode_constraints.m: New file. Uses solutions to the producer/consumer constraints to order conjunctions for mode analysis. Does not yet do mode inference. compiler/mcsolver.m: New file. Written by rafe, modified by myself to accomodate the rest of the mode constraints branch (and a new constraint type). Solves mode constraints to produce bindings for constraint variables from producer/consumer analysis. compiler/notes/compiler_design.html: Updated notes about constraints based mode analysis. |
||
|
|
b819fbc0a6 |
Give the compiler the capability of detecting errors that manifest themselves
Estimated hours taken: 16
Branches: main
Give the compiler the capability of detecting errors that manifest themselves
as mismatches between the format string and the list of values to be printed
in calls to string.format and io.format.
This capability is controlled through two new options:
--warn-known-bad-format-calls
--warn-unknown-format-calls
The first (which will default to "on" once this change has bootstrapped)
controls whether the compiler emits warnings for statically known mismatches.
The second (which will default to "off") controls whether the compiler emits
warnings in cases where either the format string or the structure of the list
of values to be printed is not available statically to be checked.
NEWS:
Mention the new capability.
compiler/options.m:
Add the two new options.
doc/user_guide.texi:
Document the new options.
compiler/format_call.m:
New module to implement the new capability.
compiler/notes/compiler_structure.html:
Document the new module.
compiler/check_hlds.m:
Include the new module.
compiler/simplify.m:
Invoke the new module if the procedure being processed contains calls
to string.format or io.format.
Fix an old bug: we could generate warnings or even errors when
simplifying predicate bodies imported from other modules via
intermodule optimization.
Don't export get/set predicates that do not need to be exported.
compiler/det_report.m:
Add new kinds of error specifications for the errors detected by the
new module.
Separate out the context of each error specification, in order
to allow the error messages to be sorted by context; this makes
the output much easier to read.
compiler/common.m:
compiler/det_analysis.m:
compiler/simplify.m:
Conform to the change to det_report.m.
mdbcomp/prim_data.m:
Add a utility function for forming the possibly qualified names of
library modules (such as "io" and "string").
library/Mercury.options:
compiler/Mercury.options:
Add the lines that disable the new checks in the modules that need them
disabled. The new lines are commented out until installed compilers all
understand them, at which point in time we will add the requirement to
understand the option to configure.in.
compiler/fact_table.m:
compiler/mlds_to_il.m:
Fix three bugs reported by the new check that have apparently escaped
detection all this time.
library/rtti_implementation.m:
Change some code to avoid a spurious warning from the new checks.
library/string.m:
Rename a predicate to avoid an unnecessary and confusing overloading of
its name.
Replace __ with . as module qualifier connective.
compiler/handle_options.m:
library/pprint.m:
Misc cleanups.
tests/invalid/string_format_bad.{m,err_exp}:
tests/invalid/string_format_unknown.{m,err_exp}:
New test cases to test the new warnings.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
Enable the new test cases.
tests/general/string_format_test*.exp*:
Update any expected abort messages to expect . instead of __ as module
qualifier connective.
tests/invalid/det_errors_cc.err_exp:
tests/invalid/erroneous_throw_promise.err_exp:
tests/warnings/simple_code.exp:
Expect the same error messages in program context order.
|
||
|
|
905e4a114f |
Convert a bunch of modules to four-space indentation.
Estimated hours taken: 4 Branches: main compiler/*.m: Convert a bunch of modules to four-space indentation. In the process, fix departures from our coding standards. In some cases, do minor other cleanups such as changing argument orders to be friendly to state variables. There are no algorithmic changes. |
||
|
|
cb2c3ec8bf |
Split typecheck.m into smaller modules.
Estimated hours taken: 3 Branches: main Split typecheck.m into smaller modules. compiler/typecheck.m: The main typechecking pass. compiler/typecheck_errors.m: New module. Error messages and debugging messages. compiler/typecheck_info.m: New module. The typecheck_info and type_assign data structures, plus some basic predicates. compiler/typeclasses.m: New module. The context reduction and improvement rules. compiler/check_hlds.m: Register the new modules. compiler/check_typeclass.m: Call typeclasses instead of typecheck to do context reduction. compiler/prog_type.m: Move strip_builtin_qualifiers_from_type(_list) to here. compiler/hlds_data.m: Define restrict_list_elements here instead of in typecheck.m and check_typeclass.m. |
||
|
|
9ec90c88ea |
These changes provide the framework for a new approach to constraints
Estimated hours taken: 100 Branches: main These changes provide the framework for a new approach to constraints based mode analysis. They build constraints for simple mercury programs (sorry, no higher order unifications), and can later be extended to handle all applicable hlds goals. They have been designed with the intention that they would be solved, for example, by a propagation based constraint solver, and the information used for producing a partial order on conjuncts and for mode analysis of a mercury program. compiler/prop_mode_constraints.m This module serves as an interface between the existing mode_constraints module which asks for constraints for an SCC, and build_mode_constraints, which only handles goals. Simply put, it takes an SCC and hands it to build_mode_constraints one predicate at a time. It produces the mode constraints for that SCC, and the constraint variables necessary to do so. compiler/build_mode_constraints.m This module creates the constraint variables and constraints needed for the new constraints based mode analysis. It traverses the hlds_goal data structure recursively to form mode constraints for a goal. The constraints it builds are the simplified form - they do not deal with partial instantiation. They are also incomplete, as no constraints are produced for higher order unifications, parallel conjunctions, switches etc. A rough description of the constraints can be found in chapter six of David Overton's disseration, "Precise and Expressive Mode Systems for Typed Logic Programming Languages." compiler/abstract_mode_constraints.m This module contains data structures that represent mode constraints. They have been chosen so as to minimise complication for the types of constraints most often created by mode analysis. There is also a predicate here for displaying the constraints/printing to file. compiler/check_hlds.m: Added :- include_module statements for new modules check_hlds.abstract_mode_constraints, check_hlds.build_mode_constraints and check_hlds.prop_mode_constraints. compiler/mode_constraints.m mode_constraints.process_module now switches on the global bool option prop_mode_constraints. If the option is true, it passes control over to prop_mode_constraints.process_scc instead of its own process_scc, then outputs the results to a file named after the module being processed with the extension .mode_constraints compiler/options.m New option inclued --prop-mode-constraints. Note that the propagaion mode constraints material is an offshoot of the original, so to run it both --mode-constraints and --prop-mode-constraints must be specified. compiler/notes/compiler_design.html Added a description of various parts of the new constraints based mode analysis work. |
||
|
|
59d2d4a573 |
This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17 Branches: main This adds a module mdbcomp__trace_counts that reads in the .mercury_trace_counts files produced by the compiler's trace mechanism. The format of said files was slightly changed. As the new module is to be used by the compiler and the debugger, it is placed in the mdbcomp module. This required bringing some types from the compiler into a new module within mdbcomp. browser/trace_counts.m: New module for reading execution trace summaries. browser/prim_data.m: New module holding types and predicates moved in from the compiler. Types: pred_or_func, sym_name, module_name, proc_label, special_pred_id, trace_port Predicates: string_to_sym_name, insert_module_qualifier The mode field of proc_label is now an int instead of a proc_id to avoid pulling proc_id into mdbcomp. browser/mdbcomp.m: Add trace_counts and prim_data to the mdbcomp module. browser/declarative_execution.m: Renamed mdb's definition of module_name to flat_module_name to avoid conflicts with the definition in mdbcomp__prim_data. runtime/mercury_trace_base.c: In the format of .mercury_trace_counts, write module and predicate names now use quoted atom syntax so that names with spaces and non-printable characters can be machine-parsed. browser/: compiler/: Many changes to account for movement of types, and the change to proc_label. |
||
|
|
02b9dceb8f |
Move changes in the compiler on the mode-constraints branch onto the trunk.
Estimated hours taken: unknown, but months (almost all by dmo) Branches: main Move changes in the compiler on the mode-constraints branch onto the trunk. compiler/top_level.m: Add the new package mode_robdd. compiler/check_hlds.m: Add the new modules within the check_hlds.m package: mode_constraints, mode_constraint_robdd and mode_ordering. compiler/hlds.m: Add the new modules within the hlds.m package, hhf and inst_graph. compiler/hhf.m: This new module implements the transformation from our usual superhomogeneous form to the hyperhomogeneous form required by constraint based mode analysis. compiler/inst_graph.m: This new module computes the instantiation graphs required by constraint based mode analysis. compiler/hlds_goal.m: Add an extra slot into goal_infos for use by constraint based mode analysis, and the predicates required to manipulate it. compiler/hlds_pred.m: Add two extra slots into pred_infos and one extra slot into proc_infos for use by constraint based mode analysis, and the predicates required to manipulate them. compiler/mercury_compile.m: Invoke the constraint based mode analysis pass if the options call for it. compiler/mode_constraints.m: This new module implements the top level of the constraint based mode analysis algorithm: it finds the constraints and adds them to the constraint store, and invokes other modules to find solutions and process them. compiler/mode_ordering.m: This new module processes solutions of constraint systems by trying to find execution orders for conjunctions that are consistent with the assignment of producers represented by a such a solution. compiler/mode_constraint_robdd.m: This new module provides a useful interface to operations on robdds used for constraint based mode analysis. The actual implementation uses one or two of the mode_robdd.X.m modules. compiler/mode_robdd.m: New top-level package to hold the modules listed below, which deal with robdd based solvers for the constraint systems generated by mode analysis. compiler/mode_robdd.check.m: This new module invokes two of the modules below and compares their results. If one of the modules is known to be good, this is useful for debugging the other. compiler/mode_robdd.r.m: compiler/mode_robdd.tfeir.m: compiler/mode_robdd.tfeirn.m: compiler/mode_robdd.tfer.m: compiler/mode_robdd.tfern.m: compiler/mode_robdd.tfr.m: These new modules each implement robdd based constraint solvers. They differ in the amount of information they keep in the robdd versus how much information they keep in Mercury data structures. The naming scheme assigns a letter to each kind of information we are concerned about, and includes that letter in the name the Mercury data structure has a separate field for that kind of information. The mapping is: r: robdd (present in all variants) tf: variables known to be true or false e: variable equivalences i: variable implications. n: normalization Normally only one of these would be linked in, or two if mode_robdd.check.m is being used to compare two of these modules. compiler/mode_robdd.equiv_vars.m: This module implements utility operations involving sets of equivalent variables. compiler/mode_robdd.implications.m: This module implements utility operations involving implications among variables. compiler/mode_robdd.prop.m: Experimental module; currently unused. Committed only to preserve its history. compiler/goal_path.m: Add a variant of an existing predicate needed by constraint based mode analysis. compiler/hlds_out.m: Print out the components added to the HLDS by this change if the appropriate signal character is present in the revelant option. compiler/handle_options.m: Add the signal for printing mode constraints to the names of the usual dumping aliases. They have no effect unless constraint based mode analysis is enabled. compiler/options.m: Add the options controlling the experimental mode constraints pass. doc/user_guide.texi: Document the options controlling the experimental mode constraints pass for implementors. compiler/notes/compiler_design.html: Document the new modules, and fix some old errors. |
||
|
|
885fd4a387 |
Remove almost all dependencies by the modules of parse_tree.m on the modules
Estimated hours taken: 12 Branches: main Remove almost all dependencies by the modules of parse_tree.m on the modules of hlds.m. The only such dependencies remaining now are on type_util.m. compiler/hlds_data.m: compiler/prog_data.m: Move the cons_id type from hlds_data to prog_data, since several parts of the parse tree data structure depend on it (particularly insts). Remove the need to import HLDS modules in prog_data.m by making the cons_ids that refer to procedure ids refer to them via a new type that contains shrouded pred_ids and proc_ids. Since pred_ids and proc_ids are abstract types in hlds_data, add predicates to hlds_data to shroud and unshroud them. Also move some other types, e.g. mode_id and class_id, from hlds_data to prog_data. compiler/hlds_data.m: compiler/prog_util.m: Move predicates for manipulating cons_ids from hlds_data to prog_util. compiler/inst.m: compiler/prog_data.m: Move the contents of inst.m to prog_data.m, since that is where it belongs, and since doing so eliminates a circular dependency. The separation doesn't serve any purpose any more, since we don't need to import hlds_data.m anymore to get access to the cons_id type. compiler/mode_util.m: compiler/prog_mode.m: compiler/parse_tree.m: Move the predicates in mode_util that don't depend on the HLDS to a new module prog_mode, which is part of parse_tree.m. compiler/notes/compiler_design.m: Mention prog_mode.m, and delete the mention of inst.m. compiler/mercury_to_mercury.m: compiler/hlds_out.m: Move the predicates that depend on HLDS out of mercury_to_mercury.m to hlds_out.m. Export from mercury_to_mercury.m the predicates needed by the moved predicates. compiler/hlds_out.m: compiler/prog_out.m: Move predicates for printing parts of the parse tree out of hlds_out.m to prog_out.m, since mercury_to_mercury.m needs to use them. compiler/purity.m: compiler/prog_out.m: Move predicates for printing purities from purity.m, which is part of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use them. compiler/passes_aux.m: compiler/prog_out.m: Move some utility predicates (e.g. for printing progress messages) from passes_aux.m to prog_out.m, since some predicates in submodules of parse_tree.m need to use them. compiler/foreign.m: compiler/prog_data.m: Move some types from foreign.m to prog_data.m to allow the elimination of some dependencies on foreign.m from submodules of parse_tree.m. compiler/*.m: Conform to the changes above, mostly by updating lists of imported modules and module qualifications. In some cases, also do some local cleanups such as converting predicate declarations to predmode syntax and fixing white space. |
||
|
|
5d6fd3bd6f |
Reduce the dependence of earlier parts of the compiler on the later ones.
Estimated hours taken: 4 Branches: main Reduce the dependence of earlier parts of the compiler on the later ones. Unnecessary import_module declarations in top level modules such as hlds.m cause unnecessary recompilations when adding new types in later modules, such as submodules of ll_backend.m. This change reduces the number of such unnecessary imports. There are no changes in algorithms, only functionality being moved around. compiler/code_model.m: Change this module from being a submodule of backend_libs.m to being a submodule of hlds.m, since nothing in it is dependent on any backend. compiler/arg_info.m: compiler/code_util.m: Change arg_info.m from being a submodule of ll_backend.m to being a submodule of hlds.m, since most of it is applicable to all current and foreseeable backends. Move the one exported predicate that is ll_backend dependent, and its support predicates, to code_util.m. compiler/backend_libs.m: compiler/ll_backend.m: compiler/hlds.m: Update include_module declarations in accordance with the above. compiler/prog_data.m: compiler/term_util.m: Instead of defining two separate types for holding argument size and termination information, one including HLDS-specific information (in term_util.m) and one not (in prog_data.m), use a polymorphic type defined in prog_data.m and two monomorphic instances. compiler/termination.m: compiler/mercury_to_mercury.m: Change the predicates for writing out argument size and termination information to handle the polymorphic type (we don't need special handling of the monomorphic versions), and move them from termination.m to mercury_to_mercury.m, since this allows us to avoid some undesirable dependencies. compiler/base_typeclass_info.m: compiler/hlds_code_util.m: Move the predicate make_instance_string from base_typeclass_info.m to hlds_code_util.m, again because it allows us to remove some undesirable dependencies. compiler/top_level.m: compiler/backend_libs.m: compiler/check_hlds.m: compiler/hlds.m: compiler/ll_backend.m: compiler/parse_tree.m: compiler/transform_hlds.m: Delete some import_module declarations of other top level modules in these top level modules. Some imports were totally unnecessary. Some imports were useful in only a small minority of submodules; those submodules now import the necessary top level modules directly. Move remaining import_module declarations to the implementation section where this is feasible. Where we still need to import modules we ideally shouldn't, note why. compiler/*.m: Update imports of code_util and arg_info. In some cases, import top level modules no longer imported by the parent module. In some cases, delete unnecessary imports. |
||
|
|
1cb657b998 |
Reduce inappropriate dependencies on ll_backend modules.
Estimated hours taken: 3 Branches: main Reduce inappropriate dependencies on ll_backend modules. Except for simplification of unnecessarily complicated logic in dependency_graph.m, this change only moves functionality around. compiler/llds_out.m: compiler/c_util.m: compiler/name_mangle.m: Move predicates that are used by multiple backends from ll_backend__llds_out to backend_libs__c_util and to a new module backend_libs__name_mangle. Make the relevant ones functions, and give some of them more meaningful names. compiler/trace.m: compiler/hlds_goal.m: Move a backend-independent predicate from ll_backend__trace to hlds__hlds_goal. compiler/llds.m: compiler/trace_params.m: Move the definition of the trace_port type from ll_backend__llds to libs__trace_params to avoid having libs__trace_params depend on ll_backend. compiler/exprn_aux.m: compiler/globals.m: Move the definition of the imported_is_constant from ll_backend__exprn_aux to libs__globals to avoid having libs__globals depend on ll_backend. compiler/*.m: Conform to the above changes. This removes many inappropriate dependencies on the LLDS backend. |
||
|
|
9551640f55 |
Import only one compiler module per line. Sort the blocks of imports.
Estimated hours taken: 2 Branches: main compiler/*.m: Import only one compiler module per line. Sort the blocks of imports. This makes it easier to merge in changes. In a couple of places, remove unnecessary imports. |
||
|
|
7597790760 |
Use sub-modules to structure the modules in the Mercury compiler directory.
The main aim of this change is to make the overall, high-level structure of the compiler clearer, and to encourage better encapsulation of the major components. compiler/libs.m: compiler/backend_libs.m: compiler/parse_tree.m: compiler/hlds.m: compiler/check_hlds.m: compiler/transform_hlds.m: compiler/bytecode_backend.m: compiler/aditi_backend.m: compiler/ml_backend.m: compiler/ll_backend.m: compiler/top_level.m: New files. One module for each of the major components of the Mercury compiler. These modules contain (as separate sub-modules) all the other modules in the Mercury compiler, except gcc.m and mlds_to_gcc.m. Mmakefile: compiler/Mmakefile: Handle the fact that the top-level module is now `top_level', not `mercury_compile' (since `mercury_compile' is a sub-module of `top_level'). compiler/Mmakefile: Update settings of *FLAGS-<modulename> to use the appropriate nested module names. compiler/recompilation_check.m: compiler/recompilation_version.m: compiler/recompilation_usage.m: compiler/recompilation.check.m: compiler/recompilation.version.m: compiler/recompilation.version.m: Convert the `recompilation_*' modules into sub-modules of the `recompilation' module. compiler/*.m: compiler/*.pp: Module-qualify the module names in `:- module', `:- import_module', and `:- use_module' declarations. compiler/base_type_info.m: compiler/base_type_layout.m: Deleted these unused empty modules. compiler/prog_data.m: compiler/globals.m: Move the `foreign_language' type from prog_data to globals. compiler/mlds.m: compiler/ml_util.m: compiler/mlds_to_il.m: Import `globals', for `foreign_language'. Mmake.common.in: trace/Mmakefile: runtime/Mmakefile: Rename the %.check.c targets as %.check_hdr.c, to avoid conflicts with compiler/recompilation.check.c. |