mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-29 00:04:55 +00:00
09141817ba2757504e347210abcff00aa9da9f79
54 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
98c2fbf51b |
Bug fixes.
Estimated hours taken: 12
Bug fixes.
tests/term/arit_exp.m still fails with --intermodule-optimization
due to a slightly different (but correct) trans_opt file being produced.
compiler/simplify.m
Don't produce singleton disjunctions, since the code generator
barfs on them. Use a `some' instead.
Test case: tests/general/partition.m compiled with --deforestation.
compiler/unused_args.m
Deconstructions where the arguments included `any' insts were
not being handled correctly, due to inst_matches_binding
failing for any->any.
Test case: extras/trailed_update/samples/vqueens.m at -O3.
Don't warn about predicates from `.opt' files having unused
arguments, because in most cases the warning will be generated
when compiling the imported module.
compiler/higher_order.m
Fix a bug that caused compiler/modules.m to be miscompiled at
-O3 --intermodule-optimization, due to curried arguments for
multiple known higher-order arguments being passed to a
specialised version in the wrong order.
Test case: tests/hard_coded/ho_order2.m
compiler/mercury_compile.m
Call intermod__update_pred_import_status when compiling to
C at the same stage of the compilation as the `.opt' file
was written to ensure that the same information is being used.
Test case: tests/hard_coded/rational_test.m compiled with
--intermodule-optimization failed because of a link error.
Make sure polymorphism has been run before doing unused argument
checking with --errorcheck-only. Otherwise the argument indices
read in from `.opt' files are incorrect.
compiler/intermod.m
Use code_util__compiler_generated to test if a called predicate
is compiler generated, rather than looking for a call_unify_context
(function calls have a call_unify_context).
Add a progress message for updating the import status of predicates
exported to `.opt' files.
Fix a bug where the unused_args pragmas read in from the current
module's `.opt' file were given an import_status of `imported' rather
than `opt_imported' resulting in an error message from make_hlds.m.
compiler/dead_proc_elim.m
Ensure that predicates used by instance declarations and
`:- pragma export's are not eliminated by the dead_pred_elim
pass before typechecking.
Test case: most of the typeclass tests compiled with
--intermodule-optimization.
compiler/hlds_goal.m
Remove obsolete comments about the modes of a higher-order
unification being incorrect after polymorphism, since that
was fixed months ago.
compiler/options.m
Reenable deforestation.
Enable --intermodule-optimization and --intermod-unused-args
at -O5 so they get tested occasionally.
compiler/handle_options.m
Disable deforestation if --typeinfo-liveness is set, since
there are bugs in the folding code if extra typeinfos are
added to a new predicate's arguments by hlds_pred__define_new_pred.
Disable higher_order.m if --typeinfo-liveness is set, since
higher_order.m currently does not pass all necessary typeinfos
to specialised versions or update the typeinfo_varmap of
specialised versions.
Test case: tests/valid/agc_ho_pred.m
tests/hard_coded/ho_order2.m
tests/hard_coded/ho_order2.exp
Test case for higher_order.m.
tools/test_mercury
Added --intermod-unused-args to the options for murlibobo.
extras/trailed_update/{samples,tests}/Mmakefile
Add "-I.." to MGNUCFLAGS so gcc can find unsafe.h which
is #included in c_header_code read from unsafe.opt.
|
||
|
|
e880e3ac59 |
Allow modules to be put in source files whose names do not directly match
Estimated hours taken: 12 Allow modules to be put in source files whose names do not directly match their the module names. When looking for the source for a module such as `foo:bar:baz', search for it first in `foo.bar.baz.m', then in `bar.baz.m', and finally in `baz.m'. compiler/prog_io.m: Change prog_io__read_module so that it returns the name of the module read, as determined by the `:- module' declaration. Add predicate `check_module_has_expected_name', for checking that this name matches what was expected. compiler/modules.m: Add read_mod_from_file, for reading a module given the file name, and generated_file_dependencies, for generating the dependencies of a module given the file name. (As opposed to the module name.) Change read_mod and read_mod_ignore_errors so that they search for `.m' files as described above, and return the name of the source file read. Also improve the efficiency of read_dependencies slightly: when reading in `.int' files, there's no need to call split_into_submodules, because we generate a seperate `.int' file for each submodule anyway. compiler/mercury_compile.m: Change the handling of command-line arguments. Arguments ending with `.m' are assumed to be file names, and other arguments are assumed to be module names. For file names, call read_mod_from_file instead of read_mod. compiler/handle_options.m: Change help message to reflect the above change to the semantics of command-line arguments. compiler/intermod.m: compiler/trans_opt.m: Fix a bug: call prog_io__read_opt_file instead of prog_io__read_module. doc/user_guide.texi: Document the above change to the semantics of command-line arguments. Update the "libraries" chapter to reflect our support for nested modules. tests/*/*.m: tests/*/*.exp: Fix a few incorrect module names in `:- module' declarations. |
||
|
|
935fbfe36e |
Add Mmake support for nested sub-modules.
Estimated hours taken: 6 Add Mmake support for nested sub-modules. compiler/mercury_compile.m: compiler/modules.m: compiler/intermod.m: Pass down the source file name to various places. Store the source file name in the module_imports data structure. In various places, use this source file name instead of assuming that the source file name can be obtained from the module name. compiler/modules.m: Change the generated .d and .dep files to use the source file names. Add hard-coded rules in the .d files if the source file name does not match the form expected by the pattern rules in scripts/Mmake.rules. XXX unfortunately the rules don't work right for parallel makes of nested modules scripts/Mmake.rules: Add a comment saying that any changes here might need to be duplicated in compiler/modules.m. tests/hard_coded/Mmakefile: tests/hard_coded/nested.m: tests/hard_coded/nested2.m: tests/hard_coded/nested.exp: tests/hard_coded/nested2.exp: Add a couple of test cases for nested modules (XXX not enabled, due to the above-mentioned problem with parallel makes). doc/reference_manual.texi: Update the "implementation bugs and limitations" section. NEWS: Update the news about nested modules. |
||
|
|
bcf7dbf9f8 |
Add support for tabling.
Estimated hours taken: 250 Add support for tabling. This change allows for model_det, model_semidet and model_non memoing, minimal model and loop detection tabling. compiler/base_type_layout.m: Update comments to reflect new runtime naming standard. compiler/det_analysis.m: Allow tabling to change the result of det analysis. This is necessary in the case of minimal model tabling which can turn a det procedure into a semidet one. compiler/det_report.m: compiler/hlds_data.m: Add code to report error messages for various non compatible tabling methods and determinism. compiler/hlds_out.m: compiler/modules.m: Remove reference to the old memo marker. compiler/hlds_pred.m: Create new type (eval_method) to define which of the available evaluation methods should be used each procedure. Add new field to the proc_info structure. Add several new predicates relating to the new eval_method type. compiler/inlining.m: compiler/intermod.m: Make sure only procedures with normal evaluation are inlined. compiler/make_hlds.m: Add code to process new tabling pragmas. compiler/mercury_compile.m: Call the tabling transformation code. compiler/modes.m: Make sure that all procedures with non normal evaluation have no unique/partially instantiated modes. Produce error messages if they do. Support for partially instantiated modes is currently missing as it represents a large amount of work for a case that is currently not used. compiler/module_qual.m: compile/prog_data.m: compiler/prog_io_pragma.m: Add three new pragma types: `memo' `loop_check' `minimal_model' and code to support them. compiler/simplify.m: Don't report infinite recursion warning if a procedure has minimal model evaluation. compiler/stratify.m: Change the stratification analyser so that it reports cases of definite non-stratification. Rather than reporting warnings for any code that is not definitely stratified. Remove reference to the old memo marker. compiler/switch_detection.m: Fix a small bug where goal were being placed in reverse order. Call list__reverse on the list of goals. compiler/table_gen.m: New module to do the actual tabling transformation. compiler/notes/compiler_design.html: Document addition of new tabling pass to the compiler. doc/reference_manual.texi: Fix mistake in example. library/mercury_builtin.m: Add many new predicates for support of tabling. library/std_util.m: library/store.m: Move the functions : ML_compare_type_info ML_collapse_equivalences ML_create_type_info to the runtime. runtime/mercury_deep_copy.c: runtime/mercury_type_info.h: runtime/mercury_type_info.c: Move the make_type_info function into the mercury_type_info module and make it public. runtime/Mmakefile: runtime/mercury_imp.h: Add references to new files added for tabling support. runtime/mercury_string.h: Change hash macro so it does not cause a name clash with any variable called "hash". runtime/mercury_type_info.c: runtime/mercury_type_info.h: Add three new functions taken from the library : MR_compare_type_info MR_collapse_equivalences MR_create_type_info. runtime/mercury_table_any.c: runtime/mercury_table_any.h: runtime/mercury_table_enum.c: runtime/mercury_table_enum.h: runtime/mercury_table_int_float_string.c: runtime/mercury_table_int_float_string.h: runtime/mercury_table_type_info.c: runtime/mercury_table_type_info.h: runtime/mercury_tabling.h: New modules for the support of tabling. |
||
|
|
75354e38bb |
Deforestation.
Estimated hours taken: 400
Deforestation.
This increases the code size of the compiler by ~80k when compiling
with --intermodule-optimization --deforestation.
The improvement from deforestation is not measurable for mmc -C make_hlds.m.
Compile time for make_hlds.m increased from 50.7 seconds to 52.2 seconds
when running deforestation.
compiler/simplify.m
compiler/common.m
Provide a nicer interface for simplifying a goal,
not an entire procedure.
Rework the interface to avoid manipulating lots of booleans.
Return an estimate of the improvement in cost from simplification.
Remove failing cases and disjuncts.
Add an option to optimize common structures even across calls.
Remove code to merge branched goals, since that is now
done by deforestation.
Fix a bug: the code to collect instmap_deltas for cases was not
including the switched-on variable in the instmap_delta,
which caused an abort in merge_instmap_delta if the switched
on variable was further instantiated in the switch.
This came up while compiling the compiler with --deforestation.
compiler/det_report.
Output duplicate call warnings even if --warn-simple-code is not set.
XXX fix the same problem with `:- pragma obsolete'.
compiler/code_aux.m
Update code_aux__cannot_loop to use termination information.
compiler/hlds_pred.m
compiler/dnf.m
Pass the type_info_varmap and typeclass_info_varmap
into hlds_pred__define_new_pred.
Restrict the variables of the new procedure onto the variables
of the goal.
Make sure all relevant type_infos are passed into the new
procedure if --typeinfo-liveness is set.
compiler/modes.m
compiler/unique_modes.m
compiler/mode_info.m
compiler/modecheck_unify.m
Put `how_to_check_goal' into the mode_info, rather
than passing it around.
Add a field to the `check_unique_modes' case which
controls whether unique modes is allowed to choose
a different procedure. For deforestation, this is
not allowed, since it could result in choosing a less
efficient procedure after generalisation.
compiler/options.m
New options:
--deforestation
--deforestation-depth-limit
Safety net for termination of the algorithm.
--deforestation-cost-factor
Fudge factor for working out whether deforestation
was worthwhile.
--deforestation-vars-threshold
Like --inline-vars-threshold.
Enable deforestation at -O3.
Removed an unnecessary mode for option_defaults_2, since it
resulted in a warning about disjuncts which cannot succeed.
compiler/handle_options.m
--no-reorder-conj implies --no-deforestation.
compiler/inlining.m
Separate code to rename goals into inlining__do_inline_call.
compiler/hlds_goal.m
Added predicates goal_list_nonlocals, goal_list_instmap_delta
and goal_list_determinism to approximate information about
conjunctions.
compiler/hlds_module.m
Added module_info_set_pred_proc_info to put an updated
pred_info and proc_info back into the module_info.
compiler/hlds_out.m
Exported hlds_out__write_instmap for debugging of deforestation.
Bracket module names on constructors where necessary.
compiler/mercury_compile.m
Call deforestation.
Use the new interface to simplify.m.
compiler/intermod.m
Put recursive predicates with a top-level branched goal
into `.opt' files.
goal_util.m
Added goal_calls_pred_id to work out if a predicate is
recursive before mode analysis.
Export goal_util__goals_goal_vars for use by deforestation.
Give a better message for a missing variable in a substitution.
compiler/instmap.m
Give a better message for inst_merge failing.
compiler/notes/compiler_design.m
Document the new modules.
library/varset.m
Add varset__select to project a varset's names and values
onto a set of variables.
doc/user_guide.texi
Document deforestation.
Remove a reference to a non-existent option, --no-specialize.
util/mdemangle.c
profiler/demangle.m
tests/misc_tests/mdemangle_test.{exp,inp}
Handle the `DeforestationIn__' predicate names introduced by
deforestation, similar to the `IntroducedFrom__' for lambda goals.
New files:
deforest.m Deforestation.
pd_cost.m Cost estimation.
pd_debug.m Debugging output.
pd_info.m State type and version control.
pd_term.m Termination checking.
pd_util.m Utility predicates
|
||
|
|
f4caf49a15 |
Fix a limitation of the current nested module support:
Estimated hours taken: 4 Fix a limitation of the current nested module support: ensure that we check for attempts to import inaccessible modules. compiler/modules.m: Check for attempts to import inaccessible modules (modules whose parent has not been imported, or for which there is no `include_module' declaration in the parent's interface). compiler/intermod.m: Modify the way we import `.opt' files. The previous method temporarily set the items field of the module_imports structure to [], but check_module_accessibility relies on the assumption that the items field contains the items for all modules previously read in. tests/invalid/Mmakefile: tests/invalid/test_nested.m: tests/invalid/test_nested.err_exp: tests/invalid/parent.m: tests/invalid/parent.private_child.m: tests/invalid/parent.public_child.m: tests/invalid/parent.undeclared_child.m: tests/invalid/parent.undeclared_child.err_exp: tests/invalid/parent2.m: tests/invalid/parent2.child.m: Add some tests for the above change. doc/reference_manual.texi: Update the "bugs and limitations" sub-section of the modules chapter to reflect the new status quo. |
||
|
|
f884cee0c4 |
Finish off the centralization of the file name handling code, and
Estimated hours taken: 11 Finish off the centralization of the file name handling code, and add support for generating intermediate files in subdirectories. scripts/mmake.in: Add a new boolean option `--use-subdirs'; if enabled, it just sets the environment variable MMAKE_USE_SUBDIRS to `yes' before invoking Make. Also add negative versions of the various options (`--no-use-subdirs', `--no-verbose', `--no-save-makefile'). scripts/Mmake.rules: Add code to handle generating intermediate file names in subdirectories. If MMAKE_USE_SUBDIRS=yes, we add `--use-subdirs' to MCFLAGS, and most of the pattern rules are changed to use subdirectories. Note that getting this to work required a bit of a hack: due to what seem to be bugs in GNU Make, `mmake depend' needs to do `mmc --make-short-interface *.m' to get things started. But once the int3s are there, the dependencies seem to work OK. compiler/options.m: Add a new boolean option `--use-subdirs'. compiler/modules.m: Add new predicate `fact_table_file_name'. Add an extra argument to `module_name_to_file_name', specifying whether or not to create any directories needed for the file name. Change all the file-name-creating predicates here to go through a single new predicate `choose_file_name', and add code in that predicate to handle the `--use-subdirs' option. Also if the `--use-subdirs' option is set, don't use the compact dependencies format, since it can't work in that case. compiler/fact_table.m: Call `fact_table_file_name' rather than using `string__append'. compiler/mercury_compile.m: Change `link_module_list' and `join_module_list' so that they create file names by calling `module_name_to_file_name'. compiler/export.m: compiler/intermod.m: compiler/llds_out.m: compiler/mercury_compile.m: compiler/module_qual.m: compiler/modules.m: compiler/termination.m: compiler/trans_opt.m: compiler/unused_args.m: Change all calls to `module_name_to_file_name' to pass the extra argument specifying whether or not to make any directories needed for the file name. library/Mmakefile: Change the rule for `mmake install_ints' so that it creates a `Mercury' subdirectory with symbolic links `ints', `int2s', `int3s', `opts', and `trans_opts' which just point to `..'. This is needed for the `--use-subdirs' option to work, because Mmake currently does not support mixing libraries compiled with and without `--use-subdirs'. doc/user_guide.texi: Document the above changes. |
||
|
|
c87d89ec4c |
Change things so that almost all the places which create file names
Estimated hours taken: 4.5 Change things so that almost all the places which create file names do so via just a few predicates (such as module_name_to_file_name) in modules.m. Centralising the file handling in this way will make future changes to the file naming convention simpler. (The one place which still creates file names other than via the predicates declared at the start of modules.m is mercury_compile__link_module_list. It creates them based on the value of the `-o <filename>' option. I didn't change that because I am not yet sure what the semantics of the `-o <filename>' option ought to be.) compiler/modules.m: Add three extra arguments to module_name_to_file_name/2: the file extension, and an io__state pair. Add new predicates module_name_to_lib_file_name/6, module_name_to_split_c_file_name/6, and module_name_to_make_var_name/2. compiler/export.m: compiler/intermod.m: compiler/llds_out.m: compiler/mercury_compile.m: compiler/module_qual.m: compiler/modules.m: compiler/termination.m: compiler/trans_opt.m: compiler/unused_args.m: Change all calls to module_name_to_file_name/2 to instead call one of the above-mentioned predicates in modules.m. compiler/llds_out.m: Add new predicate llds_out__make_init_name/2 which returns the name of the initialization function for a module, for use by modules.m. compiler/modules.m: A few minor changes to the generated .dep files: - add a new phony target `foo.trans_opt', to match `foo.opt'; - change the generated rule for `change_clean' so that it removes `.pic_o' files; - add `.PHONY' declarations for phony targets; - change the generated rule for making `foo.init' so that it used the names returned by llds_out__make_init_name/2, rather than using "mercury__`basename foo.m .m`__init"; - fix a bug in the generated rule for making `libfoo.a': it had `rm -f foo.a' instead of `rm -f libfoo.a'. |
||
|
|
11d8161692 |
Add support for nested modules.
Estimated hours taken: 50
Add support for nested modules.
- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
which name sub-modules
- a sub-module has access to all the declarations in the
parent module (including its implementation section).
This support is not yet complete; see the BUGS and LIMITATIONS below.
LIMITATIONS
- source file names must match module names
(just as they did previously)
- mmc doesn't allow path names on the command line any more
(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
`include_module').
BUGS
- doesn't check that the parent module is imported/used before allowing
import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced
-------------------
NEWS:
Mention that we support nested modules.
library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
Add `include_module' as a new prefix operator.
Change the associativity of `:' from xfy to yfx
(since this made parsing module qualifiers slightly easier).
compiler/prog_data.m:
Add new `include_module' declaration.
Change the `module_name' and `module_specifier' types
from strings to sym_names, so that module names can
themselves be module qualified.
compiler/modules.m:
Add predicates module_name_to_file_name/2 and
file_name_to_module_name/2.
Lots of changes to handle parent module dependencies,
to create parent interface (`.int0') files, to read them in,
to output correct dependencies information for them to the
`.d' and `.dep' files, etc.
Rewrite a lot of the code to improve the readability
(add comments, use subroutines, better variable names).
Also fix a couple of bugs:
- generate_dependencies was using the transitive implementation
dependencies rather than the transitive interface dependencies
to compute the `.int3' dependencies when writing `.d' files
(this bug was introduced during crs's changes to support
`.trans_opt' files)
- when creating the `.int' file, it was reading in the
interfaces for modules imported in the implementation section,
not just those in the interface section.
This meant that the compiler missed a lot of errors.
library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
Add `:- import_module' declarations to the interface needed
by declarations in the interface. (The previous version
of the compiler did not detect these missing interface imports,
due to the above-mentioned bug in modules.m.)
compiler/mercury_compile.m:
compiler/intermod.m:
Change mercury_compile__maybe_grab_optfiles and
intermod__grab_optfiles so that they grab the opt files for
parent modules as well as the ones for imported modules.
compiler/mercury_compile.m:
Minor changes to handle parent module dependencies.
(Also improve the wording of the warning about trans-opt
dependencies.)
compiler/make_hlds.m:
compiler/module_qual.m:
Ignore `:- include_module' declarations.
compiler/module_qual.m:
A couple of small changes to handle nested module names.
compiler/prog_out.m:
compiler/prog_util.m:
Add new predicates string_to_sym_name/3 (prog_util.m) and
sym_name_to_string/{2,3} (prog_out.m).
compiler/*.m:
Replace many occurrences of `string' with `module_name'.
Change code that prints out module names or converts
them to strings or filenames to handle the fact that
module names are now sym_names intead of strings.
Also change a few places (e.g. in intermod.m, hlds_module.m)
where the code assumed that any qualified symbol was
fully-qualified.
compiler/prog_io.m:
compiler/prog_io_goal.m:
Move sym_name_and_args/3, parse_qualified_term/4 and
parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
since they are very similar to the parse_symbol_name/2 predicate
already in prog_io.m. Rewrite these predicates, both
to improve maintainability, and to handle the newly
allowed syntax (module-qualified module names).
Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.
compiler/prog_io.m:
Rewrite the handling of `:- module' and `:- end_module'
declarations, so that it can handle nested modules.
Add code to parse `include_module' declarations.
compiler/prog_util.m:
compiler/*.m:
Add new predicates mercury_public_builtin_module/1 and
mercury_private_builtin_module/1 in prog_util.m.
Change most of the hard-coded occurrences of "mercury_builtin"
to call mercury_private_builtin_module/1 or
mercury_public_builtin_module/1 or both.
compiler/llds_out.m:
Add llds_out__sym_name_mangle/2, for mangling module names.
compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
Move the predicates in_mode/1, out_mode/1, and uo_mode/1
from special_pred.m to mode_util.m, and change various
hard-coded definitions to instead call these predicates.
compiler/polymorphism.m:
Ensure that the type names `type_info' and `typeclass_info' are
module-qualified in the generated code. This avoids a problem
where the code generated by polymorphism.m was not considered
type-correct, due to the type `type_info' not matching
`mercury_builtin:type_info'.
compiler/check_typeclass.m:
Simplify the code for check_instance_pred and
get_matching_instance_pred_ids.
compiler/mercury_compile.m:
compiler/modules.m:
Disallow directory names in command-line arguments.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
Add a `--make-private-interface' option.
The private interface file `<module>.int0' contains
all the declarations in the module; it is used for
compiling sub-modules.
scripts/Mmake.rules:
scripts/Mmake.vars.in:
Add support for creating `.int0' and `.date0' files
by invoking mmc with `--make-private-interface'.
doc/user_guide.texi:
Document `--make-private-interface' and the `.int0'
and `.date0' file extensions.
doc/reference_manual.texi:
Document nested modules.
util/mdemangle.c:
profiler/demangle.m:
Demangle names with multiple module qualifiers.
tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
Change the `:- module string__format_test' declaration in
`string__format_test.m' to `:- module string_format_test',
because with the original declaration the `__' was taken
as a module qualifier, which lead to an error message.
Hence rename the file accordingly, to avoid the warning
about file name not matching module name.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
Regression test to check that the compiler reports
errors for missing `import_module' in the interface section.
tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
Update the expected diagnostics output for the test cases to
reflect a few minor changes to the warning messages.
tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
Two simple tests case for the use of nested modules with
separate compilation.
|
||
|
|
94cc77f4c3 |
Bug fixes for inter-module optimization
Estimated hours taken: 1.5 Bug fixes for inter-module optimization compiler/Mmakefile Use the `.int' files in $(LIBRARY_DIR) rather than the installed `.int' files when creating `.opt' files for the compiler. compiler/intermod.m Handle higher-order function calls properly. This caused mmc --make-optimization-interface --enable-termination \ tests/hard_coded/agg.m to fail. Make sure types used by abstract exported types are made exported when compiling to C. This ensures that the base_type_infos are exported, avoiding link errors. tests/general/intermod_type.m tests/general/intermod_type2.m tests/general/intermod_type.exp Regression test for abstract exported types. |
||
|
|
d0085d8119 |
Assorted changes to make the HLDS type and mode correct
Estimated hours taken: 45
Assorted changes to make the HLDS type and mode correct
after lambda expansion. The HLDS is still not unique mode
correct after common structure elimination.
compiler/det_analysis.m
Make sure the inferred_determinism field of the proc_info is filled
in correctly for imported procedures and class methods.
compiler/mode_util.m
Fix a bug in recompute_instmap_delta_call to do with unreachable
instmaps. This caused an abort a couple of months ago when
compiling with --deforestation (not yet committed), but
can't currently be reproduced.
compiler/hlds_pred.m
compiler/lambda.m
Add a field to the proc_info to record which args_method
should be used for this procedure. Procedures directly
called by do_call_*_closure must be compiled with
the `compact' argument convention to avoid the need to permute
the arguments so inputs come before outputs.
compiler/lambda.m
compiler/higher_order.m
Remove permutation of argument variables of lambda expressions
so the HLDS is type and mode correct and mode analysis can
be rerun. Otherwise, rerunning mode analysis will fail on
tests/hard_coded/ho_order.m.
compiler/arg_info.m
Added arg_info__ho_call_args_method which returns
an args_method which can always be directly called by
do_call_*_closure (`compact').
Added arg_info__args_method_is_ho_callable to check that
a given args_method can be directly called.
compiler/unify_gen.m
Abort if a closure is created for a procedure compiled
with the simple argument convention.
compiler/hlds_goal.m
compiler/lambda.m
Mode analysis was not storing the non-locals list on which the
uni_modes field of the construction of a lambda goal was computed.
If the nonlocals were renamed, the sort order could change, and
the non-locals could be incorrectly matched with the arguments
of the introduced lambda expression, causing a mode error. The
argument list is now stored.
This caused rerunning mode-checking on tests/valid/lazy_list.m
after polymorphism to fail.
compiler/*.m
Fill in the args_method field of proc_infos with the value
from the globals.
Handle the extra argument to the lambda_goal unify_rhs.
compiler/follow_vars.m
Remove code to handle complicated unifications, since
they should be removed by polymorphism.m.
compiler/special_pred.m
library/mercury_builtin.m
Make the uniqueness of the comparison_result argument
of builtin_compare_* and the automatically generated
comparison procedures match that of compare/3. Unique mode
errors will still be introduced if polymorphism.m specializes
calls to any of the unique modes of compare/3 and then mode analysis
is rerun, since the compiler-generated comparison procedures
only implement the (uo, in, in) mode. (This is not yet a problem
because currently we don't rerun mode analysis.)
runtime/mercury_ho_call.c
Remove code in do_call_*_closure to deal with the
`simple' args_method. Since the output arguments no longer
need to be moved, the closure call is now a tailcall.
Remove some magic numbers.
compiler/modecheck_unify.m
Avoid some aborts and mode errors when rerunning mode analysis,
especially those resulting from not_reached insts being treated
as bound.
Avoid aborting on higher-order predicate constants with multiple
modes if lambda expansion has already been run.
tests/valid/higher_order.m
Add a test case for an abort in mode analysis when
compiling with --deforestation (not yet committed),
due to a predicate constant for a procedure with multiple
modes.
tests/valid/unreachable_code.m
Add a test case for bogus higher-order unification
mode errors in unreachable code.
|
||
|
|
fd103c3f4d |
Fix a bug introduced in Zoltan's changes to add support
Estimated hours taken: 1.5 compiler/intermod.m: Fix a bug introduced in Zoltan's changes to add support for nondet pragma c_code: when writing out `pragma c_code' declarations in `.opt' or `.trans_opt' files, take into account the possibility that the variables may have been renamed. Use the original names in the pragma c_code declaration, not the new names, so that the names match with the names used in the C code fragment. |
||
|
|
968b084fbe |
Delete all the obsolete code using magic numbers (e.g. 10000)
Estimated hours taken: 0.75 compiler/bytecode.m: compiler/code_util.m: compiler/const_prop.m: compiler/hlds_out.m: compiler/intermod.m: compiler/llds_out.m: compiler/make_hlds.m: compiler/mercury_to_c.m: compiler/modes.m: compiler/special_pred.m: compiler/term_errors.m: compiler/trace.m: Delete all the obsolete code using magic numbers (e.g. 10000) for proc_ids. This old hack, whereby make_hlds.m assigned mode numbers based on the priority given to the determinism of each mode, is not needed anymore. It is no longer needed because modecheck_call.m now chooses the mode that is the best fit (based on a variety of factors) rather than just picking the first allowable mode. tests/invalid/duplicate_modes.err_exp: The output for this test changed, in insignificant ways: the order in which it reported the duplicates modes changed, because the mode numbers had changed. |
||
|
|
5013dd9c76 |
Implement nondet pragma C codes.
Estimated hours taken: 40
Implement nondet pragma C codes.
runtime/mercury_stacks.h:
Define a new macro, mkpragmaframe, for use in the implementation
of nondet pragma C codes. This new macro includes space for a
struct with a given sruct tag in the nondet stack frame being created.
compiler/{prog_data.m,hlds_goal.m}:
Revise the representation of pragma C codes, both as the item and
in the HLDS.
compiler/prog_io_pragma.m:
Parse nondet pragma C declarations.
Fix the indentation in some places.
compiler/llds.m:
Include an extra argument in mkframe instructions. This extra argument
gives the details of the C structure (if any) to be included in the
nondet stack frame to be created.
Generalize the LLDS representation of pragma C codes. Instead of a
fixed sequence of <assign from inputs, user c code, assign to outputs>,
let the sequence contain these elements, as well as arbitrary
compiler-generated C code, in any order and possibly with repetitions.
This flexibility is needed for nondet pragma C codes.
Add a field to pragma C codes to say whether they can call Mercury.
Some optimizations can do a better job if they know that a pragma C
code cannot call Mercury.
Add another field to pragma C codes to give the name of the label
they refer to (if any). This is needed to prevent labelopt from
incorrectly optimizing away the label definition.
Add a new alternative to the type pragma_c_decl, to describe the
declaration of the local variable that points to the save struct.
compiler/llds_out.m:
Output mkframe instructions that specify a struct as invoking the new
mkpragmaframe macro, and make sure that the struct is declared just
before the procedure that uses it.
Other minor changes to keep up with the changes to the representation
of pragma C code in the LLDS, and to make the output look a bit nicer.
compiler/pragma_c_gen.m:
Add code to generate code for nondet pragma C codes. Revise the utility
predicates and their data structures a bit to make this possible.
compiler/code_gen.m:
Add code for the necessary special handling of prologs and epilogs
of procedures defined by nondet pragma C codes. The prologs need
to be modified to include a programmer-defined C structure in the
nondet stack frame and to communicate the location of this structure
to the pragma C code, whereas the functionality of the epilog is
taken care of by the pragma C code itself.
compiler/make_hlds.m:
When creating a proc_info for a procedure defined by a pragma C code,
we used to insert unifications between the headvars and the vars of
the pragma C code into the body goal. We now perform substitutions
instead. This removes a factor that would complicate the generation
of code for nondet pragma C codes.
Pass a moduleinfo down the procedures that warn about singletons
(and other basic scope errors). When checking whether to warn about
an argument of a pragma C code not being mentioned in the C code
fragment, we need to know whether the argument is input or output,
since input variables should appear in some code fragments in a
nondet pragma C code and must not appear in others. The
mode_is_{in,out}put checks need the moduleinfo.
(We do not need to check for any variables being mentioned where
they shouldn't be. The C compiler will fail in the presence of any
errors of that type, and since those variables could be referred
to via macros whose definitions we do not see, we couldn't implement
a reliable test anyway.)
compiler/opt_util.m:
Recognize that some sorts of pragma_c codes cannot affect the data
structures that control backtracking. This allows peepholing to
do a better job on code sequences produced for nondet pragma C codes.
Recognize that the C code strings inside some pragma_c codes refer to
other labels in the procedure. This prevents labelopt from incorrectly
optimizing away these labels.
compiler/dupelim.m:
If a label is referred to from within a C code string, then do not
attempt to optimize it away.
compiler/det_analysis.m:
Remove a now incorrect part of an error message.
compiler/*.m:
Minor changes to conform to changes to the HLDS and LLDS data
structures.
|
||
|
|
bb4442ddc1 |
Update copyright dates for 1998.
Estimated hours taken: 0.5 compiler/*.m: Update copyright dates for 1998. |
||
|
|
7406335105 |
This change implements typeclasses. Included are the necessary changes to
Estimated hours taken: 500 or so This change implements typeclasses. Included are the necessary changes to the compiler, runtime and library. compiler/typecheck.m: Typecheck the constraints on a pred by adding constraints for each call to a pred/func with constraints, and eliminating constraints by applying context reduction. While reducing the constraints, keep track of the proofs so that polymorphism can produce the tyepclass_infos for eliminated constraints. compiler/polymorphism.m: Perform the source-to-source transformation which turns code with typeclass constraints into code without constraints, but with extra "typeclass_info", or "dictionary" parameters. Also, rather than always having a type_info directly for each type variable, sometimes the type_info is hidden inside a typeclass_info. compiler/bytecode*.m: Insert some code to abort if bytecode generation is used when typeclasses are used. compiler/call_gen.m: Generate code for a class_method_call, which forms the body of a class method (by selecting the appropriate proc from the typeclass_info). compiler/dead_proc_elim.m: Don't eliminate class methods if they are potentially used outside the module compiler/hlds_data.m: Define data types to store: - the typeclass definitions - the instances of a class - "constraint_proof". ie. the proofs of redundancy of a constraint. This info is used by polymorphism to construct the typeclass_infos for a constraint. - the "base_tyepclass_info_constant", which is analagous the the base_type_info_constant compiler/hlds_data.m: Define the class_method_call goal. This goal is inserted into the body of class method procs, and is responsible for selecting the appropriate part of the typeclass_info to call. compiler/hlds_data.m: Add the class table and instance table to the module_info. compiler/hlds_out.m: Output info about base_typeclass_infos and class_method_calls compiler/hlds_pred.m: Change the representation of the locations of type_infos from "var" to type_info_locn, which is either a var, or part of a typeclass_info, since now the typeclass_infos contain the type_infos for the type that they constrain. Add constraints to the pred_info. Add constraint_proofs to the pred_info (so that typeclass.m can annotate the pred_info with the reasons that constraints were eliminated, so that polymorphism.m can in turn generate the typeclass_infos for the constraints). Add the "class_method" marker. compiler/lambda.m: A feable attempt at adding class ontexts to lambda expressions, untested and almost certainly not working. compiler/llds_out.m: Output the code addresses for do_*det_class_method, and output appropriately mangled symbol names for base_typeclass_infos. compiler/make_hlds.m: Add constraints to the types on pred and func decls, and add class and instance declarations to the class_table and instance_table respectively. compiler/mercury_compile.m: Add the check_typeclass pass. compiler/mercury_to_mercury.m: Output constraints of pred and funcs, and output typeclass and instance declarations. compiler/module_qual.m: Module qualify typeclass names in pred class contexts, and qualify the typeclass and instance decls themselves. compiler/modules.m: Output typeclass declarations in the short interface too. compiler/prog_data.m: Add the "typeclass" and "instance" items. Define the types to store information about the declarations, including class contexts on pred and func decls. compiler/prog_io.m: Parse constraints on pred and func declarations. compiler/prod_out.m: Output class contexts on pred and func decls. compiler/type_util.m: Add preds to apply a substitution to a class_constraint, and to a list of class constraints. Add type_list_matches_exactly/2. Also add typeclass_info and base_typeclass_info as types which should not be optimised as no_tag types (seeing that we cheat a bit about their representation). compiler/notes/compiler_design.html: Add notes on module qualification of class contexts. Needs expansion to include more stuff on typeclasses. compiler/*.m: Various minor changes. New Files: compiler/base_typeclass_info.m: Produce one base_typeclass_info for each instance declaration. compiler/prog_io_typeclass.m: Parse typeclass and instance declarations. compiler/check_typeclass.m: Check the conformance of an instance declaration to the typeclass declaration, including building up a proof of how superclass constraints are satisfied so that polymorphism.m is able to construct the typeclass_info, including the superclass typeclass_infos. library/mercury_builtin.m: Implement that base_typeclass_info and typeclass_info types, as well as the predicates type_info_from_typeclass_info/3 to extract a type_info from a typeclass_info, and superclass_from_typeclass_info/3 for extracting superclasses. library/ops.m: Add "typeclass" and "instance" as operators. library/string.m: Add a (in, uo) mode for string__length/3. runtime/mercury_ho_call.c: Implement do_call_*det_class_method, which are the pieces of code responsible for extracting the correct code address from the typeclass_info, setting up the arguments correctly, then executing the code. runtime/mercury_type_info.h: Macros for accessing the typeclass_info structure. |
||
|
|
2357cc87c9 |
Fix bugs that broke impurity declarations if intermodule
Estimated hours taken: 0.75
Fix bugs that broke impurity declarations if intermodule
optimization was enabled.
compiler/intermod.m:
Don't output `pragma' declarations for purity markers.
compiler/hlds_out.m:
For `promised_pure' markers, write out `promise_pure',
not `promised_pure', so that the pragma name is correct.
Index: intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.37
diff -u -u -r1.37 intermod.m
--- intermod.m 1997/12/09 04:00:47 1.37
+++ intermod.m 1997/12/11 21:06:02
@@ -945,17 +945,19 @@
intermod__write_pragmas(_, _, [], _) --> [].
intermod__write_pragmas(SymName, Arity, [Marker | Markers], PredOrFunc) -->
(
- \+ (
- % Since the inferred declarations are output, these
- % don't need to be done in the importing module.
- { Marker = infer_type }
- ; { Marker = infer_modes }
+ % Since the inferred declarations are output, these
+ % don't need to be done in the importing module.
+ % Also purity is output as part of the pred/func decl.
+ ( { Marker = infer_type }
+ ; { Marker = infer_modes }
+ ; { Marker = (impure) }
+ ; { Marker = (semipure) }
)
+ ;
+ []
->
{ hlds_out__marker_name(Marker, Name) },
mercury_output_pragma_decl(SymName, Arity, PredOrFunc, Name)
- ;
- []
),
intermod__write_pragmas(SymName, Arity, Markers, PredOrFunc).
Index: hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.176
diff -u -u -r1.176 hlds_out.m
--- hlds_out.m 1997/12/09 04:00:42 1.176
+++ hlds_out.m 1997/12/11 21:06:26
@@ -511,7 +511,7 @@
hlds_out__marker_name(memo, "memo").
hlds_out__marker_name((impure), "impure").
hlds_out__marker_name((semipure), "semipure").
-hlds_out__marker_name(promised_pure, "promised_pure").
+hlds_out__marker_name(promised_pure, "promise_pure").
hlds_out__marker_name(terminates, "terminates").
hlds_out__marker_name(check_termination, "check_termination").
hlds_out__marker_name(does_not_terminate, "does_not_terminate").
|
||
|
|
bf824facde |
Make Mercury cope with impure code
The purpose of this diff is to allow Mercury programs to contain
impure Mercury code without the compiler changing its behavior
inappropriately, while still allowing the compiler to aggressively
optimize pure code. To do this, we require impure predicates to be so
declared, and calls to impure predicates to be flagged as such. We
also allow predicates implemented in terms of impure predicates to be
promised to be pure; lacking such a promise, any predicate that calls
an impure predicate is assumed to be impure.
At the moment, we don't allow impure functions (only predicates),
though some of the work necessary to support them has been done.
Note that to make the operators work properly, the precedence of the
`pred' and `func' operators has been changed from 1199 to 800.
Estimated hours taken: 150
compiler/purity.m:
New compiler pass for purity checking.
compiler/hlds_goal.m:
Add `impure' and `semipure' to the goal_feature enum.
compiler/hlds_out.m:
compiler/typecheck.m:
compiler/special_pred.m:
Fixed code that prints predicate name to write something more
helpful for special (compiler-generated) predicates. Added
code to print new markers. Added purity argument to
mercury_output_pred_type. New public predicate
special_pred_description/2 provides an english description for
each compiler-generated predicate.
compiler/hlds_pred.m:
Add `impure' and `semipure' to marker enum. Added new
public predicates to get predicate purity and whether or not
it's promised to be pure.
compiler/prog_data.m:
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_dcg.m:
compiler/prog_util.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/mercury_to_c.m:
compiler/module_qual.m:
Add purity argument to pred and func items. Add new `impure'
and `semipure' operators. Add promise_pure pragma. Add
purity/2 wrapper to goal_expr type.
compiler/make_hlds.m:
compiler/mercury_to_goedel.m:
Added purity argument to module_add_{pred,func},
clauses_info_add_pragma_c_code, and to pred and func items.
Handle promise_pure pragma. Handle purity/2 wrapper used to
handle user-written impurity annotations on goals.
compiler/mercury_compile.m:
Add purity checking pass between type and mode checking.
compiler/mode_errors.m:
Distinguish mode errors caused by impure goals preventing
goals being delayed.
compiler/modes.m:
Don't delay impure goals, and ensure before scheduling an
impure goal that no goals are delayed. Actually, we go ahead
and try to schedule goals even if impurity causes a problem,
and then if it still doesn't mode check, then we report an
ordinary mode error. Only if the clause would be mode correct
except for an impure goal do we report it as an impurity problem.
compiler/simplify.m:
Don't optimize away non-pure duplicate calls. We could do
better and still optimize duplicate semipure goals without an
intervening impure goal, but it's probably not worth the
trouble. Also don't eliminate impure goals on a failing branch.
compiler/notes/compiler_design.html:
Documented purity checking pass.
doc/reference_manual.texi:
Document purity system.
doc/transition_guide.texi:
library/nc_builtin.nl:
library/ops.m:
library/sp_builtin.nl:
New operators and new precdence for `pred' and `func'
operators.
tests/hard_coded/purity.m
tests/hard_coded/purity.exp
tests/hard_coded/Mmakefile:
tests/invalid/purity.m
tests/invalid/purity_nonsense.m
tests/invalid/purity.err_exp
tests/invalid/purity_nonsense.err_exp
tests/invalid/Mmakefile:
Test cases for purity.
|
||
|
|
470532637d |
Clean up the handling of predicate markers (flags).
Estimated hours taken: 3 Clean up the handling of predicate markers (flags). compiler/hlds_pred.m: Delete the `marker_status' type. It was just adding complexity which wasn't being used. Change the "markers list" field of the pred_info from a list(marker_status) to an abstract data type representing a set of markers. Add new access predicates for this ADT. Currently the ADT is still implemented as a list, but it might be a good idea to eventually change it to be an int, using a different bit for each flag. compiler/dnf.m: Don't bother to record `done(dnf)' markers, since they're not needed. compiler/make_hlds.m: Change add_pred_marker so that it adds a single marker, rather than a list of markers. Allowing a list of markers was just adding extra complexity which wasn't being used. compiler/dnf.m: compiler/higher_order.m: compiler/hlds_out.m: compiler/intermod.m: compiler/lambda.m: compiler/make_hlds.m: compiler/mode_errors.m: compiler/modecheck_call.m: compiler/modes.m: compiler/simplify.m: compiler/stratify.m: compiler/term_util.m: compiler/termination.m: compiler/typecheck.m: compiler/unused_args.m: Update to use the new ADT. |
||
|
|
04125e10ba |
Fix a bug in the writing of .opt files.
Estimated hours taken: 1 Fix a bug in the writing of .opt files. The problem occurs when you have a pragma inline declaration for an exported function. The declaration: :- func addone(int) = int. :- pragma inline(addone/1). addone(I) = I + 1. gets written to the .opt file as: :- pragma inline((foo:addone)/2). That is, the arity of the _predicate_ version is written rather than the arity of the _function_. compiler/intermod.m: compiler/mercury_to_mercury.m: Add a pred_or_func argument to mercury_output_pragma_decl, and use that to determine the declared arity. tests/valid/intermod_test.m: tests/valid/intermod_test2.m: Regression test. |
||
|
|
10ce33a73e |
Don't write predicates with pragma no_inline
Estimated hours taken: 0.1 compiler/intermod.m Don't write predicates with pragma no_inline declarations to `.opt' files. |
||
|
|
7ea045ccf7 |
Fix a bug in the output of `:- inst' declarations that
Estimated hours taken: 0.25 compiler/intermod.m: Fix a bug in the output of `:- inst' declarations that was causing syntax errors in the generated `.opt' files. |
||
|
|
5976f769f7 |
Fix a bug for the case of a higher-order function call in code
Estimated hours taken: 1 Fix a bug for the case of a higher-order function call in code with common sub-expression; mercury 0.7 failed this test, reporting "Software Error: modecheck fails when repeated", due to confusion between h.o. _function_ call and h.o. _predicate_ call. compiler/hlds_goal.m: Add `pred_or_func' field to HLDS higher_order_calls. compiler/modes.m: compiler/modecheck_call.m: compiler/hlds_out.m: compiler/*.m: Add code to handle new field for higher_order_call goals. tests/valid/Mmake: tests/valid/ho_func_call.m: Regression test for the above-mentioned bug. |
||
|
|
99184d3578 |
Implement support for types with user-defined equality predicates.
Estimated hours taken: 30 Implement support for types with user-defined equality predicates. Types with user-defined equality predicates are called "non-canonical types"; they may have more than one representation for the same abstract value. That means that any attempt to deconstruct a value of a non-canonical type, i.e. any attempt to peek at the representation, must be cc_multi. This also implies that conceptually speaking, non-canonical types are not members of the type classes `comparable' (compare/3) or `deconstructible' (index/2, argument/3, functor/3, deconstruct/5). Since we don't support type classes yet, that just means that the type-class checking is done at runtime, i.e. any call to one of those functions for a non-canonical type will call error/1 or fatal_error(). To make non-canonical types useful, we really need type classes, so that the user can provide instance definitions for `comparable' and `deconstructible' for such types. It might also be a good idea to have a type-class `canonicalizable' which provides a function to convert its argument to some canonical type (that would require existential types to do nicely, but alternatively we could just use `univ'). Note that currently the only mechanism for promising that things are unique is via the C interface. compiler/det_analysis.m: Add code to check unifications that examine the representation of a type with a user-defined equality predicate. Any such unification must occur in a single-solution context and must not be able to fail. Such unifications determinism have determinism cc_multi. compiler/det_report.m: Add code to report errors for misuse of types with user-defined equality predicates. (Also some other stylistic improvements: split up a complicated predicate into subroutines, and avoid some unnecessary code duplication.) compiler/prog_data.m: compiler/hlds_data.m: Add a new `maybe(sym_name)' field to the du_type/3 constructor to hold the name of the user-defined equality pred for the type, if any. compiler/prog_io.m: Add code to parse the new `... where equality is <name>.' syntax. Delete the old support for `... where <condition>'. compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/mercury_to_goedel.m: Print out the new field. compiler/base_type_layout.m: compiler/code_util.m: compiler/dense_switch.m: compiler/equiv_type.m: compiler/intermod.m: compiler/make_hlds.m: compiler/mode_util.m: compiler/module_qual.m: compiler/modules.m: compiler/switch_detection.m: compiler/tag_switch.m: compiler/type_util.m: compiler/typecheck.m: compiler/unify_gen.m: Trivial changes to ignore (or leave unchanged) the new field in `du_type'. compiler/modecheck_unify.m: Pass the term__context to unify_proc__request_unify. compiler/typecheck.m: Typecheck the compiler-generated unify predicates for types with user-defined equality preds. compiler/unify_proc.m: For d.u. types, if the type has a user-defined equality predicate then generate code for the compiler-generated unify predicate that just calls the specified predicate, and generate code for the compiler-generated compare and index predicates that just calls some procedures in mercury_builtin.m that report appropriate error messages. Ensure that the automatically-generated predicates have appropriate term__contexts everywhere, so that if the user-defined equality predicate name is ambiguous, non-existent, or has the wrong type, mode, or determinism, then the error messages from type checking, mode checking, or determinism checking refer to the type declaration. library/mercury_builtin.m: Add predicates builtin_index_non_canonical_type/2 and builtin_compare_non_canonical_type/2, used by the code generated by compiler/unify_proc.m. doc/reference_manual.texi: Document the support for user-defined equality predicates. library/std_util.m: Change ML_expand() to return an indication of whether or not the type is a non-canonical type (one with a user-defined equality predicate). Change argument/2, functor/2, and deconstruct/4 to abort if called for a non-canonical type. |
||
|
|
04b720630b |
Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne". |
||
|
|
9b7f11c6dd |
Reorganisation of modules to do with the inst data type.
Estimated hours taken: 20 Reorganisation of modules to do with the inst data type. This is actually the first installment of the alias tracking mode checker in disguise. A very good disguise. The rationale for this reorganisation is to reduce coupling in the part of the mode checker which is _not_ in this change (ie most of it). Alias tracking requires a new kind of inst, alias(inst_key), where an inst_key is a handle on some other sub-inst. With it goes a data structure in which to store dereferenced insts and all the operations which go with it. This code will go in the new module inst.m so that it doesn't have to go in prog_data.m. (I briefly considered putting it in instmap.m however this introduces some bad coupling since instmap.m imports hlds_module.m. Putting it in prog_data.m would cause hlds_*.m to depend on prog_data.m, but we have designed things so that the dependencies go in the other direction.) The remainder of the reorganisation is a general cleanup: the inst testing predicates (inst_is_*) have been moved out of mode_util because they are not actually operations on modes at all, and have been moved into inst_match. inst_match has then been split because otherwise it would be 2000 lines long and will get significantly bigger when aliasing is added. Roughly speaking, any operations which create new insts from old ones have been moved into a new module, inst_util while any operations which test the values of insts remain in inst_match. Also included are the removal of some NU-Prologisms since the NU-Prolog version of the compiler is no longer supported. Two changes here: - Removal of some when declarations. - A gross hack in inst_is_*_2, where two copies of the same inst were passed into the predicate so that one could be switched on. Thank NU-Prolog's lack of common subexpression elimination. compiler/inst.m: New module which contains the data types inst, uniqueness, pred_inst_info, bound_inst. compiler/inst_util.m: New module which contains predicates which perform mode checking-like operations on insts. Moved in: abstractly_unify_inst, abstractly_unify_inst_functor, inst_merge, make_mostly_uniq_inst (from inst_match.m) compiler/inst_match.m: Moved out: inst_merge, make_mostly_uniq_inst, abstractly_unify_inst, abstractly_unify_inst_functor (to inst_util.m) Moved in: inst_is_*, inst_list_is_*, bound_inst_list_is_* (from mode_util.m) Now exported: unique_matches_initial/2, unique_matches_final/2 inst_contains_instname/3, pred_inst_matches/3 (They are required by inst_util.m, and they are useful in their own right.) compiler/instmap.m: instmap_delta_lookup_var/3 reincarnated as instmap_delta_search_var/3. The reason for this change is that previously, instmap_delta_lookup_var simply returned `free' if the searched-for var did not occur in the instmap_delta. This is somewhat non-obvious behaviour. instmap_delta_search_var/3 fails in such a situation. compiler/mode_util.m: Moved out: inst_is_*, inst_list_is_*, bound_inst_list_is_* (to inst_match.m) (These are not really operations on modes.) compiler/modecheck_call.m: Moved in modecheck_higher_order_func_call/5, from modecheck_unify.m compiler/modecheck_unify.m: Moved out modecheck_higher_order_func_call/5, to modecheck_call.m where it should have been all along. compiler/prog_data.m: Moved out the types inst, uniqueness, pred_inst_info, bound_inst (to inst.m). compiler/common.m: compiler/cse_detection.m: compiler/fact_table.m: compiler/higher_order.m: compiler/hlds_data.m: compiler/hlds_goal.m: compiler/hlds_out.m: compiler/intermod.m: compiler/liveness.m: compiler/llds.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/mode_debug.m: compiler/mode_errors.m: compiler/mode_info.m: compiler/modes.m: compiler/module_qual.m: compiler/polymorphism.m: compiler/prog_io.m: compiler/prog_io_util.m: compiler/prog_util.m: compiler/simplify.m: compiler/switch_detection.m: compiler/unify_proc.m: compiler/unique_modes.m: Miscellaneous minor changes to cope with the above changes. compiler/notes/compiler_design.html: Document the new modules. |
||
|
|
9a1f99b71f |
Efficiency improvements for inter-module optimization.
Estimated hours taken: 3
Efficiency improvements for inter-module optimization.
compiler/intermod.m
compiler/mercury_compile.m
Fix a bug with the date-stamps and --intermod-unused-args by
delaying calling update_interface and touch_interface_datestamp
until after the unused arguments information has been written to
the .opt.tmp file.
compiler/unused_args.m
Write unused argument information to the .opt.tmp file rather
than the .opt file.
compiler/dead_proc_elim.m
compiler/mercury_compile.m
Add a pass to eliminated dead non-local predicates immediately after
building the HLDS to avoid doing analysis of predicates from .opt
files which are not used.
compiler/hlds_module.m
Add module_info_remove_predicate to remove a predicate completely from
the predicate_table.
|
||
|
|
27d156bbb5 |
Implemented a :- use_module directive. This is the same as
Estimated hours taken: 14 Implemented a :- use_module directive. This is the same as :- import_module, except all uses of the imported items must be explicitly module qualified. :- use_module is implemented by ensuring that unqualified versions of items only get added to the HLDS symbol tables if they were imported using import_module. Indirectly imported items (from `.int2' files) and items declared in `.opt' files are treated as if they were imported with use_module, since all uses of them should be module qualified. compiler/module_qual.m Keep two sets of type, mode and inst ids, those which can be used without qualifiers and those which can't. Renamed some predicates which no longer have unique names since '__' became a synonym for ':'. Made mq_info_set_module_used check whether the current item is in the interface, rather than relying on its caller to do the check. Removed init_mq_info_module, since make_hlds.m now uses the mq_info built during the module qualification pass. compiler/prog_data.m Added a pseudo-declaration `used', same as `imported' except uses of the following items must be module qualified. Added a type need_qualifier to describe whether uses of an item need to be module qualified. compiler/make_hlds.m Keep with the import_status whether current item was imported using a :- use_module directive. Use the mq_info structure passed in instead of building a new one. Ensure unqualified versions of constructors only get added to the cons_table if they can be used without qualification. compiler/hlds_module.m Added an extra argument to predicate_table_insert of type need_qualifier. Only add predicates to the name and name-arity indices if they can be used without qualifiers. Changed the structure of the module-name-arity index, so that lookups can be made without an arity, such as when type-checking module qualified higher-order predicate constants. This does not change the interface to the module_name_arity index. Factored out some common code in predicate_table_insert which applies to both predicates and functions. compiler/hlds_pred.m Removed the opt_decl import_status. It isn't needed any more since all uses of items declared in .opt files must now be module qualified. Added some documentation about when the clauses_info is valid. compiler/intermod.m Ensure that predicate and function calls in the `.opt' file are module qualified. Use use_module instead of import_module in `.opt' files. compiler/modules.m Handle use_module directives. Report a warning if both use_module and import_module declarations exist for the same module. compiler/mercury_compile.m Collect inter-module optimization information before module qualification, since it can't cause conflicts any more. This means that the mq_info structure built in module_qual.m can be reused in make_hlds.m, instead of building a new one. compiler/prog_out.m Add a predicate prog_out__write_module_list, which was moved here from module_qual.m. compiler/typecheck.m Removed code to check that predicates declared in `.opt' files were being used appropriately, since this is now handled by use_module. compiler/*.m Added missing imports, mostly for prog_data and term. NEWS compiler/notes/todo.html doc/reference_manual.texi Document `:- use_module'. tests/valid/intermod_lambda_test.m tests/valid/intermod_lambda_test2.m tests/invalid/errors.m tests/invalid/errors2.m Test cases. |
||
|
|
ea6ba74472 |
Implement `:- pragma no_inline'. This pragma prevents the compiler from
Estimated hours taken: 3 Implement `:- pragma no_inline'. This pragma prevents the compiler from inlining predicates. compiler/higher_order.m: compiler/unused_args.m: Create new preds using entire marker list, rather than just inlining. compiler/hlds_out.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/prog_data.m: compiler/prog_io_pragma.m: Add code to support no_inline marker and pragma. compiler/hlds_pred.m: Add `no_inline' marker. Create new preds using entire marker list, rather than just inlining. Change `pred_info_is_inlined' to `pred_info_requested_inlining', as it was inappropriately named, and added `pred_info_requested_no_inlining'. compiler/inlining.m: Don't inline predicates with pragma no_inlines compiler/intermod.m: Use `pred_info_requested_inlining'. compiler/make_hlds.m: Add code to check for conflicting markers, check for conflicts between `inline' and `no_inline' markers. Add `no_inline' markers. Rename pragma_set_markers as pragma_add_markers, as it was actually adding extra markers to what was already there. doc/reference_manual.texi: Document no_inline. tests/hard_coded/Mmake: tests/invalid/Mmake: tests/hard_coded/no_inline.exp: tests/hard_coded/no_inline.m: tests/invalid/inline_conflict.err_exp: tests/invalid/inline_conflict.m: Add test cases for no_inline and conflicts between inline and no_inline. |
||
|
|
5294c35b1f |
Use the declared argmodes or procedures when gathering modes to put
Estimated hours taken: 0.1
compiler/intermod.m
Use the declared argmodes or procedures when gathering modes to put
into .opt files, since these are the modes that are written to the
.opt file.
tests/valid/intermod_lambda.m
tests/valid/intermod_lambda2.m
Updated these to act as a regression test.
|
||
|
|
e3471f333f |
Fix a bug in inlining of polymorphic pragma c_code procedures.
Estimated hours taken: 3 Fix a bug in inlining of polymorphic pragma c_code procedures. The bug was that if the actual argument type has a specific type of say `float', then the C variable for the corresponding formal parameter will be declared to have type `Float', whereas without inlining the argument type would have been polymorphic and so the C variable would have been declared to have type `Word'. Hence we need to keep track of the original argument types, before any inlining or specialization has occurred, and use these original argument types to determine how to declare the C variables, rather than using the actual argument types for this particular specialization. compiler/hlds_goal.m: Add a new field to pragma_c_code goals, holding the original argument types (before any inlining or specialization) of the pragma_c_code procedure. compiler/make_hlds.m: Initialize this field with the declared argument types for the pragma c_code procedure. compiler/polymorphism.m: Update this field to account for the inserted type_info variables. compiler/code_gen.m: Pass this field to pragma_c_gen.m. compiler/pragma_c_gen.m: Use the original argument types field for the pragma variable declarations, rather than looking up the actual types of the arguments. compiler/*.m: Trivial changes to handle new field. compiler/live_vars.m: Comment out some code to avoid a warning about `fail' in the condition of an if-then-else. |
||
|
|
b3aec8b27a |
When markers are written out into *.opt files, they contain declarations
Approximate hours taken: 0.3 When markers are written out into *.opt files, they contain declarations of the following form: :- pragma obsolete(math:ceiling/2). This causes a problem with parsing when the file is read back in, since '/' binds its arguments more tightly than ':'. We fix it by making intermod.m call mercury_output_pragma_decl at the right place. Of course it should be fixed by changing the operator precedences, but when this is fixed there will now be only one place to change it. compiler/hlds_out.m: Added hlds_out__marker_name/2. compiler/mercury_to_mercury.m: Export mercury_output_pragma_decl/5. compiler/intermod.m: Call mercury_output_pragma_decl to output a marker decl. |
||
|
|
14bc9b8f70 |
Bug fixes for module qualified cons_ids.
Estimated hours: 8 Bug fixes for module qualified cons_ids. Improve the compilation time of modules with lots of user_defined insts. (Compilation of tree234.m with the unique tree skeleton modes enabled is still way too slow). compiler/mode_util.m In propagate_type_info_into_modes and the predicates it calls, avoid finding the constructors for a type and substituting the argument types. compiler/hlds_pred.m Add a new field to the proc_info, maybe_declared_argmodes which holds the declared arg_modes for use in .opt files and error messages. compiler/typecheck.m Call propagate_type_info_into_modes from here to avoid calling it many times throughout mode analysis. This does not cause a substantial performance improvement, but reduces confusion over where everything should be module qualified. This also fixes a bug with the no_tag optimisation reported by Mark Brown. A runtime abort occurred because a constructor in a bound inst was not being module qualified which confused mode_to_arg_mode into giving the argument an arg_mode of top_unused. compiler/modecheck_unify.m Call propagate_type_info_mode_list for modes of lambda predicates. compiler/modes.m compiler/modecheck_call.m compiler/unique_modes.m Don't call propagate_type_info_mode_list since that has already been done in typecheck.m. compiler/intermod.m Write out the declared arg_modes, since these don't contain constructs such $typed_inst which the parser doesn't handle. compiler/clause_to_proc.m compiler/unify_proc.m Fill in the declared_argmodes field in proc_infos. compiler/type_util.m Avoid creating the substitution multiple times in type_constructors. compiler/mercury_compile.m Added some documentation. tests/hard_coded/Mmake tests/hard_coded/imported_no_tag.m tests/hard_coded/test_imported_no_tag.m tests/hard_coded/test_imported_no_tag.exp Add Mark Brown's test case. |
||
|
|
802d13a947 |
Fix two bug in my previous change to intermod.m.
Estimated hours taken: 1 Fix two bug in my previous change to intermod.m. compiler/intermod.m: In module-qualification of function calls, don't assume that anything which has the same name as a function is a function call -- it might be a constructor. (Actually this bug was in the original code too, for explicitly-qualified function names.) In module-qualification of higher-order terms, when constructing the list of argument types to pass to get_pred_id_and_proc_id, make sure we append the curried arguments and the yet-to-be-passed arguments in the right order. compiler/typecheck.m: Undo previous change: don't export `typecheck__resolve_overloading', since it isn't used anymore after the above fix to intermod.m. |
||
|
|
1954d6b274 |
Fix a bug: use the types to resolve overloading for higher-order terms.
Estimated hours taken: 4 Fix a bug: use the types to resolve overloading for higher-order terms. This avoids a software error in get_pred_and_proc_id when you try to take the address of an overloaded predicate or function, e.g. `<', without using an explicit module qualifier. hlds_module.m: Change get_pred_and_proc_id to handle overload resolution. (Also, simplify the code by splitting out `get_proc_id' as a new subroutine.) typecheck.m: Export new pred `typecheck__resolve_overloading'. Previously the code for this was part of `typecheck__resolve_pred_overloading'. intermod.m: Change call to get_pred_and_proc_id to match its new interface. Use `typecheck__resolve_overloading' rather than `typecheck__find_matching_pred_ids'. (Also, a few stylistic changes: add some documentation and rearrange the code a little.) modecheck_unify.m: Change call to get_pred_and_proc_id to match its new interface. |
||
|
|
d7319104f9 |
Making the types pred_id and proc_id (almost) abstract.
Estimated hours taken: 7
Making the types pred_id and proc_id (almost) abstract.
compiler/code_util.m:
Changed the type of several predicates:
code_util__make_uni_label/4 (arg 3 was int, now proc_id)
code_util__inline_builtin/4 (arg 3 was proc_id, now int)
Added predicate code_util__translate_builtin_2/6.
compiler/hlds_module.m:
Moved invalid_pred_id/1 to hlds_pred.m
compiler/hlds_pred.m:
Types pred_id/0 and proc_id are now abstract.
Added predicates:
hlds_pred__initial_pred_id/1, hlds_pred__initial_proc_id/1,
hlds_pred__next_pred_id/2, hlds_pred__next_proc_id/2,
pred_id_to_int/2, proc_id_to_int/2,
hlds_pred__in_in_unification_proc_id/1
Moved predicate invalid_pred_id/1 (from hlds_module.m).
compiler/*.m:
Miscellaneous minor changes to cast pred/proc_ids to ints
where appropriate.
|
||
|
|
e1d149c067 |
Module qualify constructors in .opt files to eliminate the
Estimated hours taken: 0.1 compiler/intermod.m Module qualify constructors in .opt files to eliminate the possibility of ambiguous overloading due to importing extra types in the inter-module optimization process. Rename an internal predicate to better suit its purpose. |
||
|
|
3ec8a17ffc |
Enable the code to treat `__' as an alternative syntax for module
Estimated hours taken: 8 Enable the code to treat `__' as an alternative syntax for module qualification, after fixing various places in the compiler where we use `__' in ways that are incompatible with this. compiler/prog_io.m: compiler/prog_io_goal.m: Uncomment the code to handle `__' as module qualification. compiler/intermod.m: compiler/hlds_module.m: compiler/modecheck_unify.m: Fix bugs in the handling of module qualified higher-order terms. compiler/*.m: s/hlds__/hlds_/g compiler/passes_aux.m: s/process__/process_/g compiler/pragma_c_gen.m: compiler/code_gen.m: s/code_gen__/pragma_c_gen__/ for the predicates defined in pragma_c_gen.m (this ought to have been done when the code was first moved from code_gen.m to pragma_c_gen.m). compiler/llds.m: s/llds__proc_id/llds_proc_id/g The reason for this was to avoid ambiguity between proc_id in hlds_pred.m and llds__proc_id in llds.m. compiler/quantification.m: compiler/make_hlds.m: compiler/mercury_to_c.m: s/goal_vars/quantification__goal_vars/g The reason for this was to avoid ambiguity between goal_vars in quantification.m and goal_util__goal_vars in goal_util.m. compiler/dupelim.m: compiler/optimize.m: s/dupelim__main/dupelim_main/g The reason for this change is that a program can only have one main/2 predicate. compiler/prog_io_dcg.m: Remove the old "temporary hack" to strip off and ignore io__gc_call/1, since the new handling of `__' broke it. It was only useful for optimizing NU-Prolog performance, which we don't care about anymore. compiler/mercury_compile.m: compiler/modules.m: compiler/intermod.m: compiler/prog_io.m: Remove occurrences of io__gc_call. compiler/llds_out.m: compiler/base_type_info.m: Ensure that we properly handle the special hacks in mercury_builtin where predicates from other modules (e.g. term__context_init) are defined in mercury_builtin because they are needed for type_to_term and term_to_type. llds_out.m: don't put `mercury_builtin' in the mangled names for those symbols. base_type_info.m: handle types whose status is "imported" in their own module. |
||
|
|
89d00fc12d |
The first argument of code_util__predinfo_is_builtin/2 was unused, so it has
Estimated hours taken: 0.5 The first argument of code_util__predinfo_is_builtin/2 was unused, so it has been replaced by code_util__predinfo_is_builtin/1 compiler/code_util.m: changed code_util__predinfo_is_builtin(_ModuleInfo, PredInfo) to code_util__predinfo_is_builtin(PredInfo). compiler/unused_args.m: compiler/typecheck.m: compiler/make_hlds.m: compiler/intermod.m: Fixed each usage of code_util__predinfo_is_builtin. |
||
|
|
831fac00d6 |
Remove some useless (and incorrect) code to disable a warning
Estimated hours taken: 0.1 compiler/intermod.m Remove some useless (and incorrect) code to disable a warning which can't occur. |
||
|
|
91c4330db7 |
The first half of a change to introduce nondet pragma C goals.
Estimated hours taken: 12 The first half of a change to introduce nondet pragma C goals. This half makes the necessary modifications to the HLDS; the next half will modify the LLDS and emit it. prog_data: Add a new pragma type for nondet pragma c_codes; these specify the names of a a bunch of variables to save across backtracking, and a list of label names to which backtracking may take place. Rename is_recursive to may_call_mercury, since this is a more direct expression of the meaning. prog_io: Move much of the functionality to new files. prog_io_dcg, prog_io_goal, prog_io_pragma, prog_io_util: New files, made up of pieces of prog_io. hlds_goal: Add an extra argument to the pragma_c_goals to store the extra information present in the new type of pragma c_codes. det_analysis: Take into account that the new type of pragma_c goal may have more than one solution. goal_util: Rename variables in the new field of pragma_cs. live_vars: Allocate stack slots to the saved variables in the new type of pragma_c goals. make_hlds: Handle the new type of pragma_c goals. mercury_output, hlds_out: Output the new type of pragma_c goals. garbage_out: Rename type "det" to "frame_type". others: Ignore one more arg of pragma_c goals or import prog_io_util. |
||
|
|
bb2b816787 |
* Inter-module unused argument removal.
Estimated hours taken: 100 * Inter-module unused argument removal. * Allow the user to specify which directories should be searched for .opt files. * Enhancements to simplify.m and common.m which will be useful for partial deduction. compiler/options.m Added and documented options: --intermod-unused-args to enable inter-module unused argument removal. --intermod-directory <dir>, same as --search-directory except used to locate .opt files. --use-search-directories-for-intermod - use the search directories for .opt files as well. --warn-simple-code - a flag to control the warnings produced by simplify.m so that they respect --inhibit-warnings. compiler/unused_args.m Use the unused argument info from the .opt file. Clobber the dependency_info if any new preds were added. compiler/hlds_module.m Added a field to the module_info to store unused argument information from .opt files. compiler/prog_data.m Add :- pragma unused_args to hold unused argument information. This should only be used in .opt files. compiler/make_hlds.m Build the unused_arg_info field in the module_info. Check that pragma unused_args only appears in .opt files. Fill in the non-locals field in the goal_info for the builtin stubs so that mode analysis computes the correct instmap delta. compiler/intermod.m Read in the unused argument information for the current module when compiling to C. This is used to ensure that clauses are produced with the correct number of removed arguments (it may be possible to remove more arguments with the information from other modules). Fix a bug in the handling of module qualified function calls and higher-order predicate constants. compiler/handle_options.m Handle --intermod-unused-args and --use-search-directories-for-intermod. compiler/mercury_compile.m Run the entire front end and polymorphism (not just up to typechecking) when building the .opt file with --intermod-unused-args. Use the new interface to simplify.m, remove calls to excess.m and common.m. compiler/code_util.m compiler/llds_out.m When generating local code for a specialized version of a predicate from another module, put this module's name on the label to avoid link errors. compiler/higher_order.m Don't add the originating module name to the name of the specialized version, since that is now done in code_util.m. Clobber the dependency graph so that inlining will work on the specialized versions in profiling grades (this will cause slightly slower compilation in profiling grades, something I need to fix). compiler/simplify.m Merge a branching goal and an adjacent switch where the branches of the first goal contain extra information about the switched on variable of the second goal. Merge the excess assignments and common subexpression elimination passes into simplify.m. compiler/excess.m The functionality of this module is now in simplify.m, but I'll leave it here for now. compiler/instmap.m Added predicates instmap__bind_var_to_functor and instmap_delta_bind_var_functor to which take a var, cons_id and an instmap and adjust the inst of the var. This is used to update the instmap at the beginning of each case in a switch. Fix a bug in merge_instmap_delta where variables whose inst had information added in one branch of a switch, disj, or ite had that changed inst included in the instmap_delta for the entire branched goal. compiler/mode_util.m Use instmap_delta_bind_var_to_functor in recompute_instmap_delta. Added predicate bind_inst_to_functor which takes a ground or bound inst and a cons_id and adjusts the top level of the inst to be bound to that cons_id. Other types of inst are left unchanged. Change recompute_instmap_delta so that the switched on variable of a switch is bound to the functor in each case even if the binding unification has been removed. Added a boolean argument to request recomputation of instmap_deltas for atomic goals. compiler/modes.m compiler/unique_modes.m Make sure that the instmap_delta for each branch of a switch includes the extra information added by the functor test. compiler/common.m Removed the goal traversal. Leave preds to be called by simplify.m to optimise common unifications and calls. Warn about and eliminate multiple calls to a predicate with the same input arguments. Replace deconstructions of known terms with assignments to the output variables where this would not make more variables live at stack flushes. compiler/follow_code.m Exported move_follow_code_select. Don't move follow code into erroneous branches. library/string.nu.nl Added string__contains_char/2. compiler/base_type_layout.m compiler/special_pred.m compiler/vn_order.m library/mercury_builtin.m Removed duplicate calls. doc/user_guide.texi Documented options. tests/warnings/duplicate_call.m tests/warnings/duplicate_call.exp Test duplicate call warning. |
||
|
|
f23324f5fa |
This change fixes two bugs, in quantification and liveness.
Estimated hours taken: 10 This change fixes two bugs, in quantification and liveness. I made the changes to the other files while trying to find them; they ought to be useful in trying to find similar bugs in the future. The compiler now bootstraps with agressive inlining enabled. quantification: Fix a bug that switched two different accumulators of the same type when processing pragma_c_codes. liveness: Fix a bug that could cause a variable to end up in both the post-death and post-birth set of the same goal. options: Reenable inlining. hlds_out, mercury_to_mercury: If -D v is given, include the number of each variable at the end of its name (e.g. Varname_20). The predicates involved (a few from mercury_to_mercury and many from hlds_out) now have an extra argument that says whether this should be done or not. (It is not done when printing clauses e.g. for .opt files.) The bug in quantification was causing the improper substitution of one variable for another, but both had the same name; such bugs would be very difficult to find without this change. constraint, det_report, intermod, make_hlds, mercury_to_c, mode_debug, mode_errors, module_qual, typecheck: Call predicates in hlds_out or mercury_to_mercury with the extra argument. saved_vars: Thread the io__state through this module to allow debugging. mercury_compile: Call saved_vars via its new interface. Fix an inadvertent use of an out-of-date ModuleInfo. goal_util, hlds_goal: Minor formatting cleanup. code_gen: Clean up the import sequence. |
||
|
|
0f1dd664fb |
Make the -D option take a string argument, which governs which
Estimated hours taken: 1.5 options: Make the -D option take a string argument, which governs which annotations will be printed in HLDS dumps. With an empty string as an argument, no annotations will be printed (this is the default). With the argment "all", all annotations will be printed. With any other argument value, what governs whether an annotation is printed is whether its identifying letter appears in the argument. These letters are: a - argument modes in unifications, b - builtin flags on calls, c - contexts of goals and types, d - determinism of goals, f - follow_vars sets of goals, i - instmap deltas of goals, n - nonlocal variables of goals, p - pre-birth, post-birth, pre-death and post-death sets of goals, r - resume points of goals, s - store maps of goals. hlds_out: Use the value of the argument of -D do decide what to print. handle_options: Turn -D all into what is expected by hlds_out. intermode, mercury_to_c: Update code that temporarily disables verbose dumps. |
||
|
|
37c5340f1c |
Added code to various sections of the compiler to parse
Estimated hours taken: 80 Added code to various sections of the compiler to parse `pragma fact_table' declarations and add them to the HLDS. Added output of fact_table dependencies to .d and .dep files. Added a new module fact_table.m for parsing the actual fact tables and generating code. This is not finished yet. Added ability to have `pragma c_code' declarations for Mercury functions. Modified Files: compiler/hlds_module.m Added predicate `module_info_set_pred_info' to add a `pred_info' entry to `module_info' given a `pred_id'. compiler/make_hlds.m Added code to handle new `pragma fact_table' declarations. New predicate `module_add_pragma_fact_table' which calls the fact compiler in fact_table.m to compile the fact table and generate C code to access it. Then add the C code to the HLDS as a `pragma c_code'. Mercury functions can now have `pragma c_code' declarations. compiler/intermod.m Included PredOrFunc argument in call to mercury_output_pragma_c_code. compiler/mercury_compile.m Added parameters to some predicates to allow fact table dependency information to be passed around. compiler/mercury_to_mercury.m Handle output of `pragma fact_table' declarations. Handle output of `pragma c_code' declarations for functions. compiler/module_qual.m Handle module qualification of `pragma fact_table' declarations. compiler/modules.m New predicate `get_fact_table_dependencies' to work out which fact tables a module depends on. Changes to `write_dependency_file' to write out fact table dependencies. Changes to some other predicates to allow fact table dependencies to be passed around the module. compiler/prog_data.m Added new functor `fact_table(sym_name, arity, string)' to the `pragma_type' type. Added a `pred_or_func' field to the `c_code' functor of the `pragma_type' type. compiler/prog_io.m Added code to `parse_pragma_type' to parse `:- pragma fact_table'. Here is a sample declaration. The facts are in a file called "factfile": :- pred facts(string, int, float). :- mode facts(out, out, out) is multidet. :- pragma fact_table(facts/3, "factfile"). Mercury functions can now have `pragma c_code' declarations. Here is a sample declaration: :- func c_add(int, int) = int. :- pragma c_code(non_recursive, c_add(A::in, B::in) = (C::out), " C = A + B; "). Added Files: compiler/fact_table.m Module not yet finished, but it compiles correctly and doesn't interfere with the rest of the compiler. Main purposes of the module are to parse the fact table file, perform type, mode and determinism checks and generate C code for the fact table. Completed so far: parsing, type and mode checking, determinism inference. A C array is output to represent the table, but no functions are produced yet to access it. |
||
|
|
dd4ab51822 |
Oops, should have committed this with my changes to inlining.m.
Estimated hours taken: 0.1 Oops, should have committed this with my changes to inlining.m. compiler/intermod.m: Change call to inlining__simple_goal to inlining__is_simple_goal, since the predicate has been renamed. |
||
|
|
ee24e66a71 |
Switch from using a stack of store_maps in the code_info to govern what
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. |
||
|
|
f6f5d41810 |
Bug fixes.
Estimated hours taken: 0.25 Bug fixes. compiler/intermod.m Fix a bug exposed by production of forwarding stubs for builtins - don't export clauses for builtins. compiler/modules.m Make the .c file depend on the .opt file for the current module. This is because the module is only type-checked without imported equivalence types being expanded while making the .opt file. |
||
|
|
fad6852e79 |
Simplify the source code a little.
Estimated hours taken: 0.25 compiler/intermod.m: Simplify the source code a little. |
||
|
|
2b4210f00f |
Improvements to intermodule optimization and bug fixes.
Estimated hours taken: 2 Improvements to intermodule optimization and bug fixes. compiler/intermod.m Return an error status from intermod__grab_optfiles instead of aborting on errors. Missing .opt files now result in a warning rather than an abort, since in some circumstances the .opt files for a library may not be available. Allow users to fiddle the cross-module inlining heuristic with --intermod-inline-simple-threshold. compiler/modules.m .c files now only depend on .opt files from the current directory. This allows building a --intermodule-optimization version of a program even when the .opt files for the library are unavailable. .opt files can now be built without the --intermodule-optimization flag being set when the dependencies were created. compiler/options.m --warn-missing-opt-files - warn about missing optimization interfaces. --intermod-inline-simple-threshold - same as --inline-simple-threshold except for intermodule optimization. Decreasing this without doing an mmake clean afterwards may result in link errors. Shifted --intermodule-optimization into the optimization level section. compiler/typecheck.m Predicates in .opt files should always be module qualified, and should be ignored when resolving overloading. compiler/unused_args.m Previously unused_args assumed polymorphism.m converted complicated_unifys into calls, but polymorphism is not run with --errorcheck-only. compiler/hlds_pred.m Document which items can have each particular import_status. scripts/Mmake.rules Stop the output of --make-optimization-interface going to the .err file. library/Mmake The library is compiled with --intermodule-optimization by default. The install target now installs the .opt files for the library. doc/user_guide.texi Shift --intermodule-optimization into the optimization level section. Document the new options. |