1 // cmd/7l/noop.c, cmd/7l/obj.c, cmd/ld/pass.c from Vita Nuova.
2 // https://code.google.com/p/ken-cc/source/browse/
4 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
5 // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
6 // Portions Copyright © 1997-1999 Vita Nuova Limited
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
8 // Portions Copyright © 2004,2006 Bruce Ellis
9 // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
10 // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
11 // Portions Copyright © 2009 The Go Authors. All rights reserved.
13 // Permission is hereby granted, free of charge, to any person obtaining a copy
14 // of this software and associated documentation files (the "Software"), to deal
15 // in the Software without restriction, including without limitation the rights
16 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 // copies of the Software, and to permit persons to whom the Software is
18 // furnished to do so, subject to the following conditions:
20 // The above copyright notice and this permission notice shall be included in
21 // all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
42 var complements = []obj.As{
53 func (c *ctxt7) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
54 // MOV g_stackguard(g), R1
55 p = obj.Appendp(p, c.newprog)
58 p.From.Type = obj.TYPE_MEM
60 p.From.Offset = 2 * int64(c.ctxt.Arch.PtrSize) // G.stackguard0
62 p.From.Offset = 3 * int64(c.ctxt.Arch.PtrSize) // G.stackguard1
64 p.To.Type = obj.TYPE_REG
67 // Mark the stack bound check and morestack call async nonpreemptible.
68 // If we get preempted here, when resumed the preemption request is
69 // cleared, but we'll still call morestack, which will double the stack
70 // unnecessarily. See issue #35470.
71 p = c.ctxt.StartUnsafePoint(p, c.newprog)
74 if framesize <= objabi.StackSmall {
75 // small stack: SP < stackguard
78 p = obj.Appendp(p, c.newprog)
81 p.From.Type = obj.TYPE_REG
83 p.To.Type = obj.TYPE_REG
86 p = obj.Appendp(p, c.newprog)
88 p.From.Type = obj.TYPE_REG
91 } else if framesize <= objabi.StackBig {
92 // large stack: SP-framesize < stackguard-StackSmall
93 // SUB $(framesize-StackSmall), SP, R2
95 p = obj.Appendp(p, c.newprog)
98 p.From.Type = obj.TYPE_CONST
99 p.From.Offset = int64(framesize) - objabi.StackSmall
101 p.To.Type = obj.TYPE_REG
104 p = obj.Appendp(p, c.newprog)
106 p.From.Type = obj.TYPE_REG
110 // Such a large stack we need to protect against wraparound
111 // if SP is close to zero.
112 // SP-stackguard+StackGuard < framesize + (StackGuard-StackSmall)
113 // The +StackGuard on both sides is required to keep the left side positive:
114 // SP is allowed to be slightly below stackguard. See stack.h.
115 // CMP $StackPreempt, R1
116 // BEQ label_of_call_to_morestack
117 // ADD $StackGuard, SP, R2
119 // MOV $(framesize+(StackGuard-StackSmall)), R3
121 p = obj.Appendp(p, c.newprog)
124 p.From.Type = obj.TYPE_CONST
125 p.From.Offset = objabi.StackPreempt
128 p = obj.Appendp(p, c.newprog)
131 p.To.Type = obj.TYPE_BRANCH
133 p = obj.Appendp(p, c.newprog)
135 p.From.Type = obj.TYPE_CONST
136 p.From.Offset = int64(objabi.StackGuard)
138 p.To.Type = obj.TYPE_REG
141 p = obj.Appendp(p, c.newprog)
143 p.From.Type = obj.TYPE_REG
145 p.To.Type = obj.TYPE_REG
148 p = obj.Appendp(p, c.newprog)
150 p.From.Type = obj.TYPE_CONST
151 p.From.Offset = int64(framesize) + (int64(objabi.StackGuard) - objabi.StackSmall)
152 p.To.Type = obj.TYPE_REG
155 p = obj.Appendp(p, c.newprog)
157 p.From.Type = obj.TYPE_REG
163 bls := obj.Appendp(p, c.newprog)
165 bls.To.Type = obj.TYPE_BRANCH
167 end := c.ctxt.EndUnsafePoint(bls, c.newprog, -1)
170 for last = c.cursym.Func().Text; last.Link != nil; last = last.Link {
173 // Now we are at the end of the function, but logically
174 // we are still in function prologue. We need to fix the
175 // SP data and PCDATA.
176 spfix := obj.Appendp(last, c.newprog)
178 spfix.Spadj = -framesize
180 pcdata := c.ctxt.EmitEntryStackMap(c.cursym, spfix, c.newprog)
181 pcdata = c.ctxt.StartUnsafePoint(pcdata, c.newprog)
184 movlr := obj.Appendp(pcdata, c.newprog)
186 movlr.From.Type = obj.TYPE_REG
187 movlr.From.Reg = REGLINK
188 movlr.To.Type = obj.TYPE_REG
189 movlr.To.Reg = REG_R3
191 q.To.SetTarget(movlr)
193 bls.To.SetTarget(movlr)
197 debug = obj.Appendp(debug, c.newprog)
199 debug.From.Type = obj.TYPE_CONST
200 debug.From.Offset = int64(framesize)
201 debug.To.Type = obj.TYPE_REG
202 debug.To.Reg = REGTMP
205 // BL runtime.morestack(SB)
206 call := obj.Appendp(debug, c.newprog)
208 call.To.Type = obj.TYPE_BRANCH
209 morestack := "runtime.morestack"
211 case c.cursym.CFunc():
212 morestack = "runtime.morestackc"
213 case !c.cursym.Func().Text.From.Sym.NeedCtxt():
214 morestack = "runtime.morestack_noctxt"
216 call.To.Sym = c.ctxt.Lookup(morestack)
218 pcdata = c.ctxt.EndUnsafePoint(call, c.newprog, -1)
221 jmp := obj.Appendp(pcdata, c.newprog)
223 jmp.To.Type = obj.TYPE_BRANCH
224 jmp.To.SetTarget(c.cursym.Func().Text.Link)
225 jmp.Spadj = +framesize
230 func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
231 c := ctxt7{ctxt: ctxt, newprog: newprog}
236 // $0 results in C_ZCON, which matches both C_REG and various
237 // C_xCON, however the C_REG cases in asmout don't expect a
238 // constant, so they will use the register fields and assemble
239 // a R0. To prevent that, rewrite $0 as ZR.
240 if p.From.Type == obj.TYPE_CONST && p.From.Offset == 0 {
241 p.From.Type = obj.TYPE_REG
244 if p.To.Type == obj.TYPE_CONST && p.To.Offset == 0 {
245 p.To.Type = obj.TYPE_REG
249 // Rewrite BR/BL to symbol as TYPE_BRANCH.
257 p.To.Type = obj.TYPE_BRANCH
262 // Rewrite float constants to values stored in memory.
265 if p.From.Type == obj.TYPE_FCONST {
266 f64 := p.From.Val.(float64)
268 if c.chipfloat7(f64) > 0 {
271 if math.Float32bits(f32) == 0 {
272 p.From.Type = obj.TYPE_REG
276 p.From.Type = obj.TYPE_MEM
277 p.From.Sym = c.ctxt.Float32Sym(f32)
278 p.From.Name = obj.NAME_EXTERN
283 if p.From.Type == obj.TYPE_FCONST {
284 f64 := p.From.Val.(float64)
285 if c.chipfloat7(f64) > 0 {
288 if math.Float64bits(f64) == 0 {
289 p.From.Type = obj.TYPE_REG
293 p.From.Type = obj.TYPE_MEM
294 p.From.Sym = c.ctxt.Float64Sym(f64)
295 p.From.Name = obj.NAME_EXTERN
302 // Rewrite negative immediates as positive immediates with
303 // complementary instruction.
305 case AADD, ASUB, ACMP, ACMN:
306 if p.From.Type == obj.TYPE_CONST && p.From.Offset < 0 && p.From.Offset != -1<<63 {
307 p.From.Offset = -p.From.Offset
308 p.As = complements[p.As]
310 case AADDW, ASUBW, ACMPW, ACMNW:
311 if p.From.Type == obj.TYPE_CONST && p.From.Offset < 0 && int32(p.From.Offset) != -1<<31 {
312 p.From.Offset = -p.From.Offset
313 p.As = complements[p.As]
317 // For 32-bit logical instruction with constant,
318 // rewrite the high 32-bit to be a repetition of
319 // the low 32-bit, so that the BITCON test can be
320 // shared for both 32-bit and 64-bit. 32-bit ops
321 // will zero the high 32-bit of the destination
323 if isANDWop(p.As) && p.From.Type == obj.TYPE_CONST {
324 v := p.From.Offset & 0xffffffff
325 p.From.Offset = v | v<<32
328 if c.ctxt.Flag_dynlink {
333 // Rewrite p, if necessary, to access global data via the global offset table.
334 func (c *ctxt7) rewriteToUseGot(p *obj.Prog) {
335 if p.As == obj.ADUFFCOPY || p.As == obj.ADUFFZERO {
338 // MOVD runtime.duffxxx@GOT, REGTMP
339 // ADD $offset, REGTMP
342 if p.As == obj.ADUFFZERO {
343 sym = c.ctxt.Lookup("runtime.duffzero")
345 sym = c.ctxt.Lookup("runtime.duffcopy")
347 offset := p.To.Offset
349 p.From.Type = obj.TYPE_MEM
350 p.From.Name = obj.NAME_GOTREF
352 p.To.Type = obj.TYPE_REG
354 p.To.Name = obj.NAME_NONE
357 p1 := obj.Appendp(p, c.newprog)
359 p1.From.Type = obj.TYPE_CONST
360 p1.From.Offset = offset
361 p1.To.Type = obj.TYPE_REG
363 p2 := obj.Appendp(p1, c.newprog)
365 p2.To.Type = obj.TYPE_REG
369 // We only care about global data: NAME_EXTERN means a global
370 // symbol in the Go sense, and p.Sym.Local is true for a few
371 // internally defined symbols.
372 if p.From.Type == obj.TYPE_ADDR && p.From.Name == obj.NAME_EXTERN && !p.From.Sym.Local() {
373 // MOVD $sym, Rx becomes MOVD sym@GOT, Rx
374 // MOVD $sym+<off>, Rx becomes MOVD sym@GOT, Rx; ADD <off>, Rx
376 c.ctxt.Diag("do not know how to handle TYPE_ADDR in %v with -dynlink", p)
378 if p.To.Type != obj.TYPE_REG {
379 c.ctxt.Diag("do not know how to handle LEAQ-type insn to non-register in %v with -dynlink", p)
381 p.From.Type = obj.TYPE_MEM
382 p.From.Name = obj.NAME_GOTREF
383 if p.From.Offset != 0 {
384 q := obj.Appendp(p, c.newprog)
386 q.From.Type = obj.TYPE_CONST
387 q.From.Offset = p.From.Offset
392 if p.GetFrom3() != nil && p.GetFrom3().Name == obj.NAME_EXTERN {
393 c.ctxt.Diag("don't know how to handle %v with -dynlink", p)
396 // MOVx sym, Ry becomes MOVD sym@GOT, REGTMP; MOVx (REGTMP), Ry
397 // MOVx Ry, sym becomes MOVD sym@GOT, REGTMP; MOVD Ry, (REGTMP)
398 // An addition may be inserted between the two MOVs if there is an offset.
399 if p.From.Name == obj.NAME_EXTERN && !p.From.Sym.Local() {
400 if p.To.Name == obj.NAME_EXTERN && !p.To.Sym.Local() {
401 c.ctxt.Diag("cannot handle NAME_EXTERN on both sides in %v with -dynlink", p)
404 } else if p.To.Name == obj.NAME_EXTERN && !p.To.Sym.Local() {
409 if p.As == obj.ATEXT || p.As == obj.AFUNCDATA || p.As == obj.ACALL || p.As == obj.ARET || p.As == obj.AJMP {
412 if source.Sym.Type == objabi.STLSBSS {
415 if source.Type != obj.TYPE_MEM {
416 c.ctxt.Diag("don't know how to handle %v with -dynlink", p)
418 p1 := obj.Appendp(p, c.newprog)
419 p2 := obj.Appendp(p1, c.newprog)
421 p1.From.Type = obj.TYPE_MEM
422 p1.From.Sym = source.Sym
423 p1.From.Name = obj.NAME_GOTREF
424 p1.To.Type = obj.TYPE_REG
430 if p.From.Name == obj.NAME_EXTERN {
432 p2.From.Name = obj.NAME_NONE
434 } else if p.To.Name == obj.NAME_EXTERN {
436 p2.To.Name = obj.NAME_NONE
444 func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
445 if cursym.Func().Text == nil || cursym.Func().Text.Link == nil {
449 c := ctxt7{ctxt: ctxt, newprog: newprog, cursym: cursym}
451 p := c.cursym.Func().Text
452 textstksiz := p.To.Offset
453 if textstksiz == -8 {
454 // Historical way to mark NOFRAME.
455 p.From.Sym.Set(obj.AttrNoFrame, true)
459 c.ctxt.Diag("negative frame size %d - did you mean NOFRAME?", textstksiz)
461 if p.From.Sym.NoFrame() {
463 c.ctxt.Diag("NOFRAME functions must have a frame size of 0, not %d", textstksiz)
467 c.cursym.Func().Args = p.To.Val.(int32)
468 c.cursym.Func().Locals = int32(textstksiz)
471 * find leaf subroutines
473 for p := c.cursym.Func().Text; p != nil; p = p.Link {
481 c.cursym.Func().Text.Mark &^= LEAF
488 for p := c.cursym.Func().Text; p != nil; p = p.Link {
492 c.cursym.Func().Text = p
493 c.autosize = int32(textstksiz)
495 if p.Mark&LEAF != 0 && c.autosize == 0 {
496 // A leaf function with no locals has no frame.
497 p.From.Sym.Set(obj.AttrNoFrame, true)
500 if !p.From.Sym.NoFrame() {
501 // If there is a stack frame at all, it includes
502 // space to save the LR.
507 extrasize := int32(0)
508 if c.autosize%16 == 8 {
509 // Allocate extra 8 bytes on the frame top to save FP
511 } else if c.autosize&(16-1) == 0 {
512 // Allocate extra 16 bytes to save FP for the old frame whose size is 8 mod 16
515 c.ctxt.Diag("%v: unaligned frame size %d - must be 16 aligned", p, c.autosize-8)
517 c.autosize += extrasize
518 c.cursym.Func().Locals += extrasize
520 // low 32 bits for autosize
521 // high 32 bits for extrasize
522 p.To.Offset = int64(c.autosize) | int64(extrasize)<<32
528 if c.autosize == 0 && c.cursym.Func().Text.Mark&LEAF == 0 {
529 if c.ctxt.Debugvlog {
530 c.ctxt.Logf("save suppressed in: %s\n", c.cursym.Func().Text.From.Sym.Name)
532 c.cursym.Func().Text.Mark |= LEAF
535 if cursym.Func().Text.Mark&LEAF != 0 {
536 cursym.Set(obj.AttrLeaf, true)
537 if p.From.Sym.NoFrame() {
542 if !p.From.Sym.NoSplit() {
543 p = c.stacksplit(p, c.autosize) // emit split check
546 var prologueEnd *obj.Prog
548 aoffset := c.autosize
553 // Frame is non-empty. Make sure to save link register, even if
554 // it is a leaf function, so that traceback works.
556 if c.autosize > aoffset {
557 // Frame size is too large for a MOVD.W instruction.
558 // Store link register before decrementing SP, so if a signal comes
559 // during the execution of the function prologue, the traceback
560 // code will not see a half-updated stack frame.
561 // This sequence is not async preemptible, as if we open a frame
562 // at the current SP, it will clobber the saved LR.
563 q = c.ctxt.StartUnsafePoint(q, c.newprog)
565 q = obj.Appendp(q, c.newprog)
568 q.From.Type = obj.TYPE_CONST
569 q.From.Offset = int64(c.autosize)
571 q.To.Type = obj.TYPE_REG
576 q = obj.Appendp(q, c.newprog)
579 q.From.Type = obj.TYPE_REG
581 q.To.Type = obj.TYPE_MEM
584 q1 = obj.Appendp(q, c.newprog)
587 q1.From.Type = obj.TYPE_REG
589 q1.To.Type = obj.TYPE_REG
591 q1.Spadj = c.autosize
593 if objabi.GOOS == "ios" {
594 // iOS does not support SA_ONSTACK. We will run the signal handler
595 // on the G stack. If we write below SP, it may be clobbered by
596 // the signal handler. So we save LR after decrementing SP.
597 q1 = obj.Appendp(q1, c.newprog)
600 q1.From.Type = obj.TYPE_REG
601 q1.From.Reg = REGLINK
602 q1.To.Type = obj.TYPE_MEM
606 q1 = c.ctxt.EndUnsafePoint(q1, c.newprog, -1)
608 // small frame, update SP and save LR in a single MOVD.W instruction
609 q1 = obj.Appendp(q, c.newprog)
612 q1.From.Type = obj.TYPE_REG
613 q1.From.Reg = REGLINK
614 q1.To.Type = obj.TYPE_MEM
616 q1.To.Offset = int64(-aoffset)
623 prologueEnd.Pos = prologueEnd.Pos.WithXlogue(src.PosPrologueEnd)
625 if objabi.Framepointer_enabled {
626 q1 = obj.Appendp(q1, c.newprog)
629 q1.From.Type = obj.TYPE_REG
631 q1.To.Type = obj.TYPE_MEM
635 q1 = obj.Appendp(q1, c.newprog)
638 q1.From.Type = obj.TYPE_CONST
641 q1.To.Type = obj.TYPE_REG
645 if c.cursym.Func().Text.From.Sym.Wrapper() {
646 // if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
648 // MOV g_panic(g), R1
652 // ... function body ...
654 // MOV panic_argp(R1), R2
655 // ADD $(autosize+8), RSP, R3
659 // MOVD R4, panic_argp(R1)
662 // The NOP is needed to give the jumps somewhere to land.
663 // It is a liblink NOP, not an ARM64 NOP: it encodes to 0 instruction bytes.
666 // MOV g_panic(g), R1
667 q = obj.Appendp(q, c.newprog)
669 q.From.Type = obj.TYPE_MEM
671 q.From.Offset = 4 * int64(c.ctxt.Arch.PtrSize) // G.panic
672 q.To.Type = obj.TYPE_REG
675 // CBNZ R1, checkargp
676 cbnz := obj.Appendp(q, c.newprog)
678 cbnz.From.Type = obj.TYPE_REG
679 cbnz.From.Reg = REG_R1
680 cbnz.To.Type = obj.TYPE_BRANCH
682 // Empty branch target at the top of the function body
683 end := obj.Appendp(cbnz, c.newprog)
686 // find the end of the function
688 for last = end; last.Link != nil; last = last.Link {
691 // MOV panic_argp(R1), R2
692 mov := obj.Appendp(last, c.newprog)
694 mov.From.Type = obj.TYPE_MEM
695 mov.From.Reg = REG_R1
696 mov.From.Offset = 0 // Panic.argp
697 mov.To.Type = obj.TYPE_REG
700 // CBNZ branches to the MOV above
701 cbnz.To.SetTarget(mov)
703 // ADD $(autosize+8), SP, R3
704 q = obj.Appendp(mov, c.newprog)
706 q.From.Type = obj.TYPE_CONST
707 q.From.Offset = int64(c.autosize) + 8
709 q.To.Type = obj.TYPE_REG
713 q = obj.Appendp(q, c.newprog)
715 q.From.Type = obj.TYPE_REG
720 q = obj.Appendp(q, c.newprog)
722 q.To.Type = obj.TYPE_BRANCH
726 q = obj.Appendp(q, c.newprog)
728 q.From.Type = obj.TYPE_CONST
731 q.To.Type = obj.TYPE_REG
734 // MOV R4, panic_argp(R1)
735 q = obj.Appendp(q, c.newprog)
737 q.From.Type = obj.TYPE_REG
739 q.To.Type = obj.TYPE_MEM
741 q.To.Offset = 0 // Panic.argp
744 q = obj.Appendp(q, c.newprog)
746 q.To.Type = obj.TYPE_BRANCH
752 if p.From.Type == obj.TYPE_CONST {
753 c.ctxt.Diag("using BECOME (%v) is not supported!", p)
759 if c.cursym.Func().Text.Mark&LEAF != 0 {
762 p.From.Type = obj.TYPE_CONST
763 p.From.Offset = int64(c.autosize)
764 p.To.Type = obj.TYPE_REG
766 p.Spadj = -c.autosize
768 if objabi.Framepointer_enabled {
769 p = obj.Appendp(p, c.newprog)
771 p.From.Type = obj.TYPE_CONST
774 p.To.Type = obj.TYPE_REG
779 /* want write-back pre-indexed SP+autosize -> SP, loading REGLINK*/
781 if objabi.Framepointer_enabled {
783 p.From.Type = obj.TYPE_MEM
786 p.To.Type = obj.TYPE_REG
788 p = obj.Appendp(p, c.newprog)
791 aoffset := c.autosize
795 p.From.Type = obj.TYPE_MEM
797 p.From.Offset = int64(aoffset)
799 p.To.Type = obj.TYPE_REG
804 p.From.Type = obj.TYPE_MEM
807 p.To.Type = obj.TYPE_REG
812 q.From.Type = obj.TYPE_CONST
813 q.From.Offset = int64(aoffset)
814 q.To.Type = obj.TYPE_REG
817 q.Spadj = int32(-q.From.Offset)
824 if p.As != obj.ARET {
832 if retjmp != nil { // retjmp
834 p.To.Type = obj.TYPE_BRANCH
836 p.Spadj = +c.autosize
841 p.To.Type = obj.TYPE_MEM
844 p.Spadj = +c.autosize
847 if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.From.Type == obj.TYPE_CONST {
849 p.Spadj = int32(-p.From.Offset)
851 p.Spadj = int32(+p.From.Offset)
855 case obj.AGETCALLERPC:
859 p.From.Type = obj.TYPE_REG
864 p.From.Type = obj.TYPE_MEM
869 if objabi.Framepointer_enabled {
871 // STP (FP, R27), -24(SP)
878 // copy DUFFCOPY from q1 to q4
879 q4 := obj.Appendp(p, c.newprog)
881 q4.As = obj.ADUFFCOPY
885 q1.From.Type = obj.TYPE_BRANCH
886 q1.To.Type = obj.TYPE_REG
889 q2 := obj.Appendp(q1, c.newprog)
892 q2.From.Type = obj.TYPE_REGREG
894 q2.From.Offset = int64(REG_R27)
895 q2.To.Type = obj.TYPE_MEM
899 // maintaine FP for DUFFCOPY
900 q3 := obj.Appendp(q2, c.newprog)
903 q3.From.Type = obj.TYPE_CONST
906 q3.To.Type = obj.TYPE_REG
909 q5 := obj.Appendp(q4, c.newprog)
912 q5.From.Type = obj.TYPE_CONST
915 q5.To.Type = obj.TYPE_REG
917 q1.From.SetTarget(q5)
922 if objabi.Framepointer_enabled {
924 // STP (FP, R27), -24(SP)
931 // copy DUFFZERO from q1 to q4
932 q4 := obj.Appendp(p, c.newprog)
934 q4.As = obj.ADUFFZERO
938 q1.From.Type = obj.TYPE_BRANCH
939 q1.To.Type = obj.TYPE_REG
942 q2 := obj.Appendp(q1, c.newprog)
945 q2.From.Type = obj.TYPE_REGREG
947 q2.From.Offset = int64(REG_R27)
948 q2.To.Type = obj.TYPE_MEM
952 // maintaine FP for DUFFZERO
953 q3 := obj.Appendp(q2, c.newprog)
956 q3.From.Type = obj.TYPE_CONST
959 q3.To.Type = obj.TYPE_REG
962 q5 := obj.Appendp(q4, c.newprog)
965 q5.From.Type = obj.TYPE_CONST
968 q5.To.Type = obj.TYPE_REG
970 q1.From.SetTarget(q5)
975 if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.Spadj == 0 {
977 if f.FuncFlag&objabi.FuncFlag_SPWRITE == 0 {
978 c.cursym.Func().FuncFlag |= objabi.FuncFlag_SPWRITE
979 if ctxt.Debugvlog || !ctxt.IsAsm {
980 ctxt.Logf("auto-SPWRITE: %s %v\n", c.cursym.Name, p)
982 ctxt.Diag("invalid auto-SPWRITE in non-assembly")
984 log.Fatalf("bad SPWRITE")
992 func nocache(p *obj.Prog) {
998 var unaryDst = map[obj.As]bool{
1006 var Linkarm64 = obj.LinkArch{
1007 Arch: sys.ArchARM64,
1009 Preprocess: preprocess,
1013 DWARFRegisters: ARM64DWARFRegisters,