linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: irogers@google.com, maddy@linux.ibm.com, kjain@linux.ibm.com,
	adrian.hunter@intel.com, acme@kernel.org,
	linux-perf-users@vger.kernel.org, jolsa@kernel.org,
	namhyung@kernel.org, disgoel@linux.vnet.ibm.com,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/3] tools/erf/util/annotate: Set register_char and memory_ref_char for powerpc
Date: Sat, 9 Mar 2024 11:43:26 -0600	[thread overview]
Message-ID: <20240309174326.GU19790@gate.crashing.org> (raw)
In-Reply-To: <20240309072513.9418-3-atrajeev@linux.vnet.ibm.com>

All instructions with a primary opcode from 32 to 63 are memory insns,
and no others.  It's trivial to see whether it is a load or store, too
(just bit 3 of the insn).  Trying to parse disassembled code is much
harder, and you easily make some mistakes here.

On Sat, Mar 09, 2024 at 12:55:12PM +0530, Athira Rajeev wrote:
> To identify if the instruction has any memory reference,
> "memory_ref_char" field needs to be set for specific architecture.
> Example memory instruction:
> lwz     r10,0(r9)
> 
> Here "(" is the memory_ref_char. Set this as part of arch->objdump

What about "lwzx r10,0,r19", semantically exactly the same instruction?
There is no paren in there.  Not all instructions using parens are
memory insns, either, not in assembler code at least.

> To get register number and access offset from the given instruction,
> arch->objdump.register_char is used. In case of powerpc, the register
> char is "r" (since reg names are r0 to r31). Hence set register_char
> as "r".

cr0..cr7
r0..r31
f0..f31
v0..v31
vs0..vs63
and many other spellings.  Plain "0..63" is also fine.

The "0" in my lwzx example is a register field as well (and it stands
for "no register", not for "r0").  Called "(RA|0)" usually (incidentally,
see the parens there as well, oh joy).

Don't you have the binary code here as well, not just a disassembled
representation of it?  It is way easier to just use that, and you'll get
much better results that way :-)


Segher

  reply	other threads:[~2024-03-09 17:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09  7:25 [PATCH 0/3] Add data type profiling support for powerpc Athira Rajeev
2024-03-09  7:25 ` [PATCH 1/3] tools/perf/arch/powerpc: Add load/store in powerpc annotate instructions for data type profling Athira Rajeev
2024-03-09  9:48   ` Christophe Leroy
2024-03-18 11:01     ` Athira Rajeev
2024-03-09  7:25 ` [PATCH 2/3] tools/erf/util/annotate: Set register_char and memory_ref_char for powerpc Athira Rajeev
2024-03-09 17:43   ` Segher Boessenkool [this message]
2024-03-18 11:33     ` Athira Rajeev
2024-03-09  7:25 ` [PATCH 3/3] tools/perf/arch/powerc: Add get_arch_regnum " Athira Rajeev
2024-03-09  9:54   ` Christophe Leroy
2024-03-18 11:00     ` Athira Rajeev
2024-03-26  9:35   ` Tiezhu Yang
2024-04-01 21:46     ` Namhyung Kim
2024-04-01 21:57 ` [PATCH 0/3] Add data type profiling support " Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2024-03-09  5:51 Athira Rajeev
2024-03-09  5:51 ` [PATCH 2/3] tools/erf/util/annotate: Set register_char and memory_ref_char " Athira Rajeev

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=20240309174326.GU19790@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=disgoel@linux.vnet.ibm.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kjain@linux.ibm.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=namhyung@kernel.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 NNTP newsgroup(s).