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)
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
644 if c.cursym.Func().Text.From.Sym.Wrapper() {
645 // if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
647 // MOV g_panic(g), R1
651 // ... function body ...
653 // MOV panic_argp(R1), R2
654 // ADD $(autosize+8), RSP, R3
658 // MOVD R4, panic_argp(R1)
661 // The NOP is needed to give the jumps somewhere to land.
662 // It is a liblink NOP, not an ARM64 NOP: it encodes to 0 instruction bytes.
665 // MOV g_panic(g), R1
666 q = obj.Appendp(q, c.newprog)
668 q.From.Type = obj.TYPE_MEM
670 q.From.Offset = 4 * int64(c.ctxt.Arch.PtrSize) // G.panic
671 q.To.Type = obj.TYPE_REG
674 // CBNZ R1, checkargp
675 cbnz := obj.Appendp(q, c.newprog)
677 cbnz.From.Type = obj.TYPE_REG
678 cbnz.From.Reg = REG_R1
679 cbnz.To.Type = obj.TYPE_BRANCH
681 // Empty branch target at the top of the function body
682 end := obj.Appendp(cbnz, c.newprog)
685 // find the end of the function
687 for last = end; last.Link != nil; last = last.Link {
690 // MOV panic_argp(R1), R2
691 mov := obj.Appendp(last, c.newprog)
693 mov.From.Type = obj.TYPE_MEM
694 mov.From.Reg = REG_R1
695 mov.From.Offset = 0 // Panic.argp
696 mov.To.Type = obj.TYPE_REG
699 // CBNZ branches to the MOV above
700 cbnz.To.SetTarget(mov)
702 // ADD $(autosize+8), SP, R3
703 q = obj.Appendp(mov, c.newprog)
705 q.From.Type = obj.TYPE_CONST
706 q.From.Offset = int64(c.autosize) + 8
708 q.To.Type = obj.TYPE_REG
712 q = obj.Appendp(q, c.newprog)
714 q.From.Type = obj.TYPE_REG
719 q = obj.Appendp(q, c.newprog)
721 q.To.Type = obj.TYPE_BRANCH
725 q = obj.Appendp(q, c.newprog)
727 q.From.Type = obj.TYPE_CONST
730 q.To.Type = obj.TYPE_REG
733 // MOV R4, panic_argp(R1)
734 q = obj.Appendp(q, c.newprog)
736 q.From.Type = obj.TYPE_REG
738 q.To.Type = obj.TYPE_MEM
740 q.To.Offset = 0 // Panic.argp
743 q = obj.Appendp(q, c.newprog)
745 q.To.Type = obj.TYPE_BRANCH
751 if p.From.Type == obj.TYPE_CONST {
752 c.ctxt.Diag("using BECOME (%v) is not supported!", p)
758 if c.cursym.Func().Text.Mark&LEAF != 0 {
761 p.From.Type = obj.TYPE_CONST
762 p.From.Offset = int64(c.autosize)
763 p.To.Type = obj.TYPE_REG
765 p.Spadj = -c.autosize
768 p = obj.Appendp(p, c.newprog)
770 p.From.Type = obj.TYPE_CONST
773 p.To.Type = obj.TYPE_REG
777 /* want write-back pre-indexed SP+autosize -> SP, loading REGLINK*/
781 p.From.Type = obj.TYPE_MEM
784 p.To.Type = obj.TYPE_REG
786 p = obj.Appendp(p, c.newprog)
788 aoffset := c.autosize
792 p.From.Type = obj.TYPE_MEM
794 p.From.Offset = int64(aoffset)
796 p.To.Type = obj.TYPE_REG
801 p.From.Type = obj.TYPE_MEM
804 p.To.Type = obj.TYPE_REG
809 q.From.Type = obj.TYPE_CONST
810 q.From.Offset = int64(aoffset)
811 q.To.Type = obj.TYPE_REG
814 q.Spadj = int32(-q.From.Offset)
821 // If enabled, this code emits 'MOV PC, R27' before every 'MOV LR, PC',
822 // so that if you are debugging a low-level crash where PC and LR are zero,
823 // you can look at R27 to see what jumped to the zero.
824 // This is useful when bringing up Go on a new system.
825 // (There is similar code in ../ppc64/obj9.go:/if.false.)
826 const debugRETZERO = false
828 if p.As != obj.ARET {
836 p.From.Type = obj.TYPE_BRANCH
838 p.To.Type = obj.TYPE_REG
843 if p.As != obj.ARET {
851 if retjmp != nil { // retjmp
853 p.To.Type = obj.TYPE_BRANCH
855 p.Spadj = +c.autosize
860 p.To.Type = obj.TYPE_MEM
863 p.Spadj = +c.autosize
866 if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.From.Type == obj.TYPE_CONST {
868 p.Spadj = int32(-p.From.Offset)
870 p.Spadj = int32(+p.From.Offset)
874 case obj.AGETCALLERPC:
878 p.From.Type = obj.TYPE_REG
883 p.From.Type = obj.TYPE_MEM
889 // STP (FP, R27), -24(SP)
896 // copy DUFFCOPY from q1 to q4
897 q4 := obj.Appendp(p, c.newprog)
899 q4.As = obj.ADUFFCOPY
903 q1.From.Type = obj.TYPE_BRANCH
904 q1.To.Type = obj.TYPE_REG
907 q2 := obj.Appendp(q1, c.newprog)
910 q2.From.Type = obj.TYPE_REGREG
912 q2.From.Offset = int64(REG_R27)
913 q2.To.Type = obj.TYPE_MEM
917 // maintain FP for DUFFCOPY
918 q3 := obj.Appendp(q2, c.newprog)
921 q3.From.Type = obj.TYPE_CONST
924 q3.To.Type = obj.TYPE_REG
927 q5 := obj.Appendp(q4, c.newprog)
930 q5.From.Type = obj.TYPE_CONST
933 q5.To.Type = obj.TYPE_REG
935 q1.From.SetTarget(q5)
940 // STP (FP, R27), -24(SP)
947 // copy DUFFZERO from q1 to q4
948 q4 := obj.Appendp(p, c.newprog)
950 q4.As = obj.ADUFFZERO
954 q1.From.Type = obj.TYPE_BRANCH
955 q1.To.Type = obj.TYPE_REG
958 q2 := obj.Appendp(q1, c.newprog)
961 q2.From.Type = obj.TYPE_REGREG
963 q2.From.Offset = int64(REG_R27)
964 q2.To.Type = obj.TYPE_MEM
968 // maintain FP for DUFFZERO
969 q3 := obj.Appendp(q2, c.newprog)
972 q3.From.Type = obj.TYPE_CONST
975 q3.To.Type = obj.TYPE_REG
978 q5 := obj.Appendp(q4, c.newprog)
981 q5.From.Type = obj.TYPE_CONST
984 q5.To.Type = obj.TYPE_REG
986 q1.From.SetTarget(q5)
990 if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.Spadj == 0 {
992 if f.FuncFlag&objabi.FuncFlag_SPWRITE == 0 {
993 c.cursym.Func().FuncFlag |= objabi.FuncFlag_SPWRITE
994 if ctxt.Debugvlog || !ctxt.IsAsm {
995 ctxt.Logf("auto-SPWRITE: %s %v\n", c.cursym.Name, p)
997 ctxt.Diag("invalid auto-SPWRITE in non-assembly")
999 log.Fatalf("bad SPWRITE")
1007 func nocache(p *obj.Prog) {
1013 var unaryDst = map[obj.As]bool{
1021 var Linkarm64 = obj.LinkArch{
1022 Arch: sys.ArchARM64,
1024 Preprocess: preprocess,
1028 DWARFRegisters: ARM64DWARFRegisters,