Skip to content

Commit

Permalink
ppc64asm: don't print invalid encodings of pst*/pl*/paddi insn
Browse files Browse the repository at this point in the history
Change-Id: I5a01b89c96eba94f0eac3d4db65f98d0c2fc1166
Reviewed-on: https://go-review.googlesource.com/c/arch/+/347570
Reviewed-by: Cherry Mui <[email protected]>
Reviewed-by: Carlos Eduardo Seo <[email protected]>
  • Loading branch information
Wonderex95 authored and laboger committed Sep 17, 2021
1 parent abfbd4e commit 12cdd4c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ppc64/ppc64asm/gnu.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,17 @@ func GNUSyntax(inst Inst, pc uint64) string {
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)

Expand All @@ -317,11 +322,16 @@ func GNUSyntax(inst Inst, pc uint64) string {
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
}
Expand Down
2 changes: 2 additions & 0 deletions ppc64/ppc64asm/testdata/decode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -861,3 +861,5 @@ fc811000| plan9 FCMPU F1,F2,CR1
7c2201b6| plan9 BRH R1,R2
7c220136| plan9 BRW R1,R2
7c2311b8| plan9 CFUGED R1,R2,R3
04100016e4820032| gnu .quad 0x4100016e4820032
0612000138820007| gnu .quad 0x612000138820007

0 comments on commit 12cdd4c

Please sign in to comment.