* [patch] sim/sh: fix movua for little endian
@ 2004-08-13 19:34 DJ Delorie
2004-08-23 19:48 ` Andrew Cagney
0 siblings, 1 reply; 9+ messages in thread
From: DJ Delorie @ 2004-08-13 19:34 UTC (permalink / raw)
To: gdb-patches; +Cc: dj
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;",
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] sim/sh: fix movua for little endian
2004-08-13 19:34 [patch] sim/sh: fix movua for little endian DJ Delorie
@ 2004-08-23 19:48 ` Andrew Cagney
2004-08-23 20:22 ` DJ Delorie
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2004-08-23 19:48 UTC (permalink / raw)
To: DJ Delorie; +Cc: gdb-patches
> 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.
Can you add a sim/testsuite/sh-elf/movua.s test? You'll need to clone
the infrastructure from one of the other test directories.
Andrew
> 2004-08-13 DJ Delorie <dj@redhat.com>
>
> * gencode.c (movua.l): Compensate for endianness.
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] sim/sh: fix movua for little endian
2004-08-23 19:48 ` Andrew Cagney
@ 2004-08-23 20:22 ` DJ Delorie
2004-08-23 20:43 ` Andrew Cagney
0 siblings, 1 reply; 9+ messages in thread
From: DJ Delorie @ 2004-08-23 20:22 UTC (permalink / raw)
To: cagney; +Cc: gdb-patches
> Can you add a sim/testsuite/sh-elf/movua.s test? You'll need to clone
> the infrastructure from one of the other test directories.
Should I just copy it from sim/testsuite/sim/sh ?
;-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] sim/sh: fix movua for little endian
2004-08-23 20:22 ` DJ Delorie
@ 2004-08-23 20:43 ` Andrew Cagney
2004-08-23 21:06 ` DJ Delorie
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2004-08-23 20:43 UTC (permalink / raw)
To: DJ Delorie; +Cc: gdb-patches
>>Can you add a sim/testsuite/sh-elf/movua.s test? You'll need to clone
>>> the infrastructure from one of the other test directories.
>
>
> Should I just copy it from sim/testsuite/sim/sh ?
Doh (I thought there was a test directory but missed it)! Can you
extend that test then?
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] sim/sh: fix movua for little endian
2004-08-23 20:43 ` Andrew Cagney
@ 2004-08-23 21:06 ` DJ Delorie
2004-08-24 13:13 ` Andrew Cagney
0 siblings, 1 reply; 9+ messages in thread
From: DJ Delorie @ 2004-08-23 21:06 UTC (permalink / raw)
To: cagney; +Cc: gdb-patches
> Doh (I thought there was a test directory but missed it)! Can you
> extend that test then?
Oddly, the test passes. Apparently, the simulator harness doesn't
pass the endianness flags to as/ld, so it's always assembled in big
endian mode.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] sim/sh: fix movua for little endian
2004-08-23 21:06 ` DJ Delorie
@ 2004-08-24 13:13 ` Andrew Cagney
2004-08-24 14:55 ` DJ Delorie
2004-09-08 22:35 ` DJ Delorie
0 siblings, 2 replies; 9+ messages in thread
From: Andrew Cagney @ 2004-08-24 13:13 UTC (permalink / raw)
To: DJ Delorie; +Cc: gdb-patches
>>> Doh (I thought there was a test directory but missed it)! Can you
>>> extend that test then?
>
>
> Oddly, the test passes. Apparently, the simulator harness doesn't
> pass the endianness flags to as/ld, so it's always assembled in big
> endian mode.
Can we fix that then? SIM fixes should always go hand-in-hand with a
testcase.
If fixing the be/le problems flushes out other failures, just note them,
I'm sure someone will fix them soon enough.
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] sim/sh: fix movua for little endian
2004-08-24 13:13 ` Andrew Cagney
@ 2004-08-24 14:55 ` DJ Delorie
2004-09-08 22:35 ` DJ Delorie
1 sibling, 0 replies; 9+ messages in thread
From: DJ Delorie @ 2004-08-24 14:55 UTC (permalink / raw)
To: cagney; +Cc: gdb-patches
> Can we fix that then? SIM fixes should always go hand-in-hand with
> a testcase.
I'll see what I can do.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] sim/sh: fix movua for little endian
2004-08-24 13:13 ` Andrew Cagney
2004-08-24 14:55 ` DJ Delorie
@ 2004-09-08 22:35 ` DJ Delorie
2004-09-12 15:02 ` Andrew Cagney
1 sibling, 1 reply; 9+ messages in thread
From: DJ Delorie @ 2004-09-08 22:35 UTC (permalink / raw)
To: cagney; +Cc: gdb-patches
> Can we fix that then? SIM fixes should always go hand-in-hand with a
> testcase.
>
> If fixing the be/le problems flushes out other failures, just note them,
> I'm sure someone will fix them soon enough.
I added a generic mechanism to allow the cpus to feed global options
into the test harness.
fcnvds.s fails, but I don't think it's the test suite that's broken.
I suspect there's a disagreement between gas and sim on how to lay out
doubles in memory.
I went with gcc-compatible options, for no reason other than that's
what my site.exp already used for the gcc/sh testsuite, and I didn't
want to have to have two site.exp's.
2004-09-08 DJ Delorie <dj@redhat.com>
* lib/sim-defs.exp (run_sim_test): Add global_as_options,
global_ld_options, and global_sim_options to all test cases,
if defined.
* sim/sh/allinsn.exp: Set global_as_options and
global_ld_options appropriately for little endian builds.
* sim/sh/movua.s: Support little endian.
Index: lib/sim-defs.exp
===================================================================
RCS file: /cvs/src/src/sim/testsuite/lib/sim-defs.exp,v
retrieving revision 1.6
diff -p -U3 -r1.6 sim-defs.exp
--- lib/sim-defs.exp 12 May 2004 03:34:26 -0000 1.6
+++ lib/sim-defs.exp 8 Sep 2004 22:34:00 -0000
@@ -165,6 +165,9 @@ proc run_sim_test { name requested_machs
global SIMFLAGS
global opts
global cpu_option
+ global global_as_options
+ global global_ld_options
+ global global_sim_options
if [string match "*/*" $name] {
set file $name
@@ -187,6 +190,16 @@ proc run_sim_test { name requested_machs
set opts(timeout) ""
set opts(xerror) "no"
+ if ![info exists global_as_options] {
+ set global_as_options ""
+ }
+ if ![info exists global_ld_options] {
+ set global_ld_options ""
+ }
+ if ![info exists global_sim_options] {
+ set global_sim_options ""
+ }
+
# Clear any machine specific options specified in a previous test case
foreach m $requested_machs {
if [info exists opts(as,$m)] {
@@ -250,7 +263,7 @@ proc run_sim_test { name requested_machs
if [info exists cpu_option] {
set as_options "$as_options $cpu_option=$mach"
}
- set comp_output [target_assemble $sourcefile ${name}.o "$as_options"]
+ set comp_output [target_assemble $sourcefile ${name}.o "$as_options $global_as_options"]
if ![string match "" $comp_output] {
verbose -log "$comp_output" 3
@@ -262,7 +275,7 @@ proc run_sim_test { name requested_machs
set opts(ld,$mach) $opts(ld)
}
- set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach)"]
+ set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach) $global_ld_options"]
if ![string match "" $comp_output] {
verbose -log "$comp_output" 3
@@ -281,7 +294,7 @@ proc run_sim_test { name requested_machs
set options "$options timeout=$opts(timeout)"
}
- set result [sim_run ${name}.x "$opts(sim,$mach)" "" "" "$options"]
+ set result [sim_run ${name}.x "$opts(sim,$mach) $global_sim_options" "" "" "$options"]
set status [lindex $result 0]
set output [lindex $result 1]
Index: sim/sh/allinsn.exp
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/sh/allinsn.exp,v
retrieving revision 1.5
diff -p -U3 -r1.5 allinsn.exp
--- sim/sh/allinsn.exp 12 Feb 2004 22:29:48 -0000 1.5
+++ sim/sh/allinsn.exp 8 Sep 2004 22:34:01 -0000
@@ -2,6 +2,13 @@
set all "sh shdsp"
+foreach opt $board_variant_list {
+ switch "x$opt" {
+ x-ml { set global_as_options "-little --defsym LITTLE=1"
+ set global_ld_options "-EL" }
+ }
+}
+
if [istarget sh-*elf] {
run_sim_test add.s $all
run_sim_test and.s $all
Index: sim/sh/movua.s
===================================================================
RCS file: /cvs/src/src/sim/testsuite/sim/sh/movua.s,v
retrieving revision 1.1
diff -p -U3 -r1.1 movua.s
--- sim/sh/movua.s 9 Jan 2004 19:47:36 -0000 1.1
+++ sim/sh/movua.s 8 Sep 2004 22:34:01 -0000
@@ -10,55 +10,107 @@ movua_1:
set_grs_a5a5
mov.l srcp, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x03020100
+.else
assertreg0 0x00010203
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x04030201
+.else
assertreg0 0x01020304
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x05040302
+.else
assertreg0 0x02030405
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x06050403
+.else
assertreg0 0x03040506
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x07060504
+.else
assertreg0 0x04050607
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x08070605
+.else
assertreg0 0x05060708
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x09080706
+.else
assertreg0 0x06070809
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x0a090807
+.else
assertreg0 0x0708090a
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x0b0a0908
+.else
assertreg0 0x08090a0b
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x0c0b0a09
+.else
assertreg0 0x090a0b0c
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x0d0c0b0a
+.else
assertreg0 0x0a0b0c0d
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x0e0d0c0b
+.else
assertreg0 0x0b0c0d0e
+.endif
add #1, r1
movua.l @r1, r0
+.ifdef LITTLE
+ assertreg0 0x0f0e0d0c
+.else
assertreg0 0x0c0d0e0f
+.endif
assertreg src+12, r1
test_gr_a5a5 r2
@@ -87,25 +139,41 @@ movua_4:
set_grs_a5a5
mov.l srcp2, r1
movua.l @r1+, r0
+.ifdef LITTLE
+ assertreg0 0x03020100
+.else
assertreg0 0x00010203
+.endif
assertreg src+4, r1
mov.l srcp2, r1
add #1, r1
movua.l @r1+, r0
+.ifdef LITTLE
+ assertreg0 0x04030201
+.else
assertreg0 0x01020304
+.endif
assertreg src+5, r1
mov.l srcp2, r1
add #2, r1
movua.l @r1+, r0
+.ifdef LITTLE
+ assertreg0 0x05040302
+.else
assertreg0 0x02030405
+.endif
assertreg src+6, r1
mov.l srcp2, r1
add #3, r1
movua.l @r1+, r0
+.ifdef LITTLE
+ assertreg0 0x06050403
+.else
assertreg0 0x03040506
+.endif
assertreg src+7, r1
test_gr_a5a5 r2
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] sim/sh: fix movua for little endian
2004-09-08 22:35 ` DJ Delorie
@ 2004-09-12 15:02 ` Andrew Cagney
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Cagney @ 2004-09-12 15:02 UTC (permalink / raw)
To: DJ Delorie; +Cc: gdb-patches
> fcnvds.s fails, but I don't think it's the test suite that's broken.
> I suspect there's a disagreement between gas and sim on how to lay out
> doubles in memory.
Ok, create a bug and KFAIL it if you want.
> 2004-09-08 DJ Delorie <dj@redhat.com>
>
> * lib/sim-defs.exp (run_sim_test): Add global_as_options,
> global_ld_options, and global_sim_options to all test cases,
> if defined.
> * sim/sh/allinsn.exp: Set global_as_options and
> global_ld_options appropriately for little endian builds.
> * sim/sh/movua.s: Support little endian.
Thanks! Feel free to commit.
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-09-12 15:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-13 19:34 [patch] sim/sh: fix movua for little endian DJ Delorie
2004-08-23 19:48 ` Andrew Cagney
2004-08-23 20:22 ` DJ Delorie
2004-08-23 20:43 ` Andrew Cagney
2004-08-23 21:06 ` DJ Delorie
2004-08-24 13:13 ` Andrew Cagney
2004-08-24 14:55 ` DJ Delorie
2004-09-08 22:35 ` DJ Delorie
2004-09-12 15:02 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox