Commit Graph

18 Commits

Author SHA1 Message Date
David Overton
4f79ef0b59 Implement a change to the mode system suggested by Ralph Becket to make use of
Estimated hours taken: 12
Branches: main

Implement a change to the mode system suggested by Ralph Becket to make use of
higher order functions a bit easier.

During mode checking of higher order calls, if the variable being called has a
higher-order function type, but only a ground inst with no higher-order
information, assume that it has the default function modes.

Also, when doing anything that might cause a variable's inst to lose higher
order mode information, report a mode error if the variable has a non-standard
higher order function mode.  Situations where this may occur are at call sites,
exit sites and when merging insts at the end of a branched goal.

Note that because of this restriction, this change is not backwards compatible.

compiler/inst_util.m:
	Define some predicates to check for and produce pred_inst_infos for
	default function modes.
	In 'inst_merge', ensure that higher order inst information is not lost
	from non-standard function insts.

compiler/inst_match.m:
	In 'inst_matches_initial' and 'inst_matches_final', ensure that higher
	order inst information is not lost from non-standard function insts.
	Also allow 'inst_matches_{initial,final,binding}' to succeed
	where the first inst is a standard function inst and the
	second is ground.

compiler/modecheck_call.m:
	In 'modecheck_higher_order_call', if the variable to be called has no
	pred_inst_info, but the correct higher-order function type, assume it
	has the default function modes.

mode_util.m:
pd_util.m:
	Before replacing a ground inst with 'ground(Uniq, none)', ensure that it
	does not contain any nonstandard function insts.

tests/hard_coded/Mmakefile:
tests/hard_coded/ho_func_default_inst.m:
tests/hard_coded/ho_func_default_inst.exp:
tests/invalid/Mmakefile:
tests/invalid/ho_default_func_1.m:
tests/invalid/ho_default_func_1.err_exp:
tests/invalid/ho_default_func_2.m:
tests/invalid/ho_default_func_2.err_exp:
tests/invalid/ho_default_func_3.m:
tests/invalid/ho_default_func_3.err_exp:
	Add some test cases.

tests/invalid/Mmakefile:
tests/invalid/ho_default_func_4.m:
tests/invalid/ho_default_func_4.err_exp:
tests/invalid/inst_matches_final_bug.m:
tests/invalid/inst_matches_final_bug.err_exp:
	Add some test cases which we do not yet pass due to a bug in
	inst_matches_final.

NEWS:
doc/reference_manual.tex:
	Document the change.
2001-10-12 05:23:51 +00:00
David Overton
40bda1e4a0 Fix a bug in inst_merge when merging a ground inst with a bound inst
Estimated hours taken: 8
Branches: main

Fix a bug in inst_merge when merging a ground inst with a bound inst
containing 'any' insts.  Previously,

	inst_merge(ground, bound(f(..., any, ...)))

would return a result of 'any' which is not as accurate as we would
like (e.g. this problem occurs often in Mercury code generated by the
HAL compiler).  To improve this, we pass the type of the variable
being merged to inst_merge and when this situation arises we expand
'ground' to 'bound(<functors of type>)' and use this inst in the
merge.

An alternative to passing the types through inst_merge would be to
reinstate the use of 'typed_inst' and 'typed_ground' which are created
by (currently commented out) code in 'propagate_types_into_insts'.
However, this has previously been found to cause performance problems
since it greatly expands the size of all insts and instmaps in the
program.  The approach used here is the same as that adopted for
inst_matches_{initial,final} some time ago, where it does not appear
to have a noticeable performance impact on typical programs.

compiler/inst_util.m:
	Pass types through inst_merge and implement the changes to
	inst_merge(ground, bound(...)) described above.

compiler/inst_match.m:
compiler/instmap.m:
compiler/mode_util.m:
compiler/simplify.m:
	Pass types to calls to inst_merge.

compiler/inst_match.m:
compiler/type_util.m:
	Move 'maybe_get_cons_id_arg_types' and
	'maybe_get_higher_order_arg_types' from inst_match.m to
	type_util.m and export them.

compiler/mode_util.m:
	Export 'constructors_to_bound_insts'.

tests/valid/Mmakefile:
tests/valid/merge_ground_any.m :
	Add a regression test.

tests/invalid/Mmakefile:
tests/invalid/merge_ground_any.err_exp:
tests/invalid/merge_ground_any.m:
	Add a test to make sure the ground inst is expanded out to the
	full set of functors for the type.
