1134287Smarcel/* 2134287Smarcel * Copyright (c) 2004 Marcel Moolenaar 3134287Smarcel * All rights reserved. 4134287Smarcel * 5134287Smarcel * Redistribution and use in source and binary forms, with or without 6134287Smarcel * modification, are permitted provided that the following conditions 7134287Smarcel * are met: 8134287Smarcel * 9134287Smarcel * 1. Redistributions of source code must retain the above copyright 10134287Smarcel * notice, this list of conditions and the following disclaimer. 11134287Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12134287Smarcel * notice, this list of conditions and the following disclaimer in the 13134287Smarcel * documentation and/or other materials provided with the distribution. 14134287Smarcel * 15134287Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16134287Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17134287Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18134287Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19134287Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20134287Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21134287Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22134287Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23134287Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24134287Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25134287Smarcel */ 26134287Smarcel 27134287Smarcel#include <machine/asm.h> 28134287Smarcel__FBSDID("$FreeBSD$"); 29134287Smarcel 30134287Smarcel .text 31134287Smarcel 32134287Smarcel/* 33134287Smarcel * Important registers: 34134287Smarcel * r8 structure return address 35134287Smarcel * r15 static link (nested routines) 36134287Smarcel * rp our return address 37134287Smarcel * in0 caller's ar.pfs 38134287Smarcel * in1 caller's gp 39134287Smarcel * in2 caller's rp 40134287Smarcel * in3 GOT entry 41134287Smarcel * ar.pfs our pfs 42134287Smarcel */ 43134287SmarcelENTRY_NOPROFILE(_mcount, 4) 44134287Smarcel alloc loc0 = ar.pfs, 4, 4, 2, 0 45134287Smarcel mov loc1 = r8 46134287Smarcel mov loc2 = rp 47134287Smarcel mov loc3 = r15 48134287Smarcel ;; 49134287Smarcel mov out0 = in2 50134287Smarcel mov out1 = rp 51134287Smarcel br.call.sptk rp = __mcount 52134287Smarcel ;; 53134287Smarcel1: 54134287Smarcel mov gp = in1 55134287Smarcel mov r14 = ip 56134287Smarcel mov b7 = loc2 57134287Smarcel ;; 58134287Smarcel add r14 = 2f - 1b, r14 59134287Smarcel mov ar.pfs = loc0 60134287Smarcel mov rp = in2 61134287Smarcel ;; 62134287Smarcel mov r15 = loc3 63134287Smarcel mov b7 = r14 64134287Smarcel mov b6 = loc2 65134287Smarcel mov r8 = loc1 66134287Smarcel mov r14 = in0 67134287Smarcel br.ret.sptk b7 68134287Smarcel ;; 69134287Smarcel2: 70134287Smarcel mov ar.pfs = r14 71134287Smarcel br.sptk b6 72134287Smarcel ;; 73134287SmarcelEND(_mcount) 74134287Smarcel 75134287SmarcelWEAK_ALIAS(mcount, _mcount) 76