Commit Graph

17 Commits

Author SHA1 Message Date
Simon Taylor
38fb85be30 Sort-merge semi-joins are not yet implemented in Aditi,
Estimated hours taken: 0.25
Branches: main, release

compiler/rl_sort.m:
compiler/rl_out.pp:
	Sort-merge semi-joins are not yet implemented in Aditi,
	so don't generate them.
2001-08-08 06:36:22 +00:00
Simon Taylor
6d1e43394d The Aditi query shell does not know about --use-subdirs,
Estimated hours taken: 0.2
Branches: main

The Aditi query shell does not know about --use-subdirs,
so put all the files it uses in the current directory.

compiler/modules.m:
	Put `.rlo', `.base_schema' and `.derived_schema' files
	in the current directory.

scripts/Mmake.vars.in:
	Set $(rlos_subdir) to the empty string, even with --use-subdirs.

compiler/rl_out.pp:
	Create the directory when creating the `.derived_schema' file.
	This isn't necessary any more, but will be needed if we ever
	go back to putting the `.derived_schema' file in a sub-directory.
2001-08-06 12:54:27 +00:00
Simon Taylor
871a5b88b4 Remove a stray import of rl_code.m which caused rl_code.m
Estimated hours taken: 0.1

compiler/rl_out.pp:
	Remove a stray import of rl_code.m which caused rl_code.m
	to be compiled even if `INCLUDE_ADITI_OUTPUT = no' is
	included in Mmake.params.
2001-01-04 05:23:48 +00:00
Simon Taylor
c6a02b4439 Generate RL procedures to handle bulk insertions, as is done for
Estimated hours taken: 1

Generate RL procedures to handle bulk insertions, as is done for
deletions and modifications. This change is needed because the API
function to perform bulk insertions is very slow.

compiler/rl_out.pp:
	Generate a procedure for each base relation to handle
	bulk insertion.

compiler/rl.m:
	Add `rl__get_insert_proc_name' to return the name of the
	automatically generate insertion procedure for a base relation.

