Automatic date update in version.in
[deliverable/binutils-gdb.git] / sim / ppc / gen-icache.c
index bd585a6ca448822851ea5206938676cacbca2609..8acf3fba122e88cae5314b796fc3befd0924c20e 100644 (file)
@@ -1,10 +1,10 @@
 /*  This file is part of the program psim.
 
 /*  This file is part of the program psim.
 
-    Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
+    Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
 
     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
 
     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,
     (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
     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/>.
  
     */
 
  
     */
 
@@ -92,8 +91,10 @@ print_icache_extraction(lf *file,
                        insn_field *cur_field,
                        insn_bits *bits,
                        icache_decl_type what_to_declare,
                        insn_field *cur_field,
                        insn_bits *bits,
                        icache_decl_type what_to_declare,
-                       icache_body_type what_to_do)
+                       icache_body_type what_to_do,
+                       const char *reason)
 {
 {
+  const char *expression;
   ASSERT(entry_name != NULL);
 
   /* Define a storage area for the cache element */
   ASSERT(entry_name != NULL);
 
   /* Define a storage area for the cache element */
@@ -121,11 +122,12 @@ print_icache_extraction(lf *file,
       && strcmp(entry_name, cur_field->val_string) == 0
       && ((bits->opcode->is_boolean && bits->value == 0)
          || (!bits->opcode->is_boolean))) {
       && strcmp(entry_name, cur_field->val_string) == 0
       && ((bits->opcode->is_boolean && bits->value == 0)
          || (!bits->opcode->is_boolean))) {
-    /* The field has been made constant (as a result of expanding
-       instructions or similar).  Remember that for a boolean field,
-       value is either 0 (implying the required boolean_constant) or
-       nonzero (implying some other value) - Define the variable
-       accordingly */
+    /* The simple field has been made constant (as a result of
+       expanding instructions or similar).  Remember that for a
+       boolean field, value is either 0 (implying the required
+       boolean_constant) or nonzero (implying some other value and
+       handled later below) - Define the variable accordingly */
+    expression = "constant field";
     ASSERT(bits->field == cur_field);
     ASSERT(entry_type == NULL);
     if (bits->opcode->is_boolean)
     ASSERT(bits->field == cur_field);
     ASSERT(entry_type == NULL);
     if (bits->opcode->is_boolean)
@@ -137,23 +139,41 @@ print_icache_extraction(lf *file,
       lf_printf(file, "%d", bits->value);
   }
   else if (bits != NULL
       lf_printf(file, "%d", bits->value);
   }
   else if (bits != NULL
-          && bits->opcode->is_boolean
           && original_name != NULL
           && strncmp(entry_name,
                      original_name, strlen(original_name)) == 0
           && strncmp(entry_name + strlen(original_name),
                      "_is_", strlen("_is_")) == 0
           && original_name != NULL
           && strncmp(entry_name,
                      original_name, strlen(original_name)) == 0
           && strncmp(entry_name + strlen(original_name),
                      "_is_", strlen("_is_")) == 0
-          && (atol(entry_name + strlen(original_name) + strlen("_is_"))
-              == bits->opcode->boolean_constant)) {
+          && ((bits->opcode->is_boolean
+               && (atol(entry_name + strlen(original_name) + strlen("_is_"))
+                   == bits->opcode->boolean_constant))
+              || (!bits->opcode->is_boolean))) {
+    expression = "constant compare";
     /* An entry, derived from ORIGINAL_NAME, is testing to see of the
        ORIGINAL_NAME has a specific constant value.  That value
     /* An entry, derived from ORIGINAL_NAME, is testing to see of the
        ORIGINAL_NAME has a specific constant value.  That value
-       matching a boolean bit field */
-    lf_printf(file, "%d /* %s == %d */",
-             bits->value == 0, original_name, bits->opcode->boolean_constant);
+       matching a boolean or constant field */
+    if (bits->opcode->is_boolean)
+      lf_printf(file, "%d /* %s == %d */",
+               bits->value == 0,
+               original_name,
+               bits->opcode->boolean_constant);
+    else if (bits->opcode->last < bits->field->last)
+      lf_printf(file, "%d /* %s == %d */",
+               (atol(entry_name + strlen(original_name) + strlen("_is_"))
+                == (bits->value << (bits->field->last - bits->opcode->last))),
+               original_name,
+               (bits->value << (bits->field->last - bits->opcode->last)));
+    else
+      lf_printf(file, "%d /* %s == %d */",
+               (atol(entry_name + strlen(original_name) + strlen("_is_"))
+                == bits->value),
+               original_name,
+               bits->value);
   }
   else {
     /* put the field in the local variable, possibly also enter it
        into the cache */
   }
   else {
     /* put the field in the local variable, possibly also enter it
        into the cache */
+    expression = "extraction";
     /* handle the cache */
     if ((what_to_do & get_values_from_icache)
        || (what_to_do & put_values_in_icache)) {
     /* handle the cache */
     if ((what_to_do & get_values_from_icache)
        || (what_to_do & put_values_in_icache)) {
@@ -176,11 +196,12 @@ print_icache_extraction(lf *file,
     }
   }
 
     }
   }
 
-  if ((what_to_declare == define_variables)
-      || (what_to_declare == undef_variables))
-    lf_printf(file, "\n");
-  else
-    lf_printf(file, ";\n");
+  if (!((what_to_declare == define_variables)
+       || (what_to_declare == undef_variables)))
+    lf_printf(file, ";");
+  if (reason != NULL)
+    lf_printf(file, " /* %s - %s */", reason, expression);
+  lf_printf(file, "\n");
 }
 
 
 }
 
 
@@ -260,7 +281,8 @@ print_icache_body(lf *file,
                                      cur_field,
                                      bits,
                                      what_to_declare,
                                      cur_field,
                                      bits,
                                      what_to_declare,
-                                     do_not_use_icache);
+                                     do_not_use_icache,
+                                     "icache scratch");
            else if (cache_rule->type == compute_value
                     && ((what_to_do & get_values_from_icache)
                         || what_to_do == do_not_use_icache))
            else if (cache_rule->type == compute_value
                     && ((what_to_do & get_values_from_icache)
                         || what_to_do == do_not_use_icache))
