Implement ERET instruction.
authorAndrew Cagney <cagney@redhat.com>
Tue, 21 Apr 1998 04:30:27 +0000 (04:30 +0000)
committerAndrew Cagney <cagney@redhat.com>
Tue, 21 Apr 1998 04:30:27 +0000 (04:30 +0000)
Add {signed,unsigned}_address type.

sim/common/ChangeLog
sim/common/sim-types.h
sim/mips/ChangeLog
sim/mips/interp.c
sim/mips/mips.igen

index fa67c10..59dd8cc 100644 (file)
@@ -1,3 +1,12 @@
+Tue Apr 21 13:18:41 1998  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * sim-types.h (signed_address, unsigned_address): Define.
+
+Mon Apr 20 21:47:54 1998  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * sim-fpu.c (sim_fpu_2d): Don't return an SNaN, convert it into a
+       QNaN.
+
 Thu Apr 16 10:30:14 1998  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * sim-fpu.c, sim-fpu.h (sim_fpu_fractionto, sim_fpu_tofraction):
index ddf9095..3b6d6ad 100644 (file)
@@ -65,15 +65,18 @@ typedef unsigned long unsigned32;
 #if defined __GNUC__ || defined _MSC_VER
 #ifdef __GNUC__
 
+/* GDB sometimes likes to make what appear to be signed `0x*L' values
+   unsigned by default */
+
 typedef long long natural64;
 typedef signed long long signed64;
 typedef unsigned long long unsigned64;
 
 #define UNSIGNED64(X) (X##ULL)
-#define SIGNED64(X) (X##LL)
+#define SIGNED64(X) ((signed64) X##LL)
 
 #define UNSIGNED32(X) (X##UL)
-#define SIGNED32(X) (X##L)
+#define SIGNED32(X) ((signed32) X##L)
 
 #else  /* _MSC_VER */
 
@@ -137,11 +140,14 @@ typedef signed32 signed_word;
 
 /* Other instructions */
 #if (WITH_TARGET_ADDRESS_BITSIZE == 64)
-typedef unsigned64 address_word;
+typedef unsigned64 unsigned_address;
+typedef signed64 signed_address;
 #endif
 #if (WITH_TARGET_ADDRESS_BITSIZE == 32)
-typedef unsigned32 address_word;
+typedef unsigned32 unsigned_address;
+typedef signed32 signed_address;
 #endif
+typedef unsigned_address address_word;
 
 /* IEEE 1275 cell size */
 #if (WITH_TARGET_CELL_BITSIZE == 64)
@@ -155,4 +161,13 @@ typedef unsigned32 unsigned_cell;
 typedef signed32 signed_cell;
 #endif
 
+/* Floating point registers */
+#if (WITH_TARGET_FLOATING_POINT_BITSIZE == 64)
+typedef unsigned64 fp_word;
+#endif
+#if (WITH_TARGET_FLOATING_POINT_BITSIZE == 32)
+typedef unsigned32 fp_word;
+#endif
+
+
 #endif /* _SIM_TYPES_H_ */
index f1725ab..f183029 100644 (file)
@@ -1,3 +1,16 @@
+Tue Apr 21 11:59:50 1998  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * mips.igen (ERET): Implement.
+
+       * interp.c (decode_coproc): Return sign-extended EPC.
+
+       * mips.igen (ANDI, LUI, MFC0): Add tracing code.
+
+       * interp.c (signal_exception): Do not ignore Trap.
+       (signal_exception): On TRAP, restart at exception address.
+       (HALT_INSTRUCTION, HALT_INSTRUCTION_MASK): Define.
+       (signal_exception): Update.
+
 Mon Apr 20 11:26:55 1998  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * sim-main.h (struct hilo_access, struct hilo_history): Define,
index 612b73b..7314388 100644 (file)
@@ -100,6 +100,7 @@ char* pr_uword64 PARAMS ((uword64 addr));
 /* The following reserved instruction value is used when a simulator
    trap is required. NOTE: Care must be taken, since this value may be
    used in later revisions of the MIPS ISA. */
+
 #define RSVD_INSTRUCTION           (0x00000005)
 #define RSVD_INSTRUCTION_MASK      (0xFC00003F)
 
@@ -107,6 +108,13 @@ char* pr_uword64 PARAMS ((uword64 addr));
 #define RSVD_INSTRUCTION_ARG_MASK  0xFFFFF  
 
 
+/* The following reserved instruction value is used when a simulator
+   halt is required.  NOTE: Care must be taken, since this value may
+   be used in later revisions of the MIPS ISA. */
+#define HALT_INSTRUCTION       (0x03ff000d)
+#define HALT_INSTRUCTION_MASK  (0x03FFFFC0)
+
+
 /* Bits in the Debug register */
 #define Debug_DBD 0x80000000   /* Debug Branch Delay */
 #define Debug_DM  0x40000000   /* Debug Mode         */
