options.m:
By default, disable value numbering.
(From what I understand it should work now, but nevertheless
it should not be enabled by default since it slows down
compilation.)
frameopt:
Look inside blocks introduced by value numbering when looking
restorations of succip.
value_number, opt_util:
If we are using conservative garbage collection, disable value
numbering for blocks that allocate more than one cell on the heap.
This allows value numbering of most blocks to work in the absence
of -DALL_INTERIOR_POINTERS.
all other source files:
Clean up "blank" lines that nevertheless contain space or tab
characters.
options.m, mercury_compile.pp:
Added a new compilation warning (& option), which issues a warning if
a module has an interface section that doesn't export anything, or
is non-existant.
common:
Reorganized the way ready-for-reuse structures are represented.
The type of the variable to which the structure is bound is now
stored with the structure information, so we can avoid reusing
a structure for a variable of a different type (which may have
a different data representation). This is necessary for correct
handling of convert_item/2 in prog_io.
options:
Turn on common structure optimization by default.
mercury_compile.pp, options.m:
Split most of the option post-processing into a separate predicate.
Changed the handling of --num-tag-bits: previously this option was
ignored unless you specified --tags high, but now it works like
it originally did, i.e. even with --tags low. The autoconf value
is only used if no --num-tag-bits option is specified.
Removed the undocumented arbitrary limit of a maximum of 6 tag bits.
(On a 64-bit architecture, you might well want to use 30 tag bits!)
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.
mercury_compile.pp, options.m:
Add `-o' (`--output-file') and `--link-flags' options.
Separate the "Output Options" into two sections.
Change `-m-' (`--no-modecheck') to `-t' (`--typecheck-only').
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.
options.m:
Added the profiling option, which generates a file <module>.prof, which
contains the static call graph.
dependency_graph.m:
Predicate to output the static call graph in a form useful for the
profiler.
prof.m:
Scan's through the LLDS marking all labels that are continuation
labels. eg All label's cont_type field should be unknown now.
llds.m, code_info.m:
Minor changes so that the above stuff works.
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.
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.
mercury_compile:
Perform arg_info only if we are generating code.
llds:
Handle redo and fail by outputing a branch to their labels in the
runtime, since this is smaller than the code for the macro itself.
dupelim, options:
Added an extra optimization pass to eliminate duplicate blocks of
code. Reduces compiler size by half a percent.
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.
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.
compiler/*:
Add copyright messages.
Change all occurences of *.nl in comments to *.m.
compiler/mercury_compile.pp:
Change the output to the .dep files to use *.m rather than *.nl.
(NOTE: this means that `mmake' will not work any more if you
call your files *.nl!!!)
Makefile.common:
Use mkdir -p.
Add mmake.sh.
Change the tags rule so that it gets the .pp files first.
Change the name of the compiler target from comp to mercury_compile.
Remove the rules for test.exe since they duplicate the auto-generated
ones in test.dep (which call the target `test' not `test.exe').
Remove the `code_gen' target. (Tom, if you need it, put it in
Makefile.params.)
Hack around with the installation rules (still in a state of flux).
options.nl:
Disable the --mod-comments option by default.
llds.nl:
Only output the gc livevals comment if --mod-comments is enabled.
mercury_compile.nl, prog_io.nl:
Handle `file not found' errors more cleanly.
When making the dependencies, assume that any files not found
are library files, so don't put them in the dependencies.
modes.nl:
Resolve type ambiguity introduced by change to prog_io.nl.
Mmake.rules Mmake.vars:
Split Makefile.mercury into two halves for use by mmake.
NOTE: I haven't removed Makefile.mercury yet, so any changes
need to be made in both places!
Makefile.mercury:
Change the default grade from `fast' to `asm_fast.gc'.
Makefile.common, mercury_compile.pp:
Change the rules in the generated .dep makefiles so that
the NU-Prolog executable is called `<module>.nu', not `<module>'.
Add new rules for creating `<module>' and `<module>_init.c'
using mc and mod2init.
mercury_compile.pp:
Fix a couple of bugs in the option handling: firstly `--gc
conservative' should imply `--tags none', and secondly the
CONSERVATIVE_GC, TAGBITS, and HIGHTAGS #defines were not
being passed to gcc.
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.
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.
call_gen.nl:
Fix the code generation for call/N to handle input args.
code_util.nl:
Recognise all call/Ns as builtin
options.nl:
Turn off common subexpression elimination by default
garbage_out.*:
A new module to handle the output of the garbage collection
information, presently it generates and puts the continuation
table into a .garb file.
Makefile, Makefile.mercury:
Rule for creating .garb files, and new dependencies for
targets.
io.nl, io.nu.nl:
Added io__read_anything/3 and io__read_anything/4.
mercury_compile.pp, options.nl:
Added option support for garbage collection, `--gc accurate'
switches on .garb file output, but code-generation must
also be on.
shapes.nl:
Cosmetic changes.
optimisation. It doesn't appear to be doing that yet but nor does
it appear to be doing any harm :-)
It can be switched out in any case with the --no-common-subexpression option
Makefile.common:
Add new targets `mercury_compile.sicstus' (the Mercury compiler
compiled with Sicstus) and `mercury_compile.sicstus.debug'
(debugging version of the above).
*.nl:
Use Sicstus-compatible char and string escapes.
Avoid the use of explicit existential quantification.
Various other hacks to get things to parse correctly under Sicstus.
prog_io.nl:
Don't allow (A -> B) in DCGs, since NU-Prolog and Mercury give
it different semantics to Sicstus.
sp_builtin.nl, sp_lib.nl:
Split sp_builtin.nl into sp_builtin.nl and sp_lib.nl.
sp_conv.sed:
Add sed script which converts some character escapes so that
they work with Sicstus.
term_io.nl:
Remove term_io__prefix_op etc. since they aren't used anymore.
graph.nl:
Added more stuff needed for the call_graph.
mercury_to_mercury.nl:
added a version of the predicate for outputing
mode declarations that leaves off the ':-' and '\n'
options.nl:
added the option -C for generating a call graph in the
file <module>.call_graph
Makefile.common:
Various minor bugfixes.
Makefile.mercury:
Add rules for creating assembler (.s) files.
term.nl, *.nl:
Replace term__context_init/1 with term__context_init/0.
The first argument was always zero anyway.
io.nl:
Change the interface to io__read_char and io__read_line so that
they return a better error indicator.
Add a new predicate io__putback_char.
polymorphism.nl:
Don't abort if a predicate doesn't have any modes.
options.nl:
Let's try turning polymorphism on again. It seems to work this time.
string.nl, string.nu.nl:
Add string__to_float.
Move implementation of string__to_int from string.nl to string.nu.nl.
mercury_compile:
Added back an old garbage collection point.
optimize:
Added some new garbage collection points, and made the file into .pp.
value_number, vn_util, opt_debug:
Changed the way access vns are counted. Pushed noop vnlvals towards
the front of the flush order; this can improve the speed of the
generated code.
middle_rec:
Clarified a bit of code.
Makefile.common:
Add some targets for compiling the compiler and the library.
type_util.nl, dense_switch.nl, switch_gen.nl, polymorphism.nl:
Rename inttype, chartype, etc. as int_type, char_type, etc.
Add polymorphic_type.
modes.nl, mode_errors.nl:
Report an error for direct attempts to unify higher-order pred types.
(Of course, we don't catch indirect attempts via polymorphic types -
that would require global analysis. For them, we report the error
at runtime.)
modes.nl:
Remove unreachable code from conjuctions.
(XXX also should do this for if-then-else.)
options.nl:
Turn -p off by default. I'll turn it on again when it works ;-)
polymorphism.nl:
Fix some bugs:
- I had forgotten to update the argmodes of the modified
procedures
- I was updating the argtypes and attempting to use there
old value. I fixed this by splitting the algorithm
into two passes.
- to compute the types of the arguments to a call,
apply the type mapping from the _caller_ not the callee.
Also improve efficiency in a couple of places.
hlds.nl:
Add some new access predicates required by polymorphism.nl.
list.nl:
Add a new predicate list__duplicate, which is used by polymorphism.nl.
typecheck.nl, type_util.nl:
Move the type_unify routines from typecheck.nl into type_util.nl,
since they're also needed by polymorphism.nl.
term.nl:
Export term__apply_rec_substitution_to_list, since it's needed
by polymorphism.nl.
- - - - - - - - - - - - - - - - - - - - - - - - -
mode_util.nl, type_util.nl:
Move some routines from mode_util.nl to type_util.nl, where they
really belong.
- - - - - - - - - - - - - - - - - - - - - - - - -
make_hlds.nl, code_util.nl, typecheck.nl:
Mark builtin predicates as "external" in make_hlds.nl,
rather than checking for them as a special case in typecheck.nl.
- - - - - - - - - - - - - - - - - - - - - - - - -
prog_io.nl, hlds.nl, typecheck.nl:
For documentation purposes, define equivalent types `tvar',
`tvarset', `tsubst' for type variables, type varsets, and
type substitutions.
- - - - - - - - - - - - - - - - - - - - - - - - -
mercury_compile.pp, options.nl:
Change the handling of the --dump-hlds option so that you can
now dump the HLDS after any of the 12 HLDS transformation passes.
- - - - - - - - - - - - - - - - - - - - - - - - -
make_hlds.nl:
Report an error if there are clauses for an imported predicate.
- - - - - - - - - - - - - - - - - - - - - - - - -
io.nu.nl:
Add a new predicate r/1 which is like run/1 except that
you pass it a string rather than a list of atoms.
So now you can do
$ mercury_compile.debug
Mercury Interpreter 0.1
NU-Prolog 1.6.4
1?- r("mc -options blah blah blah").
value_number, vn_util:
Closer to working than before :-)
opt_util:
Moved all value_number-related functionality from there to vn_util.
llds and other files:
Renamed live_lvalues to liveinfo, and added a list of these as a
third argument to call_closure as well. Fergus and Tom, please generate
this third argument in call_gen.
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.
now in dense_switch, string_switch and tag_switch, with the original
if-then-else implementation and the code that decides on optimizations
still in switch_gen.
Added options to replace the magic numbers governing the choice of switch
method.
Added comments to frameopt, jumpopt, labelopt and peephole.