ClickHouse/utils/memcpy-bench/glibc/sysdep.h

132 lines
4.1 KiB
C++
Raw Normal View History

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