[m-dev.] diff: GCC back-end: fix MR_box_float link error

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jan 23 03:06:53 AEDT 2001


Estimated hours taken: 1.5

Fix a bug with the GCC back-end interface where it was generating
calls to `MR_box_float', but `MR_box_float' was not defined in the
runtime library.

mercury/runtime/mercury.h:
mercury/runtime/mercury.c:
	Add a new function `MR_asm_box_float'.  This is the same as
	`MR_box_float' except that it is always defined as an external
	function, never as a macro or inline function.
	Also fix a bug where the return type of `MR_box_float' was
	declared as `MR_Float *' rather than `MR_Box'.

gcc/mercury/mercury-gcc.c:
mercury/compiler/gcc.m:
	Generate calls to `MR_asm_box_float' rather than to `MR_box_float'.

Workspace: /home/hg/fjh/gcc-cvs/gcc/mercury
Index: compiler/gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/gcc.m,v
retrieving revision 1.18
diff -u -d -r1.18 gcc.m
--- compiler/gcc.m	2001/01/22 14:47:05	1.18
+++ compiler/gcc.m	2001/01/22 15:26:05
@@ -249,7 +249,7 @@
 :- func alloc_func_decl = gcc__func_decl.	% GC_malloc()
 :- func strcmp_func_decl = gcc__func_decl.	% strcmp()
 :- func hash_string_func_decl = gcc__func_decl.	% MR_hash_string()
-:- func box_float_func_decl = gcc__func_decl.	% MR_box_float()
+:- func box_float_func_decl = gcc__func_decl.	% MR_asm_box_float()
 :- func setjmp_func_decl = gcc__func_decl.	% __builtin_setjmp()
 :- func longjmp_func_decl = gcc__func_decl.	% __builtin_longjmp()
 
Index: runtime/mercury.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.c,v
retrieving revision 1.22
diff -u -d -r1.22 mercury.c
--- runtime/mercury.c	2001/01/12 14:08:46	1.22
+++ runtime/mercury.c	2001/01/22 15:22:52
@@ -852,7 +852,7 @@
 
 #ifdef MR_AVOID_MACROS
 
-MR_Float *
+MR_Box
 MR_box_float(MR_Float f)
 {
 	MR_Float *ptr = (MR_Float *)
@@ -870,6 +870,21 @@
 #endif /* MR_AVOID_MACROS */
 
 #endif /* __GNUC__ */
+
+/*
+** This is exactly the same as MR_box_float(), except that
+** it is unconditionally defined as an external function,
+** not as a macro, static function, or inline function.
+** It is used by the `--target asm' GCC back-end interface.
+*/
+MR_Box
+MR_asm_box_float(MR_Float f)
+{
+	MR_Float *ptr = (MR_Float *)
+		MR_new_object(MR_Float, sizeof(MR_Float), "float");
+	*ptr = f;
+	return (MR_Box) ptr;
+}
 
 /*---------------------------------------------------------------------------*/
 
Index: runtime/mercury.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.h,v
retrieving revision 1.33
diff -u -d -r1.33 mercury.h
--- runtime/mercury.h	2001/01/17 17:37:24	1.33
+++ runtime/mercury.h	2001/01/22 15:27:36
@@ -386,6 +386,13 @@
   #define MR_unbox_float(ptr) (*(MR_Float *)ptr)
 #endif
 
+/*
+** Like MR_box_float, but always an external function, never a macro
+** or an inline function.  This is used by the `--target asm'
+** GCC back-end interface.
+*/
+MR_Box MR_asm_box_float(MR_Float f);
+
 /*---------------------------------------------------------------------------*/
 /*
 ** Function declarations
Index: mercury-gcc.c
===================================================================
RCS file: /home/mercury1/repository/gcc/mercury/mercury-gcc.c,v
retrieving revision 1.24
diff -u -d -u -r1.24 mercury-gcc.c
--- mercury-gcc.c	2001/01/19 16:41:41	1.24
+++ mercury-gcc.c	2001/01/22 15:33:08
@@ -89,7 +89,7 @@
 tree merc_alloc_function_node;		/* GC_malloc() */
 tree merc_strcmp_function_node;		/* strcmp() */
 tree merc_hash_string_function_node;	/* MR_hash_string() */
-tree merc_box_float_function_node;	/* MR_box_float() */
+tree merc_box_float_function_node;	/* MR_asm_box_float() */
 tree merc_setjmp_function_node;		/* __builtin_setjmp() */
 tree merc_longjmp_function_node;	/* __builtin_longjmp() */
 
@@ -1486,14 +1486,13 @@
     = builtin_function ("MR_hash_string", hash_string_function_type,
 			0, NOT_BUILT_IN, NULL_PTR);
 
-  /* Declare `MR_Float * MR_box_float(MR_Float);'.  */
+  /* Declare `MR_Box MR_asm_box_float(MR_Float);'.  */
   box_float_function_param_types
     = tree_cons (NULL_TREE, double_type_node, no_more_params);
   box_float_function_type
-    = build_function_type (build_pointer_type (double_type_node),
-    			   box_float_function_param_types);
+    = build_function_type (ptr_type_node, box_float_function_param_types);
   merc_box_float_function_node
-    = builtin_function ("MR_box_float", box_float_function_type,
+    = builtin_function ("MR_asm_box_float", box_float_function_type,
 			0, NOT_BUILT_IN, NULL_PTR);
 
   /* Declare `int __builtin_setjmp(void *);'.  */
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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