]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: merge TPTR32 and TPTR64 as TPTR
authorMatthew Dempsky <mdempsky@google.com>
Mon, 6 Nov 2017 22:50:30 +0000 (14:50 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 4 Oct 2018 04:08:08 +0000 (04:08 +0000)
Change-Id: I0490098a7235458c5aede1135426a9f19f8584a7
Reviewed-on: https://go-review.googlesource.com/c/76312
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
19 files changed:
src/cmd/compile/internal/gc/alg.go
src/cmd/compile/internal/gc/align.go
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/const.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/fmt.go
src/cmd/compile/internal/gc/iexport.go
src/cmd/compile/internal/gc/pgen_test.go
src/cmd/compile/internal/gc/plive.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/gc/types.go
src/cmd/compile/internal/gc/universe.go
src/cmd/compile/internal/gc/walk.go
src/cmd/compile/internal/ssa/export_test.go
src/cmd/compile/internal/types/type.go
src/cmd/compile/internal/types/utils.go

index b7d88531fd7ca7f0dd1c19a03f95c673b804a113..9a13ed368b900c944a57ae11696854bf45971417 100644 (file)
@@ -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
 
index 9e752fc628e1415ee37622d4f514efa2cc301c4f..fb761d2339758891df9a1e3ab29938206a63bdfa 100644 (file)
@@ -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:
index 3ef1e6af4d089aa7a2ae2669f948dda457e31665..7c09ab5a34d20b591d5312cfbebcb4b2705aed7c 100644 (file)
@@ -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())
index a80455a30c6deaa8c0aa3f46f94287683e248869..effed1f4ac152c541ac9dec026194dd98c78db41 100644 (file)
@@ -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:
@@ -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
index 145007f5e1bb6784a3c34fcc1fc4f0f76cdae02e..94190f0020bd3db40becc65c8750426ef1812e1d 100644 (file)
@@ -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.
index 5d2e36ee51079d91429776b22fd80589f1245d08..28e9b9b6dcc95166c662dbad6434217d6041a25e 100644 (file)
@@ -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 {
index 3007c9cabfa57e5c1956a0364067475e3e7ad8fe..d90c97ad922d370bb453378d4b120e33a9547e31 100644 (file)
@@ -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())
 
@@ -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
index d75c5b82392603f424751dc528b28f73986fccab..89b977de85c499d9fa297b0c33eb254dd739b70e 100644 (file)
@@ -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
 }
index 563b425db7decbf287d73210cad6c3c27bddb309..a38c33647eea810ea0dc5e5ef7928928ae8aa47e 100644 (file)
@@ -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)
                }
@@ -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,
index 935c3b05031b1b53251ac7c729c04ca980f9607a..3ef568230181bb0f0ca2993edbd56fd253593340 100644 (file)
@@ -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
                        }
@@ -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,
@@ -736,8 +735,7 @@ func typeptrdata(t *types.Type) int64 {
        }
 
        switch t.Etype {
-       case TPTR32,
-               TPTR64,
+       case TPTR,
                TUNSAFEPTR,
                TFUNC,
                TCHAN,
@@ -1035,8 +1033,7 @@ func isreflexive(t *types.Type) bool {
                TINT64,
                TUINT64,
                TUINTPTR,
-               TPTR32,
-               TPTR64,
+               TPTR,
                TUNSAFEPTR,
                TSTRING,
                TCHAN:
@@ -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
@@ -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)
@@ -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
                }
        }
index 2b67ef9a6f3a72dbe90f387aef863a7573882ff8..469fbb8c96968efb087411c375e69ebf3985a021 100644 (file)
@@ -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,
@@ -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,
index 7e450e2e668f5551fbcdb3472256f57c3c488511..9a6c61a651a41c6a278698579f1f9eec185d6394 100644 (file)
@@ -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,
@@ -2003,8 +2002,7 @@ func isdirectiface(t *types.Type) bool {
        }
 
        switch t.Etype {
-       case TPTR32,
-               TPTR64,
+       case TPTR,
                TCHAN,
                TMAP,
                TFUNC,
index 4831ecca3415c70c386aebe98a59c60f8c6f79e7..897dd710b9e69804d3180d62aee3e13000da869f 100644 (file)
@@ -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",
index aa0f066a461772995a92207372d91f30106a92bb..ce82c3a52e2cbcd70ea0fbbc82e38526a1ffd0bc 100644 (file)
@@ -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
index dbc2d647c9c39163bbacee5b09904d7531f965d5..96980ad500d578e41da69c87a2f9c1ba0c858e56 100644 (file)
@@ -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
@@ -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
        }
