compiler/equiv_type.m:
Don't export a predicate that does not need to be exported.
compiler/hlds_data.m:
compiler/polymorphism.m:
mdbcomp/goal_path.m:
Put knowledge of the goal_id to hand head constraints in only one place:
mdbcomp/goal_path.m.
compiler/goal_path.m:
Allocate goal_ids using counters.
compiler/foreign.m:
Delete an unused predicate.
compiler/ite_gen.m:
Factor out some common code.
compiler/equiv_type_hlds.m:
compiler/error_util.m:
compiler/exception_analysis.m:
compiler/global_data.m:
compiler/globals.m:
compiler/goal_expr_to_goal.m:
compiler/goal_form.m:
compiler/granularity.m:
compiler/hlds_args.m:
compiler/hlds_out_util.m:
compiler/interval.m:
compiler/java_names.m:
compiler/jumpopt.m:
compiler/labelopt.m:
compiler/lambda.m:
compiler/lco.m:
compiler/live_vars.m:
compiler/livemap.m:
compiler/modecheck_conj.m:
compiler/type_constraints.m:
Minor style cleanups.
compiler/*.m:
Module qualify the end_module declarations. In some cases, add them.
compiler/table_gen.m:
Remove an unused predicate, and inline another in the only place
where it is used.
compiler/add_pragma.m:
Give some predicates more meaningful names.
Estimated hours taken: 8
Branches: main
A bunch of individually small changes to speed up the compiler when compiling
training_cars_full.m. Altogether, the changes speed up the compiler on that
task by a bit more than 11% when the target grade is asm_fast.gc, and by a bit
more than 7% when the target grade is hlc.gc. (Several of the changes affect
the code that optimizes the LLDS; we don't have corresponding optimizers
for the MLDS.)
compiler/c_util.m:
Specialize the code that prints out quoted strings for the target
language. We don't want to check the target language during
the conversion of EVERY SINGLE CHARACTER.
compiler/dead_proc_elim.m:
When we analyze the module for inlining, we are only after the
use counts of procedures. We do not need to traverse ground structures
to get those counts.
compiler/dupelim.m:
Do the search and insertion in the standardized code sequence map
in one pass.
compiler/global_data.m:
compiler/ml_global_data.m:
Do the search and insertion in the scalar data map in one pass.
library/bimap.m:
Add a search_insert predicate to make possible the changes in
{ml_,}global_data.m.
NEWS:
Mention the new predicate in bimap.m.
compiler/inst_match.m:
Do searches and insertions in sets of expansions in one pass.
Highlight discrepancies between comments on the declarations
of two predicates and comments on their code.
compiler/llds_out_global.m:
compiler/post_typecheck.m:
Reorder the bodies of some test conditions to put the cheaper and
more-frequently-failing tests first.
compiler/labelopt.m:
compiler/opt_util.m:
Do not require opt_util to return a list of code addresses that
labelopt then throws away; allow opt_util.m not to gather those
addresses in the first place (if the unused_args optimization
is applied to it, which it is by default.)
In opt_util.m, make an unnecessarily-exported predicate private.
compiler/prog_data.m:
Use predicates in varset.m that do directly what we want, instead
of using a different predicate and then post-processing its output.
(The code was originally written before the directly useful predicate
in varset.m was available.)
compiler/type_util.m:
Specialize the frequently occurring case of no typeclass constraints
at all.
compiler/typecheck_info.m:
Give the field names of some types identifying prefixes.
Make a function symbol's name more meaningful.
compiler/typecheck.m:
compiler/typecheck_errors.m:
Conform to the changes in typecheck_info.m.
Estimated hours taken: 0.5
Branches: main
compiler/frameopt.m:
compiler/jumpopt.m:
compiler/labelopt.m:
compiler/optimize.m:
Speed up the compiler by 0.8% when generating low level C code
by using 234 trees instead of lists to store sets of labels.
Estimated hours taken: 6
Branches: main
compiler/*.m:
Convert almost all remaining modules in the compiler to use
"$module, $pred" instead of "this_file" in error messages.
In a few cases, the old error message was misleading, since it
contained an incorrect, out-of-date or cut-and-pasted predicate name.
tests/invalid/unresolved_overloading.err_exp:
Update an expected output containing an updated error message.
Branches: main
Change the argument ordering of predicates in the set module.
library/set.m:
Change predicate argument orders to match the versions
in the svset module.
Group function definitions with the corresponding predicates
rather than at the end of the file.
Delete Ralph's comments regarding the argument order in the
module interface: readers of the library reference guide are
unlikely to be interested in his opinion of the argument ordering
ten or so years ago.
Add extra modes for set.map/3 and set.map_fold/5.
library/svset.m:
library/eqvclass.m:
library/tree234.m:
library/varset.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
mdbcomp/trace_counts.m:
extras/moose/grammar.m:
extras/moose/lalr.m:
extras/moose/moose.m:
tests/hard_coded/bitset_tester.m:
Conform to the above change.
NEWS:
Announce the above changes.
Estimated hours taken: 2
Branches: main, release
Make the system compiler with --warn-unused-imports.
browser/*.m:
library/*.m:
compiler/*.m:
Remove unnecesary imports as flagged by --warn-unused-imports.
In some files, do some minor cleanup along the way.
Estimated hours taken: 10
Branches: main
This diff changes a few types from being defined as equivalent to a pair
to being discriminated union types with their own function symbol. This
was motivated by an error message (one of many, but the one that broke
the camel's back) about "-" being used in an ambiguous manner. It will
reduce the number of such messages in the future, and will make compiler
data structures easier to inspect in the debugger.
The most important type changed by far is hlds_goal, whose function symbol
is now "hlds_goal". Second and third in importance are llds.instruction
(function symbol "llds_instr") and prog_item.m's item_and_context (function
symbol "item_and_context"). There are some others as well.
In several places, I rearranged predicates to factor the deconstruction of
goals into hlds_goal_expr and hlds_goal_into out of each clause into a single
point. In many places, I changed variable names that used "Goal" to refer
to just hlds_goal_exprs to use "GoalExpr" instead. I also changed variable
names that used "Item" to refer to item_and_contexts to use "ItemAndContext"
instead. This should make reading such code less confusing.
I renamed some function symbols and predicates to avoid ambiguities.
I only made one algorithmic change (at least intentionally).
In assertion.m, comparing two goals for equality now ignores goal_infos
for all kinds of goals, whereas previously it ignored them for most kinds
of goals, but for shorthand goals it was insisting on them being equal.
This seemed to me to be a bug. Pete, can you confirm this?
Estimated hours taken: 4
Branches: main
Add fields to structures representing the C code itself that says whether
or not the C code affects the liveness of lvals. This is intended as the basis
for future improvements in the optimization of such code.
Implement a new foreign_proc attribute that allows programmers to set
the value of this field.
Eliminate names referring to `pragma c_code' in the LLDS backend in favor
of names referring to foreign_procs.
compiler/llds.m:
Make the changes described above.
Consistently put the field containing C code last in the function
symbols that contain them.
compiler/prog_data.m:
Make the changes described above.
Rename some other function symbols to avoid ambiguity.
compiler/prog_io_pragma.m:
Parse the new foreign_proc attribute.
doc/reference_manual.texi:
Document the new attribute.
compiler/pragma_c_gen.m:
Rename the main predicates.
compiler/opt_util.m:
Change some predicates into functions, for more convenient invocation.
compiler/livemap.m:
Rename the predicates in this module to avoid ambiguity and the need
for module qualification.
compiler/*.m:
Conform to the changes above.
Estimated hours taken: 6
Branches: main
browser/*.m:
compiler/*.m:
Rename a bunch of predicates and function symbols to eliminate
ambiguities.
The only real change is factoring out some common code in the mlds
and llds code generators, replacing them with single definitions
in switch_util.m.
Estimated hours taken: 8
Branches: main
Get rid of a bunch more ambiguities by renaming predicates, mostly
in polymorphism.m, {abstract,build,ordering}_mode_constraints.m, prog_type.m,
and opt_debug.m in the compiler directory and term_io.m, term.m, parser.m,
and string.m in the library.
In some cases, when the library and the compiler defined the same predicate
with the same code, delete the compiler's copy and give it access to the
library's definition by exporting the relevant predicate (in the undocumented
part of the library module's interface).
NEWS:
Mention that the names of some library functions have changed.
library/*.m:
compiler/*.m:
mdbcomp/*.m:
browser/*.m:
Make the changes mentioned above, and conform to them.
test/general/string_test.m:
test/hard_coded/string_strip.m:
test/hard_coded/string_strip.exp:
Conform to the above changes.
Estimated hours taken: 6
Branches: main
This diff contains no algorithmic changes. It merely renames apart a bunch more
function symbols to reduce ambiguity.
After this diff, the summary line from the mdb command "ambiguity -f" is
Total: 351 names used 975 times, maximum 31, average: 2.78
browser/*.m:
compiler/*.m:
Rename function symbols to eliminate ambiguities.
tests/debugger/declarative/dependency.exp:
tests/debugger/declarative/dependency2.exp:
Update the expected out where some internal function symbol names
appear in the output of the debugger. (This output is meant for
implementors only.)
Estimated hours taken: 18
Branches: main
Move the univ, maybe, pair and unit types from std_util into their own
modules. std_util still contains the general purpose higher-order programming
constructs.
library/std_util.m:
Move univ, maybe, pair and unit (plus any other related types
and procedures) into their own modules.
library/maybe.m:
New module. This contains the maybe and maybe_error types and
the associated procedures.
library/pair.m:
New module. This contains the pair type and associated procedures.
library/unit.m:
New module. This contains the types unit/0 and unit/1.
library/univ.m:
New module. This contains the univ type and associated procedures.
library/library.m:
Add the new modules.
library/private_builtin.m:
Update the declaration of the type_ctor_info struct for univ.
runtime/mercury.h:
Update the declaration for the type_ctor_info struct for univ.
runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
Update the definition of MR_Univ.
runtime/mercury_init.h:
Fix a comment: ML_type_name is now exported from type_desc.m.
compiler/mlds_to_il.m:
Update the the name of the module that defines univs (which are
handled specially by the il code generator.)
library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
Conform to the above changes. Import the new modules where they
are needed; don't import std_util where it isn't needed.
Fix formatting in lots of modules. Delete duplicate module
imports.
tests/*:
Update the test suite to confrom to the above changes.
Estimated hours taken: 6
Branches: main
compiler/*.m:
Convert almost all the compiler modules to use . instead of __ as
the module qualifier.
In some cases, change the names of predicates and types to make them
meaningful without the module qualifier. In particular, most of the
types that used to be referred to with an "mlds__" prefix have been
changed to have a "mlds_" prefix instead of changing the prefix to
"mlds.".
There are no algorithmic changes.
Estimated hours taken: 4
Branches: main
Various cleanups for the modules in the compiler directory. The are
no changes to algorithms except the replacement of some if-then-elses
that would naturally be switches with switches and the replacement of
most of the calls to error/1.
compiler/*.m:
Convert calls to error/1 to calls to unexpected/2 or sorry/2 as
appropriate throughout most or the compiler.
Fix inaccurate assertion failure messages, e.g. identifying the
assertion failure as taking place in the wrong module.
Add :- end_module declarations.
Fix formatting problems and bring the positioning of comments
into line with our current coding standards.
Fix some overlong lines.
Convert some more modules to 4-space indentation. Fix some spots
where previous conversions to 4-space indentation have stuffed
the formatting of the code up.
Fix a bunch of typos in comments.
Use state variables in more places; use library predicates
from the sv* modules where appropriate.
Delete unnecessary and duplicate module imports.
Misc. other small cleanups.
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
Estimated hours taken: 1
Branches: main
compiler/jumpopt.m:
compiler/labelopt.m:
Make the main predicates of these optimizations tail recursive in order
to allow them to handle procedures with 50,000 instructions, such as
the one reported by Michael Day.
Estimated hours taken: 0.5
Branches: main
Minor cleanups I did while browsing files related to the bug in jumpopt.
compiler/dupelim.m:
Factor out some common code dealing with pragma_c instructions.
Reorder arguments to allow the use of state variable notation.
Use switches in preference to if-then-elses if possible.
compiler/labelopt.m:
Convert comments to our preferred format.
Use switches in preference to if-then-elses if possible.
compiler/opt_util.m:
Convert comments to our preferred format.
Factor out some common code.
Use switches in preference to if-then-elses if possible.
Use state variable notation where appropriate.
Estimated hours taken: 4
Branches: main
compiler/*.m:
Change a bunch of modules to import only one module per line, even
from the library.
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
Convert these modules to our current coding style. Use state variables
where appropriate. Use predmode declarations where possible.
Estimated hours taken: 6
Branches: main
Perform frame optimization on nondet predicates. The need for this was revealed
by benchmarking in Uppsala, which initially showed Mercury to take three to
five times as long as XSB on some tabling benchmarks. One major contributor
was the fact that the predicate returning answers out of answer table
was creating and destroying a nondet stack frame for every answer it returned.
To make this change easier, make the representation of labels more reader
friendly, classifying them primarily on whether they represent entry or
internal labels, and only secondarily on the scope in which they represent
valid references to the label.
compiler/frameopt.m:
Add a predicate to perform frame optimization on model_non predicates.
This optimization involves separating the steps of creating the frame
(done once) and setting the redoip (potentially done on every
iteration).
compiler/optimize.m:
Invoke this new predicate. Reorder the arguments of predicates in this
file, and the top level predicates of the optimizations it invokes,
to allow the use of state variable notation.
runtime/mercury_stacks.h:
Provide macros for creating nondet stack frames that do not fill in the
redoip slot.
compiler/llds.m:
Make the setting of redoip optional in mkframe operations.
Make the representation of labels more reader friendly.
compiler/layout_out.m:
Change the representation of label layouts to enforce the invariant
that these can refer only to internal labels. (The layout structures
of entry labels are proc layout structures, whose design enforces the
relevant invariant already.)
compiler/jumpopt.m:
Add an optimization that improves code that matches a new pattern:
% Attempt to transform code such as
%
% if (Cond) L1
% goto L2
%
% into
%
% if (! Cond) L2
% <code at L1>
%
% when we know the code at L1 and don't know the code at L2.
The new frame optimization creates instances of this pattern, usually
with L2 being do_fail.
compiler/*.m:
Minor diffs to conform to the changes above.
Estimated hours taken: 2
Branches: main
compiler/*.m:
Import only one compiler module per line. Sort the blocks of imports.
This makes it easier to merge in changes.
In a couple of places, remove unnecessary imports.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.
compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
New files. One module for each of the major components of the
Mercury compiler. These modules contain (as separate sub-modules)
all the other modules in the Mercury compiler, except gcc.m and
mlds_to_gcc.m.
Mmakefile:
compiler/Mmakefile:
Handle the fact that the top-level module is now `top_level',
not `mercury_compile' (since `mercury_compile' is a sub-module
of `top_level').
compiler/Mmakefile:
Update settings of *FLAGS-<modulename> to use the appropriate
nested module names.
compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
Convert the `recompilation_*' modules into sub-modules of the
`recompilation' module.
compiler/*.m:
compiler/*.pp:
Module-qualify the module names in `:- module', `:- import_module',
and `:- use_module' declarations.
compiler/base_type_info.m:
compiler/base_type_layout.m:
Deleted these unused empty modules.
compiler/prog_data.m:
compiler/globals.m:
Move the `foreign_language' type from prog_data to globals.
compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
Import `globals', for `foreign_language'.
Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
Rename the %.check.c targets as %.check_hdr.c,
to avoid conflicts with compiler/recompilation.check.c.
Estimated hours taken: 10
Allow the native collector to work for nondet code, by generating layout
structures for the resumption points whose addresses can be put into
redoip slots in nondet stack frames.
If the program is compiled with both native gc and debugging, entries
to disjunctions will have two labels and two layout structures, one
for gc and one for the debugger. At the moment we make no attempt
to try to combine the two structures, since doing so would add significant
extra complexity. Optimizing this option combination will not be important
for a while yet anyway.
compiler/code_info.m:
Update the code that generates resume points to also optionally
generate layout structures for the stack labels.
compiler/disj_gen.m:
When we save the heap pointer, update not only the current code_info
but the saved code_info that represents the branch start position
as well, since the slot containing the saved heap pointer will be
live in each of the following disjuncts.
compiler/labelopt.m:
compiler/mercury_compile.m:
compiler/optimize.m:
compiler/value_number.m:
Arrange to pass the global_data structure to the label elimination
and value numbering passes. This is to (a) prevent the label
elimination pass from removing labels (e.g. stack resume labels)
that have layout structures, and (b) to prevent value numbering
for moving computations across such labels, since that would
invalidate the layout structure.
(The presence of pragma_c_code fragments in the generated code avoids
both these potential problems for layout structures that correspond
to trace events, but that solution would be suboptimal for resume
labels.)
compiler/hlds_module.m:
Add a utility predicate needed by optimize.m.
Estimated hours taken: 0.75
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).
Estimated hours taken: 20
Give duplicate code elimination more teeth in dealing with similar arguments
of different function symbols. For the source code
:- type t1 ---> f(int)
; g(int, int).
:- pred p1(t1::in, int::out) is det.
p1(f(Y), Y).
p1(g(Y, _), Y).
we now generate the C code
Define_entry(mercury__xdup__p1_2_0);
r1 = const_mask_field(r1, (Integer) 0);
proceed();
thus avoiding the cost of testing the function symbol.
runtime/mercury_tags.h:
Add two new macros, mask_field and const_mask_field, that behave
just like field and const_field except that instead of stripping
off a known tag from the pointer, they strip (mask) off an unknown
tag.
compiler/llds.m:
Change the first argument of the lval field/3 from tag to maybe(tag).
Make the comments on some types more readable.
compiler/llds_out.m:
If the first arg of the lval field/3 is no, emit a (const_)mask_field
macro; otherwise, emit a (const_)field macro.
compiler/basic_block.m:
New module to convert sequences of instructions to sequences of
basic blocks and vice versa. Used in the new dupelim.m.
compiler/dupelim.m:
Complete rewrite to give duplicate code elimination more teeth.
Whereas previously we eliminated blocks of code only if they exactly
duplicated other blocks of code, we now look for blocks that can be
"anti-unified". For example, the blocks
r1 = field(mktag(0), r2, 0)
goto L1
and
r1 = field(mktag(1), r2, 0)
<fall through to L1>
anti-unify, with the most specific common generalization being
r1 = mask_field(r2, 0)
goto L1
If several basic blocks antiunify, we replace one copy with the
antiunified block and try to eliminate the others. We do not
eliminate blocks that can be fallen into, since eliminating them
would require introducing a goto, which would slow the code down.
compiler/peephole,m:
If a conditional branch to a label is followed by that label or
by an unconditional branch to that label, eliminate the branch.
Dupelim produces this kind of code.
compiler/{code_exprn,exprn_aux,lookup_switch,opt_debug,unify_gen}.m:
Minor changes required by the change to field/3.
compiler/{frameopt,jumpopt,labelopt,mercury_compile,optimize,value_number}.m:
s/__main/_main/ in predicate names.
compiler/jumpopt.m:
Add some documentation.
compiler/unify_gen.m:
Fix a module qualified predicate name reference that would not
work in Prolog.
compiler/notes/compiler_design.html:
Document the new file basic_block.m.
Estimated hours taken: 2
value_number:
Add two safety checks whose absence was bug. One of these replaces
an earlier, inadequate safety check in vn_block.
vn_block:
Remove that inadequate safety check, since now a more comprehensive
one is applied in value_number.
opt_util:
Opt_util__instr_labels now returns even those labels inside
code_addrs. This was needed for value_number.
labelopt:
Simplify the code based on the new capability of
opt_util__instr_labels.
dense_switch:
Break a too long line.
Estimated hours taken: 0.5
compiler/labelopt.m
In the two places that a set of labels was being constructed
by iterating over a list and doing set__inserts, construct a
list of labels and use set__insert_list since this changes
the complexity of the algorithm from O(N^2) to O(NlgN).
compiler/code_gen.pp:
Add a comment about shuffling r1 when generating code for
semidet pragmas.
Estimated hours taken: 20
vn_block:
Fix a typo which reflected a fundamental design error. When finding
cheaper copies of live lvals, for use in creating specialized copies
(parallels) of blocks jumped to from the current location, we used
to use the map reflecting the contents of lvals at the start of the
block, not at the point of the jump.
--pred-value-number, which uses the information computed by the
buggy predicate, actually bootstrapped some time ago despite
this fundamental bug!
value_number:
Fix a bug in the creation of parallel code sequences for computed
gotos. Add some more opprtunities for printing diagnostics.
Move code concerning final verification to vn_verify.
vn_verify:
Move the remaining code concerned with final verification from
value_number to vn_verify.
peephole:
Add a new pattern, which transforms the sequence
incr_sp N; goto L2; L1; incr_sp N; L2
into just
L1; incr_sp N; L2
The pattern is of course more broadly applicable, but I have seen
it only when it involves a single incr_sp between the two labels.
(The longer pattern can be introduced by frameopt.)
opt_util:
Look inside blocks when checking whether an instruction can fall
through. This improves the performance of labelopt.
vn_table:
Make the type vn_table abstract; add, export and use access functions.
vn_util:
Remove a noop predicate, since now it won't ever be made to do
anything.
vn_cost:
Refine debugging output.
vn_debug:
Add some more debugging routines.
opt_debug:
Add some more debugging routines.
det_analysis:
Remove an unused argument.
labelopt:
Formatting change.
Estimated hours taken: 6
arg_info:
Add support for the compact argument passing convention. The proper
handling of higher order calls etc is still missing.
globals:
Added a third global type, args_method, current either "old" or
"compact".
passes_aux:
Moved some auxiliary predicates from mercury_compile and options
to passes_aux.
constraint, det_analysis, make_hlds, modules, optimize, undef_types:
Import and refer to passes_aux.
mercury_compile, handle_options:
Remove the predicates moved to passes_aux. Also move the option
postprocessing code to a new module, handle_options.
Another change is that we stop after syntax errors if the new option
--halt-at-syntax-errors is set.
handle_option:
New module for option postprocessing.
options:
Remove the option lookup predicates, which were obsolete.
Add new options --args, --halt-at-syntax-errors and --opt-level.
Add a special handler for --opt-level.
lookup_switch:
Call getopt to look up options, not options.
value_number, vn_block:
Extended basic blocks with more than one incr_hp pose a problem for
value numbering when using boehm_gc, because value numbering coalesces
all the allocations into one. Previously we did not optimize such
sequences. I modified value numbering to divide up such blocks into
smaller blocks, each with at most one incr_hp, and optimize these.
At the moment, some of these blocks contain deeply nested field
refs, which value numbering is very slow to handle; code_exprn
should be modified to fix these.
value_number:
Rename usemap to useset, since this is more accurate.
Fixed a bug in --pred-value-number, which manifested itself as
the generation of duplicate labels.
labelopt:
Rename usemap to useset, since this is more accurate.
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.
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.
frameopt:
Make the teardown map bidirectional, and export it.
peephole:
Add a new pattern to handle cases generated by fulljump optimization.
This pattern uses the teardownmap, but it is disabled for the moment.
optimize:
Pass the teardown map where it is needed, and make sure we do a
peephole pass immediately after frameopt to use the teardownmap
while it is still valid.
jumpopt:
Rename a variable.
labelopt:
A block being eliminated may have the last remaining reference
to the label starting another block. Therefore on the last invocation
of labelopt, we iterate to a fixpoint before returning.
opt_debug:
Add a predicate to help debug bidirectional teardown maps.
opt_util:
Liberalized some optimizations, but the changes are disabled for the
moment.
value_number:
Pass an empty teardown map to peephole. Loosen the sanity check on
tags a bit.
vn_order:
If the new value of a location depends on its old value,
avoid creating a circularity in the preferred order relation.
Such circularity may be broken arbitrarily, even though we have
a clear preference.
vn_flush:
Modify the criteria for saving the old value stored in a location
about to be overwritten, in an effort to eliminate useless copies
of old values.
vn_util:
Tighten the requirement for classifying a use as a "real" use,
also in the effort to eliminate useless saves of old values.
Recognize some more expression patterns as yieldsing known
results. Move some functionality from vn_flush to vn_util,
since it is needed by the other modification.
-------------------------------------------------------
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.
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!!!)
value_number, vn_util, opt_util, opt_debug:
Fixed a bug with allowed incr_hp to overwrite its target without saving
it. Reorganized the handling of incr_sp and decr_sp to make sure they
never get reordered with respect to control flow instructions.
llds:
Fixed the output of temp declarations for blocks.
frameopt:
Generalized the set up patterns accepted as starting a det procedure.
labelopt:
Added a source-level option to remove eliminated instructions instead
of turning them into comments, and made it the default.
optimize:
After value numbering, perform jump optimization as well as peepholing
and label optimization.
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.
- optimize.nl is the main loop of the optimizer. It calls functions in
jumpopt, peephole, labelopt, frameopt and value_number.
- jumpopt.nl does short-circuiting of jumps to jumps and finds tailcalls.
- peephole.nl now just does the local pattern-match optimizations.
- labelopt.nl eliminates dead labels and dead code.
Renamed the options related to optimization.
*** IMPORTANT: the --optimize flag now enables optimize.nl, not C optimization.
C optimization is signalled via the -c-optimize flag. Both flags are on by
default.