From nobody Thu Nov 28 03:54:12 2024 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59A5918A6A1 for ; Sat, 5 Oct 2024 19:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728158218; cv=none; b=M7XBOp5xSNwKh1Yfi7xsEX+3V698NRlIoxm9SMsNYf50Os/kCLmNUL3fDdtNU9VSZJyFv9c6Q+fh/LUxwaZR6HBeQnGWjqDGzGVh6+R2HOSIUSH6Wh4rMnHvdPR0uCW5OBkYFHdVKp9WQTrywA/eDKdjZRlvshu3cG+qIYgYohs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728158218; c=relaxed/simple; bh=udd5WlhhnmwqnkiIWTPOqQEmfxASluatpyr3EoOTRkk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=Y45dzGWEO6Isy1UIHrUTrDpbBFIxTOy+wR8IYkda8arIPgSbph06ZQHG2NxG79IGnaXT+daS64Ffff9LhqAJgeRWKQFeJJ9RRsVT1msvwb7b0X+P6S3YSdlQz+WBZ+MtRDQ9IykYCXPbfnrtZ+snu2roIUoqn2eLWWEkohlTdK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FvJzSbIO; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FvJzSbIO" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e25cc76cae1so4921330276.0 for ; Sat, 05 Oct 2024 12:56:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728158214; x=1728763014; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=LSL2ccbL1zMKXwe4tQXqPGcWrUHTWmz3veARUKGe9SA=; b=FvJzSbIOP869ukyWohO0qjsu07iV9QuxNvT3futPM3vorPG+CD9kNzaWy9+k96roAw XAKim42YdGAtLJSnkg41ubrpoVBRjW1MR/AXHkpnsafaX1kr3mT17BiFIF4qYEatsMOQ Q2lcyjgRvao1vLs/9H1Q17VOp9oF1sUjpllhFZHeM5GdG4BwqeIZRADqM0Ms2LNJPx8w IXqnovbbQ7rwDKja6V+jZYtf+JikDA4pQR+lgrEop2Yfal0BLwOB7doDi5cFPWByt8Hy F8IS1X8yNSdyzSh0r7sFCnKNtGjGVOzNJ/KaUi95LjrwfduseMfIoAvDuEdhzZRvHMpH FOHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728158214; x=1728763014; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LSL2ccbL1zMKXwe4tQXqPGcWrUHTWmz3veARUKGe9SA=; b=HTl780PjCwnJl13Ops6jtbBxKT2rdHhURkJh1R/lYdcYMoUUNAAtM6krJcl7MHP3hk eNhwSu7C2NBUcX13HJHeRDKr6/lXm5S5H9AXXPg1J1agpLonBceCmSOXYWyixEgy8VbU fzamte/WvssgHoo3/GD/q4BBgfZMlnGPuMOyurKPqrdZA2QpgKZKYDED93i96KWyt5gE +ZjFXMV/NPQ8rid2ST03c4ZqU1/6zNxIVTXgjZC8wCxKcAgK4pxtu2jNS/ODJ3ihJ7OR Tuf5B8xhjSGjsgr97yNcmBwSQjqkfnWL6wXV6B3hXBtmmXuS6QutLsass8NZ2nLh4jL0 yaUw== X-Forwarded-Encrypted: i=1; AJvYcCVV7yYWul/g1+g0rZ7z6q1Lx9RP7tkkDCuAwMCfnhGhMmrP8WSkd/UOJinl8tIT2oybGdm8U1sZ9TukjE0=@vger.kernel.org X-Gm-Message-State: AOJu0YxOgszbh6ahS9vZVdF264cZd2z4kF/RaSGSzT3UFSwiqreoDyNs fwK5ZN4XC8vKIVAdJ+wJzCd1dXF/l5RwyHUdfYIqH8+9B57PdN5Lez56oja6i7dFAYvwGXGzy+W 1xSjCnQ== X-Google-Smtp-Source: AGHT+IFqH49xvkBQa7keg1rzZuWU/08D0ii8FTpSBX6sVpAkmGWs4m8R5YhQwlrDd8JE/onJIqb9MBMS1dlP X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:4c2:5b4d:8797:7249]) (user=irogers job=sendgmr) by 2002:a25:6f05:0:b0:e20:cfc2:a326 with SMTP id 3f1490d57ef6-e28932a484bmr64009276.6.1728158214036; Sat, 05 Oct 2024 12:56:54 -0700 (PDT) Date: Sat, 5 Oct 2024 12:55:35 -0700 In-Reply-To: <20241005195541.380070-1-irogers@google.com> Message-Id: <20241005195541.380070-26-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241005195541.380070-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog Subject: [PATCH v2 25/31] perf riscv: Remove dwarf-regs.c and add dwarf-regs-table.h From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nick Terrell , "Steven Rostedt (Google)" , "Masami Hiramatsu (Google)" , Guilherme Amadio , Changbin Du , Daniel Bristot de Oliveira , Daniel Wagner , Aditya Gupta , Athira Rajeev , Masahiro Yamada , Kajol Jain , Huacai Chen , Bibo Mao , Anup Patel , Atish Patra , Shenlin Liang , Oliver Upton , "Steinar H. Gunderson" , "Dr. David Alan Gilbert" , Chen Pei , Dima Kogan , Yury Norov , Alexander Lobakin , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The file just provides the function get_arch_regstr, however, if in the only caller get_dwarf_regstr EM_HOST is used for the EM_NONE case, and the register table is provided in a header file, the function can never be called. So remove as dead code. Tidy up the EM_NONE cases for riscv in dwarf-regs.c. Signed-off-by: Ian Rogers --- .../dwarf-regs-table.h} | 32 ++++--------------- tools/perf/arch/riscv/util/Build | 1 - tools/perf/util/dwarf-regs.c | 7 ++-- tools/perf/util/include/dwarf-regs.h | 2 +- 4 files changed, 12 insertions(+), 30 deletions(-) rename tools/perf/arch/riscv/{util/dwarf-regs.c =3D> include/dwarf-regs-ta= ble.h} (56%) diff --git a/tools/perf/arch/riscv/util/dwarf-regs.c b/tools/perf/arch/risc= v/include/dwarf-regs-table.h similarity index 56% rename from tools/perf/arch/riscv/util/dwarf-regs.c rename to tools/perf/arch/riscv/include/dwarf-regs-table.h index a9c4402ae57e..a45b63a6d5a8 100644 --- a/tools/perf/arch/riscv/util/dwarf-regs.c +++ b/tools/perf/arch/riscv/include/dwarf-regs-table.h @@ -1,23 +1,10 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd. - * Mapping of DWARF debug register numbers into register names. - */ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifdef DEFINE_DWARF_REGSTR_TABLE +/* This is included in perf/util/dwarf-regs.c */ =20 -#include -#include /* for EINVAL */ -#include /* for strcmp */ -#include +#define REG_DWARFNUM_NAME(reg, idx) [idx] =3D "%" #reg =20 -struct regs_dwarfnum { - const char *name; - unsigned int dwarfnum; -}; - -#define REG_DWARFNUM_NAME(r, num) {.name =3D r, .dwarfnum =3D num} -#define REG_DWARFNUM_END {.name =3D NULL, .dwarfnum =3D 0} - -struct regs_dwarfnum riscv_dwarf_regs_table[] =3D { +static const char * const riscv_regstr_tbl[] =3D { REG_DWARFNUM_NAME("%zero", 0), REG_DWARFNUM_NAME("%ra", 1), REG_DWARFNUM_NAME("%sp", 2), @@ -50,13 +37,6 @@ struct regs_dwarfnum riscv_dwarf_regs_table[] =3D { REG_DWARFNUM_NAME("%t4", 29), REG_DWARFNUM_NAME("%t5", 30), REG_DWARFNUM_NAME("%t6", 31), - REG_DWARFNUM_END, }; =20 -#define RISCV_MAX_REGS ((sizeof(riscv_dwarf_regs_table) / \ - sizeof(riscv_dwarf_regs_table[0])) - 1) - -const char *get_arch_regstr(unsigned int n) -{ - return (n < RISCV_MAX_REGS) ? riscv_dwarf_regs_table[n].name : NULL; -} +#endif diff --git a/tools/perf/arch/riscv/util/Build b/tools/perf/arch/riscv/util/= Build index 8f93091b8345..58a672246024 100644 --- a/tools/perf/arch/riscv/util/Build +++ b/tools/perf/arch/riscv/util/Build @@ -2,5 +2,4 @@ perf-util-y +=3D perf_regs.o perf-util-y +=3D header.o =20 perf-util-$(CONFIG_LIBTRACEEVENT) +=3D kvm-stat.o -perf-util-$(CONFIG_LIBDW) +=3D dwarf-regs.o perf-util-$(CONFIG_LIBDW_DWARF_UNWIND) +=3D unwind-libdw.o diff --git a/tools/perf/util/dwarf-regs.c b/tools/perf/util/dwarf-regs.c index 3d98c2bf6035..2c6b197556dd 100644 --- a/tools/perf/util/dwarf-regs.c +++ b/tools/perf/util/dwarf-regs.c @@ -20,6 +20,7 @@ #include "../arch/arm64/include/dwarf-regs-table.h" #include "../arch/sh/include/dwarf-regs-table.h" #include "../arch/powerpc/include/dwarf-regs-table.h" +#include "../arch/riscv/include/dwarf-regs-table.h" #include "../arch/s390/include/dwarf-regs-table.h" #include "../arch/sparc/include/dwarf-regs-table.h" #include "../arch/xtensa/include/dwarf-regs-table.h" @@ -33,7 +34,7 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int= machine, unsigned int { #if EM_HOST =3D=3D EM_X86_64 || EM_HOST =3D=3D EM_386 || EM_HOST =3D=3D EM= _AARCH64 || EM_HOST =3D=3D EM_ARM \ || EM_HOST =3D=3D EM_CSKY || EM_HOST =3D=3D EM_LOONGARCH || EM_HOST = =3D=3D EM_MIPS || EM_HOST =3D=3D EM_PPC \ - || EM_HOST =3D=3D EM_PPC64 + || EM_HOST =3D=3D EM_PPC64 || EM_HOST =3D=3D EM_RISCV if (machine =3D=3D EM_NONE) { /* Generic arch - use host arch */ machine =3D EM_HOST; @@ -42,7 +43,7 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int= machine, unsigned int switch (machine) { #if EM_HOST !=3D EM_X86_64 && EM_HOST !=3D EM_386 && EM_HOST !=3D EM_AARCH= 64 && EM_HOST !=3D EM_ARM \ && EM_HOST !=3D EM_CSKY && EM_HOST !=3D EM_LOONGARCH && EM_HOST !=3D E= M_MIPS && EM_HOST !=3D EM_PPC \ - && EM_HOST !=3D EM_PPC64 + && EM_HOST !=3D EM_PPC64 && EM_HOST !=3D EM_RISCV case EM_NONE: /* Generic arch - use host arch */ return get_arch_regstr(n); #endif @@ -63,6 +64,8 @@ const char *get_dwarf_regstr(unsigned int n, unsigned int= machine, unsigned int case EM_PPC: case EM_PPC64: return __get_dwarf_regstr(powerpc_regstr_tbl, n); + case EM_RISCV: + return __get_dwarf_regstr(riscv_regstr_tbl, n); case EM_SPARC: case EM_SPARCV9: return __get_dwarf_regstr(sparc_regstr_tbl, n); diff --git a/tools/perf/util/include/dwarf-regs.h b/tools/perf/util/include= /dwarf-regs.h index 1763280855ce..35f4f33205da 100644 --- a/tools/perf/util/include/dwarf-regs.h +++ b/tools/perf/util/include/dwarf-regs.h @@ -81,7 +81,7 @@ #ifdef HAVE_LIBDW_SUPPORT #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) &&= !defined(__arm__) \ && !defined(__loongarch__) && !defined(__mips__) && !defined(__powerpc= __) \ - && !defined(__powerpc64__) + && !defined(__powerpc64__) && !defined(__riscv__) const char *get_arch_regstr(unsigned int n); #endif =20 --=20 2.47.0.rc0.187.ge670bccf7e-goog