github.com/aloncn/graphics-go@v0.0.1/src/runtime/cgo/gcc_ppc64x.S (about) 1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build ppc64 ppc64le 6 7 /* 8 * Apple still insists on underscore prefixes for C function names. 9 */ 10 #if defined(__APPLE__) 11 #define EXT(s) _##s 12 #else 13 #define EXT(s) s 14 #endif 15 16 /* 17 * void crosscall_ppc64(void (*fn)(void), void *g) 18 * 19 * Calling into the gc tool chain, where all registers are caller save. 20 * Called from standard ppc64 C ABI, where r2, r14-r31, f14-f31 are 21 * callee-save, so they must be saved explicitly. 22 */ 23 .globl EXT(crosscall_ppc64) 24 EXT(crosscall_ppc64): 25 // Start with standard C stack frame layout and linkage 26 mflr %r0 27 std %r0, 16(%r1) // Save LR in caller's frame 28 std %r2, 24(%r1) // Save TOC in caller's frame 29 bl saveregs 30 stdu %r1, -296(%r1) 31 32 // Set up Go ABI constant registers 33 bl _cgo_reginit 34 nop 35 36 // Restore g pointer (r30 in Go ABI, which may have been clobbered by C) 37 mr %r30, %r4 38 39 // Call fn 40 mr %r12, %r3 41 mtctr %r3 42 bctrl 43 44 addi %r1, %r1, 296 45 bl restoreregs 46 ld %r2, 24(%r1) 47 ld %r0, 16(%r1) 48 mtlr %r0 49 blr 50 51 saveregs: 52 // Save callee-save registers 53 // O=-288; for R in %r{14..31}; do echo "\tstd\t$R, $O(%r1)"; ((O+=8)); done; for F in f{14..31}; do echo "\tstfd\t$F, $O(%r1)"; ((O+=8)); done 54 std %r14, -288(%r1) 55 std %r15, -280(%r1) 56 std %r16, -272(%r1) 57 std %r17, -264(%r1) 58 std %r18, -256(%r1) 59 std %r19, -248(%r1) 60 std %r20, -240(%r1) 61 std %r21, -232(%r1) 62 std %r22, -224(%r1) 63 std %r23, -216(%r1) 64 std %r24, -208(%r1) 65 std %r25, -200(%r1) 66 std %r26, -192(%r1) 67 std %r27, -184(%r1) 68 std %r28, -176(%r1) 69 std %r29, -168(%r1) 70 std %r30, -160(%r1) 71 std %r31, -152(%r1) 72 stfd %f14, -144(%r1) 73 stfd %f15, -136(%r1) 74 stfd %f16, -128(%r1) 75 stfd %f17, -120(%r1) 76 stfd %f18, -112(%r1) 77 stfd %f19, -104(%r1) 78 stfd %f20, -96(%r1) 79 stfd %f21, -88(%r1) 80 stfd %f22, -80(%r1) 81 stfd %f23, -72(%r1) 82 stfd %f24, -64(%r1) 83 stfd %f25, -56(%r1) 84 stfd %f26, -48(%r1) 85 stfd %f27, -40(%r1) 86 stfd %f28, -32(%r1) 87 stfd %f29, -24(%r1) 88 stfd %f30, -16(%r1) 89 stfd %f31, -8(%r1) 90 91 blr 92 93 restoreregs: 94 // O=-288; for R in %r{14..31}; do echo "\tld\t$R, $O(%r1)"; ((O+=8)); done; for F in %f{14..31}; do echo "\tlfd\t$F, $O(%r1)"; ((O+=8)); done 95 ld %r14, -288(%r1) 96 ld %r15, -280(%r1) 97 ld %r16, -272(%r1) 98 ld %r17, -264(%r1) 99 ld %r18, -256(%r1) 100 ld %r19, -248(%r1) 101 ld %r20, -240(%r1) 102 ld %r21, -232(%r1) 103 ld %r22, -224(%r1) 104 ld %r23, -216(%r1) 105 ld %r24, -208(%r1) 106 ld %r25, -200(%r1) 107 ld %r26, -192(%r1) 108 ld %r27, -184(%r1) 109 ld %r28, -176(%r1) 110 ld %r29, -168(%r1) 111 ld %r30, -160(%r1) 112 ld %r31, -152(%r1) 113 lfd %f14, -144(%r1) 114 lfd %f15, -136(%r1) 115 lfd %f16, -128(%r1) 116 lfd %f17, -120(%r1) 117 lfd %f18, -112(%r1) 118 lfd %f19, -104(%r1) 119 lfd %f20, -96(%r1) 120 lfd %f21, -88(%r1) 121 lfd %f22, -80(%r1) 122 lfd %f23, -72(%r1) 123 lfd %f24, -64(%r1) 124 lfd %f25, -56(%r1) 125 lfd %f26, -48(%r1) 126 lfd %f27, -40(%r1) 127 lfd %f28, -32(%r1) 128 lfd %f29, -24(%r1) 129 lfd %f30, -16(%r1) 130 lfd %f31, -8(%r1) 131 132 blr 133 134 135 #ifdef __ELF__ 136 .section .note.GNU-stack,"",%progbits 137 #endif