Commit 112a72a0 authored by Joel Sing's avatar Joel Sing

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/+/193818Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 3a067f71
...@@ -62,33 +62,19 @@ func Set(GOARCH string) *Arch { ...@@ -62,33 +62,19 @@ func Set(GOARCH string) *Arch {
case "arm64": case "arm64":
return archArm64() return archArm64()
case "mips": case "mips":
a := archMips() return archMips(&mips.Linkmips)
a.LinkArch = &mips.Linkmips
return a
case "mipsle": case "mipsle":
a := archMips() return archMips(&mips.Linkmipsle)
a.LinkArch = &mips.Linkmipsle
return a
case "mips64": case "mips64":
a := archMips64() return archMips64(&mips.Linkmips64)
a.LinkArch = &mips.Linkmips64
return a
case "mips64le": case "mips64le":
a := archMips64() return archMips64(&mips.Linkmips64le)
a.LinkArch = &mips.Linkmips64le
return a
case "ppc64": case "ppc64":
a := archPPC64() return archPPC64(&ppc64.Linkppc64)
a.LinkArch = &ppc64.Linkppc64
return a
case "ppc64le": case "ppc64le":
a := archPPC64() return archPPC64(&ppc64.Linkppc64le)
a.LinkArch = &ppc64.Linkppc64le
return a
case "s390x": case "s390x":
a := archS390x() return archS390x()
a.LinkArch = &s390x.Links390x
return a
case "wasm": case "wasm":
return archWasm() return archWasm()
} }
...@@ -352,7 +338,7 @@ func archArm64() *Arch { ...@@ -352,7 +338,7 @@ func archArm64() *Arch {
} }
func archPPC64() *Arch { func archPPC64(linkArch *obj.LinkArch) *Arch {
register := make(map[string]int16) register := make(map[string]int16)
// Create maps for easy lookup of instruction names etc. // Create maps for easy lookup of instruction names etc.
// Note that there is no list of names as there is for x86. // Note that there is no list of names as there is for x86.
...@@ -408,7 +394,7 @@ func archPPC64() *Arch { ...@@ -408,7 +394,7 @@ func archPPC64() *Arch {
instructions["BL"] = ppc64.ABL instructions["BL"] = ppc64.ABL
return &Arch{ return &Arch{
LinkArch: &ppc64.Linkppc64, LinkArch: linkArch,
Instructions: instructions, Instructions: instructions,
Register: register, Register: register,
RegisterPrefix: registerPrefix, RegisterPrefix: registerPrefix,
...@@ -417,7 +403,7 @@ func archPPC64() *Arch { ...@@ -417,7 +403,7 @@ func archPPC64() *Arch {
} }
} }
func archMips() *Arch { func archMips(linkArch *obj.LinkArch) *Arch {
register := make(map[string]int16) register := make(map[string]int16)
// Create maps for easy lookup of instruction names etc. // Create maps for easy lookup of instruction names etc.
// Note that there is no list of names as there is for x86. // Note that there is no list of names as there is for x86.
...@@ -464,7 +450,7 @@ func archMips() *Arch { ...@@ -464,7 +450,7 @@ func archMips() *Arch {
instructions["JAL"] = mips.AJAL instructions["JAL"] = mips.AJAL
return &Arch{ return &Arch{
LinkArch: &mips.Linkmipsle, LinkArch: linkArch,
Instructions: instructions, Instructions: instructions,
Register: register, Register: register,
RegisterPrefix: registerPrefix, RegisterPrefix: registerPrefix,
...@@ -473,7 +459,7 @@ func archMips() *Arch { ...@@ -473,7 +459,7 @@ func archMips() *Arch {
} }
} }
func archMips64() *Arch { func archMips64(linkArch *obj.LinkArch) *Arch {
register := make(map[string]int16) register := make(map[string]int16)
// Create maps for easy lookup of instruction names etc. // Create maps for easy lookup of instruction names etc.
// Note that there is no list of names as there is for x86. // Note that there is no list of names as there is for x86.
...@@ -521,7 +507,7 @@ func archMips64() *Arch { ...@@ -521,7 +507,7 @@ func archMips64() *Arch {
instructions["JAL"] = mips.AJAL instructions["JAL"] = mips.AJAL
return &Arch{ return &Arch{
LinkArch: &mips.Linkmips64, LinkArch: linkArch,
Instructions: instructions, Instructions: instructions,
Register: register, Register: register,
RegisterPrefix: registerPrefix, RegisterPrefix: registerPrefix,
......
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