Commit 45b43f61 authored by Lynn Boger's avatar Lynn Boger Committed by Brad Fitzpatrick

cmd/objdump: updates from golang.org/x/arch/ppc64/ppc64asm

Update the ppc64x disassembly code for use by objdump
from golang.org/x/arch/ppc64/ppc64asm commit fcea5ea.
Enable the objdump testcase for external linking on ppc64le
make a minor fix to the expected output.

Fixes #17447

Change-Id: I769cc7f8bfade594690a476dfe77ab33677ac03b
Reviewed-on: https://go-review.googlesource.com/32015
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent a850dbde
...@@ -54,7 +54,7 @@ var ppcNeed = []string{ ...@@ -54,7 +54,7 @@ var ppcNeed = []string{
"fmthello.go:6", "fmthello.go:6",
"TEXT main.main(SB)", "TEXT main.main(SB)",
"BR main.main(SB)", "BR main.main(SB)",
"BL fmt.Println(SB)", "CALL fmt.Println(SB)",
"RET", "RET",
} }
...@@ -143,7 +143,7 @@ func TestDisasmExtld(t *testing.T) { ...@@ -143,7 +143,7 @@ func TestDisasmExtld(t *testing.T) {
t.Skipf("skipping on %s", runtime.GOOS) t.Skipf("skipping on %s", runtime.GOOS)
} }
switch runtime.GOARCH { switch runtime.GOARCH {
case "ppc64", "ppc64le": case "ppc64":
t.Skipf("skipping on %s, no support for external linking, issue 9038", runtime.GOARCH) t.Skipf("skipping on %s, no support for external linking, issue 9038", runtime.GOARCH)
case "arm64": case "arm64":
t.Skipf("skipping on %s, issue 10106", runtime.GOARCH) t.Skipf("skipping on %s, issue 10106", runtime.GOARCH)
......
...@@ -52,6 +52,8 @@ func (a argField) Parse(i uint32) Arg { ...@@ -52,6 +52,8 @@ func (a argField) Parse(i uint32) Arg {
return F0 + Reg(a.BitFields.Parse(i)) return F0 + Reg(a.BitFields.Parse(i))
case TypeVecReg: case TypeVecReg:
return V0 + Reg(a.BitFields.Parse(i)) return V0 + Reg(a.BitFields.Parse(i))
case TypeVecSReg:
return VS0 + Reg(a.BitFields.Parse(i))
case TypeSpReg: case TypeSpReg:
return SpReg(a.BitFields.Parse(i)) return SpReg(a.BitFields.Parse(i))
case TypeImmSigned: case TypeImmSigned:
...@@ -78,6 +80,7 @@ const ( ...@@ -78,6 +80,7 @@ const (
TypeCondRegField // conditional register field (0-7) TypeCondRegField // conditional register field (0-7)
TypeFPReg // floating point register TypeFPReg // floating point register
TypeVecReg // vector register TypeVecReg // vector register
TypeVecSReg // VSX register
TypeSpReg // special register (depends on Op) TypeSpReg // special register (depends on Op)
TypeImmSigned // signed immediate TypeImmSigned // signed immediate
TypeImmUnsigned // unsigned immediate/flag/mask, this is the catch-all type TypeImmUnsigned // unsigned immediate/flag/mask, this is the catch-all type
...@@ -101,6 +104,8 @@ func (t ArgType) String() string { ...@@ -101,6 +104,8 @@ func (t ArgType) String() string {
return "FPReg" return "FPReg"
case TypeVecReg: case TypeVecReg:
return "VecReg" return "VecReg"
case TypeVecSReg:
return "VecSReg"
case TypeSpReg: case TypeSpReg:
return "SpReg" return "SpReg"
case TypeImmSigned: case TypeImmSigned:
......
...@@ -176,7 +176,7 @@ func testExtDis( ...@@ -176,7 +176,7 @@ func testExtDis(
t.Logf("%d test cases, %d expected mismatches, %d failures; %.0f cases/second", totalTests, totalSkips, totalErrors, float64(totalTests)/time.Since(start).Seconds()) t.Logf("%d test cases, %d expected mismatches, %d failures; %.0f cases/second", totalTests, totalSkips, totalErrors, float64(totalTests)/time.Since(start).Seconds())
if err := <-errc; err != nil { if err := <-errc; err != nil {
t.Fatal("external disassembler: %v", err) t.Fatalf("external disassembler: %v", err)
} }
} }
......
...@@ -156,38 +156,70 @@ const ( ...@@ -156,38 +156,70 @@ const (
V29 V29
V30 V30
V31 V31
V32 VS0
V33 VS1
V34 VS2
V35 VS3
V36 VS4
V37 VS5
V38 VS6
V39 VS7
V40 VS8
V41 VS9
V42 VS10
V43 VS11
V44 VS12
V45 VS13
V46 VS14
V47 VS15
V48 VS16
V49 VS17
V50 VS18
V51 VS19
V52 VS20
V53 VS21
V54 VS22
V55 VS23
V56 VS24
V57 VS25
V58 VS26
V59 VS27
V60 VS28
V61 VS29
V62 VS30
V63 VS31
VS32
VS33
VS34
VS35
VS36
VS37
VS38
VS39
VS40
VS41
VS42
VS43
VS44
VS45
VS46
VS47
VS48
VS49
VS50
VS51
VS52
VS53
VS54
VS55
VS56
VS57
VS58
VS59
VS60
VS61
VS62
VS63
) )
func (Reg) IsArg() {} func (Reg) IsArg() {}
...@@ -197,10 +229,12 @@ func (r Reg) String() string { ...@@ -197,10 +229,12 @@ func (r Reg) String() string {
return fmt.Sprintf("r%d", int(r-R0)) return fmt.Sprintf("r%d", int(r-R0))
case F0 <= r && r <= F31: case F0 <= r && r <= F31:
return fmt.Sprintf("f%d", int(r-F0)) return fmt.Sprintf("f%d", int(r-F0))
case V0 <= r && r <= V63: case V0 <= r && r <= V31:
return fmt.Sprintf("v%d", int(r-V0)) return fmt.Sprintf("v%d", int(r-V0))
case VS0 <= r && r <= VS63:
return fmt.Sprintf("vs%d", int(r-VS0))
default: default:
return fmt.Sprint("Reg(%d)", int(r)) return fmt.Sprintf("Reg(%d)", int(r))
} }
} }
......
...@@ -12,7 +12,10 @@ import ( ...@@ -12,7 +12,10 @@ import (
func TestObjdumpPowerTestdata(t *testing.T) { testObjdump(t, testdataCases(t)) } func TestObjdumpPowerTestdata(t *testing.T) { testObjdump(t, testdataCases(t)) }
func TestObjdumpPowerManual(t *testing.T) { testObjdump(t, hexCases(t, objdumpManualTests)) } func TestObjdumpPowerManual(t *testing.T) { testObjdump(t, hexCases(t, objdumpManualTests)) }
func TestObjdumpPowerRandom(t *testing.T) { testObjdump(t, randomCases(t)) }
// Disable this for now since generating all possible bit combinations within a word
// generates lots of ppc64x instructions not possible with golang so not worth supporting..
//func TestObjdumpPowerRandom(t *testing.T) { testObjdump(t, randomCases(t)) }
// objdumpManualTests holds test cases that will be run by TestObjdumpARMManual. // objdumpManualTests holds test cases that will be run by TestObjdumpARMManual.
// If you are debugging a few cases that turned up in a longer run, it can be useful // If you are debugging a few cases that turned up in a longer run, it can be useful
......
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
"testing" "testing"
) )
const objdumpPath = "/usr/local/bin/powerpc64-unknown-linux-gnu-objdump" const objdumpPath = "/usr/bin/objdump"
func testObjdump(t *testing.T, generate func(func([]byte))) { func testObjdump(t *testing.T, generate func(func([]byte))) {
if testing.Short() { if testing.Short() {
......
...@@ -148,16 +148,25 @@ var revCondMap = map[string]string{ ...@@ -148,16 +148,25 @@ var revCondMap = map[string]string{
// plan9OpMap maps an Op to its Plan 9 mnemonics, if different than its GNU mnemonics. // plan9OpMap maps an Op to its Plan 9 mnemonics, if different than its GNU mnemonics.
var plan9OpMap = map[Op]string{ var plan9OpMap = map[Op]string{
LWARX: "LWAR", STWCX_: "STWCCC",
LDARX: "LDAR", STDCX_: "STDCCC",
LHARX: "LHAR", STHCX_: "STHCCC",
LBARX: "LBAR", STBCX_: "STBCCC",
ADDI: "ADD",
ADD_: "ADDCC",
LBZ: "MOVBZ", STB: "MOVB", LBZ: "MOVBZ", STB: "MOVB",
LBZU: "MOVBZU", STBU: "MOVBU", // TODO(minux): indexed forms are not handled LBZU: "MOVBZU", STBU: "MOVBU", // TODO(minux): indexed forms are not handled
LHZ: "MOVHZ", LHA: "MOVH", STH: "MOVH", LHZ: "MOVHZ", LHA: "MOVH", STH: "MOVH",
LHZU: "MOVHZU", STHU: "MOVHU", LHZU: "MOVHZU", STHU: "MOVHU",
LI: "MOVD",
LIS: "ADDIS",
LWZ: "MOVWZ", LWA: "MOVW", STW: "MOVW", LWZ: "MOVWZ", LWA: "MOVW", STW: "MOVW",
LWZU: "MOVWZU", STWU: "MOVWU", LWZU: "MOVWZU", STWU: "MOVWU",
LD: "MOVD", STD: "MOVD", LD: "MOVD", STD: "MOVD",
LDU: "MOVDU", STDU: "MOVDU", LDU: "MOVDU", STDU: "MOVDU",
MTSPR: "MOV", MFSPR: "MOV", // the width is ambiguous for SPRs MTSPR: "MOVD", MFSPR: "MOVD", // the width is ambiguous for SPRs
B: "BR", B: "BR",
BL: "CALL",
CMPLD: "CMPU", CMPLW: "CMPWU", CMPLD: "CMPU", CMPLW: "CMPWU",
CMPD: "CMP", CMPW: "CMPW", CMPD: "CMP", CMPW: "CMPW",
} }
...@@ -13,7 +13,7 @@ c61bb730| gnu lfsu f16,-18640(r27) ...@@ -13,7 +13,7 @@ c61bb730| gnu lfsu f16,-18640(r27)
a9a912c1| gnu lha r13,4801(r9) a9a912c1| gnu lha r13,4801(r9)
ebb24fd1| gnu ldu r29,20432(r18) ebb24fd1| gnu ldu r29,20432(r18)
b1ce0612| gnu sth r14,1554(r14) b1ce0612| gnu sth r14,1554(r14)
f3d74322| gnu xvcvdpuxws v30,v40 f3c04322| gnu xvcvdpuxws vs30,vs40
945c62a2| gnu stwu r2,25250(r28) 945c62a2| gnu stwu r2,25250(r28)
9c8156e3| gnu stbu r4,22243(r1) 9c8156e3| gnu stbu r4,22243(r1)
f91b9c7a| gnu stq r8,-25480(r27) f91b9c7a| gnu stq r8,-25480(r27)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment