Commit Graph

31 Commits

Author SHA1 Message Date
Zoltan Somogyi
99e729814f Make sure we don't change the goal being analyzed except possibly
Estimated hours taken: 20

det_analysis:
	Make sure we don't change the goal being analyzed except possibly
	for the introduction of `some's (which should not hurt anything).

	Make sure we don't print any error messages except in the final
	iteration, when all the inputs to the inference are stable.

	If the --debug-detism options is set, print messages about the
	progress of inference and checking.

	Also moved some code around.

det_report:
	Distinguish the handling of warning messages and error messages.

simplify:
	Use the new ability of det_report to separate warnings and errors.

passes_aux:
	Add a new generic pass form, for use by simplify.

option:
	Add --debug-detism (as above), --aditi, which at the moment
	only enables the disjunctive normal form transformation, and
	--inlining/--no-inlining, which set the other three flags
	involved in inlining depending on whether you want standard
	inlining or none at all.

	Follow_code used to be set twice and follow_vars not at all;
	I fixed this.

	Reenabled optimize_higher_order at -O3.

	Moved value numbering to -O4 and pred_value_number to -O5.
	This makes it easier to separate value numbering from the
	other optimizations (which are likely to be more effective).

	Divided options_help into sections to avoid excessive
	compilation times.

store_alloc:
	Base the store map on the follow_vars info attached to the
	branched structure which I added recently, and not on the
	follow_vars map being passed around, since it will be more accurate.

hlds_out:
	Print information about follow_vars and store_maps when -D is given.

follow_code:
	Undo an old hack that change to follow_vars has made counterproductive.

middle_rec:
	Fix a bug uncovered by the change to follow_code. When looking for a
	register to hold the counter, it is not enough to avoid picking a
	register that appears in the recursive case; we must also avoid
	registers that occur only in the base case.

livemap:
	Mentioning the code address succip now causes the succip to be
	considered live. This may or may not fix the bug with pred_value_number
	miscompiling unused_args.m; the other changes have caused the input
	to value numbering to change, and they no longer trigger the problem.
	(Will try to test this later.)

mercury_compile:
	Try to make sure that we print statistics only after passes that
	were actually executed. Also, reduce the number of lookups of the
	verbose option. Move some predicates so that the order of their
	appearance matches the current order of invocation.

vn_table:
	Loosen a sanity check to let xnuc2 pass through it.

code_exprn, switch_detection:
	Minor changes.
1996-05-10 09:49:17 +00:00
Fergus Henderson
a3b0d22d9f When generating semidet pragma c_codes, make sure to shuffle r1
Estimated hours taken: 6

compiler/{code_gen.pp,code_info.m,code_exprn.m}:
	When generating semidet pragma c_codes, make sure to shuffle r1
	out of the way in case its value is needed after the pragma.
1996-04-30 00:05:51 +00:00
Zoltan Somogyi
477aa2a463 Improve a panic message.
Estimated hours taken: 0.1

code_exprn:
	Improve a panic message.
1996-04-19 11:12:41 +00:00
Fergus Henderson
974d3b9247 Do some more work on improving floating-point performance:
Estimated hours taken: 2

Do some more work on improving floating-point performance:
emit boxed floating point constants as static ground terms.

options.m:
	Add new option --unboxed-float.

exprn_aux.m
	Add --unboxed-float to the `exprn_opts' that affect whether
	or not things can be static constants.  If --unboxed-float
	is not set, and --static-ground-terms is, then consider
	float_consts to be constant.

code_exprn.m, lookup_switch.m:
	Trivial changes to handle new arity of exprn_opts type.

