mirror of
https://github.com/golang/go
synced 2024-11-19 10:14:44 -07:00
cmd/6g: make proginfo register bits constants
Also replace proginfo call with cheaper calls where only flags are needed. Change-Id: Ib6e5c12bd8752b87c0d8bcf22fa9e25e04a7941f Reviewed-on: https://go-review.googlesource.com/7630 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
00b3b40b07
commit
1fdd1d181b
@ -45,14 +45,12 @@ const (
|
|||||||
|
|
||||||
// do we need the carry bit
|
// do we need the carry bit
|
||||||
func needc(p *obj.Prog) bool {
|
func needc(p *obj.Prog) bool {
|
||||||
var info gc.ProgInfo
|
|
||||||
|
|
||||||
for p != nil {
|
for p != nil {
|
||||||
info = proginfo(p)
|
flags := progcarryflags(p)
|
||||||
if info.Flags&gc.UseCarry != 0 {
|
if flags&gc.UseCarry != 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if info.Flags&(gc.SetCarry|gc.KillCarry) != 0 {
|
if flags&(gc.SetCarry|gc.KillCarry) != 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
p = p.Link
|
p = p.Link
|
||||||
@ -508,15 +506,12 @@ func regconsttyp(a *obj.Addr) bool {
|
|||||||
|
|
||||||
// is reg guaranteed to be truncated by a previous L instruction?
|
// is reg guaranteed to be truncated by a previous L instruction?
|
||||||
func prevl(r0 *gc.Flow, reg int) bool {
|
func prevl(r0 *gc.Flow, reg int) bool {
|
||||||
var p *obj.Prog
|
|
||||||
var info gc.ProgInfo
|
|
||||||
|
|
||||||
for r := (*gc.Flow)(gc.Uniqp(r0)); r != nil; r = gc.Uniqp(r) {
|
for r := (*gc.Flow)(gc.Uniqp(r0)); r != nil; r = gc.Uniqp(r) {
|
||||||
p = r.Prog
|
p := r.Prog
|
||||||
if p.To.Type == obj.TYPE_REG && int(p.To.Reg) == reg {
|
if p.To.Type == obj.TYPE_REG && int(p.To.Reg) == reg {
|
||||||
info = proginfo(p)
|
flags := progflags(p)
|
||||||
if info.Flags&gc.RightWrite != 0 {
|
if flags&gc.RightWrite != 0 {
|
||||||
if info.Flags&gc.SizeL != 0 {
|
if flags&gc.SizeL != 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -10,13 +10,7 @@ import (
|
|||||||
"cmd/internal/obj/x86"
|
"cmd/internal/obj/x86"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
const (
|
||||||
AX = RtoB(x86.REG_AX)
|
|
||||||
BX = RtoB(x86.REG_BX)
|
|
||||||
CX = RtoB(x86.REG_CX)
|
|
||||||
DX = RtoB(x86.REG_DX)
|
|
||||||
DI = RtoB(x86.REG_DI)
|
|
||||||
SI = RtoB(x86.REG_SI)
|
|
||||||
LeftRdwr uint32 = gc.LeftRead | gc.LeftWrite
|
LeftRdwr uint32 = gc.LeftRead | gc.LeftWrite
|
||||||
RightRdwr uint32 = gc.RightRead | gc.RightWrite
|
RightRdwr uint32 = gc.RightRead | gc.RightWrite
|
||||||
)
|
)
|
||||||
@ -237,6 +231,18 @@ var progtable = [x86.ALAST]gc.ProgInfo{
|
|||||||
x86.AXORW: gc.ProgInfo{gc.SizeW | gc.LeftRead | RightRdwr | gc.SetCarry, 0, 0, 0},
|
x86.AXORW: gc.ProgInfo{gc.SizeW | gc.LeftRead | RightRdwr | gc.SetCarry, 0, 0, 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func progflags(p *obj.Prog) uint32 {
|
||||||
|
flags := progtable[p.As].Flags
|
||||||
|
if flags&gc.ImulAXDX != 0 && p.To.Type != obj.TYPE_NONE {
|
||||||
|
flags |= RightRdwr
|
||||||
|
}
|
||||||
|
return flags
|
||||||
|
}
|
||||||
|
|
||||||
|
func progcarryflags(p *obj.Prog) uint32 {
|
||||||
|
return progtable[p.As].Flags
|
||||||
|
}
|
||||||
|
|
||||||
func proginfo(p *obj.Prog) (info gc.ProgInfo) {
|
func proginfo(p *obj.Prog) (info gc.ProgInfo) {
|
||||||
info = progtable[p.As]
|
info = progtable[p.As]
|
||||||
if info.Flags == 0 {
|
if info.Flags == 0 {
|
||||||
|
@ -98,6 +98,16 @@ func doregbits(r int) uint64 {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For ProgInfo.
|
||||||
|
const (
|
||||||
|
AX = 1 << (x86.REG_AX - x86.REG_AX)
|
||||||
|
BX = 1 << (x86.REG_BX - x86.REG_AX)
|
||||||
|
CX = 1 << (x86.REG_CX - x86.REG_AX)
|
||||||
|
DX = 1 << (x86.REG_DX - x86.REG_AX)
|
||||||
|
DI = 1 << (x86.REG_DI - x86.REG_AX)
|
||||||
|
SI = 1 << (x86.REG_SI - x86.REG_AX)
|
||||||
|
)
|
||||||
|
|
||||||
func RtoB(r int) uint64 {
|
func RtoB(r int) uint64 {
|
||||||
if r < x86.REG_AX || r > x86.REG_R15 {
|
if r < x86.REG_AX || r > x86.REG_R15 {
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user