Discussion:
[PATCH v2] sparc/leon: add support for partial write psr instruction
Daniel Cederman
2018-08-23 14:04:28 UTC
Permalink
Partial write %PSR (PWRPSR) is a SPARC V8e option that allows the WRPSR
instruction to only affect the %PSR.ET field. When available it is enabled
by setting the rd field of the WRPSR instruction to a value other than 0.
For Leon processors with support for partial write %PSR (currently GR740
and GR716) the rd value must be 1.

opcodes/ChangeLog:

2018-08-21 Martin Aberg <***@gaisler.com>

* sparc-opc.c (sparc_opcodes): Add Leon specific partial write
psr (PWRPSR) instruction.

gas/ChangeLog:

2018-08-21 Daniel Cederman <***@gaisler.com>

* testsuite/gas/sparc/leon.d: New test.
* testsuite/gas/sparc/leon.s: New test.
* testsuite/gas/sparc/sparc.exp: Execute the pwrpsr test.
---
gas/testsuite/gas/sparc/leon.d | 13 +++++++++++++
gas/testsuite/gas/sparc/leon.s | 6 ++++++
gas/testsuite/gas/sparc/sparc.exp | 1 +
opcodes/sparc-opc.c | 8 ++++++++
4 files changed, 28 insertions(+)
create mode 100644 gas/testsuite/gas/sparc/leon.d
create mode 100644 gas/testsuite/gas/sparc/leon.s

diff --git a/gas/testsuite/gas/sparc/leon.d b/gas/testsuite/gas/sparc/leon.d
new file mode 100644
index 00000000000..e3cf550ed74
--- /dev/null
+++ b/gas/testsuite/gas/sparc/leon.d
@@ -0,0 +1,13 @@
+#as: -Aleon
+#objdump: -dr
+#name: LEON instructions
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+ 0: 83 88 00 10 pwr %l0, %psr
+ 4: 83 88 00 00 pwr %g0, %psr
+ 8: 83 88 20 00 pwr %g0, %psr
+ c: 83 88 3f ff pwr -1, %psr
diff --git a/gas/testsuite/gas/sparc/leon.s b/gas/testsuite/gas/sparc/leon.s
new file mode 100644
index 00000000000..7b87c474e3a
--- /dev/null
+++ b/gas/testsuite/gas/sparc/leon.s
@@ -0,0 +1,6 @@
+ .text
+foo:
+ pwr %l0, %psr
+ pwr %g0, %psr
+ pwr 0, %psr
+ pwr -1, %psr
diff --git a/gas/testsuite/gas/sparc/sparc.exp b/gas/testsuite/gas/sparc/sparc.exp
index dcfec404d16..bb5f7295211 100644
--- a/gas/testsuite/gas/sparc/sparc.exp
+++ b/gas/testsuite/gas/sparc/sparc.exp
@@ -65,6 +65,7 @@ if [istarget sparc*-*-*] {
run_dump_test "ticc-imm-reg"
run_dump_test "v8-movwr-imm"
run_dump_test "save-args"
+ run_dump_test "leon"

set_tests_arch "v9c"
run_dump_test "ldtxa"
diff --git a/opcodes/sparc-opc.c b/opcodes/sparc-opc.c
index 6de9305d145..ab39398b5b8 100644
--- a/opcodes/sparc-opc.c
+++ b/opcodes/sparc-opc.c
@@ -71,6 +71,7 @@
| MASK_V9C | MASK_V9D | MASK_V9E | MASK_V9V | MASK_V9M \
| MASK_M8)
#define sparclet (MASK_SPARCLET)
+#define leon (MASK_LEON)
/* sparclet insns supported by leon. */
#define letandleon (MASK_SPARCLET | MASK_LEON)
#define sparclite (MASK_SPARCLITE)
@@ -1023,6 +1024,13 @@ wrasr (26, HWCAP_CBCOND, 0, v9e), /* wr ...,%cfr */
wrasr (27, HWCAP_PAUSE, 0, v9e), /* wr ...,%pause */
wrasr (28, 0, HWCAP2_MWAIT, v9m), /* wr ...,%mwait */

+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|ASI(~0), "1,2,p", 0, 0, 0, leon }, /* pwr r,r,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1), "1,i,p", 0, 0, 0, leon }, /* pwr r,i,%psr */
+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|RS1_G0|ASI(~0), "2,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr %g0,rs2,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1)|RS1_G0, "i,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr %g0,i,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1)|SIMM13(~0), "1,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr rs1,0,%psr */
+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|ASI_RS2(~0), "1,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr rs1,%g0,%psr */
+
{ "pause", F3(2, 0x30, 1)|RD(27)|RS1(0), F3(~2, ~0x30, ~1)|RD(~27)|RS1(~0), "i", 0, HWCAP_PAUSE, 0, v9e }, /* wr %g0,i,%pause */

