Commit Graph

32 Commits

Author SHA1 Message Date
Simon Taylor
98c2fbf51b Bug fixes.
Estimated hours taken: 12

Bug fixes.

tests/term/arit_exp.m still fails with --intermodule-optimization
due to a slightly different (but correct) trans_opt file being produced.

compiler/simplify.m
	Don't produce singleton disjunctions, since the code generator
	barfs on them. Use a `some' instead.
	Test case: tests/general/partition.m compiled with --deforestation.

compiler/unused_args.m
	Deconstructions where the arguments included `any' insts were
	not being handled correctly, due to inst_matches_binding
	failing for any->any.
	Test case: extras/trailed_update/samples/vqueens.m at -O3.
	Don't warn about predicates from `.opt' files having unused
	arguments, because in most cases the warning will be generated
	when compiling the imported module.

compiler/higher_order.m
	Fix a bug that caused compiler/modules.m to be miscompiled at
	-O3 --intermodule-optimization, due to curried arguments for
	multiple known higher-order arguments being passed to a
	specialised version in the wrong order.
	Test case: tests/hard_coded/ho_order2.m

compiler/mercury_compile.m
	Call intermod__update_pred_import_status when compiling to
	C at the same stage of the compilation as the `.opt' file
	was written to ensure that the same information is being used.
	Test case: tests/hard_coded/rational_test.m compiled with
	--intermodule-optimization failed because of a link error.
	Make sure polymorphism has been run before doing unused argument
	checking with --errorcheck-only. Otherwise the argument indices
	read in from `.opt' files are incorrect.

compiler/intermod.m
	Use code_util__compiler_generated to test if a called predicate
	is compiler generated, rather than looking for a call_unify_context
	(function calls have a call_unify_context).
	Add a progress message for updating the import status of predicates
	exported to `.opt' files.
	Fix a bug where the unused_args pragmas read in from the current
	module's `.opt' file were given an import_status of `imported' rather
	than `opt_imported' resulting in an error message from make_hlds.m.

compiler/dead_proc_elim.m
	Ensure that predicates used by instance declarations and
	`:- pragma export's are not eliminated by the dead_pred_elim
	pass before typechecking.
	Test case: most of the typeclass tests compiled with
	--intermodule-optimization.

compiler/hlds_goal.m
	Remove obsolete comments about the modes of a higher-order
	unification being incorrect after polymorphism, since that
	was fixed months ago.

compiler/options.m
	Reenable deforestation.
	Enable --intermodule-optimization and --intermod-unused-args
	at -O5 so they get tested occasionally.

compiler/handle_options.m
	Disable deforestation if --typeinfo-liveness is set, since
	there are bugs in the folding code if extra typeinfos are
	added to a new predicate's arguments by hlds_pred__define_new_pred.
	Disable higher_order.m if --typeinfo-liveness is set, since
	higher_order.m currently does not pass all necessary typeinfos
	to specialised versions or update the typeinfo_varmap of
	specialised versions.
	Test case: tests/valid/agc_ho_pred.m

tests/hard_coded/ho_order2.m
tests/hard_coded/ho_order2.exp
	Test case for higher_order.m.

tools/test_mercury
	Added --intermod-unused-args to the options for murlibobo.

extras/trailed_update/{samples,tests}/Mmakefile
	Add "-I.." to MGNUCFLAGS so gcc can find unsafe.h which
	is #included in c_header_code read from unsafe.opt.
1998-06-03 00:44:04 +00:00
Fergus Henderson
731ae2051f Allow a predicate to have matching cc' and non-cc' modes.
Estimated hours taken: 3

Allow a predicate to have matching `cc' and `non-cc' modes.

compiler/det_analysis.m:
	If there is a call to a cc procedure in a non-cc context,
	then search for a mode of that predicate which is
	identical to the called mode except that it is not cc.
	If such a mode is found, use it, rather than reporting
	an error.

compiler/modecheck_call.m:
	Add predicate modes_are_identical_bar_cc, for use by
	det_analysis.m.

NEWS:
LIMITATIONS:
doc/reference_manual.texi:
	Document the new feature and delete documentation about the
	lack of this feature.

tests/hard_coded/Mmakefile:
tests/hard_coded/cc_and_non_cc_test.m:
tests/hard_coded/cc_and_non_cc_test.exp:
	Add a test case for the new feature.
1998-05-30 15:23:14 +00:00
Fergus Henderson
935fbfe36e Add Mmake support for nested sub-modules.
Estimated hours taken: 6

