Improve relocation overflow errors on MIPS.
[deliverable/binutils-gdb.git] / sim / ppc / dgen.c
index 2d6d3a33e07bec376a5ea333c3a17b310e2e5852..8e8f5fb61bcfbd984be2e4f16b58b76b7c1c7a4a 100644 (file)
@@ -4,7 +4,7 @@
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
+    the Free Software Foundation; either version 3 of the License, or
     (at your option) any later version.
 
     This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
     GNU General Public License for more details.
  
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+    along with this program; if not, see <http://www.gnu.org/licenses/>.
  
     */
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
 #include <getopt.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <stdarg.h>
-#include <string.h>
 
+#include "build-config.h"
 #include "misc.h"
 #include "lf.h"
 #include "table.h"
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
+
 /****************************************************************/
 
 int spreg_lookup_table = 1;
-int number_lines = 1;
 enum {
   nr_of_sprs = 1024,
 };
@@ -111,7 +123,7 @@ spreg_table_insert(spreg_table *table, table_entry *entry)
 static spreg_table *
 spreg_table_load(char *file_name)
 {
-  table *file = table_open(file_name, nr_spreg_fields);
+  table *file = table_open(file_name, nr_spreg_fields, 0);
   spreg_table *table = ZALLOC(spreg_table);
 
   {
@@ -142,15 +154,11 @@ gen_spreg_h(spreg_table *table, lf *file)
   spreg_table_entry *entry;
   char **attribute;
 
-  lf_print_copyleft(file);
+  lf_print__gnu_copyleft(file);
   lf_printf(file, "\n");
   lf_printf(file, "#ifndef _SPREG_H_\n");
   lf_printf(file, "#define _SPREG_H_\n");
   lf_printf(file, "\n");
-  lf_printf(file, "#ifndef INLINE_SPREG\n");
-  lf_printf(file, "#define INLINE_SPREG\n");
-  lf_printf(file, "#endif\n");
-  lf_printf(file, "\n");
   lf_printf(file, "typedef unsigned_word spreg;\n");
   lf_printf(file, "\n");
   lf_printf(file, "typedef enum {\n");
@@ -167,12 +175,14 @@ gen_spreg_h(spreg_table *table, lf *file)
   for (attribute = spreg_attributes;
        *attribute != NULL;
        attribute++) {
-    if (strcmp(*attribute, "name") == 0)
-      lf_printf(file, "INLINE_SPREG char *spr_%s(sprs spr);\n",
-               *attribute);
-    else
-      lf_printf(file, "INLINE_SPREG int spr_%s(sprs spr);\n",
-               *attribute);
+    if (strcmp(*attribute, "name") == 0) {
+      lf_print_function_type(file, "const char *", "INLINE_SPREG", " ");
+      lf_printf(file, "spr_%s(sprs spr);\n", *attribute);
+    }
+    else {
+      lf_print_function_type(file, "int", "INLINE_SPREG", " ");
+      lf_printf(file, "spr_%s(sprs spr);\n", *attribute);
+    }
   }
   lf_printf(file, "\n");
   lf_printf(file, "#endif /* _SPREG_H_ */\n");
@@ -186,12 +196,12 @@ gen_spreg_c(spreg_table *table, lf *file)
   char **attribute;
   int spreg_nr;
 
-  lf_print_copyleft(file);
+  lf_print__gnu_copyleft(file);
   lf_printf(file, "\n");
   lf_printf(file, "#ifndef _SPREG_C_\n");
   lf_printf(file, "#define _SPREG_C_\n");
   lf_printf(file, "\n");
-  lf_printf(file, "#include \"words.h\"\n");
+  lf_printf(file, "#include \"basics.h\"\n");
   lf_printf(file, "#include \"spreg.h\"\n");
 
   lf_printf(file, "\n");
@@ -221,10 +231,12 @@ gen_spreg_c(spreg_table *table, lf *file)
        *attribute != NULL;
        attribute++) {
     lf_printf(file, "\n");
-    if (strcmp(*attribute, "name") == 0)
-      lf_printf(file, "INLINE_SPREG char *\n");
-    else
-      lf_printf(file, "INLINE_SPREG int\n");
+    if (strcmp(*attribute, "name") == 0) {
+      lf_print_function_type(file, "const char *", "INLINE_SPREG", "\n");
+    }
+    else {
+      lf_print_function_type(file, "int", "INLINE_SPREG", "\n");
+    }
     lf_printf(file, "spr_%s(sprs spr)\n", *attribute);
     lf_printf(file, "{\n");
     if (spreg_lookup_table
@@ -267,25 +279,25 @@ main(int argc,
      char **argv,
      char **envp)
 {
+  lf_file_references file_references = lf_include_references;
   spreg_table *sprs = NULL;
   char *real_file_name = NULL;
+  int is_header = 0;
   int ch;
 
   if (argc <= 1) {
     printf("Usage: dgen ...\n");
     printf("-s  Use switch instead of table\n");
-    printf("-n  Use this as cpp line numbering name\n");
-    printf("-[Pp] <spreg>  Output spreg.h(P) or spreg.c(p)\n");
-    printf("-l  Suppress cpp line numbering in output files\n");
+    printf("-n <file-name>  Use this as cpp line numbering name\n");
+    printf("-h  Output header file\n");
+    printf("-p <spreg-file>  Output spreg.h(P) or spreg.c(p)\n");
+    printf("-L  Suppress cpp line numbering in output files\n");
   }
 
 
-  while ((ch = getopt(argc, argv, "lsn:r:P:p:")) != -1) {
+  while ((ch = getopt(argc, argv, "hLsn:r:p:")) != -1) {
     fprintf(stderr, "\t-%c %s\n", ch, ( optarg ? optarg : ""));
     switch(ch) {
-    case 'l':
-      number_lines = 0;
-      break;
     case 's':
       spreg_lookup_table = 0;
       break;
@@ -295,19 +307,23 @@ main(int argc,
     case 'n':
       real_file_name = strdup(optarg);
       break;
-    case 'P':
+    case 'L':
+      file_references = lf_omit_references;
+      break;
+    case 'h':
+      is_header = 1;
+      break;
     case 'p':
       {
-       lf *file = lf_open(optarg, real_file_name, number_lines);
-       switch (ch) {
-       case 'P':
+       lf *file = lf_open(optarg, real_file_name, file_references,
+                          (is_header ? lf_is_h : lf_is_c),
+                          argv[0]);
+       if (is_header)
          gen_spreg_h(sprs, file);
-         break;
-       case 'p':
+       else
          gen_spreg_c(sprs, file);
-         break;
-       }
        lf_close(file);
+       is_header = 0;
       }
       real_file_name = NULL;
       break;
This page took 0.02505 seconds and 4 git commands to generate.