Commit 74e88dfd authored by Rob Pike's avatar Rob Pike

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/6620Reviewed-by: default avatarRuss Cox <rsc@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 91e7ca58
...@@ -544,7 +544,7 @@ gotit: ...@@ -544,7 +544,7 @@ gotit:
} }
if gc.Debug['P'] != 0 { if gc.Debug['P'] != 0 {
fmt.Printf(" => %v\n", arm.Aconv(int(p.As))) fmt.Printf(" => %v\n", obj.Aconv(int(p.As)))
} }
return true return true
} }
...@@ -1043,7 +1043,7 @@ func xtramodes(g *gc.Graph, r *gc.Flow, a *obj.Addr) bool { ...@@ -1043,7 +1043,7 @@ func xtramodes(g *gc.Graph, r *gc.Flow, a *obj.Addr) bool {
func copyu(p *obj.Prog, v *obj.Addr, s *obj.Addr) int { func copyu(p *obj.Prog, v *obj.Addr, s *obj.Addr) int {
switch p.As { switch p.As {
default: default:
fmt.Printf("copyu: can't find %v\n", arm.Aconv(int(p.As))) fmt.Printf("copyu: can't find %v\n", obj.Aconv(int(p.As)))
return 2 return 2
case arm.AMOVM: case arm.AMOVM:
......
...@@ -615,7 +615,7 @@ func copyu(p *obj.Prog, v *obj.Addr, s *obj.Addr) int { ...@@ -615,7 +615,7 @@ func copyu(p *obj.Prog, v *obj.Addr, s *obj.Addr) int {
switch p.As { switch p.As {
default: default:
fmt.Printf("copyu: can't find %v\n", ppc64.Aconv(int(p.As))) fmt.Printf("copyu: can't find %v\n", obj.Aconv(int(p.As)))
return 2 return 2
case obj.ANOP, /* read p->from, write p->to */ case obj.ANOP, /* read p->from, write p->to */
......
...@@ -302,7 +302,7 @@ func as2variant(as int) int { ...@@ -302,7 +302,7 @@ func as2variant(as int) int {
return i return i
} }
} }
gc.Fatal("as2variant: instruction %v is not a variant of itself", ppc64.Aconv(as)) gc.Fatal("as2variant: instruction %v is not a variant of itself", obj.Aconv(as))
return 0 return 0
} }
......
...@@ -34,8 +34,6 @@ type Arch struct { ...@@ -34,8 +34,6 @@ type Arch struct {
RegisterNumber func(string, int16) (int16, bool) RegisterNumber func(string, int16) (int16, bool)
// Instruction is a jump. // Instruction is a jump.
IsJump func(word string) bool 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 // nilRegisterNumber is the register number function for architectures
...@@ -96,9 +94,14 @@ func arch386() *Arch { ...@@ -96,9 +94,14 @@ func arch386() *Arch {
// Prefixes not used on this architecture. // Prefixes not used on this architecture.
instructions := make(map[string]int) instructions := make(map[string]int)
for i, s := range i386.Anames { for i, s := range obj.Anames {
instructions[s] = i instructions[s] = i
} }
for i, s := range i386.Anames {
if i >= obj.A_ARCHSPECIFIC {
instructions[s] = i + obj.ABase386
}
}
// Annoying aliases. // Annoying aliases.
instructions["JA"] = i386.AJHI instructions["JA"] = i386.AJHI
instructions["JAE"] = i386.AJCC instructions["JAE"] = i386.AJCC
...@@ -140,7 +143,6 @@ func arch386() *Arch { ...@@ -140,7 +143,6 @@ func arch386() *Arch {
RegisterPrefix: nil, RegisterPrefix: nil,
RegisterNumber: nilRegisterNumber, RegisterNumber: nilRegisterNumber,
IsJump: jump386, IsJump: jump386,
Aconv: i386.Aconv,
} }
} }
...@@ -158,9 +160,14 @@ func archAmd64() *Arch { ...@@ -158,9 +160,14 @@ func archAmd64() *Arch {
// Register prefix not used on this architecture. // Register prefix not used on this architecture.
instructions := make(map[string]int) instructions := make(map[string]int)
for i, s := range x86.Anames { for i, s := range obj.Anames {
instructions[s] = i instructions[s] = i
} }
for i, s := range x86.Anames {
if i >= obj.A_ARCHSPECIFIC {
instructions[s] = i + obj.ABaseAMD64
}
}
// Annoying aliases. // Annoying aliases.
instructions["JA"] = x86.AJHI instructions["JA"] = x86.AJHI
instructions["JAE"] = x86.AJCC instructions["JAE"] = x86.AJCC
...@@ -209,7 +216,6 @@ func archAmd64() *Arch { ...@@ -209,7 +216,6 @@ func archAmd64() *Arch {
RegisterPrefix: nil, RegisterPrefix: nil,
RegisterNumber: nilRegisterNumber, RegisterNumber: nilRegisterNumber,
IsJump: jump386, IsJump: jump386,
Aconv: x86.Aconv,
} }
} }
...@@ -240,9 +246,14 @@ func archArm() *Arch { ...@@ -240,9 +246,14 @@ func archArm() *Arch {
} }
instructions := make(map[string]int) instructions := make(map[string]int)
for i, s := range arm.Anames { for i, s := range obj.Anames {
instructions[s] = i instructions[s] = i
} }
for i, s := range arm.Anames {
if i >= obj.A_ARCHSPECIFIC {
instructions[s] = i + obj.ABaseARM
}
}
// Annoying aliases. // Annoying aliases.
instructions["B"] = obj.AJMP instructions["B"] = obj.AJMP
instructions["BL"] = obj.ACALL instructions["BL"] = obj.ACALL
...@@ -254,7 +265,6 @@ func archArm() *Arch { ...@@ -254,7 +265,6 @@ func archArm() *Arch {
RegisterPrefix: registerPrefix, RegisterPrefix: registerPrefix,
RegisterNumber: armRegisterNumber, RegisterNumber: armRegisterNumber,
IsJump: jumpArm, IsJump: jumpArm,
Aconv: arm.Aconv,
} }
} }
...@@ -296,9 +306,14 @@ func archPPC64() *Arch { ...@@ -296,9 +306,14 @@ func archPPC64() *Arch {
} }
instructions := make(map[string]int) instructions := make(map[string]int)
for i, s := range ppc64.Anames { for i, s := range obj.Anames {
instructions[s] = i instructions[s] = i
} }
for i, s := range ppc64.Anames {
if i >= obj.A_ARCHSPECIFIC {
instructions[s] = i + obj.ABasePPC64
}
}
// Annoying aliases. // Annoying aliases.
instructions["BR"] = ppc64.ABR instructions["BR"] = ppc64.ABR
instructions["BL"] = ppc64.ABL instructions["BL"] = ppc64.ABL
...@@ -311,6 +326,5 @@ func archPPC64() *Arch { ...@@ -311,6 +326,5 @@ func archPPC64() *Arch {
RegisterPrefix: registerPrefix, RegisterPrefix: registerPrefix,
RegisterNumber: ppc64RegisterNumber, RegisterNumber: ppc64RegisterNumber,
IsJump: jumpPPC64, IsJump: jumpPPC64,
Aconv: ppc64.Aconv,
} }
} }
...@@ -314,7 +314,7 @@ func (p *Parser) asmJump(op int, cond string, a []obj.Addr) { ...@@ -314,7 +314,7 @@ func (p *Parser) asmJump(op int, cond string, a []obj.Addr) {
prog.From = a[0] prog.From = a[0]
break break
} }
p.errorf("wrong number of arguments to %s instruction", p.arch.Aconv(op)) p.errorf("wrong number of arguments to %s instruction", obj.Aconv(op))
return return
case 3: case 3:
if p.arch.Thechar == '9' { if p.arch.Thechar == '9' {
...@@ -330,7 +330,7 @@ func (p *Parser) asmJump(op int, cond string, a []obj.Addr) { ...@@ -330,7 +330,7 @@ func (p *Parser) asmJump(op int, cond string, a []obj.Addr) {
} }
fallthrough fallthrough
default: default:
p.errorf("wrong number of arguments to %s instruction", p.arch.Aconv(op)) p.errorf("wrong number of arguments to %s instruction", obj.Aconv(op))
return return
} }
switch { switch {
...@@ -402,7 +402,7 @@ func (p *Parser) branch(jmp, target *obj.Prog) { ...@@ -402,7 +402,7 @@ func (p *Parser) branch(jmp, target *obj.Prog) {
// asmInstruction assembles an instruction. // asmInstruction assembles an instruction.
// MOVW R9, (R10) // MOVW R9, (R10)
func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) { func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
// fmt.Printf("%s %+v\n", p.arch.Aconv(op), a) // fmt.Printf("%s %+v\n", obj.Aconv(op), a)
prog := &obj.Prog{ prog := &obj.Prog{
Ctxt: p.ctxt, Ctxt: p.ctxt,
Lineno: p.histLineNum, Lineno: p.histLineNum,
...@@ -451,7 +451,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) { ...@@ -451,7 +451,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
prog.To = a[1] prog.To = a[1]
break break
} }
p.errorf("unrecognized addressing for %s", p.arch.Aconv(op)) p.errorf("unrecognized addressing for %s", obj.Aconv(op))
} }
} }
prog.From = a[0] prog.From = a[0]
...@@ -538,7 +538,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) { ...@@ -538,7 +538,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
prog.From3 = a[1] prog.From3 = a[1]
prog.To = a[2] prog.To = a[2]
default: default:
p.errorf("invalid addressing modes for %s instruction", p.arch.Aconv(op)) p.errorf("invalid addressing modes for %s instruction", obj.Aconv(op))
} }
default: default:
p.errorf("TODO: implement three-operand instructions for this architecture") p.errorf("TODO: implement three-operand instructions for this architecture")
...@@ -567,7 +567,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) { ...@@ -567,7 +567,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
prog.To = a[3] prog.To = a[3]
break break
} }
p.errorf("can't handle %s instruction with 4 operands", p.arch.Aconv(op)) p.errorf("can't handle %s instruction with 4 operands", obj.Aconv(op))
case 5: case 5:
if p.arch.Thechar == '9' && arch.IsPPC64RLD(op) { if p.arch.Thechar == '9' && arch.IsPPC64RLD(op) {
// Always reg, reg, con, con, reg. (con, con is a 'mask'). // Always reg, reg, con, con, reg. (con, con is a 'mask').
...@@ -588,7 +588,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) { ...@@ -588,7 +588,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
prog.To = a[4] prog.To = a[4]
break break
} }
p.errorf("can't handle %s instruction with 5 operands", p.arch.Aconv(op)) p.errorf("can't handle %s instruction with 5 operands", obj.Aconv(op))
case 6: case 6:
// MCR and MRC on ARM // MCR and MRC on ARM
if p.arch.Thechar == '5' && arch.IsARMMRC(op) { if p.arch.Thechar == '5' && arch.IsARMMRC(op) {
...@@ -631,7 +631,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) { ...@@ -631,7 +631,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
} }
fallthrough fallthrough
default: default:
p.errorf("can't handle %s instruction with %d operands", p.arch.Aconv(op), len(a)) p.errorf("can't handle %s instruction with %d operands", obj.Aconv(op), len(a))
} }
p.append(prog, cond, true) p.append(prog, cond, true)
...@@ -650,7 +650,7 @@ func (p *Parser) getConstantPseudo(pseudo string, addr *obj.Addr) int64 { ...@@ -650,7 +650,7 @@ func (p *Parser) getConstantPseudo(pseudo string, addr *obj.Addr) int64 {
// getConstant checks that addr represents a plain constant and returns its value. // getConstant checks that addr represents a plain constant and returns its value.
func (p *Parser) getConstant(prog *obj.Prog, op int, addr *obj.Addr) int64 { func (p *Parser) getConstant(prog *obj.Prog, op int, addr *obj.Addr) int64 {
if addr.Type != obj.TYPE_MEM || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 { if addr.Type != obj.TYPE_MEM || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 {
p.errorf("%s: expected integer constant; found %s", p.arch.Aconv(op), obj.Dconv(prog, addr)) p.errorf("%s: expected integer constant; found %s", obj.Aconv(op), obj.Dconv(prog, addr))
} }
return addr.Offset return addr.Offset
} }
...@@ -658,7 +658,7 @@ func (p *Parser) getConstant(prog *obj.Prog, op int, addr *obj.Addr) int64 { ...@@ -658,7 +658,7 @@ func (p *Parser) getConstant(prog *obj.Prog, op int, addr *obj.Addr) int64 {
// getImmediate checks that addr represents an immediate constant and returns its value. // getImmediate checks that addr represents an immediate constant and returns its value.
func (p *Parser) getImmediate(prog *obj.Prog, op int, addr *obj.Addr) int64 { func (p *Parser) getImmediate(prog *obj.Prog, op int, addr *obj.Addr) int64 {
if addr.Type != obj.TYPE_CONST || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 { if addr.Type != obj.TYPE_CONST || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 {
p.errorf("%s: expected immediate constant; found %s", p.arch.Aconv(op), obj.Dconv(prog, addr)) p.errorf("%s: expected immediate constant; found %s", obj.Aconv(op), obj.Dconv(prog, addr))
} }
return addr.Offset return addr.Offset
} }
...@@ -666,7 +666,7 @@ func (p *Parser) getImmediate(prog *obj.Prog, op int, addr *obj.Addr) int64 { ...@@ -666,7 +666,7 @@ func (p *Parser) getImmediate(prog *obj.Prog, op int, addr *obj.Addr) int64 {
// getRegister checks that addr represents a register and returns its value. // getRegister checks that addr represents a register and returns its value.
func (p *Parser) getRegister(prog *obj.Prog, op int, addr *obj.Addr) int16 { func (p *Parser) getRegister(prog *obj.Prog, op int, addr *obj.Addr) int16 {
if addr.Type != obj.TYPE_REG || addr.Offset != 0 || addr.Name != 0 || addr.Index != 0 { if addr.Type != obj.TYPE_REG || addr.Offset != 0 || addr.Name != 0 || addr.Index != 0 {
p.errorf("%s: expected register; found %s", p.arch.Aconv(op), obj.Dconv(prog, addr)) p.errorf("%s: expected register; found %s", obj.Aconv(op), obj.Dconv(prog, addr))
} }
return addr.Reg return addr.Reg
} }
...@@ -145,7 +145,7 @@ const ( ...@@ -145,7 +145,7 @@ const (
) )
const ( const (
AAND = obj.A_ARCHSPECIFIC + iota AAND = obj.ABaseARM + obj.A_ARCHSPECIFIC + iota
AEOR AEOR
ASUB ASUB
ARSB ARSB
......
package arm package arm
import "cmd/internal/obj"
var Anames = []string{ var Anames = []string{
"XXX", obj.A_ARCHSPECIFIC: "AND",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"AND",
"EOR", "EOR",
"SUB", "SUB",
"RSB", "RSB",
......
...@@ -39,7 +39,7 @@ import ( ...@@ -39,7 +39,7 @@ import (
) )
type Optab struct { type Optab struct {
as uint8 as uint16
a1 uint8 a1 uint8
a2 int8 a2 int8
a3 uint8 a3 uint8
...@@ -268,7 +268,7 @@ var pool struct { ...@@ -268,7 +268,7 @@ var pool struct {
extra uint32 extra uint32
} }
var oprange [ALAST]Oprang var oprange [ALAST & obj.AMask]Oprang
var xcmp [C_GOK + 1][C_GOK + 1]uint8 var xcmp [C_GOK + 1][C_GOK + 1]uint8
...@@ -580,7 +580,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) { ...@@ -580,7 +580,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) {
return return
} }
if oprange[AAND].start == nil { if oprange[AAND&obj.AMask].start == nil {
buildop(ctxt) buildop(ctxt)
} }
...@@ -1207,14 +1207,14 @@ func oplook(ctxt *obj.Link, p *obj.Prog) *Optab { ...@@ -1207,14 +1207,14 @@ func oplook(ctxt *obj.Link, p *obj.Prog) *Optab {
if p.Reg != 0 { if p.Reg != 0 {
a2 = C_REG a2 = C_REG
} }
r := int(p.As) r := p.As & obj.AMask
o := oprange[r].start o := oprange[r].start
if o == nil { if o == nil {
o = oprange[r].stop /* just generate an error */ o = oprange[r].stop /* just generate an error */
} }
if false { /*debug['O']*/ if false { /*debug['O']*/
fmt.Printf("oplook %v %v %v %v\n", Aconv(int(p.As)), DRconv(a1), DRconv(a2), DRconv(a3)) fmt.Printf("oplook %v %v %v %v\n", obj.Aconv(int(p.As)), DRconv(a1), DRconv(a2), DRconv(a3))
fmt.Printf("\t\t%d %d\n", p.From.Type, p.To.Type) fmt.Printf("\t\t%d %d\n", p.From.Type, p.To.Type)
} }
...@@ -1335,6 +1335,10 @@ func (x ocmp) Less(i, j int) bool { ...@@ -1335,6 +1335,10 @@ func (x ocmp) Less(i, j int) bool {
return false return false
} }
func opset(a, b0 uint16) {
oprange[a&obj.AMask] = oprange[b0]
}
func buildop(ctxt *obj.Link) { func buildop(ctxt *obj.Link) {
var n int var n int
...@@ -1356,67 +1360,66 @@ func buildop(ctxt *obj.Link) { ...@@ -1356,67 +1360,66 @@ func buildop(ctxt *obj.Link) {
} }
sort.Sort(ocmp(optab[:n])) sort.Sort(ocmp(optab[:n]))
var r int
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
r = int(optab[i].as) r0 := optab[i].as & obj.AMask
oprange[r].start = optab[i:] oprange[r0].start = optab[i:]
for int(optab[i].as) == r { for optab[i].as&obj.AMask == r0 {
i++ i++
} }
oprange[r].stop = optab[i:] oprange[r0].stop = optab[i:]
i-- i--
switch r { switch r0 {
default: default:
ctxt.Diag("unknown op in build: %v", Aconv(r)) ctxt.Diag("unknown op in build: %v", obj.Aconv(int(optab[i].as)))
log.Fatalf("bad code") log.Fatalf("bad code")
case AADD: case AADD:
oprange[AAND] = oprange[r] opset(AAND, r0)
oprange[AEOR] = oprange[r] opset(AEOR, r0)
oprange[ASUB] = oprange[r] opset(ASUB, r0)
oprange[ARSB] = oprange[r] opset(ARSB, r0)
oprange[AADC] = oprange[r] opset(AADC, r0)
oprange[ASBC] = oprange[r] opset(ASBC, r0)
oprange[ARSC] = oprange[r] opset(ARSC, r0)
oprange[AORR] = oprange[r] opset(AORR, r0)
oprange[ABIC] = oprange[r] opset(ABIC, r0)
case ACMP: case ACMP:
oprange[ATEQ] = oprange[r] opset(ATEQ, r0)
oprange[ACMN] = oprange[r] opset(ACMN, r0)
case AMVN: case AMVN:
break break
case ABEQ: case ABEQ:
oprange[ABNE] = oprange[r] opset(ABNE, r0)
oprange[ABCS] = oprange[r] opset(ABCS, r0)
oprange[ABHS] = oprange[r] opset(ABHS, r0)
oprange[ABCC] = oprange[r] opset(ABCC, r0)
oprange[ABLO] = oprange[r] opset(ABLO, r0)
oprange[ABMI] = oprange[r] opset(ABMI, r0)
oprange[ABPL] = oprange[r] opset(ABPL, r0)
oprange[ABVS] = oprange[r] opset(ABVS, r0)
oprange[ABVC] = oprange[r] opset(ABVC, r0)
oprange[ABHI] = oprange[r] opset(ABHI, r0)
oprange[ABLS] = oprange[r] opset(ABLS, r0)
oprange[ABGE] = oprange[r] opset(ABGE, r0)
oprange[ABLT] = oprange[r] opset(ABLT, r0)
oprange[ABGT] = oprange[r] opset(ABGT, r0)
oprange[ABLE] = oprange[r] opset(ABLE, r0)
case ASLL: case ASLL:
oprange[ASRL] = oprange[r] opset(ASRL, r0)
oprange[ASRA] = oprange[r] opset(ASRA, r0)
case AMUL: case AMUL:
oprange[AMULU] = oprange[r] opset(AMULU, r0)
case ADIV: case ADIV:
oprange[AMOD] = oprange[r] opset(AMOD, r0)
oprange[AMODU] = oprange[r] opset(AMODU, r0)
oprange[ADIVU] = oprange[r] opset(ADIVU, r0)
case AMOVW, case AMOVW,
AMOVB, AMOVB,
...@@ -1428,7 +1431,7 @@ func buildop(ctxt *obj.Link) { ...@@ -1428,7 +1431,7 @@ func buildop(ctxt *obj.Link) {
break break
case ASWPW: case ASWPW:
oprange[ASWPBU] = oprange[r] opset(ASWPBU, r0)
case AB, case AB,
ABL, ABL,
...@@ -1448,42 +1451,42 @@ func buildop(ctxt *obj.Link) { ...@@ -1448,42 +1451,42 @@ func buildop(ctxt *obj.Link) {
break break
case AADDF: case AADDF:
oprange[AADDD] = oprange[r] opset(AADDD, r0)
oprange[ASUBF] = oprange[r] opset(ASUBF, r0)
oprange[ASUBD] = oprange[r] opset(ASUBD, r0)
oprange[AMULF] = oprange[r] opset(AMULF, r0)
oprange[AMULD] = oprange[r] opset(AMULD, r0)
oprange[ADIVF] = oprange[r] opset(ADIVF, r0)
oprange[ADIVD] = oprange[r] opset(ADIVD, r0)
oprange[ASQRTF] = oprange[r] opset(ASQRTF, r0)
oprange[ASQRTD] = oprange[r] opset(ASQRTD, r0)
oprange[AMOVFD] = oprange[r] opset(AMOVFD, r0)
oprange[AMOVDF] = oprange[r] opset(AMOVDF, r0)
oprange[AABSF] = oprange[r] opset(AABSF, r0)
oprange[AABSD] = oprange[r] opset(AABSD, r0)
case ACMPF: case ACMPF:
oprange[ACMPD] = oprange[r] opset(ACMPD, r0)
case AMOVF: case AMOVF:
oprange[AMOVD] = oprange[r] opset(AMOVD, r0)
case AMOVFW: case AMOVFW:
oprange[AMOVDW] = oprange[r] opset(AMOVDW, r0)
case AMOVWF: case AMOVWF:
oprange[AMOVWD] = oprange[r] opset(AMOVWD, r0)
case AMULL: case AMULL:
oprange[AMULAL] = oprange[r] opset(AMULAL, r0)
oprange[AMULLU] = oprange[r] opset(AMULLU, r0)
oprange[AMULALU] = oprange[r] opset(AMULALU, r0)
case AMULWT: case AMULWT:
oprange[AMULWB] = oprange[r] opset(AMULWB, r0)
case AMULAWT: case AMULAWT:
oprange[AMULAWB] = oprange[r] opset(AMULAWB, r0)
case AMULA, case AMULA,
ALDREX, ALDREX,
...@@ -2660,7 +2663,7 @@ func opbra(ctxt *obj.Link, a int, sc int) uint32 { ...@@ -2660,7 +2663,7 @@ func opbra(ctxt *obj.Link, a int, sc int) uint32 {
return 0xe<<28 | 0x5<<25 return 0xe<<28 | 0x5<<25
} }
ctxt.Diag("bad bra %v", Aconv(a)) ctxt.Diag("bad bra %v", obj.Aconv(a))
prasm(ctxt.Curp) prasm(ctxt.Curp)
return 0 return 0
} }
...@@ -2780,7 +2783,7 @@ func ofsr(ctxt *obj.Link, a int, r int, v int32, b int, sc int, p *obj.Prog) uin ...@@ -2780,7 +2783,7 @@ func ofsr(ctxt *obj.Link, a int, r int, v int32, b int, sc int, p *obj.Prog) uin
switch a { switch a {
default: default:
ctxt.Diag("bad fst %v", Aconv(a)) ctxt.Diag("bad fst %v", obj.Aconv(a))
fallthrough fallthrough
case AMOVD: case AMOVD:
......
...@@ -79,57 +79,16 @@ func Pconv(p *obj.Prog) string { ...@@ -79,57 +79,16 @@ func Pconv(p *obj.Prog) string {
var str string var str string
if a == obj.ADATA { if a == obj.ADATA {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v",
p.Pc, p.Line(), Aconv(a), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To))
} else if p.As == obj.ATEXT { } else if p.As == obj.ATEXT {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v",
p.Pc, p.Line(), Aconv(a), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To))
} else if p.Reg == 0 { } else if p.Reg == 0 {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v",
p.Pc, p.Line(), Aconv(a), sc, obj.Dconv(p, &p.From), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), sc, obj.Dconv(p, &p.From), obj.Dconv(p, &p.To))
} else { } else {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v,%v", str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v,%v",
p.Pc, p.Line(), Aconv(a), sc, obj.Dconv(p, &p.From), Rconv(int(p.Reg)), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), sc, obj.Dconv(p, &p.From), Rconv(int(p.Reg)), obj.Dconv(p, &p.To))
}
var fp string
fp += str
return fp
}
func Aconv(a int) string {
s := "???"
if a >= obj.AXXX && a < ALAST {
s = Anames[a]
}
var fp string
fp += s
return fp
}
func RAconv(a *obj.Addr) string {
str := fmt.Sprintf("GOK-reglist")
switch a.Type {
case obj.TYPE_CONST:
if a.Reg != 0 {
break
}
if a.Sym != nil {
break
}
v := int(a.Offset)
str = ""
for i := 0; i < NREG; i++ {
if v&(1<<uint(i)) != 0 {
if str == "" {
str += "[R"
} else {
str += ",R"
}
str += fmt.Sprintf("%d", i)
}
}
str += "]"
} }
var fp string var fp string
...@@ -139,6 +98,7 @@ func RAconv(a *obj.Addr) string { ...@@ -139,6 +98,7 @@ func RAconv(a *obj.Addr) string {
func init() { func init() {
obj.RegisterRegister(obj.RBaseARM, MAXREG, Rconv) obj.RegisterRegister(obj.RBaseARM, MAXREG, Rconv)
obj.RegisterOpcode(obj.ABaseARM, Anames)
} }
func Rconv(r int) string { func Rconv(r int) string {
......
...@@ -33,7 +33,7 @@ package i386 ...@@ -33,7 +33,7 @@ package i386
import "cmd/internal/obj" import "cmd/internal/obj"
const ( const (
AAAA = obj.A_ARCHSPECIFIC + iota AAAA = obj.ABase386 + obj.A_ARCHSPECIFIC + iota
AAAD AAAD
AAAM AAAM
AAAS AAAS
......
package i386 package i386
import "cmd/internal/obj"
/* /*
* this is the ranlib header * this is the ranlib header
*/ */
var Anames = []string{ var Anames = []string{
"XXX", obj.A_ARCHSPECIFIC: "AAA",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"AAA",
"AAD", "AAD",
"AAM", "AAM",
"AAS", "AAS",
......
...@@ -58,7 +58,7 @@ type ytab struct { ...@@ -58,7 +58,7 @@ type ytab struct {
zoffset uint8 zoffset uint8
} }
var opindex [ALAST + 1]*Optab var opindex [(ALAST + 1) & obj.AMask]*Optab
const ( const (
Yxxx = 0 + iota Yxxx = 0 + iota
...@@ -1331,12 +1331,11 @@ func span8(ctxt *obj.Link, s *obj.LSym) { ...@@ -1331,12 +1331,11 @@ func span8(ctxt *obj.Link, s *obj.LSym) {
} }
func instinit() { func instinit() {
var c int
for i := 1; optab[i].as != 0; i++ { for i := 1; optab[i].as != 0; i++ {
c = int(optab[i].as) c := optab[i].as & obj.AMask
if opindex[c] != nil { if opindex[c] != nil {
log.Fatalf("phase error in optab: %d (%v)", i, Aconv(c)) log.Fatalf("phase error in optab: %d (%v)", i, obj.Aconv(int(optab[i].as)))
} }
opindex[c] = &optab[i] opindex[c] = &optab[i]
} }
...@@ -1969,7 +1968,7 @@ const ( ...@@ -1969,7 +1968,7 @@ const (
var ymovtab = []uint8{ var ymovtab = []uint8{
/* push */ /* push */
APUSHL, APUSHL & obj.AMask,
Ycs, Ycs,
Ynone, Ynone,
0, 0,
...@@ -1977,7 +1976,7 @@ var ymovtab = []uint8{ ...@@ -1977,7 +1976,7 @@ var ymovtab = []uint8{
E, E,
0, 0,
0, 0,
APUSHL, APUSHL & obj.AMask,
Yss, Yss,
Ynone, Ynone,
0, 0,
...@@ -1985,7 +1984,7 @@ var ymovtab = []uint8{ ...@@ -1985,7 +1984,7 @@ var ymovtab = []uint8{
E, E,
0, 0,
0, 0,
APUSHL, APUSHL & obj.AMask,
Yds, Yds,
Ynone, Ynone,
0, 0,
...@@ -1993,7 +1992,7 @@ var ymovtab = []uint8{ ...@@ -1993,7 +1992,7 @@ var ymovtab = []uint8{
E, E,
0, 0,
0, 0,
APUSHL, APUSHL & obj.AMask,
Yes, Yes,
Ynone, Ynone,
0, 0,
...@@ -2001,7 +2000,7 @@ var ymovtab = []uint8{ ...@@ -2001,7 +2000,7 @@ var ymovtab = []uint8{
E, E,
0, 0,
0, 0,
APUSHL, APUSHL & obj.AMask,
Yfs, Yfs,
Ynone, Ynone,
0, 0,
...@@ -2009,7 +2008,7 @@ var ymovtab = []uint8{ ...@@ -2009,7 +2008,7 @@ var ymovtab = []uint8{
0xa0, 0xa0,
E, E,
0, 0,
APUSHL, APUSHL & obj.AMask,
Ygs, Ygs,
Ynone, Ynone,
0, 0,
...@@ -2017,7 +2016,7 @@ var ymovtab = []uint8{ ...@@ -2017,7 +2016,7 @@ var ymovtab = []uint8{
0xa8, 0xa8,
E, E,
0, 0,
APUSHW, APUSHW & obj.AMask,
Ycs, Ycs,
Ynone, Ynone,
0, 0,
...@@ -2025,7 +2024,7 @@ var ymovtab = []uint8{ ...@@ -2025,7 +2024,7 @@ var ymovtab = []uint8{
0x0e, 0x0e,
E, E,
0, 0,
APUSHW, APUSHW & obj.AMask,
Yss, Yss,
Ynone, Ynone,
0, 0,
...@@ -2033,7 +2032,7 @@ var ymovtab = []uint8{ ...@@ -2033,7 +2032,7 @@ var ymovtab = []uint8{
0x16, 0x16,
E, E,
0, 0,
APUSHW, APUSHW & obj.AMask,
Yds, Yds,
Ynone, Ynone,
0, 0,
...@@ -2041,7 +2040,7 @@ var ymovtab = []uint8{ ...@@ -2041,7 +2040,7 @@ var ymovtab = []uint8{
0x1e, 0x1e,
E, E,
0, 0,
APUSHW, APUSHW & obj.AMask,
Yes, Yes,
Ynone, Ynone,
0, 0,
...@@ -2049,7 +2048,7 @@ var ymovtab = []uint8{ ...@@ -2049,7 +2048,7 @@ var ymovtab = []uint8{
0x06, 0x06,
E, E,
0, 0,
APUSHW, APUSHW & obj.AMask,
Yfs, Yfs,
Ynone, Ynone,
0, 0,
...@@ -2057,7 +2056,7 @@ var ymovtab = []uint8{ ...@@ -2057,7 +2056,7 @@ var ymovtab = []uint8{
0x0f, 0x0f,
0xa0, 0xa0,
E, E,
APUSHW, APUSHW & obj.AMask,
Ygs, Ygs,
Ynone, Ynone,
0, 0,
...@@ -2067,7 +2066,7 @@ var ymovtab = []uint8{ ...@@ -2067,7 +2066,7 @@ var ymovtab = []uint8{
E, E,
/* pop */ /* pop */
APOPL, APOPL & obj.AMask,
Ynone, Ynone,
Yds, Yds,
0, 0,
...@@ -2075,7 +2074,7 @@ var ymovtab = []uint8{ ...@@ -2075,7 +2074,7 @@ var ymovtab = []uint8{
E, E,
0, 0,
0, 0,
APOPL, APOPL & obj.AMask,
Ynone, Ynone,
Yes, Yes,
0, 0,
...@@ -2083,7 +2082,7 @@ var ymovtab = []uint8{ ...@@ -2083,7 +2082,7 @@ var ymovtab = []uint8{
E, E,
0, 0,
0, 0,
APOPL, APOPL & obj.AMask,
Ynone, Ynone,
Yss, Yss,
0, 0,
...@@ -2091,7 +2090,7 @@ var ymovtab = []uint8{ ...@@ -2091,7 +2090,7 @@ var ymovtab = []uint8{
E, E,
0, 0,
0, 0,
APOPL, APOPL & obj.AMask,
Ynone, Ynone,
Yfs, Yfs,
0, 0,
...@@ -2099,7 +2098,7 @@ var ymovtab = []uint8{ ...@@ -2099,7 +2098,7 @@ var ymovtab = []uint8{
0xa1, 0xa1,
E, E,
0, 0,
APOPL, APOPL & obj.AMask,
Ynone, Ynone,
Ygs, Ygs,
0, 0,
...@@ -2107,7 +2106,7 @@ var ymovtab = []uint8{ ...@@ -2107,7 +2106,7 @@ var ymovtab = []uint8{
0xa9, 0xa9,
E, E,
0, 0,
APOPW, APOPW & obj.AMask,
Ynone, Ynone,
Yds, Yds,
0, 0,
...@@ -2115,7 +2114,7 @@ var ymovtab = []uint8{ ...@@ -2115,7 +2114,7 @@ var ymovtab = []uint8{
0x1f, 0x1f,
E, E,
0, 0,
APOPW, APOPW & obj.AMask,
Ynone, Ynone,
Yes, Yes,
0, 0,
...@@ -2123,7 +2122,7 @@ var ymovtab = []uint8{ ...@@ -2123,7 +2122,7 @@ var ymovtab = []uint8{
0x07, 0x07,
E, E,
0, 0,
APOPW, APOPW & obj.AMask,
Ynone, Ynone,
Yss, Yss,
0, 0,
...@@ -2131,7 +2130,7 @@ var ymovtab = []uint8{ ...@@ -2131,7 +2130,7 @@ var ymovtab = []uint8{
0x17, 0x17,
E, E,
0, 0,
APOPW, APOPW & obj.AMask,
Ynone, Ynone,
Yfs, Yfs,
0, 0,
...@@ -2139,7 +2138,7 @@ var ymovtab = []uint8{ ...@@ -2139,7 +2138,7 @@ var ymovtab = []uint8{
0x0f, 0x0f,
0xa1, 0xa1,
E, E,
APOPW, APOPW & obj.AMask,
Ynone, Ynone,
Ygs, Ygs,
0, 0,
...@@ -2149,7 +2148,7 @@ var ymovtab = []uint8{ ...@@ -2149,7 +2148,7 @@ var ymovtab = []uint8{
E, E,
/* mov seg */ /* mov seg */
AMOVW, AMOVW & obj.AMask,
Yes, Yes,
Yml, Yml,
1, 1,
...@@ -2157,7 +2156,7 @@ var ymovtab = []uint8{ ...@@ -2157,7 +2156,7 @@ var ymovtab = []uint8{
0, 0,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Ycs, Ycs,
Yml, Yml,
1, 1,
...@@ -2165,7 +2164,7 @@ var ymovtab = []uint8{ ...@@ -2165,7 +2164,7 @@ var ymovtab = []uint8{
1, 1,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yss, Yss,
Yml, Yml,
1, 1,
...@@ -2173,7 +2172,7 @@ var ymovtab = []uint8{ ...@@ -2173,7 +2172,7 @@ var ymovtab = []uint8{
2, 2,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yds, Yds,
Yml, Yml,
1, 1,
...@@ -2181,7 +2180,7 @@ var ymovtab = []uint8{ ...@@ -2181,7 +2180,7 @@ var ymovtab = []uint8{
3, 3,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yfs, Yfs,
Yml, Yml,
1, 1,
...@@ -2189,7 +2188,7 @@ var ymovtab = []uint8{ ...@@ -2189,7 +2188,7 @@ var ymovtab = []uint8{
4, 4,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Ygs, Ygs,
Yml, Yml,
1, 1,
...@@ -2197,7 +2196,7 @@ var ymovtab = []uint8{ ...@@ -2197,7 +2196,7 @@ var ymovtab = []uint8{
5, 5,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Yes, Yes,
2, 2,
...@@ -2205,7 +2204,7 @@ var ymovtab = []uint8{ ...@@ -2205,7 +2204,7 @@ var ymovtab = []uint8{
0, 0,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Ycs, Ycs,
2, 2,
...@@ -2213,7 +2212,7 @@ var ymovtab = []uint8{ ...@@ -2213,7 +2212,7 @@ var ymovtab = []uint8{
1, 1,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Yss, Yss,
2, 2,
...@@ -2221,7 +2220,7 @@ var ymovtab = []uint8{ ...@@ -2221,7 +2220,7 @@ var ymovtab = []uint8{
2, 2,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Yds, Yds,
2, 2,
...@@ -2229,7 +2228,7 @@ var ymovtab = []uint8{ ...@@ -2229,7 +2228,7 @@ var ymovtab = []uint8{
3, 3,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Yfs, Yfs,
2, 2,
...@@ -2237,7 +2236,7 @@ var ymovtab = []uint8{ ...@@ -2237,7 +2236,7 @@ var ymovtab = []uint8{
4, 4,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Ygs, Ygs,
2, 2,
...@@ -2247,7 +2246,7 @@ var ymovtab = []uint8{ ...@@ -2247,7 +2246,7 @@ var ymovtab = []uint8{
0, 0,
/* mov cr */ /* mov cr */
AMOVL, AMOVL & obj.AMask,
Ycr0, Ycr0,
Yml, Yml,
3, 3,
...@@ -2255,7 +2254,7 @@ var ymovtab = []uint8{ ...@@ -2255,7 +2254,7 @@ var ymovtab = []uint8{
0x20, 0x20,
0, 0,
0, 0,
AMOVL, AMOVL & obj.AMask,
Ycr2, Ycr2,
Yml, Yml,
3, 3,
...@@ -2263,7 +2262,7 @@ var ymovtab = []uint8{ ...@@ -2263,7 +2262,7 @@ var ymovtab = []uint8{
0x20, 0x20,
2, 2,
0, 0,
AMOVL, AMOVL & obj.AMask,
Ycr3, Ycr3,
Yml, Yml,
3, 3,
...@@ -2271,7 +2270,7 @@ var ymovtab = []uint8{ ...@@ -2271,7 +2270,7 @@ var ymovtab = []uint8{
0x20, 0x20,
3, 3,
0, 0,
AMOVL, AMOVL & obj.AMask,
Ycr4, Ycr4,
Yml, Yml,
3, 3,
...@@ -2279,7 +2278,7 @@ var ymovtab = []uint8{ ...@@ -2279,7 +2278,7 @@ var ymovtab = []uint8{
0x20, 0x20,
4, 4,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ycr0, Ycr0,
4, 4,
...@@ -2287,7 +2286,7 @@ var ymovtab = []uint8{ ...@@ -2287,7 +2286,7 @@ var ymovtab = []uint8{
0x22, 0x22,
0, 0,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ycr2, Ycr2,
4, 4,
...@@ -2295,7 +2294,7 @@ var ymovtab = []uint8{ ...@@ -2295,7 +2294,7 @@ var ymovtab = []uint8{
0x22, 0x22,
2, 2,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ycr3, Ycr3,
4, 4,
...@@ -2303,7 +2302,7 @@ var ymovtab = []uint8{ ...@@ -2303,7 +2302,7 @@ var ymovtab = []uint8{
0x22, 0x22,
3, 3,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ycr4, Ycr4,
4, 4,
...@@ -2313,7 +2312,7 @@ var ymovtab = []uint8{ ...@@ -2313,7 +2312,7 @@ var ymovtab = []uint8{
0, 0,
/* mov dr */ /* mov dr */
AMOVL, AMOVL & obj.AMask,
Ydr0, Ydr0,
Yml, Yml,
3, 3,
...@@ -2321,7 +2320,7 @@ var ymovtab = []uint8{ ...@@ -2321,7 +2320,7 @@ var ymovtab = []uint8{
0x21, 0x21,
0, 0,
0, 0,
AMOVL, AMOVL & obj.AMask,
Ydr6, Ydr6,
Yml, Yml,
3, 3,
...@@ -2329,7 +2328,7 @@ var ymovtab = []uint8{ ...@@ -2329,7 +2328,7 @@ var ymovtab = []uint8{
0x21, 0x21,
6, 6,
0, 0,
AMOVL, AMOVL & obj.AMask,
Ydr7, Ydr7,
Yml, Yml,
3, 3,
...@@ -2337,7 +2336,7 @@ var ymovtab = []uint8{ ...@@ -2337,7 +2336,7 @@ var ymovtab = []uint8{
0x21, 0x21,
7, 7,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ydr0, Ydr0,
4, 4,
...@@ -2345,7 +2344,7 @@ var ymovtab = []uint8{ ...@@ -2345,7 +2344,7 @@ var ymovtab = []uint8{
0x23, 0x23,
0, 0,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ydr6, Ydr6,
4, 4,
...@@ -2353,7 +2352,7 @@ var ymovtab = []uint8{ ...@@ -2353,7 +2352,7 @@ var ymovtab = []uint8{
0x23, 0x23,
6, 6,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ydr7, Ydr7,
4, 4,
...@@ -2363,7 +2362,7 @@ var ymovtab = []uint8{ ...@@ -2363,7 +2362,7 @@ var ymovtab = []uint8{
0, 0,
/* mov tr */ /* mov tr */
AMOVL, AMOVL & obj.AMask,
Ytr6, Ytr6,
Yml, Yml,
3, 3,
...@@ -2371,7 +2370,7 @@ var ymovtab = []uint8{ ...@@ -2371,7 +2370,7 @@ var ymovtab = []uint8{
0x24, 0x24,
6, 6,
0, 0,
AMOVL, AMOVL & obj.AMask,
Ytr7, Ytr7,
Yml, Yml,
3, 3,
...@@ -2379,7 +2378,7 @@ var ymovtab = []uint8{ ...@@ -2379,7 +2378,7 @@ var ymovtab = []uint8{
0x24, 0x24,
7, 7,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ytr6, Ytr6,
4, 4,
...@@ -2387,7 +2386,7 @@ var ymovtab = []uint8{ ...@@ -2387,7 +2386,7 @@ var ymovtab = []uint8{
0x26, 0x26,
6, 6,
E, E,
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ytr7, Ytr7,
4, 4,
...@@ -2397,7 +2396,7 @@ var ymovtab = []uint8{ ...@@ -2397,7 +2396,7 @@ var ymovtab = []uint8{
E, E,
/* lgdt, sgdt, lidt, sidt */ /* lgdt, sgdt, lidt, sidt */
AMOVL, AMOVL & obj.AMask,
Ym, Ym,
Ygdtr, Ygdtr,
4, 4,
...@@ -2405,7 +2404,7 @@ var ymovtab = []uint8{ ...@@ -2405,7 +2404,7 @@ var ymovtab = []uint8{
0x01, 0x01,
2, 2,
0, 0,
AMOVL, AMOVL & obj.AMask,
Ygdtr, Ygdtr,
Ym, Ym,
3, 3,
...@@ -2413,7 +2412,7 @@ var ymovtab = []uint8{ ...@@ -2413,7 +2412,7 @@ var ymovtab = []uint8{
0x01, 0x01,
0, 0,
0, 0,
AMOVL, AMOVL & obj.AMask,
Ym, Ym,
Yidtr, Yidtr,
4, 4,
...@@ -2421,7 +2420,7 @@ var ymovtab = []uint8{ ...@@ -2421,7 +2420,7 @@ var ymovtab = []uint8{
0x01, 0x01,
3, 3,
0, 0,
AMOVL, AMOVL & obj.AMask,
Yidtr, Yidtr,
Ym, Ym,
3, 3,
...@@ -2431,7 +2430,7 @@ var ymovtab = []uint8{ ...@@ -2431,7 +2430,7 @@ var ymovtab = []uint8{
0, 0,
/* lldt, sldt */ /* lldt, sldt */
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Yldtr, Yldtr,
4, 4,
...@@ -2439,7 +2438,7 @@ var ymovtab = []uint8{ ...@@ -2439,7 +2438,7 @@ var ymovtab = []uint8{
0x00, 0x00,
2, 2,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yldtr, Yldtr,
Yml, Yml,
3, 3,
...@@ -2449,7 +2448,7 @@ var ymovtab = []uint8{ ...@@ -2449,7 +2448,7 @@ var ymovtab = []uint8{
0, 0,
/* lmsw, smsw */ /* lmsw, smsw */
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Ymsw, Ymsw,
4, 4,
...@@ -2457,7 +2456,7 @@ var ymovtab = []uint8{ ...@@ -2457,7 +2456,7 @@ var ymovtab = []uint8{
0x01, 0x01,
6, 6,
0, 0,
AMOVW, AMOVW & obj.AMask,
Ymsw, Ymsw,
Yml, Yml,
3, 3,
...@@ -2467,7 +2466,7 @@ var ymovtab = []uint8{ ...@@ -2467,7 +2466,7 @@ var ymovtab = []uint8{
0, 0,
/* ltr, str */ /* ltr, str */
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Ytask, Ytask,
4, 4,
...@@ -2475,7 +2474,7 @@ var ymovtab = []uint8{ ...@@ -2475,7 +2474,7 @@ var ymovtab = []uint8{
0x00, 0x00,
3, 3,
0, 0,
AMOVW, AMOVW & obj.AMask,
Ytask, Ytask,
Yml, Yml,
3, 3,
...@@ -2485,7 +2484,7 @@ var ymovtab = []uint8{ ...@@ -2485,7 +2484,7 @@ var ymovtab = []uint8{
0, 0,
/* load full pointer */ /* load full pointer */
AMOVL, AMOVL & obj.AMask,
Yml, Yml,
Ycol, Ycol,
5, 5,
...@@ -2493,7 +2492,7 @@ var ymovtab = []uint8{ ...@@ -2493,7 +2492,7 @@ var ymovtab = []uint8{
0, 0,
0, 0,
0, 0,
AMOVW, AMOVW & obj.AMask,
Yml, Yml,
Ycol, Ycol,
5, 5,
...@@ -2503,7 +2502,7 @@ var ymovtab = []uint8{ ...@@ -2503,7 +2502,7 @@ var ymovtab = []uint8{
0, 0,
/* double shift */ /* double shift */
ASHLL, ASHLL & obj.AMask,
Ycol, Ycol,
Yml, Yml,
6, 6,
...@@ -2511,7 +2510,7 @@ var ymovtab = []uint8{ ...@@ -2511,7 +2510,7 @@ var ymovtab = []uint8{
0xa5, 0xa5,
0, 0,
0, 0,
ASHRL, ASHRL & obj.AMask,
Ycol, Ycol,
Yml, Yml,
6, 6,
...@@ -2521,7 +2520,7 @@ var ymovtab = []uint8{ ...@@ -2521,7 +2520,7 @@ var ymovtab = []uint8{
0, 0,
/* extra imul */ /* extra imul */
AIMULW, AIMULW & obj.AMask,
Yml, Yml,
Yrl, Yrl,
7, 7,
...@@ -2529,7 +2528,7 @@ var ymovtab = []uint8{ ...@@ -2529,7 +2528,7 @@ var ymovtab = []uint8{
0xaf, 0xaf,
0, 0,
0, 0,
AIMULL, AIMULL & obj.AMask,
Yml, Yml,
Yrl, Yrl,
7, 7,
...@@ -2539,7 +2538,7 @@ var ymovtab = []uint8{ ...@@ -2539,7 +2538,7 @@ var ymovtab = []uint8{
0, 0,
/* load TLS base pointer */ /* load TLS base pointer */
AMOVL, AMOVL & obj.AMask,
Ytls, Ytls,
Yrl, Yrl,
8, 8,
...@@ -2712,7 +2711,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) { ...@@ -2712,7 +2711,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
ft := int(p.Ft) * Ymax ft := int(p.Ft) * Ymax
tt := int(p.Tt) * Ymax tt := int(p.Tt) * Ymax
o := opindex[p.As] o := opindex[p.As&obj.AMask]
z := 0 z := 0
var a *obj.Addr var a *obj.Addr
...@@ -3163,7 +3162,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) { ...@@ -3163,7 +3162,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
domov: domov:
var pp obj.Prog var pp obj.Prog
for t := []byte(ymovtab); t[0] != 0; t = t[8:] { for t := []byte(ymovtab); t[0] != 0; t = t[8:] {
if p.As == int16(t[0]) { if p.As&obj.AMask == int16(t[0]) {
if ycover[ft+int(t[1])] != 0 { if ycover[ft+int(t[1])] != 0 {
if ycover[tt+int(t[2])] != 0 { if ycover[tt+int(t[2])] != 0 {
switch t[3] { switch t[3] {
......
...@@ -47,21 +47,21 @@ func Pconv(p *obj.Prog) string { ...@@ -47,21 +47,21 @@ func Pconv(p *obj.Prog) string {
switch p.As { switch p.As {
case obj.ADATA: case obj.ADATA:
str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v",
p.Pc, p.Line(), Aconv(int(p.As)), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(int(p.As)), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To))
case obj.ATEXT: case obj.ATEXT:
if p.From3.Offset != 0 { if p.From3.Offset != 0 {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v",
p.Pc, p.Line(), Aconv(int(p.As)), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(int(p.As)), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To))
break break
} }
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v",
p.Pc, p.Line(), Aconv(int(p.As)), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(int(p.As)), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To))
default: default:
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v",
p.Pc, p.Line(), Aconv(int(p.As)), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(int(p.As)), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To))
// TODO(rsc): This special case is for SHRQ $32, AX:DX, which encodes as // TODO(rsc): This special case is for SHRQ $32, AX:DX, which encodes as
// SHRQ $32(DX*0), AX // SHRQ $32(DX*0), AX
...@@ -76,10 +76,6 @@ func Pconv(p *obj.Prog) string { ...@@ -76,10 +76,6 @@ func Pconv(p *obj.Prog) string {
return fp return fp
} }
func Aconv(i int) string {
return Anames[i]
}
var Register = []string{ var Register = []string{
"AL", /* [REG_AL] */ "AL", /* [REG_AL] */
"CL", "CL",
...@@ -154,6 +150,7 @@ var Register = []string{ ...@@ -154,6 +150,7 @@ var Register = []string{
func init() { func init() {
obj.RegisterRegister(obj.RBase386, obj.RBase386+len(Register), Rconv) obj.RegisterRegister(obj.RBase386, obj.RBase386+len(Register), Rconv)
obj.RegisterOpcode(obj.ABase386, Anames)
} }
func Rconv(r int) string { func Rconv(r int) string {
......
...@@ -424,6 +424,10 @@ const ( ...@@ -424,6 +424,10 @@ const (
// These are the portable opcodes, common to all architectures. // These are the portable opcodes, common to all architectures.
// Each architecture defines many more arch-specific opcodes, // Each architecture defines many more arch-specific opcodes,
// with values starting at A_ARCHSPECIFIC. // 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.
const ( const (
AXXX = 0 + iota AXXX = 0 + iota
ACALL ACALL
...@@ -570,30 +574,4 @@ const ( ...@@ -570,30 +574,4 @@ const (
LinkExternal LinkExternal
) )
// asm5.c
// asm6.c
// asm8.c
// asm9.c
// data.c
// go.c
// ld.c
// list[5689].c
// obj.c
// objfile.c
// pass.c
// pcln.c
// sym.c
var linkbasepointer int var linkbasepointer int
...@@ -218,7 +218,7 @@ const ( ...@@ -218,7 +218,7 @@ const (
) )
const ( const (
AADD = obj.A_ARCHSPECIFIC + iota AADD = obj.ABasePPC64 + obj.A_ARCHSPECIFIC + iota
AADDCC AADDCC
AADDV AADDV
AADDVCC AADDVCC
......
package ppc64 package ppc64
/* import "cmd/internal/obj"
* this is the ranlib header
*/
var Anames = []string{ var Anames = []string{
"XXX", obj.A_ARCHSPECIFIC: "ADD",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"ADD",
"ADDCC", "ADDCC",
"ADDV", "ADDV",
"ADDVCC", "ADDVCC",
......
This diff is collapsed.
...@@ -59,14 +59,14 @@ func Pconv(p *obj.Prog) string { ...@@ -59,14 +59,14 @@ func Pconv(p *obj.Prog) string {
str := "" str := ""
if a == obj.ADATA { if a == obj.ADATA {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v",
p.Pc, p.Line(), Aconv(a), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To))
} else if a == obj.ATEXT || a == obj.AGLOBL { } else if a == obj.ATEXT || a == obj.AGLOBL {
if p.From3.Offset != 0 { if p.From3.Offset != 0 {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v",
p.Pc, p.Line(), Aconv(a), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To))
} else { } else {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v",
p.Pc, p.Line(), Aconv(a), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To))
} }
} else { } else {
if p.Mark&NOSCHED != 0 { if p.Mark&NOSCHED != 0 {
...@@ -74,24 +74,24 @@ func Pconv(p *obj.Prog) string { ...@@ -74,24 +74,24 @@ func Pconv(p *obj.Prog) string {
} }
if p.Reg == 0 && p.From3.Type == obj.TYPE_NONE { if p.Reg == 0 && p.From3.Type == obj.TYPE_NONE {
str += fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", str += fmt.Sprintf("%.5d (%v)\t%v\t%v,%v",
p.Pc, p.Line(), Aconv(a), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To))
} else if a != obj.ATEXT && p.From.Type == obj.TYPE_MEM { } else if a != obj.ATEXT && p.From.Type == obj.TYPE_MEM {
off := "" off := ""
if p.From.Offset != 0 { if p.From.Offset != 0 {
off = fmt.Sprintf("%d", p.From.Offset) off = fmt.Sprintf("%d", p.From.Offset)
} }
str += fmt.Sprintf("%.5d (%v)\t%v\t%s(%v+%v),%v", str += fmt.Sprintf("%.5d (%v)\t%v\t%s(%v+%v),%v",
p.Pc, p.Line(), Aconv(a), off, Rconv(int(p.From.Reg)), Rconv(int(p.Reg)), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(a), off, Rconv(int(p.From.Reg)), Rconv(int(p.Reg)), obj.Dconv(p, &p.To))
} else if p.To.Type == obj.TYPE_MEM { } else if p.To.Type == obj.TYPE_MEM {
off := "" off := ""
if p.From.Offset != 0 { if p.From.Offset != 0 {
off = fmt.Sprintf("%d", p.From.Offset) off = fmt.Sprintf("%d", p.From.Offset)
} }
str += fmt.Sprintf("%.5d (%v)\t%v\t%v,%s(%v+%v)", str += fmt.Sprintf("%.5d (%v)\t%v\t%v,%s(%v+%v)",
p.Pc, p.Line(), Aconv(a), obj.Dconv(p, &p.From), off, Rconv(int(p.To.Reg)), Rconv(int(p.Reg))) p.Pc, p.Line(), obj.Aconv(a), obj.Dconv(p, &p.From), off, Rconv(int(p.To.Reg)), Rconv(int(p.Reg)))
} else { } else {
str += fmt.Sprintf("%.5d (%v)\t%v\t%v", str += fmt.Sprintf("%.5d (%v)\t%v\t%v",
p.Pc, p.Line(), Aconv(a), obj.Dconv(p, &p.From)) p.Pc, p.Line(), obj.Aconv(a), obj.Dconv(p, &p.From))
if p.Reg != 0 { if p.Reg != 0 {
str += fmt.Sprintf(",%v", Rconv(int(p.Reg))) str += fmt.Sprintf(",%v", Rconv(int(p.Reg)))
} }
...@@ -113,18 +113,9 @@ func Pconv(p *obj.Prog) string { ...@@ -113,18 +113,9 @@ func Pconv(p *obj.Prog) string {
return fp return fp
} }
func Aconv(a int) string {
s := "???"
if a >= obj.AXXX && a < ALAST {
s = Anames[a]
}
var fp string
fp += s
return fp
}
func init() { func init() {
obj.RegisterRegister(obj.RBasePPC64, REG_DCR0+1024, Rconv) obj.RegisterRegister(obj.RBasePPC64, REG_DCR0+1024, Rconv)
obj.RegisterOpcode(obj.ABasePPC64, Anames)
} }
func Rconv(r int) string { func Rconv(r int) string {
......
...@@ -491,3 +491,68 @@ func regListConv(list int) string { ...@@ -491,3 +491,68 @@ func regListConv(list int) string {
str += "]" str += "]"
return str return str
} }
/*
Each architecture defines an instruction (A*) space as a unique
integer range.
Global opcodes like CALL start at 0; the architecture-specific ones
start at a distinct, big-maskable offsets.
Here is the list of architectures and the base of their opcode spaces.
*/
const (
ABase386 = (1 + iota) << 12
ABaseARM
ABaseAMD64
ABasePPC64
AMask = 1<<12 - 1 // AND with this to use the opcode as an array index.
)
type opSet struct {
lo int
names []string
}
// Not even worth sorting
var aSpace []opSet
// RegisterOpcode binds a list of instruction names
// to a given instruction number range.
func RegisterOpcode(lo int, Anames []string) {
aSpace = append(aSpace, opSet{lo, Anames})
}
func Aconv(a int) string {
if a < A_ARCHSPECIFIC {
return Anames[a]
}
for i := range aSpace {
as := &aSpace[i]
if as.lo <= a && a < as.lo+len(as.names) {
return as.names[a-as.lo]
}
}
return fmt.Sprintf("A???%d", a)
}
var Anames = []string{
"XXX",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
}
...@@ -36,7 +36,7 @@ import "cmd/internal/obj" ...@@ -36,7 +36,7 @@ import "cmd/internal/obj"
* amd64 * amd64
*/ */
const ( const (
AAAA = obj.A_ARCHSPECIFIC + iota AAAA = obj.ABaseAMD64 + obj.A_ARCHSPECIFIC + iota
AAAD AAAD
AAAM AAAM
AAAS AAAS
......
package x86 package x86
import "cmd/internal/obj"
/* /*
* this is the ranlib header * this is the ranlib header
*/ */
var Anames = []string{ var Anames = []string{
"XXX", obj.A_ARCHSPECIFIC: "AAA",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"AAA",
"AAD", "AAD",
"AAM", "AAM",
"AAS", "AAS",
......
...@@ -1435,7 +1435,7 @@ var optab = ...@@ -1435,7 +1435,7 @@ var optab =
Optab{0, nil, 0, [23]uint8{}}, Optab{0, nil, 0, [23]uint8{}},
} }
var opindex [ALAST + 1]*Optab var opindex [(ALAST + 1) & obj.AMask]*Optab
// isextern reports whether s describes an external symbol that must avoid pc-relative addressing. // isextern reports whether s describes an external symbol that must avoid pc-relative addressing.
// This happens on systems like Solaris that call .so functions instead of system calls. // This happens on systems like Solaris that call .so functions instead of system calls.
...@@ -1708,10 +1708,10 @@ func instinit() { ...@@ -1708,10 +1708,10 @@ func instinit() {
for i := 1; optab[i].as != 0; i++ { for i := 1; optab[i].as != 0; i++ {
c = int(optab[i].as) c = int(optab[i].as)
if opindex[c] != nil { if opindex[c&obj.AMask] != nil {
log.Fatalf("phase error in optab: %d (%v)", i, Aconv(c)) log.Fatalf("phase error in optab: %d (%v)", i, obj.Aconv(c))
} }
opindex[c] = &optab[i] opindex[c&obj.AMask] = &optab[i]
} }
for i := 0; i < Ymax; i++ { for i := 0; i < Ymax; i++ {
...@@ -2758,7 +2758,7 @@ func mediaop(ctxt *obj.Link, o *Optab, op int, osize int, z int) int { ...@@ -2758,7 +2758,7 @@ func mediaop(ctxt *obj.Link, o *Optab, op int, osize int, z int) int {
func doasm(ctxt *obj.Link, p *obj.Prog) { func doasm(ctxt *obj.Link, p *obj.Prog) {
ctxt.Curp = p // TODO ctxt.Curp = p // TODO
o := opindex[p.As] o := opindex[p.As&obj.AMask]
if o == nil { if o == nil {
ctxt.Diag("asmins: missing op %v", p) ctxt.Diag("asmins: missing op %v", p)
......
...@@ -59,21 +59,21 @@ func Pconv(p *obj.Prog) string { ...@@ -59,21 +59,21 @@ func Pconv(p *obj.Prog) string {
switch p.As { switch p.As {
case obj.ADATA: case obj.ADATA:
str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v",
p.Pc, p.Line(), Aconv(int(p.As)), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(int(p.As)), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To))
case obj.ATEXT: case obj.ATEXT:
if p.From3.Offset != 0 { if p.From3.Offset != 0 {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v",
p.Pc, p.Line(), Aconv(int(p.As)), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(int(p.As)), obj.Dconv(p, &p.From), p.From3.Offset, obj.Dconv(p, &p.To))
break break
} }
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v",
p.Pc, p.Line(), Aconv(int(p.As)), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(int(p.As)), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To))
default: default:
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v",
p.Pc, p.Line(), Aconv(int(p.As)), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To)) p.Pc, p.Line(), obj.Aconv(int(p.As)), obj.Dconv(p, &p.From), obj.Dconv(p, &p.To))
// TODO(rsc): This special case is for SHRQ $32, AX:DX, which encodes as // TODO(rsc): This special case is for SHRQ $32, AX:DX, which encodes as
// SHRQ $32(DX*0), AX // SHRQ $32(DX*0), AX
...@@ -88,10 +88,6 @@ func Pconv(p *obj.Prog) string { ...@@ -88,10 +88,6 @@ func Pconv(p *obj.Prog) string {
return fp return fp
} }
func Aconv(i int) string {
return Anames[i]
}
var Register = []string{ var Register = []string{
"AL", /* [D_AL] */ "AL", /* [D_AL] */
"CL", "CL",
...@@ -210,6 +206,7 @@ var Register = []string{ ...@@ -210,6 +206,7 @@ var Register = []string{
func init() { func init() {
obj.RegisterRegister(REG_AL, REG_AL+len(Register), Rconv) obj.RegisterRegister(REG_AL, REG_AL+len(Register), Rconv)
obj.RegisterOpcode(obj.ABaseAMD64, Anames)
} }
func Rconv(r int) string { func Rconv(r int) string {
......
...@@ -895,7 +895,7 @@ func pushpop(a int) bool { ...@@ -895,7 +895,7 @@ func pushpop(a int) bool {
return false return false
} }
func relinv(a int) int { func relinv(a int16) int16 {
switch a { switch a {
case AJEQ: case AJEQ:
return AJNE return AJNE
...@@ -931,7 +931,7 @@ func relinv(a int) int { ...@@ -931,7 +931,7 @@ func relinv(a int) int {
return AJOS return AJOS
} }
log.Fatalf("unknown relation: %s", Anames[a]) log.Fatalf("unknown relation: %s", obj.Aconv(int(a)))
return 0 return 0
} }
...@@ -1001,7 +1001,7 @@ loop: ...@@ -1001,7 +1001,7 @@ loop:
continue continue
} }
q.As = int16(relinv(int(q.As))) q.As = relinv(q.As)
p = q.Pcond p = q.Pcond
q.Pcond = q.Link q.Pcond = q.Link
q.Link = p q.Link = p
...@@ -1054,7 +1054,7 @@ loop: ...@@ -1054,7 +1054,7 @@ loop:
* expect conditional jump to be taken. * expect conditional jump to be taken.
* rewrite so that's the fall-through case. * rewrite so that's the fall-through case.
*/ */
p.As = int16(relinv(a)) p.As = relinv(int16(a))
q = p.Link q = p.Link
p.Link = p.Pcond p.Link = p.Pcond
...@@ -1064,7 +1064,7 @@ loop: ...@@ -1064,7 +1064,7 @@ loop:
q = p.Link q = p.Link
if q.Mark != 0 { if q.Mark != 0 {
if a != ALOOP { if a != ALOOP {
p.As = int16(relinv(a)) p.As = relinv(int16(a))
p.Link = p.Pcond p.Link = p.Pcond
p.Pcond = q p.Pcond = q
} }
......
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