Commit Graph

50 Commits

Author SHA1 Message Date
Zoltan Somogyi
d344165793 Add a new option, --branch-delay-slot, intended for use by mc on
Estimated hours taken: 3

options:
	Add a new option, --branch-delay-slot, intended for use by mc on
	the basis of the configuattion script. It says whether the machine
	architecture has delays slots on branches.

	The setting of option should affect whether we set
	--optimize-delay-slots at -O2, but this doesn't work yet.

hlds_goal:
	Add an extra field to hold follow_vars infromation to disjunctions,
	switches and if-then-elses. I intend to use this information to
	generate better code.

*.m:
	Changes to accommodate the extra field.
1996-04-20 08:37:36 +00:00
Thomas Conway
66a5fbe65d Documented the changed interfaces to list, std_util and graph.
Estimated hours taken: 6

NEWS:
	Documented the changed interfaces to list, std_util and graph.

configure.in:
	Added the number of bytes per word (calculated as sizeof(void *))
	as a configuration variable.

compiler/goal_util.m:
	Add an optional sanity check for ensuring that all variables in a goal
	get renamed in goal_util__rename_vars_in_goal[s].
	Also fixed a bug in goal_util__create_variables which was giving
	wrong names to some variables (which lead to very confusing hlds dumps).

compiler/excess.m:
	in the calls to goal_util__rename_vars_in_goals add the bool which
	indicates that we do not want to do the sanity checking operation of
	making sure that *all* variables get renamed.

compiler/inlining.m:
	in the calls to goal_util__rename_vars_in_goals add the bool which
	indicates that we do want to do the sanity checking operation of
	making sure that *all* variables get renamed.
	Also fixed up calls to goal_util__create_variables for the bug fix
	described above.

compiler/quantification.m:
	in the calls to goal_util__rename_vars_in_goals add the bool which
	indicates that we do not want to do the sanity checking operation of
	making sure that *all* variables get renamed.
	Also fixed up calls to goal_util__create_variables for the bug fix
	described above.

compiler/lookup_switch.m:
	changed lookup_switch to use a configuration option "word_size" to
	find out the number of bytes (and hence the number of bits) per
	word, rather than having a magic number.

compiler/options.m:
	added "word_size" for the number of bytes per word. Defaults to 4,
	but my next checkin will add a configuration parameter to mc.in.
	Don't port to any 16 bit machines in the next couple of days. ;-)
	also changed req_density to dense_switch_req_density and added
	lookup_switch_req_density for the minimum density of lookup switches.

compiler/switch_gen.m:
	changed req_density to dense_switch_req_density and
	lookup_switch_req_density appropriately.

library/graph.m:
	Add lots of comments.
	Fix the interface to make it more consistent.
	Fixed some bugs.

library/list.m:
	Added some HO stuff from philip:
		list__filter/3, list__filter/4
		list__filter_map, list_sort/3 (takes a cmp predicate).
	Moved the HO interface stuff into the interface at the
	top of the file.
	Removed list__map_maybe/3.

library/std_util.m:
	added a pair/3 predicate from philip for avoiding type ambiguities
	when using -/2.
	added maybe_pred/3.

doc/user_guide.texi:
	added documentation for the changes to the command line options.
1996-04-03 02:30:34 +00:00
Zoltan Somogyi
2833bfffb7 Divided the old hlds.m into four files:
Estimated hours taken: 10

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

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

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

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

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

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

other modules:
	Import the necessary part of hlds.

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

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

dnf, lambda:
	Simplify the task of defining predicates.

llds:
	Fix some comments.

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

shape, unused_args:
	Fix formatting.
1996-04-02 12:12:24 +00:00
Fergus Henderson
018f70ff4e Optimize the represention of types which have only one functor, whose arity
Estimated hours taken: 3

Optimize the represention of types which have only one functor, whose arity
is one, such as

	:- type bar ---> foo(baz).

