Function name typo error in non-PIC case, fixed in this patch.
[platform/upstream/glibc.git] / sysdeps / nios2 / machine-gmon.h
1 /* Machine-dependent definitions for profiling support.  Nios II version.
2    Copyright (C) 1996-2015 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library.  If not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #include <sysdep.h>
20
21 #define _MCOUNT_DECL(frompc, selfpc) \
22 static void __attribute_used__ __mcount_internal (u_long frompc, u_long selfpc)
23
24 /* This macro/func MUST save r4, r5, r6, r7 and r8 because the compiler inserts
25    blind calls to mcount(), ignoring the fact that mcount may clobber
26    registers; therefore, mcount may NOT clobber registers.  */
27
28 #if defined(__PIC__) || defined(PIC)
29 #define NIOS2_MCOUNT_CALL                                     \
30   "nextpc r3\n\t"                                             \
31   "1: movhi r2, %hiadj(_gp_got - 1b)\n\t"                     \
32   "addi r2, r2, %lo(_gp_got - 1b)\n\t"                        \
33   "add r2, r2, r3\n\t"                                          \
34   "ldw r2, %call(__mcount_internal)(r2)\n\t"                    \
35   "callr r2\n\t"
36 #else
37 #define NIOS2_MCOUNT_CALL                       \
38   "call\t__mcount_internal\n\t"
39 #endif
40
41 #define MCOUNT                                          \
42   asm (".globl _mcount\n\t"                             \
43        ".type _mcount,@function\n\t"                    \
44        "_mcount:\n\t"                                   \
45        "subi sp, sp, 24\n\t"                            \
46        "stw ra, 20(sp)\n\t"                             \
47        "stw r8, 16(sp)\n\t"                             \
48        "stw r7, 12(sp)\n\t"                             \
49        "stw r6, 8(sp)\n\t"                              \
50        "stw r5, 4(sp)\n\t"                              \
51        "stw r4, 0(sp)\n\t"                              \
52        "mov r4, r8\n\t"                                 \
53        "mov r5, ra\n\t"                                 \
54        NIOS2_MCOUNT_CALL                                \
55        "ldw ra, 20(sp)\n\t"                             \
56        "ldw r8, 16(sp)\n\t"                             \
57        "ldw r7, 12(sp)\n\t"                             \
58        "ldw r6, 8(sp)\n\t"                              \
59        "ldw r5, 4(sp)\n\t"                              \
60        "ldw r4, 0(sp)\n\t"                              \
61        "addi sp, sp, 24\n\t"                            \
62        "ret\n\t"                                        \
63        ".size _mcount, . - _mcount\n\t"                 \
64        );