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