cmd/internal/obj: add As type for assembly opcodes

Passes toolstash/buildall.

Fixes #14692.

Change-Id: I4352678d8251309f2b8b7793674c550fac948006
Reviewed-on: https://go-review.googlesource.com/20350
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Matthew Dempsky 2016-03-07 18:00:08 -08:00
parent b1785a5065
commit 0d9258a830
51 changed files with 461 additions and 459 deletions

View file

@ -212,7 +212,7 @@ type Prog struct {
Pc int64
Lineno int32
Spadj int32
As int16
As As // Assembler opcode.
Reg int16
RegTo2 int16 // 2nd register output operand
Mark uint16 // bitmask of arch-specific items
@ -254,16 +254,16 @@ type ProgInfo struct {
Regindex uint64 // registers used by addressing mode
}
// Prog.as opcodes.
// These are the portable opcodes, common to all architectures.
// Each architecture defines many more arch-specific opcodes,
// with values starting at A_ARCHSPECIFIC.
// Each architecture adds an offset to this so each machine has
// distinct space for its instructions. The offset is a power of
// two so it can be masked to return to origin zero.
// See the definitions of ABase386 etc.
// An As denotes an assembler opcode.
// There are some portable opcodes, declared here in package obj,
// that are common to all architectures.
// However, the majority of opcodes are arch-specific
// and are declared in their respective architecture's subpackage.
type As int16
// These are the portable opcodes.
const (
AXXX = 0 + iota
AXXX As = iota
ACALL
ACHECKNIL
ADATA
@ -286,6 +286,24 @@ const (
A_ARCHSPECIFIC
)
// Each architecture is allotted a distinct subspace of opcode values
// for declaring its arch-specific opcodes.
// Within this subspace, the first arch-specific opcode should be
// at offset A_ARCHSPECIFIC.
//
// Subspaces are aligned to a power of two so opcodes can be masked
// with AMask and used as compact array indices.
const (
ABase386 = (1 + iota) << 12
ABaseARM
ABaseAMD64
ABasePPC64
ABaseARM64
ABaseMIPS64
AMask = 1<<12 - 1 // AND with this to use the opcode as an array index.
)
// An LSym is the sort of symbol that is written to an object file.
type LSym struct {
Name string
@ -665,7 +683,7 @@ type LinkArch struct {
Assemble func(*Link, *LSym)
Follow func(*Link, *LSym)
Progedit func(*Link, *Prog)
UnaryDst map[int]bool // Instruction takes one operand, a destination.
UnaryDst map[As]bool // Instruction takes one operand, a destination.
Minlc int
Ptrsize int
Regsize int