]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: deduplicate appendpp functions
authorMatthew Dempsky <mdempsky@google.com>
Thu, 15 Sep 2016 07:34:35 +0000 (00:34 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 15 Sep 2016 08:02:57 +0000 (08:02 +0000)
Change-Id: Ifa7a882b020f7b0c9602c28c3e5567e5d4c39e73
Reviewed-on: https://go-review.googlesource.com/29216
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
src/cmd/compile/internal/amd64/ggen.go
src/cmd/compile/internal/arm/ggen.go
src/cmd/compile/internal/arm64/ggen.go
src/cmd/compile/internal/gc/gsubr.go
src/cmd/compile/internal/mips64/ggen.go
src/cmd/compile/internal/ppc64/ggen.go
src/cmd/compile/internal/s390x/ggen.go
src/cmd/compile/internal/x86/ggen.go

index 775c0d6e9f12539ec66dbb3948bfb2dea009c288..2e1fb4a2c495ca9acb9ac63bb95a4e15589da76d 100644 (file)
@@ -112,72 +112,56 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, ax *uint32, x0 *uin
                        gc.Fatalf("zerorange count not a multiple of widthptr %d", cnt)
                }
                if *ax == 0 {
-                       p = appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
+                       p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
                        *ax = 1
                }
-               p = appendpp(p, x86.AMOVL, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
+               p = gc.Appendpp(p, x86.AMOVL, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
                lo += int64(gc.Widthptr)
                cnt -= int64(gc.Widthptr)
        }
 
        if cnt == 8 {
                if *ax == 0 {
-                       p = appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
+                       p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
                        *ax = 1
                }
-               p = appendpp(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
+               p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
        } else if !isPlan9 && cnt <= int64(8*gc.Widthreg) {
                if *x0 == 0 {
-                       p = appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
+                       p = gc.Appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
                        *x0 = 1
                }
 
                for i := int64(0); i < cnt/16; i++ {
-                       p = appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+i*16)
+                       p = gc.Appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+i*16)
                }
 
                if cnt%16 != 0 {
-                       p = appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+cnt-int64(16))
+                       p = gc.Appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+cnt-int64(16))
                }
        } else if !gc.Nacl && !isPlan9 && (cnt <= int64(128*gc.Widthreg)) {
                if *x0 == 0 {
-                       p = appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
+                       p = gc.Appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
                        *x0 = 1
                }
-               p = appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo+dzDI(cnt), obj.TYPE_REG, x86.REG_DI, 0)
-               p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_ADDR, 0, dzOff(cnt))
+               p = gc.Appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo+dzDI(cnt), obj.TYPE_REG, x86.REG_DI, 0)
+               p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_ADDR, 0, dzOff(cnt))
                p.To.Sym = gc.Linksym(gc.Pkglookup("duffzero", gc.Runtimepkg))
 
                if cnt%16 != 0 {
-                       p = appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_DI, -int64(8))
+                       p = gc.Appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_DI, -int64(8))
                }
        } else {
                if *ax == 0 {
-                       p = appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
+                       p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
                        *ax = 1
                }
 
-               p = appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, cnt/int64(gc.Widthreg), obj.TYPE_REG, x86.REG_CX, 0)
-               p = appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo, obj.TYPE_REG, x86.REG_DI, 0)
-               p = appendpp(p, x86.AREP, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
-               p = appendpp(p, x86.ASTOSQ, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
+               p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, cnt/int64(gc.Widthreg), obj.TYPE_REG, x86.REG_CX, 0)
+               p = gc.Appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo, obj.TYPE_REG, x86.REG_DI, 0)
+               p = gc.Appendpp(p, x86.AREP, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
+               p = gc.Appendpp(p, x86.ASTOSQ, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
        }
 
        return p
 }
