mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: clarify unsigned interpretation of AuxInt
The way Value.AuxInt represents unsigned numbers is currently documented in genericOps.go, which is not the most obvious place for it. Move that documentation to Value.AuxInt. Furthermore, to make it harder to use incorrectly, introduce a Value.AuxUnsigned accessor that returns the zero-extended value of Value.AuxInt. Change-Id: I85030c3c68761404058a430e0b1c7464591b2f42 Reviewed-on: https://go-review.googlesource.com/102597 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
a29e25b82c
commit
2d8181e7b5
3 changed files with 25 additions and 14 deletions
|
|
@ -234,7 +234,6 @@ func (ft *factsTable) update(parent *Block, v, w *Value, d domain, r relation) {
|
|||
r = reverseBits[r]
|
||||
}
|
||||
if v != nil && w.isGenericIntConst() {
|
||||
c := w.AuxInt
|
||||
// Note: all the +1/-1 below could overflow/underflow. Either will
|
||||
// still generate correct results, it will just lead to imprecision.
|
||||
// In fact if there is overflow/underflow, the corresponding
|
||||
|
|
@ -247,6 +246,7 @@ func (ft *factsTable) update(parent *Block, v, w *Value, d domain, r relation) {
|
|||
lim := noLimit
|
||||
switch d {
|
||||
case signed:
|
||||
c := w.AuxInt
|
||||
switch r {
|
||||
case lt:
|
||||
lim.max = c - 1
|
||||
|
|
@ -279,17 +279,7 @@ func (ft *factsTable) update(parent *Block, v, w *Value, d domain, r relation) {
|
|||
lim.umax = uint64(lim.max)
|
||||
}
|
||||
case unsigned:
|
||||
var uc uint64
|
||||
switch w.Op {
|
||||
case OpConst64:
|
||||
uc = uint64(c)
|
||||
case OpConst32:
|
||||
uc = uint64(uint32(c))
|
||||
case OpConst16:
|
||||
uc = uint64(uint16(c))
|
||||
case OpConst8:
|
||||
uc = uint64(uint8(c))
|
||||
}
|
||||
uc := w.AuxUnsigned()
|
||||
switch r {
|
||||
case lt:
|
||||
lim.umax = uc - 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue