Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / src / __support / OSUtil / linux / x86_64 / syscall.h
blob986db9372ad394c67a5bc4a9aa140288ff8bc056
1 //===---------- inline implementation of x86_64 syscalls ----------* C++ *-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H
10 #define LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H
12 #include "src/__support/common.h"
14 #define SYSCALL_CLOBBER_LIST "rcx", "r11", "memory"
16 namespace LIBC_NAMESPACE {
18 LIBC_INLINE long syscall_impl(long __number) {
19 long retcode;
20 LIBC_INLINE_ASM("syscall"
21 : "=a"(retcode)
22 : "a"(__number)
23 : SYSCALL_CLOBBER_LIST);
24 return retcode;
27 LIBC_INLINE long syscall_impl(long __number, long __arg1) {
28 long retcode;
29 LIBC_INLINE_ASM("syscall"
30 : "=a"(retcode)
31 : "a"(__number), "D"(__arg1)
32 : SYSCALL_CLOBBER_LIST);
33 return retcode;
36 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2) {
37 long retcode;
38 LIBC_INLINE_ASM("syscall"
39 : "=a"(retcode)
40 : "a"(__number), "D"(__arg1), "S"(__arg2)
41 : SYSCALL_CLOBBER_LIST);
42 return retcode;
45 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
46 long __arg3) {
47 long retcode;
48 LIBC_INLINE_ASM("syscall"
49 : "=a"(retcode)
50 : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3)
51 : SYSCALL_CLOBBER_LIST);
52 return retcode;
55 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
56 long __arg3, long __arg4) {
57 long retcode;
58 register long r10 __asm__("r10") = __arg4;
59 LIBC_INLINE_ASM("syscall"
60 : "=a"(retcode)
61 : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
62 "r"(r10)
63 : SYSCALL_CLOBBER_LIST);
64 return retcode;
67 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
68 long __arg3, long __arg4, long __arg5) {
69 long retcode;
70 register long r10 __asm__("r10") = __arg4;
71 register long r8 __asm__("r8") = __arg5;
72 LIBC_INLINE_ASM("syscall"
73 : "=a"(retcode)
74 : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
75 "r"(r10), "r"(r8)
76 : SYSCALL_CLOBBER_LIST);
77 return retcode;
80 LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
81 long __arg3, long __arg4, long __arg5,
82 long __arg6) {
83 long retcode;
84 register long r10 __asm__("r10") = __arg4;
85 register long r8 __asm__("r8") = __arg5;
86 register long r9 __asm__("r9") = __arg6;
87 LIBC_INLINE_ASM("syscall"
88 : "=a"(retcode)
89 : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
90 "r"(r10), "r"(r8), "r"(r9)
91 : SYSCALL_CLOBBER_LIST);
92 return retcode;
95 #undef SYSCALL_CLOBBER_LIST
96 } // namespace LIBC_NAMESPACE
98 #endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_LINUX_X86_64_SYSCALL_H