llds.m:
	If --unboxed-float is not set, and --static-ground-terms is, then
	output `static const Float mercury_float_const_...' declarations
	for float_consts.
1996-04-07 07:41:52 +00:00
Zoltan Somogyi
587bf30a5d Avoid creating unecessary shuffling operations.
Estimated hours taken: 1

code_exprn:
	Avoid creating unecessary shuffling operations. Specifically,
	if a register (say r1) is live, and if you want to put a value
	into it, we used to generate a sequence such as:

		r2 = r1;
		r1 = <some rval>;

	Very often the original value of r1 is needed *only* in <some rval>.
	We now generate this bad code as before, but then check whether
	there are any live variables whose values *require* r2 (as opposed
	to having one of their several copies accessible via r2). If not,
	we remove the register copy.

	Most of the work is done by the auxiliary predicates introduced
	in the previous checkin.

	This change reduces the size of the compiler by 65 Kb, almost 3%.
	This is with standard optimization. Since this optimization removes
	code that is also removed by value numbering, any gain in the
	size of fully optimized code will be minimal.
1996-04-05 10:06:05 +00:00
Zoltan Somogyi
c8da041006 Made a start towards getting better code generated for nested creates
Estimated hours taken: 4

code_exprn:
	Made a start towards getting better code generated for nested creates
	and towards getting rid of useless "shuffle lval" instructions.
	Also, some minor cleanup.

exprn_aux:
	Add some auxiliary predicates for the new code_exprn.

delay_info:
	Remove a useless import of hlds, which is now empty.
1996-04-05 08:27:21 +00:00
Zoltan Somogyi
ea15e53e11 Add a couple of auxiliary predicates and use them.
Estimated hours taken: 0.5

code_exprn:
	Add a couple of auxiliary predicates and use them.
1996-04-04 00:06:15 +00:00
Zoltan Somogyi
5724b9bc64 Factor out some more common cases.
Estimated hours taken: 1

code_exprn:
	Factor out some more common cases.

livemap:
	Fix a misleading error message.
1996-04-03 14:18:47 +00:00
Zoltan Somogyi
27b615a71e Factor out some common code, moving it into a predicate.
Estimated hours taken: 0.5

code_exprn:
	Factor out some common code, moving it into a predicate.
1996-04-03 06:48:00 +00:00
Zoltan Somogyi
4808a8dfff A step towards better handling of cell creations.
Estimated hours taken: 0.2

code_exprn:
	A step towards better handling of cell creations.
1996-04-03 00:34:04 +00:00
Zoltan Somogyi
6be6177df5 Distribute the initial comments among the declarations of the exported
Estimated hours taken: 1.5

code_exprn:
	Distribute the initial comments among the declarations of the exported
	predicates. This makes it much less likely that the declarations will
	be modified without changes in the comments. Since this has happened
	in the past, some predicates are now without comments.

	Changed code_exprn__place_var to prefer to get even a constant term
	from a location if it has been produced before, and factor out some
	code that is shared between the handling of cached and evaled
	expressions.

code_exprm, code_info:
	Removed an unnecessary argument from code_exprn__get_varlocs.

dead_proc_elim:
	Changed the predicate name prefix from dead__ to dead_proc_elim__
	to conform to notes/CODING_STANDARDS.

handle_options:
	Remove an inappropriate comment.

jumpopt:
	Filter out redundant livevals whether --optimize-fulljumps is given
	or not. (I thought they aren't created if the option isn't given,
	but they are.)

options:
	Change the meaning of -O from --c-optimize to --opt-level.
	Disabled unused args until the bug is fixed.
1996-03-17 04:21:38 +00:00
Zoltan Somogyi
c70dbe9e2b When we are processing the flushing of create expressions, make sure
Estimated hours taken: 2

code_exprn:
	When we are processing the flushing of create expressions, make sure
	the Lval we are creating into isn't a field reference. This avoids
	deep field of field of field of ... nesting. It does introduce
	references to high register numbers, but this is a lesser evil,
	and Tom and I plan to fix this anyway.

arg_info, globals, options:
	Change --args old to --args simple.

options:
	Make some help messages more specific.

code_aux, code_exprn, code_info, det_report, make_hlds, mercury_to_goedel,
prog_io, typecheck:
	Changes to accommodate the move from varset__lookup_name
	to varset__search_name.
1996-03-12 03:39:13 +00:00
Zoltan Somogyi
b4f71d7b53 Both code_exprn and lookup_switch had code to check whether an
Estimated hours taken: 2

exprn_aux:
	Both code_exprn and lookup_switch had code to check whether an
	expression is constant or not. Some of the code is different
	due to different handling of variables in rvals, but exprn_aux
	now contains the common subset.

	This common subset used to treat some address constants incorrectly,
	simply by not considering them; they are now considered and treated
	properly.

code_exprn, lookup_switch, exprn_aux:
	Remove redundant option lookups in the process of checking for
	constant expressions.

code_exprn:
	Other minor cleanups, including removal of a block of code Tom
	says was "deep magic" (but which turns out to be unnecessary).

code_info:
	Removed some dead code.

options:
	Added real support for --opt-level, in the form of a table of
	default values of options for each optimization level between
	0 and 5 (both inclusive). This needs a new form of documentation.
	How do you do tables in texinfo?
1996-03-11 10:32:20 +00:00
Zoltan Somogyi
e7054745f2 Wrap parentheses around pred insts, since they are needed.
Estimated hours taken: 6

mercury_to_mercury:
	Wrap parentheses around pred insts, since they are needed.

value_number, vn_verify:
	Value numbering now reapplies itself to both halves of a block if
	it cannot optimize the block as a whole.
	Split the verification code into its own module, and fix line lengths.

vn_order:
	Fix the computation of the label at which blocks should be divided.
	Fix line lengths.

vn_debug:
	Add a message to support the new block dividing capability.

code_exprn:
	Redirect option lookup operations from options to getopt.

passes_aux:
	Prepare for some further changes.

prog_io:
	Formatting changes.
1996-03-05 23:55:48 +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
Fergus Henderson
e2d7877b0f Improve error message for one of the internal errors.
code_exprn.m:
	Improve error message for one of the internal errors.

det_analysis.m:
	Make sure we don't generated unnecessary nested `some' goals.

