[m-rev.] diff: eliminating comp_gen_c_data

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon May 8 13:31:40 AEST 2006


This diff simplifies the way we handle compiler-generate data in LLDS grades.
We used to wrap several kinds of data structures up in different function
symbols so they could be treated as values of a single type, comp_gen_c_data,
but then we divided them up into the original caregories again when creating
the output .c file. We now instead keep the various kinds of static data
separate all the way through.

compiler/llds.m:
	Delete the comp_gen_c_data type. Replace the single list of
	comp_gen_c_data items in the representation of C files with four
	lists, one for each kind of static data.

compiler/llds_out.m:
	Make the simplifications made possible by the change to llds.m.

	Output references to MR_COMMON and MR_TAG_COMMON instead of MR_XCOMMON
	and MR_TAG_XCOMMON, since the change to make these equivalent should
	have been installed on all our machines by now.

compiler/code_info.m:
compiler/global_data.m:
compiler/stack_layout.m:
	Modify data structures to contain data of specific types instead
	comp_gen_c_datas, and modify the code accordingly. This mostly means
	avoiding now redundant operations to wrap data structures with
	comp_gen_c_data's function symbols.

compiler/mercury_compile.m:
	Build c_file structures with four lists of distinct types instead
	of appending them all to get a single giant list of comp_gen_c_datas.

compiler/transform_llds.m:
	Conform to the change to llds.m.

compiler/layout.m:
compiler/layout_out.m:
	Minor style improvements.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.321
diff -u -b -r1.321 code_info.m
--- compiler/code_info.m	3 May 2006 06:46:14 -0000	1.321
+++ compiler/code_info.m	7 May 2006 03:31:39 -0000
@@ -39,6 +39,7 @@
 :- import_module libs.globals.
 :- import_module ll_backend.continuation_info.
 :- import_module ll_backend.global_data.
+:- import_module ll_backend.layout.
 :- import_module ll_backend.llds.
 :- import_module ll_backend.trace.
 :- import_module mdbcomp.prim_data.
@@ -182,7 +183,7 @@
     % Get the global static data structures that have
     % been created during code generation for closure layouts.
     %
-:- pred get_closure_layouts(code_info::in, list(comp_gen_c_data)::out) is det.
+:- pred get_closure_layouts(code_info::in, list(layout_data)::out) is det.
 
 :- pred get_max_reg_in_use_at_trace(code_info::in, int::out) is det.
 
@@ -246,7 +247,7 @@
 :- pred set_temp_content_map(map(lval, slot_contents)::in,
     code_info::in, code_info::out) is det.
 
