Estimated hours taken: 5
Remove support for term_to_type and type_to_term implemented as special
preds. Remove support for one-cell and one-or-two-cell type_infos (now
shared-one-or-two-cell type_infos). Move definitions that were in
mercury_builtin.m back to where they belong.
This code has been removed because it is no longer used, and was no
longer being maintained but was still quite complex.
compiler/globals.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
Remove one_cell and one_or_two_cell from type_info methods.
compiler/polymorphism.m:
Remove term_to_type and type_to_term support.
Remove one_cell and one_or_two_cell from type_info methods.
Fix documentation to reflect the new situation.
compiler/special_pred.m:
compiler/unify_proc.m:
Remove term_to_type and type_to_term support.
library/list.m:
Put the definition of `list' back into list.m
library/mercury_builtin.m:
Take the definitions of `list', `term', `var', `var__supply',
etc, out of this module.
Remove type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init.
Remove references to USE_TYPE_TO_TERM and #ifdefs around
SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
library/std_util.m:
Remove references ONE_OR_TWO_CELL_TYPE_INFO, and code that
handles one-cell typeinfo comparisons.
library/term.m:
Add type_to_term, term_to_type, det_term_to_type,
term__init_var_supply, term__create_var, term__var_to_int
and term__context_init back to term.m.
Add new implementation of type_to_term/2.
library/uniq_array.m:
Fix a typo in a comment - term_to_type/3 instead of term_to_type/2.
runtime/call.mod:
Remove special case code for unify, compare, index for
one-cell typeinfos.
Remove code for type_to_term/2.
runtime/type_info.h:
Remove references to ONE_CELL_TYPE_INFO or ONE_OR_TWO_CELL_TYPE_INFO.
Make sure only SHARED_ONE_OR_TWO_CELL_TYPE_INFO.
Remove references to USE_TYPE_TO_TERM.
compiler/base_type_layout.m:
compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/delay_slot.m:
compiler/det_util.m:
compiler/fact_table.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/mode_debug.m:
compiler/tree.m:
library/bag.m:
library/queue.m:
Import module `list' or `term' (or both).
Estimated hours taken: 3
Fix a bug in inlining of polymorphic pragma c_code procedures.
The bug was that if the actual argument type has a specific type
of say `float', then the C variable for the corresponding formal
parameter will be declared to have type `Float', whereas without
inlining the argument type would have been polymorphic and so
the C variable would have been declared to have type `Word'.
Hence we need to keep track of the original argument types,
before any inlining or specialization has occurred, and use
these original argument types to determine how to declare
the C variables, rather than using the actual argument types
for this particular specialization.
compiler/hlds_goal.m:
Add a new field to pragma_c_code goals, holding the
original argument types (before any inlining or specialization)
of the pragma_c_code procedure.
compiler/make_hlds.m:
Initialize this field with the declared argument types for
the pragma c_code procedure.
compiler/polymorphism.m:
Update this field to account for the inserted type_info variables.
compiler/code_gen.m:
Pass this field to pragma_c_gen.m.
compiler/pragma_c_gen.m:
Use the original argument types field for the pragma variable
declarations, rather than looking up the actual types of the
arguments.
compiler/*.m:
Trivial changes to handle new field.
compiler/live_vars.m:
Comment out some code to avoid a warning about `fail'
in the condition of an if-then-else.
Estimated hours taken: 8
Clean up the handlng of integer division and remainder.
library/int.m:
Add a new function `div'. The idea is that `div' is the same
as `//', except that `div' will round toward minus infinity, whereas
`//' will round toward zero. `div' is more well-behaved, `//'
is more efficient.
Change the behaviour of `mod' so that it is remainder after `div'
rather than remainder after `//'. This makes it more well-behaved,
but less efficient.
Add a new function `rem', which is the new name for what `mod'
used to do (i.e. remainder after `//').
compiler/llds.m:
Add some comments about the `/' and `mod' llds operators.
(The `mod' llds operator should probably be renamed `rem',
but I haven't done that yet.)
compiler/code_util.m:
Recognize `int:rem', rather than `int:mod', as the llds `mod'
operator.
tests/hard_coded/division_test.m:
Add some test cases for `div', `mod', `//', and `rem' on
negative numbers.
Estimated hours taken: 0.5
Fix a bug reported by Renaud Paquay from Mission Critical.
compiler/code_util.m:
Handle empty disjunctions in code_util__count_recursive_calls_disj:
don't call error/1, because empty disjunctions are perfectly valid
(they just mean `fail').
Estimated hours taken: 7
Making the types pred_id and proc_id (almost) abstract.
compiler/code_util.m:
Changed the type of several predicates:
code_util__make_uni_label/4 (arg 3 was int, now proc_id)
code_util__inline_builtin/4 (arg 3 was proc_id, now int)
Added predicate code_util__translate_builtin_2/6.
compiler/hlds_module.m:
Moved invalid_pred_id/1 to hlds_pred.m
compiler/hlds_pred.m:
Types pred_id/0 and proc_id are now abstract.
Added predicates:
hlds_pred__initial_pred_id/1, hlds_pred__initial_proc_id/1,
hlds_pred__next_pred_id/2, hlds_pred__next_proc_id/2,
pred_id_to_int/2, proc_id_to_int/2,
hlds_pred__in_in_unification_proc_id/1
Moved predicate invalid_pred_id/1 (from hlds_module.m).
compiler/*.m:
Miscellaneous minor changes to cast pred/proc_ids to ints
where appropriate.
Estimated hours taken: 8
Enable the code to treat `__' as an alternative syntax for module
qualification, after fixing various places in the compiler where
we use `__' in ways that are incompatible with this.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Uncomment the code to handle `__' as module qualification.
compiler/intermod.m:
compiler/hlds_module.m:
compiler/modecheck_unify.m:
Fix bugs in the handling of module qualified higher-order terms.
compiler/*.m:
s/hlds__/hlds_/g
compiler/passes_aux.m:
s/process__/process_/g
compiler/pragma_c_gen.m:
compiler/code_gen.m:
s/code_gen__/pragma_c_gen__/ for the predicates defined in
pragma_c_gen.m (this ought to have been done when the code
was first moved from code_gen.m to pragma_c_gen.m).
compiler/llds.m:
s/llds__proc_id/llds_proc_id/g
The reason for this was to avoid ambiguity between proc_id
in hlds_pred.m and llds__proc_id in llds.m.
compiler/quantification.m:
compiler/make_hlds.m:
compiler/mercury_to_c.m:
s/goal_vars/quantification__goal_vars/g
The reason for this was to avoid ambiguity between goal_vars
in quantification.m and goal_util__goal_vars in goal_util.m.
compiler/dupelim.m:
compiler/optimize.m:
s/dupelim__main/dupelim_main/g
The reason for this change is that a program can only
have one main/2 predicate.
compiler/prog_io_dcg.m:
Remove the old "temporary hack" to strip off and ignore
io__gc_call/1, since the new handling of `__' broke it.
It was only useful for optimizing NU-Prolog performance,
which we don't care about anymore.
compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
compiler/prog_io.m:
Remove occurrences of io__gc_call.
compiler/llds_out.m:
compiler/base_type_info.m:
Ensure that we properly handle the special hacks in mercury_builtin
where predicates from other modules (e.g. term__context_init)
are defined in mercury_builtin because they are needed for
type_to_term and term_to_type. llds_out.m: don't put
`mercury_builtin' in the mangled names for those symbols.
base_type_info.m: handle types whose status is "imported"
in their own module.
Estimated hours taken: 0.5
The first argument of code_util__predinfo_is_builtin/2 was unused, so it has
been replaced by code_util__predinfo_is_builtin/1
compiler/code_util.m:
changed code_util__predinfo_is_builtin(_ModuleInfo, PredInfo)
to code_util__predinfo_is_builtin(PredInfo).
compiler/unused_args.m:
compiler/typecheck.m:
compiler/make_hlds.m:
compiler/intermod.m:
Fixed each usage of code_util__predinfo_is_builtin.
Estimated hours taken: 15
Module qualification of constructors.
compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/modecheck_call.m
Enable propagate_type_info_into_modes.
Use type information to module qualify cons_ids.
compiler/mode_util.m
Use propagate_type_information_into_modes to module qualify cons_ids
in bound insts.
typed_ground/2 and free/1 insts are not yet generated, since they
are not yet used anywhere.
Avoid expanding insts when propagating type information, since
that is not yet useful.
I still need to fix the handling of
inst_matches_{initial, final, binding}(
ground(_, _), bound(_, [all_functors_in_the_type]))
compiler/typecheck.m
Don't assume a module qualified cons_id is a function call
or higher-order pred constant.
compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/instmap.m
compiler/inst_match.m
Remove some unnecessary conversion between cons_ids and consts.
compiler/typecheck.m
compiler/mode_errors.m
Strip builtin qualifiers from cons_ids.
compiler/mercury_to_mercury.m
Output module qualified cons_ids.
compiler/prog_io.m
compiler/prog_io_util.m
Module qualify constructors in type definitions.
Parse qualified cons_ids in bound insts.
compiler/hlds_data.m
Remove cons_id_to_const/3, since it doesn't make much sense any more.
Add cons_id_arity/2 and cons_id_and_args_to_term/3.
compiler/make_hlds.m
Add both qualified and unqualified versions of each cons_id to
the cons_table.
compiler/det_util.m
Handle module qualified cons_ids in det_util__interpret_unify.
compiler/code_util.m
Remove some dead code in code_util__cons_id_to_tag to do with
tags for higher-order terms. Don't assume module qualified
cons_ids are higher-order pred constants.
compiler/polymorphism.m
Module qualify type_info cons_ids.
Estimated hours taken: 3
Cleaned up the handling of labels for specialized versions of predicates
from other modules.
compiler/llds.m:
Changed the representation of proc_label slightly.
Each proc_label now contains the name of the module producing the
code for a predicate as well as the module containing the declaration
for the predicate.
compiler/code_util.m:
compiler/llds_out.m:
Fixed a bug in my last change that resulted in duplicate label
names for specialized versions of predicates.
The name of the module producing the code for the predicate
is added as an extra qualifier in the label for specialised
versions of predicates from other modules.
compiler/base_type_info.m:
compiler/opt_util.m:
compiler/opt_debug.m:
compiler/shapes.m:
Fixed uses of proc_label.
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: 2
Complete the code for generating bytecodes. We now handle complex construction
unifications (those that create partially instantiated data structures or
closures), noop-type builtins (e.g. unary plus), the output of floats,
and procedures with unused variables.
We can now generate bytecode for every module in the library and the compiler.
bytecode, bytecode_gen:
Implement the above.
code_util:
Fix a comment.
mercury_compile:
Fix a spelling error in a progress message. Write the .bytedebug file
before the .bytecode file. Because the .bytecode file is not text,
it has a higher than usual chance of breaking the I/O system.
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: 0.2
Some changes recommended by Fergus.
code_util:
Call int_min/max instead of expanding them inline.
hlds_goal:
Fix an obsolete comment.
liveness:
Clarify a comment.
Estimated hours taken: 3
code_gen, pragma_c_code:
Move the code that generates code for pragma_c_codes to a new module.
llds:
Change the representation of reg and temp lvals, in order to create
the concept of a "register type" and to reduce memory requirements.
Also add a comment indicating a possible future extension dealing with
model_non pragma_c_codes.
code_exprn, code_info:
Add the ability to request registers of a given type, or a specific
register, when acquiring registers.
bytecode, bytecode_gen, call_gen, dupelim, exprn_aux, follow_vars, frameopt,
garbage_out, jumpopt, llds_out, middle_rec, opt_debug, opt_util, store_alloc,
string_switch, tag_switch, unify_gen, vn_block, vn_cost, vn_filter, vn_flush,
vn_order, vn_temploc, vn_type, vn_util, vn_verify:
Small changes to accommodate the new register representation.
hlds_goal:
Add a comment indicating a possible future extension dealing with
model_non pragma_c_codes.
inlining:
Add a comment indicating a how to deal with a possible future extension
dealing with model_non pragma_c_codes.
Estimated hours taken: 2
hlds_goal:
Change the definition of is_builtin to use less space.
bytecode_gen, code_aux, code_gen, code_util, dependency_graph, follow_code,
higher_order, inlining, live_vars, make_hlds, modecheck_unify, modes,
polymorphism, stratify, unused_args:
Fixes to accommodate the change to is_builtin.
Estimated hours taken: 1.5
code_util:
Add a predicate for counting the maximum and minimum number of
recursive calls that may be encoutered in the execution of a goal.
switch_gen:
Use this predicate to replace our earlier heuristic for reordering
switches with two arms. The new heuristic is better because in
estimating which arm will be executed more frequently it looks
at only recursive calls, and not at irrelevancies such as the
presence of other calls in either arm.
This change also removes the special handling of the test for
two-arm switches, since unify_gen__generate_tag_test is now
smart enough to use reverse tests if these are cheaper (e.g.
test for not nil instead of testing for cons).
unify_gen:
Minor formatting change.
Estimated hours taken: 3
code_info:
Restructure into several submodules to give the module logical
structure. Make very slight alterations in the interface.
call_gen, code_gen:
Use the new interface of code_info.
code_aux:
Add comments.
code_util:
Fix a bug caught by Fergus' review.
disj_gen, ite_gen, liveness:
Fix some comments.
Estimated hours taken: _____
Take the code generator a big step closer to notes/ALLOCATION.
The new code generator emits code that is smaller and faster than
the code we used to emit.
Nondet liveness is no longer used; nondet live sets are always empty.
In code that was being modified anyway, remove its handling. Other
uses will be removed later (this keeps this change from being far too big;
as it is it is merely too big). Similarly for cont-lives.
In several places, clarify the code that gathers several code pieces together.
call_gen:
Unset the failure continuation and flush the resume vars to
their stack slots before nondet calls.
Move the code that decides whether a nondet call can be a tailcall
to code_info.
code_aux:
Remove the code to handle resume points, since these are now
handled in the specific constructs that need them. Replace it
with a sanity check.
code_exprn:
Add a predicate to place multiple vars.
code_gen:
Remove the predicate code_gen__generate_forced_goal, since it
packaged together some operations that should be executed at different
times.
Don't unset the failure continuation after every nondet goal;
this is now done in the constructs that need it.
Modify the handling of negation to use resume point info
according to notes/ALLOCATION.
Remove the predicate code_gen__ensure_vars_are_saved which was
use to save all lives variables to the stack before nondet
disjunctions and if-then-elses; we don't do that anymore.
code_info:
Significantly simplify and document the handling of failure
continuations, and make the types involved abstract types.
Factor out common code in the handling of det and semi commits.
Keep track of "zombies", variables that are dead wrt forward
execution but whose values we need because they may be needed
at a resume point we can reach.
Remove several now unneeded predicates, and introduce new
predicates to help other modules.
code_util:
Add a couple of predicates to check whether ia goal cannot fail before
flushing all variables to the stack, and whether a goal cannot flush
any variables to the stack. These are used in liveness to decide
which entry labels will be needed at resume points.
disj_gen:
Unify the handling of det and semi disjunctions. Model the code
handling of nondet disjunctions on the code handling pruned
disjunctions. It is possible that the handling of nondet and pruned
disjunctions can also be unified; the new code should make this
significantly easier.
Make the code conform to notes/ALLOCATION. This means saving
only the variables mentioned in the resume_point field, not
flushing all live variables to the stack at the start of a
nondet disjunction, handling zombies, and using the new method
of flushing variables at the ends of branched structures.
ite_gen:
Unify the handling of det and semi if-then-elses. Model the code
handling of nondet if-then-elses on the code handling det/semi
if-then-elses. It is possible that the handling of nondet and pruned
if-then-elses can also be unified; the new code should make this
significantly easier.
Make the code conform to notes/ALLOCATION. This means saving
only the variables mentioned in the resume_point field, not
flushing all live variables to the stack at the start of a
nondet if-then-else, handling zombies, and using the new method
of flushing variables at the ends of branched structures.
Apply the new rules about liveness in if-then-elses, which say that
the else part is parallel not to the then part but to the conjunction
of the condition and the then part.
dense_switch, lookup_switch, string_switch, switch_gen, tag_switch, middle_rec:
Use the new method of flushing variables at the ends of branched
structures. Don't call remake_with_store map; switch_gen will do so.
Fix an old bug in lookup_switch.
The code in switch_gen which looked for the special case of a two-way
switch used to use a heuristic to decide which one was recursive and
which one was a base case. We now check the codes of the cases.
hlds_goal:
Adjust the structure of the resume_point field to make it easier
to use. Add a more convenient access predicate.
hlds_out:
Don't print the nondet liveness and cont live fields, since they are
not used anymore. Comment out the printing of the context field,
which is rarely useful. Modify the printing of the resume_point field
to conform to its new definition.
live_vars:
Use the resume_point field, not the nondetlives field, to decide
which variables may be needed on backward execution. Remove some
code copied from liveness.m.
liveness:
Put the several pieces of information we thread through the traversal
predicates into a single tuple.
Don't put variables which are local to one branch of a branched
structure into the post-birth sets of other branches.
Apply the new rules about liveness in if-then-elses, which say that
the else part is parallel not to the then part but to the conjunction
of the condition and the then part. Variables that are needed in the
else part but not in the condition or the then part now die in at the
start of the condition (they will be protected by the resume point on
the condition).
We now treat pruned and non-pruned disjunctions the same way
wrt deadness; the old way was too conservative (it had to be).
We still mishandle branches which produce some variables but
can't succeed.
mercury_compile:
Liveness now prints its own progress message with -V; support this.
store_alloc:
When figuring out what variables need to be saved across calls,
make sure that we put in interference arcs between those variables
and those that are required by enclosing resume points.
Don't compute cont-lives, since they are not used anymore.
livemap:
Fix the starting comment.
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: 2.5
Mangle function names differently, so that we don't get
symbol name clashes between a function of arity N and
a predicate of arity N+1. (This fixes a bug which resulted
in error messages from the assembler.)
compiler/llds.m:
Add a new pred_or_func field to the proc/4 functor in
the proc_label type.
compiler/code_util.m:
Initialize this new field.
compiler/llds.m:
Use this new field when printing out labels.
compiler/{opt_debug.m,opt_util.m}:
Ignore this new field.
Estimated hours taken: 6
Module qualification of function calls and higher-order predicate constants.
compiler/hlds_data.m
Changed the cons(string, arity) constructor of cons_id to
cons(sym_name, arity). A module qualified cons_id is assumed to
be a function or higher-order pred constant, since we don't
yet support module qualification of constructors (Explicit
type qualification is much more useful anyway, but that doesn't
work yet either).
compiler/hlds_goal.m
Changed the functor(const, list(var)) constructor of unify_rhs
to functor(cons_id, list(var)) to allow the storing of a module
qualifier.
compiler/make_hlds.m
Parse qualified function calls and higher-order pred constants.
compiler/modes.m
compiler/intermod.m
Take module qualifiers into account when resolving function
overloading.
compiler/*.m
Updated unify_rhs's and cons_id's everywhere.
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: 15
hlds_data:
Rename address_const to code_addr_const, and add base_type_info_const
as a new alternative in cons_id, and make corresponding changes
to cons_tag.
Make hlds_type__defn an abstract type.
llds:
Rename address_const to code_addr_const, and add data_addr_const
as a new alternative in rval_const.
Change type "label" to have four alternatives, not three:
local/2 (for internal labels), c_local (local to a C module),
local/1 (local a Mercury module but not necessarily to a C module,
and exported.
llds_out:
Keep track of the things declared previously, and don't declare them
again unnecessarily. Associate indentation with the following item
rather than the previous item (the influence of 244); this results
in braces being put in different places than previously, but should be
easier to maintain. Handle the new forms of addresses and labels.
Refer to c_local labels as STATIC when not using --split-c-files.
code_info:
Use a presently junk field to store a cell counter, which is used
to allocate distinguishing numbers to create'd cells. Previously
we used the label counter, which meant that label numbers changed
when we optimized away some creates. Handle the new forms of
addresses and labels.
exprn_aux:
Handle the new forms of addresses and labels. We are now more
precise in figuring out what label address forms will be considered
constants by the C compilers.
others:
Changes to handle the new forms of addresses and labels, and/or to
access hlds_type__defn as an abstract type.
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: 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: 2
code_util:
Update a comment.
dead_proc_elim:
Fix a progress message.
hlds_out:
Put a comment sign before each switch arm's "X has functor f"
output, since this is not proper Prolog or Mercury syntax.
make_hlds:
Temporarily allow the definition of builtins, to permit bootchecking
while unary builtins are added.
prog_io:
Improve the handling of DCG variables in if-then-elses the same way
I recently improved disjunctions. Also factor out a bit of common
code.
Estimated hours taken: 30+
arg_info:
Fix allocation to work properly for --args compact.
bytecode*:
Handle complex deconstruction unifications. Not really tested because
I can't find a test case.
bytecode_gen, call_gen, code_util:
Use the new method to handle builtin predicates/functions. We now
handle reverse mode arithmetic and unary plus/minus as builtins.
code_gen, code_init, follow_vars, hlds_pred:
Put back the initial follow_vars field of the proc_info, since this
may allow the code generator to emit better code at the starts of
of predicates.
inlining:
Don't inline recursive predicates.
goals_util:
Add a predicate to find out if a goal calls a particular predicate.
Used in inlining to find out if a predicate is recursive.
unused_args:
Remove code that used to set the mode of unused args to free->free.
Since this changes the arg from top_in to top_unused *without* code
in other modules being aware of the change, this screws up --args
compact.
llds, llds_out, garbage_out:
Prepare for the move to the new type_info structure by adding a new
"module" type for defining structures holding type_infos. Not
currently generated or output.
llds, opt_debug, opt_util, vn_type, vn_cost, vn_temploc:
Change the argument of temp to be a reg, not an int, allowing
floating point temporaries.
vn_type:
Add information about the number of floating point registers and
temporaries to the parameter structure (these are currently unused).
llds, dupelim, frameopt, livemap, middle_rec, value_number, vn_filter,
vn_verify:
Add an extra field to blocks giving the number of float temporaries.
options:
Add parameters to configure the number of floating point registers
and temporaries.
mercury_compile:
Add an extra excess assign phase at the start of the middle pass.
This should reduce the size of the code manipulated by the other
phases, and gives more accurate size information to inlining.
(The excess assign phase before code generation is I think still
needed since optimizations can introduce such assignments.)
value_number:
Optimize code sequences before and after assignments to curfr
separately, since such assignments change the meaning of framevars.
This fixes the bug that caused singleton variable warnings to contain
garbage.
vn_block, vn_flush, vn_order, vn_util:
Add special handling of assignments to curfr. This is probably
unnecessary after my change to value_number, and will be removed
again shortly :-(
vn_flush:
Improve the code generated by value numbering (1) by computing values
into the place that needs them in some special circumstances, and
(2) by fixing a bug that did not consider special registers to be
as fast as r1 etc.
vn_util:
Improve the code generated by value numbering by removing duplicates
from the list of uses of a value before trying to find out if there
is more than one use.
simplify:
Avoid overzealous optimization of main --> { ..., error(...) }.
handle_options:
Fix an error message.
code_aux:
Break an excessive long line.
Estimated hours taken: 6
Fixup the way we handle the symbol table for predicates and functions
so that the compiler doesn't confuse the two, so that you can now define
a function of arity N and a predicate of arity N+1 in the same module
without giving the compiler heartburn.
hlds_module.m:
In the predicate_table, split the three maps used to index on name,
name/arity, and module:name/arity into two sets of three, one
for predicates and one for functions. Make sure that only predicates
get inserted into the pred indices and only functions get inserted
into the function indices. Add lots of new access predicates
for searching for just predicates or functions.
code_util.m, make_hlds.m, typecheck.m, modes.m, polymorphism.m:
Change the calls to predicate_table_search_* to make sure we
don't confuse functions with predicates.
code_util.m:
Change some error messages that said "pred" to say "pred or func".
make_hlds.m:
Change some warnings for bogus `pragma(export)' declarations
into errors, and clean up the code a little. Do a small part
of the work necessary to get `pragma(export)' to work for
functions.
typecheck.m:
Print a helpful error message in the case when a goal
contains a function call rather than a predicate call.
polymorphism.m:
Make sure that when it looks up `unify/2' and `builtin_*'
in the symbol table, it only for them in module mercury_builtin.
make_hlds.m, modes.m:
Call hlds_out__pred_or_func_to_str rather than converting
a pred_or_func to the string "pred" or "func" manually.
hlds_out.m:
Add new predicate pred_or_func_to_str.
Estimated hours taken: 8
bytecode*.m:
First working versions.
code_info:
Move the translation of cons_ids to tags to code_util, since it is
now needed in bytecode_gen, which doesn't have a code_info structure.
code_util:
Change the way we handle builtins in order to eventually allow
unary plus/minus operators to be builtins, and to allow the arithmetic
operators to be run backwards. (The changes aren't yet enabled since
they are not trivial to bootstrap check.)
call_gen:
Use new way of handling builtins.
mercury_compile:
Fix formatting.
Estimated hours taken: 24
Treat higher-order predicate calls as a new sort of goal,
rather than as calls to the special predicate call/N, in order to
remove the fixed limit on the number of arguments and on the modes
for call/N.
Also, remove the restriction on output arguments preceding input arguments
in lambda expressions.
hlds_goal.m:
Add new functor higher_order_call/6 to the hlds__goal type.
*.m:
Handle new functor higher_order_call/6.
arg_info.m:
Abstract things a bit more: the argument passing convention
for a procedure may be affected by that procedure's types,
modes, and code_model, as well as the arg_method.
follow_vars.m:
Pass down the args_method, since it is now needed for figuring
out the arg_info for unifications and higher-order calls.
follow_code.m:
Treat complicated unifications in the same way as calls.
lambda.m:
When creating lambda predicates, permute the arguments so
that all input arguments come before all output arguments.
call_gen.m:
When generating higher-order predicate calls, don't abort
if outputs precede inputs; instead, generate code assuming
that the called predicate's args have been permuted so that
the inputs to come before all the outputs.
Estimated hours taken: 3
options:
Add a new option, --branch-delay-slot, intended for use by mc on
the basis of the configuattion script. It says whether the machine
architecture has delays slots on branches.
The setting of option should affect whether we set
--optimize-delay-slots at -O2, but this doesn't work yet.
hlds_goal:
Add an extra field to hold follow_vars infromation to disjunctions,
switches and if-then-elses. I intend to use this information to
generate better code.
*.m:
Changes to accommodate the extra field.
Estimated hours taken: 0.1
compiler/code_util.m:
Add mercury_builtin:builtin_int_{lt,gt} to the list of builtin
operators, as synonyms for "<" and ">" on ints.
These two predicates don't exist yet, but this change is
the first step towards moving the definitions of < and >
on ints from mercury_builtin.m back into int.m.
(The other parts of this change can't be committed yet
due to bootstrapping problems.)
Estimated hours taken: 1
Fix the handling of builtins so that it takes module qualifiers into account.
compiler/{call_gen.m, code_util.m}:
Use module-qualifiers when recognizing builtins, so that
int:+/3 and float:+/3 can be recognized as different.
unify_proc.m:
Use a `mercury_builtin:' module-qualifier when constructing
calls to builtins in compiler-generated predicates, so that
user predicates with the same name don't interfere.
Estimated hours taken: 10
hlds, hlds_module, hlds_pred, hlds_goal, hlds_data:
Divided the old hlds.m into four files:
hlds_module.m defines the data structures that deal with issues
that are wider than a single predicate. These data structures are
the module_info structure, dependency_info, the predicate table
and the shape table.
hlds_pred.m defined pred_info and proc_info, pred_id and proc_id.
hlds_goal.m defines hlds__goal, hlds__goal_{expr,info}, and the
other parts of goal structures.
hlsd_data.m defines the HLDS types that deal with issues related
to data and its representation: function symbols, types, insts, modes.
It also defines the types related to determinism.
hlds.m is now an empty module. I have not removed it from CVS
because we may need the name hlds.m again, and CVS does not like
the reuse of a name once removed.
other modules:
Import the necessary part of hlds.
det_analysis:
Define a type that was up to now improperly defined in hlds.m.
prog_io:
Move the definition of type determinism to hlds_data. This decision
may need to be revisited when prog_io is broken up.
dnf, lambda:
Simplify the task of defining predicates.
llds:
Fix some comments.
mercury_compile:
If the option -d all is given, dump all HLDS stages.
shape, unused_args:
Fix formatting.
Estimated hours taken: 200
Added file unused_args.m which warns about and removes unused arguments,
e.g. type_infos, from predicates. Added compiler options:
warn-unused-args - default on
optimize-unused-args - default on
Added file higher_order.m which optimizes calls to higher-order predicates
where the higher-order arguments are known. Added compiler options:
optimize-higher-order - default on
compiler/unused_args.m
New file.
compiler/higher_order.m
New file.
compiler/code_util.m
code_util__make_proc_label/4 - adjusted this so to take into account
the fact that unused_args.m can remove arguments from special preds,
compiler/liveness.m
A fix to a bug in the way this handles switches.
Previously, if none of the cases of a switch contained the
switched-on variable, the variable was put in the pre-death set
and was clobbered before the switch. Without unused_args removing
unused variables local to the switch, this never occurred.
compiler/mercury_compile.pp
Added code to call unused_args.m.
Added hlds dump stage 12 unused-args.
compiler/quantification.m
Similar problem to that in liveness.m above.
Estimated hours taken: 1.5
Undo dylan's changes in the names of some library entities,
by applying the following sed script
s/term_atom/term__atom/g
s/term_string/term__string/g
s/term_integer/term__integer/g
s/term_float/term__float/g
s/term_context/term__context/g
s/term_functor/term__functor/g
s/term_variable/term__variable/g
s/_term__/_term_/g
s/std_util__bool_/bool__/g
to all the `.m' and `.pp' files in the compiler and library directories.
The reason for undoing these changes was to minimize incompatibilities
with 0.4 (and besides, the changes were not a really good idea in the first
place).
I also moved `bool' to a separate module.
The main reason for that change is to ensure that the `__' prefix is
only used when it genuinely represents a module qualifier.
(That's what dylan's changes were trying to acheive, but `term__'
does genuinely represent a module qualifier.)
compiler/*.m:
Apply sed script above;
where appropriate, add `bool' to the list of imported modules.
Estimated hours taken: _2___
Change names with badly placed double underscores (ie where the part of
a name before a double underscore is not the same as the module name.)
Reflect changes in the library interface.
compiler/*:
Use the newer, more correct form of the term and bool names.
Predicates "bool__" are now "std_util__bool" and labels of
the term ADT are now "term_" instead of "term__".
compiler/vn*.m:
change all names "vn__*" to a correct module prefix. All the
names remain qualified.
compiler/hlds.m:
s/\<is_builtin__/hlds__is_builtin_/g
s/\<dependency_info__/hlds__dependency_info_/g
compiler/unify_proc.m:
s/\<unify_proc_info__/unify_proc__info_/g
compiler/transform.m:
s/\<reschedule__conj/transform__reschedule_conj/g
tag_switch:
Fixed two bugs. First, if a primary tag value did not have cases for
all its secondary tag values, we now emit a goto the failure label
if the secondary tag does not match any case; we used to just fall
through. Second, the failure code itself used to be generated in
the context of the end of one of the cases; this should now be fixed,
although I want to go over it with Tom to make sure.
The computation of the secondary tag is now done once, instead of
being repeated at every secondary tag test.
options:
Set tag_switch_size to 4 by default, reduced from 8. It was this change
that exposed the two bugs above. After the fix, the compiler is smaller
by about 2 Kb.
switch_gen:
Add some comments.
code_util:
Fixed nonstandard indentation.
compiler/Mmake:
Add EXTRA_MLFLAGS variable, so that you can set
EXTRA_MLFLAGS=--no-strip if you want to preserve
the debugging info.
code_util.m, polymorphism.m, hlds.m, special_pred.m:
Move the stuff dealing with special_preds from hlds.m into
a new module special_pred. Add a new predicate special_pred_get_type
to that module, and use it in code_util.m and polymorphism.m
(replacing some fairly non-maintainable hacks).
make_hlds.m, unify_proc.m:
Import special_pred.m.
instructions, and the last argument from local labels. All these were
placeholders for info put in there by prof.m and used when emitting C
code.
The set of labels that serve as return points are now calculated in llds.m
just before each procedure has its C code generated. This set is passed to
output_instruction along with the label at the start of the procedure.
Lambda expressions now work, and you can now use polymorphic predicates
as higher-order pred terms. (Mode checking and determinism checking
are still not implemented, and the modes of call/N are very restrictive.
But these change makes solutions/2 a lot more useful now.)
hlds.m:
Comment out the stuff for recording num_warnings, since it
wasn't being used. Instead we now use that slot in the
module_info for a counter which holds a number to use to
name the predicates for lambda expressions. Add a new
predicate module_info_next_lambda_count/3 to get and
increment this counter.
modes.m:
Transform higher-order pred constants into lambda expressions.
(Also, use slightly more meaningful variable names in a few places.)
polymorphism.m:
Use module_info_next_lambda_count/3 to name the predicates
created for lambda expressions.
code_util.m:
Handle __LambdaGoal__ labels correctly.
context of the unification from which call was made. We we use this to generate
significantly better error messages. (There should be no more messages of the
form "call to __Unify__(blah blah blah) can fail".) Most of the files are
changed just to reflect this.
An unrelated change in det_analysis is that we now ensure the absence of
cycles by modifying the new inferred determinism in the light of the old
one, ensuring that any changes are monotonic.
In hlds_out, inhibit the printing of pseudo-imported predicates (unifications)
since nobody cares about them except sometimes Fergus.
unifications. See the comments at the top of unify_proc.m for
details of how it's done.
hlds.m:
Add new export statuses `pseudo_imported' and `pseudo_exported'
to handle unification predicates, which can now have complicated
modes.
code_gen.pp, code_info.m, common.m, constraint.m, cse_detection.m,
follow_code.m, follow_vars.m, hlds_out.m, inlining.m, live_vars,
make_hlds.m, mercury_compile.pp, modes.m, store_alloc.m,
switch_detection.m:
Handle pseudo_imported predicates.
modes.m, constraint.m:
Change modecheck to return an updated module_info, since
modechecking may insert new entries into the unify_requests
queue in the module_info. Make sure that modechecking
never inserts requests into the unify_requests queue
for code that has mode errors (or needs rescheduling).
call_gen.m, polymorphism.m:
Move duplicated code into unify_proc.m.
clause_to_proc.m:
Add new predicate clauses_to_proc for use by unify_proc.m.
unify_proc.m:
Implement complicated unifications with complicated modes.
*.m:
Changed the way the extra field in the label type is defined. Now
all labels are initially assumed to be 'unknown' and a seperate
profiling pass (to be implemented) will determine whether the label can
be accessed externally.