Commit Graph

151 Commits

Author SHA1 Message Date
Julien Fischer
b78d146b75 Improve error reporting for type class declarations in the situation where a
Estimated hours taken: 10
Branches: main

Improve error reporting for type class declarations in the situation where a
mode declaration for a method has been provided but there is no function or
predicate declaration for that method.  Currently, this causes an internal
abort in the compiler.

Avoid another compiler abort in polymorphism.m when a type class method has two
duplicate mode declarations.

compiler/add_class.m:
	Change the order in which we add type class declarations to the HLDS
	so that we can detect and report situations where a type class method
	has a mode declaration but no corresponding predicate or function
	declaration.  All of the predicate/function method declarations for a
	particular typeclass need to be added before any mode declarations.
	We can then check that there is a corresponding predicate/function
	method declaration as each mode is added.

compiler/post_typecheck.m:
	Have the post-typechecking pass indicate that an error has occurred if
	we encounter indistinguishable mode declarations.  This prevents
	polymorphism being run if there are such mode declarations.  This
	avoids an internal abort in polymorphism.m when the mode declarations
	in question are type class methods.

	Unrelated change: s/io.state/io__state/ in an error message.

compiler/hlds_error_util.m:
	When formatting predicate names, specifically identify type class
	methods as such.  e.g. instead of `predicate foo/1' we now
	write them out as `type class predicate method foo/1'.

compiler/modecheck_call.m:
	Fix a typo: s/identical/indentical/

compiler/prog_item.m:
	Add the equivalence: class_methods == list(class_method).

compiler/equiv_type.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_data.m:
compiler/prog_io_typeclass.m:
compiler/recompilation.version.m:
	Minor changes to conform to the above.

tests/README:
	Fix an line that exceeds 80 characters in length.

tests/invalid/Mmakefile:
	Enable the test cases typeclass_mode_{2,3,4} since we now pass those
	tests.

	Delete a comment about `--split-c-files'.  That option is no longer
	supported.

tests/invalid/typeclass_mode_{2,3,4}.err_exp:
	Add expected outputs for these test cases.

tests/invalid/invalid_main.err_exp:
	The module qualifier in the expected output is now '.'.

tests/invalid/qualified_cons_id2.err_exp:
	Delete the determinism error from the expected output.  It won't show
	up now as the above changes mean the compiler will abort before
	determinism checking in this case.

tests/invalid/typeclass_dup_method_mode.{m,err_exp}:
	Add a test case for the problem that causes an abort in the
	polymorphism pass when a type class method has duplicate mode
	declarations.

tests/invalid/typeclass_mode.err_exp:
	Update the expected output to conform with the above changes.  Also,
	we no longer emit the spurious error message about missing clauses.

tests/recompilation/typeclass_method_pragma_r.err_exp.2:
	Update to conform to the new naming of type class methods
	in the error message.
2006-01-16 03:08:17 +00:00
Ralph Becket
a8d3e06db7 Add support for `constraint_store is mutable(...)' or
Estimated hours taken: 3
Branches: main

Add support for `constraint_store is mutable(...)' or
`constraint_store is [mutable(...), ...]' attributes on solver type
definitions.

compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/module_qual.m:
compiler/prog_data.m:
	The solver_type_details structure now contains the list of
	mutable declatations given in the constraint_store attribute
	(empty if this attribute was not provided).

compiler/make_hlds_passes.m:
	Process the constraint_store mutable items for solver types.

compiler/mercury_to_mercury.m:
	Output the constraint_store attribute value for solver types
	if present.

compiler/prog_io.m:
	Parse the new attribute.

doc/reference_manual.texi:
	Document the addition of constraint_store solver type attributes.
2005-11-23 05:11:41 +00:00
Julien Fischer
2a477fb7e7 Split the parse tree (currently defined in prog_data.m) into two
Estimated hours taken: 3.5
Branches: main

Split the parse tree (currently defined in prog_data.m) into two
separate modules.  The reason for doing this is that while over 80%
of the modules in the compiler import prog_data, very few of them actually
require access to the types that define the parse tree (principally
the item type).  At the moment even small changes to these types can
result in recompiles that rebuild almost all of the compiler.  This change
shifts the item type (and related types) into a new module, prog_item,
that is only imported where these types are required (mostly at the
frontend of the compiler).  This should reduce the size of recompiles
required when the parse tree is modified.

This diff does not change any algorithms; it just shifts things around.

compiler/prog_data.m:
	Move the item type and any related types that are not needed
	after the HLDS has been built to the new prog_item module.

	Fix bitrot in comments.

	Fix formatting and layout of comments.

	Use unexpected/2 in place of error/1 in a spot.

compiler/prog_item.m:
	New file.  This module contains any parts of the parse tree
	that are not needed by the rest of the compiler after the
	HLDS has been built.

compiler/check_typeclass.m:
	s/list(instance_method)/instance_methods/

compiler/equiv_type.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/make_hlds.m:
compiler/mercury_compile.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/parse_tree.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/trans_opt.m:
	Conform to the above changes.

compiler/notes/compiler_design.html:
	Mention the new module.
2005-11-23 04:44:10 +00:00
Julien Fischer
dae82a8409 Implement trail usage optimization for the lowlevel backend.
Estimated hours taken: 5
Branches: main

Implement trail usage optimization for the lowlevel backend.

compiler/code_gen.m:
	As we generate code for each HLDS goal check if it is safe to omit
	trailing operations.  Do so, if trail usage optimization is enabled.

	Reformat some code for the purposes of readability.

compiler/commit_gen.m:
compiler/disj_gen.m:
compiler/ite_gen.m:
compiler/code_info.m:
	Thread the above information down to the relevant parts of the code
	generator.

	Misc. cleanups: reduce unnecessary module qualification and minor
	layout fixes.

compiler/code_util.m:
	Add a utility predicate the tests if we are allowed to omit trailing
	primitives for a given HLDS goal.

compiler/llds.m:
	Add the equivalence type: add_trail_ops == bool.

compiler/hlds_goal.m:
compiler/prog_data.m:
	Unrelated changes: fix typos in comments.

	Add an end_module declaration to the former.
2005-11-17 04:38:44 +00:00
Julien Fischer
3a64ba36ef Implement trail usage analysis. This analysis performs a bottom-up analyise
Estimated hours taken: 30
Branches: main

Implement trail usage analysis.  This analysis performs a bottom-up analyise
of a program's call-graph to work out what parts of the program cannot modify
the trail.

Implement trail usage optimization for the high-level C backend.  Use the
information from the trail usage analysis to reduce the overhead of trailing
by omitting trailing primitives where they are not needed.  This diff
adds an initial version of this optimization (future versions will exploit
further opportunities that we currently ignore).

TODO: implement this optimization for the lowlevel backend.

This change adds two new foreign code attributes: `will_not_modify_trail'
and `may_modify_trail' that can be used to inform the compiler whether
foreign_procs modify the trail or not.

compiler/trailing_analysis.m:
	New module.  Perform a bottom-up analysis of the HLDS and annotate it
	with trail usage information.

compiler/hlds_module.m:
	Add a slot to the HLDS to store trail usage information for each
	(opt-imported) procedure in a module.

compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/add_pragma.m:
	Add a new pragma: trailing_info.  This pragma can only occur in .opt
	and .trans_opt files and is used to propagate trail usage information
	across module boundaries.

	Add two new foreign_proc attributes, `will_not_modify_trail' and
	`may_modify_trail', that allow foreign_procs to be annotated with
	trail usage information.

compiler/goal_form.m:
	Add a predicate that tests if a given goal modifies the trail.

compiler/add_trail_ops.m:
	When performing the source-to-source transformation used to implement
	trailing for the MLDS backend take account of trail usage information,
	so that we can omit calls to trailing primitives in some places.

compiler/options.m:
	Add two new options: `--analyse-trail-usage' and
	`--optimize-trail-usage', that enable the new analysis and
	optimization respectively.  For the moment they are both disabled by
	default.

	Unrelated change: fix the formatting of the termination2 options.

compiler/trans_opt.m:
	Write trailing_info pragmas to .trans_opt files.

compiler/mercury_compile.m:
	Run the new analysis if `--analyse-trail-usage' is given.

compiler/mercury_to_mercury.m:
	Output trailing_info pragmas.

compiler/transform_hlds.m:
compiler/recompilation.version.m:
	Minor changes to conform to the above.
2005-11-08 08:14:55 +00:00
Julien Fischer
5fd6db5106 Fix the problem that has been causing hard_coded/intermod_poly_mode to fail.
Estimated hours taken: 16
Branches: main

Fix the problem that has been causing hard_coded/intermod_poly_mode to fail.

When writing foreign_procs to .opt files, make sure that any inst variables
have the correct name.

compiler/add_pragma.m:
	When searching for the predmode decl corresponding to a foreign_proc
	allow for a renaming between inst variables.  We need to do this
	because the inst variables in each declaration are allocated from
	different varsets, consequently the representation of the variables
	may differ.  Unifying the modes directly is not sufficient in some
	cases, see hard_coded/intermod_poly_mode for an example.

compiler/mercury_to_mercury.m:
	Fix an old XXX.  Pass the inst_varset to the procedure that writes out
	foreign_procs.  This allows us to give inst variables in foreign_proc
	arguments lists their correct names.

	Use unexpected/2 in place of error/1.

compiler/intermod.m:
	Pass the inst_varset to the procedure that writes foreign_procs in the
	.opt files, so that any inst variables have the correct name.

	Use unexpected/2 in place of error/1.

compiler/prog_data.m:
	Handle the inst_varset of a foreign_proc in a similar fashion
	to how we handle type/inst varsets in predmode declarations.

	Add an extra field to the the foreign_proc structure to
	store the inst_varset.

compiler/add_solver.m:
compiler/make_hlds_passes.m:
compiler/modules.m:
compiler/recompilation.version.m:
	Conform to the above changes.
2005-11-08 03:58:54 +00:00
Zoltan Somogyi
21685c9e22 Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 6
Branches: main

Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.

The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.

compiler/det_analysis.m:
	Keep track of goals to the right of the current goal that could fail,
	and include them in the error representation if required.

compiler/det_report.m:
	Include the list of failing goals to the right in the representations
	of determinism errors involving committed committed choice goals.

	Convert the last part of this module that wasn't using error_util
	to use error_util. Make most parts of this module just construct
	error message specifications; print those specifications (using
	error_util) in only a few places.

compiler/hlds_out.m:
	Add a function for use by the new code in det_report.m.

compiler/error_util.m:
	Add a function for use by the new code in det_report.m.

compiler/error_util.m:
compiler/compiler_util.m:
	Error_util is still changing reasonably often, and yet it is
	included in lots of modules, most of which need only a few simple
	non-parse-tree-related predicates from it (e.g. unexpected).
	Move those predicates to a new module, compiler_util.m. This also
	eliminates some undesirable dependencies from libs to parse_tree.

compiler/libs.m:
	Include compiler_util.m.

compiler/notes/compiler_design.html:
	Document compiler_util.m, and fix the documentation of some other
	modules.

compiler/*.m:
	Import compiler_util instead of or in addition to error_util.
	To make this easier, consistently use . instead of __ for module
	qualifying module names.

tests/invalid/det_errors_cc.{m,err_exp}:
	Add this new test case to test the error messages for cc contexts.

tests/invalid/det_errors_deet.{m,err_exp}:
	Add this new test case to test the error messages for unifications
	inside function symbols.

tests/invalid/Mmakefile:
	Add the new test cases.

tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
	Change the expected output to conform to the change in det_report.m,
	which is now more consistent.
2005-11-04 03:41:09 +00:00
Zoltan Somogyi
f9fe8dcf61 Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 8
Branches: main

Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.

The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.

compiler/det_analysis.m:
	Keep track of goals to the right of the current goal that could fail,
	and include them in the error representation if required.

compiler/det_report.m:
	Include the list of failing goals to the right in the representations
	of determinism errors involving committed committed choice goals.

	Convert the last part of this module that wasn't using error_util
	to use error_util. Make most parts of this module just construct
	error message specifications; print those specifications (using
	error_util) in only a few places.

compiler/hlds_out.m:
	Add a function for use by the new code in det_report.m.

compiler/error_util.m:
	Add a function for use by the new code in det_report.m.

compiler/error_util.m:
compiler/compiler_util.m:
	Error_util is still changing reasonably often, and yet it is
	included in lots of modules, most of which need only a few simple
	non-parse-tree-related predicates from it (e.g. unexpected).
	Move those predicates to a new module, compiler_util.m. This also
	eliminates some undesirable dependencies from libs to parse_tree.

compiler/libs.m:
	Include compiler_util.m.

compiler/notes/compiler_design.html:
	Document compiler_util.m, and fix the documentation of some other
	modules.

compiler/*.m:
	Import compiler_util instead of or in addition to error_util.
	To make this easier, consistently use . instead of __ for module
	qualifying module names.

tests/invalid/det_errors_cc.{m,err_exp}:
	Add this new test case to test the error messages for cc contexts.

tests/invalid/det_errors_deet.{m,err_exp}:
	Add this new test case to test the error messages for unifications
	inside function symbols.

tests/invalid/Mmakefile:
	Add the new test cases.

tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
	Change the expected output to conform to the change in det_report.m,
	which is now more consistent.
2005-10-28 02:11:03 +00:00
Zoltan Somogyi
b2012c0c0e Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
Estimated hours taken: 8
Branches: main

compiler/*.m:
	Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
	and 'mer_mode'. This is to avoid the need to parenthesize these type
	names in some contexts, and to prepare for the possibility of a parser
	that considers those words to be reserved words.

	Rename some other uses of those names (e.g. as item types in
	recompilation.m).

	Delete some redundant synonyms (prog_type, mercury_type) for mer_type.

	Change some type names (e.g. mlds__type) and predicate names (e.g.
	deforest__goal) to make them unique even without module qualification.

	Rename the function symbols (e.g. pure, &) that need to be renamed
	to avoid the need to parenthesize them. Make their replacement names
	more expressive.

	Convert some more modules to four space indentation.

	Avoid excessively long lines, such as those resulting from the
	automatic substitution of 'mer_type' for 'type'.
2005-10-24 04:14:34 +00:00
Julien Fischer
192a58021b Add optional support for generating a pure interface to mutables.
Estimated hours taken: 8
Branches: main

Add optional support for generating a pure interface to mutables.  This is
done by adding a new mutable attribute, `attach_to_io_state'.  If this
attribute is specified in the mutable declaration then in addition to the
usual non-pure access predicates, the compiler will also add a pair of access
predicates that take the IO state.

