Commit Graph

40 Commits

Author SHA1 Message Date
Zoltan Somogyi
ce18b43f9e Divide --inlining into --inline-simple, for inlining all procedures
Estimated hours taken: 1

options:
	Divide --inlining into --inline-simple, for inlining all procedures
	with simple definitions (the curent practice), --inline-single-use
	for inlining all procedures called exactly once, and --inline-threshold
	for specifying an upper bound on the product of the number of calls
	and the size of the procedure definition (roughly the number of
	connectives).

	The --inline-single-use option is off by default until the problem with
	parse_dcg_goal_2 is fixed.

inlining:
	Implement the new options.

goal_util:
	Added a predicate for computing the size of a goal.

mercury_compile:
	Call inlining if any one of three options is set.

call_gen:
	Remove an obsolete comment (all of three hours old :-)
1996-04-24 10:37:57 +00:00
Simon Taylor
0ceed741d1 Bug fixes for higher_order.m and unused_args.m
Estimated hours taken: 8

Bug fixes for higher_order.m and unused_args.m

NEWS
	Removed the message about bugs in unused_args.m and higher_order.m

compiler/options.m
	Re-enabled higher_order and unused_args.

compiler/unused_args.m
	Fixed so that this now handles partially instantiated
	deconstructions correctly.

compiler/higher_order.m
	Two bug fixes:
	Specialization of types for specialized versions of predicates.
	Fixed handling of curried arguments.

compiler/inlining.m, compiler/type_util.m:
	Moved inlining:apply_substitution_to_type_map and
	inlining:apply_rec_substitution_to_type_map to type_util.m
	for use in the higher_order.m bug fix.

library/varset.m
	Added predicate varset__new_vars which returns a list of new
	variables.

library/term.m
	Added predicates term__apply_variable_renaming(_to_list)
	to apply a variable renaming (map(var, var)) to a term
	or list of terms.

library/map.m
	Added map__det_insert_from_corresponding_lists to insert
	multiple key-value pairs into a map.

tests/valid/{Mmake, higher_order2.m, higher_order3.m, unused_args_test2.m}
	Tests for the bug fixes.
1996-04-24 05:21:50 +00:00
Zoltan Somogyi
649b6908c3 Rename branch_delay_slot to have_delay_slot.
Estimated hours taken: 8

options.m:
	Rename branch_delay_slot to have_delay_slot.
	Set optimize_delay_slot in -O2 only if have_delay_slot was set earlier.
	This is possible now because the default optimization level is now
	set in mc.

mercury_compile:
	Change verbose output a bit to be more consistent.

dead_proc_elim:
	Export the predicates that will eventually be needed by inlining.m.

inlining.m:
	Use the information about the number of times each procedure is called
	to inline local nonrecursive procedures that are called exactly once.
	EXCEPT that this is turned off at the moment, since the inlining of
	parse_dcg_goal_2 in prog_io, which this change enables, causes the
	compiler to emit incorrect code.

prog_io:
	Moved the data type definitions to prog_data. (Even though prog_io.m
	is ten times the size of prog_data.m, the sizes of the .c files are
	not too dissimilar.)
1996-04-24 01:00:23 +00:00
Zoltan Somogyi
1d65859679 Count the number of references to each predicate if that predicate
Estimated hours taken: 1.5

dead_proc_elim:
	Count the number of references to each predicate if that predicate
	is a candidate for inlining.

options:
	Enable --optimize-delay-slots for -O2 only if the machine architecture
	actually has branch delay slots.

inlining, modules:
	Fix the copyright notice.
1996-04-21 03:34:28 +00:00
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
Fergus Henderson
1390e238a1 Remove an overly conservative sanity check introduced in my previous
Estimated hours taken: 1

compiler/inlining.m:
	Remove an overly conservative sanity check introduced in my previous
	change to inlining.m.  It can't check that the HLDS is type-correct,
	because polymorphism.m introduces code which is not type-correct.
	(It might be better in the long run to change polymorphism.m,
	but there is no simple way to do that without adversely affecting
	the efficiency of the generated code.)