@@ -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
@@ -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)))
index 1b1d36b61d2f38971cc60d1d5e648a42562495eb..5aa2146a8c86fc0bb1aa00914b5c9e389294c40e 100644 (file)
@@ -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:
index 5832050a8a60883ace5c81990cda9d83d759858f..9c776d4b16a660a1b066f35758818924c818e850 100644 (file)
@@ -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
index 25f8f826e607c6977f5ea5e970ed89e7477d1747..e6e61274057244f75b7a6f4c0249dbde15eb95a9 100644 (file)
@@ -43,9 +43,7 @@ const (
 
        TBOOL
 
-       TPTR32
-       TPTR64
-
+       TPTR
        TFUNC
        TSLICE
        TARRAY
@@ -137,7 +135,7 @@ type Type struct {
        // TFUNCARGS: FuncArgs
        // TCHANARGS: ChanArgs
        // TCHAN: *Chan
-       // TPTR32, TPTR64: Ptr
+       // TPTR: Ptr
        // TARRAY: *Array
        // TSLICE: Slice
        Extra interface{}
@@ -461,7 +459,7 @@ func New(et EType) *Type {
                t.Extra = new(Struct)
        case TINTER:
                t.Extra = new(Interface)
-       case TPTR32, TPTR64:
+       case TPTR:
                t.Extra = Ptr{}
        case TCHANARGS:
                t.Extra = ChanArgs{}
@@ -560,11 +558,7 @@ func NewPtr(elem *Type) *Type {
                return t
        }
 
-       if Tptr == 0 {
-               Fatalf("NewPtr: Tptr not initialized")
-       }
-
-       t := New(Tptr)
+       t := New(TPTR)
        t.Extra = Ptr{Elem: elem}
        t.Width = int64(Widthptr)
        t.Align = uint8(Widthptr)
@@ -619,7 +613,7 @@ func SubstAny(t *Type, types *[]*Type) *Type {
                t = (*types)[0]
                *types = (*types)[1:]
 
-       case TPTR32, TPTR64:
+       case TPTR:
                elem := SubstAny(t.Elem(), types)
                if elem != t.Elem() {
                        t = t.copy()
@@ -790,7 +784,7 @@ func (t *Type) Key() *Type {
 // Usable with pointers, channels, arrays, slices, and maps.
 func (t *Type) Elem() *Type {
        switch t.Etype {
-       case TPTR32, TPTR64:
+       case TPTR:
                return t.Extra.(Ptr).Elem
        case TARRAY:
                return t.Extra.(*Array).Elem
@@ -1101,7 +1095,7 @@ func (t *Type) cmp(x *Type) Cmp {
                }
                return t.Elem().cmp(x.Elem())
 
-       case TPTR32, TPTR64, TSLICE:
+       case TPTR, TSLICE:
                // No special cases for these, they are handled
                // by the general code after the switch.
 
@@ -1199,7 +1193,7 @@ func (t *Type) cmp(x *Type) Cmp {
                panic(e)
        }
 
-       // Common element type comparison for TARRAY, TCHAN, TPTR32, TPTR64, and TSLICE.
+       // Common element type comparison for TARRAY, TCHAN, TPTR, and TSLICE.
        return t.Elem().cmp(x.Elem())
 }
 
@@ -1261,7 +1255,7 @@ func (t *Type) IsComplex() bool {
 // IsPtr reports whether t is a regular Go pointer type.
 // This does not include unsafe.Pointer.
 func (t *Type) IsPtr() bool {
-       return t.Etype == TPTR32 || t.Etype == TPTR64
+       return t.Etype == TPTR
 }
 
 // IsUnsafePtr reports whether t is an unsafe pointer.
@@ -1275,7 +1269,7 @@ func (t *Type) IsUnsafePtr() bool {
 // that consist of a single pointer shaped type.
 // TODO(mdempsky): Should it? See golang.org/issue/15028.
 func (t *Type) IsPtrShaped() bool {
-       return t.Etype == TPTR32 || t.Etype == TPTR64 || t.Etype == TUNSAFEPTR ||
+       return t.Etype == TPTR || t.Etype == TUNSAFEPTR ||
                t.Etype == TMAP || t.Etype == TCHAN || t.Etype == TFUNC
 }
 
@@ -1449,7 +1443,7 @@ func Haspointers1(t *Type, ignoreNotInHeap bool) bool {
                }
                return false
 
-       case TPTR32, TPTR64, TSLICE:
+       case TPTR, TSLICE:
                return !(ignoreNotInHeap && t.Elem().NotInHeap())
 
        case TTUPLE:
index 0eac402f8e0d71660ccabca48c40ac9bd45e9374..caaeb889fbcd72dd9faef98cff4bcba385c21395 100644 (file)
@@ -11,9 +11,6 @@ import (
 
 const BADWIDTH = -1000000000
 
-// Initialized by frontend. Exists only here.
-var Tptr EType // either TPTR32 or TPTR64
-
 // The following variables must be initialized early by the frontend.
 // They are here to break import cycles.
 // TODO(gri) eliminate these dependencies.