[m-dev.] for review: RTTI cleanup

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Jan 10 16:12:13 AEDT 2000


For review by Tyson, during his trip or after he gets back. (I would like
to build on this change soon, so I would prefer a review sooner rather
than later.)

Estimated hours taken: 8, plus unknown hours by Tyson.

Remove type_ctor_layouts and type_ctor_functors where not needed.
Simplify type_ctor_layouts by removing code that generates (and
documentations for) particularly representations that are no longer used 
now that we use type_ctor_reps.

Several files also had miscellaneous cleanups and documentation fixes.

compiler/base_type_layout.m:
        Simplify documentation.  

        Remove references to representations in type_ctor_layouts that
        are no longer used.compiler/base_type_layout.m:

compiler/base_type_info.m:
	Keep base_type_info__type_ctor_rep_to_int in sync with
	MR_TypeCtorRepresentation.

runtime/mercury_grade.h:
runtime/mercury_cpp.h:
	Move the definitions of MR_STRINGIFY and MR_PASTEn to the new file
	mercury_cpp.h. Add MR_PASTEn for several new values of n, for use by
	mercury_type_info.h.

runtime/mercury_type_info.h:
	Define macros for creating type_ctor_info structures for builtin types.
	These have NULL layout and functor fields.

	Remove several obsolete macros.

runtime/mercury_layout_util.c:
	Use the new macros for defining a dummy type_ctor_info.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
	Modify the implementation of some RTTI functions to use the layout
	and functors structures only if they are defined.

runtime/mercury_type_info.c:
	Modify MR_collapse_equivalences to use the type_ctor_rep, not the
	functors indicator, to check for equivalence, since the latter is
	not guaranteed to be present.

	Move the type_ctor_info structure for preds/funcs to builtin.m.

library/array.m:
	Use these macros to define the type_ctor_info structure for array.

library/builtin.m:
	Use these macros to define the type_ctor_info structure for int,
	float, character, string, saved succip etc values, and for preds
	and funcs.

library/private_builtin.m:
	Use these macros to define the type_ctor_info structure for type_infos,
	type_ctor_infos, typeclass_infos and base_typeclass_infos.

	Move a c_header_code to the section that needs it.

library/std_util.m:
	Use the new macros to define the type_ctor_info structure for univ
	and for std_util's own type_info type.

	Modify the implementations of some RTTI predicates to use the
	layout and functors structures only if they are defined.

Zoltan.

cvs diff: Diffing .
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/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/base_type_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_type_info.m,v
retrieving revision 1.30
diff -u -b -r1.30 base_type_info.m
--- compiler/base_type_info.m	2000/01/08 08:17:30	1.30
+++ compiler/base_type_info.m	2000/01/10 02:10:16
@@ -255,7 +255,6 @@
 	PredAddrArg = yes(const(code_addr_const(PredAddr))),
 	base_type_info__construct_pred_addrs2(Procs, ModuleInfo, PredAddrArgs).
 
-
 :- type type_ctor_representation 
 	--->	enum
 	;	enum_usereq
@@ -276,10 +275,22 @@
 	;	typeinfo
 	;	typeclassinfo
 	;	array
+	;	succip
+	;	hp
+	;	curfr
+	;	maxfr
+	;	redofr
+	;	redoip
+	;	trail_ptr
+	;	ticket
 	;	unknown.
 
+% This table should be kept in sync with the MR_TypeCtorRepresentation enum
+% in runtime/mercury_type_info.h.
+
 :- pred base_type_info__type_ctor_rep_to_int(type_ctor_representation::in,
 	int::out) is det.
+
 base_type_info__type_ctor_rep_to_int(enum, 		0).
 base_type_info__type_ctor_rep_to_int(enum_usereq,	1).
 base_type_info__type_ctor_rep_to_int(du,		2).
@@ -299,8 +310,15 @@
 base_type_info__type_ctor_rep_to_int(typeinfo,		16).
 base_type_info__type_ctor_rep_to_int(typeclassinfo,	17).
 base_type_info__type_ctor_rep_to_int(array,		18).
-base_type_info__type_ctor_rep_to_int(unknown,		19).
-
+base_type_info__type_ctor_rep_to_int(succip,		19).
+base_type_info__type_ctor_rep_to_int(hp,		20).
+base_type_info__type_ctor_rep_to_int(curfr,		21).
+base_type_info__type_ctor_rep_to_int(maxfr,		22).
+base_type_info__type_ctor_rep_to_int(redofr,		23).
+base_type_info__type_ctor_rep_to_int(redoip,		24).
+base_type_info__type_ctor_rep_to_int(trail_ptr,		25).
+base_type_info__type_ctor_rep_to_int(ticket,		26).
+base_type_info__type_ctor_rep_to_int(unknown,		27).
 
 :- pred base_type_info__construct_type_ctor_representation(hlds_type_defn,
 		maybe(rval)).
@@ -353,6 +371,3 @@
 	),
 	base_type_info__type_ctor_rep_to_int(TypeCtorRep, TypeCtorRepInt),
 	Rvals = yes(const(int_const(TypeCtorRepInt))).
-
-
-
Index: compiler/base_type_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_type_layout.m,v
retrieving revision 1.50
diff -u -b -r1.50 base_type_layout.m
--- compiler/base_type_layout.m	1999/12/13 05:22:57	1.50
+++ compiler/base_type_layout.m	2000/01/08 10:42:01
@@ -1,5 +1,5 @@
 %---------------------------------------------------------------------------%
-% Copyright (C) 1996-1999 The University of Melbourne.
+% Copyright (C) 1996-2000 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.
 %---------------------------------------------------------------------------%
@@ -36,49 +36,33 @@
 %
 % runtime:	mercury_type_info.h	- defines layout macros
 % 		mercury_deep_copy.{c,h}	- deep_copy
-%		mercury_table_any.c	- tabling
+%		mercury_tabling.c	- tabling
 % 		
 % Any module that uses type_ctor_layouts should register itself here.
-% Changes can by minimized by using the macros in type_info.h.
+% Changes can by minimized by using the macros in mercury_type_info.h.
 %
 %---------------------------------------------------------------------------%
+%
 % Data representation: Layout Tables
 %
 % Arrays are created, designed to allow indexing from actual data words.
 %
-% First index on tag:
+% First index on the primary tag of the data.  The value in the
+% layout table will itself have a tag.
 %
-% Tag 0 - 	CONST  Word = type of constant
+% Tag 0 - 	CONST  Word = pointer to enum vector
 %
-% CONST: No further indexing required, look at word in layout 
-%        to find what sort of constant is here. The data word contains
-%        a representation of this sort of constant.
-%
-% Tag 0 - 	CONST   Word = 0	- unassigned
-% Tag 0 - 	CONST   Word = 1	- unused tag
-% Tag 0 - 	CONST   Word = 2	- string
-% Tag 0 - 	CONST   Word = 3	- float
-% Tag 0 - 	CONST   Word = 4	- int
-% Tag 0 - 	CONST   Word = 5	- character
-% Tag 0 - 	CONST   Word = 6	- univ
-% Tag 0 - 	CONST   Word = 7	- pred
-% Tag 0 - 	CONST   Word = 8	- void
-% Tag 0 - 	CONST   Word = 9	- array
-% Tag 0 - 	CONST   Word = 10	- type_info
-% Tag 0 - 	CONST   Word = 11	- c_pointer
-% Tag 0 - 	CONST   Word = 12	- type_class_info
-% 			Words 13 - 1024 reserved for future use
-% Tag 0 - 	CONST   Word = 1024+	- constant(s) 
-% 					  word is pointer to enum
-% 					  vector.
+% CONST: No further indexing required.
+%        The data word contains a representation of this sort of
+%        constant.
 %
 % enum vector:
 %	- 1 or 0 (1 = enumeration, 0 = shared local)
 %	- S, the number of constants sharing this tag
 %	- S strings (functor names)
 %
-% Note that tag 0 value 0 is presently unassigned. This may be used
-% in future for some common case optimization.
+% If the pointer to the enum vector is NULL, then this tag is unused.
+% If code every encounters and unused tag, it is probably an error.
 %
 % Tag 1 - 	UNSHARED  Word = pointer to functor descriptor
 %
@@ -108,36 +92,8 @@
 %	   argument data. Use the secondary tag to index into the F
 %	   argument pointers, which point to a functors descriptors just
 %	   as in UNSHARED above. 
-%
-% Tag 3 - 	VAR/EQ  Word = type variable number, or pointer to 
-% 		 		indicator, equivalent type_ctor_info
-% 		 		and maybe functor.
-%
-% VAR/EQ:  There are 3 cases covered by this tag, all of them forms
-% 	   of equivalences.
-% 	   If under 1024, the rest of the word is a type variable number,
-% 	   that is, the polymophic argument number (starting at 1) of
-% 	   the type. Substitute that variable, and you have the type
-% 	   this type is equivalent to.
-%
-% 	   If over 1024, it's just a pointer to a vector, containing
-% 	   	- an indicator whether this is a no_tag or not
-% 	   	- a pseudo-typeinfo 
-% 	   	- possibly a string constant - the name of the 
-% 	   	  functor if it is a no_tag.
-%	   If the indicator says it isn't a no_tag, the pseudo-typeinfo
-%	   is the type this type is equivalent to. There is no string
-%	   constant.
-%	   If the indicator says it is a no_tag, then the string
-%	   contains the functor, and the pseudo-typeinfo is the
-%	   type of the argument. Except for the functor, this is much 
-%	   the same as an equivalence - the data word has a type
-%	   given by the pseudo-typeinfo (it might be worth taking
-%	   advantage of the fact that the vector for a no_tag type
-%	   is exactly the same as a functors descriptor).
 %
-% 	   In any case, you need to look at the equivalent type
-% 	   to find out what the data word represents.
+% Tag 3 - 	UNUSED.
 %
 %---------------------------------------------------------------------------%
 %
@@ -269,7 +225,6 @@
 :- type tag_category	--->	unshared 	% tagged pointer
 			; 	shared_remote 	% shared tagged pointer
 			;	shared_local	% shared constants
-			; 	no_tag 		% special case of equivalence 
 			; 	unused.		% unused tag
 
 %---------------------------------------------------------------------------%
