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: 3
code_aux, code_info:
Start using resume_point information to save variables to their
stack slots when they become forward dead.
code_gen, middle_rec:
Handle the code fragments that can now result from pre and post
goal updates.
live_vars:
Make sure that variables that can be put into stack slots at
resumption points get stack slots allocated to them.
liveness:
Fix a bug in the computation of resume_point sets.
llds_common:
Fix some comments.
Estimated hours taken: 1.5
goal_util:
Replace the two delta_liveness fields of the goal_info with four
separate fields, {pre,post}{births,deaths}, since they were being
used separate most of the time in any case. The new arrangement
will require less storage.
other files:
Use the interface predicates for getting at these sets separately.
There are no algorithmic changes in this checkin.
Estimated hours taken: 0.75
The first step towards the implementation of the new ALLOCATION strategy:
renamed call_info to stack_slots.
There are no algorithmic changes in this checkin.
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: 24
A bunch of changes required to fix problems in code generation for
model_det and model_semi disjunctions.
simplify.m:
Don't convert all model_det and model_semi disjunctions into
if-then-elses, because that doesn't work if the disjuncts
have output variables, which can happen (e.g. with cc_nondet
disjunctions)
disj_gen.m:
Fix a bug in the code generation for semidet disjunctions:
don't forget to jump to the end of the disjunction after
each disjunct!
liveness.m, live_vars.m, store_alloc.m, disj_gen.m:
Treat backtracking in model_det and model_semi disjunctions
as shallow backtracking rather than deep backtracking.
This means that rather than pushing all live variables
onto the stack at the start of a model_det/semi disjunction,
and using the nondet_lives to keep track of them, we instead
treat these disjunctions a bit more like an if-then-else and
use the ordinary liveness/deadness to keep track of them.
code_aux.m:
Change code_aux__pre_goal_update so that it only applies
the post-deaths if the goal is atomic. Applying the
*post*-deaths to the set of live variables in the *pre*-goal
update only makes sense for atomic goals.
(I think previously we only ever generated post-deaths
for atomic goals, but now we generate them also for
goals inside model_det or model_semi disjunctions.)
code_gen.pp, middle_rec.m:
Pass an is-atomic flag to code_aux__pre_goal_update.
hlds_goal.m:
Add some comments.
goal_util.m:
Fix bugs in goal_util__name_apart_goalinfo.
It wasn't applying the substitution to all the
appropriate fields.
code_exprn.m:
Improve the error message for one of the internal errors.
hlds_out.m:
Print the stack slot allocations in the HLDS dump again.
Estimated hours taken: 3
Some fixes Fergus suggested for my previous sets of changes.
Give error messages for circular equivalence types.
compiler/equiv_type.m
Detect and report circular equivalence types.
Previously the unification preds for circular equivalence
types looped.
compiler/typecheck.m
Fixed printing of constants in write_functor_name
- foo instead of foo/0
compiler/code_aux.m
Undid my previous change to code_aux__contains_only_builtins,
which made the code less general than it could be.
compiler/inlining.m
Changed inlining__simple_goal to disregard complicated_unify.
compiler/polymorphism.m
Make sure bound insts are not module qualified.
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: 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: 4
Implement `recursive' and `non_recursive' pragma c_code declarations.
This allows the compiler to optimize cases when the C code
is known to not call Mercury code. It's also necessary
to allow C code which modifies the hp register to work
(such code must be declared `non_recursive', otherwise
the registers will be saved and restored over it).
To make things bootstrap OK, the old pragma c_code declarations
default to `non_recursive'.
prog_data.m, hlds_goal.m:
Add new field c_is_recursive to pragma c_code goals.
prog_io.m:
Parse the new `recursive' and `non_recursive' pragma c_code
declarations.
make_hlds.m:
Pass the c_is_recursive field from the parse tree to the HLDS.
live_vars.m:
For non-recursive C code, don't save variables on the stack.
code_gen.pp:
For non-recursive C code, don't save variables on the stack,
don't mark the succip as needing to be saved, and don't
call save_registers() and restore_registers().
*.m:
Change c_code/5 to c_code/6.
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: 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: 1.5
Split llds into two parts. llds.m defines the data types, while llds_out.m
has the predicates for printing the code.
Removed the call_closure instruction. Instead, we use calls to the
system-defined addresses do_call_{det,semidet,nondet}_closure. This is
how call_closure was implemented already. The advantage of the new
implementation is that it allows jump optimization of what used to be
call_closures, without new code in jumpopt.
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: 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: 2
code_exprn:
When we are processing the flushing of create expressions, make sure
the Lval we are creating into isn't a field reference. This avoids
deep field of field of field of ... nesting. It does introduce
references to high register numbers, but this is a lesser evil,
and Tom and I plan to fix this anyway.
arg_info, globals, options:
Change --args old to --args simple.
options:
Make some help messages more specific.
code_aux, code_exprn, code_info, det_report, make_hlds, mercury_to_goedel,
prog_io, typecheck:
Changes to accommodate the move from varset__lookup_name
to varset__search_name.
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: 5
There was a problem where variables that die during forward
execution, and then become live again on backtracking were
not being handled correctly. There was some half-working code
to deal with the problem. It has now been fixed, and there
are some new test cases for the regression tests.
compiler/.cvsignore:
added *.ql since they become very irritating after a while...
compiler/inlining.m:
added a couple of comments
make a bit of the code more concise.
compiler/*.m:
changes to handle nondet-liveness correctly.
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
excess:
A new pass to remove unnecessary assignment unifications.
mercury_compile:
Call the new excess assignment module.
options:
Add a new option, excess_assign, to control the new optimization.
Add another, num-real-regs, to specify how many of r1, r2 etc are
actually real registers. The default is now set to 5 for kryten;
later it should be supplied by the mc script, with a value determined
at configuration time.
tag_switch:
Use num-real-regs to figure out whether it is likely to be worthwhile
to eliminate the common subexpression of taking the primary tag of
a variable. Also fix an old performance bug: the test for when a
jump table is worthwhile was reversed.
value_number, vn_block:
Do value numbering on extended basic blocks, not basic blocks.
vn_debug:
Modify an information message.
labelopt:
Clean up an export an internal predicate for value numbering. Replace
bintree_set with set.
middle_rec:
Prepare for the generalization of middle recursion optimization
to include predicates with an if-then-else structure.
cse_detection:
Fix a bug: when hoisting a common desconstruction X = f(Yi), create
new variables for the Yi. This avoids problems with any of the Yis
appearing in other branches of the code.
goal_util:
Add a new predicate for use by cse_detection.
common:
Fix a bug: recompute instmap deltas, since they may be affected by the
optimization of common structures.
code_info:
Make an error message more explicit.
det_analysis:
Restrict import list to the needed modules.
*.m:
Import assoc_list.
:- pragma(inline, predicate/arity).
This declaration means that the corresponding predicate will be inlined.
hlds.m: Add a field to the pred_info indicating whether or not to
inline the pred automatically.
make_hlds.m: Turn on the inline flag in the pred_info if there was a
pragma(inline, ...) declaration.
prog_io.m: Parse the new declaration.
mercury_to_mercury.m:
Spit out the new dec.
inlining.m: Inline the predicate if the inlining field is set in the
pred_info.
polymorphism.m:
code_aux.m: Add an extra paramater to calls to pred_info_init.
llds:
Optionally generate while (1) loops instead of short backward branches.
This is faster in the absence of fast jumps.
options:
Add a new option, --no-emit-c-loops.
middle_rec:
We now check if the LLDS code after the recursive call is empty.
If yes, we don't generate the downward loop.
code_aux:
Minor cleanup associated with previous change.
frameopt:
Instead of blindly assuming that any code before an if_val will be
able to fill the delay slot, we check whether it computes a value
that is used in the condition. We now also allow a slightly wider
range of user instructions to fill delay slots.
opt_util:
Some new preds to support the new funcionality in frameopt.
tag_switch:
Compute the tag of the switched-on value into a register at the
start, instead of computing it in each if_val.
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.
-------------------------------------------------------
Implement unique modes. We do not handle local aliasing yet, so this
is still not very useful, except for io__state. Destructive update is
not yet implemented. Also note that this really only implements
"mostly unique" variables that may be non-unique on backtracking - we
don't check that you don't backtrack over I/O, for example.
prog_io.m, mode_util.m, modes.m, inst_match.m:
Major changes to Handle unique modes.
mercury_to_mercury.m, polymorphism.m, prog_out.m, undef_modes.m:
Use `ground(Uniqueness)' rather than just `ground'.
compiler/*.m:
Fix compile errors now that unique modes are enforced: add a
few calls to copy/2, and comment out lots of unique mode
declarations that caused problems.
typecheck.m, mode_info.m:
Hack around the use of unique modes, which doesn't work
because we don't allow local aliasing yet: make the insts
`uniq_type_info' and `uniq_mode_info' not unique at all,
and add a call to copy/2 when extracting the io_state from
type_info or mode_info.
-------------------------------------------------------
Plus a couple of unrelated changes:
hlds.m:
Change the modes for the special predicates from `ground -> ground'
to `in', so that any error messages that show those modes
come out looking nicer.
Add a new shared_inst_table for shared versions of user-defined
insts.
mercury_to_goedel.m:
Use string__is_alnum_or_underscore.
mercury_compile.pp llds.m:
fix occurences of A.B (use [A|B]) which were
causing problems trying to build a sicstus
compiler.
[the rest].m:
Fix the compiler so that calculator.m works.
This involved introducing an extra field into
the goal_info to keep track of variables that
become nondet-live.
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.
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/*:
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!!!)
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.
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.
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.
inlining.nl:
make the heuristic for inlining stricter.
mercury_compile.*:
add an extra garbage collection.
code_aux.*:
add "goal_is_flat" test predicate.
middle_rec:
code to do middle recursion optimization.
code_aux:
new auxiliary module that unlike code_util, does import code_info.
Previous change to peephole and opt_util was implementation of chain rules.