1996-04-14 13:38:44 +00:00
Fergus Henderson
08633db05b Fix a bug in inlining of polymorphic predicates, which showed up
Estimated hours taken: 0.1

Fix a bug in inlining of polymorphic predicates, which showed up
for the `pseudoknot' benchmark when excess_assign was turned on again.

compiler/inlining.m:
	Make sure we substitute in the new values of any type
	parameters which are bound by an inlined call.
	This fixed a bug which led to the the code generator
	aborting because the code output from inlining.m was
	not type-correct.
	Also, tidy up the source code a bit and a some comments.

type_util.m:
	Add predicate type_list_subsumes/3, for use by inlining.m and
	modes.m.

modes.m:
	Use type_list_subsumes/3.
1996-04-12 23:30:54 +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
Thomas Conway
cdfe750146 Add and fix a few comments to do with the last change.
Estimated hours taken: 0.1

Add and fix a few comments to do with the last change.

compiler/*.m:
	change a few comments.
1996-01-04 03:54:16 +00:00
Thomas Conway
64e07ae112 There was a problem where variables that die during forward
Estimated hours taken: 5

There was a problem where variables that die during forward
execution, and then become live again on backtracking were
not being handled correctly. There was some half-working code
to deal with the problem. It has now been fixed, and there
are some new test cases for the regression tests.

compiler/.cvsignore:
	added *.ql since they become very irritating after a while...

compiler/inlining.m:
	added a couple of comments
	make a bit of the code more concise.

compiler/*.m:
	changes to handle nondet-liveness correctly.
1996-01-04 01:56:10 +00:00
Dylan Shuttleworth
3ab8d92226 Change names with badly placed double underscores (ie where the part of
Estimated hours taken: _2___

Change names with badly placed double underscores (ie where the part of
a name before a double underscore is not the same as the module name.)

Reflect changes in the library interface.

compiler/*:
	Use the newer, more correct form of the term and bool names.
	Predicates "bool__" are now "std_util__bool" and labels of
	the term ADT are now "term_" instead of "term__".

compiler/vn*.m:
	change all names "vn__*" to a correct module prefix.  All the
	names remain qualified.

compiler/hlds.m:
	s/\<is_builtin__/hlds__is_builtin_/g
	s/\<dependency_info__/hlds__dependency_info_/g

compiler/unify_proc.m:
	s/\<unify_proc_info__/unify_proc__info_/g

compiler/transform.m:
	s/\<reschedule__conj/transform__reschedule_conj/g
1995-12-29 03:45:20 +00:00
Thomas Conway
47858f4a07 goal_util.m: modify goal_util__create_variables so that it can be
Estimated hours taken: 1.0

goal_util.m: modify goal_util__create_variables so that it can be
	used for renaming apart in inlining as well as the other
	places (quantification, etc).

inlining.m:
	Remove the renaming-apart code and use the code in goal_util.

quantification.m:
	make the call to goal_util__create_variables compatible with
	the modified interface.
1995-11-02 02:25:16 +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
David Jeffery
07b9ac5c4a We now allow a declaration of the form:
:- pragma(inline, predicate/arity).

This declaration means that the corresponding predicate will be inlined.

hlds.m:		Add a field to the pred_info indicating whether or not to
		inline the pred automatically.
make_hlds.m:	Turn on the inline flag in the pred_info if there was a
		pragma(inline, ...) declaration.
prog_io.m:	Parse the new declaration.
mercury_to_mercury.m:
		Spit out the new dec.
inlining.m:	Inline the predicate if the inlining field is set in the
		pred_info.
polymorphism.m:
code_aux.m:	Add an extra paramater to calls to pred_info_init.
1995-10-23 04:51:50 +00:00
David Jeffery
f75693e80a The C interface.
The changes made allow declarations of the form:

:- pragma(c_code, predname(Varname1::mode1, Varname2::mode2, ...),
	"Some C code to execute instead of a mercury clause;").

There are still a couple of minor problems to be fixed in the near future:
If there is a regular clause given as well as a pragma(c_code, ...) dec, it
is not handled well, and variables names '_' are not handled well.

prog_io.m:
	parse the pragma(c_code, ...) dec.
hlds.m:
	define a new hlds__goal_expr 'pragma_c_code'.
make_hlds.m:
	insert the pragma(c_code, ...) dec. as a pragma_c_code into the hlds.
det_analysis.m:
	infer that pragma_c_code goals are det.
modes.m:
	convince the mode checker that the correct pragma variables are bound
	etc.
quantification.m:
	quantify the variables in the pragma(c_code, ...) dec.
code_gen.pp:
	convert pragma_c_code into pragma_c (in the llds).
llds.m:
	define a new instr, pragma_c. Output the pragma_c
hlds_out.m:
mercury_to_mercury.m:
mercury_to_goedel.m:
	spit out pragma(c_code, ...) decs properly

*.m: 	handle the new pragma_c_code in the hlds or the new pragma_c in the llds
1995-10-17 11:13:13 +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
760b99015c Another big batch of changes for higher-order predicates.
This set of changes includes most of the work necessary for
mode and determinism checking of higher-order predicates.

prog_io.m:
	Change the syntax for lambda expressions: they need
	to have a determinism declaration.  Lambda
	expressions must now look like this:

		lambda([X::in, Y::out] is det, ...goal...).
				       ^^^^^^

	Note that both the modes and the determinism are mandatory,
	not optional.

hlds.m:
	Insert a determinism field in the lambda_goal structure.

hlds_out.m, inlining.m, make_hlds.m, modes.m, polymorphism.m, quantification.m,
switch_detection.m, typecheck.m:
	Modified to use lambda_goal/4 rather than lambda_goal/3.

prog_io.m:
	Add a new field to the `ground' inst, of type `maybe(pred_inst_info)'.
	We use this to store the modes and determinism of higher-order
	predicate terms.

