}
func appendParamTypes(rts []*types.Type, t *types.Type) []*types.Type {
- w := t.Width
+ w := t.Size()
if w == 0 {
return rts
}
// to input offsets, and returns the longer slice and the next unused offset.
func appendParamOffsets(offsets []int64, at int64, t *types.Type) ([]int64, int64) {
at = align(at, t)
- w := t.Width
+ w := t.Size()
if w == 0 {
return offsets, at
}
if t.IsScalar() || t.IsPtrShaped() {
- if t.IsComplex() || int(t.Width) > types.RegSize { // complex and *int64 on 32-bit
+ if t.IsComplex() || int(t.Size()) > types.RegSize { // complex and *int64 on 32-bit
s := w / 2
return append(offsets, at, at+s), at + w
} else {
case types.TSTRUCT:
for i, f := range t.FieldSlice() {
offsets, at = appendParamOffsets(offsets, at, f.Type)
- if f.Type.Width == 0 && i == t.NumFields()-1 {
+ if f.Type.Size() == 0 && i == t.NumFields()-1 {
at++ // last field has zero width
}
}
// align returns a rounded up to t's alignment
func align(a int64, t *types.Type) int64 {
- return alignTo(a, int(t.Align))
+ return alignTo(a, int(uint8(t.Alignment())))
}
// alignTo returns a rounded up to t, where t must be 0 or a power of 2.
// specified type.
func (state *assignState) stackSlot(t *types.Type) int64 {
rv := align(state.stackOffset, t)
- state.stackOffset = rv + t.Width
+ state.stackOffset = rv + t.Size()
return rv
}
// that we've just determined to be register-assignable. The number of registers
// needed is assumed to be stored in state.pUsed.
func (state *assignState) allocateRegs(regs []RegIndex, t *types.Type) []RegIndex {
- if t.Width == 0 {
+ if t.Size() == 0 {
return regs
}
ri := state.rUsed.intRegs
// can register allocate, FALSE otherwise (and updates state
// accordingly).
func (state *assignState) regassignIntegral(t *types.Type) bool {
- regsNeeded := int(types.Rnd(t.Width, int64(types.PtrSize)) / int64(types.PtrSize))
+ regsNeeded := int(types.Rnd(t.Size(), int64(types.PtrSize)) / int64(types.PtrSize))
if t.IsComplex() {
regsNeeded = 2
}
// ABIParamResultInfo held in 'state'.
func (state *assignState) assignParamOrReturn(pt *types.Type, n types.Object, isReturn bool) ABIParamAssignment {
state.pUsed = RegAmounts{}
- if pt.Width == types.BADWIDTH {
+ if pt.Size() == types.BADWIDTH {
base.Fatalf("should never happen")
panic("unreachable")
- } else if pt.Width == 0 {
+ } else if pt.Size() == 0 {
return state.stackAllocate(pt, n)
} else if state.regassign(pt) {
return state.regAllocate(pt, n, isReturn)
}
}
- if n.Type().Width > ir.MaxStackVarSize {
+ if n.Type().Size() > ir.MaxStackVarSize {
return "too large for stack"
}
- if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Width > ir.MaxImplicitStackVarSize {
+ if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Size() > ir.MaxImplicitStackVarSize {
return "too large for stack"
}
if !ir.IsSmallIntConst(r) {
return "non-constant size"
}
- if t := n.Type(); t.Elem().Width != 0 && ir.Int64Val(r) > ir.MaxImplicitStackVarSize/t.Elem().Width {
+ if t := n.Type(); t.Elem().Size() != 0 && ir.Int64Val(r) > ir.MaxImplicitStackVarSize/t.Elem().Size() {
return "too large for stack"
}
}
if !t.IsStruct() || t.StructType().Map != nil || t.IsFuncArgStruct() {
break
}
- fmt.Fprintf(b, "#define %s__size %d\n", n.Sym().Name, int(t.Width))
+ fmt.Fprintf(b, "#define %s__size %d\n", n.Sym().Name, int(t.Size()))
for _, f := range t.Fields().Slice() {
if !f.Sym.IsBlank() {
fmt.Fprintf(b, "#define %s_%s %d\n", n.Sym().Name, f.Sym.Name, int(f.Offset))
if nam.Type() != nil && !nam.Type().HasPointers() {
flags |= obj.NOPTR
}
- base.Ctxt.Globl(s, nam.Type().Width, flags)
+ base.Ctxt.Globl(s, nam.Type().Size(), flags)
if nam.LibfuzzerExtraCounter() {
s.Type = objabi.SLIBFUZZER_EXTRA_COUNTER
}
}
}
- if n.Class == ir.PPARAM && !n.Addrtaken() && n.Type().Width > int64(types.PtrSize) {
+ if n.Class == ir.PPARAM && !n.Addrtaken() && n.Type().Size() > int64(types.PtrSize) {
// Only aggregate-typed arguments that are not address-taken can be
// partially live.
lv.partLiveArgs[n] = true
off = objw.Uint32(x, off, uint32(frameOffset))
t := v.Type()
- sz := t.Width
+ sz := t.Size()
if sz != int64(int32(sz)) {
base.Fatalf("stack object too big: %v of type %v, size %d", v, t, sz)
}
aop, _ := typecheck.Assignop(lt, rt)
if aop != ir.OXXX {
types.CalcSize(lt)
- if lt.HasTParam() || rt.IsInterface() == lt.IsInterface() || lt.Width >= 1<<16 {
+ if lt.HasTParam() || rt.IsInterface() == lt.IsInterface() || lt.Size() >= 1<<16 {
l = ir.NewConvExpr(base.Pos, aop, rt, l)
l.SetTypecheck(1)
}
aop, _ := typecheck.Assignop(rt, lt)
if aop != ir.OXXX {
types.CalcSize(rt)
- if rt.HasTParam() || rt.IsInterface() == lt.IsInterface() || rt.Width >= 1<<16 {
+ if rt.HasTParam() || rt.IsInterface() == lt.IsInterface() || rt.Size() >= 1<<16 {
r = ir.NewConvExpr(base.Pos, aop, lt, r)
r.SetTypecheck(1)
}
func AlgType(t *types.Type) types.AlgKind {
a, _ := types.AlgType(t)
if a == types.AMEM {
- if t.Alignment() < int64(base.Ctxt.Arch.Alignment) && t.Alignment() < t.Width {
+ if t.Alignment() < int64(base.Ctxt.Arch.Alignment) && t.Alignment() < t.Size() {
// For example, we can't treat [2]int16 as an int32 if int32s require
// 4-byte alignment. See issue 46283.
return a
}
- switch t.Width {
+ switch t.Size() {
case 0:
return types.AMEM0
case 1:
// For other sizes of plain memory, we build a closure
// that calls memhash_varlen. The size of the memory is
// encoded in the first slot of the closure.
- closure := TypeLinksymLookup(fmt.Sprintf(".hashfunc%d", t.Width))
+ closure := TypeLinksymLookup(fmt.Sprintf(".hashfunc%d", t.Size()))
if len(closure.P) > 0 { // already generated
return closure
}
}
ot := 0
ot = objw.SymPtr(closure, ot, memhashvarlen, 0)
- ot = objw.Uintptr(closure, ot, uint64(t.Width)) // size encoded in closure
+ ot = objw.Uintptr(closure, ot, uint64(t.Size())) // size encoded in closure
objw.Global(closure, int32(ot), obj.DUPOK|obj.RODATA)
return closure
case types.ASPECIAL:
case types.AMEM:
// make equality closure. The size of the type
// is encoded in the closure.
- closure := TypeLinksymLookup(fmt.Sprintf(".eqfunc%d", t.Width))
+ closure := TypeLinksymLookup(fmt.Sprintf(".eqfunc%d", t.Size()))
if len(closure.P) != 0 {
return closure
}
}
ot := 0
ot = objw.SymPtr(closure, ot, memequalvarlen, 0)
- ot = objw.Uintptr(closure, ot, uint64(t.Width))
+ ot = objw.Uintptr(closure, ot, uint64(t.Size()))
objw.Global(closure, int32(ot), obj.DUPOK|obj.RODATA)
return closure
case types.ASPECIAL:
elemtype := t.Elem()
types.CalcSize(keytype)
types.CalcSize(elemtype)
- if keytype.Width > MAXKEYSIZE {
+ if keytype.Size() > MAXKEYSIZE {
keytype = types.NewPtr(keytype)
}
- if elemtype.Width > MAXELEMSIZE {
+ if elemtype.Size() > MAXELEMSIZE {
elemtype = types.NewPtr(elemtype)
}
if BUCKETSIZE < 8 {
base.Fatalf("bucket size too small for proper alignment")
}
- if keytype.Align > BUCKETSIZE {
+ if uint8(keytype.Alignment()) > BUCKETSIZE {
base.Fatalf("key align too big for %v", t)
}
- if elemtype.Align > BUCKETSIZE {
+ if uint8(elemtype.Alignment()) > BUCKETSIZE {
base.Fatalf("elem align too big for %v", t)
}
- if keytype.Width > MAXKEYSIZE {
+ if keytype.Size() > MAXKEYSIZE {
base.Fatalf("key size to large for %v", t)
}
- if elemtype.Width > MAXELEMSIZE {
+ if elemtype.Size() > MAXELEMSIZE {
base.Fatalf("elem size to large for %v", t)
}
- if t.Key().Width > MAXKEYSIZE && !keytype.IsPtr() {
+ if t.Key().Size() > MAXKEYSIZE && !keytype.IsPtr() {
base.Fatalf("key indirect incorrect for %v", t)
}
- if t.Elem().Width > MAXELEMSIZE && !elemtype.IsPtr() {
+ if t.Elem().Size() > MAXELEMSIZE && !elemtype.IsPtr() {
base.Fatalf("elem indirect incorrect for %v", t)
}
- if keytype.Width%int64(keytype.Align) != 0 {
+ if keytype.Size()%keytype.Alignment() != 0 {
base.Fatalf("key size not a multiple of key align for %v", t)
}
- if elemtype.Width%int64(elemtype.Align) != 0 {
+ if elemtype.Size()%elemtype.Alignment() != 0 {
base.Fatalf("elem size not a multiple of elem align for %v", t)
}
- if bucket.Align%keytype.Align != 0 {
+ if uint8(bucket.Alignment())%uint8(keytype.Alignment()) != 0 {
base.Fatalf("bucket align not multiple of key align %v", t)
}
- if bucket.Align%elemtype.Align != 0 {
+ if uint8(bucket.Alignment())%uint8(elemtype.Alignment()) != 0 {
base.Fatalf("bucket align not multiple of elem align %v", t)
}
- if keys.Offset%int64(keytype.Align) != 0 {
+ if keys.Offset%keytype.Alignment() != 0 {
base.Fatalf("bad alignment of keys in bmap for %v", t)
}
- if elems.Offset%int64(elemtype.Align) != 0 {
+ if elems.Offset%elemtype.Alignment() != 0 {
base.Fatalf("bad alignment of elems in bmap for %v", t)
}
// Double-check that overflow field is final memory in struct,
// with no padding at end.
- if overflow.Offset != bucket.Width-int64(types.PtrSize) {
+ if overflow.Offset != bucket.Size()-int64(types.PtrSize) {
base.Fatalf("bad offset of overflow in bmap for %v", t)
}
// The size of hmap should be 48 bytes on 64 bit
// and 28 bytes on 32 bit platforms.
- if size := int64(8 + 5*types.PtrSize); hmap.Width != size {
- base.Fatalf("hmap size not correct: got %d, want %d", hmap.Width, size)
+ if size := int64(8 + 5*types.PtrSize); hmap.Size() != size {
+ base.Fatalf("hmap size not correct: got %d, want %d", hmap.Size(), size)
}
t.MapType().Hmap = hmap
hiter := types.NewStruct(types.NoPkg, fields)
hiter.SetNoalg(true)
types.CalcSize(hiter)
- if hiter.Width != int64(12*types.PtrSize) {
- base.Fatalf("hash_iter size not correct %d %d", hiter.Width, 12*types.PtrSize)
+ if hiter.Size() != int64(12*types.PtrSize) {
+ base.Fatalf("hash_iter size not correct %d %d", hiter.Size(), 12*types.PtrSize)
}
t.MapType().Hiter = hiter
hiter.StructType().Map = t
// ptrToThis typeOff
// }
ot := 0
- ot = objw.Uintptr(lsym, ot, uint64(t.Width))
+ ot = objw.Uintptr(lsym, ot, uint64(t.Size()))
ot = objw.Uintptr(lsym, ot, uint64(ptrdata))
ot = objw.Uint32(lsym, ot, types.TypeHash(t))
ot = objw.Uint8(lsym, ot, tflag)
// runtime (and common sense) expects alignment to be a power of two.
- i := int(t.Align)
+ i := int(uint8(t.Alignment()))
if i == 0 {
i = 1
}
if i&(i-1) != 0 {
- base.Fatalf("invalid alignment %d for %v", t.Align, t)
+ base.Fatalf("invalid alignment %d for %v", uint8(t.Alignment()), t)
}
- ot = objw.Uint8(lsym, ot, t.Align) // align
- ot = objw.Uint8(lsym, ot, t.Align) // fieldAlign
+ ot = objw.Uint8(lsym, ot, uint8(t.Alignment())) // align
+ ot = objw.Uint8(lsym, ot, uint8(t.Alignment())) // fieldAlign
i = kinds[t.Kind()]
if types.IsDirectIface(t) {
var flags uint32
// Note: flags must match maptype accessors in ../../../../runtime/type.go
// and maptype builder in ../../../../reflect/type.go:MapOf.
- if t.Key().Width > MAXKEYSIZE {
+ if t.Key().Size() > MAXKEYSIZE {
ot = objw.Uint8(lsym, ot, uint8(types.PtrSize))
flags |= 1 // indirect key
} else {
- ot = objw.Uint8(lsym, ot, uint8(t.Key().Width))
+ ot = objw.Uint8(lsym, ot, uint8(t.Key().Size()))
}
- if t.Elem().Width > MAXELEMSIZE {
+ if t.Elem().Size() > MAXELEMSIZE {
ot = objw.Uint8(lsym, ot, uint8(types.PtrSize))
flags |= 2 // indirect value
} else {
- ot = objw.Uint8(lsym, ot, uint8(t.Elem().Width))
+ ot = objw.Uint8(lsym, ot, uint8(t.Elem().Size()))
}
- ot = objw.Uint16(lsym, ot, uint16(MapBucketType(t).Width))
+ ot = objw.Uint16(lsym, ot, uint16(MapBucketType(t).Size()))
if types.IsReflexive(t.Key()) {
flags |= 4 // reflexive key
}
// For non-trivial arrays, the program describes the full t.Width size.
func dgcprog(t *types.Type, write bool) (*obj.LSym, int64) {
types.CalcSize(t)
- if t.Width == types.BADWIDTH {
+ if t.Size() == types.BADWIDTH {
base.Fatalf("dgcprog: %v badwidth", t)
}
lsym := TypeLinksymPrefix(".gcprog", t)
p.emit(t, 0)
offset := p.w.BitIndex() * int64(types.PtrSize)
p.end()
- if ptrdata := types.PtrDataSize(t); offset < ptrdata || offset > t.Width {
- base.Fatalf("dgcprog: %v: offset=%d but ptrdata=%d size=%d", t, offset, ptrdata, t.Width)
+ if ptrdata := types.PtrDataSize(t); offset < ptrdata || offset > t.Size() {
+ base.Fatalf("dgcprog: %v: offset=%d but ptrdata=%d size=%d", t, offset, ptrdata, t.Size())
}
return lsym, offset
}
if !t.HasPointers() {
return
}
- if t.Width == int64(types.PtrSize) {
+ if t.Size() == int64(types.PtrSize) {
p.w.Ptr(offset / int64(types.PtrSize))
return
}
elem = elem.Elem()
}
- if !p.w.ShouldRepeat(elem.Width/int64(types.PtrSize), count) {
+ if !p.w.ShouldRepeat(elem.Size()/int64(types.PtrSize), count) {
// Cheaper to just emit the bits.
for i := int64(0); i < count; i++ {
- p.emit(elem, offset+i*elem.Width)
+ p.emit(elem, offset+i*elem.Size())
}
return
}
p.emit(elem, offset)
- p.w.ZeroUntil((offset + elem.Width) / int64(types.PtrSize))
- p.w.Repeat(elem.Width/int64(types.PtrSize), count-1)
+ p.w.ZeroUntil((offset + elem.Size()) / int64(types.PtrSize))
+ p.w.Repeat(elem.Size()/int64(types.PtrSize), count-1)
case types.TSTRUCT:
for _, t1 := range t.Fields().Slice() {
split, _ = sc.lookup(*ls.SplitOf)
}
k := slotKey{
- name: ls.N, offset: ls.Off, width: ls.Type.Width,
+ name: ls.N, offset: ls.Off, width: ls.Type.Size(),
splitOf: split, splitOffset: ls.SplitOffset,
}
if idx, ok := sc.slmap[k]; ok {
}
if len(inp.Registers) > 1 {
list = append(list, dwarf.DW_OP_piece)
- ts := rtypes[k].Width
+ ts := rtypes[k].Size()
list = dwarf.AppendUleb128(list, uint64(ts))
if padding[k] > 0 {
if loggingEnabled {
locs = x.splitSlots(ls, ".real", 0, selector.Type)
case OpComplexImag:
- ls := x.rewriteSelect(leaf, selector.Args[0], offset+selector.Type.Width, regOffset+RO_complex_imag) // result is FloatNN, width of result is offset of imaginary part.
- locs = x.splitSlots(ls, ".imag", selector.Type.Width, selector.Type)
+ ls := x.rewriteSelect(leaf, selector.Args[0], offset+selector.Type.Size(), regOffset+RO_complex_imag) // result is FloatNN, width of result is offset of imaginary part.
+ locs = x.splitSlots(ls, ".imag", selector.Type.Size(), selector.Type)
case OpStringLen, OpSliceLen:
ls := x.rewriteSelect(leaf, selector.Args[0], offset+x.ptrSize, regOffset+RO_slice_len)
}
return path
case types.TINT64, types.TUINT64:
- if container.Width == x.regSize {
+ if container.Size() == x.regSize {
return path
}
if offset == x.hiOffset {
for i := 0; i < len(rts); i++ {
rt := rts[i]
off := offs[i]
- fmt.Printf("rt=%s, off=%d, rt.Width=%d, rt.Align=%d\n", rt.String(), off, rt.Width, rt.Align)
+ fmt.Printf("rt=%s, off=%d, rt.Width=%d, rt.Align=%d\n", rt.String(), off, rt.Size(), uint8(rt.Alignment()))
}
panic(fmt.Errorf("offset %d of requested register %d should be zero, source=%s", offs[loadRegOffset], loadRegOffset, source.LongString()))
}
for i := loadRegOffset; i < last; i++ {
rt := rts[i]
off := offs[i]
- w := x.commonArgs[selKey{source, off, rt.Width, rt}]
+ w := x.commonArgs[selKey{source, off, rt.Size(), rt}]
if w == nil {
w = x.newArgToMemOrRegs(source, w, off, i, rt, pos)
suffix := x.pathTo(source.Type, rt, off)
if t.IsPtrShaped() {
// Preserve the original store type. This ensures pointer type
// properties aren't discarded (e.g, notinheap).
- if rt.Width != t.Width || len(pa.Registers) != 1 || i != loadRegOffset {
+ if rt.Size() != t.Size() || len(pa.Registers) != 1 || i != loadRegOffset {
b.Func.Fatalf("incompatible store type %v and %v, i=%d", t, rt, i)
}
rt = t
}
return mem
case types.TINT64, types.TUINT64:
- if t.Width == x.regSize {
+ if t.Size() == x.regSize {
break
}
tHi, tLo := x.intPairTypes(t.Kind())
}
return mem
case types.TINT64, types.TUINT64:
- if t.Width == x.regSize {
+ if t.Size() == x.regSize {
break
}
tHi, tLo := x.intPairTypes(t.Kind())
x.Printf("storeOneArg(%s; %s; %s; aO=%d; sO=%d; lrO=%d; %s)\n", source.LongString(), mem.String(), t.String(), argOffset, storeOffset, loadRegOffset, storeRc.String())
}
- w := x.commonArgs[selKey{source, argOffset, t.Width, t}]
+ w := x.commonArgs[selKey{source, argOffset, t.Size(), t}]
if w == nil {
w = x.newArgToMemOrRegs(source, w, argOffset, loadRegOffset, t, pos)
x.splitSlotsIntoNames(locs, suffix, argOffset, t, w)
case OpComplexMake:
tPart := x.typs.Float32
- wPart := t.Width / 2
+ wPart := t.Size() / 2
if wPart == 8 {
tPart = x.typs.Float64
}
switch t.Kind() {
case types.TARRAY:
elt := t.Elem()
- if source.Type != t && t.NumElem() == 1 && elt.Width == t.Width && t.Width == x.regSize {
+ if source.Type != t && t.NumElem() == 1 && elt.Size() == t.Size() && t.Size() == x.regSize {
t = removeTrivialWrapperTypes(t)
// it could be a leaf type, but the "leaf" could be complex64 (for example)
return x.storeArgOrLoad(pos, b, source, mem, t, storeOffset, loadRegOffset, storeRc)
eltRO := x.regWidth(elt)
for i := int64(0); i < t.NumElem(); i++ {
sel := source.Block.NewValue1I(pos, OpArraySelect, elt, i, source)
- mem = x.storeArgOrLoad(pos, b, sel, mem, elt, storeOffset+i*elt.Width, loadRegOffset, storeRc.at(t, 0))
+ mem = x.storeArgOrLoad(pos, b, sel, mem, elt, storeOffset+i*elt.Size(), loadRegOffset, storeRc.at(t, 0))
loadRegOffset += eltRO
pos = pos.WithNotStmt()
}
return mem
case types.TSTRUCT:
- if source.Type != t && t.NumFields() == 1 && t.Field(0).Type.Width == t.Width && t.Width == x.regSize {
+ if source.Type != t && t.NumFields() == 1 && t.Field(0).Type.Size() == t.Size() && t.Size() == x.regSize {
// This peculiar test deals with accesses to immediate interface data.
// It works okay because everything is the same size.
// Example code that triggers this can be found in go/constant/value.go, function ToComplex
return mem
case types.TINT64, types.TUINT64:
- if t.Width == x.regSize {
+ if t.Size() == x.regSize {
break
}
tHi, tLo := x.intPairTypes(t.Kind())
if typ.IsMemory() {
continue // handled elsewhere, not an indexable result
}
- size := typ.Width
+ size := typ.Size()
offset := int64(0)
switch v.Op {
case OpStructSelect:
case OpArgIntReg:
i := v.AuxInt
if w := IArg[i]; w != nil {
- if w.Type.Width != v.Type.Width {
+ if w.Type.Size() != v.Type.Size() {
f.Fatalf("incompatible OpArgIntReg [%d]: %s and %s", i, v.LongString(), w.LongString())
}
if w.Type.IsUnsafePtr() && !v.Type.IsUnsafePtr() {
case OpArgFloatReg:
i := v.AuxInt
if w := FArg[i]; w != nil {
- if w.Type.Width != v.Type.Width {
+ if w.Type.Size() != v.Type.Size() {
f.Fatalf("incompatible OpArgFloatReg [%d]: %v and %v", i, v, w)
}
v.copyOf(w)
}
case 1:
t := v.Type
- key := selKey{v, 0, t.Width, t}
+ key := selKey{v, 0, t.Size(), t}
w := x.commonArgs[key]
if w != nil {
v.copyOf(w)
defer x.indent(-3)
x.Printf("newArgToMemOrRegs(base=%s; toReplace=%s; t=%s; memOff=%d; regOff=%d)\n", baseArg.String(), toReplace.LongString(), t.String(), offset, regOffset)
}
- key := selKey{baseArg, offset, t.Width, t}
+ key := selKey{baseArg, offset, t.Size(), t}
w := x.commonArgs[key]
if w != nil {
if toReplace != nil {
// SizeOfResult returns the size of result which (indexed 0, 1, etc).
func (a *AuxCall) SizeOfResult(which int64) int64 {
- return a.TypeOfResult(which).Width
+ return a.TypeOfResult(which).Size()
}
// SizeOfArg returns the size of argument which (indexed 0, 1, etc).
// If the call is to a method, the receiver is the first argument (i.e., index 0)
func (a *AuxCall) SizeOfArg(which int64) int64 {
- return a.TypeOfArg(which).Width
+ return a.TypeOfArg(which).Size()
}
// NResults returns the number of results
OpAMD64SHLL, OpAMD64SHLLconst:
return true
case OpArg:
- return x.Type.Width == 4
+ return x.Type.Size() == 4
case OpPhi, OpSelect0, OpSelect1:
// Phis can use each-other as an arguments, instead of tracking visited values,
// just limit recursion depth.
case OpAMD64MOVWQZX, OpAMD64MOVWload, OpAMD64MOVWloadidx1, OpAMD64MOVWloadidx2:
return true
case OpArg:
- return x.Type.Width == 2
+ return x.Type.Size() == 2
case OpPhi, OpSelect0, OpSelect1:
// Phis can use each-other as an arguments, instead of tracking visited values,
// just limit recursion depth.
case OpAMD64MOVBQZX, OpAMD64MOVBload, OpAMD64MOVBloadidx1:
return true
case OpArg:
- return x.Type.Width == 1
+ return x.Type.Size() == 1
case OpPhi, OpSelect0, OpSelect1:
// Phis can use each-other as an arguments, instead of tracking visited values,
// just limit recursion depth.
return ap
}
- if a.Type().Width != b.Type().Width {
- return a.Type().Width > b.Type().Width
+ if a.Type().Size() != b.Type().Size() {
+ return a.Type().Size() > b.Type().Size()
}
return a.Sym().Name < b.Sym().Name
}
types.CalcSize(n.Type())
- w := n.Type().Width
+ w := n.Type().Size()
if w >= types.MaxWidth || w < 0 {
base.Fatalf("bad width")
}
w = 1
}
s.stksize += w
- s.stksize = types.Rnd(s.stksize, int64(n.Type().Align))
+ s.stksize = types.Rnd(s.stksize, n.Type().Alignment())
if n.Type().HasPointers() {
s.stkptrsize = s.stksize
lastHasPtr = true
types.CalcSize(from)
types.CalcSize(to)
- if from.Width != to.Width {
- s.Fatalf("CONVNOP width mismatch %v (%d) -> %v (%d)\n", from, from.Width, to, to.Width)
+ if from.Size() != to.Size() {
+ s.Fatalf("CONVNOP width mismatch %v (%d) -> %v (%d)\n", from, from.Size(), to, to.Size())
return nil
}
if etypesign(from.Kind()) != etypesign(to.Kind()) {
// TypeOK reports whether variables of type t are SSA-able.
func TypeOK(t *types.Type) bool {
types.CalcSize(t)
- if t.Width > int64(4*types.PtrSize) {
+ if t.Size() > int64(4*types.PtrSize) {
// 4*Widthptr is an arbitrary constant. We want it
// to be at least 3*Widthptr so slices can be registerized.
// Too big and we'll introduce too much register pressure.
//
// Where mask(x) is 0 if x==0 and -1 if x>0 and stride is the width
// of the element type.
- stride := s.constInt(types.Types[types.TINT], ptr.Type.Elem().Width)
+ stride := s.constInt(types.Types[types.TINT], ptr.Type.Elem().Size())
// The delta is the number of bytes to offset ptr by.
delta := s.newValue2(mulOp, types.Types[types.TINT], i, stride)
s.vars[n] = s.load(lenType, x)
case ir.OCAP:
// capacity is stored in the second word for chan
- sw := s.newValue1I(ssa.OpOffPtr, lenType.PtrTo(), lenType.Width, x)
+ sw := s.newValue1I(ssa.OpOffPtr, lenType.PtrTo(), lenType.Size(), x)
s.vars[n] = s.load(lenType, sw)
default:
s.Fatalf("op must be OLEN or OCAP")
if ir.IsZero(r) {
return true
}
- staticdata.InitConst(l, loff, r, int(typ.Width))
+ staticdata.InitConst(l, loff, r, int(typ.Size()))
return true
case ir.OADDR:
e := &p.E[i]
typ := e.Expr.Type()
if e.Expr.Op() == ir.OLITERAL || e.Expr.Op() == ir.ONIL {
- staticdata.InitConst(l, loff+e.Xoffset, e.Expr, int(typ.Width))
+ staticdata.InitConst(l, loff+e.Xoffset, e.Expr, int(typ.Size()))
continue
}
x := e.Expr
if ir.IsZero(r) {
return true
}
- staticdata.InitConst(l, loff, r, int(typ.Width))
+ staticdata.InitConst(l, loff, r, int(typ.Size()))
return true
case ir.OADDR:
for i := range p.E {
e := &p.E[i]
if e.Expr.Op() == ir.OLITERAL || e.Expr.Op() == ir.ONIL {
- staticdata.InitConst(l, loff+e.Xoffset, e.Expr, int(e.Expr.Type().Width))
+ staticdata.InitConst(l, loff+e.Xoffset, e.Expr, int(e.Expr.Type().Size()))
continue
}
ir.SetPos(e.Expr)
}
a = kv.Value
}
- s.addvalue(p, k*n.Type().Elem().Width, a)
+ s.addvalue(p, k*n.Type().Elem().Size(), a)
k++
}
}
// Check for overflow.
- if n.Type().Width != 0 && types.MaxWidth/n.Type().Width <= int64(l) {
+ if n.Type().Size() != 0 && types.MaxWidth/n.Type().Size() <= int64(l) {
break
}
- offset += int64(l) * n.Type().Width
+ offset += int64(l) * n.Type().Size()
return name, offset, true
}
// the first run and then simply copied into bv at the correct offset
// on future calls with the same type t.
func Set(t *types.Type, off int64, bv bitvec.BitVec) {
- if t.Align > 0 && off&int64(t.Align-1) != 0 {
- base.Fatalf("typebits.Set: invalid initial alignment: type %v has alignment %d, but offset is %v", t, t.Align, off)
+ if uint8(t.Alignment()) > 0 && off&int64(uint8(t.Alignment())-1) != 0 {
+ base.Fatalf("typebits.Set: invalid initial alignment: type %v has alignment %d, but offset is %v", t, uint8(t.Alignment()), off)
}
if !t.HasPointers() {
// Note: this case ensures that pointers to go:notinheap types
case types.TARRAY:
elt := t.Elem()
- if elt.Width == 0 {
+ if elt.Size() == 0 {
// Short-circuit for #20739.
break
}
for i := int64(0); i < t.NumElem(); i++ {
Set(elt, off, bv)
- off += elt.Width
+ off += elt.Size()
}
case types.TSTRUCT:
}
types.CalcSize(tr)
if n.Op() == ir.OALIGNOF {
- return int64(tr.Align)
+ return tr.Alignment()
}
- return tr.Width
+ return tr.Size()
case ir.OOFFSETOF:
// must be a selector.
}
types.CalcSize(l.Type())
- if r.Type().IsInterface() == l.Type().IsInterface() || l.Type().Width >= 1<<16 {
+ if r.Type().IsInterface() == l.Type().IsInterface() || l.Type().Size() >= 1<<16 {
l = ir.NewConvExpr(base.Pos, aop, r.Type(), l)
l.SetTypecheck(1)
}
}
types.CalcSize(r.Type())
- if r.Type().IsInterface() == l.Type().IsInterface() || r.Type().Width >= 1<<16 {
+ if r.Type().IsInterface() == l.Type().IsInterface() || r.Type().Size() >= 1<<16 {
r = ir.NewConvExpr(base.Pos, aop, l.Type(), r)
r.SetTypecheck(1)
}
if !t.IsStruct() {
base.Fatalf("IsPaddedField called non-struct %v", t)
}
- end := t.Width
+ end := t.width
if i+1 < t.NumFields() {
end = t.Field(i + 1).Offset
}
}
CalcSize(f.Type)
- if int32(f.Type.Align) > maxalign {
- maxalign = int32(f.Type.Align)
+ if int32(f.Type.align) > maxalign {
+ maxalign = int32(f.Type.align)
}
- if f.Type.Align > 0 {
- o = Rnd(o, int64(f.Type.Align))
+ if f.Type.align > 0 {
+ o = Rnd(o, int64(f.Type.align))
}
if isStruct { // For receiver/args/results, do not set, it depends on ABI
f.Offset = o
}
- w := f.Type.Width
+ w := f.Type.width
if w < 0 {
- base.Fatalf("invalid width %d", f.Type.Width)
+ base.Fatalf("invalid width %d", f.Type.width)
}
if w == 0 {
lastzero = o
if flag != 0 {
o = Rnd(o, int64(maxalign))
}
- t.Align = uint8(maxalign)
+ t.align = uint8(maxalign)
// type width only includes back to first field's offset
- t.Width = o - starto
+ t.width = o - starto
return o
}
return
}
- if t.Width == -2 {
+ if t.width == -2 {
reportTypeLoop(t)
- t.Width = 0
- t.Align = 1
+ t.width = 0
+ t.align = 1
return
}
// break infinite recursion if the broken recursive type
// is referenced again
- if t.Broke() && t.Width == 0 {
+ if t.Broke() && t.width == 0 {
return
}
base.Pos = pos
}
- t.Width = -2
- t.Align = 0 // 0 means use t.Width, below
+ t.width = -2
+ t.align = 0 // 0 means use t.Width, below
et := t.Kind()
switch et {
case TINT64, TUINT64, TFLOAT64:
w = 8
- t.Align = uint8(RegSize)
+ t.align = uint8(RegSize)
case TCOMPLEX64:
w = 8
- t.Align = 4
+ t.align = 4
case TCOMPLEX128:
w = 16
- t.Align = uint8(RegSize)
+ t.align = uint8(RegSize)
case TPTR:
w = int64(PtrSize)
case TINTER: // implemented as 2 pointers
w = 2 * int64(PtrSize)
- t.Align = uint8(PtrSize)
+ t.align = uint8(PtrSize)
expandiface(t)
case TUNION:
// Always part of an interface for now, so size/align don't matter.
// Pretend a union is represented like an interface.
w = 2 * int64(PtrSize)
- t.Align = uint8(PtrSize)
+ t.align = uint8(PtrSize)
case TCHAN: // implemented as pointer
w = int64(PtrSize)
case TCHANARGS:
t1 := t.ChanArgs()
CalcSize(t1) // just in case
- if t1.Elem().Width >= 1<<16 {
+ if t1.Elem().width >= 1<<16 {
base.ErrorfAt(typePos(t1), "channel element type too large (>64kB)")
}
w = 1 // anything will do
base.Fatalf("early CalcSize string")
}
w = StringSize
- t.Align = uint8(PtrSize)
+ t.align = uint8(PtrSize)
case TARRAY:
if t.Elem() == nil {
}
CalcSize(t.Elem())
- if t.Elem().Width != 0 {
- cap := (uint64(MaxWidth) - 1) / uint64(t.Elem().Width)
+ if t.Elem().width != 0 {
+ cap := (uint64(MaxWidth) - 1) / uint64(t.Elem().width)
if uint64(t.NumElem()) > cap {
base.ErrorfAt(typePos(t), "type %L larger than address space", t)
}
}
- w = t.NumElem() * t.Elem().Width
- t.Align = t.Elem().Align
+ w = t.NumElem() * t.Elem().width
+ t.align = t.Elem().align
case TSLICE:
if t.Elem() == nil {
}
w = SliceSize
CheckSize(t.Elem())
- t.Align = uint8(PtrSize)
+ t.align = uint8(PtrSize)
case TSTRUCT:
if t.IsFuncArgStruct() {
if w%int64(RegSize) != 0 {
base.Warn("bad type %v %d\n", t1, w)
}
- t.Align = 1
+ t.align = 1
case TTYPEPARAM:
// TODO(danscales) - remove when we eliminate the need
base.ErrorfAt(typePos(t), "type %v too large", t)
}
- t.Width = w
- if t.Align == 0 {
+ t.width = w
+ if t.align == 0 {
if w == 0 || w > 8 || w&(w-1) != 0 {
base.Fatalf("invalid alignment for %v", t)
}
- t.Align = uint8(w)
+ t.align = uint8(w)
}
base.Pos = lno
// filling in s.Width and s.Align,
// even if size calculation is otherwise disabled.
func CalcStructSize(s *Type) {
- s.Width = calcStructOffset(s, s, 0, 1) // sets align
+ s.width = calcStructOffset(s, s, 0, 1) // sets align
}
// RecalcSize is like CalcSize, but recalculates t's size even if it
// has already been calculated before. It does not recalculate other
// types.
func RecalcSize(t *Type) {
- t.Align = 0
+ t.align = 0
CalcSize(t)
}
case TARRAY:
// haspointers already eliminated t.NumElem() == 0.
- return (t.NumElem()-1)*t.Elem().Width + PtrDataSize(t.Elem())
+ return (t.NumElem()-1)*t.Elem().width + PtrDataSize(t.Elem())
case TSTRUCT:
// Find the last field that has pointers.
// TTYPEPARAM: *Typeparam
extra interface{}
- // Width is the width of this Type in bytes.
- Width int64 // valid if Align > 0
+ // width is the width of this Type in bytes.
+ width int64 // valid if Align > 0
// list of base methods (excluding embedding)
methods Fields
vargen int32 // unique name for OTYPE/ONAME
kind Kind // kind of type
- Align uint8 // the required alignment of this type, in bytes (0 means Width and Align have not yet been computed)
+ align uint8 // the required alignment of this type, in bytes (0 means Width and Align have not yet been computed)
flags bitset8
// End returns the offset of the first byte immediately after this field.
func (f *Field) End() int64 {
- return f.Offset + f.Type.Width
+ return f.Offset + f.Type.width
}
// IsMethod reports whether f represents a method rather than a struct field.
func New(et Kind) *Type {
t := &Type{
kind: et,
- Width: BADWIDTH,
+ width: BADWIDTH,
}
t.underlying = t
// TODO(josharian): lazily initialize some of these?
t := New(TPTR)
t.extra = Ptr{Elem: elem}
- t.Width = int64(PtrSize)
- t.Align = uint8(PtrSize)
+ t.width = int64(PtrSize)
+ t.align = uint8(PtrSize)
if NewPtrCacheEnabled {
elem.cache.ptr = t
}
}
func (t *Type) WidthCalculated() bool {
- return t.Align > 0
+ return t.align > 0
}
// ArgWidth returns the total aligned argument size for a function.
return 0
}
CalcSize(t)
- return t.Width
+ return t.width
}
func (t *Type) Alignment() int64 {
CalcSize(t)
- return int64(t.Align)
+ return int64(t.align)
}
func (t *Type) SimpleString() string {
// TODO(mdempsky): Fix Type rekinding.
t.kind = underlying.kind
t.extra = underlying.extra
- t.Width = underlying.Width
- t.Align = underlying.Align
+ t.width = underlying.width
+ t.align = underlying.align
t.underlying = underlying.underlying
if underlying.NotInHeap() {
a := n.Lhs[0]
var call *ir.CallExpr
- if w := t.Elem().Width; w <= zeroValSize {
+ if w := t.Elem().Size(); w <= zeroValSize {
fn := mapfn(mapaccess2[fast], t, false)
call = mkcall1(fn, fn.Type().Results(), init, reflectdata.TypePtr(t), r.X, key)
} else {
fn := typecheck.LookupRuntime("slicecopy")
fn = typecheck.SubstArgTypes(fn, ptr1.Type().Elem(), ptr2.Type().Elem())
- ncopy = mkcall1(fn, types.Types[types.TINT], &nodes, ptr1, len1, ptr2, len2, ir.NewInt(elemtype.Width))
+ ncopy = mkcall1(fn, types.Types[types.TINT], &nodes, ptr1, len1, ptr2, len2, ir.NewInt(elemtype.Size()))
} else {
// memmove(&s[len(l1)], &l2[0], len(l2)*sizeof(T))
ix := ir.NewIndexExpr(base.Pos, s, ir.NewUnaryExpr(base.Pos, ir.OLEN, l1))
sptr := ir.NewUnaryExpr(base.Pos, ir.OSPTR, l2)
nwid := cheapExpr(typecheck.Conv(ir.NewUnaryExpr(base.Pos, ir.OLEN, l2), types.Types[types.TUINTPTR]), &nodes)
- nwid = ir.NewBinaryExpr(base.Pos, ir.OMUL, nwid, ir.NewInt(elemtype.Width))
+ nwid = ir.NewBinaryExpr(base.Pos, ir.OMUL, nwid, ir.NewInt(elemtype.Size()))
// instantiate func memmove(to *any, frm *any, length uintptr)
fn := typecheck.LookupRuntime("memmove")
hp := typecheck.ConvNop(typecheck.NodAddr(ix), types.Types[types.TUNSAFEPTR])
// hn := l2 * sizeof(elem(s))
- hn := typecheck.Conv(ir.NewBinaryExpr(base.Pos, ir.OMUL, l2, ir.NewInt(elemtype.Width)), types.Types[types.TUINTPTR])
+ hn := typecheck.Conv(ir.NewBinaryExpr(base.Pos, ir.OMUL, l2, ir.NewInt(elemtype.Size())), types.Types[types.TUINTPTR])
clrname := "memclrNoHeapPointers"
hasPointers := elemtype.HasPointers()
fn := typecheck.LookupRuntime("slicecopy")
fn = typecheck.SubstArgTypes(fn, ptrL.Type().Elem(), ptrR.Type().Elem())
- return mkcall1(fn, n.Type(), init, ptrL, lenL, ptrR, lenR, ir.NewInt(n.X.Type().Elem().Width))
+ return mkcall1(fn, n.Type(), init, ptrL, lenL, ptrR, lenR, ir.NewInt(n.X.Type().Elem().Size()))
}
n.X = walkExpr(n.X, init)
nwid := ir.Node(typecheck.Temp(types.Types[types.TUINTPTR]))
setwid := ir.NewAssignStmt(base.Pos, nwid, typecheck.Conv(nlen, types.Types[types.TUINTPTR]))
ne.Body.Append(setwid)
- nwid = ir.NewBinaryExpr(base.Pos, ir.OMUL, nwid, ir.NewInt(nl.Type().Elem().Width))
+ nwid = ir.NewBinaryExpr(base.Pos, ir.OMUL, nwid, ir.NewInt(nl.Type().Elem().Size()))
call := mkcall1(fn, nil, init, nto, nfrm, nwid)
ne.Body.Append(call)
// We do not check for overflow of len(to)*elem.Width here
// since len(from) is an existing checked slice capacity
// with same elem.Width for the from slice.
- size := ir.NewBinaryExpr(base.Pos, ir.OMUL, typecheck.Conv(length, types.Types[types.TUINTPTR]), typecheck.Conv(ir.NewInt(t.Elem().Width), types.Types[types.TUINTPTR]))
+ size := ir.NewBinaryExpr(base.Pos, ir.OMUL, typecheck.Conv(length, types.Types[types.TUINTPTR]), typecheck.Conv(ir.NewInt(t.Elem().Size()), types.Types[types.TUINTPTR]))
// instantiate mallocgc(size uintptr, typ *byte, needszero bool) unsafe.Pointer
fn := typecheck.LookupRuntime("mallocgc")
return n
case types.TARRAY:
// We can compare several elements at once with 2/4/8 byte integer compares
- inline = t.NumElem() <= 1 || (types.IsSimple[t.Elem().Kind()] && (t.NumElem() <= 4 || t.Elem().Width*t.NumElem() <= maxcmpsize))
+ inline = t.NumElem() <= 1 || (types.IsSimple[t.Elem().Kind()] && (t.NumElem() <= 4 || t.Elem().Size()*t.NumElem() <= maxcmpsize))
case types.TSTRUCT:
inline = t.NumComponents(types.IgnoreBlankFields) <= 4
}
call.Args.Append(typecheck.NodAddr(cmpl))
call.Args.Append(typecheck.NodAddr(cmpr))
if needsize {
- call.Args.Append(ir.NewInt(t.Width))
+ call.Args.Append(ir.NewInt(t.Size()))
}
res := ir.Node(call)
if n.Op() != ir.OEQ {
}
} else {
step := int64(1)
- remains := t.NumElem() * t.Elem().Width
- combine64bit := unalignedLoad && types.RegSize == 8 && t.Elem().Width <= 4 && t.Elem().IsInteger()
- combine32bit := unalignedLoad && t.Elem().Width <= 2 && t.Elem().IsInteger()
- combine16bit := unalignedLoad && t.Elem().Width == 1 && t.Elem().IsInteger()
+ remains := t.NumElem() * t.Elem().Size()
+ combine64bit := unalignedLoad && types.RegSize == 8 && t.Elem().Size() <= 4 && t.Elem().IsInteger()
+ combine32bit := unalignedLoad && t.Elem().Size() <= 2 && t.Elem().IsInteger()
+ combine16bit := unalignedLoad && t.Elem().Size() == 1 && t.Elem().IsInteger()
for i := int64(0); remains > 0; {
var convType *types.Type
switch {
case remains >= 8 && combine64bit:
convType = types.Types[types.TINT64]
- step = 8 / t.Elem().Width
+ step = 8 / t.Elem().Size()
case remains >= 4 && combine32bit:
convType = types.Types[types.TUINT32]
- step = 4 / t.Elem().Width
+ step = 4 / t.Elem().Size()
case remains >= 2 && combine16bit:
convType = types.Types[types.TUINT16]
- step = 2 / t.Elem().Width
+ step = 2 / t.Elem().Size()
default:
step = 1
}
ir.NewIndexExpr(base.Pos, cmpr, ir.NewInt(i)),
)
i++
- remains -= t.Elem().Width
+ remains -= t.Elem().Size()
} else {
elemType := t.Elem().ToUnsigned()
cmplw := ir.Node(ir.NewIndexExpr(base.Pos, cmpl, ir.NewInt(i)))
lb := ir.Node(ir.NewIndexExpr(base.Pos, cmpl, ir.NewInt(i+offset)))
lb = typecheck.Conv(lb, elemType)
lb = typecheck.Conv(lb, convType)
- lb = ir.NewBinaryExpr(base.Pos, ir.OLSH, lb, ir.NewInt(8*t.Elem().Width*offset))
+ lb = ir.NewBinaryExpr(base.Pos, ir.OLSH, lb, ir.NewInt(8*t.Elem().Size()*offset))
cmplw = ir.NewBinaryExpr(base.Pos, ir.OOR, cmplw, lb)
rb := ir.Node(ir.NewIndexExpr(base.Pos, cmpr, ir.NewInt(i+offset)))
rb = typecheck.Conv(rb, elemType)
rb = typecheck.Conv(rb, convType)
- rb = ir.NewBinaryExpr(base.Pos, ir.OLSH, rb, ir.NewInt(8*t.Elem().Width*offset))
+ rb = ir.NewBinaryExpr(base.Pos, ir.OLSH, rb, ir.NewInt(8*t.Elem().Size()*offset))
cmprw = ir.NewBinaryExpr(base.Pos, ir.OOR, cmprw, rb)
}
compare(cmplw, cmprw)
i += step
- remains -= step * t.Elem().Width
+ remains -= step * t.Elem().Size()
}
}
}
return false
}
- return n.Type().Elem().Width == 0 || n.Len <= ir.MaxSmallArraySize/n.Type().Elem().Width
+ return n.Type().Elem().Size() == 0 || n.Len <= ir.MaxSmallArraySize/n.Type().Elem().Size()
}
func slicelit(ctxt initContext, n *ir.CompLitExpr, var_ ir.Node, init *ir.Nodes) {
switch r := as.Y; r.Op() {
case ir.OLITERAL:
- staticdata.InitConst(name, offset, r, int(r.Type().Width))
+ staticdata.InitConst(name, offset, r, int(r.Type().Size()))
return
case ir.OMETHEXPR:
r := r.(*ir.SelectorExpr)
case n.Op() == ir.ONAME && n.(*ir.Name).Class == ir.PEXTERN && n.(*ir.Name).Readonly():
// n is a readonly global; use it directly.
value = n
- case !escapes && fromType.Width <= 1024:
+ case !escapes && fromType.Size() <= 1024:
// n does not escape. Use a stack temporary initialized to n.
value = typecheck.Temp(fromType)
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, value, n)))
base.Fatalf("can only handle non-interfaces")
}
switch {
- case from.Size() == 2 && from.Align == 2:
+ case from.Size() == 2 && uint8(from.Alignment()) == 2:
return "convT16", types.Types[types.TUINT16], false
- case from.Size() == 4 && from.Align == 4 && !from.HasPointers():
+ case from.Size() == 4 && uint8(from.Alignment()) == 4 && !from.HasPointers():
return "convT32", types.Types[types.TUINT32], false
- case from.Size() == 8 && from.Align == types.Types[types.TUINT64].Align && !from.HasPointers():
+ case from.Size() == 8 && uint8(from.Alignment()) == uint8(types.Types[types.TUINT64].Alignment()) && !from.HasPointers():
return "convT64", types.Types[types.TUINT64], false
}
if sc := from.SoleComponent(); sc != nil {
// m[k] is not the target of an assignment.
fast := mapfast(t)
key = mapKeyArg(fast, n, key)
- if w := t.Elem().Width; w <= zeroValSize {
+ if w := t.Elem().Size(); w <= zeroValSize {
call = mkcall1(mapfn(mapaccess1[fast], t, false), types.NewPtr(t.Elem()), init, reflectdata.TypePtr(t), map_, key)
} else {
z := reflectdata.ZeroAddr(w)
}
sign := n.Type().IsSigned()
- bits := int32(8 * n.Type().Width)
+ bits := int32(8 * n.Type().Size())
if ir.IsSmallIntConst(n) {
v := ir.Int64Val(n)
// Unsafe cast through memory.
// We'll need to do a load with type kt. Create a temporary of type kt to
// ensure sufficient alignment. nt may be under-aligned.
- if kt.Align < nt.Align {
+ if uint8(kt.Alignment()) < uint8(nt.Alignment()) {
base.Fatalf("mapKeyTemp: key type is not sufficiently aligned, kt=%v nt=%v", kt, nt)
}
tmp := o.newTemp(kt, true)
}
// for v1, v2 := range ha { body }
- if cheapComputableIndex(t.Elem().Width) {
+ if cheapComputableIndex(t.Elem().Size()) {
// v1, v2 = hv1, ha[hv1]
tmp := ir.NewIndexExpr(base.Pos, ha, hv1)
tmp.SetBounded(true)
// This runs *after* the condition check, so we know
// advancing the pointer is safe and won't go past the
// end of the allocation.
- as := ir.NewAssignStmt(base.Pos, hp, addptr(hp, t.Elem().Width))
+ as := ir.NewAssignStmt(base.Pos, hp, addptr(hp, t.Elem().Size()))
nfor.Late = []ir.Node{typecheck.Stmt(as)}
case types.TMAP:
return nil
}
- elemsize := typecheck.RangeExprType(loop.X.Type()).Elem().Width
+ elemsize := typecheck.RangeExprType(loop.X.Type()).Elem().Size()
if elemsize <= 0 || !ir.IsZero(stmt.Y) {
return nil
}
func mapfast(t *types.Type) int {
// Check runtime/map.go:maxElemSize before changing.
- if t.Elem().Width > 128 {
+ if t.Elem().Size() > 128 {
return mapslow
}
switch reflectdata.AlgType(t.Key()) {