[m-rev.] diff: update GCC back-end interface to GCC 3.2

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Sep 10 19:40:27 AEST 2002


Update the Mercury gcc back-end support to work with GCC 3.1 and 3.2.

gcc/mercury/mercury-gcc.c:
	- Use the new langhooks scheme.
	- Use ansidecl.h rather than gansidecl.h,
	  since the latter doesn't exist anymore.
	- Use NULL rather than NULL_PTR,
	  since the latter doesn't exist anymore.
	- Don't include c-lex.h, since it is no longer needed.

gcc/mercury/Make-lang.in:
	- Update the dependencies to reflect changes to mercury-gcc.c.

mercury/compiler/gcc.m:
	- Don't include gansidecl.h, since it is needed here.
	- Use SET_DECL_ASSEMBLER_NAME(), rather than assuming
	  DECL_ASSEMBLER_NAME() is an lvalue.

Workspace: /home/pgrad/fjh/ws/gcc-3.2/mercury-gcc
Index: gcc/mercury/Make-lang.in
===================================================================
RCS file: /home/mercury1/repository/gcc/mercury/Make-lang.in,v
retrieving revision 1.6
diff -u -d -r1.6 Make-lang.in
--- gcc/mercury/Make-lang.in	11 Feb 2001 15:40:54 -0000	1.6
+++ gcc/mercury/Make-lang.in	10 Sep 2002 07:51:52 -0000
@@ -139,8 +139,9 @@
 mercury/mercury-gcc.o: \
 		$(srcdir)/mercury/mercury-gcc.c \
 		$(srcdir)/mercury/mercury-gcc.h \
-		$(CONFIG_H) gansidecl.h $(TREE_H) flags.h output.h \
-		c-lex.h c-tree.h $(RTL_H) tm_p.h $(GGC_H) toplev.h
+		$(CONFIG_H) $(TREE_H) flags.h real.h output.h \
+		c-tree.h $(RTL_H) tm_p.h $(GGC_H) toplev.h \
+		langhooks.h langhooks-def.h
 	$(CC) -o $@ -c $(ALL_CFLAGS) $(INCLUDES) $< 
 
 #main to test generated program
Index: gcc/mercury/mercury-gcc.c
===================================================================
RCS file: /home/mercury1/repository/gcc/mercury/mercury-gcc.c,v
retrieving revision 1.30
diff -u -d -r1.30 mercury-gcc.c
--- gcc/mercury/mercury-gcc.c	9 Jul 2001 18:09:02 -0000	1.30
+++ gcc/mercury/mercury-gcc.c	10 Sep 2002 08:00:02 -0000
@@ -36,17 +36,19 @@
 
 #include "config.h"
 #include "system.h"
-#include "gansidecl.h"
+#include "ansidecl.h"
 #include "tree.h"
 #include "flags.h"
+#include "real.h"		/* For build_real().  */
 /* XXX we should avoid the dependency on `c-*.h'. */
-#include "c-lex.h"
 #include "c-tree.h"
 #include "rtl.h"		/* For MD_INIT_BUILTINS.  */
 #include "tm_p.h"		/* For MD_INIT_BUILTINS.  */
 #include "ggc.h"
 #include "toplev.h"
 #include "diagnostic.h"
+#include "langhooks.h"
+#include "langhooks-def.h"
 
 #include "mercury-gcc.h"
 
@@ -69,16 +71,29 @@
 static tree merc_convert PARAMS((tree type, tree expr));
 static tree merc_promote_type PARAMS((tree type));
 static void merc_init_builtin_functions PARAMS((void));
+static void merc_init_decl_processing PARAMS((void));
 static void merc_handle_internal_error PARAMS((const char *msg, va_list *args));
 static int merc_call_mercury_compiler PARAMS((void));
 static void merc_push_type_decl PARAMS((tree id, tree type));
 static void merc_push_atomic_type_decl PARAMS((tree id, tree type));
 
-static void merc_lang_init PARAMS((void));
+static const char * merc_lang_init PARAMS((const char *filename));
 static void merc_lang_finish PARAMS((void));
 static void merc_lang_init_options PARAMS((void));
 static int merc_lang_decode_option PARAMS((int argc, char **argv));
 