-:- pred set_closure_layouts(list(comp_gen_c_data)::in,
+:- pred set_closure_layouts(list(layout_data)::in,
     code_info::in, code_info::out) is det.
 
 :- pred get_closure_seq_counter(code_info::in, counter::out) is det.
@@ -395,7 +396,7 @@
 
                 closure_layout_seq :: counter,
 
-                closure_layouts     :: list(comp_gen_c_data),
+                closure_layouts     :: list(layout_data),
                                     % Closure layout structures generated
                                     % by this procedure.
 
@@ -530,93 +531,54 @@
 
 %---------------------------------------------------------------------------%
 
-get_globals(CI,
-    CI ^ code_info_static ^ globals).
-get_module_info(CI,
-    CI ^ code_info_static ^ module_info).
-get_pred_id(CI,
-    CI ^ code_info_static ^ pred_id).
-get_proc_id(CI,
-    CI ^ code_info_static ^ proc_id).
-get_proc_info(CI,
-    CI ^ code_info_static ^ proc_info).
-get_pred_info(CI,
-    CI ^ code_info_static ^ pred_info).
-get_varset(CI,
-    CI ^ code_info_static ^ varset).
-get_var_slot_count(CI,
-    CI ^ code_info_static ^ var_slot_count).
-get_maybe_trace_info(CI,
-    CI ^ code_info_static ^ maybe_trace_info).
-get_opt_no_return_calls(CI,
-    CI ^ code_info_static ^ opt_no_resume_calls).
-get_emit_trail_ops(CI,
-    CI ^ code_info_static ^ emit_trail_ops).
-get_opt_trail_ops(CI,
-    CI ^ code_info_static ^ opt_trail_ops).
-get_forward_live_vars(CI,
-    CI ^ code_info_loc_dep ^ forward_live_vars).
-get_instmap(CI,
-    CI ^ code_info_loc_dep ^ instmap).
-get_zombies(CI,
-    CI ^ code_info_loc_dep ^ zombies).
-get_var_locn_info(CI,
-    CI ^ code_info_loc_dep ^ var_locn_info).
-get_temps_in_use(CI,
-    CI ^ code_info_loc_dep ^ temps_in_use).
-get_fail_info(CI,
-    CI ^ code_info_loc_dep ^ fail_info).
-get_label_counter(CI,
-    CI ^ code_info_persistent ^ label_num_src).
-get_succip_used(CI,
-    CI ^ code_info_persistent ^ store_succip).
-get_layout_info(CI,
-    CI ^ code_info_persistent ^ label_info).
-get_max_temp_slot_count(CI,
-    CI ^ code_info_persistent ^ stackslot_max).
-get_temp_content_map(CI,
-    CI ^ code_info_persistent ^ temp_contents).
-get_closure_seq_counter(CI,
-    CI ^ code_info_persistent ^ closure_layout_seq).
-get_closure_layouts(CI,
-    CI ^ code_info_persistent ^ closure_layouts).
-get_max_reg_in_use_at_trace(CI,
-    CI ^ code_info_persistent ^ max_reg_used).
-get_created_temp_frame(CI,
-    CI ^ code_info_persistent ^ created_temp_frame).
-get_static_cell_info(CI,
-    CI ^ code_info_persistent ^ static_cell_info).
+get_globals(CI, CI ^ code_info_static ^ globals).
+get_module_info(CI, CI ^ code_info_static ^ module_info).
+get_pred_id(CI, CI ^ code_info_static ^ pred_id).
+get_proc_id(CI, CI ^ code_info_static ^ proc_id).
+get_proc_info(CI, CI ^ code_info_static ^ proc_info).
+get_pred_info(CI, CI ^ code_info_static ^ pred_info).
+get_varset(CI, CI ^ code_info_static ^ varset).
+get_var_slot_count(CI, CI ^ code_info_static ^ var_slot_count).
+get_maybe_trace_info(CI, CI ^ code_info_static ^ maybe_trace_info).
+get_opt_no_return_calls(CI, CI ^ code_info_static ^ opt_no_resume_calls).
+get_emit_trail_ops(CI, CI ^ code_info_static ^ emit_trail_ops).
+get_opt_trail_ops(CI, CI ^ code_info_static ^ opt_trail_ops).
+get_forward_live_vars(CI, CI ^ code_info_loc_dep ^ forward_live_vars).
+get_instmap(CI, CI ^ code_info_loc_dep ^ instmap).
+get_zombies(CI, CI ^ code_info_loc_dep ^ zombies).
+get_var_locn_info(CI, CI ^ code_info_loc_dep ^ var_locn_info).
+get_temps_in_use(CI, CI ^ code_info_loc_dep ^ temps_in_use).
+get_fail_info(CI, CI ^ code_info_loc_dep ^ fail_info).
+get_label_counter(CI, CI ^ code_info_persistent ^ label_num_src).
+get_succip_used(CI, CI ^ code_info_persistent ^ store_succip).
+get_layout_info(CI, CI ^ code_info_persistent ^ label_info).
+get_max_temp_slot_count(CI, CI ^ code_info_persistent ^ stackslot_max).
+get_temp_content_map(CI, CI ^ code_info_persistent ^ temp_contents).
+get_closure_seq_counter(CI, CI ^ code_info_persistent ^ closure_layout_seq).
+get_closure_layouts(CI, CI ^ code_info_persistent ^ closure_layouts).
+get_max_reg_in_use_at_trace(CI, CI ^ code_info_persistent ^ max_reg_used).
+get_created_temp_frame(CI, CI ^ code_info_persistent ^ created_temp_frame).
+get_static_cell_info(CI, CI ^ code_info_persistent ^ static_cell_info).
 
 %---------------------------------------------------------------------------%
 
-set_maybe_trace_info(TI, CI,
-    CI ^ code_info_static ^ maybe_trace_info := TI).
+set_maybe_trace_info(TI, CI, CI ^ code_info_static ^ maybe_trace_info := TI).
 set_forward_live_vars(LV, CI,
     CI ^ code_info_loc_dep ^ forward_live_vars := LV).
-set_instmap(IM, CI,
-    CI ^ code_info_loc_dep ^ instmap := IM).
-set_zombies(Zs, CI,
-    CI ^ code_info_loc_dep ^ zombies := Zs).
-set_var_locn_info(EI, CI,
-    CI ^ code_info_loc_dep ^ var_locn_info := EI).
-set_temps_in_use(TI, CI,
-    CI ^ code_info_loc_dep ^ temps_in_use := TI).
-set_fail_info(FI, CI,
-    CI ^ code_info_loc_dep ^ fail_info := FI).
-set_label_counter(LC, CI,
-    CI ^ code_info_persistent ^ label_num_src := LC).
-set_succip_used(SU, CI,
-    CI ^ code_info_persistent ^ store_succip := SU).
-set_layout_info(LI, CI,
-    CI ^ code_info_persistent ^ label_info := LI).
+set_instmap(IM, CI, CI ^ code_info_loc_dep ^ instmap := IM).
+set_zombies(Zs, CI, CI ^ code_info_loc_dep ^ zombies := Zs).
+set_var_locn_info(EI, CI, CI ^ code_info_loc_dep ^ var_locn_info := EI).
+set_temps_in_use(TI, CI, CI ^ code_info_loc_dep ^ temps_in_use := TI).
+set_fail_info(FI, CI, CI ^ code_info_loc_dep ^ fail_info := FI).
+set_label_counter(LC, CI, CI ^ code_info_persistent ^ label_num_src := LC).
+set_succip_used(SU, CI, CI ^ code_info_persistent ^ store_succip := SU).
+set_layout_info(LI, CI, CI ^ code_info_persistent ^ label_info := LI).
 set_max_temp_slot_count(TM, CI,
     CI ^ code_info_persistent ^ stackslot_max := TM).
-set_temp_content_map(CM, CI,
-    CI ^ code_info_persistent ^ temp_contents := CM).
+set_temp_content_map(CM, CI, CI ^ code_info_persistent ^ temp_contents := CM).
 set_closure_seq_counter(CLS, CI,
     CI ^ code_info_persistent ^ closure_layout_seq := CLS).
-set_closure_layouts(CG, CI,
-    CI ^ code_info_persistent ^ closure_layouts := CG).
+set_closure_layouts(CG, CI, CI ^ code_info_persistent ^ closure_layouts := CG).
 set_max_reg_in_use_at_trace(MR, CI,
     CI ^ code_info_persistent ^ max_reg_used := MR).
 set_created_temp_frame(MR, CI,
@@ -744,7 +706,7 @@
 :- pred get_next_closure_seq_no(int::out,
     code_info::in, code_info::out) is det.
 
-:- pred add_closure_layout(comp_gen_c_data::in,
+:- pred add_closure_layout(layout_data::in,
     code_info::in, code_info::out) is det.
 
 :- pred add_scalar_static_cell(assoc_list(rval, llds_type)::in,
Index: compiler/global_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/global_data.m,v
retrieving revision 1.18
diff -u -b -r1.18 global_data.m
--- compiler/global_data.m	26 Apr 2006 03:05:34 -0000	1.18
+++ compiler/global_data.m	7 May 2006 03:45:19 -0000
@@ -19,6 +19,7 @@
 :- import_module hlds.hlds_pred.
 :- import_module ll_backend.continuation_info.
 :- import_module ll_backend.exprn_aux.
+:- import_module ll_backend.layout.
 :- import_module ll_backend.llds.
 :- import_module mdbcomp.prim_data.     % for module_name
 :- import_module parse_tree.prog_data.
@@ -42,7 +43,7 @@
 :- pred global_data_update_proc_layout(pred_proc_id::in, proc_layout_info::in,
     global_data::in, global_data::out) is det.
 
-:- pred global_data_add_new_closure_layouts(list(comp_gen_c_data)::in,
+:- pred global_data_add_new_closure_layouts(list(layout_data)::in,
     global_data::in, global_data::out) is det.
 
 :- pred global_data_maybe_get_proc_layout(global_data::in, pred_proc_id::in,
@@ -58,7 +59,7 @@
     list(proc_layout_info)::out) is det.
 
 :- pred global_data_get_all_closure_layouts(global_data::in,
-    list(comp_gen_c_data)::out) is det.
+    list(layout_data)::out) is det.
 
 :- pred global_data_get_static_cell_info(global_data::in,
     static_cell_info::out) is det.
@@ -86,7 +87,9 @@
 :- pred search_scalar_static_cell_offset(static_cell_info::in, data_addr::in,
     int::in, rval::out) is semidet.
 
-:- func get_static_cells(static_cell_info) = list(comp_gen_c_data).
+:- pred get_static_cells(static_cell_info::in,
+    list(scalar_common_data_array)::out, list(vector_common_data_array)::out)
+    is det.
 
     % Given an rval, figure out the type it would have as an argument.
     % Normally that's the same as its usual type; the exception is that for
@@ -121,35 +124,25 @@
 :- type global_data
     --->    global_data(
                 proc_var_map        :: proc_var_map,
-                                    % Information about the global
-                                    % variables defined by each
-                                    % procedure.
+                                    % Information about the global variables
+                                    % defined by each procedure.
 
                 proc_layout_map     :: proc_layout_map,
-                                    % Information about the
-                                    % layout structures defined
-                                    % by each procedure.
-
-                closure_layouts     :: list(comp_gen_c_data),
-                                    % The list of all closure
-                                    % layouts generated in this
-                                    % module. While all closure
-                                    % layouts are different from
-                                    % all other comp_gen_c_datas,
-                                    % it is possible, although
-                                    % unlikely, for two closures
-                                    % to have the same layout.
+                                    % Information about the layout structures
+                                    % defined by each procedure.
+
+                closure_layouts     :: list(layout_data),
+                                    % The list of all closure layouts generated
+                                    % in this module. While all closure layouts
+                                    % are different from all other layout_data,
+                                    % it is possible, although unlikely, for
+                                    % two closures to have the same layout.
 
                 static_cell_info    :: static_cell_info
-                                    % Information about all the
-                                    % statically allocated cells
-                                    % created so far.
+                                    % Information about all the statically
+                                    % allocated cells created so far.
             ).
 
-:- func wrap_layout_data(layout_data) = comp_gen_c_data.
-
-wrap_layout_data(LayoutData) = layout_data(LayoutData).
-
 global_data_init(StaticCellInfo, GlobalData) :-
     map.init(EmptyDataMap),
     map.init(EmptyLayoutMap),
@@ -467,7 +460,7 @@
 
 %-----------------------------------------------------------------------------%
 
-get_static_cells(Info) = VectorDatas ++ ScalarDatas :-
+get_static_cells(Info, ScalarDatas, VectorDatas) :-
     ModuleName = Info ^ sub_info ^ module_name,
     TypeNumMap = Info ^ cell_type_num_map,
     map.foldl(add_scalar_static_cell_for_type(ModuleName, TypeNumMap),
@@ -479,37 +472,38 @@
 
 :- pred add_scalar_static_cell_for_type(module_name::in,
     bimap(common_cell_type, int)::in, int::in, scalar_cell_group::in,
-    list(comp_gen_c_data)::in, list(comp_gen_c_data)::out) is det.
+    list(scalar_common_data_array)::in, list(scalar_common_data_array)::out)
+    is det.
 
 add_scalar_static_cell_for_type(ModuleName, TypeNumMap, TypeNum, CellGroup,
-        !Datas) :-
+        !Arrays) :-
     bimap.reverse_lookup(TypeNumMap, CellType, TypeNum),
     list.reverse(CellGroup ^ scalar_cell_rev_array, ArrayContents),
     Array = scalar_common_data_array(ModuleName, CellType, TypeNum,
         ArrayContents),
-    Data = scalar_common_data(Array),
-    !:Datas = [Data | !.Datas].
+    !:Arrays = [Array | !.Arrays].
 
 :- pred add_all_vector_static_cells_for_type(module_name::in,
     bimap(common_cell_type, int)::in, int::in, vector_cell_group::in,
-    list(comp_gen_c_data)::in, list(comp_gen_c_data)::out) is det.
+    list(vector_common_data_array)::in, list(vector_common_data_array)::out)
+    is det.
 
 add_all_vector_static_cells_for_type(ModuleName, TypeNumMap, TypeNum,
-        CellGroup, !Datas) :-
+        CellGroup, !Arrays) :-
     bimap.reverse_lookup(TypeNumMap, CellType, TypeNum),
     map.foldl(add_one_vector_static_cell(ModuleName, TypeNum, CellType),
-        CellGroup ^ vector_cell_map, !Datas).
+        CellGroup ^ vector_cell_map, !Arrays).
 
 :- pred add_one_vector_static_cell(module_name::in, int::in,
     common_cell_type::in, int::in, vector_contents::in,
-    list(comp_gen_c_data)::in, list(comp_gen_c_data)::out) is det.
+    list(vector_common_data_array)::in, list(vector_common_data_array)::out)
+    is det.
 
 add_one_vector_static_cell(ModuleName, TypeNum, CellType, CellNum,
-        vector_contents(VectorContents), !Datas) :-
+        vector_contents(VectorContents), !Arrays) :-
     Array = vector_common_data_array(ModuleName, CellType, TypeNum, CellNum,
         VectorContents),
-    Data = vector_common_data(Array),
-    !:Datas = [Data | !.Datas].
+    !:Arrays = [Array | !.Arrays].
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/layout.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/layout.m,v
retrieving revision 1.26
diff -u -b -r1.26 layout.m
--- compiler/layout.m	29 Mar 2006 08:06:53 -0000	1.26
+++ compiler/layout.m	7 May 2006 04:09:21 -0000
@@ -5,10 +5,10 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: layout.m.
 % Author: zs.
-
+%
 % Definitions of Mercury types for representing layout structures within
 % the compiler. Layout structures are generated by the compiler, and are
 % used by the parts of the runtime system that need to look at the stacks
@@ -49,7 +49,8 @@
 %-----------------------------------------------------------------------------%
 
     % This type is for strings which may contain embedded null characters.