prog_io.m, inst_match.m, mode_util.m, mercury_to_mercury.m:
	Add new insts `mostly_unique' and `mostly_clobbered', with
	semantics similar to `unique' and `clobbered', except that
	mostly-unique variables might be needed on backtracking.

unique_modes.m:
	A good start on the code to check that `unique' modes
	are not used for nondet live variables.  Still incomplete,
	but just about all the code is there except the code to
	actually compute the set of nondet live variables as you
	traverse the goal.
1996-01-01 13:19:22 +00:00
Zoltan Somogyi
3224e94532 A new pass to remove unnecessary assignment unifications.
excess:
	A new pass to remove unnecessary assignment unifications.

mercury_compile:
	Call the new excess assignment module.

options:
	Add a new option, excess_assign, to control the new optimization.
	Add another, num-real-regs, to specify how many of r1, r2 etc are
	actually real registers. The default is now set to 5 for kryten;
	later it should be supplied by the mc script, with a value determined
	at configuration time.

tag_switch:
	Use num-real-regs to figure out whether it is likely to be worthwhile
	to eliminate the common subexpression of taking the primary tag of
	a variable. Also fix an old performance bug: the test for when a
	jump table is worthwhile was reversed.

value_number, vn_block:
	Do value numbering on extended basic blocks, not basic blocks.

vn_debug:
	Modify an information message.

labelopt:
	Clean up an export an internal predicate for value numbering. Replace
	bintree_set with set.

middle_rec:
	Prepare for the generalization of middle recursion optimization
	to include predicates with an if-then-else structure.

cse_detection:
	Fix a bug: when hoisting a common desconstruction X = f(Yi), create
	new variables for the Yi. This avoids problems with any of the Yis
	appearing in other branches of the code.

goal_util:
	Add a new predicate for use by cse_detection.

common:
	Fix a bug: recompute instmap deltas, since they may be affected by the
	optimization of common structures.

code_info:
	Make an error message more explicit.

det_analysis:
	Restrict import list to the needed modules.

*.m:
	Import assoc_list.
1995-10-27 09:39:28 +00:00
Fergus Henderson
432eee8f1f Fix singleton variable warnings by deleting useless code.
code_exprn.m, modes.m:
	Fix singleton variable warnings by deleting useless code.

shapes.m, typecheck.m:
	Fix singleton variable warnings by renaming variables so that they
	start with an underscore.

make_hlds.m:
	Pass the context down into transform_goal_2, unravel_unification,
	insert_arg_unifications, and append_arg_unifications, so that
	the goal_info_context in the newly built HLDS is never empty.
	This is needed because the new warn_singletons uses the context,
	so it has to be valid.

unify_proc.m:
	Pass a term__context to unravel_unification (as required by
	above change).

quantification.m:
	Rearrange some comments that got shifted a dozen
	lines from the code they referred to.

vn_util.m:
	Fix omission in Zoltan's changes with `succip(FramePointer)'
	which caused "Software Error: unexpected lval in vn_...".
