]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Jun 2010 20:22:49 +0000 (20:22 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Jun 2010 20:22:49 +0000 (20:22 +0000)
* Makefile.in (READ_MD_H): Add $(HASHTAB_H).
(build/genconstants.o): Depend on $(READ_MD_H) gensupport.h.
* genconstants.c: Include read-md.h.
* read-rtl.c (md_constants): Move to read-md.c.
(md_name): Move to read-md.h.
(initialize_iterators): Use leading_string_hash instead of def_hash
and leading_string_eq_p instead of def_name_eq_p.
(read_name): Move to read-md.c.
(def_hash, def_name_eq_p): Delete.
(read_constants, traverse_md_constants): Move to read-md.c.
* rtl.h (md_constant, traverse_md_constants): Move to read-md.h.
* read-md.h: Include hashtab.h.
(md_name): Moved from read-rtl.c.
(md_constant): Moved from read-md.h.
(leading_string_hash, leading_string_eq_p, read_name)
(read_constants, traverse_md_constants): Declare.
* read-md.c (md_constants): Moved from read-rtl.c.
(leading_string_hash, leading_string_eq_p): New functions.
(read_name, read_constants, traverse_md_constants): Moved from
read-rtl.c.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160575 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/Makefile.in
gcc/genconstants.c
gcc/read-md.c
gcc/read-md.h
gcc/read-rtl.c
gcc/rtl.h

index 7d62dc4387aaeb92b9b4b66523390702d13d8776..c40d0a168b0a0b7e4f9319d51895b5b3c3f2ee8e 100644 (file)
@@ -1,3 +1,26 @@
+2010-06-10  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * Makefile.in (READ_MD_H): Add $(HASHTAB_H).
+       (build/genconstants.o): Depend on $(READ_MD_H) gensupport.h.
+       * genconstants.c: Include read-md.h.
+       * read-rtl.c (md_constants): Move to read-md.c.
+       (md_name): Move to read-md.h.
+       (initialize_iterators): Use leading_string_hash instead of def_hash
+       and leading_string_eq_p instead of def_name_eq_p.
+       (read_name): Move to read-md.c.
+       (def_hash, def_name_eq_p): Delete.
+       (read_constants, traverse_md_constants): Move to read-md.c.
+       * rtl.h (md_constant, traverse_md_constants): Move to read-md.h.
+       * read-md.h: Include hashtab.h.
+       (md_name): Moved from read-rtl.c.
+       (md_constant): Moved from read-md.h.
+       (leading_string_hash, leading_string_eq_p, read_name)
+       (read_constants, traverse_md_constants): Declare.
+       * read-md.c (md_constants): Moved from read-rtl.c.
+       (leading_string_hash, leading_string_eq_p): New functions.
+       (read_name, read_constants, traverse_md_constants): Moved from
+       read-rtl.c.
+
 2010-06-10  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * read-rtl.c (md_name): New structure.
index f3a354caaf1d6d61afa9aae5acb5947f1ce99429..b8379d082b16384388bf588e43273a476b4c451e 100644 (file)
@@ -871,7 +871,7 @@ RTL_BASE_H = rtl.h rtl.def $(MACHMODE_H) reg-notes.def insn-notes.def \
   $(INPUT_H) $(REAL_H) statistics.h $(VEC_H) $(FIXED_VALUE_H) alias.h
 FIXED_VALUE_H = fixed-value.h $(MACHMODE_H) double-int.h
 RTL_H = $(RTL_BASE_H) genrtl.h vecir.h
-READ_MD_H = $(OBSTACK_H) read-md.h
+READ_MD_H = $(OBSTACK_H) $(HASHTAB_H) read-md.h
 PARAMS_H = params.h params.def
 BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def
 TREE_H = tree.h all-tree.def tree.def c-family/c-common.def \
@@ -3814,7 +3814,7 @@ build/genconditions.o : genconditions.c $(RTL_BASE_H) $(BCONFIG_H)        \
 build/genconfig.o : genconfig.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
   coretypes.h $(GTM_H) errors.h gensupport.h
 build/genconstants.o : genconstants.c $(RTL_BASE_H) $(BCONFIG_H)       \
-  $(SYSTEM_H) coretypes.h $(GTM_H) errors.h
+  $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 build/genemit.o : genemit.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)     \
   coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 build/genextract.o : genextract.c $(RTL_BASE_H) $(BCONFIG_H)           \
index a68dbf157b248f0fd63bf9b929d19b9975abc1bf..1a0182c7a59db4494daa03e1df755e539a7f220a 100644 (file)
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "rtl.h"
 #include "errors.h"
