Hi,


===================================================================

Estimated hours taken: 1
Branches: main

Preparing the field for adding CTGC into the compiler by starting to add the
structure sharing analysis. 

compiler/mercury_compile.m:
compiler/top_level.m:
compiler/transform_hlds.m:
	Add structure sharing analysis as a new pass of the mercury compiler. 

compiler/ctgc.m:
compiler/structure_sharing.analysis.m:
compiler/structure_sharing.m:
	New files. 



Index: compiler/ctgc.m
===================================================================
RCS file: compiler/ctgc.m
diff -N compiler/ctgc.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/ctgc.m	8 Dec 2005 13:09:40 -0000
@@ -0,0 +1,21 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 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.
+%-----------------------------------------------------------------------------%
+%
+% File: ctgc.m
+% Main authors: nancy
+%
+% Package grouping all the modules that are used for compile-time garbage
+% collection. 
+%
+%-----------------------------------------------------------------------------%
+
+:- module transform_hlds.ctgc.
+
+:- interface.
+
+:- include_module structure_sharing.
+
+:- end_module transform_hlds.ctgc.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.363
diff -u -d -r1.363 mercury_compile.m
--- compiler/mercury_compile.m	23 Nov 2005 04:44:05 -0000	1.363
+++ compiler/mercury_compile.m	8 Dec 2005 13:09:47 -0000
@@ -92,6 +92,7 @@
 :- import_module transform_hlds.lco.
 :- import_module transform_hlds.size_prof.
 :- import_module ll_backend.deep_profiling.
+:- import_module transform_hlds.ctgc.structure_sharing.analysis.
 
     % the LLDS back-end
 :- import_module ll_backend.saved_vars.
@@ -2392,7 +2393,10 @@
     maybe_dump_hlds(!.HLDS, 190, "magic", !DumpInfo, !IO),
 
     maybe_eliminate_dead_procs(Verbose, Stats, !HLDS, !IO),
-    maybe_dump_hlds(!.HLDS, 195, "dead_procs", !DumpInfo, !IO),
+    maybe_dump_hlds(!.HLDS, 192, "dead_procs", !DumpInfo, !IO),
+
+    maybe_data_structure_sharing_analysis(Verbose, Stats, !HLDS, !IO), 
+    maybe_dump_hlds(!.HLDS, 193, "structure_sharing", !DumpInfo, !IO), 
     
     % If we are compiling in a deep profiling grade then now rerun simplify.
     % The reason for doing this now is that we want to take advantage of any
@@ -3690,6 +3694,24 @@
         maybe_report_stats(Stats, !IO)
     ;
         Dead = no
+    ).
+
+:- pred maybe_data_structure_sharing_analysis(bool::in, bool::in,
+    module_info::in, module_info::out, io::di, io::uo) is det.
+
+maybe_data_structure_sharing_analysis(Verbose, Stats, !HLDS, !IO) :- 
+    globals__io_lookup_bool_option(data_structure_sharing_analysis, 
+        Sharing, !IO), 
+    (
+        Sharing = yes, 
+        maybe_write_string(Verbose, "% Data structure sharing analysis...\n",
+            !IO), 
+        maybe_flush_output(Verbose, !IO), 
+        data_structure_sharing_analysis(!HLDS, !IO), 
+        maybe_write_string(Verbose, "% done.\n", !IO),
+        maybe_report_stats(Stats, !IO)
+    ;
+        Sharing = no
     ).
 
 :- pred maybe_term_size_prof(bool::in, bool::in,
Index: compiler/structure_sharing.analysis.m
===================================================================
RCS file: compiler/structure_sharing.analysis.m
diff -N compiler/structure_sharing.analysis.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/structure_sharing.analysis.m	8 Dec 2005 13:10:12 -0000
@@ -0,0 +1,31 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 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.
+%-----------------------------------------------------------------------------%
+%
+% File: structure_sharing.analysis.m
+% Main authors: nancy
+%
+% Implementation of the data structure analysis. 
+%
+%-----------------------------------------------------------------------------%
+
+:- module transform_hlds.ctgc.structure_sharing.analysis.
+
+:- interface.
+
+:- import_module hlds__hlds_module.
+
+:- import_module io.
+
+:- pred data_structure_sharing_analysis(module_info::in, module_info::out, 
+		io__state::di, io__state::uo) is det.
+
+:- implementation. 
+
+:- import_module io. 
+
+data_structure_sharing_analysis(!HLDS, !IO). 
+
+:- end_module transform_hlds.ctgc.structure_sharing.analysis.
Index: compiler/structure_sharing.m
===================================================================
RCS file: compiler/structure_sharing.m
diff -N compiler/structure_sharing.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/structure_sharing.m	8 Dec 2005 13:10:12 -0000
@@ -0,0 +1,23 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 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.
+%-----------------------------------------------------------------------------%
+%
+% File: structure_sharing.m
+% Main authors: nancy
+%
+% A package grouping all the modules related to the data structure sharing 
+% analysis needed for data structure reuse. 
+%
+%-----------------------------------------------------------------------------%
+
+:- module transform_hlds.ctgc.structure_sharing.
+
+:- interface.
+
+:- include_module analysis. 
+
+:- import_module hlds.
+
+:- end_module transform_hlds.ctgc.structure_sharing.
Index: compiler/top_level.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/top_level.m,v
retrieving revision 1.6
diff -u -d -r1.6 top_level.m
--- compiler/top_level.m	19 Oct 2005 05:39:04 -0000	1.6
+++ compiler/top_level.m	8 Dec 2005 13:10:12 -0000
@@ -19,6 +19,8 @@
 :- import_module mode_robdd.
 :- import_module parse_tree.
 :- import_module transform_hlds.
+:- import_module transform_hlds.ctgc.
+:- import_module transform_hlds.ctgc.structure_sharing.
 
 % Back-ends that we currently use or plan to use.
 :- import_module aditi_backend.
Index: compiler/transform_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/transform_hlds.m,v
retrieving revision 1.20
diff -u -d -r1.20 transform_hlds.m
--- compiler/transform_hlds.m	8 Nov 2005 08:14:55 -0000	1.20
+++ compiler/transform_hlds.m	8 Dec 2005 13:10:12 -0000
@@ -41,6 +41,8 @@
    :- include_module term_norm.
    :- include_module term_util.
 
+:- include_module transform_hlds.ctgc.
+
 :- include_module term_constr_main.
     :- include_module term_constr_initial.
 		% Pass 1.
