Commit Graph

52 Commits

Author SHA1 Message Date
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
Peter Schachte
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.
1997-12-09 04:02:47 +00:00
Fergus Henderson
9fc30fa8bb Change unique mode analysis (unique_modes.m) so that it does the same
Estimated hours taken: 4

Change unique mode analysis (unique_modes.m) so that it does the same
fixpoint analysis that ordinary mode analysis (modes.m) does.

This is a first step towards mode inference of "mostly-unique" modes.
Unique mode analysis still won't introduce any new modes, but it may
now change the final insts of inferred modes from `unique' to `mostly_unique'.

The next step (not included in this diff) will be to change the handling of
calls in unique_modes.m so that it does introduce new modes.

Also change things so that the inferred modes are normally printed
only after unique mode analysis, with determinism annotations attached.

compiler/modes.m:
	Add an extra WhatToCheck parameter to lots of predicates,
	so they can also be used for checking unique modes.
	Add a few small new bits of code to handle the
	`WhatToCheck = check_unique_modes' case.

compiler/unique_modes.m:
	Call the routines in modes.m rather than special casing things.
	The checking of goals is still special-cased, since for
	example unique_modes does not do reordering, but the traversal
	of modules and procedures now uses code from modes.m.

compiler/mode_errors.m:
	Add an extra bool parameter to write_mode_inference_messages
	indicating whether or not to print determinism annotations.

tests/valid/Mmakefile:
tests/valid/mostly_uniq_mode_inf.m:
	Test case for the above change.
1997-11-24 23:10:38 +00:00
Fergus Henderson
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.
1997-11-24 07:27:14 +00:00
Fergus Henderson
115b71f83b Report an error for duplicate mode declarations.
Estimated hours taken: 3

Report an error for duplicate mode declarations.

compiler/modes.m:
	Check for duplicate mode declarations.

compiler/modecheck_call.m:
	Add new predicate modes_are_indistinguishable, for use by modes.m.

compiler/mode_errors.m:
	Add predicate report_indistinguishable_mode_error to mode_errors.m,
	so that modes.m can use it to report duplicate mode declarations.

compiler/mode_errors.m:
compiler/mercury_to_mercury.m:
	Move some code in mode_errors.m into a new predicate
	mercury_output_mode_subdecls/8 in mercury_to_mercury.m.

compiler/make_hlds.m:
	Update a few comments.

tests/invalid/Mmakefile:
tests/invalid/duplicate_modes.m:
tests/invalid/duplicate_modes.err_exp:
	Test cases for the above change.
1997-11-23 05:18:41 +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
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.
1997-07-24 01:27:21 +00:00
Simon Taylor
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.
1997-06-29 23:11:42 +00:00
Simon Taylor
59b24959da Use the declared modes when writing error messages.
Estimated hours taken: 0.5

compiler/det_report.m
compiler/mode_errors.m
	Use the declared modes when writing error messages.

compiler/hlds_pred.m
	Added a predicate proc_info_declared_argmodes which
	returns the declared modes if they exist, returning
	the inferred modes otherwise.
1997-04-23 01:02:37 +00:00
Fergus Henderson
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.
1997-02-23 06:08:34 +00:00
Simon Taylor
1839ebb663 Module qualification of constructors.
Estimated hours taken: 15

Module qualification of constructors.

compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/modecheck_call.m
	Enable propagate_type_info_into_modes.
	Use type information to module qualify cons_ids.

compiler/mode_util.m
	Use propagate_type_information_into_modes to module qualify cons_ids
	in bound insts.
	typed_ground/2 and free/1 insts are not yet generated, since they
	are not yet used anywhere.
	Avoid expanding insts when propagating type information, since
	that is not yet useful.
	I still need to fix the handling of
		inst_matches_{initial, final, binding}(
			ground(_, _), bound(_, [all_functors_in_the_type]))

compiler/typecheck.m
	Don't assume a module qualified cons_id is a function call
	or higher-order pred constant.

compiler/modes.m
compiler/unique_modes.m
compiler/modecheck_unify.m
compiler/instmap.m
compiler/inst_match.m
	Remove some unnecessary conversion between cons_ids and consts.

compiler/typecheck.m
compiler/mode_errors.m
	Strip builtin qualifiers from cons_ids.

compiler/mercury_to_mercury.m
	Output module qualified cons_ids.

compiler/prog_io.m
compiler/prog_io_util.m
	Module qualify constructors in type definitions.
	Parse qualified cons_ids in bound insts.

compiler/hlds_data.m
	Remove cons_id_to_const/3, since it doesn't make much sense any more.
	Add cons_id_arity/2 and cons_id_and_args_to_term/3.

compiler/make_hlds.m
	Add both qualified and unqualified versions of each cons_id to
	the cons_table.

compiler/det_util.m
	Handle module qualified cons_ids in det_util__interpret_unify.

compiler/code_util.m
	Remove some dead code in code_util__cons_id_to_tag to do with
	tags for higher-order terms. Don't assume module qualified
	cons_ids are higher-order pred constants.

compiler/polymorphism.m
	Module qualify type_info cons_ids.
1997-02-17 01:27:10 +00:00
Zoltan Somogyi
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.
1996-12-30 11:31:17 +00:00
Zoltan Somogyi
e9cbb5c329 Add a new option, --assume-gmake. Rename the existing option
Estimated hours taken: 5

options:
	Add a new option, --assume-gmake. Rename the existing option
	--optimize-constructor-recursion to --optimize-constructor-last-call,
	since it also affects last calls that are not recursive calls.

modules.m
	If --assume-gmake is set, exploit the capabilities of gmake
	to produce significantly smaller .dep files (about 10% the size
	of the ones we produced before for mercury_compile).

mercury_compile:
	Change --optimize-constructor-recursion to
	--optimize-constructor-last-call.

hlds_out:
	Clean up the way we produce HLDS dumps. The new algorithm eliminates
	lines containing nothing but white space or a single comma or dot
	in procedure definitions. It should also be easier to modify.

constraint, mode_errors:
	Use the new interface of a predicate in hlds_out.

livemap:
	Make a predicate more self-contained.
1996-11-21 08:38:39 +00:00
Fergus Henderson
82e205e5bd Change the "In clause for `foo(in, out)'" message
Estimated hours taken: 1