@@ -464,28 +419,6 @@
 
 %---------------------------------------------------------------------------%
 
-	% Constants - these should be kept in check with the runtime
-	% definitions.
-
-:- type const_sort 	--->	unassigned
-			;	unused
-			;	string
-			;	float
-			;	int
-			;	character
-			;	univ
-			;	predicate.
-
-:- pred base_type_layout__const_value(const_sort::in, int::out) is det.
-base_type_layout__const_value(unassigned, 0).
-base_type_layout__const_value(unused, 1).
-base_type_layout__const_value(string, 2).
-base_type_layout__const_value(float, 3).
-base_type_layout__const_value(int, 4).
-base_type_layout__const_value(character, 5).
-base_type_layout__const_value(univ, 6).
-base_type_layout__const_value(predicate, 7).
-
 	% The value we use to indicate whether a type is an no_tag type
 	
 :- pred base_type_layout__no_tag_indicator(bool::in, int::out) is det.
@@ -506,7 +439,6 @@
 base_type_layout__tag_value(shared_local, 0).
 base_type_layout__tag_value(unshared, 1).
 base_type_layout__tag_value(shared_remote, 2).
-base_type_layout__tag_value(no_tag, 3).
 base_type_layout__tag_value(unused, 0).
 
 :- pred base_type_layout__tag_value_const(int::out) is det.
@@ -610,17 +542,17 @@
 	base_type_layout__tag_value_const(Tag),
 	(
 		ConsTag = string_constant(_),
-		base_type_layout__const_value(string, Value),
+		Value = 0,
 		base_type_layout__encode_mkword(LayoutInfo, Tag, 
 			const(int_const(Value)), Rval)
 	;
 		ConsTag = float_constant(_),
-		base_type_layout__const_value(float, Value),
+		Value = 0,
 		base_type_layout__encode_mkword(LayoutInfo, Tag, 
 			const(int_const(Value)), Rval)
 	;
 		ConsTag = int_constant(_),
-		base_type_layout__const_value(int, Value),
+		Value = 0,
 		base_type_layout__encode_mkword(LayoutInfo, Tag, 
 			const(int_const(Value)), Rval)
 	;
@@ -851,12 +783,9 @@
 			LayoutInfo1, Rval),
 		list__append(Rval, Rvals0, Rvals1)
 	;
-		Tag = no_tag,
-		error("type_ctor_layout: unexpected no_tag")
-	;
 		Tag = unused,
 		LayoutInfo1 = LayoutInfo0,
-		base_type_layout__const_value(unused, Value),
+		Value = 0,
 		base_type_layout__tag_value(unused, TagValue),
 		base_type_layout__encode_mkword(LayoutInfo1, TagValue, 
 			const(int_const(Value)), Rval),
@@ -1444,7 +1373,7 @@
 	shared_remote).
 base_type_layout__tag_type_and_value(shared_local_tag(Tag, _), Tag, 
 	shared_local).
-base_type_layout__tag_type_and_value(no_tag, -1, no_tag). 
+base_type_layout__tag_type_and_value(no_tag, -1, unused). 
 base_type_layout__tag_type_and_value(string_constant(_), -1, unused). 
 base_type_layout__tag_type_and_value(float_constant(_), -1, unused). 
 base_type_layout__tag_type_and_value(int_constant(_), -1, unused). 
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
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/dynamic_linking
cvs diff: Diffing extras/graphics
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/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
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/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
Index: library/array.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/array.m,v
retrieving revision 1.66
diff -u -b -r1.66 array.m
--- library/array.m	1999/11/25 09:09:37	1.66
+++ library/array.m	2000/01/08 10:05:20
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1993-1995, 1997-1999 The University of Melbourne.
+% Copyright (C) 1993-1995, 1997-2000 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -271,39 +271,7 @@
 
 :- pragma c_code("
 
-Define_extern_entry(mercury____Unify___array__array_1_0);
-Define_extern_entry(mercury____Index___array__array_1_0);
-Define_extern_entry(mercury____Compare___array__array_1_0);
-
-MR_MODULE_STATIC_OR_EXTERN 
-const struct mercury_data_array__type_ctor_layout_array_1_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data_array__type_ctor_layout_array_1 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_ARRAY_VALUE))
-};
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data_array__type_ctor_functors_array_1_struct {
-	Integer f1;
-} mercury_data_array__type_ctor_functors_array_1 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data_array__type_ctor_info_array_1 = {
-	(Integer) 1,
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Unify___array__array_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Index___array__array_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Compare___array__array_1_0)),
-	MR_TYPECTOR_REP_ARRAY,
-	(Word *) &mercury_data_array__type_ctor_functors_array_1,
-	(Word *) &mercury_data_array__type_ctor_layout_array_1,
-	MR_string_const(""array"", 5),
-	MR_string_const(""array"", 5),
-	MR_RTTI_VERSION
-};
-
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(array, array, 1, MR_TYPECTOR_REP_ARRAY);
 
 Declare_entry(mercury__array__array_equal_2_0);
 Declare_entry(mercury__array__array_compare_3_0);
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.26
diff -u -b -r1.26 builtin.m
--- library/builtin.m	1999/11/15 10:12:03	1.26
+++ library/builtin.m	2000/01/08 10:05:20
@@ -241,505 +241,93 @@
 
 :- pragma c_code("
 
-
-	/* type_ctor_layout definitions */ 
-
-	/* type_ctor_layout for `int' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_int_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_int_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_INT_VALUE))
-};
-
-	/* type_ctor_layout for `character' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_character_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_character_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_CHARACTER_VALUE))
-};
-
-	/* type_ctor_layout for `string' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_string_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_string_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_STRING_VALUE))
-};
-
-	/* type_ctor_layout for `float' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_float_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_float_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_FLOAT_VALUE))
-};
-
-	/* type_ctor_layout for `void' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_void_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_void_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_VOID_VALUE))
-};
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , int, 0,
+	MR_TYPECTOR_REP_INT,
+	mercury__builtin_unify_int_2_0,
+	mercury__builtin_index_int_2_0,
+	mercury__builtin_compare_int_3_0);
 
-#ifdef	NATIVE_GC
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , character, 0,
+	MR_TYPECTOR_REP_CHAR,
+	mercury__builtin_unify_character_2_0,
+	mercury__builtin_index_character_2_0,
+	mercury__builtin_compare_character_3_0);
 
-	/* type_ctor_layout for `succip' (only used by accurate gc) */
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , string, 0,
+	MR_TYPECTOR_REP_STRING,
+	mercury__builtin_unify_string_2_0,
+	mercury__builtin_index_string_2_0,
+	mercury__builtin_compare_string_3_0);
 
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_succip_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_succip_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_SUCCIP_VALUE))
-};
-
-	/* type_ctor_layout for `hp' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_hp_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_hp_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_HP_VALUE))
-};
-
-	/* type_ctor_layout for `curfr' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_curfr_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_curfr_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_CURFR_VALUE))
-};
-
-	/* type_ctor_layout for `maxfr' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_maxfr_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_maxfr_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_MAXFR_VALUE))
-};
-
-	/* type_ctor_layout for `redofr' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_redofr_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_redofr_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_REDOFR_VALUE))
-};
-
-	/* type_ctor_layout for `redoip' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_redoip_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_redoip_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_REDOIP_VALUE))
-};
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , float, 0,
+	MR_TYPECTOR_REP_FLOAT,
+	mercury__builtin_unify_float_2_0,
+	mercury__builtin_index_float_2_0,
+	mercury__builtin_compare_float_3_0);
 
-#endif /* NATIVE_GC */
+	/* 
+	** One of the following two is used for all higher-order types.
+	** Note that they use the same three predicates.
+	*/
 
-	/* type_ctor_layout for `trail ptr' (only used by agc and debugger) */
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , func, 0,
+	MR_TYPECTOR_REP_PRED,
+	mercury__builtin_unify_pred_2_0,
+	mercury__builtin_index_pred_2_0,
+	mercury__builtin_compare_pred_3_0);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , pred, 0,
+	MR_TYPECTOR_REP_PRED,
+	mercury__builtin_unify_pred_2_0,
+	mercury__builtin_index_pred_2_0,
+	mercury__builtin_compare_pred_3_0);
 
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_trail_ptr_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_trail_ptr_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_TRAIL_PTR_VALUE))
-};
-
-	/* type_ctor_layout for `ticket' (only used by agc and debugger) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_layout_ticket_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_ticket_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_TICKET_VALUE))
-};
-
-	/* type_ctor_functors definitions */
-
-	/* type_ctor_functors for `int' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_int_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_int_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `character' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_character_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_character_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `string' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_string_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_string_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `float' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_float_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_float_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `void' */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_void_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_void_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(void, 0, MR_TYPECTOR_REP_VOID);
 
 #ifdef	NATIVE_GC
 
-	/* type_ctor_functors for `succip' (only used by accurate gc) */
+/*
+** The following type_ctor_infos are used only by accurate gc.
+*/
 
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_succip_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_succip_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `hp' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_hp_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_hp_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `curfr' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_curfr_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_curfr_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `maxfr' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_maxfr_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_maxfr_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `redofr' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_redofr_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_redofr_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `redoip' (only used by accurate gc) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_redoip_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_redoip_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(succip, 0, MR_TYPECTOR_REP_SUCCIP);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(hp, 0, MR_TYPECTOR_REP_HP);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(curfr, 0, MR_TYPECTOR_REP_CURFR);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(maxfr, 0, MR_TYPECTOR_REP_MAXFR);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(redofr, 0, MR_TYPECTOR_REP_REDOFR);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(redoip, 0, MR_TYPECTOR_REP_REDOIP);
 
 #endif /* NATIVE_GC */
