var Widthptr int
-var Widthint int
-
var Widthreg int
var nblank *Node
Debug['l'] = 1 - Debug['l']
}
- Widthint = thearch.LinkArch.IntSize
Widthptr = thearch.LinkArch.PtrSize
Widthreg = thearch.LinkArch.RegSize
case string:
symdata := stringsym(u)
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:
Fatalf("gdata unhandled OLITERAL %v", nr)
}
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))
dataAdd := imethodSize() * n
}
}
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))
n.Xoffset = l.Xoffset + int64(array_array)
gdata(&n, nod(OADDR, a, nil), Widthptr)
n.Xoffset = l.Xoffset + int64(array_nel)
- gdata(&n, r.Right, Widthint)
+ gdata(&n, r.Right, Widthptr)
n.Xoffset = l.Xoffset + int64(array_cap)
- gdata(&n, r.Right, Widthint)
+ gdata(&n, r.Right, Widthptr)
return true
case OARRAYLIT, OSTRUCTLIT:
n.Xoffset = l.Xoffset + int64(array_array)
gdata(&n, nod(OADDR, a, nil), Widthptr)
n.Xoffset = l.Xoffset + int64(array_nel)
- gdata(&n, r.Right, Widthint)
+ gdata(&n, r.Right, Widthptr)
n.Xoffset = l.Xoffset + int64(array_cap)
- gdata(&n, r.Right, Widthint)
+ gdata(&n, r.Right, Widthptr)
// Fall through to init underlying array.
l = a
nam.Xoffset += int64(array_array)
gdata(&nam, nod(OADDR, vstat, nil), Widthptr)
nam.Xoffset += int64(array_nel) - int64(array_array)
- gdata(&nam, &v, Widthint)
+ gdata(&nam, &v, Widthptr)
nam.Xoffset += int64(array_cap) - int64(array_nel)
- gdata(&nam, &v, Widthint)
+ gdata(&nam, &v, Widthptr)
return
}
return s.f.ConstFloat64(s.peekPos(), t, c)
}
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)
}
if int64(int32(c)) != c {
default:
return e
case TINT:
- if s.config.IntSize == 8 {
+ if s.config.PtrSize == 8 {
return TINT64
}
return TINT32
case TUINT:
- if s.config.IntSize == 8 {
+ if s.config.PtrSize == 8 {
return TUINT64
}
return TUINT32
if ft.IsFloat() || tt.IsFloat() {
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 {
conv = conv1
}
var p8 []*sys.Arch
for _, a := range sys.Archs {
all = append(all, a)
- if a.IntSize == 4 {
+ if a.PtrSize == 4 {
i4 = append(i4, a)
} else {
i8 = append(i8, a)
sys.AMD64, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS)
addF("math/bits", "Len32",
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])
}
x := s.newValue1(ssa.OpZeroExt32to64, types.Types[TUINT64], args[0])
sys.AMD64, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS)
addF("math/bits", "Len16",
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])
return s.newValue1(ssa.OpBitLen32, types.Types[TINT], x)
}
// Note: disabled on AMD64 because the Go code is faster!
addF("math/bits", "Len8",
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])
return s.newValue1(ssa.OpBitLen32, types.Types[TINT], x)
}
addF("math/bits", "Len",
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.OpBitLen64, types.Types[TINT], args[0])
sys.ARM64)
addF("math/bits", "Reverse",
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.OpBitRev64, types.Types[TINT], args[0])
// We have the intrinsic - use it directly.
s.startBlock(bTrue)
op := op64
- if s.config.IntSize == 4 {
+ if s.config.PtrSize == 4 {
op = op32
}
s.vars[n] = s.newValue1(op, types.Types[TINT], args[0])
return
}
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())
case t.IsSlice():
if skip&skipLen == 0 {
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())
}
if skip&skipCap == 0 {
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())
}
case t.IsInterface():
// 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 {
size := v.Type.Size()
- if size == s.config.IntSize {
+ if size == s.config.PtrSize {
return v
}
- if size > s.config.IntSize {
+ if size > s.config.PtrSize {
// 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.
if Debug['B'] == 0 {
// Extend value to the required size
var op ssa.Op
if v.Type.IsSigned() {
- switch 10*size + s.config.IntSize {
+ switch 10*size + s.config.PtrSize {
case 14:
op = ssa.OpSignExt8to32
case 18:
s.Fatalf("bad signed index extension %s", v.Type)
}
} else {
- switch 10*size + s.config.IntSize {
+ switch 10*size + s.config.PtrSize {
case 14:
op = ssa.OpZeroExt8to32
case 18:
sameas32 types.EType
sameas64 types.EType
}{
- {"int", TINT, &Widthint, TINT32, TINT64},
- {"uint", TUINT, &Widthint, TUINT32, TUINT64},
+ {"int", TINT, &Widthptr, TINT32, TINT64},
+ {"uint", TUINT, &Widthptr, TUINT32, TUINT64},
{"uintptr", TUINTPTR, &Widthptr, TUINT32, TUINT64},
}
simtype[TUNSAFEPTR] = types.Tptr
array_array = int(Rnd(0, int64(Widthptr)))
- array_nel = int(Rnd(int64(array_array)+int64(Widthptr), int64(Widthint)))
- array_cap = int(Rnd(int64(array_nel)+int64(Widthint), int64(Widthint)))
- sizeof_Array = int(Rnd(int64(array_cap)+int64(Widthint), int64(Widthptr)))
+ array_nel = int(Rnd(int64(array_array)+int64(Widthptr), int64(Widthptr)))
+ array_cap = int(Rnd(int64(array_nel)+int64(Widthptr), int64(Widthptr)))
+ sizeof_Array = int(Rnd(int64(array_cap)+int64(Widthptr), int64(Widthptr)))
// 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.Idealstring)
// and shared across all compilations.
type Config struct {
arch string // "amd64", etc.
- IntSize int64 // 4 or 8
- PtrSize int64 // 4 or 8
- RegSize int64 // 4 or 8
+ PtrSize int64 // 4 or 8; copy of cmd/internal/sys.Arch.PtrSize
+ RegSize int64 // 4 or 8; copy of cmd/internal/sys.Arch.RegSize
Types Types
lowerBlock blockRewriter // lowering function
lowerValue valueRewriter // lowering function
c := &Config{arch: arch, Types: types}
switch arch {
case "amd64":
- c.IntSize = 8
c.PtrSize = 8
c.RegSize = 8
c.lowerBlock = rewriteBlockAMD64
c.LinkReg = linkRegAMD64
c.hasGReg = false
case "amd64p32":
- c.IntSize = 4
c.PtrSize = 4
c.RegSize = 8
c.lowerBlock = rewriteBlockAMD64
c.hasGReg = false
c.noDuffDevice = true
case "386":
- c.IntSize = 4
c.PtrSize = 4
c.RegSize = 4
c.lowerBlock = rewriteBlock386
c.LinkReg = linkReg386
c.hasGReg = false
case "arm":
- c.IntSize = 4
c.PtrSize = 4
c.RegSize = 4
c.lowerBlock = rewriteBlockARM
c.LinkReg = linkRegARM
c.hasGReg = true
case "arm64":
- c.IntSize = 8
c.PtrSize = 8
c.RegSize = 8
c.lowerBlock = rewriteBlockARM64
c.BigEndian = true
fallthrough
case "ppc64le":
- c.IntSize = 8
c.PtrSize = 8
c.RegSize = 8
c.lowerBlock = rewriteBlockPPC64
c.BigEndian = true
fallthrough
case "mips64le":
- c.IntSize = 8
c.PtrSize = 8
c.RegSize = 8
c.lowerBlock = rewriteBlockMIPS64
c.LinkReg = linkRegMIPS64
c.hasGReg = true
case "s390x":
- c.IntSize = 8
c.PtrSize = 8
c.RegSize = 8
c.lowerBlock = rewriteBlockS390X
c.BigEndian = true
fallthrough
case "mipsle":
- c.IntSize = 4
c.PtrSize = 4
c.RegSize = 4
c.lowerBlock = rewriteBlockMIPS
for _, name := range f.Names {
t := name.Type
switch {
- case t.IsInteger() && t.Size() == 8 && f.Config.IntSize == 4:
+ case t.IsInteger() && t.Size() == 8 && f.Config.PtrSize == 4:
var elemType Type
if t.IsSigned() {
elemType = f.Config.Types.Int32
}
delete(f.NamedValues, name)
case t.IsFloat():
- // floats are never decomposed, even ones bigger than IntSize
- case t.Size() > f.Config.IntSize:
+ // floats are never decomposed, even ones bigger than PtrSize
+ case t.Size() > f.Config.PtrSize:
f.Fatalf("undecomposed named type %v %v", name, t)
default:
newNames = append(newNames, name)
func decomposeBuiltInPhi(v *Value) {
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" {
// Even though ints are 32 bits, we have 64-bit ops.
break
case v.Type.IsInterface():
decomposeInterfacePhi(v)
case v.Type.IsFloat():
- // floats are never decomposed, even ones bigger than IntSize
- case v.Type.Size() > v.Block.Func.Config.IntSize:
+ // floats are never decomposed, even ones bigger than PtrSize
+ case v.Type.Size() > v.Block.Func.Config.PtrSize:
v.Fatalf("undecomposed type %s", v.Type)
}
}
if !ok {
tb.Fatalf("unknown arch %s", arch)
}
- if ctxt.Arch.IntSize != 8 {
+ if ctxt.Arch.PtrSize != 8 {
tb.Fatal("dummyTypes is 64-bit only")
}
c := &Conf{
func dec(f *Func) {
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)
}
}
// moveSize returns the number of bytes an aligned MOV instruction moves
func moveSize(align int64, c *Config) int64 {
switch {
- case align%8 == 0 && c.IntSize == 8:
+ case align%8 == 0 && c.PtrSize == 8:
return 8
case align%4 == 0:
return 4
ByteOrder binary.ByteOrder
- IntSize int
+ // PtrSize is the size in bytes of pointers and the
+ // predeclared "int", "uint", and "uintptr" types.
PtrSize int
+
+ // RegSize is the size in bytes of general purpose registers.
RegSize int
// MinLC is the minimum length of an instruction code.
Name: "386",
Family: I386,
ByteOrder: binary.LittleEndian,
- IntSize: 4,
PtrSize: 4,
RegSize: 4,
MinLC: 1,
Name: "amd64",
Family: AMD64,
ByteOrder: binary.LittleEndian,
- IntSize: 8,
PtrSize: 8,
RegSize: 8,
MinLC: 1,
Name: "amd64p32",
Family: AMD64,
ByteOrder: binary.LittleEndian,
- IntSize: 4,
PtrSize: 4,
RegSize: 8,
MinLC: 1,
Name: "arm",
Family: ARM,
ByteOrder: binary.LittleEndian,
- IntSize: 4,
PtrSize: 4,
RegSize: 4,
MinLC: 4,
Name: "arm64",
Family: ARM64,
ByteOrder: binary.LittleEndian,
- IntSize: 8,
PtrSize: 8,
RegSize: 8,
MinLC: 4,
Name: "mips",
Family: MIPS,
ByteOrder: binary.BigEndian,
- IntSize: 4,
PtrSize: 4,
RegSize: 4,
MinLC: 4,
Name: "mipsle",
Family: MIPS,
ByteOrder: binary.LittleEndian,
- IntSize: 4,
PtrSize: 4,
RegSize: 4,
MinLC: 4,
Name: "mips64",
Family: MIPS64,
ByteOrder: binary.BigEndian,
- IntSize: 8,
PtrSize: 8,
RegSize: 8,
MinLC: 4,
Name: "mips64le",
Family: MIPS64,
ByteOrder: binary.LittleEndian,
- IntSize: 8,
PtrSize: 8,
RegSize: 8,
MinLC: 4,
Name: "ppc64",
Family: PPC64,
ByteOrder: binary.BigEndian,
- IntSize: 8,
PtrSize: 8,
RegSize: 8,
MinLC: 4,
Name: "ppc64le",
Family: PPC64,
ByteOrder: binary.LittleEndian,
- IntSize: 8,
PtrSize: 8,
RegSize: 8,
MinLC: 4,
Name: "s390x",
Family: S390X,
ByteOrder: binary.BigEndian,
- IntSize: 8,
PtrSize: 8,
RegSize: 8,
MinLC: 2,
}
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 {
// Type.StructType.fields.Slice::length
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 {
- off := commonsize() + 2*SysArch.PtrSize + 2*SysArch.IntSize
+ off := commonsize() + 2*SysArch.PtrSize + 2*SysArch.PtrSize
if decodetypeHasUncommon(s) {
off += uncommonSize()
}
func decodetypeStructFieldOffs(arch *sys.Arch, s *Symbol, i int) int64 {
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
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
off := commonsize() // reflect.rtype
switch decodetypeKind(s) & kindMask {
case kindStruct: // reflect.structType
- off += 2*SysArch.PtrSize + 2*SysArch.IntSize
+ off += 2*SysArch.PtrSize + 2*SysArch.PtrSize
case kindPtr: // reflect.ptrType
off += SysArch.PtrSize
case kindFunc: // reflect.funcType
case kindMap: // reflect.mapType
off += 4*SysArch.PtrSize + 8
case kindInterface: // reflect.interfaceType
- off += SysArch.PtrSize + 2*SysArch.IntSize
+ off += SysArch.PtrSize + 2*SysArch.PtrSize
default:
// just Sizeof(rtype)
}
break
}
}
- Symgrow(t, nsections*(2*int64(SysArch.IntSize)+int64(SysArch.PtrSize)))
+ Symgrow(t, nsections*(2*int64(SysArch.PtrSize)+int64(SysArch.PtrSize)))
off := int64(0)
n := 0
if sect.Name != ".text" {
break
}
- off = setuintxx(ctxt, t, off, sect.Vaddr-textbase, int64(SysArch.IntSize))
- off = setuintxx(ctxt, t, off, sect.Length, int64(SysArch.IntSize))
+ off = setuintxx(ctxt, t, off, sect.Vaddr-textbase, int64(SysArch.PtrSize))
+ off = setuintxx(ctxt, t, off, sect.Length, int64(SysArch.PtrSize))
if n == 0 {
s := ctxt.Syms.ROLookup("runtime.text", 0)
if s == nil {