Commit Graph

29 Commits

Author SHA1 Message Date
Fergus Henderson
d86ea8fb5a Fix a couple of bugs with nondet code generation.
Estimated hours taken: 12

Fix a couple of bugs with nondet code generation.

compiler/code_info.m:
	Fix two bugs in code_info__make_known_failure cont.

	The first bug was that the way it checked for whether a temp
	frame had been created was incorrect; it was only checking
	the HaveTempFrame parameter, which was true only if the most
	recent disjunction had required creation of a temp frame,
	whereas it needs to check the whole failure continuation stack.

	The second bug was that it was doing the wrong thing in the
	case where the current failure continuation was unknown,
	but a temp frame had been created.  It was just clobbering
	the current redoip, whereas what it needs to do is to create
	another temp frame.

compiler/code_gen.m:
compiler/disj_gen.m:
compiler/ite_gen.m:
	Don't pass the HaveTempFrame parameters to and from
	code_info__make_known_failure_cont.
1997-06-11 05:13:53 +00:00
Tyson Dowd
62b46f531b Fix the insts of live variables in continuation_info.
Estimated hours taken: 1.5

Fix the insts of live variables in continuation_info. They were calculated
using the insts before the call instead of after the call.

compiler/call_gen.m:
compiler/code_info.m:
	Apply the instmap_delta of the current goal to the instmap when
	looking up the insts of live variables.
	Make the hlds_goal_info of the current goal available when
	generating calls.

compiler/code_gen.m:
	Make the hlds_goal_info of the current goal available when
	generating calls.
1997-06-05 05:47:56 +00:00
Tyson Dowd
ab20991f00 Changes to clean up the collection of live value information.
Estimated hours taken: 30

Changes to clean up the collection of live value information. Instead of
requesting shape numbers and outputting .garb files, we store the needed
information for later processing, so we can generate typeinfos for such
types later, when we create stack_layout tables.

The compiler actually _shrinks_ as a result of this change.

compiler/call_gen.m:
	- Don't request shape numbers for live data, store their types
	  and insts instead.

compiler/code_gen.m:
	- Call continuation_info__add_proc_info for each procedure
	  generated.
	- Pass around continuation_infos rather than shape_tables.

compiler/code_info.m:
	- Don't request shape numbers for live data, store their types
	  and insts instead.
	- Provide predicate for converting lvals into live_value_types.
	- Replace shape_table with continuation_info

compiler/continuation_info.m:
	- New module for storing information about continuations needed
	  for accurate garbage collection. This will later be used to
	  output stack_layout structures.

compile/hlds_module.m:
	- Remove shape_table from module_info, put continuation_info in
	  its place.

compiler/llds.m:
	- Add new live_value_type, which describes a live value (succip,
	  curfr, maxfr, redoip, hp, var(type, inst), unwanted).
	  This will replace the shape_num type.

compiler/llds_out.m:
	- Output live_value_types instead of shape_nums.

compiler/make_hlds.m:
	- Don't add abstract_exports to the shape table - we don't
	  use them anymore.

compiler/mercury_compile.m:
	- Document `join_string_list' and `join_module_list' as their names
	  are a bit cryptic.
	- Don't output .garb files, don't do abstract exports pass.
	- Replace handling of shape_table with continuation_info.

compiler/garbage_out.m:
compiler/shapes.m:
	- Remove these files, as they are no longer used.

runtime/mercury_accurate_gc.h:
	- Add new file with defintions for accurate gc.
1997-05-27 03:10:41 +00:00
Tyson Dowd
cbcb23d17b Enable --warn-interface-imports by default.
Estimated hours taken: 3

Enable --warn-interface-imports by default. This was turned off while
list and term were defined in mercury_builtin.m, since it caused many
warnings.

Fix all the unused interface imports that have been added since then.

compiler/options.m:
	Enable --warn-interface-imports by default.

compiler/module_qual.m:
	Fix formatting inconsistencies with module names in warning
	messages. (".m" was not appended to module names if there was
	only one module).

