Skip to content

Commit 78c4658

Browse files
committed
cmd/compile: deduplicate appendpp functions
Change-Id: Ifa7a882b020f7b0c9602c28c3e5567e5d4c39e73 Reviewed-on: https://go-review.googlesource.com/29216 Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Michael Hudson-Doyle <[email protected]>
1 parent 8a0bd5d commit 78c4658

File tree

8 files changed

+87
-183
lines changed

8 files changed

+87
-183
lines changed

src/cmd/compile/internal/amd64/ggen.go

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -112,72 +112,56 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, ax *uint32, x0 *uin
112112
gc.Fatalf("zerorange count not a multiple of widthptr %d", cnt)
113113
}
114114
if *ax == 0 {
115-
p = appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
115+
p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
116116
*ax = 1
117117
}
118-
p = appendpp(p, x86.AMOVL, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
118+
p = gc.Appendpp(p, x86.AMOVL, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
119119
lo += int64(gc.Widthptr)
120120
cnt -= int64(gc.Widthptr)
121121
}
122122

123123
if cnt == 8 {
124124
if *ax == 0 {
125-
p = appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
125+
p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
126126
*ax = 1
127127
}
128-
p = appendpp(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
128+
p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_REG, x86.REG_AX, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo)
129129
} else if !isPlan9 && cnt <= int64(8*gc.Widthreg) {
130130
if *x0 == 0 {
131-
p = appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
131+
p = gc.Appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
132132
*x0 = 1
133133
}
134134

135135
for i := int64(0); i < cnt/16; i++ {
136-
p = appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+i*16)
136+
p = gc.Appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+i*16)
137137
}
138138

139139
if cnt%16 != 0 {
140-
p = appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+cnt-int64(16))
140+
p = gc.Appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_SP, frame+lo+cnt-int64(16))
141141
}
142142
} else if !gc.Nacl && !isPlan9 && (cnt <= int64(128*gc.Widthreg)) {
143143
if *x0 == 0 {
144-
p = appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
144+
p = gc.Appendpp(p, x86.AXORPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_REG, x86.REG_X0, 0)
145145
*x0 = 1
146146
}
147-
p = appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo+dzDI(cnt), obj.TYPE_REG, x86.REG_DI, 0)
148-
p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_ADDR, 0, dzOff(cnt))
147+
p = gc.Appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo+dzDI(cnt), obj.TYPE_REG, x86.REG_DI, 0)
148+
p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_ADDR, 0, dzOff(cnt))
149149
p.To.Sym = gc.Linksym(gc.Pkglookup("duffzero", gc.Runtimepkg))
150150

151151
if cnt%16 != 0 {
152-
p = appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_DI, -int64(8))
152+
p = gc.Appendpp(p, x86.AMOVUPS, obj.TYPE_REG, x86.REG_X0, 0, obj.TYPE_MEM, x86.REG_DI, -int64(8))
153153
}
154154
} else {
155155
if *ax == 0 {
156-
p = appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
156+
p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, x86.REG_AX, 0)
157157
*ax = 1
158158
}
159159

160-
p = appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, cnt/int64(gc.Widthreg), obj.TYPE_REG, x86.REG_CX, 0)
161-
p = appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo, obj.TYPE_REG, x86.REG_DI, 0)
162-
p = appendpp(p, x86.AREP, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
163-
p = appendpp(p, x86.ASTOSQ, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
160+
p = gc.Appendpp(p, x86.AMOVQ, obj.TYPE_CONST, 0, cnt/int64(gc.Widthreg), obj.TYPE_REG, x86.REG_CX, 0)
161+
p = gc.Appendpp(p, leaptr, obj.TYPE_MEM, x86.REG_SP, frame+lo, obj.TYPE_REG, x86.REG_DI, 0)
162+
p = gc.Appendpp(p, x86.AREP, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
163+
p = gc.Appendpp(p, x86.ASTOSQ, obj.TYPE_NONE, 0, 0, obj.TYPE_NONE, 0, 0)
164164
}
165165

166166
return p
167167
}
168-
169-
func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
170-
q := gc.Ctxt.NewProg()
171-
gc.Clearp(q)
172-
q.As = as
173-
q.Lineno = p.Lineno
174-
q.From.Type = ftype
175-
q.From.Reg = freg
176-
q.From.Offset = foffset
177-
q.To.Type = ttype
178-
q.To.Reg = treg
179-
q.To.Offset = toffset
180-
q.Link = p.Link
181-
p.Link = q
182-
return q
183-
}

