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:
}
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
}
......@@ -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 {
switch p.As {
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
case arm.AMOVM:
......
......@@ -615,7 +615,7 @@ func copyu(p *obj.Prog, v *obj.Addr, s *obj.Addr) int {
switch p.As {
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
case obj.ANOP, /* read p->from, write p->to */
......
......@@ -302,7 +302,7 @@ func as2variant(as int) int {
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
}
......
......@@ -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,
}
}
......@@ -314,7 +314,7 @@ func (p *Parser) asmJump(op int, cond string, a []obj.Addr) {
prog.From = a[0]
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
case 3:
if p.arch.Thechar == '9' {
......@@ -330,7 +330,7 @@ func (p *Parser) asmJump(op int, cond string, a []obj.Addr) {
}
fallthrough
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
}
switch {
......@@ -402,7 +402,7 @@ func (p *Parser) branch(jmp, target *obj.Prog) {
// asmInstruction assembles an instruction.
// MOVW R9, (R10)
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{
Ctxt: p.ctxt,
Lineno: p.histLineNum,
......@@ -451,7 +451,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
prog.To = a[1]
break
}
p.errorf("unrecognized addressing for %s", p.arch.Aconv(op))
p.errorf("unrecognized addressing for %s", obj.Aconv(op))
}
}
prog.From = a[0]
......@@ -538,7 +538,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
prog.From3 = a[1]
prog.To = a[2]
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:
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) {
prog.To = a[3]
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:
if p.arch.Thechar == '9' && arch.IsPPC64RLD(op) {
// 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) {
prog.To = a[4]
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:
// MCR and MRC on ARM
if p.arch.Thechar == '5' && arch.IsARMMRC(op) {
......@@ -631,7 +631,7 @@ func (p *Parser) asmInstruction(op int, cond string, a []obj.Addr) {
}
fallthrough
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)
......@@ -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.
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 {
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
}
......@@ -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.
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 {
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
}
......@@ -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.
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 {
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
}
......@@ -145,7 +145,7 @@ const (
)
const (
AAND = obj.A_ARCHSPECIFIC + iota
AAND = obj.ABaseARM + obj.A_ARCHSPECIFIC + iota
AEOR
ASUB
ARSB
......
package arm
import "cmd/internal/obj"
var Anames = []string{
"XXX",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"AND",
obj.A_ARCHSPECIFIC: "AND",
"EOR",
"SUB",
"RSB",
......
......@@ -39,7 +39,7 @@ import (
)
type Optab struct {
as uint8
as uint16
a1 uint8
a2 int8
a3 uint8
......@@ -268,7 +268,7 @@ var pool struct {
extra uint32
}
var oprange [ALAST]Oprang
var oprange [ALAST & obj.AMask]Oprang
var xcmp [C_GOK + 1][C_GOK + 1]uint8
......@@ -580,7 +580,7 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) {
return
}
if oprange[AAND].start == nil {
if oprange[AAND&obj.AMask].start == nil {
buildop(ctxt)
}
......@@ -1207,14 +1207,14 @@ func oplook(ctxt *obj.Link, p *obj.Prog) *Optab {
if p.Reg != 0 {
a2 = C_REG
}
r := int(p.As)
r := p.As & obj.AMask
o := oprange[r].start
if o == nil {
o = oprange[r].stop /* just generate an error */
}
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)
}
......@@ -1335,6 +1335,10 @@ func (x ocmp) Less(i, j int) bool {
return false
}
func opset(a, b0 uint16) {
oprange[a&obj.AMask] = oprange[b0]
}
func buildop(ctxt *obj.Link) {
var n int
......@@ -1356,67 +1360,66 @@ func buildop(ctxt *obj.Link) {
}
sort.Sort(ocmp(optab[:n]))
var r int
for i := 0; i < n; i++ {
r = int(optab[i].as)
oprange[r].start = optab[i:]
for int(optab[i].as) == r {
r0 := optab[i].as & obj.AMask
oprange[r0].start = optab[i:]
for optab[i].as&obj.AMask == r0 {
i++
}
oprange[r].stop = optab[i:]
oprange[r0].stop = optab[i:]
i--
switch r {
switch r0 {
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")
case AADD:
oprange[AAND] = oprange[r]
oprange[AEOR] = oprange[r]
oprange[ASUB] = oprange[r]
oprange[ARSB] = oprange[r]
oprange[AADC] = oprange[r]
oprange[ASBC] = oprange[r]
oprange[ARSC] = oprange[r]
oprange[AORR] = oprange[r]
oprange[ABIC] = oprange[r]
opset(AAND, r0)
opset(AEOR, r0)
opset(ASUB, r0)
opset(ARSB, r0)
opset(AADC, r0)
opset(ASBC, r0)
opset(ARSC, r0)
opset(AORR, r0)
opset(ABIC, r0)
case ACMP:
oprange[ATEQ] = oprange[r]
oprange[ACMN] = oprange[r]
opset(ATEQ, r0)
opset(ACMN, r0)
case AMVN:
break
case ABEQ:
oprange[ABNE] = oprange[r]
oprange[ABCS] = oprange[r]
oprange[ABHS] = oprange[r]
oprange[ABCC] = oprange[r]
oprange[ABLO] = oprange[r]
oprange[ABMI] = oprange[r]
oprange[ABPL] = oprange[r]
oprange[ABVS] = oprange[r]
oprange[ABVC] = oprange[r]
oprange[ABHI] = oprange[r]
oprange[ABLS] = oprange[r]
oprange[ABGE] = oprange[r]
oprange[ABLT] = oprange[r]
oprange[ABGT] = oprange[r]
oprange[ABLE] = oprange[r]
opset(ABNE, r0)
opset(ABCS, r0)
opset(ABHS, r0)
opset(ABCC, r0)
opset(ABLO, r0)
opset(ABMI, r0)
opset(ABPL, r0)
opset(ABVS, r0)
opset(ABVC, r0)
opset(ABHI, r0)
opset(ABLS, r0)
opset(ABGE, r0)
opset(ABLT, r0)
opset(ABGT, r0)
opset(ABLE, r0)
case ASLL:
oprange[ASRL] = oprange[r]
oprange[ASRA] = oprange[r]
opset(ASRL, r0)
opset(ASRA, r0)
case AMUL:
oprange[AMULU] = oprange[r]
opset(AMULU, r0)
case ADIV:
oprange[AMOD] = oprange[r]
oprange[AMODU] = oprange[r]
oprange[ADIVU] = oprange[r]
opset(AMOD, r0)
opset(AMODU, r0)
opset(ADIVU, r0)
case AMOVW,
AMOVB,
......@@ -1428,7 +1431,7 @@ func buildop(ctxt *obj.Link) {
break
case ASWPW:
oprange[ASWPBU] = oprange[r]
opset(ASWPBU, r0)
case AB,
ABL,
......@@ -1448,42 +1451,42 @@ func buildop(ctxt *obj.Link) {
break
case AADDF:
oprange[AADDD] = oprange[r]
oprange[ASUBF] = oprange[r]
oprange[ASUBD] = oprange[r]
oprange[AMULF] = oprange[r]
oprange[AMULD] = oprange[r]
oprange[ADIVF] = oprange[r]
oprange[ADIVD] = oprange[r]
oprange[ASQRTF] = oprange[r]
oprange[ASQRTD] = oprange[r]
oprange[AMOVFD] = oprange[r]
oprange[AMOVDF] = oprange[r]
oprange[AABSF] = oprange[r]
oprange[AABSD] = oprange[r]
opset(AADDD, r0)
opset(ASUBF, r0)
opset(ASUBD, r0)
opset(AMULF, r0)
opset(AMULD, r0)
opset(ADIVF, r0)
opset(ADIVD, r0)
opset(ASQRTF, r0)
opset(ASQRTD, r0)
opset(AMOVFD, r0)
opset(AMOVDF, r0)
opset(AABSF, r0)
opset(AABSD, r0)
case ACMPF:
oprange[ACMPD] = oprange[r]
opset(ACMPD, r0)
case AMOVF:
oprange[AMOVD] = oprange[r]
opset(AMOVD, r0)
case AMOVFW:
oprange[AMOVDW] = oprange[r]
opset(AMOVDW, r0)
case AMOVWF:
oprange[AMOVWD] = oprange[r]
opset(AMOVWD, r0)
case AMULL:
oprange[AMULAL] = oprange[r]
oprange[AMULLU] = oprange[r]
oprange[AMULALU] = oprange[r]
opset(AMULAL, r0)
opset(AMULLU, r0)
opset(AMULALU, r0)
case AMULWT:
oprange[AMULWB] = oprange[r]
opset(AMULWB, r0)
case AMULAWT:
oprange[AMULAWB] = oprange[r]
opset(AMULAWB, r0)
case AMULA,
ALDREX,
......@@ -2660,7 +2663,7 @@ func opbra(ctxt *obj.Link, a int, sc int) uint32 {
return 0xe<<28 | 0x5<<25
}
ctxt.Diag("bad bra %v", Aconv(a))
ctxt.Diag("bad bra %v", obj.Aconv(a))
prasm(ctxt.Curp)
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
switch a {
default:
ctxt.Diag("bad fst %v", Aconv(a))
ctxt.Diag("bad fst %v", obj.Aconv(a))
fallthrough
case AMOVD:
......
......@@ -79,57 +79,16 @@ func Pconv(p *obj.Prog) string {
var str string
if a == obj.ADATA {
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 {
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 {
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 {
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))
}
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 += "]"
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
......@@ -139,6 +98,7 @@ func RAconv(a *obj.Addr) string {
func init() {
obj.RegisterRegister(obj.RBaseARM, MAXREG, Rconv)
obj.RegisterOpcode(obj.ABaseARM, Anames)
}
func Rconv(r int) string {
......
......@@ -33,7 +33,7 @@ package i386
import "cmd/internal/obj"
const (
AAAA = obj.A_ARCHSPECIFIC + iota
AAAA = obj.ABase386 + obj.A_ARCHSPECIFIC + iota
AAAD
AAAM
AAAS
......
package i386
import "cmd/internal/obj"
/*
* this is the ranlib header
*/
var Anames = []string{
"XXX",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"AAA",
obj.A_ARCHSPECIFIC: "AAA",
"AAD",
"AAM",
"AAS",
......
......@@ -58,7 +58,7 @@ type ytab struct {
zoffset uint8
}
var opindex [ALAST + 1]*Optab
var opindex [(ALAST + 1) & obj.AMask]*Optab
const (
Yxxx = 0 + iota
......@@ -1331,12 +1331,11 @@ func span8(ctxt *obj.Link, s *obj.LSym) {
}
func instinit() {
var c int
for i := 1; optab[i].as != 0; i++ {
c = int(optab[i].as)
c := optab[i].as & obj.AMask
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]
}
......@@ -1969,7 +1968,7 @@ const (
var ymovtab = []uint8{
/* push */
APUSHL,
APUSHL & obj.AMask,
Ycs,
Ynone,
0,
......@@ -1977,7 +1976,7 @@ var ymovtab = []uint8{
E,
0,
0,
APUSHL,
APUSHL & obj.AMask,
Yss,
Ynone,
0,
......@@ -1985,7 +1984,7 @@ var ymovtab = []uint8{
E,
0,
0,
APUSHL,
APUSHL & obj.AMask,
Yds,
Ynone,
0,
......@@ -1993,7 +1992,7 @@ var ymovtab = []uint8{
E,
0,
0,
APUSHL,
APUSHL & obj.AMask,
Yes,
Ynone,
0,
......@@ -2001,7 +2000,7 @@ var ymovtab = []uint8{
E,
0,
0,
APUSHL,
APUSHL & obj.AMask,
Yfs,
Ynone,
0,
......@@ -2009,7 +2008,7 @@ var ymovtab = []uint8{
0xa0,
E,
0,
APUSHL,
APUSHL & obj.AMask,
Ygs,
Ynone,
0,
......@@ -2017,7 +2016,7 @@ var ymovtab = []uint8{
0xa8,
E,
0,
APUSHW,
APUSHW & obj.AMask,
Ycs,
Ynone,
0,
......@@ -2025,7 +2024,7 @@ var ymovtab = []uint8{
0x0e,
E,
0,
APUSHW,
APUSHW & obj.AMask,
Yss,
Ynone,
0,
......@@ -2033,7 +2032,7 @@ var ymovtab = []uint8{
0x16,
E,
0,
APUSHW,
APUSHW & obj.AMask,
Yds,
Ynone,
0,
......@@ -2041,7 +2040,7 @@ var ymovtab = []uint8{
0x1e,
E,
0,
APUSHW,
APUSHW & obj.AMask,
Yes,
Ynone,
0,
......@@ -2049,7 +2048,7 @@ var ymovtab = []uint8{
0x06,
E,
0,
APUSHW,
APUSHW & obj.AMask,
Yfs,
Ynone,
0,
......@@ -2057,7 +2056,7 @@ var ymovtab = []uint8{
0x0f,
0xa0,
E,
APUSHW,
APUSHW & obj.AMask,
Ygs,
Ynone,
0,
......@@ -2067,7 +2066,7 @@ var ymovtab = []uint8{
E,
/* pop */
APOPL,
APOPL & obj.AMask,
Ynone,
Yds,
0,
......@@ -2075,7 +2074,7 @@ var ymovtab = []uint8{
E,
0,
0,
APOPL,
APOPL & obj.AMask,
Ynone,
Yes,
0,
......@@ -2083,7 +2082,7 @@ var ymovtab = []uint8{
E,
0,
0,
APOPL,
APOPL & obj.AMask,
Ynone,
Yss,
0,
......@@ -2091,7 +2090,7 @@ var ymovtab = []uint8{
E,
0,
0,
APOPL,
APOPL & obj.AMask,
Ynone,
Yfs,
0,
......@@ -2099,7 +2098,7 @@ var ymovtab = []uint8{
0xa1,
E,
0,
APOPL,
APOPL & obj.AMask,
Ynone,
Ygs,
0,
......@@ -2107,7 +2106,7 @@ var ymovtab = []uint8{
0xa9,
E,
0,
APOPW,
APOPW & obj.AMask,
Ynone,
Yds,
0,
......@@ -2115,7 +2114,7 @@ var ymovtab = []uint8{
0x1f,
E,
0,
APOPW,
APOPW & obj.AMask,
Ynone,
Yes,
0,
......@@ -2123,7 +2122,7 @@ var ymovtab = []uint8{
0x07,
E,
0,
APOPW,
APOPW & obj.AMask,
Ynone,
Yss,
0,
......@@ -2131,7 +2130,7 @@ var ymovtab = []uint8{
0x17,
E,
0,
APOPW,
APOPW & obj.AMask,
Ynone,
Yfs,
0,
......@@ -2139,7 +2138,7 @@ var ymovtab = []uint8{
0x0f,
0xa1,
E,
APOPW,
APOPW & obj.AMask,
Ynone,
Ygs,
0,
......@@ -2149,7 +2148,7 @@ var ymovtab = []uint8{
E,
/* mov seg */
AMOVW,
AMOVW & obj.AMask,
Yes,
Yml,
1,
......@@ -2157,7 +2156,7 @@ var ymovtab = []uint8{
0,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Ycs,
Yml,
1,
......@@ -2165,7 +2164,7 @@ var ymovtab = []uint8{
1,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yss,
Yml,
1,
......@@ -2173,7 +2172,7 @@ var ymovtab = []uint8{
2,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yds,
Yml,
1,
......@@ -2181,7 +2180,7 @@ var ymovtab = []uint8{
3,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yfs,
Yml,
1,
......@@ -2189,7 +2188,7 @@ var ymovtab = []uint8{
4,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Ygs,
Yml,
1,
......@@ -2197,7 +2196,7 @@ var ymovtab = []uint8{
5,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yml,
Yes,
2,
......@@ -2205,7 +2204,7 @@ var ymovtab = []uint8{
0,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yml,
Ycs,
2,
......@@ -2213,7 +2212,7 @@ var ymovtab = []uint8{
1,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yml,
Yss,
2,
......@@ -2221,7 +2220,7 @@ var ymovtab = []uint8{
2,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yml,
Yds,
2,
......@@ -2229,7 +2228,7 @@ var ymovtab = []uint8{
3,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yml,
Yfs,
2,
......@@ -2237,7 +2236,7 @@ var ymovtab = []uint8{
4,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yml,
Ygs,
2,
......@@ -2247,7 +2246,7 @@ var ymovtab = []uint8{
0,
/* mov cr */
AMOVL,
AMOVL & obj.AMask,
Ycr0,
Yml,
3,
......@@ -2255,7 +2254,7 @@ var ymovtab = []uint8{
0x20,
0,
0,
AMOVL,
AMOVL & obj.AMask,
Ycr2,
Yml,
3,
......@@ -2263,7 +2262,7 @@ var ymovtab = []uint8{
0x20,
2,
0,
AMOVL,
AMOVL & obj.AMask,
Ycr3,
Yml,
3,
......@@ -2271,7 +2270,7 @@ var ymovtab = []uint8{
0x20,
3,
0,
AMOVL,
AMOVL & obj.AMask,
Ycr4,
Yml,
3,
......@@ -2279,7 +2278,7 @@ var ymovtab = []uint8{
0x20,
4,
0,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ycr0,
4,
......@@ -2287,7 +2286,7 @@ var ymovtab = []uint8{
0x22,
0,
0,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ycr2,
4,
......@@ -2295,7 +2294,7 @@ var ymovtab = []uint8{
0x22,
2,
0,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ycr3,
4,
......@@ -2303,7 +2302,7 @@ var ymovtab = []uint8{
0x22,
3,
0,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ycr4,
4,
......@@ -2313,7 +2312,7 @@ var ymovtab = []uint8{
0,
/* mov dr */
AMOVL,
AMOVL & obj.AMask,
Ydr0,
Yml,
3,
......@@ -2321,7 +2320,7 @@ var ymovtab = []uint8{
0x21,
0,
0,
AMOVL,
AMOVL & obj.AMask,
Ydr6,
Yml,
3,
......@@ -2329,7 +2328,7 @@ var ymovtab = []uint8{
0x21,
6,
0,
AMOVL,
AMOVL & obj.AMask,
Ydr7,
Yml,
3,
......@@ -2337,7 +2336,7 @@ var ymovtab = []uint8{
0x21,
7,
0,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ydr0,
4,
......@@ -2345,7 +2344,7 @@ var ymovtab = []uint8{
0x23,
0,
0,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ydr6,
4,
......@@ -2353,7 +2352,7 @@ var ymovtab = []uint8{
0x23,
6,
0,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ydr7,
4,
......@@ -2363,7 +2362,7 @@ var ymovtab = []uint8{
0,
/* mov tr */
AMOVL,
AMOVL & obj.AMask,
Ytr6,
Yml,
3,
......@@ -2371,7 +2370,7 @@ var ymovtab = []uint8{
0x24,
6,
0,
AMOVL,
AMOVL & obj.AMask,
Ytr7,
Yml,
3,
......@@ -2379,7 +2378,7 @@ var ymovtab = []uint8{
0x24,
7,
0,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ytr6,
4,
......@@ -2387,7 +2386,7 @@ var ymovtab = []uint8{
0x26,
6,
E,
AMOVL,
AMOVL & obj.AMask,
Yml,
Ytr7,
4,
......@@ -2397,7 +2396,7 @@ var ymovtab = []uint8{
E,
/* lgdt, sgdt, lidt, sidt */
AMOVL,
AMOVL & obj.AMask,
Ym,
Ygdtr,
4,
......@@ -2405,7 +2404,7 @@ var ymovtab = []uint8{
0x01,
2,
0,
AMOVL,
AMOVL & obj.AMask,
Ygdtr,
Ym,
3,
......@@ -2413,7 +2412,7 @@ var ymovtab = []uint8{
0x01,
0,
0,
AMOVL,
AMOVL & obj.AMask,
Ym,
Yidtr,
4,
......@@ -2421,7 +2420,7 @@ var ymovtab = []uint8{
0x01,
3,
0,
AMOVL,
AMOVL & obj.AMask,
Yidtr,
Ym,
3,
......@@ -2431,7 +2430,7 @@ var ymovtab = []uint8{
0,
/* lldt, sldt */
AMOVW,
AMOVW & obj.AMask,
Yml,
Yldtr,
4,
......@@ -2439,7 +2438,7 @@ var ymovtab = []uint8{
0x00,
2,
0,
AMOVW,
AMOVW & obj.AMask,
Yldtr,
Yml,
3,
......@@ -2449,7 +2448,7 @@ var ymovtab = []uint8{
0,
/* lmsw, smsw */
AMOVW,
AMOVW & obj.AMask,
Yml,
Ymsw,
4,
......@@ -2457,7 +2456,7 @@ var ymovtab = []uint8{
0x01,
6,
0,
AMOVW,
AMOVW & obj.AMask,
Ymsw,
Yml,
3,
......@@ -2467,7 +2466,7 @@ var ymovtab = []uint8{
0,
/* ltr, str */
AMOVW,
AMOVW & obj.AMask,
Yml,
Ytask,
4,
......@@ -2475,7 +2474,7 @@ var ymovtab = []uint8{
0x00,
3,
0,
AMOVW,
AMOVW & obj.AMask,
Ytask,
Yml,
3,
......@@ -2485,7 +2484,7 @@ var ymovtab = []uint8{
0,
/* load full pointer */
AMOVL,
AMOVL & obj.AMask,
Yml,
Ycol,
5,
......@@ -2493,7 +2492,7 @@ var ymovtab = []uint8{
0,
0,
0,
AMOVW,
AMOVW & obj.AMask,
Yml,
Ycol,
5,
......@@ -2503,7 +2502,7 @@ var ymovtab = []uint8{
0,
/* double shift */
ASHLL,
ASHLL & obj.AMask,
Ycol,
Yml,
6,
......@@ -2511,7 +2510,7 @@ var ymovtab = []uint8{
0xa5,
0,
0,
ASHRL,
ASHRL & obj.AMask,
Ycol,
Yml,
6,
......@@ -2521,7 +2520,7 @@ var ymovtab = []uint8{
0,
/* extra imul */
AIMULW,
AIMULW & obj.AMask,
Yml,
Yrl,
7,
......@@ -2529,7 +2528,7 @@ var ymovtab = []uint8{
0xaf,
0,
0,
AIMULL,
AIMULL & obj.AMask,
Yml,
Yrl,
7,
......@@ -2539,7 +2538,7 @@ var ymovtab = []uint8{
0,
/* load TLS base pointer */
AMOVL,
AMOVL & obj.AMask,
Ytls,
Yrl,
8,
......@@ -2712,7 +2711,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
ft := int(p.Ft) * Ymax
tt := int(p.Tt) * Ymax
o := opindex[p.As]
o := opindex[p.As&obj.AMask]
z := 0
var a *obj.Addr
......@@ -3163,7 +3162,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
domov:
var pp obj.Prog
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[tt+int(t[2])] != 0 {
switch t[3] {
......
......@@ -47,21 +47,21 @@ func Pconv(p *obj.Prog) string {
switch p.As {
case obj.ADATA:
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:
if p.From3.Offset != 0 {
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
}
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:
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
// SHRQ $32(DX*0), AX
......@@ -76,10 +76,6 @@ func Pconv(p *obj.Prog) string {
return fp
}
func Aconv(i int) string {
return Anames[i]
}
var Register = []string{
"AL", /* [REG_AL] */
"CL",
......@@ -154,6 +150,7 @@ var Register = []string{
func init() {
obj.RegisterRegister(obj.RBase386, obj.RBase386+len(Register), Rconv)
obj.RegisterOpcode(obj.ABase386, Anames)
}
func Rconv(r int) string {
......
......@@ -424,6 +424,10 @@ const (
// 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.
const (
AXXX = 0 + iota
ACALL
......@@ -570,30 +574,4 @@ const (
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
......@@ -218,7 +218,7 @@ const (
)
const (
AADD = obj.A_ARCHSPECIFIC + iota
AADD = obj.ABasePPC64 + obj.A_ARCHSPECIFIC + iota
AADDCC
AADDV
AADDVCC
......
package ppc64
/*
* this is the ranlib header
*/
import "cmd/internal/obj"
var Anames = []string{
"XXX",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"ADD",
obj.A_ARCHSPECIFIC: "ADD",
"ADDCC",
"ADDV",
"ADDVCC",
......
This diff is collapsed.
......@@ -59,14 +59,14 @@ func Pconv(p *obj.Prog) string {
str := ""
if a == obj.ADATA {
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 {
if p.From3.Offset != 0 {
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 {
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 p.Mark&NOSCHED != 0 {
......@@ -74,24 +74,24 @@ func Pconv(p *obj.Prog) string {
}
if p.Reg == 0 && p.From3.Type == obj.TYPE_NONE {
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 {
off := ""
if p.From.Offset != 0 {
off = fmt.Sprintf("%d", p.From.Offset)
}
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 {
off := ""
if p.From.Offset != 0 {
off = fmt.Sprintf("%d", p.From.Offset)
}
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 {
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 {
str += fmt.Sprintf(",%v", Rconv(int(p.Reg)))
}
......@@ -113,18 +113,9 @@ func Pconv(p *obj.Prog) string {
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() {
obj.RegisterRegister(obj.RBasePPC64, REG_DCR0+1024, Rconv)
obj.RegisterOpcode(obj.ABasePPC64, Anames)
}
func Rconv(r int) string {
......
......@@ -491,3 +491,68 @@ func regListConv(list int) string {
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"
* amd64
*/
const (
AAAA = obj.A_ARCHSPECIFIC + iota
AAAA = obj.ABaseAMD64 + obj.A_ARCHSPECIFIC + iota
AAAD
AAAM
AAAS
......
package x86
import "cmd/internal/obj"
/*
* this is the ranlib header
*/
var Anames = []string{
"XXX",
"CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"AAA",
obj.A_ARCHSPECIFIC: "AAA",
"AAD",
"AAM",
"AAS",
......
......@@ -1435,7 +1435,7 @@ var optab =
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.
// This happens on systems like Solaris that call .so functions instead of system calls.
......@@ -1708,10 +1708,10 @@ func instinit() {
for i := 1; optab[i].as != 0; i++ {
c = int(optab[i].as)
if opindex[c] != nil {
log.Fatalf("phase error in optab: %d (%v)", i, Aconv(c))
if opindex[c&obj.AMask] != nil {
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++ {
......@@ -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) {
ctxt.Curp = p // TODO
o := opindex[p.As]
o := opindex[p.As&obj.AMask]
if o == nil {
ctxt.Diag("asmins: missing op %v", p)
......
......@@ -59,21 +59,21 @@ func Pconv(p *obj.Prog) string {
switch p.As {
case obj.ADATA:
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:
if p.From3.Offset != 0 {
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
}
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:
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
// SHRQ $32(DX*0), AX
......@@ -88,10 +88,6 @@ func Pconv(p *obj.Prog) string {
return fp
}
func Aconv(i int) string {
return Anames[i]
}
var Register = []string{
"AL", /* [D_AL] */
"CL",
......@@ -210,6 +206,7 @@ var Register = []string{
func init() {
obj.RegisterRegister(REG_AL, REG_AL+len(Register), Rconv)
obj.RegisterOpcode(obj.ABaseAMD64, Anames)
}
func Rconv(r int) string {
......
......@@ -895,7 +895,7 @@ func pushpop(a int) bool {
return false
}
func relinv(a int) int {
func relinv(a int16) int16 {
switch a {
case AJEQ:
return AJNE
......@@ -931,7 +931,7 @@ func relinv(a int) int {
return AJOS
}
log.Fatalf("unknown relation: %s", Anames[a])
log.Fatalf("unknown relation: %s", obj.Aconv(int(a)))
return 0
}
......@@ -1001,7 +1001,7 @@ loop:
continue
}
q.As = int16(relinv(int(q.As)))
q.As = relinv(q.As)
p = q.Pcond
q.Pcond = q.Link
q.Link = p
......@@ -1054,7 +1054,7 @@ loop:
* expect conditional jump to be taken.
* rewrite so that's the fall-through case.
*/
p.As = int16(relinv(a))
p.As = relinv(int16(a))
q = p.Link
p.Link = p.Pcond
......@@ -1064,7 +1064,7 @@ loop:
q = p.Link
if q.Mark != 0 {
if a != ALOOP {
p.As = int16(relinv(a))
p.As = relinv(int16(a))
p.Link = p.Pcond
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