+#if 0 /* for gcc 3.3 and later */
+static int merc_lang_mark_addressable PARAMS((tree exp));
+static tree merc_lang_type_for_size PARAMS((unsigned precision,
+					    int unsignedp));
+static tree merc_lang_type_for_mode PARAMS((enum machine_mode mode,
+					    int unsignedp));
+static tree merc_lang_unsigned_type PARAMS((tree type_node));
+static tree merc_lang_signed_type PARAMS((tree type_node));
+static tree merc_lang_signed_or_unsigned_type PARAMS((int unsignedp,
+						      tree type));
+#endif
+
 /*---------------------------------------------------------------------------*/
 
 /* Global variables defined elsewhere.  */
@@ -122,18 +137,42 @@
 
 /*---------------------------------------------------------------------------*/
 
-/* Global Variables Expected by gcc: */
-
-const char * const language_string = "Mercury";
+/* Hooks expected by gcc: */
 
 /* The `lang_hooks' struct is a table of function pointers.
    These are "hook" functions which are called by the gcc back-end.
-   NULL values can be used if the function does nothing.  */
-struct lang_hooks lang_hooks = {merc_lang_init,
-				merc_lang_finish,
-				merc_lang_init_options,
-				merc_lang_decode_option,
-				NULL /* post_options */};
+   Macros are used to specify which values to use to initialize
+   these function pointers.  */
+
+#undef LANG_HOOKS_NAME
+#define LANG_HOOKS_NAME "Mercury"
+#undef LANG_HOOKS_INIT
+#define LANG_HOOKS_INIT merc_lang_init
+#undef LANG_HOOKS_FINISH
+#define LANG_HOOKS_FINISH merc_lang_finish
+#undef LANG_HOOKS_INIT_OPTIONS
+#define LANG_HOOKS_INIT_OPTIONS merc_lang_init_options
+#undef LANG_HOOKS_DECODE_OPTION
+#define LANG_HOOKS_DECODE_OPTION merc_lang_decode_option
+
+#undef LANG_HOOKS_MARK_ADDRESSABLE
+#define LANG_HOOKS_MARK_ADDRESSABLE merc_lang_mark_addressable
+#undef LANG_HOOKS_TYPE_FOR_MODE
+#define LANG_HOOKS_TYPE_FOR_MODE merc_lang_type_for_mode
+#undef LANG_HOOKS_TYPE_FOR_SIZE
+#define LANG_HOOKS_TYPE_FOR_SIZE merc_lang_type_for_size
+#undef LANG_HOOKS_UNSIGNED_TYPE
+#define LANG_HOOKS_UNSIGNED_TYPE merc_lang_unsigned_type
+#undef LANG_HOOKS_SIGNED_TYPE
+#define LANG_HOOKS_SIGNED_TYPE merc_lang_signed_type
+#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE merc_lang_signed_or_unsigned_type
+
+const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
+
+/*---------------------------------------------------------------------------*/
+
+/* Global variables expected by gcc: */
 
 int flag_traditional;		/* Used by dwarfout.c.  */
 
@@ -183,7 +222,7 @@
   DECL_EXTERNAL (var_decl) = 1;
   TREE_PUBLIC (var_decl) = 1;
   layout_decl (var_decl, /*known_align=*/0);
-  rest_of_decl_compilation (var_decl, /*asm_spec=*/NULL_PTR,
+  rest_of_decl_compilation (var_decl, /*asm_spec=*/NULL,
   			    /*toplevel=*/1, /*at_end=*/0);
   return var_decl;
 }
@@ -221,7 +260,7 @@
   /* toplevel is nonzero iff this is a global variable declaration.  */
   int toplevel = (current_function_decl == NULL);
   layout_decl (var_decl, /*known_align=*/0);
-  rest_of_decl_compilation (var_decl, /*asm_spec=*/NULL_PTR,
+  rest_of_decl_compilation (var_decl, /*asm_spec=*/NULL,
   			    toplevel, /*at_end=*/0);
 }
 
@@ -327,7 +366,7 @@
 		  merc_promote_type (return_type));
   DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
 
-  rest_of_decl_compilation (fndecl, NULL_PTR, 1, 0);
+  rest_of_decl_compilation (fndecl, NULL, 1, 0);
   return fndecl;
 }
 
@@ -614,7 +653,7 @@
   /* GGC
      temporary_allocation ();
   */
