Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1498347lqt; Sat, 8 Jun 2024 00:08:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWvHq1B/Pxg2Iu2Y/6dLoW8PUCPjUquHnQ6uXWqAZYby4ps0jMqLnD8MkBPxwmf66wPhkxiyZ4HbK+jZkKT79vBRbhmqLmDPyrIcWgMkg== X-Google-Smtp-Source: AGHT+IGFaQrkMmDwoiZwPEziFbxVfRgNerDCd1ZeO9LcWGo6Qtyqhvv2LLJ+ToRXdCYltJ8HAx75 X-Received: by 2002:a05:620a:2956:b0:795:54d5:300d with SMTP id af79cd13be357-79554d53140mr90763285a.12.1717830531545; Sat, 08 Jun 2024 00:08:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717830531; cv=pass; d=google.com; s=arc-20160816; b=x6Or49xAoxTLcQ+r1sLtSRO7/Nfoyjizg/QgZEcnch6Dk5/flufI9LH9MEdw7aUnQ+ DEkpk24WVhE8+9AWfGc0m29Nk4Z6fA6e8p/LPjlgmO/Y3aG59QxkW8C0rlJFIfpXl348 1c3JYQ8QwTJGgs0BMSbZNzOHMlN/sPADXMu3FhU9V3lNu6iyH0igE/Jev9S0SvAMKWLe fM2Y9iyzQvc4fs4RmGfDjiOyJHSEdaZRGd16OTr/AbrKSrtPy8P0MEDAty7TLMq943ch R/351B4Y3pgyzVH8pHq78H9EiENDCto+X74IKMhQ4ha1YHQj5Je7zuLnZk2icQtmxp1i hbdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=01W8QivgVJI8K1/wJeJ50OhZ+tmbZlJDl+KonnRamhg=; fh=KVQmWjzmUKrFxGvUWyUohTiW2D21aptx6b1PDFMxXWs=; b=ePz1MZ/1108Y4uQbAgamus3tVX+M3SPtHysCIvdHphK6+/Z/qGWj8DT/cYlIoNvk2j ZvrqdJOtRgUpksF0eg1dxnIorTieDXT/wSXnwrNL7pZsegzbnjD7PjblDJKvKhZX+b/B KwJfhut515FmmFfQ8XmENfmeILAIFB5QH8eO6lhHFirccdZwMk7s01xfNWdG1XKwLyGT 48Z6NpkKbkisxPZex3cRXuz7pdmSIwUcbuVU9X2Fu9ZC2+dBE8+ktai/fc7E2Tkrf4cp a4D0jgi9EtXoD3mD2q78D7ZMdtmA/4eREeFwULnQ8SR4CdPWm5IEmGMzinuj4jD9T8V2 jEwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AljNxu1V; arc=pass (i=1 dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.vnet.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-206920-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206920-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-79533306e09si598070685a.498.2024.06.08.00.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jun 2024 00:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206920-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AljNxu1V; arc=pass (i=1 dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.vnet.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-206920-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206920-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 367281C21AF0 for ; Sat, 8 Jun 2024 07:08:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EFB8176ABA; Sat, 8 Jun 2024 07:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="AljNxu1V" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAC412E84A; Sat, 8 Jun 2024 07:08:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717830523; cv=none; b=qolm+RzV4MaEaltPMGZAf+2vAOU2S1xR5viSgrxNAzbTOylQbn30ECG6w1acS6FQeXkFh7G9H6gb2ejx0xe2sjuJdX8bINnMVBSZCS8I8VUtzM0xY7CVwPy7jAmycOURQa+2rkeFf6PQwObeJ215wyNXO5aU+HWMb7JueWFTjc4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717830523; c=relaxed/simple; bh=EPUkZlEoIyQkKS+8tmuGIutdgXQS2g0rbH3PEoGq4TM=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=bqcWiRYx4bNBjsiDHZdrwF0vZ+A+7xGve/XRctF6imnKRH8VgiPYFVRGHLtOQYZ42ey2nDrJVbEYZOKalZ1IrC1cziQsknw8oZYMRZIyNUD6rU/bY1N3g6FnBRal5OJHKvsLUSUBFajGYS1Ib0TtA6O3yf0W1EdEYMhhTx4txZA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com; spf=none smtp.mailfrom=linux.vnet.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=AljNxu1V; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.vnet.ibm.com Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45864YXd000319; Sat, 8 Jun 2024 07:08:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=pp1; bh=0 1W8QivgVJI8K1/wJeJ50OhZ+tmbZlJDl+KonnRamhg=; b=AljNxu1V4bRyy4wv0 v8guA2vc1LjPhFrkEKltmyNZXg1Pz4qXInNnUeHnQdGkwVuVZeTzikD+F9MA5h1S cpUp8pMZDndPGVFh5Uk3KSZsNxMRgL2H5+kEGlX3MuEin4b8QuWWoNLKUJCz+Slv OaEn47OWruEAKua7ndn369yFHPaSqqmivbq/aq5bSBv34a36BC2o1bmyoulfXZDY XmduIRNWwpHL+lPP7vf3+VC3Wl6ZX5Gm4Z4KelTGd4uOSlcUZI+6SS2nxhlhPy9V VgIGPTG4WYnxNtV9qYnHUb5XmZfJlIsRZ4FwiGRM6cuCwLkCbToOB0RSqZ4U/I3u MN8Ng== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ymhj303r3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 08 Jun 2024 07:08:30 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45878UlI021752; Sat, 8 Jun 2024 07:08:30 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ymhj303r0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 08 Jun 2024 07:08:30 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4583gLAF025354; Sat, 8 Jun 2024 07:08:28 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ymfmp8rrt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 08 Jun 2024 07:08:28 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45878N4w42533254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 8 Jun 2024 07:08:25 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 38C1C20043; Sat, 8 Jun 2024 07:08:23 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5B7C820040; Sat, 8 Jun 2024 07:08:20 +0000 (GMT) Received: from smtpclient.apple (unknown [9.43.125.209]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTPS; Sat, 8 Jun 2024 07:08:20 +0000 (GMT) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: [PATCH V3 06/14] tools/perf: Update parameters for reg extract functions to use raw instruction on powerpc From: Athira Rajeev In-Reply-To: Date: Sat, 8 Jun 2024 12:38:08 +0530 Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Ian Rogers , Segher Boessenkool , christophe.leroy@csgroup.eu, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, akanksha@linux.ibm.com, maddy@linux.ibm.com, kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com Content-Transfer-Encoding: quoted-printable Message-Id: <3AAD3E17-571C-4775-BF4B-34EDFCC94079@linux.vnet.ibm.com> References: <20240601060941.13692-1-atrajeev@linux.vnet.ibm.com> <20240601060941.13692-7-atrajeev@linux.vnet.ibm.com> To: Namhyung Kim X-Mailer: Apple Mail (2.3774.500.171.1.1) X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 50XXHJ8SRxj124TZpET4tMKoQvGz6n8E X-Proofpoint-GUID: UDnBHGh_Z---__2CDh_aH9ZvZsnhBg5u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-08_01,2024-06-06_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 impostorscore=0 bulkscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406080049 > On 6 Jun 2024, at 12:22=E2=80=AFPM, Namhyung Kim = wrote: >=20 > On Sat, Jun 01, 2024 at 11:39:33AM +0530, Athira Rajeev wrote: >> Use the raw instruction code and macros to identify memory = instructions, >> extract register fields and also offset. The implementation addresses >> the D-form, X-form, DS-form instructions. Two main functions are = added. >> New parse function "load_store__parse" as instruction ops parser for >> memory instructions. Unlink other parser (like mov__parse), this = parser >> fills in the "raw_insn" field for source/target and new added = "mem_ref" >> field. Also set if it is multi_regs and opcode as well. No other = fields >> are set because, here there is no need to parse the disassembled >> code and arch specific macros will take care of extracting offset and >> regs which is easier and will be precise. >>=20 >> In powerpc, all instructions with a primary opcode from 32 to 63 >> are memory instructions. Update "ins__find" function to have = "raw_insn" >> also as a parameter. Don't use the "extract_reg_offset", instead use >> newly added function "get_arch_regs" which will set these fields: = reg1, >> reg2, offset depending of where it is source or target ops. >>=20 >> Signed-off-by: Athira Rajeev >> --- >> .../perf/arch/powerpc/annotate/instructions.c | 16 +++++ >> tools/perf/arch/powerpc/util/dwarf-regs.c | 44 +++++++++++++ >> tools/perf/util/annotate.c | 25 +++++++- >> tools/perf/util/disasm.c | 64 = +++++++++++++++++-- >> tools/perf/util/disasm.h | 4 +- >> tools/perf/util/include/dwarf-regs.h | 3 + >> 6 files changed, 147 insertions(+), 9 deletions(-) >>=20 >> diff --git a/tools/perf/arch/powerpc/annotate/instructions.c = b/tools/perf/arch/powerpc/annotate/instructions.c >> index d57fd023ef9c..10fea5e5cf4c 100644 >> --- a/tools/perf/arch/powerpc/annotate/instructions.c >> +++ b/tools/perf/arch/powerpc/annotate/instructions.c >> @@ -49,6 +49,22 @@ static struct ins_ops = *powerpc__associate_instruction_ops(struct arch *arch, con >> return ops; >> } >>=20 >> +#define PPC_OP(op) (((op) >> 26) & 0x3F) >> + >> +static struct ins_ops *check_ppc_insn(int raw_insn) >> +{ >> + int opcode =3D PPC_OP(raw_insn); >> + >> + /* >> + * Instructions with opcode 32 to 63 are memory >> + * instructions in powerpc >> + */ >> + if ((opcode & 0x20)) >> + return &load_store_ops; >> + >> + return NULL; >> +} >> + >> static int powerpc__annotate_init(struct arch *arch, char *cpuid = __maybe_unused) >> { >> if (!arch->initialized) { >> diff --git a/tools/perf/arch/powerpc/util/dwarf-regs.c = b/tools/perf/arch/powerpc/util/dwarf-regs.c >> index 430623ca5612..38b74fa01d8b 100644 >> --- a/tools/perf/arch/powerpc/util/dwarf-regs.c >> +++ b/tools/perf/arch/powerpc/util/dwarf-regs.c >> @@ -107,3 +107,47 @@ int regs_query_register_offset(const char *name) >> #define PPC_DS(DS) ((DS) & 0xfffc) >> #define OP_LD 58 >> #define OP_STD 62 >> + >> +static int get_source_reg(unsigned int raw_insn) >> +{ >> + return PPC_RA(raw_insn); >> +} >> + >> +static int get_target_reg(unsigned int raw_insn) >> +{ >> + return PPC_RT(raw_insn); >> +} >> + >> +static int get_offset_opcode(int raw_insn __maybe_unused) >=20 > The argument is used below, no need for __maybe_unused. >=20 >> +{ >> + int opcode =3D PPC_OP(raw_insn); >> + >> + /* DS- form */ >> + if ((opcode =3D=3D OP_LD) || (opcode =3D=3D OP_STD)) >> + return PPC_DS(raw_insn); >> + else >> + return PPC_D(raw_insn); >> +} >> + >> +/* >> + * Fills the required fields for op_loc depending on if it >> + * is a source or target. >> + * D form: ins RT,D(RA) -> src_reg1 =3D RA, offset =3D D, dst_reg1 =3D= RT >> + * DS form: ins RT,DS(RA) -> src_reg1 =3D RA, offset =3D DS, = dst_reg1 =3D RT >> + * X form: ins RT,RA,RB -> src_reg1 =3D RA, src_reg2 =3D RB, = dst_reg1 =3D RT >> + */ >> +void get_arch_regs(int raw_insn __maybe_unused, int is_source = __maybe_unused, >> + struct annotated_op_loc *op_loc __maybe_unused) >=20 > Ditto. Yes, right. Will fix it both the places. Thanks Athira >=20 > Thanks, > Namhyung >=20 >=20 >> +{ >> + if (is_source) >> + op_loc->reg1 =3D get_source_reg(raw_insn); >> + else >> + op_loc->reg1 =3D get_target_reg(raw_insn); >> + >> + if (op_loc->multi_regs) >> + op_loc->reg2 =3D PPC_RB(raw_insn); >> + >> + /* TODO: Implement offset handling for X Form */ >> + if ((op_loc->mem_ref) && (PPC_OP(raw_insn) !=3D 31)) >> + op_loc->offset =3D get_offset_opcode(raw_insn); >> +} >> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c >> index 1451caf25e77..2b8cc759ae35 100644 >> --- a/tools/perf/util/annotate.c >> +++ b/tools/perf/util/annotate.c >> @@ -2079,6 +2079,12 @@ static int extract_reg_offset(struct arch = *arch, const char *str, >> return 0; >> } >>=20 >> +__weak void get_arch_regs(int raw_insn __maybe_unused, int is_source = __maybe_unused, >> + struct annotated_op_loc *op_loc __maybe_unused) >> +{ >> + return; >> +} >> + >> /** >> * annotate_get_insn_location - Get location of instruction >> * @arch: the architecture info >> @@ -2123,20 +2129,33 @@ int annotate_get_insn_location(struct arch = *arch, struct disasm_line *dl, >> for_each_insn_op_loc(loc, i, op_loc) { >> const char *insn_str =3D ops->source.raw; >> bool multi_regs =3D ops->source.multi_regs; >> + bool mem_ref =3D ops->source.mem_ref; >>=20 >> if (i =3D=3D INSN_OP_TARGET) { >> insn_str =3D ops->target.raw; >> multi_regs =3D ops->target.multi_regs; >> + mem_ref =3D ops->target.mem_ref; >> } >>=20 >> /* Invalidate the register by default */ >> op_loc->reg1 =3D -1; >> op_loc->reg2 =3D -1; >>=20 >> - if (insn_str =3D=3D NULL) >> - continue; >> + if (insn_str =3D=3D NULL) { >> + if (!arch__is(arch, "powerpc")) >> + continue; >> + } >>=20 >> - if (strchr(insn_str, arch->objdump.memory_ref_char)) { >> + /* >> + * For powerpc, call get_arch_regs function which extracts the >> + * required fields for op_loc, ie reg1, reg2, offset from the >> + * raw instruction. >> + */ >> + if (arch__is(arch, "powerpc")) { >> + op_loc->mem_ref =3D mem_ref; >> + op_loc->multi_regs =3D multi_regs; >> + get_arch_regs(ops->raw_insn, !i, op_loc); >> + } else if (strchr(insn_str, arch->objdump.memory_ref_char)) { >> op_loc->mem_ref =3D true; >> op_loc->multi_regs =3D multi_regs; >> extract_reg_offset(arch, insn_str, op_loc); >> diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c >> index 61f0f1656f82..252cb0d1f5d1 100644 >> --- a/tools/perf/util/disasm.c >> +++ b/tools/perf/util/disasm.c >> @@ -37,6 +37,7 @@ static struct ins_ops mov_ops; >> static struct ins_ops nop_ops; >> static struct ins_ops lock_ops; >> static struct ins_ops ret_ops; >> +static struct ins_ops load_store_ops; >>=20 >> static int jump__scnprintf(struct ins *ins, char *bf, size_t size, >> struct ins_operands *ops, int max_ins_name); >> @@ -517,7 +518,7 @@ static int lock__parse(struct arch *arch, struct = ins_operands *ops, struct map_s >> if (disasm_line__parse(ops->raw, &ops->locked.ins.name, = &ops->locked.ops->raw) < 0) >> goto out_free_ops; >>=20 >> - ops->locked.ins.ops =3D ins__find(arch, ops->locked.ins.name); >> + ops->locked.ins.ops =3D ins__find(arch, ops->locked.ins.name, 0); >>=20 >> if (ops->locked.ins.ops =3D=3D NULL) >> goto out_free_ops; >> @@ -672,6 +673,47 @@ static struct ins_ops mov_ops =3D { >> .scnprintf =3D mov__scnprintf, >> }; >>=20 >> +static int load_store__scnprintf(struct ins *ins, char *bf, size_t = size, >> + struct ins_operands *ops, int max_ins_name) >> +{ >> + return scnprintf(bf, size, "%-*s %s", max_ins_name, ins->name, >> + ops->raw); >> +} >> + >> +/* >> + * Sets the fields: "raw_insn", opcode, multi_regs and "mem_ref". >> + * "mem_ref" is set for ops->source which is later used to >> + * fill the objdump->memory_ref-char field. This ops is currently >> + * used by powerpc and since binary instruction code is used to >> + * extract opcode, regs and offset, no other parsing is needed here >> + */ >> +static int load_store__parse(struct arch *arch __maybe_unused, = struct ins_operands *ops, >> + struct map_symbol *ms __maybe_unused) >> +{ >> + ops->source.raw_insn =3D ops->raw_insn; >> + ops->source.mem_ref =3D true; >> + ops->source.opcode =3D ops->opcode; >> + ops->source.multi_regs =3D false; >> + >> + if (!ops->source.raw_insn) >> + return -1; >> + >> + ops->target.raw_insn =3D ops->raw_insn; >> + ops->target.mem_ref =3D false; >> + ops->target.multi_regs =3D false; >> + ops->target.opcode =3D ops->opcode; >> + >> + if (!ops->target.raw_insn) >> + return -1; >> + >> + return 0; >> +} >> + >> +static struct ins_ops load_store_ops =3D { >> + .parse =3D load_store__parse, >> + .scnprintf =3D load_store__scnprintf, >> +}; >> + >> static int dec__parse(struct arch *arch __maybe_unused, struct = ins_operands *ops, struct map_symbol *ms __maybe_unused) >> { >> char *target, *comment, *s, prev; >> @@ -762,11 +804,23 @@ static void ins__sort(struct arch *arch) >> qsort(arch->instructions, nmemb, sizeof(struct ins), ins__cmp); >> } >>=20 >> -static struct ins_ops *__ins__find(struct arch *arch, const char = *name) >> +static struct ins_ops *__ins__find(struct arch *arch, const char = *name, int raw_insn) >> { >> struct ins *ins; >> const int nmemb =3D arch->nr_instructions; >>=20 >> + if (arch__is(arch, "powerpc")) { >> + /* >> + * For powerpc, identify the instruction ops >> + * from the opcode using raw_insn. >> + */ >> + struct ins_ops *ops; >> + >> + ops =3D check_ppc_insn(raw_insn); >> + if (ops) >> + return ops; >> + } >> + >> if (!arch->sorted_instructions) { >> ins__sort(arch); >> arch->sorted_instructions =3D true; >> @@ -796,9 +850,9 @@ static struct ins_ops *__ins__find(struct arch = *arch, const char *name) >> return ins ? ins->ops : NULL; >> } >>=20 >> -struct ins_ops *ins__find(struct arch *arch, const char *name) >> +struct ins_ops *ins__find(struct arch *arch, const char *name, int = raw_insn) >> { >> - struct ins_ops *ops =3D __ins__find(arch, name); >> + struct ins_ops *ops =3D __ins__find(arch, name, raw_insn); >>=20 >> if (!ops && arch->associate_instruction_ops) >> ops =3D arch->associate_instruction_ops(arch, name); >> @@ -808,7 +862,7 @@ struct ins_ops *ins__find(struct arch *arch, = const char *name) >>=20 >> static void disasm_line__init_ins(struct disasm_line *dl, struct arch = *arch, struct map_symbol *ms) >> { >> - dl->ins.ops =3D ins__find(arch, dl->ins.name); >> + dl->ins.ops =3D ins__find(arch, dl->ins.name, dl->ops.raw_insn); >>=20 >> if (!dl->ins.ops) >> return; >> diff --git a/tools/perf/util/disasm.h b/tools/perf/util/disasm.h >> index a391e1bb81f7..831ebcc329cd 100644 >> --- a/tools/perf/util/disasm.h >> +++ b/tools/perf/util/disasm.h >> @@ -62,6 +62,7 @@ struct ins_operands { >> bool offset_avail; >> bool outside; >> bool multi_regs; >> + bool mem_ref; >> } target; >> union { >> struct { >> @@ -71,6 +72,7 @@ struct ins_operands { >> int raw_insn; >> u64 addr; >> bool multi_regs; >> + bool mem_ref; >> } source; >> struct { >> struct ins ins; >> @@ -104,7 +106,7 @@ struct annotate_args { >> struct arch *arch__find(const char *name); >> bool arch__is(struct arch *arch, const char *name); >>=20 >> -struct ins_ops *ins__find(struct arch *arch, const char *name); >> +struct ins_ops *ins__find(struct arch *arch, const char *name, int = raw_insn); >> int ins__scnprintf(struct ins *ins, char *bf, size_t size, >> struct ins_operands *ops, int max_ins_name); >>=20 >> diff --git a/tools/perf/util/include/dwarf-regs.h = b/tools/perf/util/include/dwarf-regs.h >> index 01fb25a1150a..7ea39362ecaf 100644 >> --- a/tools/perf/util/include/dwarf-regs.h >> +++ b/tools/perf/util/include/dwarf-regs.h >> @@ -1,6 +1,7 @@ >> /* SPDX-License-Identifier: GPL-2.0 */ >> #ifndef _PERF_DWARF_REGS_H_ >> #define _PERF_DWARF_REGS_H_ >> +#include "annotate.h" >>=20 >> #define DWARF_REG_PC 0xd3af9c /* random number */ >> #define DWARF_REG_FB 0xd3affb /* random number */ >> @@ -31,6 +32,8 @@ static inline int get_dwarf_regnum(const char *name = __maybe_unused, >> } >> #endif >>=20 >> +void get_arch_regs(int raw_insn, int is_source, struct = annotated_op_loc *op_loc); >> + >> #ifdef HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET >> /* >> * Arch should support fetching the offset of a register in pt_regs >> --=20 >> 2.43.0