public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* Register encoding in assembly for load/store instructions
@ 2023-07-25 17:29 Jose E. Marchesi
  2023-07-25 18:47 ` Yonghong Song
  0 siblings, 1 reply; 16+ messages in thread
From: Jose E. Marchesi @ 2023-07-25 17:29 UTC (permalink / raw)
  To: Yonghong Song; +Cc: bpf


Hello Yonghong.

We have noticed that the llvm disassembler uses different notations for
registers in load and store instructions, depending somehow on the width
of the data being loaded or stored.

For example, this is an excerpt from the assembler-disassembler.s test
file in llvm:

  // Note: For the group below w1 is used as a destination for sizes u8, u16, u32.
  //       This is disassembler quirk, but is technically not wrong, as there are
  //       no different encodings for 'r1 = load' vs 'w1 = load'.
  //
  // CHECK: 71 21 2a 00 00 00 00 00	w1 = *(u8 *)(r2 + 0x2a)
  // CHECK: 69 21 2a 00 00 00 00 00	w1 = *(u16 *)(r2 + 0x2a)
  // CHECK: 61 21 2a 00 00 00 00 00	w1 = *(u32 *)(r2 + 0x2a)
  // CHECK: 79 21 2a 00 00 00 00 00	r1 = *(u64 *)(r2 + 0x2a)
  r1 = *(u8*)(r2 + 42)
  r1 = *(u16*)(r2 + 42)
  r1 = *(u32*)(r2 + 42)
  r1 = *(u64*)(r2 + 42)

The comment there clarifies that the usage of wN instead of rN in the
u8, u16 and u32 cases is a "disassembler quirk".

Anyway, the problem is that it seems that `clang -S' actually emits
these forms with wN.

Is that intended?

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-07-28 23:25 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-25 17:29 Register encoding in assembly for load/store instructions Jose E. Marchesi
2023-07-25 18:47 ` Yonghong Song
2023-07-25 18:56   ` Jose E. Marchesi
2023-07-25 19:11     ` Jose E. Marchesi
2023-07-25 19:59       ` Yonghong Song
2023-07-25 19:45     ` Yonghong Song
2023-07-25 20:09       ` Jose E. Marchesi
2023-07-25 22:10         ` Yonghong Song
2023-07-25 22:26           ` Jose E. Marchesi
2023-07-26  0:31             ` Alexei Starovoitov
2023-07-26  0:39               ` Eduard Zingerman
2023-07-26  4:16                 ` Yonghong Song
2023-07-26 14:41                   ` Eduard Zingerman
2023-07-28 16:58                   ` Eduard Zingerman
2023-07-28 21:29                     ` Alexei Starovoitov
2023-07-28 23:25                     ` Yonghong Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox