ppc64asm: don't print invalid encodings of pst*/pl*/paddi insn
Change-Id: I5a01b89c96eba94f0eac3d4db65f98d0c2fc1166
Reviewed-on: https://go-review.googlesource.com/c/arch/+/347570
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
diff --git a/ppc64/ppc64asm/gnu.go b/ppc64/ppc64asm/gnu.go
index 225ef4f..b4c9bf8 100644
--- a/ppc64/ppc64asm/gnu.go
+++ b/ppc64/ppc64asm/gnu.go
@@ -297,12 +297,17 @@
gnuArg(&inst, 0, inst.Args[0], PC),
gnuArg(&inst, 2, inst.Args[2], PC))
startArg = 4
- } else if r == 0 {
+ } else {
str = fmt.Sprintf("%s %s,%s,%s", opName,
gnuArg(&inst, 0, inst.Args[0], PC),
gnuArg(&inst, 1, inst.Args[1], PC),
gnuArg(&inst, 2, inst.Args[2], PC))
startArg = 4
+ if r == 1 {
+ // This is an illegal encoding (ra != 0 && r == 1) on ISA 3.1.
+ v := uint64(inst.Enc)<<32 | uint64(inst.SuffixEnc)
+ return fmt.Sprintf(".quad 0x%x", v)
+ }
}
buf.WriteString(str)
@@ -317,11 +322,16 @@
str := fmt.Sprintf("%s %s,%d", opName, gnuArg(&inst, 0, inst.Args[0], PC), d)
buf.WriteString(str)
startArg = 4
- } else if r == 0 {
+ } else {
str := fmt.Sprintf("%s %s,%d(%s)", opName,
gnuArg(&inst, 0, inst.Args[0], PC),
d,
gnuArg(&inst, 2, inst.Args[2], PC))
+ if r == 1 {
+ // This is an invalid encoding (ra != 0 && r == 1) on ISA 3.1.
+ v := uint64(inst.Enc)<<32 | uint64(inst.SuffixEnc)
+ return fmt.Sprintf(".quad 0x%x", v)
+ }
buf.WriteString(str)
startArg = 4
}
diff --git a/ppc64/ppc64asm/testdata/decode.txt b/ppc64/ppc64asm/testdata/decode.txt
index a1f8fb3..3213903 100644
--- a/ppc64/ppc64asm/testdata/decode.txt
+++ b/ppc64/ppc64asm/testdata/decode.txt
@@ -861,3 +861,5 @@
7c2201b6| plan9 BRH R1,R2
7c220136| plan9 BRW R1,R2
7c2311b8| plan9 CFUGED R1,R2,R3
+04100016e4820032| gnu .quad 0x4100016e4820032
+0612000138820007| gnu .quad 0x612000138820007