2007-09-24 Andrew Stubbs <andrew.stubbs@st.com>
[deliverable/binutils-gdb.git] / sim / sh / gencode.c
index f03ba4e341e65d95ec26649426f51f0fa91bed89..738b718e23ab86e3a7bda2e665b15d5cf270d177 100644 (file)
@@ -102,8 +102,8 @@ op tab[] =
 
   { "", "n", "bit32 #imm3,@(disp12,<REG_N>)", "0011nnnni8*11001",
     "/* 32-bit logical bit-manipulation instructions.  */",
-    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "int word2 = RIAT (nip);",
+    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "i >>= 4;  /* BOGUS: Using only three bits of 'i'.  */",
     "/* MSB of 'i' must be zero.  */",
     "if (i > 7)",
@@ -215,7 +215,9 @@ op tab[] =
     "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "if (R0 == 0)",
     "  R[n] = 0xffffffff;",
-    "else (unsigned int) R[n] = (unsigned int) R[n] / (unsigned int) R0;",
+    "/* FIXME: The result may be implementation-defined if it is outside */",
+    "/* the range of signed int (i.e. if R[n] was negative and R0 == 1).  */",
+    "else R[n] = R[n] / (unsigned int) R0;",
     "L (n);",
   },
   { "n", "0n", "mulr R0,<REG_N>", "0100nnnn10000000",
@@ -238,9 +240,9 @@ op tab[] =
     "saved_state.asregs.regstack[bankn].regs[regn] = R0;",
   },
   { "", "", "resbank", "0000000001011011",
+    "int i;",
     "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     /* FIXME: cdef all */
-    "int i;",
     "if (BO) { /* Bank Overflow */",
     /* FIXME: how do we know when to reset BO?  */
     "  for (i = 0; i <= 14; i++) {",
@@ -587,8 +589,8 @@ op tab[] =
     "   and mov.bwl <REG_N>, @(disp12,<REG_M>)",
     "   and mov.bwl @(disp12,<REG_N>),<REG_M>",
     "   and movu.bw @(disp12,<REG_N>),<REG_M>.  */",
-    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "int word2 = RIAT (nip);",
+    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "SET_NIP (nip + 2);        /* Consume 2 more bytes.  */",
     "MA (1);",
     "do_long_move_insn (word2 & 0xf000, word2 & 0x0fff, m, n, &thislock);",
@@ -968,9 +970,11 @@ op tab[] =
     "WBAT (R[n] + R0, R[m]);",
   },
   { "n", "nm", "mov.b <REG_M>,@-<REG_N>", "0010nnnnmmmm0100",
+    /* Allow for the case where m == n.  */
+    "int t = R[m];",
     "MA (1);",
     "R[n] -= 1;",
-    "WBAT (R[n], R[m]);",
+    "WBAT (R[n], t);",
   },
   { "n", "n0", "mov.b R0,@<REG_N>+", "0100nnnn10001011",
     "MA (1);",
@@ -989,6 +993,7 @@ op tab[] =
     "L (0);",
   },
   { "n", "", "mov.l @(<disp>,PC),<REG_N>", "1101nnnni8p4....",
+    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "MA (1);",
     "R[n] = RLAT ((PH2T (PC) & ~3) + 4 + i);",
     "L (n);",
@@ -1033,9 +1038,11 @@ op tab[] =
     "WLAT (R0 + R[n], R[m]);",
   },
   { "n", "nm", "mov.l <REG_M>,@-<REG_N>", "0010nnnnmmmm0110",
+    /* Allow for the case where m == n.  */
+    "int t = R[m];",
     "MA (1) ;",
     "R[n] -= 4;",
-    "WLAT (R[n], R[m]);",
+    "WLAT (R[n], t);",
   },
   { "n", "n0", "mov.l R0,@<REG_N>+", "0100nnnn10101011",
     "MA (1) ;",
@@ -1053,6 +1060,7 @@ op tab[] =
     "L (0);",
   },
   { "n", "", "mov.w @(<disp>,PC),<REG_N>", "1001nnnni8p2....",
+    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "MA (1);",
     "R[n] = RSWAT (PH2T (PC + 4 + i));",
     "L (n);",
@@ -1097,9 +1105,11 @@ op tab[] =
     "WWAT (R0 + R[n], R[m]);",
   },
   { "n", "mn", "mov.w <REG_M>,@-<REG_N>", "0010nnnnmmmm0101",
+    /* Allow for the case where m == n.  */
+    "int t = R[m];",
     "MA (1);",
     "R[n] -= 2;",
-    "WWAT (R[n], R[m]);",
+    "WWAT (R[n], t);",
   },
   { "n", "0n", "mov.w R0,@<REG_N>+", "0100nnnn10011011",
     "MA (1);",
@@ -1112,6 +1122,7 @@ op tab[] =
   },
 
   { "0", "", "mova @(<disp>,PC),R0", "11000111i8p4....",
+    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "R0 = ((i + 4 + PH2T (PC)) & ~0x3);",
   },
 
@@ -1493,8 +1504,8 @@ op tab[] =
   },
 
   { "0", "", "trapa #<imm>", "11000011i8*1....", 
-    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "long imm = 0xff & i;",
+    "RAISE_EXCEPTION_IF_IN_DELAY_SLOT ();",
     "if (i < 20 || i == 33 || i == 34 || i == 0xc3)",
     "  nip += trap (i, &R0, PC, memory, maskl, maskw, endianw);",
 #if 0
This page took 0.025404 seconds and 4 git commands to generate.