For these types, the functor `foo' serves as an explicit type
conversion, but does not need to be physically represented -- there is
no need to box and unbox the `baz' value when converting to and from
type `bar'.  So I've introduced a new tag category `no_tag' for these
sort of functors.

hlds.m:
	Add new tag category `no_tag'.

make_tags.m:
	For types with only one functor, if the arity of that functor is one,
	assign it a `no_tag' tag.

unify_gen.m:
	Handle construction, deconstruction, and tag tests for `no_tag' tags.

shapes.m:
	For types with only one functor, if the arity of that functor is one,
	the tag will be a `no_tag' tag, so the shape of that object is
	determined by the shape of the argument.

switch_gen.m:
	Handle `no_tag' tags in switch_gen__priority.
	(There shouldn't be any `no_tag' switches, since such switches
	could only ever have one case -- this change is just necessary
	to avoid a determinism error.)
1996-03-31 19:06:36 +00:00
Thomas Conway
e70dc0ea8d Added a new kind of switch generation which generates array lookups
Estimated hours taken: 5.0

Added a new kind of switch generation which generates array lookups
for dense switches that output constants.

compiler/code_gen.pp:
	The interface to switch_gen__generate_switch changed - we now pass
	the goal-info which gets used in lookup_switch.

compiler/dense_switch.m:
	export dense_switch__calc_density/3 and dense_switch__type_range/5
	which get used by lookup_switch.

compiler/options.m:
	Added a new option "lookup-switch-size" which is the minimum number
	of cases that should be in a switch before we turn it into a lookup
	table. Currently, it defaults to 4 which is the same value as used
	for the "dense-switch-size" option. Some experimentation may show
	a better value.
	Also fixed the option names for "dense-switch-size" and
	"string-switch-size" which were "...switch_size".

compiler/switch_gen.m:
	switch_gen__generate_switch/Lots now take the hlds__goal_info as
	one of its arguments, because the goal-info is needed by lookup-
	switches.
	Also, in switch_gen__generate_switch/Lots, check to see if a switch
	can be turned into a dense lookup table, and turn it into one if it
	can.

compiler/lookup_switch.m:
	A new module that turns switches into lookup tables if the outputs
	of the switch are all constants. It does this by generating code
	for each of the cases and checking that no code actually got generated
	and that all the outputs were constants. The result is that for many
	predicates like char_to_int/2, etc instead of a computed goto with
	lots and lots of silly trivial cases, we get a simple lookup. This
	is good.
	There is a case where it may not be a win - if the cost of the range
	check and the bitvector lookup outweighs the cost of the jumps that
	would otherwise take place.
1996-03-06 01:35:17 +00:00
Fergus Henderson
6d7f4b9b30 Undo dylan's changes in the names of some library entities,
Estimated hours taken: 1.5

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

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

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

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