Add Mmake support for nested sub-modules.

compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
	Pass down the source file name to various places.
	Store the source file name in the module_imports data structure.
	In various places, use this source file name instead of assuming
	that the source file name can be obtained from the module name.

compiler/modules.m:
	Change the generated .d and .dep files to use the source file names.
	Add hard-coded rules in the .d files if the source file name does not
	match the form expected by the pattern rules in scripts/Mmake.rules.
	XXX unfortunately the rules don't work right for parallel makes of
	    nested modules

scripts/Mmake.rules:
	Add a comment saying that any changes here might need to
	be duplicated in compiler/modules.m.

tests/hard_coded/Mmakefile:
tests/hard_coded/nested.m:
tests/hard_coded/nested2.m:
tests/hard_coded/nested.exp:
tests/hard_coded/nested2.exp:
	Add a couple of test cases for nested modules (XXX not enabled,
	due to the above-mentioned problem with parallel makes).

doc/reference_manual.texi:
	Update the "implementation bugs and limitations" section.

NEWS:
	Update the news about nested modules.
1998-05-27 04:00:54 +00:00
Fergus Henderson
44a5c5b2f8 Make the code a little bit more readable:
Estimated hours taken: 6

compiler/mercury_to_mercury.m:
compiler/mode_errors.m:
	Make the code a little bit more readable:
	use specific types rather than `bool' in a few places.

compiler/mercury_to_mercury.m:
	Fix bugs in the generation of interface files where it was
	outputting certain graphic tokens incorrectly.  In particular,
	it was outputting things like `module:?' without any parentheses,
	space, or quotes to separate the `:' as module qualifier from
	the symbol name.

tests/hard_coded/Mmakefile:
tests/hard_coded/quoting_bug.m:
tests/hard_coded/quoting_bug_test.m:
tests/hard_coded/quoting_bug_test.exp:
	Add some tests for the above-mentioned bug fix.

tests/term/*.trans_opt_exp:
tests/misc_tests/pretty_print_test.exp:
	Update expected output for these tests to reflect the
	above changes.
1998-05-20 13:10:50 +00:00
Simon Taylor
be2b948764 Disable cycles.m since it triggers a bug in code generation
Estimated hours taken: 1

tests/hard_coded/Mmakefile
	Disable cycles.m since it triggers a bug in code generation
	for disjunctions when compiled in a non-GC grade with --deforestation.

tests/hard_coded/cycles2.m
	cycles.m expanded so that deforestation is not needed to produce
	the problem.
1998-05-04 05:15:50 +00:00
Fergus Henderson
2dcd79773b Add `--gc conservative' to the GRADEFLAGS settings for
Estimated hours taken: 0.25

tests/hard_coded/Mmakefile:
	Add `--gc conservative' to the GRADEFLAGS settings for
	integer_test and rational_test, since these test cases both use
	enough memory that they require some kind of GC -- without it
	the test fails because it runs out of heap space.
1998-04-17 20:47:24 +00:00
Bert Thompson
30ef37923c Moved tests of library/{integer,rational}.m from tests/general to
Estimated hours taken: 0.1

Moved tests of library/{integer,rational}.m from tests/general to
tests/hard_coded since the library modules and their tests cannot
be compiled under NU-Prolog.

general/Mmakefile:
general/.cvsignore:
	Removed references to integer_test and rational_test.
general/integer_test.m:
general/integer_test.exp:
general/rational_test.exp:
general/rational_test.m:
	File removed.
hard_coded/Mmakefile:
hard_coded/.cvsignore:
	Added references to integer_test and rational_test.
hard_coded/integer_test.m:
hard_coded/integer_test.exp:
hard_coded/rational_test.exp:
hard_coded/rational_test.m:
	File added.
1998-04-16 12:00:32 +00:00
Fergus Henderson
f00346033a Make another small fix to mmake.in and add more empty definitions for various
Estimated hours taken: 0.5

Make another small fix to mmake.in and add more empty definitions for various
Mmake variables to avoid spurious warnings.

scripts/mmake.in:
	Add `*clean*' to the patterns for which we do not
	pass `--warn-undefined-variables'.

scripts/Mmake.rules:
	When invoking make recursively, pass $(MFLAGS) rather than
	$(MAKEOVERRIDES).  This avoids a warning, and is probably the
	right thing to do anyway (I'm not sure why I used MAKEOVERRIDES
	in the first place).

boehm_gc/Mmakefile:
tests/hard_coded/Mmakefile:
	Add empty definition for `MMAKEFLAGS'.
