Commit 514018c0 authored by quasilyte's avatar quasilyte Committed by Brad Fitzpatrick

cmd/internal/obj/x86: ifelse->switch, named const for cap=6

Part of the x86 asm backend cleanup. Passes toolstash-check.

Change-Id: Ib9766689fb7edb07f5553868cf89175501ea1e1b
Reviewed-on: https://go-review.googlesource.com/107055Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
parent 21fa1481
...@@ -2684,8 +2684,6 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int { ...@@ -2684,8 +2684,6 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
} }
fallthrough fallthrough
// fall through
case obj.TYPE_CONST: case obj.TYPE_CONST:
if a.Sym != nil { if a.Sym != nil {
ctxt.Diag("TYPE_CONST with symbol: %v", obj.Dconv(p, a)) ctxt.Diag("TYPE_CONST with symbol: %v", obj.Dconv(p, a))
...@@ -2695,22 +2693,18 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int { ...@@ -2695,22 +2693,18 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
if ctxt.Arch.Family == sys.I386 { if ctxt.Arch.Family == sys.I386 {
v = int64(int32(v)) v = int64(int32(v))
} }
if v == 0 { switch {
case v == 0:
return Yi0 return Yi0
} case v == 1:
if v == 1 {
return Yi1 return Yi1
} case v >= 0 && v <= 3:
if v >= 0 && v <= 3 {
return Yu2 return Yu2
} case v >= 0 && v <= 127:
if v >= 0 && v <= 127 {
return Yu7 return Yu7
} case v >= 0 && v <= 255:
if v >= 0 && v <= 255 {
return Yu8 return Yu8
} case v >= -128 && v <= 127:
if v >= -128 && v <= 127 {
return Yi8 return Yi8
} }
if ctxt.Arch.Family == sys.I386 { if ctxt.Arch.Family == sys.I386 {
...@@ -3776,12 +3770,10 @@ func (ab *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) { ...@@ -3776,12 +3770,10 @@ func (ab *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
return return
} }
pre := prefixof(ctxt, &p.From) if pre := prefixof(ctxt, &p.From); pre != 0 {
if pre != 0 {
ab.Put1(byte(pre)) ab.Put1(byte(pre))
} }
pre = prefixof(ctxt, &p.To) if pre := prefixof(ctxt, &p.To); pre != 0 {
if pre != 0 {
ab.Put1(byte(pre)) ab.Put1(byte(pre))
} }
...@@ -3822,7 +3814,7 @@ func (ab *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) { ...@@ -3822,7 +3814,7 @@ func (ab *AsmBuf) doasm(ctxt *obj.Link, cursym *obj.LSym, p *obj.Prog) {
var rel obj.Reloc var rel obj.Reloc
var v int64 var v int64
args := make([]int, 0, 6) args := make([]int, 0, argListMax)
if ft != Ynone*Ymax { if ft != Ynone*Ymax {
args = append(args, ft) args = append(args, ft)
} }
......
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
package x86 package x86
type argList [6]uint8 // argListMax specifies upper arg count limit expected to be carried by obj.Prog.
// Max len(obj.Prog.RestArgs) can be inferred from this to be 4.
const argListMax int = 6
type argList [argListMax]uint8
type ytab struct { type ytab struct {
zcase uint8 zcase uint8
......
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