Commit Graph

902 Commits

Author SHA1 Message Date
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
Andrew Bromage
a26cb0ee21 Transform module. 1995-07-04 01:32:25 +00:00
Andrew Bromage
7b615f8c02 Constaint propagation. WARNING: Does not work yet. 1995-07-04 01:31:14 +00:00
Tyson Dowd
39d10b85bb Changes output format so NU-Prologs builtin parser doesn't
garbage_out.m, shapes.m:
	Changes output format so NU-Prologs builtin parser doesn't
	barf at it. (Mercury's parser is much better ;-)
1995-07-03 08:17:52 +00:00
Thomas Conway
a7b72b2b67 Change some comments in the generated code slightly.
code_info.m:
	Change some comments in the generated code slightly.

ite_gen.m:
	grab the instmap before generating the condition not
	after in all three kinds of ite.

unify_gen.m:
	grab and slap the code_info structure across the call
	to generate_failure. This pair of calls should probably
	be migrated into generate_failure. I'll check this out
	soon (tomorrow).
1995-07-03 08:06:53 +00:00
Fergus Henderson
c9f8b324d0 Mangle quoted Mercury predicate names properly,
llds.m:
	Mangle quoted Mercury predicate names properly,
	so that we don't get syntax errors from the C compiler.
1995-07-02 09:42:55 +00:00
Tyson Dowd
86ffff6687 Output exports in the .garb files.
garbage_out.m:
	Output exports in the .garb files.
1995-06-30 07:32:43 +00:00
Tyson Dowd
6335eb6a78 Output .garb files (with --gc accurate). This option overrides
call_gen.m code_gen.pp code_info.m garbage_out.m hlds.m llds.m
mercury_compile.pp shapes.m:
	Output .garb files (with --gc accurate). This option overrides
	information gleaned from the grades about GC.
	Remove some of the magic numbers that were being used for
	shape numbers.
1995-06-29 05:31:15 +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
Steven Siew
f5aa3c8281 Add new files which implement the debugger.
debug_util.m, debugger.m:
	Add new files which implement the debugger.

everything else:
	Merge in changes between when the `debugger' branch was created
	and now (Mon Jun 26 07:44:55 GMT 1995).
1995-06-26 07:50:02 +00:00
Peter Ross
d4dfcab0f9 Propogate PROFFLAGS through out the compiler.
Mmake:
	Propogate PROFFLAGS through out the compiler.
1995-06-26 05:57:18 +00:00
Fergus Henderson
0713ab1575 Change the type of the first two arguments of unify/5 in
hlds.m and lots of other files:
	Change the type of the first two arguments of unify/5 in
	hlds__goal_expr from `term, term' to `var, unify_rhs'
	where unify_rhs is given by

		:- type unify_rhs
			--->	var(var)
			;	functor(const, list(var))
			;	lambda_goal(list(var), hlds__goal).

	This change was for two reasons: firstly, it simplifies the
	code in a lot of places, and secondly, it is a step towards
	implementing lambda closures and higher-order predicates
	properly.
1995-06-25 13:47:14 +00:00
Fergus Henderson
c8ae15ffd8 Commit a work-around for a code generation bug -
det_analysis.m:
	Commit a work-around for a code generation bug -
	the compiler generated incorrect code for my change
	to det_analysis.m.
1995-06-25 08:13:12 +00:00
Zoltan Somogyi
159e986015 Add a new option, --optimize-fulljumps, which defaults on.
options, optimize:
	Add a new option, --optimize-fulljumps, which defaults on.

jumpopt, opt_util:
	If --optimize-fulljumps is set, replace unconditional gotos with
	the instruction sequence they point to. This not only avoids a jump
	at runtime, but also increases basic block length and makes value
	numbering more effective.

peephole:
	Fulljump optimization can replace a recursive tailcall with the
	initial part of the code of the procedure. Therefore peephole now
	looks for a decr_sp followed by an incr_sp, and removes such pairs
	from the instruction sequence.

frameopt:
	Do not consider a decr_sp followed by an incr_sp to be a fatal error
	(just in case peephole is switched off).

vn_block:
	Fix a big tickled by fulljump optimization: maxfr, curfr and succip
	were not required to be made up to date before an if_val exited
	the extended basic block.

vn_util:
	Simplify some more patterns of vnrvals. The extra patterns are
	involved in testing conditions that are known to be true or false.
	These patterns can arise when fulljump optimization replaces a
	recursive tailcall.
1995-06-24 15:53:28 +00:00
Fergus Henderson
f0d77e44ba Don't report a compile error if there is a higher-order pred
modes.m, typecheck.m, code_util.m:
	Don't report a compile error if there is a higher-order pred
	unification in a compiler-generated predicate.  (Instead, delay
	the error until run-time so that it only occurs if the higher-order
	pred unification in question actually gets executed.)
1995-06-24 14:12:44 +00:00
Fergus Henderson
36820eda8d Report an error if main/2 can fail.
det_analysis.m:
	Report an error if main/2 can fail.
1995-06-24 14:09:02 +00:00
Zoltan Somogyi
ca82e7dd11 Check for loops in sequences of jumps to jumps.
jumpopt:
	Check for loops in sequences of jumps to jumps. Don't loop forever
	at compile time; instead, emit code that loops forever.
1995-06-24 06:26:50 +00:00
Fergus Henderson
888208937f Fix bug in code generation for nondet if-then-else with nondet
ite_gen.m:
	Fix bug in code generation for nondet if-then-else with nondet
	condition - the save of the hijack frame maxfr was occurring
	before the hijack frame was created.
1995-06-23 11:06: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
3c7380f7b5 Fix two bugs. One was very subtle, due to the fact that
mode_util.m:
	Fix two bugs.  One was very subtle, due to the fact that
	after my recent bug fix to merge_instmap, the assumption that

		merge_instmap(empty_instmap, X) == X

	is no longer true.  The other was an obvious stupid cut-and-paste
	bug - the recursive call in `recompute_instmap_delta_disj'
	called `recompute_instmap_delta_CONJ'.
1995-06-22 14:50:43 +00:00
Fergus Henderson
e14ae58348 Use ../library/library.init and ../runtime/runtime.init to produce
compiler/Mmake:
	Use ../library/library.init and ../runtime/runtime.init to produce
	mercury_compile_init.c, rather than using ../library/*.c etc.
1995-06-22 13:25:49 +00:00
Fergus Henderson
5586254926 Fix "typechecker internal error: no type assignment" error
typecheck.m:
	Fix "typechecker internal error: no type assignment" error
	reported by Philip Dart.
1995-06-22 12:08:41 +00:00
Zoltan Somogyi
55ea9649ed Removed the obsolete target to make all the .mod files.
Mmake:
	Removed the obsolete target to make all the .mod files.
1995-06-22 02:38:22 +00:00
Zoltan Somogyi
7a3e35af3b Sort the list of interface files before printing them to a .d file.
mercury_compile:
	Sort the list of interface files before printing them to a .d file.

opt_util, peephole:
	Fix a bug tickled by value numbering. Some sequences of code were
	recognized as having no access to nondet stack control slots even
	in the presence of such accesses, which lead to the incorrect
	introduction of succeed_discards.

value_number:
	Loosen the value correspondence sanity check, which was failing
	needlessly, and tighten the tag sanity check, which was passing
	incorrect code.

	Do not try value numbering on blocks containing structures such as
	"if (tag(x) == X && field(X, x, X) == X) goto X", since these will
	definitely lead to tag sanity check violations.

vn_flush:
	If a shared node has no uses left when flushed, leave it be.
	When generating a mkframe, reflect its update of the top redoip slot
	in the data structures.

vn_order:
	Some hacks to get the relmaps partway to where I want them. This
	code needs cleaning up.

vn_debug:
	New debugging routines to support my changes to vn_order.

vn_type:
	Deleted the vn_modframe vn_instr, since its role has been taken over
	by assignments to redoip(maxfr).

opt_debug:
	Reflect the change to vn_type, print address constants in vn_rvals,
	and fix a typo.

vn_block, vn_util:
	Reflect the change to vn_type.
1995-06-22 01:44:11 +00:00
Fergus Henderson
fc8ad2af1a Fix a bug in merge_instmap_delta.
mode_util.m:
	Fix a bug in merge_instmap_delta.
1995-06-21 07:42:54 +00:00
Fergus Henderson
0fb0269398 Fix another bug in det__disj_to_ite - the internal/external
det_analysis.m:
	Fix another bug in det__disj_to_ite - the internal/external
	determinism of the if-then-else were being recalculated, and then
	clobbered with the original internal/external determinism of the
	disjunction.
1995-06-21 07:42:25 +00:00
Fergus Henderson
20eb772e23 If the context field in the goal_info is not present, set it to
typecheck.m:
	If the context field in the goal_info is not present, set it to
	the enclosing context.
1995-06-20 14:49:32 +00:00
Fergus Henderson
bba2e77b65 Fix bug in instmap delta annotations introduced by det__disj_to_ite.
det_analysis.m:
	Fix bug in instmap delta annotations introduced by det__disj_to_ite.
	(This fix has not been tested.)
1995-06-20 12:06:50 +00:00
Fergus Henderson
f9480a69de Update the TODO list. 1995-06-20 11:33:28 +00:00
Fergus Henderson
8e33e43220 Don't do mode analysis if there were any type errors.
mercury_compile.pp:
	Don't do mode analysis if there were any type errors.
	We get too many spurious mode errors.
1995-06-20 11:32:35 +00:00
Fergus Henderson
9c3ca40598 Remove the need for synchronizing the type var sets between different
typecheck.m:
	Remove the need for synchronizing the type var sets between different
	type assignments in a type assignment set, by keeping track of
	a list of argument types to match against for each type assignment
	in the set.  This allowed me to reintroduce my earlier changes
	to improve the error messages.  I also improved the error messages
	for variables with overloaded types.

	Also fix bug introduce by Zoltan's changes: only display the progress
	message once, not twice ;-)
1995-06-20 11:29:04 +00:00
Fergus Henderson
a24bcac9cf Change the output to the .dep' file so that foo_init.c' does
mercury_compile.pp:
	Change the output to the `.dep' file so that `foo_init.c' does
	not depend on anything and so that the arguments passed to $(C2INIT)
	are `foo.m bar.m' rather than `foo.c bar.c'.
	Note: this will only work with the new version of mkinit.
1995-06-20 07:12:50 +00:00
Zoltan Somogyi
5420418f24 Attempt to fill delay slots with the instruction after an if_val
frameopt, opt_util:
	Attempt to fill delay slots with the instruction after an if_val
	in preference to the saving of the succip.

optimize:
	Fix a typo in earlier change.

value_number:
	Check that the last node in the order is a control node.

vn_order:
	If two registers or stackvars can be generated in any order,
	prefer to generate them in numerical sequence for neatness.

vn_debug:
	Add routine for printing the initial and final ordering of
	unrelated nodes.
1995-06-17 12:21:40 +00:00
Zoltan Somogyi
15b8ea11d0 Put the comment about the contents of stack slots before the initial
code_gen.pp:
	Put the comment about the contents of stack slots before the initial
	label, since this way it will be preserved by optimizations.

cse_detection.m:
	Extended the search to look for cses in if-then-elses and switches
	as well as disjunctions. Removed InstmapDelta from preds in which it
	was not being used.

det_analysis.m:
	Make the diagnosis routines more robust. The changes here avoid the
	Philip's problems with lexical.m.

jumpopt.m:
	Minor formatting changes.

livemap.m:
	Avoid duplicating livevals instructions when optimizations are
	repeated, since this can confuse some optimizations.

llds.m:
	Minor documentation change.

make_hlds.m:
	Minor formatting change.

mercury_compile.pp:
	Do not map arguments to registers if any semantic errors have been
	found.

middle_rec.m and code_aux.m:
	Apply middle recursion only if tail recursion is not possible,
	since tail recursion yields more efficient code.

opt_util.m:
	Added a predicate to recognize constant conditions in if_vals.
	Modified a predicate to make it better suited for frameopt.

optimize.pp:
	Changed the way optimizations were repeated to allow better control.
	Repeat peephole once more after frameopt, since the new frameopt
	can benefit from this.

options.m:
	Removed the --compile-to-c option, which was obsolete. Added an
	option for predicate-wide value numbering, which is off by default.
	Changed some of the default values of optimization flags to reduce
	compilation time while holding the loss of speed of generated code
	to a minimum.

peephole.m:
	Look for if_vals whose conditions are constants, and eliminate the
	if_val or turn it into a goto depending on the value of the constant.
	Generalized the condition for optimizing incr_sp/decr_sp pairs.

value_number.m:
	Added a prepass to separate primary tag tests in if-then-elses from
	the test of the secondary tag, which requires dereferencing the
	pointer.

	Added sanity check routines to test two aspects of the generated code.
	First, whether it produces the same values for the live variables as
	the original code, and second, whether it has moved any dereferences
	of a pointer before a test of the tag of that pointer. If either test
	fails, we use the old instruction sequence.

vn_debug.m:
	New messages to announce the failure of the sanity checks. They are
	enabled by default, but of course can only appear if value numbering
	is turned on (it is still off by default).

vn_flush.m:
	Threaded a list of forbidden lvals (lvals that may not be assigned to)
	through the flushing routines. When saving the old value of an lval
	that is being assigned to, we use this list to avoid modifying any of
	the values used on the right hand side of the assignment, even if the
	saving of an old value results in assignment that requires another
	save, and so on recursively.

	When the flushing of a node_lval referred to a shared vn, the uses of
	the access vns of the node_lvals were not being adjusted properly.
	Now they are.

vn_order.m:
	The ctrl_vn phase of the ordering was designed to ensure that all
	nodes that need not come before a control node come after it. However,
	nodes were created after this phase operated, causing leakage of some
	value nodes in front of control nodes. Some of these led to pointer
	dereferences before tag tests, causing bus errors. The ctrl_vn phase
	is now last to avoid this problem.

vn_table.m:
	Added an extra interface predicate to support the sanity checks in
	value_number.

vn_util.m:
	The transformation of c1-e2 into (0-e2)+c1 during vnrval simplification
	could lead to an infinite loop in the compiler if c1 was zero. A test
	for this case now prevents the loop.
1995-06-17 06:08:09 +00:00
Zoltan Somogyi
5de21d69a8 Previously, if some code that did not have a frame set up had an
frameopt:
	Previously, if some code that did not have a frame set up had an
	if_val that branched to a label that required a frame, we inverted
	the test and made it branch around code that set up the frame and
	them branched to that label. This was undesirable, but I thought
	the situation would be rare. The new code generator new generates
	this kind of code more frequently (e.g. in tak), so I changed
	the algorithm for dealing with the situation. We now branch to
	a new label inserted immediately before the target label, with
	the frame setup code between those labels.
1995-06-16 01:01:03 +00:00
Fergus Henderson
3717372bca Back out my previous changes, since they introduced a bug
typecheck.m:
	Back out my previous changes, since they introduced a bug
	which I don't have time to fix right now.
1995-06-06 05:02:09 +00:00
Fergus Henderson
31fa6d1691 Update the TODO list, since some of the things have been done!
compiler/notes/TODO:
	Update the TODO list, since some of the things have been done!
1995-06-06 01:22:52 +00:00
Fergus Henderson
ea9c17ee54 Include the library .m files in the tags file.
compiler/Mmake:
	Include the library .m files in the tags file.

hlds.m and lots of other places:
	Change the type of the argument list of a HLDS `call' from
	`list(term)' to `list(var)'.
1995-06-06 01:22:10 +00:00
Fergus Henderson
247c5446d0 Modify call to implicitly_quantify_goal, since my recent
det_analysis.m:
	Modify call to implicitly_quantify_goal, since my recent
	change to quantification.m modified the interface slightly.
1995-06-06 00:58:33 +00:00
Fergus Henderson
dad0690f41 Use more meaningful predicate names.
typecheck.m:
	Use more meaningful predicate names.
1995-06-05 09:22:27 +00:00
Fergus Henderson
ab691a0382 More improvements in the error messages.
typecheck.m:
	More improvements in the error messages.
1995-06-05 09:08:29 +00:00
Fergus Henderson
d8661c5950 An improvement in one of the error messages.
typecheck.m:
	An improvement in one of the error messages.
1995-06-05 08:10:24 +00:00
Fergus Henderson
8358f40b91 If a variable is explicitly quantified, push the quantifiers
quantification.m:
	If a variable is explicitly quantified, push the quantifiers
	inwards as far as possible.  This avoids some spurious determinism
	errors that would otherwise result.
1995-06-05 04:41:42 +00:00
Andrew Bromage
39e948ed1f Adding the new Mercurians to the AUTHORS file. Oh, and fixing a
spelling mistake.
1995-06-01 10:38:17 +00:00
Zoltan Somogyi
261b42c9b9 Allow mkframes in the bodies of procedures being optimized, since this
frameopt:
	Allow mkframes in the bodies of procedures being optimized, since this
	is needed by the new version of the code generator.
1995-06-01 01:26:19 +00:00
Fergus Henderson
8e3d2ebb8d Bump up the version number.
mercury_compile.pp:
	Bump up the version number.
1995-05-30 17:45:43 +00:00
Fergus Henderson
1ef9d346b2 Update a few more files.
compiler/notes/*:
	Update a few more files.
	Remove some files which were duplicates of the information
	in the manuals, to avoid double maintenance problem.
1995-05-30 12:49:45 +00:00
Fergus Henderson
134d3272c2 Update the BUGS list. 1995-05-30 09:28:30 +00:00
Fergus Henderson
e55098066c Update the TODO list.
compiler/notes/TODO:
	Update the TODO list.
1995-05-30 09:26:05 +00:00
Fergus Henderson
ea3166a159 When computing the cons_id for a construction/deconstruction
modes.m:
	When computing the cons_id for a construction/deconstruction
	unification, check whether the cons_id is already present
	in info for that unification, and if so use the existing cons_id.
	This is necessary to make --common-goal work, since cse_detection
	invokes mode analysis after polymorphism, and polymorphism
	introduces code_address cons_ids which we must not throw away.
1995-05-29 14:35:54 +00:00