compiler/*.m:
library/*.m:
tests/invalid/type_loop.m:
tests/warnings/*.m:
	Remove usused interface imports, or move them into
	implementation (mostly bool, list and std_util).
1997-05-21 02:16:53 +00:00
Fergus Henderson
651108aac9 Fix a bug introduced by Zoltan's changes to delay flushing
Estimated hours taken: 16

compiler/dense_switch.m:
	Fix a bug introduced by Zoltan's changes to delay flushing
	of variables needed on backtracking.
	The bug was that it was the final code_info after a nondet
	dense_switch had not unset the top failure continuation.
	This caused the code generator to generate incorrect C code for
	the code following the dense switch: the generated C code
	clobbered the topmost redoip, rather than using a new temp frame.
	The fix was to ensure that we use the code_info from the
	end of one of the switch branches (for which we will have called
	code_info__unset_failure_cont from code_info__branch_end)
	rather than using the initial code_info and just resetting
	the live variables.

compiler/code_gen.m:
compiler/code_info.m:
compiler/disj_info.m:
compiler/ite_gen.m:
	Various minor improvements to the comments.

tests/general/space.m:
	Regression test for the above-mentioned bug.
1997-05-20 04:04:30 +00:00
Fergus Henderson
e3471f333f Fix a bug in inlining of polymorphic pragma c_code procedures.
Estimated hours taken: 3

Fix a bug in inlining of polymorphic pragma c_code procedures.

The bug was that if the actual argument type has a specific type
of say `float', then the C variable for the corresponding formal
parameter will be declared to have type `Float', whereas without
inlining the argument type would have been polymorphic and so
the C variable would have been declared to have type `Word'.
Hence we need to keep track of the original argument types,
before any inlining or specialization has occurred, and use
these original argument types to determine how to declare
the C variables, rather than using the actual argument types
for this particular specialization.

compiler/hlds_goal.m:
	Add a new field to pragma_c_code goals, holding the
	original argument types (before any inlining or specialization)
	of the pragma_c_code procedure.

compiler/make_hlds.m:
	Initialize this field with the declared argument types for
	the pragma c_code procedure.

compiler/polymorphism.m:
	Update this field to account for the inserted type_info variables.

compiler/code_gen.m:
	Pass this field to pragma_c_gen.m.

compiler/pragma_c_gen.m:
	Use the original argument types field for the pragma variable
	declarations, rather than looking up the actual types of the
	arguments.

compiler/*.m:
	Trivial changes to handle new field.

compiler/live_vars.m:
	Comment out some code to avoid a warning about `fail'
	in the condition of an if-then-else.
1997-05-05 11:17:40 +00:00
Andrew Bromage
f4d3661ea6 Module qualify predicate names attached to incr_sp instructions to
Estimated hours taken: 0.5

Module qualify predicate names attached to incr_sp instructions to
improve error reporting in debug grades.

compiler/code_gen.m:
compiler/code_info.m:
compiler/middle_rec.m:
	Various minor changes to do above.
1997-04-04 04:41:13 +00:00
Andrew Bromage
d7319104f9 Making the types pred_id and proc_id (almost) abstract.
Estimated hours taken: 7

Making the types pred_id and proc_id (almost) abstract.

compiler/code_util.m:
        Changed the type of several predicates:
                code_util__make_uni_label/4 (arg 3 was int, now proc_id)
                code_util__inline_builtin/4 (arg 3 was proc_id, now int)
        Added predicate code_util__translate_builtin_2/6.

compiler/hlds_module.m:
        Moved invalid_pred_id/1 to hlds_pred.m

compiler/hlds_pred.m:
        Types pred_id/0 and proc_id are now abstract.
        Added predicates:
                hlds_pred__initial_pred_id/1, hlds_pred__initial_proc_id/1,
                hlds_pred__next_pred_id/2, hlds_pred__next_proc_id/2,
                pred_id_to_int/2, proc_id_to_int/2,
                hlds_pred__in_in_unification_proc_id/1
        Moved predicate invalid_pred_id/1 (from hlds_module.m).

compiler/*.m:
        Miscellaneous minor changes to cast pred/proc_ids to ints
        where appropriate.
1997-03-06 05:09:54 +00:00
Fergus Henderson
3ec8a17ffc Enable the code to treat `__' as an alternative syntax for module
Estimated hours taken: 8

Enable the code to treat `__' as an alternative syntax for module
qualification, after fixing various places in the compiler where
we use `__' in ways that are incompatible with this.

compiler/prog_io.m:
compiler/prog_io_goal.m:
	Uncomment the code to handle `__' as module qualification.

compiler/intermod.m:
compiler/hlds_module.m:
compiler/modecheck_unify.m:
	Fix bugs in the handling of module qualified higher-order terms.

compiler/*.m:
	s/hlds__/hlds_/g

compiler/passes_aux.m:
	s/process__/process_/g

compiler/pragma_c_gen.m:
compiler/code_gen.m:
	s/code_gen__/pragma_c_gen__/ for the predicates defined in
	pragma_c_gen.m (this ought to have been done when the code
	was first moved from code_gen.m to pragma_c_gen.m).

compiler/llds.m:
	s/llds__proc_id/llds_proc_id/g
	The reason for this was to avoid ambiguity between proc_id
	in hlds_pred.m and llds__proc_id in llds.m.

compiler/quantification.m:
compiler/make_hlds.m:
compiler/mercury_to_c.m:
	s/goal_vars/quantification__goal_vars/g
	The reason for this was to avoid ambiguity between goal_vars
	in quantification.m and goal_util__goal_vars in goal_util.m.

compiler/dupelim.m:
compiler/optimize.m:
	s/dupelim__main/dupelim_main/g
	The reason for this change is that a program can only
	have one main/2 predicate.

compiler/prog_io_dcg.m:
	Remove the old "temporary hack" to strip off and ignore
	io__gc_call/1, since the new handling of `__' broke it.
	It was only useful for optimizing NU-Prolog performance,
	which we don't care about anymore.

compiler/mercury_compile.m:
compiler/modules.m:
compiler/intermod.m:
compiler/prog_io.m:
	Remove occurrences of io__gc_call.

compiler/llds_out.m:
compiler/base_type_info.m:
	Ensure that we properly handle the special hacks in mercury_builtin
	where predicates from other modules (e.g. term__context_init)
	are defined in mercury_builtin because they are needed for
	type_to_term and term_to_type.  llds_out.m: don't put
	`mercury_builtin' in the mangled names for those symbols.
	base_type_info.m: handle types whose status is "imported"
	in their own module.
1997-02-23 06:08:34 +00:00
Zoltan Somogyi
91c4330db7 The first half of a change to introduce nondet pragma C goals.
Estimated hours taken: 12

The first half of a change to introduce nondet pragma C goals.
This half makes the necessary modifications to the HLDS; the next
half will modify the LLDS and emit it.

prog_data:
	Add a new pragma type for nondet pragma c_codes; these specify
	the names of a a bunch of variables to save across backtracking,
	and a list of label names to which backtracking may take place.

	Rename is_recursive to may_call_mercury, since this is a more
	direct expression of the meaning.

prog_io:
	Move much of the functionality to new files.

prog_io_dcg, prog_io_goal, prog_io_pragma, prog_io_util:
	New files, made up of pieces of prog_io.

hlds_goal:
	Add an extra argument to the pragma_c_goals to store the extra
	information present in the new type of pragma c_codes.

det_analysis:
	Take into account that the new type of pragma_c goal may have
	more than one solution.

goal_util:
	Rename variables in the new field of pragma_cs.

live_vars:
	Allocate stack slots to the saved variables in the new type of pragma_c
	goals.

make_hlds:
	Handle the new type of pragma_c goals.

mercury_output, hlds_out:
	Output the new type of pragma_c goals.

garbage_out:
	Rename type "det" to "frame_type".

others:
	Ignore one more arg of pragma_c goals or import prog_io_util.
1997-01-27 07:45:40 +00:00
Fergus Henderson
5a75f60622 Fix the numerous gcc warnings about "type mismatch with previous
Estimated hours taken: 10

Fix the numerous gcc warnings about "type mismatch with previous
external decl" caused by nested "extern const struct ..." declarations
with incomplete struct types.  (If we're lucky, this change might also
work around the recent problems with gcc getting segmentation faults
(fatal signal 11)).

llds_out.m:
	Output all declarations at global scope rather than in
	locally nested scopes.

module_info.m:
	Add a new cell_count field.
	This is in module_info as well as in code_info since cell
	numbers need to be unique within each module, not just unique
	within each predicate.

code_info.m:
	Add cell_count as a new parameter to code_info_init.
	Make sure that cell_count is not clobbered by slap_code_info.

code_gen.m, mercury_compile.m:
	Thread the cell_count from the module_info through code_info
	and back, to ensure that cell numbers are unique within
	a module.
1997-01-16 16:35:52 +00:00
Zoltan Somogyi
06555906d4 Rewrite the submodule for handling stack slots: instead of a stack
Estimated hours taken: 3

code_info:
	Rewrite the submodule for handling stack slots: instead of a stack
	of temporary values, we now use a set. This removes the requirement
	for doing allocations and deallocations in LIFO order.

	Change the handling of the detstack slots used for performing commits
	in model_non procedures. The old way was computing the wrong liveinfo
	set for use by the accurate garbage collector for all calls inside
	two or more commits in such procedures.

code_gen:
	Pass some data between generate_pre_commit and generate_commit calls,
	since we can no longer rely on the stack top to carry this info.
1997-01-08 07:52:43 +00:00
Zoltan Somogyi
54bb1c4a67 Move the code that generates code for pragma_c_codes to a new module.
Estimated hours taken: 3

code_gen, pragma_c_code:
	Move the code that generates code for pragma_c_codes to a new module.

llds:
	Change the representation of reg and temp lvals, in order to create
	the concept of a "register type" and to reduce memory requirements.

	Also add a comment indicating a possible future extension dealing with
	model_non pragma_c_codes.

code_exprn, code_info:
	Add the ability to request registers of a given type, or a specific
	register, when acquiring registers.

bytecode, bytecode_gen, call_gen, dupelim, exprn_aux, follow_vars, frameopt,
garbage_out, jumpopt, llds_out, middle_rec, opt_debug, opt_util, store_alloc,
string_switch, tag_switch, unify_gen, vn_block, vn_cost, vn_filter, vn_flush,
vn_order, vn_temploc, vn_type, vn_util, vn_verify:
	Small changes to accommodate the new register representation.

hlds_goal:
	Add a comment indicating a possible future extension dealing with
	model_non pragma_c_codes.

inlining:
	Add a comment indicating a how to deal with a possible future extension
	dealing with model_non pragma_c_codes.
1996-12-31 09:58:59 +00:00
Zoltan Somogyi
f23324f5fa This change fixes two bugs, in quantification and liveness.
Estimated hours taken: 10

This change fixes two bugs, in quantification and liveness. I made the changes
to the other files while trying to find them; they ought to be useful in
trying to find similar bugs in the future.

The compiler now bootstraps with agressive inlining enabled.

quantification:
	Fix a bug that switched two different accumulators of the same type
	when processing pragma_c_codes.

liveness:
	Fix a bug that could cause a variable to end up in both the post-death
	and post-birth set of the same goal.

options:
	Reenable inlining.

hlds_out, mercury_to_mercury:
	If -D v is given, include the number of each variable at the end of
	its name (e.g. Varname_20).

	The predicates involved (a few from mercury_to_mercury and many from
	hlds_out) now have an extra argument that says whether this should be
	done or not. (It is not done when printing clauses e.g. for .opt
	files.)

	The bug in quantification was causing the improper substitution of
	one variable for another, but both had the same name; such bugs would
	be very difficult to find without this change.

constraint, det_report, intermod, make_hlds, mercury_to_c, mode_debug,
mode_errors, module_qual, typecheck:
	Call predicates in hlds_out or mercury_to_mercury with the extra
	argument.

saved_vars:
	Thread the io__state through this module to allow debugging.

mercury_compile:
	Call saved_vars via its new interface.

	Fix an inadvertent use of an out-of-date ModuleInfo.

goal_util, hlds_goal:
	Minor formatting cleanup.

code_gen:
	Clean up the import sequence.
1996-12-30 11:31:17 +00:00
Zoltan Somogyi
bc97676d98 Change the definition of is_builtin to use less space.
Estimated hours taken: 2

hlds_goal:
	Change the definition of is_builtin to use less space.

bytecode_gen, code_aux, code_gen, code_util, dependency_graph, follow_code,
higher_order, inlining, live_vars, make_hlds, modecheck_unify, modes,
polymorphism, stratify, unused_args:
	Fixes to accommodate the change to is_builtin.
1996-12-24 02:42:21 +00:00
Zoltan Somogyi
5544174d7c An overhaul of the code saving and restoring heap pointers and tickets,
Estimated hours taken: 3

An overhaul of the code saving and restoring heap pointers and tickets,
and some other changes that affect the interface of code_info.

code_info:
	The predicates that handle save heap pointers and tickets now return
	the slot these things are stored in; the predicates that restore
	and/or discard these values must give them back. This should avoid
	the problem we used to have with the same slot being used to store
	both a heap pointer and a ticket.

	Rename some predicates to better reflect their purpose.

	Accept pre_ and post_goal_update preds and the type lookup preds from
	code_aux, since this is where they belong.

code_aux:
	Move pre_ and post_goal_update preds and the type lookup preds to
	code_info, since that is where they belong.

call_gen:
	Fix the bug that broke nondet tailcalls for the case when the tailcall
	is a higher order call.

code_gen:
	Use the new way of saving and restoring heap pointers. We now save
	tickets across negations; the absence of code to do this was a bug.

disj_gen:
	Use the new way of saving and restoring heap pointers and tickets.
	Avoid restoring anything in the first disjunct. In pruned disjunctions,
	avoid saving the heap pointer more than once. (This does mean that
	we may restore it in some cases were we didn't used to, but such cases
	can be expected to be quite rare.)

ite_gen:
	Use the new way of saving and restoring heap pointers and tickets.

dense_switch, lookup_switch, middle_rec, unify_gen:
	Rename some called predicates as required by the changes to the
	other modules.
1996-12-22 06:37:44 +00:00
Zoltan Somogyi
21a6cafa40 Restructure into several submodules to give the module logical
Estimated hours taken: 3

code_info:
	Restructure into several submodules to give the module logical
	structure. Make very slight alterations in the interface.

call_gen, code_gen:
	Use the new interface of code_info.

code_aux:
	Add comments.

code_util:
	Fix a bug caught by Fergus' review.

disj_gen, ite_gen, liveness:
	Fix some comments.
1996-12-20 08:11:00 +00:00
Zoltan Somogyi
3243dbe238 The only significant change in this checkin is that liveness.m now
Estimated hours taken: 0.5

The only significant change in this checkin is that liveness.m now
tries to compute the best resume_locs for negations (it already did
for if-then-elses and disjunctions; leaving out negations was an
oversight in my earlier checkin).

The other changes are only syntactic:

I have removed the cont-lives and nondet-lives field from goal_info,
since they are not used anymore.

I have replaced the nondet-lives field in code_info, which is not used
anymore, with a follow-vars field, which is not used yet (but will be).

Some of the "read" access predicates in hlds_goal did not have "get" in
their name; I added them.
1996-12-18 11:09:52 +00:00
Zoltan Somogyi
08a5f48e2c Take the code generator a big step closer to notes/ALLOCATION.
Estimated hours taken: _____

Take the code generator a big step closer to notes/ALLOCATION.
The new code generator emits code that is smaller and faster than
the code we used to emit.

Nondet liveness is no longer used; nondet live sets are always empty.
In code that was being modified anyway, remove its handling. Other
uses will be removed later (this keeps this change from being far too big;
as it is it is merely too big). Similarly for cont-lives.

In several places, clarify the code that gathers several code pieces together.

call_gen:
	Unset the failure continuation and flush the resume vars to
	their stack slots before nondet calls.

	Move the code that decides whether a nondet call can be a tailcall
	to code_info.

code_aux:
	Remove the code to handle resume points, since these are now
	handled in the specific constructs that need them. Replace it
	with a sanity check.

code_exprn:
	Add a predicate to place multiple vars.

code_gen:
	Remove the predicate code_gen__generate_forced_goal, since it
	packaged together some operations that should be executed at different
	times.

	Don't unset the failure continuation after every nondet goal;
	this is now done in the constructs that need it.

	Modify the handling of negation to use resume point info
	according to notes/ALLOCATION.

	Remove the predicate code_gen__ensure_vars_are_saved which was
	use to save all lives variables to the stack before nondet
	disjunctions and if-then-elses; we don't do that anymore.

code_info:
	Significantly simplify and document the handling of failure
	continuations, and make the types involved abstract types.

	Factor out common code in the handling of det and semi commits.

	Keep track of "zombies", variables that are dead wrt forward
	execution but whose values we need because they may be needed
	at a resume point we can reach.

	Remove several now unneeded predicates, and introduce new
	predicates to help other modules.

code_util:
	Add a couple of predicates to check whether ia goal cannot fail before
	flushing all variables to the stack, and whether a goal cannot flush
	any variables to the stack. These are used in liveness to decide
	which entry labels will be needed at resume points.

disj_gen:
	Unify the handling of det and semi disjunctions. Model the code
	handling of nondet disjunctions on the code handling pruned
	disjunctions. It is possible that the handling of nondet and pruned
	disjunctions can also be unified; the new code should make this
	significantly easier.

	Make the code conform to notes/ALLOCATION. This means saving
	only the variables mentioned in the resume_point field, not
	flushing all live variables to the stack at the start of a
	nondet disjunction, handling zombies, and using the new method
	of flushing variables at the ends of branched structures.

ite_gen:
	Unify the handling of det and semi if-then-elses. Model the code
	handling of nondet if-then-elses on the code handling det/semi
	if-then-elses. It is possible that the handling of nondet and pruned
	if-then-elses can also be unified; the new code should make this
	significantly easier.

	Make the code conform to notes/ALLOCATION. This means saving
	only the variables mentioned in the resume_point field, not
	flushing all live variables to the stack at the start of a
	nondet if-then-else, handling zombies, and using the new method
	of flushing variables at the ends of branched structures.

	Apply the new rules about liveness in if-then-elses, which say that
	the else part is parallel not to the then part but to the conjunction
	of the condition and the then part.

dense_switch, lookup_switch, string_switch, switch_gen, tag_switch, middle_rec:
	Use the new method of flushing variables at the ends of branched
	structures. Don't call remake_with_store map; switch_gen will do so.

	Fix an old bug in lookup_switch.

	The code in switch_gen which looked for the special case of a two-way
	switch used to use a heuristic to decide which one was recursive and
	which one was a base case. We now check the codes of the cases.

hlds_goal:
	Adjust the structure of the resume_point field to make it easier
	to use. Add a more convenient access predicate.

hlds_out:
	Don't print the nondet liveness and cont live fields, since they are
	not used anymore. Comment out the printing of the context field,
	which is rarely useful. Modify the printing of the resume_point field
	to conform to its new definition.

live_vars:
	Use the resume_point field, not the nondetlives field, to decide
	which variables may be needed on backward execution. Remove some
	code copied from liveness.m.

liveness:
	Put the several pieces of information we thread through the traversal
	predicates into a single tuple.

	Don't put variables which are local to one branch of a branched
	structure into the post-birth sets of other branches.

	Apply the new rules about liveness in if-then-elses, which say that
	the else part is parallel not to the then part but to the conjunction
	of the condition and the then part. Variables that are needed in the
	else part but not in the condition or the then part now die in at the
	start of the condition (they will be protected by the resume point on
	the condition).

	We now treat pruned and non-pruned disjunctions the same way
	wrt deadness; the old way was too conservative (it had to be).

	We still mishandle branches which produce some variables but
	can't succeed.

mercury_compile:
	Liveness now prints its own progress message with -V; support this.

store_alloc:
	When figuring out what variables need to be saved across calls,
	make sure that we put in interference arcs between those variables
	and those that are required by enclosing resume points.

	Don't compute cont-lives, since they are not used anymore.

livemap:
	Fix the starting comment.
1996-12-18 08:56:10 +00:00
Zoltan Somogyi
b72a942944 Start using resume_point information to save variables to their
Estimated hours taken: 3

code_aux, code_info:
	Start using resume_point information to save variables to their
	stack slots when they become forward dead.

code_gen, middle_rec:
	Handle the code fragments that can now result from pre and post
	goal updates.

live_vars:
	Make sure that variables that can be put into stack slots at
	resumption points get stack slots allocated to them.

liveness:
	Fix a bug in the computation of resume_point sets.

llds_common:
	Fix some comments.
1996-11-25 10:07:59 +00:00
Zoltan Somogyi
584e402c33 Another step towards implementing notes/ALLOCATION.
Estimated hours taken: 6

Another step towards implementing notes/ALLOCATION.

hlds_goal:
	Define a new type that gives the information associated with
	resumption points. Add a field of this type to goal_info, and the
	associated operations.

	Change the layout of the access predicates to make the code_info
	structure easier to modify in the future.

liveness:
	Fill in the resume_point fields of goals that establish
	resumption points.

hlds_out:
	Print the new resume_point field of goal_info.

	Allow the printing of base_type_infos on the right hand sides
	of unifications.

code_info:
	Reuse the stack of store maps field, which we don't use anymore,
	to store the stack of resumption-point variable sets. Add operations
	on this new stack.

	Remove the slot that holds the code model of the current procedure,
	since it is used rarely and can be easily looked up in the proc_info,
	which we also store. Reuse the slot to store the maximum number of
	stack pushes, eliminating the pair used to store it previously.

	Change the layout of the access predicates to make the code_info
	structure easier to modify in the future.

code_gen:
	Don't pass the code model to code_info__init.

code_exprn:
	Make an abort message more specific.

hlds_pred:
	Fix typos.
1996-11-25 00:27:43 +00:00
Zoltan Somogyi
ee24e66a71 Switch from using a stack of store_maps in the code_info to govern what
Estimated hours taken: 2.5

Switch from using a stack of store_maps in the code_info to govern what
goes where at the end of each branched structure to using the store map
fields of the goal expressions of those structures.

Fix variable names where they resembled the wrong kind of map(var, lval).

code_info:
	Remove the operations on stacks of store maps.
	Modify the generate_forced_saves and remake_with_store_map operations
	to take a store_map parameter.

	When making variables magically live, pick random unused variables
	to hold them, since we can no longer use the guidance of the top
	store map stack entry. This may lead to the generation of some
	excess move instructions at non-reachable points in the code;
	this will be fixed later.

code_gen:
	Remove the store map push and pop invocations.
	Modify the generate_forced_goal operation to take a store_map parameter.

code_exprn:
	Export a predicate for use by code_info.

middle_rec, disj_gen, ite_gen, switch_gen,
dense_switch, lookup_switch, string_switch, tag_switch:
	Pass the store map around to get it to invocations of the primitives
	in code_gen and code_info that now need it.

goal_util:
	Name apart the new follow_vars field in hlds__goal_infos.
	(This should have been in the change that introduced that field.)

common, constraint, cse_detection, det_analysis, dnf, excess, follow_code,
intermod, lambda, lco, liveness, make_hlds, mode_util, modes, polymorphism,
quantification, simplify, switch_detection, typecheck, unique_modes,
unused_args:
	Fix variable names.

follow_vars, store_alloc:
	Add comments.
1996-11-23 10:39:02 +00:00
Zoltan Somogyi
f8da25795a Documented the distinction between the three kinds of uses we have
Estimated hours taken: 3

hlds_goal:
	Documented the distinction between the three kinds of uses we have
	for map(var, lval): stack_slots, store_map and follow_vars.
	Added a new field, follow_vars, to hlds__goal_info.

follow_vars:
	Attach the follow_vars information to the kinds of goals listed
	in notes/ALLOCATION.

hlds_out:
	Print out the follow_vars field. Make some other outputs easier to
	read.

hlds_pred:
	Remove the follow_vars field of the proc_info, since the follow_vars
	of the goal_info of the goal of the procedure has taken its place.

code_gen:
	Use the follow_vars field from the main goal's goal_info, rather
	than the follow_vars field of the proc_info.

store_alloc:
	Attach the last follow_vars not to the proc_info but to the main goal.
1996-11-23 06:01:49 +00:00
Zoltan Somogyi
92bd26cdc8 The first step towards the implementation of the new ALLOCATION strategy:
Estimated hours taken: 0.75

The first step towards the implementation of the new ALLOCATION strategy:
renamed call_info to stack_slots.

There are no algorithmic changes in this checkin.
1996-11-21 09:25:34 +00:00
Andrew Bromage
06e05928e1 Makes instmap and instmap_delta into ADTs.
Estimated hours taken: 38

Makes instmap and instmap_delta into ADTs.

compiler/code_gen.m:
compiler/code_info.m:
compiler/cse_detection.m:
compiler/det_analysis.m:
compiler/dnf.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/lookup_switch.m:
compiler/mode_debug.m:
compiler/mode_info.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/store_alloc.m:
compiler/switch_detection.m:
compiler/transform.m:
compiler/uniq_modes.m:
compiler/unused_args.m:
	Miscellaneous minor changes to use the new instmap.m

compiler/constraint.m:
	Removed unnecessary duplication of code in constraint__checkpoint/4
	and constraint__no_output_vars/2.

compiler/det_util.m:
	Changed no_output_vars/4 to det_no_output_vars/4, moved body
	of code to instmap.m.

compiler/instmap.m:
	Added abstract types instmap/0, instmap_delta/0.

	Added predicates:
		instmap__init_reachable/1, instmap__init_unreachable/1,
		instmap_delta_init_reachable/1,
		instmap_delta_init_unreachable/1, instmap__is_reachable/1,
		instmap__is_unreachable/1, instmap_delta_is_reachable/1,
		instmap_delta_is_unreachable/1, instmap__from_assoc_list/2,
		instmap_delta_from_assoc_list/2, instmap__vars/2,
		instmap__vars_list/2, instmap_delta_changed_vars/2,
		instmap_delta_lookup_var/3, instmap__set/3,
		instmap_delta_insert/4, instmap_delta_apply_instmap_delta/3,
		instmap_delta_restrict/3, instmap_delta_delete_vars/3,
		instmap__no_output_vars/4, instmap_delta_apply_sub/4,
		instmap__to_assoc_list/2, instmap_delta_to_assoc_list/2.

	Renamed predicates:
		instmap__lookup_var/3 (was instmap_lookup_var/3)
		instmap__lookup_vars/3 (was instmap_lookup_vars/3)
		instmap__apply_instmap_delta/3 (was apply_instmap_delta/3)
		instmap__merge/5 (was instmap_merge/5)
		instmap__restrict/3 (was instmap_restrict/3)

	Moved predicates:
		merge_instmap_delta/5 (from mode_util.m)

	Removed predicates:
		instmapping_lookup_var/3

compiler/mode_util.m:
	Moved merge_instmap_delta/5 to instmap.m
1996-11-19 01:18:24 +00:00
Zoltan Somogyi
0632ae69dd Fix a long-standing bug that caused all fixpoint iterations to stop
Estimated hours taken: 8

livemap:
	Fix a long-standing bug that caused all fixpoint iterations to stop
	too early. By causing value_numbering to miscompile the predicate
	mercury_compile__maybe_unused_args, this bug caused the unwanted
	printing of statistics for tests/warnings/unused_args_test.

	Fix also another bug: we did not process the control rval in
	computed gotos. To my knowledge this has never been tickled.

	Redesign the interface of the exported predicate slightly to
	make it more robust.

frameopt, value_number:
	Use the modified interface of livemap.

switch_detection:
	For a while now we have removed arms from switches if we knew from
	the instantiation of the control variable that those arms could not be
	executed. Sometimes this results in switches with no arms. If the
	control variable of the switch is never used after the switch,
	liveness won't see the occurrence in the switch construct as a use,
	and will kill the variable too early, cause the code generator to
	abort.

	We now turn switches with no arms into "fail"; this improves the
	code generated and avoids the bug. However, liveness should still
	be changed to consider the occurrence of a variable in the first
	arg of a switch a use.

code_gen, vn_block:
	Formatting changes.
1996-11-16 03:07:50 +00:00
Zoltan Somogyi
5d64b759db The main changes are
Estimated hours taken: 12

The main changes are

1	associating a name with the arguments of constructors

2	removing the follow_vars field from calls, higher-order calls
	and complicated unifications, since they are not used

3	merging the follow_vars and store_alloc passes, since they logically
	belong together

4	add a new module, lco, for detecting opportunities for last
	call optimization modulo constructor application; it won't
	actually apply the optimization until the mode system becomes
	expressive enough to handle it (this module detects 529 opportunities
	in the compiler and library)

5	make "-O3 --optimize-value-number" do the right thing; previously,
	it used not to apply value numbering because the vnrepeat option
	defaulted to zero

6	don't refer to .err2 files anymore; use .err instead.

prog_data:
	The list associated with each value of type "constructor" now
	contains not only the types of the arguments but their names as well.

equiv_type, hlds_data, hlds_out, make_hlds, mercury_to_{goedel,mercury},
mode_util, module_qual, shapes, type_util, unify_proc:
	Modify the traversal of type definitions to account for the names
	in the lists inside values of type "constructor".

prog_io:
	Parse argument names. An unrelated change is that we now
	check whether :- pred declarations give modes to some of their
	arguments but not to all, in which case we return an error.

hlds_goal:
	Remove the follow_vars field from calls, higher-order calls
	and complicated unifications.

*.m:
	Handle the new arities of calls, higher order calls and complicated
	unifications.

mercury_compile:
	Don't call follow_vars directly anymore, but do call lco if its option
	is set. Also flush the main output before a call to maybe_report_stats
	to prevent ugly output.

store_alloc:
	Call follow_vars directly.

follow_vars:
	Expose the initialization and traversal predicates for store_alloc.

lco:
	Find opportunities for last call optimization modulo constructor
	application.

passes_aux:
	Add a HLDS traversal type for lco.

optimize:
	Consider the vnrepeat count to be zero unless value numbering is on.

options:
	Set the default value of vnrepeat to 1.

modules:
	Don't refer to .err2 files.
1996-11-04 06:26:51 +00:00
Fergus Henderson
5fe0f4f82c A bunch of changes required to fix problems in code generation for
Estimated hours taken: 24

A bunch of changes required to fix problems in code generation for
model_det and model_semi disjunctions.

simplify.m:
	Don't convert all model_det and model_semi disjunctions into
	if-then-elses, because that doesn't work if the disjuncts
	have output variables, which can happen (e.g. with cc_nondet
	disjunctions)

disj_gen.m:
	Fix a bug in the code generation for semidet disjunctions:
	don't forget to jump to the end of the disjunction after
	each disjunct!

liveness.m, live_vars.m, store_alloc.m, disj_gen.m:
	Treat backtracking in model_det and model_semi disjunctions
	as shallow backtracking rather than deep backtracking.
	This means that rather than pushing all live variables
	onto the stack at the start of a model_det/semi disjunction,
	and using the nondet_lives to keep track of them, we instead
	treat these disjunctions a bit more like an if-then-else and
	use the ordinary liveness/deadness to keep track of them.

code_aux.m:
	Change code_aux__pre_goal_update so that it only applies
	the post-deaths if the goal is atomic.  Applying the
	*post*-deaths to the set of live variables in the *pre*-goal
	update only makes sense for atomic goals.
	(I think previously we only ever generated post-deaths
	for atomic goals, but now we generate them also for
	goals inside model_det or model_semi disjunctions.)

code_gen.pp, middle_rec.m:
	Pass an is-atomic flag to code_aux__pre_goal_update.

hlds_goal.m:
	Add some comments.

goal_util.m:
	Fix bugs in goal_util__name_apart_goalinfo.
	It wasn't applying the substitution to all the
	appropriate fields.

code_exprn.m:
	Improve the error message for one of the internal errors.

hlds_out.m:
	Print the stack slot allocations in the HLDS dump again.
1996-10-29 20:10:17 +00:00
Zoltan Somogyi
9d14c35534 Since NU-Prolog hasn't been capable of executing the compiler for a long time
Estimated hours taken: 1

Since NU-Prolog hasn't been capable of executing the compiler for a long time
now, I have removed the .pp files and replaced them with .m files.

code_gen, mercury_compile, optimize:
	Remove NU-Prolog specific code.

Mmake:
	Don't refer to the .pp files.

dnf:
	Add the capability of transforming all procedures regardless of
	markers. This will be useful when generating idiomatic Prolog code.

mercury_to_goedel, polymorphism:
	Fix comments.
1996-10-28 02:08:24 +00:00