1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:54:57 -07:00

cmd/internal/obj: remove Addr.Etype and Addr.Width

Since the legacy backends were removed, these fields are write-only.

Change-Id: I4816c39267b7c10a4da2a6d22cd367dc475e564d
Reviewed-on: https://go-review.googlesource.com/29246
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
This commit is contained in:
Matthew Dempsky 2016-09-15 19:00:05 -07:00
parent 073d248bf5
commit 1bd91d4ccc
4 changed files with 2 additions and 44 deletions

View File

@ -32,7 +32,6 @@ package gc
import (
"cmd/internal/obj"
"cmd/internal/sys"
"fmt"
)
@ -246,8 +245,6 @@ func Naddr(a *obj.Addr, n *Node) {
// hopes innocuous) type mismatches.
// The type mismatches should be fixed and the clearing below removed.
dowidth(n.Type)
a.Width = n.Type.Width
}
switch n.Op {
@ -261,9 +258,6 @@ func Naddr(a *obj.Addr, n *Node) {
a.Type = obj.TYPE_REG
a.Reg = n.Reg
a.Sym = nil
if Thearch.LinkArch.Family == sys.I386 { // TODO(rsc): Never clear a->width.
a.Width = 0
}
case OINDREG:
a.Type = obj.TYPE_MEM
@ -273,9 +267,6 @@ func Naddr(a *obj.Addr, n *Node) {
if a.Offset != int64(int32(a.Offset)) {
yyerror("offset %d too large for OINDREG", a.Offset)
}
if Thearch.LinkArch.Family == sys.I386 { // TODO(rsc): Never clear a->width.
a.Width = 0
}
case OCLOSUREVAR:
if !Curfn.Func.Needctxt {
@ -291,10 +282,6 @@ func Naddr(a *obj.Addr, n *Node) {
a.Sym = Linksym(n.Left.Sym)
case ONAME:
a.Etype = 0
if n.Type != nil {
a.Etype = uint8(simtype[n.Type.Etype])
}
a.Offset = n.Xoffset
s := n.Sym
a.Node = n.Orig
@ -325,7 +312,6 @@ func Naddr(a *obj.Addr, n *Node) {
case PFUNC:
a.Name = obj.NAME_EXTERN
a.Type = obj.TYPE_ADDR
a.Width = int64(Widthptr)
s = funcsym(s)
}
@ -343,9 +329,6 @@ func Naddr(a *obj.Addr, n *Node) {
Naddr(a, n.Left)
case OLITERAL:
if Thearch.LinkArch.Family == sys.I386 {
a.Width = 0
}
switch u := n.Val().U.(type) {
default:
Fatalf("naddr: const %L", n.Type)
@ -375,10 +358,6 @@ func Naddr(a *obj.Addr, n *Node) {
case OADDR:
Naddr(a, n.Left)
a.Etype = uint8(Tptr)
if !Thearch.LinkArch.InFamily(sys.MIPS64, sys.ARM, sys.ARM64, sys.PPC64, sys.S390X) { // TODO(rsc): Do this even for these architectures.
a.Width = int64(Widthptr)
}
if a.Type != obj.TYPE_MEM {
a := a // copy to let escape into Ctxt.Dconv
Fatalf("naddr: OADDR %v (from %v)", Ctxt.Dconv(a), n.Left.Op)
@ -391,8 +370,6 @@ func Naddr(a *obj.Addr, n *Node) {
if a.Type == obj.TYPE_CONST && a.Offset == 0 {
break // itab(nil)
}
a.Etype = uint8(Tptr)
a.Width = int64(Widthptr)
case OIDATA:
// idata of interface value
@ -400,13 +377,7 @@ func Naddr(a *obj.Addr, n *Node) {
if a.Type == obj.TYPE_CONST && a.Offset == 0 {
break // idata(nil)
}
if isdirectiface(n.Type) {
a.Etype = uint8(simtype[n.Type.Etype])
} else {
a.Etype = uint8(Tptr)
}
a.Offset += int64(Widthptr)
a.Width = int64(Widthptr)
// pointer in a string or slice
case OSPTR:
@ -415,9 +386,7 @@ func Naddr(a *obj.Addr, n *Node) {
if a.Type == obj.TYPE_CONST && a.Offset == 0 {
break // ptr(nil)
}
a.Etype = uint8(simtype[Tptr])
a.Offset += int64(array_array)
a.Width = int64(Widthptr)
// len of string or slice
case OLEN:
@ -426,11 +395,7 @@ func Naddr(a *obj.Addr, n *Node) {
if a.Type == obj.TYPE_CONST && a.Offset == 0 {
break // len(nil)
}
a.Etype = uint8(simtype[TUINT])
a.Offset += int64(array_nel)
if Thearch.LinkArch.Family != sys.ARM { // TODO(rsc): Do this even on arm.
a.Width = int64(Widthint)
}
// cap of string or slice
case OCAP:
@ -439,11 +404,7 @@ func Naddr(a *obj.Addr, n *Node) {
if a.Type == obj.TYPE_CONST && a.Offset == 0 {
break // cap(nil)
}
a.Etype = uint8(simtype[TUINT])
a.Offset += int64(array_cap)
if Thearch.LinkArch.Family != sys.ARM { // TODO(rsc): Do this even on arm.
a.Width = int64(Widthint)
}
}
}

View File

@ -355,7 +355,6 @@ func datagostring(sval string, a *obj.Addr) {
a.Name = obj.NAME_EXTERN
a.Sym = symhdr
a.Offset = 0
a.Etype = uint8(TSTRING)
}
func dsname(s *Sym, off int, t string) int {

View File

@ -158,9 +158,7 @@ type Addr struct {
Type AddrType
Name int8
Class int8
Etype uint8
Offset int64
Width int64
Sym *LSym
Gotype *LSym

View File

@ -22,9 +22,9 @@ func TestSizeof(t *testing.T) {
_32bit uintptr // size on 32bit platforms
_64bit uintptr // size on 64bit platforms
}{
{Addr{}, 52, 80},
{Addr{}, 44, 72},
{LSym{}, 80, 136},
{Prog{}, 196, 288},
{Prog{}, 180, 272},
}
for _, tt := range tests {