-
-	/* type_ctor_functors for `trail ptr' (only used by agc and debugger) */
 
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_trail_ptr_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_trail_ptr_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_functors for `ticket' (only used by agc and debugger) */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data___type_ctor_functors_ticket_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_ticket_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* type_ctor_infos definitions */
-
-	/* type_ctor_info for `int' */
-
-Declare_entry(mercury__builtin_unify_int_2_0);
-Declare_entry(mercury__builtin_index_int_2_0);
-Declare_entry(mercury__builtin_compare_int_3_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_int_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_unify_int_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_index_int_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_compare_int_3_0)),
-	MR_TYPECTOR_REP_INT,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_int_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_int_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""int"", 3),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `character' */
-
-Declare_entry(mercury__builtin_unify_character_2_0);
-Declare_entry(mercury__builtin_index_character_2_0);
-Declare_entry(mercury__builtin_compare_character_3_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_character_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_unify_character_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_index_character_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_compare_character_3_0)),
-	MR_TYPECTOR_REP_CHAR,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_character_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_character_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""character"", 9),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `string' */
-
-Declare_entry(mercury__builtin_unify_string_2_0);
-Declare_entry(mercury__builtin_index_string_2_0);
-Declare_entry(mercury__builtin_compare_string_3_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_string_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_unify_string_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_index_string_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_compare_string_3_0)),
-	MR_TYPECTOR_REP_STRING,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_string_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_string_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""string"", 6),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `float' */
-
-Declare_entry(mercury__builtin_unify_float_2_0);
-Declare_entry(mercury__builtin_index_float_2_0);
-Declare_entry(mercury__builtin_compare_float_3_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_float_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_unify_float_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_index_float_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_compare_float_3_0)),
-	MR_TYPECTOR_REP_FLOAT,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_float_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_float_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""float"", 5),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `void' */
-
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_void_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_VOID,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_void_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_void_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""void"", 4),
-	MR_RTTI_VERSION
-};
-
-#ifdef	NATIVE_GC
-
-	/* type_ctor_info for `succip' (only used by accurate gc) */
-
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_succip_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_SUCCIP,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_succip_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_succip_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""succip"", 6),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `hp' (only used by accurate gc) */
-
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_hp_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_HP,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_hp_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_hp_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""hp"", 2),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `curfr' (only used by accurate gc) */
-
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_curfr_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_CURFR,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_curfr_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_curfr_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""curfr"", 5),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `maxfr' (only used by accurate gc) */
-
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_maxfr_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_MAXFR,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_maxfr_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_maxfr_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""maxfr"", 5),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `redofr' (only used by accurate gc) */
-
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_redofr_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_REDOFR,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_redofr_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_redofr_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""redofr"", 6),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `redoip' (only used by accurate gc) */
-
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_redoip_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_REDOIP,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_redoip_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_redoip_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""redoip"", 6),
-	MR_RTTI_VERSION
-};
-
-#endif /* NATIVE_GC */
+/*
+** The following type_ctor_infos are used both accurate gc and by the debugger.
+*/
 
-	/* type_ctor_info for `trai ptr' (only used by agc and debugger) */
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(trailptr, 0, MR_TYPECTOR_REP_TRAIL_PTR);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(ticket, 0, MR_TYPECTOR_REP_TICKET);
 
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_trail_ptr_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_TRAIL_PTR,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_trail_ptr_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_trail_ptr_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""trail_ptr"", 9),
-	MR_RTTI_VERSION
-};
-
-	/* type_ctor_info for `ticket' (only used by agc and debugger) */
-
-Declare_entry(mercury__unused_0_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_ticket_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__unused_0_0)),
-	MR_TYPECTOR_REP_TICKET,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_ticket_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_ticket_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""ticket"", 6),
-	MR_RTTI_VERSION
-};
+Define_extern_entry(mercury__builtin_unify_pred_2_0);
+Define_extern_entry(mercury__builtin_index_pred_2_0);
+Define_extern_entry(mercury__builtin_compare_pred_3_0);
 
 BEGIN_MODULE(builtin_types_module)
-
+	init_entry_ai(mercury__builtin_unify_pred_2_0);
+	init_entry_ai(mercury__builtin_index_pred_2_0);
+	init_entry_ai(mercury__builtin_compare_pred_3_0);
 BEGIN_CODE
+/* code for predicate 'builtin_unify_pred'/2 in mode 0 */
+Define_entry(mercury__builtin_unify_pred_2_0);
+	MR_incr_sp_push_msg(2, ""private_builtin:builtin_unify_pred"");
+	fatal_error(""attempted unification of higher-order terms"");
+
+/* code for predicate 'builtin_index_pred'/2 in mode 0 */
+Define_entry(mercury__builtin_index_pred_2_0);
+	r1 = (Integer) -1;
+	proceed();
 
+/* code for predicate 'builtin_compare_pred'/3 in mode 0 */
+Define_entry(mercury__builtin_compare_pred_3_0);
+	MR_incr_sp_push_msg(2, ""private_builtin:builtin_compare_pred"");
+	fatal_error(""attempted comparison of higher-order terms"");
 END_MODULE
 
 /*
@@ -747,7 +335,8 @@
 */
 MR_MODULE_STATIC_OR_EXTERN ModuleFunc builtin_types_module;
 extern void mercury__private_builtin__init(void);
-void sys_init_builtin_types_module(void);
+
+void sys_init_builtin_types_module(void); /* suppress gcc warning */
 void sys_init_builtin_types_module(void) {
 
 	builtin_types_module();
@@ -769,6 +358,10 @@
 		mercury_data___type_ctor_info_character_0, _character_);
 	MR_INIT_BUILTIN_TYPE_CTOR_INFO(
 		mercury_data___type_ctor_info_string_0, _string_);
+	MR_INIT_BUILTIN_TYPE_CTOR_INFO(
+		mercury_data___type_ctor_info_pred_0, _pred_);
+	MR_INIT_BUILTIN_TYPE_CTOR_INFO(
+		mercury_data___type_ctor_info_func_0, _pred_);
 	MR_INIT_TYPE_CTOR_INFO_WITH_PRED(
 		mercury_data___type_ctor_info_void_0, mercury__unused_0_0);
 }
@@ -859,46 +452,11 @@
 
 :- pragma c_code("
 
-/*
- * c_pointer has a special value reserved for its layout, since it needs to
- * be handled as a special case.
- */
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data_builtin__type_ctor_layout_c_pointer_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data_builtin__type_ctor_layout_c_pointer_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_C_POINTER_VALUE))
-};
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct
-mercury_data_builtin__type_ctor_functors_c_pointer_0_struct {
-	Integer f1;
-} mercury_data_builtin__type_ctor_functors_c_pointer_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-Define_extern_entry(mercury____Unify___builtin__c_pointer_0_0);
-Define_extern_entry(mercury____Index___builtin__c_pointer_0_0);
-Define_extern_entry(mercury____Compare___builtin__c_pointer_0_0);
-
-
-const struct MR_TypeCtorInfo_struct
-mercury_data_builtin__type_ctor_info_c_pointer_0 = {
-	(Integer) 0,
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Unify___builtin__c_pointer_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Index___builtin__c_pointer_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Compare___builtin__c_pointer_0_0)),
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_PRED(builtin, c_pointer, 0,
 	MR_TYPECTOR_REP_C_POINTER,
-	(MR_TypeCtorFunctors) &mercury_data_builtin__type_ctor_functors_c_pointer_0,
-	(MR_TypeCtorLayout) &mercury_data_builtin__type_ctor_layout_c_pointer_0,
-	MR_string_const(""builtin"", 7),
-	MR_string_const(""c_pointer"", 9),
-	MR_RTTI_VERSION
-};
-
+	mercury____Unify___builtin__c_pointer_0_0,
+	mercury____Index___builtin__c_pointer_0_0,
+	mercury____Compare___builtin__c_pointer_0_0);
 
 BEGIN_MODULE(unify_c_pointer_module)
 	init_entry(mercury____Unify___builtin__c_pointer_0_0);
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.37
diff -u -b -r1.37 private_builtin.m
--- library/private_builtin.m	2000/01/09 23:24:12	1.37
+++ library/private_builtin.m	2000/01/10 01:25:30
@@ -278,151 +278,29 @@
 
 	% The definitions for type_ctor_info/1 and type_info/1.
 
