code_info.m:
Change some comments in the generated code slightly.
ite_gen.m:
grab the instmap before generating the condition not
after in all three kinds of ite.
unify_gen.m:
grab and slap the code_info structure across the call
to generate_failure. This pair of calls should probably
be migrated into generate_failure. I'll check this out
soon (tomorrow).
call_gen.m code_gen.pp code_info.m garbage_out.m hlds.m llds.m
mercury_compile.pp shapes.m:
Output .garb files (with --gc accurate). This option overrides
information gleaned from the grades about GC.
Remove some of the magic numbers that were being used for
shape numbers.
*.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.
debug_util.m, debugger.m:
Add new files which implement the debugger.
everything else:
Merge in changes between when the `debugger' branch was created
and now (Mon Jun 26 07:44:55 GMT 1995).
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.
options, optimize:
Add a new option, --optimize-fulljumps, which defaults on.
jumpopt, opt_util:
If --optimize-fulljumps is set, replace unconditional gotos with
the instruction sequence they point to. This not only avoids a jump
at runtime, but also increases basic block length and makes value
numbering more effective.
peephole:
Fulljump optimization can replace a recursive tailcall with the
initial part of the code of the procedure. Therefore peephole now
looks for a decr_sp followed by an incr_sp, and removes such pairs
from the instruction sequence.
frameopt:
Do not consider a decr_sp followed by an incr_sp to be a fatal error
(just in case peephole is switched off).
vn_block:
Fix a big tickled by fulljump optimization: maxfr, curfr and succip
were not required to be made up to date before an if_val exited
the extended basic block.
vn_util:
Simplify some more patterns of vnrvals. The extra patterns are
involved in testing conditions that are known to be true or false.
These patterns can arise when fulljump optimization replaces a
recursive tailcall.
modes.m, typecheck.m, code_util.m:
Don't report a compile error if there is a higher-order pred
unification in a compiler-generated predicate. (Instead, delay
the error until run-time so that it only occurs if the higher-order
pred unification in question actually gets executed.)
ite_gen.m:
Fix bug in code generation for nondet if-then-else with nondet
condition - the save of the hijack frame maxfr was occurring
before the hijack frame was created.
code*.m & *gen.m:
Implement an improved method of handling negated contexts.
The new method avoids saving things onto the stack before
an if-then-else or negation if it can.
Also, fix the implementation of nondet if-then-else so that
it does the soft cut properly.
mode_util.m:
Fix two bugs. One was very subtle, due to the fact that
after my recent bug fix to merge_instmap, the assumption that
merge_instmap(empty_instmap, X) == X
is no longer true. The other was an obvious stupid cut-and-paste
bug - the recursive call in `recompute_instmap_delta_disj'
called `recompute_instmap_delta_CONJ'.
mercury_compile:
Sort the list of interface files before printing them to a .d file.
opt_util, peephole:
Fix a bug tickled by value numbering. Some sequences of code were
recognized as having no access to nondet stack control slots even
in the presence of such accesses, which lead to the incorrect
introduction of succeed_discards.
value_number:
Loosen the value correspondence sanity check, which was failing
needlessly, and tighten the tag sanity check, which was passing
incorrect code.
Do not try value numbering on blocks containing structures such as
"if (tag(x) == X && field(X, x, X) == X) goto X", since these will
definitely lead to tag sanity check violations.
vn_flush:
If a shared node has no uses left when flushed, leave it be.
When generating a mkframe, reflect its update of the top redoip slot
in the data structures.
vn_order:
Some hacks to get the relmaps partway to where I want them. This
code needs cleaning up.
vn_debug:
New debugging routines to support my changes to vn_order.
vn_type:
Deleted the vn_modframe vn_instr, since its role has been taken over
by assignments to redoip(maxfr).
opt_debug:
Reflect the change to vn_type, print address constants in vn_rvals,
and fix a typo.
vn_block, vn_util:
Reflect the change to vn_type.
det_analysis.m:
Fix another bug in det__disj_to_ite - the internal/external
determinism of the if-then-else were being recalculated, and then
clobbered with the original internal/external determinism of the
disjunction.
typecheck.m:
Remove the need for synchronizing the type var sets between different
type assignments in a type assignment set, by keeping track of
a list of argument types to match against for each type assignment
in the set. This allowed me to reintroduce my earlier changes
to improve the error messages. I also improved the error messages
for variables with overloaded types.
Also fix bug introduce by Zoltan's changes: only display the progress
message once, not twice ;-)
mercury_compile.pp:
Change the output to the `.dep' file so that `foo_init.c' does
not depend on anything and so that the arguments passed to $(C2INIT)
are `foo.m bar.m' rather than `foo.c bar.c'.
Note: this will only work with the new version of mkinit.
frameopt, opt_util:
Attempt to fill delay slots with the instruction after an if_val
in preference to the saving of the succip.
optimize:
Fix a typo in earlier change.
value_number:
Check that the last node in the order is a control node.
vn_order:
If two registers or stackvars can be generated in any order,
prefer to generate them in numerical sequence for neatness.
vn_debug:
Add routine for printing the initial and final ordering of
unrelated nodes.
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.
frameopt:
Previously, if some code that did not have a frame set up had an
if_val that branched to a label that required a frame, we inverted
the test and made it branch around code that set up the frame and
them branched to that label. This was undesirable, but I thought
the situation would be rare. The new code generator new generates
this kind of code more frequently (e.g. in tak), so I changed
the algorithm for dealing with the situation. We now branch to
a new label inserted immediately before the target label, with
the frame setup code between those labels.
compiler/Mmake:
Include the library .m files in the tags file.
hlds.m and lots of other places:
Change the type of the argument list of a HLDS `call' from
`list(term)' to `list(var)'.
quantification.m:
If a variable is explicitly quantified, push the quantifiers
inwards as far as possible. This avoids some spurious determinism
errors that would otherwise result.
compiler/notes/*:
Update a few more files.
Remove some files which were duplicates of the information
in the manuals, to avoid double maintenance problem.
modes.m:
When computing the cons_id for a construction/deconstruction
unification, check whether the cons_id is already present
in info for that unification, and if so use the existing cons_id.
This is necessary to make --common-goal work, since cse_detection
invokes mode analysis after polymorphism, and polymorphism
introduces code_address cons_ids which we must not throw away.