Commit Graph

40 Commits

Author SHA1 Message Date
Fergus Henderson
d6ca6e3797 Ensure that Makefile.mercury can be used as a generic
*Makefile*:
	Ensure that Makefile.mercury can be used as a generic
	Makefile for Mercury programs.  It now gets included by the
	Makefiles in the tests/ directory.
	(It's highly likely that these changes have broken something.)

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

disj_gen.nl:
	Minor stylistic changes.

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

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

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

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

options.nl:
	Rearrange the options into a vaguely meaninful order and
	add a couple of comments.
1994-08-30 21:07:52 +00:00
Fergus Henderson
748d760138 Low-level efficiency hack: expand the definition of in'/out' modes
mercury_builtin.nl:
	Low-level efficiency hack: expand the definition of `in'/`out' modes
	to avoid unnecessary lookups.

options.nl:
	Fix cut-and-paste error in error message.
1994-08-27 19:25:41 +00:00
Thomas Conway
b9fe2dd634 Arrange stuff better, add peephole options.
options.*:
	Arrange stuff better, add peephole options.
1994-08-26 12:08:06 +00:00
Fergus Henderson
0d45c6df55 Fix bug in last fix.
llds.nl:
	Fix bug in last fix.

options.nl:
	Add missing clause for --mod-comments option.
1994-08-24 04:59:05 +00:00
Fergus Henderson
79cce1e7d1 Add an option to disable the output of comments in the .mod file.
llds.nl, options.nl:
	Add an option to disable the output of comments in the .mod file.
1994-08-22 09:30:19 +00:00
Fergus Henderson
3aedb7266a Fix a few bugs in the --compile option.
mercury_compile.nl, options.nl:
	Fix a few bugs in the --compile option.
	This required adding a new --c-include-directory option to specify
	the appropriate -I flag to pass to the C compiler.
1994-08-20 15:18:39 +00:00
Fergus Henderson
cd3738467d Implement some new options: --compile-to-c, --compile, --cc,
mercury_compile.nl, options.nl:
	Implement some new options: --compile-to-c, --compile, --cc,
	--cflags, --gcc-global-registers, --gcc-non-local-gotos,
	--debug, and --optimize.
1994-08-17 13:39:57 +00:00
Fergus Henderson
4a3d4144a9 Reclaim heap in negations.
code_gen.nl:
	Reclaim heap in negations.

options.nl:
	Make heap reclaimation on failure the default.
1994-08-14 18:37:31 +00:00
Fergus Henderson
693d42285f Rename globals__lookup*option as globals__io_lookup*option.
*.nl:
	Rename globals__lookup*option as globals__io_lookup*option.
	Create new globals__lookup*option predicates.
	Fix up the option handling in the code generator.
1994-08-14 14:26:38 +00:00
Thomas Conway
0f1d52581c Fix assumptions about where variables go at the end of switches.
code_gen.nl code_info.nl:
	Fix assumptions about where variables go at the end of switches.
	Add StoreMap.

live_vars.nl store_alloc.nl:
	Passes to compute the stack allocations, and the "known" locations
	for variables.

hlds.nl:
	Add fields to procinfo for stack allocations.

options.nl:
	Add options for eager and lazy code generation.
	Eager code generation is still mostly untested. Its
	even possible that there are unimplemented preds!

llds.nl:
	Print the code in a slightly nicer format.
1994-08-13 05:01:13 +00:00
Fergus Henderson
d3285a3000 Fix minor formatting bug.
options.nl:
	Fix minor formatting bug.
1994-08-07 12:30:56 +00:00
Thomas Conway
6dee433148 Generate code with field numbers 0.... rather than 1....
code_info.nl ite_gen.nl unify_gen.nl
	Generate code with field numbers 0.... rather than 1....
	Add stuff for heap reclaiming on failure.
	Add options in code generation (not patched through to the
	top levels of the compiler yet.

liveness.nl:
	fix some bugs.

options.nl mercury_compile.nl:
	Add some options for follow[code|vars].
1994-07-11 05:18:55 +00:00
Fergus Henderson
d8d4121af4 Fix another sillyness in the options help message.
options.nl:
	Fix another sillyness in the options help message.
1994-07-03 10:23:43 +00:00
Fergus Henderson
f60a8ef6b4 Fix some mistakes in the --help message.
options.nl:
	Fix some mistakes in the --help message.
1994-07-02 17:24:21 +00:00
Fergus Henderson
a29f0da038 Add a whole bunch of new options.
options.nl:
	Add a whole bunch of new options.
	Please read `mercury_compile --help', everyone!

code_gen.nl:
	Use the `--gc' flag instead of old `save-succip' flag.

globals.nl:
	Added two new global vars for two of the new options;
	lots of new access predicates.

int.nl:
	Add int__pow; also use slightly more meaningful variable names
	in the code for the other preds.

llds.nl:
	Output field(...) rvals and lvals with the proper `mktag(...)'.
	Also a a new mktag(...) rval.

make_hlds.nl:
	Pass the command-line options to make_tags.nl.

make_tags.nl:
	Assign the tags according to the --num-tag-bits option.

mercury_compile.nl:
	Allow more than one file on the command line;
	Also a little bit of special processing for two of the
	new options.

unify_gen.nl:
	Rearrange unify_gen__generate_tag_test slightly.
	Generate better code for tests of complicated_constant_tags.
1994-07-01 06:40:14 +00:00
Thomas Conway
ee05e3ded5 Fix bugs: save the status of succip_used across branched stuctures.
code_gen.nl code_info.nl:
	Fix bugs: save the status of succip_used across branched stuctures.
		  use liveness and deadness info properly in semidet goals.

llds.nl:
	Fix syntax error in the output code.

mercury_compile.nl options.nl:
	change xmod to mod. We're hitting the big time now ;-)
	(Changes to Makefile.* to follow)
1994-06-29 13:43:24 +00:00
Thomas Conway
988c1ecbcb Improved the code. Added array__resize.
array.nl:
	Improved the code. Added array__resize.

call_gen.nl code_gen.nl code_info.nl switch_gen.nl unify_gen.nl:
	Made a start towards abstracting "tag tests".

hlds.nl hlds_out.nl liveness.nl modes.nl code_gen.nl:
	Fixed the "before" and "after" liveness problem.
1994-06-22 15:02:46 +00:00
Fergus Henderson
c58943c3d3 Reorganize io.nl a bit. Added some new predicates (but
io.nl, prog_io.nl.
	Reorganize io.nl a bit.  Added some new predicates (but
	didn't implement them yet.)
	Renamed a couple of things, which forced the changes to prog_io.nl.

options.nl, toplevel.nl:
	Add a new `-M' option to generate a `Make'-style dependency file.

GNUMakefile, Makefile, Makefile.common:
	Moved the Makefile to Makefile.common and removed the old
	`$(ERR) : $(INT)' dependency where every .err file depended
	on every .int file.  Added a rule to create a Makefile
	by catting Makefile.common and the dependencies in toplevel.dep.
	Added a GNUMakefile which just includes the Makefile.common
	and toplevel.dep.

	Also, use `&&' rather than `;' in `sh -c' commands so that it will
	stop when a command encounters an error.
1994-06-16 22:42:23 +00:00
Fergus Henderson
30f5e18b2f Remove map__search_insert; it's not needed and it's not
bintree.nl, map.nl, varset.nl:
	Remove map__search_insert; it's not needed and it's not
	really useful.

bintree.nl:
	Fix determinism problem in bintree__from_list_2.

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

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

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

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

map.nl:
	Add map__overlay/3.

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

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

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

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

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

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

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

Makefile:
	Add a rule for creating *.hlds_dump.

array.nl:
	Fix determinism error.

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

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

llds.nl:
	Rename llds__pred_mode_id as llds__proc_id.

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

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

undef_modes, undef_insts:
	I've broken the error message code, since it's not easy
	to print pred_ids.  I just changed it so that it didn't
	print the pred_ids out.  Should fix this properly at some stage...
1994-06-14 14:23:52 +00:00
Fergus Henderson
59dcd8f161 Print out the delta liveness info.
hlds_out.nl:
	Print out the delta liveness info.

options.nl:
	Add some documentation about the effect of -d -V.

list.nl:
	Fix a couple of determinism errors.

mode_info.nl:
	Move the pred declarations into the interface.
1994-06-09 12:24:11 +00:00
Fergus Henderson
0ad664520e Rename various things for consistency:
s/term_functor/term__functor/g
	s/term_atom/term__atom/g
	s/term_string/term__string/g
	s/term_int/term__int/g
	s/term_float/term__float/g
	s/term_variable/term__variable/g

	/:- mode.*[^a-zA-Z_]input,/s/input,/in,/g
	/[^a-zA-Z_]input,.*)/s/input,/in,/g
	/:- mode.*[^a-zA-Z_]output,/s/output,/out,/g
	/[^a-zA-Z_]output,.*)/s/output,/out,/g

	/:- mode.*[^a-zA-Z_]input)/s/input)/in)/g
	/:- mode.*[^a-zA-Z_]output)/s/output)/out)/g

	/[a-z]info/s/info/_info/g
	/__info/s/__info/_info/g
1994-05-03 12:28:54 +00:00
Fergus Henderson
9345dc25f3 Improve the debugging output and the error messages.
modes.nl:
	Improve the debugging output and the error messages.
	Use hlds_out__write_pred_id rather than write_pred_id.
	Implement mode-checking of disjunctions and if-then-else.

make_hlds.nl:
	Improve the transformation to super-homogenous form so that
	it doesn't introduce unnecessary variables.

hlds_out.nl, typecheck.nl:
	Move write_unify_context from typecheck.nl to hlds_out.nl.
	Fix a couple of minor problems with the error messages in
	typecheck.nl.

options.nl:
	Add a `debug' option.  Also tidy up the help message.

int.nl:
	Avoid unnecessary parentheses.
1994-04-12 15:14:27 +00:00
Fergus Henderson
3b1487eef7 Change mode_is_input and mode_is_output so that abstract
hlds.nl:
	Change mode_is_input and mode_is_output so that abstract
	insts are assumed to be bound.

	Add predicate `inst_is_ground'.
	Add predicate `moduleinfo_set_num_errors'.

	Also change instmap_delta back into a map again (probably a mistake! -
	but I'll fix it later).

map.nl:
	Add predicate `map__from_sorted_assoc_list'.

mercury_to_mercury.nl:
	Export `mercury_output_inst' and `mercury_output_mode_list'.

modes.nl:
	Lots of changes.  It should be almost useable now.

options.nl:
	Add a new --modecheck option to invoke the mode checker.
	This is disabled by default since the modechecker doesn't
	quite work yet.

parser.nl:
	Remove obsolete comment.

prog_io.nl:
	Ensure that the bound insts in a bound(...) list are in sorted
	order.

set.nl:
	Add predicate `set__sorted_list_to_set'.

toplevel.nl:
	Changed to match the new interface to `modecheck'.
	Also don't generate code if there were any errors detected by
	make_hlds.

typecheck.nl:
	Fix a couple of minor typos in the error messages.
1994-04-11 15:40:29 +00:00
Fergus Henderson
62a70e436b Use assoc_list/2 rather than list(pair(...)).
bintree.nl, map.nl, std_util.nl:
	Use assoc_list/2 rather than list(pair(...)).

hlds.nl, det_analysis.nl:
	Make instmap delta an association list rather than a map;
	fix the determinism analysis to use that.

Makefile, doit.nl:
	Add det_analysis.nl and builtins.nl.

builins.nl:
	Fix bug.

codegen.nl:
	Make unimplemented cases abort rather than just fail.

modes.nl, typecheck.nl:
	Fix bugs introduced by the performance fixes.
	(I wonder if the performance problem will come back now? ;-)

options.nl, toplevel.nl:
	Add a new pred `maybe_flush_output' and use it in toplevel.nl.
1994-03-30 11:53:25 +00:00
Fergus Henderson
9c3d102cd5 (1) Add a singleton variable warning (and an option to turn it off).
(2)  Fix the singleton variable warnings in prog_io.nl (found and fixed
     a bug in the DCG expansion).

(3)  Improve the error reporting in typecheck.nl

(4)  Improve the layout of error messages.
1994-03-25 23:38:49 +00:00
Fergus Henderson
48a4d0a30a `make clean' now removes *.ugly.
Makefile:
	`make clean' now removes *.ugly.

mercury_to_goedel.nl mercury_to_mercury.nl options.nl:
	Add a new option `-l' to indicate whether we should
	output comments indicating the source line numbers
	in the generated code.
1994-03-23 07:35:43 +00:00
Fergus Henderson
66f1274c33 Add set.nl.
Makefile, doit.nl:
	Add set.nl.

Makefile:
	Remove the old (now obsolete) Goedel stuff.

hlds.nl:
	Add a new field which holds to non-local vars of each
	goal to the goalinfo.

make_hlds.nl:
	*** Handle implicit quantification. ***

mercury_to_mercury.nl, toplevel.nl, options.nl:
	Send the mercury-to-mercury output to `<module>.ugly'
	instead of overwriting `<module>.int'.
	Also fix a silly bug with the --convert-to-goedel flag.

set.nl:
	Add a new predicate set__list_to_set/2.
	Also a couple of bug fixes.

term_io.nl, list.nl:
	Trivial changes.
1994-03-22 16:09:23 +00:00
Fergus Henderson
a86bc5e354 - Integrate mercury_to_goedel into the compiler;
Makefile, toplevel.nl, mercury_to_goedel.nl, mercury_to_mercury.nl, options.nl:
	- Integrate mercury_to_goedel into the compiler;
	  mercury_to_goedel is now just an option (-M) to mercury_compile.
	  Also add the ability to call mercury_to_mercury on the
	  whole source file (XXX but the output file gets named <module.int>,
	  which is wrong).

mercury_to_mercury.nl:
	Output `:- interface' and `:- implementation' directives.

toplevel.nl, options.nl:
	Add a `--help' option.  Only display the long description of the
	options if `--help' is specified.
1994-03-22 11:14:29 +00:00
Fergus Henderson
ba1a19a4de Add an XXX comment.
llds.nl:
	Add an XXX comment.

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

options.nl, prog_io.nl:
	Add a -I option.

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

bintree.nl:
	Add predicates to work out the depth and number of items
	in a bintree.
map.nl:
	Make the fact that maps are bintrees externally visible,
	so that toplevel.nl can print out some stats about some maps.
toplevel.nl:
	Print out some stats about the pred, type, and cons maps.
1994-03-21 10:38:31 +00:00
Fergus Henderson
a4bec15437 Improve error messages.
typecheck.nl:
	Improve error messages.

make_hlds.nl:
	Do part of the transformation to super-homogenous form.

options.nl, toplevel.nl, make_hlds.nl, typecheck.nl, modes.nl:
	Use different options to control the different output messages.
	Introduced two new options -e and -s, and changed various
	places to check for these options instead of -v or -w.

std_util.nl:
	Change the statistics output by report_stats so that they
	fit in a single line.
1994-03-16 14:45:12 +00:00
Fergus Henderson
960b4c01e4 Various minor bug-fixes.
io.nl, io.nu.nl, options.nl, string.nl:
	Various minor bug-fixes.

Makefile:
	Use nc's `-u' option rather than mercury_compile's `-h' option.
1994-03-16 08:22:55 +00:00
Fergus Henderson
8720bb03e8 Added a new -h option which solves the NU-Prolog memory management
problem.
1994-03-15 13:35:38 +00:00
Fergus Henderson
92d1371b4c New file: converts the prog_io data structure back into Mercury source
mercury_to_mercury.nl:
	New file: converts the prog_io data structure back into Mercury source
	code.

term_io.nl:
	Export mercury_quote_string for use by mercury_to_mercury.nl.

Makefile, doit.nl:
	Add mercury_to_mercury.

options.nl, toplevel.nl:
	Add a new option to save the interface of a module to a `.int' file,
	using mercury_to_mercury.

Makefile:
	Modify the rule for the `clean' target so that it removes `.int' files.

mercury_builtin.nl:
	Fix the module name.

std_util.nl:
	Suppress warnings from nit.
1994-03-14 14:53:58 +00:00
Fergus Henderson
5b3da4cdde An error message was omitting the file name & line number.
prog_io.nl:
	An error message was omitting the file name & line number.
	Also ensure that all error messages start with "error:".

codegen.nl, interpreter.nl, bintree.nl, list.nl:
	Fix stuff detected by nit.

make_hlds.nl:
	Transform to `semi-homogeneous' form (still need to expand
	unifications).

prog_util.nl:
	Fix bug.

mercury_builtin.nl:
	Add call/1.

hlds.nl:
	Add a count of the number of errors and warnings to the module_info
	data structure.

toplevel.nl:
	Continue processing after syntax errors.
1994-03-12 06:00:36 +00:00
Fergus Henderson
30baaf2e45 Added predicate varset__vars.
varset.nl:
	Added predicate varset__vars.

term.nl:
	Added predicate term__vars_list.

typecheck.nl:
	Implement two previously unimplemented parts of the typechecker:
	detect attempts to instantiate type variables which occur in
	the predicate's type declaration, and detect any failure to
	bind all other type variables.  (That was the last two;
	apart from

prog_util.nl:
	Fix problem where the expansion of equivalence types was
	introducing fresh variables into the type varset, which caused
	problems in relation to the above changes to typecheck.nl.

hlds_out.nl:
	Fix typo in type declaration (found by above fixes to typechecker).

options.nl:
	Fix bug in type definition introduced by last change.

make_hlds.nl:
	Add a missing pred & mode declaration.

modes.nl:
	Don't display the verbose messages unless the very-verbose
	flag was specified.
1994-03-11 18:57:16 +00:00
Fergus Henderson
e9cf453b62 Added a `--builtin-module' option to mercury_compile and a file
no_builtin.nl which is an empty module for use with that option.
Note that `mercury_compile -g -b no_builtin some_simple_file'
should now work if the file `some_simple_file.nl' contains a sufficiently
simple program, like the one in my email.
1994-03-08 16:07:07 +00:00
Fergus Henderson
9bbbd6ffd0 Add new option -g' / --generate-code' and modify toplevel.nl to
toplevel.nl, options.nl:
	Add new option `-g' / `--generate-code' and modify toplevel.nl to
	invoke the code generator if this option is specified.
1994-03-06 09:51:02 +00:00
Fergus Henderson
9f29364f56 Added handling of command-line options.
toplevel.nl, typecheck.nl:
	Added handling of command-line options.

globals.nl:
	Added predicate `lookup_option'.

options.nl:
	Added new option `-d' / `--dump-hlds'.  Also added some new
	predicates `maybe_write_string' and `maybe_report_stats'.

io.nl:
	Added predicate io__report_stats.  The old report_stats
	should not be used.
1994-03-03 16:41:29 +00:00
Fergus Henderson
c852e70715 Add command-line option handling.
(Command-line options are now parsed, and the option data is saved
in the io__state, but the options aren't yet actually used.)
1994-03-03 05:36:17 +00:00