@@ -275,7 +297,8 @@ print_icache_body(lf *file,
                                      cur_field,
                                      bits,
                                      what_to_declare,
                                      cur_field,
                                      bits,
                                      what_to_declare,
-                                     do_not_use_icache);
+                                     do_not_use_icache,
+                                     "semantic compute");
            else if (cache_rule->type == cache_value
                     && ((what_to_declare != undef_variables)
                         || !(what_to_do & put_values_in_icache)))
            else if (cache_rule->type == cache_value
                     && ((what_to_declare != undef_variables)
                         || !(what_to_do & put_values_in_icache)))
@@ -292,11 +315,14 @@ print_icache_body(lf *file,
                                      ((what_to_do & put_values_in_icache)
                                       ? declare_variables
                                       : what_to_declare),
                                      ((what_to_do & put_values_in_icache)
                                       ? declare_variables
                                       : what_to_declare),
-                                     what_to_do);
+                                     what_to_do,
+                                     "in icache");
          }
        }
       }
          }
        }
       }
-      /* No rule at all, assume that it should go into the cache */
+      /* No rule at all, assume that this is needed in the semantic
+         function (when values are extracted from the icache) and
+         hence must be put into the cache */
       if (found_rule == 0
          && ((what_to_declare != undef_variables)
              || !(what_to_do & put_values_in_icache)))
       if (found_rule == 0
          && ((what_to_declare != undef_variables)
              || !(what_to_do & put_values_in_icache)))
@@ -311,7 +337,8 @@ print_icache_body(lf *file,
                                ((what_to_do & put_values_in_icache)
                                 ? declare_variables
                                 : what_to_declare),
                                ((what_to_do & put_values_in_icache)
                                 ? declare_variables
                                 : what_to_declare),
-                               what_to_do);
+                               what_to_do,
+                               "default in icache");
       /* any thing else ... */
     }
   }
       /* any thing else ... */
     }
   }
@@ -329,7 +356,8 @@ print_icache_body(lf *file,
                            NULL, 0, /* file_name & line_nr */
                            NULL, NULL,
                            what_to_declare,
                            NULL, 0, /* file_name & line_nr */
                            NULL, NULL,
                            what_to_declare,
-                           what_to_do);
+                           what_to_do,
+                           NULL);
   }
 }
 
   }
 }
 
@@ -594,7 +622,7 @@ print_icache_internal_function_declaration(insn_table *table,
   ASSERT((code & generate_with_icache) != 0);
   if (it_is("internal", function->fields[insn_flags])) {
     lf_printf(file, "\n");
   ASSERT((code & generate_with_icache) != 0);
   if (it_is("internal", function->fields[insn_flags])) {
     lf_printf(file, "\n");
-    lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "INLINE_ICACHE",
+    lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "PSIM_INLINE_ICACHE",
                           "\n");
     print_function_name(file,
                        function->fields[insn_name],
                           "\n");
     print_function_name(file,
                        function->fields[insn_name],
@@ -614,7 +642,7 @@ print_icache_internal_function_definition(insn_table *table,
   ASSERT((code & generate_with_icache) != 0);
   if (it_is("internal", function->fields[insn_flags])) {
     lf_printf(file, "\n");
   ASSERT((code & generate_with_icache) != 0);
   if (it_is("internal", function->fields[insn_flags])) {
     lf_printf(file, "\n");
-    lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "INLINE_ICACHE",
+    lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "PSIM_INLINE_ICACHE",
                           "\n");
     print_function_name(file,
                        function->fields[insn_name],
                           "\n");
     print_function_name(file,
                        function->fields[insn_name],
This page took 0.027914 seconds and 4 git commands to generate.