123571Sbde/*-
223571Sbde * Copyright (c) 1990 The Regents of the University of California.
323571Sbde * All rights reserved.
423571Sbde *
523571Sbde * This code is derived from software contributed to Berkeley by
623571Sbde * William Jolitz.
723571Sbde *
823571Sbde * Redistribution and use in source and binary forms, with or without
923571Sbde * modification, are permitted provided that the following conditions
1023571Sbde * are met:
1123571Sbde * 1. Redistributions of source code must retain the above copyright
1223571Sbde *    notice, this list of conditions and the following disclaimer.
1323571Sbde * 2. Redistributions in binary form must reproduce the above copyright
1423571Sbde *    notice, this list of conditions and the following disclaimer in the
1523571Sbde *    documentation and/or other materials provided with the distribution.
1623571Sbde * 4. Neither the name of the University nor the names of its contributors
1723571Sbde *    may be used to endorse or promote products derived from this software
1823571Sbde *    without specific prior written permission.
1923571Sbde *
2023571Sbde * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2123571Sbde * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2223571Sbde * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2323571Sbde * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2423571Sbde * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2523571Sbde * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2623571Sbde * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2723571Sbde * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2823571Sbde * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2923571Sbde * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3023571Sbde * SUCH DAMAGE.
3123571Sbde *
3223571Sbde *	from: @(#)DEFS.h	5.1 (Berkeley) 4/23/90
3350477Speter * $FreeBSD$
3423571Sbde */
3523571Sbde
3625111Sbde#ifndef _MACHINE_ASM_H_
3725111Sbde#define	_MACHINE_ASM_H_
3825111Sbde
3923571Sbde#include <sys/cdefs.h>
4023571Sbde
4123571Sbde#ifdef PIC
4223571Sbde#define	PIC_PLT(x)	x@PLT
43114349Speter#define	PIC_GOT(x)	x@GOTPCREL(%rip)
4423571Sbde#else
4523571Sbde#define	PIC_PLT(x)	x
4623571Sbde#define	PIC_GOT(x)	x
4723571Sbde#endif
4823571Sbde
4923571Sbde/*
5023571Sbde * CNAME and HIDENAME manage the relationship between symbol names in C
5123571Sbde * and the equivalent assembly language names.  CNAME is given a name as
5223571Sbde * it would be used in a C program.  It expands to the equivalent assembly
5323571Sbde * language name.  HIDENAME is given an assembly-language name, and expands
5423571Sbde * to a possibly-modified form that will be invisible to C programs.
5523571Sbde */
5623571Sbde#define CNAME(csym)		csym
57115678Speter#define HIDENAME(asmsym)	.asmsym
5823571Sbde
59144884Salc#define _START_ENTRY	.text; .p2align 4,0x90
6023571Sbde
6125111Sbde#define _ENTRY(x)	_START_ENTRY; \
6225111Sbde			.globl CNAME(x); .type CNAME(x),@function; CNAME(x):
6325111Sbde
6425111Sbde#ifdef PROF
6556581Sbde#define	ALTENTRY(x)	_ENTRY(x); \
66130322Speter			pushq %rbp; movq %rsp,%rbp; \
6725111Sbde			call PIC_PLT(HIDENAME(mcount)); \
68130322Speter			popq %rbp; \
6956581Sbde			jmp 9f
7056581Sbde#define	ENTRY(x)	_ENTRY(x); \
71130322Speter			pushq %rbp; movq %rsp,%rbp; \
7256581Sbde			call PIC_PLT(HIDENAME(mcount)); \
73130322Speter			popq %rbp; \
7456581Sbde			9:
7523571Sbde#else
7656581Sbde#define	ALTENTRY(x)	_ENTRY(x)
7725111Sbde#define	ENTRY(x)	_ENTRY(x)
7823571Sbde#endif
7923571Sbde
80171914Sjkoshy#define	END(x)		.size x, . - x
81171914Sjkoshy
8225111Sbde#define RCSID(x)	.text; .asciz x
8323571Sbde
8492998Sobrien#undef __FBSDID
8592998Sobrien#if !defined(lint) && !defined(STRIP_FBSDID)
8692998Sobrien#define __FBSDID(s)	.ident s
8792998Sobrien#else
8892998Sobrien#define __FBSDID(s)	/* nothing */
8992998Sobrien#endif /* not lint and not STRIP_FBSDID */
9092998Sobrien
9125111Sbde#endif /* !_MACHINE_ASM_H_ */
92