[m-rev.] for review: make compiler use sub-modules

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 8 01:54:32 AEDT 2002


Since Zoltan requested it, here's an extract from the full diff, showing
just the new files that I've added.  These are taken from the sub-modules
of the `mc' module in my original post.

compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
	New files.  One module for each of the major components of the
	Mercury compiler.  These modules contain (as separate sub-modules)
	all the other modules in the Mercury compiler, except gcc.m and
	mlds_to_gcc.m.

Workspace: /home/ceres/fjh/ws-ceres3/mercury
Index: compiler/aditi_backend.m
===================================================================
RCS file: compiler/aditi_backend.m
diff -N compiler/aditi_backend.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/aditi_backend.m	6 Mar 2002 00:06:05 -0000
@@ -0,0 +1,62 @@
+%-----------------------------------------------------------------------------%
+%
+% The Aditi back-end
+%
+:- module aditi_backend.
+:- interface.
+:- import_module transform_hlds, check_hlds. % are these needed?
+:- import_module hlds, parse_tree, libs.
+
+%:- import_module aditi_hlds, aditi_codegen, aditi_rl_out.
+
+%
+% Phase 4-rl: Aditi-related HLDS transformations
+%
+%:- module aditi_hlds.
+%   :- interface.
+   :- include_module dnf.
+   :- include_module magic, magic_util.
+   :- include_module context.
+%:- end_module aditi_hlds.
+
+%
+% The Aditi-RL type itself.
+%
+:- include_module rl.
+:- include_module rl_dump.
+
+%
+% Phase 5-rl: The Aditi RL code generator
+%
+%:- module aditi_codegen.
+%   :- interface.
+   :- include_module rl_gen.
+   :- include_module rl_info.
+   :- include_module rl_relops.
+%:- end_module aditi_codegen.
+
+%
+% Phase 6-rl: Low-level (RL -> RL) optimizations
+%
+:- include_module rl_opt.
+   :- include_module rl_block, rl_analyse, rl_liveness, rl_loop, rl_block_opt.
+   :- include_module rl_key, rl_sort, rl_stream.
+
+%
+% Phase 7-rl: Emit RL bytecodes.
+%
+%:- module aditi_rl_out.
+   :- include_module rl_out, rl_exprn, rl_code, rl_file.
+%:- end_module aditi_rl_out.
+       
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+	% aditi_backend__rl_exprn uses ll_backend__llds
+	% and backend_libs__builtin_ops.
+:- import_module ll_backend.
+:- import_module backend_libs.
+
+:- end_module aditi_backend.
+
+%-----------------------------------------------------------------------------%
Index: compiler/backend_libs.m
===================================================================
RCS file: compiler/backend_libs.m
diff -N compiler/backend_libs.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/backend_libs.m	6 Mar 2002 00:21:49 -0000
@@ -0,0 +1,29 @@
+%-----------------------------------------------------------------------------%
+%
+% Back-end libraries.
+%
+% This package contains utility modules that are each used by
+% several different back-ends.
+%
+:- module backend_libs.
+:- interface.
+:- import_module transform_hlds, check_hlds. % are these needed?
+:- import_module hlds, parse_tree, libs.
+
+% modules that provide functionality used by several different back-ends
+:- include_module builtin_ops.
+:- include_module bytecode_data.
+:- include_module c_util.
+:- include_module code_model.
+:- include_module switch_util.
+:- include_module rtti, type_ctor_info, pseudo_type_info, base_typeclass_info.
+:- include_module foreign, export.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+:- import_module ll_backend. % XXX for llds_out__name_mangle.
+
+:- end_module backend_libs.
+
+%-----------------------------------------------------------------------------%
Index: compiler/bytecode_backend.m
===================================================================
RCS file: compiler/bytecode_backend.m
diff -N compiler/bytecode_backend.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/bytecode_backend.m	6 Mar 2002 00:08:17 -0000
@@ -0,0 +1,22 @@
+%-----------------------------------------------------------------------------%
+%
+% Phase 5-bc: The bytecode generator
+%
+:- module bytecode_backend.
+:- interface.
+:- import_module transform_hlds, check_hlds. % are these needed?
+:- import_module hlds, parse_tree, libs, backend_libs.
+
+%-----------------------------------------------------------------------------%
+
+:- include_module bytecode, bytecode_gen.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+	% bytecode_gen uses ll_backend__call_gen.m
+:- import_module ll_backend.
+
+:- end_module bytecode_backend.
+
+%-----------------------------------------------------------------------------%
Index: compiler/check_hlds.m
===================================================================
RCS file: compiler/check_hlds.m
diff -N compiler/check_hlds.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/check_hlds.m	6 Mar 2002 00:05:12 -0000
@@ -0,0 +1,54 @@
+%-----------------------------------------------------------------------------%
+%
+% Phase 3: Semantic analysis and error checking
+%	(the "front end" HLDS pass).
+%
+
+:- module check_hlds.
+:- interface.
+:- import_module hlds, parse_tree, libs.
+:- import_module backend_libs. % for base_typeclass_info, etc.
+%:- import_module check_hlds__type_analysis, check_hlds__mode_analysis.
+
+%-----------------------------------------------------------------------------%
+
+% Type checking
+%:- module type_analysis.
+    :- include_module check_typeclass, typecheck, purity, post_typecheck.
+    :- include_module type_util.
+%:- end_module type_analysis.
+
+% Polymorphism transformation.
+:- include_module polymorphism.
+:- include_module clause_to_proc.
+
+% Mode analysis
+%:- module mode_analysis.
+   :- include_module modes, modecheck_unify, modecheck_call.
+   :- include_module mode_info, delay_info, inst_match.
+   :- include_module inst_util, mode_errors, mode_util, mode_debug.
+   :- include_module unique_modes.
+   :- include_module unify_proc.
+%:- end_module mode_analysis.
+
+% Indexing and determinism analysis
+:- include_module switch_detection, cse_detection, det_analysis.
+:- include_module det_report, det_util.
+
+% Stratification.
+:- include_module stratify.
+
+% Warnings about simple code
+:- include_module simplify, common.
+
+:- include_module goal_path.
+
+%-----------------------------------------------------------------------------%
+          
+:- implementation.
+:- import_module transform_hlds. % for pd_cost, etc.
+:- import_module ll_backend. % XXX for code_util, code_aux
+
+:- end_module check_hlds.
+
+%-----------------------------------------------------------------------------%
Index: compiler/hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds.m,v
retrieving revision 1.205
diff -u -d -r1.205 hlds.m
--- compiler/hlds.m	27 Jul 1997 15:00:26 -0000	1.205
+++ compiler/hlds.m	6 Mar 2002 00:22:55 -0000
@@ -1,19 +1,54 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1993-1996 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.
+%
+% Phase 2: build the HLDS.
+%	This phase also includes quite a bit of error checking
+%	and a tiny bit of semantic analysis (quantification).
+%
+
+:- module hlds.
+:- interface.
+:- import_module parse_tree, libs.
+:- import_module check_hlds. % needed for unify_proc__unify_proc_id,
+				 % etc.
+:- import_module transform_hlds. % needed for term_util, etc.
+:- import_module backend_libs. % XXX needed for rtti, foreign, etc.
+:- import_module ll_backend. % XXX needed for `llds__lval',
+				 % which is used in various annotations
+				 % in the HLDS (stack_slots, follow_vars, etc.)
+
 %-----------------------------------------------------------------------------%
 
