mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: clean up ValAndOff funcs after untyped aux removal
Changes:
- makeValAndOff is deleted in favour of MakeValAndOff{32,64}
- canAdd is renamed to canAdd64 to uniform with existing canAdd32
- addOffset{32,64} is simplified by directly using MakeValAndOff{32,64}
- ValAndOff.Int64 is removed
Change-Id: Ic01db7fa31ddfe0aaaf1d1d77af823d48a7bee84
Reviewed-on: https://go-review.googlesource.com/c/go/+/265357
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
This commit is contained in:
parent
79a3482d9e
commit
d68c01fa1d
2 changed files with 12 additions and 32 deletions
|
|
@ -59,22 +59,22 @@ func addressingModes(f *Func) {
|
|||
v.AuxInt += p.AuxInt
|
||||
case [2]auxType{auxSymValAndOff, auxInt32}:
|
||||
vo := ValAndOff(v.AuxInt)
|
||||
if !vo.canAdd(p.AuxInt) {
|
||||
if !vo.canAdd64(p.AuxInt) {
|
||||
continue
|
||||
}
|
||||
v.AuxInt = vo.add(p.AuxInt)
|
||||
v.AuxInt = int64(vo.addOffset64(p.AuxInt))
|
||||
case [2]auxType{auxSymValAndOff, auxSymOff}:
|
||||
vo := ValAndOff(v.AuxInt)
|
||||
if v.Aux != nil && p.Aux != nil {
|
||||
continue
|
||||
}
|
||||
if !vo.canAdd(p.AuxInt) {
|
||||
if !vo.canAdd64(p.AuxInt) {
|
||||
continue
|
||||
}
|
||||
if p.Aux != nil {
|
||||
v.Aux = p.Aux
|
||||
}
|
||||
v.AuxInt = vo.add(p.AuxInt)
|
||||
v.AuxInt = int64(vo.addOffset64(p.AuxInt))
|
||||
case [2]auxType{auxSymOff, auxNone}:
|
||||
// nothing to do
|
||||
case [2]auxType{auxSymValAndOff, auxNone}:
|
||||
|
|
|
|||
|
|
@ -266,9 +266,6 @@ func (x ValAndOff) Val8() int8 { return int8(int64(x) >> 32) }
|
|||
func (x ValAndOff) Off() int64 { return int64(int32(x)) }
|
||||
func (x ValAndOff) Off32() int32 { return int32(x) }
|
||||
|
||||
func (x ValAndOff) Int64() int64 {
|
||||
return int64(x)
|
||||
}
|
||||
func (x ValAndOff) String() string {
|
||||
return fmt.Sprintf("val=%d,off=%d", x.Val(), x.Off())
|
||||
}
|
||||
|
|
@ -297,17 +294,9 @@ func validValAndOff(val, off int64) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// makeValAndOff encodes a ValAndOff into an int64 suitable for storing in an AuxInt field.
|
||||
func makeValAndOff(val, off int64) int64 {
|
||||
if !validValAndOff(val, off) {
|
||||
panic("invalid makeValAndOff")
|
||||
}
|
||||
return ValAndOff(val<<32 + int64(uint32(off))).Int64()
|
||||
}
|
||||
func makeValAndOff32(val, off int32) ValAndOff {
|
||||
return ValAndOff(int64(val)<<32 + int64(uint32(off)))
|
||||
}
|
||||
|
||||
func makeValAndOff64(val, off int64) ValAndOff {
|
||||
if !validValAndOff(val, off) {
|
||||
panic("invalid makeValAndOff64")
|
||||
|
|
@ -315,35 +304,26 @@ func makeValAndOff64(val, off int64) ValAndOff {
|
|||
return ValAndOff(val<<32 + int64(uint32(off)))
|
||||
}
|
||||
|
||||
func (x ValAndOff) canAdd(off int64) bool {
|
||||
newoff := x.Off() + off
|
||||
return newoff == int64(int32(newoff))
|
||||
}
|
||||
|
||||
func (x ValAndOff) canAdd32(off int32) bool {
|
||||
newoff := x.Off() + int64(off)
|
||||
return newoff == int64(int32(newoff))
|
||||
}
|
||||
|
||||
func (x ValAndOff) add(off int64) int64 {
|
||||
if !x.canAdd(off) {
|
||||
panic("invalid ValAndOff.add")
|
||||
}
|
||||
return makeValAndOff(x.Val(), x.Off()+off)
|
||||
func (x ValAndOff) canAdd64(off int64) bool {
|
||||
newoff := x.Off() + off
|
||||
return newoff == int64(int32(newoff))
|
||||
}
|
||||
|
||||
func (x ValAndOff) addOffset32(off int32) ValAndOff {
|
||||
if !x.canAdd32(off) {
|
||||
panic("invalid ValAndOff.add")
|
||||
panic("invalid ValAndOff.addOffset32")
|
||||
}
|
||||
return ValAndOff(makeValAndOff(x.Val(), x.Off()+int64(off)))
|
||||
return makeValAndOff64(x.Val(), x.Off()+int64(off))
|
||||
}
|
||||
|
||||
func (x ValAndOff) addOffset64(off int64) ValAndOff {
|
||||
if !x.canAdd(off) {
|
||||
panic("invalid ValAndOff.add")
|
||||
if !x.canAdd64(off) {
|
||||
panic("invalid ValAndOff.addOffset64")
|
||||
}
|
||||
return ValAndOff(makeValAndOff(x.Val(), x.Off()+off))
|
||||
return makeValAndOff64(x.Val(), x.Off()+off)
|
||||
}
|
||||
|
||||
// int128 is a type that stores a 128-bit constant.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue