Files
mercury/compiler/transform_hlds.m
Julien Fischer 3a64ba36ef Implement trail usage analysis. This analysis performs a bottom-up analyise
Estimated hours taken: 30
Branches: main

Implement trail usage analysis.  This analysis performs a bottom-up analyise
of a program's call-graph to work out what parts of the program cannot modify
the trail.

Implement trail usage optimization for the high-level C backend.  Use the
information from the trail usage analysis to reduce the overhead of trailing
by omitting trailing primitives where they are not needed.  This diff
adds an initial version of this optimization (future versions will exploit
further opportunities that we currently ignore).

TODO: implement this optimization for the lowlevel backend.

This change adds two new foreign code attributes: `will_not_modify_trail'
and `may_modify_trail' that can be used to inform the compiler whether
foreign_procs modify the trail or not.

compiler/trailing_analysis.m:
	New module.  Perform a bottom-up analysis of the HLDS and annotate it
	with trail usage information.

compiler/hlds_module.m:
	Add a slot to the HLDS to store trail usage information for each
	(opt-imported) procedure in a module.

compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/add_pragma.m:
	Add a new pragma: trailing_info.  This pragma can only occur in .opt
	and .trans_opt files and is used to propagate trail usage information
	across module boundaries.

	Add two new foreign_proc attributes, `will_not_modify_trail' and
	`may_modify_trail', that allow foreign_procs to be annotated with
	trail usage information.

compiler/goal_form.m:
	Add a predicate that tests if a given goal modifies the trail.

compiler/add_trail_ops.m:
	When performing the source-to-source transformation used to implement
	trailing for the MLDS backend take account of trail usage information,
	so that we can omit calls to trailing primitives in some places.

compiler/options.m:
	Add two new options: `--analyse-trail-usage' and
	`--optimize-trail-usage', that enable the new analysis and
	optimization respectively.  For the moment they are both disabled by
	default.

	Unrelated change: fix the formatting of the termination2 options.

compiler/trans_opt.m:
	Write trailing_info pragmas to .trans_opt files.

compiler/mercury_compile.m:
	Run the new analysis if `--analyse-trail-usage' is given.

compiler/mercury_to_mercury.m:
	Output trailing_info pragmas.

compiler/transform_hlds.m:
compiler/recompilation.version.m:
	Minor changes to conform to the above.
2005-11-08 08:14:55 +00:00

97 lines
2.6 KiB
Mathematica

%-----------------------------------------------------------------------------%
% Copyright (C) 2002-2005 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
%
% transform_hlds: High-level transformations
% that are independent of the choice of back-end
% (the "middle" HLDS pass).
%
:- module transform_hlds.
:- interface.
:- import_module hlds.
:- import_module parse_tree.
:- import_module libs.
:- import_module mdbcomp.
%-----------------------------------------------------------------------------%
:- include_module intermod.
:- include_module trans_opt.
:- include_module dependency_graph.
:- include_module equiv_type_hlds.
:- include_module table_gen.
:- include_module complexity.
:- include_module (lambda).
:- include_module closure_analysis.
:- include_module termination.
:- include_module term_pass1.
:- include_module term_pass2.
:- include_module term_traversal.
:- include_module term_errors.
:- include_module term_norm.
:- include_module term_util.
:- include_module term_constr_main.
:- include_module term_constr_initial.
% Pass 1.
:- include_module term_constr_build.
:- include_module term_constr_fixpoint.
% Pass 2.
:- include_module term_constr_pass2.
% Other bits.
:- include_module term_constr_util.
:- include_module term_constr_data.
:- include_module term_constr_errors.
:- include_module post_term_analysis.
:- include_module exception_analysis.
:- include_module trailing_analysis.
% Optimizations (HLDS -> HLDS)
:- include_module higher_order.
:- include_module inlining.
:- include_module deforest.
:- include_module constraint.
:- include_module pd_cost.
:- include_module pd_debug.
:- include_module pd_info.
:- include_module pd_term.
:- include_module pd_util.
:- include_module delay_construct.
:- include_module unused_args.
:- include_module unneeded_code.
:- include_module accumulator.
:- include_module goal_store.
:- include_module dead_proc_elim.
:- include_module const_prop.
:- include_module loop_inv.
:- include_module size_prof.
:- include_module tupling.
:- include_module untupling.
:- include_module mmc_analysis.
% XXX The following modules are all currently unused.
:- include_module transform.
:- include_module lco.
%-----------------------------------------------------------------------------%
:- implementation.
:- import_module check_hlds.
:- end_module transform_hlds.
%-----------------------------------------------------------------------------%