src/cmd/compile/internal/arm/ggen.go

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,55 +62,39 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64, r0 *uint32) *obj.Pr
6262
return p
6363
}
6464
if *r0 == 0 {
65-
p = appendpp(p, arm.AMOVW, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, arm.REG_R0, 0)
65+
p = gc.Appendpp(p, arm.AMOVW, obj.TYPE_CONST, 0, 0, obj.TYPE_REG, arm.REG_R0, 0)
6666
*r0 = 1
6767
}
6868

6969
if cnt < int64(4*gc.Widthptr) {
7070
for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
71-
p = appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REGSP, 4+frame+lo+i)
71+
p = gc.Appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REGSP, 4+frame+lo+i)
7272
}
7373
} else if !gc.Nacl && (cnt <= int64(128*gc.Widthptr)) {
74-
p = appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+frame+lo, obj.TYPE_REG, arm.REG_R1, 0)
74+
p = gc.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+frame+lo, obj.TYPE_REG, arm.REG_R1, 0)
7575
p.Reg = arm.REGSP
76-
p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
76+
p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
7777
f := gc.Sysfunc("duffzero")
7878
gc.Naddr(&p.To, f)
7979
gc.Afunclit(&p.To, f)
8080
p.To.Offset = 4 * (128 - cnt/int64(gc.Widthptr))
8181
} else {
82-
p = appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+frame+lo, obj.TYPE_REG, arm.REG_R1, 0)
82+
p = gc.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, 4+frame+lo, obj.TYPE_REG, arm.REG_R1, 0)
8383
p.Reg = arm.REGSP
84-
p = appendpp(p, arm.AADD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm.REG_R2, 0)
84+
p = gc.Appendpp(p, arm.AADD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm.REG_R2, 0)
8585
p.Reg = arm.REG_R1
86-
p = appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REG_R1, 4)
86+
p = gc.Appendpp(p, arm.AMOVW, obj.TYPE_REG, arm.REG_R0, 0, obj.TYPE_MEM, arm.REG_R1, 4)
8787
p1 := p
8888
p.Scond |= arm.C_PBIT
89-
p = appendpp(p, arm.ACMP, obj.TYPE_REG, arm.REG_R1, 0, obj.TYPE_NONE, 0, 0)
89+
p = gc.Appendpp(p, arm.ACMP, obj.TYPE_REG, arm.REG_R1, 0, obj.TYPE_NONE, 0, 0)
9090
p.Reg = arm.REG_R2
91-
p = appendpp(p, arm.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
91+
p = gc.Appendpp(p, arm.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
9292
gc.Patch(p, p1)
9393
}
9494

9595
return p
9696
}
9797

