Blame sysdeps/x86_64/sysdep.h

Packit 6c4009
/* Assembler macros for x86-64.
Packit 6c4009
   Copyright (C) 2001-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _X86_64_SYSDEP_H
Packit 6c4009
#define _X86_64_SYSDEP_H 1
Packit 6c4009
Packit 6c4009
#include <sysdeps/x86/sysdep.h>
Packit 6c4009
Packit 6c4009
#ifdef	__ASSEMBLER__
Packit 6c4009
Packit 6c4009
/* Syntactic details of assembler.  */
Packit 6c4009
Packit 6c4009
/* This macro is for setting proper CFI with DW_CFA_expression describing
Packit 6c4009
   the register as saved relative to %rsp instead of relative to the CFA.
Packit 6c4009
   Expression is DW_OP_drop, DW_OP_breg7 (%rsp is register 7), sleb128 offset
Packit 6c4009
   from %rsp.  */
Packit 6c4009
#define cfi_offset_rel_rsp(regn, off)	.cfi_escape 0x10, regn, 0x4, 0x13, \
Packit 6c4009
					0x77, off & 0x7F | 0x80, off >> 7
Packit 6c4009
Packit 6c4009
/* If compiled for profiling, call `mcount' at the start of each function.  */
Packit 6c4009
#ifdef	PROF
Packit 6c4009
/* The mcount code relies on a normal frame pointer being on the stack
Packit 6c4009
   to locate our caller, so push one just for its benefit.  */
Packit 6c4009
#define CALL_MCOUNT                                                          \
Packit 6c4009
  pushq %rbp;                                                                \
Packit 6c4009
  cfi_adjust_cfa_offset(8);                                                  \
Packit 6c4009
  movq %rsp, %rbp;                                                           \
Packit 6c4009
  cfi_def_cfa_register(%rbp);                                                \
Packit 6c4009
  call JUMPTARGET(mcount);                                                   \
Packit 6c4009
  popq %rbp;                                                                 \
Packit 6c4009
  cfi_def_cfa(rsp,8);
Packit 6c4009
#else
Packit 6c4009
#define CALL_MCOUNT		/* Do nothing.  */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#define	PSEUDO(name, syscall_name, args)				      \
Packit 6c4009
lose:									      \
Packit 6c4009
  jmp JUMPTARGET(syscall_error)						      \
Packit 6c4009
  .globl syscall_error;							      \
Packit 6c4009
  ENTRY (name)								      \
Packit 6c4009
  DO_CALL (syscall_name, args);						      \
Packit 6c4009
  jb lose
Packit 6c4009
Packit 6c4009
#undef JUMPTARGET
Packit 6c4009
#ifdef SHARED
Packit 6c4009
# ifdef BIND_NOW
Packit 6c4009
#  define JUMPTARGET(name)	*name##@GOTPCREL(%rip)
Packit 6c4009
# else
Packit 6c4009
#  define JUMPTARGET(name)	name##@PLT
Packit 6c4009
# endif
Packit 6c4009
#else
Packit 6c4009
/* For static archives, branch to target directly.  */
Packit 6c4009
# define JUMPTARGET(name)	name
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Long and pointer size in bytes.  */
Packit 6c4009
#define LP_SIZE	8
Packit 6c4009
Packit 6c4009
/* Instruction to operate on long and pointer.  */
Packit 6c4009
#define LP_OP(insn) insn##q
Packit 6c4009
Packit 6c4009
/* Assembler address directive. */
Packit 6c4009
#define ASM_ADDR .quad
Packit 6c4009
Packit 6c4009
/* Registers to hold long and pointer.  */
Packit 6c4009
#define RAX_LP	rax
Packit 6c4009
#define RBP_LP	rbp
Packit 6c4009
#define RBX_LP	rbx
Packit 6c4009
#define RCX_LP	rcx
Packit 6c4009
#define RDI_LP	rdi
Packit 6c4009
#define RDX_LP	rdx
Packit 6c4009
#define RSI_LP	rsi
Packit 6c4009
#define RSP_LP	rsp
Packit 6c4009
#define R8_LP	r8
Packit 6c4009
#define R9_LP	r9
Packit 6c4009
#define R10_LP	r10
Packit 6c4009
#define R11_LP	r11
Packit 6c4009
#define R12_LP	r12
Packit 6c4009
#define R13_LP	r13
Packit 6c4009
#define R14_LP	r14
Packit 6c4009
#define R15_LP	r15
Packit 6c4009
Packit 6c4009
#else	/* __ASSEMBLER__ */
Packit 6c4009
Packit 6c4009
/* Long and pointer size in bytes.  */
Packit 6c4009
#define LP_SIZE "8"
Packit 6c4009
Packit 6c4009
/* Instruction to operate on long and pointer.  */
Packit 6c4009
#define LP_OP(insn) #insn "q"
Packit 6c4009
Packit 6c4009
/* Assembler address directive. */
Packit 6c4009
#define ASM_ADDR ".quad"
Packit 6c4009
Packit 6c4009
/* Registers to hold long and pointer.  */
Packit 6c4009
#define RAX_LP	"rax"
Packit 6c4009
#define RBP_LP	"rbp"
Packit 6c4009
#define RBX_LP	"rbx"
Packit 6c4009
#define RCX_LP	"rcx"
Packit 6c4009
#define RDI_LP	"rdi"
Packit 6c4009
#define RDX_LP	"rdx"
Packit 6c4009
#define RSI_LP	"rsi"
Packit 6c4009
#define RSP_LP	"rsp"
Packit 6c4009
#define R8_LP	"r8"
Packit 6c4009
#define R9_LP	"r9"
Packit 6c4009
#define R10_LP	"r10"
Packit 6c4009
#define R11_LP	"r11"
Packit 6c4009
#define R12_LP	"r12"
Packit 6c4009
#define R13_LP	"r13"
Packit 6c4009
#define R14_LP	"r14"
Packit 6c4009
#define R15_LP	"r15"
Packit 6c4009
Packit 6c4009
#endif	/* __ASSEMBLER__ */
Packit 6c4009
Packit 6c4009
#endif	/* _X86_64_SYSDEP_H */