-:- type string_with_0s ---> string_with_0s(string).
+:- type string_with_0s
+    --->    string_with_0s(string).
 
 :- type layout_data
     --->    label_layout_data(      % defines MR_Label_Layout
Index: compiler/layout_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/layout_out.m,v
retrieving revision 1.65
diff -u -b -r1.65 layout_out.m
--- compiler/layout_out.m	20 Apr 2006 05:36:54 -0000	1.65
+++ compiler/layout_out.m	7 May 2006 04:26:10 -0000
@@ -5,10 +5,10 @@
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
-
+%
 % File: layout_out.m.
 % Author: zs.
-
+%
 % This structure converts layout structures from the representation used
 % within the compiler to the representation used by the runtime system.
 % The types of the inputs are defined in layout.m. The types of the outputs
@@ -17,7 +17,7 @@
 %
 % This module should be, but as yet isn't, independent of whether we are
 % compiling to LLDS or MLDS.
-
+%
 %-----------------------------------------------------------------------------%
 
 :- module ll_backend.layout_out.
@@ -122,36 +122,42 @@
 
 %-----------------------------------------------------------------------------%
 
-output_layout_data_defn(label_layout_data(ProcLabel, LabelNum, ProcLayoutAddr,
+output_layout_data_defn(Data, !DeclSet, !IO) :-
+    (
+        Data = label_layout_data(ProcLabel, LabelNum, ProcLayoutAddr,
         MaybePort, MaybeIsHidden, LabelNumber, MaybeGoalPath,
-        MaybeVarInfo), !DeclSet, !IO) :-
+            MaybeVarInfo),
     output_label_layout_data_defn(ProcLabel, LabelNum, ProcLayoutAddr,
         MaybePort, MaybeIsHidden, LabelNumber, MaybeGoalPath,
-        MaybeVarInfo, !DeclSet, !IO).
-output_layout_data_defn(proc_layout_data(ProcLabel, Traversal, MaybeRest),
-        !DeclSet, !IO) :-
+            MaybeVarInfo, !DeclSet, !IO)
+    ;
+        Data = proc_layout_data(ProcLabel, Traversal, MaybeRest),
     output_proc_layout_data_defn(ProcLabel, Traversal, MaybeRest,
-        !DeclSet, !IO).
-output_layout_data_defn(closure_proc_id_data(CallerProcLabel, SeqNo,
-        ProcLabel, ModuleName, FileName, LineNumber, PredOrigin,
-        GoalPath), !DeclSet, !IO) :-
+            !DeclSet, !IO)
+    ;
+        Data = closure_proc_id_data(CallerProcLabel, SeqNo, ProcLabel,
+            ModuleName, FileName, LineNumber, PredOrigin, GoalPath),
     output_closure_proc_id_data_defn(CallerProcLabel, SeqNo, ProcLabel,
         ModuleName, FileName, LineNumber, PredOrigin, GoalPath,
-        !DeclSet, !IO).
-output_layout_data_defn(module_layout_data(ModuleName, StringTableSize,
+            !DeclSet, !IO)
+    ;
+        Data = module_layout_data(ModuleName, StringTableSize,
         StringTable, ProcLayoutNames, FileLayouts, TraceLevel,
-        SuppressedEvents, NumLabels), !DeclSet, !IO) :-
+            SuppressedEvents, NumLabels),
     output_module_layout_data_defn(ModuleName, StringTableSize,
         StringTable, ProcLayoutNames, FileLayouts, TraceLevel,
-        SuppressedEvents, NumLabels, !DeclSet, !IO).
-output_layout_data_defn(table_io_decl_data(RttiProcLabel, Kind, NumPTIs,
-        PTIVectorRval, TypeParamsRval), !DeclSet, !IO) :-
+            SuppressedEvents, NumLabels, !DeclSet, !IO)
+    ;
+        Data = table_io_decl_data(RttiProcLabel, Kind, NumPTIs,
+            PTIVectorRval, TypeParamsRval),
     output_table_io_decl(RttiProcLabel, Kind, NumPTIs,
-        PTIVectorRval, TypeParamsRval, !DeclSet, !IO).
-output_layout_data_defn(table_gen_data(RttiProcLabel, NumInputs, NumOutputs,
-        Steps, PTIVectorRval, TypeParamsRval), !DeclSet, !IO) :-
+            PTIVectorRval, TypeParamsRval, !DeclSet, !IO)
+    ;
+        Data = table_gen_data(RttiProcLabel, NumInputs, NumOutputs,
+            Steps, PTIVectorRval, TypeParamsRval),
     output_table_gen(RttiProcLabel, NumInputs, NumOutputs, Steps,
-        PTIVectorRval, TypeParamsRval, !DeclSet, !IO).
+            PTIVectorRval, TypeParamsRval, !DeclSet, !IO)
+    ).
 
 %-----------------------------------------------------------------------------%
 
@@ -173,29 +179,32 @@
 
 :- pred extract_layout_name(layout_data::in, layout_name::out) is det.
 
-extract_layout_name(label_layout_data(ProcLabel, LabelNum, _, _, _, _, _,
-        yes(_)), LayoutName) :-
-    LayoutName = label_layout(ProcLabel, LabelNum, label_has_var_info).
-extract_layout_name(label_layout_data(ProcLabel, LabelNum, _, _, _, _, _, no),
-        LayoutName) :-
-    LayoutName = label_layout(ProcLabel, LabelNum, label_has_no_var_info).
-extract_layout_name(proc_layout_data(RttiProcLabel, _, MaybeRest),
-        LayoutName) :-
+extract_layout_name(Data, LayoutName) :-
+    (
+        Data = label_layout_data(ProcLabel, LabelNum, _, _, _, _, _, yes(_)),
+        LayoutName = label_layout(ProcLabel, LabelNum, label_has_var_info)
+    ;
+        Data = label_layout_data(ProcLabel, LabelNum, _, _, _, _, _, no),
+        LayoutName = label_layout(ProcLabel, LabelNum, label_has_no_var_info)
+    ;
+        Data = proc_layout_data(RttiProcLabel, _, MaybeRest),
     ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
     Kind = maybe_proc_layout_and_more_kind(MaybeRest, ProcLabel),
-    LayoutName = proc_layout(RttiProcLabel, Kind).
-extract_layout_name(closure_proc_id_data(CallerProcLabel, SeqNo,
-        ClosureProcLabel, _, _, _, _, _),
-        closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel)).
-extract_layout_name(module_layout_data(ModuleName, _, _, _, _, _, _, _),
-        LayoutName) :-
-    LayoutName = module_layout(ModuleName).
-extract_layout_name(table_io_decl_data(RttiProcLabel, _, _, _, _),
-        LayoutName) :-
-    LayoutName = table_io_decl(RttiProcLabel).
-extract_layout_name(table_gen_data(RttiProcLabel, _, _, _, _, _),
-        LayoutName) :-
-    LayoutName = table_gen_info(RttiProcLabel).
+        LayoutName = proc_layout(RttiProcLabel, Kind)
+    ;
+        Data = closure_proc_id_data(CallerProcLabel, SeqNo, ClosureProcLabel,
+            _, _, _, _, _),
+        LayoutName = closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel)
+    ;
+        Data = module_layout_data(ModuleName, _, _, _, _, _, _, _),
+        LayoutName = module_layout(ModuleName)
+    ;
+        Data = table_io_decl_data(RttiProcLabel, _, _, _, _),
+        LayoutName = table_io_decl(RttiProcLabel)
+    ;
+        Data = table_gen_data(RttiProcLabel, _, _, _, _, _),
+        LayoutName = table_gen_info(RttiProcLabel)
+    ).
 
 :- pred output_layout_decl(layout_name::in, decl_set::in, decl_set::out,
     io::di, io::uo) is det.
@@ -222,128 +231,151 @@
         LabelName
     ], Name).
 
-output_layout_name(label_layout(ProcLabel, LabelNum, _), !IO) :-
+output_layout_name(Data, !IO) :-
+    (
+        Data =label_layout(ProcLabel, LabelNum, _),
     % This code should be kept in sync with make_label_layout_name/1 above.
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_label_layout__", !IO),
     io.write_string(label_to_c_string(internal(LabelNum, ProcLabel), yes),
-        !IO).
-output_layout_name(proc_layout(RttiProcLabel, _), !IO) :-
+            !IO)
+    ;
+        Data = proc_layout(RttiProcLabel, _),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_proc_layout__", !IO),
     % We can't omit the mercury_ prefix on ProcLabel, even though the
     % mercury_data_prefix duplicates it, because there is no simply way
     % to make the MR_init_entryl_sl macro delete that prefix from the
     % entry label's name to get the name of its layout structure.
-    output_proc_label(make_proc_label_from_rtti(RttiProcLabel), yes, !IO).
-output_layout_name(proc_layout_exec_trace(RttiProcLabel), !IO) :-
+        output_proc_label(make_proc_label_from_rtti(RttiProcLabel), yes, !IO)
+    ;
+        Data = proc_layout_exec_trace(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_proc_layout_exec_trace__", !IO),
-    output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO).
-output_layout_name(proc_layout_head_var_nums(RttiProcLabel), !IO) :-
+        output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO)
+    ;
+        Data = proc_layout_head_var_nums(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_head_var_nums__", !IO),
-    output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO).
-output_layout_name(proc_layout_var_names(RttiProcLabel), !IO) :-
+        output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO)
+    ;
+        Data = proc_layout_var_names(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_var_names__", !IO),
-    output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO).
-output_layout_name(proc_layout_body_bytecode(RttiProcLabel), !IO) :-
+        output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO)
+    ;
+        Data = proc_layout_body_bytecode(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_body_bytecode__", !IO),
-    output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO).
-output_layout_name(closure_proc_id(CallerProcLabel, SeqNo, _), !IO) :-
+        output_proc_label(make_proc_label_from_rtti(RttiProcLabel), no, !IO)
+    ;
+        Data = closure_proc_id(CallerProcLabel, SeqNo, _),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_closure_layout__", !IO),
     output_proc_label(CallerProcLabel, no, !IO),
     io.write_string("_", !IO),
-    io.write_int(SeqNo, !IO).
-output_layout_name(file_layout(ModuleName, FileNum), !IO) :-
+        io.write_int(SeqNo, !IO)
+    ;
+        Data = file_layout(ModuleName, FileNum),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_file_layout__", !IO),
     ModuleNameStr = sym_name_mangle(ModuleName),
     io.write_string(ModuleNameStr, !IO),
     io.write_string("_", !IO),
-    io.write_int(FileNum, !IO).
-output_layout_name(file_layout_line_number_vector(ModuleName, FileNum), !IO) :-
+        io.write_int(FileNum, !IO)
+    ;
+        Data = file_layout_line_number_vector(ModuleName, FileNum),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_file_lines__", !IO),
     ModuleNameStr = sym_name_mangle(ModuleName),
     io.write_string(ModuleNameStr, !IO),
     io.write_string("_", !IO),
-    io.write_int(FileNum, !IO).
-output_layout_name(file_layout_label_layout_vector(ModuleName, FileNum),
-        !IO) :-
+        io.write_int(FileNum, !IO)
+    ;
+        Data = file_layout_label_layout_vector(ModuleName, FileNum),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_file_label_layouts__", !IO),
     ModuleNameStr = sym_name_mangle(ModuleName),
     io.write_string(ModuleNameStr, !IO),
     io.write_string("_", !IO),