1998-04-02 13:23:10 +00:00
Fergus Henderson
713349d3e6 Move the rtc_bug' test case from the general'
Estimated hours taken: 0.2

tests/general/Mmakefile:
tests/general/rtc_bug.m:
tests/general/rtc_bug.exp:
tests/general/.cvsignore:
tests/hard_coded/Mmakefile:
tests/hard_coded/rtc_bug.m:
tests/hard_coded/rtc_bug.exp:
tests/hard_coded/.cvsignore:
	Move the `rtc_bug' test case from the `general'
	directory to the `hard_coded' directory, since it doesn't
	work in Prolog.
1998-04-02 13:18:47 +00:00
Fergus Henderson
86d6c4398e Move the relation_test' test case from the general'
Estimated hours taken: 0.25

tests/general/Mmakefile:
tests/general/relation_test.m:
tests/general/relation_test.exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/relation_test.m:
tests/hard_coded/relation_test.exp:
	Move the `relation_test' test case from the `general'
	directory to the `hard_coded' directory, since it doesn't
	work in Prolog.
1998-03-27 16:42:32 +00:00
Fergus Henderson
002ad1c8d8 Fix a bug in string__base_string_to_int:
Estimated hours taken: 1

library/string.m:
	Fix a bug in string__base_string_to_int:
	it was handling MININT incorrectly.

tests/hard_coded/Mmakefile:
tests/hard_coded/minint_bug.m:
tests/hard_coded/minint_bug.exp:
	Regression test.
1998-03-18 14:16:20 +00:00
Fergus Henderson
9308d1815a Change the `rev_arith.m' test so that it only tests
Estimated hours taken: 0.25

tests/hard_coded/Mmakefile:
tests/hard_coded/rev_arith.m:
tests/hard_coded/rev_arith.exp:
	Change the `rev_arith.m' test so that it only tests
	for the things which we actually support, and enable it.
1998-03-11 19:36:28 +00:00
Fergus Henderson
2823abbcac Move the common_type_cast' test from the general' directory
Estimated hours taken: 0.25

tests/general/Mmakefile:
tests/general/common_type_cast.m:
tests/general/common_type_cast.exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/common_type_cast.m:
tests/hard_coded/common_type_cast.exp:
	Move the `common_type_cast' test from the `general' directory
	to the `hard_coded' directory.  The reason for this was that
	the output under Mercury is slightly different to the output
	under NU-Prolog (the difference being trailing zeroes on
	floating point numbers); moving the test to the `hard_coded'
	directory was the simplest way of fixing this.
1998-03-10 11:09:30 +00:00
Fergus Henderson
11d8161692 Add support for nested modules.
Estimated hours taken: 50

Add support for nested modules.

- module names may themselves be module-qualified
- modules may contain `:- include_module' declarations
  which name sub-modules
- a sub-module has access to all the declarations in the
  parent module (including its implementation section).

This support is not yet complete; see the BUGS and LIMITATIONS below.

LIMITATIONS
- source file names must match module names
	(just as they did previously)
- mmc doesn't allow path names on the command line any more
	(e.g. `mmc --make-int ../library/foo.m').
