Estimated hours taken: 6
Another step towards implementing notes/ALLOCATION.
hlds_goal:
Define a new type that gives the information associated with
resumption points. Add a field of this type to goal_info, and the
associated operations.
Change the layout of the access predicates to make the code_info
structure easier to modify in the future.
liveness:
Fill in the resume_point fields of goals that establish
resumption points.
hlds_out:
Print the new resume_point field of goal_info.
Allow the printing of base_type_infos on the right hand sides
of unifications.
code_info:
Reuse the stack of store maps field, which we don't use anymore,
to store the stack of resumption-point variable sets. Add operations
on this new stack.
Remove the slot that holds the code model of the current procedure,
since it is used rarely and can be easily looked up in the proc_info,
which we also store. Reuse the slot to store the maximum number of
stack pushes, eliminating the pair used to store it previously.
Change the layout of the access predicates to make the code_info
structure easier to modify in the future.
code_gen:
Don't pass the code model to code_info__init.
code_exprn:
Make an abort message more specific.
hlds_pred:
Fix typos.
Estimated hours taken: 2.5
Switch from using a stack of store_maps in the code_info to govern what
goes where at the end of each branched structure to using the store map
fields of the goal expressions of those structures.
Fix variable names where they resembled the wrong kind of map(var, lval).
code_info:
Remove the operations on stacks of store maps.
Modify the generate_forced_saves and remake_with_store_map operations
to take a store_map parameter.
When making variables magically live, pick random unused variables
to hold them, since we can no longer use the guidance of the top
store map stack entry. This may lead to the generation of some
excess move instructions at non-reachable points in the code;
this will be fixed later.
code_gen:
Remove the store map push and pop invocations.
Modify the generate_forced_goal operation to take a store_map parameter.
code_exprn:
Export a predicate for use by code_info.
middle_rec, disj_gen, ite_gen, switch_gen,
dense_switch, lookup_switch, string_switch, tag_switch:
Pass the store map around to get it to invocations of the primitives
in code_gen and code_info that now need it.
goal_util:
Name apart the new follow_vars field in hlds__goal_infos.
(This should have been in the change that introduced that field.)
common, constraint, cse_detection, det_analysis, dnf, excess, follow_code,
intermod, lambda, lco, liveness, make_hlds, mode_util, modes, polymorphism,
quantification, simplify, switch_detection, typecheck, unique_modes,
unused_args:
Fix variable names.
follow_vars, store_alloc:
Add comments.
Estimated hours taken: 3
hlds_goal:
Documented the distinction between the three kinds of uses we have
for map(var, lval): stack_slots, store_map and follow_vars.
Added a new field, follow_vars, to hlds__goal_info.
follow_vars:
Attach the follow_vars information to the kinds of goals listed
in notes/ALLOCATION.
hlds_out:
Print out the follow_vars field. Make some other outputs easier to
read.
hlds_pred:
Remove the follow_vars field of the proc_info, since the follow_vars
of the goal_info of the goal of the procedure has taken its place.
code_gen:
Use the follow_vars field from the main goal's goal_info, rather
than the follow_vars field of the proc_info.
store_alloc:
Attach the last follow_vars not to the proc_info but to the main goal.
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: 8
livemap:
Fix a long-standing bug that caused all fixpoint iterations to stop
too early. By causing value_numbering to miscompile the predicate
mercury_compile__maybe_unused_args, this bug caused the unwanted
printing of statistics for tests/warnings/unused_args_test.
Fix also another bug: we did not process the control rval in
computed gotos. To my knowledge this has never been tickled.
Redesign the interface of the exported predicate slightly to
make it more robust.
frameopt, value_number:
Use the modified interface of livemap.
switch_detection:
For a while now we have removed arms from switches if we knew from
the instantiation of the control variable that those arms could not be
executed. Sometimes this results in switches with no arms. If the
control variable of the switch is never used after the switch,
liveness won't see the occurrence in the switch construct as a use,
and will kill the variable too early, cause the code generator to
abort.
We now turn switches with no arms into "fail"; this improves the
code generated and avoids the bug. However, liveness should still
be changed to consider the occurrence of a variable in the first
arg of a switch a use.
code_gen, vn_block:
Formatting changes.
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: 1
Since NU-Prolog hasn't been capable of executing the compiler for a long time
now, I have removed the .pp files and replaced them with .m files.
code_gen, mercury_compile, optimize:
Remove NU-Prolog specific code.
Mmake:
Don't refer to the .pp files.
dnf:
Add the capability of transforming all procedures regardless of
markers. This will be useful when generating idiomatic Prolog code.
mercury_to_goedel, polymorphism:
Fix comments.