1 /* Machine-dependent definitions for profiling support. Nios II version.
2 Copyright (C) 1996-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
21 #define _MCOUNT_DECL(frompc, selfpc) \
22 static void __attribute_used__ __mcount_internal (u_long frompc, u_long selfpc)
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. */
28 #if defined(__PIC__) || defined(PIC)
29 #define NIOS2_MCOUNT_CALL \
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" \
37 #define NIOS2_MCOUNT_CALL \
38 "call\t__mcount_internal\n\t"
42 asm (".globl _mcount\n\t" \
43 ".type _mcount,@function\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" \
55 "ldw ra, 20(sp)\n\t" \
56 "ldw r8, 16(sp)\n\t" \
57 "ldw r7, 12(sp)\n\t" \
61 "addi sp, sp, 24\n\t" \
63 ".size _mcount, . - _mcount\n\t" \