mirror of
https://github.com/golang/go
synced 2024-11-22 22:40:02 -07:00
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: Keith Randall <khr@golang.org>
This commit is contained in:
parent
048c766e66
commit
9a033bf9d3
@ -547,22 +547,22 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
|
||||
p.To.Reg = v.Args[0].Reg()
|
||||
gc.AddAux(&p.To, v)
|
||||
case ssa.Op386ADDLconstmodify:
|
||||
var p *obj.Prog = nil
|
||||
sc := v.AuxValAndOff()
|
||||
off := sc.Off()
|
||||
val := sc.Val()
|
||||
if val == 1 {
|
||||
p = s.Prog(x86.AINCL)
|
||||
} else if val == -1 {
|
||||
p = s.Prog(x86.ADECL)
|
||||
} else {
|
||||
p = s.Prog(v.Op.Asm())
|
||||
p.From.Type = obj.TYPE_CONST
|
||||
p.From.Offset = val
|
||||
if val == 1 || val == -1 {
|
||||
var p *obj.Prog
|
||||
if val == 1 {
|
||||
p = s.Prog(x86.AINCL)
|
||||
} else {
|
||||
p = s.Prog(x86.ADECL)
|
||||
}
|
||||
off := sc.Off()
|
||||
p.To.Type = obj.TYPE_MEM
|
||||
p.To.Reg = v.Args[0].Reg()
|
||||
gc.AddAux2(&p.To, v, off)
|
||||
break
|
||||
}
|
||||
p.To.Type = obj.TYPE_MEM
|
||||
p.To.Reg = v.Args[0].Reg()
|
||||
gc.AddAux2(&p.To, v, off)
|
||||
fallthrough
|
||||
case ssa.Op386ANDLconstmodify, ssa.Op386ORLconstmodify, ssa.Op386XORLconstmodify:
|
||||
sc := v.AuxValAndOff()
|
||||
off := sc.Off()
|
||||
|
Loading…
Reference in New Issue
Block a user