-
-func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
-       q := gc.Ctxt.NewProg()
-       gc.Clearp(q)
-       q.As = as
-       q.Lineno = p.Lineno
-       q.From.Type = ftype
-       q.From.Reg = freg
-       q.From.Offset = foffset
-       q.To.Type = ttype
-       q.To.Reg = treg
-       q.To.Offset = toffset
-       q.Link = p.Link
-       p.Link = q
-       return q
-}
index c971f986a59936e0c51e9ee9e1faa4a46db1198d..66acf03a8f1c8f9c405d610ae17233546c41f2e1 100644 (file)
@@ -62,55 +62,39 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, r0 *uint32) *obj.Pr
                return p
        }
        if *r0 == 0 {
-               p = appendpp(p, arm.AMOVW, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, arm.REG_R0, 0)
+               p = gc.Appendpp(p, arm.AMOVW, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, arm.REG_R0, 0)
                *r0 = 1
        }
 
        if cnt < int64(4*gc.Widthptr) {
                for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
-                       p = appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REGSP, 4+frame+lo+i)
+                       p = gc.Appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REGSP, 4+frame+lo+i)
                }
        } else if !gc.Nacl && (cnt <= int64(128*gc.Widthptr)) {
-               p = appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+frame+lo, obj.TYPE_REG, arm.REG_R1, 0)
+               p = gc.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+frame+lo, obj.TYPE_REG, arm.REG_R1, 0)
                p.Reg = arm.REGSP
-               p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
+               p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
                f := gc.Sysfunc("duffzero")
                gc.Naddr(&p.To, f)
                gc.Afunclit(&p.To, f)
                p.To.Offset = 4 * (128 - cnt/int64(gc.Widthptr))
        } else {
-               p = appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+frame+lo, obj.TYPE_REG, arm.REG_R1, 0)
+               p = gc.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+frame+lo, obj.TYPE_REG, arm.REG_R1, 0)
                p.Reg = arm.REGSP
-               p = appendpp(p, arm.AADD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm.REG_R2, 0)
+               p = gc.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm.REG_R2, 0)
                p.Reg = arm.REG_R1
-               p = appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REG_R1, 4)
+               p = gc.Appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REG_R1, 4)
                p1 := p
                p.Scond |= arm.C_PBIT
-               p = appendpp(p, arm.ACMP, obj.TYPE_REG, arm.REG_R1, 0, obj.TYPE_NONE, 0, 0)
+               p = gc.Appendpp(p, arm.ACMP, obj.TYPE_REG, arm.REG_R1, 0, obj.TYPE_NONE, 0, 0)
                p.Reg = arm.REG_R2
-               p = appendpp(p, arm.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
+               p = gc.Appendpp(p, arm.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
                gc.Patch(p, p1)
        }
 
        return p
 }
 
-func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
-       q := gc.Ctxt.NewProg()
-       gc.Clearp(q)
-       q.As = as
-       q.Lineno = p.Lineno
-       q.From.Type = ftype
-       q.From.Reg = freg
-       q.From.Offset = foffset
-       q.To.Type = ttype
-       q.To.Reg = treg
-       q.To.Offset = toffset
-       q.Link = p.Link
-       p.Link = q
-       return q
-}
-
 func ginsnop() {
        var r gc.Node
        gc.Nodreg(&r, gc.Types[gc.TINT], arm.REG_R0)
index 9efb95c3dc7100fa0a582c0ff6b2200aab2c8019..0ea3e4adeac16956db6b5a39325146223c8489fc 100644 (file)
@@ -74,53 +74,37 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        }
        if cnt < int64(4*gc.Widthptr) {
                for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
-                       p = appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, 8+frame+lo+i)
+                       p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, 8+frame+lo+i)
                }
        } else if cnt <= int64(128*gc.Widthptr) && !darwin { // darwin ld64 cannot handle BR26 reloc with non-zero addend
-               p = appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGSP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
-               p = appendpp(p, arm64.AADD, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, arm64.REGRT1, 0)
+               p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGSP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
+               p = gc.Appendpp(p, arm64.AADD, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, arm64.REGRT1, 0)
                p.Reg = arm64.REGRT1
-               p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
+               p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
                f := gc.Sysfunc("duffzero")
                gc.Naddr(&p.To, f)
                gc.Afunclit(&p.To, f)
                p.To.Offset = 4 * (128 - cnt/int64(gc.Widthptr))
        } else {
-               p = appendpp(p, arm64.AMOVD, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, arm64.REGTMP, 0)
-               p = appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGSP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
-               p = appendpp(p, arm64.AADD, obj.TYPE_REG, arm64.REGTMP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
+               p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, arm64.REGTMP, 0)
+               p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGSP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
+               p = gc.Appendpp(p, arm64.AADD, obj.TYPE_REG, arm64.REGTMP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
                p.Reg = arm64.REGRT1
-               p = appendpp(p, arm64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm64.REGTMP, 0)
-               p = appendpp(p, arm64.AADD, obj.TYPE_REG, arm64.REGTMP, 0, obj.TYPE_REG, arm64.REGRT2, 0)
+               p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm64.REGTMP, 0)
+               p = gc.Appendpp(p, arm64.AADD, obj.TYPE_REG, arm64.REGTMP, 0, obj.TYPE_REG, arm64.REGRT2, 0)
                p.Reg = arm64.REGRT1
-               p = appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGRT1, int64(gc.Widthptr))
+               p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGRT1, int64(gc.Widthptr))
                p.Scond = arm64.C_XPRE
                p1 := p