2001-09-13 23:18:17 +00:00
Fergus Henderson
6107b040d9 Fix a bug reported by dgj.
Estimated hours taken: 1.5
Branches: main, release

Fix a bug reported by dgj.

compiler/inst_util.m:
	Fix a bug in inst_merge: it wasn't handling the case where a
	bound inst containing any insts was merged with a ground inst.
	That case should be allowed.

tests/valid/Mmakefile:
tests/valid/any_inst_merge.m:
	A regression test.
2001-03-30 06:04:27 +00:00
David Overton
82378c381b Allow polymorphic ground insts. This change assumes that all inst
Estimated hours taken: 80

Allow polymorphic ground insts.  This change assumes that all inst
parameters in the mode declaration for a predicate or function are
constrained to be ground-shared.  This is a temporary measure until we
work out a nice syntax to allow the programmer to tell the compiler that
certain inst parameters may be treated as ground insts.  Since we don't
currently support unconstrained inst parameters anyway, this shouldn't
cause a problem.

	TODO:
		- Add syntax, something like `:- mode p(in(I)) <= ground(I).',
		  to specify that an inst parameter represents a ground inst.
		- Allow abstract ground insts that are treated in a similar
		  way to what we've done here with ground inst parameters.
		- Make mode checking more efficient (i.e. rewrite the mode
		  system).

compiler/inst.m:
	Add a new alternative for ground insts:
		`constrained_inst_var(inst_var)'.
	Define the type `inst_var_sub'.

compiler/inst_match.m:
	Change inst_matches_initial so that it:
		- handles constrained_inst_vars correctly;
		- returns the inst_var substitutions necessary for the call;
		- handles inst_matches_initial(ground(...), bound(...), ...)
		  properly (this requires knowing the type of the variable).

	  The last change has also been made for inst_matches_final
	  and inst_matches_binding.  However, the check is disabled for
	  now because, without alias tracking, the mode checker
	  becomes too conservative.

compiler/hlds_pred.m:
compiler/mode_info.m:
compiler/simplify.m:
compiler/det_util.m:
	Include the inst_varset in the proc_info, mode_info and simplify_info.
	Add a vartypes field to the det_info.
	Remove the vartypes field from the simplify_info since it is
	now in the det_info.
	Use record syntax for these data structures and their access predicates
	to make future changes easier.

compiler/prog_io.m:
	When processing pred and func mode declarations, convert all inst_var(V)
	insts to ground(shared, constrained_inst_var(V)).

compiler/prog_data.m:
compiler/hlds_data.m:
compiler/make_hlds.m:
compiler/mode_util.m:
	Use inst_vars instead of inst_params.

compiler/modes.m:
compiler/modecheck_call.m:
compiler/unique_modes.m:
compiler/mode_util.m:
	When checking or recomputing initial insts of a call, build up
	an inst_var substitution (using the modified
	inst_matches_initial) and apply this to the final insts of the
	called procedure before checking/recomputing them.

compiler/mode_util.m:
	Make sure that recompute_instmap_delta recomputes the
	instmap_deltas for lambda_goals even when RecomputeAtomic = no.

compiler/type_util.m:
	Add a new predicate, type_util__cons_id_arg_types which
	nondeterministically returns the cons_ids and argument types for a
	given type.
	Add a new predicate type_util__get_consid_non_existential_arg_types
	which is the same as type_util__get_existential_arg_types except
	that it fails rather than aborting for existenially typed arguments.

compiler/accumulator.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/common.m:
compiler/continuation_info.m:
compiler/deforest.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/dnf.m:
compiler/follow_code.m:
compiler/goal_store.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_util.m:
compiler/instmap.m:
compiler/lambda.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/mercury_to_mercury.m:
compiler/modecheck_unify.m:
compiler/module_qual.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_io_util.m:
compiler/prog_rep.m:
compiler/saved_vars.m:
compiler/stack_layout.m:
compiler/table_gen.m:
compiler/unify_proc.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
	Pass inst_varsets and types where needed.
	Changes to reflect change in definition of the inst data type.

compiler/inlining.m:
	Recompute the instmap deltas for a procedure after inlining.
	This bug showed up compiling tests/hard_coded/lp.m with
	inlining and deforestation turned on: deforestation was
	getting incorrect instmap deltas from inlining, causing
	the transformation to break mode-correctness.  It has only
	just shown up because of the added call to
	`inst_matches_initial' from within `recompute_instmap_delta'.