- import_module declarations must use the fully-qualified module name
- module qualifiers must use the fully-qualified module name
- no support for root-qualified module names
	(e.g. `:parent:child' instead of `parent:child').
- modules may not be physically nested (only logical nesting, via
  `include_module').

BUGS
- doesn't check that the parent module is imported/used before allowing
	import/use of its sub-modules.
- doesn't check that there is an include_module declaration in the
	parent for each module claiming to be a child of that parent
- privacy of private modules is not enforced

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

NEWS:
	Mention that we support nested modules.

library/ops.m:
library/nc_builtin.nl:
library/sp_builtin.nl:
compiler/mercury_to_mercury.m:
	Add `include_module' as a new prefix operator.
	Change the associativity of `:' from xfy to yfx
	(since this made parsing module qualifiers slightly easier).

compiler/prog_data.m:
	Add new `include_module' declaration.
	Change the `module_name' and `module_specifier' types
	from strings to sym_names, so that module names can
	themselves be module qualified.

compiler/modules.m:
	Add predicates module_name_to_file_name/2 and
	file_name_to_module_name/2.
	Lots of changes to handle parent module dependencies,
	to create parent interface (`.int0') files, to read them in,
	to output correct dependencies information for them to the
	`.d' and `.dep' files, etc.
	Rewrite a lot of the code to improve the readability
	(add comments, use subroutines, better variable names).
	Also fix a couple of bugs:
	- generate_dependencies was using the transitive implementation
	  dependencies rather than the transitive interface dependencies
	  to compute the `.int3' dependencies when writing `.d' files
	  (this bug was introduced during crs's changes to support
	  `.trans_opt' files)
	- when creating the `.int' file, it was reading in the
	  interfaces for modules imported in the implementation section,
	  not just those in the interface section.
	  This meant that the compiler missed a lot of errors.

library/graph.m:
library/lexer.m:
library/term.m:
library/term_io.m:
library/varset.m:
compiler/*.m:
	Add `:- import_module' declarations to the interface needed
	by declarations in the interface.  (The previous version
	of the compiler did not detect these missing interface imports,
	due to the above-mentioned bug in modules.m.)

compiler/mercury_compile.m:
compiler/intermod.m:
	Change mercury_compile__maybe_grab_optfiles and
	intermod__grab_optfiles so that they grab the opt files for
	parent modules as well as the ones for imported modules.

compiler/mercury_compile.m:
	Minor changes to handle parent module dependencies.
	(Also improve the wording of the warning about trans-opt
	dependencies.)

compiler/make_hlds.m:
compiler/module_qual.m:
	Ignore `:- include_module' declarations.

compiler/module_qual.m:
	A couple of small changes to handle nested module names.

compiler/prog_out.m:
compiler/prog_util.m:
	Add new predicates string_to_sym_name/3 (prog_util.m) and
	sym_name_to_string/{2,3} (prog_out.m).

compiler/*.m:
	Replace many occurrences of `string' with `module_name'.
	Change code that prints out module names or converts
	them to strings or filenames to handle the fact that
	module names are now sym_names intead of strings.
	Also change a few places (e.g. in intermod.m, hlds_module.m)
	where the code assumed that any qualified symbol was
	fully-qualified.

compiler/prog_io.m:
compiler/prog_io_goal.m:
	Move sym_name_and_args/3, parse_qualified_term/4 and
	parse_qualified_term/5 preds from prog_io_goal.m to prog_io.m,
	since they are very similar to the parse_symbol_name/2 predicate
	already in prog_io.m.  Rewrite these predicates, both
	to improve maintainability, and to handle the newly
	allowed syntax (module-qualified module names).
	Rename parse_qualified_term/5 as `parse_implicit_qualified_term'.

compiler/prog_io.m:
	Rewrite the handling of `:- module' and `:- end_module'
	declarations, so that it can handle nested modules.
	Add code to parse `include_module' declarations.

compiler/prog_util.m:
compiler/*.m:
	Add new predicates mercury_public_builtin_module/1 and
	mercury_private_builtin_module/1 in prog_util.m.
	Change most of the hard-coded occurrences of "mercury_builtin"
	to call mercury_private_builtin_module/1 or
	mercury_public_builtin_module/1 or both.

compiler/llds_out.m:
	Add llds_out__sym_name_mangle/2, for mangling module names.

compiler/special_pred.m:
compiler/mode_util.m:
compiler/clause_to_proc.m:
compiler/prog_io_goal.m:
compiler/lambda.m:
compiler/polymorphism.m:
	Move the predicates in_mode/1, out_mode/1, and uo_mode/1
	from special_pred.m to mode_util.m, and change various
	hard-coded definitions to instead call these predicates.

compiler/polymorphism.m:
	Ensure that the type names `type_info' and `typeclass_info' are
	module-qualified in the generated code.  This avoids a problem
	where the code generated by polymorphism.m was not considered
	type-correct, due to the type `type_info' not matching
	`mercury_builtin:type_info'.

compiler/check_typeclass.m:
	Simplify the code for check_instance_pred and
	get_matching_instance_pred_ids.

compiler/mercury_compile.m:
compiler/modules.m:
	Disallow directory names in command-line arguments.

compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/modules.m:
	Add a `--make-private-interface' option.
	The private interface file `<module>.int0' contains
	all the declarations in the module; it is used for
	compiling sub-modules.

scripts/Mmake.rules:
scripts/Mmake.vars.in:
	Add support for creating `.int0' and `.date0' files
	by invoking mmc with `--make-private-interface'.

doc/user_guide.texi:
	Document `--make-private-interface' and the `.int0'
	and `.date0' file extensions.

doc/reference_manual.texi:
	Document nested modules.

util/mdemangle.c:
profiler/demangle.m:
	Demangle names with multiple module qualifiers.

tests/general/Mmakefile:
tests/general/string_format_test.m:
tests/general/string_format_test.exp:
tests/general/string__format_test.m:
tests/general/string__format_test.exp:
tests/general/.cvsignore:
	Change the `:- module string__format_test' declaration in
	`string__format_test.m' to `:- module string_format_test',
	because with the original declaration the `__' was taken
	as a module qualifier, which lead to an error message.
	Hence rename the file accordingly, to avoid the warning
	about file name not matching module name.

tests/invalid/Mmakefile:
tests/invalid/missing_interface_import.m:
tests/invalid/missing_interface_import.err_exp:
	Regression test to check that the compiler reports
	errors for missing `import_module' in the interface section.

tests/invalid/*.err_exp:
tests/warnings/unused_args_test.exp:
tests/warnings/unused_import.exp:
	Update the expected diagnostics output for the test cases to
	reflect a few minor changes to the warning messages.

tests/hard_coded/Mmakefile:
tests/hard_coded/parent.m:
tests/hard_coded/parent.child.m:
tests/hard_coded/parent.exp:
tests/hard_coded/parent2.m:
tests/hard_coded/parent2.child.m:
tests/hard_coded/parent2.exp:
	Two simple tests case for the use of nested modules with
	separate compilation.
1998-03-03 17:48:14 +00:00
Fergus Henderson
5f196b4f9b Fix a bug which caused the compiler to generate incorrect
Estimated hours taken: 0.75

compiler/modecheck_unify.m:
	Fix a bug which caused the compiler to generate incorrect
	code for the case where a function had the same name and arity
	as a data constructor (but a different return type),
	and the data constructor was used with an explicit module
	qualifier -- it incorrectly ignored the types and chose
	the function rather than the data constructor.

tests/hard_coded/Mmakefile:
tests/hard_coded/func_ctor_ambig.m:
tests/hard_coded/func_ctor_ambig.exp:
	Regression test.
1998-02-19 03:17:16 +00:00
Zoltan Somogyi
5e333f4424 Fix a bug that broke Tom's implementation of a random number generator at -O6.
Estimated hours taken: 3

Fix a bug that broke Tom's implementation of a random number generator at -O6.
The bug appeared only if value numbering is run for a second time after most
other low-level optimizations have been repeated several times. The problem
was that the first invocation of value numbering introduces a temp variable,
and the second one deletes the assignment to the temp variable because an
if_val with a liveness annotation comes between this assignment and the
first use of the temp variable.

compiler/livemap.m:
	When an if_val is preceded by a livevals annotation,
	do not replace the current liveness with the contents
	of the annotation. Instead, just include the contents
	of the annotation in the current set of live lvals.

tests/hard_coded/rnd.{m,exp}:
	Tom's test case.

tests/hard_coded/Mmakefile:
	Always run Tom's test case at -O6.
1998-02-18 03:24:46 +00:00
Fergus Henderson
9335ac4e70 Fix another bug in the handling of the `typeclasses'
Estimated hours taken: 0.25

tests/hard_coded/Mmakefile:
	Fix another bug in the handling of the `typeclasses'
	subdirectory: ensure that variables are quoted when
	passing them down to make subdirectories, so that it
	works for settings such as EXTRA_MCFLAGS="-O2 --opt-space"
	which contain embedded spaces.
1998-02-05 02:51:15 +00:00
Fergus Henderson
7788661dee Link the mode_choice' test with --no-strip', to
Estimated hours taken: 0.5

tests/hard_coded/Mmakefile:
	Link the `mode_choice' test with `--no-strip', to
	work around a probably bug in the Solaris linker.
1998-02-04 06:29:40 +00:00
Fergus Henderson
57797ed0eb Fix a couple of bugs introduced when dgj added a `typeclasses'
Estimated hours taken: 0.5

tests/hard_coded/Mmakefile:
	Fix a couple of bugs introduced when dgj added a `typeclasses'
	subdirectory:
	- ensure that `mmake clean' and `mmake realclean' recursively
	  clean the subdirectories
	- when recursively invoking the Mmakefiles in subdirectories,
	  make sure we pass down the values of the GRADE, EXTRA_CFLAGS
	  and EXTRA_MCFLAGS variables.
1998-02-04 04:36:57 +00:00
David Jeffery
94f3114b40 Remove typeclass_test_* from the Mmakefile, as these tests now reside
Estimated hours taken: 0.05

tests/hard_coded/Mmakefile:
	Remove typeclass_test_* from the Mmakefile, as these tests now reside
	in the tyepclasses directory.
1998-01-29 23:54:58 +00:00
David Jeffery
59f2b0bef9 Change the Mmakefile so that it executes the tests in the typeclasses
Estimated hours taken: 15

tests/hard_coded/Mmakefile:
	Change the Mmakefile so that it executes the tests in the typeclasses
	directory as well.
1998-01-29 23:50:26 +00:00
Fergus Henderson
40dcaf4f4f For calls to class methods, if the particular class instance is
Estimated hours taken: 3 (plus 1 from dgj)

compiler/polymorphism.m:
	For calls to class methods, if the particular class instance is
	known at the call site, then specialize the code by generating
	a direct call to the method for that instance.

tests/invalid/Mmakefile:
tests/invalid/typeclass_test_{1,2,3,4}.m:
tests/invalid/typeclass_test_{1,2,3,4}.err_exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/typeclass_test_{5,6}.m:
tests/hard_coded/typeclass_test_{5,6}.exp:
	Some test cases for type classes, including one for the above change.
1998-01-29 08:39:56 +00:00
Fergus Henderson
ad82d19c92 Fix a bug reported by Mark Brown that caused type_to_term
Estimated hours taken: 0.25

Fix a bug reported by Mark Brown that caused type_to_term
to fail when used for values of type `character'.

library/mercury_builtin.m:
	Fix a bug in the hand-coded base_type_info for the
	"character" type -- it had the type name as "char", not
	"character"

tests/hard_coded/Mmakefile:
tests/hard_coded/ground_dd.m:
tests/hard_coded/ground_dd.exp:
	Regression test.
1998-01-22 07:12:30 +00:00
Fergus Henderson
ced3f74b87 Fix a bug in io__remove_file_2 that was spotted by
Estimated hours taken: 0.5

library/io.m:
	Fix a bug in io__remove_file_2 that was spotted by
	Thomas By <T.By@dcs.shef.ac.uk>: a call to strcpy()
	in the pragma c_code had the wrong argument, causing
	it to do the wrong thing in the case where io__remove_file
	returned an error.

tests/hard_coded/Mmakefile:
tests/hard_coded/remove_file.m:
tests/hard_coded/remove_file.exp:
	Regression test.
1998-01-22 02:26:53 +00:00
Fergus Henderson
6db3f94609 Fix a bug that caused the compiler to report spurious unique mode
Estimated hours taken: 4

Fix a bug that caused the compiler to report spurious unique mode
errors for cases involving nested conjunctions, reordering, and
unique modes.

compiler/modes.m:
	When modechecking conjunctions, if the conjunction as a whole
	delays, make sure that we restore the original live_vars set.

compiler/mode_info.m:
	Add mode_info_get_live_vars/2 and mode_info_set_live_vars/3,
	for use by modes.m.

tests/hard_coded/Mmakefile:
tests/hard_coded/reorder_di.m:
tests/hard_coded/reorder_di.exp:
	Regression test for the above-mentioned bug.
1998-01-21 06:11:20 +00:00
Fergus Henderson
1d1a7f5ebd Fix a bug where semidet pragma c_codes didn't work in non-gc grades.
Estimated hours taken: 8

compiler/pragma_c_gen.m:
	Fix a bug where semidet pragma c_codes didn't work in non-gc grades.
	The problem was that in the following code fragment
		{ <the c code itself> }
		#ifndef CONSERVATIVE_GC
		  restore_registers();
		#endif
		if (r1) ...
	the C code would assign to SUCCESS_INDICATOR, which is #defined
	to `r1', and then the call to restore_registers() would clobber r1.

	In the process of fixing the bug, reorganize the code for
	generating ordinary (det/semi) pragma_c so that it more closely
	matches the layout of the code it generates, and add a few comments.

compiler/dupelim.m:
	Fix a bug in dupelim__build_maps: a lambda expression was using
	the same variable name (`Label') as the code outside it,
	resulting in it accidentally capturing that variable rather
	than being a fresh variable.

compiler/frameopt.m:
	Fix a bug in possible_targets/2: the possible targets for
	a `pragma_c' instruction include the label, if it has one.

compiler/opt_util.m:
	Update the comments for component_can_branch_away/2
	to reflect the fact that pragma_c_raw_code components for
	semidet pragma c_codes can branch away.  Also check for the
	special case of an empty string in pragma_c_raw_code.

tests/hard_coded/Mmakefile:
	Re-enable the `pragma_import' test which uncovered this bug.
1998-01-16 07:05:48 +00:00
Fergus Henderson
5352eeff09 Add `GRADEFLAGS-pragma_import = --gc conservative',
Estimated hours taken: 0.5

tests/hard_coded/Mmakefile:
	Add `GRADEFLAGS-pragma_import = --gc conservative',
	because the `pragma_import' test currently does not
	work in non-gc grades.
1998-01-14 02:16:28 +00:00
Fergus Henderson
64009ded0b Add support for `pragma import', which is a simplified form of
Estimated hours taken: 20

Add support for `pragma import', which is a simplified form of
`pragma c_code'.  With `pragma import', the user specifies only
the C function name, rather than a C code fragment, and the
Mercury compiler handles the argument-passing automatically.

TODO
- add documentation to doc/reference_manual.texi.

WISHLIST
- change `pragma import' and `pragma export'
  to take an additional parameter indicating the language
  (e.g. C, Prolog, Ada, Fortran, etc.) and/or calling
  convention

compiler/prog_data.m:
	Add `pragma import' to the parse tree data structure.

compiler/prog_io_pragma.m:
	Add code to parse `pragma import' declarations.

compiler/mercury_to_mercury.m:
	Add code to pretty-print `pragma import' declarations.

compiler/module_qual.m:
	Add code to module-qualify `pragma import' declarations.

compiler/make_hlds.m:
	Add code to process `pragma import' declarations,
	by converting them to clauses with HLDS `c_code' instructions.

compiler/export.m:
	Declare `export__exclude_argument_type' in the interface,
	for use by the code for handling `pragma import' in make_hlds.m.
	Change the documentation to say that this procedure is used for
	both exported and imported procedures.

compiler/notes/compiler_design.html:
	Document how the compiler handles `pragma import' declarations.

tests/hard_coded/Mmakefile:
tests/hard_coded/pragma_import.m:
tests/hard_coded/pragma_import.exp:
	Add some test cases for `pragma import'.
1998-01-09 11:56:29 +00:00
Fergus Henderson
9ff3da65b5 Fix a bug in ML_create_type_info():
Estimated hours taken: 5

library/std_util.m:
	Fix a bug in ML_create_type_info():
	when searching for type parameters to substituting with their
	corresponding values, they were only looking at the top level
	of the type.  To get correct results, it is necessary to
	traverse recursively through all levels of the type.

runtime/mercury_deep_copy.c:
	Fix a bug similar to the one above in make_type_info().
	The fix is a bit more complicated, due to memory management
	issues --- we need to keep a linked list of all the memory
	cells we allocate so that we can free them when we're done.

	Also avoid some duplicated code in mercury_deep_copy.c
	by introducing a new function deep_copy_arg().

	And fix a bug in deep_copy_type_info(): it should be
	allocating memory using incr_saved_hp(), not using
	make(). make() calls newmem(), which in non-conservative GC
	grades calls malloc(), which results in a memory leak;
	whereas incr_saved_hp() allocates on the Mercury heap,
	which is (in accurate gc grades) subject to garbage collection.

tests/hard_coded/Mmakefile:
tests/hard_coded/eqv_type_bug.m:
tests/hard_coded/eqv_type_bug.exp:
	Regression test for the above-mentioned bug in ML_create_type_info().
1997-12-30 06:42:25 +00:00
Peter Schachte
bf824facde Make Mercury cope with impure code
The purpose of this diff is to allow Mercury programs to contain
impure Mercury code without the compiler changing its behavior
inappropriately, while still allowing the compiler to aggressively
optimize pure code.  To do this, we require impure predicates to be so
declared, and calls to impure predicates to be flagged as such.  We
also allow predicates implemented in terms of impure predicates to be
promised to be pure; lacking such a promise, any predicate that calls
an impure predicate is assumed to be impure.

At the moment, we don't allow impure functions (only predicates),
though some of the work necessary to support them has been done.

Note that to make the operators work properly, the precedence of the
`pred' and `func' operators has been changed from 1199 to 800.

Estimated hours taken: 150

compiler/purity.m:
	New compiler pass for purity checking.
compiler/hlds_goal.m:
	Add `impure' and `semipure' to the goal_feature enum.
compiler/hlds_out.m:
compiler/typecheck.m:
compiler/special_pred.m:
	Fixed code that prints predicate name to write something more
	helpful for special (compiler-generated) predicates.  Added
	code to print new markers.  Added purity argument to
	mercury_output_pred_type.  New public predicate
	special_pred_description/2 provides an english description for
	each compiler-generated predicate.
compiler/hlds_pred.m:
	Add `impure' and `semipure' to marker enum.  Added new
	public predicates to get predicate purity and whether or not
	it's promised to be pure.
compiler/prog_data.m:
compiler/mercury_to_mercury.m:
compiler/prog_io.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_dcg.m:
compiler/prog_util.m:
compiler/equiv_type.m:
compiler/intermod.m:
compiler/mercury_to_c.m:
compiler/module_qual.m:
	Add purity argument to pred and func items.  Add new `impure'
	and `semipure' operators.  Add promise_pure pragma.  Add
	purity/2 wrapper to goal_expr type.
compiler/make_hlds.m:
compiler/mercury_to_goedel.m:
	Added purity argument to module_add_{pred,func},
	clauses_info_add_pragma_c_code, and to pred and func items.
	Handle promise_pure pragma.  Handle purity/2 wrapper used to
	handle user-written impurity annotations on goals.
compiler/mercury_compile.m:
	Add purity checking pass between type and mode checking.
compiler/mode_errors.m:
	Distinguish mode errors caused by impure goals preventing
	goals being delayed.
compiler/modes.m:
	Don't delay impure goals, and ensure before scheduling an
	impure goal that no goals are delayed.  Actually, we go ahead
	and try to schedule goals even if impurity causes a problem,
	and then if it still doesn't mode check, then we report an
	ordinary mode error.  Only if the clause would be mode correct
	except for an impure goal do we report it as an impurity problem.
compiler/simplify.m:
	Don't optimize away non-pure duplicate calls.  We could do
	better and still optimize duplicate semipure goals without an
	intervening impure goal, but it's probably not worth the
	trouble.  Also don't eliminate impure goals on a failing branch.
compiler/notes/compiler_design.html:
	Documented purity checking pass.
doc/reference_manual.texi:
	Document purity system.
doc/transition_guide.texi:
library/nc_builtin.nl:
library/ops.m:
library/sp_builtin.nl:
	New operators and new precdence for `pred' and `func'
	operators.
tests/hard_coded/purity.m
tests/hard_coded/purity.exp
tests/hard_coded/Mmakefile:
tests/invalid/purity.m
tests/invalid/purity_nonsense.m
tests/invalid/purity.err_exp
tests/invalid/purity_nonsense.err_exp
tests/invalid/Mmakefile:
	Test cases for purity.
1997-12-09 04:02:47 +00:00
Fergus Henderson
7e0eb57816 Change the way mode analysis chooses which mode of a predicate to call.
Estimated hours taken: 6

Change the way mode analysis chooses which mode of a predicate to call.
If there are multiple matching modes, choose the best one, rather
than just the first one.  "Best" is determined by comparing the
argument insts and livenesses, and (if that fails) determinism
of all the modes which do match.  If two modes are equal, or
incomparable, in this partial ordering, we choose the first one
(according to the order in which they were declared).

Still to do (will be committed seperately): delete the hacks in make_hlds.m
etc. that assign mode numbers with a priority based on determinism.

compiler/modecheck_call.m:
	For calls to predicates with multiple modes, find all the modes
	which match and select the best one, rather than just picking
	the first one that matches.

compiler/det_report.m:
	Export compare_determinism/3, for use by modecheck_call.m.

NEWS:
LIMITATIONS:
	We've fixed one of the limitations: unique mode declarations
	no longer have to precede non-unique mode declarations.

tests/hard_coded/Mmakefile:
tests/hard_coded/mode_choice.m:
tests/hard_coded/mode_choice.exp:
	Some tests cases for this change.
1997-10-15 07:46:33 +00:00
Fergus Henderson
6e06050558 Rename Mmake' as Mmakefile', since using the name `Mmake'
Estimated hours taken: 0.25

*/Mmake:
	Rename `Mmake' as `Mmakefile', since using the name `Mmake'
	causes problems on case-insensitive file systems.
1997-09-29 18:05:38 +00:00