Commit ccc337d8 authored by Ben Shi's avatar Ben Shi

cmd/compile: combine similar code in amd64's assembly generator

BSFQ/BSRQ/BSFL/BSRL/SQRTSD have similar logic in amd64's assembly
generator. This CL combines them together while does not impact
generated amd64 code. The total size of
pkg/linux_amd64/cmd/compile/internal decreases about 1.8KB.

Change-Id: I5f3210c5178c20ac9108877c69f17234baf5b6b7
Reviewed-on: https://go-review.googlesource.com/c/140438
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarKeith Randall <khr@golang.org>
parent 39333025
...@@ -782,14 +782,14 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { ...@@ -782,14 +782,14 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
// Break false dependency on destination register. // Break false dependency on destination register.
opregreg(s, x86.AXORPS, r, r) opregreg(s, x86.AXORPS, r, r)
opregreg(s, v.Op.Asm(), r, v.Args[0].Reg()) opregreg(s, v.Op.Asm(), r, v.Args[0].Reg())
case ssa.OpAMD64MOVQi2f, ssa.OpAMD64MOVQf2i: case ssa.OpAMD64MOVQi2f, ssa.OpAMD64MOVQf2i, ssa.OpAMD64MOVLi2f, ssa.OpAMD64MOVLf2i:
p := s.Prog(x86.AMOVQ) var p *obj.Prog
p.From.Type = obj.TYPE_REG switch v.Op {
p.From.Reg = v.Args[0].Reg() case ssa.OpAMD64MOVQi2f, ssa.OpAMD64MOVQf2i:
p.To.Type = obj.TYPE_REG p = s.Prog(x86.AMOVQ)
p.To.Reg = v.Reg() case ssa.OpAMD64MOVLi2f, ssa.OpAMD64MOVLf2i:
case ssa.OpAMD64MOVLi2f, ssa.OpAMD64MOVLf2i: p = s.Prog(x86.AMOVL)
p := s.Prog(x86.AMOVL) }
p.From.Type = obj.TYPE_REG p.From.Type = obj.TYPE_REG
p.From.Reg = v.Args[0].Reg() p.From.Reg = v.Args[0].Reg()
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
...@@ -934,24 +934,17 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { ...@@ -934,24 +934,17 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := s.Prog(v.Op.Asm()) p := s.Prog(v.Op.Asm())
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
p.To.Reg = r p.To.Reg = r
case ssa.OpAMD64BSFQ, ssa.OpAMD64BSRQ: case ssa.OpAMD64BSFQ, ssa.OpAMD64BSRQ, ssa.OpAMD64BSFL, ssa.OpAMD64BSRL, ssa.OpAMD64SQRTSD:
p := s.Prog(v.Op.Asm()) p := s.Prog(v.Op.Asm())
p.From.Type = obj.TYPE_REG p.From.Type = obj.TYPE_REG
p.From.Reg = v.Args[0].Reg() p.From.Reg = v.Args[0].Reg()
p.To.Type = obj.TYPE_REG p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg0() switch v.Op {
case ssa.OpAMD64BSFL, ssa.OpAMD64BSRL: case ssa.OpAMD64BSFQ, ssa.OpAMD64BSRQ:
p := s.Prog(v.Op.Asm()) p.To.Reg = v.Reg0()
p.From.Type = obj.TYPE_REG case ssa.OpAMD64BSFL, ssa.OpAMD64BSRL, ssa.OpAMD64SQRTSD:
p.From.Reg = v.Args[0].Reg() p.To.Reg = v.Reg()
p.To.Type = obj.TYPE_REG }
p.To.Reg = v.Reg()
case ssa.OpAMD64SQRTSD:
p := s.Prog(v.Op.Asm())
p.From.Type = obj.TYPE_REG
p.From.Reg = v.Args[0].Reg()
p.To.Type = obj.TYPE_REG
p.To.Reg = v.Reg()
case ssa.OpAMD64ROUNDSD: case ssa.OpAMD64ROUNDSD:
p := s.Prog(v.Op.Asm()) p := s.Prog(v.Op.Asm())
val := v.AuxInt val := v.AuxInt
......
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