1995-09-06 17:29:28 +00:00
Fergus Henderson
ce9a5cf7d5 Optimize away unifications with dead variables.
modes.m:
	Optimize away unifications with dead variables.
	(The code generator already does that, but by
	that time we have already allocated unnecessary
	stack slots for them.)

code_exprn.m:
	Avoid generating sequences such as `r2 = r3; r3 = r2;'
	when a register already contains the correct value.
	(This change was in fact at least as much Tom's work as mine.)

store_alloc.m:
	For disjunctions, we only want to allocate registers
	for the variables that are output by the disjunction.
	The inputs should go in framevars, not in registers.
	This avoids much of the register-shuffling
	in the code generated for e.g. list__member(out, in).
	(This change was in fact at least as much Tom's work as mine.)
1995-09-06 11:42:11 +00:00
Zoltan Somogyi
bebe96be34 Look inside blocks introduced by value numbering when looking
frameopt:
	Look inside blocks introduced by value numbering when looking
	restorations of succip.

value_number, opt_util:
	If we are using conservative garbage collection, disable value
	numbering for blocks that allocate more than one cell on the heap.
	This allows value numbering of most blocks to work in the absence
	of -DALL_INTERIOR_POINTERS.

all other source files:
	Clean up "blank" lines that nevertheless contain space or tab
	characters.
1995-08-27 11:10:20 +00:00
Fergus Henderson
62d57a5ab5 Fix bug reported by Dylan: float constants are boxed and thus
code_exprn.m:
	Fix bug reported by Dylan: float constants are boxed and thus
	cannot be considered constant.
1995-07-17 02:46:41 +00:00
Thomas Conway
1b9ff54448 Double bug fix. Static ground terms were not being correctly
code_exprn.m:
	Double bug fix. Static ground terms were not being correctly
	handled. Neither were partially instantiated terms. Both are
	now handled correctly (famous last words, no doubt).

det_analysis.m:
	I thought I'd committed this change at *least* once before
	(though I havn;t checked the revision history). I fixed the
	code generator bug that was causing a commented out section
	to fail. So I've uncommented out that section.
1995-07-14 00:56:26 +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
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
Thomas Conway
57e3bc01db Fix a bug that was causing the code generator to loose
code_exprn.m:
	Fix a bug that was causing the code generator to loose
	track of how many references there are to a register.
	The bug was what caused incorrect results for one of
	Bart's programs.
1995-04-30 10:12:37 +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
Thomas Conway
215b965214 The interface of set changed slightly.
code_exprn.m, common.m graph_colour.m, quantification.m:
	The interface of set changed slightly.
1995-03-24 09:21:12 +00:00
Thomas Conway
1fd52bc3a5 Fix an overly conservative sanity check.
code_exprn.m
code_info.m:
	Fix an overly conservative sanity check.

mercury_compile.pp
typecheck.m:
	Fix type errors due to the changed implementation of map.
	Possibly these bits of code should be removed or something
	so that map is properly abstract.
1995-03-22 11:40:54 +00:00
Thomas Conway
a0140a10e9 Thread options down into the new part of the code generator
code_exprn.m:
code_info.m:
	Thread options down into the new part of the code generator
	so that it does the right thing with constant expressions.
1995-03-18 09:41:06 +00:00
Thomas Conway
56185418db a new module for manipulating rvals and lvals.
exprn_aux.nl:
	a new module for manipulating rvals and lvals.

code_exprn.nl:
	the new bottom level of the new code generator. This replaces
	a large chunk of code_info.

*code* & *gen*:
	various small changes to use the new bottom level of the
	code generator.
1995-03-15 08:07:56 +00:00