mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-05-01 09:14:08 +00:00
Estimated hours taken: 4 Branches: main Reduce the dependence of earlier parts of the compiler on the later ones. Unnecessary import_module declarations in top level modules such as hlds.m cause unnecessary recompilations when adding new types in later modules, such as submodules of ll_backend.m. This change reduces the number of such unnecessary imports. There are no changes in algorithms, only functionality being moved around. compiler/code_model.m: Change this module from being a submodule of backend_libs.m to being a submodule of hlds.m, since nothing in it is dependent on any backend. compiler/arg_info.m: compiler/code_util.m: Change arg_info.m from being a submodule of ll_backend.m to being a submodule of hlds.m, since most of it is applicable to all current and foreseeable backends. Move the one exported predicate that is ll_backend dependent, and its support predicates, to code_util.m. compiler/backend_libs.m: compiler/ll_backend.m: compiler/hlds.m: Update include_module declarations in accordance with the above. compiler/prog_data.m: compiler/term_util.m: Instead of defining two separate types for holding argument size and termination information, one including HLDS-specific information (in term_util.m) and one not (in prog_data.m), use a polymorphic type defined in prog_data.m and two monomorphic instances. compiler/termination.m: compiler/mercury_to_mercury.m: Change the predicates for writing out argument size and termination information to handle the polymorphic type (we don't need special handling of the monomorphic versions), and move them from termination.m to mercury_to_mercury.m, since this allows us to avoid some undesirable dependencies. compiler/base_typeclass_info.m: compiler/hlds_code_util.m: Move the predicate make_instance_string from base_typeclass_info.m to hlds_code_util.m, again because it allows us to remove some undesirable dependencies. compiler/top_level.m: compiler/backend_libs.m: compiler/check_hlds.m: compiler/hlds.m: compiler/ll_backend.m: compiler/parse_tree.m: compiler/transform_hlds.m: Delete some import_module declarations of other top level modules in these top level modules. Some imports were totally unnecessary. Some imports were useful in only a small minority of submodules; those submodules now import the necessary top level modules directly. Move remaining import_module declarations to the implementation section where this is feasible. Where we still need to import modules we ideally shouldn't, note why. compiler/*.m: Update imports of code_util and arg_info. In some cases, import top level modules no longer imported by the parent module. In some cases, delete unnecessary imports.
73 lines
2.2 KiB
Mathematica
73 lines
2.2 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 1997-1998, 2003-2004 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.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% File: commit_gen.m
|
|
%
|
|
% Main authors: conway, fjh, zs.
|
|
%
|
|
% The predicates of this module generate code for performing commits.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module ll_backend__commit_gen.
|
|
|
|
:- interface.
|
|
|
|
:- import_module hlds__code_model.
|
|
:- import_module hlds__hlds_goal.
|
|
:- import_module ll_backend__code_info.
|
|
:- import_module ll_backend__llds.
|
|
|
|
:- pred commit_gen__generate_commit(code_model::in, hlds_goal::in,
|
|
code_tree::out, code_info::in, code_info::out) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module libs__tree.
|
|
:- import_module ll_backend__code_gen.
|
|
|
|
:- import_module std_util, require.
|
|
|
|
commit_gen__generate_commit(OuterCodeModel, Goal, Code) -->
|
|
{ Goal = _ - InnerGoalInfo },
|
|
{ goal_info_get_code_model(InnerGoalInfo, InnerCodeModel) },
|
|
(
|
|
{ OuterCodeModel = model_det },
|
|
(
|
|
{ InnerCodeModel = model_det },
|
|
code_gen__generate_goal(InnerCodeModel, Goal, Code)
|
|
;
|
|
{ InnerCodeModel = model_semi },
|
|
{ error("semidet model in det context") }
|
|
;
|
|
{ InnerCodeModel = model_non },
|
|
code_info__prepare_for_det_commit(CommitInfo,
|
|
PreCommit),
|
|
code_gen__generate_goal(InnerCodeModel, Goal, GoalCode),
|
|
code_info__generate_det_commit(CommitInfo, Commit),
|
|
{ Code = tree(PreCommit, tree(GoalCode, Commit)) }
|
|
)
|
|
;
|
|
{ OuterCodeModel = model_semi },
|
|
(
|
|
{ InnerCodeModel = model_det },
|
|
code_gen__generate_goal(InnerCodeModel, Goal, Code)
|
|
;
|
|
{ InnerCodeModel = model_semi },
|
|
code_gen__generate_goal(InnerCodeModel, Goal, Code)
|
|
;
|
|
{ InnerCodeModel = model_non },
|
|
code_info__prepare_for_semi_commit(CommitInfo,
|
|
PreCommit),
|
|
code_gen__generate_goal(InnerCodeModel, Goal, GoalCode),
|
|
code_info__generate_semi_commit(CommitInfo, Commit),
|
|
{ Code = tree(PreCommit, tree(GoalCode, Commit)) }
|
|
)
|
|
;
|
|
{ OuterCodeModel = model_non },
|
|
code_gen__generate_goal(InnerCodeModel, Goal, Code)
|
|
).
|