This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Let gencodes declare predicates (was: SH: declare fpul_operands)


Here's an updated version of a patch I had posted earlier, that
addresses an issue Bernd raised in private (missing comments) and adds
Copyright notes.  Since I've only modified comments since the last
patch, I haven't bootstrapped&checked it again.  Ok to install?

Index: gcc/ChangeLog

	* gencodes.c (output_predicate_decls): New function.
	(main): Call it.
	* machmode.h (GET_MODE_MASK): Arrange for it to be defined
	even if it is not the first time machmode.h is #included.
	* config/sh/sh.c (fpul_operand): Declare MODE argument.

Index: gcc/gencodes.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gencodes.c,v
retrieving revision 1.34
diff -u -p -r1.34 gencodes.c
--- gcc/gencodes.c 2000/11/22 18:50:41 1.34
+++ gcc/gencodes.c 2001/01/03 19:37:46
@@ -2,7 +2,7 @@
    - some macros CODE_FOR_... giving the insn_code_number value
    for each of the defined standard insn names.
    Copyright (C) 1987, 1991, 1995, 1998,
-   1999, 2000 Free Software Foundation, Inc.
+   1999, 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA.  */
 static int insn_code_number;
 
 static void gen_insn PARAMS ((rtx));
+static void output_predicate_decls PARAMS ((void));
 static int print_md_constant PARAMS ((void **, void *));
 
 static void
@@ -46,6 +47,30 @@ gen_insn (insn)
 	    insn_code_number);
 }
 
+/* Print out declarations for all predicates mentioned in
+   PREDICATE_CODES.  */
+
+static void
+output_predicate_decls ()
+{
+#ifdef PREDICATE_CODES
+  static struct {
+    const char *name;
+    RTX_CODE codes[NUM_RTX_CODE];
+  } *p, predicate[] = {
+    PREDICATE_CODES
+    {NULL, {}}
+  };
+  
+  putc ('\n', stdout);
+  puts ("struct rtx_def;\n#include \"machmode.h\"\n");
+  for (p = predicate; p->name; p++)
+    printf ("extern int %s PARAMS ((struct rtx_def *, enum machine_mode));\n",
+	    p->name);
+  putc ('\n', stdout);
+#endif
+}
+
 extern int main PARAMS ((int, char **));
 
 int
@@ -90,6 +115,8 @@ from the machine description file `md'. 
   printf ("\n#define MAX_INSN_CODE ((int) CODE_FOR_nothing)\n\n");
 
   traverse_md_constants (print_md_constant, stdout);
+
+  output_predicate_decls ();
 
   printf ("\n#endif /* MAX_INSN_CODE */\n");
 
Index: gcc/machmode.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/machmode.h,v
retrieving revision 1.24
diff -u -p -r1.24 machmode.h
--- gcc/machmode.h 2000/09/18 17:55:38 1.24
+++ gcc/machmode.h 2001/01/03 19:37:47
@@ -1,5 +1,5 @@
 /* Machine mode definitions for GNU C-Compiler; included by rtl.h and tree.h.
-   Copyright (C) 1991, 1993, 1994, 1996, 1998, 1999, 2000
+   Copyright (C) 1991, 1993, 1994, 1996, 1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
 This file is part of GNU CC.
@@ -96,7 +96,9 @@ extern const unsigned int mode_unit_size
 extern const unsigned int mode_bitsize[];
 #define GET_MODE_BITSIZE(MODE)  (mode_bitsize[(int) (MODE)])
 
-#ifdef HOST_WIDE_INT
+#endif /* not HAVE_MACHINE_MODES */
+
+#if defined HOST_WIDE_INT && ! defined GET_MODE_MASK
 
 /* Get a bitmask containing 1 for all bits in a word
    that fit within mode MODE.  */
@@ -105,8 +107,11 @@ extern const unsigned HOST_WIDE_INT mode
 
 #define GET_MODE_MASK(MODE) mode_mask_array[(int) (MODE)]
 
-#endif /* HOST_WIDE_INT */
+#endif /* defined (HOST_WIDE_INT) && ! defined GET_MODE_MASK */
 
+#if ! defined GET_MODE_WIDER_MODE || ! defined GET_MODE_ALIGNMENT \
+    || ! defined GET_CLASS_NARROWEST_MODE
+
 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI).  */
 
 extern const unsigned char mode_wider_mode[];
@@ -153,4 +158,5 @@ extern enum machine_mode byte_mode;
 extern enum machine_mode word_mode;
 extern enum machine_mode ptr_mode;
 
-#endif /* not HAVE_MACHINE_MODES */
+#endif /* ! defined GET_MODE_WIDER_MODE || ! defined GET_MODE_ALIGNMENT
+	  || ! defined GET_CLASS_NARROWEST_MODE */
Index: gcc/config/sh/sh.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/sh/sh.c,v
retrieving revision 1.81
diff -u -p -r1.81 sh.c
--- gcc/config/sh/sh.c 2000/12/30 07:53:35 1.81
+++ gcc/config/sh/sh.c 2001/01/03 19:37:58
@@ -1,5 +1,5 @@
 /* Output routines for GCC for Hitachi Super-H.
-   Copyright (C) 1993, 1994, 1995, 1997, 1997, 1998, 1999, 2000
+   Copyright (C) 1993, 1994, 1995, 1997, 1997, 1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
    Contributed by Steve Chamberlain (sac@cygnus.com).
    Improved by Jim Wilson (wilson@cygnus.com). 
@@ -4793,6 +4793,7 @@ fpscr_operand (op, mode)
 int
 fpul_operand (op, mode)
      rtx op;
+     enum machine_mode mode;
 {
   return (GET_CODE (op) == REG
 	  && (REGNO (op) == FPUL_REG || REGNO (op) >= FIRST_PSEUDO_REGISTER)

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]