{ "rd", F3(2, 0x28, 0)|RS1(2), F3(~2, ~0x28, ~0)|RS1(~2)|SIMM13(~0), "E,d", 0, 0, 0, v9 }, /* rd %ccr,r */
--
2.17.1
Jose E. Marchesi
2018-08-29 12:06:05 UTC
Permalink
Partial write %PSR (PWRPSR) is a SPARC V8e option that allows the WRPSR
instruction to only affect the %PSR.ET field. When available it is enabled
by setting the rd field of the WRPSR instruction to a value other than 0.
For Leon processors with support for partial write %PSR (currently GR740
and GR716) the rd value must be 1.

LGTM

opcodes/ChangeLog:

2018-08-21 Martin Aberg <***@gaisler.com>

* sparc-opc.c (sparc_opcodes): Add Leon specific partial write
psr (PWRPSR) instruction.

gas/ChangeLog:

2018-08-21 Daniel Cederman <***@gaisler.com>

* testsuite/gas/sparc/leon.d: New test.
* testsuite/gas/sparc/leon.s: New test.
* testsuite/gas/sparc/sparc.exp: Execute the pwrpsr test.
---
gas/testsuite/gas/sparc/leon.d | 13 +++++++++++++
gas/testsuite/gas/sparc/leon.s | 6 ++++++
gas/testsuite/gas/sparc/sparc.exp | 1 +
opcodes/sparc-opc.c | 8 ++++++++
4 files changed, 28 insertions(+)
create mode 100644 gas/testsuite/gas/sparc/leon.d
create mode 100644 gas/testsuite/gas/sparc/leon.s

diff --git a/gas/testsuite/gas/sparc/leon.d b/gas/testsuite/gas/sparc/leon.d
new file mode 100644
index 00000000000..e3cf550ed74
--- /dev/null
+++ b/gas/testsuite/gas/sparc/leon.d
@@ -0,0 +1,13 @@
+#as: -Aleon
+#objdump: -dr
+#name: LEON instructions
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+ 0: 83 88 00 10 pwr %l0, %psr
+ 4: 83 88 00 00 pwr %g0, %psr
+ 8: 83 88 20 00 pwr %g0, %psr
+ c: 83 88 3f ff pwr -1, %psr
diff --git a/gas/testsuite/gas/sparc/leon.s b/gas/testsuite/gas/sparc/leon.s
new file mode 100644
index 00000000000..7b87c474e3a
--- /dev/null
+++ b/gas/testsuite/gas/sparc/leon.s
@@ -0,0 +1,6 @@
+ .text
+foo:
+ pwr %l0, %psr
+ pwr %g0, %psr
+ pwr 0, %psr
+ pwr -1, %psr
diff --git a/gas/testsuite/gas/sparc/sparc.exp b/gas/testsuite/gas/sparc/sparc.exp
index dcfec404d16..bb5f7295211 100644
--- a/gas/testsuite/gas/sparc/sparc.exp
+++ b/gas/testsuite/gas/sparc/sparc.exp
@@ -65,6 +65,7 @@ if [istarget sparc*-*-*] {
run_dump_test "ticc-imm-reg"
run_dump_test "v8-movwr-imm"
run_dump_test "save-args"
+ run_dump_test "leon"

set_tests_arch "v9c"
run_dump_test "ldtxa"
diff --git a/opcodes/sparc-opc.c b/opcodes/sparc-opc.c
index 6de9305d145..ab39398b5b8 100644
--- a/opcodes/sparc-opc.c
+++ b/opcodes/sparc-opc.c
@@ -71,6 +71,7 @@
| MASK_V9C | MASK_V9D | MASK_V9E | MASK_V9V | MASK_V9M \
| MASK_M8)
#define sparclet (MASK_SPARCLET)
+#define leon (MASK_LEON)
/* sparclet insns supported by leon. */
#define letandleon (MASK_SPARCLET | MASK_LEON)
#define sparclite (MASK_SPARCLITE)
@@ -1023,6 +1024,13 @@ wrasr (26, HWCAP_CBCOND, 0, v9e), /* wr ...,%cfr */
wrasr (27, HWCAP_PAUSE, 0, v9e), /* wr ...,%pause */
wrasr (28, 0, HWCAP2_MWAIT, v9m), /* wr ...,%mwait */

