[m-rev.] for review: change MR_bool from char to int

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Sep 17 04:51:46 AEST 2002


On 16-Sep-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 16-Sep-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> > On 16-Sep-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > > 	Change the definition of MR_bool to use int rather than char.
> > > 	Add a new typedef MR_small_bool, which is defined as char,
> > > 	for use when you need to optimize space.
> > 
> > Have you done a grep for MR_bool in {runtime,trace,library}/* to check which
> > existing uses of MR_bool should be converted to MR_small_bool?
> 
> I had a look in runtime/*, and didn't spot any.
> But I'll have a look at the other directories.

I did, and there weren't any.
Almost all occurrences of MR_bool were on function arguments, return types,
or local variables.  The only array of MR_bool was for the debugflags;
there's only one occurrence of that, so it's more important to optimize
speed rather than time.

However, I also need to modify the use of boolean types in the GCC back-end.
Hence the following changes.

mercury/compiler/mlds_to_gcc.m:
	Change definition of MR_bool to use int rather than char.

gcc/mercury/mercury-gcc.c:
	Define boolean_type to have the same size as int, rather than
	default to the smallest possible size (one byte).

--- /home/pgrad/fjh/ws/gcc-latest/mercury-gcc/gcc/mercury/mercury-gcc.c	Wed Sep 11 05:57:02 2002
+++ mercury-gcc.c.new	Tue Sep 17 04:13:35 2002
@@ -1438,8 +1440,12 @@
   				    ? "short unsigned int"
 				    : WCHAR_TYPE);
 
+  /* We used to define boolean_type_node with TYPE_PRECISION being 1.
+     But this caused trouble, because GCC had problems optimizing
+     tail recursion for procedures that return types smaller than `int'.
+     So now we give it the same size as `int'.  */
   boolean_type_node = make_node (BOOLEAN_TYPE);
-  TYPE_PRECISION (boolean_type_node) = 1;
+  TYPE_PRECISION (boolean_type_node) = TYPE_PRECISION (integer_type_node);
   fixup_unsigned_type (boolean_type_node);
   merc_push_atomic_type_decl (get_identifier ("boolean"), boolean_type_node);
   boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
Index: mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.74
diff -u -d -u -r1.74 mlds_to_gcc.m
--- mlds_to_gcc.m	4 Sep 2002 07:24:20 -0000	1.74
+++ mlds_to_gcc.m	15 Sep 2002 17:58:45 -0000
@@ -3514,7 +3525,7 @@
 'MR_ConstString'	= gcc__string_type_node.
 	% XXX 'MR_Word' should perhaps be unsigned, to match the C back-end
 'MR_Word'		= gcc__intptr_type_node.
-'MR_bool'		= gcc__char_type_node.
+'MR_bool'		= gcc__integer_type_node. % i.e. typedef int MR_bool
 
 'MR_TypeInfo'		= gcc__ptr_type_node.
 'MR_PseudoTypeInfo'	= gcc__ptr_type_node.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list