-  make_decl_rtl (fndecl, NULL_PTR);
+  make_decl_rtl (fndecl, NULL);
   
   init_function_start (fndecl, input_filename, lineno);
   expand_function_start (fndecl, 0);
@@ -680,10 +719,14 @@
 

 /* Routines Expected by gcc:  */
 
-const char *
-init_parse (filename)
+static const char *
+merc_lang_init (filename)
      const char *filename;
 {
+  set_internal_error_function (merc_handle_internal_error);
+
+  merc_init_decl_processing();
+
   if (!filename)
     {
       fprintf (stderr, "%s: error: too few arguments.\n", progname);
@@ -788,27 +831,12 @@
   return result;
 }
 
-void 
-finish_parse (void)
-{
-  /* Nothing to do. */
-}
-
 static void 
 merc_lang_init_options (void)
 {
   /* Nothing to do. */
 }
 
-void 
-lang_print_xnode (file, node, indent)
-     FILE *file ATTRIBUTE_UNUSED;
-     tree node ATTRIBUTE_UNUSED;
-     int indent ATTRIBUTE_UNUSED;
-{
-  /* Nothing to do */
-}
-
 

 /* Decode all the language specific options that cannot be decoded by GCC. The
    option decoding phase of GCC calls this routine on the flags that it cannot
@@ -845,26 +873,12 @@
   return 0;
 }
 
-/* Perform all the initialization steps that are language-specific.  */
-
-static void
-merc_lang_init ()
-{
-  set_internal_error_function (merc_handle_internal_error);
-}
-
 /* Perform all the finalization steps that are language-specific.  */
 
 static void
 merc_lang_finish ()
 {}
 
-/* Return a short string identifying this language to the debugger.  */
-
-const char *
-lang_identify ()
-{ return "mercury"; }
-
 /*---------------------------------------------------------------------------*/
 
 /* Routines Expected by gcc:  */
@@ -1244,14 +1258,12 @@
    Initialize the global binding level.
    Make definitions for built-in primitive functions.  */
 
-void
-init_decl_processing ()
+static void
+merc_init_decl_processing ()
 {
   tree array_domain_type;
   tree jmpbuf_domain_type;
 
-  set_identifier_size (sizeof (struct tree_identifier));
-
   current_function_decl = NULL;
   current_binding_level = NULL_BINDING_LEVEL;
   pushlevel (0);	/* make the binding_level structure for global names */
@@ -1403,9 +1415,6 @@
   merc_init_builtin_functions ();
 
   pedantic_lvalues = pedantic;
-
-  start_identifier_warnings ();
-
 }
 
 /* Handle a fatal error, for the Mercury front-end.
@@ -1456,7 +1465,7 @@
     = build_function_type (ptr_type_node, alloc_function_param_types);
   merc_alloc_function_node
     = builtin_function ("GC_malloc", alloc_function_type,
-			0, NOT_BUILT_IN, NULL_PTR);
+			0, NOT_BUILT_IN, NULL);
   DECL_IS_MALLOC (merc_alloc_function_node) = 1;
 
   /* Declare `int strcmp(const char *, const char *);'.  */
@@ -1478,7 +1487,7 @@
     = build_function_type (integer_type_node, hash_string_function_param_types);
   merc_hash_string_function_node
     = builtin_function ("MR_hash_string", hash_string_function_type,
-			0, NOT_BUILT_IN, NULL_PTR);
+			0, NOT_BUILT_IN, NULL);
 
   /* Declare `MR_Box MR_asm_box_float(MR_Float);'.  */
   box_float_function_param_types
@@ -1487,7 +1496,7 @@
     = build_function_type (ptr_type_node, box_float_function_param_types);
   merc_box_float_function_node
     = builtin_function ("MR_asm_box_float", box_float_function_type,
-			0, NOT_BUILT_IN, NULL_PTR);
+			0, NOT_BUILT_IN, NULL);
 
   /* Declare `int __builtin_setjmp(void *);'.  */
   setjmp_function_param_types
