Blame sysdeps/ia64/_mcount.S

Packit 6c4009
/* Machine-specific calling sequence for `mcount' profiling function.  ia64
Packit 6c4009
   Copyright (C) 2000-2018 Free Software Foundation, Inc.
Packit 6c4009
     Contributed by David Mosberger <davidm@hpl.hp.com>
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
/* Assembly stub to invoke _mcount().  Compiler generated code calls
Packit 6c4009
   this stub before executing a function's prologue and without saving
Packit 6c4009
   any registers.  It is therefore necessary to preserve the input
Packit 6c4009
   registers as they may contain function arguments.  To work
Packit 6c4009
   correctly with frame-less functions, it is also necessary to
Packit 6c4009
   preserve the return pointer (b0 aka rp).
Packit 6c4009
Packit 6c4009
   State upon entering _mcount:
Packit 6c4009
Packit 6c4009
    r8  address of return value structure (used only when called
Packit 6c4009
	function returns a large structure)
Packit 6c4009
    r15 static link (used only for nested functions)
Packit 6c4009
    in0 ar.pfs to restore before returning to the function that
Packit 6c4009
	called _mcount
Packit 6c4009
    in1 gp value to restore before returning to the function that
Packit 6c4009
	called _mcount
Packit 6c4009
    in2 return address in the function that invoked the caller
Packit 6c4009
	of _mcount (frompc)
Packit 6c4009
    in3	address of the global-offset table entry that holds the
Packit 6c4009
	profile count dword allocated by the compiler; to get
Packit 6c4009
	the address of this dword, use "ld8 in2=[in2]; this
Packit 6c4009
	dword can be used in any way by _mcount (including
Packit 6c4009
	not at all, as is the case with the current implementation)
Packit 6c4009
    b0	address to return to after _mcount is done
Packit 6c4009
*/
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
#undef ret
Packit 6c4009
Packit 6c4009
LEAF(_mcount)
Packit 6c4009
	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(4)
Packit 6c4009
	alloc loc1 = ar.pfs, 4, 4, 3, 0
Packit 6c4009
	mov loc0 = rp
Packit 6c4009
	.body
Packit 6c4009
	mov loc2 = r8	// gcc uses r8 to pass pointer to return structure
Packit 6c4009
	;;
Packit 6c4009
	mov loc3 = r15	// gcc uses r15 to pass the static link to nested functions
Packit 6c4009
	mov out0 = in2
Packit 6c4009
	mov out1 = rp
Packit 6c4009
	br.call.sptk.few rp = __mcount
Packit 6c4009
	;;
Packit 6c4009
.here:
Packit 6c4009
{
Packit 6c4009
	.mii
Packit 6c4009
	mov gp = in1
Packit 6c4009
	mov r2 = ip
Packit 6c4009
	mov ar.pfs = loc1
Packit 6c4009
}
Packit 6c4009
	;;
Packit 6c4009
	adds r2 = _mcount_ret_helper - .here, r2
Packit 6c4009
	mov b7 = loc0
Packit 6c4009
	mov rp = in2
Packit 6c4009
	;;
Packit 6c4009
	mov r3 = in0
Packit 6c4009
	mov r8 = loc2
Packit 6c4009
	mov r15 = loc3
Packit 6c4009
	mov b6 = r2
Packit 6c4009
	br.ret.sptk.few b6
Packit 6c4009
END(_mcount)
Packit 6c4009
Packit 6c4009
LOCAL_LEAF(_mcount_ret_helper)
Packit 6c4009
	.prologue
Packit 6c4009
	.altrp b7
Packit 6c4009
	.save ar.pfs, r3
Packit 6c4009
	.body
Packit 6c4009
	alloc r2 = ar.pfs, 0, 0, 8, 0
Packit 6c4009
	mov ar.pfs = r3
Packit 6c4009
	br b7
Packit 6c4009
END(_mcount_ret_helper)
Packit 6c4009
Packit 6c4009
weak_alias (_mcount, mcount)