mirror of
https://github.com/golang/go
synced 2024-11-18 04:34:52 -07:00
cmd/internal/obj: clean up checkaddr
Coalesce identical cases. Give it a proper doc comment. Fix comment locations. Update/delete old comments. Passes toolstash-check -all. Change-Id: I88d9cf20e6e04b0c1c6583e92cd96335831f183f Reviewed-on: https://go-review.googlesource.com/38442 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
3394633db0
commit
33266df861
@ -49,31 +49,23 @@ func brloop(ctxt *Link, p *Prog) *Prog {
|
|||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkaddr checks that a has an expected encoding, especially TYPE_CONST vs TYPE_ADDR.
|
||||||
func checkaddr(ctxt *Link, p *Prog, a *Addr) {
|
func checkaddr(ctxt *Link, p *Prog, a *Addr) {
|
||||||
// Check expected encoding, especially TYPE_CONST vs TYPE_ADDR.
|
|
||||||
switch a.Type {
|
switch a.Type {
|
||||||
case TYPE_NONE:
|
case TYPE_NONE, TYPE_REGREG2, TYPE_REGLIST:
|
||||||
return
|
return
|
||||||
|
|
||||||
case TYPE_BRANCH:
|
case TYPE_BRANCH, TYPE_TEXTSIZE:
|
||||||
if a.Reg != 0 || a.Index != 0 || a.Scale != 0 || a.Name != 0 {
|
if a.Reg != 0 || a.Index != 0 || a.Scale != 0 || a.Name != 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
case TYPE_TEXTSIZE:
|
|
||||||
if a.Reg != 0 || a.Index != 0 || a.Scale != 0 || a.Name != 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return
|
|
||||||
|
|
||||||
//if(a->u.bits != 0)
|
|
||||||
// break;
|
|
||||||
case TYPE_MEM:
|
case TYPE_MEM:
|
||||||
return
|
return
|
||||||
|
|
||||||
// TODO(rsc): After fixing SHRQ, check a->index != 0 too.
|
|
||||||
case TYPE_CONST:
|
case TYPE_CONST:
|
||||||
|
// TODO(rsc): After fixing SHRQ, check a.Index != 0 too.
|
||||||
if a.Name != 0 || a.Sym != nil || a.Reg != 0 {
|
if a.Name != 0 || a.Sym != nil || a.Reg != 0 {
|
||||||
ctxt.Diag("argument is TYPE_CONST, should be TYPE_ADDR, in %v", p)
|
ctxt.Diag("argument is TYPE_CONST, should be TYPE_ADDR, in %v", p)
|
||||||
return
|
return
|
||||||
@ -90,9 +82,9 @@ func checkaddr(ctxt *Link, p *Prog, a *Addr) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
// TODO(rsc): After fixing PINSRQ, check a->offset != 0 too.
|
|
||||||
// TODO(rsc): After fixing SHRQ, check a->index != 0 too.
|
|
||||||
case TYPE_REG:
|
case TYPE_REG:
|
||||||
|
// TODO(rsc): After fixing PINSRQ, check a.Offset != 0 too.
|
||||||
|
// TODO(rsc): After fixing SHRQ, check a.Index != 0 too.
|
||||||
if a.Scale != 0 || a.Name != 0 || a.Sym != nil {
|
if a.Scale != 0 || a.Name != 0 || a.Sym != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -107,27 +99,15 @@ func checkaddr(ctxt *Link, p *Prog, a *Addr) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
case TYPE_SHIFT:
|
case TYPE_SHIFT, TYPE_REGREG:
|
||||||
if a.Index != 0 || a.Scale != 0 || a.Name != 0 || a.Sym != nil || a.Val != nil {
|
if a.Index != 0 || a.Scale != 0 || a.Name != 0 || a.Sym != nil || a.Val != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
case TYPE_REGREG:
|
|
||||||
if a.Index != 0 || a.Scale != 0 || a.Name != 0 || a.Sym != nil || a.Val != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return
|
|
||||||
|
|
||||||
case TYPE_REGREG2:
|
|
||||||
return
|
|
||||||
|
|
||||||
case TYPE_REGLIST:
|
|
||||||
return
|
|
||||||
|
|
||||||
// Expect sym and name to be set, nothing else.
|
|
||||||
// Technically more is allowed, but this is only used for *name(SB).
|
|
||||||
case TYPE_INDIR:
|
case TYPE_INDIR:
|
||||||
|
// Expect sym and name to be set, nothing else.
|
||||||
|
// Technically more is allowed, but this is only used for *name(SB).
|
||||||
if a.Reg != 0 || a.Index != 0 || a.Scale != 0 || a.Name == 0 || a.Offset != 0 || a.Sym == nil || a.Val != nil {
|
if a.Reg != 0 || a.Index != 0 || a.Scale != 0 || a.Name == 0 || a.Offset != 0 || a.Sym == nil || a.Val != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user