@@ -1496,7 +1505,7 @@
     = build_function_type (integer_type_node, setjmp_function_param_types);
   merc_setjmp_function_node
     = builtin_function ("__builtin_setjmp", setjmp_function_type,
-			BUILT_IN_SETJMP, BUILT_IN_NORMAL, NULL_PTR);
+			BUILT_IN_SETJMP, BUILT_IN_NORMAL, NULL);
 
   /* Declare `void __builtin_longjmp(void *, int);'.  */
   longjmp_function_param_types
@@ -1507,7 +1516,7 @@
     = build_function_type (void_type_node, longjmp_function_param_types);
   merc_longjmp_function_node
     = builtin_function ("__builtin_longjmp", longjmp_function_type,
-			BUILT_IN_LONGJMP, BUILT_IN_NORMAL, NULL_PTR);
+			BUILT_IN_LONGJMP, BUILT_IN_NORMAL, NULL);
 
   /* Register our global tree nodes as roots for the garbage collector.  */
   ggc_add_tree_root (&merc_alloc_function_node, 1);
@@ -1641,49 +1650,11 @@
     }
 }
 
-/* Print any language-specific compilation statistics.  */
-
-void
-print_lang_statistics ()
-{}
-
-/* Since we don't use the DECL_LANG_SPECIFIC field, this is a no-op.  */
-
 void
 copy_lang_decl (node)
      tree node ATTRIBUTE_UNUSED;
 {}
 
-/* Hooks for print-tree.c:  */
-
-void
-print_lang_decl (file, node, indent)
-     FILE *file ATTRIBUTE_UNUSED;
-     tree node ATTRIBUTE_UNUSED;
-     int indent ATTRIBUTE_UNUSED;
-{}
-
-void
-print_lang_type (file, node, indent)
-     FILE *file ATTRIBUTE_UNUSED;
-     tree node ATTRIBUTE_UNUSED;
-     int indent ATTRIBUTE_UNUSED;
-{}
-
-void
-print_lang_identifier (file, node, indent)
-     FILE *file ATTRIBUTE_UNUSED;
-     tree node ATTRIBUTE_UNUSED;
-     int indent ATTRIBUTE_UNUSED;
-{}
-
-/* Sets some debug flags for the parser. It does nothing here.  */
-
-void
-set_yydebug (value)
-     int value ATTRIBUTE_UNUSED;
-{}
-
 /* mark any data hanging of a tree node as used, for garbage collection  */
 void 
 lang_mark_tree (t)
@@ -1693,16 +1664,6 @@
   return;
 }
 
-/* Return the typed-based alias set for T, which may be an expression
-   or a type.  Return -1 if we don't do anything special.  */
-
-HOST_WIDE_INT
-lang_get_alias_set (t)
-     tree t ATTRIBUTE_UNUSED;
-{
-  return -1;
-}
-
 /* Return a definition for a builtin function named NAME and whose data type
    is TYPE.  TYPE should be a function type with argument types.
    FUNCTION_CODE tells later passes how to compile calls to this function.
@@ -1733,7 +1694,7 @@
     DECL_BUILT_IN_NONANSI (decl) = 1;
   if (library_name)
     SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
-  make_decl_rtl (decl, NULL_PTR);
+  make_decl_rtl (decl, NULL);
   pushdecl (decl);
   DECL_BUILT_IN_CLASS (decl) = class;
   DECL_FUNCTION_CODE (decl) = function_code;
Index: mercury/compiler/gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/gcc.m,v
retrieving revision 1.26
diff -u -d -r1.26 gcc.m
--- mercury/compiler/gcc.m	22 Jul 2002 07:12:57 -0000	1.26
+++ mercury/compiler/gcc.m	10 Sep 2002 09:33:25 -0000
@@ -681,7 +681,6 @@
 
 #include ""gcc/config.h""
 #include ""gcc/system.h""
-#include ""gcc/gansidecl.h""
 #include ""gcc/toplev.h""
 #include ""gcc/tree.h""
 /* XXX we should eliminate the dependency on the C front-end */
@@ -1146,7 +1145,7 @@
 	set_var_decl_asm_name(Decl::in, AsmName::in, _IO0::di, _IO::uo),
 	[will_not_call_mercury, promise_pure, tabled_for_io],
 "
-	DECL_ASSEMBLER_NAME((tree) Decl) = get_identifier(AsmName);
+	SET_DECL_ASSEMBLER_NAME((tree) Decl, get_identifier(AsmName));
 ").
 
 %

-- 
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