1/* $OpenBSD: asm.h,v 1.19 2024/03/29 21:05:34 miod Exp $ */ 2/* $NetBSD: asm.h,v 1.15 2000/08/02 22:24:39 eeh Exp $ */ 3 4/* 5 * Copyright (c) 1994 Allen Briggs 6 * All rights reserved. 7 * 8 * Gleaned from locore.s and sun3 asm.h which had the following copyrights: 9 * locore.s: 10 * Copyright (c) 1988 University of Utah. 11 * Copyright (c) 1982, 1990 The Regents of the University of California. 12 * sun3/include/asm.h: 13 * Copyright (c) 1993 Adam Glass 14 * Copyright (c) 1990 The Regents of the University of California. 15 * 16 * Redistribution and use in source and binary forms, with or without 17 * modification, are permitted provided that the following conditions 18 * are met: 19 * 1. Redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer. 21 * 2. Redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution. 24 * 3. Neither the name of the University nor the names of its contributors 25 * may be used to endorse or promote products derived from this software 26 * without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 * SUCH DAMAGE. 39 */ 40 41#ifndef _MACHINE_ASM_H_ 42#define _MACHINE_ASM_H_ 43 44/* Pull in CC64FSZ and BIAS from frame.h */ 45#include <machine/frame.h> 46 47#define _C_LABEL(name) name 48#define _ASM_LABEL(name) name 49 50#ifdef __PIC__ 51/* 52 * PIC_PROLOGUE() is akin to the compiler generated function prologue for 53 * PIC code. It leaves the address of the Global Offset Table in DEST, 54 * clobbering register TMP in the process. Using the temporary enables us 55 * to work without a stack frame (doing so requires saving %o7) . 56 */ 57#define PIC_PROLOGUE(dest,tmp) \ 58 sethi %hi(_GLOBAL_OFFSET_TABLE_-4),dest; \ 59 rd %pc, tmp; \ 60 or dest,%lo(_GLOBAL_OFFSET_TABLE_+4),dest; \ 61 add dest,tmp,dest 62#else 63#define PIC_PROLOGUE(dest,tmp) 64#endif 65 66#define FTYPE(x) .type x,@function 67#define OTYPE(x) .type x,@object 68 69#define _ENTRY_NB(name) \ 70 .align 4; .proc 1; FTYPE(name); name: 71#define _ENTRY(name) .globl name; _ENTRY_NB(name) 72 73#if defined(PROF) || defined(GPROF) 74#define _PROF_PROLOGUE \ 75 .data; .align 8; 1: .uaword 0; .uaword 0; \ 76 .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call _mcount; \ 77 or %o0,%lo(1b),%o0; restore 78#else 79#define _PROF_PROLOGUE 80#endif 81 82#define ENTRY(name) _ENTRY(name); _PROF_PROLOGUE 83#define NENTRY(name) _ENTRY(name) 84#define ENTRY_NB(name) _ENTRY_NB(name); _PROF_PROLOGUE 85#define ASENTRY(name) _ENTRY(name); _PROF_PROLOGUE 86#define FUNC(name) ASENTRY(name) 87#define END(y) .size y, . - y 88 89#define STRONG_ALIAS(alias,sym) \ 90 .global alias; \ 91 alias = sym 92#define WEAK_ALIAS(alias,sym) \ 93 .weak alias; \ 94 alias = sym 95 96#endif /* _MACHINE_ASM_H_ */ 97