public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Vineet Gupta <vineet.gupta@linux.dev>
To: bpf@vger.kernel.org
Cc: bpf@gcc.gnu.org, jose.marchesi@oracle.com, ast@kernel.org,
	Eduard Zingerman <eddyz87@gmail.com>,
	Yonghong Song <yonghong.song@linux.dev>,
	Vineet Gupta <vineet.gupta@linux.dev>
Subject: [PATCH v2 1/2] bpf, doc: Clarify Pseudo-C notation and w vs r register usage
Date: Thu,  2 Apr 2026 15:13:38 -0700	[thread overview]
Message-ID: <20260402221339.1614989-2-vineet.gupta@linux.dev> (raw)
In-Reply-To: <20260402221339.1614989-1-vineet.gupta@linux.dev>

As a newcomer to BPF ecosystem I was confused with Pseudo-C being the
actual assembly. And while it's obvious now that w and r forms represent
32-bit and 64-bit regs respectively, it's better to call this out in
documentation explicitly and make it more newbie-proof.

Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
---
Changes since v1
  - Address review comments from AI CI-bot
---
 .../bpf/standardization/instruction-set.rst        | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/bpf/standardization/instruction-set.rst b/Documentation/bpf/standardization/instruction-set.rst
index 39c74611752b..96181565906f 100644
--- a/Documentation/bpf/standardization/instruction-set.rst
+++ b/Documentation/bpf/standardization/instruction-set.rst
@@ -315,13 +315,21 @@ For arithmetic and jump instructions (``ALU``, ``ALU64``, ``JMP`` and
 Arithmetic instructions
 -----------------------
 
-``ALU`` uses 32-bit wide operands while ``ALU64`` uses 64-bit wide operands for
-otherwise identical operations. ``ALU64`` instructions belong to the
+``ALU`` uses 32-bit wide operands ('w' registers in assembly) while
+``ALU64`` uses 64-bit wide operands ('r' registers) for otherwise
+identical operations. ``ALU64`` instructions belong to the
 base64 conformance group unless noted otherwise.
-The 'code' field encodes the operation as below, where 'src' refers to the
+The 'code' field encodes the operation as below, where 'src' refers to
 the source operand and 'dst' refers to the value of the destination
 register.
 
+.. note:: BPF ISA is unique as it uses "Pseudo-C" notation for the assembly
+          instructions. In the table below, the column "name" specifies the
+          encoding names. Assembly instructions (as generated by compilers)
+          are specified in the description column for some cases. Description
+          of ``DIV/SDIV``, ``MOD/SMOD`` includes additional semantic logic,
+          not actual assembly.
+
 .. table:: Arithmetic instructions
 
   =====  =====  =======  ===================================================================================
-- 
2.53.0


  reply	other threads:[~2026-04-02 22:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 22:13 [PATCH v2 0/2] BPF documentation improvements Vineet Gupta
2026-04-02 22:13 ` Vineet Gupta [this message]
2026-04-02 22:13 ` [PATCH v2 2/2] bpf, doc: Improve MOV/MOVSX documentation and add examples Vineet Gupta
2026-04-03  5:27   ` bot+bpf-ci

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=20260402221339.1614989-2-vineet.gupta@linux.dev \
    --to=vineet.gupta@linux.dev \
    --cc=ast@kernel.org \
    --cc=bpf@gcc.gnu.org \
    --cc=bpf@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=jose.marchesi@oracle.com \
    --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