mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 13:23:53 +00:00
ada4e26dd11e052f8f244cb0af94208f4d329452
27 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
637c76926d |
Add some preliminary infrastructure for an HLDS->Erlang code generator.
Estimated hours take: 4
Branches: main
Add some preliminary infrastructure for an HLDS->Erlang code generator.
compiler/globals.m:
compiler/options.m:
Recognise "erlang" as a valid compilation target.
Add new options: `--erlang' and `--erlang-only' as synonyms
for `--target erlang' and `--target erlang --target-code-only'.
XXX the new options are currently undocumented.
compiler/hlds_data.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Recognise "Erlang" as a valid language for foreign code.
compiler/handle_options.m:
For erlang targets, set the gc_method to automatic and disable
optimize_constructor_last_call.
compiler/add_pragma.m:
compiler/add_type.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/export.m:
compiler/foreign.m:
compiler/granularity.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_gen.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/modules.m:
compiler/pragma_c_gen.m:
compiler/prog_foreign.m:
compiler/simplify.m:
Conform to the above changes.
|
||
|
|
aa671f1974 |
Fix failure of tests/valid/foreign_type_spec.
Estimated hours taken: 3
Branches: main
Fix failure of tests/valid/foreign_type_spec.
compiler/add_type.m:
Fix a place where error codes were being `and'ed together
rather than `or'ed, resulting in missing foreign type
declarations not being reported and compiler aborts later.
Remove code to only test GRADEFLAGS when generating code.
GRADEFLAGS is passed for all compilation targets now.
library/bitmap.m:
Uncomment the IL definition of the bitmap type to allow
the interface files to be used by tests in grade `il'.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/invalid/foreign_type_missing.{m,err_exp}:
Test case for missing foreign type declarations for
the current back-end.
tests/valid/Mercury.options:
Fix a typo which caused different parts of the foreign_type_spec
test case to be compiled in different grades.
tests/EXPECT_FAIL_TESTS.all_grades:
Remove foreign_type_spec.
|
||
|
|
74b6457c51 |
Add some preliminary infrastructure for the LLDS->x86_64 assembler
Estimated hours taken: 2 Branches: main Add some preliminary infrastructure for the LLDS->x86_64 assembler code generator that Fransiska is working on. compiler/globals.m: compiler/options.m: compiler/handle_options.m: compiler/mercury_compile.m: Recognise "x86_64" as a valid compilation target. Add new options: `--x86_64' and `--x86_64-only' as synonyms for `--target x86_64' and `--target x86_64 --target-code-only'. In the backend passes for the lowlevel backend branch appropriately depending on whether we are generating C or x86_64 assembler. compiler/foreign.m: compiler/prog_foreign.m: When compiling to x86_64 assembler use C as the preferred foreign language. compiler/mlds.m: compiler/ml_code_gen.m: compiler/ml_optimize.m: compiler/ml_switch_gen.m: compiler/ml_type_gen.m: compiler/ml_unify_gen.m: compiler/mlds_to_c.m: Handle "x86_64" as a target in the MLDS backend. This does (and should) cause a compiler abort since "x86_64" is intended to be an MLDS target language. compiler/make.module_target.m: compiler/make.program_target.m: compiler/modules.m: Add placeholders for --target x86_64 in the build systems. compiler/make_hlds_passes.m. We don't currently support mutables with --target x86_64. compiler/simplify.m: We don't currently support runtime conditions on trace goals with --target x86_64. compiler/add_type.m: compiler/compile_target_code.m: compiler/granularity.m: compiler/intermod.m: Conform to the above changes. |
||
|
|
b4c3bb1387 |
Clean up in unused module imports in the Mercury system detected
Estimated hours taken: 3 Branches: main Clean up in unused module imports in the Mercury system detected by --warn-unused-imports. analysis/*.m: browser/*.m: deep_profiler/*.m: compiler/*.m: library/*.m: mdbcomp/*.m: profiler/*.m: slice/*.m: Remove unused module imports. Fix some minor departures from our coding standards. analysis/Mercury.options: browser/Mercury.options: deep_profiler/Mercury.options: compiler/Mercury.options: library/Mercury.options: mdbcomp/Mercury.options: profiler/Mercury.options: slice/Mercury.options: Set --no-warn-unused-imports for those modules that are used as packages or otherwise break --warn-unused-imports, e.g. because they contain predicates with both foreign and Mercury clauses and some of the imports only depend on the latter. |
||
|
|
82eab0e65e |
Add an optional pass that tries to avoid generating too many parallel goals.
Estimated hours taken: 12
Branches: main
Add an optional pass that tries to avoid generating too many parallel goals.
The first transformation implemented by this pass is to transform parallel
conjunctions into goals of the form
( queues already contain lot of work ->
sequential version of parallel conjunction
;
parallel conjunction as before
)
if they contain recursive calls.
The effect of this transformation is to reduce the overhead of the new par_fib
test case from:
fib(35): sequential 189 vs parallel 5770
to
fib(35): sequential 189 vs parallel 1090
i.e. a speedup of more than a factor of five.
compiler/granularity.m:
New module that implements this transformation. I intend to add other,
more sophisticated transformations in the future.
compiler/transform_hlds.m:
Add granularity.m as one of the submodules of transform_hlds.m.
compiler/mercury_compile.m:
Invoke the new pass.
Invoke dep_par_conj only if needed.
Fix some stage numbers.
compiler/notes/compiler_design.html:
Document the new module.
Document some modules that should have been documented earlier.
Fix a hurried deletion of a reference to the Aditi backend.
compiler/goal_util.m:
Add some utility functions for use by the new module.
compiler/simplify.m:
Record the information mercury_compile.m needs in order to check
whether we have any parallelism for granularity.m and dep_par_conj.m
to process.
compiler/hlds_module.m:
Add a slot to the module_info to record the information from
simplify.m. Clean up some interfaces.
compiler/add_type.m:
Conform to the change to hlds_module.m.
compiler/dependency_graph.m:
Delete unnecessary module qualifications, and rename some predicates
to avoid potential ambiguities.
compiler/options.m:
Add the options required for controlling the new transformation.
Rename an option's internal name to avoid conflict with a language
keyword (the user-visible name remains unchanged).
Move some options around to put them in logical groups.
doc/user_guide.texi:
Document the new options.
Fix some omissions in some earlier options.
compiler/handle_options.m:
compiler/termination.m:
Conform to the option rename.
compiler/quantification.m:
Rename some predicates to avoid ambiguities.
library/par_builtin.m:
Add a predicate for use by the new transformation.
tests/par_conj/par_fib.{m,exp}:
A new test case: a version of fib for use in testing parallelism.
tests/par_conj/Mmakefile:
Enable the new test case.
|
||
|
|
f08f22a7de |
Generate an XML representation of the du types in the current module.
Estimated hours taken: 24 Branches: main Generate an XML representation of the du types in the current module. The XML representation contains all the information about the type, as well as associating with each type, data constructor and data field any comments located near the comment. The current strategy associates the comment starting on the same line as the type declaration, and if there is none then the comment directly above. At a later date, this strategy needs to be made more flexible. This required two main changes to the compiler. Change one was to associate with a term.variable the context of that variable. Then the constructor and constructor_arg types had to have their context recorded. compiler/xml_documentation.m: Add a pass that generates an XML documentation for the du types in the current module. compiler/handle_options.m: compiler/mercury_compile.m: compiler/options.m: Call the xml_documentation phase and stop afterwards. compiler/error_utils.m: Add a utitily predicate for reporting errors where a file is unable to be opened. library/term.m: Add the term.context to term.variables. Remove the backwards mode of var_list_to_term_list as it no longer works. Make the predicate version of term_list_to_var_list semidet as we can no longer use the backwards version var_list_to_term_list. NEWS: Mention the changes to the term module. library/parser.m: Fill in the term.context of term.variables while parsing. compiler/prog_data.m: Add the context to the constructor and constructor_arg types. compiler/prog_io.m: Fill in the context fields in the constructor and constructor_arg types. compiler/add_clause.m: compiler/prog_io.m: compiler/prog_io_typeclass.m: compiler/typecheck.m: Call the correct version of term_list_to_var_list, to deal with the fact that we removed the reverse mode of var_list_to_term_list. compiler/notes/compiler_design.html: doc/user_guide.texi: Document the new module. compiler/add_clause.m: compiler/det_util.m: compiler/fact_table.m: compiler/hlds_out.m: compiler/inst_graph.m: compiler/intermod.m: compiler/make_hlds_passes.m: compiler/mercury_to_mercury.m: compiler/prog_ctgc.m: compiler/prog_io.m: compiler/prog_io_dcg.m: compiler/prog_io_goal.m: compiler/prog_io_pragma.m: compiler/prog_io_typeclass.m: compiler/prog_io_util.m: compiler/prog_io_util.m: compiler/prog_util.m: compiler/state_var.m: compiler/superhomogeneous.m: compiler/switch_detection.m: compiler/typecheck_errors.m: library/term_io.m: library/varset.m: Handle the context in the term.variable structure. compiler/add_type.m: compiler/check_typeclass.m: compiler/equiv_type.m: compiler/hhf.m: compiler/hlds_out.m: compiler/inst_check.m: compiler/make_tags.m: compiler/mercury_to_mercury.m: compiler/ml_type_gen.m: compiler/ml_unify_gen.m: compiler/mode_util.m: compiler/module_qual.m: compiler/post_typecheck.m: compiler/prog_io.m: compiler/prog_mode.m: compiler/prog_type.m: compiler/recompilation.check.m: compiler/recompilation.usage.m: compiler/special_pred.m: compiler/term_constr_build.m: compiler/term_norm.m: compiler/type_ctor_info.m: compiler/type_util.m: compiler/typecheck.m: compiler/unify_proc.m: compiler/untupling.m: compiler/unused_imports.m: Handle the context field in the constructor and constructor_arg types. compiler/check_hlds.m: Add the xml_documentation module. |
||
|
|
863874df85 |
Document my recent change implementing coverage testing.
Estimated hours taken: 6 Branches: main Document my recent change implementing coverage testing. At the same time, eliminate the old hack that allowed a file containing a list of file names to be considered a trace count file. We haven't needed it since the addition of mtc_union, and it can lead to incomprensible error messages. (The presence of the old hack made documenting coverage testing harder.) In the process, fix the tools code for rerunning failed test cases only. doc/user_guide.texi: Document my recent change implementing coverage testing, and the elimination of the old hack. mdbcomp/trace_counts.m: Modify the predicates for reading in trace count files along the lines above. mdbcomp/slice_and_dice.m: Modify the predicates for reading in slices and dices along the lines above. Rename some function symbols to avoid ambiguities. compiler/tupling.m: slice/mcov.m: slice/mtc_diff.m: slice/mtc_union.m: trace/mercury_trace_declarative.c: Conform to the changes above. slice/mcov.m: Fix the usage message, which referred to this program by its old name mct. Allow the output to be restricted to a set of named modules only. This is to make testing easier. slice/mtc_diff.m: Rename the long form of the -o option from --out to --output-file, to make it consistent with the other programs. tests/run_one_test: tools/bootcheck: Modify the algorithm we use to gather trace counts for the Mercury compiler from both passed and failed test cases to run mtc_union periodically instead of gathering all the trace counts file and keeping them to the end (which takes far too much disk space). Fix an old bug: gather trace counts from executions of the Mercury compiler only. tests/debugger/Mmakefile: tests/debugger/dice.passes: Modify the dice test case to compute the union of the trace counts for the passed versions of this test case to use mtc_union to create dice.passes, instead of having dice.passes statically contain the list of the names of the passed trace count files (since that capability is deleted by this diff). tools/bootcheck: tests/Mmake.common: Fix the code for rerunning failed tests only. mdbcomp/prim_data.m: Eliminate some ambiguities in predicate names. compiler/*.m: Conform to the change to prim_data.m. compiler/error_util.m: Add reading files as a phase in error messages. compiler/mercury_compile.m: Use the new facilities in error_util for printing an error message. |
||
|
|
f070e2a1b7 |
Convert the make_hlds stage of the compiler from printing out error messages
Estimated hours taken: 14 Branches: main Convert the make_hlds stage of the compiler from printing out error messages one at a time to gathering them all up and printing them all at once after sorting and deleting duplicates. This approach makes it much easier to be consistent about updating the exit status in the I/O state and the error count in the module info, and indeed this diff fixes some bugs in this area. This approach also means that instead of threading a pair of I/O states through these modules, we now mostly thread through a list of error specifications. In a couple of places, we create the I/O states we need for printing progress messages using trace goals. configure.in: Check that the installed compiler supports trace goals (perhaps with warnings), since the compiler now uses them. compiler/Mercury.options: Temporarily compensate for a bug in the handling of trace goals. compiler/add_class.m: compiler/add_clause.m: compiler/add_mode.m: compiler/add_pragma.m: compiler/add_pred.m: compiler/add_solver.m: compiler/add_type.m: compiler/field_access.m: compiler/foreign.m: compiler/make_hlds_error.m: compiler/make_hlds_passes.m: compiler/make_hlds_warn.m: compiler/module_qual.m: compiler/modules.m: compiler/qual_info.m: compiler/state_var.m: compiler/superhomogeneous.m: Make the change described at the top. In many cases, this required changing code to error util instead of io.write_strings to create the error messages. In some cases, move a predicate used in one module but defined in another module to the first module. Delete some predicates whose job used to be to test options to see whether a message should be generated, since we can now embed the option value that a message depends on in the error message itself. In module_qual.m, remove unnecessary module qualifications. In modules.m, give explicit names to a bunch of lambda expressions. Reformat comments to exploit the available columns. compiler/check_typeclass.m: Conform to the changes above. Mark with XXX the places where we are ignoring the proper update of the error count in module_infos. compiler/modes.m: compiler/post_typecheck.m: compiler/stratify.m: compiler/table_gen.m: compiler/unused_args.m: Use error_specs instead of plain pieces to print error messages. compiler/options.m: Rename an option that conflicts with a language keyword. compiler/handle_options.m: Conform to the change to options.m. compiler/prog_data.m: Rename some function symbols that conflict with language keywords. compiler/prog_out.m: compiler/prog_io_util.m: Conform the change above, and delete some predicates that have now become unused. compiler/mercury_compile.m: Rename a predicate to avoid an ambiguity. Conform to the changes above. compiler/hlds_out.m: compiler/make.module_dep_file.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/mode_errors.m: compiler/prog_io.m: Conform to the changes above. In some cases, delete predicates that aren't needed anymore. tests/invalid/errors.err_exp: tests/invalid/errors1.err_exp: tests/invalid/state_vars_test3.err_exp: tests/invalid/undef_inst.err_exp: Update this expected output to reflect the fact that we now sort the error messages. tests/invalid/missing_interface_import2.err_exp: tests/warnings/double_underscore.exp: Update this expected output to reflect the fact that we no longer print the same error message twice. tests/invalid/missing_det_decls.err_exp: Update this expected output to reflect the fact that we now indent an error messages correctly. tests/invalid/multimode_syntax.err_exp: Update this expected output to reflect the fact that we now use error_util instead of plain io.writes to create an error message. tests/invalid/typeclass_test.err_exp: tests/invalid/unsatisfiable_constraint.err_exp: Update this expected output to reflect minor improvements in the formatting of an error message. |
||
|
|
5eee81204e |
A big step towards cleaning up the way we handle errors.
Estimated hours taken: 28 Branches: main A big step towards cleaning up the way we handle errors. The main changes are - the provision, in error_util.m, of a mechanism for completely specifying everything to do with a single error in one data structure, - the conversion of typecheck_errors.m from using io.write_string to using this new capability, - the conversion of mode_errors.m and det_report.m from using write_error_pieces to using this new capability, and - consistently using the quoting style `symname'/N instead of `symname/N' in error_util and hlds_error_util (previously, error_util used the former but hlds_error_util used the latter). This diff sets up later diffs which will collect all error specifications in a central place and print them all at once, in order. compiler/error_util.m: The new type error_spec, which completely specifies an error. An error_spec may have multiple components with different contexts and may have parts which are printed only under certain conditions, e.g. a given option being set. Each error_spec has a severity and also records which phase found the error. The new predicate write_error_spec takes care of updates of the exit status for errors and (if --halt-at-warn is set) for warnings. It also takes care of setting the flag that calls for the reminder about -E at the end. This diff also makes it simpler to use the ability to print arbitrary output. It adds the ability to include integers in messages directly, and the ability to create blank lines. It renames some function symbols to avoid ambiguities. Move a predicate that only used by typecheck_errors.m to that file. compiler/hlds_error_util.m: Switch to the `symname'/N quoting style for describing predicates and procedures. compiler/prog_util.m: Switch to the `symname'/N quoting style for describing sym_name_and_arity. compiler/hlds_module.m: Provide a predicate to increment the number of errors not by one, but by the number of errors printed by write_error_spec. Fix some documentation rot. compiler/typecheck_errors.m: Use write_error_spec instead of io.write_strings to print error messages. In several cases, improve the formatting of the messages printed. Mark a number of places where we don't (yet) update the number of errors in the module_info correctly. Rename the checkpoint predicate to avoid potential ambiguity with similar predicates in e.g. mode_info. compiler/typecheck_info.m: Group the code for writing stuff out together in one bunch. For each such predicate, create another that returns a list of format components instead of doing I/O directly. compiler/typecheck.m: Move the code for writing inference messages here from typecheck_errors.m, since these messages aren't errors. compiler/mode_errors.m: compiler/det_report.m: Use write_error_spec instead of write_error_pieces. In the case of mode_errors.m, this means we now get correct the set of circumstances in which we set the flag that calls for the reminder about -E. compiler/add_pragma.m: compiler/add_type.m: Convert some code that used to use write_error_pieces to print error messages to use write_error_spec instead. compiler/assertion.m: compiler/hlds_pred.m: compiler/post_typecheck.m: Assertion.m used to contain some code to check for assertions in the interface that mention predicates that are not exported. Move most of this code to post_typecheck.m (which is where this code used to be called from). One small part, which is a test for a particular property of import_statuses, is moved to hlds_pred.m to be with all the other similar tests of import_statuses. compiler/prog_util.m: Change unqualify_name from a predicate to a function. compiler/pred_table.m: compiler/hlds_out.m: Avoid some ambiguities by adding a suffix to the names of some predicates. compiler/*.m: Conform to the changes above. library/list.m: Add a function that was previously present (with different names) in two compiler modules. tests/hard_coded/allow_stubs.exp: Update the format of the expected exception. tests/invalid/errors2.err_exp2: Remove this file. As far as I can tell, it was never the correct expected output on the main branch. (It originated on the alias branch way back in the mists of time.) tests/invalid/*.err_exp: tests/invalid/purity/*.err_exp: tests/warnings/*.exp: Update the format of the expected error messages. tests/recompilation/*.err_exp.2: Update the format of the expected messages about what was modified. |
||
|
|
2b2f3d3cbe |
This diff contains no algorithmic changes.
Estimated hours taken: 8 Branches: main This diff contains no algorithmic changes. It merely renames apart a bunch of function symbols to reduce ambiguity. Basically I went through prog_data.m, prog_item.m, hlds_data.m, hlds_goal.m and hlds_pred.m looking for type definitions containing function symbol names that were either language "keywords" (e.g. "terminates", which is an annotation on foreign_procs), used with slightly different meanings in several types (e.g. "sym"), or both (e.g. "call"). When I found such type definitions, I changed the names of the function symbols, usually by adding a prefix or suffix indicating the type to all function symbols of the type. For example, the old function symbol "foreign_proc" in type "pragma_type" is now named "pragma_foreign_proc", and the names of all other function symbols in that type also start with "pragma_". All of this should yield simpler compiler error messages when we make mistakes, and will make it more likely that looking up a function symbol using a tags file will take you to the actual definition of the relevant instance of that function symbol. However, the most important benefit is the increase in the readability of unfamiliar code; the reader won't have to emulate the compiler's type ambiguity resolution algorithm (which in many cases used to require distinguishing between f/14 and f/15 by counting the arguments, e.g. for "pred_or_func"). compiler/prog_data.m: compiler/prog_item.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/hlds_pred.m: Rename function symbols as explained above. compiler/*.m: Conform to the function symbol renames. In some cases, rename other function symbols as well. Minor style fixes, e.g. replace if-then-elses with switches, or simple det predicates with functions. |
||
|
|
aeeedd2c13 |
Standardize formatting of comments at the beginning of modules.
compiler/*.m: Standardize formatting of comments at the beginning of modules. |
||
|
|
835d8315ef |
Do not allow discriminated unions with a single zero-arity constructor to have
Estimated hours taken: 10
Branches: main, release
Do not allow discriminated unions with a single zero-arity constructor to have
user-defined equality or comparison. Defining such types causes an assertion
failure in the compiler because the types are considered to be dummy types and
the runtime currently doesn't support (and probably won't ever) d.u. dummy
types with user-defined equality or comparison.
Fix another bug where the compiler was not printing out the `recompile with
-E' prompt at the appropriate time. The bug was caused by the fact that there
were several copies of the globals structure and the one that was being
checked at the time the prompt was being printed out was not the one that had
been updated during the rest of compilation.
compiler/add_types.m:
Emit an error message if an attempt is made to define a d.u. dummy
type with user-defined equality or comparison.
compiler/globals.m:
Remove the extra_error_info field from the globals structure and turn
it into a mutable. Export access predicates for this mutable. The
reason for doing this is that the compiler was sometimes looking at
the wrong copy of the globals structure when checking the value of
this flag - this meant that sometimes the recompile with `-E' prompt
was not being displayed. Turning this flag into a mutable avoids the
problem because now there is only one copy.
compiler/make_hlds.m:
s/__/./ in a few spots.
doc/reference_manual.texi:
Mention the new restrictions on discriminated union types with
user-defined equality or comparison.
tests/invalid/exported_unify2.m:
tests/invalid/exported_unify3.m:
Change some types with user-defined equality or comparison so that
they are no longer dummy types. These test cases have not been
triggering the assertion failure in the compiler because they are only
error checked and the assertion that is failing occurs further along
in the compilation process.
tests/invalid/user_eq_dummy.{m,err_exp}:
Test the new error message for dummy types with user-defined equality
or comparison.
tests/invalid/extra_info_prompt.{m,err_exp}:
Test that the recompile with `-E' prompt is being displayed when it
should.
tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
Include the new test cases.
Where there is a verbose version of the error message compile with
`-E'.
tests/recompilation/add_type_re.err_exp.2:
tests/invalid/*.err_exp:
Update expected outputs to conform to the above.
|
||
|
|
74ce85d476 |
Provide a mechanism for collecting statistics about tabling operations,
Estimated hours taken: 60
Branches: main
Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.
Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.
Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.
Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.
To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.
Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.
runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
Move the description of structure of tables from mercury_stack_layout.h
to mercury_tabling.h, since we now need it for statistics even if
execution tracing is not enabled.
Modify those data structures to have room for the statistics.
Don't distinguish "strict", "fast_loose" and "specified" memoing
as separate eval methods; treat them as just different kinds
of the same eval method: "memo".
Remove underscores from the names of some types that the style guide
says shouldn't be there.
runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
Modify the approach we use for macros that implement the predicates
of library/table_builtin.m. Instead of selecting between debug and
nondebug based on whether MR_TABLE_DEBUG is defined or not, add
an explicit argument controlling this to each debuggable macro.
The advantage of the new arrangement is that it scales. Another
argument controls whether we are computing statistics (and if yes,
where do we put it), and a third argument controls whether we maintain
back links in the tries and hash tables (this last argument is present
but is ignored for now).
Since the values of the arguments will be known when the .c files
containing calls to these macros are compiled, we pay the space and
time cost of debugging, statistics gathering and the maintenance of
back links if and only we need the revelant functionality.
Provide macros for limited backward compatibility with the old set
of macros; these allow workspaces created by old compilers to work
with the new macros in the runtime. The old macros followed the
naming scheme MR_table_*, the new ones are named MR_tbl_*.
runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
New files containing parts of the old mercury_tabling.c. Each of these
files contains the body of the functions that used to be in
mercury_tabling.c. The new mercury_tabling.c #includes each of these
files more than once, to provide more than one variant of the old
function. These variants differ in aspects such as whether debugging
is enabled or statistics is being collected. Each variant therefore
incurs only the time costs it needs to. (We pay the space cost of
having all these variants all the time of course, but this cost
is negligible.)
runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
New files that serve as wrappers around the newly #included files,
controlling how they handle statistics.
runtime/mercury_tabling.c:
Delete functions now in the new files, and #include them instead.
Delete the data structures that used to contain summary statistics;
the new approach keeps statistics in compiler-generated,
procedure-specific data structures.
runtime/mercury_trace_base.c:
Use the new versions of the tabling macros to access the I/O table.
runtime/mercury_type_info.h:
Update some documentation for the movement of code out of
mercury_tabling.c.
runtime/mercury_types.h:
Provide forward declarations of the identifiers denoting the new types
in mercury_tabling.h.
runtime/mercury_grade.h:
Increment the exec trace version number, since we have changed
a part of the exec trace structure.
runtime/mercury_bootstrap.h:
Fix some temporary issues that arise from some renames above.
runtime/mercury_hash_lookup_or_add_body.h:
Fix comment.
runtime/Mmakefile:
Mention the new files and the dependencies that involve them.
library/table_builtin.m:
Provide a type for representing statistics and a predicate for
printing statistics.
Use the updated versions of the macros in
runtime/mercury_tabling_preds.h.
compiler/prog_item.m:
Change representation of tabling pragmas to allow room for the new
attributes.
Allow an item to be marked as being generated by the compiler
as a result of a pragma memo attribute. We use this for the reset
and statistics predicates.
compiler/mercury_to_mercury.m:
Write out the new attributes of the tabling pragma.
compiler/prog_data.m:
compiler/hlds_data.m:
Change the cons_id that used to refer to a procedure's call table root
to refer to the entirety of the new data structure now containing it.
The compiler now needs a way to refer to the other components of this
new data structure, since it contains the statistics.
As in the runtime, don't distinguish "strict", "fast_loose" and
"specified" memoing as separate eval methods; treat them as just
different kinds of the same eval method: "memo".
Rename some of the uses of the function symbols "c", "java", "il".
compiler/hlds_pred.m:
Add an extra field in proc_infos for storing any tabling attributes.
Change the existing proc_info field that records information about
the kinds of arguments of tabled procedures to record the information
needed by the debugger too. This was needed to allow us to shift all
the RTTI for procedure-specific tables (as opposed to the RTTI for
the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
without duplicating the data (which would be a maintenance problem).
Reformat some comments to make them easier to read.
compiler/layout.m:
compiler/layout_out.m:
Delete the part of the exec trace information that used to record
RTTI for tables, since this information is not generated only as
part of the debugger data structures anymore.
compiler/prog_io_pragma.m:
Recognize the updated syntax for tabling pragmas.
compiler/add_pragma.m:
When processing tabling pragmas for inclusion in the HLDS, create
any reset and statistics predicates they ask for.
compiler/make_hlds_passes.m:
Export a predicate now needed by add_pragma.m.
Handle the new attributes on tabling pragmas
compiler/globals.m:
Change the function symbols of the types describing backends and
foreign languages to say what they are. Previously, both types (as well
as several others) included the function symbol "c"; now, they are
target_c and lang_c respectively.
compiler/table_gen.m:
Implement the changes described at the top.
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/goal_util.m:
compiler/hlds_goal.m:
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/rtti.m:
Provide types for representing the runtime's data structures for
tabling (which are now significantly more complex than a single word)
and predicates for manipulating them, for use by both the ml and ll
backends.
compiler/llds.m:
Replace the comp_gen_c_var type with the tabling_info_struct type,
which contains the information needed to create the per-procedure
tabling data structures.
Replace references to call tables with references to the various
components of the new tabling data structures.
compiler/llds_out.m:
Add code to write out tabling_info_structs.
Delete the code required for the old, hacky way of resetting tables.
Reorder some code more logically.
compiler/proc_gen.m:
Generate tabling_info_structs.
compiler/stack_layout.m:
Don't generate the information now generated in proc_gen.m.
compiler/mlds.m:
Give mlds_proc_labels their own function symbols, instead of using
a pair. Rename some other function symbols to avoid ambiguity and add
expressiveness.
Provide for the representation of references to the various components
of the new tabling data structures, and for the representation of their
types.
compiler/ml_code_gen.m:
When generating code for a tabled procedure, generate also the data
structures required for its table.
compiler/rtti_to_mlds.m:
compiler/ml_util.m:
Move some predicates from rtti_to_mlds.m to ml_util.m, since we
now also want to call them from ml_code_gen.m.
compiler/name_mangle.m:
Add some utility predicates.
compiler/options.m:
Delete the old --allow-table-reset option.
Add the new --table-debug option.
Comment out an implementor-only option.
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
Conform to the changes above, and/or improve some comments.
mdbcomp/prim_data.m:
Make the names of the function symbols of the proc_label type more
expressive and less ambiguous.
mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
Use . instead of __ as module qualifier.
Conform to the change to prim_data.m.
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
Conform the change to mdbcomp/prim_data.m.
tests/debugger/Mercury.options:
Don't specify --allow-table-reset for fib.m, since that option
doesn't exist anymore.
tests/debugger/fib.m:
Use the new mechanism for resetting the table.
tests/debugger/print_table.m:
Use the new syntax for pragma memo attributes.
tests/invalid/specified.{m,err_exp}:
Use to the new syntax and reset method for pragma memo attributes.
Test the handling of errors in the new attribute syntax.
tests/tabling/Mercury.options:
Don't specify --allow-table-reset for specified.m, since that option
doesn't exist anymore.
tests/tabling/specified.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables. We could also use this test case
for testing the printing of statistics, but the format of that
output is still not final.
tests/tabling/fast_loose.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables.
trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
Conform to the changes in the RTTI data structures regarding tabling.
Remove underscores from the names of some types that the style guide
says shouldn't be there.
library/robdd.m:
Comment out the tabling pragma until this change is bootstrapped.
Without this, the conflict between the old calls to macros generated
by the existing compiler and the new definition of those macros
in the runtime would cause errors from the C compiler.
|
||
|
|
46a67b0b48 |
When the typechecker finds highly ambiguous overloading, print what symbols
Estimated hours taken: 16
Branches: main
When the typechecker finds highly ambiguous overloading, print what symbols
were overloaded, and where they occurred. Without this information, it is
very hard to fix the error if the predicate body is at all large.
Fix some software engineering problems encountered during this process.
Modify some predicates in error_util in order to simplify their typical usage.
Change the type_ctor type to be not simply a sym_name - int pair but a type
with its own identifying type constructor. Change several other types that
were also sym_name - int pairs (mode_id, inst_id, item_name, module_qual.id
and the related simple_call_id) to have their own function symbols too.
compiler/typecheck_info.m:
Add a field to the typecheck_info structure that records the overloaded
symbols encountered.
compiler/typecheck.m:
When processing ambiguous predicate and function symbols, record this
fact in the typecheck_info.
Add a field to the cons_type_info structure to make this possible.
compiler/typecheck_errors.m:
When printing the message about highly ambiguous overloading,
what the overloaded symbols were and where they occurred.
compiler/error_util.m:
Make error_msg_specs usable with plain in and out modes by separating
out the capability requiring special modes (storing a higher order
value in a function symbol) into its own, rarely used type.
Make component_list_to_line_pieces a bit more flexible.
compiler/prog_data.m:
compiler/module_qual.m:
compiler/recompilation.m:
Change the types listed above from being equivalence types (pairs)
to being proper discriminated union types.
compiler/*.m:
Conform to the changes above.
In some cases, simplify the code's use of error_util.
tests/warnings/ambiguous_overloading.{m,exp}:
Greatly extend this test case to test the new functionality.
tests/recompilation/*.err_exp.2
Reflect the fact that the expected messages now use the standard
error_util way of quoting sym_name/arity pairs.
|
||
|
|
459847a064 |
Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18 Branches: main Move the univ, maybe, pair and unit types from std_util into their own modules. std_util still contains the general purpose higher-order programming constructs. library/std_util.m: Move univ, maybe, pair and unit (plus any other related types and procedures) into their own modules. library/maybe.m: New module. This contains the maybe and maybe_error types and the associated procedures. library/pair.m: New module. This contains the pair type and associated procedures. library/unit.m: New module. This contains the types unit/0 and unit/1. library/univ.m: New module. This contains the univ type and associated procedures. library/library.m: Add the new modules. library/private_builtin.m: Update the declaration of the type_ctor_info struct for univ. runtime/mercury.h: Update the declaration for the type_ctor_info struct for univ. runtime/mercury_mcpp.h: runtime/mercury_hlc_types.h: Update the definition of MR_Univ. runtime/mercury_init.h: Fix a comment: ML_type_name is now exported from type_desc.m. compiler/mlds_to_il.m: Update the the name of the module that defines univs (which are handled specially by the il code generator.) library/*.m: compiler/*.m: browser/*.m: mdbcomp/*.m: profiler/*.m: deep_profiler/*.m: Conform to the above changes. Import the new modules where they are needed; don't import std_util where it isn't needed. Fix formatting in lots of modules. Delete duplicate module imports. tests/*: Update the test suite to confrom to the above changes. |
||
|
|
be5b71861b |
Convert almost all the compiler modules to use . instead of __ as
Estimated hours taken: 6 Branches: main compiler/*.m: Convert almost all the compiler modules to use . instead of __ as the module qualifier. In some cases, change the names of predicates and types to make them meaningful without the module qualifier. In particular, most of the types that used to be referred to with an "mlds__" prefix have been changed to have a "mlds_" prefix instead of changing the prefix to "mlds.". There are no algorithmic changes. |
||
|
|
18c0510231 |
Improve the formatting of some error messages by using error_util
Estimated hours taken: 2
Branches: main
Improve the formatting of some error messages by using error_util
and hlds_error_util to handle the formatting of the error messages.
compiler/error_util.m:
Add a new format component `quote', which is identical to `fixed'
except that it outputs it's argument surrounded by `' quotes.
compiler/add_clause.m:
compiler/add_type.m:
compiler/make_hlds_passes.m:
compiler/options_file.m:
compiler/qual_info.m:
compiler/stratify.m:
Use the error_util to format warning/error messages rather than
doing it manually.
compiler/passes_aux.m:
complier/hlds_out.m:
Update comments.
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/multimode_dcg.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/sub_c.err_exp:
tests/invalid/types.err_exp:
Update the expected outputs of these test cases to account
for formatting changes introduced by the above.
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/non_stratification.{exp,m}:
Add a test case for the `--warn-non-stratification' option.
|
||
|
|
45fdb6c451 |
Use expect/3 in place of require/2 throughout most of the
Estimated hours taken: 4 Branches: main compiler/*.m: Use expect/3 in place of require/2 throughout most of the compiler. Use unexpected/2 (or sorry/2) in place of error/1 in more places. Fix more dodgy assertion error messages. s/map(prog_var, mer_type)/vartypes/ where the latter is meant. |
||
|
|
e9c112bedc |
Implement support for writing Mmakefile in the style of
"Recursive make considered harmful". This consists of two parts, giving mmake the optional ability to ignore the .d files in the current directory. The second part is adding support to the compiler to write out just the .d file. We may need to ignore the .d files in the current directory because we may have included that file from another directory and we don't want to define rules twice. scripts/mmake.in: scripts/Mmake.vars.in: If the mmake variable MMAKE_AUTO_INCLUDE_DS is set to no then don't include the rules defined in the .d files in the current directory. compiler/mercury_compile.m: Add support for the --generate-dependency-file flag which just writes out the .d file for a module and then stops. compiler/options.m: Add the generate_dependency_file option. compiler/mercury_compile.m: compiler/add_type.m: compiler/handle_options.m: Make sure that generate_dependency_file implies that we don't need to build/link anything. doc/user_guide.texi: Document the --generate-dependency-file flag. |
||
|
|
f9fe8dcf61 |
Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
|
||
|
|
b2012c0c0e |
Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
Estimated hours taken: 8 Branches: main compiler/*.m: Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst' and 'mer_mode'. This is to avoid the need to parenthesize these type names in some contexts, and to prepare for the possibility of a parser that considers those words to be reserved words. Rename some other uses of those names (e.g. as item types in recompilation.m). Delete some redundant synonyms (prog_type, mercury_type) for mer_type. Change some type names (e.g. mlds__type) and predicate names (e.g. deforest__goal) to make them unique even without module qualification. Rename the function symbols (e.g. pure, &) that need to be renamed to avoid the need to parenthesize them. Make their replacement names more expressive. Convert some more modules to four space indentation. Avoid excessively long lines, such as those resulting from the automatic substitution of 'mer_type' for 'type'. |
||
|
|
d609181cb9 |
Consider types of the form
Estimated hours taken: 30
Branches: main
Consider types of the form
:- type x ---> f.
to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.
runtime/mercury_type_info.h:
Add a new type_ctor_rep for dummy types.
runtime/mercury_tabling.h:
Add a representation for "tabled" dummy types, which don't actually
have a level in the trie, so that the runtime system can handle that
fact.
runtime/mercury_ml_expand_body.h:
When deconstructing a value of a dummy type, ignore the actual value
(since it will contain garbage) and instead return the only possible
value of the type.
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
Handle the type_ctor_rep of dummy types.
runtime/mercury_builtin_types.c:
Provide a place to record profiling information about unifications and
comparisons for dummy types.
runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
Add a new type_ctor_rep for dummy types, and fix some previous
discrepancies in type_ctor_reps.
mdbcomp/prim_data.m:
Move a bunch of predicates for manipulating special_pred_ids here from
the browser and compiler directories.
Rename the function symbols of the special_pred_id type to avoid the
need to parenthesize the old `initialise' function symbol.
Convert to four-space indentation.
mdbcomp/rtti_access.m:
Don't hardcode the names of special preds: use the predicates in
prim_data.m.
Convert to four-space indentation.
browser/declarative_execution.m:
Delete some predicates whose functionality is now in
mdbcomp/prim_data.m.
compiler/hlds_data.m:
Replace the part of du type that says whether a type an enum, which
used to be a bool, with something that also says whether the type is a
dummy type.
Convert to four-space indentation.
compiler/make_tags.m:
Compute the value for the new field of du type definitions.
compiler/hlds_out.m:
Write out the new field of du type definitions.
compiler/rtti.m:
Modify the data structures we use to create type_ctor_infos to allow
for dummy types.
Convert to four-space indentation.
compiler/type_ctor_info.m:
Modify the code that generates type_ctor_infos to handle dummy types.
compiler/type_util.m:
Provide predicates for recognizing dummy types.
Convert to four-space indentation.
compiler/unify_proc.m:
Generate the unify and compare predicates of dummy types using a new
code scheme that avoids referencing arguments that contain garbage.
When generating code for unifying or comparing other types, ignore
any arguments of function symbols that are dummy types.
Don't use DCG style access predicates.
compiler/higher_order.m:
Specialize the unification and comparison of values of dummy types.
Break up an excessively large predicate, and factor out common code
from the conditions of a chain of if-then-elses.
compiler/llds.m:
For each input and output of a foreign_proc, include a field saying
whether the value is of a dummy type.
compiler/pragma_c_gen.m:
Fill in the new fields in foreign_proc arguments.
compiler/hlds_goal.m:
Rename some predicates for constructing unifications to avoid
unnecessary ad-hoc overloading. Clarify their documentation.
Rename a predicate to make clear the restriction on its use,
and document the restriction.
Add a predicate for creating simple tests.
Add a utility predicate for setting the context of a goal directly.
compiler/modules.m:
Include dummy types interface files, even if they are private to the
module. This is necessary because with the MLDS backend, the generated
code inside the module and outside the module must agree whether a
function returning a value of the type returns a real value or a void
value, and this requires them to agree on whether the type is dummy
or not.
The impact on interface files is minimal, since very few types are
dummy types, and changing a type from a dummy type to a non-dummy type
or vice versa is an ever rarer change.
compiler/hlds_pred.m:
Provide a representation in the compiler of the trie step for dummy
types.
compiler/layout_out.m:
Print the trie step for dummy types.
compiler/table_gen.m:
Don't table values of dummy types, and record the fact that we don't
by including a dummy trie step in the list of trie steps.
compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
Conform to the changes above.
compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
Conform to the changes above.
Convert to four-space indentation.
compiler/mlds_to_java.m:
compiler/var_locn.m:
Conform to the changes above, which requires threading the module_info
through the module.
Convert to four-space indentation.
compiler/mercury_compile.m:
Pass the module_info to mlds_to_java.m.
compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
Delete some previously missed references to the temporary types used
to bootstrap the change to the type_info type's arity.
compiler/polymorphism.m:
Turn back on an optimization that avoids passing parameters (such as
type_infos) to foreign_procs if they are not actually referred to.
compiler/prog_data.m:
Convert to four-space indentation.
library/svvarset.m:
Add a missing predicate.
trace/mercury_trace.c:
Delete the unused function that used to check for dummy types.
tests/debugger/field_names.{m,inp,exp}:
Add to this test case a test of the handling of dummy types. Check that
their values can be printed out during normal execution, and that the
debugger doesn't consider them live nondummy variables, just as it
doesn't consider I/O states live nondummy variables.
|
||
|
|
b54ab42d70 |
A simple tool for performing substitutions on the source files of the
Estimated hours taken: 0.5 Branches: main tools/subst: A simple tool for performing substitutions on the source files of the compiler. compiler/*.m: Change the names of the get predicates operating on module_infos to include "get" in the name, for uniformity. This was done mostly by the following sed script, with some manual cleanup afterwards to reduce excessive line lengths. s/module_info_types/module_info_get_type_table/ s/module_info_set_types/module_info_set_type_table/ s/module_info_insts/module_info_get_inst_table/ s/module_info_set_insts/module_info_set_inst_table/ s/module_info_modes/module_info_get_mode_table/ s/module_info_set_modes/module_info_set_mode_table/ s/module_info_ctors/module_info_get_cons_table/ s/module_info_set_ctors/module_info_set_cons_table/ s/module_info_classes/module_info_get_class_table/ s/module_info_set_classes/module_info_set_class_table/ s/module_info_instances/module_info_get_instance_table/ s/module_info_set_instances/module_info_set_instance_table/ s/module_info_superclasses/module_info_get_superclass_table/ s/module_info_set_superclasses/module_info_set_superclass_table/ s/module_info_assertion_table/module_info_get_assertion_table/ s/module_info_exclusive_table/module_info_get_exclusive_table/ s/module_info_ctor_field_table/module_info_get_ctor_field_table/ s/module_info_name/module_info_get_name/ s/module_info_globals/module_info_get_globals/ s/module_info_contains_foreign_types/module_info_get_contains_foreign_types/ s/module_info_num_errors/module_info_get_num_errors/ s/module_info_type_ctor_gen_infos/module_info_get_type_ctor_gen_infos/ s/module_info_stratified_preds/module_info_get_stratified_preds/ s/module_info_unused_arg_info/module_info_get_unused_arg_info/ s/module_info_exception_info/module_info_get_exception_info/ s/module_info_type_spec_info/module_info_get_type_spec_info/ s/module_info_no_tag_types/module_info_get_no_tag_types/ s/module_info_analysis_info/module_info_get_analysis_info/ s/module_info_aditi_top_down_procs/module_info_get_aditi_top_down_procs/ |
||
|
|
e069d16ab1 |
Do not display the For more information try recompiling with -E'' prompt
Estimated hours taken: 1.5 Branches: main Do not display the `For more information try recompiling with `-E'' prompt unless we really mean it, i.e. there is actually more information available. XXX This change is incomplete for the mode_errors module because that module requires more substantial changes to make this work - I'll do that as a separate diff. compiler/globals.m Add a new global (and access predicates) that keeps track of whether we have any verbose error information that could be displayed if we recompiled with `-E'. compiler/mercury_compile.m Check the new global flag before prompting the user to recompile with `-E'. compiler/mode_errors.m Add an XXX comment about needing to respect the extra error info flag properly. compiler/accumulator.m compiler/add_clause.m compiler/add_pred.m compiler/add_type.m compiler/assertion.m compiler/check_typeclass.m compiler/det_report.m compiler/magic_util.m compiler/make_hlds_error.m compiler/modes.m compiler/module_qual.m compiler/modules.m compiler/post_typecheck.m compiler/purity.m compiler/stratify.m compiler/typecheck_errors.m Set the new global flag when we come across an error for which we have a verbose error message. tests/recompilation/*: tests/invalid/*: Update expected error files. |
||
|
|
3fc6b3f128 |
Change the representation of types in the compiler.
Estimated hours taken: 30 Branches: main Change the representation of types in the compiler. We also add some support for handling kinds, which will be used later when we have a kind system. There are a number of places where kinds are not yet handled correctly -- we assume that all kinds will be `star'. Each of these locations is flagged with a comment that contains "XXX kind inference:". compiler/prog_data.m: Implement the new version of type (type). Change the definition of type_param to be a variable instead of a term, since all parameters must be variables anyway. Implement versions of varset.merge_* which work with tvarsets and produce renamings instead of substitutions. Renamings are more convenient than substitutions because we don't need to know the kinds of type variables in order to build the renaming, and in any case the substitutions shouldn't have anything other than variables in the range so renamings will be more efficient and safe. Define the type of kinds, and provide a couple of utility predicates to operate on them. compiler/prog_io.m: Parse type definition heads as a sym_name and list of type_params, rather than a functor. Handle this change in other predicates. Allow parse errors to be returned by get_with_type/3, and handle these errors. Remove parse_type/2. This predicate didn't do any processing, it just forwarded handling to convert_type/2. compiler/prog_io_typeclass.m: Change type_is_functor_and_vars to handle the new representation of types. In doing so, we retain the old behaviour that pure predicates pass this test, but no other pred or func types. This behaviour is arguably incorrect, but there is little point changing the behaviour at the moment. Instead we should remove these kind of restrictions entirely, but that should be done later. compiler/prog_io_util.m: Provide predicates to both parse and unparse types. We need to unparse types before printing them out, since we do a lot of special case handling when printing out terms and we don't want to duplicate this functionality for types. compiler/module_qual.m: Remove report_invalid_type. We now report ill-formed types during parsing. compiler/superhomogeneous.m: Handle errors from the parsing of type expressions. compiler/prog_out.m: Provide a predicate to convert builtin_types to their string names, and vice-versa. compiler/prog_type.m: Add a bunch of simple tests to use on types which may have kind annotations present. In such cases, types do not have a canonical representation so the simple handling of these tests is not what we want. (Note that these are only required in early phases. The kind annotations -- when they are implemented -- will be removed before type checking.) Consistently handle the application of renamings, substitutions and recursive substitutions to various data structures. compiler/mercury_to_mercury.m: Implement mercury_output_type, mercury_format_type and mercury_type_to_string. These convert the type to a term before formatting -- the reason for this is so that appropriate parentheses are used when formatting operators. This results in some slight changes to error messages, which are reflected in changes to the expected output files in the tests. Remove the old version of mercury_type_to_string. Change the argument ordering of mercury_format_var to be consistent with mercury_format_type. (Other predicates in this module should probably be changed in a similar way, since this argument ordering is more amenable to higher-order programming. But that can be left for another change.) compiler/type_util.m: Implement type unification. The behaviour is much the same as the previous behaviour, except that we now handle apply/N types properly, and we also allow for kind annotations. Implement an occurs check for types. Remove the example definition of replace_eqv_type. It isn't used and would no longer work anyway even if it would have worked before. Add a tvar_kind_map field to ctor_defn. The functions type_info_type and type_ctor_info_type now return types with `void' as their argument, rather than the type that the type_info or type_ctor_info was for. Remove type_util.real_vars/2, since it no longer does anything different from prog_type.vars/2. Remove the commented out implementation of type_to_ctor_and_args/3. Its implementation is in prog_type.m, and has changed significantly in any case. compiler/add_clause.m: Move parse_purity_annotation/3 to prog_io_util.m. compiler/check_typeclass.m: Remove apply_substitution_to_var_list/3, since we now have predicates in prog_type.m to handle such things. compiler/continuation_info.m: compiler/trace.m: Use prog_type.vars/2 instead of type_util.real_vars/2. The two predicates have the same meaning now since type_infos don't contain any type variables. compiler/hlds_data.m: Add tvar_kind_map fields to hlds_type_defn and hlds_class_defn. compiler/hlds_pred.m: Add a tvar_kind_map field to pred_info. compiler/polymorphism.m: Add a tvar_kind_map field to poly_info. Remove unify_corresponding_types, which is no longer used. compiler/hlds_out.m: Use mercury_output_type/5 instead of term_io__write_term/4 and mercury_output_term/5. compiler/post_typecheck.m: Build the void substitution directly rather than building intermediate lists. compiler/recompilation.version.m: Use term__list_subsumes instead of type_list_subsumes, which now operates only on types. This follows up on what was suggested in an XXX comment. compiler/typecheck_errors.m: Use unparse_type/2 to format error messages. compiler/typecheck_info.m: Don't export write_type_with_bindings/5. It is no longer used outside of this module. compiler/*.m: Conform to the above changes. library/rtti_implementation.m: Fix a syntax error that went undetected in our previous implementation, and amazingly enough was compiled correctly anyway. library/term.m: Move the versions of term__unify, term__unify_list and term__list_subsumes that were implemented specifically for types to here. The version of term_unify that takes a list of bound variables (i.e., variables that should not be bound any further) is used by the subsumption check, which in turn is used by recompilation.version.m. tests/invalid/kind.err_exp: tests/invalid/tc_err1.err_exp: tests/invalid/tc_err2.err_exp: tests/misc_tests/pretty_print_test.exp: Update the expected output of these tests to match what we now do. |
||
|
|
6df9a05856 |
This diff cleans up a bunch of modules. It has no algorithmic changes
Estimated hours taken: 10 Branches: main This diff cleans up a bunch of modules. It has no algorithmic changes other than in the formatting of error messages. compiler/error_util.m: Delete the obsolete predicate append_punctuation, since the suffix format component can now do more, and do it more easily. compiler/goal_util.m: compiler/hlds_goal.m: compiler/hlds_llds.m: compiler/instmap.m: compiler/const_prop.m: Change the argument order of some the predicates exported by these modules to make them easier to use with state variable syntax. compiler/*.m: Convert a bunch of these modules to four space indentation, and fix departures from our coding style. Conform to the changed argument order above. Use suffixes instead of append_punctuation. library/string.m: Add string.foldl2. tests/invalid/circ_*.err_exp: tests/warnings/unused_args_*.exp: Expect the updated error messages, which format sym_names consistently the same way as other messages. |
||
|
|
10536c5ee0 |
Divide make_hlds.m into submodules of manageable size.
Estimated hours taken: 12 Branches: main Divide make_hlds.m into submodules of manageable size. compiler/make_hlds.m: Distribute all the code that was previously here to new submodules. Include those submodules. Keep the existing interface of this module by defining predicates that do nothing except call the actual implementation in one of those submodules. The only changes visible from outside are the renaming of a predicate and the creation of a second name, make_hlds_qual_info, for qual_info. Both changes are designed to avoid ambiguity in the presence of intermodule optimization. compiler/add_aditi.m: Submodule for dealing with aditi-specific issues. compiler/add_class.m: Submodule for handling typeclasses. compiler/add_clause.m: Submodule for handling the general processing of clauses. compiler/add_pred.m: Submodule for handling new predicates. compiler/add_special_pred.m: Submodule for handling special (unify/compare/index/init) predicates. compiler/add_type.m: Submodule for handling new types. compiler/add_mode.m: Submodule for handling new insts and modes. compiler/add_solver.m: Submodule for handling new solver types. compiler/add_pragma.m: Submodule for handling new pragmas. compiler/state_var.m: Submodule for handling the state variable transformation. compiler/superhomogeneous.m: Submodule for converting clauses to superhomogeneous form. compiler/field_access.m: Submodule for field access syntax. compiler/make_hlds_passes.m: Submodule containing the code that performs passes on the item list, adding things to the HLDS, calling the other submodules as necessary. compiler/make_hlds_warn.m: Submodule that looks for constructs that merit warnings. compiler/make_hlds_error.m: Submodule containing error messages used by more than one submodule. compiler/hlds_pred.m: Since this module defines the clauses_info and proc_id types, move the predicates that initialize values of that type here as well from make_hlds.m (deleting an unnecessary parameter from one). compiler/hlds_pred.m: compiler/prog_data.m: Move the type tvar_name_map from from hlds_pred.m to prog_data.m, since that is where similar maps are. compiler/check_typeclass.m: compiler/mercury_compile.m: Conform to the change to make_hlds_qual_info. compiler/hlds_out.m: compiler/prog_out.m: Replace two identical predicates for printing out lists of strings in hlds_out.m and make_hlds.m with just one in prog_out.m, since that is where it belongs in the compiler. compiler/prog_util.m: Move some utility predicates for substitutions and term recognition here from make_hlds.m, since they are needed by more than one submodule. Make this module conform to our coding guidelines, and convert it to four-space indentation to eliminate bad line breaks. compiler/clause_to_proc.m: compiler/hlds_code_util.m: compiler/make_tags.m: compiler/prog_mode.m: compiler/quantification.m: compiler/type_util.m: Trivial formatting changes. compiler/notes/compiler_design.html: Describe the new modules. |