Commit 3d06db9b authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

perf regs: Refactor use of arch__sample_reg_masks() to perf_reg_name()



arch__sample_reg_masks isn't supported on ARM(32), csky, loongarch,
MIPS, RISC-V and s390.

The table returned by the function just has the name of a register
paired with the corresponding sample_regs_user mask value.

For a given perf register we can compute the name with perf_reg_name and
the mask is just 1 left-shifted by the perf register number.

Change __parse_regs to use this method for finding registers rather than
arch__sample_reg_masks, thereby adding __parse_regs support for ARM(32),
csky, loongarch, MIPS, RISC-V and s390.

As arch__sample_reg_masks is then unused, remove the now unneeded
declarations.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarThomas Richter <tmricht@linux.ibm.com>
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Chun-Tse Shao <ctshao@google.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Haibo Xu <haibo1.xu@intel.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Krzysztof Łopatowski <krzysztof.m.lopatowski@gmail.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sergei Trofimovich <slyich@gmail.com>
Cc: Shimin Guo <shimin.guo@skydio.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f0d98c78
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -2,10 +2,6 @@
#include "perf_regs.h"
#include "../../../util/perf_regs.h"

static const struct sample_reg sample_reg_masks[] = {
	SMPL_REG_END
};

uint64_t arch__intr_reg_mask(void)
{
	return PERF_REGS_MASK;
@@ -15,8 +11,3 @@ uint64_t arch__user_reg_mask(void)
{
	return PERF_REGS_MASK;
}

const struct sample_reg *arch__sample_reg_masks(void)
{
	return sample_reg_masks;
}
+4 −10
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include "debug.h"
#include "symbol.h"
#include "callchain.h"
#include "callchain.h" // prototype of arch__add_leaf_frame_record_opts
#include "perf_regs.h"
#include "record.h"
#include "util/perf_regs.h"

#define SMPL_REG_MASK(b) (1ULL << (b))

void arch__add_leaf_frame_record_opts(struct record_opts *opts)
{
	const struct sample_reg *sample_reg_masks = arch__sample_reg_masks();

	opts->sample_user_regs |= sample_reg_masks[PERF_REG_ARM64_LR].mask;
	opts->sample_user_regs |= SMPL_REG_MASK(PERF_REG_ARM64_LR);
}
+2 −43
Original line number Diff line number Diff line
@@ -12,48 +12,12 @@
#include "../../../util/event.h"
#include "../../../util/perf_regs.h"

#define SMPL_REG_MASK(b) (1ULL << (b))

#ifndef HWCAP_SVE
#define HWCAP_SVE	(1 << 22)
#endif

static const struct sample_reg sample_reg_masks[] = {
	SMPL_REG(x0, PERF_REG_ARM64_X0),
	SMPL_REG(x1, PERF_REG_ARM64_X1),
	SMPL_REG(x2, PERF_REG_ARM64_X2),
	SMPL_REG(x3, PERF_REG_ARM64_X3),
	SMPL_REG(x4, PERF_REG_ARM64_X4),
	SMPL_REG(x5, PERF_REG_ARM64_X5),
	SMPL_REG(x6, PERF_REG_ARM64_X6),
	SMPL_REG(x7, PERF_REG_ARM64_X7),
	SMPL_REG(x8, PERF_REG_ARM64_X8),
	SMPL_REG(x9, PERF_REG_ARM64_X9),
	SMPL_REG(x10, PERF_REG_ARM64_X10),
	SMPL_REG(x11, PERF_REG_ARM64_X11),
	SMPL_REG(x12, PERF_REG_ARM64_X12),
	SMPL_REG(x13, PERF_REG_ARM64_X13),
	SMPL_REG(x14, PERF_REG_ARM64_X14),
	SMPL_REG(x15, PERF_REG_ARM64_X15),
	SMPL_REG(x16, PERF_REG_ARM64_X16),
	SMPL_REG(x17, PERF_REG_ARM64_X17),
	SMPL_REG(x18, PERF_REG_ARM64_X18),
	SMPL_REG(x19, PERF_REG_ARM64_X19),
	SMPL_REG(x20, PERF_REG_ARM64_X20),
	SMPL_REG(x21, PERF_REG_ARM64_X21),
	SMPL_REG(x22, PERF_REG_ARM64_X22),
	SMPL_REG(x23, PERF_REG_ARM64_X23),
	SMPL_REG(x24, PERF_REG_ARM64_X24),
	SMPL_REG(x25, PERF_REG_ARM64_X25),
	SMPL_REG(x26, PERF_REG_ARM64_X26),
	SMPL_REG(x27, PERF_REG_ARM64_X27),
	SMPL_REG(x28, PERF_REG_ARM64_X28),
	SMPL_REG(x29, PERF_REG_ARM64_X29),
	SMPL_REG(lr, PERF_REG_ARM64_LR),
	SMPL_REG(sp, PERF_REG_ARM64_SP),
	SMPL_REG(pc, PERF_REG_ARM64_PC),
	SMPL_REG(vg, PERF_REG_ARM64_VG),
	SMPL_REG_END
};

/* %xNUM */
#define SDT_OP_REGEX1  "^(x[1-2]?[0-9]|3[0-1])$"

@@ -175,8 +139,3 @@ uint64_t arch__user_reg_mask(void)
	}
	return PERF_REGS_MASK;
}

const struct sample_reg *arch__sample_reg_masks(void)
{
	return sample_reg_masks;
}
+0 −9
Original line number Diff line number Diff line
@@ -2,10 +2,6 @@
#include "perf_regs.h"
#include "../../util/perf_regs.h"

static const struct sample_reg sample_reg_masks[] = {
	SMPL_REG_END
};

uint64_t arch__intr_reg_mask(void)
{
	return PERF_REGS_MASK;
@@ -15,8 +11,3 @@ uint64_t arch__user_reg_mask(void)
{
	return PERF_REGS_MASK;
}

const struct sample_reg *arch__sample_reg_masks(void)
{
	return sample_reg_masks;
}
+0 −9
Original line number Diff line number Diff line
@@ -2,10 +2,6 @@
#include "perf_regs.h"
#include "../../../util/perf_regs.h"

static const struct sample_reg sample_reg_masks[] = {
	SMPL_REG_END
};

uint64_t arch__intr_reg_mask(void)
{
	return PERF_REGS_MASK;
@@ -15,8 +11,3 @@ uint64_t arch__user_reg_mask(void)
{
	return PERF_REGS_MASK;
}

const struct sample_reg *arch__sample_reg_masks(void)
{
	return sample_reg_masks;
}
Loading