modes.m, unify_proc.m:
Fix obscure "map_lookup failed" bug triggered by a partially
instantiated mode of a complicated unification predicate, whose
procedure body contained a call the the same complicated
unification predicate in a different partially instantiated
mode.
constraint.m, cse_detection.m:
Change calls to modecheck to match new simplified interface.
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.
hlds:
Removed the notion of "internal determinism"; commits are now indicated
through "some" goals. Renamed the predicate module_info_shapes to
module_info_get_shapes. Will later change other predicates also to
get consistent naming.
hlds_out:
Removed printing of internal determinisms.
det_analysis:
Changes to accommodate the new way of signalling commits. The comments
on optimizations have been modified to reflect the need for information
about whether goals can raise exceptions. Exported two predicates for
use by follow_code.
live_vars:
Changes to accommodate the new way of signalling commits.
code_gen:
Shift the handling of commits to "some" goals. Some predicates
had three versions, one for each code model; these have been
simplified significantly. The sequence of predicates has also
been rationalised a bit. There is still room for improvement
on both fronts.
disj_gen, ite_gen, middle_rec:
Changed calls to modified predicates in code_gen.
common:
When this pass changes A == f(B, C), D := f(B, C) into A == f(B, C),
D := A, it can change the scopes of A, B and C. The pass did not
take this into account; now it does. The pass is still disabled
until it has been more adequately tested.
mercury_compile:
Moved followcode into the back end. We now thread ModuleInfo through
the backend instead of Shapes, since follow_code modifies other parts
of ModuleInfo as well. Rationalised the stage numbers, WHICH MEANS
-d NUMBERS HAVE CHANGED.
follow_code:
Follow_code is now after determinism analysis, so that we can check
that it does not change the determinism of the branched structure
we are pushing code into. We now push not just builtins but also the
first call after the branched structure into the branched structure,
since this will reduce register shuffling. Made a start on pushing code
into the fronts of branched structures, when some code before the branch
point is useful only in one branch.
options:
Added an option prev_code for the (incomplete) functionality in
follow_code.
vn_flush:
Moved a comment about future functionality to where it now belongs.
cse_detection:
Removed obsolete debugging predicate.
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.
options:
Cleanup of the option set. Main change is making linking the default,
and the replacement of -g, --compile and --link by -e, -C and -c.
WARNING: this makes the compiler inconsistent with the standard mmake
configuration, so don't do a cvs update yet unless you know what you
are doing.
conf:
Find out at configuration time how many bits the --tags low option
uses.
mercury_compile:
With the help of conf, we now make sure --tags and --num-tag-bits
are consistent. We use the new set of options. We also generate
program-specific .clean rules in .dep files.
make_tags:
Mercury_compile now makes sure that --tags and --num-tag-bits are
consistent, so make_tags need not do it.
mode_errors:
Use the new set of options.
llds:
Changes to introduce the new option use_macro_for_redo_fail and
change --mod-comments into --auto-comments.
cse_detection:
We now print the messages about redoing mode analysis, switch detection
and cse detection only if very verbose is on.
typecheck:
The error message for wrong number of arguments now gives the actual
number and the right number(s).
value_number:
Tighten the sanity check; theold version wasn't tight enough for
the code generated for prof.m.
hlds.m and lots of other files:
Change the type of the first two arguments of unify/5 in
hlds__goal_expr from `term, term' to `var, unify_rhs'
where unify_rhs is given by
:- type unify_rhs
---> var(var)
; functor(const, list(var))
; lambda_goal(list(var), hlds__goal).
This change was for two reasons: firstly, it simplifies the
code in a lot of places, and secondly, it is a step towards
implementing lambda closures and higher-order predicates
properly.
code_gen.pp:
Put the comment about the contents of stack slots before the initial
label, since this way it will be preserved by optimizations.
cse_detection.m:
Extended the search to look for cses in if-then-elses and switches
as well as disjunctions. Removed InstmapDelta from preds in which it
was not being used.
det_analysis.m:
Make the diagnosis routines more robust. The changes here avoid the
Philip's problems with lexical.m.
jumpopt.m:
Minor formatting changes.
livemap.m:
Avoid duplicating livevals instructions when optimizations are
repeated, since this can confuse some optimizations.
llds.m:
Minor documentation change.
make_hlds.m:
Minor formatting change.
mercury_compile.pp:
Do not map arguments to registers if any semantic errors have been
found.
middle_rec.m and code_aux.m:
Apply middle recursion only if tail recursion is not possible,
since tail recursion yields more efficient code.
opt_util.m:
Added a predicate to recognize constant conditions in if_vals.
Modified a predicate to make it better suited for frameopt.
optimize.pp:
Changed the way optimizations were repeated to allow better control.
Repeat peephole once more after frameopt, since the new frameopt
can benefit from this.
options.m:
Removed the --compile-to-c option, which was obsolete. Added an
option for predicate-wide value numbering, which is off by default.
Changed some of the default values of optimization flags to reduce
compilation time while holding the loss of speed of generated code
to a minimum.
peephole.m:
Look for if_vals whose conditions are constants, and eliminate the
if_val or turn it into a goto depending on the value of the constant.
Generalized the condition for optimizing incr_sp/decr_sp pairs.
value_number.m:
Added a prepass to separate primary tag tests in if-then-elses from
the test of the secondary tag, which requires dereferencing the
pointer.
Added sanity check routines to test two aspects of the generated code.
First, whether it produces the same values for the live variables as
the original code, and second, whether it has moved any dereferences
of a pointer before a test of the tag of that pointer. If either test
fails, we use the old instruction sequence.
vn_debug.m:
New messages to announce the failure of the sanity checks. They are
enabled by default, but of course can only appear if value numbering
is turned on (it is still off by default).
vn_flush.m:
Threaded a list of forbidden lvals (lvals that may not be assigned to)
through the flushing routines. When saving the old value of an lval
that is being assigned to, we use this list to avoid modifying any of
the values used on the right hand side of the assignment, even if the
saving of an old value results in assignment that requires another
save, and so on recursively.
When the flushing of a node_lval referred to a shared vn, the uses of
the access vns of the node_lvals were not being adjusted properly.
Now they are.
vn_order.m:
The ctrl_vn phase of the ordering was designed to ensure that all
nodes that need not come before a control node come after it. However,
nodes were created after this phase operated, causing leakage of some
value nodes in front of control nodes. Some of these led to pointer
dereferences before tag tests, causing bus errors. The ctrl_vn phase
is now last to avoid this problem.
vn_table.m:
Added an extra interface predicate to support the sanity checks in
value_number.
vn_util.m:
The transformation of c1-e2 into (0-e2)+c1 during vnrval simplification
could lead to an infinite loop in the compiler if c1 was zero. A test
for this case now prevents the loop.
switch_detection:
Detect partial switches, i.e. disjunctions in which not all
disjuncts form part of the switch. We give preference to full
switches, and failing that, to partial switches with the most arms.
peephole, opt_util:
Fixed the code for the introduction of succeed_discard.
code_gen:
Fixed spelling error in error message.
code_info:
Made error message somewhat more informative.
cse_detection:
Removed debugging code; we now always repeat cse detection after
finding some cses.
det_analysis:
Added some comments.
value_number, vn_debug, vn_flush:
Changes to make debugging easier.