compiler/prog_data.m:
	Add the `attach_to_io_state' mutable attribute.

	Add the necessary access predicates for the mutable_var_attributes
	structure.

compiler/prog_io.m:
	Parse the `attach_to_io_state' attribute.

compiler/prog_mutable.m:
	Shift some of the code for constructing items related to mutables to
	this module from make_hlds_passes.  This reduces unnecessary clutter in
	the latter.

	Remove the XXX comment about needing to mangle the names of the
	globals - we now do that.

compiler/make_hlds_passes.m:
	If a mutable has the `attach_to_io_state' attribute specified then
	create pure access predicates that take the IO state in addition
	to the non-pure ones.

compiler/modules.m:
	If we are generating the pure access predicates then output the
	declarations for these predicates in private interfaces.

compiler/type_util.m:
	Replace the use of ':' as a module qualifier in some comments.

doc/reference_manual.texi:
	Document the `attach_to_io_state' mutable attribute.

vim/syntax/mercury.vim:
	Highlight various mutable attributes appropriately.

tests/hard_coded/Mmakefile:
tests/hard_coded/pure_mutable.m:
tests/hard_coded/pure_mutable.exp:
	Test mutables with pure access predicates.

tests/hard_coded/ppc_bug.m:
	Unrelated change: update the comments in this test case so
	they describe what the cause of the bug and the fix were.
2005-10-06 08:26:12 +00:00
Zoltan Somogyi
d609181cb9 Consider types of the form
Estimated hours taken: 30
Branches: main

Consider types of the form

	:- type x ---> f.

to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.

runtime/mercury_type_info.h:
	Add a new type_ctor_rep for dummy types.

runtime/mercury_tabling.h:
	Add a representation for "tabled" dummy types, which don't actually
	have a level in the trie, so that the runtime system can handle that
	fact.

runtime/mercury_ml_expand_body.h:
	When deconstructing a value of a dummy type, ignore the actual value
	(since it will contain garbage) and instead return the only possible
	value of the type.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
	Handle the type_ctor_rep of dummy types.

runtime/mercury_builtin_types.c:
	Provide a place to record profiling information about unifications and
	comparisons for dummy types.

runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
	Add a new type_ctor_rep for dummy types, and fix some previous
	discrepancies in type_ctor_reps.

mdbcomp/prim_data.m:
	Move a bunch of predicates for manipulating special_pred_ids here from
	the browser and compiler directories.

	Rename the function symbols of the special_pred_id type to avoid the
	need to parenthesize the old `initialise' function symbol.

	Convert to four-space indentation.

mdbcomp/rtti_access.m:
	Don't hardcode the names of special preds: use the predicates in
	prim_data.m.

	Convert to four-space indentation.

browser/declarative_execution.m:
	Delete some predicates whose functionality is now in
	mdbcomp/prim_data.m.

compiler/hlds_data.m:
	Replace the part of du type that says whether a type an enum, which
	used to be a bool, with something that also says whether the type is a
	dummy type.

	Convert to four-space indentation.

compiler/make_tags.m:
	Compute the value for the new field of du type definitions.

compiler/hlds_out.m:
	Write out the new field of du type definitions.

compiler/rtti.m:
	Modify the data structures we use to create type_ctor_infos to allow
	for dummy types.

	Convert to four-space indentation.

compiler/type_ctor_info.m:
	Modify the code that generates type_ctor_infos to handle dummy types.

compiler/type_util.m:
	Provide predicates for recognizing dummy types.

	Convert to four-space indentation.

compiler/unify_proc.m:
	Generate the unify and compare predicates of dummy types using a new
	code scheme that avoids referencing arguments that contain garbage.

	When generating code for unifying or comparing other types, ignore
	any arguments of function symbols that are dummy types.

	Don't use DCG style access predicates.

compiler/higher_order.m:
	Specialize the unification and comparison of values of dummy types.

	Break up an excessively large predicate, and factor out common code
	from the conditions of a chain of if-then-elses.

compiler/llds.m:
	For each input and output of a foreign_proc, include a field saying
	whether the value is of a dummy type.

compiler/pragma_c_gen.m:
	Fill in the new fields in foreign_proc arguments.

compiler/hlds_goal.m:
	Rename some predicates for constructing unifications to avoid
	unnecessary ad-hoc overloading. Clarify their documentation.

	Rename a predicate to make clear the restriction on its use,
	and document the restriction.

	Add a predicate for creating simple tests.

	Add a utility predicate for setting the context of a goal directly.

compiler/modules.m:
	Include dummy types interface files, even if they are private to the
	module. This is necessary because with the MLDS backend, the generated
	code inside the module and outside the module must agree whether a
	function returning a value of the type returns a real value or a void
	value, and this requires them to agree on whether the type is dummy
	or not.

	The impact on interface files is minimal, since very few types are
	dummy types, and changing a type from a dummy type to a non-dummy type
	or vice versa is an ever rarer change.

compiler/hlds_pred.m:
	Provide a representation in the compiler of the trie step for dummy
	types.

compiler/layout_out.m:
	Print the trie step for dummy types.

compiler/table_gen.m:
	Don't table values of dummy types, and record the fact that we don't
	by including a dummy trie step in the list of trie steps.

compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
	Conform to the changes above.

compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
	Conform to the changes above.

	Convert to four-space indentation.

compiler/mlds_to_java.m:
compiler/var_locn.m:
	Conform to the changes above, which requires threading the module_info
	through the module.

	Convert to four-space indentation.

compiler/mercury_compile.m:
	Pass the module_info to mlds_to_java.m.

compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
	Delete some previously missed references to the temporary types used
	to bootstrap the change to the type_info type's arity.

compiler/polymorphism.m:
	Turn back on an optimization that avoids passing parameters (such as
	type_infos) to foreign_procs if they are not actually referred to.

compiler/prog_data.m:
	Convert to four-space indentation.

library/svvarset.m:
	Add a missing predicate.

trace/mercury_trace.c:
	Delete the unused function that used to check for dummy types.

tests/debugger/field_names.{m,inp,exp}:
	Add to this test case a test of the handling of dummy types. Check that
	their values can be printed out during normal execution, and that the
	debugger doesn't consider them live nondummy variables, just as it
	doesn't consider I/O states live nondummy variables.
2005-10-05 06:34:27 +00:00
Julien Fischer
2755655989 Support impure initialise and finalise predicates in user code.
Estimated hours taken: 4
Branches: main

Support impure initialise and finalise predicates in user code.  In order to
support this the arity of the initialise or finalise predicate can no longer be
optionally omitted from the declaration.  Supporting impure arity zero
initialise/finalise declarations removes the restriction that every module that
has an initialise/finalise declaration must import the io module.

Allow initialize/finalize to be used as synonyms for initialise/finalise.

Improve the documentation of initialise/finalise declarations.
In particular:

	- mention the above changes.
	- mention that they may be cc_multi.
	- specify the order in which they invoked with respect to
	  standard library initialisation/finalisation.
	- mention that these declarations are not currently available
	  on non-C backends.

compiler/make_hlds_passes.m:
	Support impure user initialise/finalise predicates.

compiler/mercury_to_mercury.m:
	Write out the arities of the predicates specified in
	initialise and finalise declarations.

compiler/prog_data.m:
	Add an arity field to the initialise and finalise items.

compiler/prog_io.m:
	Don't allow the arity to be omitted in initialise and finalise
	declarations.

compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Conform to the changes in the initialise and finalise items.

library/ops.m:
	Add the alternate spellings of initialise and finalise to the ops
	table.

doc/reference_manual.texi:
	Update the ops table.

	Mention that initialise and finalise predicates may be cc_multi.

	Document impure initialisation and finalisation predicates.

	Add some disclaimers: mutable, initialise and finalise declarations
	are not implemented for the non-C backends.

tests/hard_coded/Mmakefile:
tests/hard_coded/impure_init_and_final.m:
tests/hard_coded/impure_init_and_final.exp:
	Test impure initialise and finalise declarations.

tests/hard_coded/finalise_decl.m:
tests/hard_coded/intialise_decl.m:
	Conform to the above changes.  Also test the versions of the
	declarations that use the -ize ending.

tests/hard_coded/sub-modules/finalise_parent.m:
tests/hard_coded/sub-modules/initialise_child.m:
tests/hard_coded/sub-modules/initialise_parent.m:
	Conform to the above changes.

tests/invalid/bad_finalise.m:
tests/invalid/bad_finalise.err_exp:
tests/invalid/bad_initialise.m:
tests/invalid/bad_initialise.err_exp:
	Extend these tests to check for missing or bad arities
	in intialise or finalise declarations.

vim/syntax/mercury.vim:
	Highlight recently added syntax appropriately.
2005-10-04 07:20:24 +00:00
Julien Fischer
f57fe1b7df Add language and compiler support for finalise declarations.
Estimated hours taken: 8
Branches: main

Add language and compiler support for finalise declarations.

NEWS:
	Mention finalise declarations.

compiler/prog_data.m:
	Add a new item type for finalise declarations.

	Add a new kind of item origin - items can now be introduced as part of
	the source-to-source transformation that implements finalise
	declarations.

compiler/prog_io.m:
	Parse finalise declarations.

compiler/modules.m:
	Don't write out finalise declarations in private interfaces.

compiler/hlds_module.m:
	Add a slot to the HLDS that stores the names of the predicates in
	finalise declarations.

	Add access predicates for the above.

compiler/add_pragma.m:
compiler/make_hlds_passes.m:
	Fix in incorrect comment: we add initialise declarations on third, not
	second, pass.

	Restore the code that use the enhanced switch detection capability.

	Implement the source-to-source transformation that implements finalise
	declarations.  This is almost identical to that for intitialise
	declarations.

compiler/llds.m:
compiler/llds_out.m:
compiler/transform_llds.m:
	Add a slot to the LLDS to hold the name of the predicates specified in
	the finalise declarations.

	Emit the necessary code to call these predicates after main has finished.

compiler/mlds.m:
compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
	As above, but for the MLDS.

compiler/mercury_compile.m:
	Conform to changes in the MLDS.
	XXX This module probably shouldn't manipulating the MLDS directly.

compiler/module_qual.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Conform to the above changes.

library/ops.m:
	Add `finalise' as an operator.

runtime/mercury_wrapper.c:
	Call any user specified finalise predicates from
	mercury_runtime_terminate.

doc/reference_manual.texi:
	Document finalise declarations.

tests/hard_coded/Mmakefile:
tests/hard_coded/finalise_decl.m:
tests/hard_coded/finalise_decl.exp:
	Tests finalise declarations.

tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/finalise_child.m:
tests/hard_coded/sub-modules/finalise_parent.m:
tests/hard_coded/sub-modules/finalise_parent.{exp,exp2}:
	Test finalise declarations and sub-modules.  There are two expected
	outputs because the order of execution between a parent module and its
	children of any finalisers is arbitrary.

tests/invalid/Mmakefile:
tests/invalid/bad_finalise_decl.m:
tests/invalid/bad_finalise_decl.err_exp:
	Test error messages associated with finalise declarations.
2005-09-29 06:33:17 +00:00
Julien Fischer
2856c276d5 Make the declarations for the globals variables used to implement mutables
Estimated hours taken: 8
Branches: main

Make the declarations for the globals variables used to implement mutables
visible across module boundaries.  Not doing so means that we cannot inline
the access predicates across module boundaries (this is currently causing
the tests for mutables and sub-modules to fail on that compile with
--intermodule-optimization).

Doing so requires us to module qualify the globals in the generated code, this
diff also fixes an earlier XXX about not mangling the names of mutables.

