diff options
| author | Joel Sing <joel@sing.id.au> | 2019-09-07 04:40:38 +1000 |
|---|---|---|
| committer | Joel Sing <joel@sing.id.au> | 2019-09-07 09:43:04 +0000 |
| commit | 112a72a020f8976876ea7644f9220dbfb0f85464 (patch) | |
| tree | 4e1f3955505fb5f75002781ca72ebf86e7f7997f /src/cmd/asm | |
| parent | 3a067f71e9737fc8ae1e49348155d92d52e66718 (diff) | |
| download | go-112a72a020f8976876ea7644f9220dbfb0f85464.tar.xz | |
cmd/asm/internal/arch: consolidate LinkArch handling
Rather than manually setting the LinkArch for each case, pass the correct
*obj.LinkArch to the arch* function, as is already done for archX86().
Change-Id: I4cf950780aa30a1385e785fb1d26edacb99bda79
Reviewed-on: https://go-review.googlesource.com/c/go/+/193818
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/asm')
| -rw-r--r-- | src/cmd/asm/internal/arch/arch.go | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/src/cmd/asm/internal/arch/arch.go b/src/cmd/asm/internal/arch/arch.go index 221d80596a..638ab736cc 100644 --- a/src/cmd/asm/internal/arch/arch.go +++ b/src/cmd/asm/internal/arch/arch.go @@ -62,33 +62,19 @@ func Set(GOARCH string) *Arch { case "arm64": return archArm64() case "mips": - a := archMips() - a.LinkArch = &mips.Linkmips - return a + return archMips(&mips.Linkmips) case "mipsle": - a := archMips() - a.LinkArch = &mips.Linkmipsle - return a + return archMips(&mips.Linkmipsle) case "mips64": - a := archMips64() - a.LinkArch = &mips.Linkmips64 - return a + return archMips64(&mips.Linkmips64) case "mips64le": - a := archMips64() - a.LinkArch = &mips.Linkmips64le - return a + return archMips64(&mips.Linkmips64le) case "ppc64": - a := archPPC64() - a.LinkArch = &ppc64.Linkppc64 - return a + return archPPC64(&ppc64.Linkppc64) case "ppc64le": - a := archPPC64() - a.LinkArch = &ppc64.Linkppc64le - return a + return archPPC64(&ppc64.Linkppc64le) case "s390x": - a := archS390x() - a.LinkArch = &s390x.Links390x - return a + return archS390x() case "wasm": return archWasm() } @@ -352,7 +338,7 @@ func archArm64() *Arch { } -func archPPC64() *Arch { +func archPPC64(linkArch *obj.LinkArch) *Arch { register := make(map[string]int16) // Create maps for easy lookup of instruction names etc. // Note that there is no list of names as there is for x86. @@ -408,7 +394,7 @@ func archPPC64() *Arch { instructions["BL"] = ppc64.ABL return &Arch{ - LinkArch: &ppc64.Linkppc64, + LinkArch: linkArch, Instructions: instructions, Register: register, RegisterPrefix: registerPrefix, @@ -417,7 +403,7 @@ func archPPC64() *Arch { } } -func archMips() *Arch { +func archMips(linkArch *obj.LinkArch) *Arch { register := make(map[string]int16) // Create maps for easy lookup of instruction names etc. // Note that there is no list of names as there is for x86. @@ -464,7 +450,7 @@ func archMips() *Arch { instructions["JAL"] = mips.AJAL return &Arch{ - LinkArch: &mips.Linkmipsle, + LinkArch: linkArch, Instructions: instructions, Register: register, RegisterPrefix: registerPrefix, @@ -473,7 +459,7 @@ func archMips() *Arch { } } -func archMips64() *Arch { +func archMips64(linkArch *obj.LinkArch) *Arch { register := make(map[string]int16) // Create maps for easy lookup of instruction names etc. // Note that there is no list of names as there is for x86. @@ -521,7 +507,7 @@ func archMips64() *Arch { instructions["JAL"] = mips.AJAL return &Arch{ - LinkArch: &mips.Linkmips64, + LinkArch: linkArch, Instructions: instructions, Register: register, RegisterPrefix: registerPrefix, |
