aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/asm/internal/arch
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2015-03-02 20:17:20 -0800
committerRob Pike <r@golang.org>2015-03-03 17:06:27 +0000
commit74e88dfdeebef392d52d3f792e2071b058c1e231 (patch)
treee066ac4bde456ffd50b2ecaf402020056f97653c /src/cmd/asm/internal/arch
parent91e7ca588d07b8e04e9608c4436d2d701f6c59d0 (diff)
downloadgo-74e88dfdeebef392d52d3f792e2071b058c1e231.tar.xz
cmd/internal/obj: switch to one global Aconv
Aconv is the pretty-printer for instruction opcodes like AMOVQ. There was one for each architecture. Make the space of A names have a different region for each architecture, much as we did for the registers, so a single global Aconv function can do the work. Each architecture registers its region as a slice of names at a given offset. The global names like CALL and JMP are now defined only once. The A values are used for indexing tables, so make it easy to do the indexing by making the offset maskable. Remove a bunch of now-duplicated architecture-specific code. Change-Id: Ib15647b7145a1c089e21e36543691a19e146b60e Reviewed-on: https://go-review.googlesource.com/6620 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/asm/internal/arch')
-rw-r--r--src/cmd/asm/internal/arch/arch.go34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/cmd/asm/internal/arch/arch.go b/src/cmd/asm/internal/arch/arch.go
index 1ec8e0c12b..79e2f722ac 100644
--- a/src/cmd/asm/internal/arch/arch.go
+++ b/src/cmd/asm/internal/arch/arch.go
@@ -34,8 +34,6 @@ type Arch struct {
RegisterNumber func(string, int16) (int16, bool)
// Instruction is a jump.
IsJump func(word string) bool
- // Aconv pretty-prints an instruction opcode for this architecture.
- Aconv func(int) string
}
// nilRegisterNumber is the register number function for architectures
@@ -96,9 +94,14 @@ func arch386() *Arch {
// Prefixes not used on this architecture.
instructions := make(map[string]int)
- for i, s := range i386.Anames {
+ for i, s := range obj.Anames {
instructions[s] = i
}
+ for i, s := range i386.Anames {
+ if i >= obj.A_ARCHSPECIFIC {
+ instructions[s] = i + obj.ABase386
+ }
+ }
// Annoying aliases.
instructions["JA"] = i386.AJHI
instructions["JAE"] = i386.AJCC
@@ -140,7 +143,6 @@ func arch386() *Arch {
RegisterPrefix: nil,
RegisterNumber: nilRegisterNumber,
IsJump: jump386,
- Aconv: i386.Aconv,
}
}
@@ -158,9 +160,14 @@ func archAmd64() *Arch {
// Register prefix not used on this architecture.
instructions := make(map[string]int)
- for i, s := range x86.Anames {
+ for i, s := range obj.Anames {
instructions[s] = i
}
+ for i, s := range x86.Anames {
+ if i >= obj.A_ARCHSPECIFIC {
+ instructions[s] = i + obj.ABaseAMD64
+ }
+ }
// Annoying aliases.
instructions["JA"] = x86.AJHI
instructions["JAE"] = x86.AJCC
@@ -209,7 +216,6 @@ func archAmd64() *Arch {
RegisterPrefix: nil,
RegisterNumber: nilRegisterNumber,
IsJump: jump386,
- Aconv: x86.Aconv,
}
}
@@ -240,9 +246,14 @@ func archArm() *Arch {
}
instructions := make(map[string]int)
- for i, s := range arm.Anames {
+ for i, s := range obj.Anames {
instructions[s] = i
}
+ for i, s := range arm.Anames {
+ if i >= obj.A_ARCHSPECIFIC {
+ instructions[s] = i + obj.ABaseARM
+ }
+ }
// Annoying aliases.
instructions["B"] = obj.AJMP
instructions["BL"] = obj.ACALL
@@ -254,7 +265,6 @@ func archArm() *Arch {
RegisterPrefix: registerPrefix,
RegisterNumber: armRegisterNumber,
IsJump: jumpArm,
- Aconv: arm.Aconv,
}
}
@@ -296,9 +306,14 @@ func archPPC64() *Arch {
}
instructions := make(map[string]int)
- for i, s := range ppc64.Anames {
+ for i, s := range obj.Anames {
instructions[s] = i
}
+ for i, s := range ppc64.Anames {
+ if i >= obj.A_ARCHSPECIFIC {
+ instructions[s] = i + obj.ABasePPC64
+ }
+ }
// Annoying aliases.
instructions["BR"] = ppc64.ABR
instructions["BL"] = ppc64.ABL
@@ -311,6 +326,5 @@ func archPPC64() *Arch {
RegisterPrefix: registerPrefix,
RegisterNumber: ppc64RegisterNumber,
IsJump: jumpPPC64,
- Aconv: ppc64.Aconv,
}
}