-    io.write_int(FileNum, !IO).
-output_layout_name(module_layout_string_table(ModuleName), !IO) :-
+        io.write_int(FileNum, !IO)
+    ;
+        Data = module_layout_string_table(ModuleName),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_module_strings__", !IO),
     ModuleNameStr = sym_name_mangle(ModuleName),
-    io.write_string(ModuleNameStr, !IO).
-output_layout_name(module_layout_file_vector(ModuleName), !IO) :-
+        io.write_string(ModuleNameStr, !IO)
+    ;
+        Data = module_layout_file_vector(ModuleName),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_module_files__", !IO),
     ModuleNameStr = sym_name_mangle(ModuleName),
-    io.write_string(ModuleNameStr, !IO).
-output_layout_name(module_layout_proc_vector(ModuleName), !IO) :-
+        io.write_string(ModuleNameStr, !IO)
+    ;
+        Data = module_layout_proc_vector(ModuleName),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_module_procs__", !IO),
     ModuleNameStr = sym_name_mangle(ModuleName),
-    io.write_string(ModuleNameStr, !IO).
-output_layout_name(module_layout_label_exec_count(ModuleName, _), !IO) :-
+        io.write_string(ModuleNameStr, !IO)
+    ;
+        Data = module_layout_label_exec_count(ModuleName, _),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_module_label_exec_counts__", !IO),
     ModuleNameStr = sym_name_mangle(ModuleName),
-    io.write_string(ModuleNameStr, !IO).
-output_layout_name(module_layout(ModuleName), !IO) :-
+        io.write_string(ModuleNameStr, !IO)
+    ;
+        Data = module_layout(ModuleName),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_module_layout__", !IO),
     ModuleNameStr = sym_name_mangle(ModuleName),