-:- pragma c_header_code("
-
-extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-	mercury_data___type_ctor_info_int_0;
-extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-	mercury_data___type_ctor_info_string_0;
-extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-	mercury_data___type_ctor_info_float_0;
-extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-	mercury_data___type_ctor_info_character_0;
-
-").
-
 :- pragma c_code("
 
-Define_extern_entry(mercury____Unify___private_builtin__type_info_1_0);
-Define_extern_entry(mercury____Index___private_builtin__type_info_1_0);
-Define_extern_entry(mercury____Compare___private_builtin__type_info_1_0);
-
-extern const struct
-	mercury_data_private_builtin__type_ctor_layout_type_info_1_struct
-	mercury_data_private_builtin__type_ctor_layout_type_info_1;
-extern const struct
-	mercury_data_private_builtin__type_ctor_functors_type_info_1_struct
-	mercury_data_private_builtin__type_ctor_functors_type_info_1;
-
 	/*
 	** For most purposes, type_ctor_info can be treated just like
 	** type_info.  The code that handles type_infos can also handle
 	** type_ctor_infos.
 	*/
 
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data_private_builtin__type_ctor_info_type_ctor_info_1 = {
-	((Integer) 1),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Unify___private_builtin__type_info_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Index___private_builtin__type_info_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Compare___private_builtin__type_info_1_0)),
-	MR_TYPECTOR_REP_TYPEINFO,
-	(MR_TypeCtorFunctors) &
-	    mercury_data_private_builtin__type_ctor_functors_type_info_1,
-	(MR_TypeCtorLayout) &
-		mercury_data_private_builtin__type_ctor_layout_type_info_1,
-	MR_string_const(""private_builtin"", 15),
-	MR_string_const(""type_ctor_info"", 14),
-	MR_RTTI_VERSION
-};
-
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data_private_builtin__type_ctor_info_type_info_1 = {
-	((Integer) 1),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Unify___private_builtin__type_info_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Index___private_builtin__type_info_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Compare___private_builtin__type_info_1_0)),
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_PRED(private_builtin, type_ctor_info, 1,
 	MR_TYPECTOR_REP_TYPEINFO,
-	(MR_TypeCtorFunctors) &
-		mercury_data_private_builtin__type_ctor_functors_type_info_1,
-	(MR_TypeCtorLayout) &
-		mercury_data_private_builtin__type_ctor_layout_type_info_1,
-	MR_string_const(""private_builtin"", 15),
-	MR_string_const(""type_info"", 9),
-	MR_RTTI_VERSION
-};
-
-const struct mercury_data_private_builtin__type_ctor_layout_type_info_1_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data_private_builtin__type_ctor_layout_type_info_1 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG,
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_TYPEINFO_VALUE))
-};
-
-const struct mercury_data_private_builtin__type_ctor_functors_type_info_1_struct {
-	Integer f1;
-} mercury_data_private_builtin__type_ctor_functors_type_info_1 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-Define_extern_entry(mercury____Unify___private_builtin__typeclass_info_1_0);
-Define_extern_entry(mercury____Index___private_builtin__typeclass_info_1_0);
-Define_extern_entry(mercury____Compare___private_builtin__typeclass_info_1_0);
-
-extern const struct
-	mercury_data_private_builtin__type_ctor_layout_typeclass_info_1_struct 
-	mercury_data_private_builtin__type_ctor_layout_typeclass_info_1;
-extern const struct
-	mercury_data_private_builtin__type_ctor_functors_typeclass_info_1_struct
-	mercury_data_private_builtin__type_ctor_functors_typeclass_info_1;
-
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data_private_builtin__type_ctor_info_base_typeclass_info_1 = {
-	((Integer) 1),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Unify___private_builtin__typeclass_info_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Index___private_builtin__typeclass_info_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Compare___private_builtin__typeclass_info_1_0)),
-	MR_TYPECTOR_REP_TYPECLASSINFO,
-	(MR_TypeCtorFunctors) &
-	    mercury_data_private_builtin__type_ctor_functors_typeclass_info_1,
-	(MR_TypeCtorLayout) &
-	    mercury_data_private_builtin__type_ctor_layout_typeclass_info_1,
-	MR_string_const(""private_builtin"", 15),
-	MR_string_const(""base_typeclass_info"", 19),
-	MR_RTTI_VERSION
-};
-
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data_private_builtin__type_ctor_info_typeclass_info_1 = {
-	((Integer) 1),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Unify___private_builtin__typeclass_info_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Index___private_builtin__typeclass_info_1_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(
-		mercury____Compare___private_builtin__typeclass_info_1_0)),
+	mercury____Unify___private_builtin__type_info_1_0,
+	mercury____Index___private_builtin__type_info_1_0,
+	mercury____Compare___private_builtin__type_info_1_0);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, type_info, 1,
+	MR_TYPECTOR_REP_TYPEINFO);
+
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_PRED(private_builtin, base_typeclass_info, 1,
 	MR_TYPECTOR_REP_TYPECLASSINFO,
-	(MR_TypeCtorFunctors) &
-	    mercury_data_private_builtin__type_ctor_functors_typeclass_info_1,
-	(MR_TypeCtorLayout) &
-	    mercury_data_private_builtin__type_ctor_layout_typeclass_info_1,
-	MR_string_const(""private_builtin"", 15),
-	MR_string_const(""typeclass_info"", 14),
-	MR_RTTI_VERSION
-};
-
-const struct
-mercury_data_private_builtin__type_ctor_layout_typeclass_info_1_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data_private_builtin__type_ctor_layout_typeclass_info_1 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_TYPECLASSINFO_VALUE))
-};
-
-const struct mercury_data_private_builtin__type_ctor_functors_typeclass_info_1_struct {
-	Integer f1;
-} mercury_data_private_builtin__type_ctor_functors_typeclass_info_1 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
+	mercury____Unify___private_builtin__typeclass_info_1_0,
+	mercury____Index___private_builtin__typeclass_info_1_0,
+	mercury____Compare___private_builtin__typeclass_info_1_0);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, typeclass_info, 1,
+	MR_TYPECTOR_REP_TYPECLASSINFO);
 
 BEGIN_MODULE(type_info_module)
 	init_entry(mercury____Unify___private_builtin__type_info_1_0);
@@ -1223,6 +1101,19 @@
 %-----------------------------------------------------------------------------%
 
 :- implementation.
+
+:- pragma c_header_code("
+
+extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
+	mercury_data___type_ctor_info_int_0;
+extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
+	mercury_data___type_ctor_info_string_0;
+extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
+	mercury_data___type_ctor_info_float_0;
+extern MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
+	mercury_data___type_ctor_info_character_0;
+
+").
 
 :- pragma c_code(table_lookup_insert_int(T0::in, I::in, T::out),
 		will_not_call_mercury, "
Index: library/std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.177
diff -u -b -r1.177 std_util.m
--- library/std_util.m	1999/12/11 15:41:06	1.177
+++ library/std_util.m	2000/01/10 02:00:06
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1994-1999 The University of Melbourne.
+% Copyright (C) 1994-2000 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -75,7 +75,6 @@
 	%
 :- func univ_type(univ) = type_info.
 
-
 	% univ_value(Univ):
 	%	returns the value of the object stored in Univ.
 :- some [T] func univ_value(univ) = T.
@@ -495,7 +494,6 @@
 snd(P,X) :-
 	X = snd(P).
 
-
 maybe_pred(Pred, X, Y) :-
 	(
 		call(Pred, X, Z)
@@ -934,7 +932,6 @@
 
 #include ""mercury_type_info.h""
 
-
 ").
 
 % :- pred type_to_univ(T, univ).
@@ -987,80 +984,22 @@
 
 :- pragma c_code("
 
-/*
- * Univ has a special value reserved for its layout, since it needs to
- * be handled as a special case. See above for information on 
- * the representation of data of type `univ'.
- */
-
-Declare_entry(mercury____Unify___std_util__univ_0_0);
-Declare_entry(mercury____Index___std_util__univ_0_0);
-Declare_entry(mercury____Compare___std_util__univ_0_0);
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data_std_util__type_ctor_functors_univ_0_struct {
-	Integer f1;
-} mercury_data_std_util__type_ctor_functors_univ_0 = {
-	MR_TYPE_CTOR_FUNCTORS_UNIV
-};
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data_std_util__type_ctor_layout_univ_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data_std_util__type_ctor_layout_univ_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_UNIV_VALUE))
-};
-
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data_std_util__type_ctor_info_univ_0 = {
-	(Integer) 0,
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Unify___std_util__univ_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Index___std_util__univ_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Compare___std_util__univ_0_0)),
-	MR_TYPECTOR_REP_UNIV,
-	(Word *) &mercury_data_std_util__type_ctor_functors_univ_0,
-	(Word *) &mercury_data_std_util__type_ctor_layout_univ_0,
-	MR_string_const(""std_util"", 8),
-	MR_string_const(""univ"", 4),
-	MR_RTTI_VERSION
-};
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct mercury_data_std_util__type_ctor_layout_type_info_0_struct
-{
-	TYPE_LAYOUT_FIELDS
-} mercury_data_std_util__type_ctor_layout_type_info_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_TYPEINFO_VALUE))
-};
-
-MR_MODULE_STATIC_OR_EXTERN
-const struct
-mercury_data_std_util__type_ctor_functors_type_info_0_struct {
-	Integer f1;
-} mercury_data_std_util__type_ctor_functors_type_info_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-Declare_entry(mercury____Unify___std_util__type_info_0_0);
-Declare_entry(mercury____Index___std_util__type_info_0_0);
-Declare_entry(mercury____Compare___std_util__type_info_0_0);
-
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data_std_util__type_ctor_info_type_info_0 = {
-	(Integer) 0,
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Unify___std_util__type_info_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Index___std_util__type_info_0_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury____Compare___std_util__type_info_0_0)),
-	(Integer) 15,
-	(Word *) &mercury_data_std_util__type_ctor_functors_type_info_0,
-	(Word *) &mercury_data_std_util__type_ctor_layout_type_info_0,
-	MR_string_const(""std_util"", 8),
-	MR_string_const(""type_info"", 9),
-	MR_RTTI_VERSION
-};
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(std_util, type_info, 0,
+	MR_TYPECTOR_REP_C_POINTER);
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(std_util, univ, 0,
+	MR_TYPECTOR_REP_UNIV);
+
+#ifndef	COMPACT_ARGS
+
+Declare_label(mercury____Compare___std_util__univ_0_0_i1);
+
+MR_MAKE_PROC_LAYOUT(mercury____Compare___std_util__univ_0_0,
+	MR_DETISM_DET, 1, MR_LONG_LVAL_STACKVAR(1),
+	MR_PREDICATE, ""std_util"", ""compare_univ"", 3, 0);
+MR_MAKE_INTERNAL_LAYOUT(mercury____Compare___std_util__univ_0_0, 1);
 
+#endif
+
 Define_extern_entry(mercury____Unify___std_util__type_info_0_0);
 Define_extern_entry(mercury____Index___std_util__type_info_0_0);
 Define_extern_entry(mercury____Compare___std_util__type_info_0_0);
@@ -1221,7 +1160,6 @@
 
 	% Code for type manipulation.
 
