cmd: remove IntSize and Widthint

Use PtrSize and Widthptr instead. CL prepared mostly with sed and
uniq.

Passes toolstash-check -all.

Fixes #19954.

Change-Id: I09371bd7128672885cb8bc4e7f534ad56a88d755
Reviewed-on: https://go-review.googlesource.com/40506
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Matthew Dempsky 2017-04-21 18:44:34 -07:00
parent 8a07469663
commit c87520c598
16 changed files with 58 additions and 80 deletions

View file

@ -177,8 +177,6 @@ var Curfn *Node
var Widthptr int var Widthptr int
var Widthint int
var Widthreg int var Widthreg int
var nblank *Node var nblank *Node

View file

@ -364,7 +364,6 @@ func Main(archInit func(*Arch)) {
Debug['l'] = 1 - Debug['l'] Debug['l'] = 1 - Debug['l']
} }
Widthint = thearch.LinkArch.IntSize
Widthptr = thearch.LinkArch.PtrSize Widthptr = thearch.LinkArch.PtrSize
Widthreg = thearch.LinkArch.RegSize Widthreg = thearch.LinkArch.RegSize

View file

@ -405,7 +405,7 @@ func gdata(nam *Node, nr *Node, wid int) {
case string: case string:
symdata := stringsym(u) symdata := stringsym(u)
s.WriteAddr(Ctxt, nam.Xoffset, Widthptr, symdata, 0) s.WriteAddr(Ctxt, nam.Xoffset, Widthptr, symdata, 0)
s.WriteInt(Ctxt, nam.Xoffset+int64(Widthptr), Widthint, int64(len(u))) s.WriteInt(Ctxt, nam.Xoffset+int64(Widthptr), Widthptr, int64(len(u)))
default: default:
Fatalf("gdata unhandled OLITERAL %v", nr) Fatalf("gdata unhandled OLITERAL %v", nr)

View file

@ -1185,7 +1185,7 @@ ok:
} }
ot = dgopkgpath(lsym, ot, tpkg) ot = dgopkgpath(lsym, ot, tpkg)
ot = dsymptr(lsym, ot, lsym, ot+Widthptr+2*Widthint+uncommonSize(t)) ot = dsymptr(lsym, ot, lsym, ot+Widthptr+2*Widthptr+uncommonSize(t))
ot = duintptr(lsym, ot, uint64(n)) ot = duintptr(lsym, ot, uint64(n))
ot = duintptr(lsym, ot, uint64(n)) ot = duintptr(lsym, ot, uint64(n))
dataAdd := imethodSize() * n dataAdd := imethodSize() * n
@ -1277,7 +1277,7 @@ ok:
} }
} }
ot = dgopkgpath(lsym, ot, pkg) ot = dgopkgpath(lsym, ot, pkg)
ot = dsymptr(lsym, ot, lsym, ot+Widthptr+2*Widthint+uncommonSize(t)) ot = dsymptr(lsym, ot, lsym, ot+Widthptr+2*Widthptr+uncommonSize(t))
ot = duintptr(lsym, ot, uint64(n)) ot = duintptr(lsym, ot, uint64(n))
ot = duintptr(lsym, ot, uint64(n)) ot = duintptr(lsym, ot, uint64(n))

View file

@ -333,9 +333,9 @@ func staticcopy(l *Node, r *Node, out *[]*Node) bool {
n.Xoffset = l.Xoffset + int64(array_array) n.Xoffset = l.Xoffset + int64(array_array)
gdata(&n, nod(OADDR, a, nil), Widthptr) gdata(&n, nod(OADDR, a, nil), Widthptr)
n.Xoffset = l.Xoffset + int64(array_nel) n.Xoffset = l.Xoffset + int64(array_nel)
gdata(&n, r.Right, Widthint) gdata(&n, r.Right, Widthptr)
n.Xoffset = l.Xoffset + int64(array_cap) n.Xoffset = l.Xoffset + int64(array_cap)
gdata(&n, r.Right, Widthint) gdata(&n, r.Right, Widthptr)
return true return true
case OARRAYLIT, OSTRUCTLIT: case OARRAYLIT, OSTRUCTLIT:
@ -434,9 +434,9 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
n.Xoffset = l.Xoffset + int64(array_array) n.Xoffset = l.Xoffset + int64(array_array)
gdata(&n, nod(OADDR, a, nil), Widthptr) gdata(&n, nod(OADDR, a, nil), Widthptr)
n.Xoffset = l.Xoffset + int64(array_nel) n.Xoffset = l.Xoffset + int64(array_nel)
gdata(&n, r.Right, Widthint) gdata(&n, r.Right, Widthptr)
n.Xoffset = l.Xoffset + int64(array_cap) n.Xoffset = l.Xoffset + int64(array_cap)
gdata(&n, r.Right, Widthint) gdata(&n, r.Right, Widthptr)
// Fall through to init underlying array. // Fall through to init underlying array.
l = a l = a
@ -797,9 +797,9 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
nam.Xoffset += int64(array_array) nam.Xoffset += int64(array_array)
gdata(&nam, nod(OADDR, vstat, nil), Widthptr) gdata(&nam, nod(OADDR, vstat, nil), Widthptr)
nam.Xoffset += int64(array_nel) - int64(array_array) nam.Xoffset += int64(array_nel) - int64(array_array)
gdata(&nam, &v, Widthint) gdata(&nam, &v, Widthptr)
nam.Xoffset += int64(array_cap) - int64(array_nel) nam.Xoffset += int64(array_cap) - int64(array_nel)
gdata(&nam, &v, Widthint) gdata(&nam, &v, Widthptr)
return return
} }