-    io.write_string(ModuleNameStr, !IO).
-output_layout_name(proc_static(RttiProcLabel), !IO) :-
+        io.write_string(ModuleNameStr, !IO)
+    ;
+        Data = proc_static(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_proc_static__", !IO),
     ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
-    output_proc_label(ProcLabel, no, !IO).
-output_layout_name(proc_static_call_sites(RttiProcLabel), !IO) :-
+        output_proc_label(ProcLabel, no, !IO)
+    ;
+        Data = proc_static_call_sites(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_proc_static_call_sites__", !IO),
     ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
-    output_proc_label(ProcLabel, no, !IO).
-output_layout_name(table_io_decl(RttiProcLabel), !IO) :-
+        output_proc_label(ProcLabel, no, !IO)
+    ;
+        Data = table_io_decl(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_table_io_decl__", !IO),
     ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
-    output_proc_label(ProcLabel, no, !IO).
-output_layout_name(table_gen_info(RttiProcLabel), !IO) :-
+        output_proc_label(ProcLabel, no, !IO)
+    ;
+        Data = table_gen_info(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_table_gen__", !IO),
     ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
-    output_proc_label(ProcLabel, no, !IO).
-output_layout_name(table_gen_enum_params(RttiProcLabel), !IO) :-
+        output_proc_label(ProcLabel, no, !IO)
+    ;
+        Data = table_gen_enum_params(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_table_enum_params__", !IO),
     ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
-    output_proc_label(ProcLabel, no, !IO).
-output_layout_name(table_gen_steps(RttiProcLabel), !IO) :-
+        output_proc_label(ProcLabel, no, !IO)
+    ;
+        Data = table_gen_steps(RttiProcLabel),
     io.write_string(mercury_data_prefix, !IO),
     io.write_string("_table_steps__", !IO),
     ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
-    output_proc_label(ProcLabel, no, !IO).
+        output_proc_label(ProcLabel, no, !IO)
+    ).
 
-output_layout_name_storage_type_name(
-        label_layout(ProcLabel, LabelNum, LabelVars), _BeingDefined, !IO) :-
+output_layout_name_storage_type_name(Data, BeingDefined, !IO) :-
+    (
+        Data = label_layout(ProcLabel, LabelNum, LabelVars),
     io.write_string("static const ", !IO),
     io.write_string(label_vars_to_type(LabelVars), !IO),
     io.write_string(" ", !IO),
-    output_layout_name(label_layout(ProcLabel, LabelNum, LabelVars), !IO).
-output_layout_name_storage_type_name(proc_layout(ProcLabel, Kind),
-        BeingDefined, !IO) :-
+        output_layout_name(label_layout(ProcLabel, LabelNum, LabelVars), !IO)
+    ;
+        Data = proc_layout(ProcLabel, Kind),
     ProcIsImported = ProcLabel ^ proc_is_imported,
     ProcIsExported = ProcLabel ^ proc_is_exported,
     (
@@ -362,31 +394,31 @@
     io.write_string("const ", !IO),
     io.write_string(proc_layout_kind_to_type(Kind), !IO),
     io.write_string(" ", !IO),
-    output_layout_name(proc_layout(ProcLabel, Kind), !IO).
-output_layout_name_storage_type_name(proc_layout_exec_trace(ProcLabel),
-        _BeingDefined, !IO) :-
+        output_layout_name(proc_layout(ProcLabel, Kind), !IO)
+    ;
+        Data = proc_layout_exec_trace(ProcLabel),
     io.write_string("static MR_STATIC_CODE_CONST MR_Exec_Trace\n\t", !IO),
-    output_layout_name(proc_layout_exec_trace(ProcLabel), !IO).
-output_layout_name_storage_type_name(proc_layout_head_var_nums(ProcLabel),
-        _BeingDefined, !IO) :-
+        output_layout_name(proc_layout_exec_trace(ProcLabel), !IO)
+    ;
+        Data = proc_layout_head_var_nums(ProcLabel),
     io.write_string("static const ", !IO),
     io.write_string("MR_uint_least16_t ", !IO),
     output_layout_name(proc_layout_head_var_nums(ProcLabel), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(proc_layout_var_names(ProcLabel),
-        _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = proc_layout_var_names(ProcLabel),
     io.write_string("static const ", !IO),
     io.write_string("MR_uint_least32_t ", !IO),
     output_layout_name(proc_layout_var_names(ProcLabel), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(proc_layout_body_bytecode(ProcLabel),
-        _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = proc_layout_body_bytecode(ProcLabel),
     io.write_string("static const ", !IO),
     io.write_string("MR_uint_least8_t ", !IO),
     output_layout_name(proc_layout_body_bytecode(ProcLabel), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(closure_proc_id(CallerProcLabel, SeqNo,
-        ClosureProcLabel), _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel),
     io.write_string("static const ", !IO),
     (
         ClosureProcLabel = proc(_, _, _, _, _, _),
@@ -396,77 +428,78 @@
         io.write_string("MR_UCI_Closure_Id\n", !IO)
     ),
     output_layout_name(closure_proc_id(CallerProcLabel, SeqNo,
-        ClosureProcLabel), !IO).
-output_layout_name_storage_type_name(file_layout(ModuleName, FileNum),
-        _BeingDefined, !IO) :-
+            ClosureProcLabel), !IO)
+    ;
+        Data = file_layout(ModuleName, FileNum),
     io.write_string("static const MR_Module_File_Layout ", !IO),
-    output_layout_name(file_layout(ModuleName, FileNum), !IO).
-output_layout_name_storage_type_name(file_layout_line_number_vector(
-        ModuleName, FileNum), _BeingDefined, !IO) :-
+        output_layout_name(file_layout(ModuleName, FileNum), !IO)
+    ;
+        Data = file_layout_line_number_vector(ModuleName, FileNum),
     io.write_string("static const MR_int_least16_t ", !IO),
     output_layout_name(
         file_layout_line_number_vector(ModuleName, FileNum), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(file_layout_label_layout_vector(
-        ModuleName, FileNum), _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = file_layout_label_layout_vector(ModuleName, FileNum),
     io.write_string("static const MR_Label_Layout *", !IO),
     output_layout_name(
         file_layout_label_layout_vector(ModuleName, FileNum), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(module_layout_string_table(ModuleName),
-        _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = module_layout_string_table(ModuleName),
     io.write_string("static const char ", !IO),
     output_layout_name(module_layout_string_table(ModuleName), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(module_layout_file_vector(ModuleName),
-        _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = module_layout_file_vector(ModuleName),
     io.write_string("static const MR_Module_File_Layout *", !IO),
     output_layout_name(module_layout_file_vector(ModuleName), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(module_layout_label_exec_count(
-        ModuleName, NumElements), _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = module_layout_label_exec_count(ModuleName, NumElements),
     io.write_string("static MR_Unsigned ", !IO),
     output_layout_name(
         module_layout_label_exec_count(ModuleName, NumElements), !IO),
     io.write_string("[", !IO),
     io.write_int(NumElements, !IO),
-    io.write_string("]", !IO).
-output_layout_name_storage_type_name(module_layout_proc_vector(ModuleName),
-        _BeingDefined, !IO) :-
+        io.write_string("]", !IO)
+    ;
+        Data = module_layout_proc_vector(ModuleName),
     io.write_string("static const MR_Proc_Layout *", !IO),
     output_layout_name(module_layout_proc_vector(ModuleName), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(module_layout(ModuleName),
-        _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = module_layout(ModuleName),
     io.write_string("static const MR_Module_Layout ", !IO),
-    output_layout_name(module_layout(ModuleName), !IO).
-output_layout_name_storage_type_name(proc_static(RttiProcLabel),
-        _BeingDefined, !IO) :-
+        output_layout_name(module_layout(ModuleName), !IO)
+    ;
+        Data = proc_static(RttiProcLabel),
     io.write_string("static MR_ProcStatic ", !IO),
-    output_layout_name(proc_static(RttiProcLabel), !IO).
-output_layout_name_storage_type_name(proc_static_call_sites(RttiProcLabel),
-        _BeingDefined, !IO) :-
+        output_layout_name(proc_static(RttiProcLabel), !IO)
+    ;
+        Data = proc_static_call_sites(RttiProcLabel),
     io.write_string("static const MR_CallSiteStatic ", !IO),
     output_layout_name(proc_static_call_sites(RttiProcLabel), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(table_io_decl(RttiProcLabel),
-        _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = table_io_decl(RttiProcLabel),
     io.write_string("static const MR_Table_Io_Decl ", !IO),
-    output_layout_name(table_io_decl(RttiProcLabel), !IO).
-output_layout_name_storage_type_name(table_gen_info(RttiProcLabel),
-        _BeingDefined, !IO) :-
+        output_layout_name(table_io_decl(RttiProcLabel), !IO)
+    ;
+        Data = table_gen_info(RttiProcLabel),
     io.write_string("static const MR_Table_Gen ", !IO),
-    output_layout_name(table_gen_info(RttiProcLabel), !IO).
-output_layout_name_storage_type_name(table_gen_enum_params(RttiProcLabel),
-        _BeingDefined, !IO) :-
+        output_layout_name(table_gen_info(RttiProcLabel), !IO)
+    ;
+        Data = table_gen_enum_params(RttiProcLabel),
     io.write_string("static const MR_Integer ", !IO),
     output_layout_name(table_gen_enum_params(RttiProcLabel), !IO),
-    io.write_string("[]", !IO).
-output_layout_name_storage_type_name(table_gen_steps(RttiProcLabel),
-        _BeingDefined, !IO) :-
+        io.write_string("[]", !IO)
+    ;
+        Data = table_gen_steps(RttiProcLabel),
     io.write_string("static const MR_Table_Trie_Step ", !IO),
     output_layout_name(table_gen_steps(RttiProcLabel), !IO),
-    io.write_string("[]", !IO).
+        io.write_string("[]", !IO)
+    ).
 
 layout_name_would_include_code_addr(label_layout(_, _, _)) = no.
 layout_name_would_include_code_addr(proc_layout(_, _)) = no.
@@ -498,12 +531,9 @@
 
 :- func proc_layout_kind_to_type(proc_layout_kind) = string.
 
-proc_layout_kind_to_type(proc_layout_traversal) =
-    "MR_Proc_Layout_Traversal".
-proc_layout_kind_to_type(proc_layout_proc_id(user)) =
-    "MR_Proc_Layout_User".
-proc_layout_kind_to_type(proc_layout_proc_id(uci)) =
-    "MR_Proc_Layout_UCI".
+proc_layout_kind_to_type(proc_layout_traversal) = "MR_Proc_Layout_Traversal".
+proc_layout_kind_to_type(proc_layout_proc_id(user)) = "MR_Proc_Layout_User".
+proc_layout_kind_to_type(proc_layout_proc_id(uci)) = "MR_Proc_Layout_UCI".
 
 %-----------------------------------------------------------------------------%
 
@@ -777,8 +807,8 @@
     decl_set::in, decl_set::out, io::di, io::uo) is det.
 
 output_layout_traversal_decls(Traversal, !DeclSet, !IO) :-
-    Traversal = proc_layout_stack_traversal(MaybeEntryLabel,
-        _MaybeSuccipSlot, _StackSlotCount, _Detism),
+    Traversal = proc_layout_stack_traversal(MaybeEntryLabel, _MaybeSuccipSlot,
+        _StackSlotCount, _Detism),
     (
         MaybeEntryLabel = yes(EntryLabel),
         output_code_addr_decls(label(EntryLabel), !DeclSet, !IO)
@@ -790,8 +820,8 @@
     io::di, io::uo) is det.
 
 output_layout_traversal_group(Traversal, !IO) :-
-    Traversal = proc_layout_stack_traversal(MaybeEntryLabel,
-        MaybeSuccipSlot, StackSlotCount, Detism),
+    Traversal = proc_layout_stack_traversal(MaybeEntryLabel, MaybeSuccipSlot,
+        StackSlotCount, Detism),
     io.write_string("{\n", !IO),
     (
         MaybeEntryLabel = yes(EntryLabel),
@@ -864,8 +894,7 @@
     % The job of this predicate is to minimize stack space consumption in
     % grades that do not allow output_bytecodes to be tail recursive.
     %
-:- pred output_bytecodes_driver(list(int)::in, io::di, io::uo)
-    is det.
+:- pred output_bytecodes_driver(list(int)::in, io::di, io::uo) is det.
 
 output_bytecodes_driver(Bytes, !IO) :-
     (
@@ -1557,8 +1586,7 @@
     ).
 
 :- pred groupable_labels(proc_label::in, int::in, int::out,
-    list(int)::in, list(int)::out, list(label)::in, list(label)::out)
-    is det.
+    list(int)::in, list(int)::out, list(label)::in, list(label)::out) is det.
 
 groupable_labels(ProcLabel, !Count, !RevLabelsNums, !Labels) :-
     (
@@ -1682,8 +1710,8 @@
     io.write_int(Index, !IO),
     io.write_string(" */ ", !IO),
     (
-        CallSiteStatic = normal_call(Callee, TypeSubst,
-            FileName, LineNumber, GoalPath),
+        CallSiteStatic = normal_call(Callee, TypeSubst, FileName, LineNumber,
+            GoalPath),
         io.write_string("MR_normal_call, (MR_Proc_Layout *)\n&", !IO),
         CalleeProcLabel = make_proc_label_from_rtti(Callee),
         CalleeUserOrUci = proc_label_user_or_uci(CalleeProcLabel),
@@ -1871,8 +1899,7 @@
     output_table_gen_steps(Steps, MaybeEnumParams, !IO).
 
 :- pred output_table_gen_enum_params_table(rtti_proc_label::in,
-    list(maybe(int))::in, decl_set::in, decl_set::out,
-    io::di, io::uo) is det.
+    list(maybe(int))::in, decl_set::in, decl_set::out, io::di, io::uo) is det.
 
 output_table_gen_enum_params_table(RttiProcLabel, MaybeEnumParams,
         !DeclSet, !IO) :-
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.330
diff -u -b -r1.330 llds.m
--- compiler/llds.m	26 Apr 2006 03:05:35 -0000	1.330
+++ compiler/llds.m	7 May 2006 04:04:15 -0000
@@ -70,10 +70,13 @@
                 cfile_foreign_code            :: list(user_foreign_code),
                 cfile_foreign_export          :: list(foreign_export),
                 cfile_vars                    :: list(comp_gen_c_var),
-                cfile_data                    :: list(comp_gen_c_data),
+                cfile_scalar_common_data    :: list(scalar_common_data_array),
+                cfile_vector_common_data    :: list(vector_common_data_array),
+                cfile_rtti_data             :: list(rtti_data),
+                cfile_layout_data           :: list(layout_data),
                 cfile_code                    :: list(comp_gen_c_module),
-                cfile_user_init_pred_c_names  :: list(string),
-                cfile_user_final_pred_c_names :: list(string)
+                cfile_user_init_c_names     :: list(string),
+                cfile_user_final_c_names    :: list(string)
             ).
 
     % Global variables generated by the compiler.
@@ -114,15 +117,6 @@
                 rval            % The field value.
             ).
 
-    % Global data generated by the compiler. Usually readonly, with one
-    % exception: data containing code addresses must be initialized.
-    %
-:- type comp_gen_c_data
-    --->    scalar_common_data(scalar_common_data_array)
-    ;       vector_common_data(vector_common_data_array)
-    ;       rtti_data(rtti_data)
-    ;       layout_data(layout_data).
-
 :- type scalar_common_data_array
     --->    scalar_common_data_array(
                 scda_module     :: module_name,
@@ -1032,8 +1026,6 @@
 
 :- pred break_up_local_label(label::in, proc_label::out, int::out) is det.
 
-:- pred wrap_rtti_data(rtti_data::in, comp_gen_c_data::out) is det.
-
     % Given a non-var rval, figure out its type.
     %
 :- pred rval_type(rval::in, llds_type::out) is det.
@@ -1109,8 +1101,6 @@
         Label = entry(_, _),
         unexpected(this_file, "break_up_local_label: entry label")
     ).
-
-wrap_rtti_data(RttiData, rtti_data(RttiData)).
 
 lval_type(reg(RegType, _), Type) :-
     register_type(RegType, Type).
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.277
diff -u -b -r1.277 llds_out.m
--- compiler/llds_out.m	26 Apr 2006 03:05:35 -0000	1.277
+++ compiler/llds_out.m	8 May 2006 02:49:43 -0000
@@ -234,7 +234,7 @@
 %-----------------------------------------------------------------------------%
 
 output_llds(CFile, ComplexityProcs, StackLayoutLabels, !IO) :-
-    CFile = c_file(ModuleName, _, _, _, _, _, _, _, _),
+    ModuleName = CFile ^ cfile_modulename,
     module_name_to_file_name(ModuleName, ".c", yes, FileName, !IO),
     io.open_output(FileName, Result, !IO),
     (
@@ -288,7 +288,8 @@
 output_single_c_file(CFile, ComplexityProcs, StackLayoutLabels,
         FileStream, !DeclSet, !IO) :-
     CFile = c_file(ModuleName, C_HeaderLines, UserForeignCode, Exports,
-        Vars, Datas, Modules, UserInitPredCNames, UserFinalPredCNames),
+        Vars, ScalarCommonDatas, VectorCommonDatas, RttiDatas, LayoutDatas0,
+        Modules, UserInitPredCNames, UserFinalPredCNames),
     library.version(Version),
     io.set_output_stream(FileStream, OutputStream, !IO),
     module_name_to_file_name(ModuleName, ".m", no, SourceFileName, !IO),
@@ -301,11 +302,6 @@
     io.write_string("\n", !IO),
 
     gather_c_file_labels(Modules, Labels),
-    classify_comp_gen_c_data(Datas,
-        [], ScalarCommonDatas0, [], VectorCommonDatas0,
-        [], RttiDatas, [], LayoutDatas0),
-    list.reverse(ScalarCommonDatas0, ScalarCommonDatas),
-    list.reverse(VectorCommonDatas0, VectorCommonDatas),
     order_layout_datas(LayoutDatas0, LayoutDatas),
 
     list.foldl2(output_scalar_common_data_decl, ScalarCommonDatas,
@@ -327,8 +323,8 @@
     list.foldl(output_user_foreign_code, UserForeignCode, !IO),
     list.foldl(io.write_string, Exports, !IO),
     io.write_string("\n", !IO),
-    output_c_module_init_list(ModuleName, Modules, Datas, Vars,
-        ComplexityProcs, StackLayoutLabels, !DeclSet, !IO),
+    output_c_module_init_list(ModuleName, Modules, RttiDatas, LayoutDatas,
+        Vars, ComplexityProcs, StackLayoutLabels, !DeclSet, !IO),
     io.set_output_stream(OutputStream, _, !IO).
 
 :- pred order_layout_datas(list(layout_data)::in, list(layout_data)::out)
@@ -360,12 +356,12 @@
     order_layout_datas_2(Layouts, !ProcLayouts, !LabelLayouts, !OtherLayouts).
 
 :- pred output_c_module_init_list(module_name::in, list(comp_gen_c_module)::in,
-    list(comp_gen_c_data)::in, list(comp_gen_c_var)::in,
+    list(rtti_data)::in, list(layout_data)::in, list(comp_gen_c_var)::in,
     list(complexity_proc_info)::in, map(label, data_addr)::in,
     decl_set::in, decl_set::out, io::di, io::uo) is det.
 
-output_c_module_init_list(ModuleName, Modules, Datas, Vars, ComplexityProcs,
-        StackLayoutLabels, !DeclSet, !IO) :-
+output_c_module_init_list(ModuleName, Modules, RttiDatas, LayoutDatas, Vars,
+        ComplexityProcs, StackLayoutLabels, !DeclSet, !IO) :-
     MustInit = (pred(Module::in) is semidet :-
         module_defines_label_with_layout(Module, StackLayoutLabels)
     ),
@@ -441,7 +437,7 @@
             "maybe", 0, !IO)
     ),
 
-    output_c_data_init_list(Datas, !IO),
+    output_c_data_init_list(RttiDatas, !IO),
     % The call to the debugger initialization function is for bootstrapping;
     % once the debugger has been modified to call do_init_modules_debugger()
     % and all debuggable object files created before this change have been
@@ -460,10 +456,10 @@
     io.write_string("\t\treturn;\n", !IO),
     io.write_string("\t}\n", !IO),
     io.write_string("\tdone = MR_TRUE;\n", !IO),
-    output_type_tables_init_list(Datas, !IO),
+    output_type_tables_init_list(RttiDatas, !IO),
     io.write_string("}\n\n", !IO),
 
-    output_debugger_init_list_decls(Datas, !DeclSet, !IO),
+    output_debugger_init_list_decls(LayoutDatas, !DeclSet, !IO),
     io.write_string("\n", !IO),
     io.write_string("void ", !IO),
     output_init_name(ModuleName, !IO),
@@ -474,16 +470,16 @@
     io.write_string("\t\treturn;\n", !IO),
     io.write_string("\t}\n", !IO),
     io.write_string("\tdone = MR_TRUE;\n", !IO),
-    output_debugger_init_list(Datas, !IO),
+    output_debugger_init_list(LayoutDatas, !IO),
     io.write_string("}\n\n", !IO),
 
     io.write_string("#ifdef MR_DEEP_PROFILING\n", !IO),
-    output_write_proc_static_list_decls(Datas, !DeclSet, !IO),
+    output_write_proc_static_list_decls(LayoutDatas, !DeclSet, !IO),
     io.write_string("\nvoid ", !IO),
     output_init_name(ModuleName, !IO),
     io.write_string("write_out_proc_statics(FILE *fp)\n", !IO),
     io.write_string("{\n", !IO),
-    output_write_proc_static_list(Datas, !IO),
+    output_write_proc_static_list(LayoutDatas, !IO),
     io.write_string("}\n", !IO),
     io.write_string("\n#endif\n\n", !IO),
 
@@ -565,45 +561,33 @@
 
     % Output MR_INIT_TYPE_CTOR_INFO(TypeCtorInfo, Typector);
     % for each type_ctor_info defined in this module.
-
-:- pred output_c_data_init_list(list(comp_gen_c_data)::in, io::di, io::uo)
-    is det.
+    %
+:- pred output_c_data_init_list(list(rtti_data)::in, io::di, io::uo) is det.
 
 output_c_data_init_list([], !IO).
 output_c_data_init_list([Data | Datas], !IO) :-
-    ( Data = rtti_data(RttiData) ->
-        rtti_out.init_rtti_data_if_nec(RttiData, !IO)
-    ;
-        true
-    ),
+    rtti_out.init_rtti_data_if_nec(Data, !IO),
     output_c_data_init_list(Datas, !IO).
 
     % Output code to register each type_ctor_info defined in this module.
-
-:- pred output_type_tables_init_list(list(comp_gen_c_data)::in,
-    io::di, io::uo) is det.
+    %
+:- pred output_type_tables_init_list(list(rtti_data)::in, io::di, io::uo)
+    is det.
 
 output_type_tables_init_list([], !IO).
 output_type_tables_init_list([Data | Datas], !IO) :-
-    ( Data = rtti_data(RttiData) ->
-        rtti_out.register_rtti_data_if_nec(RttiData, !IO)
-    ;
-        true
-    ),
+    rtti_out.register_rtti_data_if_nec(Data, !IO),
     output_type_tables_init_list(Datas, !IO).
 
     % Output declarations for each module layout defined in this module
     % (there should only be one, of course).
     %
-:- pred output_debugger_init_list_decls(list(comp_gen_c_data)::in,
+:- pred output_debugger_init_list_decls(list(layout_data)::in,
     decl_set::in, decl_set::out, io::di, io::uo) is det.
 
 output_debugger_init_list_decls([], !DeclSet, !IO).
 output_debugger_init_list_decls([Data | Datas], !DeclSet, !IO) :-
-    (
-        Data = layout_data(LayoutData),
-        LayoutData = module_layout_data(ModuleName, _,_,_,_,_,_,_)
-    ->
+    ( Data = module_layout_data(ModuleName, _, _, _, _, _, _, _) ->
         output_data_addr_decls(layout_addr(module_layout(ModuleName)),
             !DeclSet, !IO)
     ;
@@ -615,15 +599,12 @@
     % for each module layout defined in this module
     % (there should only be one, of course).
     %
-:- pred output_debugger_init_list(list(comp_gen_c_data)::in, io::di, io::uo)
+:- pred output_debugger_init_list(list(layout_data)::in, io::di, io::uo)
     is det.
 
 output_debugger_init_list([], !IO).
 output_debugger_init_list([Data | Datas], !IO) :-
-    (
-        Data = layout_data(LayoutData),
-        LayoutData = module_layout_data(ModuleName, _,_,_,_,_,_,_)
-    ->
+    ( Data = module_layout_data(ModuleName, _, _, _, _, _, _, _) ->
         io.write_string("\tif (MR_register_module_layout != NULL) {\n", !IO),
         io.write_string("\t\t(*MR_register_module_layout)(", !IO),
         io.write_string("\n\t\t\t&", !IO),
@@ -634,30 +615,28 @@
     ),
     output_debugger_init_list(Datas, !IO).
 
-:- pred output_write_proc_static_list_decls(list(comp_gen_c_data)::in,
+:- pred output_write_proc_static_list_decls(list(layout_data)::in,
     decl_set::in, decl_set::out, io::di, io::uo) is det.
 
 output_write_proc_static_list_decls([], !DeclSet, !IO).
 output_write_proc_static_list_decls([Data | Datas], !DeclSet, !IO) :-
     (
-        Data = layout_data(LayoutData),
-        LayoutData = proc_layout_data(_, _, MaybeRest),
+        Data = proc_layout_data(_, _, MaybeRest),
         MaybeRest = proc_id(yes(_), _)
     ->
-        output_maybe_layout_data_decl(LayoutData, !DeclSet, !IO)
+        output_maybe_layout_data_decl(Data, !DeclSet, !IO)
     ;
         true
     ),
     output_write_proc_static_list_decls(Datas, !DeclSet, !IO).
 
-:- pred output_write_proc_static_list(list(comp_gen_c_data)::in,
+:- pred output_write_proc_static_list(list(layout_data)::in,
     io::di, io::uo) is det.
 
 output_write_proc_static_list([], !IO).
 output_write_proc_static_list([Data | Datas], !IO) :-
     (
-        Data = layout_data(LayoutData),
-        LayoutData = proc_layout_data(RttiProcLabel, _, MaybeRest),
+        Data = proc_layout_data(RttiProcLabel, _, MaybeRest),
         MaybeRest = proc_id(yes(_), _)
     ->
         ProcLabel = make_proc_label_from_rtti(RttiProcLabel),
@@ -802,49 +781,6 @@
     io.write_string("_bunch_", !IO),
     io.write_int(Number, !IO).
 
-:- pred classify_comp_gen_c_data(list(comp_gen_c_data)::in,
-    list(scalar_common_data_array)::in, list(scalar_common_data_array)::out,
-    list(vector_common_data_array)::in, list(vector_common_data_array)::out,
-    list(rtti_data)::in, list(rtti_data)::out,
-    list(layout_data)::in, list(layout_data)::out) is det.
-
-classify_comp_gen_c_data([], !ScalarCommonList, !VectorCommonList,
-        !RttiList, !LayoutList).
-classify_comp_gen_c_data([Data | Datas], !ScalarCommonList, !VectorCommonList,
-        !RttiList, !LayoutList) :-
-    (
-        Data = scalar_common_data(ScalarCommonData),
-        !:ScalarCommonList = [ScalarCommonData | !.ScalarCommonList]
-    ;
-        Data = vector_common_data(VectorCommonData),
-        !:VectorCommonList = [VectorCommonData | !.VectorCommonList]
-    ;
-        Data = rtti_data(Rtti),
-        !:RttiList = [Rtti | !.RttiList]
-    ;
-        Data = layout_data(Layout),
-        !:LayoutList = [Layout | !.LayoutList]
-    ),
-    classify_comp_gen_c_data(Datas, !ScalarCommonList, !VectorCommonList,
-        !RttiList, !LayoutList).
-
-    % output_c_data_type_def outputs the given the type definition.
-    % This is needed because some compilers need the type definition
-    % to appear before any use of the type in forward declarations
-    % of static constants.
-    %
-:- pred output_c_data_type_def(comp_gen_c_data::in,
-    decl_set::in, decl_set::out, io::di, io::uo) is det.
-
-output_c_data_type_def(scalar_common_data(ScalarCommonData), !DeclSet, !IO) :-
-    output_scalar_common_data_decl(ScalarCommonData, !DeclSet, !IO).
-output_c_data_type_def(vector_common_data(VectorCommonData), !DeclSet, !IO) :-
-    output_vector_common_data_decl(VectorCommonData, !DeclSet, !IO).
-output_c_data_type_def(rtti_data(RttiData), !DeclSet, !IO) :-
-    output_rtti_data_decl(RttiData, !DeclSet, !IO).
-output_c_data_type_def(layout_data(LayoutData), !DeclSet, !IO) :-
-    output_maybe_layout_data_decl(LayoutData, !DeclSet, !IO).
-
 :- pred output_scalar_common_data_decl(scalar_common_data_array::in,
     decl_set::in, decl_set::out, io::di, io::uo) is det.
 
@@ -933,18 +869,6 @@
     DataAddr = data_addr(ModuleName, tabling_pointer(ProcLabel)),
     decl_set_insert(decl_data_addr(DataAddr), !DeclSet).
 
-:- pred output_comp_gen_c_data(comp_gen_c_data::in,
-    decl_set::in, decl_set::out, io::di, io::uo) is det.
-
-output_comp_gen_c_data(scalar_common_data(ScalarCommonData), !DeclSet, !IO) :-
-    output_scalar_common_data_defn(ScalarCommonData, !DeclSet, !IO).
-output_comp_gen_c_data(vector_common_data(VectorCommonData), !DeclSet, !IO) :-
-    output_vector_common_data_defn(VectorCommonData, !DeclSet, !IO).
-output_comp_gen_c_data(rtti_data(RttiData), !DeclSet, !IO) :-
-    output_rtti_data_defn(RttiData, !DeclSet, !IO).
-output_comp_gen_c_data(layout_data(LayoutData), !DeclSet, !IO) :-
-    output_layout_data_defn(LayoutData, !DeclSet, !IO).
-
 :- pred output_scalar_common_data_defn(scalar_common_data_array::in,
     decl_set::in, decl_set::out, io::di, io::uo) is det.
 
@@ -4462,7 +4386,7 @@
         DataAddr = data_addr(_, DataName),
         DataName = scalar_common_ref(TypeNum, CellNum)
     ->
-        io.write_string("MR_TAG_XCOMMON(", !IO),
+        io.write_string("MR_TAG_COMMON(", !IO),
         io.write_int(Tag, !IO),
         io.write_string(",", !IO),
         io.write_int(TypeNum, !IO),
@@ -4579,16 +4503,16 @@
     % cast them here to avoid type errors. The offset is also in MR_Words.
     (
         MaybeOffset = no,
-        % The tests for special cases below increase the runtime
-        % of the compiler very slightly, but the use of shorter names
-        % reduces the size of the generated C source file, which has
-        % a considerably longer lifetime. In debugging grades, the
-        % file size difference can be very substantial.
+        % The tests for special cases below increase the runtime of the
+        % compiler very slightly, but the use of shorter names reduces the size
+        % of the generated C source file, which has a considerably longer
+        % lifetime. In debugging grades, the file size difference can be
+        % very substantial.
         (
             DataAddr = data_addr(_, DataName),
             DataName = scalar_common_ref(TypeNum, CellNum)
         ->
-            io.write_string("MR_XCOMMON(", !IO),
+            io.write_string("MR_COMMON(", !IO),
             io.write_int(TypeNum, !IO),
             io.write_string(",", !IO),
             io.write_int(CellNum, !IO),
@@ -4626,8 +4550,8 @@
     ;
         Module = Module0
     ),
-    % We don't need to mangle the module name, but we do need to
-    % convert it to a C identifier in the standard fashion.
+    % We don't need to mangle the module name, but we do need to convert it
+    % to a C identifier in the standard fashion.
     ModuleStr = sym_name_mangle(Module),
     ( Arity = 0 ->
         (
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.386
diff -u -b -r1.386 mercury_compile.m
--- compiler/mercury_compile.m	3 May 2006 06:46:15 -0000	1.386
+++ compiler/mercury_compile.m	7 May 2006 03:53:57 -0000
@@ -3989,13 +3989,10 @@
         FactTableObjFiles, !IO) :-
     globals.io_lookup_bool_option(verbose, Verbose, !IO),
     globals.io_lookup_bool_option(statistics, Stats, !IO),
-    %
-    % Here we generate the LLDS representations for
-    % various data structures used for RTTI, type classes,
-    % and stack layouts.
-    % XXX this should perhaps be part of backend_pass
-    % rather than output_pass.
-    %
+
+    % Here we generate the LLDS representations for various data structures
+    % used for RTTI, type classes, and stack layouts.
+    % XXX This should perhaps be part of backend_pass rather than output_pass.
     type_ctor_info.generate_rtti(HLDS, TypeCtorRttiData),
     generate_base_typeclass_info_rtti(HLDS, OldTypeClassInfoRttiData),
     globals.io_lookup_bool_option(new_type_class_rtti, NewTypeClassRtti, !IO),
@@ -4003,29 +4000,25 @@
         NewTypeClassInfoRttiData),
     list.append(OldTypeClassInfoRttiData, NewTypeClassInfoRttiData,
         TypeClassInfoRttiData),
-    list.map(llds.wrap_rtti_data, TypeCtorRttiData, TypeCtorTables),
-    list.map(llds.wrap_rtti_data, TypeClassInfoRttiData, TypeClassInfos),
-    stack_layout.generate_llds(HLDS, GlobalData0, GlobalData, StackLayouts,
+    stack_layout.generate_llds(HLDS, GlobalData0, GlobalData, StackLayoutDatas,
         LayoutLabels),
-    %
+
     % Here we perform some optimizations on the LLDS data.
-    % XXX this should perhaps be part of backend_pass
-    % rather than output_pass.
-    %
-    % XXX We assume that the foreign language we use is C
+    % XXX This should perhaps be part of backend_pass rather than output_pass.
+    % XXX We assume that the foreign language we use is C.
     get_c_interface_info(HLDS, c, C_InterfaceInfo),
     global_data_get_all_proc_vars(GlobalData, GlobalVars),
-    global_data_get_all_closure_layouts(GlobalData, ClosureLayouts),
+    global_data_get_all_closure_layouts(GlobalData, ClosureLayoutDatas),
     global_data_get_static_cell_info(GlobalData, StaticCellInfo),
-    StaticCells = get_static_cells(StaticCellInfo),
+    get_static_cells(StaticCellInfo,
+        ScalarCommonCellDatas, VectorCommonCellDatas),
 
-    %
     % Next we put it all together and output it to one or more C files.
-    %
-    list.condense([StaticCells, ClosureLayouts, StackLayouts,
-        TypeCtorTables, TypeClassInfos], AllData),
-    construct_c_file(HLDS, C_InterfaceInfo, Procs, GlobalVars, AllData, CFile,
-        !IO),
+    RttiDatas = TypeCtorRttiData ++ TypeClassInfoRttiData,
+    LayoutDatas = ClosureLayoutDatas ++ StackLayoutDatas,
+    construct_c_file(HLDS, C_InterfaceInfo, Procs, GlobalVars,
+        ScalarCommonCellDatas, VectorCommonCellDatas, RttiDatas, LayoutDatas,
+        CFile, !IO),
     module_info_get_complexity_proc_infos(HLDS, ComplexityProcs),
     output_llds(ModuleName, CFile, ComplexityProcs, LayoutLabels,
         Verbose, Stats, !IO),
@@ -4033,9 +4026,7 @@
     C_InterfaceInfo = foreign_interface_info(_, _, _, _, C_ExportDecls, _),
     export.produce_header_file(C_ExportDecls, ModuleName, !IO),
 
-    %
     % Finally we invoke the C compiler to compile it.
-    %
     globals.io_lookup_bool_option(target_code_only, TargetCodeOnly, !IO),
     (
         TargetCodeOnly = no,
@@ -4054,12 +4045,15 @@
     ).
 
     % Split the code up into bite-size chunks for the C compiler.
-
+    %
 :- pred construct_c_file(module_info::in, foreign_interface_info::in,
-    list(c_procedure)::in, list(comp_gen_c_var)::in, list(comp_gen_c_data)::in,
-    c_file::out, io::di, io::uo) is det.
+    list(c_procedure)::in, list(comp_gen_c_var)::in,
+    list(scalar_common_data_array)::in, list(vector_common_data_array)::in,
+    list(rtti_data)::in, list(layout_data)::in, c_file::out, io::di, io::uo)
+    is det.
 
-construct_c_file(ModuleInfo, C_InterfaceInfo, Procedures, GlobalVars, AllData,
+construct_c_file(ModuleInfo, C_InterfaceInfo, Procedures, GlobalVars,
+        ScalarCommonCellDatas, VectorCommonCellDatas, RttiDatas, LayoutDatas,
         CFile, !IO) :-
     C_InterfaceInfo = foreign_interface_info(ModuleSymName, C_HeaderCode0,
         C_Includes, C_BodyCode0, _C_ExportDecls, C_ExportDefns),
@@ -4093,7 +4087,8 @@
     module_info_user_final_pred_c_names(ModuleInfo, UserFinalPredCNames),
 
     CFile = c_file(ModuleSymName, C_HeaderCode, C_BodyCode, C_ExportDefns,
-        GlobalVars, AllData, ChunkedModules, UserInitPredCNames,
+        GlobalVars, ScalarCommonCellDatas, VectorCommonCellDatas,
+        RttiDatas, LayoutDatas, ChunkedModules, UserInitPredCNames,
         UserFinalPredCNames).
 
 :- pred foreign_decl_code_is_local(foreign_decl_code::in) is semidet.
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.116
diff -u -b -r1.116 stack_layout.m
--- compiler/stack_layout.m	26 Apr 2006 03:05:39 -0000	1.116
+++ compiler/stack_layout.m	7 May 2006 04:01:45 -0000
@@ -32,6 +32,7 @@
 :- import_module hlds.hlds_pred.
 :- import_module ll_backend.continuation_info.
 :- import_module ll_backend.global_data.
+:- import_module ll_backend.layout.
 :- import_module ll_backend.llds.
 :- import_module mdbcomp.prim_data.
 :- import_module parse_tree.prog_data.
@@ -46,13 +47,13 @@
     % converting it into LLDS data structures.
     %
 :- pred generate_llds(module_info::in, global_data::in, global_data::out,
-    list(comp_gen_c_data)::out, map(label, data_addr)::out) is det.
+    list(layout_data)::out, map(label, data_addr)::out) is det.
 
 :- pred construct_closure_layout(proc_label::in, int::in,
     closure_layout_info::in, proc_label::in, module_name::in,
-    string::in, int::in, pred_origin::in, string::in, static_cell_info::in,
-    static_cell_info::out, assoc_list(rval, llds_type)::out,
-    comp_gen_c_data::out) is det.
+    string::in, int::in, pred_origin::in, string::in,
+    static_cell_info::in, static_cell_info::out,
+    assoc_list(rval, llds_type)::out, layout_data::out) is det.
 
     % Construct a representation of a variable location as a 32-bit
     % integer.
@@ -166,9 +167,9 @@
         ),
         format_label_tables(EffLabelTables, SourceFileLayouts),
         SuppressedEvents = encode_suppressed_events(TraceSuppress),
-        ModuleLayout = layout_data(module_layout_data(ModuleName,
-            StringOffset, ConcatStrings, ProcLayoutNames,
-            SourceFileLayouts, TraceLevel, SuppressedEvents, NumLabels)),
+        ModuleLayout = module_layout_data(ModuleName,
+            StringOffset, ConcatStrings, ProcLayoutNames, SourceFileLayouts,
+            TraceLevel, SuppressedEvents, NumLabels),
         Layouts = [ModuleLayout | Layouts0]
     ;
         TraceLayout = no,
@@ -557,10 +558,8 @@
         More = proc_id(MaybeProcStatic, MaybeExecTrace)
     ),
     ProcLayout = proc_layout_data(RttiProcLabel, Traversal, More),
-    Data = layout_data(ProcLayout),
     LayoutName = proc_layout(RttiProcLabel, Kind),
-    add_proc_layout_data(Data, LayoutName, EntryLabel,
-        !Info),
+    add_proc_layout_data(ProcLayout, LayoutName, EntryLabel, !Info),
     (
         MaybeTableInfo = no
     ;
@@ -920,10 +919,9 @@
     ),
     LayoutData = label_layout_data(ProcLabel, LabelNum, ProcLayoutName,
         MaybePort, MaybeIsHidden, LabelNumber, MaybeGoalPath, MaybeVarInfo),
-    CData = layout_data(LayoutData),
     LayoutName = label_layout(ProcLabel, LabelNum, LabelVars),
     Label = internal(LabelNum, ProcLabel),
-    add_internal_layout_data(CData, Label, LayoutName, !Info),
+    add_internal_layout_data(LayoutData, Label, LayoutName, !Info),
     LabelLayout = {ProcLabel, LabelNum, LabelVars, Internal}.
 
 %---------------------------------------------------------------------------%
@@ -1227,9 +1225,9 @@
         RvalsTypes, Data) :-
     DataAddr = layout_addr(
         closure_proc_id(CallerProcLabel, SeqNo, ClosureProcLabel)),
-    Data = layout_data(closure_proc_id_data(CallerProcLabel, SeqNo,
+    Data = closure_proc_id_data(CallerProcLabel, SeqNo,
         ClosureProcLabel, ModuleName, FileName, LineNumber, Origin, 
-        GoalPath)),
+        GoalPath),
     ProcIdRvalType = const(data_addr_const(DataAddr, no)) - data_ptr,
     ClosureLayoutInfo = closure_layout_info(ClosureArgs, TVarLocnMap),
     construct_closure_arg_rvals(ClosureArgs,
@@ -1605,9 +1603,9 @@
                 procid_stack_layout     :: bool, % generate proc id info?
                 static_code_addresses   :: bool, % have static code addresses?
                 label_counter           :: counter,
-                table_infos             :: list(comp_gen_c_data),
-                proc_layouts            :: list(comp_gen_c_data),
-                internal_layouts        :: list(comp_gen_c_data),
+                table_infos             :: list(layout_data),
+                proc_layouts            :: list(layout_data),
+                internal_layouts        :: list(layout_data),
                 label_set               :: map(label, data_addr),
                                         % The set of labels (both entry
                                         % and internal) with layouts.
@@ -1623,30 +1621,23 @@
                 static_cell_info        :: static_cell_info
             ).
 
-:- pred get_module_info(stack_layout_info::in,
-    module_info::out) is det.
-:- pred get_agc_stack_layout(stack_layout_info::in,
-    bool::out) is det.
-:- pred get_trace_stack_layout(stack_layout_info::in,
-    bool::out) is det.
-:- pred get_procid_stack_layout(stack_layout_info::in,
-    bool::out) is det.
-:- pred get_static_code_addresses(stack_layout_info::in,
-    bool::out) is det.
-:- pred get_table_infos(stack_layout_info::in,
-    list(comp_gen_c_data)::out) is det.
-:- pred get_proc_layout_data(stack_layout_info::in,
-    list(comp_gen_c_data)::out) is det.
-:- pred get_internal_layout_data(stack_layout_info::in,
-    list(comp_gen_c_data)::out) is det.
-:- pred get_label_set(stack_layout_info::in,
-    map(label, data_addr)::out) is det.
-:- pred get_string_table(stack_layout_info::in,
-    string_table::out) is det.
-:- pred get_label_tables(stack_layout_info::in,
-    map(string, label_table)::out) is det.
-:- pred get_static_cell_info(stack_layout_info::in,
-    static_cell_info::out) is det.
+:- pred get_module_info(stack_layout_info::in, module_info::out) is det.
+:- pred get_agc_stack_layout(stack_layout_info::in, bool::out) is det.
+:- pred get_trace_stack_layout(stack_layout_info::in, bool::out) is det.
+:- pred get_procid_stack_layout(stack_layout_info::in, bool::out) is det.
+:- pred get_static_code_addresses(stack_layout_info::in, bool::out) is det.
+:- pred get_table_infos(stack_layout_info::in, list(layout_data)::out) is det.
+:- pred get_proc_layout_data(stack_layout_info::in, list(layout_data)::out)
+    is det.
+:- pred get_internal_layout_data(stack_layout_info::in, list(layout_data)::out)
+    is det.
+:- pred get_label_set(stack_layout_info::in, map(label, data_addr)::out)
+    is det.
+:- pred get_string_table(stack_layout_info::in, string_table::out) is det.
+:- pred get_label_tables(stack_layout_info::in, map(string, label_table)::out)
+    is det.
+:- pred get_static_cell_info(stack_layout_info::in, static_cell_info::out)
+    is det.
 
 get_module_info(LI, LI ^ module_info).
 get_agc_stack_layout(LI, LI ^ agc_stack_layout).
@@ -1674,11 +1665,10 @@
 
 add_table_data(TableIoDeclData, !LI) :-
     TableIoDecls0 = !.LI ^ table_infos,
-    TableIoDecls = [layout_data(TableIoDeclData) | TableIoDecls0],
+    TableIoDecls = [TableIoDeclData | TableIoDecls0],
     !:LI = !.LI ^ table_infos := TableIoDecls.
 
-:- pred add_proc_layout_data(comp_gen_c_data::in,
-    layout_name::in, label::in,
+:- pred add_proc_layout_data(layout_data::in, layout_name::in, label::in,
     stack_layout_info::in, stack_layout_info::out) is det.
 
 add_proc_layout_data(ProcLayout, ProcLayoutName, Label, !LI) :-
@@ -1692,12 +1682,11 @@
     !:LI = !.LI ^ label_set := LabelSet,
     !:LI = !.LI ^ proc_layout_name_list := ProcLayoutNames.
 
-:- pred add_internal_layout_data(comp_gen_c_data::in,
+:- pred add_internal_layout_data(layout_data::in,
     label::in, layout_name::in, stack_layout_info::in,
     stack_layout_info::out) is det.
 
-add_internal_layout_data(InternalLayout, Label, LayoutName,
-        !LI) :-
+add_internal_layout_data(InternalLayout, Label, LayoutName, !LI) :-
     InternalLayouts0 = !.LI ^ internal_layouts,
     InternalLayouts = [InternalLayout | InternalLayouts0],
     LabelSet0 = !.LI ^ label_set,
Index: compiler/transform_llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/transform_llds.m,v
retrieving revision 1.23
diff -u -b -r1.23 transform_llds.m
--- compiler/transform_llds.m	26 Apr 2006 03:05:40 -0000	1.23
+++ compiler/transform_llds.m	7 May 2006 03:52:33 -0000
@@ -65,15 +65,16 @@
 :- pred transform_c_file(c_file::in, c_file::out, globals::in) is det.
 
 transform_c_file(CFile0, CFile, Globals) :-
-    CFile0 = c_file(ModuleName, _, _, _, _, _, Modules0, _, _),
-    % split up large computed gotos
+    ModuleName = CFile0 ^ cfile_modulename,
+    Modules0 = CFile0 ^ cfile_code,
+    % Split up large computed gotos.
     globals.lookup_int_option(Globals, max_jump_table_size, MaxSize),
     ( MaxSize = 0 ->
         Modules1 = Modules0
     ;
         transform_c_module_list(Modules0, Modules1, MaxSize)
     ),
-    % append an end label for accurate GC
+    % Append an end label for accurate GC.
     globals.get_gc_method(Globals, GC),
     (
         GC = accurate,
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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