Commit Graph

13 Commits

Author SHA1 Message Date
Zoltan Somogyi
1c90f19e02 Fix a typo which reflected a fundamental design error.
Estimated hours taken: 20

vn_block:
	Fix a typo which reflected a fundamental design error. When finding
	cheaper copies of live lvals, for use in creating specialized copies
	(parallels) of blocks jumped to from the current location, we used
	to use the map reflecting the contents of lvals at the start of the
	block, not at the point of the jump.

	--pred-value-number, which uses the information computed by the
	buggy predicate, actually bootstrapped some time ago despite
	this fundamental bug!

value_number:
	Fix a bug in the creation of parallel code sequences for computed
	gotos. Add some more opprtunities for printing diagnostics.
	Move code concerning final verification to vn_verify.

vn_verify:
	Move the remaining code concerned with final verification from
	value_number to vn_verify.

peephole:
	Add a new pattern, which transforms the sequence

	incr_sp N; goto L2; L1; incr_sp N; L2

	into just

	L1; incr_sp N; L2

	The pattern is of course more broadly applicable, but I have seen
	it only when it involves a single incr_sp between the two labels.
	(The longer pattern can be introduced by frameopt.)

opt_util:
	Look inside blocks when checking whether an instruction can fall
	through. This improves the performance of labelopt.

vn_table:
	Make the type vn_table abstract; add, export and use access functions.

vn_util:
	Remove a noop predicate, since now it won't ever be made to do
	anything.

vn_cost:
	Refine debugging output.

vn_debug:
	Add some more debugging routines.

opt_debug:
	Add some more debugging routines.

det_analysis:
	Remove an unused argument.

labelopt:
	Formatting change.
1996-04-11 01:02:48 +00:00
Zoltan Somogyi
bc2b8632b1 Add support for the compact argument passing convention.
Estimated hours taken: 6

arg_info:
	Add support for the compact argument passing convention. The proper
	handling of higher order calls etc is still missing.

globals:
	Added a third global type, args_method, current either "old" or
	"compact".

passes_aux:
	Moved some auxiliary predicates from mercury_compile and options
	to passes_aux.

constraint, det_analysis, make_hlds, modules, optimize, undef_types:
	Import and refer to passes_aux.

mercury_compile, handle_options:
	Remove the predicates moved to passes_aux. Also move the option
	postprocessing code to a new module, handle_options.

	Another change is that we stop after syntax errors if the new option
	--halt-at-syntax-errors is set.

handle_option:
	New module for option postprocessing.

options:
	Remove the option lookup predicates, which were obsolete.
	Add new options --args, --halt-at-syntax-errors and --opt-level.
	Add a special handler for --opt-level.

lookup_switch:
	Call getopt to look up options, not options.

value_number, vn_block:
	Extended basic blocks with more than one incr_hp pose a problem for
	value numbering when using boehm_gc, because value numbering coalesces
	all the allocations into one. Previously we did not optimize such
	sequences. I modified value numbering to divide up such blocks into
	smaller blocks, each with at most one incr_hp, and optimize these.
	At the moment, some of these blocks contain deeply nested field
	refs, which value numbering is very slow to handle; code_exprn
	should be modified to fix these.

value_number:
	Rename usemap to useset, since this is more accurate.
	Fixed a bug in --pred-value-number, which manifested itself as
	the generation of duplicate labels.

labelopt:
	Rename usemap to useset, since this is more accurate.
1996-03-11 05:21:53 +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
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
Zoltan Somogyi
89648b1d29 Fix singleton variable warnings in each of the modified files. 1995-09-12 10:22:05 +00:00
Fergus Henderson
09065f4777 Back out Zoltan's last change, since it doesn't work under
labelopt.m:
	Back out Zoltan's last change, since it doesn't work under
	SICStus Prolog.
1995-08-31 08:55:16 +00:00
Zoltan Somogyi
ea892b6875 Remove a block if the only reference to the label starting a block
labelopt:
	Remove a block if the only reference to the label starting a block
	is from within the block.
1995-08-28 02:13:36 +00:00
Zoltan Somogyi
1708fd6adc Make the teardown map bidirectional, and export it.
frameopt:
	Make the teardown map bidirectional, and export it.

