]>
Commit | Line | Data |
---|---|---|
781b52c5 | 1 | /* Machine-specific calling sequence for `mcount' profiling function. MIPS |
7b44519f AO |
2 | Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003 |
3 | Free Software Foundation, Inc. | |
781b52c5 UD |
4 | This file is part of the GNU C Library. |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
3214b89b AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
781b52c5 UD |
10 | |
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
3214b89b | 14 | Lesser General Public License for more details. |
781b52c5 | 15 | |
3214b89b AJ |
16 | You should have received a copy of the GNU Lesser General Public |
17 | License along with the GNU C Library; if not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
19 | 02111-1307 USA. */ | |
781b52c5 | 20 | |
4bf39226 AJ |
21 | #define _MCOUNT_DECL(frompc,selfpc) \ |
22 | static void __attribute_used__ __mcount (u_long frompc, u_long selfpc) | |
781b52c5 | 23 | |
7b44519f | 24 | /* Call __mcount with the return PC for our caller, |
781b52c5 | 25 | and the return PC our caller will return to. */ |
7b44519f AO |
26 | |
27 | #if _MIPS_SIM == _MIPS_SIM_ABI32 | |
28 | ||
73a35fc4 | 29 | #ifdef __PIC__ |
7b44519f AO |
30 | # define CPLOAD ".cpload $25;" |
31 | # define CPRESTORE ".cprestore 44\n\t" | |
781b52c5 | 32 | #else |
7b44519f AO |
33 | # define CPLOAD |
34 | # define CPRESTORE | |
781b52c5 UD |
35 | #endif |
36 | ||
37 | #define MCOUNT asm(\ | |
c8523a3c AJ |
38 | ".globl _mcount;\n\t" \ |
39 | ".align 2;\n\t" \ | |
40 | ".type _mcount,@function;\n\t" \ | |
41 | ".ent _mcount\n\t" \ | |
42 | "_mcount:\n\t" \ | |
43 | ".frame $sp,44,$31\n\t" \ | |
44 | ".set noreorder;\n\t" \ | |
45 | ".set noat;\n\t" \ | |
781b52c5 | 46 | CPLOAD \ |
c8523a3c AJ |
47 | "subu $29,$29,48;\n\t" \ |
48 | CPRESTORE \ | |
49 | "sw $4,24($29);\n\t" \ | |
50 | "sw $5,28($29);\n\t" \ | |
51 | "sw $6,32($29);\n\t" \ | |
52 | "sw $7,36($29);\n\t" \ | |
53 | "sw $2,40($29);\n\t" \ | |
54 | "sw $1,16($29);\n\t" \ | |
55 | "sw $31,20($29);\n\t" \ | |
56 | "move $5,$31;\n\t" \ | |
57 | "move $4,$1;\n\t" \ | |
58 | "jal __mcount;\n\t" \ | |
59 | "nop;\n\t" \ | |
60 | "lw $4,24($29);\n\t" \ | |
61 | "lw $5,28($29);\n\t" \ | |
62 | "lw $6,32($29);\n\t" \ | |
63 | "lw $7,36($29);\n\t" \ | |
64 | "lw $2,40($29);\n\t" \ | |
65 | "lw $31,20($29);\n\t" \ | |
66 | "lw $1,16($29);\n\t" \ | |
67 | "addu $29,$29,56;\n\t" \ | |
68 | "j $31;\n\t" \ | |
69 | "move $31,$1;\n\t" \ | |
70 | ".set reorder;\n\t" \ | |
71 | ".set at\n\t" \ | |
72 | ".end _mcount"); | |
7b44519f AO |
73 | |
74 | #else | |
75 | ||
76 | #ifdef __PIC__ | |
77 | # define CPSETUP ".cpsetup $25, 88, _mcount;" | |
78 | # define CPRETURN ".cpreturn;" | |
79 | #else | |
80 | # define CPSETUP | |
81 | # define CPRETURN | |
82 | #endif | |
83 | ||
84 | #if defined _ABIN32 && _MIPS_SIM == _ABIN32 | |
85 | # define PTR_ADDU_STRING "add" /* no u */ | |
86 | # define PTR_SUBU_STRING "sub" /* no u */ | |
87 | #elif defined _ABI64 && _MIPS_SIM == _ABI64 | |
88 | # define PTR_ADDU_STRING "daddu" | |
89 | # define PTR_SUBU_STRING "dsubu" | |
90 | #else | |
91 | # error "Unknown ABI" | |
92 | #endif | |
93 | ||
94 | #define MCOUNT asm(\ | |
95 | ".globl _mcount;\n\t" \ | |
96 | ".align 3;\n\t" \ | |
97 | ".type _mcount,@function;\n\t" \ | |
98 | ".ent _mcount\n\t" \ | |
99 | "_mcount:\n\t" \ | |
100 | ".frame $sp,88,$31\n\t" \ | |
101 | ".set noreorder;\n\t" \ | |
102 | ".set noat;\n\t" \ | |
103 | PTR_SUBU_STRING " $29,$29,96;\n\t" \ | |
104 | CPSETUP \ | |
105 | "sd $4,24($29);\n\t" \ | |
106 | "sd $5,32($29);\n\t" \ | |
107 | "sd $6,40($29);\n\t" \ | |
108 | "sd $7,48($29);\n\t" \ | |
109 | "sd $8,56($29);\n\t" \ | |
110 | "sd $9,64($29);\n\t" \ | |
111 | "sd $10,72($29);\n\t" \ | |
112 | "sd $11,80($29);\n\t" \ | |
113 | "sd $2,16($29);\n\t" \ | |
114 | "sd $1,0($29);\n\t" \ | |
115 | "sd $31,8($29);\n\t" \ | |
116 | "move $5,$31;\n\t" \ | |
117 | "move $4,$1;\n\t" \ | |
118 | "jal __mcount;\n\t" \ | |
119 | "nop;\n\t" \ | |
120 | "ld $4,24($29);\n\t" \ | |
121 | "ld $5,32($29);\n\t" \ | |
122 | "ld $6,40($29);\n\t" \ | |
123 | "ld $7,48($29);\n\t" \ | |
124 | "ld $8,56($29);\n\t" \ | |
125 | "ld $9,64($29);\n\t" \ | |
126 | "ld $10,72($29);\n\t" \ | |
127 | "ld $11,80($29);\n\t" \ | |
128 | "ld $2,16($29);\n\t" \ | |
129 | "ld $31,8($29);\n\t" \ | |
130 | "ld $1,0($29);\n\t" \ | |
131 | CPRETURN \ | |
132 | PTR_ADDU_STRING " $29,$29,96;\n\t" \ | |
133 | "j $31;\n\t" \ | |
134 | "move $31,$1;\n\t" \ | |
135 | ".set reorder;\n\t" \ | |
136 | ".set at\n\t" \ | |
137 | ".end _mcount"); | |
138 | ||
139 | #endif |