public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: caiyinyu <caiyinyu@loongson.cn>, libc-alpha@sourceware.org
Cc: adhemerval.zanella@linaro.org
Subject: Re: [PATCH] LoongArch: Add Syscall Assembly Implementation
Date: Thu, 23 Mar 2023 17:25:52 +0800	[thread overview]
Message-ID: <c969ecf793e73e79b7723dc8b1b7d71a7e48ec6a.camel@xry111.site> (raw)
In-Reply-To: <20230323084013.1100656-1-caiyinyu@loongson.cn>

General question: is there a notable benefit optimizing syscall with
assembly?  AFAIK nobody will put syscall on a hot path, and the cycles
saved by using the assembly implementation should be negligible
comparing with all the cost of context switch etc.

On Thu, 2023-03-23 at 16:40 +0800, caiyinyu wrote:
> + ENTRY (syscall)
> +        move	t0, a7
> +        move	a7, a0		/* Syscall number -> a0.  */
> +        move	a0, a1		/* shift arg1 - arg6.  */
> +        move	a1, a2
> +        move	a2, a3
> +        move	a3, a4
> +        move	a4, a5
> +        move	a5, a6
> +        move	a6, t0		/* arg7 is saved in t0.  */
> +        syscall 0		/* Do the system call.  */
> +       lu12i.w t0, -1

"li.w t0, -4096" will do the same thing, and be more readable.

And this line seems indented with a tab, while other lines are indented
with 8 spaces.

> +        bltu   t0, a0, L (error)
> +        ret                     /* Return to caller.  */

"ret" is not recognized by GNU assembler <= 2.39, it's better to use
the old-style "jr      ra" for backward compatibility.

> +
> +L (error):
> +        b      __syscall_error

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2023-03-23  9:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23  8:40 caiyinyu
2023-03-23  9:25 ` Xi Ruoyao [this message]
2023-03-23 12:01   ` caiyinyu
2023-03-23 13:12     ` Andreas Schwab
2023-03-23 13:34       ` Xi Ruoyao
2023-03-23 13:43         ` Xi Ruoyao
2023-03-23 17:34           ` Xi Ruoyao
2023-03-23 18:26             ` Xi Ruoyao
2023-03-23 18:40               ` Adhemerval Zanella Netto
2023-03-23 19:08                 ` Xi Ruoyao
2023-03-23 13:12     ` Xi Ruoyao
2023-03-23 12:00 caiyinyu

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=c969ecf793e73e79b7723dc8b1b7d71a7e48ec6a.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=libc-alpha@sourceware.org \
    /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).