Switch the inferior too in switch_to_program_space_and_thread
[deliverable/binutils-gdb.git] / sim / igen / gen-semantics.c
index 3acd6d802e0cf8973df05b4db21b0421353b30a1..d28b431fbfa1c4fb8750674e8941894fb248b0d4 100644 (file)
@@ -1,22 +1,23 @@
-/*  This file is part of the program psim.
+/* The IGEN simulator generator for GDB, the GNU Debugger.
 
-    Copyright (C) 1994-1998, Andrew Cagney <cagney@highland.com.au>
+   Copyright 2002-2020 Free Software Foundation, Inc.
 
-    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
-    (at your option) any later version.
+   Contributed by Andrew Cagney.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    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.
-    */
+   This file is part of GDB.
+
+   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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>.  */
 
 
 
@@ -45,7 +46,7 @@ print_semantic_function_header (lf *file,
                                int nr_prefetched_words)
 {
   int indent;
-  lf_printf(file, "\n");
+  lf_printf (file, "\n");
   lf_print__function_type_function (file, print_semantic_function_type,
                                    "EXTERN_SEMANTICS",
                                    (is_function_definition ? "\n" : " "));
@@ -82,52 +83,58 @@ print_semantic_function_header (lf *file,
 
 void
 print_semantic_declaration (lf *file,
-                           insn_entry *insn,
+                           insn_entry * insn,
                            opcode_bits *expanded_bits,
-                           insn_opcodes *opcodes,
-                           int nr_prefetched_words)
+                           insn_opcodes *opcodes, int nr_prefetched_words)
 {
   print_semantic_function_header (file,
                                  insn->name,
                                  insn->format_name,
                                  expanded_bits,
-                                 0/* is not function definition*/,
+                                 0 /* is not function definition */ ,
                                  nr_prefetched_words);
 }
+\f
 
 
-\f
 /* generate the semantics.c file */
 
 
 void
-print_idecode_invalid (lf *file,
-                      const char *result,
-                      invalid_type type)
+print_idecode_invalid (lf *file, const char *result, invalid_type type)
 {
   const char *name;
   switch (type)
     {
-    default: name = "unknown"; break;
-    case invalid_illegal: name = "illegal"; break;
-    case invalid_fp_unavailable: name = "fp_unavailable"; break;
-    case invalid_wrong_slot: name = "wrong_slot"; break;
+    default:
+      name = "unknown";
+      break;
+    case invalid_illegal:
+      name = "illegal";
+      break;
+    case invalid_fp_unavailable:
+      name = "fp_unavailable";
+      break;
+    case invalid_wrong_slot:
+      name = "wrong_slot";
+      break;
     }
   if (options.gen.code == generate_jumps)
     {
       lf_printf (file, "goto %s_%s;\n",
-                (options.gen.icache ? "icache" : "semantic"),
-                name);
+                (options.gen.icache ? "icache" : "semantic"), name);
     }
   else if (options.gen.icache)
     {
-      lf_printf (file, "%s %sicache_%s (", result, options.module.global.prefix.l, name);
+      lf_printf (file, "%s %sicache_%s (", result,
+                options.module.global.prefix.l, name);
       print_icache_function_actual (file, 0);
       lf_printf (file, ");\n");
     }
   else
     {
-      lf_printf (file, "%s %ssemantic_%s (", result, options.module.global.prefix.l, name);
+      lf_printf (file, "%s %ssemantic_%s (", result,
+                options.module.global.prefix.l, name);
       print_semantic_function_actual (file, 0);
       lf_printf (file, ");\n");
     }
@@ -136,18 +143,17 @@ print_idecode_invalid (lf *file,
 
 void
 print_semantic_body (lf *file,
-                    insn_entry *instruction,
-                    opcode_bits *expanded_bits,
-                    insn_opcodes *opcodes)
+                    insn_entry * instruction,
+                    opcode_bits *expanded_bits, insn_opcodes *opcodes)
 {
   /* validate the instruction, if a cache this has already been done */
   if (!options.gen.icache)
     {
       print_idecode_validate (file, instruction, opcodes);
     }
-  
-  print_itrace (file, instruction, 0/*put_value_in_cache*/);
-  
+
+  print_itrace (file, instruction, 0 /*put_value_in_cache */ );
+
   /* generate the instruction profile call - this is delayed until
      after the instruction has been verified.  The count macro
      generated is prefixed by ITABLE_PREFIX */
@@ -174,22 +180,20 @@ print_semantic_body (lf *file,
     print_function_name (file,
                         instruction->name,
                         instruction->format_name,
-                        NULL,
-                        NULL,
-                        function_name_prefix_itable);
+                        NULL, NULL, function_name_prefix_itable);
     lf_printf (file, ", cpu, cia);\n");
     lf_indent_suppress (file);
     lf_printf (file, "#endif\n");
     lf_printf (file, "\n");
   }
-  
+
   /* determine the new instruction address */
   {
-    lf_printf(file, "/* keep the next instruction address handy */\n");
+    lf_printf (file, "/* keep the next instruction address handy */\n");
     if (options.gen.nia == nia_is_invalid)
       {
-       lf_printf(file, "nia = %sINVALID_INSTRUCTION_ADDRESS;\n",
-                 options.module.global.prefix.u);
+       lf_printf (file, "nia = %sINVALID_INSTRUCTION_ADDRESS;\n",
+                  options.module.global.prefix.u);
       }
     else
       {
@@ -215,7 +219,7 @@ print_semantic_body (lf *file,
                lf_printf (file, "nia = cia + %d * (%d + 1); %s\n",
                           options.insn_bit_size / 8, nr_immeds,
                           "/* skip immeds as well */");
-               
+
              }
            else
              {
@@ -225,7 +229,7 @@ print_semantic_body (lf *file,
          }
       }
   }
-  
+
   /* if conditional, generate code to verify that the instruction
      should be issued */
   if (filter_is_member (instruction->options, "c")
@@ -238,7 +242,7 @@ print_semantic_body (lf *file,
       lf_indent (file, +4);
       /* FIXME - need to log a conditional failure */
     }
-  
+
   /* Architecture expects a REG to be zero.  Instead of having to
      check every read to see if it is refering to that REG just zap it
      at the start of every instruction */
@@ -246,9 +250,9 @@ print_semantic_body (lf *file,
     {
       lf_printf (file, "\n");
       lf_printf (file, "/* Architecture expects REG to be zero */\n");
-      lf_printf (file, "GPR_SET(%d, 0);\n", options.gen.zero_reg_nr);
+      lf_printf (file, "GPR_CLEAR(%d);\n", options.gen.zero_reg_nr);
     }
-  
+
   /* generate the code (or at least something */
   lf_printf (file, "\n");
   lf_printf (file, "/* semantics: */\n");
@@ -284,32 +288,30 @@ print_semantic_body (lf *file,
       lf_indent (file, -indent);
       lf_print__internal_ref (file);
     }
-  
+
   /* Close off the conditional execution */
   if (filter_is_member (instruction->options, "c")
       || options.gen.conditional_issue)
     {
       lf_indent (file, -4);
       lf_printf (file, "  }\n");
-    }  
+    }
 }
 
 static void
 print_c_semantic (lf *file,
-                 insn_entry *instruction,
+                 insn_entry * instruction,
                  opcode_bits *expanded_bits,
                  insn_opcodes *opcodes,
-                 cache_entry *cache_rules,
-                 int nr_prefetched_words)
+                 cache_entry *cache_rules, int nr_prefetched_words)
 {
-  
+
   lf_printf (file, "{\n");
   lf_indent (file, +2);
-  
+
   print_my_defines (file,
                    instruction->name,
-                   instruction->format_name,
-                   expanded_bits);
+                   instruction->format_name, expanded_bits);
   lf_printf (file, "\n");
   print_icache_body (file,
                     instruction,
@@ -320,16 +322,13 @@ print_c_semantic (lf *file,
                      : declare_variables),
                     (options.gen.icache
                      ? get_values_from_icache
-                     : do_not_use_icache),
-                    nr_prefetched_words);
-  
-  lf_printf (file, "%sinstruction_address nia;\n", options.module.global.prefix.l);
-  print_semantic_body (file,
-                      instruction,
-                      expanded_bits,
-                      opcodes);
+                     : do_not_use_icache), nr_prefetched_words);
+
+  lf_printf (file, "%sinstruction_address nia;\n",
+            options.module.global.prefix.l);
+  print_semantic_body (file, instruction, expanded_bits, opcodes);
   lf_printf (file, "return nia;\n");
