1/*
2*
3*                Language Independent Library
4*
5*        Copyright 1983-2000 Green Hills Software,Inc.
6*
7*  This program is the property of Green Hills Software, Inc,
8*  its contents are proprietary information and no part of it
9*  is to be disclosed to anyone except employees of Green Hills
10*  Software, Inc., or as agreed in writing signed by the President
11*  of Green Hills Software, Inc.
12*
13*/
14/* ind_gcnt.ppc: compiler internal wrapper for Graph Profiling (PPC family). */
15
16	.file	"ind_mcnt.ppc"
17#include "ppc_regs.ppc"
18
19#if defined(EMBEDDED) || defined(__VXWORKS) || defined(CHORUS)
20
21#ifdef __vle
22	.section ".vletext", "vax"
23	.vle
24
25 ; Assembly-language interface to __mcount_ghs.
26 ; Call with 4(sp) holding the address of a count variable, which we will
27 ; pass on.  We also need to pass address of our caller, and
28 ; address of address of our caller's caller.
29 ; We must not harm any argument registers.
30SF=40	; stack frame size
31	.globl	__ghs_gcount
32__ghs_gcount:
33	e_stwu	sp, -SF(sp)	; make a stack frame
34	se_stw	r3, 8(sp)	; save all arg regs
35	se_stw	r4, 12(sp)
36	se_stw	r5, 16(sp)
37	se_stw	r6, 20(sp)
38	se_stw	r7, 24(sp)
39	e_stw	r8, 28(sp)
40	e_stw	r9, 32(sp)
41	e_stw	r10, 36(sp)
42	se_mflr	r3		; get our caller's address
43	se_stw	r3, SF+4(sp)	; save it in normal spot
44	se_lwz	r4, 0(sp)	; get caller's sp
45	se_lwz	r4, 0(r4)	; get caller's caller's sp
46	se_addi	r4, 4		; get address of caller's caller
47#if defined(TRANSFER_VECTOR)
48	e_bl	%tv(__ghs_indgcount)
49#else
50	e_bl	__ghs_indgcount
51#endif
52	se_lwz	r3, SF+4(sp)	; get back our caller's address
53	se_mtlr	r3		; be ready to return to it
54	se_lwz	r3, 8(sp)	; restore all arg regs
55	se_lwz	r4, 12(sp)
56	se_lwz	r5, 16(sp)
57	se_lwz	r6, 20(sp)
58	se_lwz	r7, 24(sp)
59	e_lwz	r8, 28(sp)
60	e_lwz	r9, 32(sp)
61	e_lwz	r10, 36(sp)
62	se_lwz	sp, 0(sp)	; restore stack
63	se_blr			; and return
64#else /* __vle */
65	.text
66
67 ; Assembly-language interface to __mcount_ghs.
68 ; Call with 4(sp) holding the address of a count variable, which we will
69 ; pass on.  We also need to pass address of our caller, and
70 ; address of address of our caller's caller.
71 ; We must not harm any argument registers.
72
73#if defined(__PPC64_ABI__) && !defined(__PPC64_NO_FUNC_DESC)
74	.section ".opd", "aw"
75	.align 3
76	.global __ghs_gcount
77__ghs_gcount:
78	.quad	.__ghs_gcount, .TOC.@tocbase, 0
79	.size 	__ghs_gcount, 24
80
81	.text
82	.globl  .__ghs_gcount
83.__ghs_gcount:
84#else
85	.globl	__ghs_gcount
86__ghs_gcount:
87#endif
88
89#ifdef __PPC64_ABI__
90SF=112	; stack frame size
91	stdu	sp, -SF(sp)	; make a stack frame
92	std	r3, 48(sp)	; save all arg regs
93	std	r4, 56(sp)
94	std	r5, 64(sp)
95	std	r6, 72(sp)
96	std	r7, 80(sp)
97	std	r8, 88(sp)
98	std	r9, 96(sp)
99	std	r10,104(sp)
100	mflr	r3		; get our caller's address
101	std	r3, SF+16(sp)	; save it in normal spot
102	ld	r4, 0(sp)	; get caller's sp
103	ld	r4, 0(r4)	; get caller's caller's sp
104	addi	r4, r4, 16	; get address of caller's caller
105#if defined(TRANSFER_VECTOR)
106	bl	%tv(__ghs_indgcount)
107#else
108	bl	__ghs_indgcount
109#endif
110        ld      r3, SF+16(sp)    ; get back our caller's address
111        mtlr    r3              ; be ready to return to it
112        ld      r3, 48(sp)      ; restore all arg regs
113        ld      r4, 56(sp)
114        ld      r5, 64(sp)
115        ld      r6, 72(sp)
116        ld      r7, 80(sp)
117        ld      r8, 88(sp)
118        ld      r9, 96(sp)
119        ld      r10, 104(sp)
120        ld      sp, 0(sp)       ; restore stack
121        blr                     ; and return
122#elif __PPC64__
123SF=80	; stack frame size
124	stdu	sp, -SF(sp)	; make a stack frame
125	std	r3, 16(sp)	; save all arg regs
126	std	r4, 24(sp)
127	std	r5, 32(sp)
128	std	r6, 40(sp)
129	std	r7, 48(sp)
130	std	r8, 56(sp)
131	std	r9, 64(sp)
132	std	r10, 72(sp)
133	mflr	r3		; get our caller's address
134	std	r3, SF+8(sp)	; save it in normal spot
135	ld	r4, 0(sp)	; get caller's sp
136	ld	r4, 0(r4)	; get caller's caller's sp
137	addi	r4, r4, 8	; get address of caller's caller
138#if defined(TRANSFER_VECTOR)
139	bl	%tv(__ghs_indgcount)
140#else
141	bl	__ghs_indgcount
142#endif
143	ld	r3, SF+8(sp)	; get back our caller's address
144	mtlr	r3		; be ready to return to it
145	ld	r3, 16(sp)	; restore all arg regs
146	ld	r4, 24(sp)
147	ld	r5, 32(sp)
148	ld	r6, 40(sp)
149	ld	r7, 48(sp)
150	ld	r8, 56(sp)
151	ld	r9, 64(sp)
152	ld	r10, 72(sp)
153	ld	sp, 0(sp)	; restore stack
154	blr			; and return
155#else
156SF=40	; stack frame size
157	stwu	sp, -SF(sp)	; make a stack frame
158	stw	r3, 8(sp)	; save all arg regs
159	stw	r4, 12(sp)
160	stw	r5, 16(sp)
161	stw	r6, 20(sp)
162	stw	r7, 24(sp)
163	stw	r8, 28(sp)
164	stw	r9, 32(sp)
165	stw	r10, 36(sp)
166	mflr	r3		; get our caller's address
167	stw	r3, SF+4(sp)	; save it in normal spot
168	lwz	r4, 0(sp)	; get caller's sp
169	lwz	r4, 0(r4)	; get caller's caller's sp
170	addi	r4, r4, 4	; get address of caller's caller
171#if defined(TRANSFER_VECTOR)
172	bl	%tv(__ghs_indgcount)
173#else
174	bl	__ghs_indgcount
175#endif
176	lwz	r3, SF+4(sp)	; get back our caller's address
177	mtlr	r3		; be ready to return to it
178	lwz	r3, 8(sp)	; restore all arg regs
179	lwz	r4, 12(sp)
180	lwz	r5, 16(sp)
181	lwz	r6, 20(sp)
182	lwz	r7, 24(sp)
183	lwz	r8, 28(sp)
184	lwz	r9, 32(sp)
185	lwz	r10, 36(sp)
186	lwz	sp, 0(sp)	; restore stack
187	blr			; and return
188
189#endif /* __PPC64__ */
190#endif /* __vle */
191
192#ifdef __ELF
193	.fsize	40
194	.scall	__ghs_indgcount
195#if defined(__PPC64_ABI__) && !defined(__PPC64_NO_FUNC_DESC)
196	.type .__ghs_gcount,@function
197	.size .__ghs_gcount,$-.__ghs_gcount
198#else
199	.type __ghs_gcount,@function
200	.size __ghs_gcount,$-__ghs_gcount
201#endif
202#endif /* __ELF */
203
204#endif /* EMBEDDED */
205