Mercurial > hg > CbC > CbC_gcc
diff gcc/genconstants.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | a06113de4d67 |
children | 04ced10e8804 |
line wrap: on
line diff
--- a/gcc/genconstants.c Tue May 25 18:58:51 2010 +0900 +++ b/gcc/genconstants.c Tue Mar 22 17:18:12 2011 +0900 @@ -3,7 +3,7 @@ a (define_constants ...) pattern. Copyright (C) 1987, 1991, 1995, 1998, 1999, 2000, 2001, 2003, 2004, - 2007 Free Software Foundation, Inc. + 2007, 2010 Free Software Foundation, Inc. This file is part of GCC. @@ -28,21 +28,50 @@ #include "bconfig.h" #include "system.h" #include "coretypes.h" -#include "tm.h" -#include "rtl.h" #include "errors.h" -#include "gensupport.h" +#include "read-md.h" /* Called via traverse_md_constants; emit a #define for the current constant definition. */ static int -print_md_constant (void **slot, void *info) +print_md_constant (void **slot, void *info ATTRIBUTE_UNUSED) { struct md_constant *def = (struct md_constant *) *slot; - FILE *file = (FILE *) info; + + if (!def->parent_enum) + printf ("#define %s %s\n", def->name, def->value); + return 1; +} + +/* Called via traverse_enums. Emit an enum definition for + enum_type *SLOT. */ + +static int +print_enum_type (void **slot, void *info ATTRIBUTE_UNUSED) +{ + struct enum_type *def; + struct enum_value *value; + char *value_name; - fprintf (file, "#define %s %s\n", def->name, def->value); + def = (struct enum_type *) *slot; + printf ("\nenum %s {", def->name); + for (value = def->values; value; value = value->next) + { + printf ("\n %s = %s", value->def->name, value->def->value); + if (value->next) + putc (',', stdout); + } + printf ("\n};\n"); + + /* Define NUM_<enum>_VALUES to be the largest enum value + 1. */ + value_name = ACONCAT (("num_", def->name, "_values", NULL)); + upcase_string (value_name); + printf ("#define %s %d\n", value_name, def->num_values); + + /* Declare the array that is generated by genenum. */ + printf ("extern const char *const %s_strings[];\n", def->name); + return 1; } @@ -51,7 +80,7 @@ { progname = "genconstants"; - if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) + if (!read_md_files (argc, argv, NULL, NULL)) return (FATAL_EXIT_CODE); /* Initializing the MD reader has the side effect of loading up @@ -62,7 +91,8 @@ puts ("#ifndef GCC_INSN_CONSTANTS_H"); puts ("#define GCC_INSN_CONSTANTS_H\n"); - traverse_md_constants (print_md_constant, stdout); + traverse_md_constants (print_md_constant, 0); + traverse_enum_types (print_enum_type, 0); puts ("\n#endif /* GCC_INSN_CONSTANTS_H */");