code_info.m, inst_match.m, mercury_to_mercury.m, mode_util.m, modes.m,
polymorphism.m, shapes.m, undef_modes.m:
	Modified to handle higher-order pred modes:
	use ground/2 rather than ground/1.
	(Note that modes.m still requires a bit more work on this.)

llds.m:
	Add a new field to the call_closure/3 instruction to hold the
	caller address for use with profiling, since the C macros
	require a caller address.

dup_elim.m, frame_opt.m, garbage_out.m, live_map.m, middle_rec.m, opt_debug.m,
opt_util.m, value_number.m, vn_*.m:
	Modified to use call_closure/4 rather than call_closure/3.

mercury_to_mercury.m:
	Export mercury_output_det for use by hlds_out.m.
1995-08-26 20:04:46 +00:00
Fergus Henderson
160a32038a More work on lambda expressions.
hlds.m:
	Insert new `list(mode)' field in the lambda_goal/2 structure.

hlds_out.m, inlining.m, quantification.m, switch_detection.m,
	Use lambda_goal/3 instead of lambda_goal/2.

parser.m, make_hlds.m, typecheck.m, modes.m:
	Parse, typecheck, and modecheck lambda expressions.

mercury_to_mercury.m:
	Export mercury_output_mode/4 for use by hlds_out.m.
1995-08-20 18:17:36 +00:00
Zoltan Somogyi
b905b2f4d8 Added an extra argument to call, which contains a maybe of the unification
context of the unification from which call was made. We we use this to generate
significantly better error messages. (There should be no more messages of the
form "call to __Unify__(blah blah blah) can fail".) Most of the files are
changed just to reflect this.

An unrelated change in det_analysis is that we now ensure the absence of
cycles by modifying the new inferred determinism in the light of the old
one, ensuring that any changes are monotonic.

In hlds_out, inhibit the printing of pseudo-imported predicates (unifications)
since nobody cares about them except sometimes Fergus.
1995-07-31 08:35:41 +00:00
Fergus Henderson
36878440a1 This batch of changes implements complicated modes of complicated
unifications.  See the comments at the top of unify_proc.m for
details of how it's done.

hlds.m:
	Add new export statuses `pseudo_imported' and `pseudo_exported'
	to handle unification predicates, which can now have complicated
	modes.

