1*199767f8SToomas Soome /*- 2*199767f8SToomas Soome * Copyright (c) 1990 The Regents of the University of California. 3*199767f8SToomas Soome * All rights reserved. 4*199767f8SToomas Soome * 5*199767f8SToomas Soome * This code is derived from software contributed to Berkeley by 6*199767f8SToomas Soome * William Jolitz. 7*199767f8SToomas Soome * 8*199767f8SToomas Soome * Redistribution and use in source and binary forms, with or without 9*199767f8SToomas Soome * modification, are permitted provided that the following conditions 10*199767f8SToomas Soome * are met: 11*199767f8SToomas Soome * 1. Redistributions of source code must retain the above copyright 12*199767f8SToomas Soome * notice, this list of conditions and the following disclaimer. 13*199767f8SToomas Soome * 2. Redistributions in binary form must reproduce the above copyright 14*199767f8SToomas Soome * notice, this list of conditions and the following disclaimer in the 15*199767f8SToomas Soome * documentation and/or other materials provided with the distribution. 16*199767f8SToomas Soome * 4. Neither the name of the University nor the names of its contributors 17*199767f8SToomas Soome * may be used to endorse or promote products derived from this software 18*199767f8SToomas Soome * without specific prior written permission. 19*199767f8SToomas Soome * 20*199767f8SToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21*199767f8SToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22*199767f8SToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23*199767f8SToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24*199767f8SToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25*199767f8SToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26*199767f8SToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27*199767f8SToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28*199767f8SToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29*199767f8SToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30*199767f8SToomas Soome * SUCH DAMAGE. 31*199767f8SToomas Soome * 32*199767f8SToomas Soome * from: @(#)DEFS.h 5.1 (Berkeley) 4/23/90 33*199767f8SToomas Soome * $FreeBSD$ 34*199767f8SToomas Soome */ 35*199767f8SToomas Soome 36*199767f8SToomas Soome #ifndef _MACHINE_ASM_H_ 37*199767f8SToomas Soome #define _MACHINE_ASM_H_ 38*199767f8SToomas Soome 39*199767f8SToomas Soome #include <sys/cdefs.h> 40*199767f8SToomas Soome 41*199767f8SToomas Soome #ifdef PIC 42*199767f8SToomas Soome #define PIC_PLT(x) x@PLT 43*199767f8SToomas Soome #define PIC_GOT(x) x@GOTPCREL(%rip) 44*199767f8SToomas Soome #else 45*199767f8SToomas Soome #define PIC_PLT(x) x 46*199767f8SToomas Soome #endif 47*199767f8SToomas Soome 48*199767f8SToomas Soome /* 49*199767f8SToomas Soome * CNAME and HIDENAME manage the relationship between symbol names in C 50*199767f8SToomas Soome * and the equivalent assembly language names. CNAME is given a name as 51*199767f8SToomas Soome * it would be used in a C program. It expands to the equivalent assembly 52*199767f8SToomas Soome * language name. HIDENAME is given an assembly-language name, and expands 53*199767f8SToomas Soome * to a possibly-modified form that will be invisible to C programs. 54*199767f8SToomas Soome */ 55*199767f8SToomas Soome #define CNAME(csym) csym 56*199767f8SToomas Soome #define HIDENAME(asmsym) .asmsym 57*199767f8SToomas Soome 58*199767f8SToomas Soome #define _START_ENTRY .text; .p2align 4,0x90 59*199767f8SToomas Soome 60*199767f8SToomas Soome #define _ENTRY(x) _START_ENTRY; \ 61*199767f8SToomas Soome .globl CNAME(x); .type CNAME(x),@function; CNAME(x): 62*199767f8SToomas Soome 63*199767f8SToomas Soome #ifdef PROF 64*199767f8SToomas Soome #define ALTENTRY(x) _ENTRY(x); \ 65*199767f8SToomas Soome pushq %rbp; movq %rsp,%rbp; \ 66*199767f8SToomas Soome call PIC_PLT(HIDENAME(mcount)); \ 67*199767f8SToomas Soome popq %rbp; \ 68*199767f8SToomas Soome jmp 9f 69*199767f8SToomas Soome #define ENTRY(x) _ENTRY(x); \ 70*199767f8SToomas Soome pushq %rbp; movq %rsp,%rbp; \ 71*199767f8SToomas Soome call PIC_PLT(HIDENAME(mcount)); \ 72*199767f8SToomas Soome popq %rbp; \ 73*199767f8SToomas Soome 9: 74*199767f8SToomas Soome #else 75*199767f8SToomas Soome #define ALTENTRY(x) _ENTRY(x) 76*199767f8SToomas Soome #define ENTRY(x) _ENTRY(x) 77*199767f8SToomas Soome #endif 78*199767f8SToomas Soome 79*199767f8SToomas Soome #define END(x) .size x, . - x 80*199767f8SToomas Soome /* 81*199767f8SToomas Soome * WEAK_REFERENCE(): create a weak reference alias from sym. 82*199767f8SToomas Soome * The macro is not a general asm macro that takes arbitrary names, 83*199767f8SToomas Soome * but one that takes only C names. It does the non-null name 84*199767f8SToomas Soome * translation inside the macro. 85*199767f8SToomas Soome */ 86*199767f8SToomas Soome #define WEAK_REFERENCE(sym, alias) \ 87*199767f8SToomas Soome .weak CNAME(alias); \ 88*199767f8SToomas Soome .equ CNAME(alias),CNAME(sym) 89*199767f8SToomas Soome 90*199767f8SToomas Soome #define RCSID(x) .text; .asciz x 91*199767f8SToomas Soome 92*199767f8SToomas Soome #undef __FBSDID 93*199767f8SToomas Soome #if !defined(lint) && !defined(STRIP_FBSDID) 94*199767f8SToomas Soome #define __FBSDID(s) .ident s 95*199767f8SToomas Soome #else 96*199767f8SToomas Soome #define __FBSDID(s) /* nothing */ 97*199767f8SToomas Soome #endif /* not lint and not STRIP_FBSDID */ 98*199767f8SToomas Soome 99*199767f8SToomas Soome #endif /* !_MACHINE_ASM_H_ */ 100