tests/invalid/Mmakefile:
tests/invalid/unbound_inst_var.m:
tests/invalid/unbound_inst_var.err_exp:
tests/valid/Mmakefile:
tests/valid/unbound_inst_var.m:
	Move the `unbound_inst_var' test case from `invalid' to `valid'
	and extend its coverage a bit.
2000-10-13 13:56:17 +00:00
Zoltan Somogyi
ea605db104 Fix formatting of comment.
Estimated hours taken: 0.01

compiler/inst_util.m:
	Fix formatting of comment.
2000-08-25 06:29:44 +00:00
Fergus Henderson
0f911044c8 Fix a performance problem reported by Tom Conway,
Estimated hours taken: 10

Fix a performance problem reported by Tom Conway,
that caused the compiler to take forever when compiling
very simple test cases making use of user-defined insts.

compiler/inst_match.m:
compiler/inst_util.m:
	In the implementation of the procedures that traverse insts, e.g.
	inst_matches_initial, inst_matches_final, inst_is_ground, etc., ensure
	that we thread the set of already processed inst names through the
	code, i.e. pass it both in and out, rather than just passing it in.
	This ensures that we don't traverse the same inst name more than once
	for each call to one of those top-level procedures.
	The previous algorithm lead to an exponential performance
	blow-out.

	Also change mode_list_contains_inst_var so that it does not
	expand modes or defined_insts, but instead just returns the
	inst_vars that the mode list contains directly.

tests/valid/Mmakefile:
tests/valid/inst_perf_bug_1.m:
tests/valid/inst_perf_bug_2.m:
	Add a couple of regression tests, one for the performance bug
	that this change fixes, one for a similar performance bug that
	still remains even after this change.  For now only the first
	one is enabled.
2000-02-22 10:56:40 +00:00
Peter Ross
9622ec3bbe Fix bug where unification of two variables with identical bound inst
Estimated hours taken: 5

Fix bug where unification of two variables with identical bound inst
lists were incorrectly being inferred det.

tests/warnings/Mmakefile:
tests/warnings/det_infer_warning.exp:
tests/warnings/det_infer_warning.m:
    Test case to exercise the bug.

mercury/compiler/inst_util.m:
    Handle bound inst lists of length > 1 correctly.
1999-06-23 04:17:57 +00:00
Fergus Henderson
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.
1998-03-03 17:48:14 +00:00
Andrew Bromage
046f2afecb Fix a semantic hole. Previously, unique variables could be used
Estimated hours taken: 6

Fix a semantic hole.  Previously, unique variables could be used
as non-local variables inside a lambda goal and shared within that
lambda.  This fixes the problem by requiring that all non-local
vars to a lambda must be ground-shared.

compiler/modecheck_unify.m:
	Changes detailed above.

compiler/mode_errors.m:
	Add a new kind of mode error, mode_error_non_local_lambda_var.
	One small change to find_important_errors/3 to ensure that this
	error will be reported if the lambda is an implicit call argument
	unification.

compiler/inst_util.m:
	Export make_shared_inst_list/4 for use by modecheck_unify.m.

compiler/instmap.m:
	New predicate: instmap__set_vars/4, which sets multiple vars
	in an instmap.

tests/invalid/bind_var_errors.m:
tests/invalid/bind_var_errors.err_exp:
	Regression test.
1998-02-13 10:12:35 +00:00
Fergus Henderson
73131e8df3 Undo Zoltan's bogus update of all the copyright dates.
Estimated hours taken: 0.75