compiler/call_gen.m:
	Set up the procedure name argument to `do_aditi_bulk_insert'.
2000-05-24 07:12:25 +00:00
Simon Taylor
7622eb1d36 Finish the implementation of Aditi updates.
Estimated hours taken: 120

Finish the implementation of Aditi updates.

compiler/hlds_goal.m:
	Refactor the aditi_builtin type so that operations with
	similar syntax and implementations are grouped together.

	Add operations to delete a single tuple (`aditi_delete') and
	to modify tuples (`aditi_bulk_modify').

compiler/*.m:
	Minor changes required by refactoring the aditi_builtin type.

compiler/make_hlds.m:
	Parse `aditi_delete' and `aditi_bulk_modify' goals.

	Parse a nicer syntax for `aditi_bulk_delete' and
	`aditi_bulk_insert' goals
	(e.g. aditi_bulk_delete(p(_, X, _) :- X > 2)).

compiler/rl_out.pp:
	For each base relation, generate RL procedures to apply
	deletions and modifications to the relation. `aditi_bulk_modify'
	takes a closure which produces tuples which contain both the
	attributes of the tuple to delete and the tuple to insert. The
	modification RL procedure performs two projections on the
	closure result to produce the tuples to delete and the tuples
	to delete.

	The input stream to the rl_PROC_delete RL instruction must contain
	only tuples taken from the relation to delete from -- the deletion
	is done using the tuple-id rather than the tuple contents.
	The generated deletion procedure performs a semi-join of the
	relation to delete from with the relation containing the
	tuples to delete.

compiler/rl.m:
	Add predicates to generate the names of the modification
	and deletion RL procedures generated for each base relation.

compiler/rl_exprn.m:
	Generate the projection expressions required by the modification
	RL procedures generated for each base relation.

	Generate the equi-join expressions required by the modification
	and deletion RL procedures generated for each base relation.

compiler/unify_gen.m:
	Implement code generation for `aditi_bottom_up' closures.

compiler/rl.m:
compiler/magic.m:
	Factor out the code used to create the name of the RL procedure
	used to interface top-down Mercury to Aditi, for use by unify_gen.m
	to generate `aditi_bottom_up' closures.

compiler/code_util.m:
	Add predicate code_util__make_user_proc_label, which constructs
	a label name from the given all the individual pieces of information
	used to construct it, rather than just a pred_id and proc_id.
	This is used to produce the RL procedure name for an `aditi_bottom_up'
	closure, so that the code doesn't have to work out what the pred_id
	of the magic sets transformed procedure is.

compiler/magic.m:
	Always create new procedures to interface Mercury to Aditi,
	to make it easier for unify_gen.m to work out what the name
	of the interface procedure is -- don't optimize the case of
	a predicate with no input arguments.

	Alter the goal generated for the interface procedures so
	that it doesn't matter whether the interface procedure
	and the procedure it interfaces to are compiled together
	by rl_gen.m -- the old code generated for these procedures
	assumed they were compiled separately, which wasn't always the
	case.

	Don't pass a `magic_info' through the code to generate the
	C interface procedures -- only the module_info field was
	required.

compiler/magic_util.m:
compiler/magic.m:
compiler/context.m:
	Don't pass a `magic_info' through
	magic_util__create_input_test_unifications --
	only the module_info and proc_info fields were used.

compiler/post_typecheck.m:
compiler/magic_util.m:
	Don't report errors for the second `aditi__state' argument
	of the closure passed to `aditi_bulk_modify'.

compiler/purity.m:
	Change the mode of the second `aditi__state' argument
	of the closure passed to `aditi_bulk_modify' to `unused'.

compiler/call_gen.m:
	Generate `aditi_delete' and `aditi_bulk_modify'.

	Remove the `aditi__state' from the tuple to insert passed
	to an `aditi_insert' or `aditi_delete' operation -- the relation
	on disk does not contain the `aditi__state' attribute.

extras/aditi/aditi.m:
	Implement the updates.

	Allocate all memory on the Mercury heap to avoid memory
	leaks when a transaction aborts.

	Uncaught exceptions within a transaction now cause
	the transaction to abort, and the exception is rethrown
	to the caller.

	If using trailing, add trail entries for the output relation
	and cursor created for a call to an Aditi procedure, so that
	they will be cleaned up if only one solution of the call
	is needed or if an exception is thrown.

	Include line numbers in the debugging messages if an Aditi API
	function fails.

compiler/llds.m:
compiler/*.m:
	Rename the `do_aditi_modify' label to `do_aditi_bulk_modify' -- we
	may eventually want to implement a modification goal type which
	doesn't produce all modified tuples before applying the update.

doc/reference_manual.texi:
	Document `aditi_delete' and `aditi_bulk_modify'.

	Add some extra spacing in the Aditi update section to
	improve readability.

tests/valid/aditi_update.m:
tests/invalid/aditi_update_errors.m:
tests/invalid/aditi_update_errors.err_exp:
tests/invalid/aditi_update_mode_errors.m:
tests/invalid/aditi_update_mode_errors.err_exp:
	Changed to fit in with the new syntax.

tests/valid/Mmakefile:
	Code generation for Aditi updates now works, so enable full
	compilation of the aditi_update.m test case, rather than
	just checking for errors.
2000-04-14 08:39:24 +00:00
Simon Taylor
b203582c18 Fix some bugs in the optimization of indexed and sort joins.
Estimated hours taken: 3

Fix some bugs in the optimization of indexed and sort joins.

compiler/rl_out.pp:
compiler/rl.m:
compiler/rl_dump.m:
compiler/rl_block_opt.m:
compiler/rl_stream.m:
compiler/rl_sort.m:
	Avoid adding indexes to base relations during queries.
	Change the code generated for an add_index instruction
	to first test whether the input relation is a base
	relation. If it is, the relation must be copied -- queries
	should never modify base relations.

	The add_index instruction now takes an input and returns
	an output, rather than just modifying its argument.

compiler/rl_sort.m:
	Fix the merging of sort and index information -- the code
	was erroneously finding that some relations were definitely
	sorted when they were only sorted on some of the branches leading
	into a block.

	Don't treat indexed relations as sorted when attempting
	to generate a sort-merge join -- if a relation is indexed
	an indexed join should be used.

compiler/rl_code.m:
	Add a rl_PROC_is_permanent bytecode to test whether
	a relation variable refers to a permanent relation.

	Increment the version number.
2000-03-13 05:24:40 +00:00
Simon Taylor
c6cc811c65 More optimization of Aditi joins and subtracts.
Estimated hours taken: 25

More optimization of Aditi joins and subtracts.

compiler/rl.m:
	Add predicates to detect trivial subtracts -- subtracts
	for which the condition doesn't use one of the input tuples.

compiler/rl_sort.m:
	Introduce index and hash subtract operations.

	Improve the handling of trivial joins and subtracts
	which can just pass one of their input relations
	to the output, so that following instructions can make
	use of any indexing on the passed through input relation.

compiler/rl_relops.m:
compiler/rl_block_opt.m:
	Detect trivial- and semi-joins and trivial subtracts when
	the instructions are generated in rl_relops.m, rather
	than in rl_block_opt.m -- these should be detected regardless
	of whether the more complex optimizations are being performed.

compiler/rl_code.m:
	The indexed instructions now take a parameter describing
	whether the key ranges are open or closed -- all key ranges
	currently generated by the compiler are closed.

	Increment the RL bytecode version number.

compiler/rl_block.m:
	Don't assume the output of map__keys is sorted --
	use map__sorted_keys instead.

compiler/rl_dump.m:
	Write out information about trivial subtracts.

compiler/rl_key.m:
	Fix the handling of unbounded key ranges.

compiler/rl_out.pp:
	Generate trivial, index and hash subtracts.

	Don't optimize away unneeded projects here --
	they should be removed (or not generated) earlier.

compiler/rl_stream.m:
	Fix the handling of trivial joins and subtracts
	which can create aliases of one of their input
	relations.
2000-03-01 01:04:52 +00:00
Simon Taylor
f39064371d Improve the handling of joins in the Aditi back end.
Estimated hours taken: 80

Improve the handling of joins in the Aditi back end.
- generate hash and sort-merge joins for equijoins.
- use the semi-join bytecodes for joins which
	return one of the input tuples.
- optimize `trivial' joins where the join condition does not
	depend on one of the input tuples.

compiler/rl.m:
	Store information about whether a join is a semi-join
	or a trivial join.

	Add `hash' to the list of alternatives for `join_type'.

	Remove `semi' from the list of alternatives for `join_type' --
	semi-join is a modified implementation of one of the other
	join types.

	Remove `cross' from the list of alternatives for `join_type' --
	a cross-product is just a modified nested-loop join.

	All subtracts are done as semi-subtracts (no projection is performed
	on the output by the subtract instruction) -- rename the
	constructors of type `subtract_type' to reflect this.

	Add more predicates to manipulate join conditions.

	Add field labels to the `rl_goal' type.

compiler/rl_sort.m:
	Introduce sort-merge and hash joins.

compiler/rl_key.m:
	Add `rl_key__is_equijoin', to work out whether a join
	condition tests whether attributes of the input tuples
	are equal.

compiler/rl_block_opt.m:
	Fill in the semi-join and trivial join fields of join
	instructions.

compiler/rl_out.pp:
	Handle sort-merge, hash, semi and trivial joins.

	Use record syntax for the rl_out_info access predicates.

compiler/rl_exprn.m:
	Generate RL expressions for use in sort-merge and
	hash joins.

compiler/rl_relops.m:
	Remove code to handle semi-joins -- they are
	introduced later.

compiler/rl_*.m:
	Handle the extra fields of join instructions.
2000-02-22 02:55:34 +00:00
Simon Taylor
63983a9128 Fix confusion over whether attributes are numbered starting from
Estimated hours taken: 3

Fix confusion over whether attributes are numbered starting from
zero or one.

compiler/prog_data.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/rl_sort.m:
	Attributes in sort and index specifications are
	now numbered starting from 1, to be consistent with
	argument numbering in the rest of the compiler, and for
	error messages.

compiler/rl_exprn.m:
compiler/rl_out.pp:
	Aditi numbers arguments starting from 0, so convert
	the numbers here.
1999-08-25 06:34:03 +00:00
Simon Taylor
0aadc99c0d Add semi' to the list of alternatives for subtract_type'.
Estimated hours taken: 0.5

compiler/rl.m:
	Add `semi' to the list of alternatives for `subtract_type'.

compiler/rl_out.pp:
	Use `rl_PROC_semisubtract_nl' instead of `rl_PROC_subtract_nl'
	because Aditi's definition of `rl_PROC_subtract_nl' has changed
	to match its specification (it now performs a projection on
	its output rather than just returning the left input tuple).
	`semisubtract' implements the old behaviour.

compiler/rl*.m:
	Handle semisubtract.
1999-08-14 04:52:26 +00:00
Simon Taylor
55dd5cbd15 The RL aggregate instruction takes one input tuple, not two.
Estimated hours taken: 0.1

compiler/rl_out.pp:
	The RL aggregate instruction takes one input tuple, not two.
1999-07-30 05:14:27 +00:00
Simon Taylor
2725b1a331 Aditi update syntax, type and mode checking.
Estimated hours taken: 220

Aditi update syntax, type and mode checking.

Change the hlds_goal for constructions in preparation for
structure reuse to avoid making multiple conflicting changes.

compiler/hlds_goal.m:
	Merge `higher_order_call' and `class_method_call' into a single
	`generic_call' goal type. This also has alternatives for the
	various Aditi builtins for which type declarations can't
	be written.

	Remove the argument types field from higher-order/class method calls.
	It wasn't used often, and wasn't updated by optimizations
	such as inlining. The types can be obtained from the vartypes
	field of the proc_info.

	Add a `lambda_eval_method' field to lambda_goals.

	Add a field to constructions to identify which RL code fragment should
	be used for an top-down Aditi closure.

	Add fields to constructions to hold structure reuse information.
	This is currently ignored -- the changes to implement structure
	reuse will be committed to the alias branch.
	This is included here to avoid lots of CVS conflicts caused by
	changing the definition of `hlds_goal' twice.

	Add a field to `some' goals to specify whether the quantification
	can be removed. This is used to make it easier to ensure that
	indexes are used for updates.

	Add a field to lambda_goals to describe whether the modes were
	guessed by the compiler and may need fixing up after typechecking
	works out the argument types.

	Add predicate `hlds_goal__generic_call_id' to work out a call_id
	for a generic call for use in error messages.

compiler/purity.m:
compiler/post_typecheck.m:
	Fill in the modes of Aditi builtin calls and closure constructions.
	This needs to know which are the `aditi__state' arguments, so
	it must be done after typechecking.

compiler/prog_data.m:
	Added `:- type sym_name_and_arity ---> sym_name/arity'.

	Add a type `lambda_eval_method', which describes how a closure
	is to be executed. The alternatives are normal Mercury execution,
	bottom-up execution by Aditi and top-down execution by Aditi.

compiler/prog_out.m:
	Add predicate `prog_out__write_sym_name_and_arity', which
	replaces duplicated inline code in a few places.

compiler/hlds_data.m:
	Add a `lambda_eval_method' field to `pred_const' cons_ids and
	`pred_closure_tag' cons_tags.

compiler/hlds_pred.m:
	Remove type `pred_call_id', replace it with type `simple_call_id',
	which combines a `pred_or_func' and a `sym_name_and_arity'.

	Add a type `call_id' which describes all the different types of call,
	including normal calls, higher-order and class-method calls
	and Aditi builtins.

	Add `aditi_top_down' to the type `marker'.

	Remove `aditi_interface' from type `marker'. Interfacing to
	Aditi predicates is now handled by `generic_call' hlds_goals.

	Add a type `rl_exprn_id' which identifies a predicate to
	be executed top-down by Aditi.
	Add a `maybe(rl_exprn_id)'  field to type `proc_info'.

	Add predicate `adjust_func_arity' to convert between the arity
	of a function to its arity as a predicate.

	Add predicates `get_state_args' and `get_state_args_det' to
	extract the DCG state arguments from an argument list.

	Add predicate `pred_info_get_call_id' to get a `simple_call_id'
	for a predicate for use in error messages.

compiler/hlds_out.m:
	Write the new representation for call_ids.

	Add a predicate `hlds_out__write_call_arg_id' which
	replaces similar code in mode_errors.m and typecheck.m.

compiler/prog_io_goal.m:
	Add support for `aditi_bottom_up' and `aditi_top_down' annotations
	on pred expressions.

compiler/prog_io_util.m:
compiler/prog_io_pragma.m:
	Add predicates
	- `prog_io_util:parse_name_and_arity' to parse `SymName/Arity'
		(moved from prog_io_pragma.m).
	- `prog_io_util:parse_pred_or_func_name_and_arity to parse
		`pred SymName/Arity' or `func SymName/Arity'.
	- `prog_io_util:parse_pred_or_func_and_args' to parse terms resembling
		a clause head (moved from prog_io_pragma.m).

compiler/type_util.m:
	Add support for `aditi_bottom_up' and `aditi_top_down' annotations
	on higher-order types.

	Add predicates `construct_higher_order_type',
	`construct_higher_order_pred_type' and
	`construct_higher_order_func_type' to avoid some code duplication.

compiler/mode_util.m:
	Add predicate `unused_mode/1', which returns `builtin:unused'.
	Add functions `aditi_di_mode/0', `aditi_ui_mode/0' and
	`aditi_uo_mode/0' which return `in', `in', and `out', but will
	be changed to return `di', `ui' and `uo' when alias tracking
	is implemented.

compiler/goal_util.m:
	Add predicate `goal_util__generic_call_vars' which returns
	any arguments to a generic_call which are not in the argument list,
	for example the closure passed to a higher-order call or
	the typeclass_info for a class method call.

compiler/llds.m:
compiler/exprn_aux.m:
compiler/dupelim.m:
compiler/llds_out.m:
compiler/opt_debug.m:
	Add builtin labels for the Aditi update operations.

compiler/hlds_module.m:
	Add predicate predicate_table_search_pf_sym, used for finding
	possible matches for a call with the wrong number of arguments.

compiler/intermod.m:
	Don't write predicates which build `aditi_top_down' goals,
	because there is currently no way to tell importing modules
	which RL code fragment to use.

compiler/simplify.m:
	Obey the `cannot_remove' field of explicit quantification goals.

compiler/make_hlds.m:
	Parse Aditi updates.

	Don't typecheck clauses for which syntax errors in Aditi updates
	are found - this avoids spurious "undefined predicate `aditi_insert/3'"
	errors.

	Factor out some common code to handle terms of the form `Head :- Body'.
	Factor out common code in the handling of pred and func expressions.

compiler/typecheck.m:
	Typecheck Aditi builtins.

	Allow the argument types of matching predicates to be adjusted
	when typechecking the higher-order arguments of Aditi builtins.

	Change `typecheck__resolve_pred_overloading' to take a list of
	argument types rather than a `map(var, type)' and a list of
	arguments to allow a transformation to be performed on the
	argument types before passing them.

compiler/error_util.m:
	Move the part of `report_error_num_args' which writes
	"wrong number of arguments (<x>; expected <y>)" from
	typecheck.m for use by make_hlds.m when reporting errors
	for Aditi builtins.

compiler/modes.m:
compiler/unique_modes.m:
compiler/modecheck_call.m:
	Modecheck Aditi builtins.

compiler/lambda.m:
	Handle the markers for predicates introduced for
	`aditi_top_down' and `aditi_bottom_up' lambda expressions.

compiler/polymorphism.m:
	Add extra type_infos to `aditi_insert' calls
	describing the tuple to insert.

compiler/call_gen.m:
	Generate code for Aditi builtins.

compiler/unify_gen.m:
compiler/bytecode_gen.m:
	Abort on `aditi_top_down' and `aditi_bottom_up' lambda
	expressions - code generation for them is not yet implemented.

compiler/magic.m:
	Use the `aditi_call' generic_call rather than create
	a new procedure for each Aditi predicate called from C.

compiler/rl_out.pp:
compiler/rl_gen.m:
compiler/rl.m:
	Move some utility code used by magic.m and call_gen.m into rl.m.

	Remove an XXX comment about reference counting being not yet
	implemented - Evan has fixed that.

library/ops.m:
compiler/mercury_to_mercury.m:
doc/transition_guide.texi:
	Add unary prefix operators `aditi_bottom_up' and `aditi_top_down',
	used as qualifiers on lambda expressions.
	Add infix operator `==>' to separate the tuples in an
	`aditi_modify' call.

compiler/follow_vars.m:
	Thread a `map(prog_var, type)' through, needed because
	type information is no longer held in higher-order call goals.

compiler/table_gen.m:
	Use the `make_*_construction' predicates in hlds_goal.m
	to construct constants.

compiler/*.m:
	Trivial changes to add extra fields to hlds_goal structures.

doc/reference_manual.texi:
	Document Aditi updates.

	Use @samp{pragma base_relation} instead of
	@samp{:- pragma base_relation} throughout the Aditi documentation
	to be consistent with other parts of the reference manual.

tests/valid/Mmakefile:
tests/valid/aditi_update.m:
tests/valid/aditi.m:
	Test case.

tests/valid/Mmakefile:
	Remove some hard-coded --intermodule-optimization rules which are
	no longer needed because `mmake depend' is now run in this directory.

tests/invalid/*.err_exp:
	Fix expected output for changes in reporting of call_ids
	in typecheck.m.

tests/invalid/Mmakefile
tests/invalid/aditi_update_errors.{m,err_exp}:
tests/invalid/aditi_update_mode_errors.{m,err_exp}:
	Test error messages for Aditi updates.

tests/valid/aditi.m:
tests/invalid/aditi.m:
	Cut down version of extras/aditi/aditi.m to provide basic declarations
	for Aditi compilation such as `aditi__state' and the modes
	`aditi_di', `aditi_uo' and `aditi_ui'. Installing extras/aditi/aditi.m
	somewhere would remove the need for these.
1999-07-13 08:55:28 +00:00
Simon Taylor
817ea9408c Use the `one_reference' bytecode to avoid unnecessary copying.
Estimated hours taken: 5

compiler/rl_out.pp:
	Use the `one_reference' bytecode to avoid unnecessary copying.
	Use the `has_index' bytecode to avoid adding indexes multiple times.

compiler/rl_sort.m:
	Fix bugs in the rules describing how required and available
	sorting and indexing are affected by the `make_unique' instruction.

compiler/rl.m:
	Remove an obsolete comment.
1999-06-24 02:07:19 +00:00
Simon Taylor
69afde6f39 Fix a bug which caused missing constant declarations in the
Estimated hours taken: 3

compiler/rl_exprn.m:
	Fix a bug which caused missing constant declarations in the
	RL generated for aggregate goals.

	Remove some code duplication for generation of constant
	and constructor declarations.

	For consistency, return the list of variable types for
	key range expressions, even though it should currently
	always be empty.

compiler/rl_out.pp:
	Handle the variable types returned for key range expressions.
1999-06-16 00:36:32 +00:00
Simon Taylor
a9140e4f69 Add an argument to rl_PROC_materialise instructions to make
Estimated hours taken: 0.5

compiler/rl_code.m:
compiler/rl_out.pp:
	 Add an argument to rl_PROC_materialise instructions to make
	 it easier to identify which materialise instruction causes
	 each part of the debugging output from Aditi.
1999-05-11 05:03:59 +00:00
Simon Taylor
79f04d3d0b Rearrange the code so INCLUDE_ADITI_OUTPUT actually works.
Estimated hours taken: 0.25

compiler/rl_out.pp:
	Rearrange the code so INCLUDE_ADITI_OUTPUT actually works.

	Don't output a schema entry for each mode of a base_relation
	in the `<module>.base_schema file - we only need one for
	the predicate because all the procedures refer to the same
	on-disk relation.
1999-05-05 06:31:01 +00:00
Simon Taylor
c262a2306e Preprocess mercury_compile.m and rl_file.m to remove dependencies
Estimated hours taken: 3

Preprocess mercury_compile.m and rl_file.m to remove dependencies
on rl_code.m. This is done to avoid major mode analysis efficiency
problems on the alias branch.

Mmake.common.in:
	Include the Aditi support by default.

compiler/Mmakefile:
	Add rules to process `.pp' files.

compiler/rl_out.pp:
compiler/rl_file.pp:
	Add preprocessing to remove dependencies on rl_code.m.

compiler/rl_out.m:
compiler/rl_file.m:
	Removed.

compiler/rl_out.m:
compiler/rl.m:
compiler/rl_gen.m:
compiler/magic.m:
	Move the code to convert schemas to strings into rl.m,
	since these are not just used for RL output.
1999-04-28 01:18:44 +00:00