The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: geert@linux-m68k.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
	martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
	jolsa@kernel.org, jserv@ccns.ncku.edu.tw, eleanor15x@gmail.com,
	marscheng@google.com, linux-kernel@vger.kernel.org,
	linux-m68k@lists.linux-m68k.org, bpf@vger.kernel.org,
	Daniel Palmer <daniel@thingy.jp>
Subject: Re: [PATCH bpf-next v4 RESEND] m68k, bpf: Add initial BPF JIT compiler support
Date: Mon, 10 Aug 2026 18:05:58 +0800	[thread overview]
Message-ID: <anmihq6bmwufwTOs@google.com> (raw)
In-Reply-To: <871pclresq.fsf@igel.home>

Hi Andreas,

On Wed, Jul 29, 2026 at 05:33:41PM +0200, Andreas Schwab wrote:
> On Jul 29 2026, Kuan-Wei Chiu wrote:
> 
> > +static void emit_alu32_k(const struct bpf_insn *insn, struct jit_ctx *ctx)
> > +{
> > +	const s8 *dst = bpf2m68k[insn->dst_reg];
> > +	const s8 *tmp1 = bpf2m68k[TMP_REG_1];
> > +	const s8 *tmp2 = bpf2m68k[TMP_REG_2];
> > +	s8 d_reg;
> > +
> > +	d_reg = bpf_get_reg32(dst[1], tmp1[1], ctx);
> > +
> > +	switch (BPF_OP(insn->code)) {
> > +	case BPF_MOV:
> > +		emit_16(ctx, 0x203c | (d_reg << 9));		/* move.l #imm, dst */
> > +		emit_32(ctx, insn->imm);
> > +		break;
> > +	case BPF_ADD:
> > +		emit_16(ctx, 0x0680 | d_reg);			/* addi.l #imm, dst */
> > +		emit_32(ctx, insn->imm);
> > +		break;
> > +	case BPF_SUB:
> > +		emit_16(ctx, 0x0480 | d_reg);			/* subi.l #imm, dst */
> > +		emit_32(ctx, insn->imm);
> > +		break;
> > +	case BPF_AND:
> > +		emit_16(ctx, 0x0280 | d_reg);			/* andi.l #imm, dst */
> > +		emit_32(ctx, insn->imm);
> > +		break;
> > +	case BPF_OR:
> > +		emit_16(ctx, 0x0080 | d_reg);			/* ori.l #imm, dst */
> > +		emit_32(ctx, insn->imm);
> > +		break;
> > +	case BPF_XOR:
> > +		emit_16(ctx, 0x0a80 | d_reg);			/* eori.l #imm, dst */
> > +		emit_32(ctx, insn->imm);
> > +		break;
> > +	case BPF_LSH:
> > +	case BPF_RSH:
> > +	case BPF_ARSH:
> > +		emit_16(ctx, 0x203c | (tmp2[1] << 9));		/* move.l #imm, count */
> > +		emit_32(ctx, insn->imm & 0x1f);
> 
> That can be moveq.  Also, for the other cases, if imm is in the range of
> moveq it is worthwhile to load it into a temporary register.
> 
Thanks for the suggestions.
I will include these optimizations in v5.

Regards,
Kuan-Wei

  reply	other threads:[~2026-08-10 10:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  0:27 [PATCH bpf-next v4 RESEND] m68k, bpf: Add initial BPF JIT compiler support Kuan-Wei Chiu
2026-07-29 15:33 ` Andreas Schwab
2026-08-10 10:05   ` Kuan-Wei Chiu [this message]
2026-08-06 15:28 ` Greg Ungerer
2026-08-10 10:04   ` Kuan-Wei Chiu
2026-08-06 23:34 ` [PATCH bpf-next v4 RESEND] m68k, bpf: Add initial BPF JIT compiler support (resend) Greg Ungerer

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=anmihq6bmwufwTOs@google.com \
    --to=visitorckw@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=daniel@thingy.jp \
    --cc=eddyz87@gmail.com \
    --cc=eleanor15x@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=jolsa@kernel.org \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=marscheng@google.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=schwab@linux-m68k.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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