Commit Graph

11 Commits

Author SHA1 Message Date
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
Fergus Henderson
3b36da6e77 Implement functional syntax. You can now use `:- func' in a similar manner
Estimated hours taken: 12

Implement functional syntax.  You can now use `:- func' in a similar manner
to `:- pred'.  For example, `:- func foo(int, int) = int.' declares a function,
and `:- mode foo(in, in) = out.' defines a mode for it.  You can write clauses
for functions, such as `foo(X, Y) = Z :- Z is 2*X + Y.'  Any term in the
head or body of a clause can be a function call, e.g. `bar(X, Y, foo(X, Y))'.

Until we have implemented a proper Mercury debugger, this syntax
should not be used (except that I might reimplement the functions
provided by Prolog's is/2 predicate using this syntax, rather than
the current special-case hack in the parser).

prog_io.m:
	Add syntax for declaring and defining functions.
	Disallow the use of `=' to define modes, as in `:- mode foo = bar.'
	(Instead, you should use `::'.  `==' is also allowed.)
	Also, use higher-order predicates to simplify some of the rather
	repetitious parsing code.

mercury_to_mercury.m, mercury_to_goedel.m, make_hlds.m, modules.m:
	Handle new functional syntax.

typecheck.m:
	Add support for functions, function types such as `func(int) = int',
	and currying.  (But there's currently no equivalent to call/N for
	functions, so function types and currying aren't very useful yet.)

undef_types.m:
	Add support for function types.

modes.m:
	Convert function calls into predicate calls.
	(This must be done after typechecking is complete,
	so I put it in mode analysis.)

hlds.m:
	Add new field `pred_or_func' to the pred_info.

hlds_out.m:
	Print out the `pred_or_func' field.

higher_order.m, unused_args.m, lambda.m, dnf.m:
	Pass extra pred_or_func argument to pred_info_init to specify that
	the thing being created is a predicate, not a function.

constraint.m, dependency_graph.m, hlds_out.m:
	`mercury_output_mode_subdecl' has been renamed
	`mercury_output_pred_mode_subdecl'.

prog_util.m:
	Add new predicate split_type_and_mode/3.

llds.m:
	Print out
		/* code for predicate '*'/3 in mode 0 */
	rather than
		/* code for predicate */3 in mode 0 */
	to avoid a syntax error in the generated C code.
1996-03-25 07:41:54 +00:00
Fergus Henderson
e500f1d94d Change the rule for building foo.split.a' in the generated .dep'
Estimated hours taken: 0.5

compiler/modules.m:
	Change the rule for building `foo.split.a' in the generated `.dep'
	file so that it first creates an empty archive, and then adds
	the object files to that archive one directory at a time,
	rather than adding them all at once.  This avoids overflowing
	fixed limits on the length of a command line due to the
	expansion of *.dir/*.o being too long.  (It failed while trying to
	create library.split.a on IRIX 5.)
1996-03-18 15:40:35 +00:00
Fergus Henderson
24366ad708 Eliminate some unnecessary transitive interface dependencies.
Estimated hours taken: 0.5

Eliminate some unnecessary transitive interface dependencies.

compiler/modules.m:
	Change the generated `.int2' files: if they don't declare
	anything, or only declare abstract types, then they don't need
	to contain any `:- import_module' directives.
1996-03-17 12:28:27 +00:00
Fergus Henderson
b820e72c61 Add some stuff to the generated .d' and .dep' files for
Estimated hours taken: 1.5

compiler/modules.m:
	Add some stuff to the generated `.d' and `.dep' files for
	`--split-c-files', so that you can do `mmake foo.depend;
	mmake foo.split'.

compiler/Mmake:
	Remove rule for mercury_compile.split, since that rule is now done
	automatically.
1996-03-16 19:11:47 +00:00
Fergus Henderson
b2373fa050 Ensure that the .d' files generated by mc --generate-depencies' are
Estimated hours taken: 3

Ensure that the `.d' files generated by `mc --generate-depencies' are
the same as the ones produced by `mc -c'.

compiler/modules.m:
	- Avoid any possible duplication in the list of .int and .int2 files.
	- When searching for files in generate_dependencies,
	  if the `.m' file is not found, look for the `.int' file instead.
	  (Necessary to ensure that the `.d' files are identical.)
	- Ensure that `.int' and `.int2' files include a `:- interface'
	  declaration.  (Necessary to make the above change work.)
	- Fix a bug where I had swapped around the lists of interface and
	  implementation dependencies.
	- Add some more comments.
1996-03-16 16:50:21 +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
518eddba91 Fix a bug in the check for modules not exporting anything.
Estimated hours taken: 0.5

compiler/modules.m:
	Fix a bug in the check for modules not exporting anything.
	In the process, remove about 70 lines of unnecessary code.
1996-03-05 08:02:02 +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
837661243b This check-in combines several changes.
Estimated hours taken: 16

This check-in combines several changes.

* Change mercury_compile.pp so that it continues as far as possible
  after errors.

* Split the parts of mercury_compile.pp which handle module
  imports and exports into a new module called `modules.m'.

* Move the polymorphism.m pass after determinism analysis and unique mode
  checking.  This is because unique_modes.m may change the mode in which
  a unification predicate is called; as a result, we need to do mode
  checking, determinism analysis, and unique mode checking for new
  modes of unification predicates which are requested only after
  unique mode checking.  That won't work if we have done polymorphism.m
  in between mode checking and determinism analysis, since unification
  predicates are created without type_info arguments, and polymorphism.m
  cannot be run on just one predicate at a time.  (NB. I haven't changed
  unique_modes.m to actually do this yet.)
  I also had to move lambda.m after polymorphism.m, since polymorphism.m
  doesn't handle higher-order pred constants.

* Fix determinism analyis of simple_test unifications.
  The compiler would think that a unification of an inst such as
  `bound(foo)' with itself could fail.  The problem is that there is no
  `can_fail' field for simple_test unifications, so determinism.m just
  assumes that they can all fail.  I fixed this by changing modes.m to
  optimize away simple_tests that cannot fail.

* Fix determinism analyis of complicated_unifications.
  Again, determinism analysis just assumed that all complicated_unifications
  were semidet, because unify_proc.m always declared the out-of-line
  unification predicates to be semidet.  The fix was to pass the determinism
  inferred during mode analysis to unify_proc__request_unify.
  However, the '='(in, in) mode still needs to be semidet - its address is
  taken and put into the type_infos, and so it needs to have the
  right interface.  To handle det '='(in, in) unifications, the
  determinism also needs to be passed to unify_proc__search_mode_num,
  which will select the '='(in, in) mode only if the determinism is
  semidet.  (It would of course be better to optimize det '='(in, in)
  unifications to `true', but they are unlikely to occur much in real
  code anyway, so that is a low priority.)

* Compute the instmap deltas for all variables, not just the non-local
  variables of a goal, because variables which are not present in a goal
  can become nondet live if the goal is e.g. a nondet call.

mercury_compile.pp:
	- Rearrange the order of the passes as described above.
	- Add code to call check_undef_types and check_undef_modes
	  directly rather than via typecheck.m/modes.m.
	  Stop only if we get an undef error; if we get any other
	  sort of type/mode error, we can keep going.
	- Move lots of code to modules.m.

modules.m:
	New file, containing code moved from mercury_compile.pp.

polymorphism.m:
	Make sure that the goals that we generate have the correct
	determinism annotations.  Handle switches.
	Put back the call to lambda__transform_lambda.

lambda.m:
	Put back the stuff that allowed lambda.m to be called from
	polymorphism.m.

modes.m, unify_proc.m, call_gen.m, polymorphism.m,
	Pass the determinism of the unification to unify_proc__request_unify,
	so that it can declare the right determinism for the unification
	predicate.  (Previously it just assumed that all complicated
	unifications were `semidet'.)
	Also pass the determinism to unify_proc__search_mode_num, so that
	it will generate a new unification pred for deterministic '='(in,in)
	unifications rather than calling the existing semidet one.

modes.m, typecheck.m:
	Remove the calls to check_undefined_types and check_undefined_modes.
	They are now instead called directly from mercury_compile.pp.

modes.m:
	Don't call lambda__transform_lambda.
	Optimize away simple_tests that cannot fail.

modes.m, unique_modes.m:
	Call mode_info_get_instmap/2 rather than mode_info_get_vars_instmap/3.

mode_info.m:
	Delete the predicate mode_info_get_vars_instmap/3.
1996-01-22 00:55:15 +00:00