library/*.m:
compiler/*.m:
	Undo Zoltan's bogus update of all the copyright dates.
	The dates in the copyright header should reflect the years
	in which the file was modified (and no, changes to the
	copyright header itself don't count as modifications).
1998-01-23 12:57:08 +00:00
Zoltan Somogyi
bb4442ddc1 Update copyright dates for 1998.
Estimated hours taken: 0.5

compiler/*.m:
	Update copyright dates for 1998.
1998-01-13 10:06:08 +00:00
Andrew Bromage
80c1dc75cd Minor bug fix.
Estimated hours taken: 0.1

Minor bug fix.

compiler/inst_util.m:
	A dead unification between a pred inst and an any inst is
	dead for the purpose of computing the final uniqueness, not
	live.
1997-10-06 02:55:06 +00:00
Fergus Henderson
93a0e44731 Extend the handling of `any' insts.
Estimated hours taken: 1

Extend the handling of `any' insts.

compiler/inst_util.m:
	Change inst_merge to allow merging of `any' with `ground'.
	This is safe now that we assume that `any' insts and `ground'
	insts have the same representation.

compiler/inst_util.m:
compiler/inst_match.m:
	Change inst_matches_initial, inst_matches_final,
	and inst_merge to allow `free' insts to match with
	`any' in the case where the result is not live
	(i.e. it is a `clobbered' or `mostly_clobbered' any).
	This is safe even though `free' insts may be represented
	as uninitialized memory, because `clobbered' or `mostly_clobbered'
	inst guarantees that the memory will never be accessed.
1997-09-21 09:22:18 +00:00
Fergus Henderson
e37b6bc222 Extend the support for `any' insts.
Estimated hours taken: 2

Extend the support for `any' insts.

The compiler now assumes that the representation of `ground' or `bound'
insts is the same as for `any' insts, but in return it is possible to
mix these insts without the user having to provide explicit conversions
between different representations.

compiler/inst_match.m:
	Allow `ground' or `bound' insts to be passed or returned where `any'
	is expected.

compiler/inst_util.m:
	Allow unification of `any' insts with `any' or `bound' or `ground'
	insts.

compiler/unify_proc.m:
	Use the `in_in' unification proc id (i.e. proc 0) for
	unifications between `any' and `any' or `any' and `ground',
	as well as for `ground' and `ground'.  This should be safe,
	I think, since the representation of `ground' and `any' is
	required to be the same.
1997-09-15 13:47:09 +00:00
Fergus Henderson
c56d92d1de Fix a bug where the compiler reported an internal error `unify_inst failed'
Estimated hours taken: 6

Fix a bug where the compiler reported an internal error `unify_inst failed'
for certain ill-moded calls involving `any' insts.

compiler/inst_util.m:
	Add code in abstractly_unify_inst to handle some more cases
	of `any' that previously we didn't allow; specifically, the case
	of unifying a `bound' or `ground' inst with `any'.
	The new cases are allowed only in the `fake_unify' case, not in
	the `real_unify' case, because code generation doesn't yet
	support these cases.

	Also fix a couple of unrelated bugs in abstractly_unify_inst
	where the `live' case was passing `dead' rather than `live'
	to unify_uniq.

compiler/prog_data.m:
	Add a new compiler-generated inst name `any_inst', similar to
	`ground_inst', but for insts resulting from unification with
	`any' rather than unification with `ground'.

compiler/hlds_data.m:
	Any a new `any_inst' table, similar to the `ground_inst' table.

compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/mode_qual.m:
	Minor changes to handle new `any_inst' insts.

tests/invalid/Mmake:
tests/invalid/any_mode.m:
tests/invalid/any_mode.err_exp:
	Regression test for the above change.
1997-09-14 09:24:30 +00:00
Andrew Bromage
b539cb29f7 Better handling of abstract unification of insts which always fail.
Estimated hours taken: 8

Better handling of abstract unification of insts which always fail.

compiler/det_analysis.m:
	New predicate det_par_conjunction_detism/3 to compute the
	determinism of parallel conjunctions (or virtual parallel
	conjunctions).

compiler/hlds_data.m:
	Make the ground_inst_table store the determinism of the
	grounding operation.  The reason for this is that
	make_ground_inst* now returns the determinism of the
	grounding operation, and so it makes sense to store the
	determinisms along with cached groundings to avoid
	recomputing them.

compiler/inst_util.m:
	Add a new argument to return the determinism of the
	unification/grounding to the following predicates:

		abstractly_unify_inst_functor
		abstractly_unify_bound_inst_list
		abstractly_unify_bound_inst_list_lives
		abstractly_unify_inst_list_lives
		make_ground_inst_list_lives
		make_ground_inst_list
		make_ground_inst
		make_ground_bound_inst_list

	This is to make it easier to locate unifications which
	cannot succeed.

compiler/instmap.m:
	If you attempt to insert a not_reached into an instmap, the
	entire instmap becomes unreachable.

compiler/modecheck_unify.m:
	Slight reorganisation of code dealing with var-functor
	unifications.  Simple optimisations have been moved to
	modecheck_unify_functor.

	All unifications which definitely fail are now optimised
	to `fail'.

compiler/mode_util.m:
	Minor change to support the alteration to the ground_inst_table
	above.

tests/valid/Mmake:
tests/valid/empty_bound_inst_list.m:
	Test case.
1997-08-21 07:29:35 +00:00
Fergus Henderson
04b720630b Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne".
1997-07-27 15:09:59 +00:00
Andrew Bromage
11d52a2ac5 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.
1997-07-24 02:21:18 +00:00