This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] sim/sh: fix movua for little endian


The movua opcode was hardcoded for big endian; on little endian
targets it would retrieve the word backwards.  Note that the global
endian compensators are keyed to the HOST endian as well and are not
usable for this purpose.

The problem and solution are obvious, but my implementation may not
be, so I await approval (global maintainers - no sim/sh maintainer).

Tested with an ABI testsuite I'm working on which is known to use
movua.

2004-08-13  DJ Delorie  <dj@redhat.com>

	* gencode.c (movua.l): Compensate for endianness.

Index: gencode.c
===================================================================
RCS file: /cvs/src/src/sim/sh/gencode.c,v
retrieving revision 1.28
diff -p -U1 -r1.28 gencode.c
--- gencode.c	13 Feb 2004 00:01:19 -0000	1.28
+++ gencode.c	13 Aug 2004 19:17:00 -0000
@@ -868,5 +868,6 @@ op tab[] =
     "int regn = R[n];",
+    "int e = target_little_endian ? 3 : 0;",
     "MA (1);",
-    "R[0] = (RBAT (regn) << 24) + (RBAT (regn + 1) << 16) + ",
-    "  (RBAT (regn + 2) << 8) + RBAT (regn + 3);",
+    "R[0] = (RBAT (regn + (0^e)) << 24) + (RBAT (regn + (1^e)) << 16) + ",
+    "  (RBAT (regn + (2^e)) << 8) + RBAT (regn + (3^e));",
     "L (0);",
@@ -875,5 +876,6 @@ op tab[] =
     "int regn = R[n];",
+    "int e = target_little_endian ? 3 : 0;",
     "MA (1);",
-    "R[0] = (RBAT (regn) << 24) + (RBAT (regn + 1) << 16) + ",
-    "  (RBAT (regn + 2) << 8) + RBAT (regn + 3);",
+    "R[0] = (RBAT (regn + (0^e)) << 24) + (RBAT (regn + (1^e)) << 16) + ",
+    "  (RBAT (regn + (2^e)) << 8) + RBAT (regn + (3^e));",
     "R[n] += 4;",


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]