Blame sysdeps/nios2/machine-gmon.h

Packit 6c4009
/* Machine-dependent definitions for profiling support.  Nios II version.
Packit 6c4009
   Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
#define _MCOUNT_DECL(frompc, selfpc) \
Packit 6c4009
static void __attribute_used__ __mcount_internal (u_long frompc, u_long selfpc)
Packit 6c4009
Packit 6c4009
/* This macro/func MUST save r4, r5, r6, r7 and r8 because the compiler inserts
Packit 6c4009
   blind calls to mcount(), ignoring the fact that mcount may clobber
Packit 6c4009
   registers; therefore, mcount may NOT clobber registers.  */
Packit 6c4009
Packit 6c4009
#if defined(__PIC__) || defined(PIC)
Packit 6c4009
#define NIOS2_MCOUNT_CALL				      \
Packit 6c4009
  "nextpc r3\n\t"					      \
Packit 6c4009
  "1: movhi r2, %hiadj(_gp_got - 1b)\n\t"		      \
Packit 6c4009
  "addi r2, r2, %lo(_gp_got - 1b)\n\t"			      \
Packit 6c4009
  "add r2, r2, r3\n\t"						\
Packit 6c4009
  "ldw r2, %call(__mcount_internal)(r2)\n\t"			\
Packit 6c4009
  "callr r2\n\t"
Packit 6c4009
#else
Packit 6c4009
#define NIOS2_MCOUNT_CALL			\
Packit 6c4009
  "call\t__mcount_internal\n\t"
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#define MCOUNT						\
Packit 6c4009
  asm (".globl _mcount\n\t"				\
Packit 6c4009
       ".type _mcount,@function\n\t"			\
Packit 6c4009
       "_mcount:\n\t"					\
Packit 6c4009
       "subi sp, sp, 24\n\t"				\
Packit 6c4009
       "stw ra, 20(sp)\n\t"				\
Packit 6c4009
       "stw r8, 16(sp)\n\t"				\
Packit 6c4009
       "stw r7, 12(sp)\n\t"				\
Packit 6c4009
       "stw r6, 8(sp)\n\t"				\
Packit 6c4009
       "stw r5, 4(sp)\n\t"				\
Packit 6c4009
       "stw r4, 0(sp)\n\t"				\
Packit 6c4009
       "mov r4, r8\n\t"					\
Packit 6c4009
       "mov r5, ra\n\t"					\
Packit 6c4009
       NIOS2_MCOUNT_CALL				\
Packit 6c4009
       "ldw ra, 20(sp)\n\t"				\
Packit 6c4009
       "ldw r8, 16(sp)\n\t"				\
Packit 6c4009
       "ldw r7, 12(sp)\n\t"				\
Packit 6c4009
       "ldw r6, 8(sp)\n\t"				\
Packit 6c4009
       "ldw r5, 4(sp)\n\t"				\
Packit 6c4009
       "ldw r4, 0(sp)\n\t"				\
Packit 6c4009
       "addi sp, sp, 24\n\t"				\
Packit 6c4009
       "ret\n\t"					\
Packit 6c4009
       ".size _mcount, . - _mcount\n\t"			\
Packit 6c4009
       );