98-
func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
99-
q := gc.Ctxt.NewProg()
100-
gc.Clearp(q)
101-
q.As = as
102-
q.Lineno = p.Lineno
103-
q.From.Type = ftype
104-
q.From.Reg = freg
105-
q.From.Offset = foffset
106-
q.To.Type = ttype
107-
q.To.Reg = treg
108-
q.To.Offset = toffset
109-
q.Link = p.Link
110-
p.Link = q
111-
return q
112-
}
113-
11498
func ginsnop() {
11599
var r gc.Node
116100
gc.Nodreg(&r, gc.Types[gc.TINT], arm.REG_R0)

src/cmd/compile/internal/arm64/ggen.go

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -74,53 +74,37 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
7474
}
7575
if cnt < int64(4*gc.Widthptr) {
7676
for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
77-
p = appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, 8+frame+lo+i)
77+
p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGSP, 8+frame+lo+i)
7878
}
7979
} else if cnt <= int64(128*gc.Widthptr) && !darwin { // darwin ld64 cannot handle BR26 reloc with non-zero addend
80-
p = appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGSP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
81-
p = appendpp(p, arm64.AADD, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, arm64.REGRT1, 0)
80+
p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGSP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
81+
p = gc.Appendpp(p, arm64.AADD, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, arm64.REGRT1, 0)
8282
p.Reg = arm64.REGRT1
83-
p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
83+
p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
8484
f := gc.Sysfunc("duffzero")
8585
gc.Naddr(&p.To, f)
8686
gc.Afunclit(&p.To, f)
8787
p.To.Offset = 4 * (128 - cnt/int64(gc.Widthptr))
8888
} else {
89-
p = appendpp(p, arm64.AMOVD, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, arm64.REGTMP, 0)
90-
p = appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGSP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
91-
p = appendpp(p, arm64.AADD, obj.TYPE_REG, arm64.REGTMP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
89+
p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, arm64.REGTMP, 0)
90+
p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGSP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
91+
p = gc.Appendpp(p, arm64.AADD, obj.TYPE_REG, arm64.REGTMP, 0, obj.TYPE_REG, arm64.REGRT1, 0)
9292
p.Reg = arm64.REGRT1
93-
p = appendpp(p, arm64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm64.REGTMP, 0)
94-
p = appendpp(p, arm64.AADD, obj.TYPE_REG, arm64.REGTMP, 0, obj.TYPE_REG, arm64.REGRT2, 0)
93+
p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, arm64.REGTMP, 0)
94+
p = gc.Appendpp(p, arm64.AADD, obj.TYPE_REG, arm64.REGTMP, 0, obj.TYPE_REG, arm64.REGRT2, 0)
9595
p.Reg = arm64.REGRT1
96-
p = appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGRT1, int64(gc.Widthptr))
96+
p = gc.Appendpp(p, arm64.AMOVD, obj.TYPE_REG, arm64.REGZERO, 0, obj.TYPE_MEM, arm64.REGRT1, int64(gc.Widthptr))
9797
p.Scond = arm64.C_XPRE
9898
p1 := p
99-
p = appendpp(p, arm64.ACMP, obj.TYPE_REG, arm64.REGRT1, 0, obj.TYPE_NONE, 0, 0)
99+
p = gc.Appendpp(p, arm64.ACMP, obj.TYPE_REG, arm64.REGRT1, 0, obj.TYPE_NONE, 0, 0)
100100
p.Reg = arm64.REGRT2
101-
p = appendpp(p, arm64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
101+
p = gc.Appendpp(p, arm64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
102102
gc.Patch(p, p1)
103103
}
104104

105105
return p
106106
}
107107