-               p = appendpp(p, arm64.ACMP, obj.TYPE_REG, arm64.REGRT1, 0, obj.TYPE_NONE, 0, 0)
+               p = gc.Appendpp(p, arm64.ACMP, obj.TYPE_REG, arm64.REGRT1, 0, obj.TYPE_NONE, 0, 0)
                p.Reg = arm64.REGRT2
-               p = appendpp(p, arm64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
+               p = gc.Appendpp(p, arm64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
                gc.Patch(p, p1)
        }
 
        return p
 }
 
-func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
-       q := gc.Ctxt.NewProg()
-       gc.Clearp(q)
-       q.As = as
-       q.Lineno = p.Lineno
-       q.From.Type = ftype
-       q.From.Reg = freg
-       q.From.Offset = foffset
-       q.To.Type = ttype
-       q.To.Reg = treg
-       q.To.Offset = toffset
-       q.Link = p.Link
-       p.Link = q
-       return q
-}
-
 func ginsnop() {
        var con gc.Node
        gc.Nodconst(&con, gc.Types[gc.TINT], 0)
index ccbb3c40abd3984e32d458fcf56cc9ec388820fc..918c311f416794f3bbd000f6df22dc13a3074985 100644 (file)
@@ -102,6 +102,22 @@ func Clearp(p *obj.Prog) {
        pcloc++
 }
 
+func Appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
+       q := Ctxt.NewProg()
+       Clearp(q)
+       q.As = as
+       q.Lineno = p.Lineno
+       q.From.Type = ftype
+       q.From.Reg = freg
+       q.From.Offset = foffset
+       q.To.Type = ttype
+       q.To.Reg = treg
+       q.To.Offset = toffset
+       q.Link = p.Link
+       p.Link = q
+       return q
+}
+
 func dumpdata() {
        ddumped = true
        if dfirst == nil {
index 4490420f60a0e2edea596d9247bc30532e46b3d8..c8c0d91fdda54ed34bd34b255ba19dbac8a678a3 100644 (file)
@@ -65,15 +65,15 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        }
        if cnt < int64(4*gc.Widthptr) {
                for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
-                       p = appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, 8+frame+lo+i)
+                       p = gc.Appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, 8+frame+lo+i)
                }
                // TODO(dfc): https://golang.org/issue/12108
                // If DUFFZERO is used inside a tail call (see genwrapper) it will
                // overwrite the link register.
        } else if false && cnt <= int64(128*gc.Widthptr) {
-               p = appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, mips.REGRT1, 0)
+               p = gc.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, mips.REGRT1, 0)
                p.Reg = mips.REGSP
-               p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
+               p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
                f := gc.Sysfunc("duffzero")
                gc.Naddr(&p.To, f)
                gc.Afunclit(&p.To, f)