@@ -455,6 +463,19 @@ sim_open (kind, cb, abfd, argv)
     open_trace(sd);
 #endif /* TRACE */
 
+  /* Write an abort sequence into the TRAP (common) exception vector
+     addresses.  This is to catch code executing a TRAP (et.al.)
+     instruction without installing a trap handler. */
+  {
+    unsigned32 halt[2] = { 0x2404002f /* addiu r4, r0, 47 */,
+                          HALT_INSTRUCTION /* BREAK */ };
+    H2T (halt[0]);
+    H2T (halt[1]);
+    sim_write (sd, 0x80000180, (char *) halt, sizeof (halt));
+    sim_write (sd, 0xBFC00380, (char *) halt, sizeof (halt));
+  }
+
+
   /* Write the monitor trap address handlers into the monitor (eeprom)
      address space.  This can only be done once the target endianness
      has been determined. */
@@ -1574,13 +1595,6 @@ signal_exception (SIM_DESC sd,
   LLBIT = 0;
 
   switch (exception) {
-    /* TODO: For testing purposes I have been ignoring TRAPs. In
-       reality we should either simulate them, or allow the user to
-       ignore them at run-time.
-       Same for SYSCALL */
-    case Trap :
-     sim_io_eprintf(sd,"Ignoring instruction TRAP (PC 0x%s)\n",pr_addr(cia));
-     break;
 
     case SystemCall :
       {
@@ -1668,14 +1682,16 @@ signal_exception (SIM_DESC sd,
       {
        va_list ap;
        unsigned int instruction;
-       va_start(ap,exception);
+       va_start(ap, exception);
        instruction = va_arg(ap,unsigned int);
        va_end(ap);
        /* Check for our special terminating BREAK: */
-       if ((instruction & 0x03FFFFC0) == 0x03ff0000) {
-         sim_engine_halt (SD, CPU, NULL, cia,
-                          sim_exited, (unsigned int)(A0 & 0xFFFFFFFF));
-       }
+       if ((instruction & HALT_INSTRUCTION_MASK)
+           == (HALT_INSTRUCTION & HALT_INSTRUCTION_MASK))
+         {
+           sim_engine_halt (SD, CPU, NULL, cia,
+                            sim_exited, (unsigned int)(A0 & 0xFFFFFFFF));
+         }
       }
       if (STATE & simDELAYSLOT)
        PC = cia - 4; /* reference the branch instruction */
@@ -1751,6 +1767,9 @@ signal_exception (SIM_DESC sd,
                          sim_stopped, SIM_SIGFPE);
 
        case Trap:
+        sim_engine_restart (SD, CPU, NULL, PC);
+        break;
+
        case Watch:
        case SystemCall:
         PC = EPC;
@@ -3140,6 +3159,12 @@ decode_coproc (SIM_DESC sd,
                  CAUSE = GPR[rt];
                break;
                /* 14 = EPC                R4000   VR4100  VR4300 */
+             case 14:
+               if (code == 0x00)
+                 GPR[rt] = (signed_word) (signed_address) EPC;
+               else
+                 EPC = GPR[rt];
+               break;
                /* 15 = PRId               R4000   VR4100  VR4300 */
 #ifdef SUBTARGET_R3900
                 /* 16 = Debug */
index 89c1986..4050a2c 100644 (file)
 *tx19:
 // end-sanitize-tx19
 {
+  TRACE_ALU_INPUT2 (GPR[RS], IMMEDIATE);
   GPR[RT] = GPR[RS] & IMMEDIATE;
+  TRACE_ALU_RESULT (GPR[RT]);
 }
 
 
 *tx19:
 // end-sanitize-tx19
 {
+  TRACE_ALU_INPUT1 (IMMEDIATE);
   GPR[RT] = EXTEND32 (IMMEDIATE << 16);
+  TRACE_ALU_RESULT (GPR[RT]);
 }
 
 
 // start-sanitize-r5900
 *r5900:
 // end-sanitize-r5900
+{
+  if (SR & status_ERL)
+    {
+      /* Oops, not yet available */
+      sim_io_printf (SD, "Warning: ERET when SR[ERL] set not supported");
+      NIA = EPC;
+      SR &= ~status_ERL;
+    }
+  else
+    {
+      NIA = EPC;
+      SR &= ~status_EXL;
+    }
+}
 
 
 010000,00000,5.RT,5.RD,00000,6.REGX:COP0:32::MFC0
 *r5900:
 // end-sanitize-r5900
 {
+  TRACE_ALU_INPUT0 ();
   DecodeCoproc (instruction_0);
+  TRACE_ALU_RESULT (GPR[RT]);
 }
 
 010000,00100,5.RT,5.RD,00000,6.REGX:COP0:32::MTC0