-% HLDS - The High-Level Data Structure.
+% The HLDS data structure itself
+:- include_module hlds_data, hlds_goal, hlds_pred, hlds_module.
+:- include_module instmap.
+:- include_module (assertion), special_pred.
 
-% Main authors: fjh, conway.
+% Modules for creating the HLDS
+:- include_module make_hlds, make_tags.
+:- include_module quantification.
 
-% This file used to contain the data types for the high-level data structure.
-% The definitions have now been split into several files:
-%
-%	hlds_data
-%	hlds_goal
-%	hlds_pred
-%	hlds_module
+% Modules for pretty-printing it.
+:- include_module hlds_out.
 
-:- module hlds.
+% Miscellaneous utilities.
+:- include_module passes_aux, error_util.
+:- include_module goal_util. % XXX goal_util imports code_aux.m
+:- include_module hlds_code_util.	% XXX currently code_util.m
+
+%:- module smart_recompilation.
+    :- include_module recompilation.
+    :- include_module recompilation_check.
+    :- include_module recompilation_usage.
+    :- include_module recompilation_version.
+    :- include_module timestamp.
+%:- module smart_recompilation.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+:- import_module aditi_backend. % XXX for rl__get_entry_proc_name,
+				    % which is used by hlds_out.m to dump
+				    % aditi_call goals.
+:- end_module hlds.
+
+%-----------------------------------------------------------------------------%
Index: compiler/libs.m
===================================================================
RCS file: compiler/libs.m
diff -N compiler/libs.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/libs.m	6 Mar 2002 00:03:45 -0000
@@ -0,0 +1,19 @@
+%-----------------------------------------------------------------------------%
+%
+% This package contains general utilities that are used by other packages.
+%
+
+:- module libs.
+:- interface.
+:- import_module ll_backend. % XXX trace_params depends on llds__trace_port.
+
+% option handling
+:- include_module globals, options, handle_options, trace_params.
+
+% generic algorithms and data structures that are not
+% quite useful enough to go in the standard library
+:- include_module tree, graph_colour, atsort.
+
+:- end_module libs.
+
+%-----------------------------------------------------------------------------%
Index: compiler/ll_backend.m
===================================================================
RCS file: compiler/ll_backend.m
diff -N compiler/ll_backend.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/ll_backend.m	6 Mar 2002 00:53:49 -0000
@@ -0,0 +1,85 @@
+%-----------------------------------------------------------------------------%
+%
+% Phase 5c: The low-level code generator
+%
+:- module ll_backend.
+:- interface.
+:- import_module transform_hlds, check_hlds. % are these needed?
+:- import_module hlds, parse_tree, libs, backend_libs.
+:- import_module aditi_backend. % XXX for rl_file, used in llds_out.
+
+%-----------------------------------------------------------------------------%
+
+% Pre-passes to transform or annotate the HLDS
+% (XXX these are not listed in right order)
+:- include_module saved_vars.	% transform
+:- include_module arg_info.		% annotate
+:- include_module liveness.		% annotate
+:- include_module live_vars.		% annotate
+:- include_module follow_code.	% transform
+:- include_module follow_vars.	% annotate
+:- include_module store_alloc.	% annotate
+:- include_module deep_profiling. % transform
+
+% The llds data structure itself
+:- include_module llds.
+:- include_module code_util. % XXX
+
+% The HLDS->LLDS code generator.
+:- include_module code_gen.
+   :- include_module ite_gen, call_gen, disj_gen, unify_gen, 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, par_conj_gen.
+   :- include_module middle_rec.
+   :- include_module trace.
+
+   :- include_module code_info.
+   :- include_module code_exprn.
+   :- include_module exprn_aux.
+   :- include_module code_aux. % XXX
+   :- include_module continuation_info.
+   :- include_module var_locn.
+
+% An alternative HLDS->LLDS code generator for fact tables.
+:- include_module fact_table.
+
+%:- module llds_rtti.
+   :- include_module ll_pseudo_type_info.
+   :- include_module layout.
+   :- include_module stack_layout, prog_rep.
+   :- include_module static_term.
+%:- end_module llds_rtti.
+
+% LLDS->LLDS optimization passes.
+:- include_module optimize.
+   :- include_module jumpopt, dupelim, frameopt, delay_slot, labelopt.
+:- include_module peephole.
+   :- include_module wrap_blocks, use_local_vars.
+%   :- include_module value_number.
+%      :- include_module vn_block.
+%      :- include_module vn_cost.
+%      :- include_module vn_debug.
+%      :- include_module vn_filter.
+%      :- include_module vn_flush.
+%      :- include_module vn_order.
+%      :- include_module vn_temploc.
+%      :- include_module vn_util.
+%      :- include_module vn_verify.
+%      :- include_module vn_type.
+%      :- include_module vn_table.
+   :- include_module llds_common.
+   :- include_module livemap, basic_block, opt_util, opt_debug.
+                
+% The LLDS->C output phase.
+:- include_module transform_llds.
+:- include_module llds_out.
+:- include_module layout_out.
+:- include_module rtti_out.
+  
+:- end_module ll_backend.
+
+%-----------------------------------------------------------------------------%
Index: compiler/ml_backend.m
===================================================================
RCS file: compiler/ml_backend.m
diff -N compiler/ml_backend.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/ml_backend.m	6 Mar 2002 00:06:18 -0000
@@ -0,0 +1,58 @@
+%-----------------------------------------------------------------------------%
+%
+% The medium-level code generator
+%
+:- module ml_backend.
+:- interface.
+:- import_module transform_hlds, check_hlds. % are these needed?
+:- import_module hlds, parse_tree, libs, backend_libs.
+:- import_module ll_backend. % XXX needed for llds_out__name_mangle, etc.
+
+%-----------------------------------------------------------------------------%
+
+:- include_module mlds.
+:- include_module ml_util.
+
+% Phase 4-ml: MLDS-specific HLDS to HLDS transformations and annotations.
+:- include_module add_heap_ops, add_trail_ops. % transformations
+:- include_module mark_static_terms. % annotation
+
+% Phase 5-ml: compile HLDS to MLDS
+:- include_module ml_code_gen.
+   :- include_module ml_type_gen.
+   :- include_module ml_call_gen.
+   :- include_module ml_unify_gen, ml_closure_gen.
+   :- include_module ml_switch_gen.
+      :- include_module ml_string_switch, ml_tag_switch, ml_simplify_switch.
+:- include_module ml_code_util.
+:- include_module rtti_to_mlds.
+
+% Phase 6-ml: MLDS -> MLDS transformations
+:- include_module ml_elim_nested.
+:- include_module ml_tailcall.
+:- include_module ml_optimize.
+
+% Phase 7-ml: compile MLDS to target code
+
+% MLDS->C back-end
+:- include_module mlds_to_c.
+
+% MLDS->Assembler back-end
+:- include_module maybe_mlds_to_gcc.
+% :- include_module mlds_to_gcc, gcc.
+
+% MLDS->Java back-end
+:- include_module mlds_to_java, java_util.
+
+% MLDS->.NET CLR back-end
+:- include_module mlds_to_il.
+:- include_module mlds_to_ilasm.
+:- include_module mlds_to_csharp.
+:- include_module mlds_to_mcpp.
+:- include_module ilds.
+:- include_module ilasm.
+:- include_module il_peephole.
+
+:- end_module ml_backend.
+
+%-----------------------------------------------------------------------------%
Index: compiler/parse_tree.m
===================================================================
RCS file: compiler/parse_tree.m
diff -N compiler/parse_tree.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/parse_tree.m	6 Mar 2002 00:02:55 -0000
@@ -0,0 +1,56 @@
+%-----------------------------------------------------------------------------%
+%
+% Phase 1: create the Parse Tree.
+%
+
+:- module parse_tree.
+:- interface.
+:- import_module libs.
+:- import_module hlds. % XXX for hlds_data__cons_id
+:- import_module backend_libs. % XXX for `foreign'
+
+% The parse tree data type itself.
+:- include_module prog_data, (inst).
+	% XXX inst uses hlds_data__cons_id
+
+% The parser.
+:- include_module prog_io.
+   :- include_module prog_io_goal, prog_io_dcg, prog_io_pragma.
+   :- include_module prog_io_typeclass, prog_io_util.
+
+% Pretty-printers.
+:- include_module prog_out, mercury_to_mercury.
+
+% Utility routines.
+:- include_module prog_util.
+
+% Transformations that act on the parse tree,
+% and stuff relating to the module system.
+:- include_module equiv_type.
+:- include_module modules, module_qual.
+
+% (Note that intermod and trans_opt also contain routines that
+% act on the parse tree, but those modules are considered part
+% of the HLDS transformations package.)
+% :- include_module intermod, trans_opt.
+
+% :- implementation.
+
+% XXX lots of stuff uses hlds_data__type_id and type_util.m.
+% XXX modules.m uses llds_out for the init names.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module check_hlds.     % XXX for type_util.m
+:- import_module transform_hlds. % XXX for write_pragma_termination_info
+				     % in termination.m, which is used by
+				     % mercury_to_mercury.m
+:- import_module ll_backend.     % XXX for llds_out.m, which is used
+				     % by modules__append_to_init_list,
+				     % which creates the LLDS and RL
+				     % initialization code.
+:- end_module parse_tree.
+
+%-----------------------------------------------------------------------------%
Index: compiler/top_level.m
===================================================================
RCS file: compiler/top_level.m
diff -N compiler/top_level.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/top_level.m	6 Mar 2002 00:21:56 -0000
@@ -0,0 +1,22 @@
+%-----------------------------------------------------------------------------%
+
+:- module top_level.
+:- interface.
+
+% the front-ends
+:- import_module parse_tree, hlds, check_hlds, transform_hlds.
+
+% back-ends that we currently use or plan to use
+:- import_module aditi_backend, ll_backend, ml_backend.
+
+% obsolete or incomplete back-ends
+:- import_module bytecode_backend.
+
+% misc utilities
+:- import_module libs, backend_libs.
+
+:- include_module mercury_compile.
+
+:- end_module top_level.
+
+%-----------------------------------------------------------------------------%
Index: compiler/transform_hlds.m
===================================================================
RCS file: compiler/transform_hlds.m
diff -N compiler/transform_hlds.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/transform_hlds.m	6 Mar 2002 00:07:35 -0000
@@ -0,0 +1,55 @@
+%-----------------------------------------------------------------------------%
+%          
+% Phase 4: High-level transformations
+%	that are independent of the choice of back-end
+%	(the "middle" HLDS pass).
+%  
+
+:- module transform_hlds.
+:- interface.
+:- import_module check_hlds. % is this needed?
+:- import_module hlds, parse_tree, libs.
+
+%-----------------------------------------------------------------------------%
+
+:- include_module intermod, trans_opt.
+
+:- include_module dependency_graph.	% XXX imports llds (for profiling labels)
+
+:- include_module table_gen.
+
+:- include_module (lambda).
+
+:- include_module termination.
+   :- include_module term_pass1, term_pass2, term_traversal, term_errors.
+   :- include_module term_util.
+   :- include_module lp. % this could alternatively go in the `libs' module
+
+% Optimizations (HLDS -> HLDS)
+:- include_module higher_order.
+:- include_module inlining.
+:- include_module deforest.
+   :- include_module pd_cost, pd_debug, pd_info, 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.
+
+% XXX The following modules are all currently unused.
+:- include_module constraint, transform.
+:- include_module excess.
+:- include_module lco.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+:- import_module ll_backend. % XXX for code_util, code_aux
+:- import_module backend_libs. % XXX for rtti
+
+:- end_module transform_hlds.
+
+%-----------------------------------------------------------------------------%
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list