-  
+
   /* generate something to clean up any #defines created for the cache */
   if (options.gen.direct_access)
     {
@@ -340,51 +339,41 @@ print_c_semantic (lf *file,
                         undef_variables,
                         (options.gen.icache
                          ? get_values_from_icache
-                         : do_not_use_icache),
-                        nr_prefetched_words);
+                         : do_not_use_icache), nr_prefetched_words);
     }
-  
+
   lf_indent (file, -2);
   lf_printf (file, "}\n");
 }
 
 static void
 print_c_semantic_function (lf *file,
-                          insn_entry *instruction,
+                          insn_entry * instruction,
                           opcode_bits *expanded_bits,
                           insn_opcodes *opcodes,
-                          cache_entry *cache_rules,
-                          int nr_prefetched_words)
+                          cache_entry *cache_rules, int nr_prefetched_words)
 {
   /* build the semantic routine to execute the instruction */
   print_semantic_function_header (file,
                                  instruction->name,
                                  instruction->format_name,
                                  expanded_bits,
-                                 1/*is-function-definition*/,
+                                 1 /*is-function-definition */ ,
                                  nr_prefetched_words);
   print_c_semantic (file,
                    instruction,
-                   expanded_bits,
-                   opcodes,
-                   cache_rules,
-                   nr_prefetched_words);
+                   expanded_bits, opcodes, cache_rules, nr_prefetched_words);
 }
 
 void
 print_semantic_definition (lf *file,
-                          insn_entry *insn,
+                          insn_entry * insn,
                           opcode_bits *expanded_bits,
                           insn_opcodes *opcodes,
-                          cache_entry *cache_rules,
-                          int nr_prefetched_words)
+                          cache_entry *cache_rules, int nr_prefetched_words)
 {
   print_c_semantic_function (file,
                             insn,
                             expanded_bits,
-                            opcodes,
-                            cache_rules,
-                            nr_prefetched_words);
+                            opcodes, cache_rules, nr_prefetched_words);
 }
-
-
This page took 0.03485 seconds and 4 git commands to generate.