+#include "read-md.h"
 #include "gensupport.h"
 
 /* Called via traverse_md_constants; emit a #define for
index 654e625d1942b014312a0a41fda25f08315edacf..07882aa240d478673b21afc6b10adf740dd4203e 100644 (file)
@@ -62,6 +62,29 @@ const char *read_md_filename;
 /* The current line number in READ_MD_FILE.  */
 int read_md_lineno;
 
+/* A table of md_constant structures, hashed by name.  Null if no
+   constant expansion should occur.  */
+static htab_t md_constants;
+
+/* Given an object that starts with a char * name field, return a hash
+   code for its name.  */
+
+hashval_t
+leading_string_hash (const void *def)
+{
+  return htab_hash_string (*(const char *const *) def);
+}
+
+/* Given two objects that start with char * name fields, return true if
+   they have the same name.  */
+
+int
+leading_string_eq_p (const void *def1, const void *def2)
+{
+  return strcmp (*(const char *const *) def1,
+                *(const char *const *) def2) == 0;
+}
+
 /* Return a hash value for the pointer pointed to by DEF.  */
 
 static hashval_t
@@ -314,6 +337,63 @@ read_skip_spaces (void)
     }
 }
 
+/* Read an rtx code name into NAME.  It is terminated by any of the
+   punctuation chars of rtx printed syntax.  */
+
+void
+read_name (struct md_name *name)
+{
+  int c;
+  size_t i;
+
+  c = read_skip_spaces ();
+
+  i = 0;
+  while (1)
+    {
+      if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r'
+         || c == EOF)
+       break;
+      if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
+         || c == '(' || c == '[')
+       {
+         unread_char (c);
+         break;
+       }
+
+      if (i == sizeof (name->buffer) - 1)
+       fatal_with_file_and_line ("name too long");
+      name->buffer[i++] = c;
+
+      c = read_char ();
+    }
+
+  if (i == 0)
+    fatal_with_file_and_line ("missing name or number");
+  if (c == '\n')
+    read_md_lineno++;
+
+  name->buffer[i] = 0;
+  name->string = name->buffer;
+
+  if (md_constants)
+    {
+      /* Do constant expansion.  */
+      struct md_constant *def;
+
+      do
+       {
+         struct md_constant tmp_def;
+
+         tmp_def.name = name->string;
+         def = (struct md_constant *) htab_find (md_constants, &tmp_def);
+         if (def)
+           name->string = def->value;
+       }
+      while (def);
+    }
+}
+
 /* Subroutine of the string readers.  Handles backslash escapes.
    Caller has read the backslash, but not placed it into the obstack.  */
 
@@ -522,6 +602,76 @@ scan_comma_elt (const char **pstr)
   return start;
 }
 
+/* Process a define_constants directive, starting with the optional space
+   after the "define_constants".  */
+
+void
+read_constants (void)
+{
+  int c;
+  htab_t defs;
+
+  defs = md_constants;
+  if (! defs)
+    defs = htab_create (32, leading_string_hash,
+                       leading_string_eq_p, (htab_del) 0);
+
+  c = read_skip_spaces ();
+  if (c != '[')
+    fatal_expected_char ('[', c);
+
+  /* Disable constant expansion during definition processing.  */
+  md_constants = 0;
+  while ( (c = read_skip_spaces ()) != ']')
+    {
+      struct md_name name, value;
+      struct md_constant *def, tmp_def;
+      void **entry_ptr;
+
+      if (c != '(')
+       fatal_expected_char ('(', c);
+
+      read_name (&name);
+      read_name (&value);
+
+      tmp_def.name = name.string;
+      entry_ptr = htab_find_slot (defs, &tmp_def, INSERT);
+      if (*entry_ptr)
+       {
+         def = (struct md_constant *) *entry_ptr;
+         if (strcmp (def->value, value.string) != 0)
+           fatal_with_file_and_line ("redefinition of %s, was %s, now %s",
+                                     def->name, def->value, value.string);
+       }
+      else
+       {
+         def = XNEW (struct md_constant);
+         def->name = xstrdup (name.string);
+         def->value = xstrdup (value.string);
+         *entry_ptr = def;
+       }
+
+      c = read_skip_spaces ();
+      if (c != ')')
+       fatal_expected_char (')', c);
+    }
+  md_constants = defs;
+  c = read_skip_spaces ();
+  if (c != ')')
+    fatal_expected_char (')', c);
+}
+
+/* For every constant definition, call CALLBACK with two arguments:
+   a pointer a pointer to the constant definition and INFO.
+   Stop when CALLBACK returns zero.  */
+
+void
+traverse_md_constants (htab_trav callback, void *info)
+{
+  if (md_constants)
+    htab_traverse (md_constants, callback, info);
+}
+
 /* Initialize this file's static data.  */
 
 void