mode_errors.m:
	Change the "In clause for `foo(in, out)'" message
	so that it handles functions properly, i.e as
	"In clause for `foo(in) = out'".
1996-11-07 17:50:57 +00:00
Andrew Bromage
5c149e55b2 Mode analyser reorganisation.
Estimated hours taken: 20

Mode analyser reorganisation.

compiler/mode_util.m:
	Removed: instmap_init/1,  apply_instmap_delta/3, instmap_lookup_var/3,
	instmapping_lookup_var/3, instmap_restrict/3, map_restrict/3 (all
	moved to instmap.m).

compiler/hlds_goal.m:
	Removed the declarations of instmap_delta, instmap and instmapping.

compiler/mode_errors.m:
	Added report_mode_errors/2 (was modecheck_report_errors, from
	modes.m).

compiler/modes.m:
	Predicates now exported:
		modecheck_goal/4
		modecheck_goal_expr/5 (previously named modecheck_goal_2/5)
		handle_extra_goals/8
		mode_context_to_unify_context/3

	Moved to mode_errors.m:
		modecheck_report_errors/2

	Moved to instmap.m:
		compute_instmap_delta/4
		instmap_merge/3
		instmap_lookup_vars (was instmap_lookup_arg_list/3)
		compute_instmap_delta/4

	Moved to mode_debug.m:
		Type port/0
		mode_checkpoint/4

	Moved to modecheck_call.m:
		modecheck_call_pred/7
		modecheck_higher_order_call/10
		modecheck_higher_order_pred_call/4
		modecheck_higher_order_func_call/7

	Moved to modecheck_unify.m:
		modecheck_unification/9
		categorize_unify_var_var/12
		categorize_unify_var_functor/11
		categorize_unify_var_lambda/9

	Moved to mode_info.m:
		mode_info_error/4
		mode_info_add_error/3

compiler/code_gen.pp, compiler/code_info.m, compiler/constraint.m,
compiler/cse_detection.m, compiler/det_analysis.m, compiler/det_util.m,
compiler/dnf.m, compiler/goal_util.m, compiler/higher_order.m,
compiler/hlds_out.m, compiler/hlds_pred.m, compiler/live_vars.m,
compiler/liveness.m, compiler/lookup_switch.m, compiler/polymorphism.m,
compiler/simplify.m, compiler/store_alloc.m, compiler/switch_detection.m,
compiler/transform.m, compiler/unused_args.m:
	Imported instmap.m

New files:

compiler/instmap.m:
	Handle operations associated with instmaps.

compiler/modecheck_unify.m:
	Handle mode checking of unifications.

compiler/modecheck_call.m:
	Handle mode checking of calls

compiler/mode_debug.m:
        Code to trace the actions of the mode checker.
1996-10-17 05:28:01 +00:00
Fergus Henderson
79b8104db1 Improve error messages from determinism analysis.
Estimated hours taken: 4

Improve error messages from determinism analysis.

mode_errors.m, mode_util.m:
	Move the predicate strip_builtin_qualifiers_from_mode_list
	from mode_errors.m to mode_util.m so that it can be used
	by det_report.m.  Also, change it so that it strips off
	qualifiers nested inside bound insts, higher-order modes, etc.
	(previously it only stripped the top-level modes).

det_report.m:
	Call strip_builtin_qualifiers_from_mode_list, to remove the
	`mercury_builtin:' qualifiers on built-in modes such as `in', etc.
	Make sure that determinism errors in function calls are reported
	as being in the function call, not in the containing unification
	(I got a misleading error message along those lines that confused me).
	Make sure that capital letters are NOT used for lines
	that are NOT the first line in the error message.

det_report.m, hlds_out.m:
	Make sure that capital letters ARE used for lines
	that ARE the first line in the error message.
1996-06-28 17:37:13 +00:00
Simon Taylor
5d9e4158f7 Module qualification of types, insts and modes.
Estimated hours taken: 45

Module qualification of types, insts and modes.

Added a new interface file - <module>.int3. This contains the
short interface qualified as much as possible given the information
in the current module.