View file

@ -492,7 +492,7 @@ func (s *state) constFloat64(t ssa.Type, c float64) *ssa.Value {
return s.f.ConstFloat64(s.peekPos(), t, c) return s.f.ConstFloat64(s.peekPos(), t, c)
} }
func (s *state) constInt(t ssa.Type, c int64) *ssa.Value { func (s *state) constInt(t ssa.Type, c int64) *ssa.Value {
if s.config.IntSize == 8 { if s.config.PtrSize == 8 {
return s.constInt64(t, c) return s.constInt64(t, c)
} }
if int64(int32(c)) != c { if int64(int32(c)) != c {
@ -1164,12 +1164,12 @@ func (s *state) concreteEtype(t *types.Type) types.EType {
default: default:
return e return e
case TINT: case TINT:
if s.config.IntSize == 8 { if s.config.PtrSize == 8 {
return TINT64 return TINT64
} }
return TINT32 return TINT32
case TUINT: case TUINT:
if s.config.IntSize == 8 { if s.config.PtrSize == 8 {
return TUINT64 return TUINT64
} }
return TUINT32 return TUINT32
@ -1602,7 +1602,7 @@ func (s *state) expr(n *Node) *ssa.Value {
if ft.IsFloat() || tt.IsFloat() { if ft.IsFloat() || tt.IsFloat() {
conv, ok := fpConvOpToSSA[twoTypes{s.concreteEtype(ft), s.concreteEtype(tt)}] conv, ok := fpConvOpToSSA[twoTypes{s.concreteEtype(ft), s.concreteEtype(tt)}]
if s.config.IntSize == 4 && thearch.LinkArch.Name != "amd64p32" && thearch.LinkArch.Family != sys.MIPS { if s.config.PtrSize == 4 && thearch.LinkArch.Name != "amd64p32" && thearch.LinkArch.Family != sys.MIPS {
if conv1, ok1 := fpConvOpToSSA32[twoTypes{s.concreteEtype(ft), s.concreteEtype(tt)}]; ok1 { if conv1, ok1 := fpConvOpToSSA32[twoTypes{s.concreteEtype(ft), s.concreteEtype(tt)}]; ok1 {
conv = conv1 conv = conv1
} }
@ -2500,7 +2500,7 @@ func init() {
var p8 []*sys.Arch var p8 []*sys.Arch
for _, a := range sys.Archs { for _, a := range sys.Archs {
all = append(all, a) all = append(all, a)
if a.IntSize == 4 { if a.PtrSize == 4 {
i4 = append(i4, a) i4 = append(i4, a)
} else { } else {
i8 = append(i8, a) i8 = append(i8, a)
@ -2765,7 +2765,7 @@ func init() {
sys.AMD64, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS) sys.AMD64, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS)
addF("math/bits", "Len32", addF("math/bits", "Len32",
func(s *state, n *Node, args []*ssa.Value) *ssa.Value { func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
if s.config.IntSize == 4 { if s.config.PtrSize == 4 {
return s.newValue1(ssa.OpBitLen32, types.Types[TINT], args[0]) return s.newValue1(ssa.OpBitLen32, types.Types[TINT], args[0])
} }
x := s.newValue1(ssa.OpZeroExt32to64, types.Types[TUINT64], args[0]) x := s.newValue1(ssa.OpZeroExt32to64, types.Types[TUINT64], args[0])
@ -2774,7 +2774,7 @@ func init() {
sys.AMD64, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS) sys.AMD64, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS)
addF("math/bits", "Len16", addF("math/bits", "Len16",
func(s *state, n *Node, args []*ssa.Value) *ssa.Value { func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
if s.config.IntSize == 4 { if s.config.PtrSize == 4 {
x := s.newValue1(ssa.OpZeroExt16to32, types.Types[TUINT32], args[0]) x := s.newValue1(ssa.OpZeroExt16to32, types.Types[TUINT32], args[0])
return s.newValue1(ssa.OpBitLen32, types.Types[TINT], x) return s.newValue1(ssa.OpBitLen32, types.Types[TINT], x)
} }
@ -2785,7 +2785,7 @@ func init() {
// Note: disabled on AMD64 because the Go code is faster! // Note: disabled on AMD64 because the Go code is faster!
addF("math/bits", "Len8", addF("math/bits", "Len8",
func(s *state, n *Node, args []*ssa.Value) *ssa.Value { func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
if s.config.IntSize == 4 { if s.config.PtrSize == 4 {
x := s.newValue1(ssa.OpZeroExt8to32, types.Types[TUINT32], args[0]) x := s.newValue1(ssa.OpZeroExt8to32, types.Types[TUINT32], args[0])
return s.newValue1(ssa.OpBitLen32, types.Types[TINT], x) return s.newValue1(ssa.OpBitLen32, types.Types[TINT], x)
} }
@ -2796,7 +2796,7 @@ func init() {
addF("math/bits", "Len", addF("math/bits", "Len",
func(s *state, n *Node, args []*ssa.Value) *ssa.Value { func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
if s.config.IntSize == 4 { if s.config.PtrSize == 4 {
return s.newValue1(ssa.OpBitLen32, types.Types[TINT], args[0]) return s.newValue1(ssa.OpBitLen32, types.Types[TINT], args[0])
} }
return s.newValue1(ssa.OpBitLen64, types.Types[TINT], args[0]) return s.newValue1(ssa.OpBitLen64, types.Types[TINT], args[0])
@ -2825,7 +2825,7 @@ func init() {
sys.ARM64) sys.ARM64)
addF("math/bits", "Reverse", addF("math/bits", "Reverse",
func(s *state, n *Node, args []*ssa.Value) *ssa.Value { func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
if s.config.IntSize == 4 { if s.config.PtrSize == 4 {
return s.newValue1(ssa.OpBitRev32, types.Types[TINT], args[0]) return s.newValue1(ssa.OpBitRev32, types.Types[TINT], args[0])
} }
return s.newValue1(ssa.OpBitRev64, types.Types[TINT], args[0]) return s.newValue1(ssa.OpBitRev64, types.Types[TINT], args[0])
@ -2849,7 +2849,7 @@ func init() {
// We have the intrinsic - use it directly. // We have the intrinsic - use it directly.
s.startBlock(bTrue) s.startBlock(bTrue)
op := op64 op := op64
if s.config.IntSize == 4 { if s.config.PtrSize == 4 {
op = op32 op = op32
} }
s.vars[n] = s.newValue1(op, types.Types[TINT], args[0]) s.vars[n] = s.newValue1(op, types.Types[TINT], args[0])
@ -3545,17 +3545,17 @@ func (s *state) storeTypeScalars(t *types.Type, left, right *ssa.Value, skip ski
return return
} }
len := s.newValue1(ssa.OpStringLen, types.Types[TINT], right) len := s.newValue1(ssa.OpStringLen, types.Types[TINT], right)
lenAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, s.config.IntSize, left) lenAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, s.config.PtrSize, left)
s.vars[&memVar] = s.newValue3A(ssa.OpStore, ssa.TypeMem, types.Types[TINT], lenAddr, len, s.mem()) s.vars[&memVar] = s.newValue3A(ssa.OpStore, ssa.TypeMem, types.Types[TINT], lenAddr, len, s.mem())
case t.IsSlice(): case t.IsSlice():
if skip&skipLen == 0 { if skip&skipLen == 0 {
len := s.newValue1(ssa.OpSliceLen, types.Types[TINT], right) len := s.newValue1(ssa.OpSliceLen, types.Types[TINT], right)
lenAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, s.config.IntSize, left) lenAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, s.config.PtrSize, left)
s.vars[&memVar] = s.newValue3A(ssa.OpStore, ssa.TypeMem, types.Types[TINT], lenAddr, len, s.mem()) s.vars[&memVar] = s.newValue3A(ssa.OpStore, ssa.TypeMem, types.Types[TINT], lenAddr, len, s.mem())
} }
if skip&skipCap == 0 { if skip&skipCap == 0 {
cap := s.newValue1(ssa.OpSliceCap, types.Types[TINT], right) cap := s.newValue1(ssa.OpSliceCap, types.Types[TINT], right)
capAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, 2*s.config.IntSize, left) capAddr := s.newValue1I(ssa.OpOffPtr, s.f.Config.Types.IntPtr, 2*s.config.PtrSize, left)
s.vars[&memVar] = s.newValue3A(ssa.OpStore, ssa.TypeMem, types.Types[TINT], capAddr, cap, s.mem()) s.vars[&memVar] = s.newValue3A(ssa.OpStore, ssa.TypeMem, types.Types[TINT], capAddr, cap, s.mem())
} }
case t.IsInterface(): case t.IsInterface():
@ -4615,10 +4615,10 @@ func AddAux2(a *obj.Addr, v *ssa.Value, offset int64) {
// panic using the given function if v does not fit in an int (only on 32-bit archs). // panic using the given function if v does not fit in an int (only on 32-bit archs).
func (s *state) extendIndex(v *ssa.Value, panicfn *obj.LSym) *ssa.Value { func (s *state) extendIndex(v *ssa.Value, panicfn *obj.LSym) *ssa.Value {
size := v.Type.Size() size := v.Type.Size()
if size == s.config.IntSize { if size == s.config.PtrSize {
return v return v
} }
if size > s.config.IntSize { if size > s.config.PtrSize {
// truncate 64-bit indexes on 32-bit pointer archs. Test the // truncate 64-bit indexes on 32-bit pointer archs. Test the
// high word and branch to out-of-bounds failure if it is not 0. // high word and branch to out-of-bounds failure if it is not 0.
if Debug['B'] == 0 { if Debug['B'] == 0 {
@ -4632,7 +4632,7 @@ func (s *state) extendIndex(v *ssa.Value, panicfn *obj.LSym) *ssa.Value {
// Extend value to the required size // Extend value to the required size
var op ssa.Op var op ssa.Op
if v.Type.IsSigned() { if v.Type.IsSigned() {
switch 10*size + s.config.IntSize { switch 10*size + s.config.PtrSize {
case 14: case 14:
op = ssa.OpSignExt8to32 op = ssa.OpSignExt8to32
case 18: case 18:
@ -4647,7 +4647,7 @@ func (s *state) extendIndex(v *ssa.Value, panicfn *obj.LSym) *ssa.Value {
s.Fatalf("bad signed index extension %s", v.Type) s.Fatalf("bad signed index extension %s", v.Type)
} }
} else { } else {
switch 10*size + s.config.IntSize { switch 10*size + s.config.PtrSize {
case 14: case 14:
op = ssa.OpZeroExt8to32 op = ssa.OpZeroExt8to32
case 18: case 18:

View file

@ -40,8 +40,8 @@ var typedefs = [...]struct {
sameas32 types.EType sameas32 types.EType
sameas64 types.EType sameas64 types.EType
}{ }{
{"int", TINT, &Widthint, TINT32, TINT64}, {"int", TINT, &Widthptr, TINT32, TINT64},
{"uint", TUINT, &Widthint, TUINT32, TUINT64}, {"uint", TUINT, &Widthptr, TUINT32, TUINT64},
{"uintptr", TUINTPTR, &Widthptr, TUINT32, TUINT64}, {"uintptr", TUINTPTR, &Widthptr, TUINT32, TUINT64},
} }
@ -359,12 +359,12 @@ func typeinit() {
simtype[TUNSAFEPTR] = types.Tptr simtype[TUNSAFEPTR] = types.Tptr
array_array = int(Rnd(0, int64(Widthptr))) array_array = int(Rnd(0, int64(Widthptr)))
array_nel = int(Rnd(int64(array_array)+int64(Widthptr), int64(Widthint))) array_nel = int(Rnd(int64(array_array)+int64(Widthptr), int64(Widthptr)))
array_cap = int(Rnd(int64(array_nel)+int64(Widthint), int64(Widthint))) array_cap = int(Rnd(int64(array_nel)+int64(Widthptr), int64(Widthptr)))
sizeof_Array = int(Rnd(int64(array_cap)+int64(Widthint), int64(Widthptr))) sizeof_Array = int(Rnd(int64(array_cap)+int64(Widthptr), int64(Widthptr)))
// string is same as slice wo the cap // string is same as slice wo the cap
sizeof_String = int(Rnd(int64(array_nel)+int64(Widthint), int64(Widthptr))) sizeof_String = int(Rnd(int64(array_nel)+int64(Widthptr), int64(Widthptr)))
dowidth(types.Types[TSTRING]) dowidth(types.Types[TSTRING])
dowidth(types.Idealstring) dowidth(types.Idealstring)

View file

@ -17,9 +17,8 @@ import (
// and shared across all compilations. // and shared across all compilations.
type Config struct { type Config struct {
arch string // "amd64", etc. arch string // "amd64", etc.
IntSize int64 // 4 or 8 PtrSize int64 // 4 or 8; copy of cmd/internal/sys.Arch.PtrSize
PtrSize int64 // 4 or 8 RegSize int64 // 4 or 8; copy of cmd/internal/sys.Arch.RegSize
RegSize int64 // 4 or 8
Types Types Types Types
lowerBlock blockRewriter // lowering function lowerBlock blockRewriter // lowering function
lowerValue valueRewriter // lowering function lowerValue valueRewriter // lowering function
@ -143,7 +142,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c := &Config{arch: arch, Types: types} c := &Config{arch: arch, Types: types}
switch arch { switch arch {
case "amd64": case "amd64":
c.IntSize = 8
c.PtrSize = 8 c.PtrSize = 8
c.RegSize = 8 c.RegSize = 8
c.lowerBlock = rewriteBlockAMD64 c.lowerBlock = rewriteBlockAMD64
@ -155,7 +153,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.LinkReg = linkRegAMD64 c.LinkReg = linkRegAMD64
c.hasGReg = false c.hasGReg = false
case "amd64p32": case "amd64p32":
c.IntSize = 4
c.PtrSize = 4 c.PtrSize = 4
c.RegSize = 8 c.RegSize = 8
c.lowerBlock = rewriteBlockAMD64 c.lowerBlock = rewriteBlockAMD64
@ -168,7 +165,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.hasGReg = false c.hasGReg = false
c.noDuffDevice = true c.noDuffDevice = true
case "386": case "386":
c.IntSize = 4
c.PtrSize = 4 c.PtrSize = 4
c.RegSize = 4 c.RegSize = 4
c.lowerBlock = rewriteBlock386 c.lowerBlock = rewriteBlock386
@ -180,7 +176,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.LinkReg = linkReg386 c.LinkReg = linkReg386
c.hasGReg = false c.hasGReg = false
case "arm": case "arm":
c.IntSize = 4
c.PtrSize = 4 c.PtrSize = 4
c.RegSize = 4 c.RegSize = 4
c.lowerBlock = rewriteBlockARM c.lowerBlock = rewriteBlockARM
@ -192,7 +187,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.LinkReg = linkRegARM c.LinkReg = linkRegARM
c.hasGReg = true c.hasGReg = true
case "arm64": case "arm64":
c.IntSize = 8
c.PtrSize = 8 c.PtrSize = 8
c.RegSize = 8 c.RegSize = 8
c.lowerBlock = rewriteBlockARM64 c.lowerBlock = rewriteBlockARM64
@ -208,7 +202,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.BigEndian = true c.BigEndian = true
fallthrough fallthrough
case "ppc64le": case "ppc64le":
c.IntSize = 8
c.PtrSize = 8 c.PtrSize = 8
c.RegSize = 8 c.RegSize = 8
c.lowerBlock = rewriteBlockPPC64 c.lowerBlock = rewriteBlockPPC64
@ -224,7 +217,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.BigEndian = true c.BigEndian = true
fallthrough fallthrough
case "mips64le": case "mips64le":
c.IntSize = 8
c.PtrSize = 8 c.PtrSize = 8
c.RegSize = 8 c.RegSize = 8
c.lowerBlock = rewriteBlockMIPS64 c.lowerBlock = rewriteBlockMIPS64
@ -237,7 +229,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.LinkReg = linkRegMIPS64 c.LinkReg = linkRegMIPS64
c.hasGReg = true c.hasGReg = true
case "s390x": case "s390x":
c.IntSize = 8
c.PtrSize = 8 c.PtrSize = 8
c.RegSize = 8 c.RegSize = 8
c.lowerBlock = rewriteBlockS390X c.lowerBlock = rewriteBlockS390X
@ -254,7 +245,6 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.BigEndian = true c.BigEndian = true
fallthrough fallthrough
case "mipsle": case "mipsle":
c.IntSize = 4
c.PtrSize = 4 c.PtrSize = 4
c.RegSize = 4 c.RegSize = 4
c.lowerBlock = rewriteBlockMIPS c.lowerBlock = rewriteBlockMIPS

View file

@ -25,7 +25,7 @@ func decomposeBuiltIn(f *Func) {
for _, name := range f.Names { for _, name := range f.Names {
t := name.Type t := name.Type
switch { switch {
case t.IsInteger() && t.Size() == 8 && f.Config.IntSize == 4: case t.IsInteger() && t.Size() == 8 && f.Config.PtrSize == 4:
var elemType Type var elemType Type
if t.IsSigned() { if t.IsSigned() {
elemType = f.Config.Types.Int32 elemType = f.Config.Types.Int32
@ -95,8 +95,8 @@ func decomposeBuiltIn(f *Func) {
} }
delete(f.NamedValues, name) delete(f.NamedValues, name)
case t.IsFloat(): case t.IsFloat():
// floats are never decomposed, even ones bigger than IntSize // floats are never decomposed, even ones bigger than PtrSize
case t.Size() > f.Config.IntSize: case t.Size() > f.Config.PtrSize:
f.Fatalf("undecomposed named type %v %v", name, t) f.Fatalf("undecomposed named type %v %v", name, t)
default: default:
newNames = append(newNames, name) newNames = append(newNames, name)
@ -107,7 +107,7 @@ func decomposeBuiltIn(f *Func) {
func decomposeBuiltInPhi(v *Value) { func decomposeBuiltInPhi(v *Value) {
switch { switch {
case v.Type.IsInteger() && v.Type.Size() == 8 && v.Block.Func.Config.IntSize == 4: case v.Type.IsInteger() && v.Type.Size() == 8 && v.Block.Func.Config.PtrSize == 4:
if v.Block.Func.Config.arch == "amd64p32" { if v.Block.Func.Config.arch == "amd64p32" {
// Even though ints are 32 bits, we have 64-bit ops. // Even though ints are 32 bits, we have 64-bit ops.
break break
@ -122,8 +122,8 @@ func decomposeBuiltInPhi(v *Value) {
case v.Type.IsInterface(): case v.Type.IsInterface():
decomposeInterfacePhi(v) decomposeInterfacePhi(v)
case v.Type.IsFloat(): case v.Type.IsFloat():
// floats are never decomposed, even ones bigger than IntSize // floats are never decomposed, even ones bigger than PtrSize
case v.Type.Size() > v.Block.Func.Config.IntSize: case v.Type.Size() > v.Block.Func.Config.PtrSize:
v.Fatalf("undecomposed type %s", v.Type) v.Fatalf("undecomposed type %s", v.Type)
} }
} }

View file

@ -30,7 +30,7 @@ func testConfigArch(tb testing.TB, arch string) *Conf {
if !ok { if !ok {
tb.Fatalf("unknown arch %s", arch) tb.Fatalf("unknown arch %s", arch)
} }
if ctxt.Arch.IntSize != 8 { if ctxt.Arch.PtrSize != 8 {
tb.Fatal("dummyTypes is 64-bit only") tb.Fatal("dummyTypes is 64-bit only")
} }
c := &Conf{ c := &Conf{

View file

@ -11,7 +11,7 @@ func opt(f *Func) {
func dec(f *Func) { func dec(f *Func) {
applyRewrite(f, rewriteBlockdec, rewriteValuedec) applyRewrite(f, rewriteBlockdec, rewriteValuedec)
if f.Config.IntSize == 4 && f.Config.arch != "amd64p32" { if f.Config.PtrSize == 4 && f.Config.arch != "amd64p32" {
applyRewrite(f, rewriteBlockdec64, rewriteValuedec64) applyRewrite(f, rewriteBlockdec64, rewriteValuedec64)
} }
} }

View file

@ -450,7 +450,7 @@ func isSamePtr(p1, p2 *Value) bool {
// moveSize returns the number of bytes an aligned MOV instruction moves // moveSize returns the number of bytes an aligned MOV instruction moves
func moveSize(align int64, c *Config) int64 { func moveSize(align int64, c *Config) int64 {
switch { switch {
case align%8 == 0 && c.IntSize == 8: case align%8 == 0 && c.PtrSize == 8:
return 8 return 8
case align%4 == 0: case align%4 == 0:
return 4 return 4

View file

@ -30,8 +30,11 @@ type Arch struct {
ByteOrder binary.ByteOrder ByteOrder binary.ByteOrder
IntSize int // PtrSize is the size in bytes of pointers and the
// predeclared "int", "uint", and "uintptr" types.
PtrSize int PtrSize int
// RegSize is the size in bytes of general purpose registers.
RegSize int RegSize int
// MinLC is the minimum length of an instruction code. // MinLC is the minimum length of an instruction code.
@ -53,7 +56,6 @@ var Arch386 = &Arch{
Name: "386", Name: "386",
Family: I386, Family: I386,
ByteOrder: binary.LittleEndian, ByteOrder: binary.LittleEndian,
IntSize: 4,
PtrSize: 4, PtrSize: 4,
RegSize: 4, RegSize: 4,
MinLC: 1, MinLC: 1,
@ -63,7 +65,6 @@ var ArchAMD64 = &Arch{
Name: "amd64", Name: "amd64",
Family: AMD64, Family: AMD64,
ByteOrder: binary.LittleEndian, ByteOrder: binary.LittleEndian,
IntSize: 8,
PtrSize: 8, PtrSize: 8,
RegSize: 8, RegSize: 8,
MinLC: 1, MinLC: 1,
@ -73,7 +74,6 @@ var ArchAMD64P32 = &Arch{
Name: "amd64p32", Name: "amd64p32",
Family: AMD64, Family: AMD64,
ByteOrder: binary.LittleEndian, ByteOrder: binary.LittleEndian,
IntSize: 4,
PtrSize: 4, PtrSize: 4,
RegSize: 8, RegSize: 8,
MinLC: 1, MinLC: 1,
@ -83,7 +83,6 @@ var ArchARM = &Arch{
Name: "arm", Name: "arm",
Family: ARM, Family: ARM,
ByteOrder: binary.LittleEndian, ByteOrder: binary.LittleEndian,
IntSize: 4,
PtrSize: 4, PtrSize: 4,
RegSize: 4, RegSize: 4,
MinLC: 4, MinLC: 4,
@ -93,7 +92,6 @@ var ArchARM64 = &Arch{
Name: "arm64", Name: "arm64",
Family: ARM64, Family: ARM64,
ByteOrder: binary.LittleEndian, ByteOrder: binary.LittleEndian,
IntSize: 8,
PtrSize: 8, PtrSize: 8,
RegSize: 8, RegSize: 8,
MinLC: 4, MinLC: 4,
@ -103,7 +101,6 @@ var ArchMIPS = &Arch{
Name: "mips", Name: "mips",
Family: MIPS, Family: MIPS,
ByteOrder: binary.BigEndian, ByteOrder: binary.BigEndian,
IntSize: 4,
PtrSize: 4, PtrSize: 4,
RegSize: 4, RegSize: 4,
MinLC: 4, MinLC: 4,
@ -113,7 +110,6 @@ var ArchMIPSLE = &Arch{
Name: "mipsle", Name: "mipsle",
Family: MIPS, Family: MIPS,
ByteOrder: binary.LittleEndian, ByteOrder: binary.LittleEndian,
IntSize: 4,
PtrSize: 4, PtrSize: 4,
RegSize: 4, RegSize: 4,
MinLC: 4, MinLC: 4,
@ -123,7 +119,6 @@ var ArchMIPS64 = &Arch{
Name: "mips64", Name: "mips64",
Family: MIPS64, Family: MIPS64,
ByteOrder: binary.BigEndian, ByteOrder: binary.BigEndian,
IntSize: 8,
PtrSize: 8, PtrSize: 8,
RegSize: 8, RegSize: 8,
MinLC: 4, MinLC: 4,
@ -133,7 +128,6 @@ var ArchMIPS64LE = &Arch{
Name: "mips64le", Name: "mips64le",
Family: MIPS64, Family: MIPS64,
ByteOrder: binary.LittleEndian, ByteOrder: binary.LittleEndian,
IntSize: 8,
PtrSize: 8, PtrSize: 8,
RegSize: 8, RegSize: 8,
MinLC: 4, MinLC: 4,
@ -143,7 +137,6 @@ var ArchPPC64 = &Arch{
Name: "ppc64", Name: "ppc64",
Family: PPC64, Family: PPC64,
ByteOrder: binary.BigEndian, ByteOrder: binary.BigEndian,
IntSize: 8,
PtrSize: 8, PtrSize: 8,
RegSize: 8, RegSize: 8,
MinLC: 4, MinLC: 4,
@ -153,7 +146,6 @@ var ArchPPC64LE = &Arch{
Name: "ppc64le", Name: "ppc64le",
Family: PPC64, Family: PPC64,
ByteOrder: binary.LittleEndian, ByteOrder: binary.LittleEndian,
IntSize: 8,
PtrSize: 8, PtrSize: 8,
RegSize: 8, RegSize: 8,
MinLC: 4, MinLC: 4,
@ -163,7 +155,6 @@ var ArchS390X = &Arch{
Name: "s390x", Name: "s390x",
Family: S390X, Family: S390X,
ByteOrder: binary.BigEndian, ByteOrder: binary.BigEndian,
IntSize: 8,
PtrSize: 8, PtrSize: 8,
RegSize: 8, RegSize: 8,
MinLC: 2, MinLC: 2,

View file

@ -129,7 +129,7 @@ func Adduint64(ctxt *Link, s *Symbol, v uint64) int64 {
} }
func adduint(ctxt *Link, s *Symbol, v uint64) int64 { func adduint(ctxt *Link, s *Symbol, v uint64) int64 {
return adduintxx(ctxt, s, v, SysArch.IntSize) return adduintxx(ctxt, s, v, SysArch.PtrSize)
} }
func setuint8(ctxt *Link, s *Symbol, r int64, v uint8) int64 { func setuint8(ctxt *Link, s *Symbol, r int64, v uint8) int64 {

View file

@ -210,11 +210,11 @@ func decodetypeFuncOutType(arch *sys.Arch, s *Symbol, i int) *Symbol {
// Type.StructType.fields.Slice::length // Type.StructType.fields.Slice::length
func decodetypeStructFieldCount(arch *sys.Arch, s *Symbol) int { func decodetypeStructFieldCount(arch *sys.Arch, s *Symbol) int {
return int(decodeInuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.IntSize)) return int(decodeInuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.PtrSize))
} }
func decodetypeStructFieldArrayOff(s *Symbol, i int) int { func decodetypeStructFieldArrayOff(s *Symbol, i int) int {
off := commonsize() + 2*SysArch.PtrSize + 2*SysArch.IntSize off := commonsize() + 2*SysArch.PtrSize + 2*SysArch.PtrSize
if decodetypeHasUncommon(s) { if decodetypeHasUncommon(s) {
off += uncommonSize() off += uncommonSize()
} }
@ -255,12 +255,12 @@ func decodetypeStructFieldType(s *Symbol, i int) *Symbol {
func decodetypeStructFieldOffs(arch *sys.Arch, s *Symbol, i int) int64 { func decodetypeStructFieldOffs(arch *sys.Arch, s *Symbol, i int) int64 {
off := decodetypeStructFieldArrayOff(s, i) off := decodetypeStructFieldArrayOff(s, i)
return int64(decodeInuxi(arch, s.P[off+2*SysArch.PtrSize:], SysArch.IntSize) >> 1) return int64(decodeInuxi(arch, s.P[off+2*SysArch.PtrSize:], SysArch.PtrSize) >> 1)
} }
// InterfaceType.methods.length // InterfaceType.methods.length
func decodetypeIfaceMethodCount(arch *sys.Arch, s *Symbol) int64 { func decodetypeIfaceMethodCount(arch *sys.Arch, s *Symbol) int64 {
return int64(decodeInuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.IntSize)) return int64(decodeInuxi(arch, s.P[commonsize()+2*SysArch.PtrSize:], SysArch.PtrSize))
} }
// methodsig is a fully qualified typed method signature, like // methodsig is a fully qualified typed method signature, like
@ -342,7 +342,7 @@ func decodetypeMethods(arch *sys.Arch, s *Symbol) []methodsig {
off := commonsize() // reflect.rtype off := commonsize() // reflect.rtype
switch decodetypeKind(s) & kindMask { switch decodetypeKind(s) & kindMask {
case kindStruct: // reflect.structType case kindStruct: // reflect.structType
off += 2*SysArch.PtrSize + 2*SysArch.IntSize off += 2*SysArch.PtrSize + 2*SysArch.PtrSize
case kindPtr: // reflect.ptrType case kindPtr: // reflect.ptrType
off += SysArch.PtrSize off += SysArch.PtrSize
case kindFunc: // reflect.funcType case kindFunc: // reflect.funcType
@ -356,7 +356,7 @@ func decodetypeMethods(arch *sys.Arch, s *Symbol) []methodsig {
case kindMap: // reflect.mapType case kindMap: // reflect.mapType
off += 4*SysArch.PtrSize + 8 off += 4*SysArch.PtrSize + 8
case kindInterface: // reflect.interfaceType case kindInterface: // reflect.interfaceType
off += SysArch.PtrSize + 2*SysArch.IntSize off += SysArch.PtrSize + 2*SysArch.PtrSize
default: default:
// just Sizeof(rtype) // just Sizeof(rtype)
} }

View file

@ -318,7 +318,7 @@ func textsectionmap(ctxt *Link) uint32 {
break break
} }
} }
Symgrow(t, nsections*(2*int64(SysArch.IntSize)+int64(SysArch.PtrSize))) Symgrow(t, nsections*(2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize)))
off := int64(0) off := int64(0)
n := 0 n := 0
@ -337,8 +337,8 @@ func textsectionmap(ctxt *Link) uint32 {
if sect.Name != ".text" { if sect.Name != ".text" {
break break
} }
off = setuintxx(ctxt, t, off, sect.Vaddr-textbase, int64(SysArch.IntSize)) off = setuintxx(ctxt, t, off, sect.Vaddr-textbase, int64(SysArch.PtrSize))
off = setuintxx(ctxt, t, off, sect.Length, int64(SysArch.IntSize)) off = setuintxx(ctxt, t, off, sect.Length, int64(SysArch.PtrSize))
if n == 0 { if n == 0 {
s := ctxt.Syms.ROLookup("runtime.text", 0) s := ctxt.Syms.ROLookup("runtime.text", 0)
if s == nil { if s == nil {