compiler/*.m:
	Apply sed script above;
	where appropriate, add `bool' to the list of imported modules.
1996-02-03 17:30:14 +00:00
Zoltan Somogyi
707ed33da0 Fixed two bugs. First, if a primary tag value did not have cases for
tag_switch:
	Fixed two bugs. First, if a primary tag value did not have cases for
	all its secondary tag values, we now emit a goto the failure label
	if the secondary tag does not match any case; we used to just fall
	through. Second, the failure code itself used to be generated in
	the context of the end of one of the cases; this should now be fixed,
	although I want to go over it with Tom to make sure.

	The computation of the secondary tag is now done once, instead of
	being repeated at every secondary tag test.

options:
	Set tag_switch_size to 4 by default, reduced from 8. It was this change
	that exposed the two bugs above. After the fix, the compiler is smaller
	by about 2 Kb.

switch_gen:
	Add some comments.

code_util:
	Fixed nonstandard indentation.
1995-09-24 08:45:34 +00:00
Zoltan Somogyi
eef27b6a67 Removed the caller argument from the call, call_closure and goto LLDS
instructions, and the last argument from local labels. All these were
placeholders for info put in there by prof.m and used when emitting C
code.

The set of labels that serve as return points are now calculated in llds.m
just before each procedure has its C code generated. This set is passed to
output_instruction along with the label at the start of the procedure.
1995-09-05 10:16:19 +00:00
Fergus Henderson
67ab08e245 Rename list__sort' as list__sort_and_remove_dups'.
garbage_out.m, mercury_compile.pp, mode_util.m, prog_io.m, shapes.m,
switch_gen.m:
	Rename `list__sort' as `list__sort_and_remove_dups'.
1995-08-26 05:57:43 +00:00
Andrew Bromage
9dddf14a3f OK, finally, everything should be back in order. 1995-07-05 23:38:32 +00:00
Andrew Bromage
fda56846cb With any luck, this should be the call_graph branch successfully
merged.  Do not use --constraint-propagation, because it doesn't
schedule conjunctions properly yet.
1995-07-04 03:15:30 +00:00
Peter Ross
6cc1f3e0b0 Changed the way the extra field in the label type is defined.
*.m:
	Changed the way the extra field in the label type is defined.  Now
	all labels are initially assumed to be 'unknown' and a seperate
	profiling pass (to be implemented) will determine whether the label can
	be accessed externally.
1995-06-27 09:48:20 +00:00
Thomas Conway
0dc8ca50d8 Implement an improved method of handling negated contexts.
code*.m & *gen.m:
	Implement an improved method of handling negated contexts.
	The new method avoids saving things onto the stack before
	an if-then-else or negation if it can.
	Also, fix the implementation of nondet if-then-else so that
	it does the soft cut properly.
1995-06-22 23:55:59 +00:00
Fergus Henderson
596eac55c5 Change the tests of switch size vs option value to use `>='
switch_gen.m:
	Change the tests of switch size vs option value to use `>='
	rather than `>', so that it matches the documentation.
1995-04-14 14:25:59 +00:00
Zoltan Somogyi
389599b337 Revamped the determinism system.
prog_io, hlds:	Added the functor "multidet" to the type determinism.
		Added types and predicates to relate determinism to its
		two components, can_fail and soln_count.

		Removed the functor "unspecified" from the type determinism,
		substituting maybe(determinism) for determinism in proc_info.

		Replaced the type category with the type code_model,
		and added predicates to compute it from determinism.

det_analysis:	Redone the analyses to work with determinism, not category
		(or code_model). This should enable programmers to write
		their own erroneous (and failure) predicates.

other files:	Use the new and renamed types and access predicates.
1995-04-06 02:13:05 +00:00
Fergus Henderson
ac4f8ba0fb Add copyright messages.
compiler/*:
	Add copyright messages.
	Change all occurences of *.nl in comments to *.m.

compiler/mercury_compile.pp:
	Change the output to the .dep files to use *.m rather than *.nl.
	(NOTE: this means that `mmake' will not work any more if you
	call your files *.nl!!!)
1995-03-30 21:03:41 +00:00
Fergus Henderson
77b16b11d9 Implement floating point.
code_util.nl, float.nl, llds.nl, mercury_builtin.nl, opt_debug.nl,
parser.nl, polymorphism.nl, sp_lib.nl, string.nl, string.nu.nl,
type_util.nl, typecheck.nl, unify_gen.nl:
	Implement floating point.

Makefile.common:
	Remove `-include test.dep' line.  Use Mmake.

int.nl:
	Update a few of the comments.

io.nu.nl:
	For Sicstus Prolog, if main/2 is not defined then enter the
	debugger.
1995-03-15 14:28:24 +00:00
Peter Ross
d9865c2fc1 Introduced a new predicate which ignore's any whitespace in the input.
io.nl:
	Introduced a new predicate which ignore's any whitespace in the input.
	Needs to have all the whitespace character's added to it.

*.nl and *.pp:
	Changed the implementation of time profiling.  Now during a compile,
	the compiler identifies all the internal labels which can be accessed
	externally, and marks them.  At the moment, these are the continuation
	labels of calls and the next disjunct in nondet disjunctions.  Then
	at the .mod output, it places a macro 'update_prof_current_proc' to
	restore the profiling counter.
1995-03-13 17:09:01 +00:00
Peter Ross
fcc624ae6b Introduced an extra argument to the LLDS goto.
llds.nl:
	Introduced an extra argument to the LLDS goto.  It is the label
	address of the Caller and is used for the profiling of tailcall's.

*.nl and *.pp:
	Propagated the extra argument to all the appropiate files.
1995-02-28 04:20:27 +00:00
Fergus Henderson
56c4d2cbc4 The fields in a `type_info' structure should be just
code_info.nl hlds.nl hlds_out.nl io.nl llds.int llds.nl opt_debug.nl
polymorphism.nl shapes.nl switch_gen.nl unify_gen.nl:
	The fields in a `type_info' structure should be just
	procedure addresses, not closures.
1995-02-08 19:09:41 +00:00
Fergus Henderson
65ac02d56e Add some targets for compiling the compiler and the library.
Makefile.common:
	Add some targets for compiling the compiler and the library.

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

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

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

options.nl:
	Turn -p off by default.  I'll turn it on again when it works ;-)
1995-01-19 16:09:44 +00:00
Fergus Henderson
0080e12000 Bug fix.
switch_gen.nl:
	Bug fix.
1995-01-17 10:59:17 +00:00
Fergus Henderson
48e3dea925 Fix some bugs:
polymorphism.nl:
	Fix some bugs:
		- I had forgotten to update the argmodes of the modified
		  procedures
		- I was updating the argtypes and attempting to use there
		  old value.  I fixed this by splitting the algorithm
		  into two passes.
		- to compute the types of the arguments to a call,
		  apply the type mapping from the _caller_ not the callee.
	Also improve efficiency in a couple of places.

hlds.nl:
	Add some new access predicates required by polymorphism.nl.

list.nl:
	Add a new predicate list__duplicate, which is used by polymorphism.nl.

typecheck.nl, type_util.nl:
	Move the type_unify routines from typecheck.nl into type_util.nl,
	since they're also needed by polymorphism.nl.

term.nl:
	Export term__apply_rec_substitution_to_list, since it's needed
	by polymorphism.nl.

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

mode_util.nl, type_util.nl:
	Move some routines from mode_util.nl to type_util.nl, where they
	really belong.

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

make_hlds.nl, code_util.nl, typecheck.nl:
	Mark builtin predicates as "external" in make_hlds.nl,
	rather than checking for them as a special case in typecheck.nl.

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

prog_io.nl, hlds.nl, typecheck.nl:
	For documentation purposes, define equivalent types `tvar',
	`tvarset', `tsubst' for type variables, type varsets, and
	type substitutions.

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

mercury_compile.pp, options.nl:
	Change the handling of the --dump-hlds option so that you can
	now dump the HLDS after any of the 12 HLDS transformation passes.

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

make_hlds.nl:
	Report an error if there are clauses for an imported predicate.

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

io.nu.nl:
	Add a new predicate r/1 which is like run/1 except that
	you pass it a string rather than a list of atoms.
	So now you can do
		$ mercury_compile.debug
		Mercury Interpreter 0.1
		NU-Prolog 1.6.4
		1?- r("mc -options blah blah blah").
1995-01-14 11:59:51 +00:00
Fergus Henderson
1a977ea19a Replace all occurrences of `not(Vars, Goal)' with just
*.nl:
	Replace all occurrences of `not(Vars, Goal)' with just
	plain `not(Goal)'.

type_util.nl, switch_gen.nl:
	Higher-order pred types are not user-defined types.
	Add a `predtype' type category for them.

call_gen.nl:
	Change call_closure/2 to call_closure/3 (with liveinfo).
	Plus a little bit of random hacking.
1995-01-10 18:35:59 +00:00
Zoltan Somogyi
f5dfd6a643 Broke switch_gen into four pieces. The three optimized switch methods are
now in dense_switch, string_switch and tag_switch, with the original
if-then-else implementation and the code that decides on optimizations
still in switch_gen.

Added options to replace the magic numbers governing the choice of switch
method.

Added comments to frameopt, jumpopt, labelopt and peephole.
1994-12-22 02:55:16 +00:00
Zoltan Somogyi
33974b50c6 generate code to test primary tags from most shared to least shared.
switch_gen:
	generate code to test primary tags from most shared to least shared.

frameopt:
	separated out the pass that removes superfluous saves of succip.

llds, opt_debug:
	added two new unary operators, unmktag and unmkbody, that reverse
	the effects of mktag and mkbody.

graph, value_number:
	fixed occurrences of implied modes.

code_info:
	fixed a spelling error in a comment.

*** Tom, please fix the mismatch in the names of the unification procedures.
1994-12-16 05:21:02 +00:00
Zoltan Somogyi
67d15cc907 Added comprehensive optimization of detstack frame manipulation
frameopt, opt_util, code_uti, middle_recl:
	Added comprehensive optimization of detstack frame manipulation
	instructions, replacing the earlier limited one. In the process,
	moved a function from middle_rec to code_util, since frameopt
	could also use it.

switch_gen:
	Specialized the handling of switches with two cases to avoid
	pipeline breaks.

std_util:
	Added boolean and and or predicates.

set:
	Added membership enquiry function.

mercury_compile:
	Commented out a manual garbage collection point that was causing
	trouble.
1994-12-09 01:12:45 +00:00
Fergus Henderson
d8c9479872 Override the MERCURY_LIB_OBJS variable when invoking ml.
Makefile.mercury:
	Override the MERCURY_LIB_OBJS variable when invoking ml.
	This avoids some bootstrapping problems.
	Also, add mercury_compile.nu.

Makefile.common:
	Bump NU-Prolog's -u option up to 2000 (8M), to avoid some memory
	problems.

array.nl, bintree.nl, char.nl, dir.nl, globals.nl, list.nl, map.nl, modes.nl,
prog_util.nl, stack.nl, std_util.nl, string.nl, term.nl:
	Avoid the use of implied modes.

code_info.nl, bimap.nl, make_hlds.nl, mercury_compile.nl,
mercury_to_mercury.nl, unify_proc.nl:
	Fix determinism errors which had previously not been discovered
	because of either implied modes or running out of memory.
	(Note that I had to change the interface to bimap__lookup, since
	it's not possible to make it bidirectional.)

code_util.nl, llds.nl, opt_debug.nl, value_number.nl:
	Rename `operator' as `binary_op'.

hlds.nl, code_info.nl, unify_gen.nl, llds.nl, opt_debug.nl, switch_gen.nl:
	*** Handle simple cases of higher-order pred terms. ***
	(We don't yet handle taking the address of an overloaded
	predicate or a predicate with multiple modes.
	We don't handle closures.  call/1 and call/N are not yet implemented.
	This has not yet been tested.)

make_hlds.nl:
	Modify the mode priority ordering so that semidet modes get
	selected before det ones.

llds.nl:
	Don't include the priority part of the mode number in the mangled
	label name.  *** Note: this will break some things! ***

mercury_compile.nl:
	Move the NU-Prolog hacks into mercury_compile.nu.nl.

switch_gen.nl:
	Fix a simple logic bug in handling the grab/slap of the code_info.

prog_io.nl, builtins.nl, int.nl:
	Fix bugs and omissions with handling of the new arithmetic operators.

prog_io.nl:
	As a quick hack, strip off calls to io__gc_call
	(this avoids spurious error messages which are due to
	the fact that we don't get mode analysis right in those cases).
1994-10-02 17:00:57 +00:00
Fergus Henderson
1a27233878 Make the handling of builtins a little more general.
call_gen.nl:
	Make the handling of builtins a little more general.

code_info.nl, unify_gen.nl:
	Use code_info__get_next_label_number rather than
	the lower-level routines code_info__get_label_count
	and set_label_count.

code_util.nl:
	Rame atom_to_operator as code_util__atom_to_binop
	and add code_util__atom_to_unop.

prog_io.nl, code_util.nl, llds.nl, int.nl, opt_debug.
	Add bitwise operators.
	Add array_index binary operator.
	Add hash_string unary operator.
	Add int__log2 predicate.
	Cast operands to (int) in llds.nl, so that we
	get integer comparisons and integer operations.

string.nl:
	Add string__hash predicate.

interpreter.nl:
	Use disjunction in semidet preds.

options.nl:
	Add --smart-indexing option (enabled by default).

switch_gen.nl:
	**** Generate a hash table lookup for string switches. ****
1994-09-30 21:42:27 +00:00
Fergus Henderson
e646a016e5 Fix determinism error which was due to the lack of multi-level
opt_util.nl:
	Fix determinism error which was due to the lack of multi-level
	indexing.

code_info.nl:
	A very minor code simplification.

switch_gen.nl:
	Generate better code for switches on atomic types.
	We now use jump tables in more cases.
	(This speeds up `crypt' by about 0.4% - not much).
1994-09-29 10:19:42 +00:00
Fergus Henderson
ed84ab722e Implement switches which just switch on a range of integers or
switch.nl:
	Implement switches which just switch on a range of integers or
	enumeration constants without any gaps by using a dense jump
	table.  (This won't improve the benchmarks at all, since none
	of them contain any such switches, except for one in one of the
	output routine in poly.nl.)

	Also for chained switches, sort the cases so that we test for
	complicated_constant_tags first (single register comparison),
	simple_tags second (mask & reg compare), and complicated_tags last.
	(This might improve the benchmark times just a fraction.)

	Handling

llds.nl:
	Add a `cast_to_unsigned' operator.
	Fix bugs in the output of computed_goto instructions.

peephole.nl:
	Fix bug where the targets of computed_gotos got optimized
	away.  (But we still don't optimize computed jumps to jumps yet.)
	Reorganzied the code a little so that it's easier to
	maintain when we add new instrunctions.
1994-09-10 07:25:30 +00:00
Fergus Henderson
fce7928c58 Replace the 3 switch_gen preds with a single one, since
switch_gen.nl, code_gen.nl:
	Replace the 3 switch_gen preds with a single one, since
	they all did almost exactly the same thing.
1994-09-10 01:10:54 +00:00
Fergus Henderson
37474a09f1 Reorganize the LLDS representation to minimize duplication.
llds.nl, *_gen.nl, code*.nl, unify_proc.nl, peephole.nl:
	Reorganize the LLDS representation to minimize duplication.
1994-09-09 23:24:40 +00:00
Fergus Henderson
2d421c9dcf - Add another rule to suppress the default Modula-2 rule.
Makefile.mercury:
	- Add another rule to suppress the default Modula-2 rule.
	- Remove the rule for making *_init.c; this has to be done
	manually by the user's makefile, since the necessary
	information isn't available here.
	- Change the default MOD2INITFLAGS to -wmercury__main_predicate_3_0.

*_gen.nl, code_info.nl:
	Generate fail() rather than redo() if we know the redoip
	must point to do_fail.
1994-09-08 11:58:01 +00:00
Fergus Henderson
91ee238587 Added a new pred code_info__produce_variable, which combines
*_gen.nl, code_info.nl:
	Added a new pred code_info__produce_variable, which combines
	flush_variable and variable_get_register, except that it
	returns an rval rather than an lval.  The idea is
	that using produce_variable means we don't have to store
	constants in registers before we can use them.

code_info.nl:
	Avoid generate some unnecessary register shuffles.

mercury_compile.nl, Makefile.mercury.
	Add some gross hackery to do manual memory management
	with NU-Prolog.  Up the -u option to 1200.
1994-09-08 07:31:38 +00:00
Fergus Henderson
ac0f113de6 Install ml.sh.
Makefile:
	Install ml.sh.

*_gen.nl, code_info.nl:

	Reorganize the handling of failure continuations and mixing
	det/semidet/nondet code in the one procedure.
	It should now work! ;-)

	The category_context field has gone away.
	The fall_though field is now a stack(maybe(label)) rather
	than a stack(label).  If Cont = yes(label), then we
	fail by jumping to that label.  If Cont = no, then we
	fail by executing a redo().  Whenever we create a semidet
	choice point, we just push a failure continuation label.
	Whenever we create a nondet choice point, we do two things:
	(1) generate code which does a `modframe()'
	(2) push a failure continuation label
	The failure continuation records what value is currently in the
	redoip.  This allows us to short-circuit redo() instructions
	into direct jumps.  Whenever we get to a nondet goal, we change
	the current failure continuation to `no', since the nondet goal
	might have left some choice points behind.
	(TODO: The same sort of mechanism would allow us to optimize `redo()'
	to `fail()' but we don't do that yet; also currently we generate
	quite a few unnecessary modframe() instructions.)

	`generate_[i]cond_branch' has gone away.
	Instead, push a failure continuation and then call
	generate_test_and_fail.

code_util.nl, llds.nl:
	Fix newly discovered determinism errors.

code_info.nl, live_vars.nl:
	framevars start at 0, not at 1!!!
1994-08-28 21:39:24 +00:00
Fergus Henderson
a407841788 Only save and restore the heap pointer if the goal being
backtracked over contains a construction unification or a
non-builtin call.  Add code to save/restore the heap pointer
in one or two places where this was missing, e.g. semidet disjunctions.

Change switch/2 into switch/3 so that we can store the `local
determinism' of the switch there, rather than in the goal_info.

Fix code generation for semidet/nondet switches, so that
we omit the test for the last case if the switch is locally
det.
1994-08-27 08:29:26 +00:00
Fergus Henderson
fca313a44d Improve code generation for deterministic switches by omitting
switch_gen.nl:
	Improve code generation for deterministic switches by omitting
	the test for the last case.  (I haven't tested this change.)
1994-08-23 19:12:34 +00:00
Fergus Henderson
0ce51d7a2f Add a new pred proc_info_interface_determinism and
arg_info.nl, call_gen.nl, code_gen.nl, live_vars.nl, hlds.nl:
	Add a new pred proc_info_interface_determinism and
	ensure that it is called from the appropriate places.

code_gen.nl:
	Improve the code generation for commits (don't bother
	to restore maxfr if the goal fails, since maxfr won't
	have been modified).

llds.nl:
	Add a generate way of inserting arbitrary C code in the LLDS.

switch_gen.nl, code_info.nl:
	Generate correct code for switches whose determinism has
	incorrectly been inferred as det.
1994-08-16 10:08:11 +00:00
Fergus Henderson
3e984e7793 Various bug fixes for non-deterministic code.
code_gen.nl, code_info.nl, disj_gen.nl, ite_gen.nl, switch_gen.nl:
	Various bug fixes for non-deterministic code.
	(nqueens now works! ;-)

live_vars.nl:
	Bug fix: initial liveness should be {input vars} not {output vars}.
	(Apologies from Thomas ;-).

llds.nl:
	Couple of minor bug fixes.  Added code to output redo().

io.nl, portray.nl, prog_io.nl, std_util.nu.nl, term_io.nu.nl:
	Change X.Xs into [X|Xs].

swi_builtin.nl, doit.pl:
	Add some support for SWI-Prolog.

set.nl, stack.nl:
	Suppress bogus SWI-Prolog singleton variables warnings in
	type declarations.

term_io.nu.nl:
	Remove some of the dependences on NU-Prologisms.
1994-08-14 12:14:51 +00:00
Thomas Conway
fc2aa5cf3d Improve the generation of tests.
code_info.nl switch_gen.nl unify_gen.nl:
		Improve the generation of tests.

llds.nl:	fix a few things (some brackets and stuff).
1994-07-07 08:39:07 +00:00
Thomas Conway
42920f22f5 Bugfixes. Implement the basics of nondeterministic code.
code_info.nl, *_gen.nl:
	Bugfixes. Implement the basics of nondeterministic code.
	Lots of cases still not handled, but look, you've got to
	start somewhere :-)

liveness.nl:
	Fix bugs shown up by the follow* transformations.

llds.nl:
	Add a few extra things for nondeterministic code.
1994-07-06 16:36:49 +00:00
Thomas Conway
f776ba61eb Fixed the handling of liveness in the presence of erroneous
liveness.nl:
	Fixed the handling of liveness in the presence of erroneous
	predicates. Bug was shown up by the followcode/followvars
	transformation.

*_gen.nl code_info.nl:
	Bugfixes. Laid some of the groundwork in preparation for
	nondeterministic code generation (long live bottom up design!)
1994-07-06 09:28:22 +00:00
Thomas Conway
1a855efa62 Fix the interface dependencies so that they are not circular.
code_util.nl:
	Fix the interface dependencies so that they are not circular.

group.nl:
	Fix a determinism error.

switch_gen.nl unify_gen.nl:
	Bug fixes - survive a whole lot more test cases.
1994-06-28 13:09:35 +00:00
Fergus Henderson
186b2bdc36 Minor efficiency improvement.
switch_detection.nl:
	Minor efficiency improvement.

call_gen.nl, hlds.nl, make_hlds.nl, modes.nl, det_analysis, followvars,
code_gen.nl:
	Add an extra field to record the determinism for
	deconstruct(...) and complicated_unify(...) unifications.

modes.nl, mode_util.nl:
	Handle free-free unifications as assignments, not as
	complicated_unifies.
	Add mode_is_unused to mode_util.nl so we can detect them.

call_info.nl:
	Fix bug in call_info__cons_id_to_tag.
1994-06-27 23:10:48 +00:00
Thomas Conway
e10492fa2a Added mkbody and body rvals which expand to macros.
llds.nl:
	Added mkbody and body rvals which expand to macros.

*_gen.nl code_info.nl:
	Fixed tag stuff. String things call error/1 but the
	rest is approximately right. Still wants for testing.
1994-06-27 16:13:00 +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
Thomas Conway
0dfcb0f881 Add a pair of rules for builing the library dependencies.
Makefile.common:
	Add a pair of rules for builing the library dependencies.

*_gen.nl code_info.nl:
	Fix spelling error.

code_gen.nl toplevel.nl:
	Pass io__state into the top of the code generator to print
	status messages.

liveness.nl:
	More fixes. Needs change to goal_info structure. Will happen
	soon.
1994-06-20 02:49:58 +00:00
Thomas Conway
1603c5d1e0 removed - now code_gen.nl
codegen.nl:
	removed - now code_gen.nl
Makefile:
	minor fixes
code_gen, code_info, call_gen, switch_gen,unify_gen:
	bug fixes. The code generator works better than ever :-)
	It still contains bugs though...
toplevel.nl:
	added the liveness pass.
1994-06-13 05:16:28 +00:00
Thomas Conway
b0d87c4f1c various changes. Added switch_gen.nl renamed the other codegen
Makefile:
	various changes. Added switch_gen.nl renamed the other codegen
	files to fit the naming conventions.
array.nl:
	added some determinism declarations.
bimap.nl:
	fixed some of the determinism problems.
doit.nl:
	minor changes.
hlds.nl:
	added liveness to the procinfo structure.
	added access predicates and type definition for liveness_info.
hlds_out.nl, modes.nl:
	patched the explicit usage of proc/11. for the above change.
int.nl:
	fixed it so that it compiles under mc!
map.nl, set.nl, term.nl:
	fixed determinism warnings.
toplevel.nl:
	import code_info.
various:
	file renaming to fit naming conventions.
1994-06-09 07:31:45 +00:00