When producing the .int and .int2 files for a module, the compiler uses
the information in the .int3 files of modules imported in the interface
to fully module qualify all items. The .int2 file is just a fully
qualified version of the .int3 file. The .int3 file cannot be overwritten
by the fully qualified version in the .int2 file because then mmake would
not be able to tell when the interface files that depend on that .int3
file really need updating.

The --warn-interface-imports option can be used to check whether
a module imported in the interface really needs to be imported in
the interface.


compiler/module_qual.m
Module qualify all types, insts and modes. Also checks for modules
imported in the interface of a module that do not need to be.

compiler/modules.m
The .int file for a module now depends on the .int3 files of imported
modules. Added code to generate the make rule for the .int file in the
.d file. There is now a file .date2 which records the last time the
.int2 file was updated.
The .int3 files are made using the --make-short-interface option
introduced a few weeks ago.

compiler/options.m
Added option --warn-interface-imports to enable warning about interface
imports which need not be in the interface. This is off by default
because a lot of modules in the library import list.m when they only
need the type list, which is defined in mercury_builtin.m.
Removed option --builtin-module, since the mercury_builtin name is wired
into the compiler in a large number of places.

compiler/prog_util.m
Added a predicates construct_qualified_term/3 and construct_qualfied_term/4
which take a sym_name, a list of argument term and a context for the /4
version and give a :/2 term.

compiler/type_util.m
Modified type_to_type_id to handle qualified types. Also added predicates
construct_type/3 and construct_type/4 which take a sym_name and a list of
types and return a type by calling prog_util:construct_qualified_term.

compiler/modes.m
On the first iteration of mode analysis, module qualify the modes of
lambda expressions.

compiler/mode_info.m
Added field to mode_info used to decide whether or not to module qualify
lambda expressions.

compiler/mode_errors.m
Added dummy mode error for when module qualification fails so that mode
analysis will stop.
Added code to strip mercury_builtin qualifiers from error messages to
improve readability.

compiler/typecheck.m
Strip builtin qualifiers from error messages.

compiler/llds.m
compiler/llds_out.m
compiler/opt_util.m
compiler/opt_debug.m
Change the format of labels produced for the predicates to use the
qualified version of the type name.

compiler/mercury_compile.pp
Call module_qual__module_qualify_items and make_short_interface.
Remove references to undef_modes.m and undef_types.m

compiler/undef_modes.m
compiler/undef_types.m
Removed, since their functionality is now in module_qual.m.

compiler/prog_io.m
Changed to qualify the subjects of type, mode and inst declarations.

