]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf disasm: Refactor ins__is_call/jump to avoid exposing arch ins_ops
authorIan Rogers <irogers@google.com>
Thu, 22 Jan 2026 21:35:13 +0000 (13:35 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 23 Jan 2026 19:58:38 +0000 (16:58 -0300)
Add booleans indicating whether and ins_ops are call or jump and
return it. This avoids exposing loongarch and s390 ins_ops for the
sake of matching.

Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Aditya Bodkhe <aditya.b1@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Julia Lawall <Julia.Lawall@inria.fr>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Krzysztof Ɓopatowski <krzysztof.m.lopatowski@gmail.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
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: Suchit Karunakaran <suchitkarunakaran@gmail.com>
Cc: Thomas Falcon <thomas.falcon@intel.com>
Cc: Tianyou Li <tianyou.li@intel.com>
Cc: Will Deacon <will@kernel.org>
Cc: Zecheng Li <zecheng@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/annotate-arch/annotate-loongarch.c
tools/perf/util/annotate-arch/annotate-s390.c
tools/perf/util/disasm.c
tools/perf/util/disasm.h

index 32df10f6fed5143269d7bbd7efadfb115b4c6658..79dc116ade2f58525c42502d32b3df8f0705191f 100644 (file)
@@ -57,9 +57,10 @@ static int loongarch_call__parse(const struct arch *arch, struct ins_operands *o
        return 0;
 }
 
-const struct ins_ops loongarch_call_ops = {
+static const struct ins_ops loongarch_call_ops = {
        .parse     = loongarch_call__parse,
        .scnprintf = call__scnprintf,
+       .is_call   = true,
 };
 
 static int loongarch_jump__parse(const struct arch *arch, struct ins_operands *ops,
@@ -106,9 +107,10 @@ static int loongarch_jump__parse(const struct arch *arch, struct ins_operands *o
        return 0;
 }
 
-const struct ins_ops loongarch_jump_ops = {
+static const struct ins_ops loongarch_jump_ops = {
        .parse     = loongarch_jump__parse,
        .scnprintf = jump__scnprintf,
+       .is_jump   = true,
 };
 
 static
index 81db102b3e1590e1f1c890510f09431e56e6eba0..7b2d27b62e6b6f53f908ea7f00bd36bea000ccc5 100644 (file)
@@ -57,9 +57,10 @@ static int s390_call__parse(const struct arch *arch, struct ins_operands *ops,
        return 0;
 }
 
-const struct ins_ops s390_call_ops = {
+static const struct ins_ops s390_call_ops = {
        .parse     = s390_call__parse,
        .scnprintf = call__scnprintf,
+       .is_call   = true,
 };
 
 static int s390_mov__parse(const struct arch *arch __maybe_unused,
index 845c2d0f39b12f5d07848642793e0c1c1d3fc032..8c3e9094600a18559dfc674695fbff62c130201a 100644 (file)
@@ -315,11 +315,12 @@ int call__scnprintf(const struct ins *ins, char *bf, size_t size,
 const struct ins_ops call_ops = {
        .parse     = call__parse,
        .scnprintf = call__scnprintf,
+       .is_call   = true,
 };
 
 bool ins__is_call(const struct ins *ins)
 {
-       return ins->ops == &call_ops || ins->ops == &s390_call_ops || ins->ops == &loongarch_call_ops;
+       return ins->ops && ins->ops->is_call;
 }
 
 /*
@@ -469,11 +470,12 @@ const struct ins_ops jump_ops = {
        .free      = jump__delete,
        .parse     = jump__parse,
        .scnprintf = jump__scnprintf,
+       .is_jump   = true,
 };
 
 bool ins__is_jump(const struct ins *ins)
 {
-       return ins->ops == &jump_ops || ins->ops == &loongarch_jump_ops;
+       return ins->ops && ins->ops->is_jump;
 }
 
 static int comment__symbol(char *raw, char *comment, u64 *addrp, char **namep)
index 83503c5075f9ad7d477b7336c4aa78d7fe882d9c..b6a2a30fdf27f107a022386711a2274c6ed7663e 100644 (file)
@@ -93,6 +93,8 @@ struct ins_ops {
                        struct disasm_line *dl);
        int (*scnprintf)(const struct ins *ins, char *bf, size_t size,
                         struct ins_operands *ops, int max_ins_name);
+       bool is_jump;
+       bool is_call;
 };
 
 struct annotate_args {
@@ -139,9 +141,6 @@ bool ins__is_fused(const struct arch *arch, const char *ins1, const char *ins2);
 bool ins__is_ret(const struct ins *ins);
 bool ins__is_lock(const struct ins *ins);
 
-extern const struct ins_ops s390_call_ops;
-extern const struct ins_ops loongarch_call_ops;
-extern const struct ins_ops loongarch_jump_ops;
 const struct ins_ops *check_ppc_insn(struct disasm_line *dl);
 
 struct disasm_line *disasm_line__new(struct annotate_args *args);