Commit 9a033bf9 authored by Ben Shi's avatar Ben Shi

cmd/compile: optimize 386's assembly generator

The ADDconstmodify has similar logic with other constmodify like
instructions. This CL optimize them to share code via fallthrough.
And the size of pkg/linux_386/cmd/compile/internal/x86.a decreases
about 0.3KB.

Change-Id: Ibdf06228afde875e8fe8e30851b50ca2be513dd9
Reviewed-on: https://go-review.googlesource.com/136398
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 048c766e
...@@ -547,22 +547,22 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { ...@@ -547,22 +547,22 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p.To.Reg = v.Args[0].Reg() p.To.Reg = v.Args[0].Reg()
gc.AddAux(&p.To, v) gc.AddAux(&p.To, v)
case ssa.Op386ADDLconstmodify: case ssa.Op386ADDLconstmodify:
var p *obj.Prog = nil
sc := v.AuxValAndOff() sc := v.AuxValAndOff()
off := sc.Off()
val := sc.Val() val := sc.Val()
if val == 1 || val == -1 {
var p *obj.Prog
if val == 1 { if val == 1 {
p = s.Prog(x86.AINCL) p = s.Prog(x86.AINCL)
} else if val == -1 {
p = s.Prog(x86.ADECL)
} else { } else {
p = s.Prog(v.Op.Asm()) p = s.Prog(x86.ADECL)
p.From.Type = obj.TYPE_CONST
p.From.Offset = val
} }
off := sc.Off()
p.To.Type = obj.TYPE_MEM p.To.Type = obj.TYPE_MEM
p.To.Reg = v.Args[0].Reg() p.To.Reg = v.Args[0].Reg()
gc.AddAux2(&p.To, v, off) gc.AddAux2(&p.To, v, off)
break
}
fallthrough
case ssa.Op386ANDLconstmodify, ssa.Op386ORLconstmodify, ssa.Op386XORLconstmodify: case ssa.Op386ANDLconstmodify, ssa.Op386ORLconstmodify, ssa.Op386XORLconstmodify:
sc := v.AuxValAndOff() sc := v.AuxValAndOff()
off := sc.Off() off := sc.Off()
......
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