108-
func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
109-
q := gc.Ctxt.NewProg()
110-
gc.Clearp(q)
111-
q.As = as
112-
q.Lineno = p.Lineno
113-
q.From.Type = ftype
114-
q.From.Reg = freg
115-
q.From.Offset = foffset
116-
q.To.Type = ttype
117-
q.To.Reg = treg
118-
q.To.Offset = toffset
119-
q.Link = p.Link
120-
p.Link = q
121-
return q
122-
}
123-
124108
func ginsnop() {
125109
var con gc.Node
126110
gc.Nodconst(&con, gc.Types[gc.TINT], 0)

src/cmd/compile/internal/gc/gsubr.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ func Clearp(p *obj.Prog) {
102102
pcloc++
103103
}
104104

105+
func Appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
106+
q := Ctxt.NewProg()
107+
Clearp(q)
108+
q.As = as
109+
q.Lineno = p.Lineno
110+
q.From.Type = ftype
111+
q.From.Reg = freg
112+
q.From.Offset = foffset
113+
q.To.Type = ttype
114+
q.To.Reg = treg
115+
q.To.Offset = toffset
116+
q.Link = p.Link
117+
p.Link = q
118+
return q
119+
}
120+
105121
func dumpdata() {
106122
ddumped = true
107123
if dfirst == nil {

src/cmd/compile/internal/mips64/ggen.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
6565
}
6666
if cnt < int64(4*gc.Widthptr) {
6767
for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
68-
p = appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, 8+frame+lo+i)
68+
p = gc.Appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGSP, 8+frame+lo+i)
6969
}
7070
// TODO(dfc): https://golang.org/issue/12108
7171
// If DUFFZERO is used inside a tail call (see genwrapper) it will
7272
// overwrite the link register.
7373
} else if false && cnt <= int64(128*gc.Widthptr) {
74-
p = appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, mips.REGRT1, 0)
74+
p = gc.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, mips.REGRT1, 0)
7575
p.Reg = mips.REGSP
76-
p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
76+
p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
7777
f := gc.Sysfunc("duffzero")
7878
gc.Naddr(&p.To, f)
7979
gc.Afunclit(&p.To, f)
@@ -85,37 +85,21 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
8585
// MOVV R0, (Widthptr)r1
8686
// ADDV $Widthptr, r1
8787
// BNE r1, r2, loop
88-
p = appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, mips.REGRT1, 0)
88+
p = gc.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, 8+frame+lo-8, obj.TYPE_REG, mips.REGRT1, 0)
8989
p.Reg = mips.REGSP
90-
p = appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, mips.REGRT2, 0)
90+
p = gc.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, mips.REGRT2, 0)
9191
p.Reg = mips.REGRT1
92-
p = appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGRT1, int64(gc.Widthptr))
92+
p = gc.Appendpp(p, mips.AMOVV, obj.TYPE_REG, mips.REGZERO, 0, obj.TYPE_MEM, mips.REGRT1, int64(gc.Widthptr))
9393
p1 := p
94-
p = appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, int64(gc.Widthptr), obj.TYPE_REG, mips.REGRT1, 0)
95-
p = appendpp(p, mips.ABNE, obj.TYPE_REG, mips.REGRT1, 0, obj.TYPE_BRANCH, 0, 0)
94+
p = gc.Appendpp(p, mips.AADDV, obj.TYPE_CONST, 0, int64(gc.Widthptr), obj.TYPE_REG, mips.REGRT1, 0)
95+
p = gc.Appendpp(p, mips.ABNE, obj.TYPE_REG, mips.REGRT1, 0, obj.TYPE_BRANCH, 0, 0)
9696
p.Reg = mips.REGRT2
9797
gc.Patch(p, p1)
9898
}
9999

100100
return p
101101
}
102102

