@@ -152,60 +152,61 @@ func stacksplit(ctxt *obj.Link, p *obj.Prog, framesize int32) *obj.Prog {
152
152
p .Reg = REG_R2
153
153
}
154
154
155
- // BHI done
156
- p = obj .Appendp (ctxt , p )
157
- q1 := p
155
+ // BLS do-morestack
156
+ bls := obj .Appendp (ctxt , p )
157
+ bls .As = ABLS
158
+ bls .To .Type = obj .TYPE_BRANCH
158
159
159
- p .As = ABHI
160
- p .To .Type = obj .TYPE_BRANCH
160
+ var last * obj.Prog
161
+ for last = ctxt .Cursym .Text ; last .Link != nil ; last = last .Link {
162
+ }
161
163
162
164
// MOV LR, R3
163
- p = obj .Appendp (ctxt , p )
164
-
165
- p .As = AMOVD
166
- p .From .Type = obj .TYPE_REG
167
- p .From .Reg = REGLINK
168
- p .To .Type = obj .TYPE_REG
169
- p .To .Reg = REG_R3
165
+ movlr := obj .Appendp (ctxt , last )
166
+ movlr .As = AMOVD
167
+ movlr .From .Type = obj .TYPE_REG
168
+ movlr .From .Reg = REGLINK
169
+ movlr .To .Type = obj .TYPE_REG
170
+ movlr .To .Reg = REG_R3
170
171
if q != nil {
171
- q .Pcond = p
172
+ q .Pcond = movlr
173
+ }
174
+ bls .Pcond = movlr
175
+
176
+ debug := movlr
177
+ if false {
178
+ debug = obj .Appendp (ctxt , debug )
179
+ debug .As = AMOVD
180
+ debug .From .Type = obj .TYPE_CONST
181
+ debug .From .Offset = int64 (framesize )
182
+ debug .To .Type = obj .TYPE_REG
183
+ debug .To .Reg = REGTMP
172
184
}
173
-
174
- // TODO(minux): only for debug
175
- p = obj .Appendp (ctxt , p )
176
- p .As = AMOVD
177
- p .From .Type = obj .TYPE_CONST
178
- p .From .Offset = int64 (framesize )
179
- p .To .Type = obj .TYPE_REG
180
- p .To .Reg = REGTMP
181
185
182
186
// BL runtime.morestack(SB)
183
- p = obj .Appendp (ctxt , p )
184
-
185
- p .As = ABL
186
- p .To .Type = obj .TYPE_BRANCH
187
- if ctxt .Cursym .Cfunc != 0 {
188
- p .To .Sym = obj .Linklookup (ctxt , "runtime.morestackc" , 0 )
189
- } else if ctxt .Cursym .Text .From3 .Offset & obj .NEEDCTXT == 0 {
190
- p .To .Sym = obj .Linklookup (ctxt , "runtime.morestack_noctxt" , 0 )
191
- } else {
192
- p .To .Sym = obj .Linklookup (ctxt , "runtime.morestack" , 0 )
187
+ call := obj .Appendp (ctxt , debug )
188
+ call .As = ABL
189
+ call .To .Type = obj .TYPE_BRANCH
190
+ morestack := "runtime.morestack"
191
+ switch {
192
+ case ctxt .Cursym .Cfunc != 0 :
193
+ morestack = "runtime.morestackc"
194
+ case ctxt .Cursym .Text .From3 .Offset & obj .NEEDCTXT == 0 :
195
+ morestack = "runtime.morestack_noctxt"
193
196
}
197
+ call .To .Sym = obj .Linklookup (ctxt , morestack , 0 )
194
198
195
199
// B start
196
- p = obj .Appendp (ctxt , p )
197
-
198
- p .As = AB
199
- p .To .Type = obj .TYPE_BRANCH
200
- p .Pcond = ctxt .Cursym .Text .Link
201
-
202
- // placeholder for q1's jump target
203
- p = obj .Appendp (ctxt , p )
200
+ jmp := obj .Appendp (ctxt , call )
201
+ jmp .As = AB
202
+ jmp .To .Type = obj .TYPE_BRANCH
203
+ jmp .Pcond = ctxt .Cursym .Text .Link
204
204
205
- p .As = obj .ANOP
206
- q1 .Pcond = p
205
+ // placeholder for bls's jump target
206
+ // p = obj.Appendp(ctxt, p)
207
+ // p.As = obj.ANOP
207
208
208
- return p
209
+ return bls
209
210
}
210
211
211
212
func progedit (ctxt * obj.Link , p * obj.Prog ) {
0 commit comments