compiler/*.m
Changes to stop various parts of the compiler from throwing away
module qualifiers.
Qualified various mercury_builtin builtins, e.g. in, out, term etc.
where they are wired in to the compiler.

compiler/hlds_data.m
The mode_table and user_inst_table are now abstract types each
storing the {mode | inst}_id to hlds__{mode | inst}_defn maps
and a list of mode_ids or inst_ids. This was done to improve the
efficiency of module qualifying the modes of lambda expressions
during mode analysis.
module_info_optimize/2 now sorts the lists of ids.
The hlds_module interface to the mode and inst tables has not changed.

compiler/hlds_module.m
Added yet another predicate to search the predicate table.
predicate_table_search_pf_sym_arity searches for predicates or
functions matching the given sym_name, arity and pred_or_func.

compiler/higher_order.m
Changed calls to solutions/2 to list__filter/3. Eliminated unnecessary
requantification of goals.

compiler/unused_args.m
Improved abstraction slightly.
1996-06-11 06:30:10 +00:00
Fergus Henderson
0ac3ffa304 Four loosely related changes to improve mode inference.
Estimated hours taken: 12

Four loosely related changes to improve mode inference.

--------------------

(1) Fix a problem with inference of unique modes.

Previously it was sufficient to just look at the final insts of the
mode and check whether they were `clobbered' or not in order to tell
which arguments will be dead on exit from this procedure.  However,
that doesn't work for inferred modes, where the final inst will
initially be `not_reached'.  Previously mode inference just assumed that
all arguments to a predicate were live, but that prevents it from being
able to infer `di' modes.  So I've added a new field to the proc_info
to record which arguments are required to be dead on exit.
I've also changed mode analysis so that it checks that such
arguments really are dead.  This means you can declare both `di' and
`ui' modes of a predicate, and so long as you declare the `di' one
first, mode checking should handle this overloading.  It also means
that errors such as passing a variable which is live to a procedure with
a `di' mode argument are caught earlier, with a potentially better
error message; mode checking may also be able to reorder such calls,
so that the `di' mode pred is scheduled last.  Mode inference now
notices if an argument is dead, and if so will try infering a `di'
mode.

hlds_pred.m:
	Add a new field to the proc_info, the `maybe_arglives', of type
	`maybe(list(is_live))'.  If set, this records whether or not the
	arguments are required to be dead after the procedure or not.
	Add an access predicate which checks whether this is set,
	and returns either the value set, or if no value special value
	is set, looks up a value based on the modes by calling get_arg_lives
	from mode_util.m.

make_hlds.m:
	Add a MaybeArgLives parameter to add_new_pred.
	(Also change the error messages about pragmas to reflect
	the new pragma syntax.)

clause_to_proc.m, unify_proc.m:
	Pass MaybeArgLives = no to add_new_pred.

modes.m, mode_errors.m:
	Use the new arglives field.  When mode-checking a call (or
	higher-order call), check that all the variables which are
	required to be dead really are dead.

unique_modes.m:
	Use the new arglives field.

mode_util.m:
	Add predicate `get_arg_lives', for use by modes.m and hlds_pred.m.

--------------------

(2) Fix a problem with mode inference looping.

It was checking whether a fixpoint had been reached by comparing the
(un-normalised) inferred final insts with the previously recorded final
insts (which had been normalised).  Instead, it has to normalise the
insts before the comparison.

modes.m:
	When doing mode analysis of an inferred mode, normalise the insts
	before checking whether they've changed, rather than vice versa.

--------------------

(3) Fix a problem with the computation of liveness for mode-analysis
of if-then-elses that was detected when I tried to bootcheck the above
changes.

modes.m, unique_modes.m:
	When mode-checking if-then-elses, the variables in the "else"
	should not be considered live when checking the condition.
	(They're nondet-live, but not live with regard to forward execution.)

--------------------

(4) Reduce the occurrence of mode inference inferring spurious
`in(not_reached)' modes.

modes.m:
	If the top-level inst of a variable becomes `not_reached', set
	the whole instmap to `unreachable'.
1996-05-27 17:15:08 +00:00
Fergus Henderson
81f9959dc3 Fix the handling of error message contexts for mode errors
Estimated hours taken: 4

compiler/{mode_errors.m,mode_info.m,modes.m,unique_modes.m}:
	Fix the handling of error message contexts for mode errors
	so that it does say `in call to predicate foo/2' when it
	means `in call to function foo/1'.
1996-05-26 08:01:09 +00:00
Fergus Henderson
8496c71b04 Add preliminary support for mode inference.
Estimated hours taken: 24

Add preliminary support for mode inference.

hlds_pred.m, hlds_out.m:
	Add a new pred marker `infer_modes'.

make_hlds.m:
	If there are no declared modes for a predicate,
	set the `infer_modes' marker in the pred_info.

modes.m:
	Implement mode inference.

	When we see a call to a predicate with the `infer_modes' marker
	set, then if the call does not match any of the modes we've
	already inferred for the predicate, create a new inferred mode;
	the initial insts are set to the normalised argument insts, and
	the final insts are initially set to not_reached.  When
	analysing such a predicate, rather than checking whether the
	inferred final insts match the declared final insts, just
	replace the old final insts with the normalised version of the
	newly inferred insts.  Change the top-level to repeat mode
	analysis until a fixpoint is reached.  We need to "normalise"
	insts to a bounded approximation avoid non-termination due to
	infinite expansion.

	Also fix a bug which meant that using `inst constrained == any.'
	didn't work - the checks for `any' weren't calling `inst_expand'.

mode_util.m:
	Change the predicates `inst_is_ground', `inst_is_unique', etc.
	so that they consider `not_reached' insts to satisfy the
	condition.

mode_errors.m:
	Change the message for predicates with no mode declaration.
	Add code for printing out inferred mode declarations.

clause_to_proc.m:
	Add a new predicate copy_module_clauses_to_procs
	to call copy_clauses_to_procs for a list of pred_ids.
	We call this from modes.m at the start of each fixpoint iteration.
1996-05-25 05:25:17 +00:00
Fergus Henderson
60b9fa83b6 Implement higher-order functions.
Estimated hours taken: 12

Implement higher-order functions.

Add higher-order function terms
(function lambda expressions, e.g. `Func = (func(X) = Y :- Y is 2 * X)'
and higher-order function calls (apply/N, e.g. `Z = apply(Func, 42)').
Add higher-order function insts and modes.

hlds_goal.m:
	Add a new field pred_or_func to lambda_goal.

prog_data.m:
	Add a new field pred_or_func to pred_inst_info.

prog_io.m:
	Add support for parsing higher-order function terms and
	higher-order function insts and modes.

make_hlds.m:
	Add support for parsing higher-order function terms.

typecheck.m:
	Add support for type-checking higher-order function calls
	and higher-order function terms.

modes.m, mode_errors.m:
	Add support for mode-checking higher-order function calls
	and higher-order function terms.

higher_order.m:
	Handle higher-order function types and insts.

hlds_pred.m:
	Add new predicate pred_args_to_func_args, for extracting the
	function arguments and function return from the arguments
	of a predicate that is really a function.

*.m:
	Minor changes to handle new pred_or_func field in lambda_goals
	and pred_inst_infos.
1996-05-14 10:07:46 +00:00
Fergus Henderson
9a7da88ce0 Treat higher-order predicate calls as a new sort of goal,
Estimated hours taken: 24

Treat higher-order predicate calls as a new sort of goal,
rather than as calls to the special predicate call/N, in order to
remove the fixed limit on the number of arguments and on the modes
for call/N.

Also, remove the restriction on output arguments preceding input arguments
in lambda expressions.

hlds_goal.m:
	Add new functor higher_order_call/6 to the hlds__goal type.

*.m:
	Handle new functor higher_order_call/6.

arg_info.m:
	Abstract things a bit more: the argument passing convention
	for a procedure may be affected by that procedure's types,
	modes, and code_model, as well as the arg_method.

follow_vars.m:
	Pass down the args_method, since it is now needed for figuring
	out the arg_info for unifications and higher-order calls.

follow_code.m:
	Treat complicated unifications in the same way as calls.

lambda.m:
	When creating lambda predicates, permute the arguments so
	that all input arguments come before all output arguments.

call_gen.m:
	When generating higher-order predicate calls, don't abort
	if outputs precede inputs; instead, generate code assuming
	that the called predicate's args have been permuted so that
	the inputs to come before all the outputs.
1996-05-02 22:44:50 +00:00
Zoltan Somogyi
649b6908c3 Rename branch_delay_slot to have_delay_slot.
Estimated hours taken: 8

options.m:
	Rename branch_delay_slot to have_delay_slot.
	Set optimize_delay_slot in -O2 only if have_delay_slot was set earlier.
	This is possible now because the default optimization level is now
	set in mc.

mercury_compile:
	Change verbose output a bit to be more consistent.

dead_proc_elim:
	Export the predicates that will eventually be needed by inlining.m.

inlining.m:
	Use the information about the number of times each procedure is called
	to inline local nonrecursive procedures that are called exactly once.
	EXCEPT that this is turned off at the moment, since the inlining of
	parse_dcg_goal_2 in prog_io, which this change enables, causes the
	compiler to emit incorrect code.

prog_io:
	Moved the data type definitions to prog_data. (Even though prog_io.m
	is ten times the size of prog_data.m, the sizes of the .c files are
	not too dissimilar.)
1996-04-24 01:00:23 +00:00
Fergus Henderson
6a338a4ce8 A bunch of cleanups: improve error messages, tidy up the code.
Estimated hours taken: 3

A bunch of cleanups: improve error messages, tidy up the code.
Also, do some work towards supporting higher-order functions.

type_util.m:
	Add new predicate type_is_higher_order/3 for checking
	whether a type is a higher-order type.  This recognizes
	both higher-order predicate types and also higher-order
	function types.

code_info.m, modes.m, polymorphism.m, shapes.m:
	Use type_is_higher_order/3.

make_hlds.m:
	Fix another error message to do the right thing when
	reporting errors for functions.

mercury_to_mercury:
	List `func' in the table of operators, so that it gets
	parenthesized correctly.

modes.m, mode_errors.m:
	Improve the error message for attempted higher-order unifications:
	spit out some context, and if verbose_errors is enabled, spit
	out a long description.
1996-04-05 18:19:17 +00:00
Zoltan Somogyi
2833bfffb7 Divided the old hlds.m into four files:
Estimated hours taken: 10

hlds, hlds_module, hlds_pred, hlds_goal, hlds_data:
	Divided the old hlds.m into four files:

	hlds_module.m defines the data structures that deal with issues
	that are wider than a single predicate. These data structures are
	the module_info structure, dependency_info, the predicate table
	and the shape table.

	hlds_pred.m defined pred_info and proc_info, pred_id and proc_id.

	hlds_goal.m defines hlds__goal, hlds__goal_{expr,info}, and the
	other parts of goal structures.

	hlsd_data.m defines the HLDS types that deal with issues related
	to data and its representation: function symbols, types, insts, modes.
	It also defines the types related to determinism.

	hlds.m is now an empty module. I have not removed it from CVS
	because we may need the name hlds.m again, and CVS does not like
	the reuse of a name once removed.

other modules:
	Import the necessary part of hlds.

det_analysis:
	Define a type that was up to now improperly defined in hlds.m.

prog_io:
	Move the definition of type determinism to hlds_data. This decision
	may need to be revisited when prog_io is broken up.

dnf, lambda:
	Simplify the task of defining predicates.

llds:
	Fix some comments.

mercury_compile:
	If the option -d all is given, dump all HLDS stages.

shape, unused_args:
	Fix formatting.
1996-04-02 12:12:24 +00:00
Fergus Henderson
6d7f4b9b30 Undo dylan's changes in the names of some library entities,
Estimated hours taken: 1.5

Undo dylan's changes in the names of some library entities,
by applying the following sed script

	s/term_atom/term__atom/g
	s/term_string/term__string/g
	s/term_integer/term__integer/g
	s/term_float/term__float/g
	s/term_context/term__context/g
	s/term_functor/term__functor/g
	s/term_variable/term__variable/g
	s/_term__/_term_/g
	s/std_util__bool_/bool__/g

to all the `.m' and `.pp' files in the compiler and library directories.
The reason for undoing these changes was to minimize incompatibilities
with 0.4 (and besides, the changes were not a really good idea in the first
place).

I also moved `bool' to a separate module.
The main reason for that change is to ensure that the `__' prefix is
only used when it genuinely represents a module qualifier.
(That's what dylan's changes were trying to acheive, but `term__'
does genuinely represent a module qualifier.)

compiler/*.m:
	Apply sed script above;
	where appropriate, add `bool' to the list of imported modules.
1996-02-03 17:30:14 +00:00
Dylan Shuttleworth
3ab8d92226 Change names with badly placed double underscores (ie where the part of
Estimated hours taken: _2___

Change names with badly placed double underscores (ie where the part of
a name before a double underscore is not the same as the module name.)

Reflect changes in the library interface.

compiler/*:
	Use the newer, more correct form of the term and bool names.
	Predicates "bool__" are now "std_util__bool" and labels of
	the term ADT are now "term_" instead of "term__".

compiler/vn*.m:
	change all names "vn__*" to a correct module prefix.  All the
	names remain qualified.

compiler/hlds.m:
	s/\<is_builtin__/hlds__is_builtin_/g
	s/\<dependency_info__/hlds__dependency_info_/g

compiler/unify_proc.m:
	s/\<unify_proc_info__/unify_proc__info_/g

compiler/transform.m:
	s/\<reschedule__conj/transform__reschedule_conj/g
1995-12-29 03:45:20 +00:00
Zoltan Somogyi
3224e94532 A new pass to remove unnecessary assignment unifications.
excess:
	A new pass to remove unnecessary assignment unifications.

mercury_compile:
	Call the new excess assignment module.

options:
	Add a new option, excess_assign, to control the new optimization.
	Add another, num-real-regs, to specify how many of r1, r2 etc are
	actually real registers. The default is now set to 5 for kryten;
	later it should be supplied by the mc script, with a value determined
	at configuration time.

tag_switch:
	Use num-real-regs to figure out whether it is likely to be worthwhile
	to eliminate the common subexpression of taking the primary tag of
	a variable. Also fix an old performance bug: the test for when a
	jump table is worthwhile was reversed.

value_number, vn_block:
	Do value numbering on extended basic blocks, not basic blocks.

vn_debug:
	Modify an information message.

labelopt:
	Clean up an export an internal predicate for value numbering. Replace
	bintree_set with set.

middle_rec:
	Prepare for the generalization of middle recursion optimization
	to include predicates with an if-then-else structure.

cse_detection:
	Fix a bug: when hoisting a common desconstruction X = f(Yi), create
	new variables for the Yi. This avoids problems with any of the Yis
	appearing in other branches of the code.

goal_util:
	Add a new predicate for use by cse_detection.

common:
	Fix a bug: recompute instmap deltas, since they may be affected by the
	optimization of common structures.

code_info:
	Make an error message more explicit.

det_analysis:
	Restrict import list to the needed modules.

*.m:
	Import assoc_list.
1995-10-27 09:39:28 +00:00
Fergus Henderson
c42a89455e Fix unique mode errors detected by the compiler's stricter checking.
compiler/{mode_errors.m,mode_info.m,modes.m,typecheck.m}:
	Fix unique mode errors detected by the compiler's stricter checking.
1995-10-09 17:07:17 +00:00
Fergus Henderson
4e7467563d Change the heuristic for reporting mode errors, so that
compiler/mode_errors.m:
	Change the heuristic for reporting mode errors, so that
	it will hopefully pick the right error to report more
	often.  This change is in response to a bug report from
	Philip Dart.
1995-10-05 11:17:17 +00:00
Fergus Henderson
f8dd293cd7 Finish implementing mode checking of lambda expressions.
modes.m, mode_errors.m, mode_util.m:
	Finish implementing mode checking of lambda expressions.

inst_match.m:
	Mode checking of higher-order pred modes was slightly
	too strict - relax it a little.

modes.m, mode_errors.m, mode_info.m:
	For mode errors that occur in predicate calls,
	record the argument number that they occurred in,
	and print it out in mode error messages.
	(This also fixes a bug where some of the determinism
	error messages would say "in argument 0 of call to pred ...").

polymorphism.m:
	A couple of minor simplifications.
1995-08-27 17:27:18 +00:00
Zoltan Somogyi
0bc196dbdd Cleanup of the option set. Main change is making linking the default,
options:
	Cleanup of the option set. Main change is making linking the default,
	and the replacement of -g, --compile and --link by -e, -C and -c.
	WARNING: this makes the compiler inconsistent with the standard mmake
	configuration, so don't do a cvs update yet unless you know what you
	are doing.

conf:
	Find out at configuration time how many bits the --tags low option
	uses.

mercury_compile:
	With the help of conf, we now make sure --tags and --num-tag-bits
	are consistent. We use the new set of options. We also generate
	program-specific .clean rules in .dep files.

make_tags:
	Mercury_compile now makes sure that --tags and --num-tag-bits are
	consistent, so make_tags need not do it.

mode_errors:
	Use the new set of options.

llds:
	Changes to introduce the new option use_macro_for_redo_fail and
	change --mod-comments into --auto-comments.

cse_detection:
	We now print the messages about redoing mode analysis, switch detection
	and cse detection only if very verbose is on.

typecheck:
	The error message for wrong number of arguments now gives the actual
	number and the right number(s).

value_number:
	Tighten the sanity check; theold version wasn't tight enough for
	the code generated for prof.m.
1995-07-12 15:11:00 +00:00
Andrew Bromage
9dddf14a3f OK, finally, everything should be back in order. 1995-07-05 23:38:32 +00:00
Andrew Bromage
fda56846cb With any luck, this should be the call_graph branch successfully
merged.  Do not use --constraint-propagation, because it doesn't
schedule conjunctions properly yet.
1995-07-04 03:15:30 +00:00
Fergus Henderson
0713ab1575 Change the type of the first two arguments of unify/5 in
hlds.m and lots of other files:
	Change the type of the first two arguments of unify/5 in
	hlds__goal_expr from `term, term' to `var, unify_rhs'
	where unify_rhs is given by

		:- type unify_rhs
			--->	var(var)
			;	functor(const, list(var))
			;	lambda_goal(list(var), hlds__goal).

	This change was for two reasons: firstly, it simplifies the
	code in a lot of places, and secondly, it is a step towards
	implementing lambda closures and higher-order predicates
	properly.
1995-06-25 13:47:14 +00:00
Zoltan Somogyi
0f46c5d4e7 Merged in changes from the pass_str_branch. 1995-05-06 07:29:58 +00:00
Fergus Henderson
ac4f8ba0fb Add copyright messages.
compiler/*:
	Add copyright messages.
	Change all occurences of *.nl in comments to *.m.

compiler/mercury_compile.pp:
	Change the output to the .dep files to use *.m rather than *.nl.
	(NOTE: this means that `mmake' will not work any more if you
	call your files *.nl!!!)
1995-03-30 21:03:41 +00:00
Fergus Henderson
b2f2578ac0 Report a more meaningful error message if a called predicate
modes.m mode_errors.m:
	Report a more meaningful error message if a called predicate
	doesn't have any modes.
1995-03-19 12:22:10 +00:00
Fergus Henderson
62fa8be865 Add new targets `mercury_compile.sicstus' (the Mercury compiler
Makefile.common:
	Add new targets `mercury_compile.sicstus' (the Mercury compiler
	compiled with Sicstus) and `mercury_compile.sicstus.debug'
	(debugging version of the above).

*.nl:
	Use Sicstus-compatible char and string escapes.
	Avoid the use of explicit existential quantification.
	Various other hacks to get things to parse correctly under Sicstus.

prog_io.nl:
	Don't allow (A -> B) in DCGs, since NU-Prolog and Mercury give
	it different semantics to Sicstus.

sp_builtin.nl, sp_lib.nl:
	Split sp_builtin.nl into sp_builtin.nl and sp_lib.nl.

sp_conv.sed:
	Add sed script which converts some character escapes so that
	they work with Sicstus.

term_io.nl:
	Remove term_io__prefix_op etc. since they aren't used anymore.
1995-01-31 06:00:16 +00:00
Fergus Henderson
65ac02d56e Add some targets for compiling the compiler and the library.
Makefile.common:
	Add some targets for compiling the compiler and the library.

type_util.nl, dense_switch.nl, switch_gen.nl, polymorphism.nl:
	Rename inttype, chartype, etc. as int_type, char_type, etc.
	Add polymorphic_type.

modes.nl, mode_errors.nl:
	Report an error for direct attempts to unify higher-order pred types.
	(Of course, we don't catch indirect attempts via polymorphic types -
	that would require global analysis.  For them, we report the error
	at runtime.)

modes.nl:
	Remove unreachable code from conjuctions.
	(XXX also should do this for if-then-else.)

options.nl:
	Turn -p off by default.  I'll turn it on again when it works ;-)
1995-01-19 16:09:44 +00:00
Fergus Henderson
361ee0398c Fix determinism errors.
frameopt.nl, bintree.nl, mode_errors.nl:
	Fix determinism errors.
1995-01-09 12:19:33 +00:00
Fergus Henderson
8951141284 Fix a couple of newly introduced bugs.
modes.nl:
	Fix a couple of newly introduced bugs.
	Update a few of the comments.
	Change it so that `ground' does _not_ match `bound(...)'
	(still not quite right, since there are some cases when it
	should match, but this fix should be enough for the moment).

modes.nl, mode_errors.nl:
	Fix mode declarations to comply with the above change.
1995-01-09 08:04:31 +00:00
Fergus Henderson
f87d753f93 Remove the "detect builtins" pass.
builtins.nl, call_gen.nl, code_util.nl, mercury_compile.nl, modes.nl:
	Remove the "detect builtins" pass.
	Instead, determing which predicate calls are builtins
	happens during the mode analysis pass.  modes.nl calls
	code_util__is_builtin.

io.nl, io.nu.nl:
	Move io__get/set_globals from io.nu.nl to io.nl.

modes.nl, mode_errors.nl:
	Warn about predicates which have no modes.

arg_info.nl:
	Generate correct arg_info for all predicates, including
	imported predicates and predicates with no clauses.

typecheck.nl:
	Don't warn about predicate having no clauses if the
	the predicate is a builtin.
1994-10-05 15:56:55 +00:00
Fergus Henderson
dbed5a2d3e Did some work towards implementing implied modes.
modes.nl, mode_errors.nl:
	Did some work towards implementing implied modes.  We still
	don't implement them yet, but at least we know report an error if
	you try (and you also used --generate-code).
1994-09-09 23:43:21 +00:00
Fergus Henderson
d6ca6e3797 Ensure that Makefile.mercury can be used as a generic
*Makefile*:
	Ensure that Makefile.mercury can be used as a generic
	Makefile for Mercury programs.  It now gets included by the
	Makefiles in the tests/ directory.
	(It's highly likely that these changes have broken something.)

code_util.nl, peephole.nl, code_info.nl:
	Move peephole__neg_rval to code_util.nl, so that it can
	also be used by code_info.nl.  Improve it a bit.

disj_gen.nl:
	Minor stylistic changes.

peephole.nl:
	Use bintree_set(label) rather than map(label, bool).

ite_gen.nl:
	Implement non-deterministic if-then-elses.

mercury_compile.nl:
	Change the action in the automatically generated .dep makefile
	to use `$(MNL)' rather than `$(NC)' to link the `.no' files
	together.

mode_util.nl, mode_info.nl:
	Fix some (recently detected) determinism errors.

options.nl:
	Rearrange the options into a vaguely meaninful order and
	add a couple of comments.
1994-08-30 21:07:52 +00:00
Fergus Henderson
693d42285f Rename globals__lookup*option as globals__io_lookup*option.
*.nl:
	Rename globals__lookup*option as globals__io_lookup*option.
	Create new globals__lookup*option predicates.
	Fix up the option handling in the code generator.
1994-08-14 14:26:38 +00:00
Fergus Henderson
534e5c221e Fix lots of determinism problems.
*.nl:
	Fix lots of determinism problems.
1994-07-07 20:16:08 +00:00
Fergus Henderson
30f5e18b2f Remove map__search_insert; it's not needed and it's not
bintree.nl, map.nl, varset.nl:
	Remove map__search_insert; it's not needed and it's not
	really useful.

bintree.nl:
	Fix determinism problem in bintree__from_list_2.

options.nl, det_analysis.nl, make_hlds.nl:
	Add options to suppress determinism warnings.

det_analysis.nl, hlds.nl, modes.nl:
	Allow the delta-instmap to be `unreachable'.

hlds_out.nl:
	Output the delta-instmap.
	Output conjunctions differently in verbose mode.

llds.nl:
	Fix determinism problem.
	Change GOTO(LABEL(...)) into GOTO_LABEL(...) which can be
	more efficient.

map.nl:
	Add map__overlay/3.

typecheck.nl, modes.nl, mode_errors.nl, options.nl, hlds_out.nl.
	Split the old `debug' option into debug-types and debug-modes.
	Change the default for the `modecheck' option to `yes'.
	Add a new verbose-dump-hlds option, and use that instead
	of the very-verbose option in hlds_out.nl.

mode_util.nl:
	Export mode_get_insts/4.
	Add instmap_lookup_var (moved from modes.nl).
	Add apply_instmap_delta.

modes.nl, term.nl, prog_util.nl:
	Add determinism annotations.

term.nl, prog_io.nl:
	Fix bugs in when declarations.

std_util.nl, prog_io.nl:
	Add a maybe(T) type to std_util.nl.
	Rename the maybe(T) type in prog_io.nl as maybe1(T).
1994-06-16 16:05:59 +00:00
Fergus Henderson
94d9c1abb9 Use det_pred(...), semidet_pred(...), nondet_pred(...)
mercury_builtin.nl:
	Use det_pred(...), semidet_pred(...), nondet_pred(...)
	rather than call_pred(...) for the higher-order predicate modes.

prog_io.nl, io.nl, varset.nl, etc.
	Add determinism annotations.

hlds.nl, make_hlds.nl, LOTS of other files:
	Reorganize the way the predicate table works.
	Make hlds.nl a bit more modular.
	Change call/4 to call/5.
	Remove all/2 from the hlds.
	Changed pred_id to an integer.
	Added pred_call_id which is similar to the old pred_id.

Makefile:
	Add a rule for creating *.hlds_dump.

array.nl:
	Fix determinism error.

det_analysis.nl:
	Fix a bug in printing determinism warnings.

fix_errors.sed:
	Modify this so it allows all the `inferred nondet' determinism
	errors but none of the `inferred semidet' ones.

llds.nl:
	Rename llds__pred_mode_id as llds__proc_id.

mode_errors.nl:
	Finally got around to implementing Zoltan's suggestions
	about the error messages from the mode analysis.
	If an error occurs in a conjunction, only one error message
	is printed out - the first error which doesn't relate to
	a head unification.

modes.nl:
	Handle X = f(X) properly.  NB: determinism analysis and code
	generation still get it wrong!

undef_modes, undef_insts:
	I've broken the error message code, since it's not easy
	to print pred_ids.  I just changed it so that it didn't
	print the pred_ids out.  Should fix this properly at some stage...
1994-06-14 14:23:52 +00:00
Fergus Henderson
7efe74c6ea Change case/3 to case/2.
builtins.nl, hlds.nl, det_analysis.nl, hlds_out.nl:
	Change case/3 to case/2.

char.nl, mode_info.nl:
	Add some determinism declarations.

hlds.nl:
	Change the `liveness' field to a `delta_liveness' field.
	Add goal_to_conj_list/2 and goal_to_disj_list/2.

hlds_out.nl:
	Export hlds_out__write_goal.

make_hlds.nl:
	Warn about missing determinism annotations.

mercury_to_mercury.nl, hlds_out.nl:
	Fix the problem where determinism annotations were
	not being output correctly for zero-arity predicates
	in interface files.

mercury_to_mercury.nl, mode_errors.nl:
	Remove mercury_output_hlds_goal (it's been replaced by
	hlds_out__write_goal).

parser.nl:
	Minor change.

switch_detection.nl:
	Fix this.  It now works!

toplevel.nl:
	Call switch_detection.nl.

Makefile, doit.nl:
	Add switch_detection.nl.
1994-06-08 08:53:25 +00:00