code_gen.pp, code_info.m, common.m, constraint.m, cse_detection.m,
follow_code.m, follow_vars.m, hlds_out.m, inlining.m, live_vars,
make_hlds.m, mercury_compile.pp, modes.m, store_alloc.m,
switch_detection.m:
	Handle pseudo_imported predicates.

modes.m, constraint.m:
	Change modecheck to return an updated module_info, since
	modechecking may insert new entries into the unify_requests
	queue in the module_info.  Make sure that modechecking
	never inserts requests into the unify_requests queue
	for code that has mode errors (or needs rescheduling).

call_gen.m, polymorphism.m:
	Move duplicated code into unify_proc.m.

clause_to_proc.m:
	Add new predicate clauses_to_proc for use by unify_proc.m.

unify_proc.m:
	Implement complicated unifications with complicated modes.
1995-07-20 13:32:36 +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
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
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
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
b759b4436a change occurences of is_builtin and not_builtin to abstract
various:
	change occurences of is_builtin and not_builtin to abstract
	calls.

code_info.nl:
	perform transitive checking for variable dependencies.
1995-02-07 07:39:13 +00:00
Fergus Henderson
d08e9f5e4c Fix warning introduced in last change.
inlining.nl:
	Fix warning introduced in last change.
1995-01-27 06:31:12 +00:00
Fergus Henderson
c590262b5f Now that Tom has simplified the inlining algorithm,
inlining.nl:
	Now that Tom has simplified the inlining algorithm,
	we don't need to requantify goals after inlining,
	since inlining preserves the right quantification.
1995-01-27 06:14:44 +00:00
Fergus Henderson
41a8a66278 Remove some redundant code.
inlining.nl:
	Remove some redundant code.
1995-01-17 22:42:28 +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
Thomas Conway
0cffee5bb9 Remove some dead code.
inlining.nl:
	Remove some dead code.
1995-01-10 00:03:54 +00:00
Fergus Henderson
bfd857ca3a Remove unnecessary import of arg_info.
inlining.nl:
	Remove unnecessary import of arg_info.
1995-01-09 13:26:18 +00:00
Thomas Conway
6a2c0aad85 array.nl : fix the bug fjh pointed out
inlining.nl:	minor bugfix.
1995-01-06 22:33:39 +00:00
Thomas Conway
88ae01878c fixed it up so that it now works for partially instantiated
inlining.nl:
	fixed it up so that it now works for partially instantiated
	structures, and also avoids generating redundant guff.
1994-12-19 04:36:13 +00:00
Fergus Henderson
e3725ca5ff Improve an error message.
code_info.nl:
	Improve an error message.

followcode.nl:
	Add a comment.

hlds_out.nl:
	Output ":=", "==", or "=" for the different types of unifications.
======> READ THIS: <======
	(Known bug: the order of the operands for ":=" is wrong.)

make_hlds.nl, unify_proc.nl:
	Make complicated unifications work!
1994-12-14 12:02:10 +00:00
Fergus Henderson
5b4d3706d8 Change not' to \+'.
inlining.nl:
	Change `not' to `\+'.
1994-12-12 13:04:42 +00:00
Thomas Conway
3977ea3b87 added an option --inlining.
options.nl, mercury_compile.pp:
	added an option --inlining.

hlds.nl, inlining.nl:
	bugfixes - propegate the type information for inlined preds
		 - get the assign/2 arguments in the right order :-)
1994-12-05 06:21:58 +00:00
Thomas Conway
fdd22bec82 make the heuristic for inlining stricter.
inlining.nl:
	make the heuristic for inlining stricter.

mercury_compile.*:
	add an extra garbage collection.

code_aux.*:
	add "goal_is_flat" test predicate.
1994-12-05 03:36:34 +00:00
Thomas Conway
122237c299 A pass that performs inlining. The current heuristic of
inlining.*:
	A pass that performs inlining. The current heuristic of
	what to in line is that only predicates containing builtins
	get inlined. The inlining mechanism will trivially extend
	to inlining more complex predicates.

	Currently, inlining cannot cross module boundaries.

misc:
	Additions for inlining.
1994-12-02 13:41:14 +00:00