mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 13:55:07 +00:00
Estimated hours taken: 40 Branches: main Optimize calls that would be tail calls in Prolog but are followed by construction unifications in Mercury: last call modulo construction. For now, the optimization is available only for the LLDS backend. compiler/lco.m: Turn this module from a placeholder to a real implementation of the optimization. compiler/hlds_goal.m: Allow lco.m to attach to construction unifications a note that says that certain arguments, instead of being filled in by the unification, should have their addresses taken and stored in the corresponding variables. Group this note together with the note that asks for term size profiling to avoid an increase in the sizes of goals in the compiler in most cases. compiler/hlds_pred.m: Provide a predicate for setting the name of a predicate after its creation. This functionality is used by lco.m. Extend the pred_transformation part of the pred_origin type to allow it to express that a procedure was created by lco.m. List the new primitive store_at_ref as a no-typeinfo builtin. Fix some problems with indentation. compiler/layout_out.m: Handle the new pred_transformation. compiler/unify_gen.m: When processing construction unifications that have the new feaure turned on, perform the requested action. Fix some departures from coding style. Shorten lines by deleting unnecessary module qualifications. Add some auxiliary predicates to make the code easier to read. compiler/var_locn.m: Fix an earlier oversight: when materializing variables inside rvals and lvals, look inside memory references too. Previously, the omission didn't matter, since we didn't generate such references, but now we do. Fix some departures from coding style. compiler/llds_out.m: Fix some old XXXs in code handling memory references. We didn't use to generate such references, but now we do. Move some functionality here from code_aux.m. compiler/code_info.m: Provide some primitive operations needed by the new code in var_locn.m. Delete an unneeded predicate. compiler/options.m: Rename the existing option optimize_constructor_last_call as optimize_constructor_last_call_accumulator, since that optimization is done by accumulator.m. Make optimize_constructor_last_call be the option that calls for the new optimization. compiler/handle_options.m: Handle the implications of the new option. compiler/mercury_compile.m: Invoke the lco module by its new interface. librrary/private_builtin.m: Add a new primitive operation, store_at_ref, for use by the new optimization. Switch the module to four-space indentation. compiler/add_clause.m: Comment out the warning for clauses for builtin, since this is needed to bootstrap the addition of the new builtin. compiler/term_constr_initial.m: Handle the new builtin. compiler/accumulator.m: Conform to the change in options. compiler/builtin_ops.m: Provide a third template for builtins, for use by store_at_ref. Convert the file to four-space indentation. compiler/call_gen.m: Generate code following the new builtin template. compiler/rl_exprn.m: Minor changes to conform to the changes in builtin templates. compiler/quantification.m: Minor changes to conform to the changes in construct unifications. Don't make the "get" predicates operating on quantification_infos to return the "new" quantification_info: it is always the same as the old one. compiler/aditi_builtin_ops.m: compiler/common.m: compiler/deep_profiling.m: compiler/higher_order.m: compiler/hlds_out.m: compiler/lambda.m: compiler/magic_util.m: compiler/ml_unify_gen.m: compiler/modecheck_unify.m: compiler/polymorphism.m: compiler/size_prof.m: Minor changes to conform to the changes in construct unifications. compiler/dependency_graph.m: Add a new predicate to recompute the dependency information, even if a previous (and possibly now inaccurate) version is present. Change the interface to make it clearer, by changing bools into types specific to the situation. Convert the file to four-space indentation. compiler/mode_constraints.m: Minor changes to conform to the changes in dependency_graph.m. compiler/code_aux.m: Delete this module. Half its functionality has been moved into llds_out.m, half to middle_rec.m (its only user). compiler/goal_form.m: Move the predicates in this module that are used only by middle_rec.m to middle_rec.m. Convert the file to four-space indentation. compiler/goal_util.m: compiler/det_util.m: Move update_instmap from det_util to goal_util, since it is usefulness extends beyond determinism analysis. Convert det_util.m to four-space indentation. compiler/middle_rec.m: Move here the code required only here from code_aux and goal_form. Update the moved code for the changes in construct unifications. The updates are specific to middle_rec.m: they wouldn't be of use to other modules. They basically say that any code that takes the addresses of fields cannot be handled by middle_rec.m. compiler/code_gen.m: compiler/det_analysis.m: compiler/live_vars.m: compiler/ll_backend.m: compiler/loop_inv.m: compiler/switch_detection.m: compiler/switch_gen.m: compiler/notes/compiler_design.html: Minor changes to conform to the deletion of code_aux.m and/or the movement of code from det_util to goal_util.m. compiler/opt_debug.m: Print info for vars in rvals. compiler/hlds_module.m: Convert a lambda to an explicit predicate to make some code easier to read. Switch the module to four-space indentation.
100 lines
3.0 KiB
Mathematica
100 lines
3.0 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 2002,2003-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.
|
|
%-----------------------------------------------------------------------------%
|
|
%
|
|
% This package contains the low-level back-end
|
|
% (a.k.a. the LLDS back-end).
|
|
%
|
|
:- module ll_backend.
|
|
:- interface.
|
|
|
|
:- import_module aditi_backend. % XXX for rl_file, used in llds_out.
|
|
:- import_module hlds.
|
|
:- import_module mdbcomp.
|
|
:- import_module parse_tree.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
% Pre-passes to transform or annotate the HLDS
|
|
:- include_module deep_profiling. % transform
|
|
:- include_module saved_vars. % transform
|
|
:- include_module stack_opt. % transform
|
|
:- include_module follow_code. % transform
|
|
:- include_module liveness. % annotate
|
|
:- include_module stack_alloc. % annotate
|
|
:- include_module live_vars. % annotate
|
|
:- include_module follow_vars. % annotate
|
|
:- include_module store_alloc. % annotate
|
|
|
|
% The llds data structure itself
|
|
:- include_module llds.
|
|
:- include_module code_util.
|
|
|
|
% The HLDS->LLDS code generator.
|
|
:- include_module code_gen.
|
|
:- include_module ite_gen.
|
|
:- include_module call_gen.
|
|
:- include_module disj_gen.
|
|
:- include_module unify_gen.
|
|
:- include_module commit_gen.
|
|
:- include_module switch_gen.
|
|
:- include_module dense_switch.
|
|
:- include_module lookup_switch.
|
|
:- include_module string_switch.
|
|
:- include_module tag_switch.
|
|
:- include_module pragma_c_gen.
|
|
:- include_module par_conj_gen.
|
|
:- include_module middle_rec.
|
|
:- include_module trace.
|
|
|
|
:- include_module code_info.
|
|
:- include_module exprn_aux.
|
|
:- include_module continuation_info.
|
|
:- include_module var_locn.
|
|
|
|
% An alternative HLDS->LLDS code generator for fact tables.
|
|
:- include_module fact_table.
|
|
|
|
%:- module llds_data.
|
|
:- include_module ll_pseudo_type_info.
|
|
:- include_module layout.
|
|
:- include_module stack_layout.
|
|
:- include_module prog_rep.
|
|
:- include_module global_data.
|
|
%:- end_module llds_data.
|
|
|
|
% LLDS->LLDS optimization passes.
|
|
:- include_module optimize.
|
|
:- include_module jumpopt.
|
|
:- include_module dupelim.
|
|
:- include_module dupproc.
|
|
:- include_module frameopt.
|
|
:- include_module delay_slot.
|
|
:- include_module labelopt.
|
|
:- include_module peephole.
|
|
:- include_module use_local_vars.
|
|
:- include_module wrap_blocks.
|
|
:- include_module livemap.
|
|
:- include_module reassign.
|
|
:- include_module basic_block.
|
|
:- include_module opt_util.
|
|
:- include_module opt_debug.
|
|
|
|
% The LLDS->C output phase.
|
|
:- include_module transform_llds.
|
|
:- include_module llds_out.
|
|
:- include_module layout_out.
|
|
:- include_module rtti_out.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module check_hlds. % needed for type_util, mode_util etc
|
|
:- import_module backend_libs.
|
|
:- import_module libs.
|
|
|
|
:- end_module ll_backend.
|
|
|
|
%-----------------------------------------------------------------------------%
|