Skip to content

Commit

Permalink
cmd/compile: merge TPTR32 and TPTR64 as TPTR
Browse files Browse the repository at this point in the history
Change-Id: I0490098a7235458c5aede1135426a9f19f8584a7
Reviewed-on: https://go-review.googlesource.com/c/76312
Run-TryBot: Matthew Dempsky <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
  • Loading branch information
mdempsky committed Oct 4, 2018
1 parent d397d4b commit 62e5215
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/gc/alg.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func algtype1(t *types.Type) (AlgKind, *types.Type) {
case TINT8, TUINT8, TINT16, TUINT16,
TINT32, TUINT32, TINT64, TUINT64,
TINT, TUINT, TUINTPTR,
TBOOL, TPTR32, TPTR64,
TBOOL, TPTR,
TCHAN, TUNSAFEPTR:
return AMEM, nil

Expand Down
8 changes: 2 additions & 6 deletions src/cmd/compile/internal/gc/align.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,8 @@ func dowidth(t *types.Type) {
w = 16
t.Align = uint8(Widthreg)

case TPTR32:
w = 4
checkwidth(t.Elem())

case TPTR64:
w = 8
case TPTR:
w = int64(Widthptr)
checkwidth(t.Elem())

case TUNSAFEPTR:
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/gc/bexport.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (p *exporter) markType(t *types.Type) {
// the user already needs some way to construct values of
// those types.
switch t.Etype {
case TPTR32, TPTR64, TARRAY, TSLICE, TCHAN:
case TPTR, TARRAY, TSLICE, TCHAN:
// TODO(mdempsky): Skip marking element type for
// send-only channels?
p.markType(t.Elem())
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/gc/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func convlit1(n *Node, t *types.Type, explicit bool, reuse canReuseNode) *Node {
case TARRAY:
goto bad

case TPTR32, TPTR64, TUNSAFEPTR:
case TPTR, TUNSAFEPTR:
n.SetVal(Val{new(Mpint)})

case TCHAN, TFUNC, TINTER, TMAP, TSLICE:
Expand Down Expand Up @@ -1482,7 +1482,7 @@ func smallintconst(n *Node) bool {
TBOOL:
return true

case TIDEAL, TINT64, TUINT64, TPTR32, TPTR64:
case TIDEAL, TINT64, TUINT64, TPTR:
v, ok := n.Val().U.(*Mpint)
if ok && v.Cmp(minintval[TINT32]) > 0 && v.Cmp(maxintval[TINT32]) < 0 {
return true
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/gc/esc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ func (e *EscState) addDereference(n *Node) *Node {
e.nodeEscState(ind).Loopdepth = e.nodeEscState(n).Loopdepth
ind.Pos = n.Pos
t := n.Type
if t.IsKind(types.Tptr) || t.IsSlice() {
if t.IsPtr() || t.IsSlice() {
// This should model our own sloppy use of OIND to encode
// decreasing levels of indirection; i.e., "indirecting" a slice
// yields the type of an element.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/gc/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ func typefmt(t *types.Type, flag FmtFlag, mode fmtMode, depth int) string {
}

switch t.Etype {
case TPTR32, TPTR64:
case TPTR:
switch mode {
case FTypeId, FTypeIdName:
if flag&FmtShort != 0 {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/gc/iexport.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func (w *exportWriter) doTyp(t *types.Type) {
}

switch t.Etype {
case TPTR32, TPTR64:
case TPTR:
w.startType(pointerType)
w.typ(t.Elem())

Expand Down Expand Up @@ -743,7 +743,7 @@ func constTypeOf(typ *types.Type) Ctype {
return CTSTR
case TINT, TINT8, TINT16, TINT32, TINT64,
TUINT, TUINT8, TUINT16, TUINT32, TUINT64, TUINTPTR,
TPTR32, TPTR64, TUNSAFEPTR:
TPTR, TUNSAFEPTR:
return CTINT
case TFLOAT32, TFLOAT64:
return CTFLT
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/gc/pgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func typeWithoutPointers() *types.Type {

func typeWithPointers() *types.Type {
t := types.New(TSTRUCT)
f := &types.Field{Type: types.New(TPTR64)}
f := &types.Field{Type: types.New(TPTR)}
t.SetFields([]*types.Field{f})
return t
}
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/compile/internal/gc/plive.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func onebitwalktype1(t *types.Type, off int64, bv bvec) {
TINT, TUINT, TUINTPTR, TBOOL,
TFLOAT32, TFLOAT64, TCOMPLEX64, TCOMPLEX128:

case TPTR32, TPTR64, TUNSAFEPTR, TFUNC, TCHAN, TMAP:
case TPTR, TUNSAFEPTR, TFUNC, TCHAN, TMAP:
if off&int64(Widthptr-1) != 0 {
Fatalf("onebitwalktype1: invalid alignment, %v", t)
}
Expand Down Expand Up @@ -1163,8 +1163,7 @@ func clobberWalk(b *ssa.Block, v *Node, offset int64, t *types.Type) {
return
}
switch t.Etype {
case TPTR32,
TPTR64,
case TPTR,
TUNSAFEPTR,
TFUNC,
TCHAN,
Expand Down
17 changes: 7 additions & 10 deletions src/cmd/compile/internal/gc/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ func typePkg(t *types.Type) *types.Pkg {
tsym := t.Sym
if tsym == nil {
switch t.Etype {
case TARRAY, TSLICE, TPTR32, TPTR64, TCHAN:
case TARRAY, TSLICE, TPTR, TCHAN:
if t.Elem() != nil {
tsym = t.Elem().Sym
}
Expand Down Expand Up @@ -714,8 +714,7 @@ var kinds = []int{
TFLOAT64: objabi.KindFloat64,
TBOOL: objabi.KindBool,
TSTRING: objabi.KindString,
TPTR32: objabi.KindPtr,
TPTR64: objabi.KindPtr,
TPTR: objabi.KindPtr,
TSTRUCT: objabi.KindStruct,
TINTER: objabi.KindInterface,
TCHAN: objabi.KindChan,
Expand All @@ -736,8 +735,7 @@ func typeptrdata(t *types.Type) int64 {
}

switch t.Etype {
case TPTR32,
TPTR64,
case TPTR,
TUNSAFEPTR,
TFUNC,
TCHAN,
Expand Down Expand Up @@ -1035,8 +1033,7 @@ func isreflexive(t *types.Type) bool {
TINT64,
TUINT64,
TUINTPTR,
TPTR32,
TPTR64,
TPTR,
TUNSAFEPTR,
TSTRING,
TCHAN:
Expand Down Expand Up @@ -1071,7 +1068,7 @@ func isreflexive(t *types.Type) bool {
func needkeyupdate(t *types.Type) bool {
switch t.Etype {
case TBOOL, TINT, TUINT, TINT8, TUINT8, TINT16, TUINT16, TINT32, TUINT32,
TINT64, TUINT64, TUINTPTR, TPTR32, TPTR64, TUNSAFEPTR, TCHAN:
TINT64, TUINT64, TUINTPTR, TPTR, TUNSAFEPTR, TCHAN:
return false

case TFLOAT32, TFLOAT64, TCOMPLEX64, TCOMPLEX128, // floats and complex can be +0/-0
Expand Down Expand Up @@ -1279,7 +1276,7 @@ func dtypesym(t *types.Type) *obj.LSym {
ot = duint8(lsym, ot, uint8(obj.Bool2int(needkeyupdate(t.Key()))))
ot = dextratype(lsym, ot, t, 0)

case TPTR32, TPTR64:
case TPTR:
if t.Elem().Etype == TANY {
// ../../../../runtime/type.go:/UnsafePointerType
ot = dcommontype(lsym, t)
Expand Down Expand Up @@ -1356,7 +1353,7 @@ func dtypesym(t *types.Type) *obj.LSym {
// functions must return the existing type structure rather
// than creating a new one.
switch t.Etype {
case TPTR32, TPTR64, TARRAY, TCHAN, TFUNC, TMAP, TSLICE, TSTRUCT:
case TPTR, TARRAY, TCHAN, TFUNC, TMAP, TSLICE, TSTRUCT:
keep = true
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/cmd/compile/internal/gc/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -1363,8 +1363,7 @@ var opToSSA = map[opAndType]ssa.Op{
opAndType{OEQ, TFUNC}: ssa.OpEqPtr,
opAndType{OEQ, TMAP}: ssa.OpEqPtr,
opAndType{OEQ, TCHAN}: ssa.OpEqPtr,
opAndType{OEQ, TPTR32}: ssa.OpEqPtr,
opAndType{OEQ, TPTR64}: ssa.OpEqPtr,
opAndType{OEQ, TPTR}: ssa.OpEqPtr,
opAndType{OEQ, TUINTPTR}: ssa.OpEqPtr,
opAndType{OEQ, TUNSAFEPTR}: ssa.OpEqPtr,
opAndType{OEQ, TFLOAT64}: ssa.OpEq64F,
Expand All @@ -1384,8 +1383,7 @@ var opToSSA = map[opAndType]ssa.Op{
opAndType{ONE, TFUNC}: ssa.OpNeqPtr,
opAndType{ONE, TMAP}: ssa.OpNeqPtr,
opAndType{ONE, TCHAN}: ssa.OpNeqPtr,
opAndType{ONE, TPTR32}: ssa.OpNeqPtr,
opAndType{ONE, TPTR64}: ssa.OpNeqPtr,
opAndType{ONE, TPTR}: ssa.OpNeqPtr,
opAndType{ONE, TUINTPTR}: ssa.OpNeqPtr,
opAndType{ONE, TUNSAFEPTR}: ssa.OpNeqPtr,
opAndType{ONE, TFLOAT64}: ssa.OpNeq64F,
Expand Down
6 changes: 2 additions & 4 deletions src/cmd/compile/internal/gc/subr.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,7 @@ func assignop(src *types.Type, dst *types.Type, why *string) Op {
// 5. src is the predeclared identifier nil and dst is a nillable type.
if src.Etype == TNIL {
switch dst.Etype {
case TPTR32,
TPTR64,
case TPTR,
TFUNC,
TMAP,
TCHAN,
Expand Down Expand Up @@ -2003,8 +2002,7 @@ func isdirectiface(t *types.Type) bool {
}

switch t.Etype {
case TPTR32,
TPTR64,
case TPTR,
TCHAN,
TMAP,
TFUNC,
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/compile/internal/gc/typecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ var _typekind = []string{
TFLOAT64: "float64",
TBOOL: "bool",
TSTRING: "string",
TPTR32: "pointer",
TPTR64: "pointer",
TPTR: "pointer",
TUNSAFEPTR: "unsafe.Pointer",
TSTRUCT: "struct",
TINTER: "interface",
Expand Down
4 changes: 1 addition & 3 deletions src/cmd/compile/internal/gc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ const (

TBOOL = types.TBOOL

TPTR32 = types.TPTR32
TPTR64 = types.TPTR64

TPTR = types.TPTR
TFUNC = types.TFUNC
TSLICE = types.TSLICE
TARRAY = types.TARRAY
Expand Down
23 changes: 7 additions & 16 deletions src/cmd/compile/internal/gc/universe.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,8 @@ func typeinit() {
simtype[et] = et
}

types.Types[TPTR32] = types.New(TPTR32)
dowidth(types.Types[TPTR32])

types.Types[TPTR64] = types.New(TPTR64)
dowidth(types.Types[TPTR64])
types.Types[TPTR] = types.New(TPTR)
dowidth(types.Types[TPTR])

t := types.New(TUNSAFEPTR)
types.Types[TUNSAFEPTR] = t
Expand All @@ -190,11 +187,6 @@ func typeinit() {
asNode(t.Sym.Def).Name = new(Name)
dowidth(types.Types[TUNSAFEPTR])

types.Tptr = TPTR32
if Widthptr == 8 {
types.Tptr = TPTR64
}

for et := TINT8; et <= TUINT64; et++ {
isInt[et] = true
}
Expand Down Expand Up @@ -263,8 +255,7 @@ func typeinit() {
okforlen[TSLICE] = true
okforlen[TSTRING] = true

okforeq[TPTR32] = true
okforeq[TPTR64] = true
okforeq[TPTR] = true
okforeq[TUNSAFEPTR] = true
okforeq[TINTER] = true
okforeq[TCHAN] = true
Expand Down Expand Up @@ -357,10 +348,10 @@ func typeinit() {
types.Types[TINTER] = types.New(TINTER)

// simple aliases
simtype[TMAP] = types.Tptr
simtype[TCHAN] = types.Tptr
simtype[TFUNC] = types.Tptr
simtype[TUNSAFEPTR] = types.Tptr
simtype[TMAP] = TPTR
simtype[TCHAN] = TPTR
simtype[TFUNC] = TPTR
simtype[TUNSAFEPTR] = TPTR

array_array = int(Rnd(0, int64(Widthptr)))
array_nel = int(Rnd(int64(array_array)+int64(Widthptr), int64(Widthptr)))
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/gc/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,7 @@ func walkprint(nn *Node, init *Nodes) *Node {
on = syslook("printiface")
}
on = substArgTypes(on, n.Type) // any-1
case TPTR32, TPTR64, TCHAN, TMAP, TFUNC, TUNSAFEPTR:
case TPTR, TCHAN, TMAP, TFUNC, TUNSAFEPTR:
on = syslook("printpointer")
on = substArgTypes(on, n.Type) // any-1
case TSLICE:
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/ssa/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func init() {
}
types.Dowidth = func(t *types.Type) {}

types.Tptr = types.TPTR64
for _, typ := range [...]struct {
width int64
et types.EType
Expand Down
Loading

0 comments on commit 62e5215

Please sign in to comment.