@@ -85,14 +85,14 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
                //      MOVV    R0, (Widthptr)r1
                //      ADDV    $Widthptr, r1
                //      BNE             r1, r2, loop
-               p = appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, mips.REGRT1, 0)
+               p = gc.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, mips.REGRT1, 0)
                p.Reg = mips.REGSP
-               p = appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, mips.REGRT2, 0)
+               p = gc.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, mips.REGRT2, 0)
                p.Reg = mips.REGRT1
-               p = appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGRT1, int64(gc.Widthptr))
+               p = gc.Appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGRT1, int64(gc.Widthptr))
                p1 := p
-               p = appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, int64(gc.Widthptr), obj.TYPE_REG, mips.REGRT1, 0)
-               p = appendpp(p, mips.ABNE, obj.TYPE_REG, mips.REGRT1, 0, obj.TYPE_BRANCH, 0, 0)
+               p = gc.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, int64(gc.Widthptr), obj.TYPE_REG, mips.REGRT1, 0)
+               p = gc.Appendpp(p, mips.ABNE, obj.TYPE_REG, mips.REGRT1, 0, obj.TYPE_BRANCH, 0, 0)
                p.Reg = mips.REGRT2
                gc.Patch(p, p1)
        }
@@ -100,22 +100,6 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        return p
 }
 