peephole:
	Add a new pattern to handle cases generated by fulljump optimization.
	This pattern uses the teardownmap, but it is disabled for the moment.

optimize:
	Pass the teardown map where it is needed, and make sure we do a
	peephole pass immediately after frameopt to use the teardownmap
	while it is still valid.

jumpopt:
	Rename a variable.

labelopt:
	A block being eliminated may have the last remaining reference
	to the label starting another block. Therefore on the last invocation
	of labelopt, we iterate to a fixpoint before returning.

opt_debug:
	Add a predicate to help debug bidirectional teardown maps.

opt_util:
	Liberalized some optimizations, but the changes are disabled for the
	moment.

value_number:
	Pass an empty teardown map to peephole. Loosen the sanity check on
	tags a bit.

vn_order:
	If the new value of a location depends on its old value,
	avoid creating a circularity in the preferred order relation.
	Such circularity may be broken arbitrarily, even though we have
	a clear preference.

vn_flush:
	Modify the criteria for saving the old value stored in a location
	about to be overwritten, in an effort to eliminate useless copies
	of old values.

vn_util:
	Tighten the requirement for classifying a use as a "real" use,
	also in the effort to eliminate useless saves of old values.
	Recognize some more expression patterns as yieldsing known
	results. Move some functionality from vn_flush to vn_util,
	since it is needed by the other modification.
1995-08-25 12:56:54 +00:00
Fergus Henderson
b87de68334 Implement unique modes. We do not handle local aliasing yet, so this
-------------------------------------------------------

Implement unique modes.  We do not handle local aliasing yet, so this
is still not very useful, except for io__state.  Destructive update is
not yet implemented.  Also note that this really only implements
"mostly unique" variables that may be non-unique on backtracking - we
don't check that you don't backtrack over I/O, for example.

prog_io.m, mode_util.m, modes.m, inst_match.m:
	Major changes to Handle unique modes.

mercury_to_mercury.m, polymorphism.m, prog_out.m, undef_modes.m:
	Use `ground(Uniqueness)' rather than just `ground'.

compiler/*.m:
	Fix compile errors now that unique modes are enforced: add a
	few calls to copy/2, and comment out lots of unique mode
	declarations that caused problems.

typecheck.m, mode_info.m:
	Hack around the use of unique modes, which doesn't work
	because we don't allow local aliasing yet: make the insts
	`uniq_type_info' and `uniq_mode_info' not unique at all,
	and add a call to copy/2 when extracting the io_state from
	type_info or mode_info.

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

Plus a couple of unrelated changes:

hlds.m:
	Change the modes for the special predicates from `ground -> ground'
	to `in', so that any error messages that show those modes
	come out looking nicer.

	Add a new shared_inst_table for shared versions of user-defined
	insts.

mercury_to_goedel.m:
	Use string__is_alnum_or_underscore.
1995-08-02 07:53:53 +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
Zoltan Somogyi
0d8fccaecc Fixed a bug with allowed incr_hp to overwrite its target without saving
value_number, vn_util, opt_util, opt_debug:
	Fixed a bug with allowed incr_hp to overwrite its target without saving
	it. Reorganized the handling of incr_sp and decr_sp to make sure they
	never get reordered with respect to control flow instructions.

llds:
	Fixed the output of temp declarations for blocks.

frameopt:
	Generalized the set up patterns accepted as starting a det procedure.

labelopt:
	Added a source-level option to remove eliminated instructions instead
	of turning them into comments, and made it the default.

optimize:
	After value numbering, perform jump optimization as well as peepholing
	and label optimization.
1995-01-25 10:30:42 +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
879c551076 Divided peephole.nl into several files.
-	optimize.nl is the main loop of the optimizer. It calls functions in
	jumpopt, peephole, labelopt, frameopt and value_number.

-	jumpopt.nl does short-circuiting of jumps to jumps and finds tailcalls.

-	peephole.nl now just does the local pattern-match optimizations.

-	labelopt.nl eliminates dead labels and dead code.

Renamed the options related to optimization.

*** IMPORTANT: the --optimize flag now enables optimize.nl, not C optimization.
C optimization is signalled via the -c-optimize flag. Both flags are on by
default.
1994-12-20 08:19:34 +00:00