Add another mutable attribute, foreign_name, that allows the user to override
the compiler's choice of name for the global variable.  This is useful where
foreign code needs also needs to access the mutable, e.g. in library
bindings.  Currently, we only support this facility in the C backends.
(Actually, it's almost implemented for the other backends as well, but
there's no way to test it at the moment).

Support `trailed' and `not_thread_safe' as mutable attributes.  These are
the defaults so in practice they will probably rarely be used.

compiler/make_hlds_passes.m:
	If there is a foreign_name attribute for a mutable, then use that name
	rather than a compiler generated one.

	Make sure that there is a declaration for the global variable in the
	module's .mh file.

	Emit an error message if an attempt is made to use a trailed mutable
	in a non-trailing grade.

compiler/prog_mutable.m:
	Append the module name to the name of the global variable used to
	implement the mutable.

compiler/prog_data.m:
	Make the set of mutable attributes into an abstract type.  Handle this
	in a similar fashion to foreign code attributes.

	Add access predicates for the above type.

	Fix the positioning of comments and section headings in this module.

	Unrelated change: add a comment explaining why the intermediate
	form of the constraints in the termination2_info pragmas is necessary.

compiler/prog_io.m:
	Parse the new mutable attributes.

	Update the description of the source-to-source transformation used to
	implement mutable variables.

compiler/prog_io_pragma.m:
	Export the predicate parse_foreign_language/2.  It is now needed
	by the code that parses mutable declarations.

compiler/globals.m:
	Add a function that returns the compilation target as a string.

doc/reference_manual.m:
	Document the new attributes.

tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
tests/invalid/trailed_mutable.m:
tests/invalid/trailed_mutable.err_exp:
	Test the error message that results if a trailed mutable is used in a
	non-trailing grade.

tests/hard_coded/bad_mutable.{m,err_exp}:
	Extend this test case to cover the new attributes.

tests/hard_coded/Mmakefile:
tests/hard_coded/foreign_name_mutable.{m,exp}:
tests/hard_coded/unusual_name_mutable.{m,exp}:
	Further test for mutable variables.
2005-09-28 09:02:17 +00:00
Mark Brown
3fc6b3f128 Change the representation of types in the compiler.
Estimated hours taken: 30
Branches: main

Change the representation of types in the compiler.

We also add some support for handling kinds, which will be used later when we
have a kind system.  There are a number of places where kinds are not yet
handled correctly -- we assume that all kinds will be `star'.  Each of these
locations is flagged with a comment that contains "XXX kind inference:".


compiler/prog_data.m:
	Implement the new version of type (type).

	Change the definition of type_param to be a variable instead of a
	term, since all parameters must be variables anyway.

	Implement versions of varset.merge_* which work with tvarsets and
	produce renamings instead of substitutions.  Renamings are more
	convenient than substitutions because we don't need to know the
	kinds of type variables in order to build the renaming, and in any
	case the substitutions shouldn't have anything other than variables
	in the range so renamings will be more efficient and safe.

	Define the type of kinds, and provide a couple of utility predicates
	to operate on them.

compiler/prog_io.m:
	Parse type definition heads as a sym_name and list of type_params,
	rather than a functor.  Handle this change in other predicates.

	Allow parse errors to be returned by get_with_type/3, and handle
	these errors.

	Remove parse_type/2.  This predicate didn't do any processing, it
	just forwarded handling to convert_type/2.

compiler/prog_io_typeclass.m:
	Change type_is_functor_and_vars to handle the new representation
	of types.  In doing so, we retain the old behaviour that pure
	predicates pass this test, but no other pred or func types.  This
	behaviour is arguably incorrect, but there is little point changing
	the behaviour at the moment.  Instead we should remove these kind of
	restrictions entirely, but that should be done later.

compiler/prog_io_util.m:
	Provide predicates to both parse and unparse types.  We need to
	unparse types before printing them out, since we do a lot of special
	case handling when printing out terms and we don't want to duplicate
	this functionality for types.

compiler/module_qual.m:
	Remove report_invalid_type.  We now report ill-formed types during
	parsing.

compiler/superhomogeneous.m:
	Handle errors from the parsing of type expressions.

compiler/prog_out.m:
	Provide a predicate to convert builtin_types to their string names,
	and vice-versa.

compiler/prog_type.m:
	Add a bunch of simple tests to use on types which may have kind
	annotations present.  In such cases, types do not have a canonical
	representation so the simple handling of these tests is not what we
	want.  (Note that these are only required in early phases.  The kind
	annotations -- when they are implemented -- will be removed before
	type checking.)

	Consistently handle the application of renamings, substitutions and
	recursive substitutions to various data structures.

compiler/mercury_to_mercury.m:
	Implement mercury_output_type, mercury_format_type and
	mercury_type_to_string.  These convert the type to a term before
	formatting -- the reason for this is so that appropriate parentheses
	are used when formatting operators.  This results in some slight
	changes to error messages, which are reflected in changes to the
	expected output files in the tests.

	Remove the old version of mercury_type_to_string.

	Change the argument ordering of mercury_format_var to be consistent
	with mercury_format_type.  (Other predicates in this module should
	probably be changed in a similar way, since this argument ordering
	is more amenable to higher-order programming.  But that can be left
	for another change.)

compiler/type_util.m:
	Implement type unification.  The behaviour is much the same as the
	previous behaviour, except that we now handle apply/N types properly,
	and we also allow for kind annotations.

	Implement an occurs check for types.

	Remove the example definition of replace_eqv_type.  It isn't used and
	would no longer work anyway even if it would have worked before.

	Add a tvar_kind_map field to ctor_defn.

	The functions type_info_type and type_ctor_info_type now return
	types with `void' as their argument, rather than the type that the
	type_info or type_ctor_info was for.

	Remove type_util.real_vars/2, since it no longer does anything
	different from prog_type.vars/2.

	Remove the commented out implementation of type_to_ctor_and_args/3.
	Its implementation is in prog_type.m, and has changed significantly
	in any case.

compiler/add_clause.m:
	Move parse_purity_annotation/3 to prog_io_util.m.

compiler/check_typeclass.m:
	Remove apply_substitution_to_var_list/3, since we now have predicates
	in prog_type.m to handle such things.

compiler/continuation_info.m:
compiler/trace.m:
	Use prog_type.vars/2 instead of type_util.real_vars/2.  The two
	predicates have the same meaning now since type_infos don't contain
	any type variables.

compiler/hlds_data.m:
	Add tvar_kind_map fields to hlds_type_defn and hlds_class_defn.

compiler/hlds_pred.m:
	Add a tvar_kind_map field to pred_info.

compiler/polymorphism.m:
	Add a tvar_kind_map field to poly_info.

	Remove unify_corresponding_types, which is no longer used.

compiler/hlds_out.m:
	Use mercury_output_type/5 instead of term_io__write_term/4 and
	mercury_output_term/5.

compiler/post_typecheck.m:
	Build the void substitution directly rather than building intermediate
	lists.

compiler/recompilation.version.m:
	Use term__list_subsumes instead of type_list_subsumes, which now
	operates only on types.  This follows up on what was suggested in
	an XXX comment.

compiler/typecheck_errors.m:
	Use unparse_type/2 to format error messages.

compiler/typecheck_info.m:
	Don't export write_type_with_bindings/5.  It is no longer used
	outside of this module.

compiler/*.m:
	Conform to the above changes.

library/rtti_implementation.m:
	Fix a syntax error that went undetected in our previous
	implementation, and amazingly enough was compiled correctly anyway.

library/term.m:
	Move the versions of term__unify, term__unify_list and
	term__list_subsumes that were implemented specifically for types
	to here.  The version of term_unify that takes a list of bound
	variables (i.e., variables that should not be bound any further)
	is used by the subsumption check, which in turn is used by
	recompilation.version.m.

tests/invalid/kind.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/misc_tests/pretty_print_test.exp:
	Update the expected output of these tests to match what we now do.
2005-09-12 05:25:01 +00:00
Julien Fischer
a25ba19ea0 Improve the error checking for mutable declarations.
Estimated hours taken: 12
Branches: main

Improve the error checking for mutable declarations.

Fix a bug with solver types and sub-modules reported by Peter Hawkins.

Workaround a bug with mutable declarations and sub-modules.  Currently,
the compiler aborts if there is a mutable declaration in the parent module.
With this change mutable declarations will not be visible in child modules.

XXX This is not correct since they should be visible, but this can be fixed
as a separate change.

compiler/prog_data.m:
	Extend the item_origin type with information about what
	source-to-source transformations are responsible for compiler
	introduced items.  We need this information for error checking mutable
	declarations.  It also provides an additional layer of sanity checking
	in the parse tree.

	Add origin fields to the clause and initialise items, since they can
	both now be introduced by source-to-source transformations.

compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_typeclass.m:
	Conform to the above change.

compiler/make_hlds_passes.m:
	Don't issue spurious errors about initialise declarations that were
	introduced by the transformation for mutable declarations.  Abort if
	invalid initialise declarations were introduced by other compiler
	passes since this indicates a bug in the compiler.

	Check if mutable declarations occur in the interface of a module and
	emit an error if they do.

	Don't generate initialise items and foreign code from a mutable
	declaration unless we are in the defining module for the mutable
	declaration.

	Don't generate foreign_procs for solver types *unless* we are in the
	defining module.  Doing otherwise breaks the compiler when using
	solver types and sub-modules.

	Fix the formatting of an error message concerning initialise decls.
	s/foreign_code/foreign_proc/ in a spot.

compiler/add_solver.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/add_class.m:
compiler/add_pragma.m:
compiler/state_var.m:
	Conform to the above changes.

compiler/modules.m:
	Handle mutable declarations in private interfaces.

	Clean up some code related to foreign_import_module decls.

	Conform to the changes in prog_data.m.

compiler/prog_util.m:
	Shift the functions for mutable access predicates and variables to
	this module.  The code that generates interface files also needs to be
	able to access them.

compiler/module_qual.m:
	Conform to the above changes.

	Fix a bug where the context in the mq_info structure was not being
	updated.  This caused error messages for mutable declarations that
	contain undefined types or insts to have the wrong context.

compiler/hlds_data.m:
	Fix a typo.

vim/syntax/mercury.vim:
	Highlight `mutable' and `untrailed' appropriately.

tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/ts.m:
tests/hard_coded/sub-modules/ts.tsub.m:
tests/hard_coded/sub-modules/ts.exp:
	Add Peter Hawkin's test case for the bug with solver
	types and sub-modules.

tests/invalid/Mmakefile:
tests/invalid/bad_mutable.m:
tests/invalid/bad_mutable.err_exp:
	Add a test for the various sorts of errors that can occur with mutable
	declarations.
2005-09-12 03:05:51 +00:00
Julien Fischer
68d2c2e1e1 Improve error reporting for initialise declarations.
Estimated hours taken: 2
Branches: main

Improve error reporting for initialise declarations.

Make clauses in module interfaces an error rather than a warning.
Do the same for pragmas that should not occur in a module interface.

compiler/make_hlds_error.m:
	Add two new predicates that handle error reporting for items that
	should not occur in module interfaces.

compiler/make_hlds_warn.m:
	Remove the predicate for warning about items that should not occur in
	module interfaces.  It is now unused.

compiler/make_hlds_passes.m:
	Do not emit an error for export declarations that have ended up in the
	interface of a module as a result of the source-to-source
	transformation used to implement initialise declarations.

	Report initialise declarations that refer to predicates that do not
	exist directly rather than reporting that the introduced export
	pragmas are incorrect.  The latter is confusing since the pragmas
	do not appear in the source code

	Delete the XXX comment about the above.  Also fix the description of
	the transformation used to implement initialise declarations.

	Make clauses in a module interface an error rather than a warning.
	When reporting this also print out the name and arity of the predicate
	or function to which the clauses belong.

	Make it an error for pragmas that are not allowed in a module
	interface to occur in a module interface.

compiler/prog_data.m:
	Add a type that allows us to distinguish between items that originated
	with user code and those introduced by source-to-source
	transformations on the parse tree.

compiler/recompilation.version.m:
compiler/recompilation.check.m:
compiler/prog_io_pragam.m:
compiler/prog_io.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/add_pragma.m:
compiler/add_solver.m:
compiler/equiv_type.m:
compiler/intermod.m:
	Conform to the above changes.

tests/invalid/Mmakefile:
tests/invalid/not_in_interface.m:
tests/invalid/not_in_interface.err_exp.m:
	Test cases for the above errors.

tests/invalid/bad_initialise_decl.m:
tests/invalid/bad_initialise_decl.err_exp:
	Update this test case.
2005-09-05 03:45:59 +00:00
Ralph Becket
da2984c507 Add `:- mutable' directives to the language, providing modules with private
Estimated hours taken: 24
Branches: main

Add `:- mutable' directives to the language, providing modules with private
mutable variables.  A directives

:- mutable(x, int, 0, ground, [thread_safe]).

leads to the compiler generating the following:

:- semipure pred get_x(int::out(ground)) is det.
:- impure   pred set_x(int::in(ground)) is det.
:-          pred initialise_mutable_x(io::di, io::uo) is det.
:- initialise initialise_mutable_x/2.

initialise_mutable_x(!IO) :-
	promise_pure(
		impure set_x(0)
	).

:- pragma foreign_decl("C", "MR_Word mutable_variable_x;").

:- pragma foreign_proc("C", get_x(X::out(ground)),
[thread_safe, promise_semipure],
"MR_trail_current_value(&mutable_variable_x); X = mutable_variable_x;").

:- pragma foreign_proc("C", set_x(X::in(ground)),
[thread_safe],
"mutable_variable_x = X;").

Possible attributes for a mutable variable are `thread_safe' and
`untrailed'.



NEWS:
	Mention the new language feature.

compiler/make_hlds_passes.m:
	Handle the new mutable/5 item.

	Pass 1 expands a mutable directives into the pred
	declaration items.

	Pass 2 expands a mutable directives into the initialise
	and foreign_decl declaration items.

	Pass 3 expands a mutable directives into the initialise
	declaration and the clauses for the preds.

compiler/mercury_to_mercury.m:
compiler/mercury_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Cover the new mutable/5 item.

compiler/prog_data.m:
	Add a new mutable/5 program item.

compiler/prog_io.m:
	Parse `:- mutable' directives.

compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
	Move list_term_to_term_list from prog_io_typeclass to prog_io_util
	(it's a generally useful predicate).

doc/reference_manual.texi:
	Document the new `:- mutable' directive.

tests/hard_coded/Mmakefile:
tests/hard_coded/mutable_decl.m:
tests/hard_coded/mutable_decl.exp:
	Added a test case that only runs in trailing grades.
2005-09-05 02:29:59 +00:00
Ralph Becket
88b75863dc Add support for initialisation predicates to be called before main/2 is
Estimated hours taken: 16
Branches: main

Add support for initialisation predicates to be called before main/2 is
invoked.  The new directive is `:- initialise initpredname.'

NEWS:
	Mention the new functionality.

compiler/export.m:
	`:- pragma export' also adds a C function declaration in the
	generated C wrapper code to avoid C compiler warnings about
	missing declarations.

compiler/hlds_module.m:
	Added a new user_init_preds field to the module_info to
	record the preds named in `initialise' directives.
	Added predicates to access and update the new field.
	The exported names are generated automatically.

compiler/llds.m:
	Added a new field cfile_num_user_inits to c_file structure.

compiler/llds_out.m:
	Add code to include the `REQUIRED_INIT initpredexportname' lines
	in the comment section of the generated C that is recognised
	by mkinit.

compiler/make_hlds_passes.m:
	Handle the new `initialise' directives.

compiler/mercury_compile.m:
	Make sure the list of user defined init pred export names is passed to
	the C code construction preds.

compiler/mercury_to_mercury.m:
	Handle the output of `initialise' directives.

compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Handle the new `initialise' item.

compiler/prog_data.m:
	Add a new `initialise(sym_name)' item.

compiler/prog_io.m:
	Add code to parse `initialise' directives.

compiler/prog_mode.m:
	Add di_mode pred and func.

compiler/transform_llds.m:
	Handle the extra field in c_file.

doc/reference_manual.texi:
	Update the operator table in the reference manual.
	Document the new `initialise' directive.

library/list.m:
	Added index[01]_of_first_occurrence preds and
	det_index[01]_of_first_occurrence funcs.  I've often
	had a need for these and they are used in looking up
	initprednames in the new module_info field.

library/ops.m:
	Add `initialise' as a prefix operator.

runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
	Add a new exported variable, MR_address_of_init_modules_required.
	Call the function pointed to by this variable at the right point
	during module initialisation.

test/hard_coded/Mmakefile:
test/hard_coded/initialise_decl.exp:
test/hard_coded/initialise_decl.m:
test/invalid/Mmakefile:
test/invalid/bad_initialise_decl.err_exp:
test/invalid/bad_initialise_decl.m:
	Added test cases.

util/mkinit.c:
	Now always checks C files for extra inits (previously you had to
	explicitly supply the -x flag).
2005-08-29 03:22:32 +00:00
Zoltan Somogyi
f7c8e5899d Add a new tabling method, one which specifies how each argument should
Estimated hours taken: 20
Branches: main

Add a new tabling method, one which specifies how each argument should
be treated, like this:

    :- pragma memo(p(in, in, in, out), [value, addr, promise_implied, output]).

doc/reference_manual.texi:
	Document the new tabling method.

compiler/prog_data.m:
	Add a new tabling method, one which specifies how each argument should
	be treated.

compiler/hlds_pred.m:
	Provide for the description of untabled input arguments of tabled
	procedures.

compiler/prog_io_pragma.m:
	Parse the new tabling method.

	Fix a bunch of formatting problems.

compiler/add_pragma.m:
	When adding a tabling pragma to the HLDS, check that if the pragma
	individually specifies the tabling methods of a procedure's arguments,
	then those tabling methods agree with the modes of those arguments.

	Fix an old bug: check whether a tabled predicate's arguments are
	fully input or fully output, and print an error message if not.
	We used to check this only in table_gen.m, but there we could only
	abort the compiler if the check failed.

	Factor out some common code and thereby fix an old bug: check for
	conflicting tabling pragmas not just when adding the pragma to all
	procedures of a predicate, but also when adding it to only a
	specified procedure.

compiler/table_gen.m:
	Implement the new tabling method.

compiler/prog_out.m:
compiler/layout_out.m:
	Conform to the changes above.

runtime/mercury_stack_layout.h:
	Provide for the description of untabled input arguments of tabled
	procedures.

trace/mercury_trace.c:
	Handle the new tabling method.

trace/mercury_trace_internal.c:
	Handle the new tabling method. Delete the defaults from some switches
	on enums to allow gcc to recognize missing cases.

	Handle the untabled input arguments of tabled procedures: skip over
	them when printing procedures' call tables.

	Enable better completion for mdb's "table" command.

trace/mercury_trace_tables.[ch]:
	Rename the breakpoint completer the proc_spec completer, since it does
	completions on procedure specifications.

tests/debugger/print_table.{m,inp,exp}:
	Modify this test case to test the ability to print the tables of
	predicates with some untabled arguments.

tests/tabling/specified.{m,exp}:
	New test case to check the functioning of the new tabling method
	by testing whether it is in fact faster to table the address of
	an argument instead of its value, or to not table it at all.
	Since the gains here are not quite as dramatic as tabled vs untabled,
	use a slightly looser criterion for comparing speeds than we use
	in the various versions of the fib test case.

tests/tabling/Mmakefile:
tests/tabling/Mercury.options:
	Enable the new test case, and set up the option it needs.

tests/invalid/specified.{m,err_exp}:
	New test case, a slight variant of tests/tabling/specified.m,
	to check the compiler's ability to detect errors in the new form
	of tabling pragma.

tests/invalid/Mmakefile:
	Enable the new test case.
2005-08-14 03:20:59 +00:00
Zoltan Somogyi
a65ad5dcb6 Allow simple_call_ids to be formatted by the predicates of error_util.m,
Estimated hours taken: 6
Branches: main

Allow simple_call_ids to be formatted by the predicates of error_util.m,
and convert the error messages in some submodules of make_hlds.m to use this
capability.

compiler/hlds_pred.m:
compiler/prog_data.m:
	Move the simple_call_id type from hlds_pred to prog_data,
	since error_util shouldn't import any HLDS modules.

compiler/hlds_out.m:
compiler/prog_out.m:
	Move the predicates for printing simple_call_ids from hlds_out to
	prog_out.

	Change prog_out.m to four-space indentation to reduce the number
	of bad line breaks.

	In prog_out.m, move the relevant comments to the interface,
	delete unnecessary module qualifications, and delete some long
	obsolete commented-out code.

compiler/error_util.m:
	Add simple_call_id to the list of format components.

	Change to four-space indentation to reduce the number of bad line
	breaks.

	Conform to the standard format for comments.

compiler/add_pragma.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_warn.m:
	Use the new capability to convert some error reporting code to use
	error_util.

compiler/*.m:
	Conform to the changes above, mostly by deleting now incorrect module
	qualifications.

tests/invalid/*.err_exp:
tests/warnings/*.err_exp:
	Expect the new, better formatted error messages.

tests/invalid/Mmakefile:
	Fix some too-long lines in comments.
2005-08-08 02:33:19 +00:00
Zoltan Somogyi
10536c5ee0 Divide make_hlds.m into submodules of manageable size.
Estimated hours taken: 12
Branches: main

Divide make_hlds.m into submodules of manageable size.

compiler/make_hlds.m:
	Distribute all the code that was previously here to new submodules.
	Include those submodules. Keep the existing interface of this module
	by defining predicates that do nothing except call the actual
	implementation in one of those submodules. The only changes visible
	from outside are the renaming of a predicate and the creation of a
	second name, make_hlds_qual_info, for qual_info. Both changes are
	designed to avoid ambiguity in the presence of intermodule
	optimization.

compiler/add_aditi.m:
	Submodule for dealing with aditi-specific issues.

compiler/add_class.m:
	Submodule for handling typeclasses.

compiler/add_clause.m:
	Submodule for handling the general processing of clauses.

compiler/add_pred.m:
	Submodule for handling new predicates.

compiler/add_special_pred.m:
	Submodule for handling special (unify/compare/index/init) predicates.

compiler/add_type.m:
	Submodule for handling new types.

compiler/add_mode.m:
	Submodule for handling new insts and modes.

compiler/add_solver.m:
	Submodule for handling new solver types.

compiler/add_pragma.m:
	Submodule for handling new pragmas.

compiler/state_var.m:
	Submodule for handling the state variable transformation.

compiler/superhomogeneous.m:
	Submodule for converting clauses to superhomogeneous form.

compiler/field_access.m:
	Submodule for field access syntax.

compiler/make_hlds_passes.m:
	Submodule containing the code that performs passes on the item list,
	adding things to the HLDS, calling the other submodules as necessary.

compiler/make_hlds_warn.m:
	Submodule that looks for constructs that merit warnings.

compiler/make_hlds_error.m:
	Submodule containing error messages used by more than one submodule.

compiler/hlds_pred.m:
	Since this module defines the clauses_info and proc_id types, move
	the predicates that initialize values of that type here as well from
	make_hlds.m (deleting an unnecessary parameter from one).

compiler/hlds_pred.m:
compiler/prog_data.m:
	Move the type tvar_name_map from from hlds_pred.m to prog_data.m,
	since that is where similar maps are.

compiler/check_typeclass.m:
compiler/mercury_compile.m:
	Conform to the change to make_hlds_qual_info.

compiler/hlds_out.m:
compiler/prog_out.m:
	Replace two identical predicates for printing out lists of strings
	in hlds_out.m and make_hlds.m with just one in prog_out.m, since that
	is where it belongs in the compiler.

compiler/prog_util.m:
	Move some utility predicates for substitutions and term recognition
	here from make_hlds.m, since they are needed by more than one
	submodule.

	Make this module conform to our coding guidelines, and convert it to
	four-space indentation to eliminate bad line breaks.

compiler/clause_to_proc.m:
compiler/hlds_code_util.m:
compiler/make_tags.m:
compiler/prog_mode.m:
compiler/quantification.m:
compiler/type_util.m:
	Trivial formatting changes.

compiler/notes/compiler_design.html:
	Describe the new modules.
2005-07-26 01:56:30 +00:00
Julien Fischer
3510163b3a Do not base the variable ids in the termination2_info pragmas
Estimated hours taken: 2
Branches: main

Do not base the variable ids in the termination2_info pragmas
directly on variable ids from the HLDS.  This makes the
termination2_info pragmas smaller and prevents the test
cases in tests/term failing in the .debug grades.

The identity of variables in the termination2_info pragmas
is now based upon the order of the procedure arguments.

compiler/term_constr_initial.m:
	Convert the new form of the pragma into argument size
	information.

compiler/term_constr_main.m:
	Write out the new form of the termination2_info pragma
	to the optimization interfaces.

	s/pramga/pragma

	Make some unnecessarily exported procedures private.

compiler/prog_data.m:
	Remove the headvar_ids field from the termination2_info
	pragma.

compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
compiler/recompilation.version.m:
	Minor changes to conform to the above.
2005-07-13 11:41:46 +00:00
Zoltan Somogyi
6e2d095a98 Add a new form of tabling pragma, fast_loose_memo.
Estimated hours taken: 12
Branches: main

Add a new form of tabling pragma, fast_loose_memo. It differs from memo in
only one way: for arguments of user-defined types, instead of tabling every
single function symbol in the value, it tables a pointer to the term instead.
(Actually, it tables the contents of the selected argument register, so it
works even if the value is not a pointer.)

As the name implies, this form of tabling is faster than memo. The tradeoff
is that it is looser: if two invocations specify two terms that are at
different addresses but have the same value, this new form of tabling will
not recognize the commonality.

doc/reference_manual.texi:
	Document the new pragma.

compiler/prog_data.m:
	Generalize the type specifying eval methods to allow the expression
	of the new form of tabling.

compiler/prog_io_pragma.m:
	Parse the new form of tabling pragma.

compiler/hlds_pred.m:
	Handle the new, more general form of memoing.

	Add the required provisions for the representation of the new form
	of trie step in tables.

compiler/table_gen.m:
	Implement the new form of tabling as a minor variant of memo tabling.

	Convert this module to four-space indentation to reduce the number
	of bad line breaks.

compiler/layout_out.m:
compiler/prog_out.m:
	Conform to the changes above.

library/table_builtins.m:
	Add the primitives required to implement fast_loose_memo.

	Fix an old bug: make table_lookup_insert_poly call the right macro.

runtime/mercury_tabling.h:
runtime/mercury_tabling_macros.h:
runtime/mercury_tabling_preds.h:
	Provide the basic mechanism of fast_loose_memo tabling: a hash table
	that works on MR_Words.

runtime/mercury_stack_layout.h:
	Allow the representation of the new evaluation method and the new form
	of trie step.

tests/tabling/fast_loose.{m,exp}:
	Add this test case of the operation of fast_loose tabling. The test
	case pronounces success only if fast_loose_memo is measured to be
	significantly faster than plain memo.

tests/tabling/Mmakefile:
	Enable the new test case.
2005-06-07 03:00:10 +00:00
Zoltan Somogyi
0a58be4096 Fix several performance problems that arose when compiling predicates defined
Estimated hours taken: 10
Branches: main

Fix several performance problems that arose when compiling predicates defined
by lots of facts, e.g. 16000 facts of the edge relation used in my recent
paper with Kostis on tabling. We couldn't use fact tables because they return
solutions in a different order, which would be OK semantically but which
invalidated the performance comparison we tried to make. I had to either fix
fact tables to use standard order or fix the performance problems of the usual
path of compilation. The latter is more generally useful, and reduces the
chances of any similar surprises.

The first performance problem was the quadratic complexity of always adding
clauses at the end of the clause list. The fix is to keep the list in reverse
order while it is being added to. This takes the time to read in the 16000-fact
predicate from 80+s to ~1s.

The second performance problem was our use of generate/test to check whether
any clause had impure code when copying the clauses to procs. Since we don't
have tail recursion for model_non code, this couldn't reuse stack frames, and
as a result ran at memory speed, not cache speed. The fix is to use an explicit
recursive predicate. (A better fix would be to implement proper tail recursion
for model_non code, but that would take significantly longer.) This fix
doesn't make much difference in the usual grades, but makes a significant
difference in debug grades.

The third performance problem is the quadratic or worse behavior of the mode
checker when merging the instmaps of disjuncts at the ends of large
disjunctions. With our old setup, this was inevitable, since given a bunch of
facts of the form

	edge(1, 2).
	edge(2, 3).
	edge(3, 4).
	...

etc, the instmap delta the mode checker builds for HeadVar__1 for the
disjunction of clauses is free -> bound(1; 2; 3; ...). The solution to that
is to add a new pragma, mode_check_clauses, that causes the mode checker
to check each clause individually, and to create a simple free -> ground
(or whatever the declared mode calls for) instmap delta for HeadVar__1.
We should consider making this pragma be implied for predicates defined
by lots of facts, but this diff does not do that. This change takes the
time to modecheck that 16000-fact predicate from ~360s to ~5s.

Theoretically, another way of tackling the problem would have been to
introduce widening, in which any list of functors inside "bound()" whose
length was above the threshold would be replaced by "ground", if the arguments
of the functors themselves were bound. However, that change would be much more
complex, and its behavior would be hard for users to predict. In a future
constraint-based mode system with separate passes for computing
producers/consumers and for computing the set of function symbols a
variable can be bound to, we could simply disable the latter pass
for predicates like this.

There are at least three other performance problems left. The fourth is
the same as the third, except for unique mode checking. The fifth is in
simplification, and the sixth is in equiv_type_hlds. I'll work on those next.

compiler/hlds_pred.m:
	Instead of exposing the clause list part of the clause_info, make it
	an abstract type. Make the abstract type keep the reverse list when
	adding clauses to the list, the forward list when the later parts
	of the compiler manipulate the clause list, and both when it is
	convenient to do so. Add the predicates necessary to manipulate
	this more complex representation. Move the code manipulating
	clauses_infos into its own implementation section, next to its
	declarations.

	Add a new mode_check_clauses predicate marker, which records the
	presence of the new pragma.

	Fix departures from our coding standard.

compiler/clause_to_proc.m:
	Replace the generate/test code with an explicit loop, as
	mentioned above.

compiler/prog_data.m:
	Add the new pragma.

compiler/prog_io_pragma.m:
	Recognize the new pragma.

compiler/modes.m:
	Implement separate mode checking of clauses.

	Convert the file to use four-space indentation to reduce the number of
	bad line breaks. Give some predicates more meaningful names.
	Use error_util to print some error messages. Fix departures from
	our coding standard.

compiler/make_hlds.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
	Handle the new pragma.

compiler/*.m:
	Conform to the change in hlds_pred.m and/or prog_data.m.
	In some cases, convert files to four-space indentation.

tests/hard_coded/mode_check_clauses.{m,exp}:
	A new test case to check that the mode_check_clauses pragma works
	correctly.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2005-05-23 03:15:49 +00:00
Mark Brown
d075d35702 Implement functional dependencies for the typeclass system.
Estimated hours taken: 240
Branches: main

Implement functional dependencies for the typeclass system.  The implementation
has two major parts.  First, some of the basic checks of constraints are
relaxed.  These used to occur in make_hlds but that functionality has now been
moved to check_typeclass.  We also add a range of new tests to ensure that
the FDs are used correctly.  Second, an "improvement" pass to context
reduction is added.  This looks for constraints which match certain rules,
and when it finds them updates the current bindings.  The general rule is
that type variables become more instantiated, but only in a way which provably
does not affect the satisfiability of the constraints.

XXX The plan for this change is to put the context reduction into a new
module check_hlds.typeclasses.m, but I have left the code in typecheck.m
for the moment because the diff will be easier to review that way.  Moving
to the new module will also remove the problem of one particular function
being implemented in both typecheck and hlds_data, which is flagged by an XXX
in the code.

XXX the check for consistency of instances is not yet complete.  We check all
visible instances, but not instances that are only present at link time.  We
could check these in a similar way to the check for overlapping instances
(that is, by defining a symbol that will conflict and cause a link error
if there are overlapping instances), but in the long run a better solution
will be required.  Producing this is left for a later change.

compiler/check_typeclass.m:
	Check for ambiguities in typeclass constraints here, rather than
	make_hlds.  We check by calculating the closure of the bound type
	variables under the induced functional dependencies.  This pass
	is merged in with the already existing pass that checks the
	quantifiers on constrained type variables.

	Check instances for range-restrictedness and for consistency.

	When checking for cycles in the typeclass hierarchy, build up the
	set of ancestors of a class which have FDs on them.  This set is
	used when searching for opportunities to apply improvement rules
	during type checking.

compiler/hlds_data.m:
	Define hlds_class_fundeps and add it to to hlds_class_defn.

	Add a field to hlds_class_defn to store the ancestors which have
	functional dependencies.

	Define the type 'instance_id', which is just an integer.  This is
	what is used in proofs to identify instances.

	In hlds_constraints and in constraint_ids, use the terms 'assumed'
	and 'unproven' rather than 'existential' and 'universal'.  The latter
	are confusing to use since the treatment of constraints differs
	depending on whether the constraint is on the head or the body of a
	clause.

	Add a field to the hlds_constraints for redundant constraints.  These
	are constraints that have either already been reduced or don't need to
	be reduced, which may contribute to improvement of types.

	Define some new predicates for initialising and updating the
	hlds_constraints.

compiler/type_util.m:
	Accommodate the change to hlds_constraints.

compiler/hlds_out.m:
	Output the functional dependencies.

compiler/intermod.m:
	Reconstruct a functional dependency from the HLDS, for outputting.

compiler/make_hlds.m:
	Convert functional dependencies from parse tree form and add them
	to the HLDS.

	Check that functional dependencies are identical in subsequent
	definitions of the same typeclass.

	Don't check for ambiguity here.  That is now done in check_typeclass.

compiler/mercury_to_mercury.m:
	Output functional dependencies in typeclass declarations.

compiler/prog_data.m:
	Define prog_fundeps and add them to the parse tree.

compiler/prog_io_typeclass.m:
	Parse functional dependencies on typeclass declarations.

compiler/typecheck.m:
	Require the class_table to be passed to
	reduce_context_by_rule_application, since the functional dependencies
	are stored here.  Also thread the bindings argument through, since the
	bindings may be improved by context reduction.  Save the resulting
	bindings in the type_assign.

	Instead of passing a list of assumed constraints and threading the
	unproven constraints through context reduction, thread through a
	hlds_constraints structure.  This contains more information about
	redundant constraints than just the two lists.

	Extend context reduction with two new passes.  The first applies the
	"class" FD rule, which tries to find two constraints which are
	identical on the domain of some FD, and then unifies the range
	arguments.  The pair of constraints are either both redundant
	constraints, or one redundant constraint and one assumed constraint.
	The second applies the "instance" FD rule, which for each constraint
	tries to find an instance which is more general on the domain
	arguments.  It then binds the instance arguments and unifies the
	range arguments of the instance with those of the constraint.

	When calculating the head_type_params for a predicate, include all
	variables that occur in universal constraints, since these may not
	necessarily occur in the arguments.

	Rename some variables: use variable prefixes "Pred" and "Parent" for
	types that are from the callee or that have been renamed apart
	respectively.  This follows the same naming scheme used in
	polymorphism.

	Remove the headtypes/0 type, and use head_type_params/0 throughout.

	Add a new kind of cons_error for using "new" on a constructor that is
	not existentially typed.  We check for this situation in
	convert_cons_defn, and report it in report_cons_error.

	Pass a value to convert_cons_defn indicating whether the constraints
	should be flipped or not, and whether the context is a constructor
	that uses 'new'.  We flip the constraints here rather than after the
	fact, since creating the constraints now requires some extra
	processing to be done, and we don't want to have to redo that
	processing.

	Add a constant function that specifies whether variable numbers should
	be displayed as part of the debugging output.  This is currently set
	to 'yes' but the previous behaviour can be achieved by changing the
	value to 'no'.

doc/reference_manual.texi:
	Document the new feature.

NEWS:
	Announce the new feature.

tests/*:
	New test cases.

compler/*.m:
	Minor changes related to the above.

compiler/error_util.m:
	Fix comment grammar.

compiler/prog_type.m:
	Fix an incorrect comment.
2005-04-20 12:57:59 +00:00
Ralph Becket
c1ca7d12d1 Fix a bug where state variables in the variable list of a
Estimated hours taken: 4
Branches: main

Fix a bug where state variables in the variable list of a
promise_equivalent_solutions goal were not handled.

compiler/prog_data.m:
	Adjust the promise_equivalent_solutions data constructor to
	include extra fields for "dot" and "colon" state variables in
	the variable list.

compiler/make_hlds.m:
	Adjust the transformation of promise_equivalent_solutions goals
	to ensure that !.X and !:X in the variable list correspond to the
	"initial" and "final" versions, respectively, of state variable X in
	the transformed goal body.

compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_io_goal.m:
compiler/prog_util.m:
	Adjust for the new promise_equivalent_solutions constructor fields.

compiler/prog_io_util.m:
	Add parse_vars_and_state_vars/4 to handle state variables
	appearing in the variable list of a promise_equivalent_solutions
	goal.

tests/hard_coded/Mmakefile:
tests/hard_coded/promise_equiv_with_svars.m:
tests/hard_coded/promise_equiv_with_svars.exp:
	Added test case.
2005-04-14 06:51:03 +00:00
Julien Fischer
c5e315b0fc Add the first part of the new termination analyser.
Estimated hours taken: lots
Branches: main

Add the first part of the new termination analyser.  This includes most
of the argument size analyser and a simple termination checker - I'll
add a more extensive one as part of another diff.  The one included here
is only a placeholder and is roughly equivalent to the one used by the
existing termination analyser.

The new analysis abstracts term size relationships over a domain of
(rational) convex constraints.  The resulting size relationships are, in
many cases, more precise than we can obtain with the old analysis.  This
means that we should be able to prove termination in more cases.  The
tradeoff for this increased precision is that the new termination
analysis is slower than the old one.  We should also be able to adapt
the new analyser to handle things like higher-order constructs and
intermodule mutual recursion more easily than the old one.

The code for writing termination2_info pragmas to .opt and .trans_opt
files is currently commented out.  It will need to stay that way until
after this change bootstraps and after the tests/term directory as been
reworked (the .trans_opt_exp files need to updated and some new test
cases have to added - I'll do this as part of separate diff).

It isn't clear what the relationship between the new analyser and the
existing one should be, so at the moment they are as independent of each
other as possible.

compiler/termination2.m:
	New file.  Invokes the the other passes of the new analysis
	and handles the output of termination2_info pragmas to .opt
	and .trans_opt files.

	XXX I've disabled the writing out of termination2_info
	pragmas to the (transitive-)intermodule optimization files
	until I've updated the test suite.

compiler/term_constr_data.m:
	New file.  Defines the main data structures used by the
	new analysis.

compiler/term_constr_initial.m:
	New file.  Sets up information for builtin and compiler
	generated procedures and processes information about
	imported procedures.  Also handles termination pragmas.

compiler/term_constr_build.m:
	New file.  Converts the HLDS representation of a procedure
	into the abstract representation that we use during the rest
	of the analysis.

compiler/term_constr_fixpoint.m:
	New file.  Perform a fixpoint calculation in order to derive
	interargument size relationships for a procedure (in the
	form of convex constraints).

compiler/term_constr_pass2.m:
	New file.  A rudimentary termination checker that is roughly
	equivalent to what the existing termination analysis does.
	This is just a placeholder.

compiler/term_constr_util.m:
	New file.  Utility predicates that are used by the above modules.

compiler/term_constr_errors.m:
	New file.  Equivalent to term_errors.m for the new analyser.

compiler/rat.m:
	Provide rational numbers over fixed precision integers.
	Originally committed on the termination2 branch.

compiler/lp_rational.m:
	Provides the necessary machinery for manipulating systems
	of linear constraints.  Originally committed on the termination2
	branch although most of this version is new.  (Some bits of the
	version on the termination2 branch are now in polyhedron.m).
	The linear solver is essentially the one that is currently
	in lp.m converted to use rationals rather than floats.

compiler/polyhedron.m:
	New file.  An ADT that provides convex polyhedra over the
	rationals (or at least over rats).  The abstraction barrier was
	designed so that we could experiment with different representations
	for the polyhedra.

compiler/term_norm:
	Clean up the documentation of this module.
	Make set_functor_info into a function.
	Add a function for finding a lower bound on the weight of a functor.

compiler/trans_opt.m:
	Output termination2_info pragmas in .trans_opt files.

compiler/transform_hlds.m:
	Include the new termination analyser.

compiler/goal_form.m:
	When checking whether a goal can loop or not use
	information from the new termination analyser as well as
	the old one.

compiler/globals.m:
compiler/handle_options:
compiler/options.m:
	Add options to control the new analyser.   The documentation
	is currently commented out because the new analysis is still
	a work-in-progress.  It should be uncommented when the new
	analysis is more mature.

	XXX The user guide still needs to be updated.

compiler/hlds_out.m:
	Add hlds_out.write_pred_proc_id/4.

compiler/hlds_pred.m:
	Add a slot in the proc_sub_info structure for the
	termination2_info structure.

compiler/rat.m:
	Provide rational numbers over fixed precision integers.

compiler/lp_rational.m:
	Provide the constraint machinery required by the analyser.

compiler/make_hlds.m:
	Handle imports of termination2_info pragmas.

compiler/mercury_compile.m:
	Run the new pass.  Currently, we do this directly after
	the old termination analysis pass.

compiler/mercury_to_mercury.m:
	Add code to output termination2_info pragmas.

compiler/libs.m:
	Include the rat, polyhedron and lp_rational modules.

compiler/prog_data.m:
	Define the types necessary for termination2_info pragmas.

	Change the cannot_loop constructor of the generic_termination_info
	type so it has a polymorphic argument.  The new analyser stores
	information in it.

	Fix some spelling errors in some of the comments

compiler/prog_io_pragma.m:
	Parse termination2_info pragmas.

compiler/error_util.m:
	Add function versions of sorry/2 and unexpected/2.

compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
compiler/termination.m
compiler/term_pass2.m
compiler/term_util.m:
	Minor changes to confrom to the above.
2005-04-07 06:32:17 +00:00
Mark Brown
4427723508 Remove the assumption made by polymorphism.m that all type variables
Estimated hours taken: 240
Branches: main

Remove the assumption made by polymorphism.m that all type variables
appearing in class constraints also appear in the type being constrained.
This is a first step towards adding functional dependencies, since in the
presence of functional dependencies (or "improvement" in general) this
assumption no longer holds.

The assumption made by polymorphism manifests itself in the fact that
constraints on atomic goals are reconstructed by unifying the types of
formal parameters with the types of actual arguments, and then applying
the resulting substitution to the constraints.  Any type variables in
constraints that don't appear in the formal parameters will therefore
remain unbound.

This change overcomes the assumption by building up a map from constraint
identifiers to constraints during typechecking, and then looking up this
map in order to reconstruct the constraint during the polymorphism
transformation.

To support this, the type 'class_constraint' has been removed and replaced
by two distinct types, 'prog_constraint' and 'hlds_constraint'.  The former
is part of the parse tree and holds the same information as the old
class_constraint.  The latter is part of the HLDS, and is used during
typechecking; in addition to the information in prog_constraints, it also
stores a set of identifiers that represent where the constraint came from.
These identifiers are used as the keys in the aforementioned map.

At this stage the constraint identifiers are only used by typechecking to
build the constraint map.  Other passes use either prog_constraints or
hlds_constraints with an empty set of identifiers.

compiler/hlds_data.m:
	Define the constraint_id type, which is used to uniquely identify
	class constraints.  A better scheme than this one has been suggested,
	but that will be left to a later change.  An XXX comment to that
	effect has been added.

	Define the hlds_constraint type, which is like prog_constraint but
	it also includes a set of constraint_ids.  Define a set of predicates
	to initialise and manipulate these.

	Define the constraint_map type here.  Move the definition of
	constraint_proof_map to here, where it more sensibly belongs.

	Update the comments in hlds_instance_defn slightly, with information
	that I found I needed to know when making this change.

compiler/hlds_pred.m:
	Add a field to the pred_info to store the constraint_map.

	Move the definition of constraint_proof_map from here.

compiler/hlds_out.m:
	Print out a representation of the constraint map if it isn't empty.

compiler/type_util.m:
	Change the predicates that used to operate on class_constraints so
	that they now operate on hlds_constraints.  The old versions of these
	predicates have now moved to prog_util.

	Add some utility predicates to manipulate constraint_maps.

	Add a predicate to apply a variable renaming to constraint_proof_maps.

compiler/prog_data.m:
	Rename class_constraint(s) to prog_constraint(s).

compiler/prog_util.m:
	Provide a set of predicates for manipulating prog_constraints.

compiler/typecheck.m:
	Ensure that goal_paths are filled in before the first iteration
	of typechecking.

	Pass the hlds_goal_info down through typecheck_goal_2 so that the
	goal_path can be retrieved when needed to assign identifiers to
	constraints.  Thread the goal_path through to wherever it is needed.

	Store hlds_constraints in the args_type_assign rather than
	prog_constraints, so that the required information is available
	when creating the new set of type_assigns.  Do likewise for the
	cons_type_info type.  Don't pass the module_info through
	make_pred_cons_info*, since it isn't used.  Do pass the goal_path,
	though, so that constraints in cons_type_infos can be given the
	correct identifier.

	Add a constraint_map field to the typecheck_info, initialised to empty.

	When retrieving the final information from a typecheck_info, return
	the resulting constraint_map, after applying any type bindings.
	Ensure that any constraints that may not have been entered into the
	constraint_map are put there now.  Call the new predicate in type_util
	to rename the constraint_proof_map, rather than doing it longhand
	here.

	Make the following changes to context reduction:

		- Thread the constraint_map through, so that it can be updated
		as constraints are eliminated.

		- Instead of simply calling sort_and_remove_dups on the
		set of constraints remaining after one iteration, merge the
		constraints in such a way that the complete set of
		constraint_ids is retained.

		- Disregard the constraint_ids when deleting newly introduced
		constraints that are equivalent to constraints that have
		already been seen.

		- Simplify the code of find_matching_instance_rule_2 by
		moving the deterministic code out of the condition of the
		if-then-else.

	Move find_first_map into the library.

compiler/polymorphism.m:
	Ensure that the goal_path is set when constructing lambda goals.

	In process_call, look up the constraints in the constraint_map
	using the goal_path as part of the key, rather than calculating
	the constraints by applying the ParentToActual type substitution.
	Rearrange this code so that it is divided into easier to understand
	blocks.

	Add a field to the poly_info to store the constraint_map, and
	initialise it from the pred_info.

compiler/goal_path.m:
	Fill slots in lambda_goals, since constraints inside these will
	otherwise not be identified properly.  The goal_paths inside here
	do not entirely make sense, since there is no goal_path_step for
	the lambda_goal itself.  However, there is enough information
	retained to distinguish these goal_paths from any other possible
	goal_path, which is all that we require to identify constraints.

	Add a warning not to fill in the goal slots between the typechecking
	and polymorphism passes, since doing so could potentially render the
	constraint_maps incorrect.

compiler/make_hlds.m:
	Initialise the constraint_map to empty in pred_infos.

	Move the code for updating the superclass_table into a separate
	predicate.  Initially this change was made because, in an earlier
	version of the change, the superclass_table had some extra
	information that needed to be filled in.  That part of the change
	is not needed in this diff, but the new predicate simplifies the
	code a bit so I've left it there.

compiler/check_typeclass.m:
	Convert the prog_constraints into hlds_constraints before passing
	them to typecheck.reduce_context_by_rule_application.  They are
	assigned no identifiers, since these constraints are not required
	to be put into the constraint map.

	Change the name of the function get_constraint_id to
	get_constraint_class_id, since it would now be ambiguous otherwise.

compiler/cse_detection.m:
	Import parse_tree__prog_util, since that is where renamings of
	prog_constraints are now defined.

compiler/higher_order.m:
	Initialise pred_infos here with an empty constraint_map.

compiler/post_typecheck.m:
	When binding type vars to void, apply the void substitution to the
	constraint_map.

compiler/table_gen.m:
	Pass the constraint_map when creating a new pred_info.

compiler/unused_args.m:
	Create the pred_info with an empty constraint_map.  The constraint_map
	won't be used by this stage anyway.

compiler/*.m:
	Update to use the new type names.  Also update to use the existing
	type synonyms typeclass_info_varmap and constraint_proof_map.

	Change names of predicates and functions to use prog_constraint
	instead of class_constraint, where applicable.

library/list.m:
	Add find_first_map from typecheck.  Also add find_first_map{2,3},
	since at one stage during development I needed find_first_map3, and,
	although it's not used in the current diff, there is little point
	removing it now.
2005-04-01 14:29:19 +00:00
Zoltan Somogyi
8b8b3b7d3f Replace the some() HLDS goal with a more general scope() goal, which can be
Estimated hours taken: 12
Branches: main

Replace the some() HLDS goal with a more general scope() goal, which can be
used not just for existential quantification but also for other purposes.

The main such purposes are new goal types that allow the programmer
to annotate arbitrary goals, and not just whole procedure bodies, with the
equivalents of promise_pure/promise_semipure and promise_only_solution:

	promise_pure ( <impure/semipure goal> )
	promise_semipure ( <impure goal> )

	promise_equivalent_solutions [OutVar1, OutVar2] (
		<cc_multi/cc_nondet goal that computed OutVar1 & OutVar2>
	)

Both are intended to be helpful in writing constraint solvers, as well as in
other situations.

doc/reference_manual.texi:
	Document the new constructs.

library/ops.m:
	Add the keywords of the new constructs to the list of operators.
	Since they work similarly to the "some" operator, they have the same
	precedence.

compiler/hlds_goal.m:
	Replace the some(Vars, SubGoal) HLDS construct, with its optional
	keep_this_commit attribute, with the new scope(Reason, SubGoal)
	construct. The Reason argument may say that this scope is an
	existential quantification, but it can also say that it represents
	a purity promise, the introduction of a single-solution context
	with promise_equivalent_solutions, or a decision by a compiler pass.

	It can also say that the scope represents a set of goals that all arise
	from the unraveling of a unification between a variable and a ground
	term. This was intended to speed up mode checking by significantly
	reducing the number of delays and wakeups, but the cost of the scopes
	themselves turned out to be bigger than the gain in modechecking speed.

	Update the goal_path_step type to refer to scope goals instead of just
	existential quantification.

compiler/prog_data.m:
	Add new function symbols to the type we use to represent goals in items
	to stand for the new Mercury constructs.

compiler/prog_io_goal.m:
	Add code to read in the new language constructs.

compiler/prog_io_util.m:
	Add a utility predicate for use by the new code in prog_io_goal.m.

compiler/make_hlds.m:
	Convert the item representation of the new constructs to the HLDS
	representation.

	Document how the from_ground_term scope reason would work, but do not
	enable the code.

compiler/purity.m:
	When checking the purity of goals, respect the new promise_pure and
	promise_semipure scopes. Generate warnings if such scopes are
	redundant.

compiler/det_analysis.m:
	Make the insides of promise_equivalent_solutions goals single solution
	contexts.

compiler/det_report.m:
	Provide mechanisms for reporting inappropriate usage of
	promise_equivalent_solutions goals.

compiler/instmap.m:
	Add a utility predicate for use by one of the modules above.

compiler/deep_profiling.m:
	Use one of the new scope reasons to prevent simplify from optimizing
	away commits of goals that have been made impure, instead of the old
	keep_this_commit goal feature.

compiler/modes.m:
	Handle from_ground_term scopes when present; for now, they won't be
	present, since make_hlds isn't creating them.

compiler/options.m:
	Add two new compiler options, for use by implementors only, to allow
	finer control over the amount of output one gets with --debug-modes.
	(I used them when debugging the performance of the from_ground_term
	scope reason.) The options are --debug-modes-minimal and
	--debug-modes-verbose.

compiler/handle_options.m:
	Make the options that are meaningful only in the presence of
	--debug-modes imply --debug-modes, since this allows more convenient
	(shorter) invocations.

compiler/mode_debug.m:
	Respect the new options when deciding how much data to print
	when debugging of the mode checking process is enabled.

compiler/switch_detect.m:
	Rename a predicate to make it differ from another predicate by more
	than just its arity.

compiler/passes_aux.m:
	Bring this module up to date with our current style guidelines,
	by using state variable syntax where appropriate.

compiler/*.m:
	Minor changes to conform to the change in the HLDS and/or parse tree
	goal type.

mdbcomp/program_representation.m:
	Rename the some goal to the scope goal, and the same for path steps,
	to keep them in sync with the HLDS.

browser/declarative_tree.m:
	Conform to the change in goal representations.

tests/hard_coded/promise_equivalent_solutions_test.{m,exp}:
	A new test case to test the handling of the
	promise_equivalent_solutions construct.

tests/hard_coded/Mmakefile:
	Enable the new test.

tests/hard_coded/purity/promise_pure_test.{m,exp}:
	A new test case to test the handling of the promise_pure and
	promise_semipure constructs.

tests/hard_coded/purity/Mmakefile:
	Enable the new test.

tests/invalid/promise_equivalent_solutions.{m,err_exp}:
	A new test case to test the error messages for improper use of the
	promise_pure and promise_semipure constructs.

tests/invalid/Mmakefile:
	Enable the new test.
2005-03-24 05:34:41 +00:00
Zoltan Somogyi
3c60c0e485 Change a bunch of modules to import only one module per line, even
Estimated hours taken: 4
Branches: main

compiler/*.m:
	Change a bunch of modules to import only one module per line, even
	from the library.

compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
	Convert these modules to our current coding style. Use state variables
	where appropriate. Use predmode declarations where possible.
2005-03-22 06:40:32 +00:00
Zoltan Somogyi
99af5e671a Provide a mechanism to allow a predicate to be defined as a foreign_proc for
Estimated hours taken: 10
Branches: main

Provide a mechanism to allow a predicate to be defined as a foreign_proc for
one backend and as external for another backend. The intended use is to
implement builtin_catch in exception.m, which cannot be implemented as a
foreign_proc for hlc grades, but whose implementation as external for the
LLDS grades requires handwriting extremely error-prone code and data structures
that the compiler could generate reliably.

The mechanism is two language extensions. One allows :- external declarations
such as

	:- external(high_level_backend, p/3).

The second allows foreign_procs such as

	:- pragma foreign_proc("C",
	       p(N::in, IO0::di, IO::uo),
	       [will_not_call_mercury, promise_pure, low_level_backend],
	       ...

compiler/prog_data.m:
	Add an extra field to the items for `:- external' declarations to
	allow hold the optional backend designation.

	Add an extra optional attribute to foreign_procs to handle the
	backend designation.

compiler/prog_io_pragma.m:
	Change the code for reading external declarations to handle the new
	attribute.

compiler/prog_io_pragma.m:
	Change the code for reading foreign_proc attributes to handle the new
	attribute.

compiler/make_hlds.m:
	Ignore external declarations and foreign_proc definitions if they are
	for the wrong backend.

	Use state variables in a place that can benefit from it.

compiler/hlds_module.m:
	Clean up some formatting.

compiler/equiv_type.m:
compiler/ml_code_gen.m:
compiler/module_qual.m:
compiler/modules.m:
	Conform to the changed data structures in prog_data.

doc/reference_manual.texi:
	Add commented-out documentation of the extension to foreign_procs.
	There is no existing documentation of :- external to update.

tests/hard_coded/backend_external.{m,exp,exp2}:
	New test case for the new language extensions.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2005-03-10 02:36:04 +00:00
Julien Fischer
f9f67d679b Add a new foreign proc attribute `maybe_thread_safe' and
Estimated hours taken: 4.5
Branches: main

Add a new foreign proc attribute `maybe_thread_safe' and
a new compiler option `--maybe-thread-safe'.

The thread safety of foreign procs that have the `maybe_thread_safety'
attribute set is dependent upon the value of the `--maybe-thread-safe'
option.  This facility is intended for use in writing bindings to
libraries whose thread safety is itself conditional.

At quite an early stage `maybe_thread_safe' is turned into
either `thread_safe' or `not_thread_safe' depending on the
value of the `--maybe-thread-safe' option.  In particular,
it will appear as either `thread_safe' or `not_thread_safe'
in any optimization interfaces.

compiler/prog_io_pragma.m
compiler/prog_data.m
	Parse the new foreign code attribute, `maybe_thread_safe'.

	Fix a place where the line width was > 79 characters.

compiler/options.m:
compiler/globals.m:
compiler/handle_options.m:
	Add a new option `--maybe-thread-safe' that tells the compiler
	how to handle `maybe_thread_safe' foreign code attributes.

compiler/make_hlds.m:
	Convert any `maybe_thread_safe' attributes into `thread_safe'
	or `not_thread_safe' attributes depending upon the value of the
	`--maybe-thread-safe' option.

compiler/pragma_c_gen.m:
	Call unexpected/2 if we encounter the `maybe_thread_safe'
	attribute here, as it should have been replaced with either
	`thread_safe' or `not_thread_safe' by this point.

doc/reference_manual.texi:
doc/user_guide.texi:
	Document the new attribute and option.

vim/syntax/mercury.vim:
	Highlight the new attribute.
2005-02-24 06:07:12 +00:00
Peter Wang
59d2d4a573 This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17
Branches: main

This adds a module mdbcomp__trace_counts that reads in the
.mercury_trace_counts files produced by the compiler's trace mechanism.
The format of said files was slightly changed.

As the new module is to be used by the compiler and the debugger, it is
placed in the mdbcomp module.  This required bringing some types from the
compiler into a new module within mdbcomp.

browser/trace_counts.m:
	New module for reading execution trace summaries.

browser/prim_data.m:
	New module holding types and predicates moved in from the compiler.
	Types:
		pred_or_func, sym_name, module_name, proc_label,
		special_pred_id, trace_port
	Predicates:
		string_to_sym_name, insert_module_qualifier

	The mode field of proc_label is now an int instead of a proc_id
	to avoid pulling proc_id into mdbcomp.

browser/mdbcomp.m:
	Add trace_counts and prim_data to the mdbcomp module.

browser/declarative_execution.m:
	Renamed mdb's definition of module_name to flat_module_name
	to avoid conflicts with the definition in mdbcomp__prim_data.

runtime/mercury_trace_base.c:
	In the format of .mercury_trace_counts, write module and predicate
	names now use quoted atom syntax so that names with spaces and
	non-printable characters can be machine-parsed.

browser/:
compiler/:
	Many changes to account for movement of types, and the change to
	proc_label.
2005-01-19 03:11:22 +00:00
Julien Fischer
6ce720be87 Add the foreign proc. attribute `will_not_throw_exception'.
Estimated hours taken: 6
Branches: main

Add the foreign proc. attribute `will_not_throw_exception'.
This allows the user to promise the exception analysis that
foreign procs that do not have determinism erroneous and make
calls back to Mercury will not throw an exception.

The behaviour for erroneous foreign procs and those that do
not make calls back to Mercury is unchanged.

compiler/prog_data.m:
compiler/prog_io_pragma.m:
	Handle the new attribute.

compiler/exception_analysis.m:
	If the user has provided the `will_not_throw_exception'
	attribute on a foreign proc that makes calls back to
	Mercury then set then have the exception analysis
	take account of this information.

	Fix a typo.

compiler/det_analysis.m:
compiler/det_report.m:
	Emit an error if the `will_not_throw_exception'
	attribute is used on foreign procs. that have
	been declared erroneous.

doc/reference_manual.texi:
	Mention the new foreign proc attribute.

tests/term/Mmakefile:
tests/term/Mercury.options:
tests/term/promise_no_throw_exception.m:
tests/term/promise_no_throw_exception.trans_opt_exp:
tests/invalid/Mmakefile:
tests/invalid/erroneous_promise_throw.m:
tests/invalid/erroneous_proimse_throw.err_exp:
	Test cases for the above.

vim/syntax/mercury.vim:
	Highlight the annotation appropriately.
2004-12-10 07:03:45 +00:00
Julien Fischer
980afa90c5 Add an analysis that tries to identify those procedures
Estimated hours taken: 70
Branches: main

Add an analysis that tries to identify those procedures
in a module that will not throw an exception.
(I guess it may be more accurate to call it a non-exception analysis).

For those procedures that might throw exceptions the
analysis further tries to distinguish between those
that throw an exception as a result of a call to throw
and those that throw an exception as a result of a
call to a unification/comparison predicate that may involve
calls to user-defined equality/comparison predicates that throw
exceptions.

This sort of thing used to be done by the termination analysis,
where being able to prove termination was equated with not
throwing an exception.  This no longer works now that
the termination analyser considers exception.throw/1 to
be terminating - and in fact it never quite worked anyway
because the termination analyser was not handling things
like foreign code and user-defined equality and comparison
predicates correctly.

There are currently a few limitations, the main ones being:

* we currently use transitive-intermodule optimization rather
  than the intermodule-analysis framework.  This may causes
  problems when their are cycles in the module dependency graph.

* we currently assume that all calls to higher-order predicates
  may result in an exception being thrown.

* we currently assume that all foreign procs that make calls
  back to Mercury may throw exceptions.

* we currently assume that all solver types and existentially
  quantified types might result in an exception being thrown.

It should be possible to remove these limitations in later
versions.

This diff also modifies the cannot_loop_or_throw family of
predicates in goal_form.m.  There are now two versions of each
predicate; one that can make use of information from the
termination and exception analyses and one that cannot.

compiler/exception_analysis.m:
	The new analysis.

compiler/prog_data.m:
compiler/prog_io_pragma.m:
	Handle `:- pragma exceptions(...' in .opt and .trans_opt files.

compiler/hlds_module.m:
	Attach information to each module about whether each procedure
	in the module may throw an exception.

compiler/goal_form.m:
	Rewrite the predicates in this module so that they can
	optionally use information from the exception analysis.

compiler/constraint.m:
compiler/goal_util.m:
compiler/rl.m:
compiler/simplify.m:
	Use information from exception and termination analyses
	when performing various optimizations.

compiler/type_util.m:
	Add a new predicate type_util.type_is_existq/2 that tests
	whether a type is existentially quantified or not.

compiler/mercury_compile.m:
compiler/mercury_to_mercury.m:
compiler/modules.m:
compiler/options.m:
compiler/module_qual.m:
compiler/make_hlds.m:
compiler/recompilation.version.m:
compiler/trans_opt.m:
compiler/transform_hlds.m:
	Minor changes needed by the above.

NEWS:
compiler/notes/compiler_design.html:
doc/user_guide.texi:
	Mention the new analysis.

tests/README:
	Include a description of the term directory.

tests/term/Mercury.options:
tests/term/Mmakefile:
tests/term/exception_analysis_test.m:
tests/term/exception_analysis_test.trans_opt_exp:
	Add a test for the new analysis.
2004-10-16 15:08:55 +00:00
Julien Fischer
d721ca08de Remove support for NU-Prolog style `when' declarations.
Estimated hours taken: 0.5
Branches: main

Remove support for NU-Prolog style `when' declarations.
These have been deprecated for some time.

NEWS
	Mention this change.

compiler/prog_data.m:
compiler/prog_io.m:
	Remove remaining support for when declarations.

tests/general/interpreter.m:
tests/valid/lazy_list.m:
	Remove some old when declarations.
2004-09-29 04:36:28 +00:00
Ralph Becket
bf2e37d199 Implemented the solver types design.
Estimated hours taken: 100s
Branches: main

Implemented the solver types design.

Solver types provide the means for adding constrained types to Mercury
programs.  A variable of a constrained type may have constraints placed
on it, limiting the values it may be bound to, *before* the variable is
actually bound to a particular value (cf. CLP(Z), CLP(R), CLP(FD) etc.)

Improve the scheduling of solver type goals by preferring deconstructions
over constructions followed by unifications.  This is arranged by allowing
solver type initialisation calls to be inserted only when all else fails.
(XXX This implementation is O(n^2).  I will fix things if this becomes an
issue in practice.)

I have also made some small, opportunistic cosmetic changes.  This
implementation has evolved through several design changes, during which some
functionality was added then later removed - I elected to preserve any
cleaned-up replacement code if removing the no-longer-needed-by-the-
solver-types-design functionality was easy to do.

doc/reference_manual.texi:
	Document solver types.

compiler/hlds_data.m:
	Changed the du_type and foreign_type constructors appropriately
	and added a new solver_type constructor.

compiler/hlds_out.m:
	Improved the code to write out the `where ...' part of
	a type definition and moved it to mercury_output.m.

compiler/inst_match.m:
	Added the pred inst_is_any/1.

compiler/inst_util.m:
	Added the pred inst_contains_unconstrained_var/1.

compiler/make_hlds.m:
	Added processing for solver types, in particular adding the
	compiler generated declarations and implementations of the
	conversion functions.

compiler/mercury_to_mercury.m:
	Added predicate mercury_output_where_attributes.

compiler/mode_info.m:
	Added a new field to mode_info to indicate whether solver type
	initialisation calls can be inserted by modecheck_conj_list_2.

compiler/mode_errors.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
	The compiler now inserts calls to initialisation preds, where
	necessary, before calls and at the end of procedures.  It does
	not yet do this at the end of disjuncts and its scheduling
	policy is naive (i.e. it performs terribly.)

	Added modecheck_conj_list_3 which allows modecheck_conj_list_2
	to insert initialisation calls for a single goal, then repeats
	if this succeeded in scheduling some delayed goals.

compiler/modules.m:
	XXX Reviewers: please look at the `rafe: XXX' comments and
	advise!

compiler/prog_data.m:
	Added the solver_type constructor and the special_type_details
	and solver_type_details types.

compiler/prog_io.m:
compiler/prog_io_pragma.m:
	Parse the new syntax.
	Replaced get_maybe_equality_compare_preds with
	parse_type_decl_where_part_if_present.

compiler/prog_mode.m:
	Added funcs in_mode/1, out_mode/1, in_any_mode/0,
	out_any_mode/0, and any_inst/0.

compiler/special_pred.m:
	Added `initialise' constructor to special_pred_id.
	Changed special_pred_name to include the type name and arity
	with `__Unify__', `__Inex__' etc.

compiler/type_util.m:
	Added some more utility funcs/preds.

compiler/unify_proc.m:
	Generate the forwarding predicates for initialisation preds.

compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/foreign.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_code_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/rl_key.m:
compiler/table_gen.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/type_ctor_info.m:
compiler/typecheck.m:
	Propagate the changes to hlds_goal_expr.
2004-09-05 23:52:54 +00:00
Zoltan Somogyi
e854a5f9d9 Major improvements to tabling, of two types.
Estimated hours taken: 32
Branches: main

Major improvements to tabling, of two types. The first is the implementation
of the loopcheck and memo forms of tabling for model_non procedures, and the
second is a start on the implementation of a new method of implementing
minimal model tabling, one that has the potential for a proper fix of the
problem that we currently merely detect with the pneg stack (the detection
is followed by a runtime abort). Since this new method relies on giving each
own generator its own stack, the grade component denoting it is "mmos"
(minimal model own stack). The true name of the existing method is changed
from "mm" to "mmsc" (minimal model stack copy). The grade component "mm"
is now a shorthand for "mmsc"; when the new method works, "mm" will be changed
to be a shorthand for "mmos".

configure.in:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
compiler/options.m:
	Handle the new way of handling minimal model grades.

scripts/mgnuc.in:
compiler/compile_target_code.m:
	Conform to the changes in minimal model grade options.

compiler/table_gen.m:
	Implement the transformations required by the loopcheck and memo
	tabling of model_non procedures, and the minimal model own stack
	transformation.

	The new implementation transformations use foreign_procs with extra
	args, since there is no point in implementing them both that way and
	with separate calls to library predicates. This required making the
	choice of which method to use at the top level of each transformation.

	Fix an oversight that hasn't caused problems yet but may in the future:
	mark goals wrapping the original goals as not impure for determinism
	computations.

compiler/handle_options.m:
	Handle the new arrangement of the options for minimal model tabling.
	Detect simultaneous calls for both forms of minimal model tabling,
	and generate an error message. Allow for more than one error message
	generated at once; report them all once rather than separately.

compiler/globals.m:
	Add a mechanism to allow a fix a problem detected by the changes
	to handle_options: the fact that we currently may generate a usage
	message more than once for invocations with more than one error.

compiler/mercury_compile.m:
compiler/make.program_target.m:
compiler/make.util.m:
	Use the new mechanism in handle_options to avoid generating duplicate
	usage messages.

compiler/error_util.m:
	Add a utility predicate for use by handle_options.

compiler/hlds_pred.m:
	Allow memo tabling for model_non predicates, and handle own stack
	tabling.

compiler/hlds_out.m:
	Print information about the modes of the arguments of foreign_procs,
	since this is useful in debugging transformations such as tabling
	that generate them.

compiler/prog_data.m:
compiler/layout_out.m:
compiler/prog_out.m:
runtime/mercury_stack_layout.h:
	Mention the new evaluation method.

compiler/goal_util.m:
	Change the predicates for creating calls and foreign_procs to allow
	more than one goal feature to be attached to the new goal. table_gen.m
	now uses this capability.

compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/typecheck.m:
compiler/unify_proc.m:
	Conform to the changes in goal_util.

compiler/code_info.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
	Conform to the new the options controlling minimal model
	tabling.

compiler/prog_util.m:
	Add a utility predicate for use by table_gen.m.

library/std_util.m:
	Conform to the changes in the macros for minimal model tabling grades.

library/table_builtin.m:
	Add the types and predicates required by the new transformations.

	Delete an obsolete comment.

runtime/mercury_grade.h:
	Handle the new minimal model grade component.

runtime/mercury_conf_param.h:
	List macros controlling minimal model grades.

runtime/mercury_tabling.[ch]:
	Define the types needed by the new transformations,

	Implement the performance-critical predicates that need to be
	hand-written for memo tabling of model_non predicates.

	Add utility predicates for debugging.

runtime/mercury_tabling_preds.h:
	Add the implementations of the predicates required by the new
	transformations.

runtime/mercury_mm_own_stacks.[ch]:
	This new module contains the first draft of the implementation
	of the own stack implementation of minimal model tabling.

runtime/mercury_imp.h:
	Include the new file if the grade needs it.

runtime/Mmakefile:
	Mention the new files, and sort the lists of filenames.

runtime/mercury_tabling_macros.h:
	Add a macro for allocating answer blocks without requiring them to be
	pointed to directly by trie nodes.

runtime/mercury_minimal_model.[ch]:
	The structure type holding answer lists is now in mercury_tabling.h,
	since it is now also needed by memo tabling of model_non predicates.
	It no longer has a field for an answer num, because while it is ok
	to require a separate grade for debugging minimal model tabling,
	it is not ok to require a separate grade for debugging memo tabling
	of model_non predicates. Instead of printing the answer numbers,
	print the answers themselves when we need to identify solutions
	for debugging.

	Change function names, macro names, error messages etc where this is
	useful to distinguish the two kinds of minimal model tabling.

	Fix some oversights wrt transient registers.

runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
	With own stack tabling, each subgoal has its own context, so record
	the identity of the subgoal owning a context in the context itself.
	The main computation's context is the exception: it has no owner.

	Record not just the main context, but also the contexts of subgoals
	in the engine.

	Add variables for holding the sizes of the det and nondet stacks
	of the contexts of subgoals (which should in general be smaller
	than the sizes of the corresponding stacks of the main context),
	and initialize them as needed.

	Initialize the variables holding the sizes of the gen, cut and pneg
	stacks, even in grades where the stacks are not used, for safety.

	Fix some out-of-date documentation, and conform to our coding
	guidelines.

runtime/mercury_memory_zones.[ch]:
	Add a function to test whether a pointer is in a zone, to help
	debugging.

runtime/mercury_debug.[ch]:
	Add some functions to help debugging in the presence of multiple
	contexts, and factor out some common code to help with this.

	Delete the obsolete, unused function MR_printdetslot_as_label.

runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
	Move a bootstrapping #define from mercury_context.h to
	mercury_bootstrap.h.

runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
	Move a bootstrapping #define from mercury_context.h to
	mercury_bootstrap.h.

runtime/mercury_types.h:
	Add some more forward declarations of type names.

runtime/mercury_dlist.[ch]:
	Rename a field to avoid assignments that dereference NULL.

runtime/mercury_debug.c:
runtime/mercury_memory.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.[ch]:
trace/mercury_trace_util.c
	Update uses of the macros that control minimal model tabling.

runtime/mercury_stack_trace.c:
	Provide a mechanism to allow stack traces to be suppressed entirely.
	The intention is that by using this mechanism, by the testing system
	won't have to provide separate .exp files for hlc grades, nondebug
	LLDS grades and debug LLDS grades, as we do currently. The mechanism
	is the environment variable MERCURY_SUPPRESS_STACK_TRACE.

tools/bootcheck:
tools/test_mercury:
	Specify MERCURY_SUPPRESS_STACK_TRACE.

trace/mercury_trace.c:
	When performing retries across tabled calls, handle memo tabled
	model_non predicates, for which the call table tip variable holds
	a record with a back pointer to a trie node, instead of the trie node
	itself.

trace/mercury_trace_internal.c:
	When printing tables, handle memo tabled model_non predicates. Delete
	the code now moved to runtime/mercury_tabling.c.

	Add functions for printing the data structures for own stack minimal
	model tabling.

tests/debugger/print_table.{m,inp,exp}:
	Update this test case to also test the printing of tables for
	memo tabled model_non predicates.

tests/debugger/retry.{m,inp,exp}:
	Update this test case to also test retries across memo tabled
	model_non predicates.

tests/tabling/loopcheck_nondet.{m,exp}:
tests/tabling/loopcheck_nondet_non_loop.{m,exp}:
	New test cases to test loopcheck tabled model_non predicates.
	One test case has a loop to detect, one doesn't.

tests/tabling/memo_non.{m,exp}:
tests/tabling/tc_memo.{m,exp}:
tests/tabling/tc_memo2.{m,exp}:
	New test cases to test memo tabled model_non predicates.
	One test case has a loop to detect, one has a need for minimal model
	tabling to detect, and the third doesn't have either.

tests/tabling/Mmakefile:
	Add the new test cases, and reenable the existing tc_loop test case.

	Rename some make variables and targets to make them better reflect
	their meaning.

tests/tabling/test_mercury:
	Conform to the change in the name of the make target.
2004-07-20 04:41:55 +00:00
Zoltan Somogyi
bf0a828169 Provide a mechanism for working around a problem with the Java implementation
Estimated hours taken: 1
Branches: main

Provide a mechanism for working around a problem with the Java implementation
of the nondet and multi modes of catch_impl in exception.m. The workaround
is not intended to be a long term solution.

compiler/ml_code_gen.m:
	Allow ordinary foreign_procs for nondet and multi procedures
	if they have the new foreign_proc attribute ordinary_despite_detism.

compiler/prog_data.m:
	Add the new attribute.

compiler/prog_io_pragma.m:
	Parse the new attribute.
2004-07-06 04:18:50 +00:00
Zoltan Somogyi
e4b0328ade Provide a mechanism for declaring foreign types that can be operated on by
Estimated hours taken: 4
Branches: main

Provide a mechanism for declaring foreign types that can be operated on by
compare_representation. The intended use of the mechanism is to declare
a foreign type to represent proc_layouts in the declarative debugger,
as part of the representation of atoms; since atoms are keys in maps
in the oracle, they are input to compare_representation.

Since we don't want the result of compare_representation to change as
execution proceeds, we require an assertion that the foreign value is
stable, i.e. that the value of the foreign type variable completely
determines the data it points to, directly and indirectly. Proc_layouts
are static, so this is not a problem. Being able to do the comparison
requires the foreign type to be an integral type or a pointer, which
is what the existing can_pass_as_mercury_type assertion promises.
The stability is promised by a new assertion.

For foreign types that have both assertions, we use a new type_ctor_rep,
which differs from the existing type_ctor_rep for foreign types by doing
a real comparison instead of an abort in compare_representation.

doc/reference_manual.texi:
	Document the new kind of assertion.

compiler/prog_data.m:
	Add the new kind of assertion.

compiler/prog_io_pragma.m:
	Parse the new kind of assertion.

compiler/rtti.m:
	Add the representation of the new type_ctor_rep. Factor out the
	stability of c_pointers as well as foreign types.

compiler/type_ctor_info.m:
	Generate the new type_ctor_rep for types with both assertions.

compiler/foreign.m:
	Export a predicate for use by type_ctor_info.m.

compiler/mercury_to_mercury.m:
	Print the new assertion.

compiler/*.m:
	Minor changes to conform to the diffs above.

	Use state variable notation.

library/rtti_implementation.m:
	Handle the new type_ctor_rep.

runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
java/runtime/TypeCtorRep.java:
	Add the new type_ctor_rep to the runtime.

runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
compiler/type_ctor_info.m:
	Increment the rtti version number.

	When we rely on the availability of this new capability,
	we should add a test for the new rtti version number to configure.in.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_term_size.h:
	Handle stable foreign types the same way as other foreign types.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
	Handle stable foreign types in a useful manner, relying on the
	assertions behind them.

tests/hard_coded/stable_foreign.{m,exp}:
	A test case for the handling of values of a stable foreign type.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2004-06-28 04:50:10 +00:00
Zoltan Somogyi
885fd4a387 Remove almost all dependencies by the modules of parse_tree.m on the modules
Estimated hours taken: 12
Branches: main

Remove almost all dependencies by the modules of parse_tree.m on the modules
of hlds.m. The only such dependencies remaining now are on type_util.m.

compiler/hlds_data.m:
compiler/prog_data.m:
	Move the cons_id type from hlds_data to prog_data, since several parts
	of the parse tree data structure depend on it (particularly insts).
	Remove the need to import HLDS modules in prog_data.m by making the
	cons_ids that refer to procedure ids refer to them via a new type
	that contains shrouded pred_ids and proc_ids. Since pred_ids and
	proc_ids are abstract types in hlds_data, add predicates to hlds_data
	to shroud and unshroud them.

	Also move some other types, e.g. mode_id and class_id, from hlds_data
	to prog_data.

compiler/hlds_data.m:
compiler/prog_util.m:
	Move predicates for manipulating cons_ids from hlds_data to prog_util.

compiler/inst.m:
compiler/prog_data.m:
	Move the contents of inst.m to prog_data.m, since that is where it
	belongs, and since doing so eliminates a circular dependency.
	The separation doesn't serve any purpose any more, since we don't
	need to import hlds_data.m anymore to get access to the cons_id type.

compiler/mode_util.m:
compiler/prog_mode.m:
compiler/parse_tree.m:
	Move the predicates in mode_util that don't depend on the HLDS to a new
	module prog_mode, which is part of parse_tree.m.

compiler/notes/compiler_design.m:
	Mention prog_mode.m, and delete the mention of inst.m.

compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
	Move the predicates that depend on HLDS out of mercury_to_mercury.m
	to hlds_out.m. Export from mercury_to_mercury.m the predicates needed
	by the moved predicates.

compiler/hlds_out.m:
compiler/prog_out.m:
	Move predicates for printing parts of the parse tree out of hlds_out.m
	to prog_out.m, since mercury_to_mercury.m needs to use them.

compiler/purity.m:
compiler/prog_out.m:
	Move predicates for printing purities from purity.m, which is part
	of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use
	them.

compiler/passes_aux.m:
compiler/prog_out.m:
	Move some utility predicates (e.g. for printing progress messages) from
	passes_aux.m to prog_out.m, since some predicates in submodules of
	parse_tree.m need to use them.

compiler/foreign.m:
compiler/prog_data.m:
	Move some types from foreign.m to prog_data.m to allow the elimination
	of some dependencies on foreign.m from submodules of parse_tree.m.

compiler/*.m:
	Conform to the changes above, mostly by updating lists of imported
	modules and module qualifications. In some cases, also do some local
	cleanups such as converting predicate declarations to predmode syntax
	and fixing white space.
2004-06-14 04:17:03 +00:00
Zoltan Somogyi
27d766c073 Add a mechanism that allows foreign_decl pieces of code to remain local
Estimated hours taken: 4
Branches: main

Add a mechanism that allows foreign_decl pieces of code to remain local
to the module. This is needed by the robdd module, which I want to add
to the library.

doc/reference_manual.texi:
	Document the new mechanism, which is an optional field in foreign_decl
	pragmas.

compiler/foreign.m:
	Add a flag to foreign_decls that says whether they are local to
	their defining module, or exported to other modules.

compiler/prog_data.m:
	Add a field to the foreign_decl item to hold this flag.

compiler/prog_io_pragm.m:
	Parse the optional field in foreign_decl pragmas that specifies this
	flag.

compiler/mercury_to_mercury.m:
	Print the field in foreign_decl items.

compiler/make_hlds.m:
	Transmit the field from the item to the HLDS.

compiler/mercury_compile.m:
	When generating the list of foreign_decls to put at the start of a C
	file, do not enclose the local declarations in the usual guards.
	These guards are defined by the header file, but having seen the header
	file doesn't guarantee any more that we have seen all the foreign_decls
	of the module we are compiling.

compiler/export.m:
compiler/mlds_to_c.m:
	When generating header files, only include a foreign_decl
	if it is not marked as local.

compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
	Ignore the local/exported distinction for foreign_decls for now.
	Implementing it for these languages may be nontrivial, and we don't
	yet need the capability.

compiler/hlds_module.m:
compiler/llds_out.m:
compiler/recompilation.version.m:
compiler/module_qual.m:
compiler/modules.m:
	Conform to the changes above.
2004-06-09 07:56:20 +00:00
Zoltan Somogyi
679bfe629b Extend foreign_type declarations with optional annotations that allow the
Estimated hours taken: 4
Branches: main

Extend foreign_type declarations with optional annotations that allow the
programmer to assert that values of the given type can be passed to and from
Mercury without boxing, via casts, which are faster.

doc/reference_manual.texi:
	Document the new assertions.

compiler/prog_io_pragma.m:
	Parse the new assertions in foreign_type declarations.

compiler/prog_data.m:
compiler/hlds_data.m:
	Extend the foreign_type item and the foreign_type kind of HLDS type
	definition with a field containing a list of assertions. Currently
	the only assertion available is the one described above.

compiler/llds.m:
	Extend the structures containing the input/output arguments of
	foreign_procs with the list of applicable assertions.

compiler/make_hlds.m:
	Transfer any assertions from foreign_type items to the HLDS type
	definition.

compiler/pragma_c_gen.m:
	Transfer any assertions from the HLDS type definition to the
	descriptions of the inputs and outputs.

compiler/llds_out.m:
	If the new assertion is present in the input/output arguments of
	foreign_procs, generate casts instead of boxing/unboxing code.

compiler/foreign.m:
compiler/intermod.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_gen.m:
compiler/mlds.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Minor changes to conform to the changes in data structures.

tests/hard_coded/foreign_type_assertion.{m,exp}
	New test case to test the handling of the new assertion.

tests/hard_coded/Mmakefile:
	Enable the new assertion in C grades.
2004-05-12 14:24:35 +00:00
Zoltan Somogyi
ed8e8c2c1d Bring these compiler modules up to our current coding standards.
Estimated hours taken: 2
Branches: main

compiler/det_util.m:
compiler/hlds_goal.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/prog_data.m:
	Bring these compiler modules up to our current coding standards.
	Use predmode declarations and state variable syntax where relevant.
	Reorder arguments where this is needed for the use state variables.
	Make the order of predicate definitions correspond to the order of
	their declarations.

compiler/unique_modes.m:
	Conform to a changed argument order.
2004-03-31 08:52:24 +00:00
Zoltan Somogyi
5d6fd3bd6f Reduce the dependence of earlier parts of the compiler on the later ones.
Estimated hours taken: 4
Branches: main

Reduce the dependence of earlier parts of the compiler on the later ones.
Unnecessary import_module declarations in top level modules such as hlds.m
cause unnecessary recompilations when adding new types in later modules,
such as submodules of ll_backend.m. This change reduces the number of such
unnecessary imports.

There are no changes in algorithms, only functionality being moved around.

compiler/code_model.m:
	Change this module from being a submodule of backend_libs.m to being a
	submodule of hlds.m, since nothing in it is dependent on any backend.

compiler/arg_info.m:
compiler/code_util.m:
	Change arg_info.m from being a submodule of ll_backend.m to being a
	submodule of hlds.m, since most of it is applicable to all current
	and foreseeable backends. Move the one exported predicate that is
	ll_backend dependent, and its support predicates, to code_util.m.

compiler/backend_libs.m:
compiler/ll_backend.m:
compiler/hlds.m:
	Update include_module declarations in accordance with the above.

compiler/prog_data.m:
compiler/term_util.m:
	Instead of defining two separate types for holding argument size and
	termination information, one including HLDS-specific information (in
	term_util.m) and one not (in prog_data.m), use a polymorphic type
	defined in prog_data.m and two monomorphic instances.

compiler/termination.m:
compiler/mercury_to_mercury.m:
	Change the predicates for writing out argument size and termination
	information to handle the polymorphic type (we don't need special
	handling of the monomorphic versions), and move them from termination.m
	to mercury_to_mercury.m, since this allows us to avoid some
	undesirable dependencies.

compiler/base_typeclass_info.m:
compiler/hlds_code_util.m:
	Move the predicate make_instance_string from base_typeclass_info.m
	to hlds_code_util.m, again because it allows us to remove some
	undesirable dependencies.

compiler/top_level.m:
compiler/backend_libs.m:
compiler/check_hlds.m:
compiler/hlds.m:
compiler/ll_backend.m:
compiler/parse_tree.m:
compiler/transform_hlds.m:
	Delete some import_module declarations of other top level modules
	in these top level modules. Some imports were totally unnecessary.
	Some imports were useful in only a small minority of submodules;
	those submodules now import the necessary top level modules directly.

	Move remaining import_module declarations to the implementation section
	where this is feasible.

	Where we still need to import modules we ideally shouldn't, note why.

compiler/*.m:
	Update imports of code_util and arg_info.

	In some cases, import top level modules no longer imported by the
	parent module.

	In some cases, delete unnecessary imports.
2004-03-23 10:52:14 +00:00
Julien Fischer
677b02b68a Reposition a comment that ended up in the wrong place after
compiler/prog_data.m:
	Reposition a comment that ended up in the wrong place after
	my last change.
2004-02-25 02:38:49 +00:00
Julien Fischer
2031a8a552 Change how the termination analysis deals with foreign_procs.
Estimated hours taken: 19
Branches: main

Change how the termination analysis deals with foreign_procs.
Add `terminates' and `does_not_terminate' as foreign proc attributes.

Currently the termination analysis assumes that all procedures implemented
via the foreign language interface will terminate.  For foreign code
that does not make calls back to Mercury this is generally the behaviour
we want but for foreign code that does make calls back to Mercury we should
not assume termination because we do not know what Mercury procedures may be
called.

This change alters the termination analysis so that in the absence of
of any user supplied information foreign_procs that do not call Mercury
are considered terminating and those that do make calls back to Mercury
are non-terminating.  This new behaviour is safer than the old behaviour.
For example some of the compiler's optimization passes may rely on
information from the termination analysis about whether or not a predicate
will terminate.

The second part of this diff adds `terminates' and `does_not_terminate'
as foreign_proc attributes.  This is a cleaner way of specifying termination
properties than pragma terminates/does_not_terminate and it is also
more flexible than the pragmas.  For example, in cases where procedures have
both foreign and Mercury clauses, pragma terminates/does_not_terminate
declarations will apply to both.  Foreign code attributes allows us to
specify the termination properties of the foreign clauses and leave the
termination analysis to work out the termination properties of the
Mercury clauses.

compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma:
	Handle terminates/does_not_terminate as foreign proc attributes.

compiler/term_errors.m:
compiler/term_traversal.m:
compiler/termination.m:
	Handle terminates/does_not_terminate as foreign proc attributes.
	Check that the foreign proc attributes do not conflict with any
	termination pragmas that the user has supplied.
	Modify assumptions about the termination of foreign procs.
compiler/term_util.m:
	Move some utility predicates to this module.

doc/reference_manual.texi:
	Document new foreign proc attributes and the new behaviour
	of the termination analysis for foreign_procs.
	Fix a typo.

tests/term/Mmakefile:
tests/term/foreign_valid.m:
tests/term/foreign_valid.trans_opt_exp:
tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/foreign_term_invalid.m:
tests/warnings/foreign_term_invalid.exp:
	Test cases for the above.
2004-02-12 03:36:18 +00:00
Zoltan Somogyi
087f163712 Add field names to the constructor type.
Estimated hours taken: 0.1
Branches: main

compiler/prog_data.m:
	Add field names to the constructor type.
2003-12-23 03:10:39 +00:00
Zoltan Somogyi
fa9ca36d03 This diff makes several files easier to read and to maintain (as well as
Estimated hours taken: 5
Branches: main

This diff makes several files easier to read and to maintain (as well as
more than 400 lines shorter), but contains no changes in algorithms whatsoever.

compiler/deep_profiling.m:
compiler/foreign.m:
compiler/hlds_module.m:
compiler/hlds_data.m:
compiler/make_hlds.m:
compiler/post_typecheck.m:
compiler/prog_data.m:
compiler/purity.m:
compiler/type_util.m:
	Bring these modules into line with our current coding standards.

	Use predmode declarations and state variable syntax when appropriate.

	Reorder arguments of predicates where necessary for the use of state
	variable syntax, and where this improves readability.

	Replace predicates with functions where appropriate.

	Standardize indentation.

compiler/*.m:
	Conform to the changes above.
2003-12-21 05:04:38 +00:00