Skip to content

Commit 6544aa4

Browse files
pmurlaboger
authored andcommitted
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 <[email protected]> Reviewed-by: Carlos Eduardo Seo <[email protected]>
1 parent 5e4c51d commit 6544aa4

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ppc64/ppc64asm/gnu.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,17 @@ func GNUSyntax(inst Inst, pc uint64) string {
297297
gnuArg(&inst, 0, inst.Args[0], PC),
298298
gnuArg(&inst, 2, inst.Args[2], PC))
299299
startArg = 4
300-
} else if r == 0 {
300+
} else {
301301
str = fmt.Sprintf("%s %s,%s,%s", opName,
302302
gnuArg(&inst, 0, inst.Args[0], PC),
303303
gnuArg(&inst, 1, inst.Args[1], PC),
304304
gnuArg(&inst, 2, inst.Args[2], PC))
305305
startArg = 4
306+
if r == 1 {
307+
// This is an illegal encoding (ra != 0 && r == 1) on ISA 3.1.
308+
v := uint64(inst.Enc)<<32 | uint64(inst.SuffixEnc)
309+
return fmt.Sprintf(".quad 0x%x", v)
310+
}
306311
}
307312
buf.WriteString(str)
308313

@@ -317,11 +322,16 @@ func GNUSyntax(inst Inst, pc uint64) string {
317322
str := fmt.Sprintf("%s %s,%d", opName, gnuArg(&inst, 0, inst.Args[0], PC), d)
318323
buf.WriteString(str)
319324
startArg = 4
320-
} else if r == 0 {
325+
} else {
321326
str := fmt.Sprintf("%s %s,%d(%s)", opName,
322327
gnuArg(&inst, 0, inst.Args[0], PC),
323328
d,
324329
gnuArg(&inst, 2, inst.Args[2], PC))
330+
if r == 1 {
331+
// This is an invalid encoding (ra != 0 && r == 1) on ISA 3.1.
332+
v := uint64(inst.Enc)<<32 | uint64(inst.SuffixEnc)
333+
return fmt.Sprintf(".quad 0x%x", v)
334+
}
325335
buf.WriteString(str)
326336
startArg = 4
327337
}

ppc64/ppc64asm/testdata/decode.txt

+2
Original file line numberDiff line numberDiff line change
@@ -861,3 +861,5 @@ fc811000| plan9 FCMPU F1,F2,CR1
861861
7c2201b6| plan9 BRH R1,R2
862862
7c220136| plan9 BRW R1,R2
863863
7c2311b8| plan9 CFUGED R1,R2,R3
864+
04100016e4820032| gnu .quad 0x4100016e4820032
865+
0612000138820007| gnu .quad 0x612000138820007

0 commit comments

Comments
 (0)