Commit cfb3c8df authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/internal/obj: eliminate Link.Asmode

Asmode is always set to p.Mode,
which is always set based on the arch family.
Instead, use the arch family directly.

Passes toolstash-check -all.

Change-Id: Id982472dcc8eeb6dd22cac5ad2f116b54a44caee
Reviewed-on: https://go-review.googlesource.com/38451
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
parent a470e5d4
...@@ -740,7 +740,6 @@ type Link struct { ...@@ -740,7 +740,6 @@ type Link struct {
Rep int Rep int
Repn int Repn int
Lock int Lock int
Asmode int
AsmBuf AsmBuf // instruction buffer for x86 AsmBuf AsmBuf // instruction buffer for x86
Instoffset int64 Instoffset int64
Autosize int32 Autosize int32
......
...@@ -2254,7 +2254,7 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int { ...@@ -2254,7 +2254,7 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
// Can't use SP as the index register // Can't use SP as the index register
return Yxxx return Yxxx
} }
if ctxt.Asmode == 64 { if ctxt.Arch.Family == sys.AMD64 {
switch a.Name { switch a.Name {
case obj.NAME_EXTERN, obj.NAME_STATIC, obj.NAME_GOTREF: case obj.NAME_EXTERN, obj.NAME_STATIC, obj.NAME_GOTREF:
// Global variables can't use index registers and their // Global variables can't use index registers and their
...@@ -2379,7 +2379,7 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int { ...@@ -2379,7 +2379,7 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
REG_R13B, REG_R13B,
REG_R14B, REG_R14B,
REG_R15B: REG_R15B:
if ctxt.Asmode != 64 { if ctxt.Arch.Family == sys.I386 {
return Yxxx return Yxxx
} }
fallthrough fallthrough
...@@ -2409,7 +2409,7 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int { ...@@ -2409,7 +2409,7 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
REG_R13, REG_R13,
REG_R14, REG_R14,
REG_R15: REG_R15:
if ctxt.Asmode != 64 { if ctxt.Arch.Family == sys.I386 {
return Yxxx return Yxxx
} }
fallthrough fallthrough
...@@ -2580,7 +2580,7 @@ func asmidx(ctxt *obj.Link, scale int, index int, base int) { ...@@ -2580,7 +2580,7 @@ func asmidx(ctxt *obj.Link, scale int, index int, base int) {
REG_R13, REG_R13,
REG_R14, REG_R14,
REG_R15: REG_R15:
if ctxt.Asmode != 64 { if ctxt.Arch.Family == sys.I386 {
goto bad goto bad
} }
fallthrough fallthrough
...@@ -2628,7 +2628,7 @@ bas: ...@@ -2628,7 +2628,7 @@ bas:
REG_R13, REG_R13,
REG_R14, REG_R14,
REG_R15: REG_R15:
if ctxt.Asmode != 64 { if ctxt.Arch.Family == sys.I386 {
goto bad goto bad
} }
fallthrough fallthrough
...@@ -4359,7 +4359,6 @@ func nacltrunc(ctxt *obj.Link, reg int) { ...@@ -4359,7 +4359,6 @@ func nacltrunc(ctxt *obj.Link, reg int) {
func asmins(ctxt *obj.Link, p *obj.Prog) { func asmins(ctxt *obj.Link, p *obj.Prog) {
ctxt.AsmBuf.Reset() ctxt.AsmBuf.Reset()
ctxt.Asmode = int(p.Mode)
if ctxt.Headtype == obj.Hnacl && p.Mode == 32 { if ctxt.Headtype == obj.Hnacl && p.Mode == 32 {
switch p.As { switch p.As {
...@@ -4462,7 +4461,6 @@ func asmins(ctxt *obj.Link, p *obj.Prog) { ...@@ -4462,7 +4461,6 @@ func asmins(ctxt *obj.Link, p *obj.Prog) {
ctxt.Rexflag = 0 ctxt.Rexflag = 0
ctxt.Vexflag = 0 ctxt.Vexflag = 0
mark := ctxt.AsmBuf.Len() mark := ctxt.AsmBuf.Len()
ctxt.Asmode = int(p.Mode)
doasm(ctxt, p) doasm(ctxt, p)
if ctxt.Rexflag != 0 && ctxt.Vexflag == 0 { if ctxt.Rexflag != 0 && ctxt.Vexflag == 0 {
/* /*
......
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