Blame sysdeps/alpha/_mcount.S

Packit 6c4009
/* Machine-specific calling sequence for `mcount' profiling function.  alpha
Packit 6c4009
   Copyright (C) 1995-2018 Free Software Foundation, Inc.
Packit 6c4009
   Contributed by David Mosberger (davidm@cs.arizona.edu).
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 after executing a function's prologue and without saving any
Packit 6c4009
   registers.  It is therefore necessary to preserve a0..a5 as they may
Packit 6c4009
   contain function arguments.  To work correctly with frame- less
Packit 6c4009
   functions, it is also necessary to preserve ra.  Finally, division
Packit 6c4009
   routines are invoked with a special calling convention and the
Packit 6c4009
   compiler treats those calls as if they were instructions.  In
Packit 6c4009
   particular, it doesn't save any of the temporary registers (caller
Packit 6c4009
   saved registers).  It is therefore necessary to preserve all
Packit 6c4009
   caller-saved registers as well.
Packit 6c4009
Packit 6c4009
   Upon entering _mcount, register $at holds the return address and ra
Packit 6c4009
   holds the return address of the function's caller (selfpc and frompc,
Packit 6c4009
   respectively in gmon.c language...). */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
	.set	noat
Packit 6c4009
	.set	noreorder
Packit 6c4009
Packit 6c4009
LEAF(_mcount, 0xb0)
Packit 6c4009
	subq	 sp, 0xb0, sp
Packit 6c4009
	.prologue 0
Packit 6c4009
	stq	 a0, 0x00(sp)
Packit 6c4009
	mov	 ra, a0		# a0 = caller-pc
Packit 6c4009
	stq	 a1, 0x08(sp)
Packit 6c4009
	mov	$at, a1		# a1 = self-pc
Packit 6c4009
	stq	$at, 0x10(sp)
Packit 6c4009
Packit 6c4009
	stq	 a2, 0x18(sp)
Packit 6c4009
	stq	 a3, 0x20(sp)
Packit 6c4009
	stq	 a4, 0x28(sp)
Packit 6c4009
	stq	 a5, 0x30(sp)
Packit 6c4009
	stq	 ra, 0x38(sp)
Packit 6c4009
	stq	 gp, 0x40(sp)
Packit 6c4009
Packit 6c4009
	br	gp, 1f
Packit 6c4009
1:	ldgp	gp, 0(gp)
Packit 6c4009
Packit 6c4009
	stq	 t0, 0x48(sp)
Packit 6c4009
	stq	 t1, 0x50(sp)
Packit 6c4009
	stq	 t2, 0x58(sp)
Packit 6c4009
	stq	 t3, 0x60(sp)
Packit 6c4009
	stq	 t4, 0x68(sp)
Packit 6c4009
	stq	 t5, 0x70(sp)
Packit 6c4009
	stq	 t6, 0x78(sp)
Packit 6c4009
Packit 6c4009
	stq	 t7, 0x80(sp)
Packit 6c4009
	stq	 t8, 0x88(sp)
Packit 6c4009
	stq	 t9, 0x90(sp)
Packit 6c4009
	stq	t10, 0x98(sp)
Packit 6c4009
	stq	t11, 0xa0(sp)
Packit 6c4009
	stq	 v0, 0xa8(sp)
Packit 6c4009
Packit 6c4009
	jsr	ra, __mcount
Packit 6c4009
Packit 6c4009
	ldq	 a0, 0x00(sp)
Packit 6c4009
	ldq	 a1, 0x08(sp)
Packit 6c4009
	ldq	$at, 0x10(sp)	# restore self-pc
Packit 6c4009
	ldq	 a2, 0x18(sp)
Packit 6c4009
	ldq	 a3, 0x20(sp)
Packit 6c4009
	ldq	 a4, 0x28(sp)
Packit 6c4009
	ldq	 a5, 0x30(sp)
Packit 6c4009
	ldq	 ra, 0x38(sp)
Packit 6c4009
	ldq	 gp, 0x40(sp)
Packit 6c4009
	mov	$at, pv		# make pv point to return address
Packit 6c4009
	ldq	 t0, 0x48(sp)	# this is important under OSF/1 to
Packit 6c4009
	ldq	 t1, 0x50(sp)	# ensure that the code that we return
Packit 6c4009
	ldq	 t2, 0x58(sp)	# can correctly compute its gp
Packit 6c4009
	ldq	 t3, 0x60(sp)
Packit 6c4009
	ldq	 t4, 0x68(sp)
Packit 6c4009
	ldq	 t5, 0x70(sp)
Packit 6c4009
	ldq	 t6, 0x78(sp)
Packit 6c4009
	ldq	 t7, 0x80(sp)
Packit 6c4009
	ldq	 t8, 0x88(sp)
Packit 6c4009
	ldq	 t9, 0x90(sp)
Packit 6c4009
	ldq	t10, 0x98(sp)
Packit 6c4009
	ldq	t11, 0xa0(sp)
Packit 6c4009
	ldq	 v0, 0xa8(sp)
Packit 6c4009
Packit 6c4009
	addq	sp, 0xb0, sp
Packit 6c4009
	ret	zero,($at),1
Packit 6c4009
Packit 6c4009
	END(_mcount)
Packit 6c4009
Packit 6c4009
weak_alias (_mcount, mcount)