-
 	% Prototypes and type definitions.
 
 :- pragma c_header_code("
@@ -1250,7 +1188,6 @@
 
 ").
 
-
 	% A type_ctor_info is really just a subtype of type_info,
 	% but we should hide this from users as it is an implementation
 	% detail.
@@ -1377,12 +1314,10 @@
 MR_DECLARE_TYPE_CTOR_INFO_STRUCT(mercury_data___type_ctor_info_pred_0);
 MR_DECLARE_TYPE_CTOR_INFO_STRUCT(mercury_data___type_ctor_info_func_0);
 
-
 ").
 
 :- pragma c_code("
 
-
 Word ML_make_ctor_info(Word *type_info, MR_TypeCtorInfo type_ctor_info)
 {
 	Word ctor_info = (Word) type_ctor_info;
@@ -1407,7 +1342,6 @@
 
 ").
 
-
 :- pragma c_code(type_ctor_and_args(TypeInfo::in,
 		TypeCtor::out, TypeArgs::out), will_not_call_mercury, "
 {
@@ -1511,17 +1445,17 @@
 {
 	MR_TypeCtorInfo type_ctor = (MR_TypeCtorInfo) TypeCtor;
 
+	/* XXX zs: I think this code is wrong */
 	if (MR_TYPECTOR_IS_HIGHER_ORDER(type_ctor)) {
-		TypeCtorName = (String) (Word) 
-			MR_TYPECTOR_GET_HOT_NAME(type_ctor);
 		TypeCtorModuleName = (String) (Word) 
 			MR_TYPECTOR_GET_HOT_MODULE_NAME(type_ctor);
+		TypeCtorName = (String) (Word)
+			MR_TYPECTOR_GET_HOT_NAME(type_ctor);
 		TypeCtorArity = MR_TYPECTOR_GET_HOT_ARITY(type_ctor);
 	} else {
-		TypeCtorName = MR_TYPE_CTOR_INFO_GET_TYPE_NAME(type_ctor);
+		TypeCtorModuleName = type_ctor->type_ctor_module_name;
+		TypeCtorName = type_ctor->type_ctor_name;
 		TypeCtorArity = MR_TYPE_CTOR_INFO_GET_TYPE_ARITY(type_ctor);
-		TypeCtorModuleName = 
-			MR_TYPE_CTOR_INFO_GET_TYPE_MODULE_NAME(type_ctor);
 	}
 }
 ").
@@ -1574,6 +1508,7 @@
 :- pragma c_code(construct(TypeInfo::in, FunctorNumber::in, ArgList::in) =
 	(Term::out), will_not_call_mercury, "
 {
+	MR_TypeCtorInfo		type_ctor_info;
 	Word 	layout_entry, new_data, term_vector;
 	ML_Construct_Info info;
 	bool success;
@@ -1597,10 +1532,12 @@
 		** 
 		*/
 	if (success) {
+
+		type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(
+			(Word *) TypeInfo);
 
-		layout_entry = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_LAYOUT_ENTRY(
-			MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) TypeInfo), 
-				info.primary_tag);
+		layout_entry = type_ctor_info->type_ctor_layout[
+			info.primary_tag];
 
 		if (info.vector_type == MR_TYPE_CTOR_FUNCTORS_ENUM) {
 			/*
@@ -1712,13 +1649,19 @@
 	*/
 
 static int 
-ML_get_functor_info(Word type_info, int functor_number, ML_Construct_Info *info)
+ML_get_functor_info(Word type_info, int functor_number,
+	ML_Construct_Info *info)
 {
+	MR_TypeCtorInfo		type_ctor_info;
 	Word *type_ctor_functors;
 
-	type_ctor_functors = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_FUNCTORS(
-		MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) type_info));
+	type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) type_info);
+	if (! MR_type_ctor_rep_is_basically_du(type_ctor_info->type_ctor_rep))
+	{
+		return FALSE;
+	}
 
+	type_ctor_functors = type_ctor_info->type_ctor_functors;
 	info->vector_type = MR_TYPE_CTOR_FUNCTORS_INDICATOR(type_ctor_functors);
 
 	switch (info->vector_type) {
@@ -1856,7 +1799,6 @@
 	}
 }
 
-
 	/*
 	** ML_make_type(arity, type_ctor_info, arg_types_list):
 	**
@@ -1914,7 +1856,6 @@
 	}
 }
 
-
 	/*
 	** ML_get_functors_check_range:
 	**
@@ -1939,7 +1880,6 @@
 		ML_get_functor_info(type_info, functor_number, info);
 }
 
-
 	/* 
 	** ML_copy_argument_typeinfos:
 	**
@@ -1983,7 +1923,6 @@
 	return type_info_list;
 }
 
-
 	/* 
 	** ML_get_num_functors:
 	**
@@ -1997,21 +1936,27 @@
 int 
 ML_get_num_functors(Word type_info)
 {
+	MR_TypeCtorInfo	type_ctor_info;
 	Word *type_ctor_functors;
-	int Functors;
+	int		functors;
+
+	type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) type_info);
+	if (! MR_type_ctor_rep_is_basically_du(type_ctor_info->type_ctor_rep))
+	{
+		return -1;
+	}
 
-	type_ctor_functors = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_FUNCTORS(
-		MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) type_info));
+	type_ctor_functors = type_ctor_info->type_ctor_functors;
 
 	switch ((int) MR_TYPE_CTOR_FUNCTORS_INDICATOR(type_ctor_functors)) {
 
 		case MR_TYPE_CTOR_FUNCTORS_DU:
-			Functors = MR_TYPE_CTOR_FUNCTORS_DU_NUM_FUNCTORS(
+			functors = MR_TYPE_CTOR_FUNCTORS_DU_NUM_FUNCTORS(
 					type_ctor_functors);
 			break;
 
 		case MR_TYPE_CTOR_FUNCTORS_ENUM:
-			Functors = MR_TYPE_CTOR_FUNCTORS_ENUM_NUM_FUNCTORS(
+			functors = MR_TYPE_CTOR_FUNCTORS_ENUM_NUM_FUNCTORS(
 					type_ctor_functors);
 			break;
 
@@ -2020,36 +1965,36 @@
 			equiv_type = (Word *) 
 				MR_TYPE_CTOR_FUNCTORS_EQUIV_TYPE(
 					type_ctor_functors);
-			Functors = ML_get_num_functors((Word)
+			functors = ML_get_num_functors((Word)
 					MR_create_type_info((Word *) 
 						type_info, equiv_type));
 			break;
 		}
 
 		case MR_TYPE_CTOR_FUNCTORS_SPECIAL:
-			Functors = -1;
+			functors = -1;
 			break;
 
 		case MR_TYPE_CTOR_FUNCTORS_NO_TAG:
-			Functors = 1;
+			functors = 1;
 			break;
 
 		case MR_TYPE_CTOR_FUNCTORS_UNIV:
-			Functors = -1;
+			functors = -1;
 			break;
 
 		default:
 			fatal_error(""std_util:ML_get_num_functors :""
 				"" unknown indicator"");
 	}
-	return Functors;
+
+	return functors;
 }
 
 ").
 
 %-----------------------------------------------------------------------------%
 
-
 :- pragma c_header_code("
 
 	#include <stdio.h>
@@ -2079,7 +2024,6 @@
 	 * (that is, they should not be relied on to remain unchanged).
 	 */
 
-
 typedef struct ML_Expand_Info_Struct {
 	ConstString functor;
 	int arity;
@@ -2091,7 +2035,6 @@
 	bool need_args;
 } ML_Expand_Info;
 
-
 	/* Prototypes */
 
 void ML_expand(Word* type_info, Word *data_word_ptr, ML_Expand_Info *info);
@@ -2154,11 +2097,9 @@
     int			data_tag; 
     MR_DiscUnionTagRepresentation tag_rep;
 
-
     type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
-    type_ctor_layout = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_LAYOUT(type_ctor_info);
-    type_ctor_functors = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_FUNCTORS(
-        type_ctor_info);
+    type_ctor_layout = type_ctor_info->type_ctor_layout;
+    type_ctor_functors = type_ctor_info->type_ctor_functors;
 
     compare_pred = type_ctor_info->compare_pred;
     info->non_canonical_type = ( compare_pred ==
@@ -2168,13 +2109,12 @@
     data_tag = MR_tag(data_word);
     data_value = MR_body(data_word, data_tag);
 
-    layout_for_tag = type_ctor_layout[data_tag];
-    layout_vector_for_tag = MR_strip_tag(layout_for_tag);
-
     switch(type_ctor_info->type_ctor_rep) {
 
         case MR_TYPECTOR_REP_ENUM:
         case MR_TYPECTOR_REP_ENUM_USEREQ:
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = MR_strip_tag(layout_for_tag);
             info->functor = MR_TYPE_CTOR_LAYOUT_ENUM_VECTOR_FUNCTOR_NAME(
                 layout_vector_for_tag, data_word);
             info->arity = 0;
@@ -2185,6 +2125,8 @@
 
         case MR_TYPECTOR_REP_DU:
         case MR_TYPECTOR_REP_DU_USEREQ:
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = MR_strip_tag(layout_for_tag);
             tag_rep = MR_get_tag_representation((Word) layout_for_tag);
             switch (tag_rep) {
             case MR_DISCUNIONTAG_SHARED_LOCAL:
@@ -2259,7 +2201,11 @@
         case MR_TYPECTOR_REP_NOTAG_USEREQ:
         {
             int i;
-	    Word * functor_descriptor = (Word *) layout_vector_for_tag;
+            Word * functor_descriptor;
+
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = MR_strip_tag(layout_for_tag);
+            functor_descriptor = (Word *) layout_vector_for_tag;
 
             data_value = (Word) data_word_ptr;
 
@@ -2302,18 +2248,19 @@
         case MR_TYPECTOR_REP_EQUIV: {
             Word *equiv_type_info;
 
-			equiv_type_info = MR_create_type_info(
-				type_info, 
-				(Word *) MR_TYPE_CTOR_LAYOUT_EQUIV_TYPE(
-					layout_vector_for_tag));
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = MR_strip_tag(layout_for_tag);
+            equiv_type_info = MR_create_type_info(type_info, (Word *)
+	    	MR_TYPE_CTOR_LAYOUT_EQUIV_TYPE(layout_vector_for_tag));
 			ML_expand(equiv_type_info, data_word_ptr, info);
             break;
         }
         case MR_TYPECTOR_REP_EQUIV_VAR: {
             Word *equiv_type_info;
 
-			equiv_type_info = MR_create_type_info(
-				type_info, 
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = MR_strip_tag(layout_for_tag);
+            equiv_type_info = MR_create_type_info(type_info,
 				(Word *) layout_vector_for_tag);
 			ML_expand(equiv_type_info, data_word_ptr, info);
             break;
@@ -2866,4 +2813,3 @@
 
 pow(F, N, X) =
 	( if N = 0 then X else pow(F, N - 1, F(X)) ).
-
cvs diff: Diffing profiler
cvs diff: Diffing runtime
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.50
diff -u -b -r1.50 Mmakefile
--- runtime/Mmakefile	2000/01/03 08:53:05	1.50
+++ runtime/Mmakefile	2000/01/08 06:02:12
@@ -35,6 +35,7 @@
 			mercury_conf.h		\
 			mercury_conf_param.h	\
 			mercury_context.h	\
+			mercury_cpp.h		\
 			mercury_debug.h		\
 			mercury_deep_copy.h	\
 			mercury_deep_copy_body.h \
Index: runtime/mercury_cpp.h
===================================================================
RCS file: mercury_cpp.h
diff -N mercury_cpp.h
--- /dev/null	Thu Mar  4 04:20:11 1999
+++ mercury_cpp.h	Sat Jan  8 16:43:03 2000
@@ -0,0 +1,27 @@
+/*
+** Copyright (C) 2000 The University of Melbourne.
+** This file may only be copied under the terms of the GNU Library General
+** Public License - see the file COPYING.LIB in the Mercury distribution.
+*/
+
+/*
+** mercury_cpp.h - C preprocessor tricks.
+*/
+
+/* convert a macro to a string */
+#define MR_STRINGIFY(x)		MR_STRINGIFY_2(x)
+#define MR_STRINGIFY_2(x)	#x
+
+/* paste two macros together */
+#define MR_PASTE2(a,b)			MR_PASTE2_2(a,b)
+#define MR_PASTE2_2(a,b)		a##b
+#define MR_PASTE3(a,b,c)		MR_PASTE3_2(a,b,c)
+#define MR_PASTE3_2(a,b,c)		a##b##c
+#define MR_PASTE4(a,b,c,d)		MR_PASTE4_2(a,b,c,d)
+#define MR_PASTE4_2(a,b,c,d)		a##b##c##d
+#define MR_PASTE5(a,b,c,d,e)		MR_PASTE5_2(a,b,c,d,e)
+#define MR_PASTE5_2(a,b,c,d,e)		a##b##c##d##e
+#define MR_PASTE6(a,b,c,d,e,f)		MR_PASTE6_2(a,b,c,d,e,f)
+#define MR_PASTE6_2(a,b,c,d,e,f)	a##b##c##d##e##f
+#define MR_PASTE7(a,b,c,d,e,f,g)	MR_PASTE7_2(a,b,c,d,e,f,g)
+#define MR_PASTE7_2(a,b,c,d,e,f,g)	a##b##c##d##e##f##g
Index: runtime/mercury_deep_copy_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_copy_body.h,v
retrieving revision 1.17
diff -u -b -r1.17 mercury_deep_copy_body.h
--- runtime/mercury_deep_copy_body.h	1999/12/11 15:32:29	1.17
+++ runtime/mercury_deep_copy_body.h	2000/01/08 08:05:03
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1997-1999 The University of Melbourne.
+** Copyright (C) 1997-2000 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
@@ -45,8 +45,6 @@
     data_value = (Word *) MR_body(data, data_tag);
 
     type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
-    layout_entry = type_ctor_info->type_ctor_layout[data_tag];
-    entry_value = (Word *) MR_strip_tag(layout_entry);
 
     switch (type_ctor_info->type_ctor_rep) {
         case MR_TYPECTOR_REP_ENUM:
@@ -56,6 +54,8 @@
 
         case MR_TYPECTOR_REP_DU:
         case MR_TYPECTOR_REP_DU_USEREQ:
+            layout_entry = type_ctor_info->type_ctor_layout[data_tag];
+            entry_value = (Word *) MR_strip_tag(layout_entry);
             tag_rep = MR_get_tag_representation(layout_entry);
             switch (tag_rep) {
 
@@ -195,18 +195,24 @@
         break;
         case MR_TYPECTOR_REP_NOTAG:
         case MR_TYPECTOR_REP_NOTAG_USEREQ:
+            layout_entry = type_ctor_info->type_ctor_layout[data_tag];
+            entry_value = (Word *) MR_strip_tag(layout_entry);
             new_data = copy_arg(NULL, data_ptr, NULL, type_info, 
                     (Word *) *MR_TYPE_CTOR_LAYOUT_NO_TAG_VECTOR_ARGS(
                      entry_value), lower_limit, upper_limit);
             break;
 
         case MR_TYPECTOR_REP_EQUIV: 
+            layout_entry = type_ctor_info->type_ctor_layout[data_tag];
+            entry_value = (Word *) MR_strip_tag(layout_entry);
             new_data = copy_arg(NULL, data_ptr, NULL, type_info,
                 (const Word *) MR_TYPE_CTOR_LAYOUT_EQUIV_TYPE((Word *)
                         entry_value), lower_limit, upper_limit);
             break;
 
         case MR_TYPECTOR_REP_EQUIV_VAR:
+            layout_entry = type_ctor_info->type_ctor_layout[data_tag];
+            entry_value = (Word *) MR_strip_tag(layout_entry);
             new_data = copy(data_ptr,
 	            (Word *) type_info[(Word) entry_value],
                     lower_limit, upper_limit);
@@ -473,7 +479,7 @@
                         new_type_info[1] = arity;
                         offset = 2;
                 } else {
-                        arity = MR_TYPE_CTOR_INFO_GET_TYPE_ARITY(type_ctor_info);
+                        arity = type_ctor_info->arity;
                         incr_saved_hp(LVALUE_CAST(Word, new_type_info),
                                 arity + 1);
                         new_type_info[0] = (Word) type_ctor_info;
Index: runtime/mercury_grade.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_grade.h,v
retrieving revision 1.25
diff -u -b -r1.25 mercury_grade.h
--- runtime/mercury_grade.h	1999/12/21 10:10:09	1.25
+++ runtime/mercury_grade.h	2000/01/08 05:27:48
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1997-1999 The University of Melbourne.
+** Copyright (C) 1997-2000 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
@@ -29,14 +29,7 @@
 #define MERCURY_GRADES_H
 
 #include "mercury_tags.h" /* for TAGBITS */
-
-/* convert a macro to a string */
-#define MR_STRINGIFY(x)		MR_STRINGIFY_2(x)
-#define MR_STRINGIFY_2(x)	#x
-
-/* paste two macros together */
-#define MR_PASTE2(p1,p2)	MR_PASTE2_2(p1,p2)
-#define MR_PASTE2_2(p1,p2)	p1##p2
+#include "mercury_cpp.h"	/* for MR_STRINGIFY and MR_PASTE2 */
 
 /*
 ** Here we build up the MR_GRADE macro part at a time,
Index: runtime/mercury_layout_util.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_layout_util.c,v
retrieving revision 1.15
diff -u -b -r1.15 mercury_layout_util.c
--- runtime/mercury_layout_util.c	1999/12/12 14:29:06	1.15
+++ runtime/mercury_layout_util.c	2000/01/08 07:20:11
@@ -73,20 +73,11 @@
 	** universally quantified when the type_info is
 	** passed to MR_get_arg_type_info().
 	*/
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_stack_layout_0 = {
-	TYPE_CTOR_LAYOUT_MAX_VARINT, /* arity = maximum */
-	0,
-	0,
-	0,
-	MR_TYPECTOR_REP_UNKNOWN,
-	0,
-	0,
-	string_const("private_builtin", 7),
-	string_const("stack_layout", 4),
-	MR_RTTI_VERSION
-};
 
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(stack_layout,
+	TYPE_CTOR_LAYOUT_MAX_VARINT,
+	MR_TYPECTOR_REP_UNKNOWN);
+
 Word *
 MR_materialize_typeinfos(const MR_Stack_Layout_Vars *vars,
 	Word *saved_regs)
@@ -113,7 +104,7 @@
 		** we need to fill in type_params[0] with a dummy type_ctor_info.
 		*/
 		type_params[0] = (Word)
-			&mercury_data___type_ctor_info_stack_layout_0;
+			&mercury_data___type_ctor_info_stack_layout_1024;
 		for (i = 0; i < count; i++) {
 			if (vars->MR_slvs_tvars->MR_tp_param_locns[i] != 0) {
 				type_params[i + 1] = MR_lookup_long_lval_base(
Index: runtime/mercury_tabling.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tabling.c,v
retrieving revision 1.19
diff -u -b -r1.19 mercury_tabling.c
--- runtime/mercury_tabling.c	2000/01/08 06:42:54	1.19
+++ runtime/mercury_tabling.c	2000/01/10 01:25:33
@@ -619,13 +619,9 @@
     data_value = (Word *) MR_body(data, data_tag);
 
     type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO(type_info);
-    type_ctor_layout = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_LAYOUT(type_ctor_info);
-    type_ctor_functors = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_FUNCTORS(
-                    type_ctor_info);
+    type_ctor_layout = type_ctor_info->type_ctor_layout;
+    type_ctor_functors = type_ctor_info->type_ctor_functors;
 
-    layout_for_tag = type_ctor_layout[data_tag];
-    layout_vector_for_tag = (Word *) MR_strip_tag(layout_for_tag);
-
 #ifdef  MR_TABLE_DEBUG
     if (MR_tabledebug) {
         printf("ENTRY %p %x, data rep: %d\n",
@@ -637,7 +633,11 @@
         case MR_TYPECTOR_REP_ENUM: 
         case MR_TYPECTOR_REP_ENUM_USEREQ: 
 	{
-            int functors = MR_TYPE_CTOR_LAYOUT_ENUM_VECTOR_NUM_FUNCTORS(
+            int functors;
+
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = (Word *) MR_strip_tag(layout_for_tag);
+            functors = MR_TYPE_CTOR_LAYOUT_ENUM_VECTOR_NUM_FUNCTORS(
                                 layout_vector_for_tag);
             MR_DEBUG_TABLE_ENUM(table, functors, data);
             break;
@@ -645,6 +645,8 @@
         case MR_TYPECTOR_REP_DU: 
         case MR_TYPECTOR_REP_DU_USEREQ: 
 	{
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = (Word *) MR_strip_tag(layout_for_tag);
             tag_rep = MR_get_tag_representation((Word) layout_for_tag);
             switch(tag_rep) {
             case MR_DISCUNIONTAG_SHARED_LOCAL: {
@@ -717,6 +719,9 @@
         case MR_TYPECTOR_REP_NOTAG_USEREQ:
 	{
             Word *new_type_info;
+
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = (Word *) MR_strip_tag(layout_for_tag);
             new_type_info = MR_make_type_info(type_info,
                 (Word *) *MR_TYPE_CTOR_LAYOUT_NO_TAG_VECTOR_ARGS(
                     layout_vector_for_tag),
@@ -726,6 +731,9 @@
         }
         case MR_TYPECTOR_REP_EQUIV: {
             Word *new_type_info;
+
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = (Word *) MR_strip_tag(layout_for_tag);
             new_type_info = MR_make_type_info(type_info,
                 (Word *) MR_TYPE_CTOR_LAYOUT_EQUIV_TYPE(layout_vector_for_tag),
                 &allocated_memory_cells);
@@ -733,6 +741,8 @@
             break;
         }
         case MR_TYPECTOR_REP_EQUIV_VAR:
+            layout_for_tag = type_ctor_layout[data_tag];
+            layout_vector_for_tag = (Word *) MR_strip_tag(layout_for_tag);
             MR_DEBUG_TABLE_ANY(table,
                 (Word *) type_info[(Word) layout_vector_for_tag], data);
             break;
Index: runtime/mercury_type_info.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.c,v
retrieving revision 1.30
diff -u -b -r1.30 mercury_type_info.c
--- runtime/mercury_type_info.c	1999/12/12 14:29:07	1.30
+++ runtime/mercury_type_info.c	2000/01/10 01:22:22
@@ -1,8 +1,4 @@
 /*
-INIT mercury_sys_init_type_info
-ENDINIT
-*/
-/*
 ** Copyright (C) 1995-1999 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
@@ -10,8 +6,8 @@
 
 /*
 ** type_info.c -
-**	Definitions for type_infos, type_layouts, and
-**	type_functors tables needed by the Mercury runtime system..
+**	Definitions for dealing with type_infos needed by the Mercury
+**	runtime system.
 */
 
 #include "mercury_imp.h"
@@ -26,107 +22,9 @@
 
 /*---------------------------------------------------------------------------*/
 
-	/* type_ctor_layout for `pred' */
-	/* (this is used for all higher-order types) */
+extern	struct MR_TypeCtorInfo_struct	mercury_data___type_ctor_info_pred_0;
+extern	struct MR_TypeCtorInfo_struct	mercury_data___type_ctor_info_func_0;
 
-const struct mercury_data___type_ctor_layout_pred_0_struct {
-	TYPE_LAYOUT_FIELDS
-} mercury_data___type_ctor_layout_pred_0 = {
-	make_typelayout_for_all_tags(TYPE_CTOR_LAYOUT_CONST_TAG, 
-		MR_mkbody(MR_TYPE_CTOR_LAYOUT_PREDICATE_VALUE))
-};
-
-	/* type_ctor_functors for `pred' */
-	/* (this is used for all higher-order types) */
-
-const struct mercury_data___type_ctor_functors_pred_0_struct {
-	Integer f1;
-} mercury_data___type_ctor_functors_pred_0 = {
-	MR_TYPE_CTOR_FUNCTORS_SPECIAL
-};
-
-	/* 
-	** type_ctor_info for `func' 
-	** (this is used for all higher-order func types) 
-	**
-	** Note: we use the special predicates, functors and layout for
-	** `pred'.
-	*/
-
-Declare_entry(mercury__builtin_unify_pred_2_0);
-Declare_entry(mercury__builtin_index_pred_2_0);
-Declare_entry(mercury__builtin_compare_pred_3_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_func_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_unify_pred_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_index_pred_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_compare_pred_3_0)),
-	MR_TYPECTOR_REP_PRED,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_pred_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_pred_0,
-	string_const("builtin", 7),
-	string_const("func", 4),
-	MR_RTTI_VERSION
-};
-
-	/*
-	** type_ctor_info for `pred' 
-	** (this is used for all higher-order pred types) 
-	*/
-
-Declare_entry(mercury__builtin_unify_pred_2_0);
-Declare_entry(mercury__builtin_index_pred_2_0);
-Declare_entry(mercury__builtin_compare_pred_3_0);
-MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct
-mercury_data___type_ctor_info_pred_0 = {
-	((Integer) 0),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_unify_pred_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_index_pred_2_0)),
-	MR_MAYBE_STATIC_CODE(ENTRY(mercury__builtin_compare_pred_3_0)),
-	MR_TYPECTOR_REP_PRED,
-	(MR_TypeCtorFunctors) & mercury_data___type_ctor_functors_pred_0,
-	(MR_TypeCtorLayout) & mercury_data___type_ctor_layout_pred_0,
-	string_const("builtin", 7),
-	string_const("pred", 4),
-	MR_RTTI_VERSION
-};
-
-Define_extern_entry(mercury__builtin_unify_pred_2_0);
-Define_extern_entry(mercury__builtin_index_pred_2_0);
-Define_extern_entry(mercury__builtin_compare_pred_3_0);
-
-BEGIN_MODULE(mercury__builtin_unify_pred_module)
-	init_entry_ai(mercury__builtin_unify_pred_2_0);
-BEGIN_CODE
-
-/* code for predicate 'builtin_unify_pred'/2 in mode 0 */
-Define_entry(mercury__builtin_unify_pred_2_0);
-	MR_incr_sp_push_msg(2, "private_builtin:builtin_unify_pred");
-	fatal_error("attempted unification of higher-order terms");
-END_MODULE
-
-
-BEGIN_MODULE(mercury__builtin_index_pred_module)
-	init_entry_ai(mercury__builtin_index_pred_2_0);
-BEGIN_CODE
-
-/* code for predicate 'builtin_index_pred'/2 in mode 0 */
-Define_entry(mercury__builtin_index_pred_2_0);
-	r1 = (Integer) -1;
-	proceed();
-END_MODULE
-
-BEGIN_MODULE(mercury__builtin_compare_pred_module)
-	init_entry_ai(mercury__builtin_compare_pred_3_0);
-BEGIN_CODE
-
-/* code for predicate 'builtin_compare_pred'/3 in mode 0 */
-Define_entry(mercury__builtin_compare_pred_3_0);
-	MR_incr_sp_push_msg(2, "private_builtin:builtin_compare_pred");
-	fatal_error("attempted comparison of higher-order terms");
-END_MODULE
-
 	/* 
 	** MR_create_type_info():
 	**
@@ -163,6 +61,7 @@
 	** which does much the same thing, only allocating using MR_GC_malloc()
 	** instead of on the Mercury heap.
 	*/
+
 Word * 
 MR_create_type_info(const Word *term_type_info, const Word *arg_pseudo_type_info)
 {
@@ -184,6 +83,7 @@
 	** existentially typed type variables, then it is OK
 	** for the data_value and functor_descriptor to be NULL.
 	*/
+
 Word * 
 MR_create_type_info_maybe_existq(const Word *term_type_info, 
 	const Word *arg_pseudo_type_info, const Word *data_value, 
@@ -461,31 +361,36 @@
 Word
 MR_collapse_equivalences(Word maybe_equiv_type_info) 
 {
-	Word *functors, equiv_type_info;
+	MR_TypeCtorInfo	type_ctor_info;
+	Word		*functors;
+	Word		equiv_type_info;
 	
-	functors = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_FUNCTORS(
-			MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) 
-					maybe_equiv_type_info));
+	type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) 
+					maybe_equiv_type_info);
 
 		/* Look past equivalences */
-	while (MR_TYPE_CTOR_FUNCTORS_INDICATOR(functors) == MR_TYPE_CTOR_FUNCTORS_EQUIV) {
-		equiv_type_info = (Word) MR_TYPE_CTOR_FUNCTORS_EQUIV_TYPE(functors);
+	while (type_ctor_info->type_ctor_rep == MR_TYPECTOR_REP_EQUIV
+		|| type_ctor_info->type_ctor_rep == MR_TYPECTOR_REP_EQUIV_VAR)
+	{
+		functors = type_ctor_info->type_ctor_functors;
+		equiv_type_info = (Word)
+				MR_TYPE_CTOR_FUNCTORS_EQUIV_TYPE(functors);
 		equiv_type_info = (Word) MR_create_type_info(
 				(Word *) maybe_equiv_type_info, 
 				(Word *) equiv_type_info);
-		functors = MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_FUNCTORS(
-			MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) 
-				equiv_type_info));
+
 		maybe_equiv_type_info = equiv_type_info;
+		type_ctor_info = MR_TYPEINFO_GET_TYPE_CTOR_INFO((Word *) 
+						maybe_equiv_type_info);
 	}
 
 	return maybe_equiv_type_info;
 }
 
-
 /*
 ** MR_deallocate() frees up a list of memory cells
 */
+
 void
 MR_deallocate(MR_MemoryList allocated)
 {
@@ -548,6 +453,7 @@
 	** the values whose pseudo type-info we are looking at was taken, as
 	** well as the functor descriptor for that functor.
 	*/
+
 Word *
 MR_make_type_info_maybe_existq(const Word *term_type_info, 
 	const Word *arg_pseudo_type_info, const Word *data_value, 
@@ -657,18 +563,6 @@
 		default:
 		fatal_error("MR_get_tag_representation: unknown tag representation");
 	}
-}
-
-/*---------------------------------------------------------------------------*/
-
-void mercury_sys_init_type_info(void); /* suppress gcc warning */
-void mercury_sys_init_type_info(void) {
-	mercury__builtin_unify_pred_module();
-	mercury__builtin_index_pred_module();
-	mercury__builtin_compare_pred_module();
-
-	MR_INIT_BUILTIN_TYPE_CTOR_INFO(
-		mercury_data___type_ctor_info_pred_0, _pred_);
 }
 
 /*---------------------------------------------------------------------------*/
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.34
diff -u -b -r1.34 mercury_type_info.h
--- runtime/mercury_type_info.h	1999/12/21 09:45:17	1.34
+++ runtime/mercury_type_info.h	2000/01/10 02:10:18
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1995-1999 The University of Melbourne.
+** Copyright (C) 1995-2000 The University of Melbourne.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
@@ -33,11 +33,10 @@
 #define MERCURY_TYPE_INFO_H
 
 #include "mercury_types.h"	/* for `Word' */
+#include "mercury_cpp.h"	/* for `MR_STRINGIFY' and `MR_PASTEn' */
 
 /*---------------------------------------------------------------------------*/
 
-
-
 /* 
 ** The version of the RTTI data structures -- useful for bootstrapping.
 ** MR_RTTI_VERSION sets the version number in the handwritten
@@ -154,28 +153,6 @@
 	#undef USE_TYPE_LAYOUT
 #endif
 
-
-/*
-** Code intended for defining type_layouts for handwritten code.
-**
-** See library/io.m or library/builtin.m for details.
-*/
-#if TAGBITS >= 2
-	typedef const Word *TypeLayoutField;
-	#define TYPE_LAYOUT_FIELDS \
-		TypeLayoutField f1,f2,f3,f4,f5,f6,f7,f8;
-	#define make_typelayout(Tag, Value) \
-		MR_mkword(MR_mktag(Tag), (Value))
-#else
-	typedef const Word *TypeLayoutField;
-	#define TYPE_LAYOUT_FIELDS \
-		TypeLayoutField f1,f2,f3,f4,f5,f6,f7,f8;
-		TypeLayoutField f9,f10,f11,f12,f13,f14,f15,f16;
-	#define make_typelayout(Tag, Value) \
-		(const Word *) (Tag), \
-		(const Word *) (Value)
-#endif
-
 /*
 ** Declaration for structs.
 */
@@ -185,40 +162,6 @@
 #define MR_DECLARE_TYPE_CTOR_INFO_STRUCT(T)			\
 	extern const struct MR_TypeCtorInfo_struct T
 
-/*
-** Typelayouts for builtins are often defined as X identical
-** values, where X is the number of possible tag values.
-*/
-
-#if TAGBITS == 0
-#define make_typelayout_for_all_tags(Tag, Value) \
-	make_typelayout(Tag, Value)
-#elif TAGBITS == 1
-#define make_typelayout_for_all_tags(Tag, Value) \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value)
-#elif TAGBITS == 2
-#define make_typelayout_for_all_tags(Tag, Value) \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value)
-#elif TAGBITS == 3
-#define make_typelayout_for_all_tags(Tag, Value) \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value), \
-	make_typelayout(Tag, Value)
-#endif
-
-#if !defined(make_typelayout_for_all_tags)
-#error "make_typelayout_for_all_tags is not defined for this number of tags"
-#endif
-
 /*---------------------------------------------------------------------------*/
 
 /* 
@@ -267,19 +210,6 @@
 	MR_TYPE_CTOR_LAYOUT_TYPEINFO_VALUE,
 	MR_TYPE_CTOR_LAYOUT_C_POINTER_VALUE,
 	MR_TYPE_CTOR_LAYOUT_TYPECLASSINFO_VALUE,
-		/*
-		** The following enum values represent the "types" of
-		** of values stored in lvals that the garbage collector
-		** and/or the debugger need to know about.
-		*/
-	MR_TYPE_CTOR_LAYOUT_SUCCIP_VALUE,
-	MR_TYPE_CTOR_LAYOUT_HP_VALUE,
-	MR_TYPE_CTOR_LAYOUT_CURFR_VALUE,
-	MR_TYPE_CTOR_LAYOUT_MAXFR_VALUE,
-	MR_TYPE_CTOR_LAYOUT_REDOFR_VALUE,
-	MR_TYPE_CTOR_LAYOUT_REDOIP_VALUE,
-	MR_TYPE_CTOR_LAYOUT_TRAIL_PTR_VALUE,
-	MR_TYPE_CTOR_LAYOUT_TICKET_VALUE,
 	MR_TYPE_CTOR_LAYOUT_UNWANTED_VALUE
 };
 
@@ -385,7 +315,6 @@
 		((Word *) (Word) &Base)[Offset]	= (Word) ENTRY(PredAddr);\
 	} while (0)
 			
-
 #define MR_SPECIAL_PRED_INIT(Base, TypeId, Offset, Pred)	\
 	MR_INIT_CODE_ADDR(Base, mercury____##Pred##___##TypeId, Offset)
 
@@ -511,10 +440,9 @@
 
 #define MR_TYPE_CTOR_FUNCTORS_OFFSET_FOR_INDICATOR	((Integer) 0)
 
-#define MR_TYPE_CTOR_FUNCTORS_INDICATOR(Functors)				\
-	((Functors)[MR_TYPE_CTOR_FUNCTORS_OFFSET_FOR_INDICATOR])
+#define MR_TYPE_CTOR_FUNCTORS_INDICATOR(functors)			\
+	((functors)[MR_TYPE_CTOR_FUNCTORS_OFFSET_FOR_INDICATOR])
 
-
 /*
 ** Values that the indicator can take.
 */
@@ -526,7 +454,6 @@
 #define MR_TYPE_CTOR_FUNCTORS_NO_TAG	((Integer) 4)
 #define MR_TYPE_CTOR_FUNCTORS_UNIV	((Integer) 5)
 
-
 	/*
 	** Macros to access the data in a discriminated union
 	** type_functors, the number of functors, and the functor descriptor
@@ -616,7 +543,6 @@
 #define MR_TYPE_CTOR_LAYOUT_ENUM_VECTOR_FUNCTOR_NAME(Vector, N)		\
 	( (&((MR_TypeLayout_EnumVector *)(Vector))->functor1) [N] )
 
-
 	/*
 	** Macros for dealing with functor descriptors.
 	**
@@ -766,7 +692,6 @@
 #define MR_TYPEINFO_GET_HIGHER_ARITY(TypeInfo)				\
 	((Integer) (Word *) (TypeInfo)[TYPEINFO_OFFSET_FOR_PRED_ARITY]) 
 
-
 /*---------------------------------------------------------------------------*/
 
 /*
@@ -827,7 +752,7 @@
 /*---------------------------------------------------------------------------*/
 
 /*
-** definitions and functions for categorizing data representations.
+** Definitions and functions for categorizing data representations.
 */
 
 /*
@@ -837,8 +762,10 @@
 ** value -- lookup the tag value in type_ctor_layout to find out this
 ** information.
 **
-** 
+** This enum should be kept in sync with base_type_info__type_ctor_rep_to_int
+** in compiler/base_type_info.m.
 */
+
 typedef enum MR_TypeCtorRepresentation {
 	MR_TYPECTOR_REP_ENUM,
 	MR_TYPECTOR_REP_ENUM_USEREQ,
@@ -874,11 +801,20 @@
 	MR_TYPECTOR_REP_UNKNOWN
 } MR_TypeCtorRepresentation;
 
+#define	MR_type_ctor_rep_is_basically_du(rep)				\
+	(  ((rep) == MR_TYPECTOR_REP_ENUM)				\
+	|| ((rep) == MR_TYPECTOR_REP_ENUM_USEREQ)			\
+	|| ((rep) == MR_TYPECTOR_REP_DU)				\
+	|| ((rep) == MR_TYPECTOR_REP_DU_USEREQ)				\
+	|| ((rep) == MR_TYPECTOR_REP_NOTAG)				\
+	|| ((rep) == MR_TYPECTOR_REP_NOTAG_USEREQ) )
+
 /*
-** If the MR_TypeCtorRepresentation is MR_TYPE_CTOR_REP_DU, we have a
-** discriminated union type (other than a no-tag or enumeration).  Each
-** tag may have a different representation.
+** If the MR_TypeCtorRepresentation is MR_TYPE_CTOR_REP_DU{,_USEREQ},
+** we have a discriminated union type which is not a no-tag type or
+** an enumeration. Each tag may have a different representation.
 */
+
 typedef enum MR_DiscUnionTagRepresentation {
 	MR_DISCUNIONTAG_SHARED_LOCAL,
 	MR_DISCUNIONTAG_UNSHARED,
@@ -903,6 +839,9 @@
 	** A type_ctor_info describes the structure of a particular
 	** type constructor.  One of these is generated for every
 	** `:- type' declaration.
+	**
+	** The offsets of the fields in this structure must match the
+	** offset macros defines near the top of this file.
 	*/
 
 struct MR_TypeCtorInfo_struct {
@@ -940,23 +879,46 @@
 	** XXX zs: these macros should be deleted; the code using them
 	** would be clearer if it referred to TypeCtorInfo fields directly.
 	*/
-#define MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_FUNCTORS(TypeCtorInfo)		\
-	((TypeCtorInfo)->type_ctor_functors)
-
-#define MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_LAYOUT(TypeCtorInfo)		\
-	((TypeCtorInfo)->type_ctor_layout)
 
-#define MR_TYPE_CTOR_INFO_GET_TYPE_CTOR_LAYOUT_ENTRY(TypeCtorInfo, Tag)	\
-	((TypeCtorInfo)->type_ctor_layout[(Tag)])
-
 #define MR_TYPE_CTOR_INFO_GET_TYPE_ARITY(TypeCtorInfo)			\
 	((TypeCtorInfo)->arity)
 
-#define MR_TYPE_CTOR_INFO_GET_TYPE_NAME(TypeCtorInfo)			\
-	((TypeCtorInfo)->type_ctor_name)
+	/*
+	** Macros to help the runtime and the library create type_ctor_info
+	** structures for builtin and special types.
+	*/
 
-#define MR_TYPE_CTOR_INFO_GET_TYPE_MODULE_NAME(TypeCtorInfo)		\
-	((TypeCtorInfo)->type_ctor_module_name)
+#define	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(m, cm, n, a, cr, u, i, c)	\
+	Declare_entry(u);						\
+	Declare_entry(i);						\
+	Declare_entry(c);						\
+	MR_STATIC_CODE_CONST struct MR_TypeCtorInfo_struct		\
+	MR_PASTE6(mercury_data_, cm, __type_ctor_info_, n, _, a) = {	\
+		a,							\
+		MR_MAYBE_STATIC_CODE(ENTRY(u)),				\
+		MR_MAYBE_STATIC_CODE(ENTRY(i)),				\
+		MR_MAYBE_STATIC_CODE(ENTRY(c)),				\
+		cr,							\
+		NULL,							\
+		NULL,							\
+		MR_string_const(MR_STRINGIFY(m), sizeof(MR_STRINGIFY(m))-1),\
+		MR_string_const(MR_STRINGIFY(n), sizeof(MR_STRINGIFY(n))-1),\
+		MR_RTTI_VERSION						\
+	}
+
+#define	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_PRED(m, n, a, cr, u, i, c)	\
+	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(m, m, n, a, cr, u, i, c)
+
+#define	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(m, n, a, cr)			\
+	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(m, m, n, a, cr,		\
+		MR_PASTE7(mercury____Unify___, m, __, n, _, a, _0),	\
+		MR_PASTE7(mercury____Index___, m, __, n, _, a, _0),	\
+		MR_PASTE7(mercury____Compare___, m, __, n, _, a, _0))
+
+#define	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_UNUSED(n, a, cr)		\
+	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL(builtin, , n, a, cr,	\
+		mercury__unused_0_0,					\
+		mercury__unused_0_0,					\
+		mercury__unused_0_0)
 
-/*---------------------------------------------------------------------------*/
 #endif /* not MERCURY_TYPEINFO_H */
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 scripts
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/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list