bfd macro conversion to inline functions
[deliverable/binutils-gdb.git] / sim / ppc / igen.c
index 471c97bc1a5fa8b205f0673232cf3a9a4ab5d332..5a1df3ee911df36e738ac39063c3df372c96574b 100644 (file)
@@ -1,10 +1,10 @@
 /*  This file is part of the program psim.
 
-    Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
+    Copyright 1994, 1995, 1996, 1997, 2003 Andrew Cagney
 
     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 "misc.h"
 #include "lf.h"
 #include "table.h"
-#include "config.h"
+#include "build-config.h"
 
 #include "filter.h"
 
-#include "ld-decode.h"
 #include "ld-cache.h"
+#include "ld-decode.h"
 #include "ld-insn.h"
 
 #include "igen.h"
@@ -48,7 +47,7 @@ int insn_bit_size = max_insn_bit_size;
 igen_code code = generate_calls;
 
 int generate_expanded_instructions;
-int icache_size;
+int icache_size = 1024;
 int generate_smp;
 
 /****************************************************************/
@@ -107,6 +106,8 @@ print_function_name(lf *file,
       switch (*pos) {
       case '/':
       case '-':
+      case '(':
+      case ')':
        break;
       case ' ':
        nr += lf_putchr(file, '_');
@@ -127,9 +128,11 @@ print_function_name(lf *file,
 
 
 void
-print_define_my_index(lf *file,
-                     table_entry *file_entry)
+print_my_defines(lf *file,
+                insn_bits *expanded_bits,
+                table_entry *file_entry)
 {
+  /* #define MY_INDEX xxxxx */
   lf_indent_suppress(file);
   lf_printf(file, "#undef MY_INDEX\n");
   lf_indent_suppress(file);
@@ -139,6 +142,16 @@ print_define_my_index(lf *file,
                       NULL,
                       function_name_prefix_itable);
   lf_printf(file, "\n");
+  /* #define MY_PREFIX xxxxxx */
+  lf_indent_suppress(file);
+  lf_printf(file, "#undef MY_PREFIX\n");
+  lf_indent_suppress(file);
+  lf_printf(file, "#define MY_PREFIX ");
+  print_function_name(file,
+                     file_entry->fields[insn_name],
+                     expanded_bits,
+                     function_name_prefix_none);
+  lf_printf(file, "\n");
 }
 
 
@@ -169,6 +182,12 @@ gen_semantics_h(insn_table *table,
            SEMANTIC_FUNCTION_FORMAL);
   lf_printf(file, "\n");
   if ((code & generate_calls)) {
+    lf_printf(file, "extern int option_mpc860c0;\n");
+    lf_printf(file, "#define PAGE_SIZE 0x1000\n");
+    lf_printf(file, "\n");
+    lf_printf(file, "PSIM_EXTERN_SEMANTICS(void)\n");
+    lf_printf(file, "semantic_init(device* root);\n");
+    lf_printf(file, "\n");
     if (generate_expanded_instructions)
       insn_table_traverse_tree(table,
                               file, NULL,
@@ -200,8 +219,23 @@ gen_semantics_c(insn_table *table,
     lf_printf(file, "#include \"cpu.h\"\n");
     lf_printf(file, "#include \"idecode.h\"\n");
     lf_printf(file, "#include \"semantics.h\"\n");
+    lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
+    lf_printf(file, "#include \"sim-inline.h\"\n");
+    lf_printf(file, "#include \"sim-fpu.h\"\n");
+    lf_printf(file, "#endif\n");
     lf_printf(file, "#include \"support.h\"\n");
     lf_printf(file, "\n");
+    lf_printf(file, "int option_mpc860c0 = 0;\n");
+    lf_printf(file, "\n");
+    lf_printf(file, "PSIM_EXTERN_SEMANTICS(void)\n");
+    lf_printf(file, "semantic_init(device* root)\n");
+    lf_printf(file, "{\n");
+    lf_printf(file, "  option_mpc860c0 = 0;\n");
+    lf_printf(file, "  if (tree_find_property(root, \"/options/mpc860c0\"))\n");
+    lf_printf(file, "    option_mpc860c0 = tree_find_integer_property(root, \"/options/mpc860c0\");\n");
+    lf_printf(file, "    option_mpc860c0 *= 4;   /* convert word count to byte count */\n");
+    lf_printf(file, "}\n");
+    lf_printf(file, "\n");
     if (generate_expanded_instructions)
       insn_table_traverse_tree(table,
                               file, cache_rules,
@@ -273,6 +307,10 @@ gen_icache_c(insn_table *table,
     lf_printf(file, "#include \"idecode.h\"\n");
     lf_printf(file, "#include \"semantics.h\"\n");
     lf_printf(file, "#include \"icache.h\"\n");
+    lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
+    lf_printf(file, "#include \"sim-inline.h\"\n");
+    lf_printf(file, "#include \"sim-fpu.h\"\n");
+    lf_printf(file, "#endif\n");
     lf_printf(file, "#include \"support.h\"\n");
     lf_printf(file, "\n");
     insn_table_traverse_function(table,
@@ -312,6 +350,7 @@ main(int argc,
   decode_table *decode_rules = NULL;
   filter *filters = NULL;
   insn_table *instructions = NULL;
+  table_include *includes = NULL;
   char *real_file_name = NULL;
   int is_header = 0;
   int ch;
@@ -321,18 +360,22 @@ main(int argc,
     printf("  igen <config-opts> ... <input-opts>... <output-opts>...\n");
     printf("Config options:\n");
     printf("  -F <filter-out-flag>  eg -F 64 to skip 64bit instructions\n");
-    printf("  -C                    Include semantics in cache functions\n");
     printf("  -E                    Expand (duplicate) semantic functions\n");
     printf("  -I <icache-size>      Generate cracking cache version\n");
+    printf("  -C                    Include semantics in cache functions\n");
+    printf("  -S                    Include insn (instruction) in icache\n");
     printf("  -R                    Use defines to reference cache vars\n");
     printf("  -L                    Supress line numbering in output files\n");
     printf("  -B <bit-size>         Set the number of bits in an instruction\n");
     printf("  -H <high-bit>         Set the nr of the high (msb bit)\n");
     printf("  -N <nr-cpus>          Specify the max number of cpus the simulation will support\n");
     printf("  -J                    Use jumps instead of function calls\n");
+    printf("  -T <mechanism>        Override the mechanism used to decode an instruction\n");
+    printf("                        using <mechanism> instead of what was specified in the\n");
+    printf("                        decode-rules input file\n");
     printf("\n");
     printf("Input options (ucase version also dumps loaded table):\n");
-    printf("  -o <opcode-rules>\n");
+    printf("  -o <decode-rules>\n");
     printf("  -k <cache-rules>\n");
     printf("  -i <instruction-table>\n");
     printf("\n");
@@ -348,15 +391,17 @@ main(int argc,
   }
 
   while ((ch = getopt(argc, argv,
-                     "F:EI:RLJCB:H:N:o:k:i:n:hc:d:m:s:t:f:"))
+                     "F:EI:RSLJT:CB:H:N:o:k:i:n:hc:d:m:s:t:f:"))
         != -1) {
     fprintf(stderr, "\t-%c %s\n", ch, (optarg ? optarg : ""));
     switch(ch) {
     case 'C':
       code |= generate_with_icache;
       code |= generate_with_semantic_icache;
-      if (icache_size == 0)
-       icache_size = 1024;
+      break;
+    case 'S':
+      code |= generate_with_icache;
+      code |= generate_with_insn_in_icache;
       break;
     case 'L':
       file_references = lf_omit_references;
@@ -364,18 +409,55 @@ main(int argc,
     case 'E':
       generate_expanded_instructions = 1;
       break;
+    case 'G':
+      {
+       int enable_p;
+       char *argp;
+       if (strncmp (optarg, "no-", strlen ("no-")) == 0)
+         {
+           argp = optarg + strlen ("no-");
+           enable_p = 0;
+         }
+       else if (strncmp (optarg, "!", strlen ("!")) == 0)
+         {
+           argp = optarg + strlen ("no-");
+           enable_p = 0;
+         }
+       else
+         {
+           argp = optarg;
+           enable_p = 1;
+         }
+        if (strncmp (argp, "gen-icache", strlen ("gen-icache")) == 0)
+          {
+            switch (argp[strlen ("gen-icache")])
+              {
+              case '=':
+               icache_size = atoi (argp + strlen ("gen-icache") + 1);
+               code |= generate_with_icache;
+                break;
+              case '\0':
+               code |= generate_with_icache;
+                break;
+              default:
+                error (NULL, "Expecting -Ggen-icache or -Ggen-icache=<N>\n");
+              }
+          }
+       }
     case 'I':
-      icache_size = a2i(optarg);
-      code |= generate_with_icache;
+      {
+       table_include **dir = &includes;
+       while ((*dir) != NULL)
+         dir = &(*dir)->next;
+       (*dir) = ZALLOC (table_include);
+       (*dir)->dir = strdup (optarg);
+      }
       break;
     case 'N':
       generate_smp = a2i(optarg);
       break;
     case 'R':
-      code |= generate_with_icache;
-      code |= generate_with_direct_access_icache;
-      if (icache_size == 0)
-       icache_size = 1024;
+      code |= generate_with_direct_access;
       break;
     case 'B':
       insn_bit_size = a2i(optarg);
@@ -393,12 +475,16 @@ main(int argc,
       code &= ~generate_calls;
       code |= generate_jumps;
       break;
+    case 'T':
+      force_decode_gen_type(optarg);
+      break;
     case 'i':
-      if (decode_rules == NULL || cache_rules == NULL) {
-       fprintf(stderr, "Must specify decode and cache tables\n");
+      if (decode_rules == NULL) {
+       fprintf(stderr, "Must specify decode tables\n");
        exit (1);
       }
-      instructions = load_insn_table(optarg, decode_rules, filters);
+      instructions = load_insn_table(optarg, decode_rules, filters, includes,
+                                    &cache_rules);
       fprintf(stderr, "\texpanding ...\n");
       insn_table_expand_insns(instructions);
       break;
This page took 0.027605 seconds and 4 git commands to generate.