index 075260b82b61031039be823eb7f3e7835825c150..2edd3ce4c21d4e4ce7a8a3750320c134de2d643c 100644 (file)
@@ -20,6 +20,26 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "obstack.h"
+#include "hashtab.h"
+
+/* Holds one symbol or number in the .md file.  */
+struct md_name {
+  /* The name as it appeared in the .md file.  Names are syntactically
+     limited to the length of this buffer.  */
+  char buffer[256];
+
+  /* The name that should actually be used by the generator programs.
+     This is an expansion of NAME, after things like constant substitution.  */
+  char *string;
+};
+
+/* This structure represents a constant defined by define_constant.
+   NAME is the name of the constant and VALUE is the string it
+   expands to.  */
+struct md_constant {
+  char *name;
+  char *value;
+};
 
 extern FILE *read_md_file;
 extern int read_md_lineno;
@@ -42,6 +62,8 @@ unread_char (int ch)
   ungetc (ch, read_md_file);
 }
 
+extern hashval_t leading_string_hash (const void *);
+extern int leading_string_eq_p (const void *, const void *);
 extern void copy_md_ptr_loc (const void *, const void *);
 extern void print_md_ptr_loc (const void *);
 extern const char *join_c_conditions (const char *, const char *);
@@ -52,8 +74,11 @@ extern void fatal_with_file_and_line (const char *, ...)
   ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
 extern void fatal_expected_char (int, int) ATTRIBUTE_NORETURN;
 extern int read_skip_spaces (void);
+extern void read_name (struct md_name *);
 extern char *read_quoted_string (void);
 extern char *read_string (int);
 extern int n_comma_elts (const char *);
 extern const char *scan_comma_elt (const char **);
+extern void read_constants (void);
+extern void traverse_md_constants (htab_trav, void *);
 extern void init_md_reader (void);
index 1b7d77d09c5324d204d9a7ffb71d5681035ae7ee..a3a9b61753c34c9bd2b889bc8aaac2176a653bf4 100644 (file)
@@ -33,19 +33,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "read-md.h"
 #include "gensupport.h"
 
-static htab_t md_constants;
-
-/* Holds one symbol or number in the .md file.  */
-struct md_name {
-  /* The name as it appeared in the .md file.  Names are syntactically
-     limited to the length of this buffer.  */
-  char buffer[256];
-
-  /* The name that should actually be used by the generator programs.
-     This is an expansion of NAME, after things like constant substitution.  */
-  char *string;
-};
-
 /* One element in a singly-linked list of (integer, string) pairs.  */
 struct map_value {
   struct map_value *next;
@@ -125,10 +112,6 @@ static struct mapping *add_mapping (struct iterator_group *, htab_t t,
 static struct map_value **add_map_value (struct map_value **,
                                         int, const char *);
 static void initialize_iterators (void);
-static void read_name (struct md_name *);
-static hashval_t def_hash (const void *);
-static int def_name_eq_p (const void *, const void *);
-static void read_constants (void);
 static void read_conditions (void);
 static void validate_const_int (const char *);
 static int find_iterator (struct iterator_group *, const char *);
@@ -579,15 +562,17 @@ initialize_iterators (void)
   char *copy, *p;
   int i;
 
-  modes.attrs = htab_create (13, def_hash, def_name_eq_p, 0);
-  modes.iterators = htab_create (13, def_hash, def_name_eq_p, 0);
+  modes.attrs = htab_create (13, leading_string_hash, leading_string_eq_p, 0);
+  modes.iterators = htab_create (13, leading_string_hash,
+                                leading_string_eq_p, 0);
   modes.num_builtins = MAX_MACHINE_MODE;
   modes.find_builtin = find_mode;
   modes.uses_iterator_p = uses_mode_iterator_p;
   modes.apply_iterator = apply_mode_iterator;
 
-  codes.attrs = htab_create (13, def_hash, def_name_eq_p, 0);
-  codes.iterators = htab_create (13, def_hash, def_name_eq_p, 0);
+  codes.attrs = htab_create (13, leading_string_hash, leading_string_eq_p, 0);
+  codes.iterators = htab_create (13, leading_string_hash,
+                                leading_string_eq_p, 0);
   codes.num_builtins = NUM_RTX_CODE;
   codes.find_builtin = find_code;
   codes.uses_iterator_p = uses_code_iterator_p;
@@ -621,63 +606,6 @@ initialize_iterators (void)
       upper_ptr = add_map_value (upper_ptr, i, copy);
     }
 }
