Estimated hours taken: 6
Fix a bug where the compiler reported an internal error `unify_inst failed'
for certain ill-moded calls involving `any' insts.
compiler/inst_util.m:
Add code in abstractly_unify_inst to handle some more cases
of `any' that previously we didn't allow; specifically, the case
of unifying a `bound' or `ground' inst with `any'.
The new cases are allowed only in the `fake_unify' case, not in
the `real_unify' case, because code generation doesn't yet
support these cases.
Also fix a couple of unrelated bugs in abstractly_unify_inst
where the `live' case was passing `dead' rather than `live'
to unify_uniq.
compiler/prog_data.m:
Add a new compiler-generated inst name `any_inst', similar to
`ground_inst', but for insts resulting from unification with
`any' rather than unification with `ground'.
compiler/hlds_data.m:
Any a new `any_inst' table, similar to the `ground_inst' table.
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/mode_qual.m:
Minor changes to handle new `any_inst' insts.
tests/invalid/Mmake:
tests/invalid/any_mode.m:
tests/invalid/any_mode.err_exp:
Regression test for the above change.
Estimated hours taken: 30
Implement support for types with user-defined equality predicates.
Types with user-defined equality predicates are called "non-canonical types";
they may have more than one representation for the same abstract value.
That means that any attempt to deconstruct a value of a non-canonical
type, i.e. any attempt to peek at the representation, must be cc_multi.
This also implies that conceptually speaking, non-canonical types are not
members of the type classes `comparable' (compare/3) or `deconstructible'
(index/2, argument/3, functor/3, deconstruct/5). Since we don't support
type classes yet, that just means that the type-class checking is done
at runtime, i.e. any call to one of those functions for a non-canonical
type will call error/1 or fatal_error().
To make non-canonical types useful, we really need type classes,
so that the user can provide instance definitions for `comparable'
and `deconstructible' for such types. It might also be a good idea
to have a type-class `canonicalizable' which provides a function
to convert its argument to some canonical type (that would
require existential types to do nicely, but alternatively we could
just use `univ').
Note that currently the only mechanism for promising that things are
unique is via the C interface.
compiler/det_analysis.m:
Add code to check unifications that examine the
representation of a type with a user-defined equality predicate.
Any such unification must occur in a single-solution context and
must not be able to fail. Such unifications determinism have
determinism cc_multi.
compiler/det_report.m:
Add code to report errors for misuse of types with user-defined
equality predicates. (Also some other stylistic improvements:
split up a complicated predicate into subroutines, and
avoid some unnecessary code duplication.)
compiler/prog_data.m:
compiler/hlds_data.m:
Add a new `maybe(sym_name)' field to the du_type/3 constructor
to hold the name of the user-defined equality pred for the
type, if any.
compiler/prog_io.m:
Add code to parse the new `... where equality is <name>.' syntax.
Delete the old support for `... where <condition>'.
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/mercury_to_goedel.m:
Print out the new field.
compiler/base_type_layout.m:
compiler/code_util.m:
compiler/dense_switch.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/make_hlds.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/switch_detection.m:
compiler/tag_switch.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
Trivial changes to ignore (or leave unchanged)
the new field in `du_type'.
compiler/modecheck_unify.m:
Pass the term__context to unify_proc__request_unify.
compiler/typecheck.m:
Typecheck the compiler-generated unify predicates for types
with user-defined equality preds.
compiler/unify_proc.m:
For d.u. types, if the type has a user-defined equality predicate
then generate code for the compiler-generated unify predicate
that just calls the specified predicate, and generate
code for the compiler-generated compare and index predicates
that just calls some procedures in mercury_builtin.m that
report appropriate error messages.
Ensure that the automatically-generated predicates
have appropriate term__contexts everywhere, so that if
the user-defined equality predicate name is ambiguous,
non-existent, or has the wrong type, mode, or determinism,
then the error messages from type checking, mode checking,
or determinism checking refer to the type declaration.
library/mercury_builtin.m:
Add predicates builtin_index_non_canonical_type/2
and builtin_compare_non_canonical_type/2, used by
the code generated by compiler/unify_proc.m.
doc/reference_manual.texi:
Document the support for user-defined equality predicates.
library/std_util.m:
Change ML_expand() to return an indication of whether or not
the type is a non-canonical type (one with a user-defined
equality predicate). Change argument/2, functor/2, and
deconstruct/4 to abort if called for a non-canonical type.
Estimated hours taken: 20
Reorganisation of modules to do with the inst data type.
This is actually the first installment of the alias tracking mode
checker in disguise. A very good disguise. The rationale for
this reorganisation is to reduce coupling in the part of the mode
checker which is _not_ in this change (ie most of it).
Alias tracking requires a new kind of inst, alias(inst_key), where
an inst_key is a handle on some other sub-inst. With it goes a
data structure in which to store dereferenced insts and all the
operations which go with it. This code will go in the new module
inst.m so that it doesn't have to go in prog_data.m. (I briefly
considered putting it in instmap.m however this introduces some
bad coupling since instmap.m imports hlds_module.m. Putting it
in prog_data.m would cause hlds_*.m to depend on prog_data.m,
but we have designed things so that the dependencies go in the
other direction.)
The remainder of the reorganisation is a general cleanup: the
inst testing predicates (inst_is_*) have been moved out of
mode_util because they are not actually operations on modes at
all, and have been moved into inst_match. inst_match has then
been split because otherwise it would be 2000 lines long and
will get significantly bigger when aliasing is added. Roughly
speaking, any operations which create new insts from old ones
have been moved into a new module, inst_util while any operations
which test the values of insts remain in inst_match.
Also included are the removal of some NU-Prologisms since the
NU-Prolog version of the compiler is no longer supported. Two
changes here:
- Removal of some when declarations.
- A gross hack in inst_is_*_2, where two copies of
the same inst were passed into the predicate so that
one could be switched on. Thank NU-Prolog's lack of
common subexpression elimination.
compiler/inst.m:
New module which contains the data types inst, uniqueness,
pred_inst_info, bound_inst.
compiler/inst_util.m:
New module which contains predicates which perform mode
checking-like operations on insts.
Moved in:
abstractly_unify_inst, abstractly_unify_inst_functor,
inst_merge, make_mostly_uniq_inst (from inst_match.m)
compiler/inst_match.m:
Moved out:
inst_merge, make_mostly_uniq_inst,
abstractly_unify_inst, abstractly_unify_inst_functor
(to inst_util.m)
Moved in:
inst_is_*, inst_list_is_*, bound_inst_list_is_*
(from mode_util.m)
Now exported:
unique_matches_initial/2, unique_matches_final/2
inst_contains_instname/3, pred_inst_matches/3
(They are required by inst_util.m, and they are
useful in their own right.)
compiler/instmap.m:
instmap_delta_lookup_var/3 reincarnated as
instmap_delta_search_var/3. The reason for this change is
that previously, instmap_delta_lookup_var simply returned
`free' if the searched-for var did not occur in the
instmap_delta. This is somewhat non-obvious behaviour.
instmap_delta_search_var/3 fails in such a situation.
compiler/mode_util.m:
Moved out:
inst_is_*, inst_list_is_*, bound_inst_list_is_*
(to inst_match.m)
(These are not really operations on modes.)
compiler/modecheck_call.m:
Moved in modecheck_higher_order_func_call/5, from modecheck_unify.m
compiler/modecheck_unify.m:
Moved out modecheck_higher_order_func_call/5, to modecheck_call.m
where it should have been all along.
compiler/prog_data.m:
Moved out the types inst, uniqueness, pred_inst_info,
bound_inst (to inst.m).
compiler/common.m:
compiler/cse_detection.m:
compiler/fact_table.m:
compiler/higher_order.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/liveness.m:
compiler/llds.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/mode_debug.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/polymorphism.m:
compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/prog_util.m:
compiler/simplify.m:
compiler/switch_detection.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
Miscellaneous minor changes to cope with the above changes.
compiler/notes/compiler_design.html:
Document the new modules.
Estimated hours taken: 14
Implemented a :- use_module directive. This is the same as
:- import_module, except all uses of the imported items
must be explicitly module qualified.
:- use_module is implemented by ensuring that unqualified versions
of items only get added to the HLDS symbol tables if they were imported
using import_module.
Indirectly imported items (from `.int2' files) and items declared in `.opt'
files are treated as if they were imported with use_module, since all uses
of them should be module qualified.
compiler/module_qual.m
Keep two sets of type, mode and inst ids, those which can
be used without qualifiers and those which can't.
Renamed some predicates which no longer have unique names since
'__' became a synonym for ':'.
Made mq_info_set_module_used check whether the current item is in
the interface, rather than relying on its caller to do the check.
Removed init_mq_info_module, since make_hlds.m now uses the
mq_info built during the module qualification pass.
compiler/prog_data.m
Added a pseudo-declaration `used', same as `imported' except uses of
the following items must be module qualified.
Added a type need_qualifier to describe whether uses of an item
need to be module qualified.
compiler/make_hlds.m
Keep with the import_status whether current item was imported
using a :- use_module directive.
Use the mq_info structure passed in instead of building a new one.
Ensure unqualified versions of constructors only get added to the
cons_table if they can be used without qualification.
compiler/hlds_module.m
Added an extra argument to predicate_table_insert of type
need_qualifier.
Only add predicates to the name and name-arity indices if they
can be used without qualifiers.
Changed the structure of the module-name-arity index, so that
lookups can be made without an arity, such as when type-checking
module qualified higher-order predicate constants. This does not
change the interface to the module_name_arity index.
Factored out some common code in predicate_table_insert which
applies to both predicates and functions.
compiler/hlds_pred.m
Removed the opt_decl import_status. It isn't needed any more
since all uses of items declared in .opt files must now be
module qualified.
Added some documentation about when the clauses_info is valid.
compiler/intermod.m
Ensure that predicate and function calls in the `.opt' file are
module qualified. Use use_module instead of import_module in
`.opt' files.
compiler/modules.m
Handle use_module directives.
Report a warning if both use_module and import_module declarations
exist for the same module.
compiler/mercury_compile.m
Collect inter-module optimization information before module
qualification, since it can't cause conflicts any more. This means
that the mq_info structure built in module_qual.m can be reused in
make_hlds.m, instead of building a new one.
compiler/prog_out.m
Add a predicate prog_out__write_module_list, which was moved
here from module_qual.m.
compiler/typecheck.m
Removed code to check that predicates declared in `.opt' files
were being used appropriately, since this is now handled by
use_module.
compiler/*.m
Added missing imports, mostly for prog_data and term.
NEWS
compiler/notes/todo.html
doc/reference_manual.texi
Document `:- use_module'.
tests/valid/intermod_lambda_test.m
tests/valid/intermod_lambda_test2.m
tests/invalid/errors.m
tests/invalid/errors2.m
Test cases.
Estimated hours taken: 3
Implement `:- pragma no_inline'. This pragma prevents the compiler from
inlining predicates.
compiler/higher_order.m:
compiler/unused_args.m:
Create new preds using entire marker list, rather than just
inlining.
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Add code to support no_inline marker and pragma.
compiler/hlds_pred.m:
Add `no_inline' marker.
Create new preds using entire marker list, rather than just
inlining.
Change `pred_info_is_inlined' to `pred_info_requested_inlining',
as it was inappropriately named, and added
`pred_info_requested_no_inlining'.
compiler/inlining.m:
Don't inline predicates with pragma no_inlines
compiler/intermod.m:
Use `pred_info_requested_inlining'.
compiler/make_hlds.m:
Add code to check for conflicting markers, check for conflicts
between `inline' and `no_inline' markers.
Add `no_inline' markers.
Rename pragma_set_markers as pragma_add_markers, as it was
actually adding extra markers to what was already there.
doc/reference_manual.texi:
Document no_inline.
tests/hard_coded/Mmake:
tests/invalid/Mmake:
tests/hard_coded/no_inline.exp:
tests/hard_coded/no_inline.m:
tests/invalid/inline_conflict.err_exp:
tests/invalid/inline_conflict.m:
Add test cases for no_inline and conflicts between inline and
no_inline.
Estimated hours taken: 0.25
compiler/prog_data.m:
Add a comment about `det' unifications to the discussion of
`real' and `fake' unifications of clobbered insts.
Estimated hours taken: 12
The first half of a change to introduce nondet pragma C goals.
This half makes the necessary modifications to the HLDS; the next
half will modify the LLDS and emit it.
prog_data:
Add a new pragma type for nondet pragma c_codes; these specify
the names of a a bunch of variables to save across backtracking,
and a list of label names to which backtracking may take place.
Rename is_recursive to may_call_mercury, since this is a more
direct expression of the meaning.
prog_io:
Move much of the functionality to new files.
prog_io_dcg, prog_io_goal, prog_io_pragma, prog_io_util:
New files, made up of pieces of prog_io.
hlds_goal:
Add an extra argument to the pragma_c_goals to store the extra
information present in the new type of pragma c_codes.
det_analysis:
Take into account that the new type of pragma_c goal may have
more than one solution.
goal_util:
Rename variables in the new field of pragma_cs.
live_vars:
Allocate stack slots to the saved variables in the new type of pragma_c
goals.
make_hlds:
Handle the new type of pragma_c goals.
mercury_output, hlds_out:
Output the new type of pragma_c goals.
garbage_out:
Rename type "det" to "frame_type".
others:
Ignore one more arg of pragma_c goals or import prog_io_util.
Estimated hours taken: 100
* Inter-module unused argument removal.
* Allow the user to specify which directories should be searched
for .opt files.
* Enhancements to simplify.m and common.m which will be useful for
partial deduction.
compiler/options.m
Added and documented options:
--intermod-unused-args to enable inter-module unused argument removal.
--intermod-directory <dir>, same as --search-directory except used
to locate .opt files.
--use-search-directories-for-intermod - use the search directories
for .opt files as well.
--warn-simple-code - a flag to control the warnings produced by
simplify.m so that they respect --inhibit-warnings.
compiler/unused_args.m
Use the unused argument info from the .opt file.
Clobber the dependency_info if any new preds were added.
compiler/hlds_module.m
Added a field to the module_info to store unused argument
information from .opt files.
compiler/prog_data.m
Add :- pragma unused_args to hold unused argument information.
This should only be used in .opt files.
compiler/make_hlds.m
Build the unused_arg_info field in the module_info.
Check that pragma unused_args only appears in .opt files.
Fill in the non-locals field in the goal_info for the builtin
stubs so that mode analysis computes the correct instmap delta.
compiler/intermod.m
Read in the unused argument information for the current module when
compiling to C. This is used to ensure that clauses are produced with
the correct number of removed arguments (it may be possible to remove
more arguments with the information from other modules).
Fix a bug in the handling of module qualified function calls and
higher-order predicate constants.
compiler/handle_options.m
Handle --intermod-unused-args and
--use-search-directories-for-intermod.
compiler/mercury_compile.m
Run the entire front end and polymorphism (not just up to
typechecking) when building the .opt file with
--intermod-unused-args.
Use the new interface to simplify.m, remove calls to excess.m
and common.m.
compiler/code_util.m
compiler/llds_out.m
When generating local code for a specialized version of a predicate
from another module, put this module's name on the label to avoid
link errors.
compiler/higher_order.m
Don't add the originating module name to the name of the specialized
version, since that is now done in code_util.m.
Clobber the dependency graph so that inlining will work on the
specialized versions in profiling grades (this will cause slightly
slower compilation in profiling grades, something I need to fix).
compiler/simplify.m
Merge a branching goal and an adjacent switch where the branches
of the first goal contain extra information about the switched
on variable of the second goal.
Merge the excess assignments and common subexpression elimination
passes into simplify.m.
compiler/excess.m
The functionality of this module is now in simplify.m, but I'll
leave it here for now.
compiler/instmap.m
Added predicates instmap__bind_var_to_functor and
instmap_delta_bind_var_functor to which take a var, cons_id
and an instmap and adjust the inst of the var. This is used to
update the instmap at the beginning of each case in a switch.
Fix a bug in merge_instmap_delta where variables whose inst had
information added in one branch of a switch, disj, or ite had that
changed inst included in the instmap_delta for the entire
branched goal.
compiler/mode_util.m
Use instmap_delta_bind_var_to_functor in recompute_instmap_delta.
Added predicate bind_inst_to_functor which takes a ground or bound
inst and a cons_id and adjusts the top level of the inst to be bound
to that cons_id. Other types of inst are left unchanged.
Change recompute_instmap_delta so that the switched on variable of
a switch is bound to the functor in each case even if the binding
unification has been removed. Added a boolean argument to request
recomputation of instmap_deltas for atomic goals.
compiler/modes.m
compiler/unique_modes.m
Make sure that the instmap_delta for each branch of a switch
includes the extra information added by the functor test.
compiler/common.m
Removed the goal traversal. Leave preds to be called by simplify.m
to optimise common unifications and calls.
Warn about and eliminate multiple calls to a predicate with the same
input arguments.
Replace deconstructions of known terms with assignments to the output
variables where this would not make more variables live at stack
flushes.
compiler/follow_code.m
Exported move_follow_code_select.
Don't move follow code into erroneous branches.
library/string.nu.nl
Added string__contains_char/2.
compiler/base_type_layout.m
compiler/special_pred.m
compiler/vn_order.m
library/mercury_builtin.m
Removed duplicate calls.
doc/user_guide.texi
Documented options.
tests/warnings/duplicate_call.m
tests/warnings/duplicate_call.exp
Test duplicate call warning.
Estimated hours taken: 4
Allow `pragma export' for semidet predicates and for det/semidet functions.
(Previously it only worked for det predicates.)
prog_data.m:
Add a pred_or_func field to the pragma_export struct.
prog_io.m:
Add code to parse `pragma export' declarations for functions,
e.g. `pragma export(foo(in) = out, "foo")'.
mercury_to_mercury.m:
Add code to print out `pragma export' declarations for functions.
module_qual.m:
Change export/3 to export/4.
export.m:
Handle semidet procedures -- the C function returns TRUE/FALSE
depending on whether the Mercury procedure succeeded or failed.
Handle functions -- for det functions whose return value has
mode `out', the Mercury function return value is returned as the C
function return value.
Don't call save_registers() after returning from call_engine(),
since call_engine() now saves them itself.
When generating header files, don't make up argument names
for the function prototypes, instead just leave the arguments
unnamed. Also, make sure the `#ifndef HEADER_NAME_H' comes
at the very start of the file, before #include "imp.h".
Estimated hours taken: 80
Added code to various sections of the compiler to parse
`pragma fact_table' declarations and add them to the HLDS.
Added output of fact_table dependencies to .d and .dep files.
Added a new module fact_table.m for parsing the actual fact tables and
generating code. This is not finished yet.
Added ability to have `pragma c_code' declarations for Mercury
functions.
Modified Files:
compiler/hlds_module.m
Added predicate `module_info_set_pred_info' to add a `pred_info'
entry to `module_info' given a `pred_id'.
compiler/make_hlds.m
Added code to handle new `pragma fact_table' declarations.
New predicate `module_add_pragma_fact_table' which calls the
fact compiler in fact_table.m to compile the fact table and
generate C code to access it. Then add the C code to the HLDS
as a `pragma c_code'.
Mercury functions can now have `pragma c_code' declarations.
compiler/intermod.m
Included PredOrFunc argument in call to mercury_output_pragma_c_code.
compiler/mercury_compile.m
Added parameters to some predicates to allow fact table
dependency information to be passed around.
compiler/mercury_to_mercury.m
Handle output of `pragma fact_table' declarations.
Handle output of `pragma c_code' declarations for functions.
compiler/module_qual.m
Handle module qualification of `pragma fact_table'
declarations.
compiler/modules.m
New predicate `get_fact_table_dependencies' to work out which
fact tables a module depends on.
Changes to `write_dependency_file' to write out fact table
dependencies.
Changes to some other predicates to allow fact table
dependencies to be passed around the module.
compiler/prog_data.m
Added new functor `fact_table(sym_name, arity, string)'
to the `pragma_type' type.
Added a `pred_or_func' field to the `c_code' functor of the
`pragma_type' type.
compiler/prog_io.m
Added code to `parse_pragma_type' to parse `:- pragma fact_table'.
Here is a sample declaration. The facts are in a file called
"factfile":
:- pred facts(string, int, float).
:- mode facts(out, out, out) is multidet.
:- pragma fact_table(facts/3, "factfile").
Mercury functions can now have `pragma c_code' declarations.
Here is a sample declaration:
:- func c_add(int, int) = int.
:- pragma c_code(non_recursive, c_add(A::in, B::in) = (C::out), "
C = A + B;
").
Added Files:
compiler/fact_table.m
Module not yet finished, but it compiles correctly and doesn't
interfere with the rest of the compiler.
Main purposes of the module are to parse the fact table
file, perform type, mode and determinism checks and generate C
code for the fact table.
Completed so far: parsing, type and mode checking,
determinism inference. A C array is output to represent the
table, but no functions are produced yet to access it.
Estimated hours taken: 12
The main changes are
1 associating a name with the arguments of constructors
2 removing the follow_vars field from calls, higher-order calls
and complicated unifications, since they are not used
3 merging the follow_vars and store_alloc passes, since they logically
belong together
4 add a new module, lco, for detecting opportunities for last
call optimization modulo constructor application; it won't
actually apply the optimization until the mode system becomes
expressive enough to handle it (this module detects 529 opportunities
in the compiler and library)
5 make "-O3 --optimize-value-number" do the right thing; previously,
it used not to apply value numbering because the vnrepeat option
defaulted to zero
6 don't refer to .err2 files anymore; use .err instead.
prog_data:
The list associated with each value of type "constructor" now
contains not only the types of the arguments but their names as well.
equiv_type, hlds_data, hlds_out, make_hlds, mercury_to_{goedel,mercury},
mode_util, module_qual, shapes, type_util, unify_proc:
Modify the traversal of type definitions to account for the names
in the lists inside values of type "constructor".
prog_io:
Parse argument names. An unrelated change is that we now
check whether :- pred declarations give modes to some of their
arguments but not to all, in which case we return an error.
hlds_goal:
Remove the follow_vars field from calls, higher-order calls
and complicated unifications.
*.m:
Handle the new arities of calls, higher order calls and complicated
unifications.
mercury_compile:
Don't call follow_vars directly anymore, but do call lco if its option
is set. Also flush the main output before a call to maybe_report_stats
to prevent ugly output.
store_alloc:
Call follow_vars directly.
follow_vars:
Expose the initialization and traversal predicates for store_alloc.
lco:
Find opportunities for last call optimization modulo constructor
application.
passes_aux:
Add a HLDS traversal type for lco.
optimize:
Consider the vnrepeat count to be zero unless value numbering is on.
options:
Set the default value of vnrepeat to 1.
modules:
Don't refer to .err2 files.
Estimated hours taken: 50
- Inter-module optimization.
Allows inlining and higher-order specialization across module boundaries.
Gives ~10% speed-up on the compiler compiling to C.
- The code to handle explicit type qualification.
The test to recognise a type qualification is semidet_fail'ed
until we work out which operator to use.
- Improved data structures in module_qual.m.
Also, module qualification of the modes of lambda expressions is now
done in make_hlds.m, since it is more convenient now that type
qualifications are module qualified there also.
* Type qualification and module qualifiers on higher-order predicate
constants and function calls still need to be implemented before this
will work on all programs.
* To create a version of a program using this optimization method,
add --intermodule-optimization to MCFLAGS, mmake change_clean,
mmake depend, then make as normal.
* mmake change_clean removes the executable, the .dep file and all
.cs and .os.
compiler/intermod.m
Handle input and output of .opt files.
compiler/modules.m
Added some new dependencies in the .d files for
the .c and .opt files if inter-module optimization
is being used.
Also added .opt and .optdate to the list of things for
mmake realclean to remove.
Added a target, change_clean, which removes only those files
necessary to force a rebuild using --intermodule-optimization.
These are <module>, <module>.dep and all the .c, .o and .s files.
compiler/options.m
Added options:
--make-optimization-interface - make the .opt file.
--intermodule-optimization - puts extra dependencies
into .d files and turns on input of .opt files.
compiler/make_hlds.m
Changes to give items from .opt files the correct import_status.
Also, when matching pragma_c_code clauses to the declared modes
of the predicates, expand and match on the initial and final insts
of the argument modes, not the modes themselves, since items in
.opt files have the modes expanded.
Module qualify the modes of lambda expressions in unravel_unification
rather than during mode analysis.
Parse explicit type qualifications, and add these to the vartypes.
At the moment this is disabled.
compiler/typecheck.m
Get the head type params from the tvarset, not from the arg types,
so that tvars in type qualifications are included.
Added checks to prevent matching of predicates, functions and
constructors which should not be visible to a clause.
compiler/module_qual.m
Module qualify explicit type qualifications.
More efficient data structures.
compiler/mercury_to_mercury.m
Export some predicates. Make sure C code strings are properly
quoted in the .opt files.
compiler/hlds_out.m
Output function calls correctly. Alter hlds_out__write_goal to write
out type qualifications on all functors if writing a .opt file.
compiler/hlds_pred.m
Added a new import_status opt_imported for clauses and declarations
read from a .opt file. Pred and func declarations read from a .opt
file get an `opt_decl' import_status so that the compiler doesn't
expect clauses for them and local preds can't use them.
Also added import_status abstract_imported and abstract_exported
to describe types which have only an abstract definition imported
or exported.
Added a field to clauses_info to store the map(var, type) from
explicit type qualifications.
Renamed pred_info_set_status/3 to pred_info_set_import_status/3 to
be consistent with pred_info_import_status/2.
compiler/hlds_data.m
Added an import_status field to the hlds__mode_defn and
hlds__inst_defn so that intermod.m knows what has already
been exported.
compiler/equiv_type.m
Pass out the equiv_map and export a predicate used to
expand type qualifications.
compiler/dead_proc_elim.m
Remove non-optimized versions of opt_imported preds. All
optimizations must give the optimized version an import_status
of local.
compiler/code_util.m
Changed code_util__make_local_entry_label so that `localcall's
are used for recursive calls in exported predicates.
compiler/code_aux.m
Changed code_aux__contains_only_builtins_2 so that it doesn't
check for complicated unifies, since any time this is called,
complicated unifies have either not been created (when called
when writing the .opt files) or have been converted to calls
(when called during inlining).
compiler/higher_order.m
Make sure that the specialized versions get unique names.
compiler/mercury_compile.pp
Add calls to intermod.m predicates.
compiler/bytecode_gen.m
Bracketed some '->'/2 insts so that they can be parsed by SICStus.
compiler/peephole.m
Replace computed_gotos where all the targets are the same with
an unconditional goto.
compiler/notes/COMPILER_DESIGN
Documented intermod.m.
library/list.m
Added list__all_same/1, which is true if all elements of a list are
identical. Also added list__last/2, which returns the final element
of a list, failing on the empty list.
library/io.m
Change the format specifier for io__write_float so that the decimal
point is always output. Without this, the result may not be a valid
Mercury floating point constant.
library/varset.m
Add predicate varset__create_name_var_map/2 to create a mapping
from variable name to variable id given a varset. This is used
in processing type qualifications.
scripts/Mmake.rules
scripts/Mmake.vars.in
Add suffixes, rules and options for .opt and .optdate.
scripts/mercury_update_interface.in
Work-around for a problem with parallel gmake. mc --make-interface
was being run twice in a row on the same module. The first call
mercury_update_interface moves module.int.tmp to module.int,
then the second can't find module.int.tmp. The work-around is to
ignore the exit status of the mv.
Some cleaning up:
compiler/*.m
Fixed some out of date comments about the handling of
complicated_unify. Also commented some dead code to do
with generation of code for complicated_unify.
compiler/modes.m
compiler/mode_info.m
Moved code to module qualify modes of lambda expressions into
make_hlds.
Moved predicates resolve_pred_overloading and find_matching_pred_id
into typecheck, renaming with a typecheck__ prefix, so that these
can be called from intermod.m.
compiler/undef_modes.m
compiler/undef_types.m
Removed - their functionality is now in module_qual.m, except
for checking for looping equivalence types.
compiler/no_builtin.m
compiler/nit_builtin.m
Removed - they were made useless (if they weren't already) by
the removal of the --builtin-module option.
compiler/notes/AUTHORS
Updated student email addresses.
Estimated hours taken: 4
passes_aux:
Flesh out the code already here for traversing module_infos,
making it suitable to handle all the passes of the back end.
mercury_compile:
Use the traversal code in passes_aux to invoke the back end passes
over each procvedure in turn. Print a one-line message for each
predicate if -v is given (this fixes a long-standing bug).
excess.m, follow_code.m, follow_vars.m, live_vars.m, lveness.m, store_alloc.m:
Remove the code to traverse module_infos, since it is now unnecessary.
export.m:
Remove an unused argument from export__produce_header_file_2.
others:
Move imports from interfaces to implementations, or in some cases
remove them altogether.
Estimated hours taken: 3
Implement a new `:- pragma source_file("<source file name>").' declaration,
and a `#<line number>' directive, to make it more convenient to use
preprocessors or to use Mercury as a target language.
prog_data.m:
Add `source_file' pragma.
make_hlds.m, module_qual.m:
Ignore `pragma source_file' declarations.
mercury_to_mercury.m:
Print `pragma source_file' declarations.
Simplify a couple of unnecessarily complicated bits of code.
prog_io.m:
Parse `source_file' pragmas. When parsing items, check for them;
handle `pragma source_file' declarations by keeping track of the
source file name, and passing it to parser__parse_term/4.
Also, change the "Error: module should start with a `:- module'
declaration" message from an error to a warning.
Also, fix the capitalization in a bunch of error messages:
change from "Error: Blah" to "Error: blah".
Estimated hours taken: 45
Module qualification of types, insts and modes.
Added a new interface file - <module>.int3. This contains the
short interface qualified as much as possible given the information
in the current module.
When producing the .int and .int2 files for a module, the compiler uses
the information in the .int3 files of modules imported in the interface
to fully module qualify all items. The .int2 file is just a fully
qualified version of the .int3 file. The .int3 file cannot be overwritten
by the fully qualified version in the .int2 file because then mmake would
not be able to tell when the interface files that depend on that .int3
file really need updating.
The --warn-interface-imports option can be used to check whether
a module imported in the interface really needs to be imported in
the interface.
compiler/module_qual.m
Module qualify all types, insts and modes. Also checks for modules
imported in the interface of a module that do not need to be.
compiler/modules.m
The .int file for a module now depends on the .int3 files of imported
modules. Added code to generate the make rule for the .int file in the
.d file. There is now a file .date2 which records the last time the
.int2 file was updated.
The .int3 files are made using the --make-short-interface option
introduced a few weeks ago.
compiler/options.m
Added option --warn-interface-imports to enable warning about interface
imports which need not be in the interface. This is off by default
because a lot of modules in the library import list.m when they only
need the type list, which is defined in mercury_builtin.m.
Removed option --builtin-module, since the mercury_builtin name is wired
into the compiler in a large number of places.
compiler/prog_util.m
Added a predicates construct_qualified_term/3 and construct_qualfied_term/4
which take a sym_name, a list of argument term and a context for the /4
version and give a :/2 term.
compiler/type_util.m
Modified type_to_type_id to handle qualified types. Also added predicates
construct_type/3 and construct_type/4 which take a sym_name and a list of
types and return a type by calling prog_util:construct_qualified_term.
compiler/modes.m
On the first iteration of mode analysis, module qualify the modes of
lambda expressions.
compiler/mode_info.m
Added field to mode_info used to decide whether or not to module qualify
lambda expressions.
compiler/mode_errors.m
Added dummy mode error for when module qualification fails so that mode
analysis will stop.
Added code to strip mercury_builtin qualifiers from error messages to
improve readability.
compiler/typecheck.m
Strip builtin qualifiers from error messages.
compiler/llds.m
compiler/llds_out.m
compiler/opt_util.m
compiler/opt_debug.m
Change the format of labels produced for the predicates to use the
qualified version of the type name.
compiler/mercury_compile.pp
Call module_qual__module_qualify_items and make_short_interface.
Remove references to undef_modes.m and undef_types.m
compiler/undef_modes.m
compiler/undef_types.m
Removed, since their functionality is now in module_qual.m.
compiler/prog_io.m
Changed to qualify the subjects of type, mode and inst declarations.
compiler/*.m
Changes to stop various parts of the compiler from throwing away
module qualifiers.
Qualified various mercury_builtin builtins, e.g. in, out, term etc.
where they are wired in to the compiler.
compiler/hlds_data.m
The mode_table and user_inst_table are now abstract types each
storing the {mode | inst}_id to hlds__{mode | inst}_defn maps
and a list of mode_ids or inst_ids. This was done to improve the
efficiency of module qualifying the modes of lambda expressions
during mode analysis.
module_info_optimize/2 now sorts the lists of ids.
The hlds_module interface to the mode and inst tables has not changed.
compiler/hlds_module.m
Added yet another predicate to search the predicate table.
predicate_table_search_pf_sym_arity searches for predicates or
functions matching the given sym_name, arity and pred_or_func.
compiler/higher_order.m
Changed calls to solutions/2 to list__filter/3. Eliminated unnecessary
requantification of goals.
compiler/unused_args.m
Improved abstraction slightly.
Estimated hours taken: 4
Implement `recursive' and `non_recursive' pragma c_code declarations.
This allows the compiler to optimize cases when the C code
is known to not call Mercury code. It's also necessary
to allow C code which modifies the hp register to work
(such code must be declared `non_recursive', otherwise
the registers will be saved and restored over it).
To make things bootstrap OK, the old pragma c_code declarations
default to `non_recursive'.
prog_data.m, hlds_goal.m:
Add new field c_is_recursive to pragma c_code goals.
prog_io.m:
Parse the new `recursive' and `non_recursive' pragma c_code
declarations.
make_hlds.m:
Pass the c_is_recursive field from the parse tree to the HLDS.
live_vars.m:
For non-recursive C code, don't save variables on the stack.
code_gen.pp:
For non-recursive C code, don't save variables on the stack,
don't mark the succip as needing to be saved, and don't
call save_registers() and restore_registers().
*.m:
Change c_code/5 to c_code/6.
Estimated hours taken: 0.25
prog_data.m, prog_io.m:
Rename the `pragma' type as `pragma_type', to avoid bootstrapping
problems caused by my change to make `pragma' an operator.
Estimated hours taken: 3
Add a new pragma `:- pragma obsolete(Name/Arity).';
the effect of this pragma is that we issue a warning for
any call to the specified predicate(s) or function(s).
prog_data.m:
Add new pragma type `obsolete'.
prog_io.m:
Parse pragma `obsolete'.
hlds_pred.m, hlds_out.m:
Add new pred_marker `obsolete'
make_hlds.m:
When we encounter a pragma `obsolete', insert `request(obsolete)'
in the pred_marker list for the specified predicate(s) and function(s).
simplify.m:
For each predicate call, check if the called predicate has been
marked as obsolete. If so, return a `warn_obsolete' warning.
det_report.m:
Add a new warning type `warn_obsolete', and add code to print
the warning for this warning type.
det_analysis.m:
Add a comment.
Estimated hours taken: 12
Implement higher-order functions.
Add higher-order function terms
(function lambda expressions, e.g. `Func = (func(X) = Y :- Y is 2 * X)'
and higher-order function calls (apply/N, e.g. `Z = apply(Func, 42)').
Add higher-order function insts and modes.
hlds_goal.m:
Add a new field pred_or_func to lambda_goal.
prog_data.m:
Add a new field pred_or_func to pred_inst_info.
prog_io.m:
Add support for parsing higher-order function terms and
higher-order function insts and modes.
make_hlds.m:
Add support for parsing higher-order function terms.
typecheck.m:
Add support for type-checking higher-order function calls
and higher-order function terms.
modes.m, mode_errors.m:
Add support for mode-checking higher-order function calls
and higher-order function terms.
higher_order.m:
Handle higher-order function types and insts.
hlds_pred.m:
Add new predicate pred_args_to_func_args, for extracting the
function arguments and function return from the arguments
of a predicate that is really a function.
*.m:
Minor changes to handle new pred_or_func field in lambda_goals
and pred_inst_infos.