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_mcnt.ppc: compiler internal wrapper for Call Count Profiling (PPC). */
15
16	.file	"ind_mcnt.ppc"
17#include "ppc_regs.ppc"
18
19#if defined(EMBEDDED) || defined(__VXWORKS) || defined(CHORUS) || defined (__OSE)
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_mcount
32__ghs_mcount:
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_lwz	r3, SF+4(sp)	; get our argument
43	se_mflr	r4		; get our caller's address
44	se_stw	r4, SF+4(sp)	; save it in normal spot
45#if defined(TRANSFER_VECTOR)
46	e_bl	%tv(__ghs_indmcount)
47#else
48	e_bl	__ghs_indmcount
49#endif
501:
51	se_lwz	r3, SF+4(sp)	; get back our caller's address
52	se_mtlr	r3		; be ready to return to it
53	se_lwz	r3, 8(sp)	; restore all arg regs
54	se_lwz	r4, 12(sp)
55	se_lwz	r5, 16(sp)
56	se_lwz	r6, 20(sp)
57	se_lwz	r7, 24(sp)
58	e_lwz	r8, 28(sp)
59	e_lwz	r9, 32(sp)
60	e_lwz	r10, 36(sp)
61	se_lwz	sp, 0(sp)	; restore stack
62	se_blr			; and return
63#else /* __vle */
64	.text
65
66 ; Assembly-language interface to __mcount_ghs.
67 ; Call with 4(sp) holding the address of a count variable, which we will
68 ; pass on.  We also need to pass address of our caller, and
69 ; address of address of our caller's caller.
70 ; We must not harm any argument registers.
71#if defined(__PPC64_ABI__) && !defined(__PPC64_NO_FUNC_DESC)
72	.section ".opd", "aw"
73	.align 3
74	.global __ghs_mcount
75__ghs_mcount:
76	.quad	.__ghs_mcount, .TOC.@tocbase, 0
77	.size 	__ghs_mcount, 24
78
79	.text
80	.globl  .__ghs_mcount
81.__ghs_mcount:
82#else
83	.globl	__ghs_mcount
84__ghs_mcount:
85#endif
86
87#ifdef __PPC64_ABI__
88SF=112;	stack frame size
89	stdu	sp, -SF(sp)	; make a stack frame
90	std	r3, 48(sp)	; save all arg regs
91	std	r4, 56(sp)
92	std	r5, 64(sp)
93	std	r6, 72(sp)
94	std	r7, 80(sp)
95	std	r8, 88(sp)
96	std	r9, 96(sp)
97	std	r10,104(sp)
98	ld	r3, SF+8(sp)	; get our argument
99	mflr	r4		; get our caller's address
100	std	r4, SF+16(sp)	; save it in normal spot
101#if defined(TRANSFER_VECTOR)
102	bl	%tv(__ghs_indmcount)
103#else
104	bl	__ghs_indmcount
105#endif
106	ld	r3, SF+16(sp)	; get back our caller's address
107	mtlr	r3		; be ready to return to it
108	ld	r3, 48(sp)	; restore all arg regs
109	ld	r4, 56(sp)
110	ld	r5, 64(sp)
111	ld	r6, 72(sp)
112	ld	r7, 80(sp)
113	ld	r8, 88(sp)
114	ld	r9, 96(sp)
115	ld	r10,104(sp)
116        ld      sp, 0(sp)       ; restore stack
117        blr                     ; and return
118#elif __PPC64__
119SF=80	; stack frame size
120	stdu	sp, -SF(sp)	; make a stack frame
121	std	r3, 16(sp)	; save all arg regs
122	std	r4, 24(sp)
123	std	r5, 32(sp)
124	std	r6, 40(sp)
125	std	r7, 48(sp)
126	std	r8, 56(sp)
127	std	r9, 64(sp)
128	std	r10, 72(sp)
129	ld	r3, SF+8(sp)	; get our argument
130	mflr	r4		; get our caller's address
131	std	r4, SF+8(sp)	; save it in normal spot
132#if defined(TRANSFER_VECTOR)
133	bl	%tv(__ghs_indmcount)
134#else
135	bl	__ghs_indmcount
136#endif
1371:
138	ld	r3, SF+8(sp)	; get back our caller's address
139	mtlr	r3		; be ready to return to it
140	ld	r3, 16(sp)	; restore all arg regs
141	ld	r4, 24(sp)
142	ld	r5, 32(sp)
143	ld	r6, 40(sp)
144	ld	r7, 48(sp)
145	ld	r8, 56(sp)
146	ld	r9, 64(sp)
147	ld	r10, 72(sp)
148	ld	sp, 0(sp)	; restore stack
149	blr			; and return
150#else
151SF=40	; stack frame size
152	stwu	sp, -SF(sp)	; make a stack frame
153	stw	r3, 8(sp)	; save all arg regs
154	stw	r4, 12(sp)
155	stw	r5, 16(sp)
156	stw	r6, 20(sp)
157	stw	r7, 24(sp)
158	stw	r8, 28(sp)
159	stw	r9, 32(sp)
160	stw	r10, 36(sp)
161	lwz	r3, SF+4(sp)	; get our argument
162	mflr	r4		; get our caller's address
163	stw	r4, SF+4(sp)	; save it in normal spot
164#if defined(TRANSFER_VECTOR)
165	bl	%tv(__ghs_indmcount)
166#else
167	bl	__ghs_indmcount
168#endif
1691:
170	lwz	r3, SF+4(sp)	; get back our caller's address
171	mtlr	r3		; be ready to return to it
172	lwz	r3, 8(sp)	; restore all arg regs
173	lwz	r4, 12(sp)
174	lwz	r5, 16(sp)
175	lwz	r6, 20(sp)
176	lwz	r7, 24(sp)
177	lwz	r8, 28(sp)
178	lwz	r9, 32(sp)
179	lwz	r10, 36(sp)
180	lwz	sp, 0(sp)	; restore stack
181	blr			; and return
182#endif /* __PPC64__ */
183#endif /* __vle */
184
185#ifdef __ELF
186	.fsize	40
187	.scall	__ghs_indmcount
188#if defined(__PPC64_ABI__) && !defined(__PPC64_NO_FUNC_DESC)
189	.type .__ghs_mcount,@function
190	.size .__ghs_mcount,$-.__ghs_mcount
191#else
192	.type __ghs_mcount,@function
193	.size __ghs_mcount,$-__ghs_mcount
194#endif
195#endif /* __ELF */
196
197#endif /* EMBEDDED */
198