+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|ASI(~0), "1,2,p", 0, 0, 0, leon }, /* pwr r,r,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1), "1,i,p", 0, 0, 0, leon }, /* pwr r,i,%psr */
+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|RS1_G0|ASI(~0), "2,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr %g0,rs2,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1)|RS1_G0, "i,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr %g0,i,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1)|SIMM13(~0), "1,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr rs1,0,%psr */
+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|ASI_RS2(~0), "1,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr rs1,%g0,%psr */
+
{ "pause", F3(2, 0x30, 1)|RD(27)|RS1(0), F3(~2, ~0x30, ~1)|RD(~27)|RS1(~0), "i", 0, HWCAP_PAUSE, 0, v9e }, /* wr %g0,i,%pause */

{ "rd", F3(2, 0x28, 0)|RS1(2), F3(~2, ~0x28, ~0)|RS1(~2)|SIMM13(~0), "E,d", 0, 0, 0, v9 }, /* rd %ccr,r */
Daniel Cederman
2018-08-29 13:41:48 UTC
Permalink
Thanks Jose!

I do not have commit access, would you mind applying the patch for me?

Best regards,

Daniel Cederman
Cobham Gaisler
Post by Daniel Cederman
Partial write %PSR (PWRPSR) is a SPARC V8e option that allows the WRPSR
instruction to only affect the %PSR.ET field. When available it is enabled
by setting the rd field of the WRPSR instruction to a value other than 0.
For Leon processors with support for partial write %PSR (currently GR740
and GR716) the rd value must be 1.
LGTM
* sparc-opc.c (sparc_opcodes): Add Leon specific partial write
psr (PWRPSR) instruction.
* testsuite/gas/sparc/leon.d: New test.
* testsuite/gas/sparc/leon.s: New test.
* testsuite/gas/sparc/sparc.exp: Execute the pwrpsr test.
---
gas/testsuite/gas/sparc/leon.d | 13 +++++++++++++
gas/testsuite/gas/sparc/leon.s | 6 ++++++
gas/testsuite/gas/sparc/sparc.exp | 1 +
opcodes/sparc-opc.c | 8 ++++++++
4 files changed, 28 insertions(+)
create mode 100644 gas/testsuite/gas/sparc/leon.d
create mode 100644 gas/testsuite/gas/sparc/leon.s
diff --git a/gas/testsuite/gas/sparc/leon.d b/gas/testsuite/gas/sparc/leon.d
new file mode 100644
index 00000000000..e3cf550ed74
--- /dev/null
+++ b/gas/testsuite/gas/sparc/leon.d
@@ -0,0 +1,13 @@
+#as: -Aleon
+#objdump: -dr
+#name: LEON instructions
+
+.*: +file format .*
+
+
+ 0: 83 88 00 10 pwr %l0, %psr
+ 4: 83 88 00 00 pwr %g0, %psr
+ 8: 83 88 20 00 pwr %g0, %psr
+ c: 83 88 3f ff pwr -1, %psr
diff --git a/gas/testsuite/gas/sparc/leon.s b/gas/testsuite/gas/sparc/leon.s
new file mode 100644
index 00000000000..7b87c474e3a
--- /dev/null
+++ b/gas/testsuite/gas/sparc/leon.s
@@ -0,0 +1,6 @@
+ .text
+ pwr %l0, %psr
+ pwr %g0, %psr
+ pwr 0, %psr
+ pwr -1, %psr
diff --git a/gas/testsuite/gas/sparc/sparc.exp b/gas/testsuite/gas/sparc/sparc.exp
index dcfec404d16..bb5f7295211 100644
--- a/gas/testsuite/gas/sparc/sparc.exp
+++ b/gas/testsuite/gas/sparc/sparc.exp
@@ -65,6 +65,7 @@ if [istarget sparc*-*-*] {
run_dump_test "ticc-imm-reg"
run_dump_test "v8-movwr-imm"
run_dump_test "save-args"
+ run_dump_test "leon"
set_tests_arch "v9c"
run_dump_test "ldtxa"
diff --git a/opcodes/sparc-opc.c b/opcodes/sparc-opc.c
index 6de9305d145..ab39398b5b8 100644
--- a/opcodes/sparc-opc.c
+++ b/opcodes/sparc-opc.c
@@ -71,6 +71,7 @@
| MASK_V9C | MASK_V9D | MASK_V9E | MASK_V9V | MASK_V9M \
| MASK_M8)
#define sparclet (MASK_SPARCLET)
+#define leon (MASK_LEON)
/* sparclet insns supported by leon. */
#define letandleon (MASK_SPARCLET | MASK_LEON)
#define sparclite (MASK_SPARCLITE)
@@ -1023,6 +1024,13 @@ wrasr (26, HWCAP_CBCOND, 0, v9e), /* wr ...,%cfr */
wrasr (27, HWCAP_PAUSE, 0, v9e), /* wr ...,%pause */
wrasr (28, 0, HWCAP2_MWAIT, v9m), /* wr ...,%mwait */
+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|ASI(~0), "1,2,p", 0, 0, 0, leon }, /* pwr r,r,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1), "1,i,p", 0, 0, 0, leon }, /* pwr r,i,%psr */
+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|RS1_G0|ASI(~0), "2,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr %g0,rs2,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1)|RS1_G0, "i,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr %g0,i,%psr */
+{ "pwr", F3(2, 0x31, 1)|RD(1), F3(~2, ~0x31, ~1)|RD(~1)|SIMM13(~0), "1,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr rs1,0,%psr */
+{ "pwr", F3(2, 0x31, 0)|RD(1), F3(~2, ~0x31, ~0)|RD(~1)|ASI_RS2(~0), "1,p", F_PREF_ALIAS, 0, 0, leon }, /* pwr rs1,%g0,%psr */
+
{ "pause", F3(2, 0x30, 1)|RD(27)|RS1(0), F3(~2, ~0x30, ~1)|RD(~27)|RS1(~0), "i", 0, HWCAP_PAUSE, 0, v9e }, /* wr %g0,i,%pause */
{ "rd", F3(2, 0x28, 0)|RS1(2), F3(~2, ~0x28, ~0)|RS1(~2)|SIMM13(~0), "E,d", 0, 0, 0, v9 }, /* rd %ccr,r */
Jose E. Marchesi
2018-08-29 18:58:46 UTC
Permalink
Thanks Jose!

I do not have commit access, would you mind applying the patch for
me?

I did some regression testing (in a S7 sparc64-linux-gnu box) for the
following targets:

SPARC_TARGETS="sparc-linux sparc-vxworks sparc64-linux
sparc-sun-solaris2.12"

X86_TARGETS="i386-darwin i386-lynxos i586-linux i686-nacl i686-pc-beos
i686-pc-elf i686-pe i686-vxworks x86_64-linux x86_64-w64-mingw32
x86_64-nacl "

All good. I applied the patch.
Thanks!
H.J. Lu
2018-08-30 18:21:32 UTC
Permalink
On Wed, Aug 29, 2018 at 11:58 AM, Jose E. Marchesi
Post by Daniel Cederman
Thanks Jose!
I do not have commit access, would you mind applying the patch for me?
I did some regression testing (in a S7 sparc64-linux-gnu box) for the
SPARC_TARGETS="sparc-linux sparc-vxworks sparc64-linux
sparc-sun-solaris2.12"
X86_TARGETS="i386-darwin i386-lynxos i586-linux i686-nacl i686-pc-beos
i686-pc-elf i686-pe i686-vxworks x86_64-linux x86_64-w64-mingw32
x86_64-nacl "
All good. I applied the patch.
Thanks!
The new test failed on Linux/x86-64:

/export/build/gnu/tools-build/binutils-cross-run/build-sparc64-linux/gas/testsuite/../../binutils/objdump
-dr dump.o
Executing on host: sh -c
{/export/build/gnu/tools-build/binutils-cross-run/build-sparc64-linux/gas/testsuite/../../binutils/objdump
-dr dump.o >dump.out 2>gas.stderr} /dev/null (timeout = 300)
spawn [open ...]^M
regexp_diff match failure
regexp "^ 0: 83 88 00 10 pwr %l0, %psr$"
line " 0: 83 88 00 10 unknown"
regexp_diff match failure
regexp "^ 4: 83 88 00 00 pwr %g0, %psr$"
line " 4: 83 88 00 00 restored "
regexp_diff match failure
regexp "^ 8: 83 88 20 00 pwr %g0, %psr$"
line " 8: 83 88 20 00 unknown"
regexp_diff match failure
regexp "^ c: 83 88 3f ff pwr -1, %psr$"
line " c: 83 88 3f ff unknown"
FAIL: LEON instructions
--
H.J.
Jose E. Marchesi
2018-08-30 21:39:21 UTC
Permalink
spawn [open ...]^M
regexp_diff match failure
regexp "^ 0: 83 88 00 10 pwr %l0, %psr$"
line " 0: 83 88 00 10 unknown"
regexp_diff match failure
regexp "^ 4: 83 88 00 00 pwr %g0, %psr$"
line " 4: 83 88 00 00 restored "
regexp_diff match failure
regexp "^ 8: 83 88 20 00 pwr %g0, %psr$"
line " 8: 83 88 20 00 unknown"
regexp_diff match failure
regexp "^ c: 83 88 3f ff pwr -1, %psr$"
line " c: 83 88 3f ff unknown"
FAIL: LEON instructions

Oops. Thanks for pointing that out.
Should be fixed now.

Salud!

Loading...