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 1/2] bpf, doc: Clarify Pseudo-C notation and w vs r register usage
Date: Wed,  1 Apr 2026 10:01:14 -0700	[thread overview]
Message-ID: <20260401170115.495836-2-vineet.gupta@linux.dev> (raw)
In-Reply-To: <20260401170115.495836-1-vineet.gupta@linux.dev>

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

Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
---
 .../bpf/standardization/instruction-set.rst      | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/Documentation/bpf/standardization/instruction-set.rst b/Documentation/bpf/standardization/instruction-set.rst
index 39c74611752b..fd688c5d3f04 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
-base64 conformance group unless noted otherwise.
-The 'code' field encodes the operation as below, where 'src' refers 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 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 actually specifies
+      the encodings. Assembly instructions (as generated by compilers) are
+      specified in the description column for some cases. Description of
+      ``?DIV``, ``?MOD`` includes additional logic part of semantics not
+      actual assembly.
+
 .. table:: Arithmetic instructions
 
   =====  =====  =======  ===================================================================================
-- 
2.53.0


  reply	other threads:[~2026-04-01 17:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01 17:01 [PATCH 0/2] BPF documentation improvements Vineet Gupta
2026-04-01 17:01 ` Vineet Gupta [this message]
2026-04-01 17:59   ` [PATCH 1/2] bpf, doc: Clarify Pseudo-C notation and w vs r register usage bot+bpf-ci
2026-04-01 18:10     ` Vineet Gupta
2026-04-01 17:01 ` [PATCH 2/2] bpf, doc: Improve MOV* documentation Vineet Gupta
2026-04-01 17:59   ` bot+bpf-ci
2026-04-01 18:28     ` Vineet Gupta

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=20260401170115.495836-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