]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use a uint8-sized named type for Addr.Type
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 15 May 2015 03:11:28 +0000 (20:11 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sun, 6 Mar 2016 04:52:28 +0000 (04:52 +0000)
No immediate reduction in the size of Addr.

Passes toolstash -cmp.

Change-Id: I78ea4c6e181b6e571ce70a5f1ae8158844eb197d
Reviewed-on: https://go-review.googlesource.com/20276
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
15 files changed:
src/cmd/compile/internal/amd64/ggen.go
src/cmd/compile/internal/amd64/gsubr.go
src/cmd/compile/internal/arm/ggen.go
src/cmd/compile/internal/arm64/ggen.go
src/cmd/compile/internal/mips64/ggen.go
src/cmd/compile/internal/ppc64/ggen.go
src/cmd/compile/internal/x86/ggen.go
src/cmd/compile/internal/x86/peep.go
src/cmd/internal/obj/arm/asm5.go
src/cmd/internal/obj/arm64/asm7.go
src/cmd/internal/obj/data.go
src/cmd/internal/obj/link.go
src/cmd/internal/obj/ppc64/asm9.go
src/cmd/internal/obj/util.go
src/cmd/internal/obj/x86/asm6.go

index 6c921dd4c2e5e4951bd394a12e72aa41be833ec5..a6706eefccc1ef060a8dbd7643c1c14a4c9f61da 100644 (file)
@@ -166,15 +166,15 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, ax *uint32, x0 *uin
        return p
 }
 
-func appendpp(p *obj.Prog, as int, ftype int, freg int, foffset int64, ttype int, treg int, toffset int64) *obj.Prog {
+func appendpp(p *obj.Prog, as int, ftype obj.AddrType, freg int, foffset int64, ttype obj.AddrType, treg int, toffset int64) *obj.Prog {
        q := gc.Ctxt.NewProg()
        gc.Clearp(q)
        q.As = int16(as)
        q.Lineno = p.Lineno
-       q.From.Type = int16(ftype)
+       q.From.Type = ftype
        q.From.Reg = int16(freg)
        q.From.Offset = foffset
-       q.To.Type = int16(ttype)
+       q.To.Type = ttype
        q.To.Reg = int16(treg)
        q.To.Offset = toffset
        q.Link = p.Link
index 003b0ad0c9932e0792828c2230b53377ea4305e5..b2fa11388be7ef74a8140ec63c139fc90b47a7ea 100644 (file)
@@ -1408,7 +1408,7 @@ func sudoaddable(as int, n *gc.Node, a *obj.Addr) bool {
                }
 
                a.Type = obj.TYPE_NONE
-               a.Index = obj.TYPE_NONE
+               a.Index = x86.REG_NONE
                gc.Fixlargeoffset(&n1)
                gc.Naddr(a, &n1)
                return true
index d4d4e27d099f7e15ec67967bcf6e47c921bc73ef..ffe4f5510577b4b91ac454d8f4543fb95ee3f781 100644 (file)
@@ -95,15 +95,15 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, r0 *uint32) *obj.Pr
        return p
 }
 
