public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: libc-alpha@sourceware.org
Cc: caiyinyu <caiyinyu@loongson.cn>, Wang Xuerui <i@xen0n.name>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Andreas Schwab <schwab@suse.de>,
	Florian Weimer <fw@deneb.enyo.de>, Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH v2 4/5] x86_64: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux
Date: Sat, 25 Mar 2023 22:08:14 +0800	[thread overview]
Message-ID: <20230325140815.4170296-5-xry111@xry111.site> (raw)
In-Reply-To: <20230325140815.4170296-1-xry111@xry111.site>

x86_64 calling convention treats the variable arguments same as named
ones (it sets %al to the number of floating-point variable arguments but
it's simply ignored because our syscall wrappers don't take
floating-point arguments), and when each argument is an integer
not wider than 8 bytes, the ith argument is in registers %rdi, %rsi,
%rdx, %rcx, %r8, and %r9 (0 <= i < 6), or the stack slot at
(%rsp + 8 * (i - 6)) (i >= 8) no matter how many arguments are passed.
So we can define __ASSUME_SYSCALL_NAMED_WORKS to avoid unnecessary stack
stores in the syscall wrappers caused by va_start.
---
 sysdeps/unix/sysv/linux/x86_64/kernel-features.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
index 68322ff476..7783a0eebc 100644
--- a/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/x86_64/kernel-features.h
@@ -23,4 +23,13 @@
 # define __ASSUME_WORDSIZE64_ILP32	1
 #endif
 
+/* Define this if the calling convention for passing x named arguments and y
+   variable arguments is same as passing (x + y) named arguments, while each
+   argument is either an integer of which the width is less than or equal to
+   "long", or a pointer; and an argument can be fetched from the same register
+   or the same offset from the stack pointer no matter how many (maybe zero)
+   arguments are passed after it.  It avoids useless stack stores caused by
+   usage of va_start.  */
+#define __ASSUME_SYSCALL_NAMED_WORKS	1
+
 #include_next <kernel-features.h>
-- 
2.40.0


  parent reply	other threads:[~2023-03-25 14:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-25 14:08 [PATCH v2 0/5] linux: Avoid va_list for generic syscall wrappers if possible Xi Ruoyao
2023-03-25 14:08 ` [PATCH v2 1/5] linux: Add __ASSUME_SYSCALL_NAMED_WORKS to allow avoiding va_list for generic syscall Xi Ruoyao
2023-03-25 14:08 ` [PATCH v2 2/5] linux: [__ASSUME_SYSCALL_NAMED_WORKS] Avoid using va_list for various syscall wrappers Xi Ruoyao
2023-03-25 14:08 ` [PATCH v2 3/5] LoongArch: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux Xi Ruoyao
2023-03-25 14:08 ` Xi Ruoyao [this message]
2023-03-25 14:08 ` [PATCH v2 5/5] aarch64: " Xi Ruoyao
2023-03-27 13:06   ` Adhemerval Zanella Netto
2023-03-27 13:32     ` Xi Ruoyao
2023-03-27 14:04 ` [PATCH v2 0/5] linux: Avoid va_list for generic syscall wrappers if possible Carlos O'Donell
2023-03-27 14:44   ` Xi Ruoyao
2023-03-27 14:45   ` Xi Ruoyao
2023-03-27 14:51     ` Xi Ruoyao
2023-04-04  1:25     ` caiyinyu
2023-04-04 12:12       ` Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230325140815.4170296-5-xry111@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=fw@deneb.enyo.de \
    --cc=i@xen0n.name \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).