-func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
-       q := gc.Ctxt.NewProg()
-       gc.Clearp(q)
-       q.As = as
-       q.Lineno = p.Lineno
-       q.From.Type = ftype
-       q.From.Reg = freg
-       q.From.Offset = foffset
-       q.To.Type = ttype
-       q.To.Reg = treg
-       q.To.Offset = toffset
-       q.Link = p.Link
-       p.Link = q
-       return q
-}
-
 func ginsnop() {
        var reg gc.Node
        gc.Nodreg(&reg, gc.Types[gc.TINT], mips.REG_R0)
index b21a4a4170afb274004852a9214614d59a18b1c4..bc7a91cec71c5288fd3afdb54983915bc0c99697 100644 (file)
@@ -65,49 +65,33 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        }
        if cnt < int64(4*gc.Widthptr) {
                for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
-                       p = appendpp(p, ppc64.AMOVD, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGSP, gc.Ctxt.FixedFrameSize()+frame+lo+i)
+                       p = gc.Appendpp(p, ppc64.AMOVD, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGSP, gc.Ctxt.FixedFrameSize()+frame+lo+i)
                }
        } else if cnt <= int64(128*gc.Widthptr) {
-               p = appendpp(p, ppc64.AADD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+frame+lo-8, obj.TYPE_REG, ppc64.REGRT1, 0)
+               p = gc.Appendpp(p, ppc64.AADD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+frame+lo-8, obj.TYPE_REG, ppc64.REGRT1, 0)
                p.Reg = ppc64.REGSP
-               p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
+               p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
                f := gc.Sysfunc("duffzero")
                gc.Naddr(&p.To, f)
                gc.Afunclit(&p.To, f)
                p.To.Offset = 4 * (128 - cnt/int64(gc.Widthptr))
        } else {
-               p = appendpp(p, ppc64.AMOVD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+frame+lo-8, obj.TYPE_REG, ppc64.REGTMP, 0)
-               p = appendpp(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT1, 0)
+               p = gc.Appendpp(p, ppc64.AMOVD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+frame+lo-8, obj.TYPE_REG, ppc64.REGTMP, 0)
+               p = gc.Appendpp(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT1, 0)
                p.Reg = ppc64.REGSP
-               p = appendpp(p, ppc64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, ppc64.REGTMP, 0)
-               p = appendpp(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT2, 0)
+               p = gc.Appendpp(p, ppc64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, ppc64.REGTMP, 0)
+               p = gc.Appendpp(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT2, 0)
                p.Reg = ppc64.REGRT1
-               p = appendpp(p, ppc64.AMOVDU, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGRT1, int64(gc.Widthptr))
+               p = gc.Appendpp(p, ppc64.AMOVDU, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGRT1, int64(gc.Widthptr))
                p1 := p
-               p = appendpp(p, ppc64.ACMP, obj.TYPE_REG, ppc64.REGRT1, 0, obj.TYPE_REG, ppc64.REGRT2, 0)
-               p = appendpp(p, ppc64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
+               p = gc.Appendpp(p, ppc64.ACMP, obj.TYPE_REG, ppc64.REGRT1, 0, obj.TYPE_REG, ppc64.REGRT2, 0)
+               p = gc.Appendpp(p, ppc64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
                gc.Patch(p, p1)
        }
 
        return p
 }
 
-func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
-       q := gc.Ctxt.NewProg()
-       gc.Clearp(q)
-       q.As = as
-       q.Lineno = p.Lineno
-       q.From.Type = ftype
-       q.From.Reg = freg
-       q.From.Offset = foffset
-       q.To.Type = ttype
-       q.To.Reg = treg
-       q.To.Offset = toffset
-       q.Link = p.Link
-       p.Link = q
-       return q
-}
-
 func ginsnop() {
        var reg gc.Node
        gc.Nodreg(&reg, gc.Types[gc.TINT], ppc64.REG_R0)
index cfaf88da3635eecb8b5c4ca6786335b8c15f780d..60b08c89f07df5711c2ff0d384561b596fe7197b 100644 (file)
@@ -80,7 +80,7 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        // need to create a copy of the stack pointer that we can adjust.
        // We also need to do this if we are going to loop.
        if offset < 0 || offset > 4096-clearLoopCutoff || cnt > clearLoopCutoff {
-               p = appendpp(p, s390x.AADD, obj.TYPE_CONST, 0, offset, obj.TYPE_REG, s390x.REGRT1, 0)
+               p = gc.Appendpp(p, s390x.AADD, obj.TYPE_CONST, 0, offset, obj.TYPE_REG, s390x.REGRT1, 0)
                p.Reg = int16(s390x.REGSP)
                reg = s390x.REGRT1
                offset = 0
@@ -90,16 +90,16 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        if cnt > clearLoopCutoff {
                n := cnt - (cnt % 256)
                end := int16(s390x.REGRT2)
-               p = appendpp(p, s390x.AADD, obj.TYPE_CONST, 0, offset+n, obj.TYPE_REG, end, 0)
+               p = gc.Appendpp(p, s390x.AADD, obj.TYPE_CONST, 0, offset+n, obj.TYPE_REG, end, 0)
                p.Reg = reg
-               p = appendpp(p, s390x.AXC, obj.TYPE_MEM, reg, offset, obj.TYPE_MEM, reg, offset)
+               p = gc.Appendpp(p, s390x.AXC, obj.TYPE_MEM, reg, offset, obj.TYPE_MEM, reg, offset)
                p.From3 = new(obj.Addr)
                p.From3.Type = obj.TYPE_CONST
                p.From3.Offset = 256
                pl := p
-               p = appendpp(p, s390x.AADD, obj.TYPE_CONST, 0, 256, obj.TYPE_REG, reg, 0)
-               p = appendpp(p, s390x.ACMP, obj.TYPE_REG, reg, 0, obj.TYPE_REG, end, 0)
-               p = appendpp(p, s390x.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
+               p = gc.Appendpp(p, s390x.AADD, obj.TYPE_CONST, 0, 256, obj.TYPE_REG, reg, 0)
+               p = gc.Appendpp(p, s390x.ACMP, obj.TYPE_REG, reg, 0, obj.TYPE_REG, end, 0)
+               p = gc.Appendpp(p, s390x.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
                gc.Patch(p, pl)
 
                cnt -= n
@@ -126,11 +126,11 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
                        case 2:
                                ins = s390x.AMOVH
                        }
-                       p = appendpp(p, ins, obj.TYPE_CONST, 0, 0, obj.TYPE_MEM, reg, offset)
+                       p = gc.Appendpp(p, ins, obj.TYPE_CONST, 0, 0, obj.TYPE_MEM, reg, offset)
 
                // Handle clears that would require multiple move instructions with XC.
                default:
-                       p = appendpp(p, s390x.AXC, obj.TYPE_MEM, reg, offset, obj.TYPE_MEM, reg, offset)
+                       p = gc.Appendpp(p, s390x.AXC, obj.TYPE_MEM, reg, offset, obj.TYPE_MEM, reg, offset)
                        p.From3 = new(obj.Addr)
                        p.From3.Type = obj.TYPE_CONST
                        p.From3.Offset = n
@@ -143,22 +143,6 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
        return p
 }
 
-func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
-       q := gc.Ctxt.NewProg()
-       gc.Clearp(q)
-       q.As = as
-       q.Lineno = p.Lineno
-       q.From.Type = ftype
-       q.From.Reg = freg
-       q.From.Offset = foffset
-       q.To.Type = ttype
-       q.To.Reg = treg
-       q.To.Offset = toffset
-       q.Link = p.Link
-       p.Link = q
-       return q
-}
-
 func ginsnop() {
        var reg gc.Node
        gc.Nodreg(&reg, gc.Types[gc.TINT], s390x.REG_R0)
index a6d0588d4d63bcc0248bfd39ae03960eb8fde5ee..97788254f9d0893e9c11f86d6ebadf85fad4e3f3 100644 (file)
@@ -62,40 +62,24 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, ax *uint32) *obj.Pr
                return p
        }
        if *ax == 0 {
-               p = appendpp(p, x86.AMOVL, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
+               p = gc.Appendpp(p, x86.AMOVL, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
                *ax = 1
        }
 
        if cnt <= int64(4*gc.Widthreg) {
                for i := int64(0); i < cnt; i += int64(gc.Widthreg) {
-                       p = appendpp(p, x86.AMOVL, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+i)
+                       p = gc.Appendpp(p, x86.AMOVL, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+i)
                }
        } else if !gc.Nacl && cnt <= int64(128*gc.Widthreg) {
-               p = appendpp(p, x86.ALEAL, obj.TYPE_MEM, x86.REG_SP, frame+lo, obj.TYPE_REG, x86.REG_DI, 0)
-               p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_ADDR, 0, 1*(128-cnt/int64(gc.Widthreg)))
+               p = gc.Appendpp(p, x86.ALEAL, obj.TYPE_MEM, x86.REG_SP, frame+lo, obj.TYPE_REG, x86.REG_DI, 0)
+               p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_ADDR, 0, 1*(128-cnt/int64(gc.Widthreg)))
                p.To.Sym = gc.Linksym(gc.Pkglookup("duffzero", gc.Runtimepkg))
        } else {
-               p = appendpp(p, x86.AMOVL, obj.TYPE_CONST, 0, cnt/int64(gc.Widthreg), obj.TYPE_REG, x86.REG_CX, 0)
-               p = appendpp(p, x86.ALEAL, obj.TYPE_MEM, x86.REG_SP, frame+lo, obj.TYPE_REG, x86.REG_DI, 0)
-               p = appendpp(p, x86.AREP, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
-               p = appendpp(p, x86.ASTOSL, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
+               p = gc.Appendpp(p, x86.AMOVL, obj.TYPE_CONST, 0, cnt/int64(gc.Widthreg), obj.TYPE_REG, x86.REG_CX, 0)
+               p = gc.Appendpp(p, x86.ALEAL, obj.TYPE_MEM, x86.REG_SP, frame+lo, obj.TYPE_REG, x86.REG_DI, 0)
+               p = gc.Appendpp(p, x86.AREP, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
+               p = gc.Appendpp(p, x86.ASTOSL, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
        }
 
        return p
 }
-
-func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
-       q := gc.Ctxt.NewProg()
-       gc.Clearp(q)
-       q.As = as
-       q.Lineno = p.Lineno
-       q.From.Type = ftype
-       q.From.Reg = freg
-       q.From.Offset = foffset
-       q.To.Type = ttype
-       q.To.Reg = treg
-       q.To.Offset = toffset
-       q.Link = p.Link
-       p.Link = q
-       return q
-}