-func appendpp(p *obj.Prog, as int, ftype int, freg int, foffset int32, ttype int, treg int, toffset int32) *obj.Prog {
+func appendpp(p *obj.Prog, as int, ftype obj.AddrType, freg int, foffset int32, ttype obj.AddrType, treg int, toffset int32) *obj.Prog {
        q := gc.Ctxt.NewProg()
        gc.Clearp(q)
        q.As = int16(as)
        q.Lineno = p.Lineno
-       q.From.Type = int16(ftype)
+       q.From.Type = ftype
        q.From.Reg = int16(freg)
        q.From.Offset = int64(foffset)
-       q.To.Type = int16(ttype)
+       q.To.Type = ttype
        q.To.Reg = int16(treg)
        q.To.Offset = int64(toffset)
        q.Link = p.Link
index da2f71cfc39e64535d5634ef9d4a71edcd06bba6..9e1149de842243f1c49fce7dd342987f220fb576 100644 (file)
@@ -106,15 +106,15 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        return p
 }
 
-func appendpp(p *obj.Prog, as int, ftype int, freg int, foffset int64, ttype int, treg int, toffset int64) *obj.Prog {
+func appendpp(p *obj.Prog, as int, ftype obj.AddrType, freg int, foffset int64, ttype obj.AddrType, treg int, toffset int64) *obj.Prog {
        q := gc.Ctxt.NewProg()
        gc.Clearp(q)
        q.As = int16(as)
        q.Lineno = p.Lineno
-       q.From.Type = int16(ftype)
+       q.From.Type = ftype
        q.From.Reg = int16(freg)
        q.From.Offset = foffset
-       q.To.Type = int16(ttype)
+       q.To.Type = ttype
        q.To.Reg = int16(treg)
        q.To.Offset = toffset
        q.Link = p.Link
index 6436ce6a83c9e8a501623b0ed1607d399ba0a555..57508c8832919a281153accdfd03c5637dafd739 100644 (file)
@@ -101,15 +101,15 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        return p
 }
 
-func appendpp(p *obj.Prog, as int, ftype int, freg int, foffset int64, ttype int, treg int, toffset int64) *obj.Prog {
+func appendpp(p *obj.Prog, as int, ftype obj.AddrType, freg int, foffset int64, ttype obj.AddrType, treg int, toffset int64) *obj.Prog {
        q := gc.Ctxt.NewProg()
        gc.Clearp(q)
        q.As = int16(as)
        q.Lineno = p.Lineno
-       q.From.Type = int16(ftype)
+       q.From.Type = ftype
        q.From.Reg = int16(freg)
        q.From.Offset = foffset
-       q.To.Type = int16(ttype)
+       q.To.Type = ttype
        q.To.Reg = int16(treg)
        q.To.Offset = toffset
        q.Link = p.Link
index 8e63d38ce117c7b12607752605f13ab23f8cb351..5030630921012d475366c3b710351cd2965298c9 100644 (file)
@@ -93,15 +93,15 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        return p
 }
 
-func appendpp(p *obj.Prog, as int, ftype int, freg int, foffset int64, ttype int, treg int, toffset int64) *obj.Prog {
+func appendpp(p *obj.Prog, as int, ftype obj.AddrType, freg int, foffset int64, ttype obj.AddrType, treg int, toffset int64) *obj.Prog {
        q := gc.Ctxt.NewProg()
        gc.Clearp(q)
        q.As = int16(as)
        q.Lineno = p.Lineno
-       q.From.Type = int16(ftype)
+       q.From.Type = ftype
        q.From.Reg = int16(freg)
        q.From.Offset = foffset
-       q.To.Type = int16(ttype)
+       q.To.Type = ttype
        q.To.Reg = int16(treg)
        q.To.Offset = toffset
        q.Link = p.Link
index cf605feefc8974a8e426c18e54105bef9d016aa3..f3481c3b875f364d8090fa84cd97fe8bee3c489e 100644 (file)
@@ -84,15 +84,15 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, ax *uint32) *obj.Pr
        return p
 }
 
-func appendpp(p *obj.Prog, as int, ftype int, freg int, foffset int64, ttype int, treg int, toffset int64) *obj.Prog {
+func appendpp(p *obj.Prog, as int, ftype obj.AddrType, freg int, foffset int64, ttype obj.AddrType, treg int, toffset int64) *obj.Prog {
        q := gc.Ctxt.NewProg()
        gc.Clearp(q)
        q.As = int16(as)
        q.Lineno = p.Lineno
-       q.From.Type = int16(ftype)
+       q.From.Type = ftype
        q.From.Reg = int16(freg)
        q.From.Offset = foffset
-       q.To.Type = int16(ttype)
+       q.To.Type = ttype
        q.To.Reg = int16(treg)
        q.To.Offset = toffset
        q.Link = p.Link
index b9f05d3b472e29fa4e3197454f216864883fb6e4..a11785006b944a990a6887d7ceae9c71a093571d 100644 (file)
@@ -733,7 +733,7 @@ func copysub(a *obj.Addr, v *obj.Addr, s *obj.Addr, f int) int {
        if regtyp(v) {
                reg := int(v.Reg)
                if (a.Type == obj.TYPE_MEM || a.Type == obj.TYPE_ADDR) && int(a.Reg) == reg {
-                       if (s.Reg == x86.REG_BP) && a.Index != obj.TYPE_NONE {
+                       if (s.Reg == x86.REG_BP) && a.Index != x86.REG_NONE {
                                return 1 /* can't use BP-base with index */
                        }
                        if f != 0 {
index 9da33bc854b1212786f7d17a45c3c04f89abc00b..8536e7628bbc1ca1a5e293ced67822a36ef7343b 100644 (file)
@@ -1067,7 +1067,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
 
                        return C_LAUTO
 
-               case obj.TYPE_NONE:
+               case obj.NAME_NONE:
                        ctxt.Instoffset = a.Offset
                        t := int(immaddr(int32(ctxt.Instoffset)))
                        if t != 0 {
@@ -1115,7 +1115,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
        case obj.TYPE_CONST,
                obj.TYPE_ADDR:
                switch a.Name {
-               case obj.TYPE_NONE:
+               case obj.NAME_NONE:
                        ctxt.Instoffset = a.Offset
                        if a.Reg != 0 {
                                return aconsize(ctxt)
index 2b0a9cc287bf3a9fbd25d49deb10433fb27c0b3b..bc0096d62472d300450cb9cd37d2d91fa97a0617 100644 (file)
@@ -970,8 +970,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
 
        case obj.TYPE_MEM:
                switch a.Name {
-               case obj.NAME_EXTERN,
-                       obj.NAME_STATIC:
+               case obj.NAME_EXTERN, obj.NAME_STATIC:
                        if a.Sym == nil {
                                break
                        }
@@ -999,7 +998,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
                        ctxt.Instoffset = int64(ctxt.Autosize) + a.Offset + 8
                        return autoclass(ctxt.Instoffset)
 
-               case obj.TYPE_NONE:
+               case obj.NAME_NONE:
                        ctxt.Instoffset = a.Offset
                        return oregclass(ctxt.Instoffset)
                }
@@ -1011,10 +1010,9 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
        case obj.TYPE_TEXTSIZE:
                return C_TEXTSIZE
 
-       case obj.TYPE_CONST,
-               obj.TYPE_ADDR:
+       case obj.TYPE_CONST, obj.TYPE_ADDR:
                switch a.Name {
-               case obj.TYPE_NONE:
+               case obj.NAME_NONE:
                        ctxt.Instoffset = a.Offset
                        if a.Reg != 0 && a.Reg != REGZERO {
                                goto aconsize
@@ -1058,8 +1056,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
                        }
                        return C_VCON
 
-               case obj.NAME_EXTERN,
-                       obj.NAME_STATIC:
+               case obj.NAME_EXTERN, obj.NAME_STATIC:
                        if a.Sym == nil {
                                break
                        }
index 96129fd9543d9f331429585ea44d7c7bd2cbb3a5..438435fd585543f19f7c7dd37b0a1d7cb0bf0f78 100644 (file)
@@ -66,7 +66,7 @@ func savedata(ctxt *Link, s *LSym, p *Prog, file string) {
        }
        Symgrow(ctxt, s, int64(off+siz))
 
-       switch int(p.To.Type) {
+       switch p.To.Type {
        default:
                ctxt.Diag("bad data: %v", p)
 
@@ -88,7 +88,7 @@ func savedata(ctxt *Link, s *LSym, p *Prog, file string) {
                copy(s.P[off:off+siz], p.To.Val.(string))
 
        case TYPE_CONST, TYPE_ADDR:
-               if p.To.Sym != nil || int(p.To.Type) == TYPE_ADDR {
+               if p.To.Sym != nil || p.To.Type == TYPE_ADDR {
                        r := Addrel(s)
                        r.Off = off
                        r.Siz = uint8(siz)
index 53a8fa33342d22bdd2e0a2bc1e523a18ee155a91..b7683ebaa273e8ce4dccb6e7af5f68e54ae61194 100644 (file)
@@ -144,10 +144,10 @@ import "encoding/binary"
 //                     scale = 1
 //
 type Addr struct {
-       Type   int16
        Reg    int16
        Index  int16
        Scale  int16 // Sometimes holds a register.
+       Type   AddrType
        Name   int8
        Class  int8
        Etype  uint8
@@ -166,6 +166,8 @@ type Addr struct {
        Node interface{} // for use by compiler
 }
 
+type AddrType uint8
+
 const (
        NAME_NONE = 0 + iota
        NAME_EXTERN
@@ -178,11 +180,9 @@ const (
 )
 
 const (
-       TYPE_NONE = 0
-)
+       TYPE_NONE AddrType = 0
 
-const (
-       TYPE_BRANCH = 5 + iota
+       TYPE_BRANCH AddrType = 5 + iota
        TYPE_TEXTSIZE
        TYPE_MEM
        TYPE_CONST
@@ -228,7 +228,7 @@ type Prog struct {
 }
 
 // From3Type returns From3.Type, or TYPE_NONE when From3 is nil.
-func (p *Prog) From3Type() int16 {
+func (p *Prog) From3Type() AddrType {
        if p.From3 == nil {
                return TYPE_NONE
        }
index c4e8fdc21dee18e9a0a60f6514efb4fe2ff2fff8..cf2a6e82b035367ad1d6c130431bedfc60a01ad7 100644 (file)
@@ -636,7 +636,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
        case obj.TYPE_CONST,
                obj.TYPE_ADDR:
                switch a.Name {
-               case obj.TYPE_NONE:
+               case obj.NAME_NONE:
                        ctxt.Instoffset = a.Offset
                        if a.Reg != 0 {
                                if -BIG <= ctxt.Instoffset && ctxt.Instoffset <= BIG {
index a1c1cca895b13d7f468cc57fea791c5c1f46f2c3..7689d22d7f0907dc14f53c1925ec07a70d653567 100644 (file)
@@ -383,7 +383,7 @@ func Dconv(p *Prog, a *Addr) string {
                }
 
                str = Rconv(int(a.Reg))
-               if a.Name != TYPE_NONE || a.Sym != nil {
+               if a.Name != NAME_NONE || a.Sym != nil {
                        str = fmt.Sprintf("%v(%v)(REG)", Mconv(a), Rconv(int(a.Reg)))
                }
 
index c4f2140e9c32745f2a3862570ff7b65ee50b3989..0f81bbb74f03cc7c8db0ebf1b71e38efc674d565 100644 (file)
@@ -4621,10 +4621,10 @@ func asmins(ctxt *obj.Link, p *obj.Prog) {
                }
 
                if p.As != ALEAQ && p.As != ALEAL {
-                       if p.From.Index != obj.TYPE_NONE && p.From.Scale > 0 {
+                       if p.From.Index != REG_NONE && p.From.Scale > 0 {
                                nacltrunc(ctxt, int(p.From.Index))
                        }
-                       if p.To.Index != obj.TYPE_NONE && p.To.Scale > 0 {
+                       if p.To.Index != REG_NONE && p.To.Scale > 0 {
                                nacltrunc(ctxt, int(p.To.Index))
                        }
                }