103-
func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
104-
q := gc.Ctxt.NewProg()
105-
gc.Clearp(q)
106-
q.As = as
107-
q.Lineno = p.Lineno
108-
q.From.Type = ftype
109-
q.From.Reg = freg
110-
q.From.Offset = foffset
111-
q.To.Type = ttype
112-
q.To.Reg = treg
113-
q.To.Offset = toffset
114-
q.Link = p.Link
115-
p.Link = q
116-
return q
117-
}
118-
119103
func ginsnop() {
120104
var reg gc.Node
121105
gc.Nodreg(&reg, gc.Types[gc.TINT], mips.REG_R0)

src/cmd/compile/internal/ppc64/ggen.go

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -65,49 +65,33 @@ func zerorange(p *obj.Prog, frame int64, lo int64, hi int64) *obj.Prog {
6565
}
6666
if cnt < int64(4*gc.Widthptr) {
6767
for i := int64(0); i < cnt; i += int64(gc.Widthptr) {
68-
p = appendpp(p, ppc64.AMOVD, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGSP, gc.Ctxt.FixedFrameSize()+frame+lo+i)
68+
p = gc.Appendpp(p, ppc64.AMOVD, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGSP, gc.Ctxt.FixedFrameSize()+frame+lo+i)
6969
}
7070
} else if cnt <= int64(128*gc.Widthptr) {
71-
p = appendpp(p, ppc64.AADD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+frame+lo-8, obj.TYPE_REG, ppc64.REGRT1, 0)
71+
p = gc.Appendpp(p, ppc64.AADD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+frame+lo-8, obj.TYPE_REG, ppc64.REGRT1, 0)
7272
p.Reg = ppc64.REGSP
73-
p = appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
73+
p = gc.Appendpp(p, obj.ADUFFZERO, obj.TYPE_NONE, 0, 0, obj.TYPE_MEM, 0, 0)
7474
f := gc.Sysfunc("duffzero")
7575
gc.Naddr(&p.To, f)
7676
gc.Afunclit(&p.To, f)
7777
p.To.Offset = 4 * (128 - cnt/int64(gc.Widthptr))
7878
} else {
79-
p = appendpp(p, ppc64.AMOVD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+frame+lo-8, obj.TYPE_REG, ppc64.REGTMP, 0)
80-
p = appendpp(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT1, 0)
79+
p = gc.Appendpp(p, ppc64.AMOVD, obj.TYPE_CONST, 0, gc.Ctxt.FixedFrameSize()+frame+lo-8, obj.TYPE_REG, ppc64.REGTMP, 0)
80+
p = gc.Appendpp(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT1, 0)
8181
p.Reg = ppc64.REGSP
82-
p = appendpp(p, ppc64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, ppc64.REGTMP, 0)
83-
p = appendpp(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT2, 0)
82+
p = gc.Appendpp(p, ppc64.AMOVD, obj.TYPE_CONST, 0, cnt, obj.TYPE_REG, ppc64.REGTMP, 0)
83+
p = gc.Appendpp(p, ppc64.AADD, obj.TYPE_REG, ppc64.REGTMP, 0, obj.TYPE_REG, ppc64.REGRT2, 0)
8484
p.Reg = ppc64.REGRT1
85-
p = appendpp(p, ppc64.AMOVDU, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGRT1, int64(gc.Widthptr))
85+
p = gc.Appendpp(p, ppc64.AMOVDU, obj.TYPE_REG, ppc64.REGZERO, 0, obj.TYPE_MEM, ppc64.REGRT1, int64(gc.Widthptr))
8686
p1 := p
87-
p = appendpp(p, ppc64.ACMP, obj.TYPE_REG, ppc64.REGRT1, 0, obj.TYPE_REG, ppc64.REGRT2, 0)
88-
p = appendpp(p, ppc64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
87+
p = gc.Appendpp(p, ppc64.ACMP, obj.TYPE_REG, ppc64.REGRT1, 0, obj.TYPE_REG, ppc64.REGRT2, 0)
88+
p = gc.Appendpp(p, ppc64.ABNE, obj.TYPE_NONE, 0, 0, obj.TYPE_BRANCH, 0, 0)
8989
gc.Patch(p, p1)
9090
}
9191

9292
return p
9393
}
9494

95-
func appendpp(p *obj.Prog, as obj.As, ftype obj.AddrType, freg int16, foffset int64, ttype obj.AddrType, treg int16, toffset int64) *obj.Prog {
96-
q := gc.Ctxt.NewProg()
97-
gc.Clearp(q)
98-
q.As = as
99-
q.Lineno = p.Lineno
100-
q.From.Type = ftype
101-
q.From.Reg = freg
102-
q.From.Offset = foffset
103-
q.To.Type = ttype
104-
q.To.Reg = treg
105-
q.To.Offset = toffset
106-
q.Link = p.Link
107-
p.Link = q
108-
return q
109-
}
110-
11195
func ginsnop() {
11296
var reg gc.Node
11397
gc.Nodreg(&reg, gc.Types[gc.TINT], ppc64.REG_R0)

0 commit comments

Comments
 (0)