-
-/* Read an rtx code name into NAME.  It is terminated by any of the
-   punctuation chars of rtx printed syntax.  */
-
-static void
-read_name (struct md_name *name)
-{
-  int c;
-  size_t i;
-
-  c = read_skip_spaces ();
-
-  i = 0;
-  while (1)
-    {
-      if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r'
-         || c == EOF)
-       break;
-      if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
-         || c == '(' || c == '[')
-       {
-         unread_char (c);
-         break;
-       }
-
-      if (i == sizeof (name->buffer) - 1)
-       fatal_with_file_and_line ("name too long");
-      name->buffer[i++] = c;
-
-      c = read_char ();
-    }
-
-  if (i == 0)
-    fatal_with_file_and_line ("missing name or number");
-  if (c == '\n')
-    read_md_lineno++;
-
-  name->buffer[i] = 0;
-  name->string = name->buffer;
-
-  if (md_constants)
-    {
-      /* Do constant expansion.  */
-      struct md_constant *def;
-
-      do
-       {
-         struct md_constant tmp_def;
-
-         tmp_def.name = name->string;
-         def = (struct md_constant *) htab_find (md_constants, &tmp_def);
-         if (def)
-           name->string = def->value;
-       }
-      while (def);
-    }
-}
 \f
 /* Provide a version of a function to read a long long if the system does
    not provide one.  */
@@ -716,95 +644,6 @@ atoll (const char *p)
   return tmp_wide;
 }
 #endif
-
-/* Given an object that starts with a char * name field, return a hash
-   code for its name.  */
-static hashval_t
-def_hash (const void *def)
-{
-  unsigned result, i;
-  const char *string = *(const char *const *) def;
-
-  for (result = i = 0; *string++ != '\0'; i++)
-    result += ((unsigned char) *string << (i % CHAR_BIT));
-  return result;
-}
-
-/* Given two objects that start with char * name fields, return true if
-   they have the same name.  */
-static int
-def_name_eq_p (const void *def1, const void *def2)
-{
-  return ! strcmp (*(const char *const *) def1,
-                  *(const char *const *) def2);
-}
-
-/* Process a define_constants directive, starting with the optional space
-   after the "define_constants".  */
-static void
-read_constants (void)
-{
-  int c;
-  htab_t defs;
-
-  c = read_skip_spaces ();
-  if (c != '[')
-    fatal_expected_char ('[', c);
-
-  defs = md_constants;
-  if (! defs)
-    defs = htab_create (32, def_hash, def_name_eq_p, (htab_del) 0);
-
-  /* Disable constant expansion during definition processing.  */
-  md_constants = 0;
-  while ( (c = read_skip_spaces ()) != ']')
-    {
-      struct md_name name, value;
-      struct md_constant *def, tmp_def;
-      void **entry_ptr;
-
-      if (c != '(')
-       fatal_expected_char ('(', c);
-
-      read_name (&name);
-      read_name (&value);
-
-      tmp_def.name = name.string;
-      entry_ptr = htab_find_slot (defs, &tmp_def, INSERT);
-      if (*entry_ptr)
-       {
-         def = (struct md_constant *) *entry_ptr;
-         if (strcmp (def->value, value.string) != 0)
-           fatal_with_file_and_line ("redefinition of %s, was %s, now %s",
-                                     def->name, def->value, value.string);
-       }
-      else
-       {
-         def = XNEW (struct md_constant);
-         def->name = xstrdup (name.string);
-         def->value = xstrdup (value.string);
-         *entry_ptr = def;
-       }
-
-      c = read_skip_spaces ();
-      if (c != ')')
-       fatal_expected_char (')', c);
-    }
-  md_constants = defs;
-  c = read_skip_spaces ();
-  if (c != ')')
-    fatal_expected_char (')', c);
-}
-
-/* For every constant definition, call CALLBACK with two arguments:
-   a pointer a pointer to the constant definition and INFO.
-   Stops when CALLBACK returns zero.  */
-void
-traverse_md_constants (htab_trav callback, void *info)
-{
-  if (md_constants)
-    htab_traverse (md_constants, callback, info);
-}
 \f
 /* Process a define_conditions directive, starting with the optional
    space after the "define_conditions".  The directive looks like this:
index 1ed8f73ebcfc09d8b60579579de73be35d2c2c9e..5826496fd891935dbc0b3aea8586d7e59e13ad9c 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2356,10 +2356,6 @@ extern void init_varasm_once (void);
 
 extern rtx make_debug_expr_from_rtl (const_rtx);
 
-/* In rtl.c */
-extern void traverse_md_constants (int (*) (void **, void *), void *);
-struct md_constant { char *name, *value; };
-
 /* In read-rtl.c */
 extern bool read_rtx (rtx *, int *);