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.
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)'.
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.
options.m call_gen.m code_gen.pp code_info.m code_util.m llds.m unify_gen.m:
A bunch of changes to implement the procs-per-c-function option.
This default is now `--procs-per-c-function 1', for reasonable
efficiency of compilation, but for efficiency of generated code
(e.g. when compiling benchmarks!)
use `--procs-per-c-function 0' (0 really means infinity).
I haven't tested this in any mode except asm_fast, so it's possible
that this change might break the other modes. If that turns out
to be the case, let me know. The symptom will be an error from
the C compiler or linker.
prog_io, hlds: Added the functor "multidet" to the type determinism.
Added types and predicates to relate determinism to its
two components, can_fail and soln_count.
Removed the functor "unspecified" from the type determinism,
substituting maybe(determinism) for determinism in proc_info.
Replaced the type category with the type code_model,
and added predicates to compute it from determinism.
det_analysis: Redone the analyses to work with determinism, not category
(or code_model). This should enable programmers to write
their own erroneous (and failure) predicates.
other files: Use the new and renamed types and access predicates.
frameopt:
fix the problem with destroying stack frames and creating
them again later, accessing detstackvars that were earlier
nominally destroyed.
vn_livemap:
renamed it to livemap since frameopt now uses it also.
value_number, vn_*:
Fixed some bugs. Reorganized the handling of blocks: they are now
put in at the last minute before llds writes out the code.
Made a start towards exploiting info about cheaper copies of
values.
optimize, options:
Made value_numbering an iterated optimization. Added a new
option to control how many times it is iterated together
with other the jumpopt, peephole and labelopt.
llds, call_gen, code_gen, code_info, middle_rec, opt_debug:
changed type of the argument of livevals to plain set.
Warning: in more than a week I haven't been able to fully test this change,
dur to kryten's flakiness and bugs upstream of the optimizer.
code_gen.pp:
Oops, back out previous change, since it didn't quite work
properly (need to change things so that it doesn't do a
localcall to procedures that are not in the same C function).
exprn_aux.nl:
a new module for manipulating rvals and lvals.
code_exprn.nl:
the new bottom level of the new code generator. This replaces
a large chunk of code_info.
*code* & *gen*:
various small changes to use the new bottom level of the
code generator.
io.nl:
Introduced a new predicate which ignore's any whitespace in the input.
Needs to have all the whitespace character's added to it.
*.nl and *.pp:
Changed the implementation of time profiling. Now during a compile,
the compiler identifies all the internal labels which can be accessed
externally, and marks them. At the moment, these are the continuation
labels of calls and the next disjunct in nondet disjunctions. Then
at the .mod output, it places a macro 'update_prof_current_proc' to
restore the profiling counter.
unify_gen:
Whenever we do a test of a variable against a non-constant functor,
we now try to turn it into a negated test on a constant functor.
This is possible if these two functors are the only ones.
code_aux:
Added an extra predicate to look up type definitions to make the
previous change easier.
llds, code_gen, opt_util, opt_debug, frameopt, jumpopt, peephole:
Added a boolean argument to do_succeed to say whether the nondet
frame should be discarded on success or not. The default is no,
but peephole has an optimization that tries to turn on this flag.
optimize, value_number, vn*:
Restructured the top level of value numbering as part of an effort
to identify blocks that could be optimized further given our knowledge
that the contents of e.g. stackvars is also in registers when we
jump to those blocks. Redone the interface between value_number and
frameopt to allow value_number to be iterated, which is necessary
to take advantage of the previously mentioned capability. Threated
the I/O state through the relevant predicates; value numbering doesn't
use non-logical I/O any more.
llds.nl:
Introduced an extra argument to the LLDS goto. It is the label
address of the Caller and is used for the profiling of tailcall's.
*.nl and *.pp:
Propagated the extra argument to all the appropiate files.
Makefile.*:
Added a target to make the library as a shared library, not just as
an archive.
code_gen, options:
Introduced a new option to disable middle recursion optimization.
This is needed to generate the right example code for section 3 of
the JLP paper.
jumpopt:
Factored some code.
frameopt:
Put back a most of an optimization lost by a previous change.
vn_order:
Changed the computation of desired dependencies; the new method should
lead to improvements more frequently.
code_gen.{nl,pp}:
Fix a long-known undocumented bug in which preds for which
the main conj has inst 'unreachable' aborted.
Before generating a negated goal, save live variables onto
the stack so we can find them again later.
ite_gen.nl:
Before generating the condition of an if-then-else, save the
live variables onto the stack so that we can find them in the
else clause.
live_vars.nl:
Add interference for the cases where live vars are saved before
negations and ite conditions.
shapes:
New module to handle shape information collection.
call_gen, code_gen, code_info, hlds, mercury_compile:
Modifications to call the shapes module, and keep a shape
table in the module_info structure.
code_gen.nl:
changed the epilogue for semidet prcs so that hte livevals
for the failure proceed contains only r1.
bintree_set.nl:
added bintree_set_singleton_set/2.
value_number, vn_util:
Value numbering should now work with code that allocates memory.
frameopt:
Create a stack frame before an if_val if both continuations need one.
optimize, mercury_compile:
-V now prints a message for each optimization pass for each proc.
llds, call_gen, code_gen, middle_rec etc:
Change livevals/2 back into livevals1.
jumpopt:
Rename instmap to instrmap at fjh's request.
think I have forgotten ;-)
live_vars.nl:
Fixed the stackslot sharing problem.
Still need to fix the instmap problem.
code_*.nl:
Bits and pieces of higher order stuff, threading the
instmap through code generation.
hlds_out.nl:
Write out the stack allocations (with var numbers).
*.nl:
Replace all occurrences of `not(Vars, Goal)' with just
plain `not(Goal)'.
type_util.nl, switch_gen.nl:
Higher-order pred types are not user-defined types.
Add a `predtype' type category for them.
call_gen.nl:
Change call_closure/2 to call_closure/3 (with liveinfo).
Plus a little bit of random hacking.
llds.nl:
changed call/2 to call/3 to include gc information about
what registers and stack locations are live, and what their
`shape numbers' are. Currently all the shape numbers are -1
because the shape table stuff hasn't been implemented.
* The changes made are only cosmetic as far as everything else
* is concerned.
*.nl, etc:
changes related to the above.
term.nl:
In term__create_var, use bit reversals rather than random numbers
to ensure that the binary trees remain balanced.
call_gen.nl:
For polymorphic unifications, generate a call to fatal_error().
code_gen.nl, hlds.nl, make_hlds.nl, modes.nl, unify_proc.nl:
Move the unify_request data structure from code_info to the HLDS,
and move the unify_request handling from code_gen.nl to modes.nl.
This is because we now generate HLDS code rather than LLDS code
for complicated unifications.
code_util.nl, hlds_out.nl:
Do some special name mangling for =/2.
float.nl, typecheck.nl, undef_types.nl, term.nl, hlds.nl:
Until we implement `float' properly, define it as an abstract type
in float.nl.
hlds.nl, make_hlds.nl:
Rename `local_pred, imported_pred, exported_pred' to just
`local, imported, exported' since they also apply to types, etc.,
not just to preds.
mercury_compile.pp, mercury_to_goedel.nl, prog_util.nl:
Replace to goedel__ prefixes in prog_util.nl with prog_util__.
std_util.nl:
Change the code for semidet_succeed to avoid determinism warning.
code_gen, opt_util:
prepared then for middle_rec.
peephole, opt_debug:
old changes.
printlist.int:
shouldn't have been here in the first place.
source_stats.awk:
turned comments into awk syntax.
value_number.nl:
a lot less functionality is missing now :-)
atsort.nl:
approximate topological sort for value numbering
opt_*.nl:
changes to supprt value numbering
llds.nl, *_gen.nl:
changed livevals/1 into livevals/2 to support value numbering
list.nl:
added a predicate to delete a list (set) of items from a list
peephole.nl:
implement shortcircuiting inside computed goto label lists. Not tested
since the only place we use computed gotos has no opportunities for
short circuiting.
options.nl:
added option to control the maximum number of repetitions of
the peephole optimizations; default value is 2.
dir.nl:
fixed spelling error
Makefile*:
Add some more stuff for compiling to .o
Makefile*, mercury_compile*, code_gen*:
Add some stuff for handling `.pp' files.
`.pp' files are Mercury source code containing
NU-Prolog hacks inside
#if NU_PROLOG
...
#endif
These hacks are preprocessed out (using sed, not cpp)
except when compiling with `mnc'.
term_io.nl, term_io.nu.nl, interpreter.nl, prog_out.nl:
Make sure all the predicates in term_io.nl are
prefixed with `term_io__', not `io__'.
term_io.nl, require.nl:
Add some `external' declarations.
call_gen.nl, unify_gen.nl:
A temporary hack - generate incorrect code for complicated/polymorphic
unifications, rather than aborting.
random.nl:
Make the code more efficient.
hlds.nl, term.nl:
Allocate pred_ids and variable numbers randomly rather than
sequentially, so that the binary trees remain reasonably balanced.
code_info.nl, unify_gen.nl, hlds_out.nl:
Generate informative comments for tag tests: say the name of
the variable being tested, and which constructor we are testing for.
llds.nl:
Cast field() expressions to (int) when used as rvals, so
that comparisons work as expected.
make_hlds.nl:
Improve error reporting.